|
|
@ -6,10 +6,7 @@ import com.hfkj.common.exception.SysCode; |
|
|
|
import com.hfkj.entity.BsUser; |
|
|
|
import com.hfkj.entity.BsUser; |
|
|
|
import com.hfkj.entity.BsUserParentRel; |
|
|
|
import com.hfkj.entity.BsUserParentRel; |
|
|
|
import com.hfkj.service.sec.SecDictionaryService; |
|
|
|
import com.hfkj.service.sec.SecDictionaryService; |
|
|
|
import com.hfkj.service.user.BsUserAccountService; |
|
|
|
import com.hfkj.service.user.*; |
|
|
|
import com.hfkj.service.user.BsUserContributeService; |
|
|
|
|
|
|
|
import com.hfkj.service.user.BsUserParentRelService; |
|
|
|
|
|
|
|
import com.hfkj.service.user.BsUserService; |
|
|
|
|
|
|
|
import com.hfkj.sysenum.user.UserAccountRecordSourceTypeEnum; |
|
|
|
import com.hfkj.sysenum.user.UserAccountRecordSourceTypeEnum; |
|
|
|
import com.hfkj.sysenum.user.UserGradeEnum; |
|
|
|
import com.hfkj.sysenum.user.UserGradeEnum; |
|
|
|
import org.apache.commons.collections4.MapUtils; |
|
|
|
import org.apache.commons.collections4.MapUtils; |
|
|
@ -26,7 +23,9 @@ import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
|
|
|
|
* 会员等级贡献 |
|
|
|
* @className: BsUserContributeServiceImpl |
|
|
|
* @className: BsUserContributeServiceImpl |
|
|
|
* @author: HuRui |
|
|
|
* @author: HuRui |
|
|
|
* @date: 2024/9/12 |
|
|
|
* @date: 2024/9/12 |
|
|
@ -55,7 +54,7 @@ public class BsUserContributeServiceImpl implements BsUserContributeService { |
|
|
|
// 元宝汇率
|
|
|
|
// 元宝汇率
|
|
|
|
BigDecimal goldCoinExchangeRate = new BigDecimal(secDictionaryService.getDictionary("GOLD_COIN_EXCHANGE_RATE").get(0).getCodeValue()); |
|
|
|
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<>(); |
|
|
|
Map<String, Object> userRechargeParam = new HashMap<>(); |
|
|
|
userRechargeParam.put("sourceId", MapUtils.getLong(otherParam, "sourceId")); |
|
|
|
userRechargeParam.put("sourceId", MapUtils.getLong(otherParam, "sourceId")); |
|
|
@ -67,18 +66,28 @@ public class BsUserContributeServiceImpl implements BsUserContributeService { |
|
|
|
// 查询用户上级
|
|
|
|
// 查询用户上级
|
|
|
|
BsUserParentRel parentRel = userParentRelService.getDetailByUserId(userId); |
|
|
|
BsUserParentRel parentRel = userParentRelService.getDetailByUserId(userId); |
|
|
|
if (parentRel != null && parentRel.getParentUserId() != null) { |
|
|
|
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())) { |
|
|
|
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())) { |
|
|
|
} 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())) { |
|
|
|
} else if (UserGradeEnum.grade2.getCode().equals(parentRel.getParentUserGrade())) { |
|
|
|
// 正式会员
|
|
|
|
// 正式会员
|
|
|
|
|
|
|
|
parentGrade2(UserGradeEnum.getDataByType(user.getGrade()), rebateAmount, parentRel, otherParam); |
|
|
|
|
|
|
|
|
|
|
|
} else if (UserGradeEnum.grade1.getCode().equals(parentRel.getParentUserGrade())) { |
|
|
|
} else if (UserGradeEnum.grade1.getCode().equals(parentRel.getParentUserGrade())) { |
|
|
|
// 见习会员
|
|
|
|
// 见习会员
|
|
|
|
|
|
|
|
parentGrade1(UserGradeEnum.getDataByType(user.getGrade()), rebateAmount, parentRel, otherParam); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -87,31 +96,49 @@ public class BsUserContributeServiceImpl implements BsUserContributeService { |
|
|
|
* 渠道 |
|
|
|
* 渠道 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void parentGrade4(UserGradeEnum userGrade,BigDecimal rebateAmount,BsUserParentRel parentRel,Map<String,Object> otherParam) throws Exception { |
|
|
|
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 goldCoinExchangeRate = new BigDecimal(secDictionaryService.getDictionary("GOLD_COIN_EXCHANGE_RATE").get(0).getCodeValue()); |
|
|
|
|
|
|
|
|
|
|
|
// 直属贡献比例
|
|
|
|
// 直属贡献比例
|
|
|
|
BigDecimal directlyContributeRate = new BigDecimal("0"); |
|
|
|
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"); |
|
|
|
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)) |
|
|
|
BigDecimal goldCoin = (rebateAmount.multiply(goldCoinExchangeRate)) |
|
|
|
.multiply(directlyContributeRate.divide(new BigDecimal("100"))) |
|
|
|
.multiply(directlyContributeRate.divide(new BigDecimal("100"))) |
|
|
|
.setScale(6, BigDecimal.ROUND_HALF_DOWN); |
|
|
|
.setScale(6, BigDecimal.ROUND_HALF_DOWN); |
|
|
|
|
|
|
|
if (parentRel != null) { |
|
|
|
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); |
|
|
|
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"); |
|
|
|
directlyContributeRate = new BigDecimal("9"); |
|
|
|
// 直属贡献 = (返利金额 * 元宝汇率) * 直属贡献
|
|
|
|
// 贡献 = (返利金额 * 元宝汇率) * 直属贡献
|
|
|
|
goldCoin = (rebateAmount.multiply(goldCoinExchangeRate)) |
|
|
|
goldCoin = (rebateAmount.multiply(goldCoinExchangeRate)) |
|
|
|
.multiply(directlyContributeRate.divide(new BigDecimal("100"))) |
|
|
|
.multiply(directlyContributeRate.divide(new BigDecimal("100"))) |
|
|
|
.setScale(6, BigDecimal.ROUND_HALF_DOWN); |
|
|
|
.setScale(6, BigDecimal.ROUND_HALF_DOWN); |
|
|
@ -121,39 +148,51 @@ public class BsUserContributeServiceImpl implements BsUserContributeService { |
|
|
|
parentUserParam.put("sourceOrderNo", MapUtils.getString(otherParam, "sourceOrderNo")); |
|
|
|
parentUserParam.put("sourceOrderNo", MapUtils.getString(otherParam, "sourceOrderNo")); |
|
|
|
parentUserParam.put("sourceContent", "直属渠道团队贡献"); |
|
|
|
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 { |
|
|
|
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 goldCoinExchangeRate = new BigDecimal(secDictionaryService.getDictionary("GOLD_COIN_EXCHANGE_RATE").get(0).getCodeValue()); |
|
|
|
// 直属贡献比例
|
|
|
|
// 直属贡献比例
|
|
|
|
BigDecimal directlyContributeRate = new BigDecimal("0"); |
|
|
|
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"); |
|
|
|
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)) |
|
|
|
BigDecimal goldCoin = (rebateAmount.multiply(goldCoinExchangeRate)) |
|
|
|
.multiply(directlyContributeRate.divide(new BigDecimal("100"))) |
|
|
|
.multiply(directlyContributeRate.divide(new BigDecimal("100"))) |
|
|
|
.setScale(6, BigDecimal.ROUND_HALF_DOWN); |
|
|
|
.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); |
|
|
|
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( |
|
|
|
BsUserParentRel userParentRel = userParentRelService.getParent( |
|
|
|
Arrays.asList(UserGradeEnum.grade4, UserGradeEnum.grade3), |
|
|
|
Arrays.asList(UserGradeEnum.grade4, UserGradeEnum.grade3), |
|
|
|
parentRel.getParentUserId() |
|
|
|
parentRel.getParentUserId() |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
// 团长或渠道
|
|
|
|
if (userParentRel != null) { |
|
|
|
if (userParentRel != null) { |
|
|
|
|
|
|
|
// 团长
|
|
|
|
if (UserGradeEnum.grade3.getCode().equals(userParentRel.getParentUserGrade())) { |
|
|
|
if (UserGradeEnum.grade3.getCode().equals(userParentRel.getParentUserGrade())) { |
|
|
|
// 贡献比例 10%
|
|
|
|
// 贡献比例 10%
|
|
|
|
directlyContributeRate = new BigDecimal("10"); |
|
|
|
directlyContributeRate = new BigDecimal("10"); |
|
|
@ -162,12 +201,12 @@ public class BsUserContributeServiceImpl implements BsUserContributeService { |
|
|
|
.multiply(directlyContributeRate.divide(new BigDecimal("100"))) |
|
|
|
.multiply(directlyContributeRate.divide(new BigDecimal("100"))) |
|
|
|
.setScale(6, BigDecimal.ROUND_HALF_DOWN); |
|
|
|
.setScale(6, BigDecimal.ROUND_HALF_DOWN); |
|
|
|
// 渠道贡献
|
|
|
|
// 渠道贡献
|
|
|
|
otherParam.clear(); |
|
|
|
parentUserParam.clear(); |
|
|
|
otherParam.put("sourceId", ""); |
|
|
|
parentUserParam.put("sourceId", MapUtils.getString(otherParam, "sourceId")); |
|
|
|
otherParam.put("sourceOrderNo", ""); |
|
|
|
parentUserParam.put("sourceOrderNo", MapUtils.getString(otherParam, "sourceOrderNo")); |
|
|
|
otherParam.put("sourceContent", "直属团长贡献"); |
|
|
|
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()); |
|
|
|
userParentRel = userParentRelService.getParent(Arrays.asList(UserGradeEnum.grade4), parentRel.getParentUserId()); |
|
|
@ -179,16 +218,47 @@ public class BsUserContributeServiceImpl implements BsUserContributeService { |
|
|
|
.multiply(directlyContributeRate.divide(new BigDecimal("100"))) |
|
|
|
.multiply(directlyContributeRate.divide(new BigDecimal("100"))) |
|
|
|
.setScale(6, BigDecimal.ROUND_HALF_DOWN); |
|
|
|
.setScale(6, BigDecimal.ROUND_HALF_DOWN); |
|
|
|
// 渠道贡献
|
|
|
|
// 渠道贡献
|
|
|
|
otherParam.clear(); |
|
|
|
parentUserParam.clear(); |
|
|
|
otherParam.put("sourceId", ""); |
|
|
|
parentUserParam.put("sourceId", MapUtils.getString(otherParam, "sourceId")); |
|
|
|
otherParam.put("sourceOrderNo", ""); |
|
|
|
parentUserParam.put("sourceOrderNo", MapUtils.getString(otherParam, "sourceOrderNo")); |
|
|
|
otherParam.put("sourceContent", "非直属团长团队贡献"); |
|
|
|
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())) { |
|
|
|
} 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()); |
|
|
|
BsUserParentRel teamLeader = userParentRelService.getParent(Arrays.asList(UserGradeEnum.grade3), parentRel.getParentUserId()); |
|
|
|
if (teamLeader != null) { |
|
|
|
if (teamLeader != null) { |
|
|
|
// 贡献比例 2 3%
|
|
|
|
// 贡献比例 2 3%
|
|
|
@ -198,14 +268,187 @@ public class BsUserContributeServiceImpl implements BsUserContributeService { |
|
|
|
.multiply(directlyContributeRate.divide(new BigDecimal("100"))) |
|
|
|
.multiply(directlyContributeRate.divide(new BigDecimal("100"))) |
|
|
|
.setScale(6, BigDecimal.ROUND_HALF_DOWN); |
|
|
|
.setScale(6, BigDecimal.ROUND_HALF_DOWN); |
|
|
|
// 贡献
|
|
|
|
// 贡献
|
|
|
|
otherParam.clear(); |
|
|
|
parentUserParam.clear(); |
|
|
|
otherParam.put("sourceId", ""); |
|
|
|
parentUserParam.put("sourceId", MapUtils.getString(otherParam, "sourceId")); |
|
|
|
otherParam.put("sourceOrderNo", ""); |
|
|
|
parentUserParam.put("sourceOrderNo", MapUtils.getString(otherParam, "sourceOrderNo")); |
|
|
|
otherParam.put("sourceContent", "直属团长团队贡献"); |
|
|
|
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%
|
|
|
|
// 贡献比例 9%
|
|
|
|
directlyContributeRate = new BigDecimal("9"); |
|
|
|
directlyContributeRate = new BigDecimal("9"); |
|
|
|
// 贡献 = (返利金额 * 元宝汇率) * 直属贡献
|
|
|
|
// 贡献 = (返利金额 * 元宝汇率) * 直属贡献
|
|
|
@ -213,16 +456,153 @@ public class BsUserContributeServiceImpl implements BsUserContributeService { |
|
|
|
.multiply(directlyContributeRate.divide(new BigDecimal("100"))) |
|
|
|
.multiply(directlyContributeRate.divide(new BigDecimal("100"))) |
|
|
|
.setScale(6, BigDecimal.ROUND_HALF_DOWN); |
|
|
|
.setScale(6, BigDecimal.ROUND_HALF_DOWN); |
|
|
|
// 贡献
|
|
|
|
// 贡献
|
|
|
|
otherParam.clear(); |
|
|
|
parentUserParam.clear(); |
|
|
|
otherParam.put("sourceId", ""); |
|
|
|
parentUserParam.put("sourceId", MapUtils.getString(otherParam, "sourceId")); |
|
|
|
otherParam.put("sourceOrderNo", ""); |
|
|
|
parentUserParam.put("sourceOrderNo", MapUtils.getString(otherParam, "sourceOrderNo")); |
|
|
|
otherParam.put("sourceContent", "直属渠道团队贡献"); |
|
|
|
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); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|