Files
lotteryLaravel/app/Events/JackpotBurstBroadcast.php

55 lines
1.8 KiB
PHP

<?php
namespace App\Events;
use Illuminate\Broadcasting\Channel;
use Illuminate\Queue\SerializesModels;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
/** Jackpot 爆池公共广播:`jackpot.burst` */
final class JackpotBurstBroadcast implements ShouldBroadcastNow
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public function __construct(
public readonly int $drawId,
public readonly string $drawNo,
public readonly string $firstPrizeNumber,
public readonly string $currencyCode,
public readonly int $totalPayoutAmount,
public readonly int $winnerCount,
public readonly string $triggerType,
public readonly int $poolAmountAfter,
public readonly int $emittedAtMs,
) {}
/** @return array<int, Channel> */
public function broadcastOn(): array
{
return [new Channel('lottery-hall')];
}
public function broadcastAs(): string
{
return 'jackpot.burst';
}
/** @return array{draw_id: int, draw_no: string, first_prize_number: string, currency_code: string, total_payout_amount: int, winner_count: int, trigger_type: string, pool_amount_after: int, emitted_at_ms: int} */
public function broadcastWith(): array
{
return [
'draw_id' => $this->drawId,
'draw_no' => $this->drawNo,
'first_prize_number' => $this->firstPrizeNumber,
'currency_code' => $this->currencyCode,
'total_payout_amount' => $this->totalPayoutAmount,
'winner_count' => $this->winnerCount,
'trigger_type' => $this->triggerType,
'pool_amount_after' => $this->poolAmountAfter,
'emitted_at_ms' => $this->emittedAtMs,
];
}
}