xiaoyong931011
2023-03-01 ba2eebb488f3d3b2820441bc5f01bbeaf2cd4a01
src/main/java/cc/mrbird/febs/mall/controller/AdminSystemController.java
@@ -20,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
@@ -52,12 +53,51 @@
        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();
    }