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; } /** * 确认支付方式是否是微信支付 * * @return bool */ public function isWxpay(): bool { return in_array($this->pay_way, [ static::PAY_WAY_WXPAY_APP, static::PAY_WAY_WXPAY_JSAPI, static::PAY_WAY_WXPAY_MINI, static::PAY_WAY_WXPAY_H5, ]); } /** * 确认支付方式是否是线下支付 * * @return bool */ public function isOffline(): bool { return $this->pay_way === static::PAY_WAY_OFFLINE; } /** * 确认支付方式是否是钱包付款 * * @return bool */ public function isWallet(): bool { return $this->pay_way === static::PAY_WAY_WALLET; } }