|
@@ -6,6 +6,7 @@ import cn.newfeifan.mall.module.distri.controller.admin.duser.vo.DuserSaveReqVO;
|
|
import cn.newfeifan.mall.module.distri.controller.admin.integral.vo.IntegralSaveReqVO;
|
|
import cn.newfeifan.mall.module.distri.controller.admin.integral.vo.IntegralSaveReqVO;
|
|
import cn.newfeifan.mall.module.distri.controller.admin.ptprofit.vo.PtProfitSaveReqVO;
|
|
import cn.newfeifan.mall.module.distri.controller.admin.ptprofit.vo.PtProfitSaveReqVO;
|
|
import cn.newfeifan.mall.module.distri.controller.admin.ptprofitlog.vo.PtProfitLogSaveReqVO;
|
|
import cn.newfeifan.mall.module.distri.controller.admin.ptprofitlog.vo.PtProfitLogSaveReqVO;
|
|
|
|
+import cn.newfeifan.mall.module.distri.controller.admin.ptprofitlogdetails.vo.PtProfitLogDetailsSaveReqVO;
|
|
import cn.newfeifan.mall.module.distri.dal.dataobject.integral.IntegralDO;
|
|
import cn.newfeifan.mall.module.distri.dal.dataobject.integral.IntegralDO;
|
|
import cn.newfeifan.mall.module.distri.dal.dataobject.orderpercentage.OrderPercentageDO;
|
|
import cn.newfeifan.mall.module.distri.dal.dataobject.orderpercentage.OrderPercentageDO;
|
|
import cn.newfeifan.mall.module.distri.dal.dataobject.ptprofit.PtProfitDO;
|
|
import cn.newfeifan.mall.module.distri.dal.dataobject.ptprofit.PtProfitDO;
|
|
@@ -21,6 +22,7 @@ import cn.newfeifan.mall.module.distri.service.orderpercentage.OrderPercentageSe
|
|
import cn.newfeifan.mall.module.distri.service.partitioncrash.PartitionCrashService;
|
|
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.ptprofit.PtProfitService;
|
|
import cn.newfeifan.mall.module.distri.service.ptprofitlog.PtProfitLogService;
|
|
import cn.newfeifan.mall.module.distri.service.ptprofitlog.PtProfitLogService;
|
|
|
|
+import cn.newfeifan.mall.module.distri.service.ptprofitlogdetails.PtProfitLogDetailsService;
|
|
import cn.newfeifan.mall.module.distri.service.sharepath.SharePathService;
|
|
import cn.newfeifan.mall.module.distri.service.sharepath.SharePathService;
|
|
import org.springframework.context.annotation.Lazy;
|
|
import org.springframework.context.annotation.Lazy;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -83,6 +85,9 @@ public class OrderCalcServiceImpl implements OrderCalcService {
|
|
@Resource
|
|
@Resource
|
|
private PartitionCrashService partitionCrashService;
|
|
private PartitionCrashService partitionCrashService;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ private PtProfitLogDetailsService ptProfitLogDetailsService;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public Long createOrderCalc(OrderCalcSaveReqVO createReqVO) {
|
|
public Long createOrderCalc(OrderCalcSaveReqVO createReqVO) {
|
|
// 插入
|
|
// 插入
|
|
@@ -197,6 +202,9 @@ public class OrderCalcServiceImpl implements OrderCalcService {
|
|
BigDecimal price = new BigDecimal(priceStream);
|
|
BigDecimal price = new BigDecimal(priceStream);
|
|
BigDecimal costPrice = new BigDecimal(longStream);
|
|
BigDecimal costPrice = new BigDecimal(longStream);
|
|
|
|
|
|
|
|
+ // 添加平台利润记录详情
|
|
|
|
+ List<PtProfitLogDetailsSaveReqVO> ptProfitLogDetailsSaveReqVOS = new ArrayList<>();
|
|
|
|
+
|
|
|
|
|
|
// 计算
|
|
// 计算
|
|
// 计算利润: (价格 - 成本价格) * 产品数量
|
|
// 计算利润: (价格 - 成本价格) * 产品数量
|
|
@@ -211,11 +219,16 @@ public class OrderCalcServiceImpl implements OrderCalcService {
|
|
profit[1] = profit[1].add(new BigDecimal(j.getIncreaseIntegral())); //自得积分
|
|
profit[1] = profit[1].add(new BigDecimal(j.getIncreaseIntegral())); //自得积分
|
|
profit[2] = profit[2].add(new BigDecimal(j.getAncestorIncreaseIntegral())); //自得积分
|
|
profit[2] = profit[2].add(new BigDecimal(j.getAncestorIncreaseIntegral())); //自得积分
|
|
|
|
|
|
|
|
+ // 遍历订单项拿到订单项编号
|
|
updateOrderItem(j.getOrderItemId());
|
|
updateOrderItem(j.getOrderItemId());
|
|
|
|
+ PtProfitLogDetailsSaveReqVO ptProfitLogDetailsSaveReqVO = PtProfitLogDetailsSaveReqVO.builder()
|
|
|
|
+ .orderItemId(j.getOrderItemId())
|
|
|
|
+ .build();
|
|
|
|
+ ptProfitLogDetailsSaveReqVOS.add(ptProfitLogDetailsSaveReqVO);
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
- // 计算毛利: 利润 * 0.38
|
|
|
|
|
|
+ // 计算毛利: 利润 * 1
|
|
BigDecimal grossProfit = profit[0].multiply(new BigDecimal(orderPercentageDO.getGrossProfitPerc())).setScale(4, RoundingMode.DOWN);
|
|
BigDecimal grossProfit = profit[0].multiply(new BigDecimal(orderPercentageDO.getGrossProfitPerc())).setScale(4, RoundingMode.DOWN);
|
|
|
|
|
|
// 计算平台收益
|
|
// 计算平台收益
|
|
@@ -231,10 +244,10 @@ public class OrderCalcServiceImpl implements OrderCalcService {
|
|
// 直推奖: 毛利 * 0.3 (上一级)
|
|
// 直推奖: 毛利 * 0.3 (上一级)
|
|
BigDecimal ancestorQuota = profit[2];
|
|
BigDecimal ancestorQuota = profit[2];
|
|
|
|
|
|
- // 合赢将: 毛利 * 0.08
|
|
|
|
|
|
+ // 合赢将: 毛利 * 0.12
|
|
BigDecimal bonusQuota = grossProfit.multiply(new BigDecimal(orderPercentageDO.getGrossProfitBonusQuotaPerc())).setScale(4, RoundingMode.DOWN);
|
|
BigDecimal bonusQuota = grossProfit.multiply(new BigDecimal(orderPercentageDO.getGrossProfitBonusQuotaPerc())).setScale(4, RoundingMode.DOWN);
|
|
|
|
|
|
- // 平台服务费: 毛利 * 0.22
|
|
|
|
|
|
+ // 平台服务费: 毛利 * 0.05
|
|
BigDecimal platformQuota = grossProfit.multiply(new BigDecimal(orderPercentageDO.getGrossProfitPlatformQuotaPerc())).setScale(4, RoundingMode.DOWN);
|
|
BigDecimal platformQuota = grossProfit.multiply(new BigDecimal(orderPercentageDO.getGrossProfitPlatformQuotaPerc())).setScale(4, RoundingMode.DOWN);
|
|
|
|
|
|
|
|
|
|
@@ -344,6 +357,7 @@ public class OrderCalcServiceImpl implements OrderCalcService {
|
|
.amount(platformQuotaInt + grossProfitAfterBonusInt)
|
|
.amount(platformQuotaInt + grossProfitAfterBonusInt)
|
|
.afterAmount(ptProfitDO.getPtTotalAdd() + platformQuotaInt + grossProfitAfterBonusInt)
|
|
.afterAmount(ptProfitDO.getPtTotalAdd() + platformQuotaInt + grossProfitAfterBonusInt)
|
|
.percentTemplate(percentTemplate)
|
|
.percentTemplate(percentTemplate)
|
|
|
|
+ .generateUserId(integralDO.getUserId())
|
|
.build();
|
|
.build();
|
|
// 平台收益
|
|
// 平台收益
|
|
PtProfitLogSaveReqVO ptGrossAddLog = PtProfitLogSaveReqVO.builder()
|
|
PtProfitLogSaveReqVO ptGrossAddLog = PtProfitLogSaveReqVO.builder()
|
|
@@ -353,6 +367,7 @@ public class OrderCalcServiceImpl implements OrderCalcService {
|
|
.amount(grossProfitAfterBonusInt)
|
|
.amount(grossProfitAfterBonusInt)
|
|
.afterAmount(ptProfitDO.getPtGrossAdd() + ptProfitSaveReqVO.getPtGrossAdd())
|
|
.afterAmount(ptProfitDO.getPtGrossAdd() + ptProfitSaveReqVO.getPtGrossAdd())
|
|
.percentTemplate(percentTemplate)
|
|
.percentTemplate(percentTemplate)
|
|
|
|
+ .generateUserId(integralDO.getUserId())
|
|
.build();
|
|
.build();
|
|
|
|
|
|
// 平台服务费
|
|
// 平台服务费
|
|
@@ -363,6 +378,7 @@ public class OrderCalcServiceImpl implements OrderCalcService {
|
|
.amount(platformQuotaInt)
|
|
.amount(platformQuotaInt)
|
|
.afterAmount(ptProfitDO.getPtAdd() + ptProfitSaveReqVO.getPtAdd())
|
|
.afterAmount(ptProfitDO.getPtAdd() + ptProfitSaveReqVO.getPtAdd())
|
|
.percentTemplate(percentTemplate)
|
|
.percentTemplate(percentTemplate)
|
|
|
|
+ .generateUserId(integralDO.getUserId())
|
|
.build();
|
|
.build();
|
|
|
|
|
|
|
|
|
|
@@ -380,6 +396,7 @@ public class OrderCalcServiceImpl implements OrderCalcService {
|
|
.maxAvailablePointsAmount(-amount)
|
|
.maxAvailablePointsAmount(-amount)
|
|
.afterMaxAvailablePointsAmount(ancestorHighQuota - amount)
|
|
.afterMaxAvailablePointsAmount(ancestorHighQuota - amount)
|
|
.percentTemplate(percentTemplate)
|
|
.percentTemplate(percentTemplate)
|
|
|
|
+ .generateUserId(integralDO.getUserId())
|
|
.build();
|
|
.build();
|
|
|
|
|
|
|
|
|
|
@@ -396,6 +413,7 @@ public class OrderCalcServiceImpl implements OrderCalcService {
|
|
.maxAvailablePointsAmount(highQuotaInt)
|
|
.maxAvailablePointsAmount(highQuotaInt)
|
|
.afterMaxAvailablePointsAmount(integralDO.getHighQuota())
|
|
.afterMaxAvailablePointsAmount(integralDO.getHighQuota())
|
|
.percentTemplate(percentTemplate)
|
|
.percentTemplate(percentTemplate)
|
|
|
|
+ .generateUserId(integralDO.getUserId())
|
|
.build();
|
|
.build();
|
|
|
|
|
|
// 合赢奖记录
|
|
// 合赢奖记录
|
|
@@ -405,16 +423,20 @@ public class OrderCalcServiceImpl implements OrderCalcService {
|
|
.orderNo(k.getNo())
|
|
.orderNo(k.getNo())
|
|
.amount(bonusQuotaInt)
|
|
.amount(bonusQuotaInt)
|
|
.afterAmount(0L)
|
|
.afterAmount(0L)
|
|
|
|
+ .generateUserId(integralDO.getUserId())
|
|
.percentTemplate(percentTemplate).build();
|
|
.percentTemplate(percentTemplate).build();
|
|
-
|
|
|
|
|
|
+ // 添加获得合赢奖的记录
|
|
|
|
+ hyjLog.setId(ptProfitLogService.createPtProfitLog(hyjLog));
|
|
|
|
+ for (PtProfitLogDetailsSaveReqVO ptProfitLogDetailsSaveReqVO : ptProfitLogDetailsSaveReqVOS) {
|
|
|
|
+ ptProfitLogDetailsSaveReqVO.setDistriPtProfitLogId(hyjLog.getId());
|
|
|
|
+ }
|
|
|
|
+ ptProfitLogDetailsService.saveBatch(ptProfitLogDetailsSaveReqVOS);
|
|
|
|
|
|
ptProfitLogSaveReqVOS.add(ptTotal);
|
|
ptProfitLogSaveReqVOS.add(ptTotal);
|
|
ptProfitLogSaveReqVOS.add(ptGrossAddLog);
|
|
ptProfitLogSaveReqVOS.add(ptGrossAddLog);
|
|
ptProfitLogSaveReqVOS.add(ptAddLog);
|
|
ptProfitLogSaveReqVOS.add(ptAddLog);
|
|
ptProfitLogSaveReqVOS.add(tjrLog);
|
|
ptProfitLogSaveReqVOS.add(tjrLog);
|
|
ptProfitLogSaveReqVOS.add(ztrLog);
|
|
ptProfitLogSaveReqVOS.add(ztrLog);
|
|
- ptProfitLogSaveReqVOS.add(hyjLog);
|
|
|
|
-
|
|
|
|
|
|
|
|
});
|
|
});
|
|
|
|
|