LiuJ 5 天之前
父节点
当前提交
02b17426d6
共有 1 个文件被更改,包括 183 次插入147 次删除
  1. 183 147
      app/JsonRpc/NewsService.php

+ 183 - 147
app/JsonRpc/NewsService.php

@@ -46,6 +46,7 @@ use Hamcrest\Arrays\IsArray;
 use Hyperf\Codec\Json;
 use Hyperf\Codec\Json;
 
 
 use App\Tools\buildMenuTree;
 use App\Tools\buildMenuTree;
+
 #[RpcService(name: "NewsService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
 #[RpcService(name: "NewsService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
 class NewsService implements NewsServiceInterface
 class NewsService implements NewsServiceInterface
 {
 {
@@ -690,7 +691,7 @@ class NewsService implements NewsServiceInterface
         // return Result::success($data['website_id']);
         // return Result::success($data['website_id']);
         $category = WebsiteCategory::where('website_id', $data['website_id'])->pluck('category_id');
         $category = WebsiteCategory::where('website_id', $data['website_id'])->pluck('category_id');
         $category = array_values(array_unique($category->toArray()));
         $category = array_values(array_unique($category->toArray()));
-       
+
         if ($category) {
         if ($category) {
             $placeid = isset($data['placeid']) && !empty($data['placeid']) ? $data['placeid'] - 1 : 0;
             $placeid = isset($data['placeid']) && !empty($data['placeid']) ? $data['placeid'] - 1 : 0;
             $where = [
             $where = [
@@ -749,27 +750,27 @@ class NewsService implements NewsServiceInterface
             //如果是4:最新资讯(数据库已不存在) 5:资讯推荐(数据库已不存在);
             //如果是4:最新资讯(数据库已不存在) 5:资讯推荐(数据库已不存在);
             // 1:头条资讯;2:轮播图;6:热点资讯;(数据库)
             // 1:头条资讯;2:轮播图;6:热点资讯;(数据库)
             var_dump($where, 'where-----------------');
             var_dump($where, 'where-----------------');
-           // 初始化基础查询
+            // 初始化基础查询
             $query = Article::where($where)
             $query = Article::where($where)
-              ->whereIn("catid", $category)
-              ->where(function ($query) use ($data) {
-                $query->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($data['website_id']) . "') = 0")
-                  ->orWhereNull("ignore_ids");
-              });
+                ->whereIn("catid", $category)
+                ->where(function ($query) use ($data) {
+                    $query->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($data['website_id']) . "') = 0")
+                        ->orWhereNull("ignore_ids");
+                });
 
 
             // 处理 level 相关查询条件
             // 处理 level 相关查询条件
             $query->when($data['level'] == 5, function ($query) {
             $query->when($data['level'] == 5, function ($query) {
-              $query->inRandomOrder()
-                ->where('updated_at', '>', date("Y-m-d H:i:s", strtotime("-30 day")));
+                $query->inRandomOrder()
+                    ->where('updated_at', '>', date("Y-m-d H:i:s", strtotime("-30 day")));
             })->when($data['level'] == 4, function ($query) {
             })->when($data['level'] == 4, function ($query) {
-              $query->orderBy("article.updated_at", "desc");
+                $query->orderBy("article.updated_at", "desc");
             })->when(!empty($data['level']), function ($query) use ($data) {
             })->when(!empty($data['level']), function ($query) use ($data) {
-              if ($data['level'] != 4 && $data['level'] != 5) {
-                $query->whereRaw("JSON_CONTAINS(level, '" . intval($data['level']) . "') = 1")
-                  ->orderBy("article.updated_at", "desc");
-              }
+                if ($data['level'] != 4 && $data['level'] != 5) {
+                    $query->whereRaw("JSON_CONTAINS(level, '" . intval($data['level']) . "') = 1")
+                        ->orderBy("article.updated_at", "desc");
+                }
             });
             });
-               // 初始化结果数组
+            // 初始化结果数组
             $result = [];
             $result = [];
             // $input = $data['website_id']; 
             // $input = $data['website_id']; 
             // 处理图片新闻查询
             // 处理图片新闻查询
@@ -779,29 +780,31 @@ class NewsService implements NewsServiceInterface
                 $imgQuery = clone $query;
                 $imgQuery = clone $query;
                 if ($imgQuery->getBindings() === null) {
                 if ($imgQuery->getBindings() === null) {
                     $imgQuery->setBindings([]);
                     $imgQuery->setBindings([]);
-                }   
+                }
                 $result['img'] = $imgQuery->where('article.imgurl', '!=', '')
                 $result['img'] = $imgQuery->where('article.imgurl', '!=', '')
-                    ->select('article.id',
-                    'article.title',
-                    'article.imgurl',
-                    'article.author',
-                    'article.updated_at',
-                    'article.introduce',
-                    'article.islink',
-                    'article.linkurl',
-                    'article.copyfrom',
-                    'article.catid')
+                    ->select(
+                        'article.id',
+                        'article.title',
+                        'article.imgurl',
+                        'article.author',
+                        'article.updated_at',
+                        'article.introduce',
+                        'article.islink',
+                        'article.linkurl',
+                        'article.copyfrom',
+                        'article.catid'
+                    )
                     ->offset($data['placeid'])
                     ->offset($data['placeid'])
                     ->limit($data['imgnum'])
                     ->limit($data['imgnum'])
                     ->get()
                     ->get()
-                    ->map(function ($article ) use ($data) {
+                    ->map(function ($article) use ($data) {
                         $catid = $article->catid;
                         $catid = $article->catid;
                         $pinyin = '';
                         $pinyin = '';
                         $category = WebsiteCategory::where('category_id', $catid)->where('website_category.website_id', $data['website_id'])->first();
                         $category = WebsiteCategory::where('category_id', $catid)->where('website_category.website_id', $data['website_id'])->first();
                         if (!empty($category->aLIas_pinyin) && $category->pid != 0) {
                         if (!empty($category->aLIas_pinyin) && $category->pid != 0) {
                             $childCategory = WebsiteCategory::where('category_id', $category->pid)->where('website_category.website_id', $data['website_id'])->first();
                             $childCategory = WebsiteCategory::where('category_id', $category->pid)->where('website_category.website_id', $data['website_id'])->first();
                             if ($childCategory && !empty($childCategory->aLIas_pinyin)) {
                             if ($childCategory && !empty($childCategory->aLIas_pinyin)) {
-                                $pinyin = $childCategory->aLIas_pinyin ?  $childCategory->aLIas_pinyin.'/'. $category->aLIas_pinyin : null;
+                                $pinyin = $childCategory->aLIas_pinyin ?  $childCategory->aLIas_pinyin . '/' . $category->aLIas_pinyin : null;
                             }
                             }
                         } else {
                         } else {
                             $pinyin = $category->aLIas_pinyin ?  $category->aLIas_pinyin : null;
                             $pinyin = $category->aLIas_pinyin ?  $category->aLIas_pinyin : null;
@@ -811,32 +814,34 @@ class NewsService implements NewsServiceInterface
                     });
                     });
                 // $result['img'] = $this->processArticles($img_article, $input); 
                 // $result['img'] = $this->processArticles($img_article, $input); 
             }
             }
-            
+
             // 处理文字新闻查询
             // 处理文字新闻查询
             if (!empty($data['textnum'])) {
             if (!empty($data['textnum'])) {
                 $textQuery = clone $query;
                 $textQuery = clone $query;
                 $result['text'] = $textQuery
                 $result['text'] = $textQuery
-                ->select('article.id',
-                    'article.title',
-                    'article.imgurl',
-                    'article.author',
-                    'article.updated_at',
-                    'article.introduce',
-                    'article.islink',
-                    'article.linkurl',
-                    'article.copyfrom',
-                    'article.catid')
+                    ->select(
+                        'article.id',
+                        'article.title',
+                        'article.imgurl',
+                        'article.author',
+                        'article.updated_at',
+                        'article.introduce',
+                        'article.islink',
+                        'article.linkurl',
+                        'article.copyfrom',
+                        'article.catid'
+                    )
                     ->offset($data['placeid'])
                     ->offset($data['placeid'])
                     ->limit($data['textnum'])
                     ->limit($data['textnum'])
                     ->get()
                     ->get()
-                    ->map(function ($article ) use ($data) {
+                    ->map(function ($article) use ($data) {
                         $catid = $article->catid;
                         $catid = $article->catid;
                         $pinyin = '';
                         $pinyin = '';
                         $category = WebsiteCategory::where('category_id', $catid)->where('website_category.website_id', $data['website_id'])->first();
                         $category = WebsiteCategory::where('category_id', $catid)->where('website_category.website_id', $data['website_id'])->first();
                         if (!empty($category->aLIas_pinyin) && $category->pid != 0) {
                         if (!empty($category->aLIas_pinyin) && $category->pid != 0) {
                             $childCategory = WebsiteCategory::where('category_id', $category->pid)->where('website_category.website_id', $data['website_id'])->first();
                             $childCategory = WebsiteCategory::where('category_id', $category->pid)->where('website_category.website_id', $data['website_id'])->first();
                             if ($childCategory && !empty($childCategory->aLIas_pinyin)) {
                             if ($childCategory && !empty($childCategory->aLIas_pinyin)) {
-                                $pinyin = $childCategory->aLIas_pinyin ?  $childCategory->aLIas_pinyin.'/'. $category->aLIas_pinyin : null;
+                                $pinyin = $childCategory->aLIas_pinyin ?  $childCategory->aLIas_pinyin . '/' . $category->aLIas_pinyin : null;
                             }
                             }
                         } else {
                         } else {
                             $pinyin = $category->aLIas_pinyin ?  $category->aLIas_pinyin : null;
                             $pinyin = $category->aLIas_pinyin ?  $category->aLIas_pinyin : null;
@@ -846,7 +851,7 @@ class NewsService implements NewsServiceInterface
                     });
                     });
                 // $result['text'] = $this->processArticles($text_article, $input); 
                 // $result['text'] = $this->processArticles($text_article, $input); 
             }
             }
-            
+
             if (empty($result) || count($result) == 0) {
             if (empty($result) || count($result) == 0) {
                 return Result::error("暂无头条新闻");
                 return Result::error("暂无头条新闻");
             }
             }
@@ -932,36 +937,37 @@ class NewsService implements NewsServiceInterface
                 }
                 }
             }
             }
         })
         })
