Commit f20c071f by 吕明尚

修改会员等级滚动降级定时任务

parent 3b58b84a
...@@ -625,12 +625,7 @@ public class RedisTask { ...@@ -625,12 +625,7 @@ public class RedisTask {
//判断会员进度是否大于扣除进度 //判断会员进度是否大于扣除进度
} else if (consumerMember.getMembershipProgress().compareTo(sum[0].abs()) >= 0) { } else if (consumerMember.getMembershipProgress().compareTo(sum[0].abs()) >= 0) {
//会员进度减去扣除进度 //会员进度减去扣除进度
BigDecimal subtract = BigDecimal.ZERO; BigDecimal subtract = consumerMember.getMembershipProgress().subtract(sum[0]);
if (sum[0].compareTo(BigDecimal.ZERO) < 0) {
subtract = consumerMember.getMembershipProgress().add(sum[0]);
} else if (sum[0].compareTo(BigDecimal.ZERO) > 0) {
subtract = consumerMember.getMembershipProgress().subtract(sum[0]);
}
// consumerMember.setMembershipProgress(subtract); // consumerMember.setMembershipProgress(subtract);
// if (consumerMember.getMembershipProgress().compareTo(BigDecimal.valueOf(memberConfig.getLimitRequirements())) < 0) { // if (consumerMember.getMembershipProgress().compareTo(BigDecimal.valueOf(memberConfig.getLimitRequirements())) < 0) {
//等级降一级 //等级降一级
...@@ -640,13 +635,20 @@ public class RedisTask { ...@@ -640,13 +635,20 @@ public class RedisTask {
//转Map limitRequirements,MemberConfig //转Map limitRequirements,MemberConfig
Map<Long, MemberConfig> configMap = memberConfigService.list(new LambdaQueryWrapper<MemberConfig>() Map<Long, MemberConfig> configMap = memberConfigService.list(new LambdaQueryWrapper<MemberConfig>()
.orderByDesc(MemberConfig::getMembershipLevel)).stream().collect(Collectors.toMap(MemberConfig::getMembershipLevel, Function.identity())); .orderByDesc(MemberConfig::getMembershipLevel)).stream().collect(Collectors.toMap(MemberConfig::getMembershipLevel, Function.identity()));
//Map根
//判断subtract小于当前等级的积分,并大于下一等级的积分 //判断subtract小于当前等级的积分,并大于下一等级的积分
for (Map.Entry<Long, MemberConfig> entry : configMap.entrySet()) { for (Map.Entry<Long, MemberConfig> entry : configMap.entrySet()) {
if (subtract.compareTo(BigDecimal.valueOf(entry.getValue().getLimitRequirements())) < 0 && if (subtract.compareTo(BigDecimal.valueOf(entry.getValue().getLimitRequirements())) > 0 &&
subtract.compareTo(BigDecimal.valueOf(configMap.get(entry.getKey() - 1).getLimitRequirements())) >= 0 subtract.compareTo(BigDecimal.valueOf(configMap.get(entry.getKey() + 1).getLimitRequirements())) <= 0
&& entry.getKey().compareTo(Collections.min(configMap.keySet())) > 0) { && entry.getKey().compareTo(Collections.min(configMap.keySet())) > 0) {
consumerMember.setMembershipLevel(entry.getKey()); consumerMember.setMembershipLevel(entry.getKey());
consumerMember.setMembershipProgress(subtract); consumerMember.setMembershipProgress(subtract);
updateList.add(consumerMember);
return;
} else if (subtract.compareTo(BigDecimal.valueOf(configMap.get(Collections.min(configMap.keySet())).getLimitRequirements())) <= 0) {
consumerMember.setMembershipLevel(Collections.min(configMap.keySet()));
consumerMember.setMembershipProgress(subtract);
updateList.add(consumerMember);
return; return;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment