From e882e29eb571be2ecdfcec889c6447c77895b504 Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Mon, 16 Mar 2026 17:58:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=E5=85=8D=E8=B4=B9?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E5=AE=B6=E6=97=8FVIP=E7=AD=89=E7=BA=A7?= =?UTF-8?q?=E6=9D=83=E7=9B=8A=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/command/family/FamilyCreateExe.java | 6 +++ .../other/domain/enums/VipAbilityType.java | 48 +++++++++++++++++++ .../gateway/user/UserProfileGateway.java | 7 +++ .../gateway/user/UserProfileGatewayImpl.java | 17 +++++-- 4 files changed, 73 insertions(+), 5 deletions(-) create mode 100644 rc-service/rc-service-other/other-domain/src/main/java/com/red/circle/other/domain/enums/VipAbilityType.java diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/family/FamilyCreateExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/family/FamilyCreateExe.java index 540bc940..899dc090 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/family/FamilyCreateExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/family/FamilyCreateExe.java @@ -11,6 +11,7 @@ import com.red.circle.framework.core.response.CommonErrorCode; import com.red.circle.framework.core.response.ResponseErrorCode; import com.red.circle.other.app.common.account.FamilyAccountShortProduction; import com.red.circle.other.app.dto.cmd.family.FamilyCreateCmd; +import com.red.circle.other.domain.enums.VipAbilityType; 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.OwnSpecialId; @@ -175,6 +176,11 @@ public class FamilyCreateExe { return; } + boolean hasAbility = userProfileGateway.getUserVipAbility(cmd.getReqUserId(), VipAbilityType.CREATE_FAMILY_FREE); + if (hasAbility) { + return; + } + //创建家族扣除金币 consumeCandy(cmd, createRules); diff --git a/rc-service/rc-service-other/other-domain/src/main/java/com/red/circle/other/domain/enums/VipAbilityType.java b/rc-service/rc-service-other/other-domain/src/main/java/com/red/circle/other/domain/enums/VipAbilityType.java new file mode 100644 index 00000000..5baa7122 --- /dev/null +++ b/rc-service/rc-service-other/other-domain/src/main/java/com/red/circle/other/domain/enums/VipAbilityType.java @@ -0,0 +1,48 @@ +package com.red.circle.other.domain.enums; + +/** + * VIP 布尔权限类型. + * 各等级顺序: VIP1(VISCOUNT) ~ VIP6(EMPEROR) + */ +public enum VipAbilityType { + + /** 拒绝陌生人联系 */ + BLOCK_STRANGERS(false, false, false, true, true, true), + + /** 免费创建家族 */ + CREATE_FAMILY_FREE(false, false, false, true, true, true), + + /** 防踢 */ + KICK_PREVENTION(false, false, false, false, true, true), + + /** 防拉黑 */ + ANTI_BLOCK(false, false, false, false, false, true), + + /** 神秘隐身 */ + MYSTERIOUS_INVISIBILITY(false, false, false, false, false, true); + + // index 0~5 = VIP1~VIP6 + private final boolean[] levels; + + VipAbilityType(boolean... levels) { + this.levels = levels; + } + + /** + * 根据 VIP name 判断是否拥有该权限,非VIP或未匹配返回 false. + */ + public boolean hasAbility(String vipName) { + if (vipName == null) { + return false; + } + switch (vipName) { + case "VISCOUNT": return levels[0]; + case "EARL": return levels[1]; + case "MARQUIS": return levels[2]; + case "DUKE": return levels[3]; + case "KING": return levels[4]; + case "EMPEROR": return levels[5]; + default: return false; + } + } +} 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 0793e924..f0b9af33 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,7 @@ 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.VipAbilityType; import com.red.circle.other.domain.enums.VipBenefitType; import java.math.BigDecimal; import com.red.circle.other.domain.model.user.NobleAbilityCO; @@ -196,4 +197,10 @@ public interface UserProfileGateway { */ BigDecimal getUserVipBenefit(Long userId, VipBenefitType benefitType); + /** + * 判断用户是否拥有指定VIP权限. + * 非VIP或等级不足返回 false. + */ + boolean getUserVipAbility(Long userId, VipAbilityType abilityType); + } 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 2f85479b..ef3b2f54 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.VipAbilityType; 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; @@ -497,14 +498,22 @@ public class UserProfileGatewayImpl implements UserProfileGateway { return userCacheService.getUserActualEquityEnum(userId, this::getUserPropsVipActualEquity); } + @Override + public boolean getUserVipAbility(Long userId, VipAbilityType abilityType) { + return abilityType.hasAbility(resolveUserVipName(userId)); + } + @Override public BigDecimal getUserVipBenefit(Long userId, VipBenefitType benefitType) { + return benefitType.getValue(resolveUserVipName(userId)); + } + + private String resolveUserVipName(Long userId) { UserProfile userProfile = getByUserId(userId); if (Objects.isNull(userProfile) || CollectionUtils.isEmpty(userProfile.getUseProps())) { - return benefitType.getDefaultValue(); + return null; } - - String vipName = userProfile.getUseProps().stream() + return userProfile.getUseProps().stream() .filter(props -> Objects.nonNull(props.getPropsResources()) && PropsCommodityType.NOBLE_VIP.name().equals(props.getPropsResources().getType()) && props.getExpireTime() != null @@ -512,8 +521,6 @@ public class UserProfileGatewayImpl implements UserProfileGateway { .map(props -> props.getPropsResources().getName()) .findFirst() .orElse(null); - - return benefitType.getValue(vipName); } @Override