feat(baccarat): 实现百家乐实时下注人数统计功能
- 新增 BaccaratPoolUpdated 事件,用于通过 WebSocket 广播实时下注数据更新 - 增加数据库迁移以在 baccarat_rounds 表中添加对应的下注人数统计字段 - 更新 BaccaratRound 模型以及 BaccaratController,支持实时下注统计更新与 WebSocket 事件分发 - 更新前端 chat.js 以及 baccarat-panel.blade.php,利用 Alpine.js 和 Echo 接收事件并动态渲染 "大"、"小"、"豹子" 的实时下注计数
This commit is contained in:
@@ -56,6 +56,9 @@ class BaccaratController extends Controller
|
||||
'total_bet_big' => $round->total_bet_big,
|
||||
'total_bet_small' => $round->total_bet_small,
|
||||
'total_bet_triple' => $round->total_bet_triple,
|
||||
'bet_count_big' => $round->bet_count_big,
|
||||
'bet_count_small' => $round->bet_count_small,
|
||||
'bet_count_triple' => $round->bet_count_triple,
|
||||
'my_bet' => $myBet ? [
|
||||
'bet_type' => $myBet->bet_type,
|
||||
'amount' => $myBet->amount,
|
||||
@@ -139,9 +142,14 @@ class BaccaratController extends Controller
|
||||
|
||||
// 更新局次汇总统计
|
||||
$field = 'total_bet_'.$data['bet_type'];
|
||||
$countField = 'bet_count_'.$data['bet_type'];
|
||||
$round->increment($field, $data['amount']);
|
||||
$round->increment($countField);
|
||||
$round->increment('bet_count');
|
||||
|
||||
// 广播各选项的最新押注人数
|
||||
event(new \App\Events\BaccaratPoolUpdated($round));
|
||||
|
||||
$betLabel = match ($data['bet_type']) {
|
||||
'big' => '大', 'small' => '小', default => '豹子'
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user