diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/game/YomiGameServiceImpl.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/game/YomiGameServiceImpl.java index 514a12d7..2d0ba4fd 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/game/YomiGameServiceImpl.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/game/YomiGameServiceImpl.java @@ -59,7 +59,7 @@ import java.util.concurrent.TimeUnit; public class YomiGameServiceImpl implements YomiGameService { private static final String IDEMPOTENT_KEY_PREFIX = "yomi:change_balance:req:"; - private static final long IDEMPOTENT_EXPIRE_SECONDS = 300L; + private static final long IDEMPOTENT_EXPIRE_SECONDS = 600L; private final YomiConfig yomiConfig; private final RedisTemplate redisTemplate; @@ -153,8 +153,12 @@ public class YomiGameServiceImpl implements YomiGameService { String processed = redisTemplate.opsForValue().get(idempotentKey); if (processed != null) { log.info("yomi余额变动重复请求,直接返回: requestId={}", cmd.getRequestId()); - long currentBalance = walletGoldClient.getBalance(userId).getBody().getDollarAmount().longValue(); - return new YomiBalanceCO(currentBalance); + ResultResponse balanceResp = walletGoldClient.getBalance(userId); + if (balanceResp == null || balanceResp.getBody() == null) { + log.warn("yomi幂等返回时查询余额失败: platUserId={}", userId); + return new YomiBalanceCO(0L); + } + return new YomiBalanceCO(balanceResp.getBody().getDollarAmount().longValue()); } WalletReceiptResDTO res = walletGoldClient.changeBalance(createReceipt(cmd)).getBody();