xiaoyong931011
2023-03-02 69025a3687c6dc6260e894c6bfb793178ef8fea2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
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;
import cc.mrbird.febs.mall.dto.AdminAgentDetailDto;
import cc.mrbird.febs.mall.dto.CashOutSettingDto;
import cc.mrbird.febs.mall.entity.DataDictionaryCustom;
import cc.mrbird.febs.mall.mapper.DataDictionaryCustomMapper;
import cc.mrbird.febs.mall.service.ICommonService;
import cc.mrbird.febs.mall.service.ISystemService;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import java.math.BigDecimal;
import java.util.Map;
 
@Slf4j
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/admin/system")
public class AdminSystemController {
 
    @Autowired
    private ISystemService systemService;
 
    private final ICommonService commonService;
    private final DataDictionaryCustomMapper dataDictionaryCustomMapper;
 
    @PostMapping(value = "/bonusSystemSetting")
    public FebsResponse bonusSystemSetting(@RequestBody Map<String, Object> map) {
        systemService.bonusSystemSetting(map);
        return new FebsResponse().success().message("设置成功");
    }
 
    @PostMapping(value = "/cashOutSetting")
    public FebsResponse cashOutSetting(CashOutSettingDto cashOutSettingDto) {
        commonService.addDataDic(DataDictionaryEnum.CASHOUT_SETTING.getType(), DataDictionaryEnum.CASHOUT_SETTING.getCode(), cashOutSettingDto, "提现设置");
        return new FebsResponse().success();
    }
 
    @PostMapping(value = "/agentAmountSetSetting")
    public FebsResponse agentAmountSetSetting(AdminAgentAmountDto adminAgentAmountDto) {
        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);
 
        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")
    public FebsResponse agentDetail(AdminAgentDetailDto adminAgentDetailDto) {
        DataDictionaryCustom dic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                DataDictionaryEnum.AGENT_DETAILS.getType(), DataDictionaryEnum.AGENT_DETAILS.getCode()
        );
 
        if(ObjectUtil.isEmpty(dic)){
            return new FebsResponse().fail().message("请刷新页面重试");
        }
        dic.setValue(adminAgentDetailDto.getAgentDetail());
        dataDictionaryCustomMapper.updateById(dic);
        return new FebsResponse().success();
    }
}