From 515bf651f43aef7e4e984ce34ae3bc26b187614c Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Tue, 26 May 2026 18:33:47 +0800 Subject: [PATCH] fix yomi idempotent null check and extend ttl --- .../other/app/service/game/YomiGameServiceImpl.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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();