2cf8122d
姜超
feature(*): 考评指标计算
|
1
2
|
package cn.fw.morax.service.biz.calculator.eval.reward;
|
7e8fb0fe
姜超
feature(*): 考评计算修改
|
3
4
|
import cn.fw.common.cache.locker.DistributedLocker;
import cn.fw.morax.common.utils.PublicUtil;
|
7e8fb0fe
姜超
feature(*): 考评计算修改
|
5
|
import cn.fw.morax.domain.bo.eval.EvalGroupUserShop;
|
7e8fb0fe
姜超
feature(*): 考评计算修改
|
6
7
|
import cn.fw.morax.domain.db.eval.EvalGroupReward;
import cn.fw.morax.domain.db.eval.EvalGroupRewardParam;
|
9bac7a5e
姜超
feature(*): 判断是否命...
|
8
|
import cn.fw.morax.domain.db.eval.EvalGroupRewardPrecondition;
|
2cf8122d
姜超
feature(*): 考评指标计算
|
9
|
import cn.fw.morax.domain.enums.EvalRewardCalMethodEnum;
|
7e8fb0fe
姜超
feature(*): 考评计算修改
|
10
11
12
13
14
|
import cn.fw.morax.domain.enums.ParamTypeEnum;
import cn.fw.morax.service.data.eval.EvalGroupService;
import cn.fw.morax.service.data.eval.EvalGroupUserService;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
|
2cf8122d
姜超
feature(*): 考评指标计算
|
15
|
import lombok.extern.slf4j.Slf4j;
|
7e8fb0fe
姜超
feature(*): 考评计算修改
|
16
|
import org.springframework.beans.factory.annotation.Value;
|
7e8fb0fe
姜超
feature(*): 考评计算修改
|
17
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
2cf8122d
姜超
feature(*): 考评指标计算
|
18
|
import org.springframework.stereotype.Component;
|
7e8fb0fe
姜超
feature(*): 考评计算修改
|
19
|
import org.springframework.util.CollectionUtils;
|
2cf8122d
姜超
feature(*): 考评指标计算
|
20
21
|
import java.math.BigDecimal;
|
7e8fb0fe
姜超
feature(*): 考评计算修改
|
22
|
import java.math.RoundingMode;
|
da42a3d8
姜超
feature(*): 计算考评代码优化
|
23
24
25
|
import java.util.HashMap;
import java.util.List;
import java.util.Map;
|
2cf8122d
姜超
feature(*): 考评指标计算
|
26
27
28
29
30
31
32
33
|
/**
* @author jiangchao
* @des: 总金额占比
* @date 2023/2/1 11:03
*/
@Component
@Slf4j
|
7e8fb0fe
姜超
feature(*): 考评计算修改
|
34
|
@RequiredArgsConstructor
|
6bd58854
姜超
feature(*): 考评导入修改
|
35
|
public class EvalRewardProportionCalculator extends EvalRewardBaseCalculator {
|
2cf8122d
姜超
feature(*): 考评指标计算
|
36
|
|
2cf8122d
姜超
feature(*): 考评指标计算
|
37
38
39
40
41
42
|
@Override
public EvalRewardCalMethodEnum getCalMethod() {
return EvalRewardCalMethodEnum.TOTAL_PROPORTION;
}
@Override
|
e2386ce2
姜超
feature(*): 考评计算得分修改
|
43
|
public BigDecimal calculate(EvalGroupUserShop param, EvalGroupReward rewardBO) {
|
2cf8122d
姜超
feature(*): 考评指标计算
|
44
45
|
return null;
}
|
7e8fb0fe
姜超
feature(*): 考评计算修改
|
46
47
|
@Override
|
e2386ce2
姜超
feature(*): 考评计算得分修改
|
48
|
public void calculateGroup(List<EvalGroupUserShop> userShops, EvalGroupReward reward) {
|
7e8fb0fe
姜超
feature(*): 考评计算修改
|
49
50
51
|
if (PublicUtil.isEmpty(userShops)) {
return;
}
|
9bac7a5e
姜超
feature(*): 判断是否命...
|
52
|
|
da42a3d8
姜超
feature(*): 计算考评代码优化
|
53
|
initReward(userShops);
|
e2386ce2
姜超
feature(*): 考评计算得分修改
|
54
|
final Long evalGroupRewardId = reward.getId();
|
9bac7a5e
姜超
feature(*): 判断是否命...
|
55
|
List<EvalGroupRewardPrecondition> preconditions = queryPrecondition(evalGroupRewardId);
|
e2386ce2
姜超
feature(*): 考评计算得分修改
|
56
|
BigDecimal money = reward.getMoney();
|
7e8fb0fe
姜超
feature(*): 考评计算修改
|
57
58
59
60
61
62
63
64
|
List<EvalGroupRewardParam> params = queryProjectParam(evalGroupRewardId, ParamTypeEnum.COMMISSION);
if (CollectionUtils.isEmpty(params)) {
return;
}
BigDecimal totalCommissionValue = BigDecimal.ZERO;
Map<Long, BigDecimal> referValueMap = new HashMap<>();
for (EvalGroupUserShop userShop : userShops) {
|
6d467cb8
姜超
feature(*): 计算修改
|
65
|
Long poolId = userShop.getPoolId();
|
7e8fb0fe
姜超
feature(*): 考评计算修改
|
66
67
|
BigDecimal commissionValue = calculateParamValue(userShop, params);
|
6d467cb8
姜超
feature(*): 计算修改
|
68
69
|
totalCommissionValue = totalCommissionValue.add(commissionValue);
referValueMap.put(poolId, commissionValue);
|
7e8fb0fe
姜超
feature(*): 考评计算修改
|
70
71
|
}
|
da42a3d8
姜超
feature(*): 计算考评代码优化
|
72
|
for (EvalGroupUserShop userShop : userShops) {
|
9bac7a5e
姜超
feature(*): 判断是否命...
|
73
|
boolean examined = examinePrecondition(userShop, preconditions);
|
9bac7a5e
姜超
feature(*): 判断是否命...
|
74
|
|
7f3e5385
姜超
feature(*): 展示占比字段
|
75
|
BigDecimal commissionValue = referValueMap.getOrDefault(userShop.getPoolId(), BigDecimal.ZERO);
|
08c31209
姜超
feature(*): 考评详情
|
76
77
78
79
|
BigDecimal proportion = BigDecimal.ZERO;
BigDecimal rewardValue = BigDecimal.ZERO;
if (totalCommissionValue.compareTo(BigDecimal.ZERO) > 0) {
|
2188d9d0
姜超
feature(*): 修改代码格式
|
80
81
|
proportion = commissionValue.divide(totalCommissionValue, 4, RoundingMode.DOWN);
rewardValue = proportion.multiply(money).divide(BigDecimal.ONE, 2, RoundingMode.DOWN);
|
08c31209
姜超
feature(*): 考评详情
|
82
|
}
|
7e8fb0fe
姜超
feature(*): 考评计算修改
|
83
|
|
c4a10f17
姜超
feature(*): 保存排名名次修改
|
84
85
86
87
88
|
//未通过条件,奖惩为0,保存日志
if (!examined) {
rewardValue = BigDecimal.ZERO;
}
|
da42a3d8
姜超
feature(*): 计算考评代码优化
|
89
90
|
userShop.setEvalGroupRewardAmount(rewardValue);
clearProjectHitLog(evalGroupRewardId, userShop);
|
08c31209
姜超
feature(*): 考评详情
|
91
92
|
BigDecimal finalRewardValue = rewardValue;
BigDecimal finalProportion = proportion;
|
da42a3d8
姜超
feature(*): 计算考评代码优化
|
93
|
saveProjectHitLog(evalGroupRewardId, userShop, log -> {
|
08c31209
姜超
feature(*): 考评详情
|
94
|
log.setRewardValue(finalRewardValue);
|
7f3e5385
姜超
feature(*): 展示占比字段
|
95
96
|
log.setProportionValue(finalProportion);
log.setHitCommissionValue(commissionValue);
|
7e8fb0fe
姜超
feature(*): 考评计算修改
|
97
98
99
|
});
}
}
|
08c31209
姜超
feature(*): 考评详情
|
100
|
|
2cf8122d
姜超
feature(*): 考评指标计算
|
101
|
}
|