LiuJ 4 месяцев назад
Родитель
Сommit
7894d9699a
1 измененных файлов с 14 добавлено и 10 удалено
  1. 14 10
      app/JsonRpc/WebsiteService.php

+ 14 - 10
app/JsonRpc/WebsiteService.php

@@ -716,9 +716,9 @@ class WebsiteService implements WebsiteServiceInterface
         $website_id = [
             'website_id' => $data['website_id'],
         ];
-        $website_column_arr = Website::where('id',$data['website_id'])->value('website_column_arr_id');
-        if(empty($website_column_arr)){
-            return Result::error("未查询到此网站所属网系!",0);
+        $website_column_arr = Website::where('id', $data['website_id'])->value('website_column_arr_id');
+        if (empty($website_column_arr)) {
+            return Result::error("未查询到此网站所属网系!", 0);
         }
         $website_column_arr = json_decode($website_column_arr, true);
         // return Result::success(!in_array(3,$website_column_arr) && $data['pid'] == 0);
@@ -733,10 +733,10 @@ class WebsiteService implements WebsiteServiceInterface
         $pid = array_values(array_unique($pid->toArray()));
         // 构建查询语句
         $query = WebsiteCategory::where($website_id)
-            ->when(!in_array(3,$website_column_arr) && $data['pid'] == 0, function ($query) use ($website_column_arr) {
+            ->when(!in_array(3, $website_column_arr) && $data['pid'] == 0, function ($query) use ($website_column_arr) {
                 $query->where('is_show', 1);
             })
-            ->when(in_array(3,$website_column_arr) ||  $data['pid'] != 0, function ($query) use ($data) {
+            ->when(in_array(3, $website_column_arr) ||  $data['pid'] != 0, function ($query) use ($data) {
                 $query->where('pid', $data['pid']);
             })
             ->offset($data['placeid'])
@@ -1844,6 +1844,10 @@ class WebsiteService implements WebsiteServiceInterface
         //        if (isset($data['city_id']) && !empty($data['city_id'])) {
         //            array_push($where, ['category.city_id', '=', $data['city_id']]);
         //        }
+
+        if (isset($data['is_show']) && !empty($data['is_show'])) {
+            array_push($where, ['website_category.is_show', '=', $data['is_show']]);
+        }
         $result_real = WebsiteCategory::where($where)
             // ->where('website_category.is_show', 1) //显示
             ->whereNotNull('website_category.real_pid') //只显示顶级
@@ -2798,16 +2802,16 @@ class WebsiteService implements WebsiteServiceInterface
         if (empty($website)) {
             return Result::error("暂无该网站", 0);
         }
-        if (isset($data['pinyin']) &&!empty($data['pinyin'])) {
-            $result = WebsiteCategory::where('website_id',$data['website_id'])
-            ->where('aLIas_pinyin',$data['pinyin'])
-            // $result = WebsiteCategory::where('category_id', $category_id)
+        if (isset($data['pinyin']) && !empty($data['pinyin'])) {
+            $result = WebsiteCategory::where('website_id', $data['website_id'])
+                ->where('aLIas_pinyin', $data['pinyin'])
+                // $result = WebsiteCategory::where('category_id', $category_id)
                 // ->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',)
+                ->select('website_category.category_id', 'website_category.type', 'website_category.alias',)
                 ->first();
         }
         if (isset($data['foot_pinyin']) && !empty($data['foot_pinyin'])) {