Преглед на файлове

fix(warehouse): 修复分类列表中空数据问题

- 在查询结果中添加商品存在性检查
- 移除没有对应商品的分类数据
- 避免返回空的商品分类信息
- 确保API响应的数据完整性
shichen преди 2 месеца
родител
ревизия
e98cb60e24
променени са 1 файла, в които са добавени 12 реда и са изтрити 0 реда
  1. 12 0
      app/controller/api/warehouse/Home.php

+ 12 - 0
app/controller/api/warehouse/Home.php

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