|
@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
import com.qs.serve.common.exception.Assert; |
|
|
import com.qs.serve.common.exception.Assert; |
|
|
import com.qs.serve.common.utils.CopierUtil; |
|
|
import com.qs.serve.common.utils.CopierUtil; |
|
|
|
|
|
import com.qs.serve.framework.base.util.DebugStrUtil; |
|
|
import com.qs.serve.modules.tbs.common.TbsActivityState; |
|
|
import com.qs.serve.modules.tbs.common.TbsActivityState; |
|
|
import com.qs.serve.modules.tbs.common.TbsCostApplyState; |
|
|
import com.qs.serve.modules.tbs.common.TbsCostApplyState; |
|
|
import com.qs.serve.modules.tbs.entity.*; |
|
|
import com.qs.serve.modules.tbs.entity.*; |
|
@ -315,25 +316,39 @@ public class TzcRebateApplication4CostServiceImpl implements TzcRebateApplicatio |
|
|
List<TzcRebateLevelsConfig> configList, |
|
|
List<TzcRebateLevelsConfig> configList, |
|
|
BigDecimal maxPeriodAmt, |
|
|
BigDecimal maxPeriodAmt, |
|
|
boolean hasCompensationFlag){ |
|
|
boolean hasCompensationFlag){ |
|
|
|
|
|
DebugStrUtil.appendStr("是否需要年度补偿:"+hasCompensationFlag+";期间目标最大金额:"+maxPeriodAmt); |
|
|
BigDecimal maxAmount = BigDecimal.ZERO; |
|
|
BigDecimal maxAmount = BigDecimal.ZERO; |
|
|
|
|
|
String maxLevelNumConfig = ""; |
|
|
|
|
|
// 存储每坎级最高金额
|
|
|
|
|
|
Map<String,BigDecimal> levelAmountMap = new HashMap<>(); |
|
|
|
|
|
for (TzcRebateLevels levels : levelsList) { |
|
|
|
|
|
int levelNum = levels.getLevelNum(); |
|
|
|
|
|
BigDecimal levelAmt = getCurrentLevelMaxAmount(levelsList,argumentList,levelNum,maxPeriodAmt,hasCompensationFlag); |
|
|
|
|
|
levelAmountMap.put(levelNum+"",levelAmt); |
|
|
|
|
|
DebugStrUtil.appendStr("坎级 "+levelNum+" ,返利金额:"+levelAmt); |
|
|
|
|
|
} |
|
|
for (TzcRebateLevelsConfig config : configList) { |
|
|
for (TzcRebateLevelsConfig config : configList) { |
|
|
Set<String> levelNumSet = Arrays.stream(config.getLevelConfigs()).collect(Collectors.toSet()); |
|
|
Set<String> levelNumSet = Arrays.stream(config.getLevelConfigs()).collect(Collectors.toSet()); |
|
|
// 默认包含当前坎级
|
|
|
// 默认包含当前坎级
|
|
|
levelNumSet.add(config.getLevelNum()+""); |
|
|
levelNumSet.add(config.getLevelNum()+""); |
|
|
BigDecimal currentConfAmount = BigDecimal.ZERO; |
|
|
BigDecimal currentConfAmount = BigDecimal.ZERO; |
|
|
for (String levelNumStr : levelNumSet) { |
|
|
for (String levelNumStr : levelNumSet) { |
|
|
int levelNum = Integer.parseInt(levelNumStr); |
|
|
|
|
|
// 当前坎级最高返利金额
|
|
|
// 当前坎级最高返利金额
|
|
|
BigDecimal currentLevelMaxAmount = getCurrentLevelMaxAmount( |
|
|
BigDecimal currentLevelMaxAmount = levelAmountMap.get(levelNumStr); |
|
|
levelsList, argumentList, levelNum,maxPeriodAmt,hasCompensationFlag); |
|
|
|
|
|
if (currentLevelMaxAmount.compareTo(BigDecimal.ZERO)>0){ |
|
|
if (currentLevelMaxAmount.compareTo(BigDecimal.ZERO)>0){ |
|
|
currentConfAmount = currentConfAmount.add(currentLevelMaxAmount); |
|
|
currentConfAmount = currentConfAmount.add(currentLevelMaxAmount); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
String levelNumConfig = Arrays.stream(config.getLevelConfigs()).collect(Collectors.joining(",")); |
|
|
|
|
|
DebugStrUtil.appendStr("坎级叠加:" |
|
|
|
|
|
+ levelNumConfig |
|
|
|
|
|
+",合计金额:"+currentConfAmount); |
|
|
if (currentConfAmount.compareTo(maxAmount)>0){ |
|
|
if (currentConfAmount.compareTo(maxAmount)>0){ |
|
|
maxAmount = currentConfAmount; |
|
|
maxAmount = currentConfAmount; |
|
|
|
|
|
maxLevelNumConfig = levelNumConfig; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
DebugStrUtil.appendStr("使用坎级配置:"+maxLevelNumConfig+";最高坎级叠加金额:"+maxAmount); |
|
|
return maxAmount; |
|
|
return maxAmount; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -356,6 +371,10 @@ public class TzcRebateApplication4CostServiceImpl implements TzcRebateApplicatio |
|
|
// 排除返利和补偿返利的最高金额
|
|
|
// 排除返利和补偿返利的最高金额
|
|
|
BigDecimal currentArgAmount = BigDecimal.ZERO; |
|
|
BigDecimal currentArgAmount = BigDecimal.ZERO; |
|
|
for (TzcRebateLevelsArgument argument : argumentList) { |
|
|
for (TzcRebateLevelsArgument argument : argumentList) { |
|
|
|
|
|
// 不需要年度补偿则跳过
|
|
|
|
|
|
if (argument.getBusinessType().equals(TzcArgTypes.LevelOverallReturn.name())&&!hasCompensationFlag){ |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
if(argument.getLevelId().equals(levels.getId())){ |
|
|
if(argument.getLevelId().equals(levels.getId())){ |
|
|
BigDecimal argAmount = BigDecimal.ZERO; |
|
|
BigDecimal argAmount = BigDecimal.ZERO; |
|
|
// 使用最高金额
|
|
|
// 使用最高金额
|
|
@ -363,9 +382,9 @@ public class TzcRebateApplication4CostServiceImpl implements TzcRebateApplicatio |
|
|
argAmount = argument.getMaxReturn(); |
|
|
argAmount = argument.getMaxReturn(); |
|
|
}else { |
|
|
}else { |
|
|
// 使用固定金额
|
|
|
// 使用固定金额
|
|
|
if (argument.getRateAmtFlag().equals(0)){ |
|
|
if (argument.getRateAmtFlag().equals(1)){ |
|
|
argAmount = argument.getReturnFixed(); |
|
|
argAmount = argument.getReturnFixed(); |
|
|
}else if (argument.getRateAmtFlag().equals(1)){ |
|
|
}else if (argument.getRateAmtFlag().equals(0)){ |
|
|
// 使用比例金额(目标返利x比例)
|
|
|
// 使用比例金额(目标返利x比例)
|
|
|
if (argument.getSumAddFlag().equals(0)){ |
|
|
if (argument.getSumAddFlag().equals(0)){ |
|
|
argAmount = argument.getReturnRate().multiply(maxPeriodAmt) |
|
|
argAmount = argument.getReturnRate().multiply(maxPeriodAmt) |
|
|