Browse Source

完善功能

gorden 9 months ago
parent
commit
62b53b66be
1 changed files with 16 additions and 1 deletions
  1. 16 1
      app/admin/service/goods/GoodsService.php

+ 16 - 1
app/admin/service/goods/GoodsService.php

@@ -36,7 +36,22 @@ class GoodsService
         if ($category == 'GOODS') {
             $categoryIds = [6, 7, 8, 10, 11, 12];
         } elseif ($category == 'SERVICE') {
-            $categoryIds = [33, 34, 35, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 36, 37, 38, 39, 40, 41];
+            $categorySuperIds = [31, 43, 65, 30, 66, 72];
+
+            $categorys = SysCategory::whereIn('category_id', $categorySuperIds)->get()->toArray();
+            foreach ($categorys as $item) {
+                if (empty($item['category_super_path'])) {
+                    $item['category_super_path'] = '#' . $item['category_id'] . '#';
+                } else {
+                    $item['category_super_path'] = $item['category_super_path'] . '#' . $item['category_id'] . '#';
+                }
+
+                $categoryIds = SysCategory::where('category_super_path', 'like', '%' . $item['category_super_path'])->pluck('category_id');
+                $categoryIds = $categoryIds ? $categoryIds->toArray() : [];
+                $categorySuperIds = array_merge($categorySuperIds, $categoryIds);
+            }
+
+            $categoryIds = array_unique($categorySuperIds);
         }
 
         $goods = Goods::with('sku')