用户财富等级新增 等级 天数 ID icon字段
This commit is contained in:
parent
b60178b596
commit
a383f82e5f
@ -1,7 +1,7 @@
|
||||
package com.red.circle.other.adapter.app.user.user;
|
||||
|
||||
import com.red.circle.common.business.core.level.UserLevelExperience;
|
||||
import com.red.circle.common.business.dto.cmd.app.AppUserIdCmd;
|
||||
import com.red.circle.other.app.dto.clientobject.user.user.UserLevelExperienceCO;
|
||||
import com.red.circle.other.app.dto.clientobject.user.user.UserLevelCO;
|
||||
import com.red.circle.other.app.dto.cmd.user.user.UserLevelCmd;
|
||||
import com.red.circle.other.app.service.user.user.UserLevelService;
|
||||
@ -49,7 +49,7 @@ public class UserLevelRestController {
|
||||
* @eo.request-type formdata
|
||||
*/
|
||||
@GetMapping("/consumption/exp")
|
||||
public UserLevelExperience getUserLevelExperience(@Validated UserLevelCmd cmd) {
|
||||
public UserLevelExperienceCO getUserLevelExperience(@Validated UserLevelCmd cmd) {
|
||||
return userLevelService.getLevelExperience(cmd);
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,9 @@ package com.red.circle.other.app.command.user.query;
|
||||
|
||||
import com.red.circle.common.business.core.level.LevelUtils;
|
||||
import com.red.circle.common.business.core.level.UserLevelExperience;
|
||||
import com.red.circle.other.app.dto.clientobject.user.user.UserLevelExperienceCO;
|
||||
import com.red.circle.other.app.dto.cmd.user.user.UserLevelCmd;
|
||||
import com.red.circle.other.app.enums.user.WealthLevelRewardEnum;
|
||||
import com.red.circle.other.infra.database.rds.service.user.user.ConsumptionLevelService;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Objects;
|
||||
@ -18,24 +20,62 @@ import org.springframework.stereotype.Component;
|
||||
@RequiredArgsConstructor
|
||||
public class UserLevelExperienceQryExe {
|
||||
|
||||
private final ConsumptionLevelService consumptionLevelService;
|
||||
private final ConsumptionLevelService consumptionLevelService;
|
||||
|
||||
public UserLevelExperience execute(UserLevelCmd cmd) {
|
||||
if (UserLevelCmd.LevelType.WEALTH.equals(cmd.getType())) {
|
||||
return LevelUtils.getWealthLevel(cmd.requireReqSysOriginEnum(), getQuantity(cmd).longValue());
|
||||
}
|
||||
return LevelUtils.getUserLevelV2(cmd.requireReqSysOriginEnum(), getQuantity(cmd).longValue());
|
||||
}
|
||||
public UserLevelExperienceCO execute(UserLevelCmd cmd) {
|
||||
UserLevelExperience base;
|
||||
if (UserLevelCmd.LevelType.WEALTH.equals(cmd.getType())) {
|
||||
base = LevelUtils.getWealthLevel(cmd.requireReqSysOriginEnum(), getQuantity(cmd).longValue());
|
||||
} else {
|
||||
base = LevelUtils.getUserLevelV2(cmd.requireReqSysOriginEnum(), getQuantity(cmd).longValue());
|
||||
}
|
||||
|
||||
private BigDecimal getQuantity(UserLevelCmd cmd) {
|
||||
if (Objects.equals(cmd.getType(), UserLevelCmd.LevelType.WEALTH)) {
|
||||
return consumptionLevelService.getConsumptionGolds(cmd.getUserId());
|
||||
UserLevelExperienceCO co = new UserLevelExperienceCO()
|
||||
.setLevel(base.getLevel())
|
||||
.setThatExperience(base.getThatExperience())
|
||||
.setThatExperienceFormat(base.getThatExperienceFormat())
|
||||
.setNextExperience(base.getNextExperience())
|
||||
.setNextExperienceFormat(base.getNextExperienceFormat());
|
||||
|
||||
if (UserLevelCmd.LevelType.WEALTH.equals(cmd.getType())) {
|
||||
fillWealthExtra(co, base.getLevel());
|
||||
}
|
||||
|
||||
return co;
|
||||
}
|
||||
|
||||
if (Objects.equals(cmd.getType(), UserLevelCmd.LevelType.CHARM)) {
|
||||
return consumptionLevelService.getConsumptionDiamond(cmd.getUserId());
|
||||
private void fillWealthExtra(UserLevelExperienceCO co, int level) {
|
||||
WealthLevelRewardEnum.of(level).ifPresent(reward -> {
|
||||
WealthLevelRewardEnum.VipReward first = reward.getRewards().get(0);
|
||||
co.setVipLevel(first.vipType().name());
|
||||
co.setVipDays(first.days());
|
||||
});
|
||||
co.setIdIconType(resolveIdIconType(level));
|
||||
}
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
|
||||
private Integer resolveIdIconType(int level) {
|
||||
if (level < 11) {
|
||||
return null;
|
||||
}
|
||||
if (level <= 20) {
|
||||
return 1;
|
||||
}
|
||||
if (level <= 30) {
|
||||
return 2;
|
||||
}
|
||||
if (level <= 40) {
|
||||
return 3;
|
||||
}
|
||||
return 4;
|
||||
}
|
||||
|
||||
private BigDecimal getQuantity(UserLevelCmd cmd) {
|
||||
if (Objects.equals(cmd.getType(), UserLevelCmd.LevelType.WEALTH)) {
|
||||
return consumptionLevelService.getConsumptionGolds(cmd.getUserId());
|
||||
}
|
||||
if (Objects.equals(cmd.getType(), UserLevelCmd.LevelType.CHARM)) {
|
||||
return consumptionLevelService.getConsumptionDiamond(cmd.getUserId());
|
||||
}
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
package com.red.circle.other.app.service.user.user;
|
||||
|
||||
import com.red.circle.common.business.core.level.UserLevelExperience;
|
||||
import com.red.circle.common.business.dto.cmd.app.AppUserIdCmd;
|
||||
import com.red.circle.other.app.command.user.query.UserConsumptionLevelQryExe;
|
||||
import com.red.circle.other.app.command.user.query.UserLevelExperienceQryExe;
|
||||
import com.red.circle.other.app.dto.clientobject.user.user.UserLevelCO;
|
||||
import com.red.circle.other.app.dto.clientobject.user.user.UserLevelExperienceCO;
|
||||
import com.red.circle.other.app.dto.cmd.user.user.UserLevelCmd;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -22,7 +22,7 @@ public class UserLevelServiceImpl implements UserLevelService {
|
||||
private final UserConsumptionLevelQryExe userConsumptionLevelQryExe;
|
||||
|
||||
@Override
|
||||
public UserLevelExperience getLevelExperience(UserLevelCmd cmd) {
|
||||
public UserLevelExperienceCO getLevelExperience(UserLevelCmd cmd) {
|
||||
return userLevelExperienceQryExe.execute(cmd);
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,43 @@
|
||||
package com.red.circle.other.app.dto.clientobject.user.user;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 用户财富/魅力等级经验详情.
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class UserLevelExperienceCO {
|
||||
|
||||
/** 当前等级. */
|
||||
private Integer level;
|
||||
|
||||
/** 当前经验. */
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long thatExperience;
|
||||
|
||||
/** 当前经验-格式化. */
|
||||
private String thatExperienceFormat;
|
||||
|
||||
/** 下一等级所需经验. */
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long nextExperience;
|
||||
|
||||
/** 下一等级所需经验-格式化. */
|
||||
private String nextExperienceFormat;
|
||||
|
||||
/** VIP 等级名称(仅财富等级有值). */
|
||||
private String vipLevel;
|
||||
|
||||
/** 对应 VIP 奖励天数(仅财富等级有值). */
|
||||
private Integer vipDays;
|
||||
|
||||
/**
|
||||
* ID 图标类型(仅财富等级有值).
|
||||
* 11~20 → 1,21~30 → 2,31~40 → 3,41+ → 4
|
||||
*/
|
||||
private Integer idIconType;
|
||||
}
|
||||
@ -1,8 +1,8 @@
|
||||
package com.red.circle.other.app.service.user.user;
|
||||
|
||||
import com.red.circle.common.business.core.level.UserLevelExperience;
|
||||
import com.red.circle.common.business.dto.cmd.app.AppUserIdCmd;
|
||||
import com.red.circle.other.app.dto.clientobject.user.user.UserLevelCO;
|
||||
import com.red.circle.other.app.dto.clientobject.user.user.UserLevelExperienceCO;
|
||||
import com.red.circle.other.app.dto.cmd.user.user.UserLevelCmd;
|
||||
|
||||
/**
|
||||
@ -12,7 +12,7 @@ import com.red.circle.other.app.dto.cmd.user.user.UserLevelCmd;
|
||||
*/
|
||||
public interface UserLevelService {
|
||||
|
||||
UserLevelExperience getLevelExperience(UserLevelCmd cmd);
|
||||
UserLevelExperienceCO getLevelExperience(UserLevelCmd cmd);
|
||||
|
||||
UserLevelCO getConsumptionLevelByUserId(AppUserIdCmd cmd);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user