package cc.mrbird.febs; import cc.mrbird.febs.common.entity.FebsResponse; import cc.mrbird.febs.common.enumerates.AgentLevelEnum; import cc.mrbird.febs.common.enumerates.DataDictionaryEnum; import cc.mrbird.febs.common.exception.FebsException; import cc.mrbird.febs.common.utils.LoginUserUtil; import cc.mrbird.febs.mall.conversion.MallGoodsConversion; import cc.mrbird.febs.mall.dto.AddOrderItemDto; import cc.mrbird.febs.mall.dto.AgentLevelUpdateDto; import cc.mrbird.febs.mall.dto.ApiCreateOrderVerifyDto; import cc.mrbird.febs.mall.dto.ApiMallActWinDetailsDto; import cc.mrbird.febs.mall.entity.*; import cc.mrbird.febs.mall.mapper.*; import cc.mrbird.febs.mall.quartz.ProfitJob; import cc.mrbird.febs.mall.service.IAgentService; import cc.mrbird.febs.mall.vo.*; import cc.mrbird.febs.rabbit.consumer.AgentConsumer; import cc.mrbird.febs.rabbit.producter.AgentProducer; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.RandomUtil; import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import lombok.extern.slf4j.Slf4j; import org.aspectj.weaver.loadtime.Agent; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import java.math.BigDecimal; import java.math.RoundingMode; import java.util.ArrayList; import java.util.List; import java.util.Map; /** * @author wzy * @date 2021-09-25 **/ @Slf4j @SpringBootTest public class AgentTest { @Autowired private AgentProducer agentProducer; @Autowired private DataDictionaryCustomMapper dataDictionaryCustomMapper; @Autowired private IAgentService agentService; @Autowired private MallGoodsStyleMapper mallGoodsStyleMapper; @Autowired private MallActAwardSetMapper mallActAwardSetMapper; @Autowired private MallMemberMapper mallMemberMapper; @Autowired private MallActWinRecordMapper mallActWinRecordMapper; @Autowired private MallActLuckdrawRecordMapper mallActLuckdrawRecordMapper; @Autowired private MallMemberWalletMapper mallMemberWalletMapper; @Autowired private MallActSetMapper mallActSetMapper; @Autowired private MallGoodsSkuMapper mallGoodsSkuMapper; @Autowired private MallOrderItemMapper mallOrderItemMapper; @Autowired private MallGoodsMapper mallGoodsMapper; @Autowired private MallGoodsImagesMapper goodsImagesMapper; @Test public void goodsDetails(){ Long id = 68L; MallGoods mallGoods = mallGoodsMapper.selectGoodsDetailById(id); if (mallGoods == null) { throw new FebsException("商品不存在"); } List images = goodsImagesMapper.selectGoodsImagesByGoodsId(mallGoods.getId()); MallGoodsDetailsVo mallGoodsDetailsVo = MallGoodsConversion.INSTANCE.entityToDetailsVo(mallGoods); List styles = mallGoodsDetailsVo.getStyles(); if(ObjectUtil.isNotEmpty(styles)){ for(GoodsDetailsStyleVo goodsDetailsStyleVo : styles){ List skus = goodsDetailsStyleVo.getSkus(); if(CollUtil.isNotEmpty(skus) ){ for(GoodsDetailsSkuVo goodsDetailsSkuVo : skus){ if(StrUtil.isNotEmpty(goodsDetailsSkuVo.getSample())){ goodsDetailsSkuVo.setSampleFlag(true); }else{ goodsDetailsSkuVo.setSampleFlag(false); } } } } } if (CollUtil.isNotEmpty(mallGoods.getStyles())) { Map stockAndVolume = mallGoodsMapper.selectGoodsStockAndVolume(id); mallGoodsDetailsVo.setStock(stockAndVolume.get("stock").intValue()); mallGoodsDetailsVo.setVolume(stockAndVolume.get("volume").intValue()); } mallGoodsDetailsVo.setImages(images); } @Test public void levelTest(){ ApiCreateOrderVerifyDto apiCreateOrderVerifyDto = new ApiCreateOrderVerifyDto(); List addOrderItemDtos = new ArrayList<>(); AddOrderItemDto addOrderItemDto = new AddOrderItemDto(); addOrderItemDto.setCnt(1); addOrderItemDto.setSkuId(243L); addOrderItemDtos.add(addOrderItemDto); apiCreateOrderVerifyDto.setItems(addOrderItemDtos); MallMember member = mallMemberMapper.selectById(401L); List items = apiCreateOrderVerifyDto.getItems(); if(CollUtil.isEmpty(items)){ System.out.println("请先挑选商品"); } for (AddOrderItemDto item : apiCreateOrderVerifyDto.getItems()) { MallGoodsSku sku = mallGoodsSkuMapper.selectSkuInfoById(item.getSkuId()); if (sku == null) { System.out.println("购买商品或sku不存在"); } if("样品".equals(sku.getSample())){ List mallOrderItems = mallOrderItemMapper.selectItemBySkuIdUnCancel(sku.getId(), member.getId()); if (CollUtil.isNotEmpty(mallOrderItems)) { System.out.println("样品只能购买一次"); } Integer cnt = item.getCnt(); if(1 < cnt){ System.out.println("样品只能购买一件"); } }else{ //验证用户的等级 if(AgentLevelEnum.ZERO_LEVEL.name().equals(member.getLevel())){ System.out.println(sku.getSkuName() + "请先申请成为代理人"); } } if (sku.getStock() < item.getCnt()) { System.out.println(sku.getSkuName() + "库存不足"); } MallGoods mallGoods = mallGoodsMapper.selectById(sku.getGoodsId()); if (MallGoods.ISSALE_STATUS_DISABLED.equals(mallGoods.getIsSale())) { System.out.println(mallGoods.getGoodsName() + "已下架"); } } } // @Test // public void skusTest() { // ApiMallAwardDetailsVo apiMallAwardDetailsVo = new ApiMallAwardDetailsVo(); // Long memberId = 4L; // Long actId = 1L; // MallMember mallMember = mallMemberMapper.selectById(memberId); // if(ObjectUtil.isEmpty(mallMember)){ // throw new FebsException("用户不存在"); // } // // MallActSet mallActSet = mallActSetMapper.selectById(actId); // if(ObjectUtil.isEmpty(mallActSet)){ // throw new FebsException("活动不存在"); // } // Integer actStatus = mallActSet.getActStatus(); // if(MallActSet.ACT_STATUS_DISABLED == actStatus){ // throw new FebsException("活动还没开始"); // } // /** // * 获取用户积分数,判断能不能抽奖 // * 减少对应的积分数量 // * 较少奖品的已抽奖 // * 生成一条抽奖记录 // */ // // MallMemberWallet wallet = mallMemberWalletMapper.selectWalletByMemberId(memberId); // if(ObjectUtil.isEmpty(wallet)){ // throw new FebsException("账户不存在"); // } // BigDecimal commission = wallet.getCommission(); // BigDecimal prizeScore = wallet.getPrizeScore(); // Integer actScoreCnt = mallActSet.getActScoreCnt(); // if(prizeScore.compareTo(new BigDecimal(actScoreCnt))<0){ // throw new FebsException("竞猜积分不足"); // } // /** // * 中奖概率 20% // * 每次抽奖产生一个随机数要大于8,则中奖 // * 历史10条抽奖记录有中奖过,中奖记录少于两条,则中奖 // */ // //获取中奖概率 // DataDictionaryCustom scoreDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( // DataDictionaryEnum.WIN_SCORE.getType(), // DataDictionaryEnum.WIN_SCORE.getCode()); // DataDictionaryCustom cashDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( // DataDictionaryEnum.WIN_CASH.getType(), // DataDictionaryEnum.WIN_CASH.getCode()); // String scoreDicValue = scoreDic.getValue(); // String cashDicValue = cashDic.getValue(); // BigDecimal totalProbability = new BigDecimal(scoreDicValue).add(new BigDecimal(cashDicValue)); // //获取那个更大一点的几率 // BigDecimal maxProbability = BigDecimal.ZERO; // BigDecimal minProbability = BigDecimal.ZERO; // Integer maxAwardType = 0; // Integer minAwardType = 0; // if(new BigDecimal(scoreDicValue).compareTo(new BigDecimal(cashDicValue)) < 0){ // maxProbability = new BigDecimal(cashDicValue); // minProbability = new BigDecimal(scoreDicValue); // maxAwardType = MallActAwardSet.AWARD_TYPE_YJ; // minAwardType = MallActAwardSet.AWARD_TYPE_JF; // }else{ // maxProbability = new BigDecimal(scoreDicValue); // minProbability = new BigDecimal(cashDicValue); // maxAwardType = MallActAwardSet.AWARD_TYPE_JF; // minAwardType = MallActAwardSet.AWARD_TYPE_YJ; // } // // BigDecimal multiply = totalProbability.multiply(new BigDecimal(100)); // BigDecimal failureScope = new BigDecimal(100).subtract(multiply); // int randomInt = 90; // //小于failureScope这个数字,则没中奖 // if(new BigDecimal(randomInt).compareTo(failureScope) <= 0){ // //抽奖记录 // MallActLuckdrawRecord mallActLuckdrawRecord = new MallActLuckdrawRecord(); // mallActLuckdrawRecord.setActId(actId); // mallActLuckdrawRecord.setActName(mallActSet.getActName()); // mallActLuckdrawRecord.setMemberId(memberId); // mallActLuckdrawRecord.setActScoreCnt(actScoreCnt); // mallActLuckdrawRecord.setStatus(MallActLuckdrawRecord.STATUS_DISABLED); // mallActLuckdrawRecordMapper.insert(mallActLuckdrawRecord); // // List mallActAwardSetXXCY = mallActAwardSetMapper.selectMallActAwardByActIdAndAwardType(actId, MallActAwardSet.AWARD_TYPE_XXCY); // if(CollUtil.isNotEmpty(mallActAwardSetXXCY)){ // apiMallAwardDetailsVo.setAwardImage(mallActAwardSetXXCY.get(0).getAwardImage()); // apiMallAwardDetailsVo.setAwardName(mallActAwardSetXXCY.get(0).getAwardName()); // }else{ // apiMallAwardDetailsVo.setAwardName("未中奖"); // } // }else if(new BigDecimal(randomInt).compareTo(failureScope) > 0 // && new BigDecimal(randomInt).compareTo(failureScope.add(maxProbability.multiply(new BigDecimal(100)))) <= 0){ // //大于failureScope.add(maxProbability.multiply(new BigDecimal(100)))这个数字,则中奖 // //获取最新的十条抽奖记录 // List records = mallActLuckdrawRecordMapper.selectRecordByMemberIdAndActId(memberId,actId); // if(CollUtil.isNotEmpty(records)){ // //中奖次数 // Integer count = 0; // for(MallActLuckdrawRecord mallActLuckdrawRecord : records){ // Integer status = mallActLuckdrawRecord.getStatus(); // if(MallActLuckdrawRecord.STATUS_ENABLE == status){ // count = count + 1; // } // } // if(new BigDecimal(count).compareTo(maxProbability.multiply(new BigDecimal(10))) < 0){ // //获取活动下该类别的奖品 // List mallActAwardSets = mallActAwardSetMapper.selectMallActAwardByActIdAndAwardType(actId,maxAwardType); // if(CollUtil.isEmpty(mallActAwardSets)){ // //抽奖记录 // MallActLuckdrawRecord mallActLuckdrawRecord = new MallActLuckdrawRecord(); // mallActLuckdrawRecord.setActId(actId); // mallActLuckdrawRecord.setActName(mallActSet.getActName()); // mallActLuckdrawRecord.setMemberId(memberId); // mallActLuckdrawRecord.setActScoreCnt(actScoreCnt); // mallActLuckdrawRecord.setStatus(MallActLuckdrawRecord.STATUS_DISABLED); // mallActLuckdrawRecordMapper.insert(mallActLuckdrawRecord); // // List mallActAwardSetXXCY = mallActAwardSetMapper.selectMallActAwardByActIdAndAwardType(actId, MallActAwardSet.AWARD_TYPE_XXCY); // if(CollUtil.isNotEmpty(mallActAwardSetXXCY)){ // apiMallAwardDetailsVo.setAwardImage(mallActAwardSetXXCY.get(0).getAwardImage()); // apiMallAwardDetailsVo.setAwardName(mallActAwardSetXXCY.get(0).getAwardName()); // }else{ // apiMallAwardDetailsVo.setAwardName("未中奖"); // } // }else{ // List idList = new ArrayList(); // for(MallActAwardSet mallActAwardSet : mallActAwardSets){ // Integer awardTotal = mallActAwardSet.getAwardTotal(); // Integer awardCnt = mallActAwardSet.getAwardCnt(); // if(awardCnt < awardTotal){ // idList.add(mallActAwardSet); // } // } // MallActAwardSet mallActAwardSet = new MallActAwardSet(); // if(idList.size() <= 1){ // mallActAwardSet = idList.get(0); // }else{ // int randomIdIndex = RandomUtil.randomInt(0, idList.size()-1); // mallActAwardSet = idList.get(randomIdIndex); // } // mallActAwardSet.setAwardCnt(mallActAwardSet.getAwardCnt() + 1); // mallActAwardSetMapper.updateById(mallActAwardSet); // // MallActLuckdrawRecord mallActLuckdrawRecord = new MallActLuckdrawRecord(); // mallActLuckdrawRecord.setActId(actId); // mallActLuckdrawRecord.setActName(mallActSet.getActName()); // mallActLuckdrawRecord.setMemberId(memberId); // mallActLuckdrawRecord.setActScoreCnt(actScoreCnt); // mallActLuckdrawRecord.setStatus(MallActLuckdrawRecord.STATUS_ENABLE); // mallActLuckdrawRecordMapper.insert(mallActLuckdrawRecord); // // MallActWinRecord mallActWinRecord = new MallActWinRecord(); // mallActWinRecord.setMemberId(memberId); // mallActWinRecord.setActId(actId); // mallActWinRecord.setActName(mallActSet.getActName()); // mallActWinRecord.setAwardId(mallActAwardSet.getId()); // mallActWinRecord.setAwardName(mallActAwardSet.getAwardName()); // mallActWinRecord.setAwardType(mallActAwardSet.getAwardType()); // mallActWinRecord.setAwardValue(mallActAwardSet.getAwardValue()); // mallActWinRecord.setRecordId(mallActLuckdrawRecord.getId()); // mallActWinRecordMapper.insert(mallActWinRecord); // // apiMallAwardDetailsVo.setAwardName(mallActAwardSet.getAwardName()); // apiMallAwardDetailsVo.setAwardType(mallActAwardSet.getAwardType()); // apiMallAwardDetailsVo.setAwardValue(mallActAwardSet.getAwardValue()); // apiMallAwardDetailsVo.setAwardImage(mallActAwardSet.getAwardImage()); // // if(MallActAwardSet.AWARD_TYPE_JF == mallActAwardSet.getAwardType()){ // prizeScore = prizeScore.add(new BigDecimal(mallActAwardSet.getAwardValue())); // }else if(MallActAwardSet.AWARD_TYPE_YJ == mallActAwardSet.getAwardType()){ // commission = commission.add(new BigDecimal(mallActAwardSet.getAwardValue())); // } // } // }else{ // //抽奖记录 // MallActLuckdrawRecord mallActLuckdrawRecord = new MallActLuckdrawRecord(); // mallActLuckdrawRecord.setActId(actId); // mallActLuckdrawRecord.setActName(mallActSet.getActName()); // mallActLuckdrawRecord.setMemberId(memberId); // mallActLuckdrawRecord.setActScoreCnt(actScoreCnt); // mallActLuckdrawRecord.setStatus(MallActLuckdrawRecord.STATUS_DISABLED); // mallActLuckdrawRecordMapper.insert(mallActLuckdrawRecord); // // List mallActAwardSetXXCY = mallActAwardSetMapper.selectMallActAwardByActIdAndAwardType(actId, MallActAwardSet.AWARD_TYPE_XXCY); // if(CollUtil.isNotEmpty(mallActAwardSetXXCY)){ // apiMallAwardDetailsVo.setAwardImage(mallActAwardSetXXCY.get(0).getAwardImage()); // apiMallAwardDetailsVo.setAwardName(mallActAwardSetXXCY.get(0).getAwardName()); // }else{ // apiMallAwardDetailsVo.setAwardName("未中奖"); // } // } // }else{ // //获取活动下该类别的奖品 // List mallActAwardSets = mallActAwardSetMapper.selectMallActAwardByActIdAndAwardType(actId,maxAwardType); // if(CollUtil.isEmpty(mallActAwardSets)){ // //抽奖记录 // MallActLuckdrawRecord mallActLuckdrawRecord = new MallActLuckdrawRecord(); // mallActLuckdrawRecord.setActId(actId); // mallActLuckdrawRecord.setActName(mallActSet.getActName()); // mallActLuckdrawRecord.setMemberId(memberId); // mallActLuckdrawRecord.setActScoreCnt(actScoreCnt); // mallActLuckdrawRecord.setStatus(MallActLuckdrawRecord.STATUS_DISABLED); // mallActLuckdrawRecordMapper.insert(mallActLuckdrawRecord); // // List mallActAwardSetXXCY = mallActAwardSetMapper.selectMallActAwardByActIdAndAwardType(actId, MallActAwardSet.AWARD_TYPE_XXCY); // if(CollUtil.isNotEmpty(mallActAwardSetXXCY)){ // apiMallAwardDetailsVo.setAwardImage(mallActAwardSetXXCY.get(0).getAwardImage()); // apiMallAwardDetailsVo.setAwardName(mallActAwardSetXXCY.get(0).getAwardName()); // }else{ // apiMallAwardDetailsVo.setAwardName("未中奖"); // } // }else{ // List idList = new ArrayList(); // for(MallActAwardSet mallActAwardSet : mallActAwardSets){ // Integer awardTotal = mallActAwardSet.getAwardTotal(); // Integer awardCnt = mallActAwardSet.getAwardCnt(); // if(awardCnt < awardTotal){ // idList.add(mallActAwardSet); // } // } // MallActAwardSet mallActAwardSet = new MallActAwardSet(); // if(idList.size() <= 1){ // mallActAwardSet = idList.get(0); // }else{ // int randomIdIndex = RandomUtil.randomInt(0, idList.size()-1); // mallActAwardSet = idList.get(randomIdIndex); // } // mallActAwardSet.setAwardCnt(mallActAwardSet.getAwardCnt() + 1); // mallActAwardSetMapper.updateById(mallActAwardSet); // // MallActLuckdrawRecord mallActLuckdrawRecord = new MallActLuckdrawRecord(); // mallActLuckdrawRecord.setActId(actId); // mallActLuckdrawRecord.setActName(mallActSet.getActName()); // mallActLuckdrawRecord.setMemberId(memberId); // mallActLuckdrawRecord.setActScoreCnt(actScoreCnt); // mallActLuckdrawRecord.setStatus(MallActLuckdrawRecord.STATUS_ENABLE); // mallActLuckdrawRecordMapper.insert(mallActLuckdrawRecord); // // MallActWinRecord mallActWinRecord = new MallActWinRecord(); // mallActWinRecord.setMemberId(memberId); // mallActWinRecord.setActId(actId); // mallActWinRecord.setActName(mallActSet.getActName()); // mallActWinRecord.setAwardId(mallActAwardSet.getId()); // mallActWinRecord.setAwardName(mallActAwardSet.getAwardName()); // mallActWinRecord.setAwardType(mallActAwardSet.getAwardType()); // mallActWinRecord.setAwardValue(mallActAwardSet.getAwardValue()); // mallActWinRecord.setRecordId(mallActLuckdrawRecord.getId()); // mallActWinRecordMapper.insert(mallActWinRecord); // // apiMallAwardDetailsVo.setAwardName(mallActAwardSet.getAwardName()); // apiMallAwardDetailsVo.setAwardType(mallActAwardSet.getAwardType()); // apiMallAwardDetailsVo.setAwardValue(mallActAwardSet.getAwardValue()); // apiMallAwardDetailsVo.setAwardImage(mallActAwardSet.getAwardImage()); // // if(MallActAwardSet.AWARD_TYPE_JF == mallActAwardSet.getAwardType()){ // prizeScore = prizeScore.add(new BigDecimal(mallActAwardSet.getAwardValue())); // }else if(MallActAwardSet.AWARD_TYPE_YJ == mallActAwardSet.getAwardType()){ // commission = commission.add(new BigDecimal(mallActAwardSet.getAwardValue())); // } // } // } // }else{ // //中奖 // //获取最新的十条抽奖记录 // List records = mallActLuckdrawRecordMapper.selectRecordByMemberIdAndActId(memberId,actId); // if(CollUtil.isNotEmpty(records)){ // //中奖次数 // Integer count = 0; // for(MallActLuckdrawRecord mallActLuckdrawRecord : records){ // Integer status = mallActLuckdrawRecord.getStatus(); // if(MallActLuckdrawRecord.STATUS_ENABLE == status){ // count = count + 1; // } // } // if(new BigDecimal(count).compareTo(minProbability.multiply(new BigDecimal(10))) < 0){ // //获取活动下该类别的奖品 // List mallActAwardSets = mallActAwardSetMapper.selectMallActAwardByActIdAndAwardType(actId,minAwardType); // if(CollUtil.isEmpty(mallActAwardSets)){ // //抽奖记录 // MallActLuckdrawRecord mallActLuckdrawRecord = new MallActLuckdrawRecord(); // mallActLuckdrawRecord.setActId(actId); // mallActLuckdrawRecord.setActName(mallActSet.getActName()); // mallActLuckdrawRecord.setMemberId(memberId); // mallActLuckdrawRecord.setActScoreCnt(actScoreCnt); // mallActLuckdrawRecord.setStatus(MallActLuckdrawRecord.STATUS_DISABLED); // mallActLuckdrawRecordMapper.insert(mallActLuckdrawRecord); // // List mallActAwardSetXXCY = mallActAwardSetMapper.selectMallActAwardByActIdAndAwardType(actId, MallActAwardSet.AWARD_TYPE_XXCY); // if(CollUtil.isNotEmpty(mallActAwardSetXXCY)){ // apiMallAwardDetailsVo.setAwardImage(mallActAwardSetXXCY.get(0).getAwardImage()); // apiMallAwardDetailsVo.setAwardName(mallActAwardSetXXCY.get(0).getAwardName()); // }else{ // apiMallAwardDetailsVo.setAwardName("未中奖"); // } // }else{ // List idList = new ArrayList(); // for(MallActAwardSet mallActAwardSet : mallActAwardSets){ // Integer awardTotal = mallActAwardSet.getAwardTotal(); // Integer awardCnt = mallActAwardSet.getAwardCnt(); // if(awardCnt < awardTotal){ // idList.add(mallActAwardSet); // } // } // MallActAwardSet mallActAwardSet = new MallActAwardSet(); // if(idList.size() <= 1){ // mallActAwardSet = idList.get(0); // }else{ // int randomIdIndex = RandomUtil.randomInt(0, idList.size()-1); // mallActAwardSet = idList.get(randomIdIndex); // } // mallActAwardSet.setAwardCnt(mallActAwardSet.getAwardCnt() + 1); // mallActAwardSetMapper.updateById(mallActAwardSet); // // MallActLuckdrawRecord mallActLuckdrawRecord = new MallActLuckdrawRecord(); // mallActLuckdrawRecord.setActId(actId); // mallActLuckdrawRecord.setActName(mallActSet.getActName()); // mallActLuckdrawRecord.setMemberId(memberId); // mallActLuckdrawRecord.setActScoreCnt(actScoreCnt); // mallActLuckdrawRecord.setStatus(MallActLuckdrawRecord.STATUS_ENABLE); // mallActLuckdrawRecordMapper.insert(mallActLuckdrawRecord); // // MallActWinRecord mallActWinRecord = new MallActWinRecord(); // mallActWinRecord.setMemberId(memberId); // mallActWinRecord.setActId(actId); // mallActWinRecord.setActName(mallActSet.getActName()); // mallActWinRecord.setAwardId(mallActAwardSet.getId()); // mallActWinRecord.setAwardName(mallActAwardSet.getAwardName()); // mallActWinRecord.setAwardType(mallActAwardSet.getAwardType()); // mallActWinRecord.setAwardValue(mallActAwardSet.getAwardValue()); // mallActWinRecord.setRecordId(mallActLuckdrawRecord.getId()); // mallActWinRecordMapper.insert(mallActWinRecord); // // apiMallAwardDetailsVo.setAwardName(mallActAwardSet.getAwardName()); // apiMallAwardDetailsVo.setAwardType(mallActAwardSet.getAwardType()); // apiMallAwardDetailsVo.setAwardValue(mallActAwardSet.getAwardValue()); // apiMallAwardDetailsVo.setAwardImage(mallActAwardSet.getAwardImage()); // // if(MallActAwardSet.AWARD_TYPE_JF == mallActAwardSet.getAwardType()){ // prizeScore = prizeScore.add(new BigDecimal(mallActAwardSet.getAwardValue())); // }else if(MallActAwardSet.AWARD_TYPE_YJ == mallActAwardSet.getAwardType()){ // commission = commission.add(new BigDecimal(mallActAwardSet.getAwardValue())); // } // } // }else{ // //抽奖记录 // MallActLuckdrawRecord mallActLuckdrawRecord = new MallActLuckdrawRecord(); // mallActLuckdrawRecord.setActId(actId); // mallActLuckdrawRecord.setActName(mallActSet.getActName()); // mallActLuckdrawRecord.setMemberId(memberId); // mallActLuckdrawRecord.setActScoreCnt(actScoreCnt); // mallActLuckdrawRecord.setStatus(MallActLuckdrawRecord.STATUS_DISABLED); // mallActLuckdrawRecordMapper.insert(mallActLuckdrawRecord); // // List mallActAwardSetXXCY = mallActAwardSetMapper.selectMallActAwardByActIdAndAwardType(actId, MallActAwardSet.AWARD_TYPE_XXCY); // if(CollUtil.isNotEmpty(mallActAwardSetXXCY)){ // apiMallAwardDetailsVo.setAwardImage(mallActAwardSetXXCY.get(0).getAwardImage()); // apiMallAwardDetailsVo.setAwardName(mallActAwardSetXXCY.get(0).getAwardName()); // }else{ // apiMallAwardDetailsVo.setAwardName("未中奖"); // } // } // }else{ // //获取活动下该类别的奖品 // List mallActAwardSets = mallActAwardSetMapper.selectMallActAwardByActIdAndAwardType(actId,minAwardType); // if(CollUtil.isEmpty(mallActAwardSets)){ // //抽奖记录 // MallActLuckdrawRecord mallActLuckdrawRecord = new MallActLuckdrawRecord(); // mallActLuckdrawRecord.setActId(actId); // mallActLuckdrawRecord.setActName(mallActSet.getActName()); // mallActLuckdrawRecord.setMemberId(memberId); // mallActLuckdrawRecord.setActScoreCnt(actScoreCnt); // mallActLuckdrawRecord.setStatus(MallActLuckdrawRecord.STATUS_DISABLED); // mallActLuckdrawRecordMapper.insert(mallActLuckdrawRecord); // // List mallActAwardSetXXCY = mallActAwardSetMapper.selectMallActAwardByActIdAndAwardType(actId, MallActAwardSet.AWARD_TYPE_XXCY); // if(CollUtil.isNotEmpty(mallActAwardSetXXCY)){ // apiMallAwardDetailsVo.setAwardImage(mallActAwardSetXXCY.get(0).getAwardImage()); // apiMallAwardDetailsVo.setAwardName(mallActAwardSetXXCY.get(0).getAwardName()); // }else{ // apiMallAwardDetailsVo.setAwardName("未中奖"); // } // }else{ // List idList = new ArrayList(); // for(MallActAwardSet mallActAwardSet : mallActAwardSets){ // Integer awardTotal = mallActAwardSet.getAwardTotal(); // Integer awardCnt = mallActAwardSet.getAwardCnt(); // if(awardCnt < awardTotal){ // idList.add(mallActAwardSet); // } // } // MallActAwardSet mallActAwardSet = new MallActAwardSet(); // if(idList.size() <= 1){ // mallActAwardSet = idList.get(0); // }else{ // int randomIdIndex = RandomUtil.randomInt(0, idList.size()-1); // mallActAwardSet = idList.get(randomIdIndex); // } // mallActAwardSet.setAwardCnt(mallActAwardSet.getAwardCnt() + 1); // mallActAwardSetMapper.updateById(mallActAwardSet); // // MallActLuckdrawRecord mallActLuckdrawRecord = new MallActLuckdrawRecord(); // mallActLuckdrawRecord.setActId(actId); // mallActLuckdrawRecord.setActName(mallActSet.getActName()); // mallActLuckdrawRecord.setMemberId(memberId); // mallActLuckdrawRecord.setActScoreCnt(actScoreCnt); // mallActLuckdrawRecord.setStatus(MallActLuckdrawRecord.STATUS_ENABLE); // mallActLuckdrawRecordMapper.insert(mallActLuckdrawRecord); // // MallActWinRecord mallActWinRecord = new MallActWinRecord(); // mallActWinRecord.setMemberId(memberId); // mallActWinRecord.setActId(actId); // mallActWinRecord.setActName(mallActSet.getActName()); // mallActWinRecord.setAwardId(mallActAwardSet.getId()); // mallActWinRecord.setAwardName(mallActAwardSet.getAwardName()); // mallActWinRecord.setAwardType(mallActAwardSet.getAwardType()); // mallActWinRecord.setAwardValue(mallActAwardSet.getAwardValue()); // mallActWinRecord.setRecordId(mallActLuckdrawRecord.getId()); // mallActWinRecordMapper.insert(mallActWinRecord); // // apiMallAwardDetailsVo.setAwardName(mallActAwardSet.getAwardName()); // apiMallAwardDetailsVo.setAwardType(mallActAwardSet.getAwardType()); // apiMallAwardDetailsVo.setAwardValue(mallActAwardSet.getAwardValue()); // apiMallAwardDetailsVo.setAwardImage(mallActAwardSet.getAwardImage()); // // if(MallActAwardSet.AWARD_TYPE_JF == mallActAwardSet.getAwardType()){ // prizeScore = prizeScore.add(new BigDecimal(mallActAwardSet.getAwardValue())); // }else if(MallActAwardSet.AWARD_TYPE_YJ == mallActAwardSet.getAwardType()){ // commission = commission.add(new BigDecimal(mallActAwardSet.getAwardValue())); // } // } // } // } // // //扣竞猜积分 // prizeScore = prizeScore.subtract(new BigDecimal(actScoreCnt)); // wallet.setPrizeScore(prizeScore); // wallet.setCommission(commission); // mallMemberWalletMapper.updateAmountWithVersion(wallet); // // System.out.println(apiMallAwardDetailsVo); // } // // @Test // public void agentTest() { //// agentProducer.sendDelayMsg(1L, 10000L); // // ApiMallActWinDetailsDto apiMallActWinDetailsDto = new ApiMallActWinDetailsDto(); // apiMallActWinDetailsDto.setActId(1L); // apiMallActWinDetailsDto.setPageNow(1); // apiMallActWinDetailsDto.setPageSize(10); // Long memberId = 4L; // MallMember mallMember = mallMemberMapper.selectById(memberId); // if(ObjectUtil.isEmpty(mallMember)){ // throw new FebsException("用户不存在"); // } // apiMallActWinDetailsDto.setMemberId(memberId); // // Long actId = apiMallActWinDetailsDto.getActId(); // MallActSet mallActSet = mallActSetMapper.selectById(actId); // if(ObjectUtil.isEmpty(mallActSet)){ // throw new FebsException("活动不存在"); // } // Page page = new Page<>(apiMallActWinDetailsDto.getPageNow(), apiMallActWinDetailsDto.getPageSize()); // IPage apiMallActWinDetailsVoIPage = mallActWinRecordMapper.selectApiMallActWinDetailsListInPage(apiMallActWinDetailsDto, page); // System.out.println(apiMallActWinDetailsVoIPage); // } // // @Test // public void insertAgentTest() { //// AgentInfo agentInfo = new AgentInfo(); //// agentInfo.setOrderType(2); //// agentInfo.setOrderCnt(2000); //// agentInfo.setLastCnt(3); //// agentInfo.setDirectIncome(BigDecimal.valueOf(50)); //// agentInfo.setTeamIncome(BigDecimal.valueOf(15)); //// agentInfo.setTeamIncomeType(2); //// //// DataDictionaryCustom data = new DataDictionaryCustom(); //// data.setType("AGENT_LEVEL_REQUIRE"); //// data.setCode(AgentLevelEnum.FOUR_LEVEL.name()); //// data.setValue(JSONObject.toJSONString(agentInfo)); //// dataDictionaryCustomMapper.insert(data); // } // // @Test // public void insertData() { // int i = 1; // for (AgentLevelEnum value : AgentLevelEnum.values()) { // DataDictionaryCustom data = new DataDictionaryCustom(); // data.setType("AGENT_LEVEL"); // data.setDescription(value.getName()); // data.setCode(value.name()); // data.setValue(String.valueOf(i)); // dataDictionaryCustomMapper.insert(data); // } // // } // // public static void main(String[] args) { // getJson(); // } // // public static void getJson(){ // AgentLevelUpdateDto adminAgentLevelUpdateInfoVo = new AgentLevelUpdateDto(); // String jsonStr = "{\"directIncome\":50,\"lastCnt\":3,\"orderCnt\":2000,\"orderType\":2,\"teamIncome\":15,\"teamIncomeType\":2}"; // JSONObject jsonObject = JSONObject.parseObject(jsonStr); // adminAgentLevelUpdateInfoVo.setDirectIncome(new BigDecimal((jsonObject.get("directIncome")==null?0:jsonObject.get("directIncome")).toString())); // adminAgentLevelUpdateInfoVo.setLastCnt(Integer.parseInt((jsonObject.get("lastCnt")==null?0:jsonObject.get("lastCnt")).toString())); // adminAgentLevelUpdateInfoVo.setOrderCnt(Integer.parseInt((jsonObject.get("orderCnt")==null?0:jsonObject.get("orderCnt")).toString())); // adminAgentLevelUpdateInfoVo.setOrderType(Integer.parseInt(jsonObject.get("orderType").toString())); // adminAgentLevelUpdateInfoVo.setTeamIncome(new BigDecimal((jsonObject.get("teamIncome")==null?0:jsonObject.get("teamIncome")).toString())); // adminAgentLevelUpdateInfoVo.setTeamIncomeType(Integer.parseInt(jsonObject.get("orderType").toString())); // adminAgentLevelUpdateInfoVo.setId(14L); // AgentLevelUpdateDto agentLevelUpdateDtoJson = new AgentLevelUpdateDto(); // agentLevelUpdateDtoJson.setDirectIncome(adminAgentLevelUpdateInfoVo.getDirectIncome()); // agentLevelUpdateDtoJson.setLastCnt(adminAgentLevelUpdateInfoVo.getLastCnt()); // agentLevelUpdateDtoJson.setOrderCnt(adminAgentLevelUpdateInfoVo.getOrderCnt()); // agentLevelUpdateDtoJson.setTeamIncome(adminAgentLevelUpdateInfoVo.getTeamIncome()); // agentLevelUpdateDtoJson.setOrderType(adminAgentLevelUpdateInfoVo.getOrderType()); // agentLevelUpdateDtoJson.setTeamIncomeType(adminAgentLevelUpdateInfoVo.getTeamIncomeType()); // JSONObject jsonObjectA = (JSONObject)JSONObject.toJSON(agentLevelUpdateDtoJson); // System.out.println(jsonObjectA.toJSONString()); // } // // @Test // public void autoLevelUp() { // // agentService.autoUpAgentLevel(3L); //// agentProducer.sendAutoLevelUpMsg(5L); // // agentProducer.sendReturnMoneyMsg(2L); // } // // @Test // public void returnMoney() { // // agentService.autoUpAgentLevel(3L); //// agentProducer.sendAutoLevelUpMsg(5L); //// agentProducer.sendReturnMoneyMsg(52L); // agentService.returnMoneyToAgent(52L); // } // // @Test // public void bigdecimalTest() { // BigDecimal aa = new BigDecimal("1.345"); // // System.out.println(aa.setScale(2, RoundingMode.DOWN)); // System.out.println(aa.setScale(2, RoundingMode.UP)); // } // // @Autowired // private ProfitJob profitJob; // // @Test // public void profitJobTest() { // profitJob.profitJob(); // } // // // @Autowired // private AgentConsumer agentConsumer; // // @Test // public void orderReturnTest() { // agentConsumer.orderReturnMoney("7"); // } }