| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- namespace App\Models\Agent;
- use App\Models\BaseModel;
- class AgentRebateRecord extends BaseModel
- {
- public const STATUS_PENDING = 'pending';
- public const STATUS_CREDITED = 'credited';
- public const GAME_TYPE_NAMES = [
- 0 => '历史汇总',
- 1 => '真人',
- 2 => '电子',
- 3 => '彩票',
- 4 => '体育',
- 5 => '电竞',
- 6 => '捕鱼',
- 7 => '棋牌',
- ];
- protected $table = 'agent_rebate_records';
- protected $hidden = ['snapshot'];
- protected $guarded = [];
- protected $appends = ['agent_username', 'game_type_text', 'flow_status_text', 'profit_status_text'];
- protected $casts = [
- 'settlement_date' => 'date', 'agent_id' => 'integer', 'game_type' => 'integer', 'bet_count' => 'integer',
- 'bet_amount' => 'decimal:4', 'valid_bet_amount' => 'decimal:4', 'win_loss' => 'decimal:4',
- 'flow_rate' => 'decimal:4', 'flow_commission' => 'decimal:4',
- 'profit_rate' => 'decimal:4', 'profit_commission' => 'decimal:4',
- 'snapshot' => 'array', 'credited_at' => 'datetime',
- ];
- public function agent()
- {
- return $this->belongsTo(Agent::class);
- }
- public function getAgentUsernameAttribute(): string
- {
- return (string) ($this->agent?->username ?? '');
- }
- public function getGameTypeTextAttribute(): string
- {
- return self::GAME_TYPE_NAMES[(int) $this->game_type] ?? '未知';
- }
- public function getFlowStatusTextAttribute(): string
- {
- return $this->statusText((string) $this->flow_status);
- }
- public function getProfitStatusTextAttribute(): string
- {
- return $this->statusText((string) $this->profit_status);
- }
- private function statusText(string $status): string
- {
- return $status === self::STATUS_CREDITED ? '已返佣' : '待返佣';
- }
- }
|