Hentua
2023-06-15 bfa4d0fc1ce8d297fb2bea1c467ec335def8fa89
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
package cc.mrbird.febs.mall.controller;
 
import cc.mrbird.febs.common.entity.FebsResponse;
import cc.mrbird.febs.common.enumerates.DataDictionaryEnum;
import cc.mrbird.febs.common.enumerates.GreenScoreEnum;
import cc.mrbird.febs.mall.dto.*;
import cc.mrbird.febs.mall.entity.DataDictionaryCustom;
import cc.mrbird.febs.mall.mapper.DataDictionaryCustomMapper;
import cc.mrbird.febs.mall.mapper.MallSystemSettingMapper;
import cc.mrbird.febs.mall.service.ICommonService;
import cc.mrbird.febs.mall.service.IMemberProfitService;
import cc.mrbird.febs.mall.service.ISystemService;
import cc.mrbird.febs.rabbit.producter.AgentProducer;
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.*;
 
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Collections;
import java.util.Map;
 
@Slf4j
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/admin/system")
public class AdminSystemController {
 
    @Autowired
    private ISystemService systemService;
 
    private final ICommonService commonService;
 
    @Autowired
    private IMemberProfitService memberProfitService;
 
    private final AgentProducer agentProducer;
 
    private final DataDictionaryCustomMapper dataDictionaryCustomMapper;
    private final MallSystemSettingMapper mallSystemSettingMapper;
 
