AgentWithdrawal.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536
  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', 'fee_rate', 'channel_fee_rate', 'channel_fee_fixed', 'channel_fee'];
  10. // 三方代付的原始返回/回调和平台三方成本只给总后台看(列表里 makeVisible)。
  11. public const ADMIN_ONLY = ['pay_data', 'callback_data', 'channel_fee_rate', 'channel_fee_fixed', 'channel_fee'];
  12. protected $hidden = ['request_key', 'pay_data', 'callback_data', 'channel_fee_rate', 'channel_fee_fixed', 'channel_fee'];
  13. protected $appends = ['status_text', 'channel'];
  14. public const STATUS_TEXT = ['pending' => '待审核', 'approved' => '已通过', 'processing' => '代付中', 'paid' => '已打款', 'rejected' => '已驳回', 'failed' => '代付失败'];
  15. protected $casts = ['agent_id' => 'integer', 'amount' => 'decimal:4', 'fee' => 'decimal:4', 'actual_amount' => 'decimal:4',
  16. 'usdt_amount' => 'decimal:4', 'actual_usdt_amount' => 'decimal:4', 'exchange_rate' => 'decimal:4',
  17. 'fee_rate' => 'decimal:6', 'channel_fee_rate' => 'decimal:6', 'channel_fee_fixed' => 'decimal:4', 'channel_fee' => 'decimal:4',
  18. 'account_snapshot' => 'array', 'audited_at' => 'datetime', 'paid_at' => 'datetime'];
  19. public function getStatusTextAttribute(): string
  20. {
  21. return self::STATUS_TEXT[(string) $this->status] ?? '';
  22. }
  23. /** 提现通道,同 account_type(历史数据为空时是 usdt)。 */
  24. public function getChannelAttribute(): string
  25. {
  26. return (string) ($this->attributes['account_type'] ?? '') ?: 'usdt';
  27. }
  28. public function agent()
  29. {
  30. return $this->belongsTo(Agent::class);
  31. }
  32. }