打榜和周星排行榜隐身处理

This commit is contained in:
tianfeng 2026-03-19 14:18:16 +08:00
parent aa50d842c6
commit cc22708e70
3 changed files with 36 additions and 9 deletions

View File

@ -11,6 +11,7 @@ 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.UserProfileGateway;
import com.red.circle.other.domain.model.user.UserProfile; import com.red.circle.other.domain.model.user.UserProfile;
import com.red.circle.other.domain.ranking.RankingActivityType; import com.red.circle.other.domain.ranking.RankingActivityType;
import com.red.circle.other.infra.utils.UserIdEncryptUtils;
import com.red.circle.other.domain.ranking.RankingCycleType; import com.red.circle.other.domain.ranking.RankingCycleType;
import com.red.circle.other.domain.ranking.RankingDimension; 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.cache.service.other.EnumConfigCacheService;
@ -72,23 +73,23 @@ public class RankingListQryExe {
cmd.getTopN() cmd.getTopN()
); );
Set<Long> userIds = getUserIds(records);
Map<Long, UserProfileDTO> userProfileMap = userProfileAppConvertor.toMapUserProfileDTO( Map<Long, UserProfileDTO> userProfileMap = userProfileAppConvertor.toMapUserProfileDTO(
userProfileGateway userProfileGateway.mapByUserIds(userIds));
.mapByUserIds(getUserIds(records))); Set<Long> invisibleUserIds = userProfileGateway.filterUsersByVipAbility(userIds, VipAbilityType.MYSTERIOUS_INVISIBILITY);
// 转换为CO并设置排名 // 转换为CO并设置排名
List<RankingActivityRecordCO> rankingList = IntStream.range(0, records.size()) List<RankingActivityRecordCO> rankingList = IntStream.range(0, records.size())
.mapToObj(i -> { .mapToObj(i -> {
RankingActivityRecord record = records.get(i); RankingActivityRecord record = records.get(i);
RankingActivityRecordCO co = convertor.toRecordCO(record); RankingActivityRecordCO co = convertor.toRecordCO(record);
co.setRank(i + 1); // 排名从1开始 co.setRank(i + 1);
UserProfileDTO userProfileDTO = userProfileMap.get(record.getUserId()); UserProfileDTO userProfileDTO = userProfileMap.get(record.getUserId());
if (userProfileDTO != null) { if (userProfileDTO != null) {
boolean invisible = userProfileGateway.getUserVipAbility( if (invisibleUserIds.contains(record.getUserId())) {
record.getUserId(), VipAbilityType.MYSTERIOUS_INVISIBILITY);
if (invisible) {
co.setUserId(null); co.setUserId(null);
co.setEncryptedId(UserIdEncryptUtils.encrypt(userProfileDTO.getId()));
co.setAccount(null); co.setAccount(null);
co.setNickname("****"); co.setNickname("****");
co.setAvatar(enumConfigCacheService.getValue(EnumConfigKey.USER_YINSHEN_COVER, userProfileDTO.getSysOriginChild())); co.setAvatar(enumConfigCacheService.getValue(EnumConfigKey.USER_YINSHEN_COVER, userProfileDTO.getSysOriginChild()));
@ -153,7 +154,10 @@ public class RankingListQryExe {
// 从排行榜列表中查找当前用户 // 从排行榜列表中查找当前用户
Optional<RankingActivityRecordCO> userInList = rankingList.stream() Optional<RankingActivityRecordCO> userInList = rankingList.stream()
.filter(record -> cmd.getReqUserId().equals(record.getUserId())) .filter(record -> cmd.getReqUserId().equals(record.getUserId())
|| (record.getUserId() == null
&& record.getEncryptedId() != null
&& cmd.getReqUserId().equals(UserIdEncryptUtils.decrypt(record.getEncryptedId()))))
.findFirst(); .findFirst();
if (userInList.isPresent()) { if (userInList.isPresent()) {

View File

@ -7,9 +7,13 @@ import com.red.circle.other.app.convertor.user.UserProfileAppConvertor;
import com.red.circle.other.app.dto.clientobject.activity.UserRankCO; import com.red.circle.other.app.dto.clientobject.activity.UserRankCO;
import com.red.circle.other.app.dto.clientobject.activity.WeekStarGiftUserRankCO; import com.red.circle.other.app.dto.clientobject.activity.WeekStarGiftUserRankCO;
import com.red.circle.other.app.dto.cmd.activity.WeekStarRankingQueryCmd; import com.red.circle.other.app.dto.cmd.activity.WeekStarRankingQueryCmd;
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.UserProfileGateway;
import com.red.circle.other.infra.database.cache.service.other.EnumConfigCacheService;
import com.red.circle.other.infra.database.mongo.entity.activity.WeekStarGiftCount; import com.red.circle.other.infra.database.mongo.entity.activity.WeekStarGiftCount;
import com.red.circle.other.infra.database.mongo.service.activity.WeekStarGiftCountService; import com.red.circle.other.infra.database.mongo.service.activity.WeekStarGiftCountService;
import com.red.circle.other.infra.utils.UserIdEncryptUtils;
import com.red.circle.other.inner.enums.config.EnumConfigKey;
import com.red.circle.other.inner.model.dto.user.UserProfileDTO; import com.red.circle.other.inner.model.dto.user.UserProfileDTO;
import com.red.circle.tool.core.collection.CollectionUtils; import com.red.circle.tool.core.collection.CollectionUtils;
import com.red.circle.tool.core.num.NumUtils; import com.red.circle.tool.core.num.NumUtils;
@ -33,6 +37,7 @@ public class WeekStarGiftRankingQueryExe {
private final UserProfileGateway userProfileGateway; private final UserProfileGateway userProfileGateway;
private final UserProfileAppConvertor userProfileAppConvertor; private final UserProfileAppConvertor userProfileAppConvertor;
private final WeekStarGiftCountService weekStarGiftCountService; private final WeekStarGiftCountService weekStarGiftCountService;
private final EnumConfigCacheService enumConfigCacheService;
public WeekStarGiftUserRankCO execute(WeekStarRankingQueryCmd cmd) { public WeekStarGiftUserRankCO execute(WeekStarRankingQueryCmd cmd) {
WeekStarGiftUserRankCO result = new WeekStarGiftUserRankCO() WeekStarGiftUserRankCO result = new WeekStarGiftUserRankCO()
@ -80,10 +85,11 @@ public class WeekStarGiftRankingQueryExe {
List<WeekStarGiftCount> weekStarGiftCounts = (List<WeekStarGiftCount>) pageResult.getRecords(); List<WeekStarGiftCount> weekStarGiftCounts = (List<WeekStarGiftCount>) pageResult.getRecords();
Set<Long> userIds = getUserIds(weekStarGiftCounts);
Map<Long, UserProfileDTO> userProfileMap = userProfileAppConvertor.toMapUserProfileDTO( Map<Long, UserProfileDTO> userProfileMap = userProfileAppConvertor.toMapUserProfileDTO(
userProfileGateway userProfileGateway.mapByUserIds(userIds)
.mapByUserIds(getUserIds(weekStarGiftCounts))
); );
Set<Long> invisibleUserIds = userProfileGateway.filterUsersByVipAbility(userIds, VipAbilityType.MYSTERIOUS_INVISIBILITY);
List<UserRankCO> list = weekStarGiftCounts.stream() List<UserRankCO> list = weekStarGiftCounts.stream()
.map(item -> { .map(item -> {
@ -91,6 +97,18 @@ public class WeekStarGiftRankingQueryExe {
if (Objects.isNull(userProfile)) { if (Objects.isNull(userProfile)) {
return null; return null;
} }
if (invisibleUserIds.contains(item.getUserId())) {
return new UserRankCO()
.setUserId(null)
.setEncryptedId(UserIdEncryptUtils.encrypt(userProfile.getId()))
.setAccount(null)
.setUserAvatar(enumConfigCacheService.getValue(EnumConfigKey.USER_YINSHEN_COVER, userProfile.getSysOriginChild()))
.setRank(item.getRank())
.setUserNickname("****")
.setQuantity(NumUtils.formatLong(item.getQuantity()))
.setCountryCode(null)
.setCountryName(null);
}
return new UserRankCO() return new UserRankCO()
.setUserId(userProfile.getId()) .setUserId(userProfile.getId())
.setAccount(userProfile.getAccount()) .setAccount(userProfile.getAccount())

View File

@ -20,6 +20,11 @@ public class RankingActivityRecordCO implements Serializable {
@JsonSerialize(using = ToStringSerializer.class) @JsonSerialize(using = ToStringSerializer.class)
private Long userId; private Long userId;
/**
* 加密后的用户ID隐身用户使用用于myRank匹配.
*/
private String encryptedId;
private String account; private String account;
/** /**