$hits */ public static function publishHits(array $hits): void { foreach ($hits as $h) { $uid = (int) ($h['user_id'] ?? 0); if ($uid <= 0) { continue; } $periodNo = (string) ($h['period_no'] ?? ''); $totalWin = (string) ($h['total_win'] ?? '0'); $rn = (int) ($h['result_number'] ?? 0); UserPushService::publish($uid, UserPushService::EVT_JACKPOT_HIT, [ 'period_no' => $periodNo, 'total_win_amount' => $totalWin, 'result_number' => $rn, 'is_jackpot' => true, ]); self::publishPublicChannels($periodNo, $uid, $totalWin, $rn); } } /** * @param array $payload */ private static function triggerChannel(Api $api, string $channel, array $payload): void { $api->trigger($channel, self::EVT_JACKPOT_HIT, $payload); } private static function publishPublicChannels(string $periodNo, int $userId, string $totalWin, int $resultNumber): void { try { $api = new Api( str_replace('0.0.0.0', '127.0.0.1', (string) config('plugin.webman.push.app.api')), (string) config('plugin.webman.push.app.app_key'), (string) config('plugin.webman.push.app.app_secret') ); $payload = [ 'period_no' => $periodNo, 'user_id' => $userId, 'total_win_amount' => $totalWin, 'result_number' => $resultNumber, 'message' => '恭喜玩家命中大奖派彩', ]; self::triggerChannel($api, self::CHANNEL_GAME_PERIOD, $payload); self::triggerChannel($api, self::CHANNEL_OPERATION_NOTICE, $payload); } catch (Throwable) { } } }