83 lines
1.9 KiB
PHP
83 lines
1.9 KiB
PHP
<?php
|
|
|
|
/**
|
|
* 文件功能:百家乐买单活动用户记录模型
|
|
*
|
|
* 保存某个用户在一次买单活动中的累计下注、输赢、
|
|
* 可补偿金额以及最终领取结果。
|
|
*/
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class BaccaratLossCoverRecord extends Model
|
|
{
|
|
/** @use HasFactory<\Database\Factories\BaccaratLossCoverRecordFactory> */
|
|
use HasFactory;
|
|
|
|
/**
|
|
* 允许批量赋值的字段。
|
|
*
|
|
* @var list<string>
|
|
*/
|
|
protected $fillable = [
|
|
'event_id',
|
|
'user_id',
|
|
'total_bet_amount',
|
|
'total_win_payout',
|
|
'total_loss_amount',
|
|
'compensation_amount',
|
|
'claim_status',
|
|
'claimed_amount',
|
|
'claimed_at',
|
|
];
|
|
|
|
/**
|
|
* 字段类型转换。
|
|
*/
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'total_bet_amount' => 'integer',
|
|
'total_win_payout' => 'integer',
|
|
'total_loss_amount' => 'integer',
|
|
'compensation_amount' => 'integer',
|
|
'claimed_amount' => 'integer',
|
|
'claimed_at' => 'datetime',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* 关联:所属活动。
|
|
*/
|
|
public function event(): BelongsTo
|
|
{
|
|
return $this->belongsTo(BaccaratLossCoverEvent::class, 'event_id');
|
|
}
|
|
|
|
/**
|
|
* 关联:所属用户。
|
|
*/
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
/**
|
|
* 返回领取状态中文标签。
|
|
*/
|
|
public function claimStatusLabel(): string
|
|
{
|
|
return match ($this->claim_status) {
|
|
'not_eligible' => '无补偿',
|
|
'pending' => '待领取',
|
|
'claimed' => '已领取',
|
|
'expired' => '已过期',
|
|
default => '未知状态',
|
|
};
|
|
}
|
|
}
|