diff --git a/bd-business/bd-business-bonus/src/main/java/com/hzs/bonus/bonus/service/impl/BonusSettleRangeHandle.java b/bd-business/bd-business-bonus/src/main/java/com/hzs/bonus/bonus/service/impl/BonusSettleRangeHandle.java index 7a56e2db..bdb35275 100644 --- a/bd-business/bd-business-bonus/src/main/java/com/hzs/bonus/bonus/service/impl/BonusSettleRangeHandle.java +++ b/bd-business/bd-business-bonus/src/main/java/com/hzs/bonus/bonus/service/impl/BonusSettleRangeHandle.java @@ -282,22 +282,13 @@ public class BonusSettleRangeHandle extends BonusSettleHandle { CuMemberRetailRangeExt sourceMemberRangeExt = memberRangeExtMap.get(saOrderExt.getPkMember()); // 推荐人 long pkParent = sourceMemberRangeExt.getPkParent(); + // 2025.08.21 需要修改:累计升级制,按订单金额以及等级对应比例拿直推级差 // 订单金额 BigDecimal orderAmount = saOrderExt.getOrderAmount(); -// // TODO 累计升级,此处订单可能没有等级值 -// if (null != saOrderExt.getPkGrade()) { -// // 订单存在升级记录信息 -// // 订单等级值 -// Integer orderGradeValue = gradeIdMap.get(saOrderExt.getPkGrade()).getGradeValue(); -// } else { -// -// } - - - Integer orderGradeValue = gradeIdMap.get(saOrderExt.getPkGrade()).getGradeValue(); - - - + if (null == orderAmount || orderAmount.compareTo(BigDecimal.ZERO) == 0) { + log.warn("订单 {} 金额为0", saOrderExt.getOrderCode()); + return memberBonusRangeList; + } // 前一个会员等级 int beforeGradeValue = 0; @@ -311,14 +302,11 @@ public class BonusSettleRangeHandle extends BonusSettleHandle { if (beforeGradeValue == EGrade.COMPANY.getValue()) { break; } - // 推荐人 + // 推荐人 - 当前处理会员 CuMemberRetailRangeExt targetMemberRangeExt = memberRangeExtMap.get(pkParent); if (null == targetMemberRangeExt) { break; } - // 推荐人的推荐人 - pkParent = targetMemberRangeExt.getPkParent(); - if (EAccountStatus.STOP_INCOME.getValue() == targetMemberRangeExt.getAccountStatus() || ECategory.NORMAL.getValue() != targetMemberRangeExt.getCategory() || targetMemberRangeExt.getEnableStatus() == EYesNo.NO.getIntValue() @@ -327,251 +315,49 @@ public class BonusSettleRangeHandle extends BonusSettleHandle { // 停算收益、非正常会员、未激活、等级为顾客、停止收益,直接跳过 continue; } + // 推荐人的推荐人 + pkParent = targetMemberRangeExt.getPkParent(); // 当前会员等级值 int targetGradeValue = targetMemberRangeExt.getGradeValue(); - // 直推级差收益 BigDecimal rangeBonusIncome = BigDecimal.ZERO; - if (EGrade.HAI_FAN.getValue() == orderGradeValue) { - // 订单等级是会员、VIP - if (targetGradeValue > beforeGradeValue) { - // 当前会员等级大于上一个会员等级 - if (EGrade.HAI_FAN.getValue() == targetGradeValue) { - // V1 推拿 30 - rangeBonusIncome = RetailConstants.V1_V1; - // 前面累计的奖金 - totalBonus = RetailConstants.V1_V1; - } else if (EGrade.YOU_KE.getValue() == targetGradeValue) { - // V2 推拿 40,或者减去之前累计 - rangeBonusIncome = RetailConstants.V2_V1.subtract(totalBonus); - // 前面累计的奖金 - totalBonus = RetailConstants.V2_V1; - } else if (EGrade.MAKER.getValue() == targetGradeValue) { - // V3 推拿 50,或者减去之前累计 - rangeBonusIncome = RetailConstants.V3_V1.subtract(totalBonus); - // 前面累计的奖金 - totalBonus = RetailConstants.V3_V1; - } else if (EGrade.VIP.getValue() == targetGradeValue) { - // V4 推拿 100,或者减去之前累计 - rangeBonusIncome = RetailConstants.V4_V1.subtract(totalBonus); - // 前面累计的奖金 - totalBonus = RetailConstants.V4_V1; - } else if (EGrade.S_VIP.getValue() == targetGradeValue) { - // V5 推拿 104,或者减去之前累计 - rangeBonusIncome = RetailConstants.V5_V1.subtract(totalBonus); - // 前面累计的奖金 - totalBonus = RetailConstants.V5_V1; - } else if (EGrade.REGION.getValue() == targetGradeValue - || EGrade.DIRECTOR.getValue() == targetGradeValue) { - // V6、V7 推拿 110 ,或者减去之前累计 - // 前一等级不是V6、V7 - rangeBonusIncome = RetailConstants.V6_V7_V1.subtract(totalBonus); - // 前面累计的奖金 - totalBonus = RetailConstants.V6_V7_V1; - } else if (EGrade.COMPANY.getValue() == targetGradeValue) { - // V8 推拿 120,或者减去之前累计 - rangeBonusIncome = RetailConstants.V8_V1.subtract(totalBonus); - // 前面累计的奖金 - totalBonus = RetailConstants.V8_V1; - } - // 前一级会员等级 - beforeGradeValue = targetGradeValue; - } - } else if (EGrade.YOU_KE.getValue() == orderGradeValue) { - // 订单等级是VIP - if (targetGradeValue > beforeGradeValue) { - // 当前会员等级大于上一个会员等级 - if (EGrade.HAI_FAN.getValue() == targetGradeValue) { - // V1 推拿 300 - rangeBonusIncome = RetailConstants.V1_V2; - // 前面累计的奖金 - totalBonus = RetailConstants.V1_V2; - } else if (EGrade.YOU_KE.getValue() == targetGradeValue) { - // V2 推拿 400,或者减去之前累计 - rangeBonusIncome = RetailConstants.V2_V2.subtract(totalBonus); - // 前面累计的奖金 - totalBonus = RetailConstants.V2_V2; - } else if (EGrade.MAKER.getValue() == targetGradeValue) { - // V3 推拿 500,或者减去之前累计 - rangeBonusIncome = RetailConstants.V3_V2.subtract(totalBonus); - // 前面累计的奖金 - totalBonus = RetailConstants.V3_V2; - } else if (EGrade.VIP.getValue() == targetGradeValue) { - // V4 推拿 1000,或者减去之前累计 - rangeBonusIncome = RetailConstants.V4_V2.subtract(totalBonus); - // 前面累计的奖金 - totalBonus = RetailConstants.V4_V2; - } else if (EGrade.S_VIP.getValue() == targetGradeValue) { - // V5 推拿 1040,或者减去之前累计 - rangeBonusIncome = RetailConstants.V5_V2.subtract(totalBonus); - // 前面累计的奖金 - totalBonus = RetailConstants.V5_V2; - } else if (EGrade.REGION.getValue() == targetGradeValue - || EGrade.DIRECTOR.getValue() == targetGradeValue) { - // V6、V7 推拿 1100,或者减去之前累计 - rangeBonusIncome = RetailConstants.V6_V7_V2.subtract(totalBonus); - // 前面累计的奖金 - totalBonus = RetailConstants.V6_V7_V2; - } else if (EGrade.COMPANY.getValue() == targetGradeValue) { - // V8 推拿 1200,或者减去之前累计 - rangeBonusIncome = RetailConstants.V8_V2.subtract(totalBonus); - // 前面累计的奖金 - totalBonus = RetailConstants.V8_V2; - } - // 前一级会员等级 - beforeGradeValue = targetGradeValue; - } - } else if (EGrade.MAKER.getValue() == orderGradeValue) { - // 订单是合伙人 - if (targetGradeValue > beforeGradeValue) { - // 当前等级大于之前等级 - if (EGrade.HAI_FAN.getValue() == targetGradeValue) { - // V1 推拿 600 - rangeBonusIncome = RetailConstants.V1_V3; - // 前面累计的奖金 - totalBonus = RetailConstants.V1_V3; - } else if (EGrade.YOU_KE.getValue() == targetGradeValue) { - // V2 推拿 800,或者减去之前累计 - rangeBonusIncome = RetailConstants.V2_V3.subtract(totalBonus); - // 前面累计的奖金 - totalBonus = RetailConstants.V2_V3; - } else if (EGrade.MAKER.getValue() == targetGradeValue) { - // V3 推拿 1000,或者减去之前累计 - rangeBonusIncome = RetailConstants.V3_V3_1.subtract(totalBonus); - // 前面累计的奖金 - totalBonus = RetailConstants.V3_V3_1; - } else if (EGrade.VIP.getValue() == targetGradeValue) { - // V4 推拿 2000,或者减去之前累计 - rangeBonusIncome = RetailConstants.V4_V3.subtract(totalBonus); - // 前面累计的奖金 - totalBonus = RetailConstants.V4_V3; - } else if (EGrade.S_VIP.getValue() == targetGradeValue) { - // V5 推拿 2080,或者减去之前累计 - rangeBonusIncome = RetailConstants.V5_V3.subtract(totalBonus); - // 前面累计的奖金 - totalBonus = RetailConstants.V5_V3; - } else if (EGrade.REGION.getValue() == targetGradeValue - || EGrade.DIRECTOR.getValue() == targetGradeValue) { - // V6、V7 推拿 2200,或者减去之前累计 - rangeBonusIncome = RetailConstants.V6_V7_V3.subtract(totalBonus); - // 前面累计的奖金 - totalBonus = RetailConstants.V6_V7_V3; - } else if (EGrade.COMPANY.getValue() == targetGradeValue) { - // V8 推拿 2400,或者减去之前累计 - rangeBonusIncome = RetailConstants.V8_V3.subtract(totalBonus); - // 前面累计的奖金 - totalBonus = RetailConstants.V8_V3; - } - // 前一级会员等级 - beforeGradeValue = targetGradeValue; - } else if (EGrade.MAKER.getValue() == beforeGradeValue - && EGrade.MAKER.getValue() == targetGradeValue) { - // 之前和现在都是合伙人,处理平级 - if (v3Count == 1) { - // V3第一平级 推拿 1200,或者减去之前累计 - rangeBonusIncome = RetailConstants.V3_V3_2.subtract(totalBonus); - // 前面累计的奖金 - totalBonus = RetailConstants.V3_V3_2; - v3Count++; - } else if (v3Count == 2) { - // V3第二平级 推拿 1300,或者减去之前累计 - rangeBonusIncome = RetailConstants.V3_V3_3.subtract(totalBonus); - // 前面累计的奖金 - totalBonus = RetailConstants.V3_V3_3; - v3Count++; - } - } - } else if (EGrade.VIP.getValue() == orderGradeValue) { - // 订单是博羚店主 - if (targetGradeValue > beforeGradeValue) { - // 当前等级大于之前等级 - if (EGrade.HAI_FAN.getValue() == targetGradeValue) { - // V1 推拿 1200 - rangeBonusIncome = RetailConstants.V1_V4; - // 前面累计的奖金 - totalBonus = RetailConstants.V1_V4; - } else if (EGrade.YOU_KE.getValue() == targetGradeValue) { - // V2 推拿 1600,或者减去之前累计 - rangeBonusIncome = RetailConstants.V2_V4.subtract(totalBonus); - // 前面累计的奖金 - totalBonus = RetailConstants.V2_V4; - } else if (EGrade.MAKER.getValue() == targetGradeValue) { - // V3 推拿 2000,或者减去之前累计 - rangeBonusIncome = RetailConstants.V3_V4_1.subtract(totalBonus); - // 前面累计的奖金 - totalBonus = RetailConstants.V3_V4_1; - } else if (EGrade.VIP.getValue() == targetGradeValue) { - // V4 推拿 4000,或者减去之前累计 - rangeBonusIncome = RetailConstants.V4_V4.subtract(totalBonus); - // 前面累计的奖金 - totalBonus = RetailConstants.V4_V4; - } else if (EGrade.S_VIP.getValue() == targetGradeValue) { - // V5 推拿 4160,或者减去之前累计 - rangeBonusIncome = RetailConstants.V5_V4.subtract(totalBonus); - // 前面累计的奖金 - totalBonus = RetailConstants.V5_V4; - } else if (EGrade.REGION.getValue() == targetGradeValue - || EGrade.DIRECTOR.getValue() == targetGradeValue) { - // V6、V7 推拿 4400,或者减去之前累计 - rangeBonusIncome = RetailConstants.V6_V7_V4.subtract(totalBonus); - // 前面累计的奖金 - totalBonus = RetailConstants.V6_V7_V4; - } else if (EGrade.COMPANY.getValue() == targetGradeValue) { - // V8 推拿 4800,或者减去之前累计 - rangeBonusIncome = RetailConstants.V8_V4.subtract(totalBonus); - // 前面累计的奖金 - totalBonus = RetailConstants.V8_V4; - } - // 前一级会员等级 - beforeGradeValue = targetGradeValue; - } else if (EGrade.MAKER.getValue() == beforeGradeValue - && EGrade.MAKER.getValue() == targetGradeValue) { - // 之前和现在都是合伙人,处理平级 - if (v3Count == 1) { - // V3第一平级 推拿 2400,或者减去之前累计 - rangeBonusIncome = RetailConstants.V3_V4_2.subtract(totalBonus); - // 前面累计的奖金 - totalBonus = RetailConstants.V3_V4_2; - v3Count++; - } else if (v3Count == 2) { - // V3第二平级 推拿 2600,或者减去之前累计 - rangeBonusIncome = RetailConstants.V3_V4_3.subtract(totalBonus); - // 前面累计的奖金 - totalBonus = RetailConstants.V3_V4_3; - v3Count++; - } - } - } else if (EGrade.REGION.getValue() == orderGradeValue) { - // 订单是区域代理 - if (targetGradeValue >= EGrade.VIP.getValue() && targetGradeValue > beforeGradeValue) { - // 博羚店主以上才有级差 并且 当前等级大于之前等级 - if (EGrade.VIP.getValue() == targetGradeValue) { - // 博羚店主 拿 50000 - rangeBonusIncome = RetailConstants.V4_V6.subtract(totalBonus); - // 前面累计的奖金 - totalBonus = RetailConstants.V4_V6; - } else if (EGrade.S_VIP.getValue() == targetGradeValue) { - // 高级店主 拿 52000,或者减去之前累计 - rangeBonusIncome = RetailConstants.V5_V6.subtract(totalBonus); - // 前面累计的奖金 - totalBonus = RetailConstants.V5_V6; - } else if (EGrade.REGION.getValue() == targetGradeValue - || EGrade.DIRECTOR.getValue() == targetGradeValue) { - // 区域代理、董事代理 拿 55000,或者减去之前累计 - rangeBonusIncome = RetailConstants.V6_V7_V6.subtract(totalBonus); - // 前面累计的奖金 - totalBonus = RetailConstants.V6_V7_V6; - } else if (EGrade.COMPANY.getValue() == targetGradeValue) { - // 总公司 拿 60000,或者减去之前累计 - rangeBonusIncome = RetailConstants.V8_V6.subtract(totalBonus); - // 前面累计的奖金 - totalBonus = RetailConstants.V8_V6; - } - // 前一级会员等级 - beforeGradeValue = targetGradeValue; + if (EGrade.HAI_FAN.getValue() == targetGradeValue) { + // 推荐人是 会员 + rangeBonusIncome = orderAmount.multiply(RetailConstants.RECOMMEND_HAI_FAN).setScale(4, BigDecimal.ROUND_HALF_UP); + } else if (EGrade.YOU_KE.getValue() == targetGradeValue) { + // 推荐人是 VIP + rangeBonusIncome = orderAmount.multiply(RetailConstants.RECOMMEND_YOU_KE).subtract(totalBonus).setScale(4, BigDecimal.ROUND_HALF_UP); + } else if (EGrade.MAKER.getValue() == targetGradeValue) { + // 推荐人是 合伙人 + if (v3Count == 1) { + rangeBonusIncome = orderAmount.multiply(RetailConstants.RECOMMEND_MAKER_1).subtract(totalBonus).setScale(4, BigDecimal.ROUND_HALF_UP); + } else if (v3Count == 2) { + rangeBonusIncome = orderAmount.multiply(RetailConstants.RECOMMEND_MAKER_2).subtract(totalBonus).setScale(4, BigDecimal.ROUND_HALF_UP); + } else if (v3Count == 3) { + rangeBonusIncome = orderAmount.multiply(RetailConstants.RECOMMEND_MAKER_3).subtract(totalBonus).setScale(4, BigDecimal.ROUND_HALF_UP); } + v3Count++; + } else if (EGrade.VIP.getValue() == targetGradeValue) { + // 推荐人是 博羚店主 + rangeBonusIncome = orderAmount.multiply(RetailConstants.RECOMMEND_VIP).subtract(totalBonus).setScale(4, BigDecimal.ROUND_HALF_UP); + } else if (EGrade.S_VIP.getValue() == targetGradeValue) { + // 推荐人是 高级店主 + rangeBonusIncome = orderAmount.multiply(RetailConstants.RECOMMEND_S_VIP).subtract(totalBonus).setScale(4, BigDecimal.ROUND_HALF_UP); + } else if (EGrade.REGION.getValue() == targetGradeValue) { + // 推荐人是 区域代理 + rangeBonusIncome = orderAmount.multiply(RetailConstants.RECOMMEND_REGION).subtract(totalBonus).setScale(4, BigDecimal.ROUND_HALF_UP); + } else if (EGrade.DIRECTOR.getValue() == targetGradeValue) { + // 推荐人是 董事代理 + rangeBonusIncome = orderAmount.multiply(RetailConstants.RECOMMEND_DIRECTOR).subtract(totalBonus).setScale(4, BigDecimal.ROUND_HALF_UP); + } else if (EGrade.COMPANY.getValue() == targetGradeValue) { + // 推荐人是 总公司 + rangeBonusIncome = orderAmount.multiply(RetailConstants.RECOMMEND_COMPANY).subtract(totalBonus).setScale(4, BigDecimal.ROUND_HALF_UP); } + // 已经算完级差等级的累计奖金 + totalBonus = totalBonus.add(rangeBonusIncome); + // 前一级会员等级 + beforeGradeValue = targetGradeValue; if (rangeBonusIncome.compareTo(BigDecimal.ZERO) > 0) { // 处理直推级差收益 diff --git a/bd-common/bd-common-core/src/main/java/com/hzs/common/core/constant/RetailConstants.java b/bd-common/bd-common-core/src/main/java/com/hzs/common/core/constant/RetailConstants.java index 5d930363..f9d9d0ff 100644 --- a/bd-common/bd-common-core/src/main/java/com/hzs/common/core/constant/RetailConstants.java +++ b/bd-common/bd-common-core/src/main/java/com/hzs/common/core/constant/RetailConstants.java @@ -14,6 +14,30 @@ public class RetailConstants { */ public static final Integer PICK_BASE = 4; + /** + * 2025.08.21 直推级差金额比例 + * 会员 - 15% + * VIP - 20% + * 合伙人1 - 25% + * 合伙人2 - 30% + * 合伙人3 - 32.5% + * 博羚店主 - 50% + * 高级店主 - 52% + * 区域代理 - 55% + * 董事代理 - 55% + * 总公司 - 60% + */ + public static final BigDecimal RECOMMEND_HAI_FAN = new BigDecimal("0.15"); + public static final BigDecimal RECOMMEND_YOU_KE = new BigDecimal("0.2"); + public static final BigDecimal RECOMMEND_MAKER_1 = new BigDecimal("0.25"); + public static final BigDecimal RECOMMEND_MAKER_2 = new BigDecimal("0.3"); + public static final BigDecimal RECOMMEND_MAKER_3 = new BigDecimal("0.325"); + public static final BigDecimal RECOMMEND_VIP = new BigDecimal("0.5"); + public static final BigDecimal RECOMMEND_S_VIP = new BigDecimal("0.5"); + public static final BigDecimal RECOMMEND_REGION = new BigDecimal("0.55"); + public static final BigDecimal RECOMMEND_DIRECTOR = new BigDecimal("0.55"); + public static final BigDecimal RECOMMEND_COMPANY = new BigDecimal("0.6"); + /** * 2025.08.13 添加分公司级差收益,每1盒(4个产品) * 第一分公司4元 -- 区域代理 @@ -24,94 +48,6 @@ public class RetailConstants { public static final BigDecimal BRANCH = new BigDecimal("4"); public static final BigDecimal COMPANY_TOTAL = new BigDecimal("14"); - - /** - * 会员 推 会员 30 - * VIP 推 会员 40 - * 合伙人 推 会员 50 - * 博羚店主 推 会员 100 - * 高级店主 推 会员 104 - * 区域代理、董事代理 推 会员 110 - * 总公司 推 会员 120 - */ - public static final BigDecimal V1_V1 = new BigDecimal("30"); - public static final BigDecimal V2_V1 = new BigDecimal("40"); - public static final BigDecimal V3_V1 = new BigDecimal("50"); - public static final BigDecimal V4_V1 = new BigDecimal("100"); - public static final BigDecimal V5_V1 = new BigDecimal("104"); - public static final BigDecimal V6_V7_V1 = new BigDecimal("110"); - public static final BigDecimal V8_V1 = new BigDecimal("120"); - - /** - * 会员 推 VIP 300 - * VIP 推 VIP 400 - * 合伙人 推 VIP 500 - * 博羚店主 推 VIP 1000 - * 高级店主 推 VIP 1040 - * 区域代理、董事代理 推 VIP 1100 - * 总公司 推 VIP 1200 - */ - public static final BigDecimal V1_V2 = new BigDecimal("300"); - public static final BigDecimal V2_V2 = new BigDecimal("400"); - public static final BigDecimal V3_V2 = new BigDecimal("500"); - public static final BigDecimal V4_V2 = new BigDecimal("1000"); - public static final BigDecimal V5_V2 = new BigDecimal("1040"); - public static final BigDecimal V6_V7_V2 = new BigDecimal("1100"); - public static final BigDecimal V8_V2 = new BigDecimal("1200"); - - /** - * 会员 推 合伙人 600 - * VIP 推 合伙人 800 - * 合伙人1 推 合伙人 1000 - * 合伙人2 推 合伙人 1200 - * 合伙人3 推 合伙人 1300 - * 博羚店主 推 合伙人 2000 - * 高级店主 推 合伙人 2080 - * 区域代理、董事代理 推 合伙人 2200 - * 总公司 推 合伙人 2400 - */ - public static final BigDecimal V1_V3 = new BigDecimal("600"); - public static final BigDecimal V2_V3 = new BigDecimal("800"); - public static final BigDecimal V3_V3_1 = new BigDecimal("1000"); - public static final BigDecimal V3_V3_2 = new BigDecimal("1200"); - public static final BigDecimal V3_V3_3 = new BigDecimal("1300"); - public static final BigDecimal V4_V3 = new BigDecimal("2000"); - public static final BigDecimal V5_V3 = new BigDecimal("2080"); - public static final BigDecimal V6_V7_V3 = new BigDecimal("2200"); - public static final BigDecimal V8_V3 = new BigDecimal("2400"); - - /** - * 会员 推 博羚店主 1200 - * VIP 推 博羚店主 1600 - * 合伙人1 推 博羚店主 2000 - * 合伙人2 推 博羚店主 2400 - * 合伙人3 推 博羚店主 2600 - * 博羚店主 推 博羚店主 4000 - * 高级店主 推 博羚店主 4160 - * 区域代理、董事代理 推 博羚店主 4400 - * 总公司 推 博羚店主 4800 - */ - public static final BigDecimal V1_V4 = new BigDecimal("1200"); - public static final BigDecimal V2_V4 = new BigDecimal("1600"); - public static final BigDecimal V3_V4_1 = new BigDecimal("2000"); - public static final BigDecimal V3_V4_2 = new BigDecimal("2400"); - public static final BigDecimal V3_V4_3 = new BigDecimal("2600"); - public static final BigDecimal V4_V4 = new BigDecimal("4000"); - public static final BigDecimal V5_V4 = new BigDecimal("4160"); - public static final BigDecimal V6_V7_V4 = new BigDecimal("4400"); - public static final BigDecimal V8_V4 = new BigDecimal("4800"); - - /** - * 博羚店主 推 分公司 50000 - * 高级店主 推 分公司 52000 - * 区域代理、董事代理 推 分公司 55000 - * 总公司 推 分公司 60000 - */ - public static final BigDecimal V4_V6 = new BigDecimal("50000"); - public static final BigDecimal V5_V6 = new BigDecimal("52000"); - public static final BigDecimal V6_V7_V6 = new BigDecimal("55000"); - public static final BigDecimal V8_V6 = new BigDecimal("60000"); - /** * 复购: * 会员 拿 6