From aaeae431695c748bd4a989943ce06bc0bef11997 Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Mon, 16 Mar 2026 16:58:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=94=A8=E6=88=B7VIP?= =?UTF-8?q?=E7=AD=89=E7=BA=A7=E6=8A=98=E6=89=A3=E6=AF=94=E4=BE=8B=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=8C=E9=AD=85=E5=8A=9B=E5=80=BC=E6=8C=89=E7=85=A7?= =?UTF-8?q?=E7=AD=89=E7=BA=A7=E6=AF=94=E4=BE=8B=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gift/strategy/GiftCountStrategy.java | 7 ++- .../other/domain/enums/VipBenefitType.java | 48 +++++++++++++++++++ .../gateway/user/UserProfileGateway.java | 8 ++++ .../gateway/user/UserProfileGatewayImpl.java | 20 ++++++++ 4 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 rc-service/rc-service-other/other-domain/src/main/java/com/red/circle/other/domain/enums/VipBenefitType.java diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/gift/strategy/GiftCountStrategy.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/gift/strategy/GiftCountStrategy.java index c5dbbc61..94d2626e 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/gift/strategy/GiftCountStrategy.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/gift/strategy/GiftCountStrategy.java @@ -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 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) { diff --git a/rc-service/rc-service-other/other-domain/src/main/java/com/red/circle/other/domain/enums/VipBenefitType.java b/rc-service/rc-service-other/other-domain/src/main/java/com/red/circle/other/domain/enums/VipBenefitType.java new file mode 100644 index 00000000..0a22fbfb --- /dev/null +++ b/rc-service/rc-service-other/other-domain/src/main/java/com/red/circle/other/domain/enums/VipBenefitType.java @@ -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]; + } +} diff --git a/rc-service/rc-service-other/other-domain/src/main/java/com/red/circle/other/domain/gateway/user/UserProfileGateway.java b/rc-service/rc-service-other/other-domain/src/main/java/com/red/circle/other/domain/gateway/user/UserProfileGateway.java index 2c5d1c7d..0793e924 100644 --- a/rc-service/rc-service-other/other-domain/src/main/java/com/red/circle/other/domain/gateway/user/UserProfileGateway.java +++ b/rc-service/rc-service-other/other-domain/src/main/java/com/red/circle/other/domain/gateway/user/UserProfileGateway.java @@ -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 ids); + /** + * 获取用户VIP指定权益值. + * 非VIP返回对应类型的默认值. + */ + BigDecimal getUserVipBenefit(Long userId, VipBenefitType benefitType); + } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/user/UserProfileGatewayImpl.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/user/UserProfileGatewayImpl.java index f1df252a..2f85479b 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/user/UserProfileGatewayImpl.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/user/UserProfileGatewayImpl.java @@ -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 ids) { if (CollectionUtils.isEmpty(ids)) {