|
@@ -267,44 +267,99 @@ public class PartitionCrashServiceImpl implements PartitionCrashService {
|
|
|
|
|
|
BigDecimal smallBigDecimal = new BigDecimal(String.valueOf(smallQuota));
|
|
|
BigDecimal multiply = smallBigDecimal.divide(new BigDecimal("2.0"), 4, RoundingMode.DOWN);
|
|
|
- if (compare(highQuota, multiply) && multiply.longValue() != 0) {
|
|
|
- integralDO.setCurrentQuota(integralDO.getCurrentQuota() + multiply.intValue());
|
|
|
- integralDO.setHighQuota(integralDO.getHighQuota() - multiply.intValue());
|
|
|
+ //直推人的本次添加积分
|
|
|
+ Long amount = 0L;
|
|
|
+ //平台需要补回的收益(也可以理解为用户溢出)
|
|
|
+ Long ptReplenish = multiply.longValue();
|
|
|
+
|
|
|
+ //直推人
|
|
|
+ if (multiply.longValue() != 0) {
|
|
|
+ if (highQuota.compareTo(0L) > 0) {
|
|
|
+
|
|
|
+ if (highQuota.compareTo(multiply.longValue()) > 0) {
|
|
|
+ amount = multiply.longValue();
|
|
|
+ ptReplenish = 0L;
|
|
|
+ } else {
|
|
|
+ amount = highQuota;
|
|
|
+ ptReplenish = multiply.longValue() - highQuota;
|
|
|
+ }
|
|
|
+ addHighQuota(userHighQuotaMap, integralDO.getUserId(), amount);
|
|
|
+ }
|
|
|
+ integralDO.setCurrentQuota(integralDO.getCurrentQuota() + amount);
|
|
|
+ integralDO.setHighQuota(integralDO.getHighQuota() - amount);
|
|
|
|
|
|
- addHighQuota(userHighQuotaMap, integralDO.getUserId(), (long) multiply.intValue());
|
|
|
|
|
|
- integralDO.setAccumulatedQuota(integralDO.getAccumulatedQuota() + multiply.intValue());
|
|
|
+ integralDO.setAccumulatedQuota(integralDO.getAccumulatedQuota() + amount);
|
|
|
// 碰撞后的额度添加到日志中 增加日志模块
|
|
|
integralService.updateIntegral(BeanUtils.toBean(integralDO, IntegralSaveReqVO.class));
|
|
|
- ptProfitLogService.addMessage(k.getUserId(), CaclEnum.SMALL_QUOTA_CRASH, Long.parseLong(String.valueOf(multiply.intValue())), integralDO.getCurrentQuota(), JsonUtils.toJsonString(orderPercentageDO));
|
|
|
+ ptProfitLogService.addMessage(k.getUserId(), CaclEnum.SMALL_QUOTA_CRASH, amount,
|
|
|
+ integralDO.getCurrentQuota(), JsonUtils.toJsonString(orderPercentageDO), ptReplenish);
|
|
|
}
|
|
|
- if (compare(parentHighQuota, multiply) && multiply.longValue() != 0) {
|
|
|
- // 减去最高额度
|
|
|
- parentIntegralDo.setCurrentQuota(parentIntegralDo.getCurrentQuota() + multiply.intValue());
|
|
|
- parentIntegralDo.setHighQuota(parentIntegralDo.getHighQuota() - multiply.intValue());
|
|
|
|
|
|
- addHighQuota(userHighQuotaMap, parentIntegralDo.getUserId(), (long) multiply.intValue());
|
|
|
+ //直推人的上级的本次添加积分
|
|
|
+ Long parentAmount = 0L;
|
|
|
+ //平台需要补回的收益(也可以理解为用户溢出)
|
|
|
+ Long parentPtReplenish = multiply.longValue();
|
|
|
+ //直推人的父级
|
|
|
+ if (multiply.longValue() != 0) {
|
|
|
+ if (parentHighQuota.compareTo(0L) > 0) {
|
|
|
+ if (parentHighQuota.compareTo(multiply.longValue()) > 0) {
|
|
|
+ parentAmount = multiply.longValue();
|
|
|
+ parentPtReplenish = 0L;
|
|
|
+ } else {
|
|
|
+ parentAmount = highQuota;
|
|
|
+ parentPtReplenish = multiply.longValue() - highQuota;
|
|
|
+ }
|
|
|
+ addHighQuota(userHighQuotaMap, parentIntegralDo.getUserId(), parentAmount);
|
|
|
+ }
|
|
|
+ // 减去最高额度
|
|
|
+ parentIntegralDo.setHighQuota(parentIntegralDo.getHighQuota() - parentAmount);
|
|
|
+ parentIntegralDo.setCurrentQuota(parentIntegralDo.getCurrentQuota() + parentAmount);
|
|
|
|
|
|
- parentIntegralDo.setAccumulatedQuota(parentIntegralDo.getAccumulatedQuota() + multiply.intValue());
|
|
|
+ parentIntegralDo.setAccumulatedQuota(parentIntegralDo.getAccumulatedQuota() + parentAmount);
|
|
|
// 碰撞后的额度添加到日志中 增加日志模块
|
|
|
integralService.updateIntegral(BeanUtils.toBean(parentIntegralDo, IntegralSaveReqVO.class));
|
|
|
- ptProfitLogService.addMessage(parentIntegralDo.getUserId(), CaclEnum.SMALL_QUOTA_CRASH, Long.parseLong(String.valueOf(multiply.intValue())), parentIntegralDo.getCurrentQuota(), JsonUtils.toJsonString(orderPercentageDO));
|
|
|
+ ptProfitLogService.addMessage(parentIntegralDo.getUserId(), CaclEnum.SMALL_QUOTA_CRASH, parentAmount,
|
|
|
+ parentIntegralDo.getCurrentQuota(), JsonUtils.toJsonString(orderPercentageDO), parentPtReplenish);
|
|
|
}
|
|
|
- if (highQuota < multiply.longValue() && multiply.longValue() != 0L) {
|
|
|
- calcIntegral(multiply.longValue(), integralDO.getUserId(), JsonUtils.toJsonString(orderPercentageDO));
|
|
|
+// if (compare(highQuota, multiply) && multiply.longValue() != 0) {
|
|
|
+// integralDO.setCurrentQuota(integralDO.getCurrentQuota() + multiply.intValue());
|
|
|
+// integralDO.setHighQuota(integralDO.getHighQuota() - multiply.intValue());
|
|
|
+//
|
|
|
+// addHighQuota(userHighQuotaMap, integralDO.getUserId(), (long) multiply.intValue());
|
|
|
+//
|
|
|
+// integralDO.setAccumulatedQuota(integralDO.getAccumulatedQuota() + multiply.intValue());
|
|
|
+// // 碰撞后的额度添加到日志中 增加日志模块
|
|
|
+// integralService.updateIntegral(BeanUtils.toBean(integralDO, IntegralSaveReqVO.class));
|
|
|
+// ptProfitLogService.addMessage(k.getUserId(), CaclEnum.SMALL_QUOTA_CRASH, Long.parseLong(String.valueOf(multiply.intValue())), integralDO.getCurrentQuota(), JsonUtils.toJsonString(orderPercentageDO));
|
|
|
+// }
|
|
|
+// if (compare(parentHighQuota, multiply) && multiply.longValue() != 0) {
|
|
|
+// // 减去最高额度
|
|
|
+// parentIntegralDo.setCurrentQuota(parentIntegralDo.getCurrentQuota() + multiply.intValue());
|
|
|
+// parentIntegralDo.setHighQuota(parentIntegralDo.getHighQuota() - multiply.intValue());
|
|
|
+//
|
|
|
+// addHighQuota(userHighQuotaMap, parentIntegralDo.getUserId(), (long) multiply.intValue());
|
|
|
+//
|
|
|
+// parentIntegralDo.setAccumulatedQuota(parentIntegralDo.getAccumulatedQuota() + multiply.intValue());
|
|
|
+// // 碰撞后的额度添加到日志中 增加日志模块
|
|
|
+// integralService.updateIntegral(BeanUtils.toBean(parentIntegralDo, IntegralSaveReqVO.class));
|
|
|
+// ptProfitLogService.addMessage(parentIntegralDo.getUserId(), CaclEnum.SMALL_QUOTA_CRASH, Long.parseLong(String.valueOf(multiply.intValue())), parentIntegralDo.getCurrentQuota(), JsonUtils.toJsonString(orderPercentageDO));
|
|
|
+// }
|
|
|
+ if (!ptReplenish.equals(0L)) {
|
|
|
+ calcIntegral(ptReplenish, integralDO.getUserId(), JsonUtils.toJsonString(orderPercentageDO));
|
|
|
}
|
|
|
- if (parentHighQuota < multiply.longValue() && multiply.longValue() != 0L) {
|
|
|
- calcIntegral(multiply.longValue(), parentIntegralDo.getUserId(), JsonUtils.toJsonString(orderPercentageDO));
|
|
|
+ if (!parentPtReplenish.equals(0L)) {
|
|
|
+ calcIntegral(parentPtReplenish, parentIntegralDo.getUserId(), JsonUtils.toJsonString(orderPercentageDO));
|
|
|
}
|
|
|
|
|
|
// 获取计算后积分, Long为userId, Integer为碰撞后额度
|
|
|
HashMap<Long, Long> map = new HashMap<>();
|
|
|
// 如果为当前用户为平台,则不需要存入这个地方
|
|
|
if (!k.getUserId().equals(PT_ID)) {
|
|
|
- map.put(k.getUserId(), multiply.longValue());
|
|
|
+ map.put(k.getUserId(), amount);
|
|
|
}
|
|
|
if (!parentIntegralDo.getUserId().equals(PT_ID)) {
|
|
|
- map.put(parentIntegralDo.getUserId(), multiply.longValue());
|
|
|
+ map.put(parentIntegralDo.getUserId(), parentAmount);
|
|
|
}
|
|
|
afterCrashMap.add(map);
|
|
|
|
|
@@ -335,8 +390,6 @@ public class PartitionCrashServiceImpl implements PartitionCrashService {
|
|
|
// if (ptProfit.getPtGrossAdd() <= 0) {
|
|
|
// break;
|
|
|
// }
|
|
|
- // 当前平台总积分
|
|
|
-// Integer ptTotalAdd = ptProfit.getPtTotalAdd();
|
|
|
|
|
|
if (entry.getValue() == 0) {
|
|
|
continue;
|
|
@@ -345,8 +398,6 @@ public class PartitionCrashServiceImpl implements PartitionCrashService {
|
|
|
// 获取当前用户的钱包
|
|
|
IntegralDO integralDO = integralDOMap.get(entry.getKey());
|
|
|
// 获取当前父亲的钱包
|
|
|
-// Long parent = sonAndParent.get(entry.getKey());
|
|
|
-// IntegralDO parentIntegralDo = integralDOMap.get(parent);
|
|
|
Long highQuota = integralDO.getHighQuota() + new BigDecimal(orderPercentageDO.getBaseMaxQuota()).longValue(); //加上基础的最大额度值
|
|
|
|
|
|
for (Long key : userHighQuotaMap.keySet()) {
|
|
@@ -359,27 +410,55 @@ public class PartitionCrashServiceImpl implements PartitionCrashService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// Long parentHighQuota = parentIntegralDo.getHighQuota() + new BigDecimal(orderPercentageDO.getBaseMaxQuota()).longValue();
|
|
|
- if (highQuota >= entry.getValue()) {
|
|
|
-// integralDO.setHighQuota(integralDO.getHighQuota() - entry.getValue());
|
|
|
+
|
|
|
+ //amount用于记录本次添加的值
|
|
|
+ Long amount = 0L;
|
|
|
+ //平台需要补回的收益
|
|
|
+ Long ptReplenish = entry.getValue();
|
|
|
+
|
|
|
+ //如果直推人的可获取额度大于0,则能够获取
|
|
|
+ if (highQuota.compareTo(0L) > 0) {
|
|
|
+ if (highQuota.compareTo(entry.getValue()) > 0) {
|
|
|
+ //如果最大额度 > 直推人可获取额度,则直接获取
|
|
|
+ amount = entry.getValue();
|
|
|
+ //平台没有需要补回的收益
|
|
|
+ ptReplenish = 0L;
|
|
|
+ } else {
|
|
|
+ //如果最大额度 < 直推人可获取额度,则获取自己的最大额度
|
|
|
+ amount = highQuota;
|
|
|
+ //用户本次没有拿到的直推奖
|
|
|
+ ptReplenish = entry.getValue() - highQuota;
|
|
|
+ }
|
|
|
+
|
|
|
integralService.updateIntegral(BeanUtils.toBean(integralDO, IntegralSaveReqVO.class));
|
|
|
-// if (parentHighQuota >= entry.getValue()) {
|
|
|
-// parentIntegralDo.setHighQuota(parentIntegralDo.getHighQuota() - entry.getValue());
|
|
|
-// integralService.updateIntegral(BeanUtils.toBean(parentIntegralDo, IntegralSaveReqVO.class));
|
|
|
-// }
|
|
|
|
|
|
|
|
|
// 扣除平台收益
|
|
|
- log.info("扣除平台收益[合赢奖] " + "用户 " + entry.getKey() + "额度: " + entry.getValue());
|
|
|
- ptProfit.setPtGrossAdd(ptProfit.getPtGrossAdd() - entry.getValue());
|
|
|
+ log.info("扣除平台收益[合赢奖] " + "用户 " + entry.getKey() + "额度: " + amount);
|
|
|
+ ptProfit.setPtGrossAdd(ptProfit.getPtGrossAdd() - amount);
|
|
|
// 平台扣除积分
|
|
|
- ptProfit.setPtTotalAdd(ptProfit.getPtTotalAdd() - entry.getValue());
|
|
|
+ ptProfit.setPtTotalAdd(ptProfit.getPtTotalAdd() - amount);
|
|
|
// 碰撞后的额度添加到日志中 增加日志模块
|
|
|
ptProfitLogService.addMessage(entry.getKey(), CaclEnum.AFTER_CRASH_CALC_PT_TOTAL_QUOTA
|
|
|
- , -entry.getValue(), ptProfit.getPtTotalAdd(), JsonUtils.toJsonString(orderPercentageDO));
|
|
|
+ , -entry.getValue(), ptProfit.getPtTotalAdd(), JsonUtils.toJsonString(orderPercentageDO), null);
|
|
|
ptProfitLogService.addMessage(entry.getKey(), CaclEnum.AFTER_CRASH_CALC_PT_TOTAL_GROSS_QUOTA
|
|
|
- , -entry.getValue(), ptProfit.getPtTotalAdd(), JsonUtils.toJsonString(orderPercentageDO));
|
|
|
+ , -entry.getValue(), ptProfit.getPtGrossAdd(), JsonUtils.toJsonString(orderPercentageDO), null);
|
|
|
}
|
|
|
+// if (highQuota.compareTo(0L) > 0) {
|
|
|
+// integralService.updateIntegral(BeanUtils.toBean(integralDO, IntegralSaveReqVO.class));
|
|
|
+//
|
|
|
+//
|
|
|
+// // 扣除平台收益
|
|
|
+// log.info("扣除平台收益[合赢奖] " + "用户 " + entry.getKey() + "额度: " + entry.getValue());
|
|
|
+// ptProfit.setPtGrossAdd(ptProfit.getPtGrossAdd() - entry.getValue());
|
|
|
+// // 平台扣除积分
|
|
|
+// ptProfit.setPtTotalAdd(ptProfit.getPtTotalAdd() - entry.getValue());
|
|
|
+// // 碰撞后的额度添加到日志中 增加日志模块
|
|
|
+// ptProfitLogService.addMessage(entry.getKey(), CaclEnum.AFTER_CRASH_CALC_PT_TOTAL_QUOTA
|
|
|
+// , -entry.getValue(), ptProfit.getPtTotalAdd(), JsonUtils.toJsonString(orderPercentageDO),null);
|
|
|
+// ptProfitLogService.addMessage(entry.getKey(), CaclEnum.AFTER_CRASH_CALC_PT_TOTAL_GROSS_QUOTA
|
|
|
+// , -entry.getValue(), ptProfit.getPtTotalAdd(), JsonUtils.toJsonString(orderPercentageDO),null);
|
|
|
+// }
|
|
|
}
|
|
|
}
|
|
|
ptProfitService.updatePtProfit(PtProfitSaveReqVO.builder().id(ptProfit.getId())
|
|
@@ -413,8 +492,8 @@ public class PartitionCrashServiceImpl implements PartitionCrashService {
|
|
|
|
|
|
private void calcIntegral(Long multiply, Long userId, String jsonString) {
|
|
|
PtProfitDO ptProfit = ptProfitService.getPtProfit();
|
|
|
- ptProfitLogService.addMessage(userId, CaclEnum.GROSS_PROFIT_BONUS_QUOTA_PERC_EXCEED_MAXIMUM_LIMIT, multiply,
|
|
|
- ptProfit.getPtTotalAdd(), jsonString);
|
|
|
+ ptProfitLogService.addMessage(null, CaclEnum.GROSS_PROFIT_BONUS_QUOTA_PERC_EXCEED_MAXIMUM_LIMIT, multiply,
|
|
|
+ ptProfit.getPtTotalAdd(), jsonString, userId);
|
|
|
}
|
|
|
|
|
|
private void createPtProfitDailyStatisticsLog(Long sum) {
|