|
@@ -200,7 +200,8 @@ public class OrderCalcServiceImpl implements OrderCalcService {
|
|
|
|
|
|
// 计算
|
|
|
// 计算利润: (价格 - 成本价格) * 产品数量
|
|
|
- final BigDecimal[] profit = {new BigDecimal("0"), new BigDecimal("0")}; //用户自得不用要计算,从orderItem里面获取
|
|
|
+ //用户自得和直推奖不用计算,从orderItem里面获取
|
|
|
+ final BigDecimal[] profit = {new BigDecimal("0"), new BigDecimal("0"), new BigDecimal("0")};
|
|
|
k.getOrderItemMessages().forEach(j -> {
|
|
|
BigDecimal onePrice = new BigDecimal(j.getPrice());
|
|
|
BigDecimal oneCostPrice = new BigDecimal(j.getCostPrice());
|
|
@@ -208,6 +209,7 @@ public class OrderCalcServiceImpl implements OrderCalcService {
|
|
|
BigDecimal oneGrossProfit = onePrice.subtract(oneCostPrice).multiply(productCount);
|
|
|
profit[0] = profit[0].add(oneGrossProfit); // 注意这里的改动
|
|
|
profit[1] = profit[1].add(new BigDecimal(j.getIncreaseIntegral())); //自得积分
|
|
|
+ profit[2] = profit[2].add(new BigDecimal(j.getAncestorIncreaseIntegral())); //自得积分
|
|
|
|
|
|
updateOrderItem(j.getOrderItemId());
|
|
|
});
|
|
@@ -227,7 +229,7 @@ public class OrderCalcServiceImpl implements OrderCalcService {
|
|
|
BigDecimal descendantQuota = profit[1];
|
|
|
|
|
|
// 直推奖: 毛利 * 0.3 (上一级)
|
|
|
- BigDecimal ancestorQuota = grossProfit.multiply(new BigDecimal(orderPercentageDO.getGrossProfitAncestorQuotaPerc())).setScale(4, RoundingMode.DOWN);
|
|
|
+ BigDecimal ancestorQuota = profit[2];
|
|
|
|
|
|
// 合赢将: 毛利 * 0.08
|
|
|
BigDecimal bonusQuota = grossProfit.multiply(new BigDecimal(orderPercentageDO.getGrossProfitBonusQuotaPerc())).setScale(4, RoundingMode.DOWN);
|
|
@@ -241,7 +243,7 @@ public class OrderCalcServiceImpl implements OrderCalcService {
|
|
|
|
|
|
// 乘以 10000 并转换为整数
|
|
|
Long grossProfitInt = grossProfit.multiply(new BigDecimal("10000")).setScale(0, RoundingMode.DOWN).longValue();
|
|
|
- Long ancestorQuotaInt = ancestorQuota.multiply(new BigDecimal("10000")).setScale(0, RoundingMode.DOWN).longValue();
|
|
|
+ Long ancestorQuotaInt = ancestorQuota.longValue();
|
|
|
Long descendantQuotaInt = descendantQuota.longValue();
|
|
|
Long bonusQuotaInt = bonusQuota.multiply(new BigDecimal("10000")).setScale(0, RoundingMode.DOWN).longValue();
|
|
|
Long highQuotaInt = highQuota.multiply(new BigDecimal("10000")).setScale(0, RoundingMode.DOWN).longValue();
|
|
@@ -252,9 +254,9 @@ public class OrderCalcServiceImpl implements OrderCalcService {
|
|
|
// 获取当前下单人关系
|
|
|
SharePathDO sharePath = getSharePath(k.getUserId());
|
|
|
// 如果sharePath为空, 则说明没有直推人关系
|
|
|
- IntegralDO integralDOAncestor = integralService.selectByUser(sharePath.getAncestor());
|
|
|
- IntegralDO integralDO = integralService.selectByUser(sharePath.getDescendant());
|
|
|
- IntegralDO ptIntegral = integralService.selectByUser(1L);
|
|
|
+ IntegralDO integralDOAncestor = integralService.selectByUser(sharePath.getAncestor()); //父级
|
|
|
+ IntegralDO integralDO = integralService.selectByUser(sharePath.getDescendant()); //自己
|
|
|
+ IntegralDO ptIntegral = integralService.selectByUser(1L); //pt
|
|
|
|
|
|
|
|
|
// ========== 身价计算 ==============
|
|
@@ -372,6 +374,8 @@ public class OrderCalcServiceImpl implements OrderCalcService {
|
|
|
.userId(sharePath.getAncestor())
|
|
|
.amount(amount)
|
|
|
.afterAmount(integralDOAncestor.getCurrentQuota())
|
|
|
+ .freezeAmount(amount)
|
|
|
+ .afterFreezeAmount(integralDOAncestor.getFreezeQuota())
|
|
|
.ancestorQuotaAmount(ptReplenish)
|
|
|
.maxAvailablePointsAmount(-amount)
|
|
|
.afterMaxAvailablePointsAmount(ancestorHighQuota - amount)
|
|
@@ -386,7 +390,7 @@ public class OrderCalcServiceImpl implements OrderCalcService {
|
|
|
.orderNo(k.getNo())
|
|
|
.userId(sharePath.getDescendant())
|
|
|
.amount(descendantQuotaInt)
|
|
|
- .afterAmount(integralDO.getCurrentQuota() + descendantQuotaInt)
|
|
|
+ .afterAmount(integralDO.getCurrentQuota())
|
|
|
.freezeAmount(-descendantQuotaInt)
|
|
|
.afterFreezeAmount(integralDO.getFreezeQuota())
|
|
|
.maxAvailablePointsAmount(highQuotaInt)
|
|
@@ -514,6 +518,7 @@ public class OrderCalcServiceImpl implements OrderCalcService {
|
|
|
// 减少推荐人的可获取额度
|
|
|
integralDOAncestor.setHighQuota(integralDOAncestor.getHighQuota() - ancestorQuota);
|
|
|
integralDOAncestor.setAncestorQuota(integralDOAncestor.getAncestorQuota() + ancestorQuota);
|
|
|
+ integralDOAncestor.setFreezeQuota(integralDOAncestor.getFreezeQuota() - ancestorQuota);
|
|
|
integralService.updateIntegral(BeanUtils.toBean(integralDOAncestor, IntegralSaveReqVO.class));
|
|
|
|
|
|
// 增加平台额度
|