From bdd2ef2f475aa243c07d294793a5a131de68043e Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Wed, 29 Oct 2025 19:34:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E6=88=BF=E9=97=B4?= =?UTF-8?q?=E8=BF=9B=E5=85=A5=E5=90=8E=E8=AE=BE=E7=BD=AEroomSpecialMikeTyp?= =?UTF-8?q?e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/command/room/RoomEnterCmdExe.java | 9 ++++++ .../gateway/user/UserProfileGateway.java | 9 ++++++ .../domain/model/user/NobleAbilityCO.java | 29 +++++++++++++++++ .../database/cache/key/user/UserKey.java | 5 +++ .../cache/service/user/UserCacheService.java | 6 ++++ .../user/impl/UserCacheServiceImpl.java | 27 ++++++++++++++++ .../gateway/user/UserProfileGatewayImpl.java | 31 +++++++++++++++++++ 7 files changed, 116 insertions(+) create mode 100644 rc-service/rc-service-other/other-domain/src/main/java/com/red/circle/other/domain/model/user/NobleAbilityCO.java diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/room/RoomEnterCmdExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/room/RoomEnterCmdExe.java index e2408bcd..926f386a 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/room/RoomEnterCmdExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/room/RoomEnterCmdExe.java @@ -18,6 +18,7 @@ import com.red.circle.other.app.dto.clientobject.room.RoomThemeCO; import com.red.circle.other.app.dto.cmd.room.RoomEntryCmd; 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.NobleAbilityCO; import com.red.circle.other.infra.database.cache.service.other.RoomManagerCacheService; import com.red.circle.other.infra.database.cache.service.user.UserAgoraTokenCacheService; import com.red.circle.other.infra.database.mongo.entity.live.RoomProfile; @@ -316,6 +317,14 @@ public class RoomEnterCmdExe { if (StringUtils.isBlank(manager.getSetting().getTakeMicRole())) { manager.getSetting().setTakeMicRole(RoomTakeMicRoleEnum.ALL.name()); } + + NobleAbilityCO userNobleAbility = userProfileGateway.getUserNobleAbility(manager.getUserId()); + if (Objects.nonNull(userNobleAbility)) { + RoomSetting setting = manager.getSetting(); + setting.setRoomSpecialMikeType("TYPE_VIP" + userNobleAbility.getVipLevel()); + manager.setSetting(setting); + } + } public void checkSysOrigin(Long userId, String sysOrigin) { 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 ade83882..db03e1cf 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 @@ -1,6 +1,7 @@ package com.red.circle.other.domain.gateway.user; import com.red.circle.common.business.core.enums.SysOriginPlatformEnum; +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; import com.red.circle.other.domain.model.user.UserConsumptionLevel; @@ -171,6 +172,14 @@ public interface UserProfileGateway { */ List listUserActualEquityEnum(Long userId); + /** + * 获取用户贵族能力. + * + * @param userId 用户ID + * @return 贵族能力信息 + */ + NobleAbilityCO getUserNobleAbility(Long userId); + /** * 修改用户签名为空. */ diff --git a/rc-service/rc-service-other/other-domain/src/main/java/com/red/circle/other/domain/model/user/NobleAbilityCO.java b/rc-service/rc-service-other/other-domain/src/main/java/com/red/circle/other/domain/model/user/NobleAbilityCO.java new file mode 100644 index 00000000..e2ae5678 --- /dev/null +++ b/rc-service/rc-service-other/other-domain/src/main/java/com/red/circle/other/domain/model/user/NobleAbilityCO.java @@ -0,0 +1,29 @@ +package com.red.circle.other.domain.model.user; + +import lombok.Data; + +/** + * 贵族能力返回对象. + * + * @author Claude AI + * @since 2025-10-29 + */ +@Data +public class NobleAbilityCO { + + /** + * VIP类型. + */ + private String vipType; + + /** + * VIP等级. + */ + private Integer vipLevel; + + /** + * 房间最大成员数. + */ + private Integer roomMaxMember; + +} diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/key/user/UserKey.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/key/user/UserKey.java index b01a13d4..aedbe8ec 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/key/user/UserKey.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/key/user/UserKey.java @@ -39,6 +39,11 @@ public enum UserKey implements RedisKeys { */ S_VIP_EQUITY, + /** + * 用户贵族能力. + */ + NOBLE_ABILITY, + /** * 用户svip身份. */ diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/service/user/UserCacheService.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/service/user/UserCacheService.java index 981989ff..3a8667c2 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/service/user/UserCacheService.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/service/user/UserCacheService.java @@ -1,5 +1,6 @@ package com.red.circle.other.infra.database.cache.service.user; +import com.red.circle.other.domain.model.user.NobleAbilityCO; import com.red.circle.other.inner.enums.material.PropsVipActualEquityEnum; import com.red.circle.other.infra.database.cache.entity.user.ConsumptionLevelCache; import com.red.circle.other.infra.database.cache.key.user.UserHashKey; @@ -78,6 +79,11 @@ public interface UserCacheService { */ List getUserActualEquityEnum(Long userId, Function> orElseGet); + /** + * 获取用户贵族能力. + */ + NobleAbilityCO getUserNobleAbility(Long userId, Function orElseGet); + /** * 移除权益缓存. */ diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/service/user/impl/UserCacheServiceImpl.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/service/user/impl/UserCacheServiceImpl.java index 36b370aa..031cabf2 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/service/user/impl/UserCacheServiceImpl.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/service/user/impl/UserCacheServiceImpl.java @@ -1,7 +1,9 @@ package com.red.circle.other.infra.database.cache.service.user.impl; +import com.alibaba.fastjson.JSON; import com.google.common.collect.Lists; import com.red.circle.component.redis.service.RedisService; +import com.red.circle.other.domain.model.user.NobleAbilityCO; import com.red.circle.other.inner.enums.material.PropsVipActualEquityEnum; import com.red.circle.tool.core.collection.CollectionUtils; import com.red.circle.tool.core.text.StringPool; @@ -171,6 +173,31 @@ public class UserCacheServiceImpl implements UserCacheService { return actualEquity; } + @Override + public NobleAbilityCO getUserNobleAbility(Long userId, + Function orElseGet) { + + String key = UserKey.NOBLE_ABILITY.getKey(userId); + + String cacheValue = redisService.getString(key); + + if (StringUtils.isNotBlank(cacheValue)) { + try { + return JSON.parseObject(cacheValue, NobleAbilityCO.class); + } catch (Exception ignored) { + } + return null; + } + + NobleAbilityCO ability = orElseGet.apply(userId); + + if (Objects.nonNull(ability)) { + redisService.setIfAbsent(key, JSON.toJSONString(ability), 10, TimeUnit.MINUTES); + } + + return ability; + } + @Override public void removeUserActualEquityEnum(Long userId) { redisService.delete(UserKey.S_VIP_EQUITY.getKey(userId)); 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 aea3dd21..3b02ca65 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 @@ -11,6 +11,7 @@ import com.red.circle.other.domain.gateway.user.UserRunProfileTransportGateway; import com.red.circle.other.domain.model.user.OwnSpecialId; import com.red.circle.other.domain.model.user.UserConsumptionLevel; import com.red.circle.other.domain.model.user.UserProfile; +import com.red.circle.other.domain.model.user.NobleAbilityCO; import com.red.circle.other.infra.common.props.PropsBackpackCommon; import com.red.circle.other.infra.common.props.UserBadgeCommon; import com.red.circle.other.infra.convertor.user.UserProfileInfraConvertor; @@ -519,6 +520,36 @@ public class UserProfileGatewayImpl implements UserProfileGateway { return Lists.newArrayList(); } + @Override + public NobleAbilityCO getUserNobleAbility(Long userId) { + return userCacheService.getUserNobleAbility(userId, this::getNobleAbility); + } + + private NobleAbilityCO getNobleAbility(Long userId) { + UserProfile userProfile = getByUserId(userId); + if (Objects.isNull(userProfile)) { + return null; + } + + Set userVipPropsIds = getUserVipPropsIds(userProfile.getUseProps()); + if (CollectionUtils.isEmpty(userVipPropsIds)) { + return null; + } + + List vipAbilities = propsNobleVipAbilityService.listByIds(userVipPropsIds); + + if (CollectionUtils.isEmpty(vipAbilities)) { + return null; + } + + PropsNobleVipAbility ability = vipAbilities.get(0); + NobleAbilityCO result = new NobleAbilityCO(); + result.setVipType(ability.getVipType()); + result.setVipLevel(ability.getVipLevel()); + result.setRoomMaxMember(ability.getRoomMaxMember()); + return result; + } + /** * 获得贵族道具ID */