Commit 7f77896b authored by Smile's avatar Smile Committed by wux

会员等级修改,1.定时任务从高等级往下匹配,2.可手动设置等级

parent 8fe46b79
......@@ -50,28 +50,34 @@ public class MemberUserLevelDetailsController {
@ApiOperation("更新等级详情")
public CommonResult<Boolean> update(@Valid @RequestBody MemberUserLevelDetailsQueryVO reqVO) {
Long id = reqVO.getId();
MemberUserLevelDetailsDO memberUserLevelDetailsDO = memberUserLevelDetailsService.getById(id);
if (memberUserLevelDetailsDO == null) {
return error(ErrorCodeConstants.LEVEL_DETAILs_NOT_EXISTS);
MemberUserLevelDetailsDO memberUserLevelDetailsDO;
if (reqVO.getId() != null){
memberUserLevelDetailsDO = memberUserLevelDetailsService.getById(reqVO.getId());
if (memberUserLevelDetailsDO == null) {
return error(ErrorCodeConstants.LEVEL_DETAILs_NOT_EXISTS);
}
}else {
memberUserLevelDetailsDO = new MemberUserLevelDetailsDO();
}
LambdaQueryWrapper<MemberUserLevelConfigDO> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(MemberUserLevelConfigDO::getLevel, reqVO.getLevel());
// 执行查询
MemberUserLevelConfigDO configDO = memberUserLevelConfigMapper.selectOne(wrapper);
if (configDO==null){
return error(ErrorCodeConstants.LEVEL_RULE_NOT_EXISTS);
MemberUserLevelConfigDO configDO = new MemberUserLevelConfigDO();
if (memberUserLevelDetailsDO.getConfigId()!=null){
configDO = memberUserLevelConfigMapper.selectById(memberUserLevelDetailsDO.getConfigId());
if (configDO == null) {
return error(ErrorCodeConstants.LEVEL_RULE_NOT_EXISTS);
}
if(configDO.getLevel().equals(reqVO.getLevel())){
memberUserLevelDetailsDO.setConfigId(null);
}
}
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
memberUserLevelDetailsDO.setLevel(reqVO.getLevel());
memberUserLevelDetailsDO.setMemberId(reqVO.getMemberId());
memberUserLevelDetailsDO.setValidityPeriod(reqVO.getValidityPeriod());
memberUserLevelDetailsDO.setSpecificSettings(reqVO.getSpecificSettings());
memberUserLevelDetailsDO.setRemarks(reqVO.getRemarks());
memberUserLevelDetailsDO.setConfigId(configDO.getId());
memberUserLevelDetailsDO.setUpdateTime(new Date());
memberUserLevelDetailsDO.setUpdater(String.valueOf(loginUser.getId()));
memberUserLevelDetailsService.updateById(memberUserLevelDetailsDO);
memberUserLevelDetailsService.saveOrUpdate(memberUserLevelDetailsDO);
//添加操作日志
MemberUserLevelOperateLogDO memberUserLevelOperateLogDo = MemberUserLevelOperateLogDO.builder()
......
......@@ -153,9 +153,9 @@ public class MemberUserController {
queryWrapper.eq("member_id",user.getId());
MemberUserLevelDetailsDO memberUserLevelDetailsDO = memberUserLevelDetailsMapper.selectOne(queryWrapper);
MemberUserScoreLevelVO scoreLevelVO;
if (memberUserLevelDetailsDO != null){
if (memberUserLevelDetailsDO != null && memberUserLevelDetailsDO.getConfigId() != null) {
MemberUserLevelConfigDO realLevel = memberUserLevelConfigService.getById(memberUserLevelDetailsDO.getConfigId());
scoreLevelVO = MemberUserScoreLevelVO.builder().memberId(user.getId())
scoreLevelVO = MemberUserScoreLevelVO.builder().memberId(user.getId())
.memberCode(user.getMemberCode())
.holdScore(user.getHoldScore())
.expiredScore(user.getExpiredScore())
......@@ -164,7 +164,7 @@ public class MemberUserController {
.levelName(realLevel.getName())
.level(realLevel.getLevel())
.build();
}else {
} else {
scoreLevelVO = MemberUserScoreLevelVO.builder().memberId(user.getId())
.memberCode(user.getMemberCode())
.holdScore(user.getHoldScore())
......@@ -172,7 +172,7 @@ public class MemberUserController {
.usedScore(user.getUsedScore())
.levelIcon(null)
.levelName(null)
.level(null)
.level(memberUserLevelDetailsDO!=null?memberUserLevelDetailsDO.getLevel():null)
.build();
}
// MemberUserLevelConfigBaseRespVO userScoreLevelVO = memberUserLevelConfigService.getLevelByCount(user.getTotalScore());
......
......@@ -26,6 +26,7 @@ import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.Map;
......@@ -67,7 +68,7 @@ public class userLevelDetailsTask implements JobHandler {
if (CollectionUtils.isEmpty(todoList)) {
return "success";
} else {
todoList.forEach(userLevelConfigDO -> {
todoList.stream().sorted(Comparator.comparing(MemberUserLevelConfigDO::getLevel).reversed()).forEach(userLevelConfigDO -> {
log.info("规则名称:{}",userLevelConfigDO.getRuleNumber());
MemberUserScoreLogQueryVO memberUserScoreLogQueryVO=new MemberUserScoreLogQueryVO();
LambdaQuery<MemberUserScoreLogDO> memberUserScoreLogDoLambdaQuery = new LambdaQuery<>();
......@@ -196,7 +197,7 @@ public class userLevelDetailsTask implements JobHandler {
memberUserLevelOperateService.save(memberUserLevelOperateLogDo);
log.info("客户等级小于当前等级,等级详情进入升级操作,规则id:{},用户id:{}",memberUserLevelConfigDO.getRuleNumber(),memberId);
return true;
}else if(memberUserLevelDetailsBackVO.getLevel()==memberUserLevelConfigDO.getLevel()&&!memberUserLevelDetailsBackVO.getRuleNumber().equals(memberUserLevelConfigDO.getRuleNumber())){
}else if(memberUserLevelDetailsBackVO.getLevel()==memberUserLevelConfigDO.getLevel()&&memberUserLevelDetailsBackVO.getConfigId()!=null&&!memberUserLevelDetailsBackVO.getConfigId().equals(memberUserLevelConfigDO.getId())){
//级别相同比较sort顺序
MemberUserLevelConfigDO memberUserLevelConfigOldDo = memberUserLevelConfigService.getById(memberUserLevelDetailsBackVO.getConfigId());
if (memberUserLevelConfigOldDo.getSort()>memberUserLevelConfigDO.getSort()){
......@@ -288,7 +289,7 @@ public class userLevelDetailsTask implements JobHandler {
memberUserLevelOperateService.save(memberUserLevelOperateLogDo);
log.info("客户等级小于当前等级,等级详情进入升级操作,规则id:{},用户id:{}",memberUserLevelConfigDO.getRuleNumber(),memberId);
return true;
}else if(memberUserLevelDetailsBackVO.getLevel()==memberUserLevelConfigDO.getLevel()&&!memberUserLevelDetailsBackVO.getRuleNumber().equals(memberUserLevelConfigDO.getRuleNumber())){
}else if(memberUserLevelDetailsBackVO.getLevel()==memberUserLevelConfigDO.getLevel()&&memberUserLevelDetailsBackVO.getConfigId()!=null&&!memberUserLevelDetailsBackVO.getConfigId().equals(memberUserLevelConfigDO.getId())){
//级别相同比较sort顺序
MemberUserLevelConfigDO memberUserLevelConfigOldDo = memberUserLevelConfigService.getById(memberUserLevelDetailsBackVO.getConfigId());
if (memberUserLevelConfigOldDo.getSort()>memberUserLevelConfigDO.getSort()){
......
......@@ -23,8 +23,8 @@ public class MemberUserLevelDetailsBackVO {
@ApiModelProperty(value = "会员等级配置id")
private Long configId;
@ApiModelProperty(value = "会员等级配置编号")
private String ruleNumber;
@ApiModelProperty(value = "会员编号")
private String memberCode;
@ApiModelProperty(value = "会员id")
private Long memberId;
......
......@@ -7,7 +7,7 @@
SELECT
muld.id as id,
muld.config_id as configId,
mulc.rule_number as ruleNumber ,
mu.code as memberCode ,
muld.member_id as memberId,
muld.updater as updater,
muld.remarks as remarks,
......@@ -17,8 +17,8 @@
muld.validity_period as validityPeriod,
muld.specific_settings as specificSettings
FROM member_user_level_details muld
left join member_user_level_config mulc
on muld.config_id =mulc.id
left join member_user mu
on muld.member_id =mu.id
where 1=1
and muld.member_id = #{query.memberId}
order by muld.create_time desc
......@@ -27,8 +27,8 @@
<select id="getPageCount" resultType="java.lang.Integer">
select count(*)
FROM member_user_level_details muld
left join member_user_level_config mulc
on muld.config_id =mulc.id
left join member_user mu
on muld.member_id =mu.id
where 1=1
and muld.member_id = #{query.memberId}
</select>
......
......@@ -1058,7 +1058,9 @@ currency.not.exist = currency not exist
date.format.error = date format error, for example : 2024-01-01 12:11:11
redeem.cancel.status.error = record status must be redeeming
level.bound.range.error = upper count must greater than lower count
level.bound.range.conflict = score range exist conflict
level.bound.range.conflict = score range exist conflict'
level.rule.not.exists = Membership level rule does not exist
level.details.not.exists = Membership level details do not exist
score.operate.idempotent.error = idempotent key conflict
score.rule.not.exists = score rule not exists
......
......@@ -1057,6 +1057,8 @@ date.format.error=Format de date incorrect, format correct : 2024-01-01 12:11:11
redeem.cancel.status.error=Seules les enregistrements avec un statut "en \u00E9change" peuvent \u00EAtre annul\u00E9s
level.bound.range.error=La valeur sup\u00E9rieure doit \u00EAtre sup\u00E9rieure \u00E0 la valeur inf\u00E9rieure
level.bound.range.conflict=Conflit dans la plage des points de fid\u00E9lit\u00E9
level.rule.not.exists = La r\u00E8gle du niveau de membre n'existe pas
level.details.not.exists = Les d\u00E9tails du niveau de membre n'existent pas
score.operate.idempotent.error=Conflit de cl\u00E9 idempotente
score.rule.not.exists=La r\u00E8gle de points n'existe pas
......
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