支持所有游戏按房间范围配置和运行

This commit is contained in:
pllx
2026-04-29 14:37:28 +08:00
parent 3672140987
commit 1607f57e3c
37 changed files with 1033 additions and 255 deletions
+14 -5
View File
@@ -16,9 +16,13 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
/**
* 类功能:保存百家乐局次数据并提供当前局查询能力。
*/
class BaccaratRound extends Model
{
protected $fillable = [
'room_id',
'dice1', 'dice2', 'dice3',
'total_points', 'result', 'status',
'bet_opens_at', 'bet_closes_at', 'settled_at',
@@ -36,6 +40,7 @@ class BaccaratRound extends Model
'bet_opens_at' => 'datetime',
'bet_closes_at' => 'datetime',
'settled_at' => 'datetime',
'room_id' => 'integer',
'dice1' => 'integer',
'dice2' => 'integer',
'dice3' => 'integer',
@@ -104,12 +109,16 @@ class BaccaratRound extends Model
/**
* 查询当前正在进行的局次(状态为 betting 且未截止)。
*/
public static function currentRound(): ?static
public static function currentRound(?int $roomId = null): ?static
{
return static::query()
$query = static::query()
->where('status', 'betting')
->where('bet_closes_at', '>', now())
->latest()
->first();
->where('bet_closes_at', '>', now());
if ($roomId !== null) {
$query->where('room_id', $roomId);
}
return $query->latest()->first();
}
}