diff --git a/app/common/service/GameBetSettleService.php b/app/common/service/GameBetSettleService.php index d901a5f..6b11367 100644 --- a/app/common/service/GameBetSettleService.php +++ b/app/common/service/GameBetSettleService.php @@ -180,7 +180,15 @@ final class GameBetSettleService 'update_time' => $now, ]); GameHotDataCoordinator::afterUserCommitted($userId); - GameWebSocketPayloadHelper::publishUserStreak($userId, $next); + $periodNo = isset($aggregateByUser[$userId]['period_no']) ? (string) $aggregateByUser[$userId]['period_no'] : ''; + GameWebSocketPayloadHelper::publishUserStreak($userId, $next, [ + // 明确标记本期结算结果,客户端可直接判断“当前用户是否中奖”。 + 'is_win' => $hadWin, + 'period_id' => $recordId, + 'period_no' => $periodNo, + 'result_number' => $resultNumber, + 'settled_at' => $now, + ]); } $jackpotHits = []; diff --git a/app/common/service/GameWebSocketPayloadHelper.php b/app/common/service/GameWebSocketPayloadHelper.php index 3baa775..c55aed1 100644 --- a/app/common/service/GameWebSocketPayloadHelper.php +++ b/app/common/service/GameWebSocketPayloadHelper.php @@ -66,12 +66,19 @@ final class GameWebSocketPayloadHelper return array_merge($payload, self::userStreakData($userId, $currentStreak)); } - public static function publishUserStreak(int $userId, ?int $currentStreak = null): void + /** + * @param array $extra + */ + public static function publishUserStreak(int $userId, ?int $currentStreak = null, array $extra = []): void { if ($userId <= 0) { return; } - GameWebSocketEventBus::publish(self::TOPIC_USER_STREAK, self::userStreakData($userId, $currentStreak)); + $payload = self::userStreakData($userId, $currentStreak); + if ($extra !== []) { + $payload = array_merge($payload, $extra); + } + GameWebSocketEventBus::publish(self::TOPIC_USER_STREAK, $payload); } /**