|
@@ -20,7 +20,6 @@ import cn.newfeifan.mall.module.distri.service.integral.IntegralService;
|
|
|
import cn.newfeifan.mall.module.distri.service.orderpercentage.OrderPercentageService;
|
|
|
import cn.newfeifan.mall.module.distri.service.partitioncrash.PartitionCrashService;
|
|
|
import cn.newfeifan.mall.module.distri.service.ptprofit.PtProfitService;
|
|
|
-import cn.newfeifan.mall.module.distri.service.ptprofitdailystatisticslog.PtProfitDailyStatisticsLogService;
|
|
|
import cn.newfeifan.mall.module.distri.service.ptprofitlog.PtProfitLogService;
|
|
|
import cn.newfeifan.mall.module.distri.service.sharepath.SharePathService;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
@@ -84,9 +83,6 @@ public class OrderCalcServiceImpl implements OrderCalcService {
|
|
|
@Resource
|
|
|
private PartitionCrashService partitionCrashService;
|
|
|
|
|
|
- @Resource
|
|
|
- private PtProfitDailyStatisticsLogService ptProfitDailyStatisticsLogService;
|
|
|
-
|
|
|
@Override
|
|
|
public Long createOrderCalc(OrderCalcSaveReqVO createReqVO) {
|
|
|
// 插入
|
|
@@ -147,7 +143,7 @@ public class OrderCalcServiceImpl implements OrderCalcService {
|
|
|
String percentTemplate = JsonUtils.toJsonString(orderPercentageDO);
|
|
|
calc(tradeOrderDO, orderPercentageDO, percentTemplate);
|
|
|
} catch (Exception e) {
|
|
|
-
|
|
|
+ System.out.println(e.getMessage());
|
|
|
} finally {
|
|
|
// todo 计算当天用户的碰撞
|
|
|
// 计算兄弟分区, 以及后代分区
|
|
@@ -162,6 +158,11 @@ public class OrderCalcServiceImpl implements OrderCalcService {
|
|
|
.in(OrderCalcDO::getUserId, userList));
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void updateOrderItem(Long orderItemId) {
|
|
|
+ orderCalcMapper.updateOrderItemById(orderItemId);
|
|
|
+ }
|
|
|
+
|
|
|
private void calc(List<OrderCalcMessage> tradeOrderDO, OrderPercentageDO orderPercentageDO, String percentTemplate) {
|
|
|
|
|
|
List<PtProfitSaveReqVO> savePFitMap = new ArrayList<>();
|
|
@@ -207,6 +208,8 @@ 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())); //自得积分
|
|
|
+
|
|
|
+ updateOrderItem(j.getOrderItemId());
|
|
|
});
|
|
|
|
|
|
|
|
@@ -256,14 +259,14 @@ public class OrderCalcServiceImpl implements OrderCalcService {
|
|
|
|
|
|
// ========== 身价计算 ==============
|
|
|
//推荐人身价计算
|
|
|
- BigDecimal orderAncestorSocialStatus = new BigDecimal(orderPercentageDO.getOrderAncestorSocialStatus());
|
|
|
- Long ancestorSocial = k.getOrderItemMessages().get(0).getTotalPrice() * orderAncestorSocialStatus.longValue();
|
|
|
- duserService.updateDuserSocial(integralDOAncestor.getUserId(), ancestorSocial, SocialStatusEnum.SHOPPING_ANCESTOR_SOCIAL.getStatus());
|
|
|
+ double orderAncestorSocialStatus = Double.parseDouble(orderPercentageDO.getOrderAncestorSocialStatus());
|
|
|
+ double ancestorSocial = k.getOrderItemMessages().get(0).getTotalPrice() * orderAncestorSocialStatus;
|
|
|
+ duserService.updateDuserSocial(integralDOAncestor.getUserId(), (long) ancestorSocial, SocialStatusEnum.SHOPPING_ANCESTOR_SOCIAL.getStatus());
|
|
|
|
|
|
//自得身价计算
|
|
|
- BigDecimal orderUserSocialStatus = new BigDecimal(orderPercentageDO.getOrderUserSocialStatus());
|
|
|
- Long descendantSocial = k.getOrderItemMessages().get(0).getTotalPrice() * orderUserSocialStatus.longValue();
|
|
|
- duserService.updateDuserSocial(integralDOAncestor.getUserId(), descendantSocial, SocialStatusEnum.SHOPPING_SOCIAL.getStatus());
|
|
|
+ double orderUserSocialStatus = Double.parseDouble(orderPercentageDO.getOrderUserSocialStatus());
|
|
|
+ double descendantSocial = k.getOrderItemMessages().get(0).getTotalPrice() * orderUserSocialStatus;
|
|
|
+ duserService.updateDuserSocial(integralDO.getUserId(), (long) descendantSocial, SocialStatusEnum.SHOPPING_SOCIAL.getStatus());
|
|
|
|
|
|
|
|
|
// ========== 汇总计算 =================
|
|
@@ -285,11 +288,13 @@ public class OrderCalcServiceImpl implements OrderCalcService {
|
|
|
// ========== 修改用户钱包 =================
|
|
|
//直推奖也要限制额度
|
|
|
Long ancestorHighQuota = integralDOAncestor.getHighQuota() + new BigDecimal(orderPercentageDO.getBaseMaxQuota()).longValue();//加上基础的最大额度值
|
|
|
- if (ancestorHighQuota > ancestorQuotaInt) {
|
|
|
- ancestorQuotaInt = 0L;
|
|
|
+ if (ancestorHighQuota < ancestorQuotaInt) {
|
|
|
+ changeUserWallet(integralSaveReqVOS, integralDO, integralDOAncestor, ptIntegral, 0L,
|
|
|
+ descendantQuotaInt, highQuotaInt, grossProfitAfterBonusInt, platformQuotaInt);
|
|
|
+ } else {
|
|
|
+ changeUserWallet(integralSaveReqVOS, integralDO, integralDOAncestor, ptIntegral, ancestorQuotaInt,
|
|
|
+ descendantQuotaInt, highQuotaInt, grossProfitAfterBonusInt, platformQuotaInt);
|
|
|
}
|
|
|
- changeUserWallet(integralSaveReqVOS, integralDO, integralDOAncestor, ptIntegral, ancestorQuotaInt,
|
|
|
- descendantQuotaInt, highQuotaInt, grossProfitAfterBonusInt, platformQuotaInt);
|
|
|
// ========== 修改平台信息 =================
|
|
|
// 每个订单计算的过程
|
|
|
// 增加平台收益
|
|
@@ -302,7 +307,7 @@ public class OrderCalcServiceImpl implements OrderCalcService {
|
|
|
|
|
|
// 当直推人获取的积分额度不足时,平台收益要加回来,并生成log
|
|
|
calcIntegral(ptProfitSaveReqVOS, ptProfitSaveReqVO, ancestorHighQuota, ancestorQuotaInt,
|
|
|
- k.getOrderId(), k.getNo(), k.getUserId());
|
|
|
+ k.getOrderId(), k.getNo(), integralDOAncestor.getUserId());
|
|
|
|
|
|
ptProfitSaveReqVOS.add(ptProfitSaveReqVO);
|
|
|
// ========== 增加日志记录 =================
|
|
@@ -381,6 +386,7 @@ public class OrderCalcServiceImpl implements OrderCalcService {
|
|
|
Long highQuotaInt, Long ancestorQuotaInt, Long orderId, String orderNo, Long userId) {
|
|
|
if (highQuotaInt < ancestorQuotaInt) {
|
|
|
ptProfitSaveReqVO.setPtGrossAdd(ptProfitSaveReqVO.getPtGrossAdd() + ancestorQuotaInt);
|
|
|
+ ptProfitSaveReqVO.setPtTotalAdd(ptProfitSaveReqVO.getPtGrossAdd() + ptProfitSaveReqVO.getPtAdd());
|
|
|
|
|
|
PtProfitLogSaveReqVO ptProfitLog = PtProfitLogSaveReqVO.builder()
|
|
|
.orderId(orderId)
|