Browse Source

商品分类

Gorden 8 months ago
parent
commit
09e4943862
1 changed files with 4 additions and 4 deletions
  1. 4 4
      app/admin/service/goods/GoodsService.php

+ 4 - 4
app/admin/service/goods/GoodsService.php

@@ -156,11 +156,11 @@ class GoodsService
             $categoryPath = SysCategory::where('category_id', $categoryId)->value('category_super_path');
             $categoryPath .= '#' . $categoryId . '#';
             $categoryIds = SysCategory::where('category_super_path', 'like', $categoryPath . '%')->pluck('category_id')->toArray();
-            $categoryIds[] = $categoryId;
+            $categoryIds[] = intval($categoryId);
             if (!empty($categoryIds)) {
                 $categoryId = $categoryIds;
             } else {
-                $categoryId = [$categoryId];
+                $categoryId = [intval($categoryId)];
             }
         }
 
@@ -191,7 +191,7 @@ class GoodsService
             ->when($classify != '', function ($query) use ($classify,$categoryId) {
                 if ($classify == 'GOODS' && empty($categoryId)) {
                     $query->whereIn('join_goods_category_id', ['6', '7', '8', '9', '10', '11', '12', '30']);
-                } else if($classify != 'GOODS') {
+                } else if($classify != 'GOODS' && empty($categoryId)) {
                     $query->where('goods_classify', $classify);
                 }
             })
@@ -213,7 +213,7 @@ class GoodsService
         })->when($classify != '', function ($query) use ($classify,$categoryId) {
             if ($classify == 'GOODS' && empty($categoryId)) {
                 $query->whereIn('join_goods_category_id', ['6', '7', '8', '9', '10', '11', '12', '30']);
-            } else if($classify != 'GOODS') {
+            } else if($classify != 'GOODS' && empty($categoryId)) {
                 $query->where('goods_classify', $classify);
             }
         })