diff --git a/app/common/service/GameBetSettleService.php b/app/common/service/GameBetSettleService.php index a3620c8..bbe6a05 100644 --- a/app/common/service/GameBetSettleService.php +++ b/app/common/service/GameBetSettleService.php @@ -621,6 +621,26 @@ final class GameBetSettleService } } + /** + * 兜底补偿:在派彩期内(status=3)允许周期性调用,确保 bet.win / jackpot.hit 最终可达。 + * - bet.win 由 dfw:v1:ws:betwin:{period_id}:{user_id} 去重 + * - jackpot.hit 由 dfw:v1:ws:jackpot_hit:{period_id} 去重 + * - user.streak / wallet.changed 仍受 dfw:v1:settle:notify:{period_id} 约束 + */ + public static function ensurePeriodWinAndJackpotNotifications(int $periodId, string $periodNo, int $resultNumber): void + { + if ($periodId <= 0 || $periodNo === '' || $resultNumber < 1) { + return; + } + self::publishSettlementWinsAfterCommit([ + 'jackpot_hits' => [], + 'bet_wins' => [], + 'user_streak_events' => [], + 'wallet_events' => [], + 'settled_order_count' => 0, + ], $periodId, $periodNo, $resultNumber); + } + /** * 开奖后兜底:库内已有中奖但 Redis 无 bet.win 去重键时补推(避免 streak/wallet 整期 dedup 或旧版逻辑漏推)。 */ diff --git a/app/common/service/GameLiveService.php b/app/common/service/GameLiveService.php index 3f3c7df..18d6a6d 100644 --- a/app/common/service/GameLiveService.php +++ b/app/common/service/GameLiveService.php @@ -1417,6 +1417,12 @@ final class GameLiveService 'result_number' => $resultNumber, 'server_time' => $now, ]); + + // 兜底:派彩期内每秒触发一次“最终一致”补偿(有独立去重键,最多各推一次)。 + // 用于处理“开奖推送已发,但结算推送 bet.win/jackpot.hit 因瞬时 Redis/入队失败丢失”的场景。 + if ($periodId > 0 && $periodNo !== '' && is_int($resultNumber) && $resultNumber > 0) { + GameBetSettleService::ensurePeriodWinAndJackpotNotifications($periodId, $periodNo, $resultNumber); + } } /**