From d1a754381651e52f962b180844004a588f2a8ee9 Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Mon, 1 Jun 2026 17:41:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=B8=E6=88=8F=E6=B4=BB=E5=8A=A8=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E9=87=8D=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit fd8d0dec8752893ee01ecd333119136e21ea0b65) --- .../app/service/game/GameActivityService.java | 45 +++++++++++++++++++ .../service/game/GameBaishunServiceImpl.java | 8 ++-- .../cmd/activity/RankingDataUpdateCmd.java | 5 +++ .../domain/ranking/RankingActivityType.java | 8 ++++ .../config/GameRankingActivityConfig.java | 43 ++++++++++++++++++ 5 files changed, 106 insertions(+), 3 deletions(-) create mode 100644 rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/config/GameRankingActivityConfig.java 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 4e4a8653..831692c7 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 @@ -8,10 +8,16 @@ 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.gateway.user.ability.UserRegionGateway; 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.config.GameRankingActivityConfig; import com.red.circle.tool.core.date.ZonedDateTimeAsiaRiyadhUtils; +import com.red.circle.tool.core.date.ZonedId; + +import java.time.LocalDateTime; +import java.time.ZonedDateTime; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -32,6 +38,8 @@ public class GameActivityService { private final RedisService redisService; private final SpinsUserTaskProgressService spinsUserTaskProgressService; private final RankingActivityService rankingActivityService; + private final UserRegionGateway userRegionGateway; + private final GameRankingActivityConfig gameRankingActivityConfig; /** * 处理游戏消费/获得任务 @@ -86,6 +94,43 @@ public class GameActivityService { rankingActivityService.accumulateRankingData(receiverCmd); } + public void incConfiguredRankingActivity(Long userId, Long rewardAmount, String gameId, RankingActivityType activityType) { + try { + GameRankingActivityConfig.ActivityItem item = gameRankingActivityConfig.getItems().stream() + .filter(i -> activityType.equals(i.resolveActivityType())) + .findFirst() + .orElse(null); + if (item == null || item.getGameId() == null || item.getFinishTime() == null || item.getCycleKey() == null) { + return; + } + if (!item.getGameId().equals(gameId)) { + return; + } + ZonedDateTime finish = ZonedDateTime.of( + LocalDateTime.parse(item.getFinishTime()), + ZonedId.ASIA_RIYADH.getZonedId() + ); + if (ZonedDateTimeAsiaRiyadhUtils.now().isAfter(finish)) { + return; + } + String regionId = userRegionGateway.getRegionId(userId); + RankingDataUpdateCmd cmd = new RankingDataUpdateCmd(); + cmd.setUserId(userId); + cmd.setUserSex(1); + cmd.setActivityType(activityType.getCode()); + cmd.setCycleType(RankingCycleType.WEEKLY.getCode()); + cmd.setCycleKey(item.getCycleKey()); + cmd.setDimension(RankingDimension.GAME_WIN.getCode()); + cmd.setIncrementQuantity(rewardAmount); + cmd.setBizNo(gameId); + cmd.setRegionId(regionId); + cmd.setReqSysOrigin(ReqSysOrigin.of("LIKEI")); + rankingActivityService.accumulateRankingData(cmd); + } catch (Exception e) { + log.error("incConfiguredRankingActivity error: userId={}, activityType={}", userId, activityType, e); + } + } + /** * 更新游戏进度 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 2625840f..05f9e8a3 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 @@ -21,6 +21,7 @@ import com.red.circle.mq.rocket.business.producer.TaskMqMessage; import com.red.circle.other.app.convertor.user.UserProfileAppConvertor; import com.red.circle.other.app.enums.violation.GameOriginEnum; import com.red.circle.other.app.service.game.common.GameEventService; +import com.red.circle.other.domain.ranking.RankingActivityType; import com.red.circle.other.app.service.task.TaskService; import com.red.circle.other.domain.gateway.user.UserProfileGateway; import com.red.circle.other.infra.database.cache.service.other.EnumConfigCacheService; @@ -181,15 +182,16 @@ public class GameBaishunServiceImpl implements GameBaishunService { } GameListConfig gameListConfig = gameListCacheService.getByGameIdWithCache( - request.getGameId(), - GameOriginEnum.BAISHUN.name(), - sysOrigin, + request.getGameId(), + GameOriginEnum.BAISHUN.name(), + sysOrigin, () -> gameListConfigService.getByGameId(request.getGameId(), GameOriginEnum.BAISHUN.name(), sysOrigin) ); // request.getCurrencyDiff() > 0 是收入 request.getCurrencyDiff() < 0 是支出 if (Objects.nonNull(gameListConfig)) { if (request.getCurrencyDiff() > 0) { + gameActivityService.incConfiguredRankingActivity(userId, request.getCurrencyDiff(), request.getGameId(), RankingActivityType.FOOT_BALL); gameEventService.onWinEvent(userId, request.getCurrencyDiff(), GameOriginEnum.BAISHUN.name(), gameListConfig); gameActivityService.handleGameSpendTask(userId, Math.abs(request.getCurrencyDiff())); gameActivityService.incKingGameDaily(userId, request.getCurrencyDiff(), request.getGameId()); diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/activity/RankingDataUpdateCmd.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/activity/RankingDataUpdateCmd.java index 35ad454a..ec25fb94 100644 --- a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/activity/RankingDataUpdateCmd.java +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/activity/RankingDataUpdateCmd.java @@ -77,4 +77,9 @@ public class RankingDataUpdateCmd extends AppExtCommand { * 扩展数据(JSON 格式) */ private String extData; + + /** + * 区域ID + */ + private String regionId; } \ No newline at end of file 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 c534bc8f..2e0172e0 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 @@ -59,6 +59,14 @@ public enum RankingActivityType { KING_GAMES_DAILY(15, "游戏王日榜活动", "统计游戏数据排行"), OPEN_RAMADAN(16, "开斋节活动", "统计送礼物消费排行"), + + POKER_ACE(17, "PokerAce游戏活动", "玩游戏获胜排行"), + + MAGIC_GIFT_DAILY(18, "每日魔法礼物", "统计送魔法礼物排行"), + + EID_AL_ADHA(19, "古尔邦节活动", "统计送魔法礼物排行"), + + FOOT_BALL(20, "FootBall", "玩游戏获胜排行"), ; /** diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/config/GameRankingActivityConfig.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/config/GameRankingActivityConfig.java new file mode 100644 index 00000000..9a3658d2 --- /dev/null +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/config/GameRankingActivityConfig.java @@ -0,0 +1,43 @@ +package com.red.circle.other.infra.config; + +import com.red.circle.other.domain.ranking.RankingActivityType; +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +import java.util.Collections; +import java.util.List; + +/** + * 游戏排行榜活动配置 + */ +@Data +@Component +@ConfigurationProperties(prefix = "game.ranking-activity") +public class GameRankingActivityConfig { + + private List items = Collections.emptyList(); + + /** + * 单个活动配置项 + */ + @Data + public static class ActivityItem { + + /** 活动类型,对应 RankingActivityType 枚举常量名 */ + private String activityType; + + /** 参与排行的游戏 ID */ + private String gameId; + + /** 活动结束时间,格式 yyyy-MM-dd'T'HH:mm:ss(Riyadh 时区) */ + private String finishTime; + + /** 周期 key,格式 yyyyMMdd */ + private String cycleKey; + + public RankingActivityType resolveActivityType() { + return RankingActivityType.getByConstantName(activityType); + } + } +}