fix
Hentua
2023-04-25 cf0acf91076a0a0f720adbbe486cc5d7f3d1d3f9
src/main/java/cc/mrbird/febs/mall/service/impl/MemberProfitServiceImpl.java
@@ -57,8 +57,6 @@
            log.info("积分订单无返利");
            return;
        }
        BigDecimal indirectPer = BigDecimal.valueOf(0.25);
        BigDecimal indirectPer2 = BigDecimal.valueOf(0.15);
        MallMember member = mallMemberMapper.selectById(orderInfo.getMemberId());
@@ -73,8 +71,14 @@
            return;
        }
        // 父级会员直推人数
        Integer directCnt = mallMemberMapper.selectOwnCntByInviteIdAndAccountLevel(parentMember.getInviteId(), parentMember.getAccountLevel());
        // 非代理推代理,非代理上级拿的收益比例
        DataDictionaryCustom indirectPerDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.UNAGENT_TO_AGENT_PARENT.getType(), DataDictionaryEnum.UNAGENT_TO_AGENT_PARENT.getCode());
        // 非代理推代理,非代理的直推收益比例
        DataDictionaryCustom unAgentDirectDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.UNAGENT_TO_AGENT.getType(), DataDictionaryEnum.UNAGENT_TO_AGENT.getCode());
        // 父级需要拥有 此会员 对应级别的直推数量
        Integer directCnt = mallMemberMapper.selectOwnCntByInviteIdAndAccountLevel(parentMember.getInviteId(), member.getAccountLevel());
        List<DataDictionaryCustom> dataDices = dataDictionaryCustomMapper.selectDicByType(DataDictionaryEnum.DIRECT_BONUS_SETTING.getType());
        directCnt = directCnt == null ? 0 : directCnt;
@@ -84,9 +88,12 @@
            return;
        }
        // 推荐奖比例
        DataDictionaryCustom indrectDicPropDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.RECOMMEND_BONUS.getType(), DataDictionaryEnum.RECOMMEND_BONUS.getCode());
        for (MallOrderItem item : items) {
            // 减去成本后算收益
            BigDecimal amount = item.getPrice().subtract(item.getCostPrice()).multiply(BigDecimal.valueOf(item.getCnt()));
            // 减去成本后算收益 减去积分付款
            BigDecimal amount = item.getPrice().subtract(item.getCostPrice()).multiply(BigDecimal.valueOf(item.getCnt())).subtract(orderInfo.getScoreAmount());
            if (amount.compareTo(BigDecimal.ZERO) < 1) {
                continue;
            }
@@ -103,8 +110,7 @@
            } else {
                // 判断上级是否与自己购买的套餐符合,若符合则走3级直推逻辑,若不符合则另外一个
                if (parentMember.getAccountLevel().equals(item.getGoodsLevel()) || AccountLevelEnums.VIP.getLevel().equals(parentMember.getAccountLevel())) {
                if (parentMember.getAccountLevel() >= item.getGoodsLevel()) {
                    for (DataDictionaryCustom dataDic : dataDices) {
                        JSONObject jsonObject = JSONObject.parseObject(dataDic.getValue());
                        if (directCnt >= jsonObject.getInteger("pushCnt")) {
@@ -114,7 +120,7 @@
                    isSameLevel = 1;
                    // 非代理推代理/非股东推股东
                } else {
                    profitPer = BigDecimal.valueOf(10);
                    profitPer = new BigDecimal(unAgentDirectDic.getValue());
                    isSameLevel = 2;
                }
            }
@@ -122,17 +128,6 @@
            // 直推奖
            BigDecimal profit = amount.multiply(profitPer.divide(new BigDecimal(100), 2, RoundingMode.HALF_UP));
            changeScoreAndCommission(parentMember.getId(), profit, MoneyFlowTypeEnum.DIRECT_BONUS.getValue(), orderInfo.getOrderNo());
            // 代理推代理
//            if (isSameLevel == 1) {
//                MallMember doubleParentMember = mallMemberMapper.selectInfoByInviteId(parentMember.getReferrerId());
//                if (doubleParentMember == null) {
//                    continue;
//                }
//
//                BigDecimal doubleParentProfit = profit.multiply(indirectPer);
//                changeScoreAndCommission(doubleParentMember.getId(), doubleParentProfit, MoneyFlowTypeEnum.DIRECT_BONUS.getValue(), orderInfo.getOrderNo());
//            }
            // 非代理推代理
            if (isSameLevel == 2) {
@@ -150,7 +145,7 @@
                        break;
                    }
                    BigDecimal doubleParentProfit = profit.multiply(indirectPer2);
                    BigDecimal doubleParentProfit = profit.multiply(new BigDecimal(indirectPerDic.getValue()));
                    changeScoreAndCommission(mallMember.getId(), doubleParentProfit, MoneyFlowTypeEnum.DIRECT_BONUS.getValue(), orderInfo.getOrderNo());
                }
            }
@@ -173,8 +168,7 @@
                    continue;
                }
                // 隔代比例
                BigDecimal indrectDicProp = new BigDecimal(20);
                BigDecimal indrectDicProp = new BigDecimal(indrectDicPropDic.getValue());
                // 隔代推荐奖 收益
                direct = direct.multiply(indrectDicProp.divide(new BigDecimal("100"), 2, RoundingMode.HALF_UP));
@@ -191,7 +185,6 @@
                walletService.add(direct, parent.getId(), "commission");
                moneyFlowService.addMoneyFlow(parent.getId(), direct, MoneyFlowTypeEnum.RECOMMEND_BONUS.getValue(), orderInfo.getOrderNo(), FlowTypeEnum.COMMISSION.getValue());
                moneyFlowService.addMoneyFlow(parent.getId(), direct.negate(), MoneyFlowTypeEnum.RECOMMEND_BONUS.getValue(), orderInfo.getOrderNo(), FlowTypeEnum.SCORE.getValue());
                changeScoreAndCommission(parent.getId(), direct, MoneyFlowTypeEnum.RECOMMEND_BONUS.getValue(), orderInfo.getOrderNo());
            }
            // =======隔代奖== end =====
        }
@@ -489,7 +482,7 @@
        BigDecimal hundred = new BigDecimal(100);
        for (MallOrderItem item : items) {
            // 减去成本后算收益
            BigDecimal amount = item.getPrice().subtract(item.getCostPrice()).multiply(BigDecimal.valueOf(item.getCnt()));
            BigDecimal amount = item.getPrice().subtract(item.getCostPrice()).multiply(BigDecimal.valueOf(item.getCnt())).subtract(orderInfo.getScoreAmount());
            if (amount.compareTo(BigDecimal.ZERO) < 1) {
                continue;
            }