游戏获胜新增打榜活动

This commit is contained in:
tianfeng 2025-12-18 17:47:56 +08:00
parent 389317b691
commit 2891b2d16f
3 changed files with 59 additions and 14 deletions

View File

@ -17,19 +17,25 @@ import com.red.circle.component.game.hotgame.response.HotGameResponse;
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.dto.ReqSysOrigin;
import com.red.circle.framework.core.security.UserCredential;
import com.red.circle.framework.web.annotation.IgnoreResultResponse;
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.dto.cmd.game.GameLxwlUpdateBalanceCmd;
import com.red.circle.other.app.dto.cmd.game.GameLxwlUserInfoCmd;
import com.red.circle.other.app.enums.violation.GameOriginEnum;
import com.red.circle.other.app.enums.violation.ViolationTypeEnum;
import com.red.circle.other.app.service.activity.RankingActivityService;
import com.red.circle.other.app.util.OfficialNoticeUtils;
import com.red.circle.other.domain.game.GameRankingIncrementCmd;
import com.red.circle.other.domain.gateway.game.GameRankingGateway;
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.cache.service.other.GameListCacheService;
import com.red.circle.other.infra.database.rds.entity.sys.GameListConfig;
@ -38,6 +44,7 @@ import com.red.circle.other.inner.enums.config.EnumConfigKey;
import com.red.circle.other.inner.enums.team.TeamPolicyTypeEnum;
import com.red.circle.other.inner.model.dto.user.UserProfileDTO;
import com.red.circle.tool.core.date.LocalDateTimeUtils;
import com.red.circle.tool.core.date.ZonedDateTimeAsiaRiyadhUtils;
import com.red.circle.tool.core.parse.DataTypeUtils;
import com.red.circle.tool.core.text.StringUtils;
import com.red.circle.tool.crypto.SecurityUtils;
@ -77,6 +84,7 @@ public class GameHkysRestController {
private final ImGroupClient imGroupClient;
private final GameRankingGateway gameRankingGateway;
private final GameListCacheService gameListCacheService;
private final RankingActivityService rankingActivityService;
@IgnoreResultResponse
@PostMapping("/getUserInfo")
@ -167,18 +175,12 @@ public class GameHkysRestController {
}
}
//游戏参与打榜活动
incGameRankingActivity(cmd);
//累计游戏排行榜
incGameRankingRecord(cmd, gameListConfig);
/*taskMqMessage.sendTask(TaskApprovalEvent.builder()
.taskId(4)
.userId(userId)
.day(LocalDateTimeUtils.nowFormat("yyyy-MM-dd"))
.currencyDiff(cmd.getCoin())
.sysOrigin(UserCredential.parseToken(cmd.getToken()).getSysOrigin())
.gameName(GoldOrigin.HKYS_GAME.name())
.gameId(Long.parseLong(cmd.getGameId()))
.build());*/
return new HkysResponse<JSONObject>()
.setErrorCode(HyksErrorEnum.SUCCESS.getErrorCode())
.setData(jsonObject);
@ -202,6 +204,22 @@ public class GameHkysRestController {
gameRankingGateway.incrementPrizeAmount(build);
}
private void incGameRankingActivity(GameLxwlUpdateBalanceCmd request) {
if (request.getCoin() > 0) {
RankingDataUpdateCmd receiverCmd = new RankingDataUpdateCmd();
receiverCmd.setUserId(DataTypeUtils.toLong(request.getUid()));
receiverCmd.setUserSex(1);
receiverCmd.setActivityType(RankingActivityType.KING_GAMES.getCode());
receiverCmd.setCycleType(RankingCycleType.WEEKLY.getCode());
receiverCmd.setCycleKey(ZonedDateTimeAsiaRiyadhUtils.nowWeekMondayToInt().toString());
receiverCmd.setDimension(RankingDimension.GAME_WIN.getCode());
receiverCmd.setIncrementQuantity(request.getCoin());
receiverCmd.setBizNo(request.getGameId());
receiverCmd.setReqSysOrigin(ReqSysOrigin.of("LIKEI"));
rankingActivityService.accumulateRankingData(receiverCmd);
}
}
@IgnoreResultResponse
@PostMapping("/orderCompensation")
public HkysResponse<JSONObject> orderCompensation(@RequestBody JSONObject object) {

View File

@ -43,6 +43,7 @@ import com.red.circle.other.inner.enums.config.EnumConfigKey;
import com.red.circle.other.inner.model.dto.user.UserProfileDTO;
import com.red.circle.tool.core.date.DateUtils;
import com.red.circle.tool.core.date.LocalDateTimeUtils;
import com.red.circle.tool.core.date.ZonedDateTimeAsiaRiyadhUtils;
import com.red.circle.tool.core.json.JacksonUtils;
import com.red.circle.tool.core.parse.DataTypeUtils;
import com.red.circle.wallet.inner.endpoint.wallet.WalletGoldClient;
@ -204,7 +205,7 @@ public class GameBaishunServiceImpl implements GameBaishunService {
if (Objects.nonNull(gameListConfig)) {
sendBroadcast(request, gameListConfig);
//游戏是否参与打榜活动
//游戏参与打榜活动
incGameRankingActivity(request);
//累计游戏排行榜
@ -277,13 +278,13 @@ public class GameBaishunServiceImpl implements GameBaishunService {
}
private void incGameRankingActivity(BaishunChangeCurrencyRequest request) {
if (gameId != null && gameId.equals(request.getGameId()) && request.getCurrencyDiff() > 0) {
if (request.getCurrencyDiff() > 0) {
RankingDataUpdateCmd receiverCmd = new RankingDataUpdateCmd();
receiverCmd.setUserId(DataTypeUtils.toLong(request.getUserId()));
receiverCmd.setUserSex(1);
receiverCmd.setActivityType(RankingActivityType.GREEDY_GAME.getCode());
receiverCmd.setCycleType(RankingCycleType.MONTHLY.getCode());
receiverCmd.setCycleKey("202511");
receiverCmd.setActivityType(RankingActivityType.KING_GAMES.getCode());
receiverCmd.setCycleType(RankingCycleType.WEEKLY.getCode());
receiverCmd.setCycleKey(ZonedDateTimeAsiaRiyadhUtils.nowWeekMondayToInt().toString());
receiverCmd.setDimension(RankingDimension.GAME_WIN.getCode());
receiverCmd.setIncrementQuantity(request.getCurrencyDiff());
receiverCmd.setBizNo(request.getGameRoundId());

View File

@ -13,20 +13,26 @@ 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.clientobject.game.HotGameUpdateRequest;
import com.red.circle.other.app.dto.cmd.activity.RankingDataUpdateCmd;
import com.red.circle.other.app.dto.cmd.game.GameLxwlUpdateBalanceCmd;
import com.red.circle.other.app.enums.violation.GameOriginEnum;
import com.red.circle.other.app.service.activity.RankingActivityService;
import com.red.circle.other.app.service.game.override.domain.HotGameUserProfile;
import com.red.circle.other.app.service.game.override.service.HotGameService;
import com.red.circle.other.app.util.OfficialNoticeUtils;
import com.red.circle.other.domain.game.GameRankingIncrementCmd;
import com.red.circle.other.domain.gateway.game.GameRankingGateway;
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.cache.service.other.GameListCacheService;
import com.red.circle.other.infra.database.rds.entity.sys.GameListConfig;
@ -34,6 +40,7 @@ import com.red.circle.other.infra.database.rds.service.sys.GameListConfigService
import com.red.circle.other.inner.enums.config.EnumConfigKey;
import com.red.circle.other.inner.model.dto.user.UserProfileDTO;
import com.red.circle.tool.core.date.LocalDateTimeUtils;
import com.red.circle.tool.core.date.ZonedDateTimeAsiaRiyadhUtils;
import com.red.circle.tool.core.json.JacksonUtils;
import com.red.circle.tool.core.num.ArithmeticUtils;
import com.red.circle.tool.core.parse.DataTypeUtils;
@ -77,6 +84,7 @@ public class HotGameServiceImpl implements HotGameService {
private final GameListConfigService gameListConfigService;
private final GameRankingGateway gameRankingGateway;
private final GameListCacheService gameListCacheService;
private final RankingActivityService rankingActivityService;
@Override
public HotGameResponse<HotGameUserProfile> getUserProfile(HotGameUserProfileQuery query) {
@ -209,6 +217,8 @@ public class HotGameServiceImpl implements HotGameService {
sendBroadcast(param, gameListConfig);
//累计游戏排行榜
incGameRankingRecord(param, gameListConfig);
//游戏参与打榜活动
incGameRankingActivity(param);
return new HotGameResponse<HotGameCoin>()
.setData(new HotGameCoin()
.setBalanceCoin(res.getBalance().getDollarAmount().longValue())
@ -247,6 +257,22 @@ public class HotGameServiceImpl implements HotGameService {
gameRankingGateway.incrementPrizeAmount(build);
}
private void incGameRankingActivity(HotGameUserCoinUpdate param) {
if (param.getCoin() > 0) {
RankingDataUpdateCmd receiverCmd = new RankingDataUpdateCmd();
receiverCmd.setUserId(DataTypeUtils.toLong(param.getUid()));
receiverCmd.setUserSex(1);
receiverCmd.setActivityType(RankingActivityType.KING_GAMES.getCode());
receiverCmd.setCycleType(RankingCycleType.WEEKLY.getCode());
receiverCmd.setCycleKey(ZonedDateTimeAsiaRiyadhUtils.nowWeekMondayToInt().toString());
receiverCmd.setDimension(RankingDimension.GAME_WIN.getCode());
receiverCmd.setIncrementQuantity(param.getCoin());
receiverCmd.setBizNo(param.getGameId());
receiverCmd.setReqSysOrigin(ReqSysOrigin.of("LIKEI"));
rankingActivityService.accumulateRankingData(receiverCmd);
}
}
private void sendBroadcast(HotGameUserCoinUpdate request, GameListConfig gameListConfig) {
if (gameListConfig == null) {
return;