-        ->where(function ($query) use ($data) {
-            $query->whereRaw("JSON_CONTAINS(ignore_ids, '".intval($data['website_id'])."') = 0")
-                  ->orWhereNull("ignore_ids");
-        })
-        ->select(
-            'article.id',
-            'article.title',
-            'article.imgurl',
-            'article.author',
-            'article.updated_at',
-            'article.introduce',
-            'article.islink',
-            'article.linkurl',
-            'article.copyfrom',
-            'article.catid')
-        ->orderBy("updated_at", "desc")
-        ->offset(($data['page'] - 1) * $data['pageSize'])
-        ->limit($data['pageSize'])
-        ->get()
-        ->map(function ($article ) use ($data) {
-            $catid = $article->catid ?? 0;
-            $pinyin = '';
-            $category = WebsiteCategory::where('category_id', $catid)->where('website_category.website_id', $data['website_id'])->first();
-            $pinyin = $category->aLIas_pinyin ? $category->aLIas_pinyin : null;
-            if ($category->pid != 0 && !empty($category->aLIas_pinyin)) {
-                $childCategory = WebsiteCategory::where('category_id', $category->pid)->where('website_category.website_id', $data['website_id'])->first();
-                $pinyin = $childCategory->aLIas_pinyin ?  $childCategory->aLIas_pinyin.'/'. $category->aLIas_pinyin : null;
-            }
-            $article->pinyin = $pinyin;
-            return $article;
+            ->where(function ($query) use ($data) {
+                $query->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($data['website_id']) . "') = 0")
+                    ->orWhereNull("ignore_ids");
+            })
+            ->select(
+                'article.id',
+                'article.title',
+                'article.imgurl',
+                'article.author',
+                'article.updated_at',
+                'article.introduce',
+                'article.islink',
+                'article.linkurl',
+                'article.copyfrom',
+                'article.catid'
+            )
+            ->orderBy("updated_at", "desc")
+            ->offset(($data['page'] - 1) * $data['pageSize'])
+            ->limit($data['pageSize'])
+            ->get()
+            ->map(function ($article) use ($data) {
+                $catid = $article->catid ?? 0;
+                $pinyin = '';
+                $category = WebsiteCategory::where('category_id', $catid)->where('website_category.website_id', $data['website_id'])->first();
+                $pinyin = $category->aLIas_pinyin ? $category->aLIas_pinyin : null;
+                if ($category->pid != 0 && !empty($category->aLIas_pinyin)) {
+                    $childCategory = WebsiteCategory::where('category_id', $category->pid)->where('website_category.website_id', $data['website_id'])->first();
+                    $pinyin = $childCategory->aLIas_pinyin ?  $childCategory->aLIas_pinyin . '/' . $category->aLIas_pinyin : null;
+                }
+                $article->pinyin = $pinyin;
+                return $article;
             });
             });
 
 
         $count = Article::where(function ($query) use ($where) {
         $count = Article::where(function ($query) use ($where) {
@@ -1819,7 +1825,8 @@ class NewsService implements NewsServiceInterface
 
 
 
 
     // 封装处理商品的路由问题
     // 封装处理商品的路由问题
-    function processGoods($goods, $data) {
+    function processGoods($goods, $data)
+    {
         return $goods->map(function ($good) use ($data) {
         return $goods->map(function ($good) use ($data) {
             $catid = $good->catid ?? 0;
             $catid = $good->catid ?? 0;
             $pinyin = '';
             $pinyin = '';
@@ -1827,14 +1834,14 @@ class NewsService implements NewsServiceInterface
             if (!empty($category->pid) && $category->pid != 0) {
             if (!empty($category->pid) && $category->pid != 0) {
                 $level = json_decode($category->category_arr_id);
                 $level = json_decode($category->category_arr_id);
                 $pinyin = WebsiteCategory::whereIn('category_id', $level)
                 $pinyin = WebsiteCategory::whereIn('category_id', $level)
-                    ->orderByRaw('FIELD(category_id, '. implode(',', $level). ')')
+                    ->orderByRaw('FIELD(category_id, ' . implode(',', $level) . ')')
                     ->get(['aLIas_pinyin'])
                     ->get(['aLIas_pinyin'])
                     ->pluck('aLIas_pinyin')
                     ->pluck('aLIas_pinyin')
                     ->implode('/');
                     ->implode('/');
             } else {
             } else {
                 $pinyin = $category->aLIas_pinyin ?? '';
                 $pinyin = $category->aLIas_pinyin ?? '';
             }
             }
-            if(isset($good->city_id) &&!empty($good->city_id)){
+            if (isset($good->city_id) && !empty($good->city_id)) {
                 $city = District::where('id', $good->city_id)->first(['name']);
                 $city = District::where('id', $good->city_id)->first(['name']);
                 $good->city_name = $city->name ?? '';
                 $good->city_name = $city->name ?? '';
             }
             }
@@ -1858,8 +1865,8 @@ class NewsService implements NewsServiceInterface
         $data = json_decode($input['id'] ?? '', true) ?? [];
         $data = json_decode($input['id'] ?? '', true) ?? [];
         $result = array_map(function ($item) use ($input) {
         $result = array_map(function ($item) use ($input) {
             // 检查parent元素是否存在且不是undefined
             // 检查parent元素是否存在且不是undefined
-            if (isset($item['level']) && $item['level'] != 'undefined' && $item['level']!= "") {
-                list($Levelid, $goodStart,$goodNum) = explode(',', $item['level']);
+            if (isset($item['level']) && $item['level'] != 'undefined' && $item['level'] != "") {
+                list($Levelid, $goodStart, $goodNum) = explode(',', $item['level']);
                 $website = $input['website_id'];
                 $website = $input['website_id'];
                 $query = Good::where('good.status', 2)
                 $query = Good::where('good.status', 2)
                     ->where('good.website_id', $website);
                     ->where('good.website_id', $website);
@@ -1867,29 +1874,38 @@ class NewsService implements NewsServiceInterface
                     case 1:
                     case 1:
                     case 2:
                     case 2:
                     case 3:
                     case 3:
-                        $goods = $query->where(function($q) use ($Levelid) {
-                            $q->whereRaw("JSON_CONTAINS(good.level, '". intval($Levelid). "') = 0")
-                              ->orWhereRaw("JSON_CONTAINS(good.level, '\"". intval($Levelid). "\"') = 0");
+                        $goods = $query->where(function ($q) use ($Levelid) {
+                            $q->whereRaw("JSON_CONTAINS(good.level, '" . intval($Levelid) . "') = 0")
+                                ->orWhereRaw("JSON_CONTAINS(good.level, '\"" . intval($Levelid) . "\"') = 0");
                         });
                         });
                         break;
                         break;
                     case 4:
                     case 4:
                         $goods = $query;
                         $goods = $query;
                         break;
                         break;
                     case 5:
                     case 5:
-                        $goods = $query->where('type_id',1);
+                        $goods = $query->where('type_id', 1);
                         break;
                         break;
                     case 6:
                     case 6:
-                        $goods = $query->where('type_id',2);
-                            
+                        $goods = $query->where('type_id', 2);
+
                         break;
                         break;
                     default:
                     default:
                         return [];
                         return [];
                 }
                 }
                 $all_goods = $goods
                 $all_goods = $goods
-                    ->select('good.id', 'good.name', 'good.imgurl', 'good.description',
-                     'good.updated_at', 'good.catid','good.type_id','good.price','good.level',
-                     'good.website_id')
-                    ->orderBy('updated_at','desc')
+                    ->select(
+                        'good.id',
+                        'good.name',
+                        'good.imgurl',
+                        'good.description',
+                        'good.updated_at',
+                        'good.catid',
+                        'good.type_id',
+                        'good.price',
+                        'good.level',
+                        'good.website_id'
+                    )
+                    ->orderBy('updated_at', 'desc')
                     ->offset($goodStart)
                     ->offset($goodStart)
                     ->limit($goodNum)
                     ->limit($goodNum)
                     ->get();
                     ->get();
@@ -1907,22 +1923,22 @@ class NewsService implements NewsServiceInterface
     public function getWebsiteshopCat(array $data): array
     public function getWebsiteshopCat(array $data): array
     {
     {
         $category = WebsiteCategory::where('website_id', $data['website_id'])
         $category = WebsiteCategory::where('website_id', $data['website_id'])
-            ->whereRaw("JSON_CONTAINS(category_arr_id, '". intval($data['id']). "') = 1")
-            ->orWhereRaw("JSON_CONTAINS(category_arr_id, '\"". intval($data['id']). "\"') = 1")
-            ->select('category_id', 'alias','aLIas_pinyin','pid','category_arr_id')
+            ->whereRaw("JSON_CONTAINS(category_arr_id, '" . intval($data['id']) . "') = 1")
+            ->orWhereRaw("JSON_CONTAINS(category_arr_id, '\"" . intval($data['id']) . "\"') = 1")
+            ->select('category_id', 'alias', 'aLIas_pinyin', 'pid', 'category_arr_id')
             ->orderBy('sort')
             ->orderBy('sort')
             ->get()
             ->get()
             ->map(function ($item) use ($data) {
             ->map(function ($item) use ($data) {
                 $pinyin = [];
                 $pinyin = [];
                 $level = json_decode($item->category_arr_id);
                 $level = json_decode($item->category_arr_id);
                 // 递归获取所有父级栏目的拼音
                 // 递归获取所有父级栏目的拼音
-                if($item->pid!= 0){
+                if ($item->pid != 0) {
                     $pinyin = WebsiteCategory::whereIn('category_id', $level)
                     $pinyin = WebsiteCategory::whereIn('category_id', $level)
-                        ->orderByRaw('FIELD(category_id, '.implode(',', $level).')')
+                        ->orderByRaw('FIELD(category_id, ' . implode(',', $level) . ')')
                         ->get(['aLIas_pinyin'])
                         ->get(['aLIas_pinyin'])
                         ->pluck('aLIas_pinyin')
                         ->pluck('aLIas_pinyin')
-                        ->implode('/'); 
-                }else{
+                        ->implode('/');
+                } else {
                     $pinyin = $item->aLIas_pinyin;
                     $pinyin = $item->aLIas_pinyin;
                 }
                 }
                 $item->aLIas_pinyin = $pinyin;
                 $item->aLIas_pinyin = $pinyin;
@@ -1930,16 +1946,16 @@ class NewsService implements NewsServiceInterface
             });
             });
         $goods = Good::where('website_id', $data['website_id'])
         $goods = Good::where('website_id', $data['website_id'])
             ->where('status', 2)
             ->where('status', 2)
-            ->select('good.id as good_id', 'name','imgurl','description','updated_at','catid','type_id','website_id')
+            ->select('good.id as good_id', 'name', 'imgurl', 'description', 'updated_at', 'catid', 'type_id', 'website_id')
             ->latest('updated_at')
             ->latest('updated_at')
-            ->offset(($data['page']-1)*$data['pageSize'])
+            ->offset(($data['page'] - 1) * $data['pageSize'])
             ->limit($data['pageSize'])
             ->limit($data['pageSize'])
             ->get();
             ->get();
-            $goods = $this->processGoods($goods, $data);
-        if(empty($category)){
+        $goods = $this->processGoods($goods, $data);
+        if (empty($category)) {
             return Result::error("栏目查询失败", 0);
             return Result::error("栏目查询失败", 0);
         }
         }
-        if(empty($goods)){
+        if (empty($goods)) {
             return Result::error("商品查询失败", 0);
             return Result::error("商品查询失败", 0);
         }
         }
         // 调用Tool中的buildMenuTree方法构建菜单树
         // 调用Tool中的buildMenuTree方法构建菜单树
@@ -1949,8 +1965,8 @@ class NewsService implements NewsServiceInterface
             'goods' => $goods,
             'goods' => $goods,
         ];
         ];
         // $resul['goods'] = $goods;
         // $resul['goods'] = $goods;
-        if(empty($result)){
-            return Result::error("查询失败", 0); 
+        if (empty($result)) {
+            return Result::error("查询失败", 0);
         }
         }
         return Result::success($result);
         return Result::success($result);
     }
     }
@@ -1966,55 +1982,66 @@ class NewsService implements NewsServiceInterface
             'status' => 2,
             'status' => 2,
             'website_id' => $data['website_id'],
             'website_id' => $data['website_id'],
         ];
         ];
-        if((empty($data['catid']) ||!isset($data['catid'])) && (empty($data['keyword']) ||!isset($data['keyword'])) && (empty($data['city_id']) || !isset($data['city_id']))){
+        if ((empty($data['catid']) || !isset($data['catid'])) && (empty($data['keyword']) || !isset($data['keyword'])) && (empty($data['city_id']) || !isset($data['city_id']))) {
             return Result::error("查询失败", 0);
             return Result::error("查询失败", 0);
         }
         }
         if ((empty($data['catid']) || !isset($data['catid'])) && (!empty($data['city_id']) || isset($data['city_id']))) {
         if ((empty($data['catid']) || !isset($data['catid'])) && (!empty($data['city_id']) || isset($data['city_id']))) {
-            $category = WebsiteCategory::where('website_id', $data['website_id'])->where('pid',$data['id'])->orderBy('sort')->first(['category_id']);
+            $category = WebsiteCategory::where('website_id', $data['website_id'])->where('pid', $data['id'])->orderBy('sort')->first(['category_id']);
             $data['catid'] = $category->category_id ??  0;
             $data['catid'] = $category->category_id ??  0;
         }
         }
-        if(isset($data['keyword']) &&!empty($data['keyword'])){
-           array_push($where, ['name', 'like', '%'. $data['keyword'].'%']);
+        if (isset($data['keyword']) && !empty($data['keyword'])) {
+            array_push($where, ['name', 'like', '%' . $data['keyword'] . '%']);
         }
         }
-        if(isset($data['type_id']) && !empty($data['type_id'])){
+        if (isset($data['type_id']) && !empty($data['type_id'])) {
             array_push($where, ['type_id', $data['type_id']]);
             array_push($where, ['type_id', $data['type_id']]);
         }
         }
         $query = Good::where($where)
         $query = Good::where($where)
-            ->when(isset($data['catid']) &&!empty($data['catid']), function ($query) use ($data) {
-                $query->where(function($q) use ($data) {
-                    $q->WhereRaw("JSON_CONTAINS(good.cat_arr_id, '". intval($data['catid']). "') = 1")
-                    ->orWhereRaw("JSON_CONTAINS(good.cat_arr_id, '\"". intval($data['catid']). "\"') = 1");
+            ->when(isset($data['catid']) && !empty($data['catid']), function ($query) use ($data) {
+                $query->where(function ($q) use ($data) {
+                    $q->WhereRaw("JSON_CONTAINS(good.cat_arr_id, '" . intval($data['catid']) . "') = 1")
+                        ->orWhereRaw("JSON_CONTAINS(good.cat_arr_id, '\"" . intval($data['catid']) . "\"') = 1");
                 });
                 });
             })
             })
             ->when(isset($data['city_id']) && !empty($data['city_id']), function ($query) use ($data) {
             ->when(isset($data['city_id']) && !empty($data['city_id']), function ($query) use ($data) {
-                $query->where(function($q) use ($data) {
-                    $q->WhereRaw("JSON_CONTAINS(good.city_arr_id, '". intval($data['city_id']). "') = 1")
-                        ->orWhereRaw("JSON_CONTAINS(good.city_arr_id, '\"". intval($data['city_id']). "\"') = 1");
+                $query->where(function ($q) use ($data) {
+                    $q->WhereRaw("JSON_CONTAINS(good.city_arr_id, '" . intval($data['city_id']) . "') = 1")
+                        ->orWhereRaw("JSON_CONTAINS(good.city_arr_id, '\"" . intval($data['city_id']) . "\"') = 1");
                 });
                 });
             })
             })
-            ->select('good.id', 'good.name', 'good.imgurl', 'good.description', 'good.updated_at', 
-            'good.catid','good.type_id','good.website_id','good.cat_arr_id','good.created_at','good.city_id')
+            ->select(
+                'good.id',
+                'good.name',
+                'good.imgurl',
+                'good.description',
+                'good.updated_at',
+                'good.catid',
+                'good.type_id',
+                'good.website_id',
+                'good.cat_arr_id',
+                'good.created_at',
+                'good.city_id'
+            )
             ->latest('updated_at');
             ->latest('updated_at');
-            // 获取 type_id 为 1 的数据
-            $result['type1'] = $this->processGoods(
-                $query->clone()
-                    ->where('type_id', 1)
-                    ->offset(($data['page'] - 1) * $data['pageSize'])
-                    ->limit($data['pageSize'])
-                    ->get(),
-                $data
-            );
-            // 获取 type_id 为 2 的数据
-            $result['type2'] = $this->processGoods(
-                $query->clone()
-                    ->where('type_id', 2)
-                    ->offset(($data['page'] - 1) * $data['pageSize'])
-                    ->limit($data['pageSize'])
-                    ->get(),
-                $data
-            );
-        if(empty($result)){
-            return Result::error("查询失败", 0); 
+        // 获取 type_id 为 1 的数据
+        $result['type1'] = $this->processGoods(
+            $query->clone()
+                ->where('type_id', 1)
+                ->offset(($data['page'] - 1) * $data['pageSize'])
+                ->limit($data['pageSize'])
+                ->get(),
+            $data
+        );
+        // 获取 type_id 为 2 的数据
+        $result['type2'] = $this->processGoods(
+            $query->clone()
+                ->where('type_id', 2)
+                ->offset(($data['page'] - 1) * $data['pageSize'])
+                ->limit($data['pageSize'])
+                ->get(),
+            $data
+        );
+        if (empty($result)) {
+            return Result::error("查询失败", 0);
         }
         }
 
 
         return Result::success($result);
         return Result::success($result);
@@ -2029,14 +2056,14 @@ class NewsService implements NewsServiceInterface
         $where = [
         $where = [
             'good.status' => 2,
             'good.status' => 2,
             'good.website_id' => $data['website_id'],
             'good.website_id' => $data['website_id'],
-        ]; 
+        ];
         $goods = Good::where($where)
         $goods = Good::where($where)
             ->where('good.id', $data['id'])
             ->where('good.id', $data['id'])
             ->leftJoin('website_category', 'website_category.category_id', 'good.catid')
             ->leftJoin('website_category', 'website_category.category_id', 'good.catid')
-            ->select('good.*','website_category.alias','website_category.category_id')
+            ->select('good.*', 'website_category.alias', 'website_category.category_id')
             ->first();
             ->first();
-        if(empty($goods)){
-            return Result::error("查询失败", 0); 
+        if (empty($goods)) {
+            return Result::error("查询失败", 0);
         }
         }
         $goods->imgurl = json_decode($goods->imgurl, true);
         $goods->imgurl = json_decode($goods->imgurl, true);
         return Result::success($goods);
         return Result::success($goods);
@@ -2044,21 +2071,22 @@ class NewsService implements NewsServiceInterface
     /**
     /**
      * 封装处理文章的路由问题
      * 封装处理文章的路由问题
      *  */
      *  */
-    function processArticles($articles, $data) {
+    function processArticles($articles, $data)
+    {
         if (!is_array($data)) {
         if (!is_array($data)) {
             // 可以根据实际情况进行日志记录或抛出异常
             // 可以根据实际情况进行日志记录或抛出异常
             // 这里简单输出错误信息
             // 这里简单输出错误信息
-            echo "Error: \$data is not an array in processArticles. It is of type ". gettype($data). PHP_EOL;
+            echo "Error: \$data is not an array in processArticles. It is of type " . gettype($data) . PHP_EOL;
             return $articles;
             return $articles;
         }
         }
         return $articles->map(function ($article) use ($data) {
         return $articles->map(function ($article) use ($data) {
-            $catid = $article->cat_arr_id?? '';
+            $catid = $article->cat_arr_id ?? '';
             $level = json_decode($catid, true);
             $level = json_decode($catid, true);
             $pinyin = '';
             $pinyin = '';
             $category = WebsiteCategory::where('category_id', $catid)->where('website_id', $data['website_id'])->first();
             $category = WebsiteCategory::where('category_id', $catid)->where('website_id', $data['website_id'])->first();
-            if (!empty($category->pid) && $category->pid!= 0) {
+            if (!empty($category->pid) && $category->pid != 0) {
                 $pinyin = WebsiteCategory::whereIn('category_id', $level)
                 $pinyin = WebsiteCategory::whereIn('category_id', $level)
-                    ->orderByRaw('FIELD(category_id, '. implode(',', $level). ')')
+                    ->orderByRaw('FIELD(category_id, ' . implode(',', $level) . ')')
                     ->get(['aLIas_pinyin'])
                     ->get(['aLIas_pinyin'])
                     ->pluck('aLIas_pinyin')
                     ->pluck('aLIas_pinyin')
                     ->implode('/');
                     ->implode('/');
@@ -2068,7 +2096,8 @@ class NewsService implements NewsServiceInterface
             $article->pinyin = $pinyin;
             $article->pinyin = $pinyin;
             return $article;
             return $article;
         });
         });
-    }    /**
+    }
+    /**
      * 验证导航名称是否重复
      * 验证导航名称是否重复
      * @return void
      * @return void
      */
      */
@@ -3434,7 +3463,7 @@ class NewsService implements NewsServiceInterface
         $user_id = $data['user_id'] ?? 0;
         $user_id = $data['user_id'] ?? 0;
         $type_id = $data['type_id'] ?? 0;
         $type_id = $data['type_id'] ?? 0;
         $website_id = $data['website_id'] ?? 0;
         $website_id = $data['website_id'] ?? 0;
-        unset($data['user_id']);
+        // unset($data['user_id']);
         unset($data['type_id']);
         unset($data['type_id']);
         // unset($data['website_id']);
         // unset($data['website_id']);
         //处理数组
         //处理数组
@@ -3482,12 +3511,19 @@ class NewsService implements NewsServiceInterface
         if (!empty($data['status'])) {
         if (!empty($data['status'])) {
             $where[] = ['book.status', '=', $data['status']];
             $where[] = ['book.status', '=', $data['status']];
         }
         }
+        $user_id = $data['user_id'];
+        $type_id =  $data['type_id'];
+        // $type_id = 4;
+        var_dump($type_id, '------1--------');
+        if ($type_id != 10000) {
+            $where[] = ['book.user_id', '=', $user_id];
+        }
         var_dump(!empty($data['status1']), '=-===1');
         var_dump(!empty($data['status1']), '=-===1');
         $result = Book::where($where)
         $result = Book::where($where)
             ->leftJoin('website', 'book.website_id', '=', 'website.id')
             ->leftJoin('website', 'book.website_id', '=', 'website.id')
             ->leftJoin('category', 'book.cat_id', '=', 'category.id')
             ->leftJoin('category', 'book.cat_id', '=', 'category.id')
             ->leftJoin('district', 'book.city_id', '=', 'district.id')
             ->leftJoin('district', 'book.city_id', '=', 'district.id')
-            ->when(!empty($data['status1']) && (isset($data['status']) &&  $data['status'] != 2), function ($query) use ($data) {
+            ->when(isset($data['status1']), function ($query) use ($data) {
                 $query->whereIn('book.status', [1, 3]);
                 $query->whereIn('book.status', [1, 3]);
             })
             })
             ->select('book.*', 'website.website_name', 'category.name as cat_name', 'district.name as city_name')
             ->select('book.*', 'website.website_name', 'category.name as cat_name', 'district.name as city_name')