| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <?php
- namespace App\Models\Agent;
- use App\Constants\Util;
- use App\Models\PaymentOrder;
- /**
- * 代理人民币充值订单。字段和状态码与会员 payment_orders 一致,
- * 所以 PaymentOrderService 的三方下单、回调、查单可以直接作用于本模型;入账走代理钱包。
- * 订单号统一以 ag 开头,回调时据此区分会员订单和代理订单。
- */
- class AgentPaymentOrder extends PaymentOrder
- {
- public const ORDER_PREFIX = 'ag';
- public const STATUS_TEXT = [
- 0 => '待处理', 1 => '处理中', 2 => '已到账', 3 => '失败', 4 => '待提交凭证', 5 => '待审核', 6 => '已撤回', 7 => '超时',
- ];
- protected $table = 'agent_payment_orders';
- protected $guarded = ['id'];
- protected $fillable = [];
- protected $hidden = ['callback_data', 'callback_url'];
- protected $appends = ['status_text', 'type_text'];
- protected $casts = [
- 'agent_id' => 'integer', 'type' => 'integer', 'status' => 'integer', 'payment_type' => 'integer',
- 'amount' => 'decimal:2', 'fee' => 'decimal:4', 'is_send' => 'integer', 'audit_admin_id' => 'integer',
- ];
- public function agent()
- {
- return $this->belongsTo(Agent::class);
- }
- public function getStatusTextAttribute(): string
- {
- return self::STATUS_TEXT[(int) $this->status] ?? '';
- }
- public function getTypeTextAttribute(): string
- {
- return (int) $this->type === 3 ? '人工充值' : '在线充值';
- }
- public function getImageAttribute($value)
- {
- return $value ? Util::ensureUrl($value) : '';
- }
- public function setImageAttribute($value)
- {
- $this->attributes['image'] = (string) Util::replacePartInUrl($value);
- }
- }
|