AgentWithdrawal.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace App\Models\Agent;
  3. use App\Models\BaseModel;
  4. class AgentWithdrawal extends BaseModel
  5. {
  6. protected $table = 'agent_withdrawals';
  7. protected $fillable = ['order_no', 'request_key', 'agent_id', 'account_id', 'account_type', 'account_snapshot', 'amount', 'fee', 'actual_amount',
  8. 'usdt_amount', 'actual_usdt_amount', 'exchange_rate', 'status', 'remark', 'audit_remark', 'audit_admin_id', 'audited_at', 'paid_at',
  9. 'pay_no', 'pay_data', 'callback_data'];
  10. // 三方代付的原始返回/回调只给总后台看(列表里 makeVisible)。
  11. protected $hidden = ['request_key', 'pay_data', 'callback_data'];
  12. protected $appends = ['status_text', 'channel'];
  13. public const STATUS_TEXT = ['pending' => '待审核', 'approved' => '已通过', 'processing' => '代付中', 'paid' => '已打款', 'rejected' => '已驳回', 'failed' => '代付失败'];
  14. protected $casts = ['agent_id' => 'integer', 'amount' => 'decimal:4', 'fee' => 'decimal:4', 'actual_amount' => 'decimal:4',
  15. 'usdt_amount' => 'decimal:4', 'actual_usdt_amount' => 'decimal:4', 'exchange_rate' => 'decimal:4',
  16. 'account_snapshot' => 'array', 'audited_at' => 'datetime', 'paid_at' => 'datetime'];
  17. public function getStatusTextAttribute(): string
  18. {
  19. return self::STATUS_TEXT[(string) $this->status] ?? '';
  20. }
  21. /** 提现通道,同 account_type(历史数据为空时是 usdt)。 */
  22. public function getChannelAttribute(): string
  23. {
  24. return (string) ($this->attributes['account_type'] ?? '') ?: 'usdt';
  25. }
  26. public function agent()
  27. {
  28. return $this->belongsTo(Agent::class);
  29. }
  30. }