64 lines
1.1 KiB
PHP
64 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class PayLog extends Model
|
|
{
|
|
/**
|
|
* 支付状态
|
|
*/
|
|
public const STATUS_PENDING = 0; // 待付款
|
|
public const STATUS_SUCCESS = 1; // 成功
|
|
public const STATUS_FAILED = 2; // 失败
|
|
|
|
/**
|
|
* 支付方式
|
|
*/
|
|
public const PAY_WAY_WXPAY = 'wxpay'; // 微信支付
|
|
public const PAY_WAY_ALIPAY = 'alipay'; // 支付宝
|
|
|
|
/**
|
|
* @var array
|
|
*/
|
|
protected $attributes = [
|
|
'status' => self::STATUS_PENDING,
|
|
];
|
|
|
|
/**
|
|
* @var array
|
|
*/
|
|
protected $casts = [
|
|
'pay_at' => 'datetime',
|
|
];
|
|
|
|
/**
|
|
* @var array
|
|
*/
|
|
protected $fillable = [
|
|
'pay_sn',
|
|
'pay_way',
|
|
'pay_at',
|
|
'out_trade_no',
|
|
'status',
|
|
'failed_reason',
|
|
];
|
|
|
|
/**
|
|
* 获取支付记录所属的模型
|
|
*/
|
|
public function payable()
|
|
{
|
|
return $this->morphTo();
|
|
}
|
|
|
|
/**
|
|
* 获取支付记录是否是待付款
|
|
*/
|
|
public function isPending()
|
|
{
|
|
return $this->status === static::STATUS_PENDING;
|
|
}
|
|
}
|