zhangchangchun 6 years ago
parent
commit
1f774dfac6
1 changed files with 7 additions and 12 deletions
  1. 7 12
      app/Http/Controllers/V1/ShopController.php

+ 7 - 12
app/Http/Controllers/V1/ShopController.php

@@ -42,22 +42,17 @@ class ShopController extends Controller {
     public function getShopList(Request $request){
         $data = $request->only('ids');
         $validator = Validator::make($data, [
-            'ids' => 'required|string',
+            'ids' => 'required|array',
         ]);
         if ($validator->fails()) {
             return $this->jsonError($validator->errors()->first());
         }
-        $ids = explode(",", $request['ids']);
-        $data = [];
-        foreach ($ids as $v){
-            $shop = Shop::where('shop_id',$v)->first();
-            if($shop){
-                $data[][$shop->shop_id] =$shop->shop_name;
-            }else{
-                return $this->jsonError('失败 shop_id '.$v.'未找到');
-            }
-
+        $shop = Shop::whereIn('shop_id',$data['ids'])->where('status',0)->select('shop_id','shop_name')->get();
+        if($shop){
+            return $this->jsonSuccess($shop);
+        }else{
+            return $this->jsonError('失败未找到');
         }
-        return $this->jsonSuccess($data);
+
     }
 }