3
0
Fork 0

## 直推级差等级固定比例进行计算;

This commit is contained in:
cabbage 2025-08-21 11:49:15 +08:00
parent 07e886c5c2
commit 8ad1f1a942
2 changed files with 66 additions and 344 deletions

View File

@ -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) {
// V6V7 推拿 110 或者减去之前累计
// 前一等级不是V6V7
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) {
// V6V7 推拿 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) {
// V6V7 推拿 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) {
// V6V7 推拿 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) {
// 处理直推级差收益

View File

@ -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