From 3e5e90d3ef2b6903af86108a423343cf1fe1847d Mon Sep 17 00:00:00 2001 From: xiaoyong931011 <15274802129@163.com> Date: Wed, 01 Mar 2023 17:15:55 +0800 Subject: [PATCH] 增加活动公告 --- src/main/java/cc/mrbird/febs/mall/controller/AdminSystemController.java | 86 +++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 86 insertions(+), 0 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 39725ab..9ca3b6f 100644 --- a/src/main/java/cc/mrbird/febs/mall/controller/AdminSystemController.java +++ b/src/main/java/cc/mrbird/febs/mall/controller/AdminSystemController.java @@ -1,7 +1,16 @@ package cc.mrbird.febs.mall.controller; 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; @@ -11,6 +20,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.math.BigDecimal; import java.util.Map; @Slf4j @@ -23,9 +33,85 @@ @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("请刷新页面重试"); + } + + String giveState = adminAgentAmountDto.getGiveState(); + if(1 == Integer.parseInt(giveState)){ + if(ObjectUtil.isEmpty(adminAgentAmountDto.getActivityBulletin())){ + return new FebsResponse().fail().message("活动公告不能为空"); + } + if(ObjectUtil.isEmpty(adminAgentAmountDto.getActivityBulletin()) + || BigDecimal.ZERO.compareTo(new BigDecimal(adminAgentAmountDto.getActivityBulletin())) > 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); + + return new FebsResponse().success(); + } + + @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(); + } } -- Gitblit v1.9.1