Procházet zdrojové kódy

fix(warehouse): 修复分类列表数据过滤逻辑

- 添加了商户ID非空判断条件
- 防止在商户ID为空时执行不必要的数据库查询操作
- 确保只有在存在商户ID的情况下才进行商品过滤检查
shichen před 2 měsíci
rodič
revize
c4ca5dc889
1 změnil soubory, kde provedl 11 přidání a 10 odebrání
  1. 11 10
      app/controller/api/warehouse/Home.php

+ 11 - 10
app/controller/api/warehouse/Home.php

@@ -50,16 +50,17 @@ class Home extends BaseController
50 50
             -> order('sort desc')
51 51
             -> group('cate_name')
52 52
             -> select();
53
-
54
-        foreach ($list as $key => $item) {
55
-            $product = Db::name('store_product')
56
-                ->where('is_show',1)
57
-                ->where('status',1)
58
-                ->where('mer_id',$merid)
59
-                ->where('cate_id',$item['store_category_id'])
60
-                ->limit(1)
61
-                ->find();
62
-            if(!$product) unset($list[$key]);
53
+        if ($merid) {
54
+            foreach ($list as $key => $item) {
55
+                $product = Db::name('store_product')
56
+                    ->where('is_show',1)
57
+                    ->where('status',1)
58
+                    ->where('mer_id',$merid)
59
+                    ->where('cate_id',$item['store_category_id'])
60
+                    ->limit(1)
61
+                    ->find();
62
+                if(!$product) unset($list[$key]);
63
+            }
63 64
         }
64 65
 
65 66
         return app('json')->success($list);