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 => '已完成', + ]; + } }