| | |
| | | |
| | | import cc.mrbird.febs.common.entity.FebsResponse; |
| | | import cc.mrbird.febs.common.entity.QueryRequest; |
| | | import cc.mrbird.febs.mall.dto.AddMallActAwardDto; |
| | | import cc.mrbird.febs.mall.dto.AddMallActDto; |
| | | import cc.mrbird.febs.mall.dto.MallActAwardUpdateDto; |
| | | import cc.mrbird.febs.mall.dto.MallActUpdateDto; |
| | | import cc.mrbird.febs.common.enumerates.DataDictionaryEnum; |
| | | import cc.mrbird.febs.mall.dto.*; |
| | | import cc.mrbird.febs.mall.entity.*; |
| | | import cc.mrbird.febs.mall.mapper.MallActAwardSetMapper; |
| | | import cc.mrbird.febs.mall.mapper.MallActLuckdrawRecordMapper; |
| | | import cc.mrbird.febs.mall.mapper.MallActSetMapper; |
| | | import cc.mrbird.febs.mall.mapper.MallActWinRecordMapper; |
| | | import cc.mrbird.febs.mall.mapper.*; |
| | | import cc.mrbird.febs.mall.service.IAdminMallActService; |
| | | import cc.mrbird.febs.mall.vo.AdminMallActLuckdrawRecordVo; |
| | | import cc.mrbird.febs.mall.vo.AdminMallActSetVo; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.core.util.NumberUtil; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | |
| | | private final MallActAwardSetMapper mallActAwardSetMapper; |
| | | private final MallActLuckdrawRecordMapper mallActLuckdrawRecordMapper; |
| | | private final MallActWinRecordMapper mallActWinRecordMapper; |
| | | private final DataDictionaryCustomMapper dataDictionaryCustomMapper; |
| | | |
| | | @Override |
| | | public IPage<AdminMallActSetVo> getActListInPage(MallActSet mallActSet, QueryRequest request) { |
| | |
| | | String actCode = addMallActDto.getActCode(); |
| | | if (StrUtil.isEmpty(actCode)) { |
| | | return new FebsResponse().fail().message("活动编码不能为空"); |
| | | } |
| | | String actImage = addMallActDto.getActImage(); |
| | | if (StrUtil.isEmpty(actImage)) { |
| | | return new FebsResponse().fail().message("活动图片不能为空"); |
| | | } |
| | | Date actStartTime = addMallActDto.getActStartTime(); |
| | | if(ObjectUtil.isEmpty(actStartTime)){ |
| | |
| | | MallActSet mallActSet = new MallActSet(); |
| | | mallActSet.setActCode(actCode); |
| | | mallActSet.setActName(actName); |
| | | mallActSet.setActImage(actImage); |
| | | mallActSet.setActStartTime(actStartTime); |
| | | mallActSet.setActEndTime(actEndTime); |
| | | mallActSet.setActScoreCnt(actScoreCnt); |
| | |
| | | MallActSet mallActSet = this.baseMapper.selectById(id); |
| | | if (ObjectUtil.isEmpty(mallActSet)) { |
| | | return new FebsResponse().fail().message("活动不存在,请刷新当前页面"); |
| | | } |
| | | Date date = new Date(); |
| | | int compareStart = DateUtil.compare(date, mallActSet.getActStartTime()); |
| | | if(compareStart < 0){ |
| | | return new FebsResponse().fail().message("活动还未开始"); |
| | | } |
| | | int compareEnd = DateUtil.compare(date, mallActSet.getActEndTime()); |
| | | if(compareEnd > 0){ |
| | | return new FebsResponse().fail().message("活动已结束"); |
| | | } |
| | | mallActSet.setActStatus(MallActSet.ACT_STATUS_ENABLE); |
| | | this.baseMapper.updateById(mallActSet); |
| | |
| | | if (StrUtil.isEmpty(actCode)) { |
| | | return new FebsResponse().fail().message("活动编码不能为空"); |
| | | } |
| | | String actImage = mallActUpdateDto.getActImage(); |
| | | if (StrUtil.isEmpty(actImage)) { |
| | | return new FebsResponse().fail().message("活动图片不能为空"); |
| | | } |
| | | Date actStartTime = mallActUpdateDto.getActStartTime(); |
| | | if(ObjectUtil.isEmpty(actStartTime)){ |
| | | return new FebsResponse().fail().message("开始日期不能为空"); |
| | |
| | | } |
| | | mallActSet.setActCode(actCode); |
| | | mallActSet.setActName(actName); |
| | | mallActSet.setActImage(actImage); |
| | | mallActSet.setActStartTime(actStartTime); |
| | | mallActSet.setActEndTime(actEndTime); |
| | | mallActSet.setActScoreCnt(actScoreCnt); |
| | |
| | | MallActWinRecord mallActWinRecord = mallActWinRecordMapper.selectByLuckDrawId(id); |
| | | return mallActWinRecord; |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse addSetting(LuckDrawSettingDto luckDrawSettingDto) { |
| | | |
| | | if(Double.parseDouble(luckDrawSettingDto.getScoreSet())>1 || Double.parseDouble(luckDrawSettingDto.getScoreSet()) <0){ |
| | | return new FebsResponse().fail().message("中奖概率必须是一个在零和一之间的小数"); |
| | | } |
| | | |
| | | if(Double.parseDouble(luckDrawSettingDto.getCashSet())>1 || Double.parseDouble(luckDrawSettingDto.getCashSet()) <0){ |
| | | return new FebsResponse().fail().message("中奖概率必须是一个在零和一之间的小数"); |
| | | } |
| | | |
| | | DataDictionaryCustom scoreDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.WIN_SCORE.getType(), |
| | | DataDictionaryEnum.WIN_SCORE.getCode()); |
| | | DataDictionaryCustom cashDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.WIN_CASH.getType(), |
| | | DataDictionaryEnum.WIN_CASH.getCode()); |
| | | |
| | | if (ObjectUtil.isNotEmpty(scoreDic)) { |
| | | scoreDic.setValue(luckDrawSettingDto.getScoreSet().toString()); |
| | | dataDictionaryCustomMapper.updateById(scoreDic); |
| | | }else{ |
| | | DataDictionaryCustom dataDictionaryCustom = new DataDictionaryCustom(); |
| | | dataDictionaryCustom.setCode(DataDictionaryEnum.WIN_SCORE.getCode()); |
| | | dataDictionaryCustom.setType(DataDictionaryEnum.WIN_SCORE.getType()); |
| | | dataDictionaryCustom.setValue(luckDrawSettingDto.getScoreSet().toString()); |
| | | dataDictionaryCustom.setDescription("积分中奖概率"); |
| | | dataDictionaryCustomMapper.insert(dataDictionaryCustom); |
| | | } |
| | | if (ObjectUtil.isNotEmpty(cashDic)) { |
| | | cashDic.setValue(luckDrawSettingDto.getCashSet().toString()); |
| | | dataDictionaryCustomMapper.updateById(cashDic); |
| | | }else{ |
| | | DataDictionaryCustom dataDictionaryCustom = new DataDictionaryCustom(); |
| | | dataDictionaryCustom.setCode(DataDictionaryEnum.WIN_CASH.getCode()); |
| | | dataDictionaryCustom.setType(DataDictionaryEnum.WIN_CASH.getType()); |
| | | dataDictionaryCustom.setValue(luckDrawSettingDto.getScoreSet().toString()); |
| | | dataDictionaryCustom.setDescription("佣金中奖概率"); |
| | | dataDictionaryCustomMapper.insert(dataDictionaryCustom); |
| | | } |
| | | |
| | | return new FebsResponse().success().message("操作成功"); |
| | | } |
| | | |
| | | } |