diff --git a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/enums/activity/PropsActivityTypeEnum.java b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/enums/activity/PropsActivityTypeEnum.java index 1180c60a..f5076506 100644 --- a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/enums/activity/PropsActivityTypeEnum.java +++ b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/enums/activity/PropsActivityTypeEnum.java @@ -202,5 +202,15 @@ public enum PropsActivityTypeEnum { */ GAME_KTV_WEEK_RANK_REWARD, + /** + * 游戏王徽章奖励 + */ + GAME_KING_BADGE, + + /** + * 游戏王荣誉奖励 + */ + GAME_KING_HONOR, + } diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/RankingRewardGrantCmdExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/RankingRewardGrantCmdExe.java index 84e218dc..044d2861 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/RankingRewardGrantCmdExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/RankingRewardGrantCmdExe.java @@ -4,16 +4,17 @@ import com.google.common.collect.Sets; import com.red.circle.common.business.enums.SendPropsOrigin; import com.red.circle.mq.business.model.event.BadgeOperateEvent; import com.red.circle.mq.rocket.business.producer.UserMqMessageService; +import com.red.circle.other.app.common.props.SingleGroupRewardPoolCommon; import com.red.circle.other.app.dto.clientobject.sys.ActivityConfigVO; import com.red.circle.other.infra.database.mongo.entity.ranking.RankingRewardSnapshot; import com.red.circle.other.infra.database.mongo.service.ranking.RankingRewardSnapshotService; -import com.red.circle.other.infra.database.rds.entity.badge.BadgeConfig; -import com.red.circle.other.infra.database.rds.service.badge.BadgeConfigService; import com.red.circle.other.inner.endpoint.material.props.PropsBackpackClient; +import com.red.circle.other.inner.enums.activity.PropsActivityTypeEnum; import com.red.circle.other.inner.enums.material.PropsCommodityType; import com.red.circle.other.inner.model.cmd.material.DeletePropsCmd; import com.red.circle.other.inner.model.cmd.material.GivePropsBackpackCmd; -import com.red.circle.other.inner.model.dto.material.PropsActivityRewardConfigInfoDTO; +import com.red.circle.other.inner.model.dto.activity.props.ActivityRewardPropsDTO; +import com.red.circle.other.inner.model.dto.sys.ActivityConfigDTO; import com.red.circle.tool.core.collection.CollectionUtils; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -34,7 +35,7 @@ public class RankingRewardGrantCmdExe { private final RankingRewardSnapshotService snapshotService; private final PropsBackpackClient propsBackpackClient; private final UserMqMessageService userMqMessageService; - private final BadgeConfigService badgeConfigService; + private final SingleGroupRewardPoolCommon singleGroupRewardPoolCommon; /** * 处理排名奖励变化. @@ -202,54 +203,46 @@ public class RankingRewardGrantCmdExe { * 获取指定排名的奖励列表. */ private List getRewardsForRank(Integer rank, ActivityConfigVO activityConfig) { - if (activityConfig == null || CollectionUtils.isEmpty(activityConfig.getButOneRewards())) { + if (activityConfig == null || activityConfig.getConfig() == null) { return Collections.emptyList(); } + + ActivityConfigDTO config = activityConfig.getConfig(); - String rankRange = getRankRange(rank); + List badgeList = singleGroupRewardPoolCommon.listRewardProps( + config.getSysOrigin(), PropsActivityTypeEnum.GAME_KING_BADGE); + List honorList = singleGroupRewardPoolCommon.listRewardProps( + config.getSysOrigin(), PropsActivityTypeEnum.GAME_KING_HONOR); + + if (rank < 1 || rank > 10) { + return Collections.emptyList(); + } + + List rewards = new ArrayList<>(); - return activityConfig.getButOneRewards().stream() - .filter(r -> rankRange.equals(r.getRankRange())) - .flatMap(r -> { - if (CollectionUtils.isEmpty(r.getRewards())) { - return java.util.stream.Stream.empty(); - } - return r.getRewards().stream() - .filter(this::isSupportedRewardType) - .map(this::convertToRewardItem); - }) - .collect(Collectors.toList()); - } - - /** - * 判断是否为支持的奖励类型. - */ - private boolean isSupportedRewardType(PropsActivityRewardConfigInfoDTO dto) { - return ("PROPS".equals(dto.getType()) && "AVATAR_FRAME".equals(dto.getDetailType())) || - ("BADGE".equals(dto.getType()) && "HONOR_ACTIVITY".equals(dto.getDetailType())); - } - - /** - * 转换为奖励项. - */ - private RankingRewardSnapshot.RewardItem convertToRewardItem(PropsActivityRewardConfigInfoDTO dto) { - return new RankingRewardSnapshot.RewardItem() - .setType(dto.getType()) - .setDetailType(dto.getDetailType()) - .setContent(dto.getContent()) - .setQuantity(dto.getQuantity()) - .setBadgeName(dto.getBadgeName()); - } - - /** - * 获取排名范围. - */ - private String getRankRange(Integer rank) { - if (rank == 1) return "1"; - if (rank == 2) return "2"; - if (rank == 3) return "3"; - if (rank <= 10) return "4-10"; - return "other"; + int index = rank - 1; + + if (CollectionUtils.isNotEmpty(badgeList) && index < badgeList.size()) { + ActivityRewardPropsDTO badge = badgeList.get(index); + RankingRewardSnapshot.RewardItem badgeItem = new RankingRewardSnapshot.RewardItem() + .setType(badge.getType()) + .setDetailType(badge.getDetailType()) + .setContent(badge.getContent()) + .setQuantity(badge.getQuantity()); + rewards.add(badgeItem); + } + + if (CollectionUtils.isNotEmpty(honorList) && index < honorList.size()) { + ActivityRewardPropsDTO honor = honorList.get(index); + RankingRewardSnapshot.RewardItem honorItem = new RankingRewardSnapshot.RewardItem() + .setType(honor.getType()) + .setDetailType(honor.getDetailType()) + .setContent(honor.getContent()) + .setQuantity(honor.getQuantity()); + rewards.add(honorItem); + } + + return rewards; } /** @@ -260,13 +253,12 @@ public class RankingRewardGrantCmdExe { ActivityConfigVO activityConfig) { List snapshotUsers = currentRankingUsers.stream() .map(user -> { - String rankRange = getRankRange(user.getRank()); List rewards = getRewardsForRank(user.getRank(), activityConfig); return new RankingRewardSnapshot.RankingUserSnapshot() .setUserId(user.getUserId()) .setRank(user.getRank()) - .setRankRange(rankRange) + .setRankRange(String.valueOf(user.getRank())) .setScore(user.getScore()) .setRewards(rewards); }) diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/activity/RankingActivityServiceImpl.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/activity/RankingActivityServiceImpl.java index 87ee48d3..6eb7c907 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/activity/RankingActivityServiceImpl.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/activity/RankingActivityServiceImpl.java @@ -74,7 +74,7 @@ public class RankingActivityServiceImpl implements RankingActivityService { String cachedJson = redisService.getString(cacheKey); if (cachedJson != null) { - return JSON.parseArray(cachedJson, RankingUserVO.class); +// return JSON.parseArray(cachedJson, RankingUserVO.class); } RankingListQueryCmd top4Cmd = new RankingListQueryCmd();