| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?php
- namespace App\Models;
- /**
- * @property $amount
- * @property $bank_name
- * @property $account
- * @property $card_no
- * @property $status
- * @property $member_id
- * @property $id
- */
- class PaymentOrder extends BaseModel
- {
- protected $table = 'payment_orders';
- protected $fillable = ['type', 'order_no', 'member_id', 'amount', 'channel', 'admin_note','bank_name', 'account', 'card_no', 'status', 'callback_url', 'callback_data', 'remark', 'pay_no', 'pay_url', 'pay_data', 'fee', 'payment_type', 'is_send', 'is_locked', 'recharge_bonus_snapshot'];
- protected $hidden = ['recharge_bonus_snapshot'];
- protected $casts = ['recharge_bonus_snapshot' => 'array'];
- protected static function booted()
- {
- parent::booted();
- static::creating(function ($order) {
- if ((int)$order->type === 3 && $order->channel === 'rgcz' && !array_key_exists('recharge_bonus_snapshot', $order->getAttributes())) {
- $snapshot = \App\Services\RechargeBonusService::capture('rgcz', (string)$order->member_id);
- if ($snapshot !== null) $order->recharge_bonus_snapshot = $snapshot;
- }
- });
- }
- // // 添加这个
- // protected $visible = [
- // 'type', 'order_no', 'member_id', 'amount', 'channel',
- // 'bank_name', 'account', 'card_no', 'status', 'callback_url',
- // 'callback_data', 'remark', 'pay_no', 'pay_url', 'pay_data', 'fee',
- // 'created_at', 'updated_at' // 添加时间戳字段
- // ];
- public function userInfo()
- {
- return $this->belongsTo(User::class, 'member_id', 'member_id')
- ->select(['id', 'member_id', 'username', 'first_name', 'admin_note', 'status', 'phone', 'visitor_id', 'register_ip']);
- }
- }
|