Kirin 4 tahun lalu
induk
melakukan
7a5a09f74a

+ 1 - 1
app/common/middleware/UserTokenMiddleware.php

@@ -68,7 +68,7 @@ class UserTokenMiddleware extends BaseMiddleware
             if (!$user['status'])
                 throw new AuthException('账号已被禁用');
 
-            $user['now_local'] = ['lng' => $longitude, 'lat' => $latitude];
+            $user['now_local'] = ['long' => $longitude, 'lat' => $latitude];
         } catch (Throwable $e) {
             if ($force)
                 throw  $e;

+ 9 - 6
app/controller/api/store/merchant/Merchant.php

@@ -31,7 +31,7 @@ class Merchant extends BaseController
     {
         parent::__construct($app);
         $this->repository = $repository;
-        $this->userInfo =$this->request->isLogin() ? $this->request->userInfo():null;
+        $this->userInfo = $this->request->isLogin() ? $this->request->userInfo() : null;
     }
 
     /**
@@ -43,6 +43,9 @@ class Merchant extends BaseController
     {
         [$page, $limit] = $this->getPage();
         $where = $this->request->params(['keyword', 'order', 'is_best', 'location', 'category_id']);
+        if (!$where['location']) {
+            $where['location'] = $this->userInfo['now_local'];
+        }
         return app('json')->success($this->repository->getList($where, $page, $limit, $this->userInfo));
     }
 
@@ -73,9 +76,9 @@ class Merchant extends BaseController
     public function productList($id)
     {
         [$page, $limit] = $this->getPage();
-        $where = $this->request->params(['keyword','order','mer_cate_id','cate_id', 'order', 'price_on', 'price_off', 'brand_id', 'pid']);
-        if(!$this->repository->apiGetOne($id)) return app('json')->fail(' 店铺已打烊');
-        return app('json')->success($this->repository->productList($id,$where, $page, $limit,$this->userInfo));
+        $where = $this->request->params(['keyword', 'order', 'mer_cate_id', 'cate_id', 'order', 'price_on', 'price_off', 'brand_id', 'pid']);
+        if (!$this->repository->apiGetOne($id)) return app('json')->fail(' 店铺已打烊');
+        return app('json')->success($this->repository->productList($id, $where, $page, $limit, $this->userInfo));
     }
 
     /**
@@ -86,14 +89,14 @@ class Merchant extends BaseController
      */
     public function categoryList($id)
     {
-        if(!$this->repository->merExists($id))
+        if (!$this->repository->merExists($id))
             return app('json')->fail('店铺已打烊');
         return app('json')->success($this->repository->categoryList($id));
     }
 
     public function qrcode($id)
     {
-        if(!$this->repository->merExists($id))
+        if (!$this->repository->merExists($id))
             return app('json')->fail('店铺已打烊');
         $url = $this->request->param('type') == 'routine' ? $this->repository->routineQrcode(intval($id)) : $this->repository->wxQrcode(intval($id));
         return app('json')->success(compact('url'));