Jelajahi Sumber

修改c端-获取商品分类

15313670163 12 jam lalu
induk
melakukan
bd4a7bfd8c
1 mengubah file dengan 8 tambahan dan 20 penghapusan
  1. 8 20
      app/JsonRpc/NewsService.php

+ 8 - 20
app/JsonRpc/NewsService.php

@@ -1466,26 +1466,14 @@ class NewsService implements NewsServiceInterface
             ->offset(($data['page']-1)*$data['pageSize']) 
             ->limit($data['pageSize']) 
             ->get(); 
-        if($goods->isEmpty()){ 
-            return Result::error("商品查询失败", 0); 
-        } 
-        if($goods->count() > 1){ 
-            $goods = $this->processGoods($goods, $web); 
-        }else{ 
-            $catid = $goods[0]['catid'] ?? 0; 
-            $good_category = WebsiteCategory::where('category_id', $catid)->where('website_id', $data['website_id'])->first(); 
-            if (!empty($good_category->pid) && $good_category->pid != 0) { 
-                $level = json_decode($good_category->category_arr_id); 
-                $pinyin = WebsiteCategory::whereIn('category_id', $level) 
-                    ->orderByRaw('FIELD(category_id, '. implode(',', $level). ')') 
-                    ->get(['aLIas_pinyin']) 
-                    ->pluck('aLIas_pinyin') 
-                    ->implode('/'); 
-            } else { 
-                $pinyin = $good_category->aLIas_pinyin ?? ''; 
-            } 
-            $goods[0]['pinyin'] = $pinyin; 
-        } 
+        if(!empty($goods)){
+            if($goods->count() > 1 && !empty($goods)){ 
+                $goods = $this->processGoods($goods, $web); 
+            }
+        }else{
+            $goods = [];
+        }
+        
         $result = [ 
             'category' => $cat_tree, 
             'goods' => $goods,