LiuJ преди 8 месеца
родител
ревизия
690881ba17
променени са 1 файла, в които са добавени 5005 реда и са изтрити 5000 реда
  1. 5005 5000
      app/JsonRpc/NewsService.php

+ 5005 - 5000
app/JsonRpc/NewsService.php

@@ -57,28 +57,28 @@ use Hyperf\Di\Annotation\Inject;
 class NewsService implements NewsServiceInterface
 {
 
-    #[Inject]
-    protected Redis $redis;
-    /**
-     * 获取导航池列表
-     * @param array $data
-     * @return array
-     */
-    public function getCategoryList(array $data): array
-    {
-        $search = $data['name'] ?? '';
-        $page = (int)($data['page'] ?? 1);
-        $perPage = (int)($data['pageSize'] ?? 10);
-
-        // 1. 查出所有匹配的分类id
-        if ($search) {
-            $matchedIds = Category::where('name', 'like', "%{$search}%")->orderBy('updated_at', 'desc')->pluck('id')->toArray();
-            if (empty($matchedIds)) {
-                return Result::success(['rows' => [], 'total' => 0]);
-            }
-            // 2. 递归查所有父级,直到一级分类
-            $idsStr = implode(',', $matchedIds);
-            $sql = "
+  #[Inject]
+  protected Redis $redis;
+  /**
+   * 获取导航池列表
+   * @param array $data
+   * @return array
+   */
+  public function getCategoryList(array $data): array
+  {
+    $search = $data['name'] ?? '';
+    $page = (int)($data['page'] ?? 1);
+    $perPage = (int)($data['pageSize'] ?? 10);
+
+    // 1. 查出所有匹配的分类id
+    if ($search) {
+      $matchedIds = Category::where('name', 'like', "%{$search}%")->orderBy('updated_at', 'desc')->pluck('id')->toArray();
+      if (empty($matchedIds)) {
+        return Result::success(['rows' => [], 'total' => 0]);
+      }
+      // 2. 递归查所有父级,直到一级分类
+      $idsStr = implode(',', $matchedIds);
+      $sql = "
                 WITH RECURSIVE parents AS (
                     SELECT * FROM category WHERE id IN ($idsStr)
                     UNION ALL
@@ -87,29 +87,29 @@ class NewsService implements NewsServiceInterface
                 )
                 SELECT * FROM parents
             ";
-            $parents = Db::select($sql);
-            $parentIds = [];
-            foreach ($parents as $row) {
-                if ($row->pid == 0) {
-                    $parentIds[] = $row->id;
-                }
-            }
-            $parentIds = array_unique($parentIds);
-        } else {
-            // 没有搜索,一级分类就是根
-            $parentIds = Category::where('pid', 0)->orderBy('updated_at', 'desc')->pluck('id')->toArray();
-        }
+      $parents = Db::select($sql);
+      $parentIds = [];
+      foreach ($parents as $row) {
+        if ($row->pid == 0) {
+          $parentIds[] = $row->id;
+        }
+      }
+      $parentIds = array_unique($parentIds);
+    } else {
+      // 没有搜索,一级分类就是根
+      $parentIds = Category::where('pid', 0)->orderBy('updated_at', 'desc')->pluck('id')->toArray();
+    }
 
-        // 3. 一级分类分页
-        $total = count($parentIds);
-        $parentIds = array_slice($parentIds, ($page - 1) * $perPage, $perPage);
-        if (empty($parentIds)) {
-            return Result::success(['rows' => [], 'total' => $total]);
-        }
+    // 3. 一级分类分页
+    $total = count($parentIds);
+    $parentIds = array_slice($parentIds, ($page - 1) * $perPage, $perPage);
+    if (empty($parentIds)) {
+      return Result::success(['rows' => [], 'total' => $total]);
+    }
 
-        // 4. 递归查所有子孙
-        $idsStr = implode(',', $parentIds);
-        $sql = "
+    // 4. 递归查所有子孙
+    $idsStr = implode(',', $parentIds);
+    $sql = "
             WITH RECURSIVE subcategories AS (
                 SELECT * FROM category WHERE id IN ($idsStr)
                 UNION ALL
@@ -118,5158 +118,5163 @@ class NewsService implements NewsServiceInterface
             )
             SELECT * FROM subcategories ORDER BY updated_at DESC
         ";
-        $allCategories = Db::select($sql);
-
-        // 5. 组装树结构
-        $categoryMap = [];
-        foreach ($allCategories as $cat) {
-            $cat = (array)$cat;
-            $cat['children'] = [];
-            $categoryMap[$cat['id']] = $cat;
-        }
-        foreach ($categoryMap as $id => &$cat) {
-            if ($cat['pid'] && isset($categoryMap[$cat['pid']])) {
-                $categoryMap[$cat['pid']]['children'][] = &$cat;
-            }
-        }
-        unset($cat);
-
-        $categoryTree = [];
-        foreach ($parentIds as $id) {
-            if (isset($categoryMap[$id])) {
-                $categoryTree[] = $categoryMap[$id];
-            }
-        }
+    $allCategories = Db::select($sql);
+
+    // 5. 组装树结构
+    $categoryMap = [];
+    foreach ($allCategories as $cat) {
+      $cat = (array)$cat;
+      $cat['children'] = [];
+      $categoryMap[$cat['id']] = $cat;
+    }
+    foreach ($categoryMap as $id => &$cat) {
+      if ($cat['pid'] && isset($categoryMap[$cat['pid']])) {
+        $categoryMap[$cat['pid']]['children'][] = &$cat;
+      }
+    }
+    unset($cat);
 
-        return Result::success([
-            'rows' => $categoryTree,
-            'total' => $total,
-        ]);
+    $categoryTree = [];
+    foreach ($parentIds as $id) {
+      if (isset($categoryMap[$id])) {
+        $categoryTree[] = $categoryMap[$id];
+      }
     }
 
-    private function findMatchedCategories($search)
-    {
-        if ($search) {
-            return Category::where('name', 'like', "%{$search}%")
-                ->orderBy('updated_at', 'desc')
-                ->get();
+    return Result::success([
+      'rows' => $categoryTree,
+      'total' => $total,
+    ]);
+  }
+
+  private function findMatchedCategories($search)
+  {
+    if ($search) {
+      return Category::where('name', 'like', "%{$search}%")
+        ->orderBy('updated_at', 'desc')
+        ->get();
+    }
+    return Category::orderBy('updated_at', 'desc') // 按 updated_at 字段倒序排序
+      ->get();
+  }
+
+  private function findAllParents($categories)
+  {
+    $allCategories = [];
+    foreach ($categories as $category) {
+      $parentId = $category->pid;
+      while ($parentId > 0) {
+        $parent = Category::find($parentId);
+        if ($parent) {
+          $allCategories[$parent->id] = $parent;
+          $parentId = $parent->pid;
+        } else {
+          break;
         }
-        return Category::orderBy('updated_at', 'desc') // 按 updated_at 字段倒序排序
-            ->get();
+      }
+      $allCategories[$category->id] = $category;
+    }
+    return array_values($allCategories);
+  }
+
+  private function buildCategoryTree($category, $allRequiredCategories)
+  {
+    $categoryData = $category->toArray();
+    $children = [];
+    foreach ($allRequiredCategories as $c) {
+      if ($c->pid === $category->id) {
+        $children[] = $this->buildCategoryTree($c, $allRequiredCategories);
+      }
+    }
+    if (!empty($children)) {
+      $categoryData['children'] = $children;
+    }
+    return $categoryData;
+  }
+
+  public function myCategoryList(array $data): array
+  {
+    $sszq = $data['sszq'] ?? '';
+    unset($data['sszq']);
+    //1,2,3 根据这些webid,。从website_category表中取出对应的分类id,然后从category表中取出分类信息
+    $catorytids = WebsiteCategory::whereIn('website_id', explode(',', $sszq))->get()->pluck('category_id')->toArray();
+    $where[] = [
+      'pid',
+      '=',
+      $data['pid'],
+    ];
+    if (isset($data['name'])) {
+      array_push($where, ['category.name', 'like', '%' . $data['name'] . '%']);
+    }
+    var_dump($where);
+    //根据分类id,从category表中取出分类信息
+    $result = Category::where($where)
+      ->whereIn('category.id', $catorytids)
+      ->select('category.*', 'category.id as category_id')->get();
+    if (empty($result)) {
+      return Result::error("没有栏目数据");
+    }
+    return Result::success($result);
+  }
+  /**
+   * @param array $data
+   * @return array
+   */
+  public function categoryList(array $data): array
+  {
+    $where[] = [
+      'pid',
+      '=',
+      $data['pid']
+    ];
+    if (isset($data['name'])) {
+      array_push($where, ['category.name', 'like', '%' . $data['name'] . '%']);
+    }
+    var_dump($where);
+    $result =  Category::where($where)->select('category.*', 'category.id as category_id')->get();
+    if (empty($result)) {
+      return Result::error("没有栏目数据");
+    }
+    return Result::success($result);
+  }
+  /**
+   * @param array $data
+   * @return array
+   */
+  public function addCategory(array $data): array
+  {
+    if (isset($data['id'])) {
+      unset($data['id']);
+    }
+    $id = Category::insertGetId($data);
+    if (empty($id)) {
+      return Result::error("添加失败");
+    }
+    return Result::success(['id' => $id]);
+  }
+
+  /**
+   * @param array $data
+   * @return array
+   */
+  public function delCategory(array $data): array
+  {
+    Db::beginTransaction();
+    try {
+      $categoryList = Category::where(['pid' => $data['id']])->get();
+      if ($categoryList->toArray()) {
+        Db::rollBack();
+        return Result::error("分类下面有子分类不能删除");
+      }
+      $articleList = Article::where(['catid' => $data['id']])->get();
+      if ($articleList->toArray()) {
+        Db::rollBack();
+        return Result::error("分类下面有资讯不能删除");
+      }
+      $result = Category::where($data)->delete();
+      WebsiteCategory::where(['category_id' => $data['id']])->delete();
+      if (!$result) {
+        return Result::error("删除失败");
+      }
+      return Result::success($result);
+      Db::commit();
+    } catch (\Exception $e) {
+      Db::rollBack();
+      return Result::error("删除失败");
+    }
+  }
+
+  /**
+   * @param array $data
+   * @return array
+   */
+  public function updateCategory(array $data): array
+  {
+    $where = [
+      'id' => $data['id'],
+    ];
+    $result = Category::where($where)->update($data);
+    if ($result) {
+      return Result::success($result);
+    } else {
+      return Result::error("更新失败");
+    }
+  }
+
+  /**
+   * 获取导航池信息
+   * @param array $data
+   * @return array
+   */
+  public function getCategoryInfo(array $data): array
+  {
+    $where = [
+      'id' => $data['id'],
+    ];
+    $result = Category::where($where)->first();
+    if ($result) {
+      return Result::success($result);
+    } else {
+      return Result::error("更新失败");
+    }
+  }
+  /**
+   * @param array $data
+   * @return array
+   */
+  public function getArticleList(array $data): array
+  {
+    //判断是否是管理员'1:个人会员 2:政务会员 3:企业会员 4:调研员 10000:管理员 20000:游客(小程序)'
+    $type_id = $data['type_id'];
+    unset($data['type_id']);
+    $user_id = $data['user_id'];
+    unset($data['user_id']);
+
+    $where = [];
+    $status1 = [];
+    if (isset($data['id']) && $data['id']) {
+      array_push($where, ['article.id', '=', $data['id']]);
+    }
+    if (isset($data['title']) && $data['title']) {
+      array_push($where, ['article.title', 'like', '%' . $data['title'] . '%']);
+    }
+    if (isset($data['category_name']) && $data['category_name']) {
+      array_push($where, ['category.name', 'like', '%' . $data['category_name'] . '%']);
+    }
+    if (isset($data['author']) && $data['author']) {
+      array_push($where, ['article.author', '=', $data['author']]);
+    }
+    if (isset($data['islink']) && $data['islink'] !== "") {
+      array_push($where, ['article.islink', '=', $data['islink']]);
+    }
+    if (isset($data['status']) && $data['status'] !== "") {
+      array_push($where, ['article.status', '=', $data['status']]);
+    }
+    if (isset($data['status1'])) {
+      $status1 = json_decode(($data['status1']));
+    }
+    //不是管理员展示个人数据;
+    if ($type_id != 10000) {
+      $where[] = ['article.admin_user_id', '=', $user_id];
     }
 
-    private function findAllParents($categories)
-    {
-        $allCategories = [];
-        foreach ($categories as $category) {
-            $parentId = $category->pid;
-            while ($parentId > 0) {
-                $parent = Category::find($parentId);
-                if ($parent) {
-                    $allCategories[$parent->id] = $parent;
-                    $parentId = $parent->pid;
-                } else {
-                    break;
-                }
-            }
-            $allCategories[$category->id] = $category;
-        }
-        return array_values($allCategories);
+    $rep = Article::where($where)
+      ->whereNotIn('article.status', [404])
+      ->when($status1, function ($query) use ($status1) {
+        if (isset($status1) && $status1) {
+          $query->whereIn('article.status', $status1);
+        }
+      })
+      ->leftJoin('category', 'article.catid', 'category.id')
+      ->leftJoin('website_category', function ($join) {
+        $join->on('article.web_site_id', '=', 'website_category.website_id')
+          ->on('article.catid', '=', 'website_category.category_id');
+      })
+      ->select("article.*", "category.name as category_name", "website_category.alias")
+      ->orderBy("article.updated_at", "desc")
+      ->limit($data['pageSize'])
+      ->offset(($data['page'] - 1) * $data['pageSize'])->get();
+    $count = Article::where($where)->whereNotIn('article.status', [404])
+      ->when($status1, function ($query) use ($status1) {
+        if (isset($status1) && $status1) {
+          $query->whereIn('article.status', $status1);
+        }
+      })
+      ->leftJoin('category', 'article.catid', 'category.id')->count();
+    $data = [
+      'rows' => $rep->toArray(),
+      'count' => $count,
+    ];
+    if (empty($rep)) {
+      return Result::error("没有信息数据");
     }
+    return Result::success($data);
+  }
+
+  /**
+   * @param array $data
+   * @return array
+   */
+  public function addArticle(array $data): array
+  {
+    var_dump($data, '----------12-----------1');
+    unset($data['user_type']);
+    unset($data['nav_add_pool_id']);
+    // unset($data['commend_id']);
+    // $data['cat_arr_id'] = is_string($data['cat_arr_id']) ? json_encode($data['cat_arr_id']) : '';
+    Db::beginTransaction();
+    try {
+      //处理投票
+      $is_survey = isset($data['is_survey']) ? $data['is_survey'] : 0;
+      $survey_name = isset($data['survey_name']) ? $data['survey_name'] : '';
+      $suvey_array = isset($data['suvey_array']) ? $data['suvey_array'] : '';
+      $website_id = isset($data['website_id']) ? $data['website_id'] : 2;
+      unset($data['is_survey']);
+      unset($data['survey_name']);
+      unset($data['suvey_array']);
+      // unset($data['website_id']);
+      // unset($data['web_site_id']);
+      // $data['web_site_id'] = is_array($data['web_site_id']) ? json_encode($data['web_site_id']) : ($data['web_site_id']);
+      if ($data['hits'] == '') {
+        $data['hits'] = 0;
+      }
+      if ($data['is_original'] == '') {
+        $data['is_original'] = 0;
+      }
+      if ($data['status'] == '') {
+        $data['status'] = 0;
+      }
+      $articleData = $data;
+      unset($articleData['content']);
+      //自动处理缩略图、关键字、描述
+      if ($articleData['imgurl'] == '') {
+        //如果没有图,设置level=0
+        $levelArr = json_decode($articleData['level'], true);
+        var_dump($levelArr, '----------levelArr-----------1');
+        //content中提取图片第一个图,正则提取
+        $reg = '/<img.*?src=[\"|\']?(.*?)[\"|\']?\s.*?>/i';
+        preg_match_all($reg, $data['content'], $matches);
+        if (isset($matches[1][0])) {
+          //截取varchar240
+          $articleData['imgurl'] = substr($matches[1][0], 0, 240);
+          //如果有图,设置level=3
+          if (!in_array(3, $levelArr)) {
+            $levelArr[] = 3;
+          }
+          $articleData['level'] = json_encode($levelArr);
+        } else {
+          if (!in_array(0, $levelArr)) {
+            $levelArr[] = 0;
+          }
+          $articleData['level'] = json_encode($levelArr);
+        }
+      }
+      var_dump($articleData['level'], '----------$articleData[level]----------1');
+      if ($articleData['keyword'] == '') {
+        //提取标题+内容中的关键词
+        $articleData['keyword'] = $data['title'];
+        //  . substr(str_replace(' ', '', strip_tags($data['content'])), 0, 20);
+        Jieba::init(); // 初始化 jieba-php
+        Finalseg::init();
+        $segList = Jieba::cut($articleData['keyword']);
+        $segList1 = array_slice($segList, 0, 8);
+        $articleData['keyword'] = implode(',', $segList1);
+      }
+      if ($articleData['introduce'] == '') {
+        //提取内容中的描述
+        $articleData['introduce'] = substr(str_replace(' ', '', strip_tags($data['content'])), 0, 100);
+      }
+
+      $id = Article::insertGetId($articleData);
+      $articleDataContent = [
+        'article_id' => $id,
+        'content' => $data['content'],
+      ];
+      ArticleData::insertGetId($articleDataContent);
+
+      //处理投票
+      if ($is_survey == 1) {
+        //生成年月日时分秒+8位随机数
+        $uuid = date('YmdHis') . rand(10000000, 99999999);
+        var_dump($suvey_array, 'suvey_array________');
+        $suveys_array = is_array($suvey_array) ? $suvey_array : json_decode($suvey_array);
+        var_dump($suveys_array, '---------------------1');
+        var_dump($suvey_array, '---------------------2');
+        $suvey_data = [];
+        foreach ($suveys_array as $key => $value) {
+          if ($value == '') {
+            continue;
+          }
+          if (is_array($value)) {
+            $suvey_data[] = [
+              'sur_id' => $uuid,
+              'art_id' => $id,
+              'website_id' => $website_id ?? 2,
+              'survey_name' => $survey_name,
+              'choice_name' => $value[1],
+              'is_other' => 1,
+              'other_id' => 0,
+              'results' => 0,
 
-    private function buildCategoryTree($category, $allRequiredCategories)
-    {
-        $categoryData = $category->toArray();
-        $children = [];
-        foreach ($allRequiredCategories as $c) {
-            if ($c->pid === $category->id) {
-                $children[] = $this->buildCategoryTree($c, $allRequiredCategories);
-            }
-        }
-        if (!empty($children)) {
-            $categoryData['children'] = $children;
+            ];
+          } else {
+            $suvey_data[] = [
+              'sur_id' => $uuid,
+              'art_id' => $id,
+              'website_id' => $website_id ?? 2,
+              'survey_name' => $survey_name,
+              'choice_name' => $value,
+              'is_other' => 0,
+              'other_id' => 0,
+              'results' => 0,
+
+            ];
+          }
+          if (empty($suvey_data)) {
+            throw new \Exception("投票数据为空");
+          }
         }
-        return $categoryData;
-    }
-
-    public function myCategoryList(array $data): array
-    {
-        $sszq = $data['sszq'] ?? '';
-        unset($data['sszq']);
-        //1,2,3 根据这些webid,。从website_category表中取出对应的分类id,然后从category表中取出分类信息
-        $catorytids = WebsiteCategory::whereIn('website_id', explode(',', $sszq))->get()->pluck('category_id')->toArray();
-        $where[] = [
-            'pid',
-            '=',
-            $data['pid'],
-        ];
-        if (isset($data['name'])) {
-            array_push($where, ['category.name', 'like', '%' . $data['name'] . '%']);
+        $result = ArticleSurvey::insert($suvey_data);
+        if (!$result) {
+          throw new \Exception("投票失败,ArticleSurvey插入失败");
         }
-        var_dump($where);
-        //根据分类id,从category表中取出分类信息
-        $result = Category::where($where)
-            ->whereIn('category.id', $catorytids)
-            ->select('category.*', 'category.id as category_id')->get();
-        if (empty($result)) {
-            return Result::error("没有栏目数据");
+        $result = Article::where('id', $id)->update(['survey_id' => $uuid, 'survey_name' => $survey_name, 'is_survey' => $is_survey]);
+        if (!$result) {
+          throw new \Exception("投票失败,更新主表失败");
         }
-        return Result::success($result);
+      }
+
+
+      Db::commit();
+      return Result::success(['id' => $id]);
+    } catch (\Throwable $ex) {
+      Db::rollBack();
+      var_dump($ex->getMessage());
+      return Result::error("创建失败", 0);
     }
-    /**
-     * @param array $data
-     * @return array
-     */
-    public function categoryList(array $data): array
-    {
-        $where[] = [
-            'pid',
-            '=',
-            $data['pid']
-        ];
-        if (isset($data['name'])) {
-            array_push($where, ['category.name', 'like', '%' . $data['name'] . '%']);
-        }
-        var_dump($where);
-        $result =  Category::where($where)->select('category.*', 'category.id as category_id')->get();
-        if (empty($result)) {
-            return Result::error("没有栏目数据");
-        }
-        return Result::success($result);
+  }
+
+  /**
+   * @param array $data
+   * @return array
+   */
+  public function delArticle(array $data): array
+  {
+    $result = Article::where($data)->delete();
+    //survey投票删除
+    articleSurvey::where(['art_id' => $data['id']])->delete();
+    if (!$result) {
+      return Result::error("删除失败");
     }
-    /**
-     * @param array $data
-     * @return array
-     */
-    public function addCategory(array $data): array
-    {
-        if (isset($data['id'])) {
-            unset($data['id']);
+    return Result::success($result);
+  }
+
+  /**
+   * @param array $data
+   * @return array
+   */
+  public function updateArticle(array $data): array
+  {
+    var_dump($data, '----------12-----------1');
+    Db::beginTransaction();
+    unset($data['user_type']);
+    // unset($data['web_site_id']);
+    unset($data['nav_add_pool_id']);
+    try {
+      //处理投票
+      $is_survey = isset($data['is_survey']) ? $data['is_survey'] : 0;
+      $survey_name = isset($data['survey_name']) ? $data['survey_name'] : '';
+      $suvey_array = isset($data['suvey_array']) ? $data['suvey_array'] : '';
+      $website_id = isset($data['website_id']) ? $data['website_id'] : 2;
+      unset($data['is_survey']);
+      unset($data['survey_name']);
+      unset($data['suvey_array']);
+      unset($data['website_id']);
+      $data['web_site_id'] = is_array($data['web_site_id']) ? json_encode($data['web_site_id']) : ($data['web_site_id']);
+      if ($data['hits'] == '') {
+        $data['hits'] = 0;
+      }
+      if ($data['is_original'] == '') {
+        $data['is_original'] = 0;
+      }
+      if ($data['status'] == '') {
+        $data['status'] = 0;
+      }
+      $data['cat_arr_id'] = is_array($data['cat_arr_id']) ? json_encode($data['cat_arr_id']) : $data['cat_arr_id'];
+      $data['tag'] = isset($data['tag']) ? json_encode($data['tag']) : '';
+      $articleData = $data;
+      unset($articleData['content']);
+      unset($articleData['status_name']);
+      unset($articleData['name']);
+      unset($articleData['content']);
+      unset($articleData['pid_arr']);
+      unset($articleData['pid']);
+      //自动处理缩略图、关键字、描述
+      if ($articleData['imgurl'] == '') {
+        //如果没有图,设置level=0
+        $levelArr = json_decode($articleData['level'], true);
+        var_dump($levelArr, '----------levelArr-----------1');
+        //content中提取图片第一个图,正则提取
+        $reg = '/<img.*?src=[\"|\']?(.*?)[\"|\']?\s.*?>/i';
+
+        preg_match_all($reg, $data['content'], $matches);
+        if (isset($matches[1][0])) {
+          //截取varchar240
+          // 截取到第一个<
+          $articleData['imgurl'] = $matches[1][0];
+          var_dump($articleData['imgurl'], '----------imgurl-----------1');
+          $pos = strpos($articleData['imgurl'], '"');
+          if ($pos !== false) {
+            $articleData['imgurl'] = substr($articleData['imgurl'], 0, $pos);
+          }
+          //$articleData['imgurl'] = substr($matches[1][0], 0, 240);
+          //如果有图,设置level=3
+          if (!in_array(3, $levelArr)) {
+            $levelArr[] = 3;
+          }
+          $articleData['level'] = json_encode($levelArr);
+        } else {
+          if (!in_array(0, $levelArr)) {
+            $levelArr[] = 0;
+          }
+          $articleData['level'] = json_encode($levelArr);
+        }
+      }
+      var_dump($articleData['level'], '----------$articleData[level]----------1');
+      if ($articleData['keyword'] == '') {
+        //提取标题+内容中的关键词
+        $articleData['keyword'] = $data['title'];
+        //  . substr(str_replace(' ', '', strip_tags($data['content'])), 0, 20);
+        Jieba::init(); // 初始化 jieba-php
+        Finalseg::init();
+        $segList = Jieba::cut($articleData['keyword']);
+        $segList1 = array_slice($segList, 0, 8);
+        $articleData['keyword'] = implode(',', $segList1);
+      }
+      if ($articleData['introduce'] == '') {
+        //提取内容中的描述
+        $articleData['introduce'] = substr(preg_replace('/\s+/', '', strip_tags($data['content'])), 0, 100);
+        // substr(str_replace(' ', '', strip_tags($data['content'])), 0, 100);
+      }
+
+      $id = Article::where(['id' => $data['id']])->update($articleData);
+      $articleDataContent = [
+        'content' => $data['content'],
+      ];
+      ArticleData::where(['article_id' => $data['id']])->update($articleDataContent);
+      //处理投票
+      $id = $data['id'];
+      $surveydata = ArticleSurvey::where(['art_id' => $data['id']])->delete();
+      var_dump($suvey_array, 'suvey_array________delete');
+
+      //处理投票
+      if ($is_survey == 1) {
+        //生成年月日时分秒+8位随机数
+        $uuid = date('YmdHis') . rand(10000000, 99999999);
+        $suveys_array = is_array($suvey_array) ? $suvey_array : json_decode($suvey_array);
+        var_dump($suveys_array, '---------------------1');
+        $suvey_data = [];
+        if (is_array($suveys_array)) {
+          foreach ($suveys_array as $key => $value) {
+            if ($value == '') {
+              continue;
+            }
+            if (is_array($value)) {
+              $suvey_data[] = [
+                'sur_id' => $uuid,
+                'art_id' => $id,
+                'website_id' => $website_id ?? 2,
+                'survey_name' => $survey_name,
+                'choice_name' => $value[1],
+                'is_other' => 1,
+                'other_id' => 0,
+                'results' => 0,
+
+              ];
+            } else {
+              $suvey_data[] = [
+                'sur_id' => $uuid,
+                'art_id' => $id,
+                'website_id' => $website_id ?? 2,
+                'survey_name' => $survey_name,
+                'choice_name' => $value,
+                'is_other' => 0,
+                'other_id' => 0,
+                'results' => 0,
+              ];
+            }
+            if (empty($suvey_data)) {
+              throw new \Exception("投票数据为空");
+            }
+          }
         }
-        $id = Category::insertGetId($data);
-        if (empty($id)) {
-            return Result::error("添加失败");
+        $result = ArticleSurvey::insert($suvey_data);
+        if (!$result) {
+          throw new \Exception("投票失败");
         }
-        return Result::success(['id' => $id]);
+        $result = Article::where('id', $id)->update(['survey_id' => $uuid, 'survey_name' => $survey_name, 'is_survey' => $is_survey]);
+        if (!$result) {
+          throw new \Exception("投票失败");
+        }
+      } else {
+        $result = Article::where('id', $id)->update(['survey_id' => '', 'survey_name' => '', 'is_survey' => 0]);
+      }
+      Db::commit();
+      return Result::success([]);
+    } catch (\Throwable $ex) {
+      Db::rollBack();
+      var_dump($ex->getMessage());
+      return Result::error("更新失败" . $ex->getMessage(), 0);
+    }
+  }
+
+  /**
+   * 更新资讯状态
+   * @param array $data
+   * @return array
+   */
+  public function upArticleStatus(array $data): array
+  {
+    $result = Article::where(['id' => $data['id']])->update($data);
+    if ($result) {
+      return Result::success();
+    } else {
+      return Result::error("更新状态失败", 0);
     }
+  }
+  /**
+   * 获取新闻详情
+   * @param array $data
+   * @return array
+   */
+  public function getArticleInfo(array $data): array
+  {
+    $where = [
+      'article.id' => $data['id'],
+      // 'article.status' => 1,
+    ];
+    $result = Article::where($where)->leftJoin("article_data", "article.id", "article_data.article_id")->first();
+    $articleSurvey = ArticleSurvey::where(['art_id' => $data['id']])->get();
+    $info = $result;
+    // var_dump($info, 'info');
+    $info['survey_array'] = $articleSurvey;
+    if ($result) {
+      return Result::success($info);
+    } else {
+      return Result::error("查询失败", 0);
+    }
+  }
+  /**
+   *  获取头条新闻
+   * @param array $data
+   * @return array
+   */
+  public function getWebsiteArticlett(array $data): array
+  {
+    // return Result::success($data['website_id']);
+    $category = WebsiteCategory::where('website_id', $data['website_id'])->pluck('category_id');
+    $category = array_values(array_unique($category->toArray()));
+    $web['website_id'] = $data['website_id'];
+    if ($category) {
+      $where = [
+        'status' => 1,
+      ];
+      var_dump($data, 'data-----------------');
+      // level=7  根据文章key来匹配文章
+      if (isset($data['level']) && $data['level'] == 7) {
+        //  根据文章id获取key
+        // $data['id'] = 50142;
+        if (isset($data['id']) && !empty($data['id'])) {
+          $keyword = Article::where('id', $data['id'])->value('keyword');
+          $keywordArray = explode(',', $keyword);
+          $whereL7 = [];
+          foreach ($keywordArray as $k => $v) {
+            $whereL7[] = ['keyword', 'like', '%' . $v . '%'];
+          }
+          // 原始查询
+          $result['level7'] = Article::where($whereL7)
+            ->when(!empty($data['imgnum']), function ($query) use ($data) {
+              $query->where('article.imgurl', '!=', '')
+                ->select('article.*')
+                ->offset($data['placeid'])
+                ->limit($data['imgnum']);
+            })
+            ->when(!empty($data['textnum']), function ($query) use ($data) {
+              $query->select('article.*')
+                ->offset($data['placeid'])
+                ->limit($data['textnum']);
+            })
+            ->orderBy('updated_at', 'desc')
+            ->get();
+          $result['level7'] = $this->processArticle($result['level7'], $web);
+          if (empty($result)) {
+            return Result::success();
+          }
+          return Result::success($result);
+        } else {
+          return Result::error("参数错误level=7,id不能为空", 0);
+        }
+      }
+      //如果是4:最新资讯(数据库已不存在) 5:资讯推荐(数据库已不存在);
+      // 1:头条资讯;2:轮播图;6:热点资讯;(数据库)
+      var_dump($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");
+        });
 
-    /**
-     * @param array $data
-     * @return array
-     */
-    public function delCategory(array $data): array
-    {
-        Db::beginTransaction();
-        try {
-            $categoryList = Category::where(['pid' => $data['id']])->get();
-            if ($categoryList->toArray()) {
-                Db::rollBack();
-                return Result::error("分类下面有子分类不能删除");
-            }
-            $articleList = Article::where(['catid' => $data['id']])->get();
-            if ($articleList->toArray()) {
-                Db::rollBack();
-                return Result::error("分类下面有资讯不能删除");
-            }
-            $result = Category::where($data)->delete();
-            WebsiteCategory::where(['category_id' => $data['id']])->delete();
-            if (!$result) {
-                return Result::error("删除失败");
+      // 处理 level 相关查询条件
+      $query->when($data['level'] == 5, function ($query) {
+        $query->inRandomOrder()
+          ->where('updated_at', '>', date("Y-m-d H:i:s", strtotime("-30 day")));
+      })->when($data['level'] == 4, function ($query) {
+        $query->orderBy("article.updated_at", "desc");
+      })->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");
+        }
+      });
+      // 初始化结果数组
+      $result = [];
+      // $input = $data['website_id']; 
+      // 处理图片新闻查询
+      if (!empty($data['imgnum'])) {
+        // 原错误提示表明 cleanBindings 方法需要传入数组类型的参数,而实际传入了 null。
+        // 这里克隆查询构建器,确保绑定参数为数组,避免该错误。
+        $imgQuery = clone $query;
+        if ($imgQuery->getBindings() === null) {
+          $imgQuery->setBindings([]);
+        }
+        $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.cat_arr_id',
+            'article.catid'
+          )
+          ->offset($data['placeid'])
+          ->limit($data['imgnum'])
+          ->get();
+        $result['img'] = $this->processArticles($result['img'], $web);
+      }
+
+      // 处理文字新闻查询
+      if (!empty($data['textnum'])) {
+        $textQuery = clone $query;
+        $result['text'] = $textQuery
+          ->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'
+          )
+          ->offset($data['placeid'])
+          ->limit($data['textnum'])
+          ->get();
+        $result['text'] = $this->processArticles($result['text'], $web);
+      }
+
+      if (empty($result) || count($result) == 0) {
+        return Result::error("暂无头条新闻");
+      }
+      return Result::success($result);
+    } else {
+      return Result::error("本网站下暂无相关栏目", 0);
+    }
+  }
+  /**
+   * 获取模块新闻
+   * @param array $data
+   * @return array
+   */
+
+  public function getWebsiteModelArticles(array $data): array
+  {
+    $catid = $data['catid'];
+    $category = WebsiteCategory::where('website_id', $data['website_id'])->where('category_id', $catid)->select('category_id')->get();
+    $category = $category->toArray();
+    if (!empty($category)) {
+      $where = [
+        'status' => 1,
+        'catid' => $catid,
+      ];
+      $placeid = isset($data['placeid']) && !empty($data['placeid']) ? $data['placeid'] - 1 : 0;
+      // 1:文字新闻;2:轮播图;3:图文;
+      // 级别:0:未分类
+      // 3:推荐图片
+      if ($data['level'] == 1) {
+        $data['level'] = 0;
+      }
+      $result = Article::where($where)
+        ->where(function ($query) use ($data) {
+          $query->whereRaw("JSON_CONTAINS(level, '" . intval($data['level']) . "') = 1")
+            ->orWhereNull("level")
+            ->orWhereRaw("level = '[]'");
+        })
+        ->where(function ($query) use ($data) {
+          $query->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($data['website_id']) . "') = 0")
+            ->orWhereNull("ignore_ids");
+        })
+        ->orderBy("updated_at", "desc")
+        ->offset($placeid)
+        ->limit($data['pagesize'])
+        ->get();
+      if (empty($result)) {
+        return Result::error("此栏目暂无相关新闻", 0);
+      }
+    } else {
+      return Result::error("此网站暂无此栏目", 0);
+    }
+    return Result::success($result);
+  }
+
+  /**
+   *获取新闻列表 
+   * @param array $data
+   * @return array
+   */
+  public function getWebsiteArticleList(array $data): array
+  {
+    // return Result::success($data);
+    $where[] = ['status', '=', 1];
+    if (isset($data['catid']) && !empty($data['catid'])) {
+      $category = WebsiteCategory::where('website_id', $data['website_id'])->where('category_id', $data['catid'])->pluck('category_id');
+      array_push($where, ['catid', '=', $data['catid']]);
+      if (empty($category)) {
+        return Result::error("此网站暂无此栏目", 0);
+      }
+    }
+    // return Result::success($where);
+    $rep = Article::where($where)
+      ->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.cat_arr_id',
+        'article.catid'
+      )
+      ->orderBy("updated_at", "desc")
+      ->offset(($data['page'] - 1) * $data['pageSize'])
+      ->limit($data['pageSize'])
+      ->get();
+    $web['website_id'] = $data['website_id'];
+    $rep = $this->processArticles($rep, $web);
+    $count = Article::where($where)
+      ->where(function ($query) use ($data) {
+        $query->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($data['website_id']) . "') = 0")
+          ->orWhereNull("ignore_ids");
+      })->count();
+
+    $data = [
+      'rows' => $rep->toArray(),
+      'count' => $count,
+    ];
+
+    if (empty($rep)) {
+      return Result::error("没有信息数据");
+    }
+    return Result::success($data);
+  }
+  /**
+   * 前端-获取新闻详情
+   * @param array $data
+   * @return array
+   */
+  public function selectWebsiteArticleInfo(array $data): array
+  {
+    $where = [
+      'article.id' => $data['id'],
+      'article.status' => 1,
+    ];
+
+    $result = Article::where($where)->leftJoin("article_data", "article.id", "article_data.article_id")
+      ->where(function ($query) use ($data) {
+        $query->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($data['website_id']) . "') = 0")
+          ->orWhereNull("ignore_ids");
+      })
+      ->first();
+    if (empty($result)) {
+      return Result::error("暂无此新闻!", 0);
+    }
+    $category = WebsiteCategory::leftJoin('website', 'website.id', '=', 'website_category.website_id')
+      ->select('website_category.*', 'website.website_name', 'website.suffix')
+      ->where('website_category.website_id', $data['website_id'])
+      ->where(['website_category.category_id' => $result['catid']])
+      ->first();
+    if (empty($category)) {
+      return Result::error("查询失败", 0);
+    }
+    //手动推荐文章
+    $commend_ids = $result['commend_id'] ? json_decode($result['commend_id']) : [];
+    $commendArticle = Article::whereIn('id', $commend_ids)
+      ->where('status', 1)
+      ->select('id', 'title', 'catid', 'imgurl', 'hits', 'created_at')
+      ->orderBy('updated_at', 'desc')
+      ->limit(5)
+      ->get();
+    $result['category_id'] = $category['category_id'];
+    $result['cat_name'] = $category['alias'];
+    $result['website_name'] = $category['website_name'] ?? "";
+    $result['suffix'] = $category['suffix'] ?? "";
+    $result['commendArticle'] = $commendArticle;
+    return Result::success($result);
+  }
+
+  /**
+   * 前端-获取网站调查问卷
+   * @param array $data
+   * @return array
+   */
+  public function getWebsiteSurvey(array $data): array
+  {
+    if (isset($data['website_id']) && !empty($data['website_id'])) {
+      $website = Website::where('id', $data['website_id'])->first();
+      if (empty($website)) {
+        return Result::error("暂无此网站", 0);
+      }
+    }
+    if (isset($data['art_id']) && !empty($data['art_id'])) {
+      $article = Article::where('id', $data['art_id'])->where('status', 1)->first();
+      if (empty($article)) {
+        return Result::error("暂无此文章", 0);
+      }
+      // return Result::error($data,0);
+      $where['art_id'] = $data['art_id'];
+      // $query = ArticleSurvey::where('art_id',$data['art_id']);
+
+    } else {
+      $survey = Article::where(function ($query) {
+        $query->whereRaw("JSON_CONTAINS(cat_arr_id, '28')")
+          ->orWhereRaw("JSON_CONTAINS(cat_arr_id, '\"28\"')");
+      })
+        ->where('status', 1)
+        ->where('is_survey', 1)
+        ->select('survey_id')
+        ->orderBy('updated_at', 'desc')
+        ->first();
+      if (empty($survey)) {
+        return Result::error("暂无调查问卷", 0);
+      }
+      $where['sur_id'] = $survey['survey_id'];
+      // $query = ArticleSurvey::where('sur_id',$survey['sur_id']);
+    }
+    // return Result::success($where);
+    $result = ArticleSurvey::where($where)
+      ->where(function ($query) {
+        $query->where('is_other', 0)
+          ->orWhere(function ($subQuery) {
+            $subQuery->where('is_other', 1)
+              ->where('other_id', 0);
+          });
+      })
+      ->leftJoin('article', 'article_survey.art_id', 'article.id')
+      ->select('article_survey.*', 'article.survey_type')
+      ->get()->all();
+    if (empty($result)) {
+      return Result::error("此文章暂无调查问卷", 0);
+    }
+    return Result::success($result);
+  }
+  /**
+   * 前端-添加网站调查问卷选项
+   * @param array $data
+   * @return array
+   */
+  public function addWebsiteSurveyOption(array $data): array
+  {
+    if (isset($data['website_id']) && !empty($data['website_id'])) {
+      $website = Website::where('id', $data['website_id'])->first();
+      if (empty($website)) {
+        return Result::error("暂无此网站", 0);
+      }
+      if (isset($data['sur_id']) && !empty($data['sur_id'])) {
+        $survey = ArticleSurvey::where('sur_id', $data['sur_id'])->where('is_other', 1)->where('other_id', 0)->first();
+        if (empty($survey)) {
+          return Result::error("此调查问卷不可添加选项", 0);
+        }
+        if (isset($data['choice_name']) && !empty($data['choice_name'])) {
+          $choice = [
+            'art_id' => $survey['art_id'],
+            'website_id' => $data['website_id'],
+            'survey_name' => $survey['survey_name'],
+            'choice_name' => $data['choice_name'],
+            'sur_id' => $survey['sur_id'],
+            'is_other' => 1,
+            'other_id' => $survey['id'],
+
+          ];
+          $result = ArticleSurvey::insertGetId($choice);
+          if (empty($result)) {
+            return Result::error("添加失败", 0);
+          }
+          return Result::success($result);
+        }
+      }
+      return Result::error("添加失败", 0);
+    }
+    return Result::error("添加失败", 0);
+  }
+  /**
+   * 前端-调查问卷投票
+   * @param array $data
+   * @return array
+   */
+  public function addWebsiteSurveyVote(array $data): array
+  {
+    // return Result::success($data);
+    if (isset($data['website_id']) && !empty($data['website_id'])) {
+      $website = Website::where('id', $data['website_id'])->first();
+      if (empty($website)) {
+        return Result::error("暂无此网站", 0);
+      }
+      if (isset($data['sur_id']) && !empty($data['sur_id'])) {
+        $is_survey = ArticleSurvey::where('sur_id', $data['sur_id'])->first();
+        // return Result::success($survey);
+        if (empty($is_survey)) {
+          return Result::error("此调查问卷不存在", 0);
+        }
+        // return Result::success($survey);
+        // 调查问卷类型
+        if (isset($data['choice_id']) && !empty($data['choice_id'])) {
+          //多选 若是json型则转化成数组类型
+          if (strpos($data['choice_id'], '[') === 0) {
+            $data['choice_id'] = json_decode($data['choice_id'], true);
+          } else {
+            // 单选  也转换成数组
+            $data['choice_id'] = [$data['choice_id']];
+          }
+          $data['choice_id'] = array_map('intval', $data['choice_id']);
+          $other = ArticleSurvey::whereIn('id', $data['choice_id'])
+            // ->where('website_id',$data['website_id'])
+            ->where('is_other', 1)
+            ->where('other_id', 0)
+            ->first();
+          if (!empty($other)) {
+            return Result::error("请选择已有的选项!", 0);
+          }
+          $choice['other'] = ArticleSurvey::whereIn('id', $data['choice_id'])
+            // ->where('website_id',$data['website_id'])
+            ->where('is_other', 1)
+            ->where('other_id', '!=', 0)
+            ->first();
+          // return Result::success($choice['other']);
+          $choice_id = $data['choice_id'];
+          if (!empty($choice['other'])) {
+            // array_push($data['choice_id'],$choice['other']['other_id']);
+            if (!empty($choice_id)) {
+              $key = array_search($choice['other']['id'], $choice_id);
+              if ($key !== false) {
+                unset($choice_id[$key]);
+                $choice_id = array_values($choice_id);
+              }
+              array_push($choice_id, $choice['other']['other_id']);
+            } else {
+              $choice_id[0] = $choice['other']['other_id'];
             }
-            return Result::success($result);
-            Db::commit();
-        } catch (\Exception $e) {
-            Db::rollBack();
-            return Result::error("删除失败");
+            array_push($data['choice_id'], $choice['other']['other_id']);
+          }
+          // return Result::success($data);
+          $choice = ArticleSurvey::whereIn('id', $data['choice_id'])
+            // ->where('website_id',$data['website_id'])
+            ->increment('results', 1);
+          if (empty($choice)) {
+            return Result::error("请选择已有的选项!", 0);
+          }
+          $survey['data'] = ArticleSurvey::where('sur_id', $data['sur_id'])
+            // ->where('website_id',$data['website_id'])
+            ->where('other_id', 0)
+            ->get();
+          $survey['choice'] = $choice_id;
+          return Result::success($survey);
         }
+        return Result::error("参数必填!");
+      }
+      return Result::error("此调查问卷不存在", 0);
+    }
+    return Result::error("参数必填!");
+  }
+  /**
+   * 后端-获取网站调查问卷列表
+   * @param array $data
+   * @return array
+   */
+  public function getSurveyList(array $data): array
+  {
+    $where = [];
+    if (isset($data['survey_name']) && !empty($data['survey_name'])) {
+      array_push($where, ['survey_name', 'like', '%' . $data['survey_name'] . '%']);
+    }
+    if (isset($data['survey_type']) && $data['survey_type'] != null) {
+      array_push($where, ['survey_type', '=', $data['survey_type']]);
+    }
+    if (isset($data['is_survey']) && $data['is_survey'] != null) {
+      array_push($where, ['is_survey', '=', $data['is_survey']]);
+    }
+    // return Result::success($where);
+
+    if (!empty($where)) {
+      $query = Article::where($where)->where(function ($q) {
+        $q->whereNotNull('survey_name')->where('survey_name', '!=', '');
+      });
+    } else {
+      $query = Article::where(function ($q) {
+        $q->whereNotNull('survey_name')->where('survey_name', '!=', '');
+      });
     }
 
-    /**
-     * @param array $data
-     * @return array
-     */
-    public function updateCategory(array $data): array
-    {
-        $where = [
-            'id' => $data['id'],
-        ];
-        $result = Category::where($where)->update($data);
-        if ($result) {
-            return Result::success($result);
+    $count = $query->count();
+    $survey = $query->orderByDesc('id')
+      ->limit($data['pageSize'])
+      ->offset(($data['page'] - 1) * $data['pageSize'])
+      ->get();
+    if (empty($survey->toArray())) {
+      return Result::error("暂无调查问卷!", 0);
+    }
+    $result = [
+      'rows' => $survey,
+      'count' => $count,
+    ];
+    return Result::success($result);
+  }
+  /**
+   * 后端-获取网站调查问卷详情
+   * @param array $data
+   * @return array
+   */
+  public function getSurveyInfo(array $data): array
+  {
+    if (isset($data['sur_id']) && !empty($data['sur_id'])) {
+      $where = ['sur_id' => $data['sur_id']];
+      $choose = ArticleSurvey::where($where)->where('is_other', 0)
+        ->leftJoin('article', 'article_survey.art_id', 'article.id')
+        ->select('article_survey.*', 'article.survey_type')
+        ->get()->all();
+      if (empty($choose)) {
+        return Result::error("此调查问卷不存在", 0);
+      }
+      $resultsArray = array_column($choose, 'results');
+      $total = array_sum($resultsArray);
+      $other = ArticleSurvey::where($where)->where('is_other', 1)->where('other_id', 0)->first();
+      $others = ArticleSurvey::where($where)->where('is_other', 1)->where('other_id', '!=', 0)->orderByDesc('created_at')->get()->all();
+      // $total = 0;
+      if (!empty($other)) {
+        $total = $total + $other['results'];
+        $other['choice_name'] = '(其他)';
+        if (!empty($others)) {
+          $other['hasChildren'] = true;
+          // array_push($other,['hasChildren','=',true]);
+          $other['children'] = $others;
+          $other_choices = [$other->toArray()];
+          $mer_choice = array_merge($choose, $other_choices);
+          $value_choice = array_values($mer_choice);
         } else {
-            return Result::error("更新失败");
-        }
+          // return Result::error('1111');
+          $other_choices = [$other->toArray()];
+          $other_choices = array_merge($choose, $other_choices);
+          $value_choice = array_values($other_choices);
+          // return Result::success($result);
+        }
+      } else {
+        $value_choice = $choose;
+      }
+      $result = [
+        'choose' => $value_choice,
+        'total' => $total,
+      ];
+    }
+    return Result::success($result);
+  }
+
+  /**
+   * 前端-搜索新闻列表
+   * @param array $data
+   * @return array
+   */
+  public function selectWebsiteArticle(array $data): array
+  {
+    $category = WebsiteCategory::where('website_id', $data['website_id'])->pluck('category_id');
+    $query = Article::where('status', 1)
+      ->whereIn('catid', $category)
+      ->where(function ($query) use ($data) {
+        $query->where(function ($subQuery) use ($data) {
+          $subQuery->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($data['website_id']) . "') = 0");
+        })->orWhereNull("ignore_ids");
+      });
+    // return Result::success($all_articles);
+    if (isset($data['cityid']) && !empty($data['cityid'])) {
+      $query->whereRaw("JSON_CONTAINS(city_arr_id, '" . intval($data['cityid']) . "')");
+    }
+    if (isset($data['department_id']) && !empty($data['department_id'])) {
+      $query->whereRaw("JSON_CONTAINS(department_arr_id, '" . intval($data['department_id']) . "')");
+    }
+    if (isset($data['keyword']) && !empty($data['keyword'])) {
+      $query->where('title', 'like', '%' . $data['keyword'] . '%');
+    }
+    // 计算总数
+    $count = $query->count();
+    // 分页查询
+    $articles = $query
+      ->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',
+        'article.department_arr_id',
+        'article.city_arr_id',
+      )
+      ->orderBy("updated_at", "desc")
+      ->offset(($data['page'] - 1) * $data['pageSize'])
+      ->limit($data['pageSize'])
+      ->get();
+    $web['website_id'] = $data['website_id'];
+    $articles = $this->processArticles($articles, $web);
+    if (empty($articles)) {
+      return Result::error("没有符合条件的资讯数据");
+    }
+    $result = [
+      'rows' => $articles,
+      'count' => $count,
+    ];
+    return Result::success($result);
+  }
+
+  /**
+   * 模块新闻加强版
+   * @param array $data
+   * @return array
+   */
+  public function getWebsiteCatidArticle(array $data): array
+  {
+    $where = [
+      'website_category.category_id' => $data['catid'],
+      'website_category.website_id' => $data['website_id'],
+    ];
+    // $category = WebsiteCategory::where($where);
+    if (isset($data['child_catnum']) && !empty($data['child_catnum'])) {
+      $child_catnum = $data['child_catnum'] ?? 1;
+      $category['child'] = WebsiteCategory::where('pid', $data['catid'])->where('website_id', $data['website_id'])->select('category_id', 'alias')->limit($child_catnum)->get()->toArray();
+      $childCategoryIds = array_column($category['child'], 'category_id');
+      if (empty($childCategoryIds)) {
+        return Result::error("暂无子栏目", 0);
+      }
+      $imgArticles = [];
+      $textArticles = [];
+      // return Result::success($childCategoryIds);
+      if (isset($data['child_imgnum']) && !empty($data['child_imgnum']) && $data['child_imgnum'] != 0) {
+        // 初始化子分类图片新闻和文字新闻数组
+
+        // 查询所有子级栏目的图文新闻
+        $imgArticles = Article::where('catid', $childCategoryIds[0])
+          ->where(function ($query) use ($data) {
+            $query->where(function ($subQuery) use ($data) {
+              $subQuery->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($data['website_id']) . "') = 0");
+            })->orWhereNull("ignore_ids");
+          })
+          ->where('status', 1)
+          ->where('imgurl', '!=', '')
+          ->select('*')
+          ->orderBy('updated_at', 'desc')
+          ->limit($data['child_imgnum'])
+          ->get();
+      }
+      if (isset($data['child_textnum']) && !empty($data['child_textnum']) && $data['child_textnum'] != 0) {
+        // 查询所有子级栏目的文字新闻
+        $textArticles = Article::where('catid', $childCategoryIds[0])
+          ->where('status', 1)
+          ->where(function ($query) use ($data) {
+            $query->where(function ($subQuery) use ($data) {
+              $subQuery->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($data['website_id']) . "') = 0");
+            })->orWhereNull("ignore_ids");
+          })
+          ->select('*')
+          ->orderBy('updated_at', 'desc')
+          ->limit($data['child_textnum'])
+          ->get();
+      }
+      // 遍历子分类,将图文新闻和文字新闻分别添加到子分类中
+      $category['child'] = array_map(function ($child) use ($imgArticles, $textArticles) {
+        $child['img'] = $imgArticles ? $imgArticles->where('catid', $child['category_id']) : [];
+        $child['text'] = $textArticles ? $textArticles->where('catid', $child['category_id']) : [];
+        return $child;
+      }, $category['child']);
+    }
+    // }
+    if (isset($data['img_num']) && !empty($data['img_num'])) {
+      $category['img'] = WebsiteCategory::where($where)
+        ->leftJoin('article', 'article.catid', 'website_category.category_id')
+        ->where('article.status', 1)
+        ->where('article.imgurl', '!=', '')
+        ->select('article.*', 'website_category.category_id', 'website_category.alias')
+        ->orderBy('article.updated_at', 'desc')
+        ->limit($data['img_num'])
+        ->get();
     }
 
-    /**
-     * 获取导航池信息
-     * @param array $data
-     * @return array
-     */
-    public function getCategoryInfo(array $data): array
-    {
-        $where = [
-            'id' => $data['id'],
-        ];
-        $result = Category::where($where)->first();
-        if ($result) {
-            return Result::success($result);
-        } else {
-            return Result::error("更新失败");
-        }
+    if (isset($data['text_num']) && !empty($data['text_num'])) {
+      $category['text'] = WebsiteCategory::where($where)
+        ->leftJoin('article', 'article.catid', 'website_category.category_id')
+        ->where('article.status', 1)
+        ->select('article.*', 'website_category.category_id', 'website_category.alias')
+        ->orderBy('article.updated_at', 'desc')
+        ->limit($data['text_num'])
+        ->get();
     }
-    /**
-     * @param array $data
-     * @return array
-     */
-    public function getArticleList(array $data): array
-    {
-        //判断是否是管理员'1:个人会员 2:政务会员 3:企业会员 4:调研员 10000:管理员 20000:游客(小程序)'
-        $type_id = $data['type_id'];
-        unset($data['type_id']);
-        $user_id = $data['user_id'];
-        unset($data['user_id']);
-
-        $where = [];
-        $status1 = [];
-        if (isset($data['id']) && $data['id']) {
-            array_push($where, ['article.id', '=', $data['id']]);
-        }
-        if (isset($data['title']) && $data['title']) {
-            array_push($where, ['article.title', 'like', '%' . $data['title'] . '%']);
-        }
-        if (isset($data['category_name']) && $data['category_name']) {
-            array_push($where, ['category.name', 'like', '%' . $data['category_name'] . '%']);
-        }
-        if (isset($data['author']) && $data['author']) {
-            array_push($where, ['article.author', '=', $data['author']]);
-        }
-        if (isset($data['islink']) && $data['islink'] !== "") {
-            array_push($where, ['article.islink', '=', $data['islink']]);
-        }
-        if (isset($data['status']) && $data['status'] !== "") {
-            array_push($where, ['article.status', '=', $data['status']]);
-        }
-        if (isset($data['status1'])) {
-            $status1 = json_decode(($data['status1']));
-        }
-        //不是管理员展示个人数据;
-        if ($type_id != 10000) {
-            $where[] = ['article.admin_user_id', '=', $user_id];
-        }
 
-        $rep = Article::where($where)
-            ->whereNotIn('article.status', [404])
-            ->when($status1, function ($query) use ($status1) {
-                if (isset($status1) && $status1) {
-                    $query->whereIn('article.status', $status1);
-                }
-            })
-            ->leftJoin('category', 'article.catid', 'category.id')
-            ->leftJoin('website_category', function ($join) {
-                $join->on('article.web_site_id', '=', 'website_category.website_id')
-                    ->on('article.catid', '=', 'website_category.category_id');
-            })
-            ->select("article.*", "category.name as category_name", "website_category.alias")
-            ->orderBy("article.updated_at", "desc")
-            ->limit($data['pageSize'])
-            ->offset(($data['page'] - 1) * $data['pageSize'])->get();
-        $count = Article::where($where)->whereNotIn('article.status', [404])
-            ->when($status1, function ($query) use ($status1) {
-                if (isset($status1) && $status1) {
-                    $query->whereIn('article.status', $status1);
-                }
-            })
-            ->leftJoin('category', 'article.catid', 'category.id')->count();
-        $data = [
-            'rows' => $rep->toArray(),
-            'count' => $count,
-        ];
-        if (empty($rep)) {
-            return Result::error("没有信息数据");
-        }
-        return Result::success($data);
+    // $category = $category->get();
+
+    if (empty($category)) {
+      return Result::error("查询失败", 0);
+    }
+    return Result::success($category);
+  }
+  /**
+   * 模块新闻加强版 
+   * @param array $data
+   * @return array
+   */
+  public function getWebsiteAllArticle(array $data): array
+  {
+
+
+
+    // $redisKey = 'website_cache';
+    // $this->redis->hSet($redisKey, $data['website_id'], json_encode($data));
+    // $result = $this->redis->sadd($redisKey);
+    // 使用缓存键
+    // $cacheKey = $data['website_id'];
+
+    //  // 尝试从缓存获取数据
+    $container = \Hyperf\Context\ApplicationContext::getContainer();
+    $cache = $container->get(\Psr\SimpleCache\CacheInterface::class);
+    // 修正传入的字符串,将单引号替换为双引号
+    $input['id'] = $data['id'];
+    $input['website_id'] = $data['website_id'];
+
+    // 将 JSON 字符串转换为 PHP 数组
+    $items = json_decode($input['id'], true);
+
+    if (!is_array($items)) {
+      return Result::error("无效的JSON格式", 0);
     }
 
-    /**
-     * @param array $data
-     * @return array
-     */
-    public function addArticle(array $data): array
-    {
-        var_dump($data, '----------12-----------1');
-        unset($data['user_type']);
-        unset($data['nav_add_pool_id']);
-        // unset($data['commend_id']);
-        // $data['cat_arr_id'] = is_string($data['cat_arr_id']) ? json_encode($data['cat_arr_id']) : '';
-        Db::beginTransaction();
-        try {
-            //处理投票
-            $is_survey = isset($data['is_survey']) ? $data['is_survey'] : 0;
-            $survey_name = isset($data['survey_name']) ? $data['survey_name'] : '';
-            $suvey_array = isset($data['suvey_array']) ? $data['suvey_array'] : '';
-            $website_id = isset($data['website_id']) ? $data['website_id'] : 2;
-            unset($data['is_survey']);
-            unset($data['survey_name']);
-            unset($data['suvey_array']);
-            // unset($data['website_id']);
-            // unset($data['web_site_id']);
-            // $data['web_site_id'] = is_array($data['web_site_id']) ? json_encode($data['web_site_id']) : ($data['web_site_id']);
-            if ($data['hits'] == '') {
-                $data['hits'] = 0;
-            }
-            if ($data['is_original'] == '') {
-                $data['is_original'] = 0;
-            }
-            if ($data['status'] == '') {
-                $data['status'] = 0;
-            }
-            $articleData = $data;
-            unset($articleData['content']);
-            //自动处理缩略图、关键字、描述
-            if ($articleData['imgurl'] == '') {
-                //如果没有图,设置level=0
-                $levelArr = json_decode($articleData['level'], true);
-                var_dump($levelArr, '----------levelArr-----------1');
-                //content中提取图片第一个图,正则提取
-                $reg = '/<img.*?src=[\"|\']?(.*?)[\"|\']?\s.*?>/i';
-                preg_match_all($reg, $data['content'], $matches);
-                if (isset($matches[1][0])) {
-                    //截取varchar240
-                    $articleData['imgurl'] = substr($matches[1][0], 0, 240);
-                    //如果有图,设置level=3
-                    if (!in_array(3, $levelArr)) {
-                        $levelArr[] = 3;
-                    }
-                    $articleData['level'] = json_encode($levelArr);
-                } else {
-                    if (!in_array(0, $levelArr)) {
-                        $levelArr[] = 0;
-                    }
-                    $articleData['level'] = json_encode($levelArr);
-                }
-            }
-            var_dump($articleData['level'], '----------$articleData[level]----------1');
-            if ($articleData['keyword'] == '') {
-                //提取标题+内容中的关键词
-                $articleData['keyword'] = $data['title'];
-                //  . substr(str_replace(' ', '', strip_tags($data['content'])), 0, 20);
-                Jieba::init(); // 初始化 jieba-php
-                Finalseg::init();
-                $segList = Jieba::cut($articleData['keyword']);
-                $segList1 = array_slice($segList, 0, 8);
-                $articleData['keyword'] = implode(',', $segList1);
-            }
-            if ($articleData['introduce'] == '') {
-                //提取内容中的描述
-                $articleData['introduce'] = substr(str_replace(' ', '', strip_tags($data['content'])), 0, 100);
-            }
+    $website = [
+      'website_id' => $input['website_id'],
+    ];
+    foreach ($items as $key => $item) {
+      if (isset($item['parent']) && $item['parent'] !== "") {
+        $parentParams = explode(',', $item['parent']);
+        if (isset($parentParams) && $parentParams[0] !== "") {
+          $parentCatId[$key] = $parentParams[0];
+        }
+      } else {
+        return Result::error("缺少必需参数错误", 0);
+      }
+    }
+    $pid = WebsiteCategory::whereIn('category_id', $parentCatId)->where($website)->pluck('pid')->toArray();
+    // return Result::success($pid);
+    if (!empty($pid)) {
+      $pid = array_values(array_unique($pid));
+      if (count($pid) == 1) {
+        $cacheKey = $data['website_id'] . ',' . $pid[0];
+      } else {
+        return Result::error("参数传递错误", 0);
+      }
+    }
+    // return Result::success($cacheKey);
+    if ($cachedData = $cache->get($cacheKey)) {
+      return Result::success(unserialize($cachedData));
+    }
+    try {
+
+
+      // 提前缓存常用查询结果,减少重复查询
+      $categoryCache = [];
+      $childCategoryCache = [];
+
+      // 使用 array_map 处理每个元素
+      $result = array_map(function ($item) use ($website, &$categoryCache, &$childCategoryCache) {
+        $resultItem = [
+          'alias' => null,
+          'category_id' => null,
+          'pinyin' => null,
+          'imgnum' => [],
+          'textnum' => [],
+          'child' => []
+        ];
 
-            $id = Article::insertGetId($articleData);
-            $articleDataContent = [
-                'article_id' => $id,
-                'content' => $data['content'],
-            ];
-            ArticleData::insertGetId($articleDataContent);
-
-            //处理投票
-            if ($is_survey == 1) {
-                //生成年月日时分秒+8位随机数
-                $uuid = date('YmdHis') . rand(10000000, 99999999);
-                var_dump($suvey_array, 'suvey_array________');
-                $suveys_array = is_array($suvey_array) ? $suvey_array : json_decode($suvey_array);
-                var_dump($suveys_array, '---------------------1');
-                var_dump($suvey_array, '---------------------2');
-                $suvey_data = [];
-                foreach ($suveys_array as $key => $value) {
-                    if ($value == '') {
-                        continue;
-                    }
-                    if (is_array($value)) {
-                        $suvey_data[] = [
-                            'sur_id' => $uuid,
-                            'art_id' => $id,
-                            'website_id' => $website_id ?? 2,
-                            'survey_name' => $survey_name,
-                            'choice_name' => $value[1],
-                            'is_other' => 1,
-                            'other_id' => 0,
-                            'results' => 0,
-
-                        ];
-                    } else {
-                        $suvey_data[] = [
-                            'sur_id' => $uuid,
-                            'art_id' => $id,
-                            'website_id' => $website_id ?? 2,
-                            'survey_name' => $survey_name,
-                            'choice_name' => $value,
-                            'is_other' => 0,
-                            'other_id' => 0,
-                            'results' => 0,
-
-                        ];
-                    }
-                    if (empty($suvey_data)) {
-                        throw new \Exception("投票数据为空");
-                    }
-                }
-                $result = ArticleSurvey::insert($suvey_data);
-                if (!$result) {
-                    throw new \Exception("投票失败,ArticleSurvey插入失败");
-                }
-                $result = Article::where('id', $id)->update(['survey_id' => $uuid, 'survey_name' => $survey_name, 'is_survey' => $is_survey]);
-                if (!$result) {
-                    throw new \Exception("投票失败,更新主表失败");
-                }
-            }
+        // 处理父级栏目
+        if (isset($item['parent']) && $item['parent'] !== 'undefined' && $item['parent'] !== "") {
+          $parentParams = explode(',', $item['parent']);
 
+          if (count($parentParams) !== 3) {
+            return Result::error("父级栏目:缺少必需参数错误", 0);
+          }
 
-            Db::commit();
-            return Result::success(['id' => $id]);
-        } catch (\Throwable $ex) {
-            Db::rollBack();
-            var_dump($ex->getMessage());
-            return Result::error("创建失败", 0);
-        }
-    }
+          list($parentCatId, $parentImgNum, $parentTextNum) = $parentParams;
+          $cacheKey = "parent_{$parentCatId}_{$website['website_id']}";
 
-    /**
-     * @param array $data
-     * @return array
-     */
-    public function delArticle(array $data): array
-    {
-        $result = Article::where($data)->delete();
-        //survey投票删除
-        articleSurvey::where(['art_id' => $data['id']])->delete();
-        if (!$result) {
-            return Result::error("删除失败");
-        }
-        return Result::success($result);
-    }
+          if (!isset($categoryCache[$cacheKey])) {
+            // 查询栏目名称
+            $categoryCache[$cacheKey] = WebsiteCategory::where('category_id', $parentCatId)
+              ->where($website)
+              ->first(['alias', 'category_id', 'aLIas_pinyin', 'type']);
+          }
 
-    /**
-     * @param array $data
-     * @return array
-     */
-    public function updateArticle(array $data): array
-    {
-        var_dump($data, '----------12-----------1');
-        Db::beginTransaction();
-        unset($data['user_type']);
-        // unset($data['web_site_id']);
-        unset($data['nav_add_pool_id']);
-        try {
-            //处理投票
-            $is_survey = isset($data['is_survey']) ? $data['is_survey'] : 0;
-            $survey_name = isset($data['survey_name']) ? $data['survey_name'] : '';
-            $suvey_array = isset($data['suvey_array']) ? $data['suvey_array'] : '';
-            $website_id = isset($data['website_id']) ? $data['website_id'] : 2;
-            unset($data['is_survey']);
-            unset($data['survey_name']);
-            unset($data['suvey_array']);
-            unset($data['website_id']);
-            $data['web_site_id'] = is_array($data['web_site_id']) ? json_encode($data['web_site_id']) : ($data['web_site_id']);
-            if ($data['hits'] == '') {
-                $data['hits'] = 0;
-            }
-            if ($data['is_original'] == '') {
-                $data['is_original'] = 0;
-            }
-            if ($data['status'] == '') {
-                $data['status'] = 0;
-            }
-            $data['cat_arr_id'] = is_array($data['cat_arr_id']) ? json_encode($data['cat_arr_id']) : $data['cat_arr_id'];
-            $data['tag'] = isset($data['tag']) ? json_encode($data['tag']) : '';
-            $articleData = $data;
-            unset($articleData['content']);
-            unset($articleData['status_name']);
-            unset($articleData['name']);
-            unset($articleData['content']);
-            unset($articleData['pid_arr']);
-            unset($articleData['pid']);
-            //自动处理缩略图、关键字、描述
-            if ($articleData['imgurl'] == '') {
-                //如果没有图,设置level=0
-                $levelArr = json_decode($articleData['level'], true);
-                var_dump($levelArr, '----------levelArr-----------1');
-                //content中提取图片第一个图,正则提取
-                $reg = '/<img.*?src=[\"|\']?(.*?)[\"|\']?\s.*?>/i';
-
-                preg_match_all($reg, $data['content'], $matches);
-                if (isset($matches[1][0])) {
-                    //截取varchar240
-                    // 截取到第一个<
-                    $articleData['imgurl'] = $matches[1][0];
-                    var_dump($articleData['imgurl'], '----------imgurl-----------1');
-                    $pos = strpos($articleData['imgurl'], '"');
-                    if ($pos !== false) {
-                        $articleData['imgurl'] = substr($articleData['imgurl'], 0, $pos);
-                    }
-                    //$articleData['imgurl'] = substr($matches[1][0], 0, 240);
-                    //如果有图,设置level=3
-                    if (!in_array(3, $levelArr)) {
-                        $levelArr[] = 3;
-                    }
-                    $articleData['level'] = json_encode($levelArr);
-                } else {
-                    if (!in_array(0, $levelArr)) {
-                        $levelArr[] = 0;
-                    }
-                    $articleData['level'] = json_encode($levelArr);
-                }
-            }
-            var_dump($articleData['level'], '----------$articleData[level]----------1');
-            if ($articleData['keyword'] == '') {
-                //提取标题+内容中的关键词
-                $articleData['keyword'] = $data['title'];
-                //  . substr(str_replace(' ', '', strip_tags($data['content'])), 0, 20);
-                Jieba::init(); // 初始化 jieba-php
-                Finalseg::init();
-                $segList = Jieba::cut($articleData['keyword']);
-                $segList1 = array_slice($segList, 0, 8);
-                $articleData['keyword'] = implode(',', $segList1);
-            }
-            if ($articleData['introduce'] == '') {
-                //提取内容中的描述
-                $articleData['introduce'] = substr(preg_replace('/\s+/', '', strip_tags($data['content'])), 0, 100);
-                // substr(str_replace(' ', '', strip_tags($data['content'])), 0, 100);
+          $category = $categoryCache[$cacheKey];
+
+          if (!empty($category)) {
+            $resultItem['alias'] = $category->alias;
+            $resultItem['category_id'] = $category->category_id;
+            $resultItem['pinyin'] = $category->aLIas_pinyin;
+
+            // 查询图片新闻
+            if (!empty($parentImgNum)) {
+              $resultItem['imgnum'] = $this->fetchArticles($parentCatId, $website, (int)$parentImgNum, true);
             }
 
-            $id = Article::where(['id' => $data['id']])->update($articleData);
-            $articleDataContent = [
-                'content' => $data['content'],
-            ];
-            ArticleData::where(['article_id' => $data['id']])->update($articleDataContent);
-            //处理投票
-            $id = $data['id'];
-            $surveydata = ArticleSurvey::where(['art_id' => $data['id']])->delete();
-            var_dump($suvey_array, 'suvey_array________delete');
-
-            //处理投票
-            if ($is_survey == 1) {
-                //生成年月日时分秒+8位随机数
-                $uuid = date('YmdHis') . rand(10000000, 99999999);
-                $suveys_array = is_array($suvey_array) ? $suvey_array : json_decode($suvey_array);
-                var_dump($suveys_array, '---------------------1');
-                $suvey_data = [];
-                if (is_array($suveys_array)) {
-                    foreach ($suveys_array as $key => $value) {
-                        if ($value == '') {
-                            continue;
-                        }
-                        if (is_array($value)) {
-                            $suvey_data[] = [
-                                'sur_id' => $uuid,
-                                'art_id' => $id,
-                                'website_id' => $website_id ?? 2,
-                                'survey_name' => $survey_name,
-                                'choice_name' => $value[1],
-                                'is_other' => 1,
-                                'other_id' => 0,
-                                'results' => 0,
-
-                            ];
-                        } else {
-                            $suvey_data[] = [
-                                'sur_id' => $uuid,
-                                'art_id' => $id,
-                                'website_id' => $website_id ?? 2,
-                                'survey_name' => $survey_name,
-                                'choice_name' => $value,
-                                'is_other' => 0,
-                                'other_id' => 0,
-                                'results' => 0,
-                            ];
-                        }
-                        if (empty($suvey_data)) {
-                            throw new \Exception("投票数据为空");
-                        }
-                    }
-                }
-                $result = ArticleSurvey::insert($suvey_data);
-                if (!$result) {
-                    throw new \Exception("投票失败");
-                }
-                $result = Article::where('id', $id)->update(['survey_id' => $uuid, 'survey_name' => $survey_name, 'is_survey' => $is_survey]);
-                if (!$result) {
-                    throw new \Exception("投票失败");
-                }
-            } else {
-                $result = Article::where('id', $id)->update(['survey_id' => '', 'survey_name' => '', 'is_survey' => 0]);
+            // 查询文字新闻
+            if (!empty($parentTextNum)) {
+              $resultItem['textnum'] = $this->fetchArticles($parentCatId, $website, (int)$parentTextNum, false);
             }
-            Db::commit();
-            return Result::success([]);
-        } catch (\Throwable $ex) {
-            Db::rollBack();
-            var_dump($ex->getMessage());
-            return Result::error("更新失败" . $ex->getMessage(), 0);
+          }
         }
-    }
 
-    /**
-     * 更新资讯状态
-     * @param array $data
-     * @return array
-     */
-    public function upArticleStatus(array $data): array
-    {
-        $result = Article::where(['id' => $data['id']])->update($data);
-        if ($result) {
-            return Result::success();
-        } else {
-            return Result::error("更新状态失败", 0);
-        }
-    }
-    /**
-     * 获取新闻详情
-     * @param array $data
-     * @return array
-     */
-    public function getArticleInfo(array $data): array
-    {
-        $where = [
-            'article.id' => $data['id'],
-            // 'article.status' => 1,
-        ];
-        $result = Article::where($where)->leftJoin("article_data", "article.id", "article_data.article_id")->first();
-        $articleSurvey = ArticleSurvey::where(['art_id' => $data['id']])->get();
-        $info = $result;
-        // var_dump($info, 'info');
-        $info['survey_array'] = $articleSurvey;
-        if ($result) {
-            return Result::success($info);
-        } else {
-            return Result::error("查询失败", 0);
-        }
-    }
-    /**
-     *  获取头条新闻
-     * @param array $data
-     * @return array
-     */
-    public function getWebsiteArticlett(array $data): array
-    {
-        // return Result::success($data['website_id']);
-        $category = WebsiteCategory::where('website_id', $data['website_id'])->pluck('category_id');
-        $category = array_values(array_unique($category->toArray()));
-        $web['website_id'] = $data['website_id'];
-        if ($category) {
-            $where = [
-                'status' => 1,
+        // 处理子级栏目
+        if (isset($item['child']) && $item['child'] !== 'undefined' && $item['child'] !== "") {
+          $childParams = explode(',', $item['child']);
+
+          if (count($childParams) !== 3) {
+            return Result::error("子级栏目:缺少必需参数错误", 0);
+          }
+
+          list($childCatId, $childImgNum, $childTextNum) = $childParams;
+          $cacheKey = "child_{$childCatId}_{$website['website_id']}";
+
+          if (!isset($childCategoryCache[$cacheKey])) {
+            // 查询子栏目信息
+            $childCategoryCache[$cacheKey] = WebsiteCategory::where($website)
+              ->where("category_id", $childCatId)
+              ->whereRaw("JSON_CONTAINS(category_arr_id, '" . intval($childCatId) . "') = 1")
+              ->first(['alias', 'category_id', 'aLIas_pinyin', 'pid', 'category_arr_id as cat_arr_id']);
+          }
+
+          $childCategory = $childCategoryCache[$cacheKey];
+
+          if (!empty($childCategory)) {
+            $childCategory = $this->processArticles($childCategory, $website);
+
+            // 查询此层级的所有子栏目
+            $allChildCategories = WebsiteCategory::where($website)
+              ->where("pid", $childCategory['pid'])
+              ->get(['alias', 'category_id', 'aLIas_pinyin', 'pid', 'category_arr_id as cat_arr_id']);
+
+            $allChildCategories = $this->processArticles($allChildCategories, $website);
+
+            $childResult = [
+              'alias' => $childCategory->alias,
+              'category_id' => $childCategory->category_id,
+              'pinyin' => $childCategory->aLIas_pinyin,
+              'all_childcat' => $allChildCategories,
+              'imgnum' => [],
+              'textnum' => []
             ];
-            var_dump($data, 'data-----------------');
-            // level=7  根据文章key来匹配文章
-            if (isset($data['level']) && $data['level'] == 7) {
-                //  根据文章id获取key
-                // $data['id'] = 50142;
-                if (isset($data['id']) && !empty($data['id'])) {
-                    $keyword = Article::where('id', $data['id'])->value('keyword');
-                    $keywordArray = explode(',', $keyword);
-                    $whereL7 = [];
-                    foreach ($keywordArray as $k => $v) {
-                        $whereL7[] = ['keyword', 'like', '%' . $v . '%'];
-                    }
-                    // 原始查询
-                    $result['level7'] = Article::where($whereL7)
-                        ->when(!empty($data['imgnum']), function ($query) use ($data) {
-                            $query->where('article.imgurl', '!=', '')
-                                ->select('article.*')
-                                ->offset($data['placeid'])
-                                ->limit($data['imgnum']);
-                        })
-                        ->when(!empty($data['textnum']), function ($query) use ($data) {
-                            $query->select('article.*')
-                                ->offset($data['placeid'])
-                                ->limit($data['textnum']);
-                        })
-                        ->orderBy('updated_at', 'desc')
-                        ->get();
-                    $result['level7'] = $this->processArticle($result['level7'], $web);
-                    if (empty($result)) {
-                        return Result::success();
-                    }
-                    return Result::success($result);
-                } else {
-                    return Result::error("参数错误level=7,id不能为空", 0);
-                }
-            }
-            //如果是4:最新资讯(数据库已不存在) 5:资讯推荐(数据库已不存在);
-            // 1:头条资讯;2:轮播图;6:热点资讯;(数据库)
-            var_dump($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");
-                });
-
-            // 处理 level 相关查询条件
-            $query->when($data['level'] == 5, function ($query) {
-                $query->inRandomOrder()
-                    ->where('updated_at', '>', date("Y-m-d H:i:s", strtotime("-30 day")));
-            })->when($data['level'] == 4, function ($query) {
-                $query->orderBy("article.updated_at", "desc");
-            })->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");
-                }
-            });
-            // 初始化结果数组
-            $result = [];
-            // $input = $data['website_id']; 
-            // 处理图片新闻查询
-            if (!empty($data['imgnum'])) {
-                // 原错误提示表明 cleanBindings 方法需要传入数组类型的参数,而实际传入了 null。
-                // 这里克隆查询构建器,确保绑定参数为数组,避免该错误。
-                $imgQuery = clone $query;
-                if ($imgQuery->getBindings() === null) {
-                    $imgQuery->setBindings([]);
-                }
-                $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.cat_arr_id',
-                        'article.catid'
-                    )
-                    ->offset($data['placeid'])
-                    ->limit($data['imgnum'])
-                    ->get();
-                $result['img'] = $this->processArticles($result['img'], $web);
-            }
 
-            // 处理文字新闻查询
-            if (!empty($data['textnum'])) {
-                $textQuery = clone $query;
-                $result['text'] = $textQuery
-                    ->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'
-                    )
-                    ->offset($data['placeid'])
-                    ->limit($data['textnum'])
-                    ->get();
-                $result['text'] = $this->processArticles($result['text'], $web);
+            // 查询子栏目图片新闻
+            if (!empty($childImgNum)) {
+              $childResult['imgnum'] = $this->fetchArticles($childCatId, $website, (int)$childImgNum, true);
             }
 
-            if (empty($result) || count($result) == 0) {
-                return Result::error("暂无头条新闻");
+            // 查询子栏目文字新闻
+            if (!empty($childTextNum)) {
+              $childResult['textnum'] = $this->fetchArticles($childCatId, $website, (int)$childTextNum, false);
             }
-            return Result::success($result);
-        } else {
-            return Result::error("本网站下暂无相关栏目", 0);
+
+            $resultItem['child'] = $childResult;
+          }
         }
+        return $resultItem;
+      }, $items);
+      $cache->set($cacheKey, serialize($result), 86400);
+      return Result::success($result);
+    } catch (\Exception $e) {
+      // 记录错误日志
+      return Result::error("获取网站文章失败: " . $e->getMessage());
     }
-    /**
-     * 获取模块新闻
-     * @param array $data
-     * @return array
-     */
-
-    public function getWebsiteModelArticles(array $data): array
-    {
-        $catid = $data['catid'];
-        $category = WebsiteCategory::where('website_id', $data['website_id'])->where('category_id', $catid)->select('category_id')->get();
-        $category = $category->toArray();
-        if (!empty($category)) {
-            $where = [
-                'status' => 1,
-                'catid' => $catid,
-            ];
-            $placeid = isset($data['placeid']) && !empty($data['placeid']) ? $data['placeid'] - 1 : 0;
-            // 1:文字新闻;2:轮播图;3:图文;
-            // 级别:0:未分类
-            // 3:推荐图片
-            if ($data['level'] == 1) {
-                $data['level'] = 0;
-            }
-            $result = Article::where($where)
-                ->where(function ($query) use ($data) {
-                    $query->whereRaw("JSON_CONTAINS(level, '" . intval($data['level']) . "') = 1")
-                        ->orWhereNull("level")
-                        ->orWhereRaw("level = '[]'");
-                })
-                ->where(function ($query) use ($data) {
-                    $query->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($data['website_id']) . "') = 0")
-                        ->orWhereNull("ignore_ids");
-                })
-                ->orderBy("updated_at", "desc")
-                ->offset($placeid)
-                ->limit($data['pagesize'])
-                ->get();
-            if (empty($result)) {
-                return Result::error("此栏目暂无相关新闻", 0);
-            }
-        } else {
-            return Result::error("此网站暂无此栏目", 0);
-        }
-        return Result::success($result);
+  }
+
+  /**
+   * 辅助方法:获取文章列表
+   */
+  private function fetchArticles($catId, $website, $limit, $isImageArticle = false)
+  {
+    sleep(1);
+    $query = Article::where('article.status', 1)
+      // 使用更高效的查询方式,避免使用 JSON_CONTAINS 函数,如果可能的话,将 cat_arr_id 拆分为单独的字段
+      ->whereRaw("(FIND_IN_SET('$catId', REPLACE(REPLACE(cat_arr_id, '[', ''), ']', '')))")
+      ->where(function ($query) use ($website) {
+        $query->whereRaw("(JSON_CONTAINS(ignore_ids, '" . intval($website['website_id']) . "') = 0 OR ignore_ids IS NULL)");
+      })
+      ->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($limit);
+
+    // 如果是图片文章,添加图片URL条件
+    if ($isImageArticle) {
+      $query->where('imgurl', '!=', '');
+    } else {
+      // 文字文章不需要imgurl字段
+      $query->addSelect('article.introduce');
     }
 
-    /**
-     *获取新闻列表 
-     * @param array $data
-     * @return array
-     */
-    public function getWebsiteArticleList(array $data): array
-    {
-        // return Result::success($data);
-        $where[] = ['status', '=', 1];
-        if (isset($data['catid']) && !empty($data['catid'])) {
-            $category = WebsiteCategory::where('website_id', $data['website_id'])->where('category_id', $data['catid'])->pluck('category_id');
-            array_push($where, ['catid', '=', $data['catid']]);
-            if (empty($category)) {
-                return Result::error("此网站暂无此栏目", 0);
-            }
-        }
-        // return Result::success($where);
-        $rep = Article::where($where)
-            ->where(function ($query) use ($data) {
-                $query->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($data['website_id']) . "') = 0")
-                    ->orWhereNull("ignore_ids");
-            })
+    $articles = $query->get();
+
+    return !empty($articles) ? $this->processArticles($articles, $website) : [];
+  }
+  /**
+   * 乡村网-获取特殊新闻模块
+   * @param array $data
+   * @return array
+   */
+  public function getWebsiteArticles(array $data): array
+  {
+    $input['id'] = $data['id'];
+    $input['website_id'] = $data['website_id'];
+    $data = json_decode($input['id'], true);
+    // 使用 array_map 处理每个元素 
+    $result = array_map(function ($item) use ($input) {
+      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']);
+      $pinyin = $category->aLIas_pinyin ? $category->aLIas_pinyin : null;
+      if (empty($category)) {
+        $imgArticles = [];
+        $textArticles = [];
+        // return Result::error("暂无此栏目",0); 
+      } else {
+        $child_category = WebsiteCategory::where('pid', $parentCatId)->where($website)->pluck('category_id')->toArray();
+        $parent_alias = $category->aLIas_pinyin ? $category->aLIas_pinyin . '/' : null;
+        // return Result::success($website);
+        // 查询图片新闻 
+        // 合并查询条件
+        $baseQuery = Article::where(function ($query) use ($website) {
+          $query->where(function ($subQuery) use ($website) {
+            $subQuery->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($website['website_id']) . "') = 0");
+          })->orWhereNull("ignore_ids");
+        })
+
+          ->where('article.status', 1)
+          ->leftJoin('website_category', 'website_category.category_id', 'article.catid')
+          ->where('website_category.website_id', $website['website_id']);
+
+        // 查询文字新闻
+        $textArticles = clone $baseQuery;
+        $textArticles = $textArticles->whereIn('catid', $child_category)
+          ->select(
+            'article.id',
+            'article.title',
+            // 'article.imgurl',
+            'article.author',
+            'article.updated_at',
+            'article.introduce',
+            'article.islink',
+            'article.linkurl',
+            'article.copyfrom',
+            'website_category.category_id',
+            'website_category.alias',
+            'website_category.aLIas_pinyin'
+          )
+          ->selectRaw("CONCAT(?, aLIas_pinyin) as aLIas_pinyin", [$parent_alias])
+          ->orderBy('article.updated_at', 'desc')
+          ->limit($parentTextNum)
+          ->get()
+          ->all();
+        if (empty($textArticles)) {
+          $textArticles = clone $baseQuery;
+          $textArticles = $textArticles->where('catid', $parentCatId)
             ->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'
+              'article.id',
+              'article.title',
+              // 'article.imgurl',
+              'article.author',
+              'article.updated_at',
+              'article.introduce',
+              'article.islink',
+              'article.linkurl',
+              'article.copyfrom',
+              'website_category.category_id',
+              'website_category.alias',
+              'website_category.aLIas_pinyin'
             )
-            ->orderBy("updated_at", "desc")
-            ->offset(($data['page'] - 1) * $data['pageSize'])
-            ->limit($data['pageSize'])
-            ->get();
-        $web['website_id'] = $data['website_id'];
-        $rep = $this->processArticles($rep, $web);
-        $count = Article::where($where)
-            ->where(function ($query) use ($data) {
-                $query->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($data['website_id']) . "') = 0")
-                    ->orWhereNull("ignore_ids");
-            })->count();
-
-        $data = [
-            'rows' => $rep->toArray(),
-            'count' => $count,
-        ];
-
-        if (empty($rep)) {
-            return Result::error("没有信息数据");
-        }
-        return Result::success($data);
-    }
-    /**
-     * 前端-获取新闻详情
-     * @param array $data
-     * @return array
-     */
-    public function selectWebsiteArticleInfo(array $data): array
-    {
-        $where = [
-            'article.id' => $data['id'],
-            'article.status' => 1,
-        ];
-
-        $result = Article::where($where)->leftJoin("article_data", "article.id", "article_data.article_id")
-            ->where(function ($query) use ($data) {
-                $query->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($data['website_id']) . "') = 0")
-                    ->orWhereNull("ignore_ids");
-            })
-            ->first();
-        if (empty($result)) {
-            return Result::error("暂无此新闻!", 0);
+            ->selectRaw("CONCAT(?, aLIas_pinyin) as aLIas_pinyin", [$parent_alias])
+            ->orderBy('article.updated_at', 'desc')
+            ->limit($parentTextNum)
+            ->get()
+            ->all();
         }
-        $category = WebsiteCategory::leftJoin('website', 'website.id', '=', 'website_category.website_id')
-            ->select('website_category.*', 'website.website_name', 'website.suffix')
-            ->where('website_category.website_id', $data['website_id'])
-            ->where(['website_category.category_id' => $result['catid']])
-            ->first();
-        if (empty($category)) {
-            return Result::error("查询失败", 0);
+        // 查询图片新闻
+        $imgArticles = clone $baseQuery;
+        $imgArticles = $imgArticles->where('imgurl', '!=', '')->whereIn('catid', $child_category)
+          ->select(
+            'article.id',
+            'article.title',
+            'article.imgurl',
+            'article.author',
+            'article.updated_at',
+            'article.introduce',
+            'article.islink',
+            'article.linkurl',
+            'article.copyfrom',
+            'website_category.category_id',
+            'website_category.alias',
+            'website_category.aLIas_pinyin'
+          )
+          ->selectRaw("CONCAT(?, aLIas_pinyin) as aLIas_pinyin", [$parent_alias])
+          ->orderBy('article.updated_at', 'desc')
+          ->limit($parentImgNum)
+          ->get()
+          ->all();
+        if (empty($imgArticles)) {
+          $imgArticles = clone $baseQuery;
+          $imgArticles = $imgArticles->where('imgurl', '!=', '')->where('catid', $parentCatId)
+            ->select(
+              'article.id',
+              'article.title',
+              'article.imgurl',
+              'article.author',
+              'article.updated_at',
+              'article.introduce',
+              'article.islink',
+              'article.linkurl',
+              'article.copyfrom',
+              'website_category.category_id',
+              'website_category.alias',
+              'website_category.aLIas_pinyin'
+            )
+            ->selectRaw("CONCAT(?, aLIas_pinyin) as aLIas_pinyin", [$parent_alias])
+            ->orderBy('article.updated_at', 'desc')
+            ->limit($parentImgNum)
+            ->get()
+            ->all();
         }
-        //手动推荐文章
-        $commend_ids = $result['commend_id'] ? json_decode($result['commend_id']) : [];
-        $commendArticle = Article::whereIn('id', $commend_ids)
-            ->where('status', 1)
-            ->select('id', 'title', 'catid', 'imgurl', 'hits', 'created_at')
+      }
+      $resultItem = [
+        'alias' => $category ? $category->alias : null,
+        'category_id' => $parentCatId,
+        'pinyin' => $pinyin ? $pinyin : null,
+        'imgnum' => $imgArticles ?? [],
+        'textnum' => $textArticles ?? [],
+
+      ];
+
+
+      return $resultItem;
+    }, $data);
+    return Result::success($result);
+  }
+
+
+  // 封装处理商品的路由问题
+  function processGoods($goods, $data)
+  {
+    return $goods->map(function ($good) use ($data) {
+      $catid = $good->catid ?? 0;
+      //     $pinyin = '';
+      $category = WebsiteCategory::where('category_id', $catid)->where('website_id', $data['website_id'])->first();
+      if (!empty($category->pid) && $category->pid != 0) {
+        $level = json_decode($category->category_arr_id);
+        $pinyin = WebsiteCategory::where('website_id', $data['website_id'])
+          ->whereIn('category_id', $level)
+          ->orderByRaw('FIELD(category_id, ' . implode(',', $level) . ')')
+          ->get(['aLIas_pinyin'])
+          ->pluck('aLIas_pinyin')
+          ->implode('/');
+      } else {
+        $pinyin = $category->aLIas_pinyin ?? '';
+      }
+      if (isset($good->city_id) && !empty($good->city_id)) {
+        $city = District::where('id', $good->city_id)->first(['name']);
+        $good->city_name = $city->name ?? '';
+      }
+      // 解析imgurl JSON并取第一条数据
+      $imgUrls = json_decode($good->imgurl, true);
+      $good->imgurl = !empty($imgUrls) ? $imgUrls[0] : null;
+      $good->pinyin = $pinyin;
+      return $good;
+    });
+  }
+  /**
+   * 获取商城首页-根据栏目id
+   * @param array $data
+   * @return array
+   *  */
+  function getWebsiteCatidshop(array $data): array
+  {
+    $input['catid'] = $data['catid'];
+    $input['website_id'] = $data['website_id'];
+    $data = json_decode($input['catid'] ?? '', true) ?? [];
+    $result = array_map(function ($item) use ($input) {
+      if (isset($item['catid']) && $item['catid'] != 'undefined' && $item['catid'] != "") {
+        list($catid, $goodStart, $goodNum) = explode(',', $item['catid']);
+        $category = WebsiteCategory::where('category_id', $catid)->where('website_id', $input['website_id'])->first(['type']);
+        // 类型:1资讯(默认)2商品3书刊音像4招聘5求职类型:1资讯(默认)2商品3书刊音像4招聘5求职6招工招聘
+        if (empty($category) || $category->type != 2) {
+          return Result::error("暂无此栏目", 0);
+        } else {
+          $website['website_id'] = $input['website_id'];
+          $goods = Good::where('good.status', 2)
+            ->where('good.website_id', $website['website_id'])
+            ->whereRaw("JSON_CONTAINS(good.cat_arr_id, '" . intval($catid) . "') = 1")
+            ->select(
+              'good.id',
+              'good.name',
+              'good.imgurl',
+              'good.description',
+              'good.updated_at',
+              'good.catid',
+              'good.type_id',
+              'good.price',
+              'good.com',
+              'good.level',
+              'good.unit'
+            )
             ->orderBy('updated_at', 'desc')
-            ->limit(5)
-            ->get();
-        $result['category_id'] = $category['category_id'];
-        $result['cat_name'] = $category['alias'];
-        $result['website_name'] = $category['website_name'] ?? "";
-        $result['suffix'] = $category['suffix'] ?? "";
-        $result['commendArticle'] = $commendArticle;
-        return Result::success($result);
+            ->offset($goodStart)
+            ->limit($goodNum);
+          $all_goods = $goods->get();
+          $all_goods = $this->processGoods($all_goods, $website);
+        }
+
+        return $all_goods ?? [];
+      }
+    }, $data);
+    return Result::success($result);
+  }
+  /**
+   * 获取商品模块
+   * @param array $data
+   * @return array
+   *  */
+  public function getWebsiteshop(array $data): array
+  {
+    $input['id'] = $data['id'];
+    $input['website_id'] = $data['website_id'];
+    $catid = $data['catid'];
+    $data = json_decode($input['id'] ?? '', true) ?? [];
+    $result['goods'] = array_map(function ($item) use ($input) {
+      // 检查parent元素是否存在且不是undefined
+      if (isset($item['level']) && $item['level'] != 'undefined' && $item['level'] != "") {
+        list($Levelid, $goodStart, $goodNum) = explode(',', $item['level']);
+        $website = $input['website_id'];
+        $query = Good::where('good.status', 2)
+          ->where('good.website_id', $website);
+        switch ($Levelid) {
+          case 1:
+          case 2:
+          case 3:
+            $goods = $query->where(function ($q) use ($Levelid) {
+              $q->whereRaw("JSON_CONTAINS(good.level, '" . intval($Levelid) . "') = 1")
+                ->orWhereRaw("JSON_CONTAINS(good.level, '\"" . intval($Levelid) . "\"') = 1");
+            });
+            break;
+          case 4:
+            $goods = $query;
+            break;
+          case 5:
+            $goods = $query->where('type_id', 1);
+            break;
+          case 6:
+            $goods = $query->where('type_id', 2);
+            break;
+          default:
+            return [];
+        }
+        $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')
+          ->offset($goodStart)
+          ->limit($goodNum)
+          ->get();
+        $web['website_id'] = $website;
+        $all_goods = $this->processGoods($all_goods, $web);
+      }
+      return  $all_goods;
+    }, $data);
+    $website = $input['website_id'];
+    $result['article'] = Article::where(function ($query) use ($website) {
+      $query->where(function ($subQuery) use ($website) {
+        $subQuery->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($website) . "') = 0");
+      })->orWhereNull("ignore_ids");
+    })
+      ->where('catid', $catid)
+      ->where('article.status', 1)
+      ->leftJoin('article_data', 'article_data.article_id', 'article.id')
+      ->select('article.id', 'article.title', 'article.updated_at', 'introduce', 'islink', 'linkurl', 'article_data.content')
+      ->orderBy('article.updated_at', 'desc')
+      ->first();
+    return Result::success($result);
+  }
+  /**
+   * 获取商品分类
+   * @param array $data
+   * @return array
+   *  */
+  public function getWebsiteshopCat(array $data): array
+  {
+    $website = $data['website_id'];
+    $category = WebsiteCategory::where('website_id', $website)
+      ->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', 'sort')
+      ->orderBy('sort')
+      ->get();
+    $cat =  $category->map(function ($item) use ($website) {
+      $cat_arr_id = json_decode($item->category_arr_id, true) ?? [];
+      $pid = $item->pid ?? 0;
+      if (!empty($cat_arr_id) && is_array($cat_arr_id) && $pid != 0) {
+        $pinyin = WebsiteCategory::whereIn('category_id', $cat_arr_id)
+          ->where('website_id', $website)
+          ->orderByRaw('FIELD(category_id, ' . implode(',', $cat_arr_id) . ')')
+          ->get(['aLIas_pinyin'])
+          ->pluck('aLIas_pinyin')
+          ->implode('/');
+      } else {
+        $pinyin = $item->aLIas_pinyin ?? '';
+      }
+      $item->pinyin = $pinyin;
+    });
+    if (empty($category)) {
+      return Result::error("栏目查询失败", 0);
+    }
+    $cat_tree = Result::buildMenuTree($category);
+    $web['website_id'] = $website;
+    $goods = Good::where('website_id', $website)
+      ->where('status', 2)
+      ->select('good.id as good_id', 'name', 'imgurl', 'description', 'updated_at', 'catid', 'type_id', 'website_id')
+      ->latest('updated_at')
+      ->offset(($data['page'] - 1) * $data['pageSize'])
+      ->limit($data['pageSize'])
+      ->get();
+    if (!empty($goods)) {
+      if ($goods->count() > 1 && !empty($goods)) {
+        $goods = $this->processGoods($goods, $web);
+      }
+    } else {
+      $goods = [];
     }
 
-    /**
-     * 前端-获取网站调查问卷
+    $result = [
+      'category' => $cat_tree,
+      'goods' => $goods,
+    ];
+    // $resul['goods'] = $goods;
+    if (empty($result)) {
+      return Result::error("查询失败", 0);
+    }
+    return Result::success($result);
+  }
+  /*
+     * 获取商品列表
      * @param array $data
      * @return array
-     */
-    public function getWebsiteSurvey(array $data): array
-    {
-        if (isset($data['website_id']) && !empty($data['website_id'])) {
-            $website = Website::where('id', $data['website_id'])->first();
-            if (empty($website)) {
-                return Result::error("暂无此网站", 0);
-            }
-        }
-        if (isset($data['art_id']) && !empty($data['art_id'])) {
-            $article = Article::where('id', $data['art_id'])->where('status', 1)->first();
-            if (empty($article)) {
-                return Result::error("暂无此文章", 0);
-            }
-            // return Result::error($data,0);
-            $where['art_id'] = $data['art_id'];
-            // $query = ArticleSurvey::where('art_id',$data['art_id']);
-
-        } else {
-            $survey = Article::where(function ($query) {
-                $query->whereRaw("JSON_CONTAINS(cat_arr_id, '28')")
-                    ->orWhereRaw("JSON_CONTAINS(cat_arr_id, '\"28\"')");
-            })
-                ->where('status', 1)
-                ->where('is_survey', 1)
-                ->select('survey_id')
-                ->orderBy('updated_at', 'desc')
-                ->first();
-            if (empty($survey)) {
-                return Result::error("暂无调查问卷", 0);
-            }
-            $where['sur_id'] = $survey['survey_id'];
-            // $query = ArticleSurvey::where('sur_id',$survey['sur_id']);
-        }
-        // return Result::success($where);
-        $result = ArticleSurvey::where($where)
-            ->where(function ($query) {
-                $query->where('is_other', 0)
-                    ->orWhere(function ($subQuery) {
-                        $subQuery->where('is_other', 1)
-                            ->where('other_id', 0);
-                    });
-            })
-            ->leftJoin('article', 'article_survey.art_id', 'article.id')
-            ->select('article_survey.*', 'article.survey_type')
-            ->get()->all();
-        if (empty($result)) {
-            return Result::error("此文章暂无调查问卷", 0);
-        }
-        return Result::success($result);
+     *  */
+  public function getWebsiteshopList(array $data): array
+  {
+    // return Result::success($data);
+    $where = [
+      'status' => 2,
+      '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']))) {
+      return Result::error("查询失败", 0);
     }
-    /**
-     * 前端-添加网站调查问卷选项
-     * @param array $data
-     * @return array
-     */
-    public function addWebsiteSurveyOption(array $data): array
-    {
-        if (isset($data['website_id']) && !empty($data['website_id'])) {
-            $website = Website::where('id', $data['website_id'])->first();
-            if (empty($website)) {
-                return Result::error("暂无此网站", 0);
-            }
-            if (isset($data['sur_id']) && !empty($data['sur_id'])) {
-                $survey = ArticleSurvey::where('sur_id', $data['sur_id'])->where('is_other', 1)->where('other_id', 0)->first();
-                if (empty($survey)) {
-                    return Result::error("此调查问卷不可添加选项", 0);
-                }
-                if (isset($data['choice_name']) && !empty($data['choice_name'])) {
-                    $choice = [
-                        'art_id' => $survey['art_id'],
-                        'website_id' => $data['website_id'],
-                        'survey_name' => $survey['survey_name'],
-                        'choice_name' => $data['choice_name'],
-                        'sur_id' => $survey['sur_id'],
-                        'is_other' => 1,
-                        'other_id' => $survey['id'],
-
-                    ];
-                    $result = ArticleSurvey::insertGetId($choice);
-                    if (empty($result)) {
-                        return Result::error("添加失败", 0);
-                    }
-                    return Result::success($result);
-                }
-            }
-            return Result::error("添加失败", 0);
-        }
-        return Result::error("添加失败", 0);
+    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']);
+      $data['catid'] = $category->category_id ??  0;
     }
-    /**
-     * 前端-调查问卷投票
-     * @param array $data
-     * @return array
-     */
-    public function addWebsiteSurveyVote(array $data): array
-    {
-        // return Result::success($data);
-        if (isset($data['website_id']) && !empty($data['website_id'])) {
-            $website = Website::where('id', $data['website_id'])->first();
-            if (empty($website)) {
-                return Result::error("暂无此网站", 0);
-            }
-            if (isset($data['sur_id']) && !empty($data['sur_id'])) {
-                $is_survey = ArticleSurvey::where('sur_id', $data['sur_id'])->first();
-                // return Result::success($survey);
-                if (empty($is_survey)) {
-                    return Result::error("此调查问卷不存在", 0);
-                }
-                // return Result::success($survey);
-                // 调查问卷类型
-                if (isset($data['choice_id']) && !empty($data['choice_id'])) {
-                    //多选 若是json型则转化成数组类型
-                    if (strpos($data['choice_id'], '[') === 0) {
-                        $data['choice_id'] = json_decode($data['choice_id'], true);
-                    } else {
-                        // 单选  也转换成数组
-                        $data['choice_id'] = [$data['choice_id']];
-                    }
-                    $data['choice_id'] = array_map('intval', $data['choice_id']);
-                    $other = ArticleSurvey::whereIn('id', $data['choice_id'])
-                        // ->where('website_id',$data['website_id'])
-                        ->where('is_other', 1)
-                        ->where('other_id', 0)
-                        ->first();
-                    if (!empty($other)) {
-                        return Result::error("请选择已有的选项!", 0);
-                    }
-                    $choice['other'] = ArticleSurvey::whereIn('id', $data['choice_id'])
-                        // ->where('website_id',$data['website_id'])
-                        ->where('is_other', 1)
-                        ->where('other_id', '!=', 0)
-                        ->first();
-                    // return Result::success($choice['other']);
-                    $choice_id = $data['choice_id'];
-                    if (!empty($choice['other'])) {
-                        // array_push($data['choice_id'],$choice['other']['other_id']);
-                        if (!empty($choice_id)) {
-                            $key = array_search($choice['other']['id'], $choice_id);
-                            if ($key !== false) {
-                                unset($choice_id[$key]);
-                                $choice_id = array_values($choice_id);
-                            }
-                            array_push($choice_id, $choice['other']['other_id']);
-                        } else {
-                            $choice_id[0] = $choice['other']['other_id'];
-                        }
-                        array_push($data['choice_id'], $choice['other']['other_id']);
-                    }
-                    // return Result::success($data);
-                    $choice = ArticleSurvey::whereIn('id', $data['choice_id'])
-                        // ->where('website_id',$data['website_id'])
-                        ->increment('results', 1);
-                    if (empty($choice)) {
-                        return Result::error("请选择已有的选项!", 0);
-                    }
-                    $survey['data'] = ArticleSurvey::where('sur_id', $data['sur_id'])
-                        // ->where('website_id',$data['website_id'])
-                        ->where('other_id', 0)
-                        ->get();
-                    $survey['choice'] = $choice_id;
-                    return Result::success($survey);
-                }
-                return Result::error("参数必填!");
-            }
-            return Result::error("此调查问卷不存在", 0);
-        }
-        return Result::error("参数必填!");
+    if (isset($data['keyword']) && !empty($data['keyword'])) {
+      array_push($where, ['name', 'like', '%' . $data['keyword'] . '%']);
     }
-    /**
-     * 后端-获取网站调查问卷列表
-     * @param array $data
-     * @return array
-     */
-    public function getSurveyList(array $data): array
-    {
-        $where = [];
-        if (isset($data['survey_name']) && !empty($data['survey_name'])) {
-            array_push($where, ['survey_name', 'like', '%' . $data['survey_name'] . '%']);
-        }
-        if (isset($data['survey_type']) && $data['survey_type'] != null) {
-            array_push($where, ['survey_type', '=', $data['survey_type']]);
-        }
-        if (isset($data['is_survey']) && $data['is_survey'] != null) {
-            array_push($where, ['is_survey', '=', $data['is_survey']]);
-        }
-        // return Result::success($where);
-
-        if (!empty($where)) {
-            $query = Article::where($where)->where(function ($q) {
-                $q->whereNotNull('survey_name')->where('survey_name', '!=', '');
-            });
-        } else {
-            $query = Article::where(function ($q) {
-                $q->whereNotNull('survey_name')->where('survey_name', '!=', '');
-            });
-        }
-
-        $count = $query->count();
-        $survey = $query->orderByDesc('id')
-            ->limit($data['pageSize'])
-            ->offset(($data['page'] - 1) * $data['pageSize'])
-            ->get();
-        if (empty($survey->toArray())) {
-            return Result::error("暂无调查问卷!", 0);
-        }
-        $result = [
-            'rows' => $survey,
-            'count' => $count,
-        ];
-        return Result::success($result);
+    if (isset($data['type_id']) && !empty($data['type_id'])) {
+      array_push($where, ['type_id', $data['type_id']]);
     }
-    /**
-     * 后端-获取网站调查问卷详情
-     * @param array $data
-     * @return array
-     */
-    public function getSurveyInfo(array $data): array
-    {
-        if (isset($data['sur_id']) && !empty($data['sur_id'])) {
-            $where = ['sur_id' => $data['sur_id']];
-            $choose = ArticleSurvey::where($where)->where('is_other', 0)
-                ->leftJoin('article', 'article_survey.art_id', 'article.id')
-                ->select('article_survey.*', 'article.survey_type')
-                ->get()->all();
-            if (empty($choose)) {
-                return Result::error("此调查问卷不存在", 0);
-            }
-            $resultsArray = array_column($choose, 'results');
-            $total = array_sum($resultsArray);
-            $other = ArticleSurvey::where($where)->where('is_other', 1)->where('other_id', 0)->first();
-            $others = ArticleSurvey::where($where)->where('is_other', 1)->where('other_id', '!=', 0)->orderByDesc('created_at')->get()->all();
-            // $total = 0;
-            if (!empty($other)) {
-                $total = $total + $other['results'];
-                $other['choice_name'] = '(其他)';
-                if (!empty($others)) {
-                    $other['hasChildren'] = true;
-                    // array_push($other,['hasChildren','=',true]);
-                    $other['children'] = $others;
-                    $other_choices = [$other->toArray()];
-                    $mer_choice = array_merge($choose, $other_choices);
-                    $value_choice = array_values($mer_choice);
-                } else {
-                    // return Result::error('1111');
-                    $other_choices = [$other->toArray()];
-                    $other_choices = array_merge($choose, $other_choices);
-                    $value_choice = array_values($other_choices);
-                    // return Result::success($result);
-                }
-            } else {
-                $value_choice = $choose;
-            }
-            $result = [
-                'choose' => $value_choice,
-                'total' => $total,
-            ];
-        }
-        return Result::success($result);
+    $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['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");
+        });
+      })
+      ->select(
+        'good.id',
+        'good.name',
+        'good.imgurl',
+        'good.description',
+        'good.updated_at',
+        'good.com',
+        'good.catid',
+        'good.type_id',
+        'good.website_id',
+        'good.cat_arr_id',
+        'good.created_at',
+        'good.city_id'
+      )
+      ->latest('updated_at');
+    $result['type1_count'] = $query->clone()->where('type_id', 1)->count();
+    // 获取 type_id 为 1 的数据
+    $result['type1'] = $this->processGoods(
+      $query->clone()
+        ->where('type_id', 1)
+        ->offset(($data['page'] - 1) * $data['pageSize'])
+        ->limit($data['pageSize'])
+        ->get(),
+      $data
+    );
+    $result['type2_count'] = $query->clone()->where('type_id', 2)->count();
+    // 获取 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);
     }
 
-    /**
-     * 前端-搜索新闻列表
-     * @param array $data
-     * @return array
-     */
-    public function selectWebsiteArticle(array $data): array
-    {
-        $category = WebsiteCategory::where('website_id', $data['website_id'])->pluck('category_id');
-        $query = Article::where('status', 1)
-            ->whereIn('catid', $category)
-            ->where(function ($query) use ($data) {
-                $query->where(function ($subQuery) use ($data) {
-                    $subQuery->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($data['website_id']) . "') = 0");
-                })->orWhereNull("ignore_ids");
-            });
-        // return Result::success($all_articles);
-        if (isset($data['cityid']) && !empty($data['cityid'])) {
-            $query->whereRaw("JSON_CONTAINS(city_arr_id, '" . intval($data['cityid']) . "')");
-        }
-        if (isset($data['department_id']) && !empty($data['department_id'])) {
-            $query->whereRaw("JSON_CONTAINS(department_arr_id, '" . intval($data['department_id']) . "')");
-        }
-        if (isset($data['keyword']) && !empty($data['keyword'])) {
-            $query->where('title', 'like', '%' . $data['keyword'] . '%');
-        }
-        // 计算总数
-        $count = $query->count();
-        // 分页查询
-        $articles = $query
-            ->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',
-                'article.department_arr_id',
-                'article.city_arr_id',
-            )
-            ->orderBy("updated_at", "desc")
-            ->offset(($data['page'] - 1) * $data['pageSize'])
-            ->limit($data['pageSize'])
-            ->get();
-        $web['website_id'] = $data['website_id'];
-        $articles = $this->processArticles($articles, $web);
-        if (empty($articles)) {
-            return Result::error("没有符合条件的资讯数据");
-        }
-        $result = [
-            'rows' => $articles,
-            'count' => $count,
-        ];
-        return Result::success($result);
+    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);
     }
-
-    /**
-     * 模块新闻加强版
-     * @param array $data
-     * @return array
-     */
-    public function getWebsiteCatidArticle(array $data): array
-    {
-        $where = [
-            'website_category.category_id' => $data['catid'],
-            'website_category.website_id' => $data['website_id'],
-        ];
-        // $category = WebsiteCategory::where($where);
-        if (isset($data['child_catnum']) && !empty($data['child_catnum'])) {
-            $child_catnum = $data['child_catnum'] ?? 1;
-            $category['child'] = WebsiteCategory::where('pid', $data['catid'])->where('website_id', $data['website_id'])->select('category_id', 'alias')->limit($child_catnum)->get()->toArray();
-            $childCategoryIds = array_column($category['child'], 'category_id');
-            if (empty($childCategoryIds)) {
-                return Result::error("暂无子栏目", 0);
-            }
-            $imgArticles = [];
-            $textArticles = [];
-            // return Result::success($childCategoryIds);
-            if (isset($data['child_imgnum']) && !empty($data['child_imgnum']) && $data['child_imgnum'] != 0) {
-                // 初始化子分类图片新闻和文字新闻数组
-
-                // 查询所有子级栏目的图文新闻
-                $imgArticles = Article::where('catid', $childCategoryIds[0])
-                    ->where(function ($query) use ($data) {
-                        $query->where(function ($subQuery) use ($data) {
-                            $subQuery->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($data['website_id']) . "') = 0");
-                        })->orWhereNull("ignore_ids");
-                    })
-                    ->where('status', 1)
-                    ->where('imgurl', '!=', '')
-                    ->select('*')
-                    ->orderBy('updated_at', 'desc')
-                    ->limit($data['child_imgnum'])
-                    ->get();
-            }
-            if (isset($data['child_textnum']) && !empty($data['child_textnum']) && $data['child_textnum'] != 0) {
-                // 查询所有子级栏目的文字新闻
-                $textArticles = Article::where('catid', $childCategoryIds[0])
-                    ->where('status', 1)
-                    ->where(function ($query) use ($data) {
-                        $query->where(function ($subQuery) use ($data) {
-                            $subQuery->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($data['website_id']) . "') = 0");
-                        })->orWhereNull("ignore_ids");
-                    })
-                    ->select('*')
-                    ->orderBy('updated_at', 'desc')
-                    ->limit($data['child_textnum'])
-                    ->get();
-            }
-            // 遍历子分类,将图文新闻和文字新闻分别添加到子分类中
-            $category['child'] = array_map(function ($child) use ($imgArticles, $textArticles) {
-                $child['img'] = $imgArticles ? $imgArticles->where('catid', $child['category_id']) : [];
-                $child['text'] = $textArticles ? $textArticles->where('catid', $child['category_id']) : [];
-                return $child;
-            }, $category['child']);
-        }
-        // }
-        if (isset($data['img_num']) && !empty($data['img_num'])) {
-            $category['img'] = WebsiteCategory::where($where)
-                ->leftJoin('article', 'article.catid', 'website_category.category_id')
-                ->where('article.status', 1)
-                ->where('article.imgurl', '!=', '')
-                ->select('article.*', 'website_category.category_id', 'website_category.alias')
-                ->orderBy('article.updated_at', 'desc')
-                ->limit($data['img_num'])
-                ->get();
-        }
-
-        if (isset($data['text_num']) && !empty($data['text_num'])) {
-            $category['text'] = WebsiteCategory::where($where)
-                ->leftJoin('article', 'article.catid', 'website_category.category_id')
-                ->where('article.status', 1)
-                ->select('article.*', 'website_category.category_id', 'website_category.alias')
-                ->orderBy('article.updated_at', 'desc')
-                ->limit($data['text_num'])
-                ->get();
-        }
-
-        // $category = $category->get();
-
-        if (empty($category)) {
-            return Result::error("查询失败", 0);
-        }
-        return Result::success($category);
+    $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);
+        }
+        $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;
     }
-    /**
-     * 模块新闻加强版 
-     * @param array $data
-     * @return array
-     */
-    public function getWebsiteAllArticle(array $data): array
-    {
-
-        // $redisKey = 'website_cache';
-        // $this->redis->hSet($redisKey, $data['website_id'], json_encode($data));
-        // $result = $this->redis->sadd($redisKey);
-        // 使用缓存键
-        // $cacheKey = $data['website_id'];
-
-        //  // 尝试从缓存获取数据
-        $container = \Hyperf\Context\ApplicationContext::getContainer();
-        $cache = $container->get(\Psr\SimpleCache\CacheInterface::class);
-        // 修正传入的字符串,将单引号替换为双引号
-        $input['id'] = $data['id'];
-        $input['website_id'] = $data['website_id'];
-
-        // 将 JSON 字符串转换为 PHP 数组
-        $items = json_decode($input['id'], true);
-
-        if (!is_array($items)) {
-            return Result::error("无效的JSON格式", 0);
-        }
-
+  }
+  // 封装处理由问题
+  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'],
+          'website_id' => $input['website_id'],
         ];
-        foreach ($items as $key => $item) {
-            if (isset($item['parent']) && $item['parent'] !== "") {
-                $parentParams = explode(',', $item['parent']);
-                if (isset($parentParams) && $parentParams[0] !== "") {
-                    $parentCatId[$key] = $parentParams[0];
-                }
-            } else {
-                return Result::error("缺少必需参数错误", 0);
-            }
-        }
-        $pid = WebsiteCategory::whereIn('category_id', $parentCatId)->where($website)->pluck('pid')->toArray();
-        // return Result::success($pid);
-        if (!empty($pid)) {
-            $pid = array_values(array_unique($pid));
-            if (count($pid) == 1) {
-                $cacheKey = $data['website_id'] . ',' . $pid[0];
-            } else {
-                return Result::error("参数传递错误", 0);
-            }
-        }
-        // return Result::success($cacheKey);
-        if ($cachedData = $cache->get($cacheKey)) {
-            return Result::success(unserialize($cachedData));
-        }
-        try {
-
-
-            // 提前缓存常用查询结果,减少重复查询
-            $categoryCache = [];
-            $childCategoryCache = [];
-
-            // 使用 array_map 处理每个元素
-            $result = array_map(function ($item) use ($website, &$categoryCache, &$childCategoryCache) {
-                $resultItem = [
-                    'alias' => null,
-                    'category_id' => null,
-                    'pinyin' => null,
-                    'imgnum' => [],
-                    'textnum' => [],
-                    'child' => []
-                ];
-
-                // 处理父级栏目
-                if (isset($item['parent']) && $item['parent'] !== 'undefined' && $item['parent'] !== "") {
-                    $parentParams = explode(',', $item['parent']);
-
-                    if (count($parentParams) !== 3) {
-                        return Result::error("父级栏目:缺少必需参数错误", 0);
-                    }
-
-                    list($parentCatId, $parentImgNum, $parentTextNum) = $parentParams;
-                    $cacheKey = "parent_{$parentCatId}_{$website['website_id']}";
-
-                    if (!isset($categoryCache[$cacheKey])) {
-                        // 查询栏目名称
-                        $categoryCache[$cacheKey] = WebsiteCategory::where('category_id', $parentCatId)
-                            ->where($website)
-                            ->first(['alias', 'category_id', 'aLIas_pinyin', 'type']);
-                    }
-
-                    $category = $categoryCache[$cacheKey];
-
-                    if (!empty($category)) {
-                        $resultItem['alias'] = $category->alias;
-                        $resultItem['category_id'] = $category->category_id;
-                        $resultItem['pinyin'] = $category->aLIas_pinyin;
-
-                        // 查询图片新闻
-                        if (!empty($parentImgNum)) {
-                            $resultItem['imgnum'] = $this->fetchArticles($parentCatId, $website, (int)$parentImgNum, true);
-                        }
-
-                        // 查询文字新闻
-                        if (!empty($parentTextNum)) {
-                            $resultItem['textnum'] = $this->fetchArticles($parentCatId, $website, (int)$parentTextNum, false);
-                        }
-                    }
-                }
-
-                // 处理子级栏目
-                if (isset($item['child']) && $item['child'] !== 'undefined' && $item['child'] !== "") {
-                    $childParams = explode(',', $item['child']);
-
-                    if (count($childParams) !== 3) {
-                        return Result::error("子级栏目:缺少必需参数错误", 0);
-                    }
-
-                    list($childCatId, $childImgNum, $childTextNum) = $childParams;
-                    $cacheKey = "child_{$childCatId}_{$website['website_id']}";
-
-                    if (!isset($childCategoryCache[$cacheKey])) {
-                        // 查询子栏目信息
-                        $childCategoryCache[$cacheKey] = WebsiteCategory::where($website)
-                            ->where("category_id", $childCatId)
-                            ->whereRaw("JSON_CONTAINS(category_arr_id, '" . intval($childCatId) . "') = 1")
-                            ->first(['alias', 'category_id', 'aLIas_pinyin', 'pid', 'category_arr_id as cat_arr_id']);
-                    }
-
-                    $childCategory = $childCategoryCache[$cacheKey];
-
-                    if (!empty($childCategory)) {
-                        $childCategory = $this->processArticles($childCategory, $website);
-
-                        // 查询此层级的所有子栏目
-                        $allChildCategories = WebsiteCategory::where($website)
-                            ->where("pid", $childCategory['pid'])
-                            ->get(['alias', 'category_id', 'aLIas_pinyin', 'pid', 'category_arr_id as cat_arr_id']);
-
-                        $allChildCategories = $this->processArticles($allChildCategories, $website);
-
-                        $childResult = [
-                            'alias' => $childCategory->alias,
-                            'category_id' => $childCategory->category_id,
-                            'pinyin' => $childCategory->aLIas_pinyin,
-                            'all_childcat' => $allChildCategories,
-                            'imgnum' => [],
-                            'textnum' => []
-                        ];
-
-                        // 查询子栏目图片新闻
-                        if (!empty($childImgNum)) {
-                            $childResult['imgnum'] = $this->fetchArticles($childCatId, $website, (int)$childImgNum, true);
-                        }
-
-                        // 查询子栏目文字新闻
-                        if (!empty($childTextNum)) {
-                            $childResult['textnum'] = $this->fetchArticles($childCatId, $website, (int)$childTextNum, false);
-                        }
-
-                        $resultItem['child'] = $childResult;
-                    }
-                }
-                return $resultItem;
-            }, $items);
-            $cache->set($cacheKey, serialize($result), 86400);
-            return Result::success($result);
-        } catch (\Exception $e) {
-            // 记录错误日志
-            return Result::error("获取网站文章失败: " . $e->getMessage());
-        }
-    }
-
-    /**
-     * 辅助方法:获取文章列表
-     */
-    private function fetchArticles($catId, $website, $limit, $isImageArticle = false)
-    {
-        $query = Article::where('article.status', 1)
-            // 使用更高效的查询方式,避免使用 JSON_CONTAINS 函数,如果可能的话,将 cat_arr_id 拆分为单独的字段
-            ->whereRaw("(FIND_IN_SET('$catId', REPLACE(REPLACE(cat_arr_id, '[', ''), ']', '')))")
-            ->where(function ($query) use ($website) {
-                $query->whereRaw("(JSON_CONTAINS(ignore_ids, '" . intval($website['website_id']) . "') = 0 OR ignore_ids IS NULL)");
+        // 查询栏目名称
+        $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')");
             })
-            ->leftJoin('website_category', function ($join) use ($website) {
-                $join->on('article.catid', '=', 'website_category.category_id')
-                    ->where('website_category.website_id', '=', $website['website_id']);
+              ->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')
+              ->limit($parentImgNum)
+              ->get()->all();
+            // 查询文字新闻
+          }
+          if ($parentTextNum != 0) {
+            $textBooks = [];
+            $textBooks = Book::where(function ($query) use ($parentCatId) {
+              $query->whereRaw("JSON_CONTAINS(cat_arr_id, '\"$parentCatId\"')")
+                ->orWhereRaw("JSON_CONTAINS(cat_arr_id, '$parentCatId')");
             })
-            ->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($limit);
-
-        // 如果是图片文章,添加图片URL条件
-        if ($isImageArticle) {
-            $query->where('imgurl', '!=', '');
-        } else {
-            // 文字文章不需要imgurl字段
-            $query->addSelect('article.introduce');
-        }
-
-        $articles = $query->get();
+              ->where('book.status', 2)
+              ->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')
+              ->limit($parentTextNum)
+              ->get()->all();
+          }
+        }
+      }
+      $resultItem = [
+        'alias' => $parent_alias ?? '',
+        'category_id' => $parentCatId ?? 0,
+        'pinyin' => $parent_pinyin ?? null,
+        'imgnum' => $imgBooks ?? [],
+        'textnum' => $textBooks ?? [],
+      ];
+      if (isset($item['child']) && $item['child'] != 'undefined' && $item['child'] != "") {
+        $parent_pinyin_str = is_string($parent_pinyin) ? $parent_pinyin . '/' : '';
+        $childCategory = WebsiteCategory::where('pid', $parentCatId)->where($website)
+          ->selectRaw("category_id, alias, CONCAT( ?, aLIas_pinyin) as aLIas_pinyin", [$parent_pinyin_str])
+          ->get()->all();
+        if (!empty($childCategory)) {
+          list($childCatId, $childImgNum, $childTextNum) = explode(',', $item['child']);
+          // 查询子栏目名称
+          $childCategoryInfo = WebsiteCategory::where('category_id', $childCatId)->where($website)
+            ->selectRaw("category_id, alias, CONCAT( ?, aLIas_pinyin) as aLIas_pinyin", [$parent_pinyin_str])
+            ->first();
+          if (empty($childCategoryInfo) || ($childImgNum == 0 && $childTextNum == 0)) {
+            $childImgArticles = [];
+            $childTextArticles = [];
+            $resultItem['child'] = [];
+          } else {
+            $child_pinyin = $childCategoryInfo->aLIas_pinyin ? $childCategoryInfo->aLIas_pinyin : null;
+            // 查询子栏目图片新闻
+            $childImgArticles = Book::where('cat_id', $childCatId)
+              ->where('status', 2)
+              ->where('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',
+                DB::raw("'$child_pinyin' as pinyin")
+              )
+              ->orderBy('updated_at', 'desc')
+              ->limit($childImgNum)
+              ->get()->all();
+            // 查询子栏目文字新闻
+            $childTextArticles = Book::where('cat_id', $childCatId)
+              ->where('status', 2)
+              ->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',
+                DB::raw("'$child_pinyin' as pinyin")
+              )
+              ->orderBy('updated_at', 'desc')
+              ->limit($childTextNum)
+              ->get()->all();
+            $resultItem['child'] = [
+              'alias' => $childCategoryInfo ? $childCategoryInfo->alias : null,
+              'category_id' => $childCatId,
+              'pinyin' => $childCategoryInfo->aLIas_pinyin ?? '',
+              'all_childcat' => $childCategory,
+              'imgnum' => $childImgArticles,
+              'textnum' => $childTextArticles,
+            ];
+          }
+        }
+      } else {
+        $resultItem['child'] = [];
+      }
+      return $resultItem;
+    }, $data);
+    return Result::success($result);
+  }
+  /**
+   * 获取书刊列表
+   * @param array $data
+   * @return array
+   *  */
+  public function getWebsiteBookList(array $data): array
+  {
+    $web = Website::where('id', $data['website_id'])->first(['id', 'website_name']);
+    if (empty($web)) {
+      return Result::error("查询失败", 0);
+    }
+    $catid = $data['id'];
+    $category = WebsiteCategory::where('website_id', $data['website_id'])->where('category_id', $catid)->orderBy('sort')->first(['pid', 'category_id', 'aLias_pinyin']);
+    $parent_categpory = WebsiteCategory::where('website_id', $data['website_id'])->where('category_id', $category['pid'])->orderBy('sort')->first(['aLias_pinyin']);
+    $parent_pinyin = $parent_categpory ? $parent_categpory->aLias_pinyin ?? '' : '';
+    $category_pinyin = $category ? $category->aLias_pinyin : '';
+    $pinyin = $category_pinyin ? $parent_pinyin . '/' . $category_pinyin ?? '' : '';
+    $categorys = WebsiteCategory::where('website_id', $data['website_id'])
+      ->where('pid', $category['pid'])
+      ->select(
+        'category_id',
+        'alias',
+        'aLIas_pinyin',
+        'pid',
+        'sort',
+        'is_url',
+        'web_url',
+        'seo_title',
+        'seo_keywords',
+        'seo_description',
+        DB::raw("CONCAT('$parent_pinyin', '/', aLIas_pinyin) as pinyin")
+      )
+      ->orderBy('sort')
+      ->get()->all();
+    if (empty($category)) {
+      return Result::error("查询失败", 0);
+    }
+    $query = Book::where('book.status', 2)
+      ->where('book.website_id', $data['website_id'])
+      ->where('book.cat_id', $catid)
+      ->select(
+        'book.id',
+        'book.title',
+        'book.img_url',
+        'book.description',
+        'book.updated_at',
+        'book.cat_id',
+        DB::raw("'$pinyin' as pinyin")
+      )
+      ->orderBy('book.updated_at', 'desc');
+    $count = $query->count();
+    $query = clone $query;
+    $Book = $query
+      ->limit($data['pageSize'])
+      ->offset(($data['page'] - 1) * $data['pageSize'])
+      ->get()->all();
+
+    $result = [
+      'category' => $categorys,
+      'books' => $Book,
+      'count' => $count,
+    ];
+    // if(empty($result)){
+    //     return Result::error("查询失败", 0);
+    // }
+    return Result::success($result);
+  }
+  /**
+   * 获取书刊详情
+   * @param array $data
+   * @return array
+   *  */
+  public function getWebsiteBookInfo(array $data): array
+  {
+    $web = Website::where('id', $data['website_id'])->first(['id', 'website_name']);
+    if (empty($web)) {
+      return Result::error("查询失败", 0);
+    }
+    $book = Book::where('status', 2)
+      ->where('website_id', $data['website_id'])
+      ->where('id', $data['id'])
+      ->select(
+        'book.*',
+      )
+      ->orderBy('updated_at', 'desc')
+      ->first();
+    if (empty($book)) {
+      return Result::error("查询失败", 0);
+    }
+    // 先查询当前分类的 pid
+    $carpid = WebsiteCategory::where('website_id', $data['website_id'])
+      ->where('category_id', $book['cat_id'])
+      ->first(['pid', 'category_id']);
+    $query = WebsiteCategory::where('website_id', $data['website_id']);
+    if (!empty($carpid)) {
+      if ($carpid->pid != 0) {
+        $pid = $carpid['pid'];
+        // $parent_pinyin = '';
+      } else {
+        $pid = $carpid['category_id'];
+        // $parent_pinyin = $currentCategory->aLias_pinyin?? '';
+      }
+    }
+    $categorys = $query->where('pid', $pid)
+      ->select(
+        'category_id',
+        'alias',
+        'aLIas_pinyin',
+        'pid',
+        'sort',
+        'is_url',
+        'web_url',
+        'category_arr_id as cat_arr_id',
+      )
+      ->orderBy('sort')
+      ->get();
+    $category = $this->processArticle($categorys, $data);
+    $result = [
+      'category' => $category,
+      'books' => $book,
+    ];
+    return Result::success($result);
+  }
+  /**
+   * 尝试
+   * @param array $data
+   * @return array
+   *  */
+  public function test(array $data): array
+  {
+    $input['id'] = $data['id'];
+    $input['website_id'] = $data['website_id'];
+    // 将 JSON 字符串转换为 PHP 数组
+    $data = json_decode($input['id'], true);
+    $result = [];
+    $article = $data;
+    $result = array_map(function ($item) use ($input) {
+      $website = [
+        'website_id' => $input['website_id'],
+      ];
+      list($parentCatId, $parentImgNum, $parentTextNum) = explode(',', $item['parent']);
+      $category = WebsiteCategory::where('pid', $parentCatId)->where($website)->first(['alias', 'category_id', 'aLIas_pinyin']);
+      $parent = [
+        0 => $category['category_id'] ?? [],
+        1 => $parentImgNum ?? [],
+        2 => $parentTextNum ?? [],
+      ];
+      list($parentCatId, $parentImgNum, $parentTextNum) = explode(',', $item['child']);
+      $child = [];
+
+      $resultItem = [
+        // 'alias' => $parent_alias ?? '',
+        'category_id' => $parentCatId ?? 0,
+        'pinyin' => $parentImgNum ?? null,
+        'imgnum' => $parentTextNum ?? [],
+        // 'textnum' => $textArticles ?? [],
+      ];
+      return $parent;
+    }, $data);
+    return Result::success($result);
+    // });
+
+
+  }
+  /**
+   * 封装处理文章的路由问题
+   *  */
+  function processArticle($article, $data)
+  {
+    return $article->map(function ($article) use ($data) {
+      $catid = $article->cat_arr_id ?? '';
+      $level = json_decode($catid, true);
+      $pinyin = '';
+      // $category = WebsiteCategory::where('category_id', $catid)->where('website_id', $data['website_id'])->first();
+      if (!empty($level) && is_array($level)) {
+        $pinyin = WebsiteCategory::whereIn('category_id', $level)
+          ->where('website_id', $data['website_id'])
+          ->orderByRaw('FIELD(category_id, ' . implode(',', $level) . ')')
+          ->get(['aLIas_pinyin'])
+          ->pluck('aLIas_pinyin')
+          ->implode('/');
+      } else {
+        $pinyin = '';
+      }
+      $article->pinyin = $pinyin;
+      return $article;
+    });
+  }
+  /**
+   * c端-获取招工招聘下拉选框
+   * @param array $data
+   * @return array
+   *  */
+  public function getWebsiteJobSelect(array $data): array
+  {
+    $web = Website::where('id', $data['website_id'])->first();
+    if (empty($web)) {
+      return Result::error("该网站不存在", 0);
+    }
+    $hy = JobIndustry::get()->all();
+    $zw = JobPosition::where('zwpid', 0)->get()->all();
+    $jtzw = JobPosition::where('zwpid', '!=', 0)->get()->all();
+    $result = [
+      'hy' => $hy,
+      'zw' => $zw,
+      'jtzw' => $jtzw,
+    ];
+    if (empty($result)) {
+      return Result::error("查询失败", 0);
+    }
+    return Result::success($result);
+  }
+  /**
+   * c端-获取招工招聘
+   * @param array $data
+   * @return array
+   *  */
+  public function getWebsiteJob(array $data): array
+  {
+    $web = Website::where('id', $data['website_id'])->first();
+    if (empty($web)) {
+      return Result::error("该网站不存在", 0);
+    }
+    $job_hunting = JobHunting::where('job_hunting.status', 2)
+      ->where('job_hunting.website_id', $data['website_id'])
+      ->when(isset($data['city_id']) && !empty($data['city_id']), function ($query) use ($data) {
+        $query->where(function ($q) use ($data) {
+          $q->WhereRaw("JSON_CONTAINS(job_hunting.city_arr_id, '" . intval($data['city_id']) . "') = 1");
+        });
+      })
+      ->select(
+        'job_hunting.id',
+        'job_hunting.cat_arr_id',
+        'job_hunting.job_name_get',
+        'job_hunting.industry',
+        'job_hunting.name',
+        'job_hunting.sexy',
+        'job_hunting.origin',
+        'job_hunting.city_arr_id',
+        'job_hunting.experience',
+        'job_hunting.updated_at',
+        'job_hunting.salary'
+      )
+      ->orderBy('updated_at', 'desc')
+      ->limit($data['job1_num'])
+      ->get();
+    $web['website_id'] = $data['website_id'];
+    if (empty($job_hunting)) {
+      $job_huntings = "未查询到相关简历信息";
+    } else {
+      $job_huntings = $this->processJob($job_hunting, $web);
+    }
+    // 0:待审核 1:已通过 2:已拒绝 
+    $job_recruiting = JobRecruiting::where('job_recruiting.status', 1)
+      ->where('job_recruiting.website_id', $data['website_id'])
+      ->when(isset($data['city_id']) && !empty($data['city_id']), function ($query) use ($data) {
+        $query->where(function ($q) use ($data) {
+          $q->WhereRaw("JSON_CONTAINS(job_recruiting.city_arr_id, '" . intval($data['city_id']) . "') = 1");
+        });
+      })
+      ->leftJoin('job_company', 'job_recruiting.id', '=', 'job_company.job_id')
+      ->select(
+        'job_recruiting.id',
+        'job_recruiting.cat_arr_id',
+        'job_recruiting.title',
+        'job_recruiting.jtzw_id',
+        'job_recruiting.hy_id',
+        'job_recruiting.city_arr_id',
+        'job_recruiting.due_data',
+        'job_recruiting.updated_at',
+        'job_recruiting.experience',
+        'job_recruiting.educational',
+        'job_recruiting.salary',
+        'job_recruiting.zw_id',
+        'job_company.business_name'
+      )
+      ->orderBy('updated_at', 'desc')
+      ->limit($data['job2_num'])
+      ->get();
+    if (empty($job_recruiting->toArray())) {
+      $job_recruitings = "未查询到相关职位信息";
+    } else {
+      $job_recruitings = $this->processJob($job_recruiting, $web);
+    }
 
-        return !empty($articles) ? $this->processArticles($articles, $website) : [];
+    $result = [
+      'job_hunting' => $job_huntings,
+      'job_recuiting' => $job_recruitings,
+    ];
+    return Result::success($result);
+  }
+  /**
+   * c端-获取招工招聘列表
+   * @param array $data
+   * @return array
+   *  */
+  public function getWebsiteJobList(array $data): array
+  {
+    $recruit_where = [];
+    $hunt_where = [];
+    $web = Website::where('id', $data['website_id'])->first(['id', 'website_name']);
+    if (empty($web)) {
+      return Result::error("此网站不存在", 0);
+    }
+    $website_id['website_id'] = $data['website_id'];
+
+
+    if ((isset($data['type']) && $data['type'] == 1) || !isset($data['type'])) {
+      if (isset($data['zw_id']) && !empty($data['zw_id'])) {
+        array_push($recruit_where, ['zw_id', $data['zw_id']]);
+      }
+      if (isset($data['jtzw_id']) && !empty($data['jtzw_id'])) {
+        array_push($recruit_where, ['jtzw_id', $data['jtzw_id']]);
+      }
+      if (isset($data['hy_id']) && !empty($data['hy_id'])) {
+        array_push($recruit_where, ['hy_id', $data['hy_id']]);
+      }
+      $query = JobRecruiting::where('job_recruiting.status', 1)
+        ->where('job_recruiting.website_id', $data['website_id'])
+        ->where($recruit_where)
+        ->when(isset($data['city_id']) && !empty($data['city_id']), function ($query) use ($data) {
+          $query->where(function ($q) use ($data) {
+            $q->WhereRaw("JSON_CONTAINS(job_recruiting.city_arr_id, '" . intval($data['city_id']) . "') = 1");
+          });
+        })
+        ->when(isset($data['catid']) && !empty($data['catid']), function ($query) use ($data) {
+          $query->where(function ($q) use ($data) {
+            $q->WhereRaw("JSON_CONTAINS(job_recruiting.cat_arr_id, '" . intval($data['catid']) . "') = 1");
+          });
+        })
+        ->leftJoin('job_company', 'job_recruiting.id', '=', 'job_company.job_id')
+        ->select(
+          'job_recruiting.id',
+          'job_recruiting.hy_id',
+          'job_recruiting.title',
+          'job_recruiting.zw_id',
+          'job_recruiting.educational',
+          'job_recruiting.jtzw_id',
+          'job_recruiting.city_arr_id',
+          'job_recruiting.due_data',
+          'job_recruiting.experience',
+          'job_recruiting.cat_arr_id',
+          'job_recruiting.updated_at',
+          'job_company.business_name'
+        )
+        ->orderBy('updated_at', 'desc');
+      $recruit_count = $query->count();
+      $query = clone $query;
+      $JobRecruiting = $query
+        ->offset(($data['page'] - 1) * $data['pageSize'])
+        ->limit($data['pageSize'])
+        ->get();
+      if (empty($JobRecruiting)) {
+        $JobRecruiting = "暂无相关职位信息";
+      } else {
+        $JobRecruiting = $this->processJob($JobRecruiting, $website_id);
+      }
+    }
+    if ((isset($data['type']) && $data['type'] == 2) || !isset($data['type'])) {
+      if (isset($data['zw_id']) && !empty($data['zw_id'])) {
+        array_push($hunt_where, ['job', $data['zw_id']]);
+      }
+      if (isset($data['jtzw_id']) && !empty($data['jtzw_id'])) {
+        array_push($hunt_where, ['job_name_get', $data['jtzw_id']]);
+      }
+      if (isset($data['hy_id']) && !empty($data['hy_id'])) {
+        array_push($hunt_where, ['industry', $data['hy_id']]);
+      }
+      $query = JobHunting::where('status', 2)
+        ->where('job_hunting.website_id', $data['website_id'])
+        ->where($hunt_where)
+        ->when(isset($data['city_id']) && !empty($data['city_id']), function ($query) use ($data) {
+          $query->where(function ($q) use ($data) {
+            $q->WhereRaw("JSON_CONTAINS(job_hunting.city_arr_id, '" . intval($data['city_id']) . "') = 1");
+          });
+        })
+        ->when(isset($data['catid_id']) && !empty($data['catid_id']), function ($query) use ($data) {
+          $query->where(function ($q) use ($data) {
+            $q->WhereRaw("JSON_CONTAINS(job_hunting.cat_arr_id, '" . intval($data['catid_id']) . "') = 1");
+          });
+        })
+        ->select('id', 'sexy', 'experience', 'origin', 'industry', 'name', 'job', 'job_name_get', 'city_arr_id', 'cat_arr_id', 'created_at', 'updated_at')
+        ->orderBy('updated_at', 'desc');
+      $hunt_count = $query->count();
+      $query = clone $query;
+      $JobHunting = $query
+        ->offset(($data['page'] - 1) * $data['pageSize'])
+        ->limit($data['pageSize'])
+        ->get();
+      if (empty($JobHunting)) {
+        $JobRecruiting = "暂无相关简历信息";
+      } else {
+        $JobHunting = $this->processJob($JobHunting, $website_id);
+      }
     }
-    /**
-     * 乡村网-获取特殊新闻模块
-     * @param array $data
-     * @return array
-     */
-    public function getWebsiteArticles(array $data): array
-    {
-        $input['id'] = $data['id'];
-        $input['website_id'] = $data['website_id'];
-        $data = json_decode($input['id'], true);
-        // 使用 array_map 处理每个元素 
-        $result = array_map(function ($item) use ($input) {
-            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']);
-            $pinyin = $category->aLIas_pinyin ? $category->aLIas_pinyin : null;
-            if (empty($category)) {
-                $imgArticles = [];
-                $textArticles = [];
-                // return Result::error("暂无此栏目",0); 
-            } else {
-                $child_category = WebsiteCategory::where('pid', $parentCatId)->where($website)->pluck('category_id')->toArray();
-                $parent_alias = $category->aLIas_pinyin ? $category->aLIas_pinyin . '/' : null;
-                // return Result::success($website);
-                // 查询图片新闻 
-                // 合并查询条件
-                $baseQuery = Article::where(function ($query) use ($website) {
-                    $query->where(function ($subQuery) use ($website) {
-                        $subQuery->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($website['website_id']) . "') = 0");
-                    })->orWhereNull("ignore_ids");
-                })
-
-                    ->where('article.status', 1)
-                    ->leftJoin('website_category', 'website_category.category_id', 'article.catid')
-                    ->where('website_category.website_id', $website['website_id']);
-
-                // 查询文字新闻
-                $textArticles = clone $baseQuery;
-                $textArticles = $textArticles->whereIn('catid', $child_category)
-                    ->select(
-                        'article.id',
-                        'article.title',
-                        // 'article.imgurl',
-                        'article.author',
-                        'article.updated_at',
-                        'article.introduce',
-                        'article.islink',
-                        'article.linkurl',
-                        'article.copyfrom',
-                        'website_category.category_id',
-                        'website_category.alias',
-                        'website_category.aLIas_pinyin'
-                    )
-                    ->selectRaw("CONCAT(?, aLIas_pinyin) as aLIas_pinyin", [$parent_alias])
-                    ->orderBy('article.updated_at', 'desc')
-                    ->limit($parentTextNum)
-                    ->get()
-                    ->all();
-                if (empty($textArticles)) {
-                    $textArticles = clone $baseQuery;
-                    $textArticles = $textArticles->where('catid', $parentCatId)
-                        ->select(
-                            'article.id',
-                            'article.title',
-                            // 'article.imgurl',
-                            'article.author',
-                            'article.updated_at',
-                            'article.introduce',
-                            'article.islink',
-                            'article.linkurl',
-                            'article.copyfrom',
-                            'website_category.category_id',
-                            'website_category.alias',
-                            'website_category.aLIas_pinyin'
-                        )
-                        ->selectRaw("CONCAT(?, aLIas_pinyin) as aLIas_pinyin", [$parent_alias])
-                        ->orderBy('article.updated_at', 'desc')
-                        ->limit($parentTextNum)
-                        ->get()
-                        ->all();
-                }
-                // 查询图片新闻
-                $imgArticles = clone $baseQuery;
-                $imgArticles = $imgArticles->where('imgurl', '!=', '')->whereIn('catid', $child_category)
-                    ->select(
-                        'article.id',
-                        'article.title',
-                        'article.imgurl',
-                        'article.author',
-                        'article.updated_at',
-                        'article.introduce',
-                        'article.islink',
-                        'article.linkurl',
-                        'article.copyfrom',
-                        'website_category.category_id',
-                        'website_category.alias',
-                        'website_category.aLIas_pinyin'
-                    )
-                    ->selectRaw("CONCAT(?, aLIas_pinyin) as aLIas_pinyin", [$parent_alias])
-                    ->orderBy('article.updated_at', 'desc')
-                    ->limit($parentImgNum)
-                    ->get()
-                    ->all();
-                if (empty($imgArticles)) {
-                    $imgArticles = clone $baseQuery;
-                    $imgArticles = $imgArticles->where('imgurl', '!=', '')->where('catid', $parentCatId)
-                        ->select(
-                            'article.id',
-                            'article.title',
-                            'article.imgurl',
-                            'article.author',
-                            'article.updated_at',
-                            'article.introduce',
-                            'article.islink',
-                            'article.linkurl',
-                            'article.copyfrom',
-                            'website_category.category_id',
-                            'website_category.alias',
-                            'website_category.aLIas_pinyin'
-                        )
-                        ->selectRaw("CONCAT(?, aLIas_pinyin) as aLIas_pinyin", [$parent_alias])
-                        ->orderBy('article.updated_at', 'desc')
-                        ->limit($parentImgNum)
-                        ->get()
-                        ->all();
-                }
-            }
-            $resultItem = [
-                'alias' => $category ? $category->alias : null,
-                'category_id' => $parentCatId,
-                'pinyin' => $pinyin ? $pinyin : null,
-                'imgnum' => $imgArticles ?? [],
-                'textnum' => $textArticles ?? [],
 
-            ];
 
 
-            return $resultItem;
-        }, $data);
-        return Result::success($result);
+    $result = [
+      'JobRecruiting' => $JobRecruiting ?? [],
+      'recruit_count' => $recruit_count ?? 0,
+      'JobHunting' => $JobHunting ?? [],
+      'hunt_count' => $hunt_count ?? 0,
+    ];
+    return Result::success($result);
+  }
+  /**
+   * c端-获取招工招聘详情
+   * @param array $data
+   * @return array
+   *  */
+  public function getWebsiteJobInfo(array $data): array
+  {
+    $web = Website::where('id', $data['website_id'])->first(['id', 'website_name']);
+    if (empty($web)) {
+      return Result::error("该网站不存在", 0);
     }
-
-
-    // 封装处理商品的路由问题
-    function processGoods($goods, $data)
-    {
-        return $goods->map(function ($good) use ($data) {
-            $catid = $good->catid ?? 0;
-            //     $pinyin = '';
-            $category = WebsiteCategory::where('category_id', $catid)->where('website_id', $data['website_id'])->first();
-            if (!empty($category->pid) && $category->pid != 0) {
-                $level = json_decode($category->category_arr_id);
-                $pinyin = WebsiteCategory::where('website_id', $data['website_id'])
-                    ->whereIn('category_id', $level)
-                    ->orderByRaw('FIELD(category_id, ' . implode(',', $level) . ')')
-                    ->get(['aLIas_pinyin'])
-                    ->pluck('aLIas_pinyin')
-                    ->implode('/');
-            } else {
-                $pinyin = $category->aLIas_pinyin ?? '';
-            }
-            if (isset($good->city_id) && !empty($good->city_id)) {
-                $city = District::where('id', $good->city_id)->first(['name']);
-                $good->city_name = $city->name ?? '';
-            }
-            // 解析imgurl JSON并取第一条数据
-            $imgUrls = json_decode($good->imgurl, true);
-            $good->imgurl = !empty($imgUrls) ? $imgUrls[0] : null;
-            $good->pinyin = $pinyin;
-            return $good;
-        });
+    $webid = [
+      'website_id' => $data['website_id'],
+    ];
+    // 职位相关信息
+    if ($data['type'] == 1) {
+      $query = JobRecruiting::where('status', 1)
+        ->where('website_id', $data['website_id'])
+        ->select('*');
+      $job = $query->where('job_recruiting.id', $data['id'])->get();
+      $company = JobCompany::where('job_id', $data['id'])->select('id', 'business_name', 'company_hy_id', 'company_size', 'company_nature', 'address_arr_id', 'address', 'job_company.email')->get();
+      if (!empty($company)) {
+        $result['company'] = $this->processJob($company, $webid);
+      }
+
+      $other_job = JobRecruiting::where('status', 1)
+        ->where('website_id', $data['website_id'])
+        ->select('title', 'id', 'updated_at', 'cat_arr_id', 'user_id')
+        ->where('id', '!=', $data['id'])
+        ->where('user_id', '=', $job[0]['user_id'])
+        ->limit($data['pageSize'])
+        ->get();
+      if (!empty($other_job)) {
+        $result['other_job'] = $this->processJob($other_job, $webid);
+      }
+    } else {
+      // 简历相关信息
+      $job = JobHunting::where('job_hunting.status', 2)
+        ->where('job_hunting.website_id', $data['website_id'])
+        ->where('job_hunting.id', $data['id'])
+        ->leftJoin('user', 'user.id', '=', 'job_hunting.user_id')
+        ->select('job_hunting.*', 'user_name')
+        ->get();
+
+      $resume = JobRemuse::where('hunt_id', $data['id'])->get();
+      if (!empty($resume->toArray())) {
+        $result['resume'] = 1;
+      } else {
+        $result['resume'] = 0;
+      }
     }
-    /**
-     * 获取商城首页-根据栏目id
-     * @param array $data
-     * @return array
-     *  */
-    function getWebsiteCatidshop(array $data): array
-    {
-        $input['catid'] = $data['catid'];
-        $input['website_id'] = $data['website_id'];
-        $data = json_decode($input['catid'] ?? '', true) ?? [];
-        $result = array_map(function ($item) use ($input) {
-            if (isset($item['catid']) && $item['catid'] != 'undefined' && $item['catid'] != "") {
-                list($catid, $goodStart, $goodNum) = explode(',', $item['catid']);
-                $category = WebsiteCategory::where('category_id', $catid)->where('website_id', $input['website_id'])->first(['type']);
-                // 类型:1资讯(默认)2商品3书刊音像4招聘5求职类型:1资讯(默认)2商品3书刊音像4招聘5求职6招工招聘
-                if (empty($category) || $category->type != 2) {
-                    return Result::error("暂无此栏目", 0);
-                } else {
-                    $website['website_id'] = $input['website_id'];
-                    $goods = Good::where('good.status', 2)
-                        ->where('good.website_id', $website['website_id'])
-                        ->whereRaw("JSON_CONTAINS(good.cat_arr_id, '" . intval($catid) . "') = 1")
-                        ->select(
-                            'good.id',
-                            'good.name',
-                            'good.imgurl',
-                            'good.description',
-                            'good.updated_at',
-                            'good.catid',
-                            'good.type_id',
-                            'good.price',
-                            'good.com',
-                            'good.level',
-                            'good.unit'
-                        )
-                        ->orderBy('updated_at', 'desc')
-                        ->offset($goodStart)
-                        ->limit($goodNum);
-                    $all_goods = $goods->get();
-                    $all_goods = $this->processGoods($all_goods, $website);
-                }
-
-                return $all_goods ?? [];
-            }
-        }, $data);
-        return Result::success($result);
+    if (empty($job->toArray())) {
+      return Result::error("id参数错误", 0);
     }
-    /**
-     * 获取商品模块
-     * @param array $data
-     * @return array
-     *  */
-    public function getWebsiteshop(array $data): array
-    {
-        $input['id'] = $data['id'];
-        $input['website_id'] = $data['website_id'];
-        $catid = $data['catid'];
-        $data = json_decode($input['id'] ?? '', true) ?? [];
-        $result['goods'] = array_map(function ($item) use ($input) {
-            // 检查parent元素是否存在且不是undefined
-            if (isset($item['level']) && $item['level'] != 'undefined' && $item['level'] != "") {
-                list($Levelid, $goodStart, $goodNum) = explode(',', $item['level']);
-                $website = $input['website_id'];
-                $query = Good::where('good.status', 2)
-                    ->where('good.website_id', $website);
-                switch ($Levelid) {
-                    case 1:
-                    case 2:
-                    case 3:
-                        $goods = $query->where(function ($q) use ($Levelid) {
-                            $q->whereRaw("JSON_CONTAINS(good.level, '" . intval($Levelid) . "') = 1")
-                                ->orWhereRaw("JSON_CONTAINS(good.level, '\"" . intval($Levelid) . "\"') = 1");
-                        });
-                        break;
-                    case 4:
-                        $goods = $query;
-                        break;
-                    case 5:
-                        $goods = $query->where('type_id', 1);
-                        break;
-                    case 6:
-                        $goods = $query->where('type_id', 2);
-                        break;
-                    default:
-                        return [];
-                }
-                $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')
-                    ->offset($goodStart)
-                    ->limit($goodNum)
-                    ->get();
-                $web['website_id'] = $website;
-                $all_goods = $this->processGoods($all_goods, $web);
-            }
-            return  $all_goods;
-        }, $data);
-        $website = $input['website_id'];
-        $result['article'] = Article::where(function ($query) use ($website) {
-            $query->where(function ($subQuery) use ($website) {
-                $subQuery->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($website) . "') = 0");
-            })->orWhereNull("ignore_ids");
-        })
-            ->where('catid', $catid)
-            ->where('article.status', 1)
-            ->leftJoin('article_data', 'article_data.article_id', 'article.id')
-            ->select('article.id', 'article.title', 'article.updated_at', 'introduce', 'islink', 'linkurl', 'article_data.content')
-            ->orderBy('article.updated_at', 'desc')
-            ->first();
-        return Result::success($result);
+    if (!empty($job[0]['job_experience'])) {
+      $job_experience = json_decode($job[0]['job_experience'], true) ?? [];
+      if (!empty($job_experience)) {
+        // $hy = [];
+        foreach ($job_experience as $key => $value) {
+          // $id = $value['id'];
+          $hy[$key] = $value['job_industry'];
+          $zw_id[$key] = $value['job_typename'];
+          $jtzw_id[$key] = $value['job_name'];
+        }
+        $hy_table = JobIndustry::whereIn('hyid', $hy)->select('hyid', 'hyname')->get();
+        $zw_table = JobPosition::select('zwid', 'zwname')->get();
+        // 先将关联表转换为索引数组,提高查找效率
+        $hyLookup = [];
+        foreach ($hy_table as $item) {
+          $hyLookup[$item['hyid']] = $item['hyname'];
+        }
+
+        $zwLookup = [];
+        foreach ($zw_table as $item) {
+          $zwLookup[$item['zwid']] = $item['zwname'];
+        }
+
+        foreach ($job_experience as $key => &$value) {
+          // 处理行业名称
+          if (isset($hy[$key]) && isset($hyLookup[$hy[$key]])) {
+            $value['hy_name'] = $hyLookup[$hy[$key]];
+          }
+
+          // 处理职位名称
+          if (isset($zw_id[$key]) && isset($zwLookup[$zw_id[$key]])) {
+            $value['zw_name'] = $zwLookup[$zw_id[$key]];
+          }
+
+          // 处理具体职位名称
+          if (isset($jtzw_id[$key]) && isset($zwLookup[$jtzw_id[$key]])) {
+            $value['jtzw_name'] = $zwLookup[$jtzw_id[$key]];
+          }
+        }
+        // 释放引用,防止意外修改后续代码
+        unset($value);
+      }
+      $result['job_experience'] = $job_experience ?? [];
     }
-    /**
-     * 获取商品分类
-     * @param array $data
-     * @return array
-     *  */
-    public function getWebsiteshopCat(array $data): array
-    {
-        $website = $data['website_id'];
-        $category = WebsiteCategory::where('website_id', $website)
-            ->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', 'sort')
-            ->orderBy('sort')
-            ->get();
-        $cat =  $category->map(function ($item) use ($website) {
-            $cat_arr_id = json_decode($item->category_arr_id, true) ?? [];
-            $pid = $item->pid ?? 0;
-            if (!empty($cat_arr_id) && is_array($cat_arr_id) && $pid != 0) {
-                $pinyin = WebsiteCategory::whereIn('category_id', $cat_arr_id)
-                    ->where('website_id', $website)
-                    ->orderByRaw('FIELD(category_id, ' . implode(',', $cat_arr_id) . ')')
-                    ->get(['aLIas_pinyin'])
-                    ->pluck('aLIas_pinyin')
-                    ->implode('/');
-            } else {
-                $pinyin = $item->aLIas_pinyin ?? '';
-            }
-            $item->pinyin = $pinyin;
-        });
-        if (empty($category)) {
-            return Result::error("栏目查询失败", 0);
-        }
-        $cat_tree = Result::buildMenuTree($category);
-        $web['website_id'] = $website;
-        $goods = Good::where('website_id', $website)
-            ->where('status', 2)
-            ->select('good.id as good_id', 'name', 'imgurl', 'description', 'updated_at', 'catid', 'type_id', 'website_id')
-            ->latest('updated_at')
-            ->offset(($data['page'] - 1) * $data['pageSize'])
-            ->limit($data['pageSize'])
-            ->get();
-        if (!empty($goods)) {
-            if ($goods->count() > 1 && !empty($goods)) {
-                $goods = $this->processGoods($goods, $web);
-            }
-        } else {
-            $goods = [];
-        }
-
-        $result = [
-            'category' => $cat_tree,
-            'goods' => $goods,
-        ];
-        // $resul['goods'] = $goods;
-        if (empty($result)) {
-            return Result::error("查询失败", 0);
-        }
-        return Result::success($result);
+    if (!empty($job[0]['education_experience'])) {
+      $education_experience = json_decode($job[0]['education_experience'], true) ?? '';
+      if (!empty($education_experience)) {
+        foreach ($education_experience as $key => $value) {
+          // $id = $value['id'];
+          $education[$key] = $value['school_education'];
+        }
+        $education_table = JobEnum::where('egroup', 'education')->whereIn('evalue', $education)->select('evalue', 'ename')->get();
+        // // 先将关联表转换为索引数组,提高查找效率
+        $educationLookup = [];
+        foreach ($education_table as $item) {
+          $educationLookup[$item['evalue']] = $item['ename'];
+        }
+
+        foreach ($education_experience as $key => &$value) {
+          // 处理学历名称
+          if (isset($education[$key]) && isset($educationLookup[$education[$key]])) {
+            $value['education_name'] = $educationLookup[$education[$key]];
+          }
+        }
+      }
+      $result['education_experience'] = $job_experience ?? [];
     }
-    /*
-     * 获取商品列表
-     * @param array $data
-     * @return array
-     *  */
-    public function getWebsiteshopList(array $data): array
-    {
-        // return Result::success($data);
-        $where = [
-            'status' => 2,
-            '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']))) {
-            return Result::error("查询失败", 0);
-        }
-        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']);
-            $data['catid'] = $category->category_id ??  0;
-        }
-        if (isset($data['keyword']) && !empty($data['keyword'])) {
-            array_push($where, ['name', 'like', '%' . $data['keyword'] . '%']);
-        }
-        if (isset($data['type_id']) && !empty($data['type_id'])) {
-            array_push($where, ['type_id', $data['type_id']]);
-        }
-        $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['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");
-                });
-            })
-            ->select(
-                'good.id',
-                'good.name',
-                'good.imgurl',
-                'good.description',
-                'good.updated_at',
-                'good.com',
-                'good.catid',
-                'good.type_id',
-                'good.website_id',
-                'good.cat_arr_id',
-                'good.created_at',
-                'good.city_id'
-            )
-            ->latest('updated_at');
-        $result['type1_count'] = $query->clone()->where('type_id', 1)->count();
-        // 获取 type_id 为 1 的数据
-        $result['type1'] = $this->processGoods(
-            $query->clone()
-                ->where('type_id', 1)
-                ->offset(($data['page'] - 1) * $data['pageSize'])
-                ->limit($data['pageSize'])
-                ->get(),
-            $data
-        );
-        $result['type2_count'] = $query->clone()->where('type_id', 2)->count();
-        // 获取 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);
+    $result['job'] = $this->processJob($job, $webid);
+    // // 返现对应的栏目
+    $catid = json_decode($job[0]['cat_arr_id'], true) ?? '';
+    $category = WebsiteCategory::where('website_id', $data['website_id'])
+      ->whereIn('category_id', $catid)
+      ->select('category_id', 'alias', 'aLIas_pinyin', 'pid')
+      ->orderBy('pid')->get()->all();
+    if (!empty($category)) {
+      $result['category'] = $category;
     }
-    /**
-     * 获取商品详情
-     * @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);
-        }
-        $goods->imgurl = json_decode($goods->imgurl, true);
-        return Result::success($goods);
+    $result['job'] = $job;
+    $result['job_experience'] = $job_experience ?? [];
+    $result['education_experience'] = $education_experience ?? [];
+    if (empty($result)) {
+      return Result::error("参数错误", 0);
     }
-    /**
-     * 封装处理文章的路由问题
-     *  */
-    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 {
-            // 若 $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;
-        }
+    return Result::success($result);
+  }
+  /**
+   * c端-申请职位
+   * @param array $data
+   * @return array
+   *  */
+  public function getWebsiteJobApply(array $data): array
+  {
+    // 首先验证网站是否存在
+    // return Result::success($data);
+    $web = Website::where('id', $data['website_id'])->first(['id', 'website_name']);
+    if (empty($web)) {
+      return Result::error("该网站不存在", 0);
     }
-    // 封装处理由问题
-    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;
-        });
+    // 验证用户是否存在且为个人会员/管理员
+    $user = User::where('id', $data['user_id'])->first(['id', 'type_id']);
+    // 1:个人会员 2:政务会员 3:企业会员 4:调研员 10000:管理员 20000:游客(小程序)
+    if (empty($user) || ($user['type_id'] != 1 && $user['type_id'] != 10000)) {
+      return Result::error("用户不存在", 0);
     }
-    /**
-     * 获取书籍模块
-     * @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')
-                            ->limit($parentImgNum)
-                            ->get()->all();
-                        // 查询文字新闻
-                    }
-                    if ($parentTextNum != 0) {
-                        $textBooks = [];
-                        $textBooks = 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)
-                            ->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')
-                            ->limit($parentTextNum)
-                            ->get()->all();
-                    }
-                }
-            }
-            $resultItem = [
-                'alias' => $parent_alias ?? '',
-                'category_id' => $parentCatId ?? 0,
-                'pinyin' => $parent_pinyin ?? null,
-                'imgnum' => $imgBooks ?? [],
-                'textnum' => $textBooks ?? [],
-            ];
-            if (isset($item['child']) && $item['child'] != 'undefined' && $item['child'] != "") {
-                $parent_pinyin_str = is_string($parent_pinyin) ? $parent_pinyin . '/' : '';
-                $childCategory = WebsiteCategory::where('pid', $parentCatId)->where($website)
-                    ->selectRaw("category_id, alias, CONCAT( ?, aLIas_pinyin) as aLIas_pinyin", [$parent_pinyin_str])
-                    ->get()->all();
-                if (!empty($childCategory)) {
-                    list($childCatId, $childImgNum, $childTextNum) = explode(',', $item['child']);
-                    // 查询子栏目名称
-                    $childCategoryInfo = WebsiteCategory::where('category_id', $childCatId)->where($website)
-                        ->selectRaw("category_id, alias, CONCAT( ?, aLIas_pinyin) as aLIas_pinyin", [$parent_pinyin_str])
-                        ->first();
-                    if (empty($childCategoryInfo) || ($childImgNum == 0 && $childTextNum == 0)) {
-                        $childImgArticles = [];
-                        $childTextArticles = [];
-                        $resultItem['child'] = [];
-                    } else {
-                        $child_pinyin = $childCategoryInfo->aLIas_pinyin ? $childCategoryInfo->aLIas_pinyin : null;
-                        // 查询子栏目图片新闻
-                        $childImgArticles = Book::where('cat_id', $childCatId)
-                            ->where('status', 2)
-                            ->where('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',
-                                DB::raw("'$child_pinyin' as pinyin")
-                            )
-                            ->orderBy('updated_at', 'desc')
-                            ->limit($childImgNum)
-                            ->get()->all();
-                        // 查询子栏目文字新闻
-                        $childTextArticles = Book::where('cat_id', $childCatId)
-                            ->where('status', 2)
-                            ->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',
-                                DB::raw("'$child_pinyin' as pinyin")
-                            )
-                            ->orderBy('updated_at', 'desc')
-                            ->limit($childTextNum)
-                            ->get()->all();
-                        $resultItem['child'] = [
-                            'alias' => $childCategoryInfo ? $childCategoryInfo->alias : null,
-                            'category_id' => $childCatId,
-                            'pinyin' => $childCategoryInfo->aLIas_pinyin ?? '',
-                            'all_childcat' => $childCategory,
-                            'imgnum' => $childImgArticles,
-                            'textnum' => $childTextArticles,
-                        ];
-                    }
-                }
-            } else {
-                $resultItem['child'] = [];
-            }
-            return $resultItem;
-        }, $data);
-        return Result::success($result);
+    // 去除重复元素和空元素,并保持原始顺序
+    $data['recruit_id'] = array_values(array_filter(array_unique($data['recruit_id']), function ($value) {
+      return !empty($value);
+    }));
+    // 验证职位是否存在   1:审核通过
+    $recruiting = JobRecruiting::where('status', 1)
+      ->where('website_id', $data['website_id'])
+      ->whereIn('id', $data['recruit_id'])
+      ->get(['id as recruit_id', 'user_id as receiver_id'])->all();
+    if (empty($recruiting)) {
+      return Result::error("该职位不存在", 0);
     }
-    /**
-     * 获取书刊列表
-     * @param array $data
-     * @return array
-     *  */
-    public function getWebsiteBookList(array $data): array
-    {
-        $web = Website::where('id', $data['website_id'])->first(['id', 'website_name']);
-        if (empty($web)) {
-            return Result::error("查询失败", 0);
-        }
-        $catid = $data['id'];
-        $category = WebsiteCategory::where('website_id', $data['website_id'])->where('category_id', $catid)->orderBy('sort')->first(['pid', 'category_id', 'aLias_pinyin']);
-        $parent_categpory = WebsiteCategory::where('website_id', $data['website_id'])->where('category_id', $category['pid'])->orderBy('sort')->first(['aLias_pinyin']);
-        $parent_pinyin = $parent_categpory ? $parent_categpory->aLias_pinyin ?? '' : '';
-        $category_pinyin = $category ? $category->aLias_pinyin : '';
-        $pinyin = $category_pinyin ? $parent_pinyin . '/' . $category_pinyin ?? '' : '';
-        $categorys = WebsiteCategory::where('website_id', $data['website_id'])
-            ->where('pid', $category['pid'])
-            ->select(
-                'category_id',
-                'alias',
-                'aLIas_pinyin',
-                'pid',
-                'sort',
-                'is_url',
-                'web_url',
-                'seo_title',
-                'seo_keywords',
-                'seo_description',
-                DB::raw("CONCAT('$parent_pinyin', '/', aLIas_pinyin) as pinyin")
-            )
-            ->orderBy('sort')
-            ->get()->all();
-        if (empty($category)) {
-            return Result::error("查询失败", 0);
-        }
-        $query = Book::where('book.status', 2)
-            ->where('book.website_id', $data['website_id'])
-            ->where('book.cat_id', $catid)
-            ->select(
-                'book.id',
-                'book.title',
-                'book.img_url',
-                'book.description',
-                'book.updated_at',
-                'book.cat_id',
-                DB::raw("'$pinyin' as pinyin")
-            )
-            ->orderBy('book.updated_at', 'desc');
-        $count = $query->count();
-        $query = clone $query;
-        $Book = $query
-            ->limit($data['pageSize'])
-            ->offset(($data['page'] - 1) * $data['pageSize'])
-            ->get()->all();
-
-        $result = [
-            'category' => $categorys,
-            'books' => $Book,
-            'count' => $count,
-        ];
-        // if(empty($result)){
-        //     return Result::error("查询失败", 0);
-        // }
-        return Result::success($result);
+    // 简历是否存在
+    $hunt_id = JobHunting::where('user_id', $data['user_id'])->where('status', 2)->first(['id as hunt_id']);
+    if (empty($hunt_id)) {
+      return Result::error("该简历不存在", 0);
     }
-    /**
-     * 获取书刊详情
-     * @param array $data
-     * @return array
-     *  */
-    public function getWebsiteBookInfo(array $data): array
-    {
-        $web = Website::where('id', $data['website_id'])->first(['id', 'website_name']);
-        if (empty($web)) {
-            return Result::error("查询失败", 0);
-        }
-        $book = Book::where('status', 2)
-            ->where('website_id', $data['website_id'])
-            ->where('id', $data['id'])
-            ->select(
-                'book.*',
-            )
-            ->orderBy('updated_at', 'desc')
-            ->first();
-        if (empty($book)) {
-            return Result::error("查询失败", 0);
-        }
-        // 先查询当前分类的 pid
-        $carpid = WebsiteCategory::where('website_id', $data['website_id'])
-            ->where('category_id', $book['cat_id'])
-            ->first(['pid', 'category_id']);
-        $query = WebsiteCategory::where('website_id', $data['website_id']);
-        if (!empty($carpid)) {
-            if ($carpid->pid != 0) {
-                $pid = $carpid['pid'];
-                // $parent_pinyin = '';
-            } else {
-                $pid = $carpid['category_id'];
-                // $parent_pinyin = $currentCategory->aLias_pinyin?? '';
-            }
-        }
-        $categorys = $query->where('pid', $pid)
-            ->select(
-                'category_id',
-                'alias',
-                'aLIas_pinyin',
-                'pid',
-                'sort',
-                'is_url',
-                'web_url',
-                'category_arr_id as cat_arr_id',
-            )
-            ->orderBy('sort')
-            ->get();
-        $category = $this->processArticle($categorys, $data);
-        $result = [
-            'category' => $category,
-            'books' => $book,
-        ];
-        return Result::success($result);
+    $data['hunt_id'] = $hunt_id['hunt_id'];
+    // // 验证是否已投递过该职位
+    $apply = JobApply::where('user_id', $data['user_id'])
+      ->where('hunt_id', $data['hunt_id'])
+      ->where('website_id', $data['website_id'])
+      ->whereIn('recruit_id', $data['recruit_id'])
+      ->get(['recruit_id']);
+    if (!empty($apply->toArray())) {
+      return Result::error("您已投递过该职位!");
     }
-    /**
-     * 尝试
-     * @param array $data
-     * @return array
-     *  */
-    public function test(array $data): array
-    {
-        $input['id'] = $data['id'];
-        $input['website_id'] = $data['website_id'];
-        // 将 JSON 字符串转换为 PHP 数组
-        $data = json_decode($input['id'], true);
-        $result = [];
-        $article = $data;
-        $result = array_map(function ($item) use ($input) {
-            $website = [
-                'website_id' => $input['website_id'],
-            ];
-            list($parentCatId, $parentImgNum, $parentTextNum) = explode(',', $item['parent']);
-            $category = WebsiteCategory::where('pid', $parentCatId)->where($website)->first(['alias', 'category_id', 'aLIas_pinyin']);
-            $parent = [
-                0 => $category['category_id'] ?? [],
-                1 => $parentImgNum ?? [],
-                2 => $parentTextNum ?? [],
-            ];
-            list($parentCatId, $parentImgNum, $parentTextNum) = explode(',', $item['child']);
-            $child = [];
-
-            $resultItem = [
-                // 'alias' => $parent_alias ?? '',
-                'category_id' => $parentCatId ?? 0,
-                'pinyin' => $parentImgNum ?? null,
-                'imgnum' => $parentTextNum ?? [],
-                // 'textnum' => $textArticles ?? [],
-            ];
-            return $parent;
-        }, $data);
-        return Result::success($result);
-        // });
-
-
+    $insertData = array_map(function ($recruiting) use ($data) {
+      return [
+        'user_id' => $data['user_id'],
+        'hunt_id' => $data['hunt_id'],
+        'website_id' => $data['website_id'],
+        'recruit_id' => $recruiting['recruit_id'],
+        'receiver_id' => $recruiting['receiver_id'],
+        'status' => 1,
+      ];
+    }, $recruiting);
+
+    // 批量插入数据
+    $result = JobApply::insert($insertData);
+    if (empty($result)) {
+      return Result::error("投递失败", 0);
     }
-    /**
-     * 封装处理文章的路由问题
-     *  */
-    function processArticle($article, $data)
-    {
-        return $article->map(function ($article) use ($data) {
-            $catid = $article->cat_arr_id ?? '';
-            $level = json_decode($catid, true);
-            $pinyin = '';
-            // $category = WebsiteCategory::where('category_id', $catid)->where('website_id', $data['website_id'])->first();
-            if (!empty($level) && is_array($level)) {
-                $pinyin = WebsiteCategory::whereIn('category_id', $level)
-                    ->where('website_id', $data['website_id'])
-                    ->orderByRaw('FIELD(category_id, ' . implode(',', $level) . ')')
-                    ->get(['aLIas_pinyin'])
-                    ->pluck('aLIas_pinyin')
-                    ->implode('/');
-            } else {
-                $pinyin = '';
-            }
-            $article->pinyin = $pinyin;
-            return $article;
-        });
+    return Result::success($result);
+  }
+  /**
+   * 招工招聘-沟通简历
+   * @param array $data
+   * @return array
+   *  */
+  public function getWebsiteJobResume(array $data): array
+  {
+    // 首先验证网站是否存在
+    $web = Website::where('id', $data['website_id'])->first(['id', 'website_name']);
+    if (empty($web)) {
+      return Result::error("该网站不存在", 0);
     }
-    /**
-     * c端-获取招工招聘下拉选框
-     * @param array $data
-     * @return array
-     *  */
-    public function getWebsiteJobSelect(array $data): array
-    {
-        $web = Website::where('id', $data['website_id'])->first();
-        if (empty($web)) {
-            return Result::error("该网站不存在", 0);
-        }
-        $hy = JobIndustry::get()->all();
-        $zw = JobPosition::where('zwpid', 0)->get()->all();
-        $jtzw = JobPosition::where('zwpid', '!=', 0)->get()->all();
-        $result = [
-            'hy' => $hy,
-            'zw' => $zw,
-            'jtzw' => $jtzw,
-        ];
-        if (empty($result)) {
-            return Result::error("查询失败", 0);
-        }
-        return Result::success($result);
+    // return Result::success($data);
+    // 验证用户是否存在且为企业会员/管理员
+    $user = User::where('id', $data['user_id'])->first(['id', 'type_id']);
+    // 1:个人会员 2:政务会员 3:企业会员 4:调研员 10000:管理员 20000:游客(小程序)
+    if (empty($user) || ($user['type_id'] != 3 && $user['type_id'] != 10000)) {
+      return Result::error("用户不存在", 0);
     }
-    /**
-     * c端-获取招工招聘
-     * @param array $data
-     * @return array
-     *  */
-    public function getWebsiteJob(array $data): array
-    {
-        $web = Website::where('id', $data['website_id'])->first();
-        if (empty($web)) {
-            return Result::error("该网站不存在", 0);
-        }
-        $job_hunting = JobHunting::where('job_hunting.status', 2)
-            ->where('job_hunting.website_id', $data['website_id'])
-            ->when(isset($data['city_id']) && !empty($data['city_id']), function ($query) use ($data) {
-                $query->where(function ($q) use ($data) {
-                    $q->WhereRaw("JSON_CONTAINS(job_hunting.city_arr_id, '" . intval($data['city_id']) . "') = 1");
-                });
-            })
-            ->select(
-                'job_hunting.id',
-                'job_hunting.cat_arr_id',
-                'job_hunting.job_name_get',
-                'job_hunting.industry',
-                'job_hunting.name',
-                'job_hunting.sexy',
-                'job_hunting.origin',
-                'job_hunting.city_arr_id',
-                'job_hunting.experience',
-                'job_hunting.updated_at',
-                'job_hunting.salary'
-            )
-            ->orderBy('updated_at', 'desc')
-            ->limit($data['job1_num'])
-            ->get();
-        $web['website_id'] = $data['website_id'];
-        if (empty($job_hunting)) {
-            $job_huntings = "未查询到相关简历信息";
-        } else {
-            $job_huntings = $this->processJob($job_hunting, $web);
-        }
-        // 0:待审核 1:已通过 2:已拒绝 
-        $job_recruiting = JobRecruiting::where('job_recruiting.status', 1)
-            ->where('job_recruiting.website_id', $data['website_id'])
-            ->when(isset($data['city_id']) && !empty($data['city_id']), function ($query) use ($data) {
-                $query->where(function ($q) use ($data) {
-                    $q->WhereRaw("JSON_CONTAINS(job_recruiting.city_arr_id, '" . intval($data['city_id']) . "') = 1");
-                });
-            })
-            ->leftJoin('job_company', 'job_recruiting.id', '=', 'job_company.job_id')
-            ->select(
-                'job_recruiting.id',
-                'job_recruiting.cat_arr_id',
-                'job_recruiting.title',
-                'job_recruiting.jtzw_id',
-                'job_recruiting.hy_id',
-                'job_recruiting.city_arr_id',
-                'job_recruiting.due_data',
-                'job_recruiting.updated_at',
-                'job_recruiting.experience',
-                'job_recruiting.educational',
-                'job_recruiting.salary',
-                'job_recruiting.zw_id',
-                'job_company.business_name'
-            )
-            ->orderBy('updated_at', 'desc')
-            ->limit($data['job2_num'])
-            ->get();
-        if (empty($job_recruiting->toArray())) {
-            $job_recruitings = "未查询到相关职位信息";
-        } else {
-            $job_recruitings = $this->processJob($job_recruiting, $web);
-        }
-
-        $result = [
-            'job_hunting' => $job_huntings,
-            'job_recuiting' => $job_recruitings,
-        ];
-        return Result::success($result);
+    // 去除重复元素和空元素,并保持原始顺序
+    $data['hunt_id'] = array_values(array_filter(array_unique($data['hunt_id']), function ($value) {
+      return !empty($value);
+    }));
+    // 验证简历是否存在
+    $hunting = JobHunting::where('status', 2)
+      ->where('website_id', $data['website_id'])
+      ->whereIn('id', $data['hunt_id'])
+      ->get(['id as hunt_id', 'user_id as receiver_id'])->all();
+    if (empty($hunting)) {
+      return Result::error("该简历不存在", 0);
     }
-    /**
-     * c端-获取招工招聘列表
-     * @param array $data
-     * @return array
-     *  */
-    public function getWebsiteJobList(array $data): array
-    {
-        $recruit_where = [];
-        $hunt_where = [];
-        $web = Website::where('id', $data['website_id'])->first(['id', 'website_name']);
-        if (empty($web)) {
-            return Result::error("此网站不存在", 0);
-        }
-        $website_id['website_id'] = $data['website_id'];
-
-
-        if ((isset($data['type']) && $data['type'] == 1) || !isset($data['type'])) {
-            if (isset($data['zw_id']) && !empty($data['zw_id'])) {
-                array_push($recruit_where, ['zw_id', $data['zw_id']]);
-            }
-            if (isset($data['jtzw_id']) && !empty($data['jtzw_id'])) {
-                array_push($recruit_where, ['jtzw_id', $data['jtzw_id']]);
-            }
-            if (isset($data['hy_id']) && !empty($data['hy_id'])) {
-                array_push($recruit_where, ['hy_id', $data['hy_id']]);
-            }
-            $query = JobRecruiting::where('job_recruiting.status', 1)
-                ->where('job_recruiting.website_id', $data['website_id'])
-                ->where($recruit_where)
-                ->when(isset($data['city_id']) && !empty($data['city_id']), function ($query) use ($data) {
-                    $query->where(function ($q) use ($data) {
-                        $q->WhereRaw("JSON_CONTAINS(job_recruiting.city_arr_id, '" . intval($data['city_id']) . "') = 1");
-                    });
-                })
-                ->when(isset($data['catid']) && !empty($data['catid']), function ($query) use ($data) {
-                    $query->where(function ($q) use ($data) {
-                        $q->WhereRaw("JSON_CONTAINS(job_recruiting.cat_arr_id, '" . intval($data['catid']) . "') = 1");
-                    });
-                })
-                ->leftJoin('job_company', 'job_recruiting.id', '=', 'job_company.job_id')
-                ->select(
-                    'job_recruiting.id',
-                    'job_recruiting.hy_id',
-                    'job_recruiting.title',
-                    'job_recruiting.zw_id',
-                    'job_recruiting.educational',
-                    'job_recruiting.jtzw_id',
-                    'job_recruiting.city_arr_id',
-                    'job_recruiting.due_data',
-                    'job_recruiting.experience',
-                    'job_recruiting.cat_arr_id',
-                    'job_recruiting.updated_at',
-                    'job_company.business_name'
-                )
-                ->orderBy('updated_at', 'desc');
-            $recruit_count = $query->count();
-            $query = clone $query;
-            $JobRecruiting = $query
-                ->offset(($data['page'] - 1) * $data['pageSize'])
-                ->limit($data['pageSize'])
-                ->get();
-            if (empty($JobRecruiting)) {
-                $JobRecruiting = "暂无相关职位信息";
-            } else {
-                $JobRecruiting = $this->processJob($JobRecruiting, $website_id);
-            }
-        }
-        if ((isset($data['type']) && $data['type'] == 2) || !isset($data['type'])) {
-            if (isset($data['zw_id']) && !empty($data['zw_id'])) {
-                array_push($hunt_where, ['job', $data['zw_id']]);
-            }
-            if (isset($data['jtzw_id']) && !empty($data['jtzw_id'])) {
-                array_push($hunt_where, ['job_name_get', $data['jtzw_id']]);
-            }
-            if (isset($data['hy_id']) && !empty($data['hy_id'])) {
-                array_push($hunt_where, ['industry', $data['hy_id']]);
-            }
-            $query = JobHunting::where('status', 2)
-                ->where('job_hunting.website_id', $data['website_id'])
-                ->where($hunt_where)
-                ->when(isset($data['city_id']) && !empty($data['city_id']), function ($query) use ($data) {
-                    $query->where(function ($q) use ($data) {
-                        $q->WhereRaw("JSON_CONTAINS(job_hunting.city_arr_id, '" . intval($data['city_id']) . "') = 1");
-                    });
-                })
-                ->when(isset($data['catid_id']) && !empty($data['catid_id']), function ($query) use ($data) {
-                    $query->where(function ($q) use ($data) {
-                        $q->WhereRaw("JSON_CONTAINS(job_hunting.cat_arr_id, '" . intval($data['catid_id']) . "') = 1");
-                    });
-                })
-                ->select('id', 'sexy', 'experience', 'origin', 'industry', 'name', 'job', 'job_name_get', 'city_arr_id', 'cat_arr_id', 'created_at', 'updated_at')
-                ->orderBy('updated_at', 'desc');
-            $hunt_count = $query->count();
-            $query = clone $query;
-            $JobHunting = $query
-                ->offset(($data['page'] - 1) * $data['pageSize'])
-                ->limit($data['pageSize'])
-                ->get();
-            if (empty($JobHunting)) {
-                $JobRecruiting = "暂无相关简历信息";
-            } else {
-                $JobHunting = $this->processJob($JobHunting, $website_id);
-            }
-        }
-
-
-
-        $result = [
-            'JobRecruiting' => $JobRecruiting ?? [],
-            'recruit_count' => $recruit_count ?? 0,
-            'JobHunting' => $JobHunting ?? [],
-            'hunt_count' => $hunt_count ?? 0,
-        ];
-        return Result::success($result);
+    // 验证是否已沟通过该简历
+    $remuse = JobRemuse::where('user_id', $data['user_id'])
+      ->where('recruit_id', $data['recruit_id'])
+      ->where('website_id', $data['website_id'])
+      ->whereIn('hunt_id', $data['hunt_id'])
+      ->get(['hunt_id']);
+    if (!empty($remuse->toArray())) {
+      return Result::error("您已沟通过该简历!");
     }
-    /**
-     * c端-获取招工招聘详情
-     * @param array $data
-     * @return array
-     *  */
-    public function getWebsiteJobInfo(array $data): array
-    {
-        $web = Website::where('id', $data['website_id'])->first(['id', 'website_name']);
-        if (empty($web)) {
-            return Result::error("该网站不存在", 0);
-        }
-        $webid = [
-            'website_id' => $data['website_id'],
-        ];
-        // 职位相关信息
-        if ($data['type'] == 1) {
-            $query = JobRecruiting::where('status', 1)
-                ->where('website_id', $data['website_id'])
-                ->select('*');
-            $job = $query->where('job_recruiting.id', $data['id'])->get();
-            $company = JobCompany::where('job_id', $data['id'])->select('id', 'business_name', 'company_hy_id', 'company_size', 'company_nature', 'address_arr_id', 'address', 'job_company.email')->get();
-            if (!empty($company)) {
-                $result['company'] = $this->processJob($company, $webid);
-            }
-
-            $other_job = JobRecruiting::where('status', 1)
-                ->where('website_id', $data['website_id'])
-                ->select('title', 'id', 'updated_at', 'cat_arr_id', 'user_id')
-                ->where('id', '!=', $data['id'])
-                ->where('user_id', '=', $job[0]['user_id'])
-                ->limit($data['pageSize'])
-                ->get();
-            if (!empty($other_job)) {
-                $result['other_job'] = $this->processJob($other_job, $webid);
-            }
-        } else {
-            // 简历相关信息
-            $job = JobHunting::where('job_hunting.status', 2)
-                ->where('job_hunting.website_id', $data['website_id'])
-                ->where('job_hunting.id', $data['id'])
-                ->leftJoin('user', 'user.id', '=', 'job_hunting.user_id')
-                ->select('job_hunting.*', 'user_name')
-                ->get();
-
-            $resume = JobRemuse::where('hunt_id', $data['id'])->get();
-            if (!empty($resume->toArray())) {
-                $result['resume'] = 1;
-            } else {
-                $result['resume'] = 0;
-            }
-        }
-        if (empty($job->toArray())) {
-            return Result::error("id参数错误", 0);
-        }
-        if (!empty($job[0]['job_experience'])) {
-            $job_experience = json_decode($job[0]['job_experience'], true) ?? [];
-            if (!empty($job_experience)) {
-                // $hy = [];
-                foreach ($job_experience as $key => $value) {
-                    // $id = $value['id'];
-                    $hy[$key] = $value['job_industry'];
-                    $zw_id[$key] = $value['job_typename'];
-                    $jtzw_id[$key] = $value['job_name'];
-                }
-                $hy_table = JobIndustry::whereIn('hyid', $hy)->select('hyid', 'hyname')->get();
-                $zw_table = JobPosition::select('zwid', 'zwname')->get();
-                // 先将关联表转换为索引数组,提高查找效率
-                $hyLookup = [];
-                foreach ($hy_table as $item) {
-                    $hyLookup[$item['hyid']] = $item['hyname'];
-                }
-
-                $zwLookup = [];
-                foreach ($zw_table as $item) {
-                    $zwLookup[$item['zwid']] = $item['zwname'];
-                }
-
-                foreach ($job_experience as $key => &$value) {
-                    // 处理行业名称
-                    if (isset($hy[$key]) && isset($hyLookup[$hy[$key]])) {
-                        $value['hy_name'] = $hyLookup[$hy[$key]];
-                    }
-
-                    // 处理职位名称
-                    if (isset($zw_id[$key]) && isset($zwLookup[$zw_id[$key]])) {
-                        $value['zw_name'] = $zwLookup[$zw_id[$key]];
-                    }
-
-                    // 处理具体职位名称
-                    if (isset($jtzw_id[$key]) && isset($zwLookup[$jtzw_id[$key]])) {
-                        $value['jtzw_name'] = $zwLookup[$jtzw_id[$key]];
-                    }
-                }
-                // 释放引用,防止意外修改后续代码
-                unset($value);
-            }
-            $result['job_experience'] = $job_experience ?? [];
-        }
-        if (!empty($job[0]['education_experience'])) {
-            $education_experience = json_decode($job[0]['education_experience'], true) ?? '';
-            if (!empty($education_experience)) {
-                foreach ($education_experience as $key => $value) {
-                    // $id = $value['id'];
-                    $education[$key] = $value['school_education'];
-                }
-                $education_table = JobEnum::where('egroup', 'education')->whereIn('evalue', $education)->select('evalue', 'ename')->get();
-                // // 先将关联表转换为索引数组,提高查找效率
-                $educationLookup = [];
-                foreach ($education_table as $item) {
-                    $educationLookup[$item['evalue']] = $item['ename'];
-                }
-
-                foreach ($education_experience as $key => &$value) {
-                    // 处理学历名称
-                    if (isset($education[$key]) && isset($educationLookup[$education[$key]])) {
-                        $value['education_name'] = $educationLookup[$education[$key]];
-                    }
-                }
-            }
-            $result['education_experience'] = $job_experience ?? [];
-        }
-        $result['job'] = $this->processJob($job, $webid);
-        // // 返现对应的栏目
-        $catid = json_decode($job[0]['cat_arr_id'], true) ?? '';
-        $category = WebsiteCategory::where('website_id', $data['website_id'])
-            ->whereIn('category_id', $catid)
-            ->select('category_id', 'alias', 'aLIas_pinyin', 'pid')
-            ->orderBy('pid')->get()->all();
-        if (!empty($category)) {
-            $result['category'] = $category;
-        }
-        $result['job'] = $job;
-        $result['job_experience'] = $job_experience ?? [];
-        $result['education_experience'] = $education_experience ?? [];
-        if (empty($result)) {
-            return Result::error("参数错误", 0);
-        }
-        return Result::success($result);
+    // 准备要插入的数据数组
+    $insertData = array_map(function ($hunting) use ($data) {
+      return [
+        'user_id' => $data['user_id'],
+        'recruit_id' => $data['recruit_id'],
+        'website_id' => $data['website_id'],
+        'hunt_id' => $hunting['hunt_id'],
+        'receiver_id' => $hunting['receiver_id'],
+        'status' => 1,
+      ];
+    }, $hunting);
+
+    // 批量插入数据
+    $result = JobRemuse::insert($insertData);
+    if (empty($result)) {
+      return Result::error("沟通失败", 0);
     }
-    /**
-     * c端-申请职位
-     * @param array $data
-     * @return array
-     *  */
-    public function getWebsiteJobApply(array $data): array
-    {
-        // 首先验证网站是否存在
-        // return Result::success($data);
-        $web = Website::where('id', $data['website_id'])->first(['id', 'website_name']);
-        if (empty($web)) {
-            return Result::error("该网站不存在", 0);
-        }
-        // 验证用户是否存在且为个人会员/管理员
-        $user = User::where('id', $data['user_id'])->first(['id', 'type_id']);
-        // 1:个人会员 2:政务会员 3:企业会员 4:调研员 10000:管理员 20000:游客(小程序)
-        if (empty($user) || ($user['type_id'] != 1 && $user['type_id'] != 10000)) {
-            return Result::error("用户不存在", 0);
-        }
-        // 去除重复元素和空元素,并保持原始顺序
-        $data['recruit_id'] = array_values(array_filter(array_unique($data['recruit_id']), function ($value) {
-            return !empty($value);
-        }));
-        // 验证职位是否存在   1:审核通过
-        $recruiting = JobRecruiting::where('status', 1)
-            ->where('website_id', $data['website_id'])
-            ->whereIn('id', $data['recruit_id'])
-            ->get(['id as recruit_id', 'user_id as receiver_id'])->all();
-        if (empty($recruiting)) {
-            return Result::error("该职位不存在", 0);
-        }
-        // 简历是否存在
-        $hunt_id = JobHunting::where('user_id', $data['user_id'])->where('status', 2)->first(['id as hunt_id']);
-        if (empty($hunt_id)) {
-            return Result::error("该简历不存在", 0);
-        }
-        $data['hunt_id'] = $hunt_id['hunt_id'];
-        // // 验证是否已投递过该职位
-        $apply = JobApply::where('user_id', $data['user_id'])
-            ->where('hunt_id', $data['hunt_id'])
-            ->where('website_id', $data['website_id'])
-            ->whereIn('recruit_id', $data['recruit_id'])
-            ->get(['recruit_id']);
-        if (!empty($apply->toArray())) {
-            return Result::error("您已投递过该职位!");
-        }
-        $insertData = array_map(function ($recruiting) use ($data) {
-            return [
-                'user_id' => $data['user_id'],
-                'hunt_id' => $data['hunt_id'],
-                'website_id' => $data['website_id'],
-                'recruit_id' => $recruiting['recruit_id'],
-                'receiver_id' => $recruiting['receiver_id'],
-                'status' => 1,
-            ];
-        }, $recruiting);
-
-        // 批量插入数据
-        $result = JobApply::insert($insertData);
-        if (empty($result)) {
-            return Result::error("投递失败", 0);
-        }
-        return Result::success($result);
+    return Result::success($result);
+  }
+  /**
+   * 招工招聘  -我的职位(企业会员)
+   * @param array $data
+   * @return array
+   */
+  public function getWebsiteJobRecruiting(array $data): array
+  {
+    $web = Website::where('id', $data['website_id'])->first('id');
+    if (empty($web)) {
+      return Result::error("该网站不存在", 0);
     }
-    /**
-     * 招工招聘-沟通简历
-     * @param array $data
-     * @return array
-     *  */
-    public function getWebsiteJobResume(array $data): array
-    {
-        // 首先验证网站是否存在
-        $web = Website::where('id', $data['website_id'])->first(['id', 'website_name']);
-        if (empty($web)) {
-            return Result::error("该网站不存在", 0);
-        }
-        // return Result::success($data);
-        // 验证用户是否存在且为企业会员/管理员
-        $user = User::where('id', $data['user_id'])->first(['id', 'type_id']);
-        // 1:个人会员 2:政务会员 3:企业会员 4:调研员 10000:管理员 20000:游客(小程序)
-        if (empty($user) || ($user['type_id'] != 3 && $user['type_id'] != 10000)) {
-            return Result::error("用户不存在", 0);
-        }
-        // 去除重复元素和空元素,并保持原始顺序
-        $data['hunt_id'] = array_values(array_filter(array_unique($data['hunt_id']), function ($value) {
-            return !empty($value);
-        }));
-        // 验证简历是否存在
-        $hunting = JobHunting::where('status', 2)
-            ->where('website_id', $data['website_id'])
-            ->whereIn('id', $data['hunt_id'])
-            ->get(['id as hunt_id', 'user_id as receiver_id'])->all();
-        if (empty($hunting)) {
-            return Result::error("该简历不存在", 0);
-        }
-        // 验证是否已沟通过该简历
-        $remuse = JobRemuse::where('user_id', $data['user_id'])
-            ->where('recruit_id', $data['recruit_id'])
-            ->where('website_id', $data['website_id'])
-            ->whereIn('hunt_id', $data['hunt_id'])
-            ->get(['hunt_id']);
-        if (!empty($remuse->toArray())) {
-            return Result::error("您已沟通过该简历!");
-        }
-        // 准备要插入的数据数组
-        $insertData = array_map(function ($hunting) use ($data) {
-            return [
-                'user_id' => $data['user_id'],
-                'recruit_id' => $data['recruit_id'],
-                'website_id' => $data['website_id'],
-                'hunt_id' => $hunting['hunt_id'],
-                'receiver_id' => $hunting['receiver_id'],
-                'status' => 1,
-            ];
-        }, $hunting);
-
-        // 批量插入数据
-        $result = JobRemuse::insert($insertData);
-        if (empty($result)) {
-            return Result::error("沟通失败", 0);
-        }
-        return Result::success($result);
+    $user = User::where('id', $data['user_id'])->first(['id', 'type_id']);
+    if (empty($user) || ($user['type_id'] != 3 && $user['type_id'] != 10000)) {
+      return Result::error("用户暂无权限!", 0);
     }
-    /**
-     * 招工招聘  -我的职位(企业会员)
-     * @param array $data
-     * @return array
-     */
-    public function getWebsiteJobRecruiting(array $data): array
-    {
-        $web = Website::where('id', $data['website_id'])->first('id');
-        if (empty($web)) {
-            return Result::error("该网站不存在", 0);
-        }
-        $user = User::where('id', $data['user_id'])->first(['id', 'type_id']);
-        if (empty($user) || ($user['type_id'] != 3 && $user['type_id'] != 10000)) {
-            return Result::error("用户暂无权限!", 0);
-        }
-        // '状态   0:待审核;1:已审核通过;(只有企业会员需要审核);2:已拒绝;
-        $result = JobRecruiting::where('website_id', $data['website_id'])
-            ->when(isset($user['type_id']) && $user['type_id'] == 3, function ($query) use ($user) {
-                $query->where('user_id', $user['id']);
+    // '状态   0:待审核;1:已审核通过;(只有企业会员需要审核);2:已拒绝;
+    $result = JobRecruiting::where('website_id', $data['website_id'])
+      ->when(isset($user['type_id']) && $user['type_id'] == 3, function ($query) use ($user) {
+        $query->where('user_id', $user['id']);
+      })
+      ->where('status', 1)
+      ->select('id', 'title', 'website_id', 'user_id', 'updated_at')
+      ->orderBy('updated_at', 'desc')
+      ->limit($data['pageSize'])
+      ->get();
+    if (empty($result)) {
+      return Result::error("暂无相关职位信息", 0);
+    }
+    return Result::success($result);
+  }
+
+  /**
+   * c端  -  验证路由
+   * @param array $data
+   * @return array
+   */
+  public function checkWebsiteRoute(array $data): array
+  {
+    $web = Website::where('id', $data['website_id'])->first(['id', 'website_name']);
+    if (empty($web)) {
+      return Result::error("该网站不存在", 0);
+    }
+    // 验证栏目路由
+    $last_category = WebsiteCategory::where('website_id', $data['website_id'])
+      ->where('aLIas_pinyin', $data['last_route'])
+      ->first();
+    if (empty($last_category)) {
+      return Result::error("该栏目不存在", 0);
+    }
+    if (isset($data['id']) && !empty($data['id'])) {
+      //   `type` int unsigned DEFAULT '1' COMMENT '类型:1资讯(默认)2商品3书刊音像4招聘5求职类型:1资讯(默认)2商品3书刊音像4招聘5求职6招工招聘'
+      switch ($last_category['type']) {
+        case 1:
+          // 文章
+          //   `status` int DEFAULT '1' COMMENT '状态: 2:已拒绝  ;1:已发布,0待发布 草稿箱 404删除(移除) 
+          $article = Article::where('status', 1)
+            ->where('id', $data['id'])
+            ->where(function ($query) use ($data) {
+              $query->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($data['website_id']) . "') = 0")
+                ->orWhereNull("ignore_ids");
             })
+            ->first(['cat_arr_id']);
+          if (empty($article)) {
+            return Result::error("该文章不存在", 0);
+          }
+          // return Result::success($article);
+          break;
+        case 2:
+          // 商品
+          // `status` int DEFAULT '1' COMMENT '审核状态,1待审核2已审核3已拒绝',
+          $article = Good::where('website_id', $data['website_id'])
+            ->where('status', 2)
+            ->where('id', $data['id'])
+            ->first(['cat_arr_id']);
+          if (empty($article)) {
+            return Result::error("该商品不存在", 0);
+          }
+          break;
+        case 3:
+          // 书刊信息
+          // `status` int DEFAULT '1' COMMENT '审核状态,1待审核2已审核3已拒绝',
+          $article = Book::where('website_id', $data['website_id'])
+            ->where('status', 2)
+            ->where('id', $data['id'])
+            ->first(['id', 'cat_arr_id']);
+          if (empty($article)) {
+            return Result::error("该书刊不存在", 0);
+          }
+          break;
+        case 4:
+          // 招聘
+          //   `status` int DEFAULT '0' COMMENT '状态   0:待审核;1:已审核;(只有企业会员需要审核)',
+          $article = JobRecruiting::where('website_id', $data['website_id'])
             ->where('status', 1)
-            ->select('id', 'title', 'website_id', 'user_id', 'updated_at')
-            ->orderBy('updated_at', 'desc')
-            ->limit($data['pageSize'])
-            ->get();
-        if (empty($result)) {
-            return Result::error("暂无相关职位信息", 0);
-        }
-        return Result::success($result);
+            ->where('id', $data['id'])
+            ->first(['cat_arr_id']);
+          if (empty($article)) {
+            return Result::error("该招聘不存在", 0);
+          }
+          break;
+        case 5:
+          // 求职
+          //   `status` int DEFAULT '1' COMMENT '审核状态,1待审核2已审核3已拒绝',
+          $article = JobHunting::where('website_id', $data['website_id'])
+            ->where('status', 2)
+            ->where('id', $data['id'])
+            ->first(['cat_arr_id']);
+          if (empty($article)) {
+            return Result::error("该求职不存在", 0);
+          }
+          break;
+        case 6:
+          // 招工招聘
+          // `status` int DEFAULT '1' COMMENT '审核状态,1待审核2已审核3已拒绝',
+          $article = JobRecruiting::where('website_id', $data['website_id'])
+            ->where('status', 1)
+            ->where('id', $data['id'])
+            ->first(['cat_arr_id']);
+          if (empty($article)) {
+            $article = JobHunting::where('website_id', $data['website_id'])
+              ->where('status', 2)
+              ->where('id', $data['id'])
+              ->first(['cat_arr_id']);
+          }
+          if (empty($article)) {
+            return Result::error("该招工招聘不存在", 0);
+          }
+          break;
+        default:
+          return Result::error("该数据不存在", 0);
+          break;
+      }
+      $catid = json_decode($article['cat_arr_id'], true);
+      if (empty($catid)) {
+        return Result::error("该数据不存在", 0);
+      }
+      $pinyin = WebsiteCategory::where('website_id', $data['website_id'])
+        ->orderByRaw('FIELD(category_id, ' . implode(',', $catid) . ')')
+        ->whereIn('category_id', $catid)
+        ->pluck('aLIas_pinyin')
+        ->implode('/');
     }
-
-    /**
-     * c端  -  验证路由
-     * @param array $data
-     * @return array
-     */
-    public function checkWebsiteRoute(array $data): array
-    {
-        $web = Website::where('id', $data['website_id'])->first(['id', 'website_name']);
-        if (empty($web)) {
-            return Result::error("该网站不存在", 0);
-        }
-        // 验证栏目路由
-        $last_category = WebsiteCategory::where('website_id', $data['website_id'])
-            ->where('aLIas_pinyin', $data['last_route'])
-            ->first();
-        if (empty($last_category)) {
-            return Result::error("该栏目不存在", 0);
-        }
-        if (isset($data['id']) && !empty($data['id'])) {
-            //   `type` int unsigned DEFAULT '1' COMMENT '类型:1资讯(默认)2商品3书刊音像4招聘5求职类型:1资讯(默认)2商品3书刊音像4招聘5求职6招工招聘'
-            switch ($last_category['type']) {
-                case 1:
-                    // 文章
-                    //   `status` int DEFAULT '1' COMMENT '状态: 2:已拒绝  ;1:已发布,0待发布 草稿箱 404删除(移除) 
-                    $article = Article::where('status', 1)
-                        ->where('id', $data['id'])
-                        ->where(function ($query) use ($data) {
-                            $query->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($data['website_id']) . "') = 0")
-                                ->orWhereNull("ignore_ids");
-                        })
-                        ->first(['cat_arr_id']);
-                    if (empty($article)) {
-                        return Result::error("该文章不存在", 0);
-                    }
-                    // return Result::success($article);
-                    break;
-                case 2:
-                    // 商品
-                    // `status` int DEFAULT '1' COMMENT '审核状态,1待审核2已审核3已拒绝',
-                    $article = Good::where('website_id', $data['website_id'])
-                        ->where('status', 2)
-                        ->where('id', $data['id'])
-                        ->first(['cat_arr_id']);
-                    if (empty($article)) {
-                        return Result::error("该商品不存在", 0);
-                    }
-                    break;
-                case 3:
-                    // 书刊信息
-                    // `status` int DEFAULT '1' COMMENT '审核状态,1待审核2已审核3已拒绝',
-                    $article = Book::where('website_id', $data['website_id'])
-                        ->where('status', 2)
-                        ->where('id', $data['id'])
-                        ->first(['id', 'cat_arr_id']);
-                    if (empty($article)) {
-                        return Result::error("该书刊不存在", 0);
-                    }
-                    break;
-                case 4:
-                    // 招聘
-                    //   `status` int DEFAULT '0' COMMENT '状态   0:待审核;1:已审核;(只有企业会员需要审核)',
-                    $article = JobRecruiting::where('website_id', $data['website_id'])
-                        ->where('status', 1)
-                        ->where('id', $data['id'])
-                        ->first(['cat_arr_id']);
-                    if (empty($article)) {
-                        return Result::error("该招聘不存在", 0);
-                    }
-                    break;
-                case 5:
-                    // 求职
-                    //   `status` int DEFAULT '1' COMMENT '审核状态,1待审核2已审核3已拒绝',
-                    $article = JobHunting::where('website_id', $data['website_id'])
-                        ->where('status', 2)
-                        ->where('id', $data['id'])
-                        ->first(['cat_arr_id']);
-                    if (empty($article)) {
-                        return Result::error("该求职不存在", 0);
-                    }
-                    break;
-                case 6:
-                    // 招工招聘
-                    // `status` int DEFAULT '1' COMMENT '审核状态,1待审核2已审核3已拒绝',
-                    $article = JobRecruiting::where('website_id', $data['website_id'])
-                        ->where('status', 1)
-                        ->where('id', $data['id'])
-                        ->first(['cat_arr_id']);
-                    if (empty($article)) {
-                        $article = JobHunting::where('website_id', $data['website_id'])
-                            ->where('status', 2)
-                            ->where('id', $data['id'])
-                            ->first(['cat_arr_id']);
-                    }
-                    if (empty($article)) {
-                        return Result::error("该招工招聘不存在", 0);
-                    }
-                    break;
-                default:
-                    return Result::error("该数据不存在", 0);
-                    break;
-            }
-            $catid = json_decode($article['cat_arr_id'], true);
-            if (empty($catid)) {
-                return Result::error("该数据不存在", 0);
-            }
-            $pinyin = WebsiteCategory::where('website_id', $data['website_id'])
-                ->orderByRaw('FIELD(category_id, ' . implode(',', $catid) . ')')
-                ->whereIn('category_id', $catid)
-                ->pluck('aLIas_pinyin')
-                ->implode('/');
-        }
-        if ($last_category['pid'] != 0) {
-            $cat_arr = json_decode($last_category['category_arr_id'], true);
-            $pinyin = WebsiteCategory::where('website_id', $data['website_id'])
-                ->orderByRaw('FIELD(category_id, ' . implode(',', $cat_arr) . ')')
-                ->whereIn('category_id', $cat_arr)
-                ->pluck('aLIas_pinyin')
-                ->implode('/');
-        } else {
-            $pinyin = $last_category['aLIas_pinyin'];
-        }
-        if (empty($pinyin) || $pinyin != $data['all_route']) {
-            return Result::error('非法路径!');
-        } else {
-            return Result::success($pinyin);
-        }
+    if ($last_category['pid'] != 0) {
+      $cat_arr = json_decode($last_category['category_arr_id'], true);
+      $pinyin = WebsiteCategory::where('website_id', $data['website_id'])
+        ->orderByRaw('FIELD(category_id, ' . implode(',', $cat_arr) . ')')
+        ->whereIn('category_id', $cat_arr)
+        ->pluck('aLIas_pinyin')
+        ->implode('/');
+    } else {
+      $pinyin = $last_category['aLIas_pinyin'];
     }
-
-    /**
-     * 验证导航名称是否重复
-     * @return void
-     */
-    public function checkCategoryName(array $data): array
-    {
-        $result = Category::when($data, function ($query) use ($data) {
-            if (isset($data['name']) && $data['name']) {
-                $query->where("name", $data['name']);
-            }
-            if (isset($data['id']) && $data['id']) {
-                $query->where("id", "!=", $data['id']);
-            }
-        })->first();
-        if ($result) {
-            return Result::error("已存在");
-        } else {
-            return Result::success();
-        }
+    if (empty($pinyin) || $pinyin != $data['all_route']) {
+      return Result::error('非法路径!');
+    } else {
+      return Result::success($pinyin);
     }
-
-    //20250226  产品列表
-
-    public function getGoodList(array $data): array
-    {
-        $type_id = isset($data['type_id']) ? $data['type_id'] : '';
-        unset($data['type_id']);
-        $user_id = isset($data['user_id']) ? $data['user_id'] : '';
-        $where = [];
-        if ($type_id != '10000') {
-            $where = [
-                'good.user_id' => $user_id,
-            ];
-        }
-        //类型
-        if (isset($data['type_id']) && $data['type_id']) {
-            $where = [
-                'type_id' => $data['type_id'],
-            ];
-        }
-        //名称
-        if (isset($data['name']) && $data['name']) {
-            $where = [
-                'good.name' => $data['name'],
-            ];
-        }
-        //status
-        if (isset($data['status']) && $data['status'] != '') {
-            $where = [
-                'good.status' => $data['status'],
-            ];
-        }
-        //status1
-        // if (isset($data['status1']) && $data['status1'] == 1) {
-        //     $status1 = 1;
-        // }
-        $where1 = [];
-        //website_id
-        // if (isset($data['website_id']) && $data['website_id']) {
-        //     $where1 = [
-        //         'good.website_id', 'like', '%' . $data['website_id'] . '%',
-        //     ];
-        // }
-        // website_name
-        if (isset($data['website_name']) && $data['website_name']) {
-            $where1[] = ['website.website_name', 'like', '%' . $data['website_name'] . '%'];
-        }
-
-        // catid
-        if (isset($data['category_name']) && $data['category_name']) {
-            $where1[] = ['category.name', 'like', '%' . $data['category_name'] . '%'];
-        }
-
-        // $result = Good::where($where)
-        // ->orderBy("updated_at", "desc")->paginate($data['pige_size'], ['*'], 'page', $data['page']);
-        $result = Good::where($where)
-            ->when(!empty($where1), function ($query) use ($where1) {
-                return $query->where($where1);
-            })
-            //status  1待审核2已审核3已拒绝
-            ->when(isset($data['status1']), function ($query) {
-                return $query->whereIn('good.status', [1, 3]);
-            })
-            ->leftJoin('district', 'good.city_id', '=', 'district.id')
-            ->leftJoin('website', 'good.website_id', '=', 'website.id')
-            ->leftJoin('category', 'good.catid', '=', 'category.id')
-            ->select('good.*', 'district.name as cityname', 'website.website_name as website_name', 'category.name as category_name')
-            ->orderBy("updated_at", "desc")
-            ->limit($data['page_size'])
-            ->offset(($data['page'] - 1) * $data['page_size'])
-            ->get();
-        $count = Good::where($where)
-            ->when(!empty($where1), function ($query) use ($where1) {
-                return $query->where($where1);
-            })
-            //status  1待审核2已审核3已拒绝
-            ->when(isset($data['status1']), function ($query) {
-                return $query->whereIn('good.status', [1, 3]);
-            })
-            ->leftJoin('district', 'good.city_id', '=', 'district.id')
-            ->leftJoin('website', 'good.website_id', '=', 'website.id')
-            ->leftJoin('category', 'good.catid', '=', 'category.id')
-            ->select('good.*', 'district.name as cityname', 'website.website_name as website_name', 'category.name as category_name')
-            ->orderBy("updated_at", "desc")->count();
-        $data = [
-            'rows' => $result->toArray(),
-            'count' => $count,
-        ];
-
-        if (empty($result)) {
-            return Result::error("此栏目暂无相关产品", 0);
-        }
-        return Result::success($data);
+  }
+
+  /**
+   * 验证导航名称是否重复
+   * @return void
+   */
+  public function checkCategoryName(array $data): array
+  {
+    $result = Category::when($data, function ($query) use ($data) {
+      if (isset($data['name']) && $data['name']) {
+        $query->where("name", $data['name']);
+      }
+      if (isset($data['id']) && $data['id']) {
+        $query->where("id", "!=", $data['id']);
+      }
+    })->first();
+    if ($result) {
+      return Result::error("已存在");
+    } else {
+      return Result::success();
     }
-    public function getGoodInfo(array $data): array
-    {
-        $result = Good::where('id', $data['id'])->first();
-        if (empty($result)) {
-            return Result::error("此产品不存在", 0);
-        }
-        return Result::success($result);
-    }
-    public function addGood(array $data): array
-    {
-        // unset($data['city_arr_id']);
-        // unset($data['cat_arr_id']);
-        $data['city_id'] = end($data['city_arr_id']);
-        $data['catid'] = end($data['cat_arr_id']);
-        $data['city_arr_id'] = isset($data['city_arr_id']) ? json_encode($data['city_arr_id']) : '';
-        $data['cat_arr_id'] = isset($data['cat_arr_id']) ? json_encode($data['cat_arr_id']) : '';
-        $data['imgurl'] = isset($data['imgurl']) ? json_encode($data['imgurl']) : '';
-        unset($data['imgUrl']);
-        if (isset($data['price']) && $data['price'] == '') {
-            $data['price'] =  0;
-        }
-        $result = Good::insert($data);
-        if (empty($result)) {
-            return Result::error("添加失败", 0);
-        }
-        return Result::success($result);
-    }
-    public function updateGood(array $data): array
-    {
-        $data['city_id'] = end($data['city_arr_id']);
-        $data['catid'] = end($data['cat_arr_id']);
-        $data['city_arr_id'] = isset($data['city_arr_id']) ? json_encode($data['city_arr_id']) : '';
-        $data['cat_arr_id'] = isset($data['cat_arr_id']) ? json_encode($data['cat_arr_id']) : '';
-        $data['imgurl'] = isset($data['imgurl']) ? json_encode($data['imgurl']) : '';
-        //设置东八区
-        date_default_timezone_set('Asia/Shanghai');
-        $data['updated_at'] = date('Y-m-d H:i:s');
-        if (isset($data['price']) && $data['price'] == '') {
-            $data['price'] =  0;
-        }
-        $result = Good::where('id', $data['id'])->update($data);
-        if (empty($result)) {
-            return Result::error("更新失败", 0);
-        }
-        return Result::success($result);
+  }
+
+  //20250226  产品列表
+
+  public function getGoodList(array $data): array
+  {
+    $type_id = isset($data['type_id']) ? $data['type_id'] : '';
+    unset($data['type_id']);
+    $user_id = isset($data['user_id']) ? $data['user_id'] : '';
+    $where = [];
+    if ($type_id != '10000') {
+      $where = [
+        'good.user_id' => $user_id,
+      ];
     }
-    public function delGood(array $data): array
-    {
-        $result = Good::where('id', $data['id'])->delete();
-        if (empty($result)) {
-            return Result::error("删除失败", 0);
-        }
-        return Result::success($result);
+    //类型
+    if (isset($data['type_id']) && $data['type_id']) {
+      $where = [
+        'type_id' => $data['type_id'],
+      ];
+    }
+    //名称
+    if (isset($data['name']) && $data['name']) {
+      $where = [
+        'good.name' => $data['name'],
+      ];
+    }
+    //status
+    if (isset($data['status']) && $data['status'] != '') {
+      $where = [
+        'good.status' => $data['status'],
+      ];
+    }
+    //status1
+    // if (isset($data['status1']) && $data['status1'] == 1) {
+    //     $status1 = 1;
+    // }
+    $where1 = [];
+    //website_id
+    // if (isset($data['website_id']) && $data['website_id']) {
+    //     $where1 = [
+    //         'good.website_id', 'like', '%' . $data['website_id'] . '%',
+    //     ];
+    // }
+    // website_name
+    if (isset($data['website_name']) && $data['website_name']) {
+      $where1[] = ['website.website_name', 'like', '%' . $data['website_name'] . '%'];
     }
 
-    //20250226  产品列表
-    //20250306  求职信息
-    public function getJobHuntingList(array $data): array
-    {
-        $where = [];
-        if (isset($data['username']) && !empty($data['username'])) {
-
-            $where[] = ['user.user_name', 'like', '%' . $data['username'] . '%'];
-        }
-        //status  1待审核2已审核3已拒绝
-        if (isset($data['status']) && $data['status'] != '') {
-            $where = [
-                'job_hunting.status' => $data['status'],
-            ];
-        }
-        $type_id = isset($data['type_id']) ? $data['type_id'] : '';
-        $user_id = isset($data['user_id']) ? $data['user_id'] : '';
-        unset($data['type_id']);
-        if ($type_id != '10000') {
-            $where[] = ['job_hunting.user_id', '=', $user_id];
-        }
-        $result = JobHunting::where($where)
-            ->when(!empty($data['status1']), function ($query) use ($data) {
-                return $query->whereIn('job_hunting.status', [1, 3]);   //1待审核2已审核3已拒绝
-            })
-
-            ->leftJoin('user', 'user.id', '=', 'job_hunting.user_id')
-            ->leftJoin('website', 'website.id', '=', 'job_hunting.website_id')
-            ->select('job_hunting.*', 'user.nickname as nickname', 'user.user_name as username', 'website.website_name as website_name')
-            ->orderBy("updated_at", "desc")
-            ->limit($data['page_size'])
-            ->offset(($data['page'] - 1) * $data['page_size'])
-            ->get();
-        if (empty($result)) {
-            return Result::error("查询失败", 0);
-        }
-        $count = JobHunting::where($where)
-            ->leftJoin('user', 'user.id', '=', 'job_hunting.user_id')
-            ->leftJoin('website', 'website.id', '=', 'job_hunting.website_id')
-            ->count();
-        $data = [
-            'rows' => $result->toArray(),
-            'count' => $count,
-        ];
-        return Result::success($data);
-    }
-    public function getJobHuntingApply(array $data): array
-    {
-        var_dump($data, '-----------------test--------1-');
-        $where = [];
-        if (isset($data['username']) && !empty($data['username'])) {
-            $where[] = ['user.user_name', 'like', '%' . $data['username'] . '%'];
-        }
-        if (isset($data['salary']) && !empty($data['salary'])) {
-            $where[] = [
-                'job_hunting.salary',
-                '=',
-                $data['salary'],
-            ];
-        }
-        $type_id = isset($data['type_id']) ? $data['type_id'] : '';
-        $user_id = isset($data['user_id']) ? $data['user_id'] : '';
-        unset($data['type_id']);
-        if ($type_id != '10000') {
-            $where[] = ['job_apply.user_id', '=', $user_id];
-        }
+    // catid
+    if (isset($data['category_name']) && $data['category_name']) {
+      $where1[] = ['category.name', 'like', '%' . $data['category_name'] . '%'];
+    }
 
-        var_dump($where, '-----------------test---------');
-        $result = jobApply::where($where)
-            // ->when(!empty($data['status1']), function ($query) use ($data) {
-            //     return $query->whereIn('job_hunting.status', [1, 3]);   //1待审核2已审核3已拒绝
-            // })
-            // ->leftJoin('user', 'user.id', '=', 'job_hunting.user_id') 'user.nickname as nickname',  , 'user.user_name as username'
-            ->where('job_enum.egroup', '=', 'income')
-            ->where('job_hunting.status', 2) //已审核
-            ->leftJoin('job_hunting', 'job_hunting.id', '=', 'job_apply.hunt_id')
-            ->leftJoin('district', 'district.id', '=', 'job_hunting.city_id')
-            ->leftJoin('job_enum', 'job_enum.evalue', '=', 'job_hunting.salary')
-            ->leftJoin('user', 'job_hunting.user_id', '=', 'user.id')
-            //职位----是申请职位
-            ->leftJoin('job_position', 'job_hunting.job_name_get', '=', 'job_position.zwid')
-            ->select('job_apply.*', 'job_position.zwname as job_name', 'job_hunting.salary as salary', 'district.name as cityname', 'job_enum.ename as salary_name', 'user.nickname as nickname', 'user.user_name as username', 'job_hunting.updated_at as updated_at')
-            ->orderBy("job_hunting.updated_at", "desc")
-            ->limit($data['page_size'])
-            ->offset(($data['page'] - 1) * $data['page_size'])
-            ->get();
-        if (empty($result)) {
-            return Result::error("查询失败", 0);
-        }
-        $count = jobApply::where($where)
-            ->where('job_enum.egroup', '=', 'income')
-            ->where('job_hunting.status', 2) //已审核
-            ->leftJoin('job_hunting', 'job_hunting.id', '=', 'job_apply.hunt_id')
-            ->leftJoin('district', 'district.id', '=', 'job_hunting.city_id')
-            ->leftJoin('job_enum', 'job_enum.evalue', '=', 'job_hunting.salary')
-            ->leftJoin('user', 'job_hunting.user_id', '=', 'user.id')
-            //职位----是申请职位
-            ->leftJoin('job_position', 'job_hunting.job_name_get', '=', 'job_position.zwid')
-            ->select('job_apply.*', 'job_position.zwname as job_name', 'job_hunting.salary as salary', 'district.name as cityname', 'job_enum.ename as salary_name', 'user.nickname as nickname', 'user.user_name as username', 'job_hunting.updated_at as updated_at')
-            ->count();
-        $data = [
-            'rows' => $result->toArray(),
-            'count' => $count,
-        ];
-        return Result::success($data);
-    }
-    public function addJobHunting(array $data): array
-    {
-        date_default_timezone_set('Asia/Shanghai');
-        unset($data['company_name']);
-        unset($data['job_industry']);
-        unset($data['job_name']);
-        unset($data['department']);
-        unset($data['job_timeList']);
-        unset($data['job_content']);
-        unset($data['job_typename']); //不知道这是啥,
-        $data['created_at'] = date('Y-m-d H:i:s');
-        $data['updated_at'] = date('Y-m-d H:i:s');
-        //根据用户 user_id 只能添加一次
-        $result = JobHunting::where('user_id', $data['user_id'])->first();
-        if (!empty($result)) {
-            return Result::error("您已添加过求职信息", 0);
-        }
-        var_dump($result, '-----------------test---------');
-        $result = JobHunting::create($data);
-        if (empty($result)) {
-            return Result::error("添加失败", 0);
-        }
-        return Result::success($result);
+    // $result = Good::where($where)
+    // ->orderBy("updated_at", "desc")->paginate($data['pige_size'], ['*'], 'page', $data['page']);
+    $result = Good::where($where)
+      ->when(!empty($where1), function ($query) use ($where1) {
+        return $query->where($where1);
+      })
+      //status  1待审核2已审核3已拒绝
+      ->when(isset($data['status1']), function ($query) {
+        return $query->whereIn('good.status', [1, 3]);
+      })
+      ->leftJoin('district', 'good.city_id', '=', 'district.id')
+      ->leftJoin('website', 'good.website_id', '=', 'website.id')
+      ->leftJoin('category', 'good.catid', '=', 'category.id')
+      ->select('good.*', 'district.name as cityname', 'website.website_name as website_name', 'category.name as category_name')
+      ->orderBy("updated_at", "desc")
+      ->limit($data['page_size'])
+      ->offset(($data['page'] - 1) * $data['page_size'])
+      ->get();
+    $count = Good::where($where)
+      ->when(!empty($where1), function ($query) use ($where1) {
+        return $query->where($where1);
+      })
+      //status  1待审核2已审核3已拒绝
+      ->when(isset($data['status1']), function ($query) {
+        return $query->whereIn('good.status', [1, 3]);
+      })
+      ->leftJoin('district', 'good.city_id', '=', 'district.id')
+      ->leftJoin('website', 'good.website_id', '=', 'website.id')
+      ->leftJoin('category', 'good.catid', '=', 'category.id')
+      ->select('good.*', 'district.name as cityname', 'website.website_name as website_name', 'category.name as category_name')
+      ->orderBy("updated_at", "desc")->count();
+    $data = [
+      'rows' => $result->toArray(),
+      'count' => $count,
+    ];
+
+    if (empty($result)) {
+      return Result::error("此栏目暂无相关产品", 0);
     }
-    public function delJobHunting(array $data): array
-    {
-        $result = JobHunting::where('id', $data['id'])->delete();
-        if (empty($result)) {
-            return Result::error("删除失败", 0);
-        }
-        return Result::success($result);
-    }
-    public function updateJobHunting(array $data): array
-    {
-        //设置东八区
-        date_default_timezone_set('Asia/Shanghai');
-        unset($data['company_name']);
-        unset($data['job_industry']);
-        unset($data['job_name']);
-        unset($data['department']);
-        unset($data['job_timeList']);
-        unset($data['job_content']);
-        unset($data['job_typename']); //不知道这是啥,
-        $data['created_at'] = date('Y-m-d H:i:s');
-        $data['updated_at'] = date('Y-m-d H:i:s');
-        $result = JobHunting::where('id', $data['id'])->update($data);
-        if (empty($result)) {
-            return Result::error("更新失败", 0);
-        }
-        return Result::success($result);
+    return Result::success($data);
+  }
+  public function getGoodInfo(array $data): array
+  {
+    $result = Good::where('id', $data['id'])->first();
+    if (empty($result)) {
+      return Result::error("此产品不存在", 0);
     }
-    public function getJobHuntingInfo(array $data): array
-    {
-        $result = JobHunting::where('id', $data['id'])->first();
-        if (empty($result)) {
-            return Result::error("查询失败", 0);
-        }
-        return Result::success($result);
-    }
-    public function getJobHuntingData(array $data): array
-    {
-        $jobEnum = JobEnum::get();
-        $jobIndustry = JobIndustry::get();
-        $jobNature = JobNature::get();
-        $jobPosition = JobPosition::get();
-        $data = [
-            'jobEnum' => $jobEnum,
-            'jobIndustry' => $jobIndustry,
-            'jobNature' => $jobNature,
-            'jobPosition' => $jobPosition,
-        ];
-        return Result::success($data);
-    }
-    public function delJobHuntingInfo(array $data): array
-    {
-        $result = JobHunting::where('id', $data['id'])->delete();
-        return Result::success();
-    }
-    //20250324  通知,公告,消息
-    public function delNotice(array $data): array
-    {
-        $result = Notice::where('id', $data['id'])->delete();
-        if ($result) {
-            return Result::success();
-        } else {
-            return Result::error("删除失败", 0);
-        }
+    return Result::success($result);
+  }
+  public function addGood(array $data): array
+  {
+    // unset($data['city_arr_id']);
+    // unset($data['cat_arr_id']);
+    $data['city_id'] = end($data['city_arr_id']);
+    $data['catid'] = end($data['cat_arr_id']);
+    $data['city_arr_id'] = isset($data['city_arr_id']) ? json_encode($data['city_arr_id']) : '';
+    $data['cat_arr_id'] = isset($data['cat_arr_id']) ? json_encode($data['cat_arr_id']) : '';
+    $data['imgurl'] = isset($data['imgurl']) ? json_encode($data['imgurl']) : '';
+    unset($data['imgUrl']);
+    if (isset($data['price']) && $data['price'] == '') {
+      $data['price'] =  0;
     }
-    public function getNoticeInfo(array $data): array
-    {
-        $result = Notice::where('id', $data['id'])->first();
-        if (empty($result)) {
-            return Result::error("查询失败", 0);
-        }
-        return Result::success($result);
-    }
-    public function addNotice(array $data): array
-    {
-        date_default_timezone_set('Asia/Shanghai');
-        $data['created_at'] = date('Y-m-d H:i:s');
-        $data['updated_at'] = date('Y-m-d H:i:s');
-        $user_id = UserInfo::
-            //city_id不是null
-            whereNotNull('city_id')
-            ->whereNotNull('department_id')
-            ->where(function ($query) use ($data) {
-                $query->where(function ($subQuery) use ($data) {
-                    $subQuery->whereRaw("JSON_VALID(city_arr_id) AND JSON_CONTAINS(city_arr_id, '" . intval($data['city_id']) . "') = 1");
-                });
-            })
-            ->where(function ($query) use ($data) {
-                $query->where(function ($subQuery) use ($data) {
-                    $subQuery->whereRaw("JSON_VALID(department_arr_id) AND JSON_CONTAINS(department_arr_id, '" . intval($data['department_id']) . "') = 1");
-                });
-            })
-            ->pluck('user_id')->toArray();
-        $user_id = array_unique($user_id);
-        $chat_ids = $user_id;
-        $user_id = json_encode($user_id);
-        $data['re_user_ids'] = $user_id;
-        $result = Notice::insertGetId($data);
-        if ($result && $data['is_group'] == 1) {
-            //chat_group
-            $group_id = PublicData::uuid();
-            $groupData = [
-                'id' => $group_id,
-                'creator_id' => $data['user_id'],
-                'group_name' => $data['group_name'] ?? '',
-                'profile' => $data['profile'] ?? 0,
-            ];
-            var_dump($groupData, '-----------------groupData-------');
-
-            $groupResult = ChatGroups::insertGetId($groupData);
-            var_dump($groupResult, '-----------------groupid-------');
-            $groupMemberData = [
-                'id' => PublicData::uuid(),
-                'user_id' => $data['user_id'],
-                'group_id' => $group_id,
-                'leader' => 2,
-            ];
-            $groupMemberResult = ChatGroupsMember::insertGetId($groupMemberData);
-
-            //$chat_ids 去除掉$data['user_id']
-            $chat_ids = array_diff($chat_ids, [$data['user_id']]);
-            //插入群成员表
-            $groupMemberDataUser = [];
-            $chatData = [];
-            foreach ($chat_ids as $key => $value) {
-                $groupMemberDataUser[] = [
-                    'id' => PublicData::uuid(),
-                    'user_id' => $value,
-                    'group_id' => $group_id,
-                    'leader' => 1,
-                ];
-                $chatData[] = [
-                    'user_id' => $value,
-                    'msg_type' => 1,
-                    'receiver_id' => $group_id,
-                    'content' => '通过通知创建群聊',
-                    'group_receiver_id' => $data['user_id'],
-                    'action' => 'recieved',
-                    'created_at' => date('Y-m-d H:i:s'),
-                ];
-            }
-            var_dump($groupMemberDataUser, '-----------------groupMemberDataUser-------');
-            ChatGroupsMember::insert($groupMemberDataUser);
-            //插入一条管理员聊天记录
-            $chatData[] = [
-                'user_id' => $data['user_id'],
-                'msg_type' => 1,
-                'receiver_id' => $group_id,
-                'content' => '通过通知创建群聊',
-                'group_receiver_id' => $data['user_id'],
-                'action' => 'said',
-                'created_at' => date('Y-m-d H:i:s'),
-            ];
-            var_dump($chatData, '-----------------chatData-------');
-            $chatResult = ChatRecords::insert($chatData);
+    $result = Good::insert($data);
+    if (empty($result)) {
+      return Result::error("添加失败", 0);
+    }
+    return Result::success($result);
+  }
+  public function updateGood(array $data): array
+  {
+    $data['city_id'] = end($data['city_arr_id']);
+    $data['catid'] = end($data['cat_arr_id']);
+    $data['city_arr_id'] = isset($data['city_arr_id']) ? json_encode($data['city_arr_id']) : '';
+    $data['cat_arr_id'] = isset($data['cat_arr_id']) ? json_encode($data['cat_arr_id']) : '';
+    $data['imgurl'] = isset($data['imgurl']) ? json_encode($data['imgurl']) : '';
+    //设置东八区
+    date_default_timezone_set('Asia/Shanghai');
+    $data['updated_at'] = date('Y-m-d H:i:s');
+    if (isset($data['price']) && $data['price'] == '') {
+      $data['price'] =  0;
+    }
+    $result = Good::where('id', $data['id'])->update($data);
+    if (empty($result)) {
+      return Result::error("更新失败", 0);
+    }
+    return Result::success($result);
+  }
+  public function delGood(array $data): array
+  {
+    $result = Good::where('id', $data['id'])->delete();
+    if (empty($result)) {
+      return Result::error("删除失败", 0);
+    }
+    return Result::success($result);
+  }
 
-            //更新result的 group_id
-            $data['group_id'] = $group_id;
-            Notice::where(['id' => $result])->update($data);
-        }
+  //20250226  产品列表
+  //20250306  求职信息
+  public function getJobHuntingList(array $data): array
+  {
+    $where = [];
+    if (isset($data['username']) && !empty($data['username'])) {
 
-        if (empty($result)) {
-            return Result::error("添加失败", 0);
-        }
-        return Result::success($result);
-    }
-    public function updateNotice(array $data): array
-    {
-        date_default_timezone_set('Asia/Shanghai');
-        //根据city_id  和department_id  查询出对应的user_id,放到 re_user_ids
-        $user_id = UserInfo::
-            //city_id不是null
-            whereNotNull('city_id')
-            ->whereNotNull('department_id')
-            ->where(function ($query) use ($data) {
-                $query->where(function ($subQuery) use ($data) {
-                    $subQuery->whereRaw("JSON_VALID(city_arr_id) AND JSON_CONTAINS(city_arr_id, '" . intval($data['city_id']) . "') = 1");
-                });
-            })
-            ->where(function ($query) use ($data) {
-                $query->where(function ($subQuery) use ($data) {
-                    $subQuery->whereRaw("JSON_VALID(department_arr_id) AND JSON_CONTAINS(department_arr_id, '" . intval($data['department_id']) . "') = 1");
-                });
-            })
-            ->pluck('user_id')->toArray();
-        $user_id = array_unique($user_id);
-        $user_id = json_encode($user_id);
-        $data['re_user_ids'] = $user_id;
-        $data['updated_at'] = date('Y-m-d H:i:s');
-        $result = Notice::where('id', $data['id'])->update($data);
-        return Result::success($result);
-    }
-    public function getNoticeList(array $data): array
-    {
-        $where = [];
-        //title
-        if (isset($data['title']) && !empty($data['title'])) {
-            $where[] = ['notice.title', 'like', '%' . $data['title'] . '%'];
-        }
-        //level
-        if (isset($data['level']) && !empty($data['level'])) {
-            $where[] = ['notice.level', '=', $data['level']];
-        }
-        //status
-        if (isset($data['status']) && !empty($data['status'])) {
-            $where[] = ['notice.status', '=', $data['status']];
-        }
-        var_dump($data, '-----------------test---------');
-        if ($data['type_id'] == 10000) {
-            $result = Notice::when(!empty($data['status1']), function ($query) use ($data) {
-                return $query->whereIn('notice.status', [1, 3]);   //1待审核2已审核3已拒绝
-            })
-                ->where($where)
-                ->orderBy('updated_at', 'desc')
-                ->limit($data['page_size'])
-                ->offset(($data['page'] - 1) * $data['page_size'])
-                ->get();
-            $total = Notice::when(!empty($data['status1']), function ($query) use ($data) {
-                return $query->whereIn('notice.status', [1, 3]);   //1待审核2已审核3已拒绝
-            })
-                ->where($where)
-                ->orderBy('updated_at', 'desc')
-                ->count();
-        } else {
-            $result = Notice::where($where)
-                // ->where('user_id', $data['user_id'])
-                ->Where(function ($query) use ($data) {
-                    $query->Where(function ($q) use ($data) {
-                        $q->whereRaw('JSON_CONTAINS(notice.re_user_ids, \'' . $data['user_id'] . '\')')
-                            ->orWhere('notice.user_id', $data['user_id']);
-                    });
-                })
-                ->orderBy('updated_at', 'desc')
-                ->limit($data['page_size'])
-                ->offset(($data['page'] - 1) * $data['page_size'])
-                ->get();
-            $total = Notice::where($where)
-                // ->where('user_id', $data['user_id'])
-                ->Where(function ($query) use ($data) {
-                    $query->Where(function ($q) use ($data) {
-                        $q->whereRaw('JSON_CONTAINS(notice.re_user_ids, \'' . $data['user_id'] . '\')')
-                            ->orWhere('notice.user_id', $data['user_id']);
-                    });
-                })
-                ->count();
-        }
-        if (empty($result)) {
-            return Result::error("查询失败", 0);
-        }
-        $data = [
-            'rows' => $result,
-            'count' => $total,
-        ];
-        return Result::success($data);
+      $where[] = ['user.user_name', 'like', '%' . $data['username'] . '%'];
     }
-    public function getNoticeDetail(array $data): array
-    {
-        $result = Notice::where('id', $data['id'])->first();
-        if (empty($result)) {
-            return Result::error("查询失败", 0);
-        }
-        return Result::success($result);
+    //status  1待审核2已审核3已拒绝
+    if (isset($data['status']) && $data['status'] != '') {
+      $where = [
+        'job_hunting.status' => $data['status'],
+      ];
+    }
+    $type_id = isset($data['type_id']) ? $data['type_id'] : '';
+    $user_id = isset($data['user_id']) ? $data['user_id'] : '';
+    unset($data['type_id']);
+    if ($type_id != '10000') {
+      $where[] = ['job_hunting.user_id', '=', $user_id];
+    }
+    $result = JobHunting::where($where)
+      ->when(!empty($data['status1']), function ($query) use ($data) {
+        return $query->whereIn('job_hunting.status', [1, 3]);   //1待审核2已审核3已拒绝
+      })
+
+      ->leftJoin('user', 'user.id', '=', 'job_hunting.user_id')
+      ->leftJoin('website', 'website.id', '=', 'job_hunting.website_id')
+      ->select('job_hunting.*', 'user.nickname as nickname', 'user.user_name as username', 'website.website_name as website_name')
+      ->orderBy("updated_at", "desc")
+      ->limit($data['page_size'])
+      ->offset(($data['page'] - 1) * $data['page_size'])
+      ->get();
+    if (empty($result)) {
+      return Result::error("查询失败", 0);
+    }
+    $count = JobHunting::where($where)
+      ->leftJoin('user', 'user.id', '=', 'job_hunting.user_id')
+      ->leftJoin('website', 'website.id', '=', 'job_hunting.website_id')
+      ->count();
+    $data = [
+      'rows' => $result->toArray(),
+      'count' => $count,
+    ];
+    return Result::success($data);
+  }
+  public function getJobHuntingApply(array $data): array
+  {
+    var_dump($data, '-----------------test--------1-');
+    $where = [];
+    if (isset($data['username']) && !empty($data['username'])) {
+      $where[] = ['user.user_name', 'like', '%' . $data['username'] . '%'];
+    }
+    if (isset($data['salary']) && !empty($data['salary'])) {
+      $where[] = [
+        'job_hunting.salary',
+        '=',
+        $data['salary'],
+      ];
+    }
+    $type_id = isset($data['type_id']) ? $data['type_id'] : '';
+    $user_id = isset($data['user_id']) ? $data['user_id'] : '';
+    unset($data['type_id']);
+    if ($type_id != '10000') {
+      $where[] = ['job_apply.user_id', '=', $user_id];
     }
-    public function deleteNotice(array $data): array
-    {
-        $notice = Notice::where('id', $data['id'])->first();
-        if (empty($notice)) {
-            return Result::error("删除失败", 0);
-        }
-        $chat_group_id = $notice->group_id;
-        if ($chat_group_id) {
-            //删除群聊
-            ChatGroups::where('id', $chat_group_id)->delete();
-            //删除群成员
-            ChatGroupsMember::where('group_id', $chat_group_id)->delete();
-            //删除群聊记录
-            ChatRecords::where('receiver_id', $chat_group_id)->delete();
-        }
-        $result = Notice::where('id', $data['id'])->delete();
-        return Result::success($result);
-    }
-    public function getMSG(array $data): array
-    {
-        $type_id = isset($data['type_id']) ? $data['type_id'] : 1;
-        // '1:个人会员 2:政务会员 3:企业会员 4:调研员 10000:管理员 20000:游客(小程序)
-        $user_id = isset($data['user_id']) ? $data['user_id'] : 0; //用户id
-        $result = [];
-        if ($type_id == 1) {
-            //最近的5篇已审的文章
-            $apply_articale = Article::where('status', 1)
-                ->where('admin_user_id', $user_id)
-                ->orderBy('updated_at', 'desc')
-                ->limit(5)->get();
-            //获取5条单聊未读聊天消息
-            $chat = ChatRecords::where('is_read', 0)
-                ->where('user_id', $user_id)
-                ->where('talk_type', 1)
-                ->orderBy('created_at', 'desc')
-                ->limit(5)->get();
-            //获取5条未读群聊信息
-            $chat_group = ChatRecords::where('is_read', 0)
-                ->where('user_id', $user_id)
-                ->where('talk_type', 2)
-                ->orderBy('created_at', 'desc')
-                ->limit(5)->get();
-            //获取5条用户的已审核商品
-            $good = Good::where('status', 2)
-                ->where('user_id', $user_id)
-                ->orderBy('updated_at', 'desc')
-                ->limit(5)->get();
-            //获取5条用户待审核的公告
-            $notice = Notice::where('status', 2)
-                ->where('user_id', $user_id)
-                ->orderBy('updated_at', 'desc')
-                ->limit(5)->get();
-            //获取5条用户的待审核投诉
-            $complaint = Complaint::where('status', 2)
-                ->where('user_id', $user_id)
-                ->orderBy('updated_at', 'desc')
-                ->limit(5)->get();
-            //获取5条用户的book
-            $book = Book::where('status', 2)
-                ->where('user_id', $user_id)
-                ->orderBy('updated_at', 'desc')
-                ->limit(5)->get();
-            //获取5条用户的求职
-            //获取5条用户的求职 1
-            $job_hunting = JobHunting::where('job_hunting.status', 1)
-                ->where('job_hunting.user_id', $user_id)
-                ->leftJoin('user', 'job_hunting.user_id', '=', 'user.id')
-                ->leftJoin('website', 'job_hunting.website_id', '=', 'website.id')
-                ->select('job_hunting.*', 'user.nickname as nickname', 'user.user_name as user_name', 'website.website_name as website_name')
-                ->orderBy('updated_at', 'desc')
-                ->limit(5)->get();
-            //获取5条用户的求职 2
-            $job_recruiting = JobRecruiting::where('job_recruiting.status', 1)
-                ->where('job_recruiting.user_id', $user_id)
-                ->leftJoin('user', 'job_recruiting.user_id', '=', 'user.id')
-                ->leftJoin('website', 'job_recruiting.website_id', '=', 'website.id')
-                ->select('job_recruiting.*', 'user.nickname as nickname', 'user.user_name as user_name', 'website.website_name as website_name')
-                ->orderBy('updated_at', 'desc')
-                ->limit(5)->get();
-            //人才库  1
-            $job_apply = JobApply::where('job_apply.status', 1)
-                ->where('job_apply.receiver_id', $user_id)
-                ->leftJoin('user', 'job_apply.user_id', '=', 'user.id')
-                ->leftJoin('website', 'job_apply.website_id', '=', 'website.id')
-                ->leftJoin('job_company', 'job_company.job_id', '=', 'job_apply.recruit_id')
-                ->leftJoin('job_recruiting', 'job_recruiting.id', '=', 'job_apply.recruit_id')
-                ->select('job_recruiting', 'job_recruiting.', '', '')
-                ->select('job_apply.*', 'user.nickname as nickname', 'user.user_name as user_name', 'website.website_name as website_name', 'job_company.business_name as business_name', 'job_recruiting.title as job_name')
-                ->orderBy('updated_at', 'desc')
-                ->limit(5)->get();
-            // 职场机会 2
-            $job_resume = JobResume::where('job_resume.status', 1)
-                ->where('job_resume.receiver_id', $user_id)
-                ->leftJoin('user', 'job_resume.receiver_id', '=', 'user.id')
-                ->leftJoin('website', 'job_resume.website_id', '=', 'website.id')
-                ->leftJoin('job_company', 'job_company.job_id', '=', 'job_resume.recruit_id')
-                ->select('job_resume.*', 'user.nickname as nickname', 'user.user_name as user_name', 'website.website_name as website_name', 'job_company.business_name as business_name')
-                ->orderBy('updated_at', 'desc')
-                ->limit(5)->get();
-
-            $count = count($chat) + count($chat_group) + count($apply_articale) + count($good) + count($notice) + count($complaint) + count($book) + count($job_hunting) + count($job_recruiting) + count($job_apply) + count($job_resume);
-            $result = [
-                'apply_articale' => $apply_articale,
-                'chat' => $chat,
-                'chat_group' => $chat_group,
-                'good' => $good,
-                'notice' => $notice,
-                'complaint' => $complaint,
-                'book' => $book,
-                'job_hunting' => $job_hunting,
-                'job_recruiting' => $job_recruiting,
-                'job_apply' => $job_apply,
-                'job_resume' => $job_resume,
-                'count' => $count,
-            ];
-        } elseif ($type_id == 2) {
-            //最近的5篇已审的文章
-            $apply_articale = Article::where('status', 1)
-                ->where('admin_user_id', $user_id)
-                ->limit(5)->get();
-            //获取5条单聊未读聊天消息
-            $chat = ChatRecords::where('is_read', 0)
-                ->where('user_id', $user_id)
-                ->where('talk_type', 1)
-                ->orderBy('created_at', 'desc')
-                ->limit(5)->get();
-            //获取5条未读群聊信息
-            $chat_group = ChatRecords::where('is_read', 0)
-                ->where('user_id', $user_id)
-                ->where('talk_type', 2)
-                ->orderBy('created_at', 'desc')
-                ->limit(5)->get();
-            //获取5条用户的已审核商品
-            $good = Good::where('status', 2)
-                ->where('user_id', $user_id)
-                ->orderBy('updated_at', 'desc')
-                ->limit(5)->get();
-            $count = count($chat) + count($chat_group) + count($apply_articale) + count($good);
-            $result = [
-                'apply_articale' => $apply_articale,
-                'chat' => $chat,
-                'chat_group' => $chat_group,
-                'good' => $good,
-                'count' => $count,
-            ];
-        } elseif ($type_id == 3) {
-            //最近的5篇已审的文章
-            $apply_articale = Article::where('status', 1)
-                ->where('admin_user_id', $user_id)
-                ->limit(5)->get();
-            //获取5条单聊未读聊天消息
-            $chat = ChatRecords::where('is_read', 0)
-                ->where('user_id', $user_id)
-                ->where('talk_type', 1)
-                ->orderBy('created_at', 'desc')
-                ->limit(5)->get();
-            //获取5条未读群聊信息
-            $chat_group = ChatRecords::where('is_read', 0)
-                ->where('user_id', $user_id)
-                ->where('talk_type', 2)
-                ->orderBy('created_at', 'desc')
-                ->limit(5)->get();
-            //获取5条用户的已审核商品
-            $good = Good::where('status', 2)
-                ->where('user_id', $user_id)
-                ->orderBy('updated_at', 'desc')
-                ->limit(5)->get();
-            $count = count($chat) + count($chat_group) + count($apply_articale) + count($good);
-            $result = [
-                'apply_articale' => $apply_articale,
-                'chat' => $chat,
-                'chat_group' => $chat_group,
-                'good' => $good,
-                'count' => $count,
-            ];
-        } elseif ($type_id == 4) {
-            //最近的5篇已审的文章
-            $apply_articale = Article::where('status', 1)
-                ->where('admin_user_id', $user_id)
-                ->limit(5)->get();
-
-            //获取5条用户的已审核商品
-            $good = Good::where('status', 2)
-                ->where('user_id', $user_id)
-                ->orderBy('updated_at', 'desc')
-                ->limit(5)->get();
-            $count =  count($apply_articale) + count($good);
-            $result = [
-                'apply_articale' => $apply_articale,
-                'chat' => '',
-                'chat_group' => '',
-                'good' => $good,
-                'count' => $count,
-            ];
-        } elseif ($type_id == 10000) {
-            //获取未审核的5篇文章
-            $apply_articale = Article::where('status', 0)
-                ->orderBy('updated_at', 'desc')
-                ->limit(5)->get();
-            //获取5条单聊未读聊天消息
-            $chat = ChatRecords::where('is_read', 0)
-                ->where('user_id', $user_id)
-                ->where('talk_type', 1)
-                ->orderBy('created_at', 'desc')
-                ->limit(5)->get();
-            //获取5条未读群聊信息
-            $chat_group = ChatRecords::where('is_read', 0)
-                ->where('user_id', $user_id)
-                ->where('talk_type', 2)
-                ->orderBy('created_at', 'desc')
-                ->limit(5)->get();
-            //获取5条用户的已审核商品
-            $good = Good::where('status', 1)
-                // ->where('user_id', $user_id)
-                ->orderBy('updated_at', 'desc')
-                ->limit(5)->get();
-            //获取5条用户待审核的公告
-            $notice = Notice::where('status', 1)
-                ->orderBy('updated_at', 'desc')
-                ->limit(5)->get();
-            //获取5条用户的待审核投诉
-            $complaint = Complaint::where('status', 1)
-                ->orderBy('updated_at', 'desc')
-                ->limit(5)->get();
-            //获取5条用户的book
-            $book = Book::where('status', 1)
-                ->orderBy('updated_at', 'desc')
-                ->limit(5)->get();
-            //获取5条用户的求职 1
-            $job_hunting = JobHunting::where('job_hunting.status', 1)
-                ->leftJoin('user', 'job_hunting.user_id', '=', 'user.id')
-                ->leftJoin('website', 'job_hunting.website_id', '=', 'website.id')
-                ->select('job_hunting.*', 'user.nickname as nickname', 'user.user_name as user_name', 'website.website_name as website_name')
-                ->orderBy('updated_at', 'desc')
-                ->limit(5)->get();
-            //获取5条用户的求职 2
-            $job_recruiting = JobRecruiting::where('job_recruiting.status', 1)
-                ->leftJoin('user', 'job_recruiting.user_id', '=', 'user.id')
-                ->leftJoin('website', 'job_recruiting.website_id', '=', 'website.id')
-                ->select('job_recruiting.*', 'user.nickname as nickname', 'user.user_name as user_name', 'website.website_name as website_name')
-                ->orderBy('updated_at', 'desc')
-                ->limit(5)->get();
-            //人才库  1
-            $job_apply = JobApply::where('job_apply.status', 1)
-                ->leftJoin('user', 'job_apply.user_id', '=', 'user.id')
-                ->leftJoin('website', 'job_apply.website_id', '=', 'website.id')
-                ->leftJoin('job_company', 'job_company.job_id', '=', 'job_apply.recruit_id')
-                ->leftJoin('job_recruiting', 'job_recruiting.id', '=', 'job_apply.recruit_id')
-                ->select('job_apply.*', 'user.nickname as nickname', 'user.user_name as user_name', 'website.website_name as website_name', 'job_company.business_name as business_name', 'job_recruiting.title as job_name')
-                ->orderBy('updated_at', 'desc')
-                ->limit(5)->get();
-            // 职场机会 2
-            $job_resume = JobResume::where('job_resume.status', 1)
-                ->leftJoin('user', 'job_resume.receiver_id', '=', 'user.id')
-                ->leftJoin('website', 'job_resume.website_id', '=', 'website.id')
-                ->leftJoin('job_company', 'job_company.job_id', '=', 'job_resume.recruit_id')
-                ->select('job_resume.*', 'user.nickname as nickname', 'user.user_name as user_name', 'website.website_name as website_name', 'job_company.business_name as business_name')
-                ->orderBy('updated_at', 'desc')
-                ->limit(5)->get();
-
-            $count = count($chat) + count($chat_group) + count($apply_articale) + count($good) + count($notice) + count($complaint) + count($book) + count($job_hunting) + count($job_recruiting) + count($job_apply) + count($job_resume);
-            $result = [
-                'apply_articale' => $apply_articale,
-                'chat' => $chat,
-                'chat_group' => $chat_group,
-                'good' => $good,
-                'notice' => $notice,
-                'complaint' => $complaint,
-                'book' => $book,
-                'job_hunting' => $job_hunting,
-                'job_recruiting' => $job_recruiting,
-                'job_apply' => $job_apply,
-                'job_resume' => $job_resume,
-                'count' => $count,
-            ];
-        } elseif ($type_id == 20000) {
-        }
-        var_dump($type_id, '-----------------test---------');
-        return Result::success($result);
-    }
-    public function getComplaintList(array $data): array
-    {
-        var_dump($data, '00000001000000000000');
-        $type_id = isset($data['type_id']) ? $data['type_id'] : '';
-        unset($data['type_id']);
-        $user_id = isset($data['user_id']) ? $data['user_id'] : '';
-        $where = [];
-        if ($type_id != 10000 && empty($data['deal_user'])) {
-            $where['complaint.user_id'] = $user_id;
-        }
-        if (!empty($data['title'])) {
-            $where[] = ['complaint.title', 'like', '%' . $data['title'] . '%'];
-        }
-        if (!empty($data['department_id'])) {
-            $where['complaint.department_id'] =   $data['department_id'];
-        }
-        if (!empty($data['deal'])) {
-            $where['complaint.deal'] =   $data['deal'];
-        }
-        if (!empty($data['status'])) {
-            $where['complaint.status'] =  $data['status'];
-        }
-        var_dump(!empty($data['deal_user']), '----------1');
-        var_dump($where, '----------2');
-        $result = Complaint::where($where)
-            ->when(!empty($data['status1']), function ($query) use ($data) {
-                $query->whereIn('complaint.status', [1, 3]);   //1待审核2已审核3已拒绝
-            })
-            ->when(!empty($data['deal_user'])  &&  $type_id != 10000, function ($query) use ($data) {
-                //json  re_user_ids   data[user_id]是不是在里面 
-                $query->Where(function ($q) use ($data) {
-                    $q->whereRaw('JSON_CONTAINS(complaint.re_user_ids, \'' . $data['user_id'] . '\')')
-                        ->where('complaint.status', 2);
-                });
-            })
-            ->leftJoin('department', 'complaint.department_id', '=', 'department.id')
-            // ->leftJoin('user', 'complaint.user_id', '=', 'user.id')
-            ->leftJoin('district', 'district.id', '=', 'complaint.city_id')
-            ->select('complaint.*', 'department.name as department_name', 'district.name as cityname')
-            ->orderBy('updated_at', 'desc')
-            ->paginate($data['page_size'], ['*'], 'page', $data['page']);
-        //sql输出
-
-        if (empty($result)) {
-            return Result::error("暂无投诉信息", 0);
-        }
-        // 取出数据
-        $rows = $result->items();
-        $count = $result->total();
 
-        $responseData = [
-            'rows' => $rows,
-            'count' => $count,
+    var_dump($where, '-----------------test---------');
+    $result = jobApply::where($where)
+      // ->when(!empty($data['status1']), function ($query) use ($data) {
+      //     return $query->whereIn('job_hunting.status', [1, 3]);   //1待审核2已审核3已拒绝
+      // })
+      // ->leftJoin('user', 'user.id', '=', 'job_hunting.user_id') 'user.nickname as nickname',  , 'user.user_name as username'
+      ->where('job_enum.egroup', '=', 'income')
+      ->where('job_hunting.status', 2) //已审核
+      ->leftJoin('job_hunting', 'job_hunting.id', '=', 'job_apply.hunt_id')
+      ->leftJoin('district', 'district.id', '=', 'job_hunting.city_id')
+      ->leftJoin('job_enum', 'job_enum.evalue', '=', 'job_hunting.salary')
+      ->leftJoin('user', 'job_hunting.user_id', '=', 'user.id')
+      //职位----是申请职位
+      ->leftJoin('job_position', 'job_hunting.job_name_get', '=', 'job_position.zwid')
+      ->select('job_apply.*', 'job_position.zwname as job_name', 'job_hunting.salary as salary', 'district.name as cityname', 'job_enum.ename as salary_name', 'user.nickname as nickname', 'user.user_name as username', 'job_hunting.updated_at as updated_at')
+      ->orderBy("job_hunting.updated_at", "desc")
+      ->limit($data['page_size'])
+      ->offset(($data['page'] - 1) * $data['page_size'])
+      ->get();
+    if (empty($result)) {
+      return Result::error("查询失败", 0);
+    }
+    $count = jobApply::where($where)
+      ->where('job_enum.egroup', '=', 'income')
+      ->where('job_hunting.status', 2) //已审核
+      ->leftJoin('job_hunting', 'job_hunting.id', '=', 'job_apply.hunt_id')
+      ->leftJoin('district', 'district.id', '=', 'job_hunting.city_id')
+      ->leftJoin('job_enum', 'job_enum.evalue', '=', 'job_hunting.salary')
+      ->leftJoin('user', 'job_hunting.user_id', '=', 'user.id')
+      //职位----是申请职位
+      ->leftJoin('job_position', 'job_hunting.job_name_get', '=', 'job_position.zwid')
+      ->select('job_apply.*', 'job_position.zwname as job_name', 'job_hunting.salary as salary', 'district.name as cityname', 'job_enum.ename as salary_name', 'user.nickname as nickname', 'user.user_name as username', 'job_hunting.updated_at as updated_at')
+      ->count();
+    $data = [
+      'rows' => $result->toArray(),
+      'count' => $count,
+    ];
+    return Result::success($data);
+  }
+  public function addJobHunting(array $data): array
+  {
+    date_default_timezone_set('Asia/Shanghai');
+    unset($data['company_name']);
+    unset($data['job_industry']);
+    unset($data['job_name']);
+    unset($data['department']);
+    unset($data['job_timeList']);
+    unset($data['job_content']);
+    unset($data['job_typename']); //不知道这是啥,
+    $data['created_at'] = date('Y-m-d H:i:s');
+    $data['updated_at'] = date('Y-m-d H:i:s');
+    //根据用户 user_id 只能添加一次
+    $result = JobHunting::where('user_id', $data['user_id'])->first();
+    if (!empty($result)) {
+      return Result::error("您已添加过求职信息", 0);
+    }
+    var_dump($result, '-----------------test---------');
+    $result = JobHunting::create($data);
+    if (empty($result)) {
+      return Result::error("添加失败", 0);
+    }
+    return Result::success($result);
+  }
+  public function delJobHunting(array $data): array
+  {
+    $result = JobHunting::where('id', $data['id'])->delete();
+    if (empty($result)) {
+      return Result::error("删除失败", 0);
+    }
+    return Result::success($result);
+  }
+  public function updateJobHunting(array $data): array
+  {
+    //设置东八区
+    date_default_timezone_set('Asia/Shanghai');
+    unset($data['company_name']);
+    unset($data['job_industry']);
+    unset($data['job_name']);
+    unset($data['department']);
+    unset($data['job_timeList']);
+    unset($data['job_content']);
+    unset($data['job_typename']); //不知道这是啥,
+    $data['created_at'] = date('Y-m-d H:i:s');
+    $data['updated_at'] = date('Y-m-d H:i:s');
+    $result = JobHunting::where('id', $data['id'])->update($data);
+    if (empty($result)) {
+      return Result::error("更新失败", 0);
+    }
+    return Result::success($result);
+  }
+  public function getJobHuntingInfo(array $data): array
+  {
+    $result = JobHunting::where('id', $data['id'])->first();
+    if (empty($result)) {
+      return Result::error("查询失败", 0);
+    }
+    return Result::success($result);
+  }
+  public function getJobHuntingData(array $data): array
+  {
+    $jobEnum = JobEnum::get();
+    $jobIndustry = JobIndustry::get();
+    $jobNature = JobNature::get();
+    $jobPosition = JobPosition::get();
+    $data = [
+      'jobEnum' => $jobEnum,
+      'jobIndustry' => $jobIndustry,
+      'jobNature' => $jobNature,
+      'jobPosition' => $jobPosition,
+    ];
+    return Result::success($data);
+  }
+  public function delJobHuntingInfo(array $data): array
+  {
+    $result = JobHunting::where('id', $data['id'])->delete();
+    return Result::success();
+  }
+  //20250324  通知,公告,消息
+  public function delNotice(array $data): array
+  {
+    $result = Notice::where('id', $data['id'])->delete();
+    if ($result) {
+      return Result::success();
+    } else {
+      return Result::error("删除失败", 0);
+    }
+  }
+  public function getNoticeInfo(array $data): array
+  {
+    $result = Notice::where('id', $data['id'])->first();
+    if (empty($result)) {
+      return Result::error("查询失败", 0);
+    }
+    return Result::success($result);
+  }
+  public function addNotice(array $data): array
+  {
+    date_default_timezone_set('Asia/Shanghai');
+    $data['created_at'] = date('Y-m-d H:i:s');
+    $data['updated_at'] = date('Y-m-d H:i:s');
+    $user_id = UserInfo::
+      //city_id不是null
+      whereNotNull('city_id')
+      ->whereNotNull('department_id')
+      ->where(function ($query) use ($data) {
+        $query->where(function ($subQuery) use ($data) {
+          $subQuery->whereRaw("JSON_VALID(city_arr_id) AND JSON_CONTAINS(city_arr_id, '" . intval($data['city_id']) . "') = 1");
+        });
+      })
+      ->where(function ($query) use ($data) {
+        $query->where(function ($subQuery) use ($data) {
+          $subQuery->whereRaw("JSON_VALID(department_arr_id) AND JSON_CONTAINS(department_arr_id, '" . intval($data['department_id']) . "') = 1");
+        });
+      })
+      ->pluck('user_id')->toArray();
+    $user_id = array_unique($user_id);
+    $chat_ids = $user_id;
+    $user_id = json_encode($user_id);
+    $data['re_user_ids'] = $user_id;
+    $result = Notice::insertGetId($data);
+    if ($result && $data['is_group'] == 1) {
+      //chat_group
+      $group_id = PublicData::uuid();
+      $groupData = [
+        'id' => $group_id,
+        'creator_id' => $data['user_id'],
+        'group_name' => $data['group_name'] ?? '',
+        'profile' => $data['profile'] ?? 0,
+      ];
+      var_dump($groupData, '-----------------groupData-------');
+
+      $groupResult = ChatGroups::insertGetId($groupData);
+      var_dump($groupResult, '-----------------groupid-------');
+      $groupMemberData = [
+        'id' => PublicData::uuid(),
+        'user_id' => $data['user_id'],
+        'group_id' => $group_id,
+        'leader' => 2,
+      ];
+      $groupMemberResult = ChatGroupsMember::insertGetId($groupMemberData);
+
+      //$chat_ids 去除掉$data['user_id']
+      $chat_ids = array_diff($chat_ids, [$data['user_id']]);
+      //插入群成员表
+      $groupMemberDataUser = [];
+      $chatData = [];
+      foreach ($chat_ids as $key => $value) {
+        $groupMemberDataUser[] = [
+          'id' => PublicData::uuid(),
+          'user_id' => $value,
+          'group_id' => $group_id,
+          'leader' => 1,
         ];
-        return Result::success($responseData);
+        $chatData[] = [
+          'user_id' => $value,
+          'msg_type' => 1,
+          'receiver_id' => $group_id,
+          'content' => '通过通知创建群聊',
+          'group_receiver_id' => $data['user_id'],
+          'action' => 'recieved',
+          'created_at' => date('Y-m-d H:i:s'),
+        ];
+      }
+      var_dump($groupMemberDataUser, '-----------------groupMemberDataUser-------');
+      ChatGroupsMember::insert($groupMemberDataUser);
+      //插入一条管理员聊天记录
+      $chatData[] = [
+        'user_id' => $data['user_id'],
+        'msg_type' => 1,
+        'receiver_id' => $group_id,
+        'content' => '通过通知创建群聊',
+        'group_receiver_id' => $data['user_id'],
+        'action' => 'said',
+        'created_at' => date('Y-m-d H:i:s'),
+      ];
+      var_dump($chatData, '-----------------chatData-------');
+      $chatResult = ChatRecords::insert($chatData);
+
+      //更新result的 group_id
+      $data['group_id'] = $group_id;
+      Notice::where(['id' => $result])->update($data);
     }
-    public function getComplaintInfo(array $data): array
-    {
-        $result = Complaint::where('id', $data['id'])->first();
-        if (empty($result)) {
-            return Result::error("查询失败", 0);
-        }
-        return Result::success($result);
-    }
-    public function addComplaint(array $data): array
-    {
-        date_default_timezone_set('Asia/Shanghai');
-        $data['created_at'] = date('Y-m-d H:i:s');
-        $data['updated_at'] = date('Y-m-d H:i:s');
-        $result = Complaint::create($data);
-        return Result::success($result);
-    }
-    public function updateComplaint(array $data): array
-    {
-
-        date_default_timezone_set('Asia/Shanghai');
-        $data['updated_at'] = date('Y-m-d H:i:s');
-        $user_id = $data['user_id'] ?? 0;
-        $type_id = $data['type_id'] ?? 0;
-        unset($data['user_id']);
-        unset($data['type_id']);
-        $result = Complaint::where('id', $data['id'])->update($data);
-        return Result::success($result);
-    }
-    public function deleteComplaint(array $data): array
-    {
-        $result = Complaint::where('id', $data['id'])->delete();
-        return Result::success($result);
-    }
-    public function getComplainInfo(array $data): array
-    {
-        $result = Complaint::where('id', $data['id'])->first();
-        if (empty($result)) {
-            return Result::error("查询失败", 0);
-        }
-        return Result::success($result);
-    }
-    public function updateComplaintStatus(array $data): array
-    {
-        date_default_timezone_set('Asia/Shanghai');
-        $data['updated_at'] = date('Y-m-d H:i:s');
-        $user_id = $data['user_id'] ?? 0;
-        $type_id = $data['type_id'] ?? 0;
-
-        unset($data['user_id']);
-        unset($data['type_id']);
-        //处理, 写入处理人
-        if (isset($data['deal']) && ($data['deal'] == 2 || $data['deal'] == 4)) {
-            $data['real_deal_user'] = $user_id;
-        }
-        //如果是deal 23,则判断是不是处理人
-        if (isset($data['deal']) && ($data['deal'] == 3) && $type_id != 10000) {
-            $complaintInof = Complaint::where('id', $data['id'])
-                ->where('real_deal_user', $user_id)
-                ->first();
-            if (empty($complaintInof)) {
-                return Result::error("处理人错误", 0);
-            }
-        }
 
-        $result = complaint::where('id', $data['id'])->update($data);
-        return Result::success($result);
-    }
-    public function updateGoodStatus(array $data): array
-    {
-        $user_id = $data['user_id'] ?? 0;
-        $type_id = $data['type_id'] ?? 0;
-        unset($data['user_id']);
-        unset($data['type_id']);
-
-        $result = Good::where('id', $data['id'])->update($data);
-        return Result::success($result);
-    }
-    public function updateJobHuntingStatus(array $data): array
-    {
-        $user_id = $data['user_id'] ?? 0;
-        $type_id = $data['type_id'] ?? 0;
-        unset($data['user_id']);
-        unset($data['type_id']);
-        $result = JobHunting::where('id', $data['id'])->update($data);
-        return Result::success($result);
-    }
-    public function updateNoticeStatus(array $data): array
-    {
-        $user_id = $data['user_id'] ?? 0;
-        $type_id = $data['type_id'] ?? 0;
-        unset($data['user_id']);
-        unset($data['type_id']);
-        $result = Notice::where('id', $data['id'])->update($data);
-        return Result::success($result);
-    }
-    public function getDUser(array $data): array
-    {
-        if (!empty($data['ids'])) {
-            $user = User::whereIn('id', $data['ids'])->getall();
-            if (empty($user)) {
-                return Result::error('无数据', 0);
-            }
-            return Result::success($user);
-        }
-        $where = [];
-        if (!empty($data['department_id'])) {
-            $where['department_id'] = $data['department_id'];
-        }
-        if (!empty($data['city_id'])) {
-            $where['city_id'] = $data['city_id'];
-        }
-        $result = User::where('type_id', 2)
-            ->where('status', 1)
-            ->where($where)
-            ->leftJoin('user_info', 'user.id', '=', 'user_info.user_id')
-            ->get();
-        if (empty($result)) {
-            return Result::error("查询失败", 0);
-        }
-        return Result::success($result);
+    if (empty($result)) {
+      return Result::error("添加失败", 0);
+    }
+    return Result::success($result);
+  }
+  public function updateNotice(array $data): array
+  {
+    date_default_timezone_set('Asia/Shanghai');
+    //根据city_id  和department_id  查询出对应的user_id,放到 re_user_ids
+    $user_id = UserInfo::
+      //city_id不是null
+      whereNotNull('city_id')
+      ->whereNotNull('department_id')
+      ->where(function ($query) use ($data) {
+        $query->where(function ($subQuery) use ($data) {
+          $subQuery->whereRaw("JSON_VALID(city_arr_id) AND JSON_CONTAINS(city_arr_id, '" . intval($data['city_id']) . "') = 1");
+        });
+      })
+      ->where(function ($query) use ($data) {
+        $query->where(function ($subQuery) use ($data) {
+          $subQuery->whereRaw("JSON_VALID(department_arr_id) AND JSON_CONTAINS(department_arr_id, '" . intval($data['department_id']) . "') = 1");
+        });
+      })
+      ->pluck('user_id')->toArray();
+    $user_id = array_unique($user_id);
+    $user_id = json_encode($user_id);
+    $data['re_user_ids'] = $user_id;
+    $data['updated_at'] = date('Y-m-d H:i:s');
+    $result = Notice::where('id', $data['id'])->update($data);
+    return Result::success($result);
+  }
+  public function getNoticeList(array $data): array
+  {
+    $where = [];
+    //title
+    if (isset($data['title']) && !empty($data['title'])) {
+      $where[] = ['notice.title', 'like', '%' . $data['title'] . '%'];
+    }
+    //level
+    if (isset($data['level']) && !empty($data['level'])) {
+      $where[] = ['notice.level', '=', $data['level']];
+    }
+    //status
+    if (isset($data['status']) && !empty($data['status'])) {
+      $where[] = ['notice.status', '=', $data['status']];
+    }
+    var_dump($data, '-----------------test---------');
+    if ($data['type_id'] == 10000) {
+      $result = Notice::when(!empty($data['status1']), function ($query) use ($data) {
+        return $query->whereIn('notice.status', [1, 3]);   //1待审核2已审核3已拒绝
+      })
+        ->where($where)
+        ->orderBy('updated_at', 'desc')
+        ->limit($data['page_size'])
+        ->offset(($data['page'] - 1) * $data['page_size'])
+        ->get();
+      $total = Notice::when(!empty($data['status1']), function ($query) use ($data) {
+        return $query->whereIn('notice.status', [1, 3]);   //1待审核2已审核3已拒绝
+      })
+        ->where($where)
+        ->orderBy('updated_at', 'desc')
+        ->count();
+    } else {
+      $result = Notice::where($where)
+        // ->where('user_id', $data['user_id'])
+        ->Where(function ($query) use ($data) {
+          $query->Where(function ($q) use ($data) {
+            $q->whereRaw('JSON_CONTAINS(notice.re_user_ids, \'' . $data['user_id'] . '\')')
+              ->orWhere('notice.user_id', $data['user_id']);
+          });
+        })
+        ->orderBy('updated_at', 'desc')
+        ->limit($data['page_size'])
+        ->offset(($data['page'] - 1) * $data['page_size'])
+        ->get();
+      $total = Notice::where($where)
+        // ->where('user_id', $data['user_id'])
+        ->Where(function ($query) use ($data) {
+          $query->Where(function ($q) use ($data) {
+            $q->whereRaw('JSON_CONTAINS(notice.re_user_ids, \'' . $data['user_id'] . '\')')
+              ->orWhere('notice.user_id', $data['user_id']);
+          });
+        })
+        ->count();
+    }
+    if (empty($result)) {
+      return Result::error("查询失败", 0);
+    }
+    $data = [
+      'rows' => $result,
+      'count' => $total,
+    ];
+    return Result::success($data);
+  }
+  public function getNoticeDetail(array $data): array
+  {
+    $result = Notice::where('id', $data['id'])->first();
+    if (empty($result)) {
+      return Result::error("查询失败", 0);
+    }
+    return Result::success($result);
+  }
+  public function deleteNotice(array $data): array
+  {
+    $notice = Notice::where('id', $data['id'])->first();
+    if (empty($notice)) {
+      return Result::error("删除失败", 0);
+    }
+    $chat_group_id = $notice->group_id;
+    if ($chat_group_id) {
+      //删除群聊
+      ChatGroups::where('id', $chat_group_id)->delete();
+      //删除群成员
+      ChatGroupsMember::where('group_id', $chat_group_id)->delete();
+      //删除群聊记录
+      ChatRecords::where('receiver_id', $chat_group_id)->delete();
+    }
+    $result = Notice::where('id', $data['id'])->delete();
+    return Result::success($result);
+  }
+  public function getMSG(array $data): array
+  {
+    $type_id = isset($data['type_id']) ? $data['type_id'] : 1;
+    // '1:个人会员 2:政务会员 3:企业会员 4:调研员 10000:管理员 20000:游客(小程序)
+    $user_id = isset($data['user_id']) ? $data['user_id'] : 0; //用户id
+    $result = [];
+    if ($type_id == 1) {
+      //最近的5篇已审的文章
+      $apply_articale = Article::where('status', 1)
+        ->where('admin_user_id', $user_id)
+        ->orderBy('updated_at', 'desc')
+        ->limit(5)->get();
+      //获取5条单聊未读聊天消息
+      $chat = ChatRecords::where('is_read', 0)
+        ->where('user_id', $user_id)
+        ->where('talk_type', 1)
+        ->orderBy('created_at', 'desc')
+        ->limit(5)->get();
+      //获取5条未读群聊信息
+      $chat_group = ChatRecords::where('is_read', 0)
+        ->where('user_id', $user_id)
+        ->where('talk_type', 2)
+        ->orderBy('created_at', 'desc')
+        ->limit(5)->get();
+      //获取5条用户的已审核商品
+      $good = Good::where('status', 2)
+        ->where('user_id', $user_id)
+        ->orderBy('updated_at', 'desc')
+        ->limit(5)->get();
+      //获取5条用户待审核的公告
+      $notice = Notice::where('status', 2)
+        ->where('user_id', $user_id)
+        ->orderBy('updated_at', 'desc')
+        ->limit(5)->get();
+      //获取5条用户的待审核投诉
+      $complaint = Complaint::where('status', 2)
+        ->where('user_id', $user_id)
+        ->orderBy('updated_at', 'desc')
+        ->limit(5)->get();
+      //获取5条用户的book
+      $book = Book::where('status', 2)
+        ->where('user_id', $user_id)
+        ->orderBy('updated_at', 'desc')
+        ->limit(5)->get();
+      //获取5条用户的求职
+      //获取5条用户的求职 1
+      $job_hunting = JobHunting::where('job_hunting.status', 1)
+        ->where('job_hunting.user_id', $user_id)
+        ->leftJoin('user', 'job_hunting.user_id', '=', 'user.id')
+        ->leftJoin('website', 'job_hunting.website_id', '=', 'website.id')
+        ->select('job_hunting.*', 'user.nickname as nickname', 'user.user_name as user_name', 'website.website_name as website_name')
+        ->orderBy('updated_at', 'desc')
+        ->limit(5)->get();
+      //获取5条用户的求职 2
+      $job_recruiting = JobRecruiting::where('job_recruiting.status', 1)
+        ->where('job_recruiting.user_id', $user_id)
+        ->leftJoin('user', 'job_recruiting.user_id', '=', 'user.id')
+        ->leftJoin('website', 'job_recruiting.website_id', '=', 'website.id')
+        ->select('job_recruiting.*', 'user.nickname as nickname', 'user.user_name as user_name', 'website.website_name as website_name')
+        ->orderBy('updated_at', 'desc')
+        ->limit(5)->get();
+      //人才库  1
+      $job_apply = JobApply::where('job_apply.status', 1)
+        ->where('job_apply.receiver_id', $user_id)
+        ->leftJoin('user', 'job_apply.user_id', '=', 'user.id')
+        ->leftJoin('website', 'job_apply.website_id', '=', 'website.id')
+        ->leftJoin('job_company', 'job_company.job_id', '=', 'job_apply.recruit_id')
+        ->leftJoin('job_recruiting', 'job_recruiting.id', '=', 'job_apply.recruit_id')
+        ->select('job_recruiting', 'job_recruiting.', '', '')
+        ->select('job_apply.*', 'user.nickname as nickname', 'user.user_name as user_name', 'website.website_name as website_name', 'job_company.business_name as business_name', 'job_recruiting.title as job_name')
+        ->orderBy('updated_at', 'desc')
+        ->limit(5)->get();
+      // 职场机会 2
+      $job_resume = JobResume::where('job_resume.status', 1)
+        ->where('job_resume.receiver_id', $user_id)
+        ->leftJoin('user', 'job_resume.receiver_id', '=', 'user.id')
+        ->leftJoin('website', 'job_resume.website_id', '=', 'website.id')
+        ->leftJoin('job_company', 'job_company.job_id', '=', 'job_resume.recruit_id')
+        ->select('job_resume.*', 'user.nickname as nickname', 'user.user_name as user_name', 'website.website_name as website_name', 'job_company.business_name as business_name')
+        ->orderBy('updated_at', 'desc')
+        ->limit(5)->get();
+
+      $count = count($chat) + count($chat_group) + count($apply_articale) + count($good) + count($notice) + count($complaint) + count($book) + count($job_hunting) + count($job_recruiting) + count($job_apply) + count($job_resume);
+      $result = [
+        'apply_articale' => $apply_articale,
+        'chat' => $chat,
+        'chat_group' => $chat_group,
+        'good' => $good,
+        'notice' => $notice,
+        'complaint' => $complaint,
+        'book' => $book,
+        'job_hunting' => $job_hunting,
+        'job_recruiting' => $job_recruiting,
+        'job_apply' => $job_apply,
+        'job_resume' => $job_resume,
+        'count' => $count,
+      ];
+    } elseif ($type_id == 2) {
+      //最近的5篇已审的文章
+      $apply_articale = Article::where('status', 1)
+        ->where('admin_user_id', $user_id)
+        ->limit(5)->get();
+      //获取5条单聊未读聊天消息
+      $chat = ChatRecords::where('is_read', 0)
+        ->where('user_id', $user_id)
+        ->where('talk_type', 1)
+        ->orderBy('created_at', 'desc')
+        ->limit(5)->get();
+      //获取5条未读群聊信息
+      $chat_group = ChatRecords::where('is_read', 0)
+        ->where('user_id', $user_id)
+        ->where('talk_type', 2)
+        ->orderBy('created_at', 'desc')
+        ->limit(5)->get();
+      //获取5条用户的已审核商品
+      $good = Good::where('status', 2)
+        ->where('user_id', $user_id)
+        ->orderBy('updated_at', 'desc')
+        ->limit(5)->get();
+      $count = count($chat) + count($chat_group) + count($apply_articale) + count($good);
+      $result = [
+        'apply_articale' => $apply_articale,
+        'chat' => $chat,
+        'chat_group' => $chat_group,
+        'good' => $good,
+        'count' => $count,
+      ];
+    } elseif ($type_id == 3) {
+      //最近的5篇已审的文章
+      $apply_articale = Article::where('status', 1)
+        ->where('admin_user_id', $user_id)
+        ->limit(5)->get();
+      //获取5条单聊未读聊天消息
+      $chat = ChatRecords::where('is_read', 0)
+        ->where('user_id', $user_id)
+        ->where('talk_type', 1)
+        ->orderBy('created_at', 'desc')
+        ->limit(5)->get();
+      //获取5条未读群聊信息
+      $chat_group = ChatRecords::where('is_read', 0)
+        ->where('user_id', $user_id)
+        ->where('talk_type', 2)
+        ->orderBy('created_at', 'desc')
+        ->limit(5)->get();
+      //获取5条用户的已审核商品
+      $good = Good::where('status', 2)
+        ->where('user_id', $user_id)
+        ->orderBy('updated_at', 'desc')
+        ->limit(5)->get();
+      $count = count($chat) + count($chat_group) + count($apply_articale) + count($good);
+      $result = [
+        'apply_articale' => $apply_articale,
+        'chat' => $chat,
+        'chat_group' => $chat_group,
+        'good' => $good,
+        'count' => $count,
+      ];
+    } elseif ($type_id == 4) {
+      //最近的5篇已审的文章
+      $apply_articale = Article::where('status', 1)
+        ->where('admin_user_id', $user_id)
+        ->limit(5)->get();
+
+      //获取5条用户的已审核商品
+      $good = Good::where('status', 2)
+        ->where('user_id', $user_id)
+        ->orderBy('updated_at', 'desc')
+        ->limit(5)->get();
+      $count =  count($apply_articale) + count($good);
+      $result = [
+        'apply_articale' => $apply_articale,
+        'chat' => '',
+        'chat_group' => '',
+        'good' => $good,
+        'count' => $count,
+      ];
+    } elseif ($type_id == 10000) {
+      //获取未审核的5篇文章
+      $apply_articale = Article::where('status', 0)
+        ->orderBy('updated_at', 'desc')
+        ->limit(5)->get();
+      //获取5条单聊未读聊天消息
+      $chat = ChatRecords::where('is_read', 0)
+        ->where('user_id', $user_id)
+        ->where('talk_type', 1)
+        ->orderBy('created_at', 'desc')
+        ->limit(5)->get();
+      //获取5条未读群聊信息
+      $chat_group = ChatRecords::where('is_read', 0)
+        ->where('user_id', $user_id)
+        ->where('talk_type', 2)
+        ->orderBy('created_at', 'desc')
+        ->limit(5)->get();
+      //获取5条用户的已审核商品
+      $good = Good::where('status', 1)
+        // ->where('user_id', $user_id)
+        ->orderBy('updated_at', 'desc')
+        ->limit(5)->get();
+      //获取5条用户待审核的公告
+      $notice = Notice::where('status', 1)
+        ->orderBy('updated_at', 'desc')
+        ->limit(5)->get();
+      //获取5条用户的待审核投诉
+      $complaint = Complaint::where('status', 1)
+        ->orderBy('updated_at', 'desc')
+        ->limit(5)->get();
+      //获取5条用户的book
+      $book = Book::where('status', 1)
+        ->orderBy('updated_at', 'desc')
+        ->limit(5)->get();
+      //获取5条用户的求职 1
+      $job_hunting = JobHunting::where('job_hunting.status', 1)
+        ->leftJoin('user', 'job_hunting.user_id', '=', 'user.id')
+        ->leftJoin('website', 'job_hunting.website_id', '=', 'website.id')
+        ->select('job_hunting.*', 'user.nickname as nickname', 'user.user_name as user_name', 'website.website_name as website_name')
+        ->orderBy('updated_at', 'desc')
+        ->limit(5)->get();
+      //获取5条用户的求职 2
+      $job_recruiting = JobRecruiting::where('job_recruiting.status', 1)
+        ->leftJoin('user', 'job_recruiting.user_id', '=', 'user.id')
+        ->leftJoin('website', 'job_recruiting.website_id', '=', 'website.id')
+        ->select('job_recruiting.*', 'user.nickname as nickname', 'user.user_name as user_name', 'website.website_name as website_name')
+        ->orderBy('updated_at', 'desc')
+        ->limit(5)->get();
+      //人才库  1
+      $job_apply = JobApply::where('job_apply.status', 1)
+        ->leftJoin('user', 'job_apply.user_id', '=', 'user.id')
+        ->leftJoin('website', 'job_apply.website_id', '=', 'website.id')
+        ->leftJoin('job_company', 'job_company.job_id', '=', 'job_apply.recruit_id')
+        ->leftJoin('job_recruiting', 'job_recruiting.id', '=', 'job_apply.recruit_id')
+        ->select('job_apply.*', 'user.nickname as nickname', 'user.user_name as user_name', 'website.website_name as website_name', 'job_company.business_name as business_name', 'job_recruiting.title as job_name')
+        ->orderBy('updated_at', 'desc')
+        ->limit(5)->get();
+      // 职场机会 2
+      $job_resume = JobResume::where('job_resume.status', 1)
+        ->leftJoin('user', 'job_resume.receiver_id', '=', 'user.id')
+        ->leftJoin('website', 'job_resume.website_id', '=', 'website.id')
+        ->leftJoin('job_company', 'job_company.job_id', '=', 'job_resume.recruit_id')
+        ->select('job_resume.*', 'user.nickname as nickname', 'user.user_name as user_name', 'website.website_name as website_name', 'job_company.business_name as business_name')
+        ->orderBy('updated_at', 'desc')
+        ->limit(5)->get();
+
+      $count = count($chat) + count($chat_group) + count($apply_articale) + count($good) + count($notice) + count($complaint) + count($book) + count($job_hunting) + count($job_recruiting) + count($job_apply) + count($job_resume);
+      $result = [
+        'apply_articale' => $apply_articale,
+        'chat' => $chat,
+        'chat_group' => $chat_group,
+        'good' => $good,
+        'notice' => $notice,
+        'complaint' => $complaint,
+        'book' => $book,
+        'job_hunting' => $job_hunting,
+        'job_recruiting' => $job_recruiting,
+        'job_apply' => $job_apply,
+        'job_resume' => $job_resume,
+        'count' => $count,
+      ];
+    } elseif ($type_id == 20000) {
+    }
+    var_dump($type_id, '-----------------test---------');
+    return Result::success($result);
+  }
+  public function getComplaintList(array $data): array
+  {
+    var_dump($data, '00000001000000000000');
+    $type_id = isset($data['type_id']) ? $data['type_id'] : '';
+    unset($data['type_id']);
+    $user_id = isset($data['user_id']) ? $data['user_id'] : '';
+    $where = [];
+    if ($type_id != 10000 && empty($data['deal_user'])) {
+      $where['complaint.user_id'] = $user_id;
+    }
+    if (!empty($data['title'])) {
+      $where[] = ['complaint.title', 'like', '%' . $data['title'] . '%'];
+    }
+    if (!empty($data['department_id'])) {
+      $where['complaint.department_id'] =   $data['department_id'];
+    }
+    if (!empty($data['deal'])) {
+      $where['complaint.deal'] =   $data['deal'];
+    }
+    if (!empty($data['status'])) {
+      $where['complaint.status'] =  $data['status'];
+    }
+    var_dump(!empty($data['deal_user']), '----------1');
+    var_dump($where, '----------2');
+    $result = Complaint::where($where)
+      ->when(!empty($data['status1']), function ($query) use ($data) {
+        $query->whereIn('complaint.status', [1, 3]);   //1待审核2已审核3已拒绝
+      })
+      ->when(!empty($data['deal_user'])  &&  $type_id != 10000, function ($query) use ($data) {
+        //json  re_user_ids   data[user_id]是不是在里面 
+        $query->Where(function ($q) use ($data) {
+          $q->whereRaw('JSON_CONTAINS(complaint.re_user_ids, \'' . $data['user_id'] . '\')')
+            ->where('complaint.status', 2);
+        });
+      })
+      ->leftJoin('department', 'complaint.department_id', '=', 'department.id')
+      // ->leftJoin('user', 'complaint.user_id', '=', 'user.id')
+      ->leftJoin('district', 'district.id', '=', 'complaint.city_id')
+      ->select('complaint.*', 'department.name as department_name', 'district.name as cityname')
+      ->orderBy('updated_at', 'desc')
+      ->paginate($data['page_size'], ['*'], 'page', $data['page']);
+    //sql输出
+
+    if (empty($result)) {
+      return Result::error("暂无投诉信息", 0);
+    }
+    // 取出数据
+    $rows = $result->items();
+    $count = $result->total();
+
+    $responseData = [
+      'rows' => $rows,
+      'count' => $count,
+    ];
+    return Result::success($responseData);
+  }
+  public function getComplaintInfo(array $data): array
+  {
+    $result = Complaint::where('id', $data['id'])->first();
+    if (empty($result)) {
+      return Result::error("查询失败", 0);
+    }
+    return Result::success($result);
+  }
+  public function addComplaint(array $data): array
+  {
+    date_default_timezone_set('Asia/Shanghai');
+    $data['created_at'] = date('Y-m-d H:i:s');
+    $data['updated_at'] = date('Y-m-d H:i:s');
+    $result = Complaint::create($data);
+    return Result::success($result);
+  }
+  public function updateComplaint(array $data): array
+  {
+
+    date_default_timezone_set('Asia/Shanghai');
+    $data['updated_at'] = date('Y-m-d H:i:s');
+    $user_id = $data['user_id'] ?? 0;
+    $type_id = $data['type_id'] ?? 0;
+    unset($data['user_id']);
+    unset($data['type_id']);
+    $result = Complaint::where('id', $data['id'])->update($data);
+    return Result::success($result);
+  }
+  public function deleteComplaint(array $data): array
+  {
+    $result = Complaint::where('id', $data['id'])->delete();
+    return Result::success($result);
+  }
+  public function getComplainInfo(array $data): array
+  {
+    $result = Complaint::where('id', $data['id'])->first();
+    if (empty($result)) {
+      return Result::error("查询失败", 0);
+    }
+    return Result::success($result);
+  }
+  public function updateComplaintStatus(array $data): array
+  {
+    date_default_timezone_set('Asia/Shanghai');
+    $data['updated_at'] = date('Y-m-d H:i:s');
+    $user_id = $data['user_id'] ?? 0;
+    $type_id = $data['type_id'] ?? 0;
+
+    unset($data['user_id']);
+    unset($data['type_id']);
+    //处理, 写入处理人
+    if (isset($data['deal']) && ($data['deal'] == 2 || $data['deal'] == 4)) {
+      $data['real_deal_user'] = $user_id;
     }
+    //如果是deal 23,则判断是不是处理人
+    if (isset($data['deal']) && ($data['deal'] == 3) && $type_id != 10000) {
+      $complaintInof = Complaint::where('id', $data['id'])
+        ->where('real_deal_user', $user_id)
+        ->first();
+      if (empty($complaintInof)) {
+        return Result::error("处理人错误", 0);
+      }
+    }
+
+    $result = complaint::where('id', $data['id'])->update($data);
+    return Result::success($result);
+  }
+  public function updateGoodStatus(array $data): array
+  {
+    $user_id = $data['user_id'] ?? 0;
+    $type_id = $data['type_id'] ?? 0;
+    unset($data['user_id']);
+    unset($data['type_id']);
+
+    $result = Good::where('id', $data['id'])->update($data);
+    return Result::success($result);
+  }
+  public function updateJobHuntingStatus(array $data): array
+  {
+    $user_id = $data['user_id'] ?? 0;
+    $type_id = $data['type_id'] ?? 0;
+    unset($data['user_id']);
+    unset($data['type_id']);
+    $result = JobHunting::where('id', $data['id'])->update($data);
+    return Result::success($result);
+  }
+  public function updateNoticeStatus(array $data): array
+  {
+    $user_id = $data['user_id'] ?? 0;
+    $type_id = $data['type_id'] ?? 0;
+    unset($data['user_id']);
+    unset($data['type_id']);
+    $result = Notice::where('id', $data['id'])->update($data);
+    return Result::success($result);
+  }
+  public function getDUser(array $data): array
+  {
+    if (!empty($data['ids'])) {
+      $user = User::whereIn('id', $data['ids'])->getall();
+      if (empty($user)) {
+        return Result::error('无数据', 0);
+      }
+      return Result::success($user);
+    }
+    $where = [];
+    if (!empty($data['department_id'])) {
+      $where['department_id'] = $data['department_id'];
+    }
+    if (!empty($data['city_id'])) {
+      $where['city_id'] = $data['city_id'];
+    }
+    $result = User::where('type_id', 2)
+      ->where('status', 1)
+      ->where($where)
+      ->leftJoin('user_info', 'user.id', '=', 'user_info.user_id')
+      ->get();
+    if (empty($result)) {
+      return Result::error("查询失败", 0);
+    }
+    return Result::success($result);
+  }
 
-    //20250324  通知,公告,消息
+  //20250324  通知,公告,消息
 
 
-    // 20250306 -------招聘--------fr
-    /*
+  // 20250306 -------招聘--------fr
+  /*
     * 招聘列表
     * */
-    public function getJobRecruitingList(array $data): array
-    {
-        $where = [];
-        // 状态   0:待审核;1:已审核通过;(只有企业会员需要审核);2:已拒绝;3;已撤回;
-        if ($data['checkout'] == 0) {
-            $job_status = [0, 2];
-        } else {
-            $job_status = [1];
-        }
-        if (isset($data['keyword']) && !empty($data['keyword'])) {
-            array_push($where, ['job_recruiting.title', 'like', '%' . $data['keyword'] . '%']);
-        }
-        $user = User::where('id', $data['user_id'])->first();
-        if (empty($user)) {
-            return Result::error("用户不存在", 0);
-        }
-        //   3:企业会员
-        if ($user['type_id'] == 3) {
-            array_push($where, ['job_recruiting.user_id', $data['user_id']]);
-            array_push($where, ['job_recruiting.website_id', $data['website_id']]);
-        }
+  public function getJobRecruitingList(array $data): array
+  {
+    $where = [];
+    // 状态   0:待审核;1:已审核通过;(只有企业会员需要审核);2:已拒绝;3;已撤回;
+    if ($data['checkout'] == 0) {
+      $job_status = [0, 2];
+    } else {
+      $job_status = [1];
+    }
+    if (isset($data['keyword']) && !empty($data['keyword'])) {
+      array_push($where, ['job_recruiting.title', 'like', '%' . $data['keyword'] . '%']);
+    }
+    $user = User::where('id', $data['user_id'])->first();
+    if (empty($user)) {
+      return Result::error("用户不存在", 0);
+    }
+    //   3:企业会员
+    if ($user['type_id'] == 3) {
+      array_push($where, ['job_recruiting.user_id', $data['user_id']]);
+      array_push($where, ['job_recruiting.website_id', $data['website_id']]);
+    }
 
-        // 如果 $where 为空,则不添加 where 条件
-        $result['rows'] = JobRecruiting::when(!empty($where), function ($query) use ($where) {
-            return $query->where($where);
-        })
-            ->whereIn('job_recruiting.status', $job_status)
-            ->leftJoin('website', 'job_recruiting.website_id', '=', 'website.id')
-            ->leftJoin('user', 'job_recruiting.user_id', '=', 'user.id')
-            ->select('job_recruiting.*', 'website.website_name as website_name', 'user.user_name as user_name')
-            ->orderBy("updated_at", "desc")
-            ->offset(($data['page'] - 1) * $data['page_size'])
-            ->limit($data['page_size'])
-            ->get()
-            ->all();
-        $result['count'] = JobRecruiting::when(!empty($where), function ($query) use ($where) {
-            return $query->where($where);
-        })
-            ->whereIn('job_recruiting.status', $job_status)
-            ->count();
-        if (empty($result)) {
-            return Result::error("暂无招聘信息", 0);
-        }
-        return Result::success($result);
+    // 如果 $where 为空,则不添加 where 条件
+    $result['rows'] = JobRecruiting::when(!empty($where), function ($query) use ($where) {
+      return $query->where($where);
+    })
+      ->whereIn('job_recruiting.status', $job_status)
+      ->leftJoin('website', 'job_recruiting.website_id', '=', 'website.id')
+      ->leftJoin('user', 'job_recruiting.user_id', '=', 'user.id')
+      ->select('job_recruiting.*', 'website.website_name as website_name', 'user.user_name as user_name')
+      ->orderBy("updated_at", "desc")
+      ->offset(($data['page'] - 1) * $data['page_size'])
+      ->limit($data['page_size'])
+      ->get()
+      ->all();
+    $result['count'] = JobRecruiting::when(!empty($where), function ($query) use ($where) {
+      return $query->where($where);
+    })
+      ->whereIn('job_recruiting.status', $job_status)
+      ->count();
+    if (empty($result)) {
+      return Result::error("暂无招聘信息", 0);
     }
+    return Result::success($result);
+  }
 
 
-    /*
+  /*
     * 招聘信息添加
     * */
-    public function addJobRecruiting(array $data): array
-    {
-        // return Result::success($data);
-        $user = User::where('user.id', $data['user_id'])
-            ->where('user.status', 1)
-            ->leftJoin('user_info', 'user_info.user_id', 'user.id')
-            ->select(
-                'user.type_id',
-                'user.mobile',
-                'user.email',
-                'user_info.business_name',
-                'user_info.company_hy_id',
-                'user_info.company_nature',
-                'user_info.company_size',
-                'user_info.introduction',
-                'user_info.real_name',
-                'user_info.company_url',
-                'user_info.address_arr_id',
-                'user_info.address'
-            )
-            ->first();
-        if (empty($user) || $user['type_id'] != $data['user_type']) {
-            return Result::error("用户不存在", 0);
-        }
-        $web = Website::where('id', $data['website_id'])->first();
-        if (empty($web)) {
-            return Result::error("网站不存在", 0);
-        }
-        // return Result::success($user);
-        $data['action_id'] = $data['user_id'];
-        $data['user_type'] = $user['type_id'];
-        $data['cat_arr_id'] = array_values(array_unique($data['cat_arr_id']));
-        $data['city_arr_id'] = array_values(array_unique($data['city_arr_id']));
-        $data['cat_arr_id'] = isset($data['cat_arr_id']) ? json_encode(array_map('intval', $data['cat_arr_id'])) : '';
-        $data['city_arr_id'] = isset($data['city_arr_id']) ? json_encode(array_map('intval', $data['city_arr_id'])) : '';
-        // 公司地址 管理员必填
-        $data['address_arr_id'] = array_values(array_unique($data['address_arr_id']));
-        $data['address_arr_id'] = isset($data['address_arr_id']) ? json_encode(array_map('intval', $data['address_arr_id'])) : '';
-        // 管理员-企业相关信息
+  public function addJobRecruiting(array $data): array
+  {
+    // return Result::success($data);
+    $user = User::where('user.id', $data['user_id'])
+      ->where('user.status', 1)
+      ->leftJoin('user_info', 'user_info.user_id', 'user.id')
+      ->select(
+        'user.type_id',
+        'user.mobile',
+        'user.email',
+        'user_info.business_name',
+        'user_info.company_hy_id',
+        'user_info.company_nature',
+        'user_info.company_size',
+        'user_info.introduction',
+        'user_info.real_name',
+        'user_info.company_url',
+        'user_info.address_arr_id',
+        'user_info.address'
+      )
+      ->first();
+    if (empty($user) || $user['type_id'] != $data['user_type']) {
+      return Result::error("用户不存在", 0);
+    }
+    $web = Website::where('id', $data['website_id'])->first();
+    if (empty($web)) {
+      return Result::error("网站不存在", 0);
+    }
+    // return Result::success($user);
+    $data['action_id'] = $data['user_id'];
+    $data['user_type'] = $user['type_id'];
+    $data['cat_arr_id'] = array_values(array_unique($data['cat_arr_id']));
+    $data['city_arr_id'] = array_values(array_unique($data['city_arr_id']));
+    $data['cat_arr_id'] = isset($data['cat_arr_id']) ? json_encode(array_map('intval', $data['cat_arr_id'])) : '';
+    $data['city_arr_id'] = isset($data['city_arr_id']) ? json_encode(array_map('intval', $data['city_arr_id'])) : '';
+    // 公司地址 管理员必填
+    $data['address_arr_id'] = array_values(array_unique($data['address_arr_id']));
+    $data['address_arr_id'] = isset($data['address_arr_id']) ? json_encode(array_map('intval', $data['address_arr_id'])) : '';
+    // 管理员-企业相关信息
+    $company = [
+      // 'user_id' => $data['user_id']?? null,
+      'business_name' => $data['business_name'] ?? null,
+      'company_hy_id' => $data['company_hy_id'] ?? null,
+      'company_size' => $data['company_size'] ?? null,
+      'company_nature' => $data['company_nature'] ?? null,
+      'introduction' => $data['introduction'] ?? null,
+      'real_name' => $data['real_name'] ?? null,
+      'mobile' => $data['mobile'] ?? null,
+      'company_url' => $data['company_url'] ?? null,
+      'address_arr_id' => $data['address_arr_id'] ?? null,
+      'address' => $data['address'] ?? null,
+      'email' => $data['email'] ?? null,
+    ];
+    //去掉相关企业信息 
+    $job = array_diff_key($data, array_flip(array_keys($company)));
+    Db::beginTransaction();
+    try {
+      // 先添加职位相关信息
+      if ($user['type_id'] == 10000) {
+        $job['status'] = 1;
+      }
+      if (empty($data['experience']) || $data['experience'] == '') {
+        $job['experience'] = null;
+      } else {
+        $job['experience'] = $data['experience'];
+      }
+      $jobId = JobRecruiting::insertGetId($job);
+      if (empty($jobId)) {
+        Db::rollBack();
+        return Result::error("添加失败");
+      }
+      // 添加公司信息
+      $company['user_id'] = $data['user_id'] ?? null;
+      $company['job_id'] = $jobId;
+      $company['user_type'] = $user['type_id'] ?? null;
+      $company['website_id'] = $data['website_id'] ?? null;
+      if ($user['type_id'] == 10000) {
+        // 管理员添加企业信息
+        //    return Result::success($company);
+        $companyId = JobCompany::insertGetId($company);
+        if (empty($companyId)) {
+          Db::rollBack();
+          return Result::error("添加失败");
+        }
+      } else {
+        // 企业会员添加企业信息
         $company = [
-            // 'user_id' => $data['user_id']?? null,
-            'business_name' => $data['business_name'] ?? null,
-            'company_hy_id' => $data['company_hy_id'] ?? null,
-            'company_size' => $data['company_size'] ?? null,
-            'company_nature' => $data['company_nature'] ?? null,
-            'introduction' => $data['introduction'] ?? null,
-            'real_name' => $data['real_name'] ?? null,
-            'mobile' => $data['mobile'] ?? null,
-            'company_url' => $data['company_url'] ?? null,
-            'address_arr_id' => $data['address_arr_id'] ?? null,
-            'address' => $data['address'] ?? null,
-            'email' => $data['email'] ?? null,
-        ];
-        //去掉相关企业信息 
-        $job = array_diff_key($data, array_flip(array_keys($company)));
-        Db::beginTransaction();
-        try {
-            // 先添加职位相关信息
-            if ($user['type_id'] == 10000) {
-                $job['status'] = 1;
-            }
-            if (empty($data['experience']) || $data['experience'] == '') {
-                $job['experience'] = null;
-            } else {
-                $job['experience'] = $data['experience'];
-            }
-            $jobId = JobRecruiting::insertGetId($job);
-            if (empty($jobId)) {
-                Db::rollBack();
-                return Result::error("添加失败");
-            }
-            // 添加公司信息
-            $company['user_id'] = $data['user_id'] ?? null;
-            $company['job_id'] = $jobId;
-            $company['user_type'] = $user['type_id'] ?? null;
-            $company['website_id'] = $data['website_id'] ?? null;
-            if ($user['type_id'] == 10000) {
-                // 管理员添加企业信息
-                //    return Result::success($company);
-                $companyId = JobCompany::insertGetId($company);
-                if (empty($companyId)) {
-                    Db::rollBack();
-                    return Result::error("添加失败");
-                }
-            } else {
-                // 企业会员添加企业信息
-                $company = [
-                    'user_id' => $data['user_id'] ?? null,
-                    'business_name' => $user['business_name'] ?? null,
-                    'company_hy_id' => $user['company_hy_id'] ?? null,
-                    'company_size' => $user['company_size'] ?? null,
-                    'company_nature' => $user['company_nature'] ?? null,
-                    'introduction' => $user['introduction'] ?? null,
-                    'real_name' => $user['real_name'] ?? null,
-                    'mobile' => $user['mobile'] ?? null,
-                    'company_url' => $user['company_url'] ?? null,
-                    'address_arr_id' => $user['address_arr_id'] ?? null,
-                    'address' => $user['address'] ?? null,
-                    'email' => $user['email'] ?? null,
-                    'website_id' => $data['website_id'] ?? null,
-                    'user_type' => $user['type_id'] ?? null,
-                    'job_id' => $jobId,
-                ];
-                $companyId = JobCompany::insertGetId($company);
-                if (empty($companyId)) {
-                    Db::rollBack();
-                    return Result::error("添加失败");
-                }
-                // return Result::success($company);
-            }
-            Db::commit();
-        } catch (\Exception $e) {
-            Db::rollBack();
-            return Result::error($e->getMessage(), 0);
-        }
-        $result = [
-            'job_id' => $jobId,
-            'company_id' => $companyId,
+          'user_id' => $data['user_id'] ?? null,
+          'business_name' => $user['business_name'] ?? null,
+          'company_hy_id' => $user['company_hy_id'] ?? null,
+          'company_size' => $user['company_size'] ?? null,
+          'company_nature' => $user['company_nature'] ?? null,
+          'introduction' => $user['introduction'] ?? null,
+          'real_name' => $user['real_name'] ?? null,
+          'mobile' => $user['mobile'] ?? null,
+          'company_url' => $user['company_url'] ?? null,
+          'address_arr_id' => $user['address_arr_id'] ?? null,
+          'address' => $user['address'] ?? null,
+          'email' => $user['email'] ?? null,
+          'website_id' => $data['website_id'] ?? null,
+          'user_type' => $user['type_id'] ?? null,
+          'job_id' => $jobId,
         ];
-        if (empty($result)) {
-            return Result::error("添加失败", 0);
-        }
-        return Result::success($result);
+        $companyId = JobCompany::insertGetId($company);
+        if (empty($companyId)) {
+          Db::rollBack();
+          return Result::error("添加失败");
+        }
+        // return Result::success($company);
+      }
+      Db::commit();
+    } catch (\Exception $e) {
+      Db::rollBack();
+      return Result::error($e->getMessage(), 0);
+    }
+    $result = [
+      'job_id' => $jobId,
+      'company_id' => $companyId,
+    ];
+    if (empty($result)) {
+      return Result::error("添加失败", 0);
     }
-    /*
+    return Result::success($result);
+  }
+  /*
     * 获取招聘信息详情
     * */
-    public function getJobRecruitingInfo(array $data): array
-    {
-        $result = JobRecruiting::where('job_recruiting.id', $data['id'])
-            ->leftJoin('website', 'job_recruiting.website_id', '=', 'website.id')
-            ->leftJoin('job_company', 'job_recruiting.id', '=', 'job_company.job_id')
-            ->select(
-                'job_recruiting.*',
-                'website.website_name as website_name',
-                'job_company.business_name',
-                'job_company.company_hy_id',
-                'job_company.company_size',
-                'job_company.company_nature',
-                'job_company.introduction',
-                'job_company.real_name',
-                'job_company.mobile',
-                'job_company.company_url',
-                'job_company.address_arr_id',
-                'job_company.address',
-                'job_company.email'
-            )
-            ->first();
-        $cityId = json_decode($result['city_arr_id'], true) ?? [];
-        if (!empty($cityId)) {
-            if (isset($cityId[1]) && $cityId[1] != null) {
-                $city = District::where('id', $cityId[1])->first(['name']);
-            } else {
-                $city = District::where('id', $cityId[0])->first(['name']);
-            }
-            $result['city'] = $city['name'] ?? '';
-        }
-        $addressId = json_decode($result['address_arr_id'], true) ?? [];
-        if (is_array($addressId) && !empty($addressId)) {
-            $address = District::whereIn('id', $addressId)
-                ->orderBy('level', 'asc')
-                ->get(['name'])
-                ->pluck('name')
-                ->implode('');
-            // $job->address_name = $address ?? '';
-            $result['address_name'] = ($address ?? '') . ($result['address'] ?? '');
-        }
-        if (empty($result)) {
-            return Result::error("招聘信息不存在", 0);
-        }
-        // return Result::success($job);
-        return Result::success($result);
+  public function getJobRecruitingInfo(array $data): array
+  {
+    $result = JobRecruiting::where('job_recruiting.id', $data['id'])
+      ->leftJoin('website', 'job_recruiting.website_id', '=', 'website.id')
+      ->leftJoin('job_company', 'job_recruiting.id', '=', 'job_company.job_id')
+      ->select(
+        'job_recruiting.*',
+        'website.website_name as website_name',
+        'job_company.business_name',
+        'job_company.company_hy_id',
+        'job_company.company_size',
+        'job_company.company_nature',
+        'job_company.introduction',
+        'job_company.real_name',
+        'job_company.mobile',
+        'job_company.company_url',
+        'job_company.address_arr_id',
+        'job_company.address',
+        'job_company.email'
+      )
+      ->first();
+    $cityId = json_decode($result['city_arr_id'], true) ?? [];
+    if (!empty($cityId)) {
+      if (isset($cityId[1]) && $cityId[1] != null) {
+        $city = District::where('id', $cityId[1])->first(['name']);
+      } else {
+        $city = District::where('id', $cityId[0])->first(['name']);
+      }
+      $result['city'] = $city['name'] ?? '';
+    }
+    $addressId = json_decode($result['address_arr_id'], true) ?? [];
+    if (is_array($addressId) && !empty($addressId)) {
+      $address = District::whereIn('id', $addressId)
+        ->orderBy('level', 'asc')
+        ->get(['name'])
+        ->pluck('name')
+        ->implode('');
+      // $job->address_name = $address ?? '';
+      $result['address_name'] = ($address ?? '') . ($result['address'] ?? '');
+    }
+    if (empty($result)) {
+      return Result::error("招聘信息不存在", 0);
     }
-    /*
+    // return Result::success($job);
+    return Result::success($result);
+  }
+  /*
     * 修改招聘信息
     * */
-    public function upJobRecruiting(array $data): array
-    {
-        $job = JobRecruiting::where('job_recruiting.id', $data['id'])->first();
-        // return Result::success($job);
-        if (empty($job)) {
-            return Result::error("招聘信息不存在", 0);
-        }
-        $user = User::where('id', $data['user_id'])->first();
-        // return Result::success($user);
-        if (empty($user) || $user['type_id'] != $data['user_type']) {
-            return Result::error("用户不存在", 0);
-        }
-        if ($user['type_id'] == 3 && $job['user_id'] != $user['id']) {
-            return Result::error("用户暂无权限修改此招聘信息!", 0);
-        }
-        $data['cat_arr_id'] = array_values(array_unique($data['cat_arr_id']));
-        $data['city_arr_id'] = array_values(array_unique($data['city_arr_id']));
-        $data['cat_arr_id'] = isset($data['cat_arr_id']) ? json_encode(array_map('intval', $data['cat_arr_id'])) : '';
-        $data['city_arr_id'] = isset($data['city_arr_id']) ? json_encode(array_map('intval', $data['city_arr_id'])) : '';
-
-        // 公司地址 管理员必填
-        $data['address_arr_id'] = array_values(array_unique($data['address_arr_id']));
-        $data['address_arr_id'] = isset($data['address_arr_id']) ? json_encode(array_map('intval', $data['address_arr_id'])) : '';
-        //   管理员-企业相关信息
-        $company = [
-            'business_name' => $data['business_name'] ?? null,
-            'company_hy_id' => $data['hy_id'] ?? null,
-            'company_size' => $data['company_size'] ?? null,
-            'company_nature' => $data['company_nature'] ?? null,
-            'introduction' => $data['introduction'] ?? null,
-            'real_name' => $data['real_name'] ?? null,
-            'mobile' => $data['mobile'] ?? null,
-            'company_url' => $data['company_url'] ?? null,
-            'address_arr_id' => $data['address_arr_id'] ?? null,
-            'address' => $data['address'] ?? null,
-            'email' => $data['email'] ?? null,
-        ];
-        //去掉相关企业信息 
-        $data = array_diff_key($data, array_flip(array_keys($company)));
-        $jobId = $data['id'];
-        $web = $data['website_id'];
-        $data['action_id'] = $data['user_id'];
-        unset($data['user_id']);
-        unset($data['user_type']);
-        unset($data['id']);
-        unset($data['website_id']);
-        // return Result::success($data);
-        Db::beginTransaction();
-        try {
-            // 管理员修改招聘信息
-            if ($user['type_id'] == 10000) {
-                $data['website_id'] = $web;
-                $company['website_id'] = $data['website_id'];
-                $data['status'] = 1;
-            } else {
-                $data['status'] = 0;
-            }
-            if (empty($data['experience']) || $data['experience'] == '') {
-                $job['experience'] = null;
-            } else {
-                $job['experience'] = $data['experience'];
-            }
-            // Db::rollBack();
-            // return Result::success($company);
-            $result['job'] = JobRecruiting::where('id', $jobId)->update($data);
-            if (empty($result['job'])) {
-                Db::rollBack();
-                return Result::error("修改招聘信息失败");
-            }
-            // 管理员修改企业相关信息
-            $result['company'] = JobCompany::where('job_id', $jobId)->update($company);
-            if (empty($result['company'])) {
-                Db::rollBack();
-                return Result::error("修改企业相关信息失败");
-            }
-            Db::commit();
-            // return Result::success($result);
-        } catch (\Exception $e) {
-            Db::rollBack();
-            return Result::error($e->getMessage(), 0);
-        }
-        return Result::success($result);
+  public function upJobRecruiting(array $data): array
+  {
+    $job = JobRecruiting::where('job_recruiting.id', $data['id'])->first();
+    // return Result::success($job);
+    if (empty($job)) {
+      return Result::error("招聘信息不存在", 0);
     }
-    /*
+    $user = User::where('id', $data['user_id'])->first();
+    // return Result::success($user);
+    if (empty($user) || $user['type_id'] != $data['user_type']) {
+      return Result::error("用户不存在", 0);
+    }
+    if ($user['type_id'] == 3 && $job['user_id'] != $user['id']) {
+      return Result::error("用户暂无权限修改此招聘信息!", 0);
+    }
+    $data['cat_arr_id'] = array_values(array_unique($data['cat_arr_id']));
+    $data['city_arr_id'] = array_values(array_unique($data['city_arr_id']));
+    $data['cat_arr_id'] = isset($data['cat_arr_id']) ? json_encode(array_map('intval', $data['cat_arr_id'])) : '';
+    $data['city_arr_id'] = isset($data['city_arr_id']) ? json_encode(array_map('intval', $data['city_arr_id'])) : '';
+
+    // 公司地址 管理员必填
+    $data['address_arr_id'] = array_values(array_unique($data['address_arr_id']));
+    $data['address_arr_id'] = isset($data['address_arr_id']) ? json_encode(array_map('intval', $data['address_arr_id'])) : '';
+    //   管理员-企业相关信息
+    $company = [
+      'business_name' => $data['business_name'] ?? null,
+      'company_hy_id' => $data['hy_id'] ?? null,
+      'company_size' => $data['company_size'] ?? null,
+      'company_nature' => $data['company_nature'] ?? null,
+      'introduction' => $data['introduction'] ?? null,
+      'real_name' => $data['real_name'] ?? null,
+      'mobile' => $data['mobile'] ?? null,
+      'company_url' => $data['company_url'] ?? null,
+      'address_arr_id' => $data['address_arr_id'] ?? null,
+      'address' => $data['address'] ?? null,
+      'email' => $data['email'] ?? null,
+    ];
+    //去掉相关企业信息 
+    $data = array_diff_key($data, array_flip(array_keys($company)));
+    $jobId = $data['id'];
+    $web = $data['website_id'];
+    $data['action_id'] = $data['user_id'];
+    unset($data['user_id']);
+    unset($data['user_type']);
+    unset($data['id']);
+    unset($data['website_id']);
+    // return Result::success($data);
+    Db::beginTransaction();
+    try {
+      // 管理员修改招聘信息
+      if ($user['type_id'] == 10000) {
+        $data['website_id'] = $web;
+        $company['website_id'] = $data['website_id'];
+        $data['status'] = 1;
+      } else {
+        $data['status'] = 0;
+      }
+      if (empty($data['experience']) || $data['experience'] == '') {
+        $job['experience'] = null;
+      } else {
+        $job['experience'] = $data['experience'];
+      }
+      // Db::rollBack();
+      // return Result::success($company);
+      $result['job'] = JobRecruiting::where('id', $jobId)->update($data);
+      if (empty($result['job'])) {
+        Db::rollBack();
+        return Result::error("修改招聘信息失败");
+      }
+      // 管理员修改企业相关信息
+      $result['company'] = JobCompany::where('job_id', $jobId)->update($company);
+      if (empty($result['company'])) {
+        Db::rollBack();
+        return Result::error("修改企业相关信息失败");
+      }
+      Db::commit();
+      // return Result::success($result);
+    } catch (\Exception $e) {
+      Db::rollBack();
+      return Result::error($e->getMessage(), 0);
+    }
+    return Result::success($result);
+  }
+  /*
     * 招聘信息删除
     * */
-    public function delJobRecruiting(array $data): array
-    {
-        $user = User::where('id', $data['user_id'])->first();
-        if (empty($user)) {
-            return Result::error("用户不存在", 0);
-        }
-        $job = JobRecruiting::where('id', $data['id'])->first();
-        if (empty($job)) {
-            return Result::error("招聘信息不存在", 0);
-        }
-        if ($user['type_id'] == 3 && $job['user_id'] != $user['id']) {
-            return Result::error("用户暂无权限修改此招聘信息!", 0);
-        }
-        Db::beginTransaction();
-        try {
-            $result['job'] = JobRecruiting::where('id', $data['id'])->delete();
-            if (empty($result['job'])) {
-                Db::rollBack();
-                return Result::error("删除招聘信息失败");
-            }
-            $result['company'] = JobCompany::where('job_id', $data['id'])->delete();
-            if (empty($result['company'])) {
-                Db::rollBack();
-                return Result::error("删除企业相关信息失败");
-            }
-            Db::commit();
-        } catch (\Exception $e) {
-            Db::rollBack();
-            return Result::error($e->getMessage(), 0);
-        }
-        return Result::success($result);
+  public function delJobRecruiting(array $data): array
+  {
+    $user = User::where('id', $data['user_id'])->first();
+    if (empty($user)) {
+      return Result::error("用户不存在", 0);
+    }
+    $job = JobRecruiting::where('id', $data['id'])->first();
+    if (empty($job)) {
+      return Result::error("招聘信息不存在", 0);
+    }
+    if ($user['type_id'] == 3 && $job['user_id'] != $user['id']) {
+      return Result::error("用户暂无权限修改此招聘信息!", 0);
+    }
+    Db::beginTransaction();
+    try {
+      $result['job'] = JobRecruiting::where('id', $data['id'])->delete();
+      if (empty($result['job'])) {
+        Db::rollBack();
+        return Result::error("删除招聘信息失败");
+      }
+      $result['company'] = JobCompany::where('job_id', $data['id'])->delete();
+      if (empty($result['company'])) {
+        Db::rollBack();
+        return Result::error("删除企业相关信息失败");
+      }
+      Db::commit();
+    } catch (\Exception $e) {
+      Db::rollBack();
+      return Result::error($e->getMessage(), 0);
     }
-    /*
+    return Result::success($result);
+  }
+  /*
     * 获取公司信息
     * */
-    public function getJobCompany(array $data): array
-    {
-        $user = User::where('user.id', $data['user_id'])
-            ->leftJoin('user_info', 'user_info.user_id', 'user.id')
-            ->select('user.user_name', 'user.mobile', 'user.email', 'user.type_id', 'user_info.*')
-            ->first();
-        // return Result::success($user);
-        if (empty($user)) {
-            return Result::error("用户不存在", 0);
-        }
-        if ($user['type_id'] == 3) {
-            $result = [
-                // 'id' => 0,
-                'user_id' => $data['user_id'],
-                'website_id' =>  $data['website_id'],
-                'business_name' => $user['business_name'],       // 企业名称
-                'company_hy_id' => $user['company_hy_id'],                       // 企业所属行业
-                'company_nature' => $user['company_nature'],     // 公司性质
-                'company_size' => $user['company_size'],         // 公司规模
-                'introduction' => $user['introduction'],         // 公司简介
-                'real_name' => $user['real_name'],               // 企业联系人
-                'mobile' => $user['mobile'],                     // 企业联系电话
-                'company_url' => $user['company_url'],           // 企业网址
-                'address_arr_id' => $user['address_arr_id'],     // 企业网址
-                'address' => $user['address'],                   // 企业地址
-                'email' => $user['email'],                       // 企业邮箱
-            ];
-        } else {
-            return Result::error("用户类型错误", 0);
-        }
-        if (empty($result)) {
-            return Result::error("公司信息不存在", 0);
-        }
-        return Result::success($result);
+  public function getJobCompany(array $data): array
+  {
+    $user = User::where('user.id', $data['user_id'])
+      ->leftJoin('user_info', 'user_info.user_id', 'user.id')
+      ->select('user.user_name', 'user.mobile', 'user.email', 'user.type_id', 'user_info.*')
+      ->first();
+    // return Result::success($user);
+    if (empty($user)) {
+      return Result::error("用户不存在", 0);
+    }
+    if ($user['type_id'] == 3) {
+      $result = [
+        // 'id' => 0,
+        'user_id' => $data['user_id'],
+        'website_id' =>  $data['website_id'],
+        'business_name' => $user['business_name'],       // 企业名称
+        'company_hy_id' => $user['company_hy_id'],                       // 企业所属行业
+        'company_nature' => $user['company_nature'],     // 公司性质
+        'company_size' => $user['company_size'],         // 公司规模
+        'introduction' => $user['introduction'],         // 公司简介
+        'real_name' => $user['real_name'],               // 企业联系人
+        'mobile' => $user['mobile'],                     // 企业联系电话
+        'company_url' => $user['company_url'],           // 企业网址
+        'address_arr_id' => $user['address_arr_id'],     // 企业网址
+        'address' => $user['address'],                   // 企业地址
+        'email' => $user['email'],                       // 企业邮箱
+      ];
+    } else {
+      return Result::error("用户类型错误", 0);
+    }
+    if (empty($result)) {
+      return Result::error("公司信息不存在", 0);
     }
-    /*
+    return Result::success($result);
+  }
+  /*
     * 修改公司信息
     * */
-    public function upJobCompany(array $data): array
-    {
-        // return Result::success($data);
-        $user = User::where('user.id', $data['user_id'])
-            ->where('user.status', 1)
-            ->select('user.user_name', 'user.type_id')
-            ->first();
-        if (empty($user)) {
-            return Result::error("用户不存在", 0);
-        }
-        $data['address_arr_id'] = isset($data['address_arr_id']) ? json_encode(array_map('intval', $data['address_arr_id'])) : '';
-        $company = [
-            'business_name' => $data['business_name'],       // 企业名称
-            'company_hy_id' => $data['company_hy_id'],       // 企业所属行业
-            'company_nature' => $data['company_nature'],     // 公司性质
-            'company_size' => $data['company_size'],         // 公司规模
-            'introduction' => $data['introduction'],         // 公司简介
-            // 'real_name' => $data['real_name'],               // 企业联系人
-            'company_url' => $data['company_url'],           // 企业网址
-            'address_arr_id' => $data['address_arr_id'],     // 企业地址
-            'address' => $data['address'],                   // 企业详细地址
-        ];
-        if ($user['type_id'] == 3) {
-            Db::beginTransaction();
-            try {
-                $result['userinfo'] = UserInfo::where('user_id', $data['user_id'])->update([
-                    'business_name' => $data['business_name'],       // 企业名称
-                    'company_hy_id' => $data['company_hy_id'],       // 企业所属行业
-                    'company_nature' => $data['company_nature'],     // 公司性质
-                    'company_size' => $data['company_size'],         // 公司规模
-                    'introduction' => $data['introduction'],         // 公司简介
-                    // 'real_name' => $data['real_name'],               // 企业联系人
-                    'company_url' => $data['company_url'],           // 企业网址
-                    'address_arr_id' => $data['address_arr_id'],     // 企业地址
-                    'address' => $data['address'],                   // 企业详细地址
-                ]);
-                $result['job_company'] = JobCompany::where('user_id', $data['user_id'])->update($company);
-                Db::commit();
-            } catch (\Exception $e) {
-                Db::rollBack();
-                return Result::error($e->getMessage(), 0);
-            }
-        } else {
-            return Result::error("用户类型错误", 0);
-        }
-        if (empty($result)) {
-            return Result::error("修改失败", 0);
-        }
-        return Result::success($result);
+  public function upJobCompany(array $data): array
+  {
+    // return Result::success($data);
+    $user = User::where('user.id', $data['user_id'])
+      ->where('user.status', 1)
+      ->select('user.user_name', 'user.type_id')
+      ->first();
+    if (empty($user)) {
+      return Result::error("用户不存在", 0);
     }
-    /*
+    $data['address_arr_id'] = isset($data['address_arr_id']) ? json_encode(array_map('intval', $data['address_arr_id'])) : '';
+    $company = [
+      'business_name' => $data['business_name'],       // 企业名称
+      'company_hy_id' => $data['company_hy_id'],       // 企业所属行业
+      'company_nature' => $data['company_nature'],     // 公司性质
+      'company_size' => $data['company_size'],         // 公司规模
+      'introduction' => $data['introduction'],         // 公司简介
+      // 'real_name' => $data['real_name'],               // 企业联系人
+      'company_url' => $data['company_url'],           // 企业网址
+      'address_arr_id' => $data['address_arr_id'],     // 企业地址
+      'address' => $data['address'],                   // 企业详细地址
+    ];
+    if ($user['type_id'] == 3) {
+      Db::beginTransaction();
+      try {
+        $result['userinfo'] = UserInfo::where('user_id', $data['user_id'])->update([
+          'business_name' => $data['business_name'],       // 企业名称
+          'company_hy_id' => $data['company_hy_id'],       // 企业所属行业
+          'company_nature' => $data['company_nature'],     // 公司性质
+          'company_size' => $data['company_size'],         // 公司规模
+          'introduction' => $data['introduction'],         // 公司简介
+          // 'real_name' => $data['real_name'],               // 企业联系人
+          'company_url' => $data['company_url'],           // 企业网址
+          'address_arr_id' => $data['address_arr_id'],     // 企业地址
+          'address' => $data['address'],                   // 企业详细地址
+        ]);
+        $result['job_company'] = JobCompany::where('user_id', $data['user_id'])->update($company);
+        Db::commit();
+      } catch (\Exception $e) {
+        Db::rollBack();
+        return Result::error($e->getMessage(), 0);
+      }
+    } else {
+      return Result::error("用户类型错误", 0);
+    }
+    if (empty($result)) {
+      return Result::error("修改失败", 0);
+    }
+    return Result::success($result);
+  }
+  /*
     * 获取省-市
     * */
-    public function getJobRecruitingArea(array $data): array
-    {
-        if (isset($data['pid']) && $data['pid'] != null) {
-            $result = District::where('pid', $data['pid'])->get()->all();
-        } else {
-            $result = District::where('level', 1)->get()->all();
-        }
-        if (empty($result)) {
-            return Result::error("暂无此省市", 0);
-        }
-        return Result::success($result);
+  public function getJobRecruitingArea(array $data): array
+  {
+    if (isset($data['pid']) && $data['pid'] != null) {
+      $result = District::where('pid', $data['pid'])->get()->all();
+    } else {
+      $result = District::where('level', 1)->get()->all();
     }
-    /*
+    if (empty($result)) {
+      return Result::error("暂无此省市", 0);
+    }
+    return Result::success($result);
+  }
+  /*
     * 获取行业分类
     * */
-    public function getIndustry(array $data): array
-    {
-        $result = JobIndustry::get()->all();
-        if (empty($result)) {
-            return Result::error("暂无行业分类", 0);
-        }
-        return Result::success($result);
+  public function getIndustry(array $data): array
+  {
+    $result = JobIndustry::get()->all();
+    if (empty($result)) {
+      return Result::error("暂无行业分类", 0);
     }
-    /*
+    return Result::success($result);
+  }
+  /*
     * 获取职位
     * */
-    public function getPositionList(array $data): array
-    {
-        if (isset($data['zwpid']) && $data['zwpid'] != null) {
-            $result = JobPosition::where('zwpid', $data['zwpid'])->get()->all();
-        } else {
-            $result = JobPosition::where('zwpid', 0)->get()->all();
-        }
-        if (empty($result)) {
-            return Result::error("暂无此职位", 0);
-        }
-        return Result::success($result);
+  public function getPositionList(array $data): array
+  {
+    if (isset($data['zwpid']) && $data['zwpid'] != null) {
+      $result = JobPosition::where('zwpid', $data['zwpid'])->get()->all();
+    } else {
+      $result = JobPosition::where('zwpid', 0)->get()->all();
+    }
+    if (empty($result)) {
+      return Result::error("暂无此职位", 0);
     }
-    /*
+    return Result::success($result);
+  }
+  /*
     * 获取工作性质-菜单
     * */
-    public function getJobNature(array $data): array
-    {
-        $result = JobEnum::where('egroup', 'nature')->get()->all();
-        if (empty($result)) {
-            return Result::error("暂无工作性质", 0);
-        }
-        return Result::success($result);
+  public function getJobNature(array $data): array
+  {
+    $result = JobEnum::where('egroup', 'nature')->get()->all();
+    if (empty($result)) {
+      return Result::error("暂无工作性质", 0);
     }
-    /*
+    return Result::success($result);
+  }
+  /*
     * 获取工作经验-菜单
     * */
-    public function getExperience(array $data): array
-    {
-        $result = JobEnum::where('egroup', 'years')->get()->all();
-        if (empty($result)) {
-            return Result::error("暂无工作经验", 0);
-        }
-        return Result::success($result);
+  public function getExperience(array $data): array
+  {
+    $result = JobEnum::where('egroup', 'years')->get()->all();
+    if (empty($result)) {
+      return Result::error("暂无工作经验", 0);
     }
-    /*
+    return Result::success($result);
+  }
+  /*
     * 获取学历-菜单
     * */
-    public function getEducation(array $data): array
-    {
-        $result = JobEnum::where('egroup', 'education')->get()->all();
-        if (empty($result)) {
-            return Result::error("暂无学历", 0);
-        }
-        return Result::success($result);
+  public function getEducation(array $data): array
+  {
+    $result = JobEnum::where('egroup', 'education')->get()->all();
+    if (empty($result)) {
+      return Result::error("暂无学历", 0);
     }
-    /*
+    return Result::success($result);
+  }
+  /*
     * 获取薪资-菜单
     * */
-    public function getSalary(array $data): array
-    {
-        $result = JobEnum::where('egroup', 'income')->get()->all();
-        if (empty($result)) {
-            return Result::error("暂无薪资", 0);
-        }
-        return Result::success($result);
+  public function getSalary(array $data): array
+  {
+    $result = JobEnum::where('egroup', 'income')->get()->all();
+    if (empty($result)) {
+      return Result::error("暂无薪资", 0);
     }
-    /*
+    return Result::success($result);
+  }
+  /*
     * 获取语言-菜单
     * */
-    public function getLanguage(array $data): array
-    {
-        $result = JobEnum::where('egroup', 'language')->get()->all();
-        if (empty($result)) {
-            return Result::error("暂无语言", 0);
-        }
-        return Result::success($result);
+  public function getLanguage(array $data): array
+  {
+    $result = JobEnum::where('egroup', 'language')->get()->all();
+    if (empty($result)) {
+      return Result::error("暂无语言", 0);
     }
-    /*
+    return Result::success($result);
+  }
+  /*
     * 获取掌握程度-菜单
     * */
-    public function getLevel(array $data): array
-    {
-        $result = JobEnum::where('egroup', 'languagetype')->get()->all();
-        if (empty($result)) {
-            return Result::error("暂无工作性质", 0);
-        }
-        return Result::success($result);
+  public function getLevel(array $data): array
+  {
+    $result = JobEnum::where('egroup', 'languagetype')->get()->all();
+    if (empty($result)) {
+      return Result::error("暂无工作性质", 0);
     }
-    // 公司信息
-    /*
+    return Result::success($result);
+  }
+  // 公司信息
+  /*
     * 获取公司性质-菜单
     * */
-    public function getCompanyNature(array $data): array
-    {
-        $result = JobNature::get()->all();
-        if (empty($result)) {
-            return Result::error("暂无公司性质", 0);
-        }
-        return Result::success($result);
+  public function getCompanyNature(array $data): array
+  {
+    $result = JobNature::get()->all();
+    if (empty($result)) {
+      return Result::error("暂无公司性质", 0);
     }
-    /*
+    return Result::success($result);
+  }
+  /*
     * 获取公司规模-菜单
     * */
-    public function getCompanySize(array $data): array
-    {
-        $result = JobEnum::where('egroup', 'cosize')->get()->all();
-        if (empty($result)) {
-            return Result::error("暂无公司规模", 0);
-        }
-        return Result::success($result);
+  public function getCompanySize(array $data): array
+  {
+    $result = JobEnum::where('egroup', 'cosize')->get()->all();
+    if (empty($result)) {
+      return Result::error("暂无公司规模", 0);
     }
+    return Result::success($result);
+  }
 
-    /*
+  /*
     * 招聘信息审核
     * */
-    public function checkJobRecruiting(array $data): array
-    {
-        $user = User::where('id', $data['user_id'])->first();
-        if (empty($user)) {
-            return Result::error("用户不存在", 0);
-        }
-        $job = JobRecruiting::where('id', $data['id'])->first();
-        if (empty($job)) {
-            return Result::error("招聘信息不存在", 0);
-        }
-        // 状态   0:待审核;1:已审核通过;;2:已驳回;
-        if ($user['type_id'] != 10000) {
-            return Result::error("用户暂无权限审核此招聘信息!", 0);
-        }
-        // 驳回原因
-        if ($data['status'] == 2) {
-            $data['refuse_reason'] = $data['refuse_reason'] ?? null;
-        }
-        $data['action_id'] = $data['user_id'];
-        unset($data['user_id']);
-        $result = JobRecruiting::where('id', $data['id'])->update($data);
-        if (empty($result)) {
-            return Result::error("审核失败", 0);
-        }
-        return Result::success($result);
+  public function checkJobRecruiting(array $data): array
+  {
+    $user = User::where('id', $data['user_id'])->first();
+    if (empty($user)) {
+      return Result::error("用户不存在", 0);
     }
-    public function myApplyList(array $data): array
-    {
-        $user = User::where('id', $data['user_id'])->first();
-        if (empty($user) || ($user['type_id'] != 10000 && $user['type_id'] != 1)) {
-            return Result::error("用户不存在", 0);
-        }
-        // 1:个人会员    职场机会
-        if ($user['type_id'] == 1) {
-            $where['user_id'] = $user['id'];
-        }
-        $recruitingId = JobApply::when($user['type_id'] == 1, function ($query) use ($user) {
-            $query->where('recruit_id', $user['id']);
-        })
-            ->pluck('recruit_id');
-        $where = [];
-        if (isset($data['salary']) && $data['salary'] != null) {
-            $where['job_recruiting.salary'] = $data['salary'];
-        }
-        if (isset($data['experience']) && $data['experience'] != null) {
-            $where['job_recruiting.experience'] = $data['experience'];
-        }
-        if (isset($data['business_name']) && $data['business_name'] != null) {
-            array_push($where, ['job_company.business_name', 'like', '%' . $data['business_name'] . '%']);
-        }
-        $query = JobRecruiting::whereIn('job_recruiting.id', $recruitingId)
-            ->leftJoin('job_company', 'job_recruiting.id', '=', 'job_company.job_id')
-            ->where($where);
-        // ->count();
-        $count = $query->count();
-        $query = clone $query;
-        $job = $query
-            ->leftJoin('job_enum as income_enum', function ($join) {
-                $join->on('job_recruiting.salary', '=', 'income_enum.evalue')
-                    ->where('income_enum.egroup', 'income');
-            })
-            ->leftJoin('job_enum as years_enum', function ($join) {
-                $join->on('job_recruiting.experience', '=', 'years_enum.evalue')
-                    ->where('years_enum.egroup', 'years');
-            })
-            // ->where($where)
-            ->orderBy('job_recruiting.updated_at', 'desc')
-            ->select(
-                'job_recruiting.id',
-                'job_recruiting.title',
-                'job_company.business_name',
-                'income_enum.evalue as salary_evalue',
-                'income_enum.ename as salary_ename',
-                'years_enum.evalue as experience_evalue',
-                'years_enum.ename as experience_ename',
-                'job_recruiting.updated_at'
-            )
-            ->offset(($data['page'] - 1) * $data['pageSize'])
-            ->limit($data['pageSize'])
-            ->get()
-            ->all();
-
-        if (empty($job)) {
-            return Result::error("暂无招聘信息", 0);
-        }
-        $result = [
-            'row' => $job,
-            'count' => $count,
-        ];
-        return Result::success($result);
+    $job = JobRecruiting::where('id', $data['id'])->first();
+    if (empty($job)) {
+      return Result::error("招聘信息不存在", 0);
     }
-    /*
+    // 状态   0:待审核;1:已审核通过;;2:已驳回;
+    if ($user['type_id'] != 10000) {
+      return Result::error("用户暂无权限审核此招聘信息!", 0);
+    }
+    // 驳回原因
+    if ($data['status'] == 2) {
+      $data['refuse_reason'] = $data['refuse_reason'] ?? null;
+    }
+    $data['action_id'] = $data['user_id'];
+    unset($data['user_id']);
+    $result = JobRecruiting::where('id', $data['id'])->update($data);
+    if (empty($result)) {
+      return Result::error("审核失败", 0);
+    }
+    return Result::success($result);
+  }
+  public function myApplyList(array $data): array
+  {
+    var_dump($data, '------参数');
+    $user = User::where('id', $data['user_id'])->first();
+    if (empty($user) || ($user['type_id'] != 10000 && $user['type_id'] != 1)) {
+      return Result::error("用户不存在", 0);
+    }
+    // 1:个人会员    职场机会
+    if ($user['type_id'] == 1) {
+      $where['user_id'] = $user['id'];
+    }
+    $recruitingId = JobApply::when($user['type_id'] == 1, function ($query) use ($user) {
+      $query->where('user_id', $user['id']);
+    })
+      ->pluck('recruit_id');
+    $where = [];
+    if (isset($data['salary']) && $data['salary'] != null) {
+      $where['job_recruiting.salary'] = $data['salary'];
+    }
+    if (isset($data['experience']) && $data['experience'] != null) {
+      $where['job_recruiting.experience'] = $data['experience'];
+    }
+    if (isset($data['business_name']) && $data['business_name'] != null) {
+      array_push($where, ['job_company.business_name', 'like', '%' . $data['business_name'] . '%']);
+    }
+    $query = JobRecruiting::whereIn('job_recruiting.id', $recruitingId)
+      ->leftJoin('job_company', 'job_recruiting.id', '=', 'job_company.job_id')
+      ->where($where);
+    // ->count();
+    $count = $query->count();
+    $query = clone $query;
+    $job = $query
+      ->leftJoin('job_enum as income_enum', function ($join) {
+        $join->on('job_recruiting.salary', '=', 'income_enum.evalue')
+          ->where('income_enum.egroup', 'income');
+      })
+      ->leftJoin('job_enum as years_enum', function ($join) {
+        $join->on('job_recruiting.experience', '=', 'years_enum.evalue')
+          ->where('years_enum.egroup', 'years');
+      })
+      // ->where($where)
+      ->orderBy('job_recruiting.updated_at', 'desc')
+      ->select(
+        'job_recruiting.id',
+        'job_recruiting.title',
+        'job_company.business_name',
+        'income_enum.evalue as salary_evalue',
+        'income_enum.ename as salary_ename',
+        'years_enum.evalue as experience_evalue',
+        'years_enum.ename as experience_ename',
+        'job_recruiting.updated_at'
+      )
+      ->offset(($data['page'] - 1) * $data['pageSize'])
+      ->limit($data['pageSize'])
+      ->get()
+      ->all();
+
+    if (empty($job)) {
+      return Result::error("暂无招聘信息", 0);
+    }
+    $result = [
+      'row' => $job,
+      'count' => $count,
+    ];
+    return Result::success($result);
+  }
+  /*
     * 获取招聘信息列表-职场机会(个人会员收到企业推送岗位)
     * */
-    public function getRecruitingList(array $data): array
-    {
-        $user = User::where('id', $data['user_id'])->first();
-        if (empty($user) || ($user['type_id'] != 10000 && $user['type_id'] != 1)) {
-            return Result::error("用户不存在", 0);
-        }
-        // 1:个人会员    职场机会
-        if ($user['type_id'] == 1) {
-            $where['user_id'] = $user['id'];
-        }
-        $recruitingId = JobResume::when($user['type_id'] == 1, function ($query) use ($user) {
-            $query->where('recruit_id', $user['id']);
-        })
-            ->pluck('recruit_id');
-        $where = [];
-        if (isset($data['salary']) && $data['salary'] != null) {
-            $where['job_recruiting.salary'] = $data['salary'];
-        }
-        if (isset($data['experience']) && $data['experience'] != null) {
-            $where['job_recruiting.experience'] = $data['experience'];
-        }
-        if (isset($data['business_name']) && $data['business_name'] != null) {
-            array_push($where, ['job_company.business_name', 'like', '%' . $data['business_name'] . '%']);
-        }
-        $query = JobRecruiting::whereIn('job_recruiting.id', $recruitingId)
-            ->leftJoin('job_company', 'job_recruiting.id', '=', 'job_company.job_id')
-            ->where($where);
-        // ->count();
-        $count = $query->count();
-        $query = clone $query;
-        $job = $query
-            ->leftJoin('job_enum as income_enum', function ($join) {
-                $join->on('job_recruiting.salary', '=', 'income_enum.evalue')
-                    ->where('income_enum.egroup', 'income');
-            })
-            ->leftJoin('job_enum as years_enum', function ($join) {
-                $join->on('job_recruiting.experience', '=', 'years_enum.evalue')
-                    ->where('years_enum.egroup', 'years');
-            })
-            // ->where($where)
-            ->orderBy('job_recruiting.updated_at', 'desc')
-            ->select(
-                'job_recruiting.id',
-                'job_recruiting.title',
-                'job_company.business_name',
-                'income_enum.evalue as salary_evalue',
-                'income_enum.ename as salary_ename',
-                'years_enum.evalue as experience_evalue',
-                'years_enum.ename as experience_ename',
-                'job_recruiting.updated_at'
-            )
-            ->offset(($data['page'] - 1) * $data['pageSize'])
-            ->limit($data['pageSize'])
-            ->get()
-            ->all();
+  public function getRecruitingList(array $data): array
+  {
 
-        if (empty($job)) {
-            return Result::error("暂无招聘信息", 0);
-        }
-        $result = [
-            'row' => $job,
-            'count' => $count,
-        ];
-        return Result::success($result);
+    $user = User::where('id', $data['user_id'])->first();
+    if (empty($user) || ($user['type_id'] != 10000 && $user['type_id'] != 1)) {
+      return Result::error("用户不存在", 0);
+    }
+    // 1:个人会员    职场机会
+    if ($user['type_id'] == 1) {
+      $where['user_id'] = $user['id'];
     }
-    /*
+    $recruitingId = JobResume::when($user['type_id'] == 1, function ($query) use ($user) {
+      $query->where('recruit_id', $user['id']);
+    })
+      ->pluck('recruit_id');
+    $where = [];
+    if (isset($data['salary']) && $data['salary'] != null) {
+      $where['job_recruiting.salary'] = $data['salary'];
+    }
+    if (isset($data['experience']) && $data['experience'] != null) {
+      $where['job_recruiting.experience'] = $data['experience'];
+    }
+    if (isset($data['business_name']) && $data['business_name'] != null) {
+      array_push($where, ['job_company.business_name', 'like', '%' . $data['business_name'] . '%']);
+    }
+    $query = JobRecruiting::whereIn('job_recruiting.id', $recruitingId)
+      ->leftJoin('job_company', 'job_recruiting.id', '=', 'job_company.job_id')
+      ->where($where);
+    // ->count();
+    $count = $query->count();
+    $query = clone $query;
+    $job = $query
+      ->leftJoin('job_enum as income_enum', function ($join) {
+        $join->on('job_recruiting.salary', '=', 'income_enum.evalue')
+          ->where('income_enum.egroup', 'income');
+      })
+      ->leftJoin('job_enum as years_enum', function ($join) {
+        $join->on('job_recruiting.experience', '=', 'years_enum.evalue')
+          ->where('years_enum.egroup', 'years');
+      })
+      // ->where($where)
+      ->orderBy('job_recruiting.updated_at', 'desc')
+      ->select(
+        'job_recruiting.id',
+        'job_recruiting.title',
+        'job_company.business_name',
+        'income_enum.evalue as salary_evalue',
+        'income_enum.ename as salary_ename',
+        'years_enum.evalue as experience_evalue',
+        'years_enum.ename as experience_ename',
+        'job_recruiting.updated_at'
+      )
+      ->offset(($data['page'] - 1) * $data['pageSize'])
+      ->limit($data['pageSize'])
+      ->get()
+      ->all();
+
+    if (empty($job)) {
+      return Result::error("暂无招聘信息", 0);
+    }
+    $result = [
+      'row' => $job,
+      'count' => $count,
+    ];
+    return Result::success($result);
+  }
+  /*
     * 获取企业会员-招聘信息列表
     * */
-    public function getRecruitingInfo(array $data): array
-    {
-        $user = User::where('id', $data['user_id'])->first();
-        if (empty($user) || ($user['type_id'] != 10000 && $user['type_id'] != 1)) {
-            return Result::error("用户不存在", 0);
-        }
-        $recruiting = JobRecruiting::where('job_recruiting.id', $data['id'])
-            ->leftJoin('job_company', 'job_recruiting.id', '=', 'job_company.job_id')
-            ->select(
-                'job_recruiting.*',
-                'job_company.business_name',
-                'job_company.company_hy_id',
-                'job_company.company_size',
-                'job_company.company_nature',
-                'job_company.introduction',
-                'job_company.real_name',
-                'job_company.mobile',
-                'job_company.company_url',
-                'job_company.address_arr_id',
-                'job_company.address',
-                'job_company.email'
-            )
-            ->get();
-        if (empty($recruiting)) {
-            return Result::error("暂无招聘信息", 0);
-        }
-        return Result::success($recruiting);
+  public function getRecruitingInfo(array $data): array
+  {
+    $user = User::where('id', $data['user_id'])->first();
+    if (empty($user) || ($user['type_id'] != 10000 && $user['type_id'] != 1)) {
+      return Result::error("用户不存在", 0);
+    }
+    $recruiting = JobRecruiting::where('job_recruiting.id', $data['id'])
+      ->leftJoin('job_company', 'job_recruiting.id', '=', 'job_company.job_id')
+      ->select(
+        'job_recruiting.*',
+        'job_company.business_name',
+        'job_company.company_hy_id',
+        'job_company.company_size',
+        'job_company.company_nature',
+        'job_company.introduction',
+        'job_company.real_name',
+        'job_company.mobile',
+        'job_company.company_url',
+        'job_company.address_arr_id',
+        'job_company.address',
+        'job_company.email'
+      )
+      ->get();
+    if (empty($recruiting)) {
+      return Result::error("暂无招聘信息", 0);
     }
-    /*
+    return Result::success($recruiting);
+  }
+  /*
     * 获取企业会员-我的沟通
     * */
-    public function getJobResumeList(array $data): array
-    {
-        $user = User::where('id', $data['user_id'])->first();
-        if (empty($user) || ($user['type_id'] != 10000 && $user['type_id'] != 3)) {
-            return Result::error("用户不存在", 0);
-        }
-        $where = [];
-        if (isset($data['salary']) && $data['salary'] != null) {
-            $where['job_hunting.salary'] = $data['salary'];
-        }
-        if (isset($data['user_name']) && $data['user_name'] != null) {
-            array_push($where, ['user.user_name', 'like', '%' . $data['user_name'] . '%']);
-        }
-        $job = JobResume::when($user['type_id'] == 3, function ($query) use ($user) {
-            $query->where('job_resume.user_id', $user['id']);
-        })
-            ->when(!empty($where), function ($query) use ($where) {
-                $query->where($where);
-            })
-            ->leftJoin('job_hunting', 'job_hunting.id', 'job_resume.hunt_id')
-            ->leftJoin('job_recruiting', 'job_recruiting.id', 'job_resume.recruit_id')
-            ->leftJoin('user', 'user.id', 'job_resume.receiver_id')
-            ->select('job_resume.hunt_id', 'job_resume.recruit_id', 'job_hunting.id', 'job_hunting.salary', 'job_hunting.city_id', 'job_hunting.updated_at', 'job_recruiting.jtzw_id', 'user.user_name');
-        $count = $job->count();
-        if ($count == 0) {
-            return Result::error("暂无沟通记录", 0);
-        }
-        $jobs = $job->orderBy('job_hunting.updated_at', 'desc')
-            ->offset(($data['page'] - 1) * $data['pageSize'])
-            ->limit($data['pageSize'])
-            ->get();
-        if (empty($jobs)) {
-            return Result::error("暂无沟通记录", 0);
-        }
-        $result['row'] = $this->processJob($jobs, '');
-        $result['count'] = $count;
-        return Result::success($result);
-    }
-    // 20250306 招聘
-    //20250422  书刊音像
-    public function addBook(array $data): array
-    {
-        // $user_id = $data['user_id'] ?? 0;
-        $type_id = $data['type_id'] ?? 0;
-        // $website_id = $data['website_id'] ?? 0;
-        // unset($data['user_id']);
-        unset($data['type_id']);
-        // unset($data['website_id']);
-        //处理数组
-        // $data['department_arr_id'] = is_array($data['department_arr_id']) ? Json::encode($data['department_arr_id']) : '[]';
-        $data['city_arr_id'] = is_array($data['city_arr_id']) ? Json::encode($data['city_arr_id']) : '[]';
-        $data['cat_arr_id'] = is_array($data['cat_arr_id']) ? Json::encode($data['cat_arr_id']) : '[]';
-        if ($data['img_url'] == '') {
-            $reg = '/<img.*?src=[\"|\']?(.*?)[\"|\']?\s.*?>/i';
-            preg_match_all($reg, $data['detail'], $matches);
-            if (isset($matches[1][0])) {
-                //截取varchar240
-                $data['img_url'] = substr($matches[1][0], 0, 240);
-            }
-        }
-        if ($data['keyword'] == '' ||  $data['keyword'] == array()) {
-            //提取标题+内容中的关键词
-            $data['keyword'] = $data['title'];
-            //  . substr(str_replace(' ', '', strip_tags($data['content'])), 0, 20);
-            Jieba::init(); // 初始化 jieba-php
-            Finalseg::init();
-            $segList = Jieba::cut($data['keyword']);
-            $segList1 = array_slice($segList, 0, 8);
-            $data['keyword'] = implode(',', $segList1);
-        }
-        if ($data['description'] == '') {
-            //提取内容中的描述
-            $data['description'] = substr(preg_replace('/\s+/', '', strip_tags($data['detail'])), 0, 100);
-        }
-        var_dump($data, '--');
+  public function getJobResumeList(array $data): array
+  {
+    $user = User::where('id', $data['user_id'])->first();
+    if (empty($user) || ($user['type_id'] != 10000 && $user['type_id'] != 3)) {
+      return Result::error("用户不存在", 0);
+    }
+    $where = [];
+    if (isset($data['salary']) && $data['salary'] != null) {
+      $where['job_hunting.salary'] = $data['salary'];
+    }
+    if (isset($data['user_name']) && $data['user_name'] != null) {
+      array_push($where, ['user.user_name', 'like', '%' . $data['user_name'] . '%']);
+    }
+    $job = JobResume::when($user['type_id'] == 3, function ($query) use ($user) {
+      $query->where('job_resume.user_id', $user['id']);
+    })
+      ->when(!empty($where), function ($query) use ($where) {
+        $query->where($where);
+      })
+      ->leftJoin('job_hunting', 'job_hunting.id', 'job_resume.hunt_id')
+      ->leftJoin('job_recruiting', 'job_recruiting.id', 'job_resume.recruit_id')
+      ->leftJoin('user', 'user.id', 'job_resume.receiver_id')
+      ->select('job_resume.hunt_id', 'job_resume.recruit_id', 'job_hunting.id', 'job_hunting.salary', 'job_hunting.city_id', 'job_hunting.updated_at', 'job_recruiting.jtzw_id', 'user.user_name');
+    $count = $job->count();
+    if ($count == 0) {
+      return Result::error("暂无沟通记录", 0);
+    }
+    $jobs = $job->orderBy('job_hunting.updated_at', 'desc')
+      ->offset(($data['page'] - 1) * $data['pageSize'])
+      ->limit($data['pageSize'])
+      ->get();
+    if (empty($jobs)) {
+      return Result::error("暂无沟通记录", 0);
+    }
+    $result['row'] = $this->processJob($jobs, '');
+    $result['count'] = $count;
+    return Result::success($result);
+  }
+  // 20250306 招聘
+  //20250422  书刊音像
+  public function addBook(array $data): array
+  {
+    // $user_id = $data['user_id'] ?? 0;
+    $type_id = $data['type_id'] ?? 0;
+    // $website_id = $data['website_id'] ?? 0;
+    // unset($data['user_id']);
+    unset($data['type_id']);
+    // unset($data['website_id']);
+    //处理数组
+    // $data['department_arr_id'] = is_array($data['department_arr_id']) ? Json::encode($data['department_arr_id']) : '[]';
+    $data['city_arr_id'] = is_array($data['city_arr_id']) ? Json::encode($data['city_arr_id']) : '[]';
+    $data['cat_arr_id'] = is_array($data['cat_arr_id']) ? Json::encode($data['cat_arr_id']) : '[]';
+    if ($data['img_url'] == '') {
+      $reg = '/<img.*?src=[\"|\']?(.*?)[\"|\']?\s.*?>/i';
+      preg_match_all($reg, $data['detail'], $matches);
+      if (isset($matches[1][0])) {
+        //截取varchar240
+        $data['img_url'] = substr($matches[1][0], 0, 240);
+      }
+    }
+    if ($data['keyword'] == '' ||  $data['keyword'] == array()) {
+      //提取标题+内容中的关键词
+      $data['keyword'] = $data['title'];
+      //  . substr(str_replace(' ', '', strip_tags($data['content'])), 0, 20);
+      Jieba::init(); // 初始化 jieba-php
+      Finalseg::init();
+      $segList = Jieba::cut($data['keyword']);
+      $segList1 = array_slice($segList, 0, 8);
+      $data['keyword'] = implode(',', $segList1);
+    }
+    if ($data['description'] == '') {
+      //提取内容中的描述
+      $data['description'] = substr(preg_replace('/\s+/', '', strip_tags($data['detail'])), 0, 100);
+    }
+    var_dump($data, '--');
 
-        $result = Book::insertGetId($data);
-        if (empty($result)) {
-            return Result::error("添加失败", 0);
-        }
-        return Result::success($result);
+    $result = Book::insertGetId($data);
+    if (empty($result)) {
+      return Result::error("添加失败", 0);
     }
-    public function getBookList(array $data): array
-    {
-        $where = [];
-        if (!empty($data["title"])) {
-            $where[] = ['book.title', 'like', '%' . $data["title"] . '%'];
-        }
-        if (!empty($data['website_name'])) {
-            $where[] = ['website.website_name', 'like', '%' . $data['website_name'] . '%'];
-        }
-        if (!empty($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');
-        $result = Book::where($where)
-            ->leftJoin('website', 'book.website_id', '=', 'website.id')
-            ->leftJoin('category', 'book.cat_id', '=', 'category.id')
-            ->leftJoin('district', 'book.city_id', '=', 'district.id')
-            ->when(isset($data['status1']), function ($query) use ($data) {
-                $query->whereIn('book.status', [1, 3]);
-            })
-            ->select('book.*', 'website.website_name', 'category.name as cat_name', 'district.name as city_name')
-            ->orderBy("updated_at", "desc")
-            ->paginate($data['page_size'], ['*'], 'page', $data['page']);
-        if (empty($result)) {
-            return Result::error("暂无数据", 0);
-        }
-        // 取出数据
-        $rows = $result->items();
-        $count = $result->total();
-        $responseData = [
-            'rows' => $rows,
-            'count' => $count,
-        ];
-        return Result::success($responseData);
+    return Result::success($result);
+  }
+  public function getBookList(array $data): array
+  {
+    $where = [];
+    if (!empty($data["title"])) {
+      $where[] = ['book.title', 'like', '%' . $data["title"] . '%'];
     }
-    public function deleteBook(array $data): array
-    {
-        $result = Book::where('id', $data['id'])->delete();
-        if (empty($result)) {
-            return Result::error("删除失败", 0);
-        }
-        return Result::success($result);
-    }
-    public function updateBook(array $data): array
-    {
-
-        // $user_id = $data['user_id'] ?? 0;
-        $type_id = $data['type_id'] ?? 0;
-        // $website_id = $data['website_id'] ?? 0;
-        unset($data['user_id']);
-        unset($data['type_id']);
-        // unset($data['website_id']);
-        //处理数组
-        // $data['department_arr_id'] = is_array($data['department_arr_id']) ? Json::encode($data['department_arr_id']) : '[]';
-        if ($data['img_url'] == '') {
-            $reg = '/<img.*?src=[\"|\']?(.*?)[\"|\']?\s.*?>/i';
-            preg_match_all($reg, $data['detail'], $matches);
-            if (isset($matches[1][0])) {
-                //截取varchar240
-                $data['img_url'] = substr($matches[1][0], 0, 240);
-            }
-        }
-        if ($data['keyword'] == '') {
-            //提取标题+内容中的关键词
-            $data['keyword'] = $data['title'];
-            //  . substr(str_replace(' ', '', strip_tags($data['content'])), 0, 20);
-            Jieba::init(); // 初始化 jieba-php
-            Finalseg::init();
-            $segList = Jieba::cut($data['keyword']);
-            $segList1 = array_slice($segList, 0, 8);
-            $data['keyword'] = implode(',', $segList1);
-        }
-        if ($data['description'] == '') {
-            //提取内容中的描述
-            $data['description'] = substr(preg_replace('/\s+/', '', strip_tags($data['detail'])), 0, 100);
-        }
-        $data['city_arr_id'] = is_array($data['city_arr_id']) ? Json::encode($data['city_arr_id']) : '[]';
-        $data['cat_arr_id'] = is_array($data['cat_arr_id']) ? Json::encode($data['cat_arr_id']) : '[]';
-        $result = Book::where("id", $data["id"])->update($data);
-        if (empty($result)) {
-            return Result::error("更新失败", 0);
-        }
-        return Result::success($result);
+    if (!empty($data['website_name'])) {
+      $where[] = ['website.website_name', 'like', '%' . $data['website_name'] . '%'];
     }
-    public function getBookInfo(array $data): array
-    {
-        $result = Book::where("id", $data["id"])->first();
-        if (empty($result)) {
-            return Result::error("获取失败", 0);
-        }
-        return Result::success($result);
-    }
-    public function updateBookStatus(array $data): array
-    {
-        //审核
-        unset($data['user_id']);
-        $result = Book::where("id", $data["id"])->update($data);
-        if (empty($result)) {
-            return Result::error("更新失败", 0);
-        }
-        return Result::success($result);
+    if (!empty($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');
+    $result = Book::where($where)
+      ->leftJoin('website', 'book.website_id', '=', 'website.id')
+      ->leftJoin('category', 'book.cat_id', '=', 'category.id')
+      ->leftJoin('district', 'book.city_id', '=', 'district.id')
+      ->when(isset($data['status1']), function ($query) use ($data) {
+        $query->whereIn('book.status', [1, 3]);
+      })
+      ->select('book.*', 'website.website_name', 'category.name as cat_name', 'district.name as city_name')
+      ->orderBy("updated_at", "desc")
+      ->paginate($data['page_size'], ['*'], 'page', $data['page']);
+    if (empty($result)) {
+      return Result::error("暂无数据", 0);
+    }
+    // 取出数据
+    $rows = $result->items();
+    $count = $result->total();
+    $responseData = [
+      'rows' => $rows,
+      'count' => $count,
+    ];
+    return Result::success($responseData);
+  }
+  public function deleteBook(array $data): array
+  {
+    $result = Book::where('id', $data['id'])->delete();
+    if (empty($result)) {
+      return Result::error("删除失败", 0);
+    }
+    return Result::success($result);
+  }
+  public function updateBook(array $data): array
+  {
+
+    // $user_id = $data['user_id'] ?? 0;
+    $type_id = $data['type_id'] ?? 0;
+    // $website_id = $data['website_id'] ?? 0;
+    unset($data['user_id']);
+    unset($data['type_id']);
+    // unset($data['website_id']);
+    //处理数组
+    // $data['department_arr_id'] = is_array($data['department_arr_id']) ? Json::encode($data['department_arr_id']) : '[]';
+    if ($data['img_url'] == '') {
+      $reg = '/<img.*?src=[\"|\']?(.*?)[\"|\']?\s.*?>/i';
+      preg_match_all($reg, $data['detail'], $matches);
+      if (isset($matches[1][0])) {
+        //截取varchar240
+        $data['img_url'] = substr($matches[1][0], 0, 240);
+      }
+    }
+    if ($data['keyword'] == '') {
+      //提取标题+内容中的关键词
+      $data['keyword'] = $data['title'];
+      //  . substr(str_replace(' ', '', strip_tags($data['content'])), 0, 20);
+      Jieba::init(); // 初始化 jieba-php
+      Finalseg::init();
+      $segList = Jieba::cut($data['keyword']);
+      $segList1 = array_slice($segList, 0, 8);
+      $data['keyword'] = implode(',', $segList1);
+    }
+    if ($data['description'] == '') {
+      //提取内容中的描述
+      $data['description'] = substr(preg_replace('/\s+/', '', strip_tags($data['detail'])), 0, 100);
+    }
+    $data['city_arr_id'] = is_array($data['city_arr_id']) ? Json::encode($data['city_arr_id']) : '[]';
+    $data['cat_arr_id'] = is_array($data['cat_arr_id']) ? Json::encode($data['cat_arr_id']) : '[]';
+    $result = Book::where("id", $data["id"])->update($data);
+    if (empty($result)) {
+      return Result::error("更新失败", 0);
+    }
+    return Result::success($result);
+  }
+  public function getBookInfo(array $data): array
+  {
+    $result = Book::where("id", $data["id"])->first();
+    if (empty($result)) {
+      return Result::error("获取失败", 0);
+    }
+    return Result::success($result);
+  }
+  public function updateBookStatus(array $data): array
+  {
+    //审核
+    unset($data['user_id']);
+    $result = Book::where("id", $data["id"])->update($data);
+    if (empty($result)) {
+      return Result::error("更新失败", 0);
     }
+    return Result::success($result);
+  }
 
-    //20250422  书刊音像
+  //20250422  书刊音像
 }