73 lines
1.9 KiB
PHP
73 lines
1.9 KiB
PHP
|
|
<?php
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 文件功能:双色球奖池流水 Model
|
|||
|
|
*
|
|||
|
|
* 记录每期奖池的每笔变动,提供透明的奖池历史查询。
|
|||
|
|
* reason 取值:ticket_sale / carry_over / admin_inject / system_inject / payout / prize_4th / prize_5th
|
|||
|
|
*
|
|||
|
|
* @author ChatRoom Laravel
|
|||
|
|
*
|
|||
|
|
* @version 1.0.0
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
namespace App\Models;
|
|||
|
|
|
|||
|
|
use Illuminate\Database\Eloquent\Model;
|
|||
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|||
|
|
|
|||
|
|
class LotteryPoolLog extends Model
|
|||
|
|
{
|
|||
|
|
public $timestamps = false;
|
|||
|
|
|
|||
|
|
protected $fillable = [
|
|||
|
|
'issue_id',
|
|||
|
|
'change_amount',
|
|||
|
|
'reason',
|
|||
|
|
'pool_after',
|
|||
|
|
'remark',
|
|||
|
|
'created_at',
|
|||
|
|
];
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 字段类型转换。
|
|||
|
|
*/
|
|||
|
|
protected function casts(): array
|
|||
|
|
{
|
|||
|
|
return [
|
|||
|
|
'change_amount' => 'integer',
|
|||
|
|
'pool_after' => 'integer',
|
|||
|
|
'created_at' => 'datetime',
|
|||
|
|
];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// ─── 关联 ──────────────────────────────────────────────────────────
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 关联的期次。
|
|||
|
|
*/
|
|||
|
|
public function issue(): BelongsTo
|
|||
|
|
{
|
|||
|
|
return $this->belongsTo(LotteryIssue::class, 'issue_id');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// ─── 业务方法 ──────────────────────────────────────────────────────
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 返回 reason 的中文标签。
|
|||
|
|
*/
|
|||
|
|
public function reasonLabel(): string
|
|||
|
|
{
|
|||
|
|
return match ($this->reason) {
|
|||
|
|
'ticket_sale' => '购票入池',
|
|||
|
|
'carry_over' => '上期滚存',
|
|||
|
|
'admin_inject' => '管理员注入',
|
|||
|
|
'system_inject' => '超级期系统注入',
|
|||
|
|
'payout' => '派奖扣除',
|
|||
|
|
'prize_4th' => '四等奖固定扣除',
|
|||
|
|
'prize_5th' => '五等奖固定扣除',
|
|||
|
|
default => $this->reason,
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
}
|