wesmiler 3 mēneši atpakaļ
vecāks
revīzija
d6aeebf9f1
2 mainītis faili ar 3 papildinājumiem un 16 dzēšanām
  1. 1 9
      app/Models/OrderModel.php
  2. 2 7
      app/Services/Api/OrderService.php

+ 1 - 9
app/Models/OrderModel.php

@@ -41,6 +41,7 @@ class OrderModel extends BaseModel
     public function orderGoods()
     public function orderGoods()
     {
     {
         return $this->hasMany(OrderGoodsModel::class, 'order_id', 'id')
         return $this->hasMany(OrderGoodsModel::class, 'order_id', 'id')
+            ->with(['category'])
             ->where('mark', 1);
             ->where('mark', 1);
     }
     }
 
 
@@ -76,13 +77,4 @@ class OrderModel extends BaseModel
             ->where(['mark' => 1])
             ->where(['mark' => 1])
             ->select(['id', 'order_no', 'goods_id', 'confirm_at', 'status']);
             ->select(['id', 'order_no', 'goods_id', 'confirm_at', 'status']);
     }
     }
-
-    /**
-     * 订单商品
-     * @return \Illuminate\Database\Eloquent\Relations\HasOne
-     */
-    public function goods()
-    {
-        return $this->hasOne(GoodsModel::class, 'id', 'goods_id')->with(['shipperCity', 'shipperDistrict', 'receiverCity', 'receiverDistrict']);
-    }
 }
 }

+ 2 - 7
app/Services/Api/OrderService.php

@@ -111,7 +111,7 @@ class OrderService extends BaseService
     public function getQuery($params)
     public function getQuery($params)
     {
     {
         $where = ['a.mark' => 1];
         $where = ['a.mark' => 1];
-        return $this->model->from('orders as a')->with(['goods'])
+        return $this->model->from('orders as a')->with(['orderGoods','store'])
             ->leftJoin('member as b', 'b.id', '=', 'a.user_id')
             ->leftJoin('member as b', 'b.id', '=', 'a.user_id')
             ->where($where)
             ->where($where)
             ->where(function ($query) use ($params) {
             ->where(function ($query) use ($params) {
@@ -124,7 +124,6 @@ class OrderService extends BaseService
                 $keyword = isset($params['keyword']) ? $params['keyword'] : '';
                 $keyword = isset($params['keyword']) ? $params['keyword'] : '';
                 if ($keyword) {
                 if ($keyword) {
                     $query->where('a.order_no', 'like', "%{$keyword}%")
                     $query->where('a.order_no', 'like', "%{$keyword}%")
-                        ->orWhere('b.nickname', 'like', "%{$keyword}%")
                         ->orWhere('b.mobile', 'like', "%{$keyword}%");
                         ->orWhere('b.mobile', 'like', "%{$keyword}%");
                 }
                 }
             });
             });
@@ -136,7 +135,7 @@ class OrderService extends BaseService
      */
      */
     public function getOrderInfo($id)
     public function getOrderInfo($id)
     {
     {
-        $statusArr = [1 => '待审核', 2 => '进行中', 3 => '已完成'];
+        $statusArr = [1 => '待支付', 2 => '待发货', 3 => '待收货',4=>'已完成'];
         $info = $this->model->from('orders as a')->with(['goods'])
         $info = $this->model->from('orders as a')->with(['goods'])
             ->leftJoin('member as b', 'b.id', '=', 'a.user_id')
             ->leftJoin('member as b', 'b.id', '=', 'a.user_id')
             ->where(['a.id' => $id, 'a.mark' => 1])
             ->where(['a.id' => $id, 'a.mark' => 1])
@@ -151,10 +150,6 @@ class OrderService extends BaseService
             if ($status) {
             if ($status) {
                 $info['status_text'] = isset($statusArr[$status]) ? $statusArr[$status] : '';
                 $info['status_text'] = isset($statusArr[$status]) ? $statusArr[$status] : '';
             }
             }
-
-            $info['goods'] = isset($info['goods']) && $info['goods'] ? $info['goods'] : [];
-            $info['goods']['shipper_phone_text'] = $info['goods']['shipper_phone'] ? format_mobile($info['goods']['shipper_phone']) : '';
-            $info['goods']['receiver_phone_text'] = $info['goods']['receiver_phone'] ? format_mobile($info['goods']['receiver_phone']) : '';
         }
         }
 
 
         return $info;
         return $info;