xiaoyong931011
2023-04-11 81c7c2463b45509406350802f9566d1f78f9e84e
后台修改
5 files modified
1540 ■■■■ changed files
src/main/resources/application-test.yml 6 ●●●● patch | view | raw | blame | history
src/main/resources/application.yml 2 ●●● patch | view | raw | blame | history
src/test/java/cc/mrbird/febs/AgentTest.java 1168 ●●●● patch | view | raw | blame | history
src/test/java/cc/mrbird/febs/PayTest.java 26 ●●●● patch | view | raw | blame | history
src/test/java/cc/mrbird/febs/ProfitTest.java 338 ●●●● patch | view | raw | blame | history
src/main/resources/application-test.yml
@@ -18,7 +18,7 @@
          username: ct_test
          password: 123456
          driver-class-name: com.mysql.cj.jdbc.Driver
          url: jdbc:mysql://120.27.238.55:3306/db_amz?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2b8
          url: jdbc:mysql://120.27.238.55:3406/db_hnto?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2b8
  redis:
    # Redis数据库索引(默认为 0)
@@ -26,9 +26,9 @@
    # Redis服务器地址
    host: 120.27.238.55
    # Redis服务器连接端口
    port: 6379
    port: 6479
    # Redis 密码
    password: xcong123
    password: d3y6dsdl;f.327
    lettuce:
      pool:
        # 连接池中的最小空闲连接
src/main/resources/application.yml
@@ -1,5 +1,5 @@
server:
  port: 8083
  port: 8186
  tomcat:
    uri-encoding: utf-8
src/test/java/cc/mrbird/febs/AgentTest.java
@@ -39,589 +39,589 @@
@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;
    @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<MallActAwardSet> 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<MallActLuckdrawRecord> 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<MallActAwardSet> 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<MallActAwardSet> 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<MallActAwardSet> 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<MallActAwardSet> 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<MallActAwardSet> 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<MallActAwardSet> 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<MallActAwardSet> 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<MallActLuckdrawRecord> 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<MallActAwardSet> 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<MallActAwardSet> 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<MallActAwardSet> 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<MallActAwardSet> 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<MallActAwardSet> 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<MallActAwardSet> 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<MallActAwardSet> 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<ApiMallActWinDetailsVo> page = new Page<>(apiMallActWinDetailsDto.getPageNow(), apiMallActWinDetailsDto.getPageSize());
        IPage<ApiMallActWinDetailsVo> 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);
//    @Autowired
//    private AgentProducer agentProducer;
//
//        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() {
    }
