diff --git a/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/activity/RankingActivityRestController.java b/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/activity/RankingActivityRestController.java index bfdec906..f5fe4b44 100644 --- a/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/activity/RankingActivityRestController.java +++ b/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/activity/RankingActivityRestController.java @@ -56,12 +56,13 @@ public class RankingActivityRestController extends BaseController { if (cmd.getCycleType() == null) { cmd.setCycleKey(ZonedDateTimeAsiaRiyadhUtils.nowWeekMondayToInt().toString()); } + if (RankingActivityType.KING_GAMES_DAILY.getCode().equals(cmd.getActivityType())) { + cmd.setCycleKey(ZonedDateTimeAsiaRiyadhUtils.nowDateToInt().toString()); + } return rankingActivityService.getRankingList(cmd); } - - /** * 查询历史Top1列表(周榜) * @@ -105,4 +106,21 @@ public class RankingActivityRestController extends BaseController { public List getTopThreeOverall(@RequestBody @Validated RankingListQueryCmd cmd) { return rankingActivityService.getTopThreeOverall(cmd); } + + /** + * 查询KING_GAMES_DAILY日榜前三名 + * + * @eo.name KING_GAMES_DAILY日榜前三名 + * @eo.url /king-games-daily-top-three + * @eo.method post + * @eo.request-type json + * @param cmd 查询命令 + * @return 日榜前三名 + */ + @PostMapping("/king-games-daily-top-three") + public List getKingGamesDailyTopThree(@RequestBody RankingListQueryCmd cmd) { + cmd.setActivityType(RankingActivityType.KING_GAMES_DAILY.getCode()); + cmd.setCycleKey(ZonedDateTimeAsiaRiyadhUtils.nowDateToInt().toString()); + return rankingActivityService.getKingGamesDailyTopThree(cmd); + } } \ No newline at end of file diff --git a/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/game/party3rd/GameHkysRestController.java b/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/game/party3rd/GameHkysRestController.java index 3b401d88..1ce03c29 100644 --- a/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/game/party3rd/GameHkysRestController.java +++ b/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/game/party3rd/GameHkysRestController.java @@ -248,6 +248,9 @@ public class GameHkysRestController { receiverCmd.setBizNo(request.getGameId()); receiverCmd.setReqSysOrigin(ReqSysOrigin.of("LIKEI")); rankingActivityService.accumulateRankingData(receiverCmd); + + //游戏王日榜 + gameActivityService.incKingGameDaily(DataTypeUtils.toLong(request.getUid()), request.getCoin(), request.getGameId()); } } diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/query/KingGamesDailyTopThreeQryExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/query/KingGamesDailyTopThreeQryExe.java new file mode 100644 index 00000000..f1d31a26 --- /dev/null +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/query/KingGamesDailyTopThreeQryExe.java @@ -0,0 +1,77 @@ +package com.red.circle.other.app.command.activity.query; + +import com.red.circle.other.app.convertor.user.UserProfileAppConvertor; +import com.red.circle.other.app.dto.clientobject.activity.RankingUserVO; +import com.red.circle.other.app.dto.cmd.activity.RankingListQueryCmd; +import com.red.circle.other.domain.gateway.user.UserProfileGateway; +import com.red.circle.other.domain.ranking.RankingActivityType; +import com.red.circle.other.domain.ranking.RankingCycleType; +import com.red.circle.other.infra.database.mongo.entity.activity.RankingActivityRecord; +import com.red.circle.other.infra.gateway.RankingActivityGateway; +import com.red.circle.other.inner.model.dto.user.UserProfileDTO; +import com.red.circle.tool.core.collection.CollectionUtils; +import com.red.circle.tool.core.num.NumUtils; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; + +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +/** + * KING_GAMES_DAILY 日榜前三名查询执行器 + * + * @author tf + */ +@Component +@RequiredArgsConstructor +public class KingGamesDailyTopThreeQryExe { + + private final RankingActivityGateway rankingActivityGateway; + private final UserProfileGateway userProfileGateway; + private final UserProfileAppConvertor userProfileAppConvertor; + + public List execute(RankingListQueryCmd cmd) { + List records = rankingActivityGateway.getRankingList( + cmd.getReqSysOrigin().getOrigin(), + RankingActivityType.KING_GAMES_DAILY, + RankingCycleType.DAILY, + cmd.getCycleKey(), + null, + 3 + ); + + if (CollectionUtils.isEmpty(records)) { + return List.of(); + } + + Set userIds = records.stream() + .map(RankingActivityRecord::getUserId) + .collect(Collectors.toSet()); + + Map userProfileMap = userProfileAppConvertor.toMapUserProfileDTO( + userProfileGateway.mapByUserIds(userIds)); + + return IntStream.range(0, records.size()) + .mapToObj(i -> { + RankingActivityRecord record = records.get(i); + UserProfileDTO profile = userProfileMap.get(record.getUserId()); + + RankingUserVO vo = new RankingUserVO(); + vo.setUserId(record.getUserId()); + vo.setRank(i + 1); + vo.setQuantity(NumUtils.formatLong(record.getQuantity())); + + if (profile != null) { + vo.setAccount(profile.getAccount()); + vo.setNickname(profile.getUserNickname()); + vo.setAvatar(profile.getUserAvatar()); + } + + return vo; + }) + .collect(Collectors.toList()); + } +} 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 8f8dded7..174ff97e 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 @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON; import com.red.circle.component.redis.service.RedisService; import com.red.circle.mq.business.model.event.GameKingRewardEvent; import com.red.circle.other.app.command.activity.query.HistoricalTop1QryExe; +import com.red.circle.other.app.command.activity.query.KingGamesDailyTopThreeQryExe; import com.red.circle.other.app.command.activity.query.RankingDataAccumulateCmdExe; import com.red.circle.other.app.command.activity.query.RankingListQryExe; import com.red.circle.other.app.command.activity.query.UserRankQryExe; @@ -46,6 +47,7 @@ public class RankingActivityServiceImpl implements RankingActivityService { private final RankingListQryExe rankingListQryExe; private final UserRankQryExe userRankQryExe; private final HistoricalTop1QryExe historicalTop1QryExe; + private final KingGamesDailyTopThreeQryExe kingGamesDailyTopThreeQryExe; private final RedisService redisService; private final UserMqMessageService userMqMessageService; private final UserProfileGateway userProfileGateway; @@ -230,6 +232,11 @@ public class RankingActivityServiceImpl implements RankingActivityService { return RANKING_LIST_CACHE_KEY_PREFIX + RankingActivityType.getByCode(cmd.getActivityType()).name() + ":" + cmd.getCycleKey(); } + @Override + public List getKingGamesDailyTopThree(RankingListQueryCmd cmd) { + return kingGamesDailyTopThreeQryExe.execute(cmd); + } + @Override public List getTopThreeOverall(RankingListQueryCmd cmd) { // 查询总榜排行(按用户ID分组汇总) diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/game/GameActivityService.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/game/GameActivityService.java index 6750fc06..e48e1abf 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/game/GameActivityService.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/game/GameActivityService.java @@ -1,9 +1,16 @@ package com.red.circle.other.app.service.game; import com.red.circle.component.redis.service.RedisService; +import com.red.circle.framework.core.dto.ReqSysOrigin; import com.red.circle.other.app.dto.cmd.SpinsTaskProgressUpdateCmd; +import com.red.circle.other.app.dto.cmd.activity.RankingDataUpdateCmd; import com.red.circle.other.app.service.SpinsUserTaskProgressService; +import com.red.circle.other.app.service.activity.RankingActivityService; import com.red.circle.other.app.util.DateTimeAsiaRiyadhUtils; +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.tool.core.date.ZonedDateTimeAsiaRiyadhUtils; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -23,6 +30,7 @@ public class GameActivityService { private final RedisService redisService; private final SpinsUserTaskProgressService spinsUserTaskProgressService; + private final RankingActivityService rankingActivityService; /** * 处理游戏消费/获得任务 @@ -63,6 +71,21 @@ public class GameActivityService { } } + public void incKingGameDaily(Long userId, Long rewardAmount, String gameId) { + RankingDataUpdateCmd receiverCmd = new RankingDataUpdateCmd(); + receiverCmd.setUserId(userId); + receiverCmd.setUserSex(1); + receiverCmd.setActivityType(RankingActivityType.KING_GAMES_DAILY.getCode()); + receiverCmd.setCycleType(RankingCycleType.DAILY.getCode()); + receiverCmd.setCycleKey(ZonedDateTimeAsiaRiyadhUtils.nowDateToInt().toString()); + receiverCmd.setDimension(RankingDimension.GAME_WIN.getCode()); + receiverCmd.setIncrementQuantity(rewardAmount); + receiverCmd.setBizNo(gameId); + receiverCmd.setReqSysOrigin(ReqSysOrigin.of("LIKEI")); + rankingActivityService.accumulateRankingData(receiverCmd); + } + + /** * 更新游戏进度 */ diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/game/GameBaishunServiceImpl.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/game/GameBaishunServiceImpl.java index c5bc26f3..9dbb3e5e 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/game/GameBaishunServiceImpl.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/game/GameBaishunServiceImpl.java @@ -324,6 +324,9 @@ public class GameBaishunServiceImpl implements GameBaishunService { receiverCmd.setBizNo(request.getGameRoundId()); receiverCmd.setReqSysOrigin(ReqSysOrigin.of("LIKEI")); rankingActivityService.accumulateRankingData(receiverCmd); + + //游戏王日榜 + gameActivityService.incKingGameDaily(DataTypeUtils.toLong(request.getUserId()), request.getCurrencyDiff(), request.getGameId()); } } diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/game/HotGameServiceImpl.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/game/HotGameServiceImpl.java index e545a6a4..fb497da5 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/game/HotGameServiceImpl.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/game/HotGameServiceImpl.java @@ -427,6 +427,9 @@ public class HotGameServiceImpl implements HotGameService { receiverCmd.setBizNo(param.getGameId()); receiverCmd.setReqSysOrigin(ReqSysOrigin.of("LIKEI")); rankingActivityService.accumulateRankingData(receiverCmd); + + //游戏王日榜 + gameActivityService.incKingGameDaily(DataTypeUtils.toLong(param.getUid()), param.getCoin(), param.getGameId()); } } diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/game/YomiGameServiceImpl.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/game/YomiGameServiceImpl.java index 12cc0684..5ed5453f 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/game/YomiGameServiceImpl.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/game/YomiGameServiceImpl.java @@ -335,5 +335,8 @@ public class YomiGameServiceImpl implements YomiGameService { receiverCmd.setBizNo(gameId); receiverCmd.setReqSysOrigin(ReqSysOrigin.of("LIKEI")); rankingActivityService.accumulateRankingData(receiverCmd); + + //游戏王日榜 + gameActivityService.incKingGameDaily(userId, rewardAmount.longValue(), gameId); } } \ No newline at end of file diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/activity/RankingActivityService.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/activity/RankingActivityService.java index e028afb8..b8ca7b79 100644 --- a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/activity/RankingActivityService.java +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/activity/RankingActivityService.java @@ -63,4 +63,12 @@ public interface RankingActivityService { * @return 总榜前三名用户列表 */ List getTopThreeOverall(RankingListQueryCmd cmd); + + /** + * 获取KING_GAMES_DAILY日榜前三名 + * + * @param cmd 查询命令 + * @return 日榜前三名用户列表 + */ + List getKingGamesDailyTopThree(RankingListQueryCmd cmd); } diff --git a/rc-service/rc-service-other/other-domain/src/main/java/com/red/circle/other/domain/ranking/RankingActivityType.java b/rc-service/rc-service-other/other-domain/src/main/java/com/red/circle/other/domain/ranking/RankingActivityType.java index 9ca56ca9..528dc056 100644 --- a/rc-service/rc-service-other/other-domain/src/main/java/com/red/circle/other/domain/ranking/RankingActivityType.java +++ b/rc-service/rc-service-other/other-domain/src/main/java/com/red/circle/other/domain/ranking/RankingActivityType.java @@ -54,6 +54,8 @@ public enum RankingActivityType { RAMADAN(13, "'斋月活动'", "'统计送礼物消费排行'"), INVITE(14, "'邀请活动'", "'邀请用户奖励金币排行'"), + + KING_GAMES_DAILY(15, "游戏王日榜活动", "统计游戏数据排行"), ; /**