|
@@ -6,12 +6,14 @@ import cn.newfeifan.mall.module.distri.controller.admin.integral.vo.IntegralSave
|
|
import cn.newfeifan.mall.module.distri.controller.admin.partitionbrothers.vo.PartitionBrothersSaveReqVO;
|
|
import cn.newfeifan.mall.module.distri.controller.admin.partitionbrothers.vo.PartitionBrothersSaveReqVO;
|
|
import cn.newfeifan.mall.module.distri.controller.admin.partitionson.vo.PartitionSonSaveReqVO;
|
|
import cn.newfeifan.mall.module.distri.controller.admin.partitionson.vo.PartitionSonSaveReqVO;
|
|
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.dal.dataobject.duser.DuserDO;
|
|
import cn.newfeifan.mall.module.distri.dal.dataobject.duser.DuserDO;
|
|
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.ordercalc.OrderCalcDO;
|
|
import cn.newfeifan.mall.module.distri.dal.dataobject.ordercalc.OrderCalcDO;
|
|
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;
|
|
|
|
+import cn.newfeifan.mall.module.distri.dal.dataobject.ptprofitdailystatisticslog.PtProfitDailyStatisticsLogDO;
|
|
|
|
+import cn.newfeifan.mall.module.distri.dal.mysql.ptprofit.PtProfitMapper;
|
|
|
|
+import cn.newfeifan.mall.module.distri.dal.mysql.ptprofitdailystatisticslog.PtProfitDailyStatisticsLogMapper;
|
|
import cn.newfeifan.mall.module.distri.enums.CaclEnum;
|
|
import cn.newfeifan.mall.module.distri.enums.CaclEnum;
|
|
import cn.newfeifan.mall.module.distri.service.duser.DuserService;
|
|
import cn.newfeifan.mall.module.distri.service.duser.DuserService;
|
|
import cn.newfeifan.mall.module.distri.service.integral.IntegralService;
|
|
import cn.newfeifan.mall.module.distri.service.integral.IntegralService;
|
|
@@ -20,7 +22,6 @@ import cn.newfeifan.mall.module.distri.service.partitionbrothers.PartitionBrothe
|
|
import cn.newfeifan.mall.module.distri.service.partitionson.PartitionSonService;
|
|
import cn.newfeifan.mall.module.distri.service.partitionson.PartitionSonService;
|
|
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.tools.LoginMessageTool;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.context.annotation.Lazy;
|
|
import org.springframework.context.annotation.Lazy;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -90,6 +91,12 @@ public class PartitionCrashServiceImpl implements PartitionCrashService {
|
|
@Resource
|
|
@Resource
|
|
private PtProfitService ptProfitService;
|
|
private PtProfitService ptProfitService;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ private PtProfitDailyStatisticsLogMapper ptProfitDailyStatisticsLogMapper;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private PtProfitMapper ptProfitMapper;
|
|
|
|
+
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public Long createPartitionCrash(PartitionCrashSaveReqVO createReqVO) {
|
|
public Long createPartitionCrash(PartitionCrashSaveReqVO createReqVO) {
|
|
@@ -201,7 +208,8 @@ public class PartitionCrashServiceImpl implements PartitionCrashService {
|
|
crashSaveReqVOBuilder.sonPrice(0L);
|
|
crashSaveReqVOBuilder.sonPrice(0L);
|
|
}
|
|
}
|
|
// 合计儿子分支额度
|
|
// 合计儿子分支额度
|
|
- Long sonSumPrice = sonOrderCalcDOS.stream().mapToLong(OrderCalcDO::getGrossProfitBonusQuota).sum();
|
|
|
|
|
|
+ double grossProfitBonusQuotaPerc = Double.parseDouble(orderPercentageDO.getGrossProfitBonusQuotaPerc());
|
|
|
|
+ Long sonSumPrice = (long) (sonOrderCalcDOS.stream().mapToLong(OrderCalcDO::getGrossProfit).sum() * grossProfitBonusQuotaPerc);
|
|
sonBuilder.price(sonSumPrice);
|
|
sonBuilder.price(sonSumPrice);
|
|
|
|
|
|
// 获取当前用户的兄弟分区
|
|
// 获取当前用户的兄弟分区
|
|
@@ -213,7 +221,7 @@ public class PartitionCrashServiceImpl implements PartitionCrashService {
|
|
}
|
|
}
|
|
|
|
|
|
// 合并兄弟分支额度
|
|
// 合并兄弟分支额度
|
|
- Long brotherSumPrice = brothersOrderCalcDOS.stream().mapToLong(OrderCalcDO::getGrossProfitBonusQuota).sum();
|
|
|
|
|
|
+ Long brotherSumPrice = (long) (brothersOrderCalcDOS.stream().mapToLong(OrderCalcDO::getGrossProfit).sum() * grossProfitBonusQuotaPerc);
|
|
brotherBuilder.price(brotherSumPrice);
|
|
brotherBuilder.price(brotherSumPrice);
|
|
|
|
|
|
|
|
|
|
@@ -305,11 +313,17 @@ public class PartitionCrashServiceImpl implements PartitionCrashService {
|
|
// 遍历hashMap
|
|
// 遍历hashMap
|
|
for (HashMap<Long, Long> longIntegerHashMap : afterCrashMap) {
|
|
for (HashMap<Long, Long> longIntegerHashMap : afterCrashMap) {
|
|
for (Map.Entry<Long, Long> entry : longIntegerHashMap.entrySet()) {
|
|
for (Map.Entry<Long, Long> entry : longIntegerHashMap.entrySet()) {
|
|
- if (ptProfit.getPtGrossAdd() <= 0) {
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
|
|
+ //暂时不设限制扣减
|
|
|
|
+// if (ptProfit.getPtGrossAdd() <= 0) {
|
|
|
|
+// break;
|
|
|
|
+// }
|
|
// 当前平台总积分
|
|
// 当前平台总积分
|
|
// Integer ptTotalAdd = ptProfit.getPtTotalAdd();
|
|
// Integer ptTotalAdd = ptProfit.getPtTotalAdd();
|
|
|
|
+
|
|
|
|
+ if(entry.getValue() == 0){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
// 扣除平台收益
|
|
// 扣除平台收益
|
|
log.info("扣除平台收益[合赢奖] " + "用户 " + entry.getKey() + "额度: " + entry.getValue());
|
|
log.info("扣除平台收益[合赢奖] " + "用户 " + entry.getKey() + "额度: " + entry.getValue());
|
|
ptProfit.setPtGrossAdd(ptProfit.getPtGrossAdd() - entry.getValue());
|
|
ptProfit.setPtGrossAdd(ptProfit.getPtGrossAdd() - entry.getValue());
|
|
@@ -317,15 +331,46 @@ public class PartitionCrashServiceImpl implements PartitionCrashService {
|
|
ptProfit.setPtTotalAdd(ptProfit.getPtTotalAdd() - entry.getValue());
|
|
ptProfit.setPtTotalAdd(ptProfit.getPtTotalAdd() - entry.getValue());
|
|
// 碰撞后的额度添加到日志中 增加日志模块
|
|
// 碰撞后的额度添加到日志中 增加日志模块
|
|
ptProfitLogService.addMessage(entry.getKey(), CaclEnum.AFTER_CRASH_CALC_PT_TOTAL_QUOTA
|
|
ptProfitLogService.addMessage(entry.getKey(), CaclEnum.AFTER_CRASH_CALC_PT_TOTAL_QUOTA
|
|
- , -entry.getValue(), ptProfit.getPtTotalAdd() - entry.getValue(), JsonUtils.toJsonString(orderPercentageDO));
|
|
|
|
|
|
+ , -entry.getValue(), ptProfit.getPtTotalAdd(), JsonUtils.toJsonString(orderPercentageDO));
|
|
ptProfitLogService.addMessage(entry.getKey(), CaclEnum.AFTER_CRASH_CALC_PT_TOTAL_GROSS_QUOTA
|
|
ptProfitLogService.addMessage(entry.getKey(), CaclEnum.AFTER_CRASH_CALC_PT_TOTAL_GROSS_QUOTA
|
|
- , -entry.getValue(), ptProfit.getPtTotalAdd() - entry.getValue(), JsonUtils.toJsonString(orderPercentageDO));
|
|
|
|
|
|
+ , -entry.getValue(), ptProfit.getPtTotalAdd(), JsonUtils.toJsonString(orderPercentageDO));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
ptProfitService.updatePtProfit(PtProfitSaveReqVO.builder().id(ptProfit.getId())
|
|
ptProfitService.updatePtProfit(PtProfitSaveReqVO.builder().id(ptProfit.getId())
|
|
.ptAdd(ptProfit.getPtAdd())
|
|
.ptAdd(ptProfit.getPtAdd())
|
|
.ptGrossAdd(ptProfit.getPtGrossAdd())
|
|
.ptGrossAdd(ptProfit.getPtGrossAdd())
|
|
.ptTotalAdd(ptProfit.getPtTotalAdd()).build());
|
|
.ptTotalAdd(ptProfit.getPtTotalAdd()).build());
|
|
|
|
+
|
|
|
|
+ // 计算平台当日的碰撞支出
|
|
|
|
+ Long sum = 0L;
|
|
|
|
+ for (HashMap<Long, Long> hashMap : afterCrashMap) {
|
|
|
|
+ for (Map.Entry<Long, Long> entry : hashMap.entrySet()) {
|
|
|
|
+ if (entry.getValue() != 0) {
|
|
|
|
+ sum += entry.getValue();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ createPtProfitDailyStatisticsLog(sum);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void createPtProfitDailyStatisticsLog(Long sum) {
|
|
|
|
+ LocalDate now = LocalDate.now();
|
|
|
|
+
|
|
|
|
+ //确保每天只有一条记录
|
|
|
|
+ PtProfitDailyStatisticsLogDO ptLog = ptProfitDailyStatisticsLogMapper.selectByEveryday(now);
|
|
|
|
+ if (ptLog != null) {
|
|
|
|
+ ptProfitDailyStatisticsLogMapper.deleteById(ptLog.getId());
|
|
|
|
+ }
|
|
|
|
+ //获取平台总收益
|
|
|
|
+ PtProfitDO ptProfitDO = ptProfitMapper.selectList().get(0);
|
|
|
|
+
|
|
|
|
+ ptLog = new PtProfitDailyStatisticsLogDO();
|
|
|
|
+ ptLog.setEveryday(now);
|
|
|
|
+ ptLog.setTotalCollisionAmount(sum);
|
|
|
|
+ ptLog.setTotalRemainingAmount(ptProfitDO.getPtGrossAdd());
|
|
|
|
+
|
|
|
|
+ ptProfitDailyStatisticsLogMapper.insert(ptLog);
|
|
}
|
|
}
|
|
|
|
|
|
public Boolean compare(Long highQuota, BigDecimal afterCrash) {
|
|
public Boolean compare(Long highQuota, BigDecimal afterCrash) {
|