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 c591ee23..85cfc7e6 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 @@ -49,7 +49,9 @@ public class RankingActivityRestController extends BaseController { */ @PostMapping("/list") public RankingListCO getRankingList(@RequestBody @Validated RankingListQueryCmd cmd) { - cmd.setCycleKey(ZonedDateTimeAsiaRiyadhUtils.nowWeekMondayToInt().toString()); + if (cmd.getCycleType() == null) { + cmd.setCycleKey(ZonedDateTimeAsiaRiyadhUtils.nowWeekMondayToInt().toString()); + } return rankingActivityService.getRankingList(cmd); } 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 b27d6781..fe097857 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 @@ -45,7 +45,7 @@ public class RankingListQryExe { public RankingListCO execute(RankingListQueryCmd cmd) { // 获取枚举 RankingActivityType activityType = RankingActivityType.getByCode(cmd.getActivityType()); - RankingCycleType cycleType = RankingCycleType.WEEKLY; + RankingCycleType cycleType = cmd.getCycleType() != null ? RankingCycleType.getByCode(cmd.getCycleType()) : RankingCycleType.WEEKLY; // 查询排行榜列表 List records = rankingActivityGateway.getRankingList( 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 2b5c2236..95a44197 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 @@ -18,13 +18,19 @@ import com.red.circle.external.inner.endpoint.message.ImGroupClient; import com.red.circle.external.inner.model.cmd.message.BroadcastGroupMsgBodyCmd; import com.red.circle.external.inner.model.enums.message.GroupMessageTypeEnum; import com.red.circle.framework.core.asserts.ResponseAssert; +import com.red.circle.framework.core.dto.ReqSysOrigin; import com.red.circle.framework.core.exception.ResponseException; import com.red.circle.framework.core.security.UserCredential; import com.red.circle.mq.business.model.event.task.TaskApprovalEvent; import com.red.circle.mq.rocket.business.producer.TaskMqMessage; import com.red.circle.other.app.convertor.user.UserProfileAppConvertor; +import com.red.circle.other.app.dto.cmd.activity.RankingDataUpdateCmd; +import com.red.circle.other.app.service.activity.RankingActivityService; import com.red.circle.other.app.util.OfficialNoticeUtils; 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.domain.ranking.RankingDimension; import com.red.circle.other.infra.database.cache.service.other.EnumConfigCacheService; import com.red.circle.other.infra.database.rds.entity.sys.GameListConfig; import com.red.circle.other.infra.database.rds.service.sys.GameListConfigService; @@ -45,6 +51,7 @@ import java.util.Objects; import java.util.concurrent.TimeUnit; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; /** @@ -67,6 +74,9 @@ public class GameBaishunServiceImpl implements GameBaishunService { private final EnumConfigCacheService enumConfigCacheService; private final GameListConfigService gameListConfigService; private final ImGroupClient imGroupClient; + private final RankingActivityService rankingActivityService; + @Value("${red-circle.game-rank.gameid}") + private String gameId; @Override public BaishunResponse getToken(BaishunTokenRequest request) { @@ -199,6 +209,13 @@ public class GameBaishunServiceImpl implements GameBaishunService { } } + //游戏是否参与打榜活动 + if (gameId != null && gameId.equals(request.getGameId()) && request.getCurrencyDiff() > 0) { + incGameRankingActivity(DataTypeUtils.toLong(request.getUserId()), 1, request.getCurrencyDiff(), + request.getGameRoundId()); + } + + log.warn("{} 发送游戏获奖通知--金币数量{}", GoldOrigin.BAISHUN_GAME.name(), request.getCurrencyDiff()); return BaishunResponse.success(new BaishunChangeCurrencyResponse() .setCurrencyBalance(receiptRes.getBalance().getDollarAmount().stripTrailingZeros()), @@ -217,7 +234,21 @@ public class GameBaishunServiceImpl implements GameBaishunService { return BaishunResponse.fail(BaishunErrorCode.SERVER_ERROR); } - private GoldReceiptCmd createReceipt(BaishunChangeCurrencyRequest param) { + private void incGameRankingActivity(Long userId, Integer userSex, Long amount, String gameRoundId) { + RankingDataUpdateCmd receiverCmd = new RankingDataUpdateCmd(); + receiverCmd.setUserId(userId); + receiverCmd.setUserSex(userSex); + receiverCmd.setActivityType(RankingActivityType.GREEDY_GAME.getCode()); + receiverCmd.setCycleType(RankingCycleType.MONTHLY.getCode()); + receiverCmd.setCycleKey("202511"); + receiverCmd.setDimension(RankingDimension.GAME_WIN.getCode()); + receiverCmd.setIncrementQuantity(amount); + receiverCmd.setBizNo(gameRoundId); + receiverCmd.setReqSysOrigin(ReqSysOrigin.of("LIKEI")); + rankingActivityService.accumulateRankingData(receiverCmd); + } + + private GoldReceiptCmd createReceipt(BaishunChangeCurrencyRequest param) { UserCredential userCredential = UserCredential.parseToken(param.getToken()); return createGoldReceiptCmdBuilder(param.getCurrencyDiff()) .userId(DataTypeUtils.toLong(param.getUserId())) 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 7d3d5984..dd309c6f 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 @@ -34,8 +34,9 @@ public enum RankingActivityType { LIBANEN_DAY(5, "黎巴嫩独立日", "统计送礼物消费排行"), - YEMEN_DAY(6, "也门独立日", "统计送礼物消费排行") + YEMEN_DAY(6, "也门独立日", "统计送礼物消费排行"), + GREEDY_GAME(1068, "GreedyLion", "游戏中奖排行"), ; /** diff --git a/rc-service/rc-service-other/other-domain/src/main/java/com/red/circle/other/domain/ranking/RankingDimension.java b/rc-service/rc-service-other/other-domain/src/main/java/com/red/circle/other/domain/ranking/RankingDimension.java index 0eeb4a59..1402ab4f 100644 --- a/rc-service/rc-service-other/other-domain/src/main/java/com/red/circle/other/domain/ranking/RankingDimension.java +++ b/rc-service/rc-service-other/other-domain/src/main/java/com/red/circle/other/domain/ranking/RankingDimension.java @@ -19,6 +19,8 @@ public enum RankingDimension { */ CONSUME_AMOUNT(1, "消费金额", "金币"), + GAME_WIN(2, "游戏中奖", "金币"), + ; /** * 维度编码 diff --git a/rc-service/rc-service-other/other-start/src/test/java/SpringTest.java b/rc-service/rc-service-other/other-start/src/test/java/SpringTest.java index 8c15eb65..0ff82ce0 100644 --- a/rc-service/rc-service-other/other-start/src/test/java/SpringTest.java +++ b/rc-service/rc-service-other/other-start/src/test/java/SpringTest.java @@ -7,13 +7,19 @@ import com.red.circle.external.inner.model.cmd.message.BroadcastGroupMsgBodyCmd; import com.red.circle.external.inner.model.cmd.message.notice.official.NoticeExtTemplateTypeCmd; import com.red.circle.external.inner.model.enums.message.GroupMessageTypeEnum; import com.red.circle.external.inner.model.enums.message.OfficialNoticeTypeEnum; +import com.red.circle.framework.core.dto.ReqSysOrigin; import com.red.circle.other.app.convertor.user.UserProfileAppConvertor; +import com.red.circle.other.app.dto.cmd.activity.RankingDataUpdateCmd; +import com.red.circle.other.app.service.activity.RankingActivityService; import com.red.circle.other.app.service.user.user.AppUserDataViolationService; import com.red.circle.other.app.util.OfficialNoticeUtils; import com.red.circle.other.domain.gateway.PropCouponGateway; import com.red.circle.other.domain.gateway.user.UserProfileGateway; import com.red.circle.other.domain.gateway.user.ability.InviteUserGateway; import com.red.circle.other.domain.propcoupon.PropCoupon; +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.rds.entity.sys.GameListConfig; import com.red.circle.other.infra.database.rds.service.sys.GameListConfigService; @@ -53,6 +59,23 @@ public class SpringTest { private PropCouponGateway propCouponGateway; @Autowired private AppUserDataViolationService userDataViolationService; + @Autowired + private RankingActivityService rankingActivityService; + + @Test + public void testGame() { + RankingDataUpdateCmd receiverCmd = new RankingDataUpdateCmd(); + receiverCmd.setUserId(1957345312961527809L); + receiverCmd.setUserSex(1); + receiverCmd.setActivityType(RankingActivityType.GREEDY_GAME.getCode()); + receiverCmd.setCycleType(RankingCycleType.MONTHLY.getCode()); + receiverCmd.setCycleKey("202511"); + receiverCmd.setDimension(RankingDimension.GAME_WIN.getCode()); + receiverCmd.setIncrementQuantity(111L); + receiverCmd.setBizNo("3243k1od"); + receiverCmd.setReqSysOrigin(ReqSysOrigin.of("LIKEI")); + rankingActivityService.accumulateRankingData(receiverCmd); + } @Test public void test() {