xiaoyong931011
2023-03-30 836e019db92b9871cba9d440c8159b35f79e1726
src/main/java/cc/mrbird/febs/mall/service/impl/MemberProfitServiceImpl.java
@@ -12,6 +12,7 @@
import cc.mrbird.febs.mall.mapper.*;
import cc.mrbird.febs.mall.service.*;
import cc.mrbird.febs.mall.vo.AdminTeamEqualsPerkVo;
import cc.mrbird.febs.rabbit.producter.AgentProducer;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateTime;
@@ -56,6 +57,8 @@
    private final MallMemberWalletMapper mallMemberWalletMapper;
    private final IAgentService iAgentService;
    private final IMallMoneyFlowService mallMoneyFlowService;
    private final MallMqRecordMapper mallMqRecordMapper;
    private final AgentProducer agentProducer;
    @Override
    @Transactional(rollbackFor = Exception.class)
@@ -685,6 +688,8 @@
                //减少补贴额度
                mallMemberWalletMapper.reduceTotalScoreById(offLinePerkAmountSum, mallMemberWallet.getId());
                iAgentService.reduceStar(mallMemberWallet.getMemberId(),offLinePerkAmountSum);
                mallMemberWalletMapper.addBalanceById(offLinePerkAmountSum, mallMemberWallet.getId());
                mallMoneyFlowService.addMoneyFlow(
@@ -732,17 +737,56 @@
                    //减少补贴额度
                    mallMemberWalletMapper.reduceTotalScoreById(teamEqualsPerkAmount, mallMemberWallet.getId());
                    iAgentService.reduceStar(mallMemberWallet.getMemberId(),teamEqualsPerkAmount);
                    mallMemberWalletMapper.addBalanceById(teamEqualsPerkAmount, mallMemberWallet.getId());
//
//                    mallMoneyFlowService.addMoneyFlow(
//                            adminTeamEqualsPerkVo.getRtMemberId(),
//                            teamEqualsPerkAmount,
//                            MoneyFlowTypeEnum.TEAM_EQUALS_PERK.getValue(),
//                            MallUtils.getOrderNum("TEP"),
//                            FlowTypeEnum.BALANCE.getValue());
                    mallMoneyFlowService.addMoneyFlow(
                            adminTeamEqualsPerkVo.getRtMemberId(),
                            teamEqualsPerkAmount,
                            MoneyFlowTypeEnum.TEAM_EQUALS_PERK.getValue(),
                            MallUtils.getOrderNum("TEP"),
                            FlowTypeEnum.BALANCE.getValue());
                            "平级奖励补贴",
                            "补贴额度:"+mallMemberWallet.getTotalScore(),
                            adminTeamEqualsPerkVo.getMemberId(),
                            2,
                            FlowTypeEnum.BALANCE.getValue(),
                            1);
                }
            }
        }
    }
    @Override
    public void mqPerkRetryJob() {
        /**
         * 每次拿重试次数大于零
         * 按ID asc排序的十条数据
         */
        List<MallMqRecord> mallMqRecords = mallMqRecordMapper.selectByStateLimitTen(2);
        if(CollUtil.isEmpty(mallMqRecords)){
            return;
        }
        for(MallMqRecord mallMqRecord : mallMqRecords){
            Integer retryTimes = mallMqRecord.getRetryTimes();
            if(retryTimes <= 0){
                continue;
            }
            retryTimes = retryTimes - 1;
            mallMqRecord.setRetryTimes(retryTimes);
            mallMqRecordMapper.updateById(mallMqRecord);
            Long orderId = mallMqRecord.getOrderId();
            agentProducer.sendPerkMoneyMsg(orderId);
        }
    }
}