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

修改c端接口:获取栏目、匹配栏目路由的接口

15313670163 преди 4 месеца
родител
ревизия
01e1f89148
променени са 1 файла, в които са добавени 9 реда и са изтрити 8 реда
  1. 9 8
      app/JsonRpc/WebsiteService.php

+ 9 - 8
app/JsonRpc/WebsiteService.php

@@ -640,14 +640,14 @@ class WebsiteService implements WebsiteServiceInterface
             ->when(isset($data['is_show']) && $data['is_show'] == 1 && $data['pid'] == 0, function ($query) use ($data) {
                 $query->where('is_show', $data['is_show']);
             })
-            ->when(!isset($data['is_show']) || $data['is_show'] != 1, function ($query) use ($data) {
+            ->when(!isset($data['is_show']), function ($query) use ($data) {
                 $query->where('pid', $data['pid']);
             })
             ->offset($data['placeid'])
             ->limit($data['num'])
             ->orderBy('sort');
         // 如果 $pid 数组不为空,添加 CASE WHEN 条件
-        
+        // return Result::success(!isset($data['is_show']) );
         if (!empty($pid)) {
             $placeholders = implode(',', array_fill(0, count($pid), '?'));
             $query->selectRaw("website_category.*, CASE WHEN website_category.category_id IN ($placeholders) THEN 1 ELSE 0 END AS children_count", $pid);
@@ -1551,6 +1551,7 @@ class WebsiteService implements WebsiteServiceInterface
             }
             $category['children_count'] = WebsiteCategory::where('website_id',$data['website_id'])->where('pid',$data['category_id'])->count();
             $parent = WebsiteCategory::where('website_id',$data['website_id'])->where('category_id',$category['pid'])->select('category_id as parent_id','alias as parent_name','aLIas_pinyin')->first();
+            // return Result::success($parent);
             $category['parent_id'] = $parent['parent_id'] ?? '';
             $category['parent_pinyin'] = $parent['aLIas_pinyin'] ?? '';
             $category['parent_name'] = $parent['parent_name'] ?? '';
@@ -2195,12 +2196,12 @@ class WebsiteService implements WebsiteServiceInterface
         }
         if (isset($data['pinyin']) &&!empty($data['pinyin'])) {
             $result = WebsiteCategory::where('website_category.website_id', $data['website_id'])
-                ->where('website_category.aLIas_pinyin', $data['pinyin'])
-                ->leftJoin('website_category as pc', function ($join) use ($data) {
-                    $join->on('pc.pid', '=', 'website_category.category_id')
-                        ->where('pc.website_id', '=', $data['website_id']);
-                })
-                ->select('website_category.category_id','website_category.type', 'website_category.alias', DB::raw('CASE WHEN pc.category_id IS NOT NULL THEN 1 ELSE 0 END as children_count'))
+                ->where('website_category.path', $data['pinyin'])
+                // ->leftJoin('website_category as pc', function ($join) use ($data) {
+                //     $join->on('pc.pid', '=', 'website_category.category_id')
+                //         ->where('pc.website_id', '=', $data['website_id']);
+                // })
+                ->select('website_category.category_id','website_category.type', 'website_category.alias',)
                 ->first();
         }
         if(isset($data['foot_pinyin']) &&!empty($data['foot_pinyin'])){