feat: 添加 Laravel Reverb 支持,更新 .env.example 文件以配置 WebSocket,增强彩票调度功能,更新 API 路由以支持期号管理与结果发布
This commit is contained in:
55
app/Models/Draw.php
Normal file
55
app/Models/Draw.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Lottery\DrawStatus;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
/** 彩票期号 {@see draws} */
|
||||
class Draw extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'draw_no',
|
||||
'business_date',
|
||||
'sequence_no',
|
||||
'status',
|
||||
'start_time',
|
||||
'close_time',
|
||||
'draw_time',
|
||||
'cooling_end_time',
|
||||
'result_source',
|
||||
'current_result_version',
|
||||
'settle_version',
|
||||
'is_reopened',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'business_date' => 'date',
|
||||
'start_time' => 'datetime',
|
||||
'close_time' => 'datetime',
|
||||
'draw_time' => 'datetime',
|
||||
'cooling_end_time' => 'datetime',
|
||||
'current_result_version' => 'integer',
|
||||
'settle_version' => 'integer',
|
||||
'is_reopened' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
public function statusEnum(): ?DrawStatus
|
||||
{
|
||||
return DrawStatus::tryFrom((string) $this->status);
|
||||
}
|
||||
|
||||
public function resultBatches(): HasMany
|
||||
{
|
||||
return $this->hasMany(DrawResultBatch::class);
|
||||
}
|
||||
|
||||
public function resultItems(): HasMany
|
||||
{
|
||||
return $this->hasMany(DrawResultItem::class);
|
||||
}
|
||||
}
|
||||
49
app/Models/DrawResultBatch.php
Normal file
49
app/Models/DrawResultBatch.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Lottery\DrawResultBatchStatus;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
/** 开奖结果批次(含 RNG 种子摘要、审核人) {@see draw_result_batches} */
|
||||
class DrawResultBatch extends Model
|
||||
{
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
'draw_id',
|
||||
'result_version',
|
||||
'source_type',
|
||||
'rng_seed_hash',
|
||||
'raw_seed_encrypted',
|
||||
'status',
|
||||
'created_by',
|
||||
'confirmed_by',
|
||||
'confirmed_at',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'result_version' => 'integer',
|
||||
'confirmed_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function draw(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Draw::class);
|
||||
}
|
||||
|
||||
public function items(): HasMany
|
||||
{
|
||||
return $this->hasMany(DrawResultItem::class, 'result_batch_id');
|
||||
}
|
||||
|
||||
public function statusEnum(): ?DrawResultBatchStatus
|
||||
{
|
||||
return DrawResultBatchStatus::tryFrom((string) $this->status);
|
||||
}
|
||||
}
|
||||
43
app/Models/DrawResultItem.php
Normal file
43
app/Models/DrawResultItem.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/** 单条中奖号码行(与界面文档奖项分区对应) {@see draw_result_items} */
|
||||
class DrawResultItem extends Model
|
||||
{
|
||||
public const UPDATED_AT = null;
|
||||
|
||||
protected $fillable = [
|
||||
'draw_id',
|
||||
'result_batch_id',
|
||||
'prize_type',
|
||||
'prize_index',
|
||||
'number_4d',
|
||||
'suffix_3d',
|
||||
'suffix_2d',
|
||||
'head_digit',
|
||||
'tail_digit',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'prize_index' => 'integer',
|
||||
'head_digit' => 'integer',
|
||||
'tail_digit' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
public function draw(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Draw::class);
|
||||
}
|
||||
|
||||
public function batch(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(DrawResultBatch::class, 'result_batch_id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user