Add baccarat loss cover activity

This commit is contained in:
2026-04-11 23:27:29 +08:00
parent dd9a8c5db8
commit e43dceab2c
22 changed files with 1898 additions and 5 deletions
+11 -1
View File
@@ -3,7 +3,7 @@
/**
* 文件功能:百家乐下注记录模型
*
* 记录用户在某局中的押注信息结算状态。
* 记录用户在某局中的押注信息结算状态以及关联的买单活动
*
* @author ChatRoom Laravel
*
@@ -20,6 +20,7 @@ class BaccaratBet extends Model
protected $fillable = [
'round_id',
'user_id',
'loss_cover_event_id',
'bet_type',
'amount',
'payout',
@@ -32,6 +33,7 @@ class BaccaratBet extends Model
protected function casts(): array
{
return [
'loss_cover_event_id' => 'integer',
'amount' => 'integer',
'payout' => 'integer',
];
@@ -53,6 +55,14 @@ class BaccaratBet extends Model
return $this->belongsTo(User::class);
}
/**
* 关联参与的百家乐买单活动。
*/
public function lossCoverEvent(): BelongsTo
{
return $this->belongsTo(BaccaratLossCoverEvent::class, 'loss_cover_event_id');
}
/**
* 获取押注类型中文名。
*/
+119
View File
@@ -0,0 +1,119 @@
<?php
/**
* 文件功能:百家乐买单活动模型
*
* 负责描述一次完整的“你玩游戏我买单”活动,
* 包含时间窗口、当前状态、统计汇总以及开启/结束操作者信息。
*/
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
class BaccaratLossCoverEvent extends Model
{
/** @use HasFactory<\Database\Factories\BaccaratLossCoverEventFactory> */
use HasFactory;
/**
* 允许批量赋值的字段。
*
* @var list<string>
*/
protected $fillable = [
'title',
'description',
'status',
'starts_at',
'ends_at',
'claim_deadline_at',
'created_by_user_id',
'closed_by_user_id',
'started_notice_sent_at',
'ended_notice_sent_at',
'participant_count',
'compensable_user_count',
'total_loss_amount',
'total_claimed_amount',
];
/**
* 字段类型转换。
*/
protected function casts(): array
{
return [
'starts_at' => 'datetime',
'ends_at' => 'datetime',
'claim_deadline_at' => 'datetime',
'started_notice_sent_at' => 'datetime',
'ended_notice_sent_at' => 'datetime',
'participant_count' => 'integer',
'compensable_user_count' => 'integer',
'total_loss_amount' => 'integer',
'total_claimed_amount' => 'integer',
];
}
/**
* 关联:开启活动的用户。
*/
public function creator(): BelongsTo
{
return $this->belongsTo(User::class, 'created_by_user_id');
}
/**
* 关联:结束活动的用户。
*/
public function closer(): BelongsTo
{
return $this->belongsTo(User::class, 'closed_by_user_id');
}
/**
* 关联:活动下的用户聚合记录。
*/
public function records(): HasMany
{
return $this->hasMany(BaccaratLossCoverRecord::class, 'event_id');
}
/**
* 关联:活动下的百家乐下注记录。
*/
public function bets(): HasMany
{
return $this->hasMany(BaccaratBet::class, 'loss_cover_event_id');
}
/**
* 判断活动当前是否允许领取补偿。
*/
public function isClaimable(): bool
{
return $this->status === 'claimable'
&& $this->claim_deadline_at !== null
&& $this->claim_deadline_at->isFuture();
}
/**
* 返回活动状态中文标签。
*/
public function statusLabel(): string
{
return match ($this->status) {
'scheduled' => '未开始',
'active' => '进行中',
'settlement_pending' => '等待结算',
'claimable' => '可领取',
'completed' => '已结束',
'cancelled' => '已取消',
default => '未知状态',
};
}
}
+82
View File
@@ -0,0 +1,82 @@
<?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 => '未知状态',
};
}
}