From c97de14f904c73563f3940430597c5892dcf904f Mon Sep 17 00:00:00 2001 From: liapples Date: Thu, 12 Aug 2021 11:00:02 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E5=A2=9E=E5=8A=A0agent=E5=92=8Csuppl?= =?UTF-8?q?ier=E6=A8=A1=E5=9E=8B=E5=85=B3=E8=81=94=EF=BC=9B2=E3=80=81?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0getPictureAttribute=E8=AE=BF=E9=97=AE?= =?UTF-8?q?=E5=99=A8=EF=BC=9B3=E3=80=81getStatusTextAttribute=E7=BB=9F?= =?UTF-8?q?=E4=B8=80=E4=BD=BF=E7=94=A8OrderStatus=E7=B1=BB=E8=8E=B7?= =?UTF-8?q?=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/Order.php | 27 ++++++++++++++++----------- app/Service/OrderStatus.php | 14 ++++++++++++++ 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/app/Models/Order.php b/app/Models/Order.php index 0ae3edb..1b76266 100644 --- a/app/Models/Order.php +++ b/app/Models/Order.php @@ -24,17 +24,7 @@ class Order extends BaseModel public function getStatusTextAttribute() { - $status_text = [ - Status::CANCEL => '已取消', - Status::UNPAID => '待付款', - Status::PAY_EARNEST => '已付定金', - Status::PAID => '已付款', - Status::PAID_RETAINAGE => '已付尾款', - Status::REFUNDING => '退款中', - Status::REFUNDED => '已退款', - Status::SUCCESS => '已完成', - ]; - return $status_text[$this->status] ?? '未知'; + return Status::array()[$this->status] ?? '未知'; } //退款信息 @@ -49,6 +39,11 @@ class Order extends BaseModel return $value ?? []; } + public function getPictureAttribute($value) + { + return $value ? $this->host . $value : ''; + } + public function agentProduct() { return $this->belongsTo(AgentProduct::class); @@ -63,4 +58,14 @@ class Order extends BaseModel { return $this->belongsTo(Coupon::class); } + + public function agent() + { + return $this->belongsTo(Agent::class); + } + + public function supplier() + { + return $this->belongsTo(Supplier::class); + } } diff --git a/app/Service/OrderStatus.php b/app/Service/OrderStatus.php index f666111..3fd511d 100644 --- a/app/Service/OrderStatus.php +++ b/app/Service/OrderStatus.php @@ -19,4 +19,18 @@ class OrderStatus const REFUNDING = 6; //退款中 const REFUNDED = 7; //退款完成 const SUCCESS = 16; //已完成 + + public static function array() + { + return [ + self::CANCEL => '已取消', + self::UNPAID => '待付款', + self::PAY_EARNEST => '已付定金', + self::PAID => '已付款', + self::PAID_RETAINAGE => '已付尾款', + self::REFUNDING => '退款中', + self::REFUNDED => '已退款', + self::SUCCESS => '已完成', + ]; + } }