|
@@ -199,7 +199,7 @@ public class OrderCalcServiceImpl implements OrderCalcService {
|
|
|
|
|
|
// 计算
|
|
|
// 计算利润: (价格 - 成本价格) * 产品数量
|
|
|
- final BigDecimal[] profit = {new BigDecimal("0"),new BigDecimal("0")}; //用户自得不用要计算,从orderItem里面获取
|
|
|
+ final BigDecimal[] profit = {new BigDecimal("0"), new BigDecimal("0")}; //用户自得不用要计算,从orderItem里面获取
|
|
|
k.getOrderItemMessages().forEach(j -> {
|
|
|
BigDecimal onePrice = new BigDecimal(j.getPrice());
|
|
|
BigDecimal oneCostPrice = new BigDecimal(j.getCostPrice());
|
|
@@ -283,6 +283,11 @@ public class OrderCalcServiceImpl implements OrderCalcService {
|
|
|
.percentTemplate(percentTemplate).build();
|
|
|
saveList.add(orderCalcSaveReqVO);
|
|
|
// ========== 修改用户钱包 =================
|
|
|
+ //直推奖也要限制额度
|
|
|
+ Long ancestorHighQuota = integralDOAncestor.getHighQuota() + new BigDecimal(orderPercentageDO.getBaseMaxQuota()).longValue();//加上基础的最大额度值
|
|
|
+ if (ancestorHighQuota > ancestorQuotaInt) {
|
|
|
+ ancestorQuotaInt = 0L;
|
|
|
+ }
|
|
|
changeUserWallet(integralSaveReqVOS, integralDO, integralDOAncestor, ptIntegral, ancestorQuotaInt,
|
|
|
descendantQuotaInt, highQuotaInt, grossProfitAfterBonusInt, platformQuotaInt);
|
|
|
// ========== 修改平台信息 =================
|
|
@@ -294,6 +299,11 @@ public class OrderCalcServiceImpl implements OrderCalcService {
|
|
|
.ptAdd(platformQuotaInt)
|
|
|
.ptGrossAdd(grossProfitAfterBonusInt)
|
|
|
.ptTotalAdd(platformQuotaInt + grossProfitAfterBonusInt).build();
|
|
|
+
|
|
|
+ // 当直推人获取的积分额度不足时,平台收益要加回来,并生成log
|
|
|
+ calcIntegral(ptProfitSaveReqVOS, ptProfitSaveReqVO, ancestorHighQuota, ancestorQuotaInt,
|
|
|
+ k.getOrderId(), k.getNo(), k.getUserId());
|
|
|
+
|
|
|
ptProfitSaveReqVOS.add(ptProfitSaveReqVO);
|
|
|
// ========== 增加日志记录 =================
|
|
|
|
|
@@ -367,6 +377,23 @@ public class OrderCalcServiceImpl implements OrderCalcService {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ private void calcIntegral(List<PtProfitSaveReqVO> ptProfitSaveReqVOS, PtProfitSaveReqVO ptProfitSaveReqVO,
|
|
|
+ Long highQuotaInt, Long ancestorQuotaInt, Long orderId, String orderNo, Long userId) {
|
|
|
+ if (highQuotaInt < ancestorQuotaInt) {
|
|
|
+ ptProfitSaveReqVO.setPtGrossAdd(ptProfitSaveReqVO.getPtGrossAdd() + ancestorQuotaInt);
|
|
|
+
|
|
|
+ PtProfitLogSaveReqVO ptProfitLog = PtProfitLogSaveReqVO.builder()
|
|
|
+ .orderId(orderId)
|
|
|
+ .profitStatus(CaclEnum.GROSS_PROFIT_ANCESTOR_QUOTA_PERC_EXCEED_MAXIMUM_LIMIT.getType())
|
|
|
+ .orderNo(orderNo)
|
|
|
+ .userId(userId)
|
|
|
+ .amount(ancestorQuotaInt)
|
|
|
+ .afterAmount(ptProfitSaveReqVOS.stream().mapToLong(PtProfitSaveReqVO::getPtGrossAdd).sum() + ancestorQuotaInt)
|
|
|
+ .build();
|
|
|
+ ptProfitLogService.createPtProfitLog(ptProfitLog);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private PtProfitDO calcPtProfit(PtProfitDO ptProfitDO, List<PtProfitSaveReqVO> ptProfitSaveReqVOS) {
|
|
|
|
|
|
Long currentPtAdd = 0L;
|
|
@@ -408,10 +435,13 @@ public class OrderCalcServiceImpl implements OrderCalcService {
|
|
|
|
|
|
integralDO.setCurrentQuota(integralDO.getCurrentQuota() + descendantQuota);
|
|
|
integralDO.setFreezeQuota(integralDO.getFreezeQuota() - descendantQuota);
|
|
|
-
|
|
|
-
|
|
|
// 增加推荐人额度
|
|
|
integralDOAncestor.setCurrentQuota(integralDOAncestor.getCurrentQuota() + ancestorQuota);
|
|
|
+ // 减少推荐人的可获取额度
|
|
|
+ integralDOAncestor.setHighQuota(integralDOAncestor.getHighQuota() - ancestorQuota);
|
|
|
+ integralDOAncestor.setAncestorQuota(integralDOAncestor.getAncestorQuota() + ancestorQuota);
|
|
|
+ integralService.updateIntegral(BeanUtils.toBean(integralDOAncestor, IntegralSaveReqVO.class));
|
|
|
+
|
|
|
// 增加平台额度
|
|
|
pt.setCurrentQuota(pt.getCurrentQuota() + ptA + ptB);
|
|
|
|
|
@@ -419,7 +449,6 @@ public class OrderCalcServiceImpl implements OrderCalcService {
|
|
|
// integralSaveReqVOS.add(BeanUtils.toBean(integralDOAncestor, IntegralSaveReqVO.class));
|
|
|
|
|
|
integralService.updateIntegral(BeanUtils.toBean(integralDO, IntegralSaveReqVO.class));
|
|
|
- integralService.updateIntegral(BeanUtils.toBean(integralDOAncestor, IntegralSaveReqVO.class));
|
|
|
integralService.updateIntegral(BeanUtils.toBean(pt, IntegralSaveReqVO.class));
|
|
|
|
|
|
}
|
|
@@ -431,4 +460,4 @@ public class OrderCalcServiceImpl implements OrderCalcService {
|
|
|
}
|
|
|
|
|
|
|
|
|
-}
|
|
|
+}
|