//    @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;
//    @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<MallActAwardSet> 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<MallActLuckdrawRecord> 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<MallActAwardSet> 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<MallActAwardSet> 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<MallActAwardSet> 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<MallActAwardSet> 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<MallActAwardSet> 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<MallActAwardSet> 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<MallActAwardSet> 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<MallActLuckdrawRecord> 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<MallActAwardSet> 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<MallActAwardSet> 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<MallActAwardSet> 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<MallActAwardSet> 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<MallActAwardSet> 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<MallActAwardSet> 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<MallActAwardSet> 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<ApiMallActWinDetailsVo> page = new Page<>(apiMallActWinDetailsDto.getPageNow(), apiMallActWinDetailsDto.getPageSize());
//        IPage<ApiMallActWinDetailsVo> 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() {
//    }
}
src/test/java/cc/mrbird/febs/PayTest.java
@@ -17,17 +17,17 @@
@SpringBootTest
public class PayTest {
    @Test
    public void aliPay() throws AlipayApiException {
        AlipayTradeAppPayModel model = new AlipayTradeAppPayModel();
        model.setBody("这是测试用");
        model.setSubject("支付测试用的");
        model.setOutTradeNo("2021092712215802974");
        model.setTimeoutExpress("15m");
        model.setTotalAmount("0.01");
        model.setPassbackParams("callback params");
        model.setProductCode("QUICK_MSECURITY_PAY");
        AlipayTradeAppPayResponse resp = AliPayApi.appPayToResponse(model, "");
        log.info("=====>>>{}", JSONObject.toJSONString(resp));
    }
//    @Test
//    public void aliPay() throws AlipayApiException {
//        AlipayTradeAppPayModel model = new AlipayTradeAppPayModel();
//        model.setBody("这是测试用");
//        model.setSubject("支付测试用的");
//        model.setOutTradeNo("2021092712215802974");
//        model.setTimeoutExpress("15m");
//        model.setTotalAmount("0.01");
//        model.setPassbackParams("callback params");
//        model.setProductCode("QUICK_MSECURITY_PAY");
//        AlipayTradeAppPayResponse resp = AliPayApi.appPayToResponse(model, "");
//        log.info("=====>>>{}", JSONObject.toJSONString(resp));
//    }
}
src/test/java/cc/mrbird/febs/ProfitTest.java
@@ -31,175 +31,175 @@
@SpringBootTest
public class ProfitTest {
    @Autowired
    private AgentConsumer agentConsumer;
    @Autowired
    private IAgentService agentService;
    @Autowired
    private IMemberProfitService memberProfitService;
    @Test
    public void dynamicProfit() {
//        agentService.returnMoneyToAgent(578L);
        agentService.autoUpAgentLevel(640L);
    }
    @Test
    public void agentProfit() {
        memberProfitService.agentProfit(null);
    }
//    @Autowired
//    private AgentConsumer agentConsumer;
//
//    @Autowired
//    private IAgentService agentService;
//
//    @Autowired
//    private IMemberProfitService memberProfitService;
//
//    @Test
//    public void staticProfit() {
//        memberProfitService.staticProfit(new Date());
//    public void dynamicProfit() {
////        agentService.returnMoneyToAgent(578L);
//        agentService.autoUpAgentLevel(640L);
//    }
    @Test
    public void thankfulProfit() {
        memberProfitService.thankfulProfit(new Date());
    }
    @Test
    public void rankProfit() {
        memberProfitService.rankProfit();
    }
    @Autowired
    private MallOrderInfoMapper mallOrderInfoMapper;
    @Test
    public void directorProfitTest() {
        memberProfitService.storeAndDirectorProfit(new Date());
    }
    @Autowired
    private MallOrderItemMapper mallOrderItemMapper;
    @Autowired
    private IMallAchieveService mallAchieveService;
    @Test
    public void achieveTest() {
        List<MallOrderItem> items = mallOrderItemMapper.selectList(null);
        for (MallOrderItem item : items) {
            mallAchieveService.add(item.getId());
        }
    }
    @Test
    public void paramTest() {
        Map<String, Integer> map = new HashMap<>();
        BigDecimal amount = new BigDecimal("100");
        map.put("amount", 1);
        changeAmount(map);
        System.out.println(map.get("amount"));
    }
    public void changeAmount(Map<String, Integer> amount) {
        amount.put("amount", 2);
    }
    @Test
    public void scorePool(){
        memberProfitService.scorePool();
    }
    @Test
    public void staticProfit(){
        memberProfitService.staticProfit(null);
    }
    @Autowired
    private OrderSettlementJob orderSettlementJob;
    @Test
    public void orderSettlementJobTest() {
//        orderSettlementJob.normalGoodsSettlementJob();
        mallAchieveService.add(83L);
    }
    @Autowired
    private UnipayService unipayService;
    @Test
    public void unipay(){
        UnipayDto unipayDto = new UnipayDto();
        unipayDto.setAmount(new BigDecimal("0.01"));
        unipayDto.setFrpCode("ALIPAY_H5");
        unipayDto.setTradeMerchantNo("777180800385820");
//        unipayDto.setFrpCode("WEIXIN_APP3");
        unipayDto.setOrderNo("2022082316415386395");
        unipayDto.setProductName("洗护套装");
        unipayService.unipay(unipayDto);
    }
    @Test
    public void getAgreeMentPaySms(){
        AgreeMentPaySmsDto agreeMentPaySmsDto = new AgreeMentPaySmsDto();
        agreeMentPaySmsDto.setOrderNo("2022082617305930328");
        BigDecimal value = new BigDecimal("0.1").setScale(2, BigDecimal.ROUND_DOWN);
        DecimalFormat decimalFormat = new DecimalFormat("0.00#");
        String strVal = decimalFormat.format(value);
        agreeMentPaySmsDto.setOrderAmount(new BigDecimal(strVal));
        agreeMentPaySmsDto.setName("肖永");
        agreeMentPaySmsDto.setCreatedTime(DateUtil.now());
        agreeMentPaySmsDto.setIdType("1");
        agreeMentPaySmsDto.setIdCardNum("430321199310113713");
        agreeMentPaySmsDto.setBankNo("6222031901002389639");
        agreeMentPaySmsDto.setPhone("15274802129");
        String agreeMentPaySms = unipayService.getAgreeMentPaySms(agreeMentPaySmsDto);
        if("JS000000".equals(agreeMentPaySms)){
            System.out.println("获取成功");
        }else{
            System.out.println(agreeMentPaySms);
        }
    }
    @Test
    public void agreementSign(){
        AgreementSignDto agreementSignDto = new AgreementSignDto();
        agreementSignDto.setOrderNo("2022082614465345250");
        agreementSignDto.setSmsCode("841243");
        unipayService.agreementSign(agreementSignDto);
    }
    @Test
    public void agreementPay(){
        AgreementPayDto agreementPayDto = new AgreementPayDto();
        agreementPayDto.setOrderNo("2022082614465345250");
        BigDecimal value = new BigDecimal("0.1").setScale(2, BigDecimal.ROUND_DOWN);
        DecimalFormat decimalFormat = new DecimalFormat("0.00#");
        String strVal = decimalFormat.format(value);
        agreementPayDto.setOrderAmount(new BigDecimal(strVal));
        agreementPayDto.setOrderTime(DateUtil.now());
        agreementPayDto.setOrderDesc("测试");
        agreementPayDto.setBankNo("6222031901002389639");
        unipayService.agreementPay(agreementPayDto);
    }
    @Test
    public void singlePay(){
        /**
         * 调用汇聚代付
         */
        String orderNo = MallUtils.getOrderNum("W");
        SinglePayDto singlePayDto = new SinglePayDto();
        singlePayDto.setMerchantOrderNo(orderNo);
        singlePayDto.setReceiverAccountNoEncBankNo("6222031903210023839639");
        singlePayDto.setReceiverAccountNoEncName("肖永");
        singlePayDto.setReceiverAccountType("201");
        BigDecimal paidAmount = new BigDecimal(1.00);
        singlePayDto.setPaidAmount(paidAmount);
        singlePayDto.setCurrency("201");
        singlePayDto.setIsChecked("202");
        singlePayDto.setPaidDesc("用户提现");
        singlePayDto.setPaidUse("202");
        String singlePayRep = unipayService.singlePay(singlePayDto);
        System.out.println(singlePayRep);
    }
//    @Test
//    public void agentProfit() {
//        memberProfitService.agentProfit(null);
//    }
//
//
////    @Test
////    public void staticProfit() {
////        memberProfitService.staticProfit(new Date());
////    }
//
//    @Test
//    public void thankfulProfit() {
//        memberProfitService.thankfulProfit(new Date());
//    }
//
//    @Test
//    public void rankProfit() {
//        memberProfitService.rankProfit();
//    }
//
//    @Autowired
//    private MallOrderInfoMapper mallOrderInfoMapper;
//
//    @Test
//    public void directorProfitTest() {
//        memberProfitService.storeAndDirectorProfit(new Date());
//    }
//
//    @Autowired
//    private MallOrderItemMapper mallOrderItemMapper;
//
//    @Autowired
//    private IMallAchieveService mallAchieveService;
//
//    @Test
//    public void achieveTest() {
//        List<MallOrderItem> items = mallOrderItemMapper.selectList(null);
//        for (MallOrderItem item : items) {
//            mallAchieveService.add(item.getId());
//        }
//    }
//
//    @Test
//    public void paramTest() {
//        Map<String, Integer> map = new HashMap<>();
//        BigDecimal amount = new BigDecimal("100");
//        map.put("amount", 1);
//        changeAmount(map);
//        System.out.println(map.get("amount"));
//    }
//
//    public void changeAmount(Map<String, Integer> amount) {
//        amount.put("amount", 2);
//    }
//
//    @Test
//    public void scorePool(){
//        memberProfitService.scorePool();
//    }
//
//    @Test
//    public void staticProfit(){
//        memberProfitService.staticProfit(null);
//    }
//
//    @Autowired
//    private OrderSettlementJob orderSettlementJob;
//
//    @Test
//    public void orderSettlementJobTest() {
////        orderSettlementJob.normalGoodsSettlementJob();
//
//        mallAchieveService.add(83L);
//    }
//
//
//    @Autowired
//    private UnipayService unipayService;
//    @Test
//    public void unipay(){
//        UnipayDto unipayDto = new UnipayDto();
//        unipayDto.setAmount(new BigDecimal("0.01"));
//        unipayDto.setFrpCode("ALIPAY_H5");
//        unipayDto.setTradeMerchantNo("777180800385820");
////        unipayDto.setFrpCode("WEIXIN_APP3");
//        unipayDto.setOrderNo("2022082316415386395");
//        unipayDto.setProductName("洗护套装");
//        unipayService.unipay(unipayDto);
//    }
//    @Test
//    public void getAgreeMentPaySms(){
//        AgreeMentPaySmsDto agreeMentPaySmsDto = new AgreeMentPaySmsDto();
//        agreeMentPaySmsDto.setOrderNo("2022082617305930328");
//
//        BigDecimal value = new BigDecimal("0.1").setScale(2, BigDecimal.ROUND_DOWN);
//        DecimalFormat decimalFormat = new DecimalFormat("0.00#");
//        String strVal = decimalFormat.format(value);
//        agreeMentPaySmsDto.setOrderAmount(new BigDecimal(strVal));
//        agreeMentPaySmsDto.setName("肖永");
//        agreeMentPaySmsDto.setCreatedTime(DateUtil.now());
//        agreeMentPaySmsDto.setIdType("1");
//        agreeMentPaySmsDto.setIdCardNum("430321199310113713");
//        agreeMentPaySmsDto.setBankNo("6222031901002389639");
//        agreeMentPaySmsDto.setPhone("15274802129");
//        String agreeMentPaySms = unipayService.getAgreeMentPaySms(agreeMentPaySmsDto);
//        if("JS000000".equals(agreeMentPaySms)){
//            System.out.println("获取成功");
//        }else{
//            System.out.println(agreeMentPaySms);
//        }
//    }
//
//    @Test
//    public void agreementSign(){
//        AgreementSignDto agreementSignDto = new AgreementSignDto();
//        agreementSignDto.setOrderNo("2022082614465345250");
//        agreementSignDto.setSmsCode("841243");
//        unipayService.agreementSign(agreementSignDto);
//    }
//
//    @Test
//    public void agreementPay(){
//        AgreementPayDto agreementPayDto = new AgreementPayDto();
//        agreementPayDto.setOrderNo("2022082614465345250");
//
//        BigDecimal value = new BigDecimal("0.1").setScale(2, BigDecimal.ROUND_DOWN);
//        DecimalFormat decimalFormat = new DecimalFormat("0.00#");
//        String strVal = decimalFormat.format(value);
//        agreementPayDto.setOrderAmount(new BigDecimal(strVal));
//        agreementPayDto.setOrderTime(DateUtil.now());
//        agreementPayDto.setOrderDesc("测试");
//        agreementPayDto.setBankNo("6222031901002389639");
//        unipayService.agreementPay(agreementPayDto);
//    }
//
//    @Test
//    public void singlePay(){
//        /**
//         * 调用汇聚代付
//         */
//        String orderNo = MallUtils.getOrderNum("W");
//        SinglePayDto singlePayDto = new SinglePayDto();
//        singlePayDto.setMerchantOrderNo(orderNo);
//        singlePayDto.setReceiverAccountNoEncBankNo("6222031903210023839639");
//        singlePayDto.setReceiverAccountNoEncName("肖永");
//        singlePayDto.setReceiverAccountType("201");
//        BigDecimal paidAmount = new BigDecimal(1.00);
//        singlePayDto.setPaidAmount(paidAmount);
//        singlePayDto.setCurrency("201");
//        singlePayDto.setIsChecked("202");
//        singlePayDto.setPaidDesc("用户提现");
//        singlePayDto.setPaidUse("202");
//        String singlePayRep = unipayService.singlePay(singlePayDto);
//
//        System.out.println(singlePayRep);
//    }
}