From 38dec9d7a2a6a37d2dc60f3764bbcd09228e858a Mon Sep 17 00:00:00 2001 From: zhenhui <1276357500@qq.com> Date: Tue, 26 May 2026 15:36:22 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BC=98=E5=8C=96=E4=B8=AD=E5=A5=96=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=E7=BB=9F=E4=B8=80=E4=BD=BF=E7=94=A8bet.win=E8=AE=A2?= =?UTF-8?q?=E9=98=85=E4=B8=AD=E5=A5=96=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/library/game/StreakWinReward.php | 13 ++++++--- app/common/service/GameBetSettleService.php | 30 +++++++++++++++++++++ 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/app/common/library/game/StreakWinReward.php b/app/common/library/game/StreakWinReward.php index b919bd0..898b36f 100644 --- a/app/common/library/game/StreakWinReward.php +++ b/app/common/library/game/StreakWinReward.php @@ -17,10 +17,12 @@ final class StreakWinReward /** @var list|null */ private static ?array $cache = null; + private static ?string $cacheConfigValue = null; public static function clearCache(): void { self::$cache = null; + self::$cacheConfigValue = null; } /** @@ -97,11 +99,16 @@ final class StreakWinReward */ public static function loadRows(): array { - if (self::$cache !== null) { + $row = GameHotDataRedis::gameConfigRow(self::CONFIG_KEY); + $rawValue = $row['config_value'] ?? null; + $normalizedRaw = is_string($rawValue) ? trim($rawValue) : (is_numeric($rawValue) ? (string) $rawValue : ''); + + if (self::$cache !== null && self::$cacheConfigValue === $normalizedRaw) { return self::$cache; } - $row = GameHotDataRedis::gameConfigRow(self::CONFIG_KEY); - self::$cache = self::parseFromConfigValue($row['config_value'] ?? null); + + self::$cache = self::parseFromConfigValue($normalizedRaw); + self::$cacheConfigValue = $normalizedRaw; return self::$cache; } diff --git a/app/common/service/GameBetSettleService.php b/app/common/service/GameBetSettleService.php index 6b11367..d4b265c 100644 --- a/app/common/service/GameBetSettleService.php +++ b/app/common/service/GameBetSettleService.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace app\common\service; use app\common\library\game\StreakWinReward; +use support\Log; use support\think\Db; use Throwable; @@ -191,6 +192,35 @@ final class GameBetSettleService ]); } + // 兜底:若已判定本期中奖(is_win=true),但聚合中奖事件意外缺失,补一条 bet.win,保证客户端可感知中奖。 + foreach ($userOutcome as $userId => $info) { + $hadWin = (bool) ($info['had_win'] ?? false); + if (!$hadWin || isset($winByUser[$userId])) { + continue; + } + $agg = $aggregateByUser[$userId] ?? null; + if (!is_array($agg) || bccomp((string) ($agg['total_win'] ?? '0.00'), '0', 2) <= 0) { + continue; + } + $isJackpotTier = isset($jackpotNotify[$userId]); + $winByUser[$userId] = [ + 'user_id' => $userId, + 'period_id' => $recordId, + 'period_no' => (string) ($agg['period_no'] ?? ''), + 'result_number' => $resultNumber, + 'total_win' => (string) ($agg['total_win'] ?? '0.00'), + 'balance_after' => (string) ($agg['balance_after'] ?? '0'), + 'is_jackpot' => $isJackpotTier, + 'bets' => [], + ]; + Log::warning('bet.win fallback emitted for settled winner', [ + 'user_id' => $userId, + 'period_id' => $recordId, + 'period_no' => (string) ($agg['period_no'] ?? ''), + 'is_jackpot' => $isJackpotTier, + ]); + } + $jackpotHits = []; $hitUserIds = []; foreach ($jackpotNotify as $uid => $_) {