xiaoyong931011
2022-08-08 bd034b20e86824436e9a35ba407a8e626c67f210
src/main/java/cc/mrbird/febs/mall/service/impl/MemberProfitServiceImpl.java
@@ -49,6 +49,8 @@
    private final DataDictionaryCustomMapper dataDictionaryCustomMapper;
    private final MallMoneyFlowMapper mallMoneyFlowMapper;
    private final MallAchieveRecordMapper mallAchieveRecordMapper;
    private final RedisUtils redisUtils;
    private final MallMemberWalletMapper mallMemberWalletMapper;
    @Override
    @Transactional(rollbackFor = Exception.class)
@@ -481,8 +483,6 @@
        log.info("#####==店补/董事==end==######");
    }
    private final RedisUtils redisUtils;
    @Override
    public void scorePool() {
        log.info("#####==积分池==start==######");
@@ -517,8 +517,21 @@
                return;
            }
            for(MallMember mallMember : mallMembers){
                walletService.add(income, mallMember.getId(), "score");
                moneyFlowService.addMoneyFlow(mallMember.getId(), income, MoneyFlowTypeEnum.SCORE_POOL.getValue(), null, FlowTypeEnum.SCORE.getValue());
                /*
                平分成佣金,一比一减少赠送积分
                如果没有赠送积分,则平分0
                 */
                BigDecimal outCome = BigDecimal.ZERO;
                MallMemberWallet mallMemberWallet = mallMemberWalletMapper.selectWalletByMemberId(mallMember.getId());
                if(mallMemberWallet.getScore().compareTo(income) < 0){
                    outCome = new BigDecimal(mallMemberWallet.getScore().intValue());
                }else{
                    outCome = income;
                }
                walletService.add(outCome, mallMember.getId(), "commission");
                walletService.reduce(outCome, mallMember.getId(), "score");
                moneyFlowService.addMoneyFlow(mallMember.getId(), outCome, MoneyFlowTypeEnum.SCORE_POOL.getValue(), null, FlowTypeEnum.COMMISSION.getValue());
                moneyFlowService.addMoneyFlow(mallMember.getId(), outCome.negate(), MoneyFlowTypeEnum.SCORE_POOL.getValue(), null, FlowTypeEnum.SCORE.getValue());
            }
        }
        log.info("#####==积分池==end==######");