|
|
|
@ -26,7 +26,9 @@ import java.util.HashMap; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 会员等级贡献 |
|
|
|
|
* @className: BsUserContributeServiceImpl |
|
|
|
|
* @author: HuRui |
|
|
|
|
* @date: 2024/9/12 |
|
|
|
@ -55,7 +57,7 @@ public class BsUserContributeServiceImpl implements BsUserContributeService { |
|
|
|
|
// 元宝汇率
|
|
|
|
|
BigDecimal goldCoinExchangeRate = new BigDecimal(secDictionaryService.getDictionary("GOLD_COIN_EXCHANGE_RATE").get(0).getCodeValue()); |
|
|
|
|
// 获得元宝数量 (返利金额 * 元宝汇率) * 等级自购奖励比例
|
|
|
|
|
BigDecimal goldCoin = (rebateAmount.multiply(goldCoinExchangeRate)).multiply(selfPurchaseReward).setScale(6, BigDecimal.ROUND_HALF_DOWN); |
|
|
|
|
BigDecimal goldCoin = (rebateAmount.multiply(goldCoinExchangeRate)).multiply(selfPurchaseReward.divide(new BigDecimal("100"))).setScale(6, BigDecimal.ROUND_HALF_DOWN); |
|
|
|
|
|
|
|
|
|
Map<String, Object> userRechargeParam = new HashMap<>(); |
|
|
|
|
userRechargeParam.put("sourceId", MapUtils.getLong(otherParam, "sourceId")); |
|
|
|
@ -67,18 +69,28 @@ public class BsUserContributeServiceImpl implements BsUserContributeService { |
|
|
|
|
// 查询用户上级
|
|
|
|
|
BsUserParentRel parentRel = userParentRelService.getDetailByUserId(userId); |
|
|
|
|
if (parentRel != null && parentRel.getParentUserId() != null) { |
|
|
|
|
// 购买用户等级是渠道,贡献时只能贡献给 渠道等级
|
|
|
|
|
if (UserGradeEnum.grade4.getCode().equals(user.getGrade())) { |
|
|
|
|
// 渠道
|
|
|
|
|
parentGrade4(UserGradeEnum.getDataByType(user.getGrade()), rebateAmount, parentRel, otherParam); |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
if (UserGradeEnum.grade4.getCode().equals(parentRel.getParentUserGrade())) { |
|
|
|
|
// 渠道
|
|
|
|
|
parentGrade4(UserGradeEnum.grade4, rebateAmount, parentRel, otherParam); |
|
|
|
|
parentGrade4(UserGradeEnum.getDataByType(user.getGrade()), rebateAmount, parentRel, otherParam); |
|
|
|
|
|
|
|
|
|
} else if (UserGradeEnum.grade3.getCode().equals(parentRel.getParentUserGrade())) { |
|
|
|
|
// 团长
|
|
|
|
|
parentGrade4(UserGradeEnum.grade4, rebateAmount, parentRel, otherParam); |
|
|
|
|
parentGrade3(UserGradeEnum.getDataByType(user.getGrade()), rebateAmount, parentRel, otherParam); |
|
|
|
|
|
|
|
|
|
} else if (UserGradeEnum.grade2.getCode().equals(parentRel.getParentUserGrade())) { |
|
|
|
|
// 正式会员
|
|
|
|
|
parentGrade2(UserGradeEnum.getDataByType(user.getGrade()), rebateAmount, parentRel, otherParam); |
|
|
|
|
|
|
|
|
|
} else if (UserGradeEnum.grade1.getCode().equals(parentRel.getParentUserGrade())) { |
|
|
|
|
// 见习会员
|
|
|
|
|
parentGrade1(UserGradeEnum.getDataByType(user.getGrade()), rebateAmount, parentRel, otherParam); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -87,31 +99,49 @@ public class BsUserContributeServiceImpl implements BsUserContributeService { |
|
|
|
|
* 渠道 |
|
|
|
|
*/ |
|
|
|
|
public void parentGrade4(UserGradeEnum userGrade,BigDecimal rebateAmount,BsUserParentRel parentRel,Map<String,Object> otherParam) throws Exception { |
|
|
|
|
Map<String, Object> parentUserParam = new HashMap<>(); |
|
|
|
|
parentUserParam.put("sourceId", MapUtils.getString(otherParam, "sourceId")); |
|
|
|
|
parentUserParam.put("sourceOrderNo", MapUtils.getString(otherParam, "sourceOrderNo")); |
|
|
|
|
// 元宝汇率
|
|
|
|
|
BigDecimal goldCoinExchangeRate = new BigDecimal(secDictionaryService.getDictionary("GOLD_COIN_EXCHANGE_RATE").get(0).getCodeValue()); |
|
|
|
|
|
|
|
|
|
// 直属贡献比例
|
|
|
|
|
BigDecimal directlyContributeRate = new BigDecimal("0"); |
|
|
|
|
|
|
|
|
|
if (UserGradeEnum.grade1.getCode().equals(userGrade.getCode()) || UserGradeEnum.grade2.getCode().equals(userGrade.getCode())) { |
|
|
|
|
if (UserGradeEnum.grade1.getCode().equals(userGrade.getCode()) |
|
|
|
|
|| UserGradeEnum.grade2.getCode().equals(userGrade.getCode())) { |
|
|
|
|
directlyContributeRate = new BigDecimal("100"); |
|
|
|
|
parentUserParam.put("sourceContent", "直属会员贡献"); |
|
|
|
|
|
|
|
|
|
} else if (UserGradeEnum.grade3.getCode().equals(userGrade.getCode())) { |
|
|
|
|
directlyContributeRate = new BigDecimal("23"); |
|
|
|
|
parentUserParam.put("sourceContent", "直属团长团队贡献"); |
|
|
|
|
|
|
|
|
|
} else if (UserGradeEnum.grade4.getCode().equals(userGrade.getCode())) { |
|
|
|
|
directlyContributeRate = new BigDecimal("9"); |
|
|
|
|
parentUserParam.put("sourceContent", "直属渠道团队贡献"); |
|
|
|
|
|
|
|
|
|
if (!UserGradeEnum.grade4.getCode().equals(parentRel.getParentUserGrade())) { |
|
|
|
|
// 递归判断找到渠道
|
|
|
|
|
parentRel = userParentRelService.getParent(Arrays.asList(UserGradeEnum.grade4), parentRel.getParentUserId()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// 直属贡献 = (返利金额 * 元宝汇率) * 直属贡献
|
|
|
|
|
BigDecimal goldCoin = (rebateAmount.multiply(goldCoinExchangeRate)) |
|
|
|
|
.multiply(directlyContributeRate.divide(new BigDecimal("100"))) |
|
|
|
|
.setScale(6, BigDecimal.ROUND_HALF_DOWN); |
|
|
|
|
|
|
|
|
|
Map<String, Object> parentUserParam = new HashMap<>(); |
|
|
|
|
parentUserParam.put("sourceId", MapUtils.getString(otherParam, "sourceId")); |
|
|
|
|
parentUserParam.put("sourceOrderNo", MapUtils.getString(otherParam, "sourceOrderNo")); |
|
|
|
|
parentUserParam.put("sourceContent", "直属会员贡献"); |
|
|
|
|
if (parentRel != null) { |
|
|
|
|
// 上级账户
|
|
|
|
|
userAccountService.recharge(parentRel.getParentUserId(), goldCoin, UserAccountRecordSourceTypeEnum.type1, parentUserParam); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 直属贡献比例 9%
|
|
|
|
|
// 渠道用户购买无需再进行贡献
|
|
|
|
|
if (!UserGradeEnum.grade4.getCode().equals(userGrade.getCode())) { |
|
|
|
|
// 递归判断找到渠道
|
|
|
|
|
BsUserParentRel channel = userParentRelService.getParent(Arrays.asList(UserGradeEnum.grade4), parentRel.getParentUserId()); |
|
|
|
|
if (channel != null) { |
|
|
|
|
// 贡献比例 9%
|
|
|
|
|
directlyContributeRate = new BigDecimal("9"); |
|
|
|
|
// 直属贡献 = (返利金额 * 元宝汇率) * 直属贡献
|
|
|
|
|
// 贡献 = (返利金额 * 元宝汇率) * 直属贡献
|
|
|
|
|
goldCoin = (rebateAmount.multiply(goldCoinExchangeRate)) |
|
|
|
|
.multiply(directlyContributeRate.divide(new BigDecimal("100"))) |
|
|
|
|
.setScale(6, BigDecimal.ROUND_HALF_DOWN); |
|
|
|
@ -121,39 +151,51 @@ public class BsUserContributeServiceImpl implements BsUserContributeService { |
|
|
|
|
parentUserParam.put("sourceOrderNo", MapUtils.getString(otherParam, "sourceOrderNo")); |
|
|
|
|
parentUserParam.put("sourceContent", "直属渠道团队贡献"); |
|
|
|
|
// 渠道账户
|
|
|
|
|
userAccountService.recharge(parentRel.getParentUserId(), goldCoin, UserAccountRecordSourceTypeEnum.type1, parentUserParam); |
|
|
|
|
userAccountService.recharge(channel.getParentUserId(), goldCoin, UserAccountRecordSourceTypeEnum.type1, parentUserParam); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 团长 |
|
|
|
|
*/ |
|
|
|
|
public void parentGrade3(UserGradeEnum userGrade,BigDecimal rebateAmount,BsUserParentRel parentRel,Map<String,Object> otherParam) throws Exception { |
|
|
|
|
Map<String,Object> parentUserParam = new HashMap<>(); |
|
|
|
|
parentUserParam.put("sourceId", MapUtils.getString(otherParam, "sourceId")); |
|
|
|
|
parentUserParam.put("sourceOrderNo", MapUtils.getString(otherParam, "sourceOrderNo")); |
|
|
|
|
|
|
|
|
|
// 元宝汇率
|
|
|
|
|
BigDecimal goldCoinExchangeRate = new BigDecimal(secDictionaryService.getDictionary("GOLD_COIN_EXCHANGE_RATE").get(0).getCodeValue()); |
|
|
|
|
// 直属贡献比例
|
|
|
|
|
BigDecimal directlyContributeRate = new BigDecimal("0"); |
|
|
|
|
|
|
|
|
|
if (UserGradeEnum.grade1.getCode().equals(userGrade.getCode()) || UserGradeEnum.grade2.getCode().equals(userGrade.getCode())) { |
|
|
|
|
if (UserGradeEnum.grade1.getCode().equals(userGrade.getCode()) |
|
|
|
|
|| UserGradeEnum.grade2.getCode().equals(userGrade.getCode())) { |
|
|
|
|
directlyContributeRate = new BigDecimal("66.6"); |
|
|
|
|
parentUserParam.put("sourceContent", "直属会员贡献"); |
|
|
|
|
|
|
|
|
|
} else if (UserGradeEnum.grade3.getCode().equals(userGrade.getCode())) { |
|
|
|
|
directlyContributeRate = new BigDecimal("10"); |
|
|
|
|
parentUserParam.put("sourceContent", "直属团长团队贡献"); |
|
|
|
|
} |
|
|
|
|
// 直属贡献 = (返利金额 * 元宝汇率) * 直属贡献
|
|
|
|
|
BigDecimal goldCoin = (rebateAmount.multiply(goldCoinExchangeRate)) |
|
|
|
|
.multiply(directlyContributeRate.divide(new BigDecimal("100"))) |
|
|
|
|
.setScale(6, BigDecimal.ROUND_HALF_DOWN); |
|
|
|
|
Map<String,Object> parentUserParam = new HashMap<>(); |
|
|
|
|
parentUserParam.put("sourceId", MapUtils.getString(otherParam, "sourceId")); |
|
|
|
|
parentUserParam.put("sourceOrderNo", MapUtils.getString(otherParam, "sourceOrderNo")); |
|
|
|
|
parentUserParam.put("sourceContent", "直属会员贡献"); |
|
|
|
|
|
|
|
|
|
// 上级账户
|
|
|
|
|
userAccountService.recharge(parentRel.getParentUserId(), goldCoin, UserAccountRecordSourceTypeEnum.type1, parentUserParam); |
|
|
|
|
|
|
|
|
|
// 购买商品用户等级
|
|
|
|
|
if (UserGradeEnum.grade1.getCode().equals(userGrade.getCode()) || UserGradeEnum.grade2.getCode().equals(userGrade.getCode())) { |
|
|
|
|
// 递归判断找到团长或渠道
|
|
|
|
|
BsUserParentRel userParentRel = userParentRelService.getParent( |
|
|
|
|
Arrays.asList(UserGradeEnum.grade4, UserGradeEnum.grade3), |
|
|
|
|
parentRel.getParentUserId() |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
// 团长或渠道
|
|
|
|
|
if (userParentRel != null) { |
|
|
|
|
// 团长
|
|
|
|
|
if (UserGradeEnum.grade3.getCode().equals(userParentRel.getParentUserGrade())) { |
|
|
|
|
// 贡献比例 10%
|
|
|
|
|
directlyContributeRate = new BigDecimal("10"); |
|
|
|
@ -162,12 +204,12 @@ public class BsUserContributeServiceImpl implements BsUserContributeService { |
|
|
|
|
.multiply(directlyContributeRate.divide(new BigDecimal("100"))) |
|
|
|
|
.setScale(6, BigDecimal.ROUND_HALF_DOWN); |
|
|
|
|
// 渠道贡献
|
|
|
|
|
otherParam.clear(); |
|
|
|
|
otherParam.put("sourceId", ""); |
|
|
|
|
otherParam.put("sourceOrderNo", ""); |
|
|
|
|
otherParam.put("sourceContent", "直属团长贡献"); |
|
|
|
|
parentUserParam.clear(); |
|
|
|
|
parentUserParam.put("sourceId", MapUtils.getString(otherParam, "sourceId")); |
|
|
|
|
parentUserParam.put("sourceOrderNo", MapUtils.getString(otherParam, "sourceOrderNo")); |
|
|
|
|
parentUserParam.put("sourceContent", "直属团长团队贡献"); |
|
|
|
|
// 团长账户
|
|
|
|
|
userAccountService.recharge(userParentRel.getUserId(), goldCoin, UserAccountRecordSourceTypeEnum.type1, otherParam); |
|
|
|
|
userAccountService.recharge(userParentRel.getUserId(), goldCoin, UserAccountRecordSourceTypeEnum.type1, parentUserParam); |
|
|
|
|
|
|
|
|
|
// 递归判断找到渠道
|
|
|
|
|
userParentRel = userParentRelService.getParent(Arrays.asList(UserGradeEnum.grade4), parentRel.getParentUserId()); |
|
|
|
@ -179,16 +221,47 @@ public class BsUserContributeServiceImpl implements BsUserContributeService { |
|
|
|
|
.multiply(directlyContributeRate.divide(new BigDecimal("100"))) |
|
|
|
|
.setScale(6, BigDecimal.ROUND_HALF_DOWN); |
|
|
|
|
// 渠道贡献
|
|
|
|
|
otherParam.clear(); |
|
|
|
|
otherParam.put("sourceId", ""); |
|
|
|
|
otherParam.put("sourceOrderNo", ""); |
|
|
|
|
otherParam.put("sourceContent", "非直属团长团队贡献"); |
|
|
|
|
parentUserParam.clear(); |
|
|
|
|
parentUserParam.put("sourceId", MapUtils.getString(otherParam, "sourceId")); |
|
|
|
|
parentUserParam.put("sourceOrderNo", MapUtils.getString(otherParam, "sourceOrderNo")); |
|
|
|
|
parentUserParam.put("sourceContent", "非直属团长团队贡献"); |
|
|
|
|
// 团长账户
|
|
|
|
|
userAccountService.recharge(userParentRel.getUserId(), goldCoin, UserAccountRecordSourceTypeEnum.type1, otherParam); |
|
|
|
|
userAccountService.recharge(userParentRel.getParentUserId(), goldCoin, UserAccountRecordSourceTypeEnum.type1, parentUserParam); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} else if (UserGradeEnum.grade4.getCode().equals(userParentRel.getParentUserGrade())) { |
|
|
|
|
// 递归找到团长
|
|
|
|
|
// 贡献比例 23%
|
|
|
|
|
directlyContributeRate = new BigDecimal("23"); |
|
|
|
|
// 贡献 = (返利金额 * 元宝汇率) * 直属贡献
|
|
|
|
|
goldCoin = (rebateAmount.multiply(goldCoinExchangeRate)) |
|
|
|
|
.multiply(directlyContributeRate.divide(new BigDecimal("100"))) |
|
|
|
|
.setScale(6, BigDecimal.ROUND_HALF_DOWN); |
|
|
|
|
// 渠道贡献
|
|
|
|
|
parentUserParam.clear(); |
|
|
|
|
parentUserParam.put("sourceId", MapUtils.getString(otherParam, "sourceId")); |
|
|
|
|
parentUserParam.put("sourceOrderNo", MapUtils.getString(otherParam, "sourceOrderNo")); |
|
|
|
|
parentUserParam.put("sourceContent", "直属团长团队贡献"); |
|
|
|
|
// 渠道账户
|
|
|
|
|
userAccountService.recharge(userParentRel.getParentUserId(), goldCoin, UserAccountRecordSourceTypeEnum.type1, parentUserParam); |
|
|
|
|
|
|
|
|
|
// 递归判断找到渠道
|
|
|
|
|
BsUserParentRel channel = userParentRelService.getParent(Arrays.asList(UserGradeEnum.grade4), userParentRel.getParentUserId()); |
|
|
|
|
if (channel != null) { |
|
|
|
|
// 贡献比例 9%
|
|
|
|
|
directlyContributeRate = new BigDecimal("9"); |
|
|
|
|
// 贡献 = (返利金额 * 元宝汇率) * 直属贡献
|
|
|
|
|
goldCoin = (rebateAmount.multiply(goldCoinExchangeRate)) |
|
|
|
|
.multiply(directlyContributeRate.divide(new BigDecimal("100"))) |
|
|
|
|
.setScale(6, BigDecimal.ROUND_HALF_DOWN); |
|
|
|
|
// 渠道贡献
|
|
|
|
|
parentUserParam.clear(); |
|
|
|
|
parentUserParam.put("sourceId", MapUtils.getString(otherParam, "sourceId")); |
|
|
|
|
parentUserParam.put("sourceOrderNo", MapUtils.getString(otherParam, "sourceOrderNo")); |
|
|
|
|
parentUserParam.put("sourceContent", "直属渠道团队贡献"); |
|
|
|
|
// 渠道账户
|
|
|
|
|
userAccountService.recharge(channel.getParentUserId(), goldCoin, UserAccountRecordSourceTypeEnum.type1, parentUserParam); |
|
|
|
|
} |
|
|
|
|
/* // 递归找到团长
|
|
|
|
|
BsUserParentRel teamLeader = userParentRelService.getParent(Arrays.asList(UserGradeEnum.grade3), parentRel.getParentUserId()); |
|
|
|
|
if (teamLeader != null) { |
|
|
|
|
// 贡献比例 2 3%
|
|
|
|
@ -198,14 +271,187 @@ public class BsUserContributeServiceImpl implements BsUserContributeService { |
|
|
|
|
.multiply(directlyContributeRate.divide(new BigDecimal("100"))) |
|
|
|
|
.setScale(6, BigDecimal.ROUND_HALF_DOWN); |
|
|
|
|
// 贡献
|
|
|
|
|
otherParam.clear(); |
|
|
|
|
otherParam.put("sourceId", ""); |
|
|
|
|
otherParam.put("sourceOrderNo", ""); |
|
|
|
|
otherParam.put("sourceContent", "直属团长团队贡献"); |
|
|
|
|
parentUserParam.clear(); |
|
|
|
|
parentUserParam.put("sourceId", MapUtils.getString(otherParam, "sourceId")); |
|
|
|
|
parentUserParam.put("sourceOrderNo", MapUtils.getString(otherParam, "sourceOrderNo")); |
|
|
|
|
parentUserParam.put("sourceContent", "直属团长团队贡献"); |
|
|
|
|
// 团长账户
|
|
|
|
|
userAccountService.recharge(teamLeader.getUserId(), goldCoin, UserAccountRecordSourceTypeEnum.type1, otherParam); |
|
|
|
|
userAccountService.recharge(teamLeader.getParentUserId(), goldCoin, UserAccountRecordSourceTypeEnum.type1, parentUserParam); |
|
|
|
|
|
|
|
|
|
// 贡献比例 9%
|
|
|
|
|
directlyContributeRate = new BigDecimal("9"); |
|
|
|
|
// 贡献 = (返利金额 * 元宝汇率) * 直属贡献
|
|
|
|
|
goldCoin = (rebateAmount.multiply(goldCoinExchangeRate)) |
|
|
|
|
.multiply(directlyContributeRate.divide(new BigDecimal("100"))) |
|
|
|
|
.setScale(6, BigDecimal.ROUND_HALF_DOWN); |
|
|
|
|
// 贡献
|
|
|
|
|
parentUserParam.clear(); |
|
|
|
|
parentUserParam.put("sourceId", MapUtils.getString(otherParam, "sourceId")); |
|
|
|
|
parentUserParam.put("sourceOrderNo", MapUtils.getString(otherParam, "sourceOrderNo")); |
|
|
|
|
parentUserParam.put("sourceContent", "直属渠道团队贡献"); |
|
|
|
|
// 渠道账户
|
|
|
|
|
userAccountService.recharge(userParentRel.getParentUserId(), goldCoin, UserAccountRecordSourceTypeEnum.type1, parentUserParam); |
|
|
|
|
}*/ |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else if (UserGradeEnum.grade3.getCode().equals(userGrade.getCode())) { |
|
|
|
|
// 递归判断找到渠道
|
|
|
|
|
BsUserParentRel userParentRel = userParentRelService.getParent(Arrays.asList(UserGradeEnum.grade4),parentRel.getParentUserId()); |
|
|
|
|
if (userParentRel != null) { |
|
|
|
|
// 贡献比例 10%
|
|
|
|
|
directlyContributeRate = new BigDecimal("13"); |
|
|
|
|
// 贡献 = (返利金额 * 元宝汇率) * 直属贡献
|
|
|
|
|
goldCoin = (rebateAmount.multiply(goldCoinExchangeRate)) |
|
|
|
|
.multiply(directlyContributeRate.divide(new BigDecimal("100"))) |
|
|
|
|
.setScale(6, BigDecimal.ROUND_HALF_DOWN); |
|
|
|
|
// 渠道贡献
|
|
|
|
|
parentUserParam.clear(); |
|
|
|
|
parentUserParam.put("sourceId", MapUtils.getString(otherParam, "sourceId")); |
|
|
|
|
parentUserParam.put("sourceOrderNo", MapUtils.getString(otherParam, "sourceOrderNo")); |
|
|
|
|
parentUserParam.put("sourceContent", "非直属团长团队贡献"); |
|
|
|
|
// 渠道账户
|
|
|
|
|
userAccountService.recharge(userParentRel.getParentUserId(), goldCoin, UserAccountRecordSourceTypeEnum.type1, parentUserParam); |
|
|
|
|
|
|
|
|
|
// 递归判断找到渠道
|
|
|
|
|
BsUserParentRel channel = userParentRelService.getParent(Arrays.asList(UserGradeEnum.grade4), userParentRel.getParentUserId()); |
|
|
|
|
if (channel != null) { |
|
|
|
|
// 贡献比例 9%
|
|
|
|
|
directlyContributeRate = new BigDecimal("9"); |
|
|
|
|
// 贡献 = (返利金额 * 元宝汇率) * 直属贡献
|
|
|
|
|
goldCoin = (rebateAmount.multiply(goldCoinExchangeRate)) |
|
|
|
|
.multiply(directlyContributeRate.divide(new BigDecimal("100"))) |
|
|
|
|
.setScale(6, BigDecimal.ROUND_HALF_DOWN); |
|
|
|
|
// 渠道贡献
|
|
|
|
|
parentUserParam.clear(); |
|
|
|
|
parentUserParam.put("sourceId", MapUtils.getString(otherParam, "sourceId")); |
|
|
|
|
parentUserParam.put("sourceOrderNo", MapUtils.getString(otherParam, "sourceOrderNo")); |
|
|
|
|
parentUserParam.put("sourceContent", "直属渠道团队贡献"); |
|
|
|
|
// 团长账户
|
|
|
|
|
userAccountService.recharge(channel.getParentUserId(), goldCoin, UserAccountRecordSourceTypeEnum.type1, parentUserParam); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 元气会员 |
|
|
|
|
*/ |
|
|
|
|
public void parentGrade2(UserGradeEnum userGrade,BigDecimal rebateAmount,BsUserParentRel parentRel,Map<String,Object> otherParam) throws Exception { |
|
|
|
|
// 元宝汇率
|
|
|
|
|
BigDecimal goldCoinExchangeRate = new BigDecimal(secDictionaryService.getDictionary("GOLD_COIN_EXCHANGE_RATE").get(0).getCodeValue()); |
|
|
|
|
// 直属贡献比例
|
|
|
|
|
BigDecimal directlyContributeRate = new BigDecimal("0"); |
|
|
|
|
// 贡献元宝
|
|
|
|
|
BigDecimal goldCoin = new BigDecimal("0"); |
|
|
|
|
|
|
|
|
|
Map<String,Object> parentUserParam = new HashMap<>(); |
|
|
|
|
parentUserParam.put("sourceId", MapUtils.getString(otherParam, "sourceId")); |
|
|
|
|
parentUserParam.put("sourceOrderNo", MapUtils.getString(otherParam, "sourceOrderNo")); |
|
|
|
|
|
|
|
|
|
if (UserGradeEnum.grade1.getCode().equals(userGrade.getCode()) || UserGradeEnum.grade2.getCode().equals(userGrade.getCode())) { |
|
|
|
|
directlyContributeRate = new BigDecimal("45"); |
|
|
|
|
parentUserParam.put("sourceContent", "直属会员贡献"); |
|
|
|
|
|
|
|
|
|
// 直属贡献 = (返利金额 * 元宝汇率) * 直属贡献
|
|
|
|
|
goldCoin = (rebateAmount.multiply(goldCoinExchangeRate)) |
|
|
|
|
.multiply(directlyContributeRate.divide(new BigDecimal("100"))) |
|
|
|
|
.setScale(6, BigDecimal.ROUND_HALF_DOWN); |
|
|
|
|
|
|
|
|
|
// 上级账户
|
|
|
|
|
userAccountService.recharge(parentRel.getParentUserId(), goldCoin, UserAccountRecordSourceTypeEnum.type1, parentUserParam); |
|
|
|
|
} |
|
|
|
|
// 递归判断找到团长或渠道
|
|
|
|
|
BsUserParentRel userParentRel = userParentRelService.getParent( |
|
|
|
|
Arrays.asList(UserGradeEnum.grade4, UserGradeEnum.grade3), |
|
|
|
|
parentRel.getParentUserId() |
|
|
|
|
); |
|
|
|
|
// 团长或渠道
|
|
|
|
|
if (userParentRel != null) { |
|
|
|
|
// 团长
|
|
|
|
|
if (UserGradeEnum.grade3.getCode().equals(userParentRel.getParentUserGrade())) { |
|
|
|
|
parentUserParam.clear(); |
|
|
|
|
parentUserParam.put("sourceId", MapUtils.getString(otherParam, "sourceId")); |
|
|
|
|
parentUserParam.put("sourceOrderNo", MapUtils.getString(otherParam, "sourceOrderNo")); |
|
|
|
|
|
|
|
|
|
// 购买用户等级
|
|
|
|
|
if (UserGradeEnum.grade3.getCode().equals(userGrade.getCode())) { |
|
|
|
|
// 贡献比例 10%
|
|
|
|
|
directlyContributeRate = new BigDecimal("10"); |
|
|
|
|
parentUserParam.put("sourceContent", "直属团长团队贡献"); |
|
|
|
|
|
|
|
|
|
} else if (UserGradeEnum.grade1.getCode().equals(userGrade.getCode()) || UserGradeEnum.grade2.getCode().equals(userGrade.getCode())) { |
|
|
|
|
// 贡献比例 21.6%
|
|
|
|
|
directlyContributeRate = new BigDecimal("21.6"); |
|
|
|
|
parentUserParam.put("sourceContent", "非直属会员贡献"); |
|
|
|
|
} |
|
|
|
|
// 贡献 = (返利金额 * 元宝汇率) * 直属贡献
|
|
|
|
|
goldCoin = (rebateAmount.multiply(goldCoinExchangeRate)) |
|
|
|
|
.multiply(directlyContributeRate.divide(new BigDecimal("100"))) |
|
|
|
|
.setScale(6, BigDecimal.ROUND_HALF_DOWN); |
|
|
|
|
// 团长账户
|
|
|
|
|
userAccountService.recharge(userParentRel.getUserId(), goldCoin, UserAccountRecordSourceTypeEnum.type1, parentUserParam); |
|
|
|
|
|
|
|
|
|
// 递归判断找到渠道
|
|
|
|
|
BsUserParentRel channel = userParentRelService.getParent(Arrays.asList(UserGradeEnum.grade4), userParentRel.getParentUserId()); |
|
|
|
|
if (channel != null) { |
|
|
|
|
parentUserParam.clear(); |
|
|
|
|
parentUserParam.put("sourceId", MapUtils.getString(otherParam, "sourceId")); |
|
|
|
|
parentUserParam.put("sourceOrderNo", MapUtils.getString(otherParam, "sourceOrderNo")); |
|
|
|
|
|
|
|
|
|
// 购买用户等级
|
|
|
|
|
if (UserGradeEnum.grade3.getCode().equals(userGrade.getCode())) { |
|
|
|
|
// 贡献比例 13%
|
|
|
|
|
directlyContributeRate = new BigDecimal("13"); |
|
|
|
|
parentUserParam.put("sourceContent", "非直属团长团队贡献"); |
|
|
|
|
|
|
|
|
|
} else if (UserGradeEnum.grade1.getCode().equals(userGrade.getCode()) || UserGradeEnum.grade2.getCode().equals(userGrade.getCode())) { |
|
|
|
|
// 是否有团长
|
|
|
|
|
if (userParentRelService.getParent(Arrays.asList(UserGradeEnum.grade4), userParentRel.getParentUserId()) == null) { |
|
|
|
|
// 贡献比例 23%
|
|
|
|
|
directlyContributeRate = new BigDecimal("23"); |
|
|
|
|
parentUserParam.put("sourceContent", "直属团长团队贡献"); |
|
|
|
|
} else { |
|
|
|
|
// 贡献比例 13%
|
|
|
|
|
directlyContributeRate = new BigDecimal("13"); |
|
|
|
|
parentUserParam.put("sourceContent", "非直属团长团队贡献"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// 贡献 = (返利金额 * 元宝汇率) * 直属贡献
|
|
|
|
|
goldCoin = (rebateAmount.multiply(goldCoinExchangeRate)) |
|
|
|
|
.multiply(directlyContributeRate.divide(new BigDecimal("100"))) |
|
|
|
|
.setScale(6, BigDecimal.ROUND_HALF_DOWN); |
|
|
|
|
|
|
|
|
|
// 渠道账户
|
|
|
|
|
userAccountService.recharge(channel.getParentUserId(), goldCoin, UserAccountRecordSourceTypeEnum.type1, parentUserParam); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
else if (UserGradeEnum.grade4.getCode().equals(userParentRel.getParentUserGrade())) { |
|
|
|
|
parentUserParam.clear(); |
|
|
|
|
parentUserParam.put("sourceId", MapUtils.getString(otherParam, "sourceId")); |
|
|
|
|
parentUserParam.put("sourceOrderNo", MapUtils.getString(otherParam, "sourceOrderNo")); |
|
|
|
|
|
|
|
|
|
if (UserGradeEnum.grade4.getCode().equals(userGrade.getCode())) { |
|
|
|
|
// 贡献比例 23%
|
|
|
|
|
directlyContributeRate = new BigDecimal("23"); |
|
|
|
|
parentUserParam.put("sourceContent", "直属团长团队贡献"); |
|
|
|
|
|
|
|
|
|
} else if (UserGradeEnum.grade1.getCode().equals(userGrade.getCode()) || UserGradeEnum.grade2.getCode().equals(userGrade.getCode())) { |
|
|
|
|
// 贡献比例 55%
|
|
|
|
|
directlyContributeRate = new BigDecimal("55"); |
|
|
|
|
parentUserParam.put("sourceContent", "非直属会员贡献"); |
|
|
|
|
} |
|
|
|
|
// 贡献 = (返利金额 * 元宝汇率) * 直属贡献
|
|
|
|
|
goldCoin = (rebateAmount.multiply(goldCoinExchangeRate)) |
|
|
|
|
.multiply(directlyContributeRate.divide(new BigDecimal("100"))) |
|
|
|
|
.setScale(6, BigDecimal.ROUND_HALF_DOWN); |
|
|
|
|
// 渠道账户
|
|
|
|
|
userAccountService.recharge(userParentRel.getParentUserId(), goldCoin, UserAccountRecordSourceTypeEnum.type1, parentUserParam); |
|
|
|
|
|
|
|
|
|
// 递归判断渠道
|
|
|
|
|
BsUserParentRel channel = userParentRelService.getParent(Arrays.asList(UserGradeEnum.grade4), parentRel.getParentUserId()); |
|
|
|
|
if (channel != null) { |
|
|
|
|
// 贡献比例 9%
|
|
|
|
|
directlyContributeRate = new BigDecimal("9"); |
|
|
|
|
// 贡献 = (返利金额 * 元宝汇率) * 直属贡献
|
|
|
|
@ -213,16 +459,153 @@ public class BsUserContributeServiceImpl implements BsUserContributeService { |
|
|
|
|
.multiply(directlyContributeRate.divide(new BigDecimal("100"))) |
|
|
|
|
.setScale(6, BigDecimal.ROUND_HALF_DOWN); |
|
|
|
|
// 贡献
|
|
|
|
|
otherParam.clear(); |
|
|
|
|
otherParam.put("sourceId", ""); |
|
|
|
|
otherParam.put("sourceOrderNo", ""); |
|
|
|
|
otherParam.put("sourceContent", "直属渠道团队贡献"); |
|
|
|
|
parentUserParam.clear(); |
|
|
|
|
parentUserParam.put("sourceId", MapUtils.getString(otherParam, "sourceId")); |
|
|
|
|
parentUserParam.put("sourceOrderNo", MapUtils.getString(otherParam, "sourceOrderNo")); |
|
|
|
|
parentUserParam.put("sourceContent", "直属渠道团队贡献"); |
|
|
|
|
// 渠道账户
|
|
|
|
|
userAccountService.recharge(channel.getParentUserId(), goldCoin, UserAccountRecordSourceTypeEnum.type1, parentUserParam); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 见习会员 |
|
|
|
|
*/ |
|
|
|
|
public void parentGrade1(UserGradeEnum userGrade,BigDecimal rebateAmount,BsUserParentRel parentRel,Map<String,Object> otherParam) throws Exception { |
|
|
|
|
// 元宝汇率
|
|
|
|
|
BigDecimal goldCoinExchangeRate = new BigDecimal(secDictionaryService.getDictionary("GOLD_COIN_EXCHANGE_RATE").get(0).getCodeValue()); |
|
|
|
|
// 直属贡献比例
|
|
|
|
|
BigDecimal directlyContributeRate = new BigDecimal("0"); |
|
|
|
|
// 贡献元宝
|
|
|
|
|
BigDecimal goldCoin = new BigDecimal("0"); |
|
|
|
|
|
|
|
|
|
Map<String,Object> parentUserParam = new HashMap<>(); |
|
|
|
|
parentUserParam.put("sourceId", MapUtils.getString(otherParam, "sourceId")); |
|
|
|
|
parentUserParam.put("sourceOrderNo", MapUtils.getString(otherParam, "sourceOrderNo")); |
|
|
|
|
|
|
|
|
|
if (UserGradeEnum.grade1.getCode().equals(userGrade.getCode()) || UserGradeEnum.grade2.getCode().equals(userGrade.getCode())) { |
|
|
|
|
directlyContributeRate = new BigDecimal("18"); |
|
|
|
|
parentUserParam.put("sourceContent", "直属会员贡献"); |
|
|
|
|
|
|
|
|
|
// 直属贡献 = (返利金额 * 元宝汇率) * 直属贡献
|
|
|
|
|
goldCoin = (rebateAmount.multiply(goldCoinExchangeRate)) |
|
|
|
|
.multiply(directlyContributeRate.divide(new BigDecimal("100"))) |
|
|
|
|
.setScale(6, BigDecimal.ROUND_HALF_DOWN); |
|
|
|
|
|
|
|
|
|
// 上级账户
|
|
|
|
|
userAccountService.recharge(parentRel.getParentUserId(), goldCoin, UserAccountRecordSourceTypeEnum.type1, parentUserParam); |
|
|
|
|
} |
|
|
|
|
// 递归判断找到团长或渠道
|
|
|
|
|
BsUserParentRel userParentRel = userParentRelService.getParent( |
|
|
|
|
Arrays.asList(UserGradeEnum.grade4, UserGradeEnum.grade3), |
|
|
|
|
parentRel.getParentUserId() |
|
|
|
|
); |
|
|
|
|
// 团长或渠道
|
|
|
|
|
if (userParentRel != null) { |
|
|
|
|
// 团长
|
|
|
|
|
if (UserGradeEnum.grade3.getCode().equals(userParentRel.getParentUserGrade())) { |
|
|
|
|
parentUserParam.clear(); |
|
|
|
|
parentUserParam.put("sourceId", MapUtils.getString(otherParam, "sourceId")); |
|
|
|
|
parentUserParam.put("sourceOrderNo", MapUtils.getString(otherParam, "sourceOrderNo")); |
|
|
|
|
|
|
|
|
|
// 购买用户等级
|
|
|
|
|
if (UserGradeEnum.grade3.getCode().equals(userGrade.getCode())) { |
|
|
|
|
// 贡献比例 10%
|
|
|
|
|
directlyContributeRate = new BigDecimal("10"); |
|
|
|
|
parentUserParam.put("sourceContent", "直属团长团队贡献"); |
|
|
|
|
|
|
|
|
|
} else if (UserGradeEnum.grade1.getCode().equals(userGrade.getCode()) || UserGradeEnum.grade2.getCode().equals(userGrade.getCode())) { |
|
|
|
|
// 贡献比例 21.6%
|
|
|
|
|
directlyContributeRate = new BigDecimal("21.6"); |
|
|
|
|
parentUserParam.put("sourceContent", "非直属会员贡献"); |
|
|
|
|
} |
|
|
|
|
// 贡献 = (返利金额 * 元宝汇率) * 直属贡献
|
|
|
|
|
goldCoin = (rebateAmount.multiply(goldCoinExchangeRate)) |
|
|
|
|
.multiply(directlyContributeRate.divide(new BigDecimal("100"))) |
|
|
|
|
.setScale(6, BigDecimal.ROUND_HALF_DOWN); |
|
|
|
|
// 团长账户
|
|
|
|
|
userAccountService.recharge(userParentRel.getUserId(), goldCoin, UserAccountRecordSourceTypeEnum.type1, parentUserParam); |
|
|
|
|
|
|
|
|
|
// 递归判断找到渠道
|
|
|
|
|
BsUserParentRel channel = userParentRelService.getParent(Arrays.asList(UserGradeEnum.grade4), userParentRel.getParentUserId()); |
|
|
|
|
if (channel != null) { |
|
|
|
|
parentUserParam.clear(); |
|
|
|
|
parentUserParam.put("sourceId", MapUtils.getString(otherParam, "sourceId")); |
|
|
|
|
parentUserParam.put("sourceOrderNo", MapUtils.getString(otherParam, "sourceOrderNo")); |
|
|
|
|
|
|
|
|
|
// 购买用户等级
|
|
|
|
|
if (UserGradeEnum.grade3.getCode().equals(userGrade.getCode())) { |
|
|
|
|
// 贡献比例 13%
|
|
|
|
|
directlyContributeRate = new BigDecimal("13"); |
|
|
|
|
parentUserParam.put("sourceContent", "非直属团长团队贡献"); |
|
|
|
|
|
|
|
|
|
} else if (UserGradeEnum.grade1.getCode().equals(userGrade.getCode()) || UserGradeEnum.grade2.getCode().equals(userGrade.getCode())) { |
|
|
|
|
// 是否有团长
|
|
|
|
|
if (userParentRelService.getParent(Arrays.asList(UserGradeEnum.grade4), userParentRel.getParentUserId()) == null) { |
|
|
|
|
// 贡献比例 23%
|
|
|
|
|
directlyContributeRate = new BigDecimal("23"); |
|
|
|
|
parentUserParam.put("sourceContent", "直属团长团队贡献"); |
|
|
|
|
} else { |
|
|
|
|
// 贡献比例 13%
|
|
|
|
|
directlyContributeRate = new BigDecimal("13"); |
|
|
|
|
parentUserParam.put("sourceContent", "非直属团长团队贡献"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// 贡献 = (返利金额 * 元宝汇率) * 直属贡献
|
|
|
|
|
goldCoin = (rebateAmount.multiply(goldCoinExchangeRate)) |
|
|
|
|
.multiply(directlyContributeRate.divide(new BigDecimal("100"))) |
|
|
|
|
.setScale(6, BigDecimal.ROUND_HALF_DOWN); |
|
|
|
|
|
|
|
|
|
// 渠道账户
|
|
|
|
|
userAccountService.recharge(userParentRel.getUserId(), goldCoin, UserAccountRecordSourceTypeEnum.type1, otherParam); |
|
|
|
|
userAccountService.recharge(channel.getParentUserId(), goldCoin, UserAccountRecordSourceTypeEnum.type1, parentUserParam); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
else if (UserGradeEnum.grade4.getCode().equals(userParentRel.getParentUserGrade())) { |
|
|
|
|
parentUserParam.clear(); |
|
|
|
|
parentUserParam.put("sourceId", MapUtils.getString(otherParam, "sourceId")); |
|
|
|
|
parentUserParam.put("sourceOrderNo", MapUtils.getString(otherParam, "sourceOrderNo")); |
|
|
|
|
|
|
|
|
|
if (UserGradeEnum.grade4.getCode().equals(userGrade.getCode())) { |
|
|
|
|
// 贡献比例 23%
|
|
|
|
|
directlyContributeRate = new BigDecimal("23"); |
|
|
|
|
parentUserParam.put("sourceContent", "直属团长团队贡献"); |
|
|
|
|
|
|
|
|
|
} else if (UserGradeEnum.grade1.getCode().equals(userGrade.getCode()) || UserGradeEnum.grade2.getCode().equals(userGrade.getCode())) { |
|
|
|
|
// 贡献比例 55%
|
|
|
|
|
directlyContributeRate = new BigDecimal("55"); |
|
|
|
|
parentUserParam.put("sourceContent", "非直属会员贡献"); |
|
|
|
|
} |
|
|
|
|
// 贡献 = (返利金额 * 元宝汇率) * 直属贡献
|
|
|
|
|
goldCoin = (rebateAmount.multiply(goldCoinExchangeRate)) |
|
|
|
|
.multiply(directlyContributeRate.divide(new BigDecimal("100"))) |
|
|
|
|
.setScale(6, BigDecimal.ROUND_HALF_DOWN); |
|
|
|
|
// 渠道账户
|
|
|
|
|
userAccountService.recharge(userParentRel.getParentUserId(), goldCoin, UserAccountRecordSourceTypeEnum.type1, parentUserParam); |
|
|
|
|
|
|
|
|
|
// 递归判断渠道
|
|
|
|
|
BsUserParentRel channel = userParentRelService.getParent(Arrays.asList(UserGradeEnum.grade4), parentRel.getParentUserId()); |
|
|
|
|
if (channel != null) { |
|
|
|
|
// 贡献比例 9%
|
|
|
|
|
directlyContributeRate = new BigDecimal("9"); |
|
|
|
|
// 贡献 = (返利金额 * 元宝汇率) * 直属贡献
|
|
|
|
|
goldCoin = (rebateAmount.multiply(goldCoinExchangeRate)) |
|
|
|
|
.multiply(directlyContributeRate.divide(new BigDecimal("100"))) |
|
|
|
|
.setScale(6, BigDecimal.ROUND_HALF_DOWN); |
|
|
|
|
// 贡献
|
|
|
|
|
parentUserParam.clear(); |
|
|
|
|
parentUserParam.put("sourceId", MapUtils.getString(otherParam, "sourceId")); |
|
|
|
|
parentUserParam.put("sourceOrderNo", MapUtils.getString(otherParam, "sourceOrderNo")); |
|
|
|
|
parentUserParam.put("sourceContent", "直属渠道团队贡献"); |
|
|
|
|
// 渠道账户
|
|
|
|
|
userAccountService.recharge(channel.getParentUserId(), goldCoin, UserAccountRecordSourceTypeEnum.type1, parentUserParam); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|