where('out_order_no', $orderno) ->orderBy('id', 'desc'); } public static function getPayOrderInfoByTradeNo($trade_no) { return self::uniacid() ->where('trade_no', $trade_no) ->orderBy('id', 'desc'); } /** * @return \Illuminate\Support\Collection */ public function getAllStatusAttribute(){ return collect([ self::STATUS_UNPAID => '未支付', self::STATUS_WAIT_PAID => '待支付', self::STATUS_PAID => '已支付', ]); } public function orderPay(){ return $this->belongsTo(OrderPay::class,'out_order_no','pay_sn'); } public function payRefundOrder(){ return $this->hasOne(PayRefundOrder::class,'out_order_no','out_order_no'); } public function isRefunded(){ return isset($this->payRefundOrder) && $this->payRefundOrder->status == 2; } /** * @return mixed */ public function getStatusNameAttribute() { if($this->isRefunded()){ return '已退款'; } return $this->all_status[$this->status]; } }