新增百家乐游戏:①数据库表+模型 ②OpenBaccaratRoundJob开局(广播+公屏) ③CloseBaccaratRoundJob结算(摇骰+赔付+CAS防并发) ④BaccaratController下注接口 ⑤前端弹窗(倒计时/骰子动画/历史趋势) ⑥调度器每分钟检查开局 ⑦GameConfig管控开关

This commit is contained in:
2026-03-01 20:25:09 +08:00
parent 8a74bfd639
commit ff28775635
15 changed files with 1424 additions and 0 deletions

View File

@@ -0,0 +1,59 @@
<?php
/**
* 文件功能:百家乐局次表迁移
*
* 每一局百家乐对应一条记录,存储骰子结果、局次状态、投注汇总等信息。
*/
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* 创建 baccarat_rounds 表。
*/
public function up(): void
{
Schema::create('baccarat_rounds', function (Blueprint $table) {
$table->id();
// 骰子结果(开奖后写入)
$table->unsignedTinyInteger('dice1')->nullable()->comment('第一颗骰子点数');
$table->unsignedTinyInteger('dice2')->nullable()->comment('第二颗骰子点数');
$table->unsignedTinyInteger('dice3')->nullable()->comment('第三颗骰子点数');
$table->unsignedTinyInteger('total_points')->nullable()->comment('骰子总点数');
$table->enum('result', ['big', 'small', 'triple', 'kill'])->nullable()->comment('开奖结果');
// 局次状态
$table->enum('status', ['betting', 'settling', 'settled', 'cancelled'])->default('betting');
// 时间
$table->dateTime('bet_opens_at')->comment('下注开始时间');
$table->dateTime('bet_closes_at')->comment('下注截止时间');
$table->dateTime('settled_at')->nullable()->comment('结算完成时间');
// 投注汇总统计
$table->unsignedBigInteger('total_bet_big')->default(0)->comment('押大总额');
$table->unsignedBigInteger('total_bet_small')->default(0)->comment('押小总额');
$table->unsignedBigInteger('total_bet_triple')->default(0)->comment('押豹子总额');
$table->unsignedBigInteger('total_payout')->default(0)->comment('总赔付额');
$table->unsignedInteger('bet_count')->default(0)->comment('下注人次');
$table->timestamps();
$table->index('status');
$table->index('bet_closes_at');
});
}
/**
* 回滚迁移。
*/
public function down(): void
{
Schema::dropIfExists('baccarat_rounds');
}
};

View File

@@ -0,0 +1,44 @@
<?php
/**
* 文件功能:百家乐下注记录表迁移
*
* 记录每个用户在每局中的押注类型、金额和结算结果。
*/
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* 创建 baccarat_bets 表。
*/
public function up(): void
{
Schema::create('baccarat_bets', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('round_id')->comment('关联局次');
$table->unsignedBigInteger('user_id')->comment('下注用户');
$table->enum('bet_type', ['big', 'small', 'triple'])->comment('押注类型');
$table->unsignedInteger('amount')->comment('押注金额');
$table->unsignedInteger('payout')->default(0)->comment('赔付金额(含本金)');
$table->enum('status', ['pending', 'won', 'lost', 'refunded'])->default('pending');
$table->timestamps();
$table->foreign('round_id')->references('id')->on('baccarat_rounds')->cascadeOnDelete();
$table->index(['round_id', 'user_id']);
$table->index(['user_id', 'status']);
// 每局每人每种类型只能下一注(可在 Service 层控制)
});
}
/**
* 回滚迁移。
*/
public function down(): void
{
Schema::dropIfExists('baccarat_bets');
}
};