1.优化中奖事件统一使用bet.win订阅中奖消息

This commit is contained in:
2026-05-26 15:36:22 +08:00
parent d8d03662ed
commit 38dec9d7a2
2 changed files with 40 additions and 3 deletions

View File

@@ -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 => $_) {