diff --git a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/enums/config/EnumConfigKey.java b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/enums/config/EnumConfigKey.java index 6a3bb611..61e48b4d 100644 --- a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/enums/config/EnumConfigKey.java +++ b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/enums/config/EnumConfigKey.java @@ -27,6 +27,11 @@ public enum EnumConfigKey { */ DEFAULT_ROOM_COVER, + /** + * 用户隐身图 + */ + USER_YINSHEN_COVER, + /** * h5基础域名. */ diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/GiftsReceivedLeaderboardQryExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/GiftsReceivedLeaderboardQryExe.java index a7072c42..b6de40ee 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/GiftsReceivedLeaderboardQryExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/GiftsReceivedLeaderboardQryExe.java @@ -4,10 +4,13 @@ import com.red.circle.common.business.dto.cmd.AppExtCommand; import com.red.circle.other.app.convertor.user.UserProfileAppConvertor; import com.red.circle.other.app.dto.clientobject.activity.ActivityLeaderboardCO; import com.red.circle.other.app.dto.clientobject.activity.ActivityLeaderboardCO.LeaderboardUserCO; +import com.red.circle.other.domain.enums.VipAbilityType; import com.red.circle.other.domain.gateway.user.UserProfileGateway; +import com.red.circle.other.infra.database.cache.service.other.EnumConfigCacheService; import com.red.circle.other.infra.database.mongo.entity.activity.RankQueenCount; import com.red.circle.other.infra.database.mongo.entity.activity.RankQueenType; import com.red.circle.other.infra.database.mongo.service.activity.RankCountService; +import com.red.circle.other.inner.enums.config.EnumConfigKey; import com.red.circle.other.inner.model.dto.user.UserProfileDTO; import com.red.circle.tool.core.collection.CollectionUtils; import com.red.circle.tool.core.json.JacksonUtils; @@ -32,6 +35,7 @@ public class GiftsReceivedLeaderboardQryExe { private final RankCountService rankCountService; private final UserProfileGateway userProfileGateway; private final UserProfileAppConvertor userProfileAppConvertor; + private final EnumConfigCacheService enumConfigCacheService; public ActivityLeaderboardCO execute(AppExtCommand cmd) { List hours = getListRank(cmd, RankQueenType.CHARM_RANK_HOUR,50); @@ -49,12 +53,13 @@ public class GiftsReceivedLeaderboardQryExe { Map userProfileMap = userProfileAppConvertor.toMapUserProfileDTO( userProfileGateway.mapByUserIds(userIds) ); + Set invisibleUserIds = userProfileGateway.filterUsersByVipAbility(userIds, VipAbilityType.MYSTERIOUS_INVISIBILITY); return new ActivityLeaderboardCO() - .setHourly(toLeaderboardUserCO(hours, userProfileMap)) - .setDaily(toLeaderboardUserCO(days, userProfileMap)) - .setWeekly(toLeaderboardUserCO(weeks, userProfileMap)) - .setMonthly(toLeaderboardUserCO(months, userProfileMap)) + .setHourly(toLeaderboardUserCO(hours, userProfileMap, invisibleUserIds)) + .setDaily(toLeaderboardUserCO(days, userProfileMap, invisibleUserIds)) + .setWeekly(toLeaderboardUserCO(weeks, userProfileMap, invisibleUserIds)) + .setMonthly(toLeaderboardUserCO(months, userProfileMap, invisibleUserIds)) ; } @@ -74,31 +79,39 @@ public class GiftsReceivedLeaderboardQryExe { Map userProfileMap = userProfileAppConvertor.toMapUserProfileDTO( userProfileGateway.mapByUserIds(userIds) ); + Set invisibleUserIds = userProfileGateway.filterUsersByVipAbility(userIds, VipAbilityType.MYSTERIOUS_INVISIBILITY); List emptyList = Collections.emptyList(); return new ActivityLeaderboardCO() - .setHourly(toLeaderboardUserCO(emptyList, userProfileMap)) - .setDaily(toLeaderboardUserCO(emptyList, userProfileMap)) - .setWeekly(toLeaderboardUserCO(weeks, userProfileMap)) - .setMonthly(toLeaderboardUserCO(emptyList, userProfileMap)) + .setHourly(toLeaderboardUserCO(emptyList, userProfileMap, invisibleUserIds)) + .setDaily(toLeaderboardUserCO(emptyList, userProfileMap, invisibleUserIds)) + .setWeekly(toLeaderboardUserCO(weeks, userProfileMap, invisibleUserIds)) + .setMonthly(toLeaderboardUserCO(emptyList, userProfileMap, invisibleUserIds)) ; } private List toLeaderboardUserCO(List list, - Map userProfileMap) { + Map userProfileMap, Set invisibleUserIds) { return list.stream().map(count -> { UserProfileDTO userProfile = userProfileMap.get(count.getBusinessId()); if (Objects.isNull(userProfile)) { log.warn("数据错误,没有找到用户记录: {}", JacksonUtils.toJson(count)); return null; } - return new LeaderboardUserCO() - .setId(userProfile.getId()) - .setAvatar(userProfile.getUserAvatar()) - .setNickname(userProfile.getUserNickname()) + LeaderboardUserCO co = new LeaderboardUserCO() .setQuantity(count.getQuantity()) .setQuantityFormat(NumUtils.formatLong(count.getQuantity())); + if (invisibleUserIds.contains(count.getBusinessId())) { + co.setId(null); + co.setNickname("****"); + co.setAvatar(enumConfigCacheService.getValue(EnumConfigKey.USER_YINSHEN_COVER, userProfile.getSysOriginChild())); + } else { + co.setId(userProfile.getId()); + co.setAvatar(userProfile.getUserAvatar()); + co.setNickname(userProfile.getUserNickname()); + } + return co; }).filter(Objects::nonNull).collect(Collectors.toList()); } diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/GiftsSendLeaderboardQryExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/GiftsSendLeaderboardQryExe.java index c169770a..91a6fd24 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/GiftsSendLeaderboardQryExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/GiftsSendLeaderboardQryExe.java @@ -4,10 +4,13 @@ import com.red.circle.common.business.dto.cmd.AppExtCommand; import com.red.circle.other.app.convertor.user.UserProfileAppConvertor; import com.red.circle.other.app.dto.clientobject.activity.ActivityLeaderboardCO; import com.red.circle.other.app.dto.clientobject.activity.ActivityLeaderboardCO.LeaderboardUserCO; +import com.red.circle.other.domain.enums.VipAbilityType; import com.red.circle.other.domain.gateway.user.UserProfileGateway; +import com.red.circle.other.infra.database.cache.service.other.EnumConfigCacheService; import com.red.circle.other.infra.database.mongo.entity.activity.RankQueenCount; import com.red.circle.other.infra.database.mongo.entity.activity.RankQueenType; import com.red.circle.other.infra.database.mongo.service.activity.RankCountService; +import com.red.circle.other.inner.enums.config.EnumConfigKey; import com.red.circle.other.inner.model.dto.user.UserProfileDTO; import com.red.circle.tool.core.collection.CollectionUtils; import com.red.circle.tool.core.json.JacksonUtils; @@ -35,6 +38,7 @@ public class GiftsSendLeaderboardQryExe { private final RankCountService rankCountService; private final UserProfileGateway userProfileGateway; private final UserProfileAppConvertor userProfileAppConvertor; + private final EnumConfigCacheService enumConfigCacheService; public ActivityLeaderboardCO execute(AppExtCommand cmd) { List hours = getListRank(cmd, RankQueenType.WEALTH_RANK_HOUR,50); @@ -49,12 +53,13 @@ public class GiftsSendLeaderboardQryExe { Map userProfileMap = userProfileAppConvertor.toMapUserProfileDTO( userProfileGateway.mapByUserIds(userIds) ); + Set invisibleUserIds = userProfileGateway.filterUsersByVipAbility(userIds, VipAbilityType.MYSTERIOUS_INVISIBILITY); return new ActivityLeaderboardCO() - .setHourly(toLeaderboardUserCO(hours, userProfileMap)) - .setDaily(toLeaderboardUserCO(days, userProfileMap)) - .setWeekly(toLeaderboardUserCO(weeks, userProfileMap)) - .setMonthly(toLeaderboardUserCO(months, userProfileMap)); + .setHourly(toLeaderboardUserCO(hours, userProfileMap, invisibleUserIds)) + .setDaily(toLeaderboardUserCO(days, userProfileMap, invisibleUserIds)) + .setWeekly(toLeaderboardUserCO(weeks, userProfileMap, invisibleUserIds)) + .setMonthly(toLeaderboardUserCO(months, userProfileMap, invisibleUserIds)); } public ActivityLeaderboardCO executeApp(AppExtCommand cmd) { @@ -70,11 +75,12 @@ public class GiftsSendLeaderboardQryExe { Map userProfileMap = userProfileAppConvertor.toMapUserProfileDTO( userProfileGateway.mapByUserIds(userIds) ); + Set invisibleUserIds = userProfileGateway.filterUsersByVipAbility(userIds, VipAbilityType.MYSTERIOUS_INVISIBILITY); return new ActivityLeaderboardCO() - .setDaily(toLeaderboardUserCO(null, userProfileMap)) - .setWeekly(toLeaderboardUserCO(weeks, userProfileMap)) - .setMonthly(toLeaderboardUserCO(null, userProfileMap)); + .setDaily(toLeaderboardUserCO(null, userProfileMap, invisibleUserIds)) + .setWeekly(toLeaderboardUserCO(weeks, userProfileMap, invisibleUserIds)) + .setMonthly(toLeaderboardUserCO(null, userProfileMap, invisibleUserIds)); } private Set getAllUserIds(List days, List weeks, @@ -95,7 +101,7 @@ public class GiftsSendLeaderboardQryExe { } private List toLeaderboardUserCO(List list, - Map userProfileMap) { + Map userProfileMap, Set invisibleUserIds) { if (CollectionUtils.isEmpty(list)) { return CollectionUtils.newArrayList(); } @@ -105,12 +111,19 @@ public class GiftsSendLeaderboardQryExe { log.warn("数据异常,找不到用户记录: {}", JacksonUtils.toJson(count)); return null; } - return new LeaderboardUserCO() - .setId(userProfile.getId()) - .setAvatar(userProfile.getUserAvatar()) - .setNickname(userProfile.getUserNickname()) + LeaderboardUserCO co = new LeaderboardUserCO() .setQuantity(count.getQuantity()) .setQuantityFormat(NumUtils.formatLong(count.getQuantity())); + if (invisibleUserIds.contains(count.getBusinessId())) { + co.setId(null); + co.setNickname("****"); + co.setAvatar(enumConfigCacheService.getValue(EnumConfigKey.USER_YINSHEN_COVER, userProfile.getSysOriginChild())); + } else { + co.setId(userProfile.getId()); + co.setAvatar(userProfile.getUserAvatar()); + co.setNickname(userProfile.getUserNickname()); + } + return co; }).filter(Objects::nonNull).toList(); } diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/query/RankingListQryExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/query/RankingListQryExe.java index 54da95d4..f3a161e9 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/query/RankingListQryExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/query/RankingListQryExe.java @@ -13,10 +13,12 @@ import com.red.circle.other.domain.model.user.UserProfile; import com.red.circle.other.domain.ranking.RankingActivityType; import com.red.circle.other.domain.ranking.RankingCycleType; import com.red.circle.other.domain.ranking.RankingDimension; +import com.red.circle.other.infra.database.cache.service.other.EnumConfigCacheService; import com.red.circle.other.infra.database.mongo.entity.activity.RankingActivityRecord; import com.red.circle.other.infra.database.mongo.entity.activity.WeekKingQueenCount; import com.red.circle.other.infra.gateway.RankingActivityGateway; import com.red.circle.other.inner.endpoint.sys.SysActivityConfigClient; +import com.red.circle.other.inner.enums.config.EnumConfigKey; import com.red.circle.other.inner.model.dto.sys.ActivityConfigDTO; import com.red.circle.other.inner.model.dto.user.UserProfileDTO; import com.red.circle.tool.core.date.ZonedDateTimeAsiaRiyadhUtils; @@ -42,13 +44,12 @@ import java.util.stream.IntStream; @RequiredArgsConstructor public class RankingListQryExe { - private static final String INVISIBLE_AVATAR = "https://tkm-likei.oss-ap-southeast-1.aliyuncs.com/default_avatar/yinshen.png"; - private final RankingActivityGateway rankingActivityGateway; private final RankingActivityConvertor convertor; private final UserProfileGateway userProfileGateway; private final UserProfileAppConvertor userProfileAppConvertor; private final SysActivityConfigClient sysActivityConfigClient; + private final EnumConfigCacheService enumConfigCacheService; public RankingListCO execute(RankingListQueryCmd cmd) { // 获取枚举 @@ -89,8 +90,8 @@ public class RankingListQryExe { if (invisible) { co.setUserId(null); co.setAccount(null); - co.setNickname(maskNickname(userProfileDTO.getUserNickname())); - co.setAvatar(INVISIBLE_AVATAR); + co.setNickname("****"); + co.setAvatar(enumConfigCacheService.getValue(EnumConfigKey.USER_YINSHEN_COVER, userProfileDTO.getSysOriginChild())); } else { co.setAccount(userProfileDTO.getAccount()); co.setNickname(userProfileDTO.getUserNickname()); diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/activity/ActivityLeaderboardServiceImpl.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/activity/ActivityLeaderboardServiceImpl.java index 71b15dce..721f1843 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/activity/ActivityLeaderboardServiceImpl.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/activity/ActivityLeaderboardServiceImpl.java @@ -9,10 +9,13 @@ import com.red.circle.other.app.command.activity.RechargeLeaderboardQryExe; import com.red.circle.other.app.command.activity.RoomGiftsLeaderboardQryExe; import com.red.circle.other.app.dto.clientobject.activity.ActivityLeaderboardCO; import com.red.circle.other.app.dto.clientobject.activity.ActivityLeaderboardListCO; +import com.red.circle.other.domain.enums.VipAbilityType; import com.red.circle.other.domain.gateway.user.UserProfileGateway; import com.red.circle.other.domain.model.user.UserProfile; import com.red.circle.other.infra.database.cache.key.RankKey; +import com.red.circle.other.infra.database.cache.service.other.EnumConfigCacheService; import com.red.circle.other.infra.database.cache.service.user.RankCacheService; +import com.red.circle.other.inner.enums.config.EnumConfigKey; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -36,6 +39,7 @@ public class ActivityLeaderboardServiceImpl implements ActivityLeaderboardServic private final GiftsReceivedLeaderboardQryExe giftsReceivedLeaderboardQryExe; private final RankCacheService rankCacheService; private final UserProfileGateway userProfileGateway; + private final EnumConfigCacheService enumConfigCacheService; @Override public ActivityLeaderboardCO roomGiftsLeaderboard(AppExtCommand cmd) { @@ -73,11 +77,9 @@ public class ActivityLeaderboardServiceImpl implements ActivityLeaderboardServic ActivityLeaderboardCO co = giftsSendLeaderboardQryExe.execute(cmd); Gson gson = new Gson(); String jsonString = gson.toJson(co); - //log.warn("礼物赠送排行榜:{}", jsonString); rankCacheService.add(jsonString, cmd.requireReqSysOrigin(), RankKey.GIFTS_SEND.name()); return co; } else { - //log.warn("礼物赠送排行榜,{}", rank); Gson gson = new Gson(); Type listType = new TypeToken(){}.getType(); ActivityLeaderboardCO activityLeaderboardCO = gson.fromJson(rank, listType); @@ -245,6 +247,16 @@ public class ActivityLeaderboardServiceImpl implements ActivityLeaderboardServic private ActivityLeaderboardCO.LeaderboardUserCO defaultRankInfo(Long userId) { UserProfile userProfile = userProfileGateway.getByUserId(userId); + boolean vipAbility = userProfileGateway.getUserVipAbility(userId, VipAbilityType.MYSTERIOUS_INVISIBILITY); + if (vipAbility) { + return new ActivityLeaderboardCO.LeaderboardUserCO() + .setId(null) + .setAvatar(enumConfigCacheService.getValue(EnumConfigKey.USER_YINSHEN_COVER, userProfile.getSysOriginChild())) + .setNickname("****") + .setQuantity(0L) + .setQuantityFormat("0"); + } + return new ActivityLeaderboardCO.LeaderboardUserCO() .setId(userProfile.getId()) .setAvatar(userProfile.getUserAvatar()) 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 50df5ab1..73b020d4 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 @@ -203,6 +203,11 @@ public interface UserProfileGateway { */ boolean getUserVipAbility(Long userId, VipAbilityType abilityType); + /** + * 批量返回具有指定VIP权限的用户ID集合. + */ + Set filterUsersByVipAbility(Set userIds, VipAbilityType abilityType); + /** * 根据 userId 查询用户当前 VIP 等级 * diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/service/user/impl/RankCacheServiceImpl.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/service/user/impl/RankCacheServiceImpl.java index ee59f21a..351abdb2 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/service/user/impl/RankCacheServiceImpl.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/service/user/impl/RankCacheServiceImpl.java @@ -23,7 +23,7 @@ import java.util.concurrent.TimeUnit; public class RankCacheServiceImpl implements RankCacheService { private final RedisService redisService; - private static final long CACHE_TIME = 1; + private static final long CACHE_TIME = 5; @Override public void remove(String sysOrigin, String type) { 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 b11e50a3..59a45a83 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 @@ -512,6 +512,22 @@ public class UserProfileGatewayImpl implements UserProfileGateway { return hasVipLevel && switchOn; } + @Override + public Set filterUsersByVipAbility(Set userIds, VipAbilityType abilityType) { + if (CollectionUtils.isEmpty(userIds)) { + return Collections.emptySet(); + } + Map profileMap = mapByUserIds(userIds); + return profileMap.entrySet().stream() + .filter(entry -> { + String vipName = resolveVipNameFromProfile(entry.getValue()); + return abilityType.hasAbility(vipName) + && userVipAbilitySettingService.isEnabled(entry.getKey(), abilityType); + }) + .map(Map.Entry::getKey) + .collect(Collectors.toSet()); + } + private boolean inWhiteList(Long userId) { EnumConfigDTO configDTO = enumConfigCacheService.getByCode("LOGIN_WHITE_CONFIG", "LIKEI"); String whiteConfig = Optional.ofNullable(configDTO).map(EnumConfigDTO::getVal).orElse(null); @@ -535,7 +551,10 @@ public class UserProfileGatewayImpl implements UserProfileGateway { } private String resolveUserVipName(Long userId) { - UserProfile userProfile = getByUserId(userId); + return resolveVipNameFromProfile(getByUserId(userId)); + } + + private String resolveVipNameFromProfile(UserProfile userProfile) { if (Objects.isNull(userProfile) || CollectionUtils.isEmpty(userProfile.getUseProps())) { return null; }