新增用户VIP等级折扣比例逻辑,魅力值按照等级比例处理

This commit is contained in:
tianfeng 2026-03-16 16:58:09 +08:00
parent 445fa1e7f6
commit aaeae43169
4 changed files with 82 additions and 1 deletions

View File

@ -18,7 +18,9 @@ import com.red.circle.other.app.dto.cmd.SpinsTaskProgressUpdateCmd;
import com.red.circle.other.app.dto.cmd.task.RoomDailyTaskProgressUpdateCmd;
import com.red.circle.other.app.service.SpinsUserTaskProgressService;
import com.red.circle.other.app.service.task.RoomDailyTaskProgressService;
import com.red.circle.other.app.service.user.user.UserProfileService;
import com.red.circle.other.app.util.DateTimeAsiaRiyadhUtils;
import com.red.circle.other.domain.enums.VipBenefitType;
import com.red.circle.other.domain.gateway.user.UserProfileGateway;
import com.red.circle.other.domain.gateway.user.ability.UserRegionGateway;
import com.red.circle.other.domain.model.user.UserProfile;
@ -144,6 +146,7 @@ public class GiftCountStrategy implements GiftStrategy {
private final DynamicMessageService dynamicMessageService;
private static final List<String> inRegionCodes = List.of("IN", "PK", "BD");
private final UserRegionCacheService userRegionCacheService;
private final UserProfileGateway userProfileGateway;
@Override
@ -190,8 +193,10 @@ public class GiftCountStrategy implements GiftStrategy {
runningWater.getAcceptUsers().forEach(accept -> {
BigDecimal userVipBenefit = userProfileGateway.getUserVipBenefit(accept.getAcceptUserId(), VipBenefitType.XP_RATE);
BigDecimal resultValueCount = giftValueCount.multiply(userVipBenefit).setScale(2, RoundingMode.HALF_UP);
// 记录魅力等级
consumptionLevelService.incrConsumptionDiamond(accept.getAcceptUserId(), giftValueCount);
consumptionLevelService.incrConsumptionDiamond(accept.getAcceptUserId(), resultValueCount);
// 保存高价值礼物公共礼物墙
if (isHighPriceGift) {

View File

@ -0,0 +1,48 @@
package com.red.circle.other.domain.enums;
import java.math.BigDecimal;
/**
* VIP 权益类型.
* 各等级顺序: 非VIP, VIP1(VISCOUNT), VIP2(EARL), VIP3(MARQUIS), VIP4(DUKE), VIP5(KING), VIP6(EMPEROR)
*/
public enum VipBenefitType {
/** 经验加成倍率 */
XP_RATE("1.0", "1.05", "1.07", "1.10", "1.15", "1.20", "1.25"),
/** 商店折扣 */
SHOP_DISCOUNT("1.0", "1.0", "1.0", "0.9", "0.85", "0.8", "0.7");
// index 0 = 非VIP, 1~6 = VIP1~VIP6
private final BigDecimal[] values;
VipBenefitType(String... values) {
this.values = new BigDecimal[values.length];
for (int i = 0; i < values.length; i++) {
this.values[i] = new BigDecimal(values[i]);
}
}
/**
* 根据 VIP name 返回对应权益值未匹配返回非VIP默认值.
*/
public BigDecimal getValue(String vipName) {
if (vipName == null) {
return values[0];
}
switch (vipName) {
case "VISCOUNT": return values[1];
case "EARL": return values[2];
case "MARQUIS": return values[3];
case "DUKE": return values[4];
case "KING": return values[5];
case "EMPEROR": return values[6];
default: return values[0];
}
}
public BigDecimal getDefaultValue() {
return values[0];
}
}

View File

@ -2,6 +2,8 @@ package com.red.circle.other.domain.gateway.user;
import com.red.circle.common.business.core.enums.SysOriginPlatformEnum;
import com.red.circle.framework.dto.PageResult;
import com.red.circle.other.domain.enums.VipBenefitType;
import java.math.BigDecimal;
import com.red.circle.other.domain.model.user.NobleAbilityCO;
import com.red.circle.other.inner.enums.material.PropsVipActualEquityEnum;
import com.red.circle.tool.core.tuple.ImmutableKeyValuePair;
@ -188,4 +190,10 @@ public interface UserProfileGateway {
*/
void updateBatchUserAutographEmpty(Collection<Long> ids);
/**
* 获取用户VIP指定权益值.
* 非VIP返回对应类型的默认值.
*/
BigDecimal getUserVipBenefit(Long userId, VipBenefitType benefitType);
}

View File

@ -8,6 +8,7 @@ import com.red.circle.common.business.core.enums.SysOriginPlatformEnum;
import com.red.circle.common.business.core.level.LevelUtils;
import com.red.circle.external.inner.endpoint.message.ImAccountClient;
import com.red.circle.framework.dto.PageResult;
import com.red.circle.other.domain.enums.VipBenefitType;
import com.red.circle.other.domain.gateway.user.UserProfileGateway;
import com.red.circle.other.domain.gateway.user.UserRunProfileTransportGateway;
import com.red.circle.other.domain.model.user.OwnSpecialId;
@ -496,6 +497,25 @@ public class UserProfileGatewayImpl implements UserProfileGateway {
return userCacheService.getUserActualEquityEnum(userId, this::getUserPropsVipActualEquity);
}
@Override
public BigDecimal getUserVipBenefit(Long userId, VipBenefitType benefitType) {
UserProfile userProfile = getByUserId(userId);
if (Objects.isNull(userProfile) || CollectionUtils.isEmpty(userProfile.getUseProps())) {
return benefitType.getDefaultValue();
}
String vipName = userProfile.getUseProps().stream()
.filter(props -> Objects.nonNull(props.getPropsResources())
&& PropsCommodityType.NOBLE_VIP.name().equals(props.getPropsResources().getType())
&& props.getExpireTime() != null
&& props.getExpireTime() > System.currentTimeMillis())
.map(props -> props.getPropsResources().getName())
.findFirst()
.orElse(null);
return benefitType.getValue(vipName);
}
@Override
public void updateBatchUserAutographEmpty(Collection<Long> ids) {
if (CollectionUtils.isEmpty(ids)) {