| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- namespace App\Models\Agent;
- use App\Models\BaseModel;
- /**
- * 合营分成每日入账记录。settlement_date 是入账批次日期,platform 存分类 key(如 self:lottery)。
- */
- class AgentRebateRecord extends BaseModel
- {
- public const STATUS_PENDING = 'pending';
- public const STATUS_CREDITED = 'credited';
- /** 分类 key => [game_type 编码, 名称]。 */
- public const CATEGORIES = [
- 'self:lottery' => [8, 'F1彩票'],
- 'self:sport' => [9, 'F1体育'],
- 'third:1' => [1, '真人'],
- 'third:2' => [2, '电子'],
- 'third:4' => [4, '体育'],
- 'third:5' => [5, '电竞'],
- 'third:6' => [6, '捕鱼'],
- 'third:7' => [7, '棋牌'],
- ];
- protected $table = 'agent_rebate_records';
- protected $hidden = ['snapshot'];
- protected $guarded = [];
- protected $appends = ['agent_username', 'category', 'category_text', 'profit_status_text'];
- protected $casts = [
- 'settlement_date' => 'date:Y-m-d', 'agent_id' => 'integer', 'game_type' => 'integer', 'bet_count' => 'integer',
- 'entry_count' => 'integer',
- 'bet_amount' => 'decimal:4', 'valid_bet_amount' => 'decimal:4', 'win_loss' => 'decimal:4',
- 'profit_rate' => 'decimal:4', 'profit_commission' => 'decimal:4',
- 'snapshot' => 'array', 'credited_at' => 'datetime',
- ];
- public function agent()
- {
- return $this->belongsTo(Agent::class);
- }
- public static function categoryName(string $category): string
- {
- return self::CATEGORIES[$category][1] ?? $category;
- }
- public function getAgentUsernameAttribute(): string
- {
- return (string) ($this->agent?->username ?? '');
- }
- public function getCategoryAttribute(): string
- {
- return (string) $this->platform;
- }
- public function getCategoryTextAttribute(): string
- {
- return self::categoryName((string) $this->platform);
- }
- public function getProfitStatusTextAttribute(): string
- {
- return (string) $this->profit_status === self::STATUS_CREDITED ? '已入账' : '待入账';
- }
- }
|