From 5416c6ab09efbd9fc0b0c2846b05e580f7869d48 Mon Sep 17 00:00:00 2001
From: KKSU <15274802129@163.com>
Date: Mon, 26 Feb 2024 10:26:27 +0800
Subject: [PATCH] 抽奖

---
 src/main/java/cc/mrbird/febs/mall/controller/AdminSystemController.java |   89 +++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 87 insertions(+), 2 deletions(-)

diff --git a/src/main/java/cc/mrbird/febs/mall/controller/AdminSystemController.java b/src/main/java/cc/mrbird/febs/mall/controller/AdminSystemController.java
index 6b0cc57..ba2bc2b 100644
--- a/src/main/java/cc/mrbird/febs/mall/controller/AdminSystemController.java
+++ b/src/main/java/cc/mrbird/febs/mall/controller/AdminSystemController.java
@@ -1,5 +1,6 @@
 package cc.mrbird.febs.mall.controller;
 
+import cc.mrbird.febs.common.annotation.ControllerEndpoint;
 import cc.mrbird.febs.common.entity.FebsResponse;
 import cc.mrbird.febs.common.enumerates.DataDictionaryEnum;
 import cc.mrbird.febs.mall.dto.AdminAgentAmountDto;
@@ -20,6 +21,9 @@
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.math.BigDecimal;
+import java.util.Arrays;
+import java.util.List;
 import java.util.Map;
 
 @Slf4j
@@ -52,13 +56,69 @@
         DataDictionaryCustom dic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                 DataDictionaryEnum.PRICE_AMOUNT.getType(), DataDictionaryEnum.PRICE_AMOUNT.getCode()
         );
-
         if(ObjectUtil.isEmpty(dic)){
             return new FebsResponse().fail().message("请刷新页面重试");
         }
+
+        DataDictionaryCustom giveStateDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.GIVE_STATE.getType(),
+                DataDictionaryEnum.GIVE_STATE.getCode());
+        if(ObjectUtil.isEmpty(giveStateDic)){
+            return new FebsResponse().fail().message("请刷新页面重试");
+        }
+
+        DataDictionaryCustom activityBulletinDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.ACTIVITY_BULLETIN.getType(),
+                DataDictionaryEnum.ACTIVITY_BULLETIN.getCode());
+        if(ObjectUtil.isEmpty(activityBulletinDic)){
+            return new FebsResponse().fail().message("请刷新页面重试");
+        }
+
+        DataDictionaryCustom giveAmountDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.GIVE_AMOUNT.getType(),
+                DataDictionaryEnum.GIVE_AMOUNT.getCode());
+        if(ObjectUtil.isEmpty(giveAmountDic)){
+            return new FebsResponse().fail().message("请刷新页面重试");
+        }
+
+        DataDictionaryCustom chargeAmountDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.CHARGE_AMOUNT.getType(),
+                DataDictionaryEnum.CHARGE_AMOUNT.getCode());
+        if(ObjectUtil.isEmpty(chargeAmountDic)){
+            return new FebsResponse().fail().message("请刷新页面重试");
+        }
+
+        String giveState = adminAgentAmountDto.getGiveState();
+        if(1 == Integer.parseInt(giveState)){
+            if(ObjectUtil.isEmpty(adminAgentAmountDto.getActivityBulletin())){
+                return new FebsResponse().fail().message("活动公告不能为空");
+            }
+            if(ObjectUtil.isEmpty(adminAgentAmountDto.getGiveAmount())){
+                return new FebsResponse().fail().message("请输入正确的赠送金额");
+            }
+            if(BigDecimal.ZERO.compareTo(new BigDecimal(adminAgentAmountDto.getGiveAmount())) > 0){
+                return new FebsResponse().fail().message("请输入正确的赠送金额");
+            }
+            if(ObjectUtil.isEmpty(adminAgentAmountDto.getChargeAmount())){
+                return new FebsResponse().fail().message("请输入正确的充值金额");
+            }
+            if(BigDecimal.ZERO.compareTo(new BigDecimal(adminAgentAmountDto.getChargeAmount())) > 0){
+                return new FebsResponse().fail().message("请输入正确的充值金额");
+            }
+        }
+
         dic.setValue(adminAgentAmountDto.getAgentAmountValue());
         dataDictionaryCustomMapper.updateById(dic);
-        return new FebsResponse().success();
+
+        giveStateDic.setValue(adminAgentAmountDto.getGiveState());
+        dataDictionaryCustomMapper.updateById(giveStateDic);
+
+        activityBulletinDic.setValue(adminAgentAmountDto.getActivityBulletin());
+        dataDictionaryCustomMapper.updateById(activityBulletinDic);
+
+        giveAmountDic.setValue(adminAgentAmountDto.getGiveAmount());
+        dataDictionaryCustomMapper.updateById(giveAmountDic);
+
+        chargeAmountDic.setValue(adminAgentAmountDto.getChargeAmount());
+        dataDictionaryCustomMapper.updateById(chargeAmountDic);
+
+        return new FebsResponse().success().message("操作成功");
     }
 
     @PostMapping(value = "/agentDetail")
@@ -74,4 +134,29 @@
         dataDictionaryCustomMapper.updateById(dic);
         return new FebsResponse().success();
     }
+
+//    public static void main(String[] args) {
+//        List<Integer> lines = Arrays.asList(new Integer[]{1, 1, 0,  1, 1, 0, 0, 1, 0,  1, 1, 0, 1, 0, 1, 0});
+//        //数字连续出现的计数
+//        Integer symbol = 0;
+//        //数字连续出现的次数限制
+//        Integer times = 3;
+//        //出现的数字
+//        Integer symbolNum = 1;
+//        //满足规则的次数
+//        Integer timesOneSign = 0;
+//        for(int i=0;i<lines.size();i++){
+//            if(symbolNum == lines.get(i)){
+//                symbol = symbol + 1;
+//                if(symbol >= times){
+//                    timesOneSign = timesOneSign + 1;
+//                    symbol = 0;
+//                }
+//            }else{
+//                symbol = 0;
+//            }
+//        }
+//
+//        System.out.println(timesOneSign);
+//    }
 }

--
Gitblit v1.9.1