|
|
@ -1,5 +1,6 @@ |
|
|
|
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.utils.CopierUtil; |
|
|
@ -22,6 +23,7 @@ import java.math.BigDecimal; |
|
|
|
import java.math.RoundingMode; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.stream.Collectors; |
|
|
@ -127,7 +129,7 @@ public class TzcRebateApplication4CostServiceImpl implements TzcRebateApplicatio |
|
|
|
activity.setRebatePeriodId(period.getId()); |
|
|
|
activity.setCostApplyId(costApplyId); |
|
|
|
activity.setActivityCode(rebate.getRebateCode()+"_"+(i+1)); |
|
|
|
activity.setActivityState(TbsActivityState.STATE_1_Finished); |
|
|
|
activity.setActivityState(TbsActivityState.STATE_0_Todo); |
|
|
|
activity.setCostPassFlag(0); |
|
|
|
activity.setActTitle(rebate.getRebateName()); |
|
|
|
activity.setSupplierId(rebate.getSupplierId()); |
|
|
@ -345,6 +347,9 @@ public class TzcRebateApplication4CostServiceImpl implements TzcRebateApplicatio |
|
|
|
.eq(TzcRebateLevels::getSamePeriodFlag, samePeriodFlag) |
|
|
|
.orderByDesc(TzcRebateLevels::getLevelNum) |
|
|
|
); |
|
|
|
if (CollUtil.isEmpty(levelsList)){ |
|
|
|
dto.appendErrorMsg(samePeriodFlag==0?"未找到匹配无同期的坎级":"未找到匹配有同期的坎级"); |
|
|
|
} |
|
|
|
dto.setSamePeriodLevelList(levelsList); |
|
|
|
// 命中的最高坎级
|
|
|
|
for (TzcRebateLevels levels : levelsList) { |
|
|
@ -357,29 +362,32 @@ public class TzcRebateApplication4CostServiceImpl implements TzcRebateApplicatio |
|
|
|
}else if (levels.getConditionType().equals(1)){ |
|
|
|
periodAmount = rebatePeriod.getPeriodAmount(); |
|
|
|
} |
|
|
|
BigDecimal targetAmt = periodAmount.multiply(levels.getConditionRate()) |
|
|
|
.divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP); |
|
|
|
// 发货金额大于坎级制定的百分比
|
|
|
|
boolean ok = dispatchAmt.compareTo( |
|
|
|
periodAmount.multiply(levels.getConditionRate()) |
|
|
|
.divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP) |
|
|
|
)>=0; |
|
|
|
boolean ok = dispatchAmt.compareTo(targetAmt)>=0; |
|
|
|
if (!ok){ |
|
|
|
log.debug("命中最高坎级:"+levels.getLevelNum()+",条件比重:"+levels.getConditionRate()+"%"); |
|
|
|
dto.appendDebugMsg("跳过坎级:"+levels.getLevelNum()+",条件金额:"+targetAmt+",发货金额:"+dispatchAmt); |
|
|
|
log.debug("跳过坎级:{},条件金额:{},发货金额:{}",levels.getLevelNum(),targetAmt,dispatchAmt); |
|
|
|
continue; |
|
|
|
} |
|
|
|
dto.appendDebugMsg("命中坎级:"+levels.getLevelNum()+",条件金额:"+targetAmt+",发货金额:"+dispatchAmt); |
|
|
|
dto.setMaxLevels(levels); |
|
|
|
return dto; |
|
|
|
}else if (levels.getConditionSelect().equals(1)){ |
|
|
|
// 发货金额大于坎级制定的固定金额
|
|
|
|
boolean ok = dispatchAmt.compareTo(levels.getConditionAmount())>=0; |
|
|
|
if (!ok){ |
|
|
|
log.debug("命中最高坎级:"+levels.getLevelNum()+",条件固定金额:"+levels.getConditionAmount()); |
|
|
|
dto.appendDebugMsg("跳过坎级:"+levels.getLevelNum()+",条件金额:"+levels.getConditionAmount()+",发货金额:"+dispatchAmt); |
|
|
|
log.debug("跳过坎级:{},条件金额:{},发货金额:{}",levels.getLevelNum(),levels.getConditionAmount(),dispatchAmt); |
|
|
|
continue; |
|
|
|
} |
|
|
|
dto.appendDebugMsg("命中坎级:"+levels.getLevelNum()+",条件固定金额:"+levels.getConditionAmount()+",发货金额:"+dispatchAmt); |
|
|
|
dto.setMaxLevels(levels); |
|
|
|
return dto; |
|
|
|
} |
|
|
|
} |
|
|
|
return null; |
|
|
|
return dto; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -387,11 +395,10 @@ public class TzcRebateApplication4CostServiceImpl implements TzcRebateApplicatio |
|
|
|
BigDecimal dispatchAmt, |
|
|
|
BigDecimal sameDispatchAmt, |
|
|
|
TzcArgTypes argType) { |
|
|
|
if (dto==null){ |
|
|
|
log.debug("没有命中坎级"); |
|
|
|
TzcRebateLevels levels = dto.getMaxLevels(); |
|
|
|
if (levels==null){ |
|
|
|
return null; |
|
|
|
} |
|
|
|
TzcRebateLevels levels = dto.getMaxLevels(); |
|
|
|
List<TzcRebateLevels> allRebateLvList = dto.getSamePeriodLevelList(); |
|
|
|
|
|
|
|
TzcRebateLevelsConfig levelsConfig = tzcRebateLevelsConfigService.getOne( |
|
|
@ -403,9 +410,12 @@ public class TzcRebateApplication4CostServiceImpl implements TzcRebateApplicatio |
|
|
|
String[] configArr; |
|
|
|
if (levelsConfig==null){ |
|
|
|
log.warn("没有坎级配置:"+levels.getLevelNum()+";返利ID:"+levels.getRebateId()); |
|
|
|
dto.appendDebugMsg("没有坎级配置:"+levels.getLevelNum()+";返利ID:"+levels.getRebateId()); |
|
|
|
configArr = new String[]{levels.getLevelNum()+""}; |
|
|
|
}else { |
|
|
|
log.debug("读取坎级配置,坎级:"+levels.getLevelNum()); |
|
|
|
dto.appendDebugMsg("读取坎级("+levels.getLevelNum()+")配置 ,配置叠级:" |
|
|
|
+ String.join(",", levelsConfig.getLevelConfigs())); |
|
|
|
configArr = levelsConfig.getLevelConfigs(); |
|
|
|
} |
|
|
|
// 获取命中的坎级
|
|
|
@ -467,6 +477,7 @@ public class TzcRebateApplication4CostServiceImpl implements TzcRebateApplicatio |
|
|
|
}else { |
|
|
|
rebateLevelsDTO.setReturnAmt(BigDecimal.ZERO); |
|
|
|
log.warn("返利参数TzcRebateLevelsArgument-ID:{},返利金额小于0",currentArgument.getId()); |
|
|
|
dto.appendErrorMsg("返利参数TzcRebateLevelsArgument-ID:"+currentArgument.getId()+",返利金额小于0"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|