61 lines
1.6 KiB
PHP
61 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Lottery\SettlementBatchStatus;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
/** 单期单次结算批次 {@see settlement_batches} */
|
|
class SettlementBatch extends Model
|
|
{
|
|
protected $fillable = [
|
|
'draw_id',
|
|
'result_batch_id',
|
|
'settle_version',
|
|
'status',
|
|
'total_ticket_count',
|
|
'total_win_count',
|
|
'total_payout_amount',
|
|
'total_jackpot_payout_amount',
|
|
'started_at',
|
|
'finished_at',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'draw_id' => 'integer',
|
|
'result_batch_id' => 'integer',
|
|
'settle_version' => 'integer',
|
|
'total_ticket_count' => 'integer',
|
|
'total_win_count' => 'integer',
|
|
'total_payout_amount' => 'integer',
|
|
'total_jackpot_payout_amount' => 'integer',
|
|
'started_at' => 'datetime',
|
|
'finished_at' => 'datetime',
|
|
];
|
|
}
|
|
|
|
public function draw(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Draw::class);
|
|
}
|
|
|
|
public function resultBatch(): BelongsTo
|
|
{
|
|
return $this->belongsTo(DrawResultBatch::class, 'result_batch_id');
|
|
}
|
|
|
|
public function details(): HasMany
|
|
{
|
|
return $this->hasMany(TicketSettlementDetail::class, 'settlement_batch_id');
|
|
}
|
|
|
|
public function statusEnum(): ?SettlementBatchStatus
|
|
{
|
|
return SettlementBatchStatus::tryFrom((string) $this->status);
|
|
}
|
|
}
|