diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/game/GameBaishunReportCmdExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/game/GameBaishunReportCmdExe.java index fbd58c57..6a4d41bb 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/game/GameBaishunReportCmdExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/game/GameBaishunReportCmdExe.java @@ -43,109 +43,12 @@ public class GameBaishunReportCmdExe { private final AuthClient authClient; public BaishunResponse execute(GameBaishunReportCmd cmd) { - if (!checkTokenStrict(cmd)) { - log.error("BaishunReportCmdExe execute checkTokenStrict fail !"); - } - - - log.info("Baishun game report: type={}, userId={}", cmd.getReportType(), cmd.getUserId()); - log.error("Baishun game report: {}", JSONObject.toJSONString(cmd)); - - /*switch (cmd.getReportType()) { - case REPORT_TYPE_START: - return handleGameStart(cmd); - case REPORT_TYPE_SETTLE: - return handleGameSettle(cmd); - default: - log.warn("Unknown report_type: {}", cmd.getReportType()); - return BaishunResponse.fail(BaishunErrorCode.DATE_ERROR); - }*/ +// if (!checkTokenStrict(cmd)) { +// log.error("BaishunReportCmdExe execute checkTokenStrict fail !"); +// } return BaishunResponse.success(null); } - private BaishunResponse handleGameStart(GameBaishunReportCmd cmd) { - GameStartInfo startInfo = parseReportMsg(cmd.getReportMsg(), GameStartInfo.class); - if (startInfo == null) { - return BaishunResponse.fail(BaishunErrorCode.READ_DATE_ERROR); - } - - // 扣除开局 bet(非AI玩家) - if (startInfo.getPlayers() != null) { - for (GameBaishunReportCmd.PlayerStartInfo player : startInfo.getPlayers()) { - if (Objects.equals(player.getIsAi(), 1) || player.getBet() == null || player.getBet() <= 0) { - continue; - } - try { - Long userId = DataTypeUtils.toLong(player.getUserId()); - walletGoldClient.changeBalance(GoldReceiptCmd.builder() - .appExpenditure() - .userId(userId) - .sysOrigin(resolveTokenSysOrigin(cmd.getSsToken())) - .origin(GoldOrigin.BAISHUN_GAME.name()) - .originDescribe(GoldOrigin.BAISHUN_GAME.getDesc()) - .eventId(startInfo.getGameRoundId() + "_" + userId + "_start") - .amount(BigDecimal.valueOf(player.getBet())) - .build()); - } catch (Exception e) { - log.error("Baishun game start deduct failed: userId={}, roundId={}", player.getUserId(), startInfo.getGameRoundId(), e); - } - } - } - - return BaishunResponse.success(null); - } - - private BaishunResponse handleGameSettle(GameBaishunReportCmd cmd) { - GameSettleInfo settleInfo = parseReportMsg(cmd.getReportMsg(), GameSettleInfo.class); - if (settleInfo == null) { - return BaishunResponse.fail(BaishunErrorCode.READ_DATE_ERROR); - } - - List players = settleInfo.getPlayers(); - if (players == null || players.isEmpty()) { - return BaishunResponse.success(null); - } - - for (PlayerResultInfo player : players) { - if (Objects.equals(player.getIsAi(), 1) || player.getReward() == null || player.getReward() <= 0) { - continue; - } - try { - Long userId = DataTypeUtils.toLong(player.getUserId()); - walletGoldClient.changeBalance(GoldReceiptCmd.builder() - .appIncome() - .userId(userId) - .sysOrigin(resolveTokenSysOrigin(cmd.getSsToken())) - .origin(GoldOrigin.BAISHUN_GAME.name()) - .originDescribe(GoldOrigin.BAISHUN_GAME.getDesc()) - .eventId(settleInfo.getGameRoundId() + "_" + userId + "_settle") - .amount(BigDecimal.valueOf(player.getReward())) - .build()); - } catch (Exception e) { - log.error("Baishun game settle reward failed: userId={}, roundId={}", player.getUserId(), settleInfo.getGameRoundId(), e); - } - } - - return BaishunResponse.success(null); - } - - private T parseReportMsg(Object reportMsg, Class clazz) { - try { - return objectMapper.convertValue(reportMsg, clazz); - } catch (Exception e) { - log.error("Failed to parse report_msg to {}: {}", clazz.getSimpleName(), reportMsg, e); - return null; - } - } - - private String resolveTokenSysOrigin(String ssToken) { - try { - return com.red.circle.framework.core.security.UserCredential.parseToken(ssToken).getSysOrigin(); - } catch (Exception e) { - return "LIKEI"; - } - } - private boolean checkTokenStrict(GameBaishunReportCmd request) { UserCredential accessToken = ResponseAssert.requiredSuccess( authClient.getUserCredential(DataTypeUtils.toLong(request.getUserId())));