|
|
@ -3,6 +3,7 @@ package com.qs.serve.modules.tzc.service.impl; |
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.qs.serve.common.exception.Assert; |
|
|
|
import com.qs.serve.common.utils.CopierUtil; |
|
|
|
import com.qs.serve.modules.tbs.common.TbsActivityState; |
|
|
|
import com.qs.serve.modules.tbs.common.TbsCostApplyState; |
|
|
@ -301,7 +302,9 @@ public class TzcRebateApplication4CostServiceImpl implements TzcRebateApplicatio |
|
|
|
@Override |
|
|
|
public BigDecimal getMaxLevelsAmount(List<TzcRebateLevels> levelsList, |
|
|
|
List<TzcRebateLevelsArgument> argumentList, |
|
|
|
List<TzcRebateLevelsConfig> configList){ |
|
|
|
List<TzcRebateLevelsConfig> configList, |
|
|
|
BigDecimal maxPeriodAmt, |
|
|
|
boolean hasCompensationFlag){ |
|
|
|
BigDecimal maxAmount = BigDecimal.ZERO; |
|
|
|
for (TzcRebateLevelsConfig config : configList) { |
|
|
|
Set<String> levelNumSet = Arrays.stream(config.getLevelConfigs()).collect(Collectors.toSet()); |
|
|
@ -311,7 +314,8 @@ public class TzcRebateApplication4CostServiceImpl implements TzcRebateApplicatio |
|
|
|
for (String levelNumStr : levelNumSet) { |
|
|
|
int levelNum = Integer.parseInt(levelNumStr); |
|
|
|
// 当前坎级最高返利金额
|
|
|
|
BigDecimal currentLevelMaxAmount = getCurrentLevelMaxAmount(levelsList, argumentList, levelNum); |
|
|
|
BigDecimal currentLevelMaxAmount = getCurrentLevelMaxAmount( |
|
|
|
levelsList, argumentList, levelNum,maxPeriodAmt,hasCompensationFlag); |
|
|
|
if (currentLevelMaxAmount.compareTo(BigDecimal.ZERO)>0){ |
|
|
|
currentConfAmount = currentConfAmount.add(currentLevelMaxAmount); |
|
|
|
} |
|
|
@ -331,7 +335,11 @@ public class TzcRebateApplication4CostServiceImpl implements TzcRebateApplicatio |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@NotNull |
|
|
|
private BigDecimal getCurrentLevelMaxAmount(List<TzcRebateLevels> levelsList, List<TzcRebateLevelsArgument> argumentList, int levelNum) { |
|
|
|
private BigDecimal getCurrentLevelMaxAmount(List<TzcRebateLevels> levelsList, |
|
|
|
List<TzcRebateLevelsArgument> argumentList, |
|
|
|
int levelNum, |
|
|
|
BigDecimal maxPeriodAmt, |
|
|
|
boolean hasCompensationFlag) { |
|
|
|
BigDecimal currentLevelMaxAmount = BigDecimal.ZERO; |
|
|
|
for (TzcRebateLevels levels : levelsList) { |
|
|
|
if(levels.getLevelNum()== levelNum){ |
|
|
@ -339,8 +347,29 @@ public class TzcRebateApplication4CostServiceImpl implements TzcRebateApplicatio |
|
|
|
BigDecimal currentArgAmount = BigDecimal.ZERO; |
|
|
|
for (TzcRebateLevelsArgument argument : argumentList) { |
|
|
|
if(argument.getLevelId().equals(levels.getId())){ |
|
|
|
if (argument.getMaxReturn().compareTo(currentArgAmount)>0){ |
|
|
|
currentArgAmount = argument.getMaxReturn(); |
|
|
|
BigDecimal argAmount = BigDecimal.ZERO; |
|
|
|
// 使用最高金额
|
|
|
|
if (argument.getMaxReturn()!=null){ |
|
|
|
argAmount = argument.getMaxReturn(); |
|
|
|
}else { |
|
|
|
// 使用固定金额
|
|
|
|
if (argument.getRateAmtFlag().equals(0)){ |
|
|
|
argAmount = argument.getReturnFixed(); |
|
|
|
}else if (argument.getRateAmtFlag().equals(1)){ |
|
|
|
// 使用比例金额(目标返利x比例)
|
|
|
|
if (argument.getSumAddFlag().equals(0)){ |
|
|
|
argAmount = argument.getReturnRate().multiply(maxPeriodAmt) |
|
|
|
.divide(BigDecimal.valueOf(100),2,RoundingMode.HALF_UP); |
|
|
|
}else{ |
|
|
|
// 增量返利缺参数:普通返利和需要年度补充则抛出异常
|
|
|
|
if ( argument.getBusinessType().equals(TzcArgTypes.LevelReturn.name()) || !hasCompensationFlag ){ |
|
|
|
Assert.throwEx("坎级("+levelNum+")基于增量但未设置最高返利金额,预算占用计算失败"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (argAmount.compareTo(currentArgAmount)>0){ |
|
|
|
currentArgAmount = argAmount; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|