等级配置 高等级levelExp显示为Null
This commit is contained in:
parent
be52ad499c
commit
2f7a415a45
@ -4,8 +4,12 @@ import com.red.circle.common.business.dto.cmd.AppExtCommand;
|
|||||||
import com.red.circle.framework.core.asserts.ResponseAssert;
|
import com.red.circle.framework.core.asserts.ResponseAssert;
|
||||||
import com.red.circle.framework.core.response.CommonErrorCode;
|
import com.red.circle.framework.core.response.CommonErrorCode;
|
||||||
import com.red.circle.other.app.dto.clientobject.family.FamilyLevelCO;
|
import com.red.circle.other.app.dto.clientobject.family.FamilyLevelCO;
|
||||||
|
import com.red.circle.other.infra.database.rds.entity.family.FamilyBaseInfo;
|
||||||
import com.red.circle.other.infra.database.rds.entity.family.FamilyLevelConfig;
|
import com.red.circle.other.infra.database.rds.entity.family.FamilyLevelConfig;
|
||||||
|
import com.red.circle.other.infra.database.rds.entity.family.FamilyMemberInfo;
|
||||||
|
import com.red.circle.other.infra.database.rds.service.family.FamilyBaseInfoService;
|
||||||
import com.red.circle.other.infra.database.rds.service.family.FamilyLevelConfigService;
|
import com.red.circle.other.infra.database.rds.service.family.FamilyLevelConfigService;
|
||||||
|
import com.red.circle.other.infra.database.rds.service.family.FamilyMemberInfoService;
|
||||||
import com.red.circle.tool.core.collection.CollectionUtils;
|
import com.red.circle.tool.core.collection.CollectionUtils;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -21,6 +25,8 @@ import org.springframework.stereotype.Component;
|
|||||||
public class FamilyLevelListExe {
|
public class FamilyLevelListExe {
|
||||||
|
|
||||||
private final FamilyLevelConfigService familyLevelConfigService;
|
private final FamilyLevelConfigService familyLevelConfigService;
|
||||||
|
private final FamilyMemberInfoService familyMemberInfoService;
|
||||||
|
private final FamilyBaseInfoService familyBaseInfoService;
|
||||||
|
|
||||||
public List<FamilyLevelCO> execute(AppExtCommand cmd) {
|
public List<FamilyLevelCO> execute(AppExtCommand cmd) {
|
||||||
List<FamilyLevelConfig> levelConfigs = familyLevelConfigService
|
List<FamilyLevelConfig> levelConfigs = familyLevelConfigService
|
||||||
@ -29,16 +35,45 @@ public class FamilyLevelListExe {
|
|||||||
ResponseAssert.isFalse(CommonErrorCode.NOT_FOUND_RECORD_INFO,
|
ResponseAssert.isFalse(CommonErrorCode.NOT_FOUND_RECORD_INFO,
|
||||||
CollectionUtils.isEmpty(levelConfigs));
|
CollectionUtils.isEmpty(levelConfigs));
|
||||||
|
|
||||||
|
// 获取用户当前家族等级
|
||||||
|
Long currentFamilyLevelId = getCurrentFamilyLevelId(cmd.getReqUserId());
|
||||||
|
|
||||||
return levelConfigs.stream()
|
return levelConfigs.stream()
|
||||||
.map(this::convertToLevelCO)
|
.map(config -> convertToLevelCO(config, currentFamilyLevelId))
|
||||||
.sorted(Comparator.comparing(FamilyLevelCO::getSort))
|
.sorted(Comparator.comparing(FamilyLevelCO::getSort))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
private FamilyLevelCO convertToLevelCO(FamilyLevelConfig config) {
|
/**
|
||||||
|
* 获取用户当前家族等级id
|
||||||
|
*/
|
||||||
|
private Long getCurrentFamilyLevelId(Long userId) {
|
||||||
|
FamilyMemberInfo familyMemberInfo = familyMemberInfoService.getFamilyMemberByUserId(userId);
|
||||||
|
if (familyMemberInfo == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
FamilyBaseInfo familyBaseInfo = familyBaseInfoService.getBaseInfoById(familyMemberInfo.getFamilyId());
|
||||||
|
if (familyBaseInfo == null) {
|
||||||
|
return 1L;
|
||||||
|
}
|
||||||
|
|
||||||
|
return familyBaseInfo.getFamilyLevelId();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 转换为LevelCO,如果等级大于当前家族等级Id,则levelExp设置为null
|
||||||
|
*/
|
||||||
|
private FamilyLevelCO convertToLevelCO(FamilyLevelConfig config, Long currentFamilyLevelId) {
|
||||||
|
// 如果用户有家族,且配置等级大于当前家族等级,则levelExp设置为null
|
||||||
|
Integer levelExp = config.getLevelExp();
|
||||||
|
if (currentFamilyLevelId != null && config.getId() > currentFamilyLevelId) {
|
||||||
|
levelExp = null;
|
||||||
|
}
|
||||||
|
|
||||||
return new FamilyLevelCO()
|
return new FamilyLevelCO()
|
||||||
.setLevel(config.getLevelKey().substring(6))
|
.setLevel(config.getLevelKey().substring(6))
|
||||||
.setLevelExp(config.getLevelExp())
|
.setLevelExp(levelExp)
|
||||||
.setMaxMember(config.getMaxMember())
|
.setMaxMember(config.getMaxMember())
|
||||||
.setMaxManager(config.getMaxManager())
|
.setMaxManager(config.getMaxManager())
|
||||||
.setLevelBackgroundPicture(config.getLevelBackgroundPicture())
|
.setLevelBackgroundPicture(config.getLevelBackgroundPicture())
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user