Jelajahi Sumber

Merge branch 'master' of http://git.bjzxtw.org.cn:3000/zxt/news_producer

rkljw 1 Minggu lalu
induk
melakukan
2f04435ab9
1 mengubah file dengan 482 tambahan dan 454 penghapusan
  1. 482 454
      app/JsonRpc/NewsService.php

+ 482 - 454
app/JsonRpc/NewsService.php

@@ -1448,18 +1448,210 @@ class NewsService implements NewsServiceInterface
         ->get();
     }
 
-    // $category = $category->get();
-
-    if (empty($category)) {
-      return Result::error("查询失败", 0);
+        // $category = $category->get();
+      
+        if(empty($category)){
+            return Result::error("查询失败", 0);
+        }
+        return Result::success($category);
+    } 
+    /**
+  * 模块新闻加强plus版 
+  * @param array $data
+  * @return array
+  */
+  public function getWebsiteAllArticle(array $data): array
+  {
+    $time1 = microtime(true);
+    $wetbsite_id = $data['website_id'] ?? 2;
+    $data = json_decode($data['id'], true);
+    
+    $categorys = $this->processArticlePro($wetbsite_id);
+    $cat_1st_arr = $categorys['cat_1st_arr'];
+    $catiall = $categorys['catiall'];
+    $websiteInfoIndexed = $categorys['websiteInfoIndexed'];
+    $parent_category = array_column($data, 'parent');
+    $parent_cat = [];        
+    $child_category = array_column($data,'child');
+    if(!empty($parent_category)){
+        foreach($parent_category as $key => $value){
+            $arr = array_map('intval', explode(',', $value));
+            $parent_cat[$key] = $arr[0] ?? 0;
+            $parent_category = $arr[0] ?? 0;
+            $article_imgnum = $arr[1] ?? 0;
+            $article_textnum = $arr[2] ?? 0;
+            if($parent_category != 0){
+                $category_arr = array_merge([$parent_category], $cat_1st_arr[$parent_category] ?? [0]);
+                // return Result::success($category_arr);
+                if($article_imgnum != 0){
+                    $img_article = Article::whereIn('catid', $category_arr)
+                        ->where('status',1)
+                        ->where('imgurl','!=', '')
+                        ->leftJoinSub(function ($query) use ($wetbsite_id) {
+                            $query->from('article_ignore')
+                                ->where('website_id', $wetbsite_id);
+                        }, 'article_ignore', function ($join) {
+                            $join->on('article_ignore.article_id', '=', 'article.id');
+                        })
+                        ->where(function ($query) use ($wetbsite_id) {
+                            $query->whereNull('article_ignore.article_id')
+                                ->orWhere('article_ignore.website_id', '!=', $wetbsite_id);
+                        })
+                        ->select('article.id','article.title','article.imgurl','article.author','article.updated_at','article.introduce','article.islink','article.linkurl','article.copyfrom','article.cat_arr_id','article.catid')
+                        ->orderBy('updated_at', 'desc')
+                        ->limit($article_imgnum)
+                        ->get()->all();
+                        foreach ($img_article as $k => $v) {
+                            $img_article[$k]->category_name = $catiall[$v->catid]['alias'];
+                            $img_article[$k]->pinyin = $catiall[$v->catid]['pinyin'];
+                            
+                        }
+                }else{
+                    $img_article = [];
+                }
+                if($article_textnum != 0){
+                    $text_article = Article::whereIn('catid', $category_arr)
+                        ->where('status',1)
+                        ->leftJoinSub(function ($query) use ($wetbsite_id) {
+                            $query->from('article_ignore')
+                                ->where('website_id', $wetbsite_id);
+                        }, 'article_ignore', function ($join) {
+                            $join->on('article_ignore.article_id', '=', 'article.id');
+                        })
+                        ->where(function ($query) use ($wetbsite_id) {
+                            $query->whereNull('article_ignore.article_id')
+                                ->orWhere('article_ignore.website_id', '!=', $wetbsite_id);
+                        })
+                        ->select('id','title','author','updated_at','introduce','islink','linkurl','copyfrom','cat_arr_id','catid')
+                        ->orderBy('updated_at', 'desc')
+                        ->limit($article_textnum)
+                        ->get()->all();
+                    foreach ($text_article as $k => $v) {
+                        $text_article[$k]->category_name = $catiall[$v->catid]['alias'];
+                        $text_article[$k]->pinyin = $catiall[$v->catid]['pinyin'];
+                        // $text_article[$k]->alias = $catiall[$v->catid]['alias'];
+                    }
+                }else{
+                    $text_article = [];
+                }
+                $catiall[$parent_category]['imgnum'] = $img_article;
+                $catiall[$parent_category]['textnum'] = $text_article;
+                $parent[$key] = $catiall[$parent_category];              
+            }else{
+                $parent[$key] = '';
+            }
+        }
     }
-    return Result::success($category);
-  }
-  /**
-   * 模块新闻加强版 
-   * @param array $data
-   * @return array
-   */
+    if(!empty($child_category)){
+        foreach($child_category as $key => $value){
+            $arr = array_map('intval', explode(',', $value));
+            $parent_category = $parent_cat[$key];
+            $child_category = $arr[0] ?? 0;
+            $article_imgnum = $arr[1] ?? 0;
+            $article_textnum = $arr[2] ?? 0;
+           
+            if($child_category != 0){
+                $all_childcat = $cat_1st_arr[$parent_category];
+                $processedChildCat = array_map(function ($v) use ($websiteInfoIndexed) {
+                    // 从 $websiteInfoIndexed 中获取对应的数据
+                    $info = $websiteInfoIndexed[$v];
+                    // 返回一个包含所需信息的数组
+                    return [
+                        'alias' => $info->alias,
+                        'category_id' => $info->category_id,
+                        'aLIas_pinyin' => $info->aLIas_pinyin,
+                        'pid' => $info->pid,
+                        'type' => $info->type,
+                        'cat_arr_id' => $info->category_arr_id ?? ['出错'],
+                        'pinyin' => $info->pinyin,
+                    ];
+                }, $all_childcat);
+             if($article_imgnum != 0){
+                $img_article = Article::where('catid', $child_category)
+                    ->where('status',1)
+                    ->where('imgurl','!=', '')
+                    ->leftJoinSub(function ($query) use ($wetbsite_id) {
+                        $query->from('article_ignore')
+                            ->where('website_id', $wetbsite_id);
+                    }, 'article_ignore', function ($join) {
+                        $join->on('article_ignore.article_id', '=', 'article.id');
+                    })
+                    ->where(function ($query) use ($wetbsite_id) {
+                        $query->whereNull('article_ignore.article_id')
+                            ->orWhere('article_ignore.website_id', '!=', $wetbsite_id);
+                    })
+                    ->select('id','title','imgurl','author','updated_at','introduce','islink','linkurl','copyfrom','cat_arr_id','catid')
+                    ->orderBy('updated_at', 'desc')
+                    ->limit($article_imgnum)
+                    ->get()->all();
+                    foreach ($img_article as $k => $v) {
+                        // var_dump($v);
+                        // var_dump($k);
+                        $img_article[$k]->category_name = $catiall[$v->catid]['alias'];
+                        $img_article[$k]->alias = $catiall[$v->catid]['alias'];
+                    }
+            }else{
+                $img_article = [];
+            }
+            if($article_textnum != 0){
+                $text_article = Article::where('catid', $child_category)
+                    ->where('status',1)
+                    ->leftJoinSub(function ($query) use ($wetbsite_id) {
+                        $query->from('article_ignore')
+                            ->where('website_id', $wetbsite_id);
+                    }, 'article_ignore', function ($join) {
+                        $join->on('article_ignore.article_id', '=', 'article.id');
+                    })
+                    ->where(function ($query) use ($wetbsite_id) {
+                        $query->whereNull('article_ignore.article_id')
+                            ->orWhere('article_ignore.website_id', '!=', $wetbsite_id);
+                    })
+                    ->select('id','title','author','updated_at','introduce','islink','linkurl','copyfrom','cat_arr_id','catid')
+                    ->orderBy('updated_at', 'desc')
+                    ->limit($article_textnum)
+                    ->get()->all();
+                foreach ($text_article as $k => $v) {
+                    // var_dump($v);
+                    // var_dump($k);
+                    $text_article[$k]->category_name = $catiall[$v->catid]['alias'];
+                    // $text_article[$k]->pinyin = $catiall[$v->catid]['pinyin'];
+                    $text_article[$k]->alias = $catiall[$v->catid]['alias'];
+                }
+            }else{
+                $text_article = [];
+            }
+            $catiall[$child_category]['all_childcat'] = $processedChildCat;
+            $catiall[$child_category]['imgnum'] = $img_article;
+            $catiall[$child_category]['textnum'] = $text_article;
+            $child[$key] = $catiall[$child_category];               
+                // var_dump($pids);
+            }else{
+                $child[$key] = '';
+            }
+        }
+    }
+    foreach($parent as $key => $value){
+        $result[$key] = $value;
+        if(!empty($child[$key])){
+            // var_dump($child[$key]);
+           
+            $result[$key]['child'] = $child[$key];
+            // $value[$key]['child'] = $child[$key];
+        }else{
+            $result[$key]['child'] = [
+                "alias" => null,
+                "category_id" => null,
+                "type" => null,
+                "pinyin" => null,
+                "all_childcat" => [],
+                "imgnum" => [],
+                "textnum" => []
+            ];
+        }
+    }
+    return Result::success($result);
+
+}
 
   /**
    * 辅助方法:获取文章列表
@@ -1939,254 +2131,291 @@ class NewsService implements NewsServiceInterface
             return Result::error("查询失败", 0); 
         }
 
-    return Result::success($result);
-  }
-  /**
-   * 获取商品详情
-   * @param array $data
-   * @return array
-   *  */
-  public function getWebsiteshopInfo(array $data): array
-  {
-    $where = [
-      'good.status' => 2,
-      'good.website_id' => $data['website_id'],
-      'good.id' => $data['id'],
-    ];
-    $goods = Good::where($where)
-      ->where('good.id', $data['id'])
-      ->leftJoin('website_category', 'website_category.category_id', 'good.catid')
-      ->select('good.*', 'website_category.alias', 'website_category.category_id')
-      ->first();
-    if (empty($goods)) {
-      return Result::error("查询失败", 0);
+        return Result::success($result);
     }
-    $goods->imgurl = json_decode($goods->imgurl, true);
-    return Result::success($goods);
-  }
-  /**
-   * 封装处理文章的路由问题
-   *  */
-  function processArticles($articles, $data)
-  {
-    // 检查 $articles 是否为数组或可迭代对象
-    if (is_array($articles) || is_iterable($articles) && !empty($articles)) {
-      return $articles->map(function ($article) use ($data) {
-        if (isset($article->cat_arr_id) && !empty($article->cat_arr_id)) {
-          $catid = $article->cat_arr_id ?? '';
-        }
-        if (isset($article->category_arr_id) && !empty($article->category_arr_id)) {
-          $catid = $article->category_arr_id ?? '';
-        }
-        // $catid = $article->cat_arr_id ||  $article->category_arr_id ?? '';
-        $level = json_decode($catid, true);
-        if (!is_array($level)) {
-          return $article;
-        } else {
-          $level = array_map('intval', $level);
+    /**
+     * 获取商品详情
+     * @param array $data
+     * @return array
+     *  */
+    public function getWebsiteshopInfo(array $data): array
+    {
+        $where = [
+            'good.status' => 2,
+            'good.website_id' => $data['website_id'],
+            'good.id' => $data['id'],
+        ]; 
+        $goods = Good::where($where)
+            ->where('good.id', $data['id'])
+            ->leftJoin('website_category', 'website_category.category_id', 'good.catid')
+            ->select('good.*','website_category.alias','website_category.category_id')
+            ->first();
+        if(empty($goods)){
+            return Result::error("查询失败", 0); 
         }
-        $pinyin = WebsiteCategory::whereIn('category_id', $level)
-          ->where($data)
-          ->orderByRaw('FIELD(category_id, ' . implode(',', $level) . ')')
-          ->pluck('aLIas_pinyin')
-          ->implode('/');
-        $article->pinyin = $pinyin ?? '';
-        return $article;
-      });
-    } else {
-      // 若 $articles 不是数组或可迭代对象,直接处理单条数据
-      $catid = $articles->cat_arr_id ?? '';
-      $level = json_decode($catid, true);
-      if (!is_array($level)) {
-        return $articles;
-      } else {
-        $level = array_map('intval', $level);
-      }
-      $pinyin = WebsiteCategory::whereIn('category_id', $level)
-        ->where($data)
-        ->orderByRaw('FIELD(category_id, ' . implode(',', $level) . ')')
-        ->pluck('aLIas_pinyin')
-        ->implode('/');
-      $articles->pinyin = $pinyin ?? '';
-      return $articles;
+        $goods->imgurl = json_decode($goods->imgurl, true);
+        return Result::success($goods);
     }
-  }
-  // 封装处理由问题
-  function processJob($job, $data)
-  {
-    return $job->map(function ($job) use ($data) {
-      $category = $job->cat_arr_id ?? '';
-      $cityid = $job->city_arr_id ?? '';
-      $city = json_decode($cityid, true);
-      $pinyin = '';
-      $level = json_decode($category, true);
-      // 路由
-      if (!empty($level) && is_array($level)) {
-        $pinyin = WebsiteCategory::whereIn('category_id', $level)
-          ->where('website_id', $data['website_id']) // 添加网站ID条件 
-          ->orderByRaw('FIELD(category_id, ' . implode(',', $level) . ')')
-          ->get(['aLIas_pinyin'])
-          ->pluck('aLIas_pinyin')
-          ->implode('/');
-        if (empty($pinyin)) {
-          $pinyin = $pinyin->aLIas_pinyin ?? '';
-        }
-        $job->pinyin = $pinyin;
-      }
-      // 取职位-城市  市??省
-      if (!empty($city) && is_array($city)) {
-        if (isset($city[1]) && !empty($city[1])) {
-          $city = District::where('id', $city[1])->first(['name']);
-          $job->city_name = $city->name ?? '';
-        } else if (isset($city[0]) && !empty($city[0])) {
-          $city = District::where('id', $city[0])->first(['name']);
-          $job->city_name = $city->name ?? '';
-        } else {
-          $job->city_name = '全国';
-        }
-      }
-      // 获取简历最后一级地区
-      if (isset($job->city_id) && !empty($job->city_id)) {
-        $city = District::where('id', $job->city_id)->first(['name']);
-        $job->hunt_cityname = $city->name ?? '';
-      }
-      // 组合详细地址
-      if (isset($job->address_arr_id) && !empty($job->address_arr_id)) {
-        $address_id = json_decode($job->address_arr_id, true) ?? [];
-        if (is_array($address_id) && !empty($address_id)) {
-          $address = District::whereIn('id', $address_id)
-            ->orderBy('level', 'asc')
-            ->get(['name'])
-            ->pluck('name')
-            ->implode('');
-          // $job->address_name = $address ?? '';
-          $job->address_name = ($address ?? '') . ($job->address ?? '');
+    /**
+     * plus  pro  处理文章路由问题
+     */
+    function processArticlePro($website_id){
+        $categorys = WebsiteCategory::where('website_id', $website_id)->get()->all();
+        $websiteInfoIndexed = array_column($categorys, null, 'category_id');
+        // 取出category_id 对应的aLIas_pinyin 
+        $categoryIds = array_column($categorys, 'category_id');
+        $categoryPIds = array_column($categorys, 'pid');
+        $aliasPinyins = array_column($categorys, 'aLIas_pinyin');
+        $cat_arr = array_combine($categoryIds, $aliasPinyins);
+        // return Result::success($categorys);
+        $catiall = [];
+        //一级所有子级的记录
+        $cat_1st_arr = [];
+        foreach ($categorys as $key => $value) {
+            $category_arr_id = json_decode($value->category_arr_id);
+            $pinyin_str = '';
+            // 算出一级  并且算出子级
+            if ($value->pid != 0) {
+                $cat_1st_arr[$value->pid][] = $value->category_id;
+            } 
+            foreach ($category_arr_id as $k => $v) {
+                $pinyin_str .= $cat_arr[$v] . '/';
+            }
+            $pinyin_str = rtrim($pinyin_str, '/');
+            $catiall[$value->category_id]['alias'] = $value->alias;
+            $catiall[$value->category_id]['category_id'] = $value->category_id;
+            $catiall[$value->category_id]['type'] = $value->type;
+            $catiall[$value->category_id]['pinyin'] = $pinyin_str; 
+            $websiteInfoIndexed[$value->category_id]->pinyin = $pinyin_str;
         }
-      }
-      // 取行业
-      if (!empty($job->hy_id) || !empty($job->industry) || !empty($job->company_hy_id || !empty($job->job_industry))) {
-        $hy_name = JobIndustry::when($job, function ($query) use ($job) {
-          if (!empty($job->industry)) {
-            $query->where('hyid', $job->industry);
-          } else if (!empty($job->hy_id)) {
-            $query->where('hyid', $job->hy_id);
-          } else if (!empty($job->company_hy_id)) {
-            $query->where('hyid', $job->company_hy_id);
-          } else {
-            $query->where('hyid', $job->job_industry);
-          }
-        })->first(['hyname']);
-        $job->hy_name = $hy_name->hyname ?? '';
-      }
-      // 取职位类别
-      if ((isset($job->zw_id) && !empty($job->zw_id)) || (isset($job->job) && !empty($job->job)) || (isset($job->job_typename) && !empty($job->job_typename))) {
-        $zwid = $job->job ?? $job->zw_id ?? $job->job_typename;
-        $zw_name = JobPosition::where('zwid', $zwid)->first(['zwname']);
-        $job->zw_name = $zw_name->zwname ?? '';
-      }
-      // 取具体职位
-      if ((isset($job->jtzw_id) && !empty($job->jtzw_id)) || (isset($job->job_name_get) && !empty($job->job_name_get)) || (isset($job->job_name) && !empty($job->job_name))) {
-        $jtzwid = $job->job_name_get ?? $job->jtzw_id ?? $job->job_name;
-        $jtzw_name = JobPosition::where('zwid', $jtzwid)->first(['zwname']);
-        $job->jtzw_name = $jtzw_name->zwname ?? '';
-      }
-      // 取工作经验
-      if (isset($job->experience) && !empty($job->experience)) {
-        $experience = JobEnum::where('egroup', 'years')->where('evalue', $job->experience)->first(['ename']);
-        $job->experience_name = $experience->ename ?? '';
-      }
-      // 取学历
-      if (isset($job->educational) && !empty($job->educational) || isset($job->school_education) && !empty($job->school_education)) {
-        $education = $job->educational ?? $job->school_education;
-        $education = JobEnum::where('egroup', 'education')->where('evalue', $education)->first(['ename']);
-        $job->education_name = $education->ename ?? '';
-      }
-      // 语言
-      if (isset($job->language) && !empty($job->language)) {
-        $language = JobEnum::where('egroup', 'language')->where('evalue', $job->language)->first(['ename']);
-        $job->language_name = $language->ename ?? '';
-      }
-      // 薪资
-      if (isset($job->salary) && !empty($job->salary)) {
-        $salary = JobEnum::where('egroup', 'income')->where('evalue', $job->salary)->first(['ename']);
-        $job->salary_name = $salary->ename ?? '';
-      }
-      // 职位性质
-      if (isset($job->nature_id) && !empty($job->nature_id)) {
-        $job_nature = JobEnum::where('egroup', 'nature')->where('evalue', $job->nature_id)->first(['ename']);
-        $job->job_nature_name = $job_nature->ename ?? '';
-      }
-      // 公司规模
-      if (isset($job->company_size) && !empty($job->company_size)) {
-        $company_size = JobEnum::where('egroup', 'cosize')->where('evalue', $job->company_size)->first(['ename']);
-        $job->company_size_name = $company_size->ename ?? '';
-      }
-      // 公司性质
-      if (isset($job->company_nature) && !empty($job->company_nature)) {
-        $company_nature = JobNature::where('id', $job->company_nature)->first(['nature_name']);
-        $job->company_nature_name = $company_nature->nature_name ?? '';
-      }
-      // $job->pinyin = $pinyin;
-      return $job;
-    });
-  }
-  /**
-   * 获取书籍模块
-   * @param array $data
-   * @return array
-   *  */
-  public function getWebsiteBook(array $data): array
-  {
-    $input['id'] = $data['id'];
-    $input['website_id'] = $data['website_id'];
-    // 将 JSON 字符串转换为 PHP 数组
-    $data = json_decode($input['id'], true);
-    // 使用 array_map 处理每个元素
-    $result = array_map(function ($item) use ($input) {
-      // 检查parent元素是否存在且不是undefined
-      if (isset($item['parent']) && $item['parent'] != 'undefined' && $item['parent'] != "") {
-        list($parentCatId, $parentImgNum, $parentTextNum) = explode(',', $item['parent']);
-        $website = [
-          'website_id' => $input['website_id'],
+        return [
+            'cat_1st_arr' => $cat_1st_arr,
+            'catiall' => $catiall,
+            'websiteInfoIndexed' => $websiteInfoIndexed,
         ];
-        // 查询栏目名称
-        $category = WebsiteCategory::where('category_id', $parentCatId)->where($website)->first(['alias', 'category_id', 'aLIas_pinyin']);
-        if (empty($category)) {
-          $parent_alias = '';
-          $parent_pinyin = null;
-          $imgBooks = [];
-          $textBooks = [];
+
+    }
+    /**
+     * 封装处理文章的路由问题
+     *  */
+    function processArticles($articles, $data) {
+        // 检查 $articles 是否为数组或可迭代对象
+        if (is_array($articles) || is_iterable($articles) &&!empty($articles)) {
+            return $articles->map(function ($article) use ($data) {
+                if(isset($article->cat_arr_id) &&!empty($article->cat_arr_id)){
+                    $catid = $article->cat_arr_id?? '';
+                }
+                if(isset($article->category_arr_id) &&!empty($article->category_arr_id)){
+                    $catid = $article->category_arr_id?? '';
+                }
+                // $catid = $article->cat_arr_id ||  $article->category_arr_id ?? '';
+                $level = json_decode($catid, true);
+                if (!is_array($level)) {
+                    return $article;
+                } else {
+                    $level = array_map('intval', $level);
+                }
+                $pinyin = WebsiteCategory::whereIn('category_id', $level)
+                    ->where($data)
+                    ->orderByRaw('FIELD(category_id, '. implode(',', $level). ')')
+                    ->pluck('aLIas_pinyin')
+                    ->implode('/');
+                $article->pinyin = $pinyin ?? '';
+                return $article;
+            });
         } else {
-          $parent_alias = $category->alias ?? '';
-          $parent_pinyin = $category->aLIas_pinyin ? $category->aLIas_pinyin : null;
-          // 查找子分类ID数组
-          $childCategoryIds = WebsiteCategory::where('pid', $parentCatId)->where($website)->pluck('category_id')->toArray();
-          array_push($childCategoryIds, $parentCatId);
-          $childCategoryIds = json_encode(array_values(array_unique($childCategoryIds)));
-          if ($parentImgNum != 0) {
-            // 查询图片新闻
-            $imgBooks = Book::where(function ($query) use ($parentCatId) {
-              $query->whereRaw("JSON_CONTAINS(cat_arr_id, '\"$parentCatId\"')")
-                ->orWhereRaw("JSON_CONTAINS(cat_arr_id, '$parentCatId')");
-            })
-              ->where('book.status', 2)
-              ->where('book.img_url', '!=', '')
-              ->leftJoin('website_category', function ($join) use ($website) {
-                $join->on('book.cat_id', '=', 'website_category.category_id')
-                  ->where('website_category.website_id', '=', $website['website_id']);
-              })
-              ->select(
-                'book.id',
-                'book.title',
-                'book.img_url',
-                'book.price',
-                'book.market_price',
-                'book.description',
-                'book.cat_id',
-                'book.description',
-                'book.updated_at',
-                'website_category.alias as category_name',
-                DB::raw("CASE WHEN book.cat_id = $parentCatId THEN '$parent_pinyin' 
+            // 若 $articles 不是数组或可迭代对象,直接处理单条数据
+            $catid = $articles->cat_arr_id?? '';
+            $level = json_decode($catid, true);
+            if (!is_array($level)) {
+                return $articles;
+            } else {
+                $level = array_map('intval', $level);
+            }
+            $pinyin = WebsiteCategory::whereIn('category_id', $level)
+                ->where($data)
+                ->orderByRaw('FIELD(category_id, '. implode(',', $level). ')')
+                ->pluck('aLIas_pinyin')
+                ->implode('/');
+            $articles->pinyin = $pinyin ?? '';
+            return $articles;
+        }
+    }
+    // 封装处理由问题
+    function processJob($job, $data) {
+        return $job->map(function ($job) use ($data) {
+            $category = $job->cat_arr_id?? '';
+            $cityid = $job->city_arr_id?? '';
+            $city = json_decode($cityid, true);
+            $pinyin = '';
+            $level = json_decode($category, true);
+            // 路由
+            if(!empty($level) && is_array($level)){
+                $pinyin = WebsiteCategory::whereIn('category_id', $level)
+                ->where('website_id', $data['website_id']) // 添加网站ID条件 
+                ->orderByRaw('FIELD(category_id, '. implode(',', $level). ')')
+                ->get(['aLIas_pinyin'])
+                ->pluck('aLIas_pinyin')
+                ->implode('/');
+                if(empty($pinyin)){
+                    $pinyin = $pinyin->aLIas_pinyin?? '';
+                }
+                $job->pinyin = $pinyin;
+            }
+            // 取职位-城市  市??省
+            if(!empty($city) && is_array($city)){
+                if(isset($city[1] ) && !empty($city[1])){
+                    $city = District::where('id', $city[1])->first(['name']);
+                    $job->city_name = $city->name?? '';
+                }else if(isset($city[0] ) && !empty($city[0])){
+                    $city = District::where('id', $city[0])->first(['name']);
+                    $job->city_name = $city->name?? '';
+                }else{
+                    $job->city_name = '全国';
+                }
+            }
+            // 获取简历最后一级地区
+            if(isset($job->city_id) &&!empty($job->city_id)){
+                $city = District::where('id', $job->city_id)->first(['name']);
+                $job->hunt_cityname = $city->name?? '';
+            }
+            // 组合详细地址
+            if(isset($job->address_arr_id) && !empty($job->address_arr_id)){
+                $address_id = json_decode($job->address_arr_id, true) ?? [];
+                if(is_array($address_id) && !empty($address_id)){
+                    $address = District::whereIn('id', $address_id)
+                    ->orderBy('level', 'asc')
+                    ->get(['name'])
+                    ->pluck('name')
+                    ->implode('');
+                    // $job->address_name = $address ?? '';
+                    $job->address_name = ($address ?? '') . ($job->address ?? '');
+                }
+            }
+            // 取行业
+            if(!empty($job->hy_id) || !empty($job->industry) || !empty($job->company_hy_id || !empty($job->job_industry))){
+                $hy_name = JobIndustry::when($job, function ($query) use ($job) {
+                    if(!empty($job->industry)){
+                        $query->where('hyid', $job->industry);
+                    }else if(!empty($job->hy_id)){
+                        $query->where('hyid', $job->hy_id);
+                    }else if(!empty($job->company_hy_id)){
+                        $query->where('hyid', $job->company_hy_id);
+                    } else{
+                        $query->where('hyid', $job->job_industry);
+                    }
+                })->first(['hyname']);
+                $job->hy_name = $hy_name->hyname?? '';
+            }
+            // 取职位类别
+            if((isset($job->zw_id) && !empty($job->zw_id)) || (isset($job->job) && !empty($job->job)) || (isset($job->job_typename) && !empty($job->job_typename))){
+                $zwid = $job->job ?? $job->zw_id ?? $job->job_typename;
+                $zw_name = JobPosition::where('zwid', $zwid)->first(['zwname']);
+                $job->zw_name = $zw_name->zwname?? '';
+            }
+            // 取具体职位
+            if((isset($job->jtzw_id) &&!empty($job->jtzw_id)) || (isset($job->job_name_get) && !empty($job->job_name_get)) || (isset($job->job_name) && !empty($job->job_name))){
+                $jtzwid = $job->job_name_get ?? $job->jtzw_id ?? $job->job_name;
+                $jtzw_name = JobPosition::where('zwid', $jtzwid)->first(['zwname']);
+                $job->jtzw_name = $jtzw_name->zwname?? '';
+            }
+            // 取工作经验
+            if(isset($job->experience) &&!empty($job->experience)){
+                $experience = JobEnum::where('egroup','years')->where('evalue',$job->experience)->first(['ename']);
+                $job->experience_name = $experience->ename?? '';
+            }
+            // 取学历
+            if(isset($job->educational) &&!empty($job->educational) || isset($job->school_education) && !empty($job->school_education)) {
+                $education = $job->educational ?? $job->school_education;
+                $education = JobEnum::where('egroup','education')->where('evalue',$education)->first(['ename']);
+                $job->education_name = $education->ename?? '';
+            }
+            // 语言
+            if(isset($job->language) &&!empty($job->language)){
+                $language = JobEnum::where('egroup','language')->where('evalue',$job->language)->first(['ename']);
+                $job->language_name = $language->ename?? '';
+            }
+            // 薪资
+            if(isset($job->salary) &&!empty($job->salary)){
+                $salary = JobEnum::where('egroup','income')->where('evalue',$job->salary)->first(['ename']);
+                $job->salary_name = $salary->ename?? '';
+            }
+            // 职位性质
+            if(isset($job->nature_id) &&!empty($job->nature_id)){
+                $job_nature = JobEnum::where('egroup','nature')->where('evalue',$job->nature_id)->first(['ename']);
+                $job->job_nature_name = $job_nature->ename?? '';
+            }
+            // 公司规模
+            if(isset($job->company_size) &&!empty($job->company_size)){
+                $company_size = JobEnum::where('egroup','cosize')->where('evalue',$job->company_size)->first(['ename']);
+                $job->company_size_name = $company_size->ename?? '';
+            }
+            // 公司性质
+            if(isset($job->company_nature) && !empty($job->company_nature)){
+                $company_nature = JobNature::where('id',$job->company_nature)->first(['nature_name']);
+                $job->company_nature_name = $company_nature->nature_name?? '';
+            }
+            // $job->pinyin = $pinyin;
+            return $job;
+        });
+    }
+    /**
+     * 获取书籍模块
+     * @param array $data
+     * @return array
+     *  */
+    public function getWebsiteBook(array $data): array
+    {
+        $input['id'] = $data['id'];
+        $input['website_id'] = $data['website_id'];
+        // 将 JSON 字符串转换为 PHP 数组
+        $data = json_decode($input['id'], true);
+        // 使用 array_map 处理每个元素
+        $result = array_map(function ($item) use ($input) {
+            // 检查parent元素是否存在且不是undefined
+            if (isset($item['parent']) && $item['parent'] != 'undefined' && $item['parent']!= "") {
+                list($parentCatId, $parentImgNum, $parentTextNum) = explode(',', $item['parent']);                                                           
+                $website = [
+                    'website_id' => $input['website_id'],
+                ];
+                // 查询栏目名称
+                $category = WebsiteCategory::where('category_id', $parentCatId)->where($website)->first(['alias', 'category_id','aLIas_pinyin']);
+                if(empty($category)){
+                    $parent_alias = '';
+                    $parent_pinyin = null;
+                    $imgBooks = [];
+                    $textBooks = [];
+                }else{
+                    $parent_alias = $category->alias ?? '';
+                    $parent_pinyin = $category->aLIas_pinyin ? $category->aLIas_pinyin : null;
+                    // 查找子分类ID数组
+                    $childCategoryIds = WebsiteCategory::where('pid', $parentCatId)->where($website)->pluck('category_id')->toArray();
+                    array_push($childCategoryIds,$parentCatId);
+                    $childCategoryIds = json_encode(array_values(array_unique($childCategoryIds)));
+                    if($parentImgNum!=0){
+                        // 查询图片新闻
+                        $imgBooks = Book::where(function($query) use ($parentCatId) {
+                            $query->whereRaw("JSON_CONTAINS(cat_arr_id, '\"$parentCatId\"')")
+                                    ->orWhereRaw("JSON_CONTAINS(cat_arr_id, '$parentCatId')");
+                            })
+                            ->where('book.status', 2)
+                            ->where('book.img_url', '!=', '')
+                            ->leftJoin('website_category', function($join) use ($website) {
+                                $join->on('book.cat_id', '=', 'website_category.category_id')
+                                    ->where('website_category.website_id', '=', $website['website_id']);
+                            })
+                            ->select(
+                                'book.id',
+                                'book.title',
+                                'book.img_url',
+                                'book.price',
+                                'book.market_price',
+                                'book.description',
+                                'book.cat_id',
+                                'book.description',
+                                'book.updated_at',
+                                'website_category.alias as category_name',
+                                DB::raw("CASE WHEN book.cat_id = $parentCatId THEN '$parent_pinyin' 
                                         ELSE CONCAT('$parent_pinyin', '/', website_category.aLIas_pinyin) END as pinyin")
               )
               ->orderBy('updated_at', 'desc')
@@ -5656,207 +5885,6 @@ class NewsService implements NewsServiceInterface
       ->toArray();
     return Result::success($articlesList);
   }
-
-  /**
-   * 模块新闻加强版 
-   * @param array $data
-   * @return array
-   */
-  public function getWebsiteAllArticle(array $data): array
-  {
-
-
-
-    // 修正传入的字符串,将单引号替换为双引号
-    $input['id'] = $data['id'];
-    $input['website_id'] = $data['website_id'];
-    // 将 JSON 字符串转换为 PHP 数组
-    $data = json_decode($input['id'], true);
-    // 使用 array_map 处理每个元素
-    $result = array_map(function ($item) use ($input) {
-      // 检查parent元素是否存在且不是undefined
-      if (isset($item['parent']) && $item['parent'] != 'undefined' && $item['parent'] != "") {
-        $count = explode(',', $item['parent']);
-        if (count($count) != 3) {
-          return Result::error("参数错误", 0);
-        }
-        list($parentCatId, $parentImgNum, $parentTextNum) = explode(',', $item['parent']);
-        $website = [
-          'website_id' => $input['website_id'],
-        ];
-        // 查询栏目名称
-        $categroy = WebsiteCategory::where('category_id', $parentCatId)->where($website)->first(['alias', 'category_id', 'aLIas_pinyin', 'type']);
-        // 查询图片新闻
-        if (isset($parentImgNum) && $parentImgNum != 0 && !empty($categroy)) {
-          $imgArticles = Article::where('article.status', 1)
-            ->where(function ($query) use ($parentCatId) {
-              $query->whereRaw("JSON_CONTAINS(cat_arr_id, '\"$parentCatId\"')")
-                ->orWhereRaw("JSON_CONTAINS(cat_arr_id, '$parentCatId')");
-            })
-            ->where(function ($query) use ($website) {
-              $query->where(function ($subQuery) use ($website) {
-                $subQuery->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($website['website_id']) . "') = 1")
-                  ->orWhereNull("ignore_ids");
-              });
-            })
-            ->where('imgurl', '!=', '')
-            ->leftJoin('website_category', function ($join) use ($website) {
-              $join->on('article.catid', '=', 'website_category.category_id')
-                ->where('website_category.website_id', '=', $website['website_id']);
-            })
-            ->select(
-              'article.id',
-              'article.title',
-              'article.imgurl',
-              'article.author',
-              'article.updated_at',
-              'article.introduce',
-              'article.islink',
-              'article.linkurl',
-              'article.copyfrom',
-              'article.cat_arr_id',
-              'article.catid',
-              'website_category.alias as category_name',
-            )
-            ->orderBy('updated_at', 'desc')
-            ->limit($parentImgNum)
-            ->get();
-          //调取封装路由的方法,处理新闻路由   
-          if (!empty($imgArticles)) {
-            $imgArticles = $this->processArticles($imgArticles, $website);
-          }
-        }
-        // 查询文字新闻
-        if (isset($parentTextNum) && $parentTextNum != 0 && !empty($categroy)) {
-          $textArticles = [];
-          $textArticles = Article::where('article.status', 1)
-            ->where(function ($query) use ($parentCatId) {
-              $query->whereRaw("JSON_CONTAINS(cat_arr_id, '\"$parentCatId\"')")
-                ->orWhereRaw("JSON_CONTAINS(cat_arr_id, '$parentCatId')");
-            })
-            ->where(function ($query) use ($website) {
-              $query->where(function ($subQuery) use ($website) {
-                $subQuery->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($website['website_id']) . "') = 1")
-                  ->orWhereNull("ignore_ids");
-              });
-            })
-            ->leftJoin('website_category', function ($join) use ($website) {
-              $join->on('article.catid', '=', 'website_category.category_id')
-                ->where('website_category.website_id', '=', $website['website_id']);
-            })
-            ->select(
-              'article.id',
-              'article.title',
-              'article.author',
-              'article.updated_at',
-              'article.cat_arr_id',
-              'article.introduce',
-              'article.islink',
-              'article.linkurl',
-              'article.copyfrom',
-              'article.catid',
-              'website_category.alias as category_name',
-            )
-            ->orderBy('updated_at', 'desc')
-            ->limit($parentTextNum)
-            ->get();
-          if (!empty($textArticles)) {
-            $textArticles = $this->processArticles($textArticles, $website);
-          }
-        }
-      }
-      $resultItem = [
-        'alias' =>  $categroy ? $categroy->alias : null,
-        'category_id' =>  $categroy ? $categroy->category_id : null,
-        'pinyin' =>  $categroy ? $categroy->aLIas_pinyin : null,
-        'imgnum' => $imgArticles ?? [],
-        'textnum' => $textArticles ?? [],
-      ];
-      if (isset($item['child']) && $item['child'] != 'undefined' && $item['child'] != "") {
-        list($childCatId, $childImgNum, $childTextNum) = explode(',', $item['child']);
-        $childCategory = WebsiteCategory::where($website)
-          ->where("category_id", $childCatId)
-          ->whereRaw("JSON_CONTAINS(category_arr_id, '" . intval($parentCatId) . "') = 1")
-          ->first(['alias', 'category_id', 'aLIas_pinyin', 'pid', 'type', 'category_arr_id as cat_arr_id']);
-        if (!empty($childCategory)) {
-          $childCategory = $this->processArticles($childCategory, $website);
-          // 查询此层级的所有子栏目
-          $all_childcat = WebsiteCategory::where($website)
-            ->where("pid", $childCategory['pid'])
-            ->whereRaw("JSON_CONTAINS(category_arr_id, '" . intval($parentCatId) . "') = 1")
-            ->get(['alias', 'category_id', 'aLIas_pinyin', 'pid', 'type', 'category_arr_id as cat_arr_id']);
-          $all_childcat = $this->processArticles($all_childcat, $website);
-          // 查询子栏目图片新闻
-          if (isset($childImgNum) && $childImgNum != 0) {
-            $childImgArticles = Article::where('catid', $childCatId)
-              ->where('status', 1)
-              ->where(function ($query) use ($website) {
-                $query->where(function ($subQuery) use ($website) {
-                  $subQuery->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($website['website_id']) . "') = 1");
-                })->orWhereNull("ignore_ids");
-              })
-              ->select(
-                'article.id',
-                'article.title',
-                'article.imgurl',
-                'article.author',
-                'article.updated_at',
-                'article.introduce',
-                'article.islink',
-                'article.linkurl',
-                'article.catid',
-                'article.cat_arr_id',
-                'article.copyfrom',
-              )
-              ->where('imgurl', '!=', '')
-              ->orderBy('updated_at', 'desc')
-              ->limit($childImgNum)
-              ->get();
-            $childImgArticles = $this->processArticles($childImgArticles, $website);
-          }
-          // 查询子栏目文字新闻
-          if (isset($childTextNum) && $childTextNum != 0) {
-            $childTextArticles = Article::where('catid', $childCatId)
-              ->where('status', 1)
-              ->where(function ($query) use ($website) {
-                $query->where(function ($subQuery) use ($website) {
-                  $subQuery->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($website['website_id']) . "') = 1");
-                })->orWhereNull("ignore_ids");
-              })
-              ->select(
-                'article.id',
-                'article.title',
-                'article.author',
-                'article.updated_at',
-                'article.introduce',
-                'article.islink',
-                'article.linkurl',
-                'article.catid',
-                'article.cat_arr_id',
-                'article.copyfrom',
-              )
-              ->orderBy('updated_at', 'desc')
-              ->limit($childTextNum)
-              ->get();
-            $childTextArticles = $this->processArticles($childTextArticles, $website);
-          }
-        }
-        $resultItem['child'] = [
-          'alias' => $childCategory ? $childCategory->alias : null,
-          'category_id' => $childCategory ? $childCategory->category_id : null,
-          'type' => $childCategory ? $childCategory->type : null,
-          'pinyin' => $childCategory ? $childCategory->pinyin : null,
-          'all_childcat' => $all_childcat ?? [],
-          'imgnum' => $childImgArticles ?? [],
-          'textnum' => $childTextArticles ?? [],
-        ];
-      } else {
-        $resultItem['child'] = [];
-      }
-      return $resultItem;
-    }, $data);
-    return Result::success($result);
-  }
   /**
      * 企业管理
      * @param array $data