游戏接入排行榜

This commit is contained in:
tianfeng 2025-12-03 12:30:25 +08:00
parent 0c149b0db3
commit 82339cc4e1
2 changed files with 49 additions and 1 deletions

View File

@ -2,6 +2,7 @@ package com.red.circle.other.adapter.app.game.party3rd;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.red.circle.common.business.core.enums.SysOriginPlatformEnum; import com.red.circle.common.business.core.enums.SysOriginPlatformEnum;
import com.red.circle.component.game.baishun.request.BaishunChangeCurrencyRequest;
import com.red.circle.component.game.hkys.GameHkysService; import com.red.circle.component.game.hkys.GameHkysService;
import com.red.circle.component.game.hkys.props.GameHkysProperties; import com.red.circle.component.game.hkys.props.GameHkysProperties;
import com.red.circle.component.game.hkys.request.HkysUserCoinUpdate; import com.red.circle.component.game.hkys.request.HkysUserCoinUpdate;
@ -26,6 +27,8 @@ 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.GameOriginEnum;
import com.red.circle.other.app.enums.violation.ViolationTypeEnum; import com.red.circle.other.app.enums.violation.ViolationTypeEnum;
import com.red.circle.other.app.util.OfficialNoticeUtils; 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.gateway.user.UserProfileGateway;
import com.red.circle.other.infra.database.cache.service.other.EnumConfigCacheService; 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.entity.sys.GameListConfig;
@ -71,6 +74,7 @@ public class GameHkysRestController {
private final UserProfileAppConvertor userProfileAppConvertor; private final UserProfileAppConvertor userProfileAppConvertor;
private final GameListConfigService gameListConfigService; private final GameListConfigService gameListConfigService;
private final ImGroupClient imGroupClient; private final ImGroupClient imGroupClient;
private final GameRankingGateway gameRankingGateway;
@IgnoreResultResponse @IgnoreResultResponse
@PostMapping("/getUserInfo") @PostMapping("/getUserInfo")
@ -137,10 +141,10 @@ public class GameHkysRestController {
cost = BigDecimal.valueOf(5000L); cost = BigDecimal.valueOf(5000L);
} }
GameListConfig gameListConfig = gameListConfigService.getByGameId(cmd.getGameId(), GameOriginEnum.LINGXIAN.name(), sysOrigin);
if (cmd.getType() != null && cmd.getType() == 2 && cmd.getCoin() >= cost.longValue()) { if (cmd.getType() != null && cmd.getType() == 2 && cmd.getCoin() >= cost.longValue()) {
UserProfileDTO userProfile = userProfileAppConvertor.toUserProfileDTO( UserProfileDTO userProfile = userProfileAppConvertor.toUserProfileDTO(
userProfileGateway.getByUserId(userId)); userProfileGateway.getByUserId(userId));
GameListConfig gameListConfig = gameListConfigService.getByGameId(cmd.getGameId(), GameOriginEnum.LINGXIAN.name(), sysOrigin);
if (Objects.nonNull(gameListConfig)) { if (Objects.nonNull(gameListConfig)) {
Map<Object, Object> build = OfficialNoticeUtils.buildUserProfile(userProfile); Map<Object, Object> build = OfficialNoticeUtils.buildUserProfile(userProfile);
build.put("gameUrl", gameListConfig.getCover()); build.put("gameUrl", gameListConfig.getCover());
@ -156,6 +160,9 @@ public class GameHkysRestController {
} }
} }
//累计游戏排行榜
incGameRankingRecord(cmd, gameListConfig);
/*taskMqMessage.sendTask(TaskApprovalEvent.builder() /*taskMqMessage.sendTask(TaskApprovalEvent.builder()
.taskId(4) .taskId(4)
.userId(userId) .userId(userId)
@ -170,6 +177,23 @@ public class GameHkysRestController {
.setData(jsonObject); .setData(jsonObject);
} }
private void incGameRankingRecord(GameLxwlUpdateBalanceCmd request, GameListConfig gameListConfig) {
if (request.getType() != 2 || gameListConfig == null || request.getCoin() <= 0) {
return;
}
GameRankingIncrementCmd build = GameRankingIncrementCmd.builder()
.gameOrigin(GameOriginEnum.LINGXIAN.name())
.gameId(gameListConfig.getGameId())
.gameName(gameListConfig.getName())
.gameCover(gameListConfig.getCover())
.sysOrigin(gameListConfig.getSysOrigin())
.amount(request.getCoin())
.periodType("ALL")
.build();
gameRankingGateway.incrementPrizeAmount(build);
}
@IgnoreResultResponse @IgnoreResultResponse
@PostMapping("/orderCompensation") @PostMapping("/orderCompensation")
public HkysResponse<JSONObject> orderCompensation(@RequestBody JSONObject object) { public HkysResponse<JSONObject> orderCompensation(@RequestBody JSONObject object) {

View File

@ -19,10 +19,13 @@ import com.red.circle.mq.business.model.event.task.TaskApprovalEvent;
import com.red.circle.mq.rocket.business.producer.TaskMqMessage; import com.red.circle.mq.rocket.business.producer.TaskMqMessage;
import com.red.circle.other.app.convertor.user.UserProfileAppConvertor; 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.clientobject.game.HotGameUpdateRequest;
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.enums.violation.GameOriginEnum;
import com.red.circle.other.app.service.game.override.domain.HotGameUserProfile; 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.service.game.override.service.HotGameService;
import com.red.circle.other.app.util.OfficialNoticeUtils; 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.gateway.user.UserProfileGateway;
import com.red.circle.other.infra.database.cache.service.other.EnumConfigCacheService; 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.entity.sys.GameListConfig;
@ -71,6 +74,7 @@ public class HotGameServiceImpl implements HotGameService {
private final TaskMqMessage taskMqMessage; private final TaskMqMessage taskMqMessage;
private final ImGroupClient imGroupClient; private final ImGroupClient imGroupClient;
private final GameListConfigService gameListConfigService; private final GameListConfigService gameListConfigService;
private final GameRankingGateway gameRankingGateway;
@Override @Override
public HotGameResponse<HotGameUserProfile> getUserProfile(HotGameUserProfileQuery query) { public HotGameResponse<HotGameUserProfile> getUserProfile(HotGameUserProfileQuery query) {
@ -213,6 +217,9 @@ public class HotGameServiceImpl implements HotGameService {
String sysOrigin = UserCredential.parseToken(param.getToken()).getSysOrigin(); String sysOrigin = UserCredential.parseToken(param.getToken()).getSysOrigin();
GameListConfig gameListConfig = gameListConfigService.getByGameId(param.getGameId(), GameOriginEnum.HOTGAME.name(), sysOrigin); GameListConfig gameListConfig = gameListConfigService.getByGameId(param.getGameId(), GameOriginEnum.HOTGAME.name(), sysOrigin);
sendBroadcast(param, gameListConfig); sendBroadcast(param, gameListConfig);
//累计游戏排行榜
incGameRankingRecord(param, gameListConfig);
} catch (Exception e) { } catch (Exception e) {
log.error("hotgame游戏飘窗推送失败 ex:{}", e.getMessage()); log.error("hotgame游戏飘窗推送失败 ex:{}", e.getMessage());
} }
@ -221,6 +228,23 @@ public class HotGameServiceImpl implements HotGameService {
.setErrorCode(HotGameErrorEnum.SERVER_ERROR.getErrorCode()); .setErrorCode(HotGameErrorEnum.SERVER_ERROR.getErrorCode());
} }
private void incGameRankingRecord(HotGameUserCoinUpdate request, GameListConfig gameListConfig) {
if (request.getType() != 2 || gameListConfig == null || request.getCoin() <= 0) {
return;
}
GameRankingIncrementCmd build = GameRankingIncrementCmd.builder()
.gameOrigin(GameOriginEnum.HOTGAME.name())
.gameId(gameListConfig.getGameId())
.gameName(gameListConfig.getName())
.gameCover(gameListConfig.getCover())
.sysOrigin(gameListConfig.getSysOrigin())
.amount(request.getCoin())
.periodType("ALL")
.build();
gameRankingGateway.incrementPrizeAmount(build);
}
private void sendBroadcast(HotGameUserCoinUpdate request, GameListConfig gameListConfig) { private void sendBroadcast(HotGameUserCoinUpdate request, GameListConfig gameListConfig) {
if (gameListConfig == null) { if (gameListConfig == null) {
return; return;