feat: 添加结算功能,更新 TicketItem 模型以支持最新结算详情,增强 DrawTickService 以自动处理结算,更新 TicketWalletService 以支持派彩入账,扩展 API 路由以管理结算批次和奖池
This commit is contained in:
60
app/Models/SettlementBatch.php
Normal file
60
app/Models/SettlementBatch.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user