    @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 = "/scorePoor")
    public FebsResponse scorePoor(ScorePoorDto scorePoorDto) {
        commonService.addDataDic(DataDictionaryEnum.SCORE_POOR_RADIO.getType(), DataDictionaryEnum.SCORE_POOR_RADIO.getCode(), scorePoorDto, "积分池设置");
        return new FebsResponse().success();
    }
 
    @PostMapping(value = "/hlmScoreSet")
    public FebsResponse hlmScoreSet(HlmScoreSetDto hlmScoreSetDto) {
        commonService.updateDataDic(
                DataDictionaryEnum.SIGN_SCORE.getType(),
                DataDictionaryEnum.SIGN_SCORE.getCode(),
                hlmScoreSetDto.getSignScore());
        commonService.updateDataDic(
                DataDictionaryEnum.SIGN_SCORE_DAYS.getType(),
                DataDictionaryEnum.SIGN_SCORE_DAYS.getCode(),
                hlmScoreSetDto.getSignScoreDays());
        commonService.updateDataDic(
                DataDictionaryEnum.SIGN_SCORE_CNT.getType(),
                DataDictionaryEnum.SIGN_SCORE_CNT.getCode(),
                hlmScoreSetDto.getSignScoreCnt());
        commonService.updateDataDic(
                DataDictionaryEnum.SCORE_PERCENT.getType(),
                DataDictionaryEnum.SCORE_PERCENT.getCode(),
                hlmScoreSetDto.getScorePercent());
        commonService.updateDataDic(
                DataDictionaryEnum.SCORE_CHANGE.getType(),
                DataDictionaryEnum.SCORE_CHANGE.getCode(),
                hlmScoreSetDto.getScoreChange());
        commonService.updateDataDic(
                DataDictionaryEnum.STAR_GET.getType(),
                DataDictionaryEnum.STAR_GET.getCode(),
                hlmScoreSetDto.getStarGet());
        return new FebsResponse().success();
    }
 
    @PostMapping(value = "/hlmBasicPerk")
    public FebsResponse hlmBasicPerk(HlmBasicPerkDto hlmBasicPerkDto) {
        commonService.updateDataDic(
                DataDictionaryEnum.SHARE_PERK.getType(),
                DataDictionaryEnum.SHARE_PERK.getCode(),
                hlmBasicPerkDto.getSharePerk());
        commonService.updateDataDic(
                DataDictionaryEnum.TEAM_PERK.getType(),
                DataDictionaryEnum.TEAM_PERK.getCode(),
                hlmBasicPerkDto.getTeamPerk());
        commonService.updateDataDic(
                DataDictionaryEnum.TEAM_EQUALS_PERK.getType(),
                DataDictionaryEnum.TEAM_EQUALS_PERK.getCode(),
                hlmBasicPerkDto.getTeamEqualsPerk());
        commonService.updateDataDic(
                DataDictionaryEnum.OFFLINE_PERK.getType(),
                DataDictionaryEnum.OFFLINE_PERK.getCode(),
                hlmBasicPerkDto.getOffLinePerk());
        commonService.updateDataDic(
                DataDictionaryEnum.AGENT_PERK.getType(),
                DataDictionaryEnum.AGENT_PERK.getCode(),
                hlmBasicPerkDto.getAgentPerk());
        return new FebsResponse().success();
    }
 
    @PostMapping(value = "/hlmVoucherSet")
    public FebsResponse hlmVoucherSet(HlmVoucherSetDto hlmVoucherSetDto) {
        BigDecimal roleReleasePercent = new BigDecimal(hlmVoucherSetDto.getRoleReleasePercent());
        if(roleReleasePercent.compareTo(BigDecimal.ZERO) <= 0
        || roleReleasePercent.compareTo(new BigDecimal(1000)) >= 0){
            return new FebsResponse().fail().message("请输入合理的比例");
        }
 
        commonService.updateDataDic(
                GreenScoreEnum.ROLE_RELEASE_PERCENT.getType(),
                GreenScoreEnum.ROLE_RELEASE_PERCENT.getCode(),
                hlmVoucherSetDto.getRoleReleasePercent());
 
        commonService.updateDataDic(
                GreenScoreEnum.ACHIEVE_RELEASE_PERCENT.getType(),
                GreenScoreEnum.ACHIEVE_RELEASE_PERCENT.getCode(),
                hlmVoucherSetDto.getAchieveReleasePercent());
 
        commonService.updateDataDic(
                GreenScoreEnum.ACHIEVE_RELEASE.getType(),
                GreenScoreEnum.ACHIEVE_RELEASE.getCode(),
                hlmVoucherSetDto.getAchieveRelease());
 
        commonService.updateDataDic(
                GreenScoreEnum.ACHIEVE_MAX.getType(),
                GreenScoreEnum.ACHIEVE_MAX.getCode(),
                hlmVoucherSetDto.getAchieveMax());
 
        commonService.updateDataDic(
                GreenScoreEnum.ACHIEVE_MIN.getType(),
                GreenScoreEnum.ACHIEVE_MIN.getCode(),
                hlmVoucherSetDto.getAchieveMin());
 
        commonService.updateDataDic(
                GreenScoreEnum.ROLE_ACHIEVE_PERCENT.getType(),
                GreenScoreEnum.ROLE_ACHIEVE_PERCENT.getCode(),
                hlmVoucherSetDto.getRoleAchievePercent());
 
        commonService.updateDataDic(
                GreenScoreEnum.STAR_ACHIEVE_PERCENT.getType(),
                GreenScoreEnum.STAR_ACHIEVE_PERCENT.getCode(),
                hlmVoucherSetDto.getStarAchievePercent());
 
        commonService.updateDataDic(
                GreenScoreEnum.LEVEL_ACHIEVE_PERCENT.getType(),
                GreenScoreEnum.LEVEL_ACHIEVE_PERCENT.getCode(),
                hlmVoucherSetDto.getLevelAchievePercent());
        return new FebsResponse().success();
    }
 
    @PostMapping(value = "/hlmVoucherButton")
    public FebsResponse hlmVoucherButton(HlmVoucherButtonDto hlmVoucherButtonDto) {
        BigDecimal scorePrice = new BigDecimal(hlmVoucherButtonDto.getScorePrice());
        if(scorePrice.compareTo(BigDecimal.ZERO) <= 0){
            return new FebsResponse().fail().message("请输入合理的价格");
        }
        BigDecimal voucherPercent = new BigDecimal(hlmVoucherButtonDto.getVoucherPercent());
        if(voucherPercent.compareTo(BigDecimal.ZERO) <= 0){
            return new FebsResponse().fail().message("请输入合理的价格");
        }
 
        commonService.updateDataDic(
                GreenScoreEnum.SCORE_PRICE.getType(),
                GreenScoreEnum.SCORE_PRICE.getCode(),
                hlmVoucherButtonDto.getScorePrice());
 
        commonService.updateDataDic(
                GreenScoreEnum.VOUCHER_ON_OFF.getType(),
                GreenScoreEnum.VOUCHER_ON_OFF.getCode(),
                hlmVoucherButtonDto.getVoucherOnOff());
 
        commonService.updateDataDic(
                GreenScoreEnum.VOUCHER_PERCENT.getType(),
                GreenScoreEnum.VOUCHER_PERCENT.getCode(),
                hlmVoucherButtonDto.getVoucherPercent());
        return new FebsResponse().success();
    }
 
    @PostMapping(value = "/selaHalfVoucher")
    public FebsResponse selaHalfVoucher() {
        DataDictionaryCustom scorePriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                GreenScoreEnum.SCORE_PRICE.getType(),
                GreenScoreEnum.SCORE_PRICE.getCode()
        );
        agentProducer.sendForceVoucherSaleMsg(scorePriceDic.getValue());
        return new FebsResponse().success();
    }
 
    @GetMapping(value = "/bonusSetting")
    public FebsResponse bonusSetting() {
        return new FebsResponse().success().data(Collections.singletonList(mallSystemSettingMapper.selectById(1L)));
    }
}