FengR vor 1 Monat
Ursprung
Commit
69b64e7b91
61 geänderte Dateien mit 14610 neuen und 525 gelöschten Zeilen
  1. 29 0
      .env
  2. 423 0
      app/JsonRpc/AdService.php
  3. 72 0
      app/JsonRpc/AdServiceInterface.php
  4. 129 0
      app/JsonRpc/AuthorityService.php
  5. 53 0
      app/JsonRpc/AuthorityServiceInterface.php
  6. 1317 0
      app/JsonRpc/ChatService.php
  7. 227 0
      app/JsonRpc/ChatServiceInterface.php
  8. 601 0
      app/JsonRpc/FormService.php
  9. 91 0
      app/JsonRpc/FormServiceInterface.php
  10. 8894 0
      app/JsonRpc/NewsService.php
  11. 372 0
      app/JsonRpc/NewsServiceInterface.php
  12. 30 4
      app/JsonRpc/PublicRpcService.php
  13. 6 0
      app/JsonRpc/PublicRpcServiceInterface.php
  14. 800 0
      app/JsonRpc/UserService.php
  15. 147 0
      app/JsonRpc/UserServiceInterface.php
  16. 153 502
      app/JsonRpc/WebsiteService.php
  17. 16 19
      app/JsonRpc/WebsiteServiceInterface.php
  18. 27 0
      app/Model/AdministrativeUnit.php
  19. 23 0
      app/Model/Article.php
  20. 27 0
      app/Model/ArticleIgnore.php
  21. 31 0
      app/Model/ArticleSurvey.php
  22. 22 0
      app/Model/Character.php
  23. 29 0
      app/Model/Contact.php
  24. 29 0
      app/Model/ContactApply.php
  25. 22 0
      app/Model/Couplet.php
  26. 22 0
      app/Model/Festival.php
  27. 28 0
      app/Model/GroupImp.php
  28. 28 0
      app/Model/GroupMemberImp.php
  29. 28 0
      app/Model/GroupTalkImp.php
  30. 28 0
      app/Model/GroupTalkMessagerImp.php
  31. 22 0
      app/Model/HistoryToday.php
  32. 22 0
      app/Model/Idiom.php
  33. 28 0
      app/Model/ImContact.php
  34. 27 0
      app/Model/ImGroup.php
  35. 27 0
      app/Model/ImGroupMember.php
  36. 27 0
      app/Model/JobApply.php
  37. 27 0
      app/Model/JobCompany.php
  38. 27 0
      app/Model/JobEnum.php
  39. 27 0
      app/Model/JobIndustry.php
  40. 27 0
      app/Model/JobNature.php
  41. 27 0
      app/Model/JobPosition.php
  42. 27 0
      app/Model/JobRemuse.php
  43. 27 0
      app/Model/JobResume.php
  44. 28 0
      app/Model/Menu.php
  45. 22 0
      app/Model/Riddle.php
  46. 27 0
      app/Model/Role.php
  47. 27 0
      app/Model/RoleLog.php
  48. 32 0
      app/Model/RoleUser.php
  49. 28 0
      app/Model/TalkGroup.php
  50. 28 0
      app/Model/TalkGroupMember.php
  51. 29 0
      app/Model/TalkRecords.php
  52. 29 0
      app/Model/TalkRecordsFile.php
  53. 29 0
      app/Model/TalkSession.php
  54. 28 0
      app/Model/TalkSessionAssociation.php
  55. 28 0
      app/Model/TalkSessionStatus.php
  56. 33 0
      app/Model/UserImp.php
  57. 27 0
      app/Model/UserInfo.php
  58. 27 0
      app/Model/UserLogin.php
  59. 27 0
      app/Model/Web.php
  60. 28 0
      app/Model/Wechat.php
  61. 87 0
      config/autoload/databases.php

+ 29 - 0
.env

@@ -11,6 +11,35 @@ DB_CHARSET=utf8mb4
 DB_COLLATION=utf8mb4_unicode_ci
 DB_PREFIX=
 
+DB_DRIVER2=mysql
+DB_HOST2=192.168.1.234
+DB_PORT2=13306
+DB_DATABASE2=collector
+DB_USERNAME2=root
+DB_PASSWORD2=zxt_mysql_dev
+DB_CHARSET2=utf8mb4
+DB_COLLATION2=utf8mb4_unicode_ci
+DB_PREFIX2=col_
+
+DB_DRIVER3=mysql
+DB_HOST3=192.168.1.234
+DB_PORT3=13306
+DB_DATABASE3=global
+DB_USERNAME3=root
+DB_PASSWORD3=zxt_mysql_dev
+DB_CHARSET3=utf8mb4
+DB_COLLATION3=utf8mb4_unicode_ci
+DB_PREFIX3=
+
+DB_DRIVER4=mysql
+DB_HOST4=192.168.1.234
+DB_PORT4=13306
+DB_DATABASE4=imp
+DB_USERNAME4=root
+DB_PASSWORD4=zxt_mysql_dev
+DB_CHARSET4=utf8mb4
+DB_COLLATION4=utf8mb4_unicode_ci
+DB_PREFIX4=
 
 #REDIS_HOST=101.254.114.211
 #REDIS_AUTH=YPWWnFnNebc7427B

+ 423 - 0
app/JsonRpc/AdService.php

@@ -0,0 +1,423 @@
+<?php
+namespace App\JsonRpc;
+use App\Model\Ad;
+use App\Model\AdPlace;
+use App\Model\AdSize;
+use Hyperf\RpcServer\Annotation\RpcService;
+use App\Tools\Result;
+use Hyperf\DbConnection\Db;
+use App\Model\WebsiteTemplate;
+
+#[RpcService(name: "AdService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
+class AdService implements AdServiceInterface
+{
+    /**
+     * @param array $data
+     * @return string
+     */
+    public function createAd(array $data): array
+    {
+        $insertData = [
+            'name'=>$data['name']??'',
+            'pid'=>$data['pid']??0,
+            'areaid'=>$data['areaid']??0,
+            'amount'=>$data['amount']??0,//浏览数量
+            'introduce'=>$data['introduce']??'',
+            'hits'=>$data['hits']??0, //点击数量
+            'fromtime'=>$data['f_t_date'][0]??0,
+            'totime'=>$data['f_t_date'][1]??0,
+            'text_name'=>$data['text_name']??'',
+            'text_url'=>$data['text_url']??'',
+            'text_title'=>$data['text_title']??'',
+            'image_src'=>$data['image_src']??'',
+            'image_url'=>$data['image_url']??'',
+            'image_alt'=>$data['image_alt']??'',
+            'video_src'=>$data['video_src']??'',//视频
+            'video_url'=>$data['video_url']??'',
+            'video_auto'=>$data['video_auto'] ??0,
+            'video_loop'=>$data['video_loop'] ??0,
+            'status'=>$data['status']??2,
+            'remark'=>$data['remark']??'',
+        ];
+        $result = Ad::query()->insertGetId($insertData);
+        if($result){
+            return Result::success();
+        }else{
+            return Result::error("创建广告失败",500);
+        }
+    }
+    /**
+     * @param int $id
+     * @return array
+     */
+    public function getAdInfo(int $id): array
+    {
+        $adInfo = Ad::query()->find($id);
+        if (empty($adInfo)) {
+            return Result::error("没有数据",0);
+        }
+        return Result::success($adInfo->toArray());
+    }
+
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function getAdList(array $data): array
+    {
+        if(isset($data['pid'])){
+            $where[] =   ['ad.pid','=',$data['pid']];
+        }
+        $rep = Ad::where($where)
+            ->leftJoin("ad_place","ad.pid","ad_place.id")
+            ->leftJoin("website","website.id","ad_place.website_id")
+            ->select("ad.*","ad_place.name as place_name","ad_place.typeid","website.website_name")
+            ->limit($data['pageSize'])->orderBy("ad.id","desc")->offset(($data['page']-1)*$data['pageSize'])->get();
+        $count =  Ad::where($where)
+            ->leftJoin("ad_place","ad.pid","ad_place.id")
+            ->leftJoin("website","website.id","ad_place.website_id")
+            ->count();
+        $data = [
+            'rows'=>$rep->toArray(),
+            'count'=>$count
+        ];
+        if(empty($rep->toArray())){
+            return Result::error("没有数据");
+        }
+        return Result::success($data);
+    }
+
+    public function updateAd(array $data): array
+    {
+        $where = [
+            'id'=>$data['id']
+        ];
+        $insertData = [
+            'name'=>$data['name']??'',
+            'pid'=>$data['pid']??0,
+            'areaid'=>$data['areaid']??0,
+            'amount'=>$data['amount']??0,//浏览数量
+            'introduce'=>$data['introduce']??'',
+            'hits'=>$data['hits']??0, //点击数量
+            'fromtime'=>$data['f_t_date'][0]??0,
+            'totime'=>$data['f_t_date'][1]??0,
+            'text_name'=>$data['text_name']??'',
+            'text_url'=>$data['text_url']??'',
+            'text_title'=>$data['text_title']??'',
+            'image_src'=>$data['image_src']??'',
+            'image_url'=>$data['image_url']??'',
+            'image_alt'=>$data['image_alt']??'',
+            'video_src'=>$data['video_src']??'',//视频
+            'video_url'=>$data['video_url']??'',
+            'video_auto'=>isset($data['video_auto']) && empty($data['video_auto'])?0:$data['video_auto'],
+            'video_loop'=>isset($data['video_loop']) && empty($data['video_loop'])?0:$data['video_loop'],
+            'status'=>$data['status']??2,
+            'remark'=>$data['remark']??'',
+        ];
+        $result = Ad::where($where)->update($insertData);
+        if($result){
+            return Result::success($result);
+        }else{
+            return Result::error("更新失败");
+        }
+    }
+
+    public function delAd(array $data): array
+    {
+        $result = Ad::where($data)->delete();
+        if(!$result){
+            return Result::error("删除失败");
+        }
+        return Result::success($result);
+    }
+
+    /**
+     * 广告位列表
+     * @param array $data
+     * @return array
+     */
+    public function getAdPlaceList(array $data): array
+    {
+
+        $where = [];
+        if(isset($data['name'])  && $data['name']){
+            array_push($where,['ad_place.name','like','%'.$data['name'].'%']);
+        }
+        if(isset($data['website_id'])  && $data['website_id']){
+            array_push($where,['ad_place.website_id','=',$data['website_id']]);
+        }
+        $rep = AdPlace::where($where)
+            ->leftJoin("ad_size","ad_place.ad_size_id","ad_size.id")
+            ->leftJoin("website","website.id","ad_place.website_id")
+            ->limit($data['pageSize'])
+            ->orderBy("ad_place.updated_at","desc")
+            ->offset(($data['page']-1)*$data['pageSize'])
+            ->select("ad_place.*","ad_size.width","ad_size.height","website.website_name","website.website_column_id","website.website_column_arr_id")
+            ->get();
+        if($rep){
+            foreach ($rep as $key=>$val){
+                $rep[$key]['website_column_arr_id'] = json_decode($val['website_column_arr_id'],true);
+            }
+        }
+        $count =  AdPlace::where($where)->count();
+        $reponse = [
+            'rows'=>$rep->toArray(),
+            'count'=>$count
+        ];
+        if(empty($rep->toArray())){
+            return Result::error("没有数据");
+        }
+        return Result::success($reponse);
+    }
+
+    public function createAdPlace(array $data): array
+    {
+        unset($data['size']);
+        $result = AdPlace::query()->insertGetId($data);
+        if($result){
+            return Result::success();
+        }else{
+            return Result::error("创建广告位失败",500);
+        }
+    }
+    /**
+     * @param array $data 
+     * @return array 
+     */ 
+    public function updateAdPlace(array $data): array   
+    {
+        // 11
+        $where = [ 
+            'ad_place.id'=>$data['id'] 
+        ]; 
+        // $website_id = intval($data['website_id']);
+
+        // 原代码 leftJoin 条件使用错误,第三个参数应该是关联字段,这里修正为 "website.id" 关联 "ad_place.website_id"
+        $web = AdPlace::where($where)
+        ->leftJoin("website","website.id","ad_place.website_id")
+        ->select("website.*","ad_place.name",'ad_place.ad_tag')
+
+        ->first();
+        if(empty($web)){
+            return Result::error("广告位不存在");
+        }
+        // 自助建站广告位-广告位编辑同步模板数据-------fr----start
+        //  return Result::success($web);
+        $website_column_arr_id = json_decode($web['website_column_arr_id'],true);
+        Db::beginTransaction();
+        try{
+            // 判断网站的广告位是否通过自助建站创建的广告位(通过网系包含2来判断)
+            if(!in_array(3,$website_column_arr_id)){
+                $template_data = ['ad_tag'=>$web['ad_tag']];
+                $template_data = array_merge($data,$template_data);
+                $template_module = WebsiteTemplate::where('website_id',$template_data['website_id'])->first();
+                $page_type = explode('_', $template_data['ad_tag']);
+                // 页面类型
+                $page = $page_type[1];
+                $ad_places = [];
+                // 模板数据及画布数据
+                $oldtemplate_data = json_decode($template_module['template_data'],true);
+                $oldcanvas_data = json_decode($template_module['canvas_data'],true);
+                if(array_key_exists( $page,$oldtemplate_data['ad'])){
+                    $ad_places = $oldtemplate_data['ad'][$page];
+                }
+                // return Result::success($ad_places);
+                if($page == 'top'){
+                    $ad_place = [
+                        'width' => $oldtemplate_data['ad'][$page]['width'],
+                        'height' => $oldtemplate_data['ad'][$page]['height'],
+                        'name'=>$template_data['name'],   //广告位名称可更改
+                        'price'=>$template_data['price'],   //广告位价格可更改
+                        'introduce'=>$template_data['introduce'],   //广告位介绍可更改
+                        'website_id'=>$oldtemplate_data['ad'][$page]['website_id'],
+                        'thumb'=>$template_data['thumb'],   //广告位默认图可更改
+                        'typeid'=>$oldtemplate_data['ad'][$page]['typeid'],
+                        'ad_tag'=>$oldtemplate_data['ad'][$page]['ad_tag'],
+                        'ad_url'=>$template_data['ad_url'],   //广告位默认链接可更改
+                    ];
+                }else{
+                    foreach($ad_places as $key=>$val){
+                        if($template_data['ad_tag'] == $val['ad_tag']){
+                            $ad_place[$key] = [
+                                'width' => $val['width'],
+                                'height' => $val['height'],
+                                'name'=>$template_data['name'],   //广告位名称可更改
+                                'price'=>$template_data['price'],   //广告位价格可更改
+                                'introduce'=>$template_data['introduce'],   //广告位介绍可更改
+                                'website_id'=>$val['website_id'],
+                                'thumb'=>$template_data['thumb'],   //广告位默认图可更改
+                                'typeid'=>$val['typeid'],
+                                'ad_tag'=>$val['ad_tag'],
+                                'ad_url'=>$template_data['ad_url'],   //广告位默认链接可更改
+
+                            ];
+                            $template_ad = $ad_place[$key];
+                        }else{
+                            $ad_place[$key] = $val;
+                        }
+
+
+                    }
+                    if(array_key_exists( $page,$oldtemplate_data['template'])){
+                        $ad_places_info = $oldtemplate_data['template'][$page];
+                    }
+                    foreach($ad_places_info as $key=>$val){
+                        $ad_info[$key] = $val;
+                        if(array_key_exists('ad',$val) && $val['ad']['ad_tag'] == $template_data['ad_tag']){
+                            $ad_info[$key]['ad'] = $template_ad;
+                            $num = $key;
+                        }
+                    }
+                    $canvas_data = $oldcanvas_data;
+                    foreach($oldcanvas_data['template'][$page] as $key=>$val){
+                        // $canvas_info_ad[$key] = $val;
+                        if(array_key_exists('ad',$val['content']) && $val['content']['ad']['ad_tag'] == $template_data['ad_tag']){
+                            // $canvas_info_ad[$key]['ad'] = $template_ad;
+                            $canvas_ad['content']['ad'] = [
+                                'width' => $val['content']['ad']['width'],
+                                'height' => $val['content']['ad']['height'],
+                                'name'=>$template_data['name'],   //广告位名称可更改
+                                'price'=>$template_data['price'],   //广告位价格可更改
+                                'introduce'=>$template_data['introduce'],   //广告位介绍可更改
+                                'website_id'=>$val['content']['ad']['website_id'],
+                                'thumb'=>$val['content']['ad']['thumb'],   //广告位默认图可更改
+                                'typeid'=>$val['content']['ad']['typeid'],
+                                'ad_tag'=>$val['content']['ad']['ad_tag'],
+                            ];
+                            $canvas_data['template'][$page][$key]['content']['ad'] = $canvas_ad['content']['ad'];
+                        }
+                    }
+                    $oldtemplate_data['template'][$page] = $ad_info;    //模板广告位相关信息已修改
+                }
+                // return Result::success($ad_place);
+
+                //  保存的模板中的广告位相关信息
+                $oldtemplate_data['ad'][$page] = $ad_place;
+
+                    
+                    // Db::rollBack();
+                // }
+                
+                
+                if($page == 'top'){
+                    $canvas_data['topAd'] = $ad_place;
+                }
+                // return Result::success($canvas_data);
+                $template_module['canvas_data'] = json_encode($canvas_data,JSON_UNESCAPED_UNICODE);
+                $template_module['template_data'] = json_encode($oldtemplate_data,JSON_UNESCAPED_UNICODE);
+                $template_result = WebsiteTemplate::where('website_id',$template_data['website_id'])->update([
+                    'canvas_data'=>$template_module['canvas_data'],
+                    'template_data'=>$template_module['template_data'], 
+                ]);
+                if(!$template_result){
+                    Db::rollBack();
+                    return Result::error('同步模板失败!');
+                }
+            }
+            // return Result::success($website_column_arr_id);
+            $Insdata = [
+                'website_id'=>$data['website_id']??'',
+                'typeid'=>$data['typeid']??1,
+                'status'=>$data['status']??2,
+                'name'=>$data['name']??'',
+                'thumb'=>$data['thumb']??'',
+                'introduce'=>$data['introduce']??'',
+                'code'=>$data['code']??'',
+                'price'=>$data['price']??0,
+                'ad_size_id'=>$data['ad_size_id']??0,
+                'ad_url'=>$data['ad_url']??'',
+                'ad_tag'=>$data['ad_tag']??'',
+
+            ];
+            $result = AdPlace::where($where)->update($Insdata);
+            if(!$result){
+                Db::rollBack();
+                return Result::error("更新失败");
+            }
+            Db::commit();
+            return Result::success($result);
+        }catch (\Exception $e) {
+            Db::rollBack();
+            return Result::error($e->getMessage());
+        }
+        // 自助建站广告位-广告位编辑同步模板数据-------fr----end
+        // 11--end
+    }  
+    /**
+     * 删除广告位
+     * @param array $data
+     * @return array
+     */
+    public function delAdPlace(array $data): array
+    {
+        $adList = Ad::where(['pid'=>$data['id']])->get();
+        if($adList->toArray()){
+            return Result::error("广告位里面还有广告,不能删除广告位");
+        }
+        $result = AdPlace::where($data)->delete();
+        if(!$result){
+            return Result::error("删除失败");
+        }
+        return Result::success($result);
+    }
+    /**
+     * @param int $id
+     * @return array
+     */
+    public function getAdPlaceInfo(int $id): array
+    {
+        $adInfo = AdPlace::query()->find($id);
+        if (empty($adInfo)) {
+            return Result::error("没有数据",0);
+        }
+        return Result::success($adInfo->toArray());
+    }
+
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function addTwinAdPlace(array $data): array
+    {
+        Db::beginTransaction();
+        try {
+            //根据传过来的website_id查询网站下的广告位 ad_tag字段组合成一个数组
+            $adTagList = AdPlace::where(['website_id'=>$data['adPlaceList'][0]['website_id']])->pluck('ad_tag')->toArray();
+            //循环传过来的adPlaceList数组取参数的ad_tag字段
+            $adTagNewList = array_column($data['adPlaceList'],'ad_tag');
+            //假设$adTagNewList=[1,2,3],$adTagList=[1,2,4,5] 我要取到$adTagList 里面的4,5
+            $adTagDiffList = array_diff($adTagList,$adTagNewList);
+            //删除AdPlace模型里面的$adTagDiffList 里面的广告位
+            if($adTagDiffList){
+                AdPlace::whereIn('ad_tag',$adTagDiffList)->delete();
+            }
+            if(isset($data['adPlaceList']) && $data['adPlaceList']){
+                foreach ($data['adPlaceList'] as $key=>$val){
+                    $adSizeInfo = AdSize::firstOrCreate(['width'=>$val['width'],'height'=>$val['height']]);
+                    $adPlaceInfo = AdPlace::updateOrCreate(
+                        [ 'ad_tag'=>$val['ad_tag'],'website_id'=>$val['website_id']],
+                        [
+                            'website_id'=>$val['website_id'],
+                            'typeid'=>$val['typeid'],
+                            'status'=>1,
+                            'name'=>$val['name']??'',
+                            'thumb'=>$val['thumb']??'',
+                            'code'=>$val['code']??'',
+                            'ad_size_id'=>$adSizeInfo->id,
+                            'ad_tag'=>$val['ad_tag']??'',
+                            'introduce'=>$val['introduce']??'',
+                            'price'=>$val['price']??0,
+                        ]
+                    );
+                }
+            }
+            Db::commit();
+            return Result::success([]);
+        }catch (\Exception $e){
+            Db::rollBack();
+            return Result::error("创建广告位失败".$e->getMessage(),0);
+        }
+
+    }
+
+}

+ 72 - 0
app/JsonRpc/AdServiceInterface.php

@@ -0,0 +1,72 @@
+<?php
+
+namespace App\JsonRpc;
+interface AdServiceInterface
+{
+    /**
+     * @param array $data
+     * @return string
+     */
+    public function createAd(array $data): array;
+
+    /**
+     * @param array $data
+     * @return mixed
+     */
+    public function getAdList(array $data);
+
+    /**
+     * @param array $data
+     * @return mixed
+     */
+    public function updateAd(array $data);
+
+    /**
+     * @param array $data
+     * @return mixed
+     */
+    public function delAd(array $data);
+
+    /**
+     * @param int $id
+     * @return array
+     */
+    public function getAdInfo(int $id): array;
+
+    /**
+     * @param array $data
+     * @return mixed
+     */
+    public function getAdPlaceList(array $data);
+
+    /**
+     * @param array $data
+     * @return mixed
+     */
+    public function createAdPlace(array $data);
+
+    /**
+     * @param array $data
+     * @return mixed
+     */
+    public function updateAdPlace(array $data);
+
+    /**
+     * @param array $data
+     * @return mixed
+     */
+    public function delAdPlace(array $data);
+
+    /**
+     * @param int $id
+     * @return array
+     */
+    public function getAdPlaceInfo(int $id);
+
+    /**
+     * @param int $id
+     * @return mixed
+     */
+    public function addTwinAdPlace(array $data);
+
+}

+ 129 - 0
app/JsonRpc/AuthorityService.php

@@ -0,0 +1,129 @@
+<?php
+namespace App\JsonRpc;
+use App\Model\Role;
+use App\Model\Menu;
+use App\Model\RoleUser;
+use App\Model\Website;
+use App\Model\WebsiteRoleUser;
+use App\Tools\Result;
+use Hyperf\RpcServer\Annotation\RpcService;
+
+#[RpcService(name: "AuthorityService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
+class AuthorityService implements AuthorityServiceInterface
+{
+
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function getMenuList(array $data): array
+    {
+        $where = [];
+        if(isset($data['id']) && $data['id']){
+            array_push($where,['pid','=',$data['id']]);
+        }
+        $result = Menu::where($where)->get();
+        if (empty($result)) {
+            return Result::error("没有菜单",0,[]);
+        }
+        return Result::success($result);
+    }
+
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function getMenuInfo(array $data): array
+    {
+        $result = Menu::where(['id'=>$data['id']])->first();
+        if (empty($result)) {
+            return Result::error("没有菜单",0,[]);
+        }
+        return Result::success($result);
+    }
+
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function updateMenu(array $data): array
+    {
+        $where = [
+            'id'=>$data['id']
+        ];
+        unset($data['id']);
+        $result = Menu::where($where)->update($data);
+        if($result){
+            return Result::success($data);
+        }else{
+            return Result::error($data);
+        }
+    }
+
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function delMenu(array $data): array
+    {
+        $result = Menu::where(['id'=>$data['id']])->delete();
+        if($result){
+            return Result::success($data);
+        }else{
+            return Result::error($data);
+        }
+    }
+
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function addMenu(array $data): array
+    {
+        $result = Menu::insertGetId($data);
+        if($result){
+            return Result::success($data);
+        }else{
+            return Result::error($data);
+        }
+    }
+
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function getRecursionMenu(array $data): array
+    {
+        //根据角色查询权限信息
+        $roleWhere = [
+            'role_user.user_id'=>$data['user_id']
+        ];
+        $roleInfo = RoleUser::where($roleWhere)
+            ->leftJoin('role', 'role.id', '=', 'role_user.role_id')
+            ->first();
+        if(empty($roleInfo)){
+            return Result::error("没有权限",0);
+        }
+        $roleArr = json_decode($roleInfo['rule']);
+        $result = Menu::whereIn('id',$roleArr)->orderBy("sort","asc")->get();
+        if (empty($result)) {
+            return Result::error("没有菜单",0,[]);
+        }
+        return Result::success($result);
+    }
+
+    /**
+     * 获取所有的权限
+     * @param array $data
+     * @return array
+     */
+    public function getAllMenuList(array $data): array
+    {
+        $result = Menu::get();
+        if($result){
+            return Result::success($result);
+        }else{
+            return Result::error("没有权限",0,[]);
+        }
+    }
+}

+ 53 - 0
app/JsonRpc/AuthorityServiceInterface.php

@@ -0,0 +1,53 @@
+<?php
+
+namespace App\JsonRpc;
+interface AuthorityServiceInterface
+{
+    /**
+     * 菜单列表
+     * @param array $data
+     * @return array
+     */
+    public function getMenuList(array $data): array;
+
+    /**
+     * 获取菜单信息
+     * @param array $data
+     * @return array
+     */
+    public function getMenuInfo(array $data): array;
+
+    /**
+     * 更新菜单
+     * @param array $data
+     * @return array
+     */
+    public function updateMenu(array $data): array;
+
+    /**
+     * 删除菜单
+     * @param array $data
+     * @return array
+     */
+    public function delMenu(array $data): array;
+
+    /**
+     * 创建菜单
+     * @param array $data
+     * @return array
+     */
+    public function addMenu(array $data): array;
+
+    /**
+     * 获取全部菜单列表
+     * @param array $data
+     * @return array
+     */
+    public function getRecursionMenu(array $data): array;
+
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function getAllMenuList(array $data): array;
+}

+ 1317 - 0
app/JsonRpc/ChatService.php

@@ -0,0 +1,1317 @@
+<?php
+
+namespace App\JsonRpc;
+
+use App\Model\ChatFriends;
+use App\Model\ChatGroups;
+use App\Model\ChatGroupsMember;
+use App\Model\ChatRecords;
+use App\Model\ChatTopic;
+use App\Model\ChatTopicsReply;
+
+use App\Model\ChatTopicClass;
+use App\Model\User;
+use App\Tools\PublicData;
+use App\Tools\Result;
+use Hyperf\DbConnection\Db;
+use Hyperf\RpcServer\Annotation\RpcService;
+use Hyperf\Context\ApplicationContext as ContextApplicationContext;
+use Hyperf\Amqp\Producer;
+
+use App\Amqp\Producer\MqProducer;
+
+#[RpcService(name: "ChatService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
+class ChatService implements ChatServiceInterface
+{
+    /**
+     * 获取用户信息
+     * @param array $data
+     * @return array
+     */
+    public function getFriendInfo(array $data): array
+    {
+        $result = ChatFriends::where('friend_id', $data['friend_id'])
+            ->where('user_id', $data['user_id'])
+            ->select(
+                'chat_friends.*',
+                'user.user_name',
+                'user.mobile',
+                'user.nickname',
+                'user.avatar'
+            )
+            ->leftJoin('user', 'user.id', '=', 'chat_friends.friend_id')
+            ->first();
+
+        return Result::success($result);
+    }
+    /**
+     * 搜索好友
+     * @param array $data
+     * @return array
+     */
+    public function searchFriend(array $data): array
+    {
+        $keyword = $data['keyword'];
+        $userId = $data['user_id'];
+
+        $result = User::leftJoin('chat_friends', function ($join) use ($userId) {
+            $join->on('user.id', '=', 'chat_friends.friend_id')
+                ->where('chat_friends.user_id', '=', $userId);
+        })
+            ->where(function ($query) use ($data) {
+                $query->where('user.user_name', 'like', '%' . $data['keyword'] . '%')
+                    ->orWhere('user.nickname', 'like', '%' . $data['keyword'] . '%')
+                    ->orWhere('user.mobile', 'like', '%' . $data['keyword'] . '%');
+            })
+            ->where('user.id', '<>', $userId)
+            ->where('user.type_id', '<>', '20000')
+            ->select('user.*', 'chat_friends.remark as remark', 'chat_friends.id as isfriend')
+            // ->select('user.*', 'chat_friends.friend_id')
+            ->get();
+
+        return Result::success($result);
+
+        if ($result) {
+            return Result::success($result);
+        } else {
+            return Result::error('没有找到相关好友');
+        }
+    }
+    /**
+     * 添加申请
+     * @param array $data
+     * @return array
+     */
+    public function addFriend(array $data): array
+    {
+        Db::beginTransaction();
+        try {
+            // 检查是否存在相同的记录
+            $existingRecord = ChatFriends::where([
+                'user_id' => $data['user_id'],
+                'friend_id' => $data['friend_id'],
+            ])->first();
+
+            if ($existingRecord) {
+                Db::rollBack();
+                if ($existingRecord->status == 1) {
+                    return Result::error("好友申请已存在", 0);
+                } elseif ($existingRecord->status == 2) {
+                    return Result::error("已经是好友关系", 0);
+                }
+            }
+
+            $result = ChatFriends::insertGetId($data);
+            Db::commit();
+        } catch (\Throwable $ex) {
+            Db::rollBack();
+            var_dump($ex->getMessage());
+            return Result::error("添加好友申请失败", 0);
+        }
+        return Result::success("添加成功");
+    }
+
+    /**
+     * 好友列表
+     * @param array $data
+     * @return array
+     */
+    public function getFriendsList(array $data): array
+    {
+        var_dump($data);
+        $result = ChatFriends::leftJoin('user', 'user.id', '=', 'chat_friends.friend_id')
+            ->select(
+                'chat_friends.*',
+                'user.user_name',
+                'user.mobile',
+                'user.nickname',
+                'user.avatar'
+            )
+            ->where([
+                ['user_id', $data['user_id']],
+                ['chat_friends.status', $data['status']], // 明确指定 chat_friends 表中的 status 列
+            ])
+            ->get();
+        return Result::success($result);
+    }
+
+    /**
+     * 好友列表
+     * @param array $data
+     * @return array
+     */
+    public function getFriendsApplyList(array $data): array
+    {
+        var_dump($data);
+        $result = ChatFriends::leftJoin('user', 'user.id', '=', 'chat_friends.user_id')
+            ->select(
+                'chat_friends.*',
+                'user.user_name',
+                'user.mobile',
+                'user.nickname',
+                'user.avatar'
+            )
+            ->where([
+                ['friend_id', $data['friend_id']],
+                ['chat_friends.status', $data['status']], // 明确指定 chat_friends 表中的 status 列
+            ])
+            ->get();
+        return Result::success($result);
+    }
+    /**
+     * 更新申请
+     * @param array $data
+     * @return array
+     */
+    public function applyFriend(array $data): array
+    {
+        $status = $data['status'];
+        //判断同意还是不同意
+        if ($status == 2) {
+            Db::beginTransaction();
+            try {
+                $where = [
+                    'id' => $data['id'],
+                    'status' => 1,
+                ];
+                $fr = ChatFriends::where($where)->first();
+                if (empty($fr)) {
+                    Db::rollBack();
+                    return Result::error("好友申请记录不存在,已经是好友了", 0);
+                }
+                $data['status'] = $status;
+                $data['applied_at'] = date("Y-m-d H:i:s"); //好友审核时间操作人friend_id
+                unset($data['user_id']);
+                ChatFriends::where($where)->update($data);
+                Db::table('chat_friends')
+                    ->updateOrInsert(
+
+                        [
+                            'user_id' => $fr['friend_id'],
+                            'friend_id' => $fr['user_id'],
+                        ],
+                        [
+                            'status' => $status,
+                        ]
+                    );
+
+                // 给对方发送通知
+                $friendId = $fr['user_id'];
+                $userId = $fr['friend_id'];
+                $content = "你们已经成为好友了" . date("Y-m-d H:i:s");
+                $chatRecordsData = [[
+                    'user_id' => $userId,
+                    'receiver_id' => $friendId,
+                    'content' => $content,
+                    'msg_type' => 1,
+                    'is_read' => 1,
+                    'talk_type' => 1,
+                    'action' => 'said',
+
+                ], [
+                    'user_id' => $friendId,
+                    'receiver_id' => $userId,
+                    'content' => $content,
+                    'msg_type' => 1,
+                    'is_read' => 1,
+                    'talk_type' => 1,
+                    'action' => 'recieved',
+
+                ]];
+                ChatRecords::insert($chatRecordsData);
+                Db::commit();
+            } catch (\Throwable $ex) {
+                Db::rollBack();
+                var_dump($ex->getMessage());
+                return Result::error("同意添加为好友失败", 0);
+            }
+            return Result::success(['添加成功']);
+        } else if ($status == 4) { //拒绝
+            Db::beginTransaction();
+            try {
+                $where1 = [
+                    'id' => $data['id'],
+                ];
+                $deletedRows = ChatFriends::where($where1)->delete();
+                if ($deletedRows > 0) {
+                    Db::commit();
+                } else {
+                    // 处理记录不存在的情况
+                    Db::rollBack();
+                    throw new \Exception('记录不存在');
+                }
+            } catch (\Throwable $ex) {
+                Db::rollBack();
+                var_dump($ex->getMessage());
+                return Result::error("拒绝添加好友失败", 0);
+            }
+            return Result::success(['已经拒绝']);
+        }
+    }
+
+    /**
+     * 删除好友
+     * @param array $data
+     * @return array
+     */
+    public function delFriend(array $data): array
+    {
+        Db::beginTransaction();
+        try {
+            $where = [
+                'user_id' => $data['user_id'],
+                'friend_id' => $data['friend_id'],
+            ];
+            $orwhere = [
+                'user_id' => $data['friend_id'],
+                'friend_id' => $data['user_id'],
+            ];
+
+            // 使用闭包来确保正确的 OR 关系
+            $result = ChatFriends::where(function ($query) use ($where) {
+                $query->where($where);
+            })
+                ->orWhere(function ($query) use ($orwhere) {
+                    $query->where($orwhere);
+                })
+                ->delete();
+
+            var_dump($result, '-0------------------');
+
+            $wherechat = [
+                'user_id' => $data['user_id'],
+                'receiver_id' => $data['friend_id'],
+            ];
+            $orwherechat = [
+                'user_id' => $data['friend_id'],
+                'receiver_id' => $data['user_id'],
+            ];
+
+            // 使用闭包来确保正确的 OR 关系
+            ChatRecords::where(function ($query) use ($wherechat) {
+                $query->where($wherechat);
+            })
+                ->orWhere(function ($query) use ($orwherechat) {
+                    $query->where($orwherechat);
+                })
+                ->delete();
+
+            Db::commit();
+            return Result::success("删除成功");
+        } catch (\Exception $e) {
+            Db::rollback();
+            return Result::error($e->getMessage());
+        }
+    }
+    /**
+     * 是否好友
+     * @param array $data
+     * @return array
+     */
+    public function isFriend(array $data): array
+    {
+        $where = [
+            'user_id' => $data['user_id'],
+            'friend_id' => $data['friend_id'],
+        ];
+        $result = ChatFriends::where($where)->first();
+        if ($result) {
+            return Result::success(true);
+        } else {
+            return Result::error('不是好友');
+        }
+    }
+
+    /**
+     * 添加聊天内容
+     * @param array $data
+     * @return array
+     */
+    public function addChatRecords(array $data): array
+    {
+        Db::beginTransaction();
+        try {
+            //添加会话内容
+            $ChatRecordsData = [[
+                'msg_type' => $data['msg_type'] ?? 0,
+                'user_id' => $data['user_id'] ?? 0,
+                'is_read' => $data['is_read'] ?? 0,
+                'talk_type' => $data['talk_type'] ?? 0,
+                'action' => $data['action'] ?? 0,
+                'group_receiver_id' => $data['group_receiver_id'] ?? 0,
+                'content' => $data['content'] ?? '',
+                'receiver_id' => $data['receiver_id'] ?? '',
+            ]];
+            ChatRecords::insert($ChatRecordsData);
+            Db::commit();
+        } catch (\Throwable $ex) {
+            Db::rollBack();
+            var_dump($ex->getMessage());
+            return Result::error("存储消息失败", 0);
+        }
+        return Result::success([]);
+    }
+
+    /**
+     * 修改好友备注
+     * @param array $data
+     * @return array
+     */
+    public function updateFriend(array $data): array
+    {
+        $result = ChatFriends::where([
+            'user_id' => $data['user_id'],
+            'friend_id' => $data['friend_id'],
+            'status' => 2,
+        ])->update(['remark' => $data['remark']]);
+        if ($result) {
+            return Result::success('修改成功');
+        } else {
+            return Result::error('修改失败');
+        }
+    }
+    /**
+     * 会话列表
+     * @param array $data
+     * @return array
+     */
+    public function getConversation(array $data): array
+    {
+        $userId = $data['user_id'];
+        $unreadMessages = ChatRecords::where('user_id', $userId)
+            ->where('is_read', 0)
+            // ->where('action', 'recieved')
+            ->leftJoin('user', 'chat_records.receiver_id', '=', 'user.id')
+            ->leftJoin('chat_groups', 'chat_records.receiver_id', '=', 'chat_groups.id')
+            ->select(
+                'receiver_id',
+                DB::raw('COUNT(receiver_id) AS num'),
+                DB::raw('MAX(chat_records.id) AS max_id'),
+                'user.user_name as user_name',
+                'user.avatar as avatar',
+                'user.mobile as mobile',
+                'chat_groups.group_name as group_name'
+            )
+            ->groupBy('receiver_id')
+            ->orderBy(DB::raw('MAX(chat_records.id)'), 'desc')
+            ->get();
+
+        // 查询已读消息,并将 num 字段设置为 0
+        $readMessages = ChatRecords::where('user_id', $userId)
+            ->where('is_read', 1)
+            // ->where('action', 'recieved')
+            ->leftJoin('user', 'chat_records.receiver_id', '=', 'user.id')
+            ->leftJoin('chat_groups', 'chat_records.receiver_id', '=', 'chat_groups.id')
+            ->select(
+                'receiver_id',
+                DB::raw('0 AS num'),
+                DB::raw('MAX(chat_records.id) AS max_id'),
+                'user.user_name as user_name',
+                'user.avatar as avatar',
+                'user.mobile as mobile',
+                'chat_groups.group_name as group_name'
+            )
+            ->groupBy('receiver_id')
+            ->orderBy(DB::raw('MAX(chat_records.id)'), 'desc')
+            ->get();
+
+        // 合并未读消息和已读消息
+        // $allMessages = array_merge($unreadMessages->toArray(), $readMessages->toArray());
+        // 使用关联数组去重,并优先保留未读消息
+        $allMessages = [];
+        foreach ($unreadMessages as $message) {
+            $allMessages[$message['receiver_id']] = $message->toArray();
+        }
+
+        foreach ($readMessages as $message) {
+            if (strlen($message['receiver_id']) === 18) {
+            } else {
+                // $allMessages[$message['receiver_id']] = $message->toArray();
+            }
+            if (!isset($allMessages[$message['receiver_id']])) {
+                $allMessages[$message['receiver_id']] = $message->toArray();
+            }
+        }
+
+        // var_dump($allMessages);
+        // 处理结果,判断是否是群聊
+        $formattedMessages = [];
+        foreach ($allMessages as $message) {
+            $formattedMessage = [
+                'receiver_id' => $message['receiver_id'],
+                'num' => $message['num'],
+                'max_id' => $message['max_id'],
+                'user_name' => $message['user_name'],
+                'avatar' => $message['avatar'],
+                'mobile' => $message['mobile'],
+                'group_name' => $message['group_name'],
+            ];
+
+            if (strlen($message['receiver_id']) === 18) { // 判断是否是 UUID
+                $formattedMessage['type'] = 'group';
+                $formattedMessage['name'] = $message['group_name'];
+                $formattedMessage['is_group'] = 1;
+            } else {
+                $formattedMessage['type'] = 'user';
+                $formattedMessage['name'] = $message['user_name'];
+                $formattedMessage['is_group'] = 0;
+            }
+
+            $formattedMessages[] = $formattedMessage;
+        }
+
+        if (!empty($formattedMessages)) {
+            return Result::success($formattedMessages);
+        } else {
+            return Result::error('没有消息');
+        }
+    }
+    /**
+     * 获取聊天记录
+     * @param array $data
+     * @return array
+     */
+    public function getChatRecords(array $data): array
+    {
+        var_dump('222222');
+        Db::beginTransaction();
+        try {
+            $userId = $data['user_id'];
+            $friendId = $data['friend_id'];
+            $result = ChatRecords::where(function ($query) use ($userId, $friendId) {
+                $query->where('user_id', $userId)->where('receiver_id', $friendId);
+            })
+                // ->orWhere(function ($query) use ($userId, $friendId) {
+                //     $query->where('user_id', $friendId)->where('receiver_id', $userId);
+                // })
+                ->leftJoin('user as u1', 'chat_records.user_id', '=', 'u1.id')
+                ->leftJoin('user as u2', 'chat_records.receiver_id', '=', 'u2.id')
+                ->select('chat_records.*', 'u1.user_name as user_id_name', 'u1.avatar as user_avatar', 'u2.user_name as receiver_id_name', 'u2.avatar as receiver_avatar')
+                ->orderBy('id', 'asc')->paginate(100, ['*'], 'page', $data['page'] ?? 1);
+            //更新聊天记录已读
+            ChatRecords::where('user_id', $userId)
+                ->where('receiver_id', $friendId)
+                ->where('is_read', 0)
+                ->where('talk_type', 1)
+                ->update(['is_read' => 1]);
+            Db::commit();
+        } catch (\Throwable $ex) {
+            Db::rollBack();
+            var_dump($ex->getMessage());
+            return Result::error("获取聊天记录失败", 0);
+        }
+        if ($result) {
+            return Result::success($result);
+        } else {
+            return Result::error('没有聊天记录');
+        }
+    }
+    /**
+     * 获取群聊天记录
+     * @param array $data
+     * @return array
+     */
+    public function getGroupChatRecords(array $data): array
+    {
+        Db::beginTransaction();
+        try {
+            $userId = $data['user_id'];
+            $group_id = $data['group_id'];
+            $result = ChatRecords::where('receiver_id', $group_id)
+                ->where('user_id', $userId)
+                ->leftJoin('user as u1', 'chat_records.user_id', '=', 'u1.id')
+                ->leftJoin('user as u2', 'chat_records.group_receiver_id', '=', 'u2.id')
+                ->select('chat_records.*', 'u1.user_name as user_id_name', 'u1.avatar as user_avatar', 'u2.user_name as receiver_id_name', 'u2.avatar as receiver_avatar')
+                ->orderBy('id', 'asc')->paginate(100, ['*'], 'page', $data['page'] ?? 1);
+            //更新群聊天记录
+            ChatRecords::where('receiver_id', $group_id)
+                ->where('user_id', $userId)
+                ->update(['is_read' => 1]);
+            Db::commit();
+        } catch (\Throwable $ex) {
+            Db::rollBack();
+            var_dump($ex->getMessage());
+            return Result::error("获取群聊天记录失败", 0);
+        }
+        if ($result) {
+            return Result::success($result);
+        } else {
+            return Result::error('没有群消息');
+        }
+    }
+    /**
+     * 群组 - 创建群
+     * @param array $data
+     * @return array
+     */
+    public function addGroup(array $data): array
+    {
+        Db::beginTransaction();
+        try {
+            //创建群
+            $groupData = [
+                'id' => PublicData::uuid(),
+                'creator_id' => $data['user_id'],
+                'group_name' => $data['group_name'],
+                'avatar' => $data['avatar'] ?? '',
+                'profile' => $data['profile'] ?? '',
+            ];
+            ChatGroups::insert($groupData);
+            //创建群用户
+            $groupMemberData = [];
+            $groupChatData = [];
+            if ($data['group_member']) {
+                foreach ($data['group_member'] as $key => $val) {
+                    $groupMemberData[$key] = [
+                        'id' => PublicData::uuid(),
+                        'group_id' => $groupData['id'],
+                        'user_id' => $val,
+                        'leader' => $data['user_id'] == $val ? 2 : 0,
+                    ];
+
+                    $groupChatData[$key] = [
+                        'user_id' => $val,
+                        'receiver_id' => $groupData['id'],
+                        'content' => '创建群' . Date('Y-m-d H:i:s'),
+                        'msg_type' => 1,
+                        'is_read' => 0,
+                        'talk_type' => 2,
+                        'action' => 'recieved',
+                        'group_receiver_id' => $data['user_id'],
+                    ];
+                }
+            }
+            ChatGroupsMember::insert($groupMemberData);
+            //插入一条消息
+            ChatRecords::insert($groupChatData);
+            Db::commit();
+        } catch (\Throwable $ex) {
+            Db::rollBack();
+            var_dump($ex->getMessage());
+            return Result::error("创建群失败", 0);
+        }
+        return Result::success([]);
+    }
+    /**
+     * 群组 - 加入群
+     * @param array $data
+     * @return array
+     */
+    public function addGroupMember(array $data): array
+    {
+        $result = ChatGroupsMember::where(['group_id' => $data['group_id'], 'user_id' => $data['user_id']])->update(['leader' => 2]);
+
+        $groupChatData = [
+            'user_id' => $data['user_id'],
+            'receiver_id' => $data['group_id'],
+            'content' => '加入群' . Date('Y-m-d H:i:s'),
+            'msg_type' => 1,
+            'is_read' => 0,
+            'talk_type' => 2,
+            'action' => 'recieved',
+            'group_receiver_id' => $data['user_id'],
+        ];
+        ChatRecords::insert($groupChatData);
+
+        if ($result) {
+            return Result::success('修改成功');
+        } else {
+            return Result::error('修改失败');
+        }
+    }
+    /**
+     * 群组 - 群信息
+     * @param array $data
+     * @return array
+     */
+    public function getGroupInfo(array $data): array
+    {
+        $result = ChatGroups::where(['chat_groups.id' => $data['group_id']])
+            ->join('user', 'chat_groups.creator_id', '=', 'user.id')
+            ->select('chat_groups.*', 'user.user_name as user_name', 'user.avatar as avatar')
+            ->first();
+        return Result::success($result);
+    }
+    /**
+     * 群组 - 删除群
+     * @param array $data
+     * @return array
+     */
+    public function delGroup(array $data): array
+    {
+        Db::beginTransaction();
+        try {
+            $groupMember = ChatGroupsMember::where(['group_id' => $data['group_id']])->delete();
+            $result = ChatGroups::where(['id' => $data['group_id']])->delete();
+            $result = ChatRecords::where(['receiver_id' => $data['group_id']])->delete();
+            //群聊记录
+            Db::commit();
+        } catch (\Throwable $ex) {
+            Db::rollBack();
+            var_dump($ex->getMessage());
+            return Result::error("删除群失败", 0);
+        }
+
+        if ($result) {
+            return Result::success('删除成功');
+        } else {
+            return Result::error('删除失败');
+        }
+    }
+    /**
+     * 群组 - 退出群
+     * @param array $data
+     * @return array
+     */
+    public function quitGroup(array $data): array
+    {
+        $result = ChatGroupsMember::where(['group_id' => $data['group_id'], 'user_id' => $data['user_id']])->delete();
+        ChatRecords::where(['receiver_id' => $data['group_id'], 'user_id' => $data['user_id']])->delete();
+
+        if ($result) {
+            return Result::success('退出成功');
+        } else {
+            return Result::error('退出失败');
+        }
+    }
+    /**
+     * 群组 - 我的群
+     * @param array $data
+     * @return array
+     */
+    public function getGroupList(array $data): array
+    {
+        $result = ChatGroupsMember::where(['user_id' => $data['user_id']])
+            ->leftJoin('chat_groups', 'chat_groups_members.group_id', '=', 'chat_groups.id')
+            ->select('chat_groups.*', 'chat_groups_members.group_id as group_id')
+            ->orderBy('chat_groups.id', 'desc')
+            ->paginate(100, ['*'], 'page', $data['page'] ?? 1);
+        return Result::success($result);
+    }
+    /**
+     * 群组 - 删除群成员
+     * @param array $data
+     * @return array
+     */
+    public function delGroupMembers(array $data): array
+    {
+        $result = ChatGroupsMember::where(['group_id' => $data['group_id'], 'user_id' => $data['user_id']])->delete();
+        ChatRecords::where(['receiver_id' => $data['group_id'], 'user_id' => $data['user_id']])->delete();
+        if ($result) {
+            return Result::success('删除成功');
+        } else {
+            return Result::error('删除失败');
+        }
+    }
+    /**
+     * 群组 - 更新群
+     * @param array $data
+     * @return array
+     */
+    public function updateGroup(array $data): array
+    {
+        // 提取需要的字段
+        $groupId = $data['group_id'];
+        $groupName = $data['group_name'] ?? null;
+        $profile = $data['profile'] ?? null;
+        $avatar = $data['avatar'] ?? null;
+        // 查询群组
+        $group = ChatGroups::find($groupId);
+        if (!$group) {
+            return Result::error('群组不存在');
+        }
+        // 更新群组信息
+        if ($groupName !== null) {
+            $group->group_name = $groupName;
+        }
+        if ($profile !== null) {
+            $group->profile = $profile;
+        }
+        if ($avatar !== null) {
+            $group->avatar = $avatar;
+        }
+        // 保存更改
+        if ($group->save()) {
+            return Result::success($group->toArray());
+        } else {
+            return Result::error('更新群组信息失败');
+        }
+    }
+    /**
+     * 群组 - 删除群
+     * @param array $data
+     * @return array
+     */
+    public function deleteGroup(array $data): array
+    {
+        $result = ChatGroups::where(['id' => $data['group_id']])->delete();
+        if ($result) {
+            return Result::success('删除成功');
+        } else {
+            return Result::error('删除失败');
+        }
+    }
+    /**
+     * 群组 - 群用户列表
+     * @param array $data
+     * @return array
+     */
+    public function getGroupMembers(array $data): array
+    {
+        $groupMember = ChatGroupsMember::where(['group_id' => $data['group_id']])
+            ->leftJoin('user as u1', 'chat_groups_members.user_id', '=', 'u1.id')
+            ->leftJoin('chat_groups as c1', 'c1.id', '=', 'chat_groups_members.group_id')
+            ->select('chat_groups_members.*', 'u1.user_name', 'u1.avatar', 'c1.group_name as group_name')
+            ->orderBy('id', 'desc')
+            ->get();
+        return Result::success($groupMember);
+    }
+
+    /**
+     * 群组 - 添加群
+     * @param array $data
+     * @return array
+     */
+    public function joinGroup(array $data): array
+    {
+        $group = ChatGroups::where(['id' => $data['group_id']])->first();
+        return Result::success($group);
+        if (empty($group)) {
+            return Result::error("群不存在", 0);
+        }
+        $groupMember = ChatGroupsMember::where(['user_id' => $data['user_id'], 'group_id' => $data['group_id']])->first();
+        if ($groupMember) {
+            return Result::error("已加入群", 0);
+        }
+        $info = [
+            'id' => PublicData::uuid(),
+            'user_id' => $data['user_id'],
+            'group_id' => $data['group_id'],
+        ];
+        $result = ChatGroupsMember::insert($info);
+        var_dump($result, '--------------------');
+        if ($result) {
+            return Result::success($data);
+        } else {
+            return Result::error($data);
+        };
+    }
+    /**
+     * 话题 - 列表
+     * @param array $data
+     * @return array
+     */
+    public function getTopicsList(array $data): array
+    {
+
+        $where = [];
+        if (!empty($data['title'])) {
+            $where[] = ['chat_topics.title', 'like', '%' . $data['title'] . '%'];
+        }
+        // 不是看自己的话题
+        if (!empty($data['user_id_search'])) {
+            $where[] = ['chat_topics.user_id', '=', $data['user_id_search']];
+        }
+        if (!empty($data['status'])) {
+            $where[] = ['chat_topics.status', '=', $data['status']];
+        }
+        if (!empty($data['type'])) {
+            $where[] = ['chat_topics.type', '=', $data['type']];
+        }
+        if (!empty($data['nickname'])) {
+            $where[] = ['user.nickname', '=', $data['nickname']];
+        }
+        var_dump($where);
+        $result = ChatTopic::where($where)
+            ->leftJoin('user', 'user.id', '=', 'chat_topics.user_id')
+            ->leftJoin('chat_topics_reply', 'chat_topics.id', '=', 'chat_topics_reply.topic_id')
+            ->leftJoin('chat_topic_class', 'chat_topics.type', '=', 'chat_topic_class.id')
+            ->select(
+                'chat_topics.*',
+                'chat_topic_class.topicname as type_name',
+                'user.nickname',
+                'user.avatar',
+                'user.user_name',
+                DB::raw('count(chat_topics_reply.id) as num')
+            )
+            ->groupBy('chat_topics.id')
+            ->orderBy('chat_topics.id', 'desc')
+            ->paginate($data['page_size'], ['*'], 'page', $data['page'] ?? 1);
+        return Result::success($result);
+    }
+    public function getTopic(array $data): array
+    {
+        $result = ChatTopic::where(['id' => $data['id']])->first();
+        return Result::success($result);
+    }
+
+    public function addTopic(array $data): array
+    {
+        $chattopic = [];
+        Db::beginTransaction();
+        try {
+            $data['created_at'] = date('Y-m-d H:i:s');
+            $data['updated_at'] = date('Y-m-d H:i:s');
+            if ($data['type_id'] != 10000) {
+                $this->sendMessage([
+                    'talk_type' => 300,
+                    'title' => $data['title'],
+                    'content' => '提交了审核',
+                    'messageType' => 4,
+                ]);
+                $data['status'] = 1;
+            } else {
+                $data['status'] = 2;
+                if ($data['is_group'] == 1) {
+                    $group_id = PublicData::uuid();
+                    $groupData = [
+                        'id' => $group_id,
+                        'creator_id' => $data['user_id'],
+                        'group_name' => $data['group_name'] ?? '',
+                        'profile' => '',
+                    ];
+                    $groupResult = ChatGroups::insertGetId($groupData);
+                    $groupMemberData = [
+                        'id' => PublicData::uuid(),
+                        'user_id' => $data['user_id'],
+                        'group_id' => $group_id,
+                        'leader' => 2,
+                    ];
+                    $groupMemberResult = ChatGroupsMember::insertGetId($groupMemberData);
+                    //更新result的 group_id
+                    $datas['group_id'] = $group_id;
+                    ChatTopic::where(['id' => $data['id']])->update($datas);
+
+                    //插入一条消息
+                    $chatRecordsData = [
+                        'user_id' => $data['user_id'],
+                        'receiver_id' => $group_id,
+                        'content' => '我创建了一个群' . Date('Y-m-d H:i:s'),
+                        'msg_type' => 1,
+                        'is_read' => 0,
+                        'talk_type' => 2,
+                        'action' => 'said',
+                        'group_receiver_id' => $data['user_id'],
+                    ];
+                    ChatRecords::insert($chatRecordsData);
+                }
+            }
+            unset($data['type_id']);
+            $result = ChatTopic::insertGetId($data);
+            $chattopic = Chattopic::find($result);
+            Db::commit();
+        } catch (\Exception $e) {
+            Db::rollBack();
+            return Result::error($data, $e->getMessage());
+        }
+        return Result::success($chattopic);
+    }
+    public function applyTopic(array $data): array
+    {
+        date_default_timezone_set('Asia/Shanghai');
+        db::beginTransaction();
+        try {
+            $query = ChatTopic::where(['id' => $data['id']]);
+            $topdata = $query->first();
+
+            $result = ChatTopic::where(['id' => $data['id']])->update(['status' => $data['status']]);
+            // var_dump($data, 'tedst111111111111111');
+            // var_dump(date('Y-m-d H:i:s'), 'tedst111111111111111');
+            $creatter = $topdata['user_id'];
+            if ($data['status'] == 2 && $topdata['is_group'] == 1) {
+                $group_id = '';
+                if (empty($topdata['group_id'])) {
+                    $group_id = PublicData::uuid();
+                    $groupData = [
+                        'id' => $group_id,
+                        'creator_id' => $topdata['user_id'],
+                        'group_name' => $topdata['group_name'] ?? '',
+                        'profile' => '',
+                    ];
+                    $groupResult = ChatGroups::insertGetId($groupData);
+                    $groupMemberData = [
+                        'id' => PublicData::uuid(),
+                        'user_id' => $topdata['user_id'],
+                        'group_id' => $group_id,
+                        'leader' => 2,
+                    ];
+                    $groupMemberResult = ChatGroupsMember::insertGetId($groupMemberData);
+                } else {
+                    $group_id = $topdata['group_id'];
+                }
+
+                //更新result的 group_id
+                $datas['group_id'] = $group_id;
+                ChatTopic::where(['id' => $data['id']])->update($datas);
+
+                //插入一条消息
+                $chatRecordsData = [
+                    'user_id' => $topdata['user_id'],
+                    'receiver_id' => $group_id,
+                    'content' => '我创建了一个群' . Date('Y-m-d H:i:s'),
+                    'msg_type' => 1,
+                    'is_read' => 0,
+                    'talk_type' => 2,
+                    'action' => 'said',
+                    'group_receiver_id' => $topdata['user_id'],
+                ];
+                ChatRecords::insert($chatRecordsData);
+            } elseif ($data['status'] == 3) {
+                if (isset($topdata['group_id']) && !empty($topdata['group_id'])) {
+                    ChatRecords::where('receiver_id', $topdata['group_id'])->delete();
+                    ChatGroupsMember::where('group_id', $topdata['group_id'])
+                        ->where([["user_id", '!=', $creatter]])->delete();
+                }
+            }
+            if ($data['status'] == 2) {
+                $this->sendMessage([
+                    'talk_type' => 301,
+                    'title' => $topdata['title'],
+                    'content' => '审核通过',
+                    'messageType' => 4,
+                    'user_id' => $topdata['user_id'],
+                ]);
+            } else if ($data['status'] == 3) {
+                $this->sendMessage([
+                    'talk_type' => 301,
+                    'title' => $topdata['title'],
+                    'content' => '审核拒绝',
+                    'messageType' => 4,
+                    'user_id' => $topdata['user_id'],
+                ]);
+            }
+            Db::commit();
+            if ($result) {
+                return Result::success($data);
+            } else {
+                return Result::error($data);
+            }
+        } catch (\Exception $e) {
+            Db::rollBack();
+            return Result::error($data, $e->getMessage());
+        }
+        if (empty($data['id'])) {
+            return Result::error('id不能为空');
+        }
+    }
+    public function updateTopic(array $data): array
+    {
+        if (empty($data['id'])) {
+            return Result::error('id不能为空');
+        }
+        if ($data['type_id'] != 10000) {
+            $this->sendMessage([
+                'talk_type' => 300,
+                'title' => $data['title'],
+                'content' => '提交了审核',
+                'messageType' => 4,
+            ]);
+            $data['status'] = 1;
+        }
+
+        $result = ChatTopic::where(['id' => $data['id']])->update($data);
+        if ($result) {
+            return Result::success($data);
+        } else {
+            return Result::error($data);
+        };
+    }
+    public function delTopic(array $data): array
+    {
+        $result = ChatTopic::where(['id' => $data['id']])->delete();
+        //删除群和成员和聊天
+        //删除话题回复
+        if ($result) {
+            return Result::success($data);
+        } else {
+            return Result::error('删除失败');
+        };
+    }
+    public function getTopicInfo(array $data): array
+    {
+        $result = ChatTopic::where(['chat_topics.id' => $data['id']])
+            ->leftJoin('user', 'user.id', '=', 'chat_topics.user_id')
+            ->leftJoin('chat_topic_class', 'chat_topic_class.id', '=', 'chat_topics.type')
+            ->select('chat_topics.*', 'user.nickname', 'user.avatar', 'user.user_name', 'chat_topic_class.topicname')
+            ->first();
+        return Result::success($result);
+    }
+    public function addReply(array $data): array
+    {
+        $result = ChatTopic::where(['id' => $data['id']])->get();
+        if ($result) {
+            $replydata['created_at'] = date('Y-m-d H:i:s');
+            $replydata['updated_at'] = date('Y-m-d H:i:s');
+            $replydata['content'] = $data['content'];
+            $replydata['user_id'] = $data['user_id'];
+            $replydata['topic_id'] = $data['id'];
+            $re = ChatTopicsReply::insertGetId($replydata);
+        }
+        if ($re) {
+            return Result::success($data);
+        } else {
+            return Result::error($data);
+        }
+    }
+    public function getTopicReply(array $data): array
+    {
+        var_dump($data);
+        $result = ChatTopicsReply::where(['topic_id' => $data['id']])
+            ->leftJoin('user', 'user.id', '=', 'chat_topics_reply.user_id')
+            ->select('chat_topics_reply.*', 'user.nickname', 'user.avatar', 'user.user_name')
+            ->orderBy('chat_topics_reply.id', 'desc')
+            ->paginate($data['page_size'], ['*'], 'page', $data['page'] ?? 1);
+        return Result::success($result);
+    }
+
+    /**
+     *  修改群成员
+     * @param array $data
+     * @return array
+     */
+    public function updateGroupMembers(array $data): array
+    {
+        DB::beginTransaction();
+        try {
+            $where = [
+                'group_id' => $data['group_id'],
+            ];
+            $group_id = $data['group_id'];
+            //先删除群成员
+            $result = ChatGroupsMember::where($where)
+                ->where([["user_id", '!=', $data['user_id']]])->delete();
+            $groupMemberData = [];
+            foreach ($data['group_member'] as $value) {
+                $groupMemberData[] = [
+                    'id' => PublicData::uuid(),
+                    'user_id' => $value,
+                    'group_id' => $group_id,
+                    'leader' => 0,
+                ];
+            }
+            $result = ChatGroupsMember::where($where)->insert($groupMemberData);
+            //删除会话踢出群的会话信息
+            // var_dump("data",$data);
+            //字符串转数组,
+            $groupIdList = $data['group_member'];
+            array_push($groupIdList, $data['user_id']);
+            // var_dump("几个",$groupIdList);
+            ChatRecords::whereNotIn('receiver_id', $groupIdList)->delete();
+
+            // 获取群信息
+            $groupInfo = ChatGroups::where(['id' => $group_id])->first();
+            DB::commit();
+            return Result::success($groupInfo);
+        } catch (\Exception $e) {
+            DB::rollBack();
+            return Result::error($data, $e->getMessage());
+        }
+    }
+    public function clearGroupRecords(array $data): array
+    {
+        $result = ChatRecords::where(['user_id' => $data['user_id'], 'receiver_id' => $data['id']])->delete();
+        if ($result) {
+            return Result::success("删除成功");
+        } else {
+            return Result::error("删除失败");
+        }
+    }
+    public function recallRecord(array $data): array
+    {
+        //获取所有id,并删除掉
+        $ids = array_column($data, 'id');
+        $result = ChatRecords::whereIn('id', $ids)->delete();
+        if ($result) {
+            return Result::success("删除成功");
+        } else {
+            return Result::error("删除失败");
+        }
+    }
+    public function clearRecords(array $data): array
+    {
+        $result = ChatRecords::where(['user_id' => $data['user_id'], 'receiver_id' => $data['friend_id']])->delete();
+        if ($result) {
+            return Result::success("删除成功");
+        } else {
+            return Result::error("删除失败");
+        }
+    }
+    public function getRecordByContent(array $data): array
+    {
+        $result = ChatRecords::where(['chat_records.user_id' => $data['user_id'], 'chat_records.receiver_id' => $data['receiver_id'], 'chat_records.content' => $data['content']])
+            ->orWhere(['chat_records.receiver_id' => $data['user_id'], 'chat_records.user_id' => $data['receiver_id'], 'chat_records.content' => $data['content']])
+            ->all();
+        if ($result) {
+            return Result::success($result['id']);
+        } else {
+            return Result::error("没有数据");
+        }
+    }
+    public function getRecord(array $data): array
+    {
+        $result = ChatRecords::where(['chat_records.id' => $data['id']])
+            ->leftJoin('user', 'user.id', '=', 'chat_records.user_id')
+            ->leftJoin('user as user2', 'user2.id', '=', 'chat_records.receiver_id')
+            ->select('chat_records.*', 'user.nickname', 'user.avatar', 'user.user_name', 'user2.nickname as receiver_nickname', 'user2.avatar as receiver_avatar')
+            ->get();
+        return Result::success($result);
+    }
+    public function delReply(array $data): array
+    {
+        $result = ChatTopicsReply::where(['id' => $data['id']])->delete();
+        if ($result) {
+            return Result::success("删除成功");
+        } else {
+            return Result::error("删除失败");
+        }
+    }
+    public function delAllReply(array $data): array
+    {
+        $result = ChatTopicsReply::where(['topic_id' => $data['topicid']])->delete();
+        if ($result) {
+            return Result::success("删除成功");
+        } else {
+            return Result::error("删除失败");
+        }
+    }
+    public function getTopicsListAdmin(array $data): array
+    {
+        $where = [];
+        if (!empty($data['type'])) {
+            $where['type'] = $data['type'];
+        }
+        if (!empty($data['title'])) {
+            $where['title'] = $data['title'];
+        }
+        $result = ChatTopic::where($where)
+            ->leftJoin('user', 'user.id', '=', 'chat_topics.user_id')
+            ->select('chat_topics.*', 'user.nickname', 'user.avatar', 'user.user_name')
+            ->paginate($data['page_size'], ['*'], 'page', $data['page'] ?? 1);
+        return Result::success($result);
+    }
+    public function getTopicClassList(array $data): array
+    {
+        $where = [];
+        if (!empty($data['topicname'])) {
+            $where[] = ['topicname', 'like', '%' . $data['topicname'] . '%'];
+        }
+        $result = ChatTopicClass::where($where)->orderBy('updated_at', 'desc')
+            ->paginate($data['page_size'], ['*'], 'page', $data['page'] ?? 1);
+        return Result::success($result);
+    }
+    public function deleteTopicClass(array $data): array
+    {
+
+        $result = ChatTopicClass::where(['id' => $data['id']])->delete();
+        if ($result) {
+            return Result::success("删除成功");
+        }
+        return Result::error("删除失败");
+    }
+
+    public function updateTopicClass(array $data): array
+    {
+        //topicname
+        if (!empty($data['topicname'])) {
+
+            $re = ChatTopicClass::where(['topicname' => $data['topicname']])->first();
+            if ($re) {
+                return Result::error("话题分类已存在");
+            }
+        }
+        $result = ChatTopicClass::where(['id' => $data['id']])->update([
+            'topicname' => $data['topicname'],
+            'updated_at' => date('Y-m-d H:i:s'),
+        ]);
+        if ($result) {
+            return Result::success("修改成功");
+        }
+        return Result::error("修改失败");
+    }
+    public function addTopicClass(array $data): array
+    {
+        //topicname
+        if (!empty($data['topicname'])) {
+
+            $re = ChatTopicClass::where(['topicname' => $data['topicname']])->first();
+            if ($re) {
+                return Result::error("话题分类已存在");
+            }
+        }
+        $result = ChatTopicClass::insert($data);
+        if ($result) {
+            return Result::success("添加成功");
+        }
+        return Result::error("添加失败");
+    }
+    /**
+     * 获取话题分类信息
+     * @param array $data
+     * @return array
+     */
+    public function getTopicClassInfo(array $data): array
+    {
+        $result = ChatTopicClass::where(['id' => $data['id']])->first();
+        return Result::success($result);
+    }
+
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function getBusinessDistrictList(array $data): array
+    {
+        $query = ChatGroupsMember::Join('chat_topics', 'chat_topics.group_id', '=', 'chat_groups_members.group_id')
+            ->leftJoin('chat_topic_class', 'chat_topic_class.id', '=', 'chat_topics.type')
+            ->where(['chat_groups_members.user_id' => $data['user_id']])
+            ->when($data, function ($query) use ($data) {
+                if (!empty($data['type'])) {
+                    $query->where(['chat_topics.type' => $data['type']]);
+                }
+                if (!empty($data['title'])) {
+                    $query->where('chat_topics.title', 'like', '%' . $data['title'] . '%');
+                }
+                if (!empty($data['created_at'])) {
+                    $query->whereDate('chat_topics.created_at', $data['created_at']);
+                }
+            })
+            ->select(
+                'chat_topics.id',
+                'chat_topics.title',
+                'chat_topics.author',
+                'chat_topics.created_at',
+                'chat_topics.updated_at',
+                'chat_topic_class.topicname',
+            )
+            ->orderBy('chat_topics.created_at', 'desc');
+        $total = $query->count();
+        $list = $query->forPage($data['page'], $data['page_size'])->get();
+        $result = [
+            'list' => $list,
+            'total' => $total,
+            'page' => intval($data['page']),
+            'page_size' => intval($data['page_size']),
+        ];
+        return  Result::success($result);
+    }
+
+    /**
+     * 发送消息
+     * @param array $messageData
+     * @return void
+     */
+    public function sendMessage($messageData)
+    {
+        $msg = [
+            'talk_type' => $messageData['talk_type'],
+            'title' => $messageData['title'],
+            'content' => $messageData['content'],
+            'messageType' => $messageData['messageType'],
+            'user_id' => $messageData['user_id'] ?? '',
+            'time' => microtime(),
+        ];
+        $message = new MqProducer($msg);
+        $producer = ContextApplicationContext::getContainer()->get(Producer::class);
+        $producer->produce($message);
+    }
+}

+ 227 - 0
app/JsonRpc/ChatServiceInterface.php

@@ -0,0 +1,227 @@
+<?php
+
+namespace App\JsonRpc;
+
+interface ChatServiceInterface
+{
+    /**
+     * 添加申请
+     * @param array $data
+     * @return array
+     */
+    public function addFriend(array $data): array;
+    /**
+     * 好友申请列表
+     * @param array $data
+     * @return array
+     */
+    public function getFriendsList(array $data): array;
+    /**
+     * 获取申请列表
+     * @param array $data
+     * @return array
+     */
+    public function getFriendsApplyList(array $data): array;
+
+    /**
+     * 更新申请
+     * @param array $data
+     * @return array
+     */
+    public function applyFriend(array $data): array;
+    /**
+     * 搜索好友
+     * @param array $data
+     * @return array
+     */
+    public function searchFriend(array $data): array;
+    /**
+     * 获取群成员
+     * @param array $data
+     * @return array
+     */
+    public function getGroupMembers(array $data): array;
+    /**
+     * 获取群列表
+     * @param array $data
+     * @return array
+     */
+    public function getGroupList(array $data): array;
+    /**
+     * 获取群信息
+     * @param array $data
+     * @return array
+     */
+    public function getGroupInfo(array $data): array;
+
+    /**
+     * 删除好友
+     * @param array $data
+     * @return array
+     */
+    public function delFriend(array $data): array;
+
+    /**
+     * 是否好友
+     * @param array $data
+     * @return array
+     */
+    public function isFriend(array $data): array;
+
+    /**
+     * 好友详情
+     * @param array $data
+     * @return array
+     */
+    public function getFriendInfo(array $data): array;
+
+    /**
+     * 添加聊天内容
+     * @param array $data
+     * @return array
+     */
+    public function addChatRecords(array $data): array;
+    /**
+     * 会话列表
+     * @param array $data
+     * @return array
+     */
+    public function getConversation(array $data): array;
+    /**
+     * 新建群
+     * @param array $data
+     * @return array
+     */
+    public function addGroup(array $data): array;
+    /**
+     * 更新群
+     * @param array $data
+     * @return array
+     */
+    public function updateGroup(array $data): array;
+    /**
+     * 删除群
+     * @param array $data
+     * @return array
+     */
+    public function delGroup(array $data): array;
+    /**
+     * 推出群
+     * @param array $data
+     * @return array
+     */
+    /**
+     * 删除群成员
+     * @param array $data
+     * @return array
+     */
+    public function delGroupMembers(array $data): array;
+    /**
+     * 修改群成员
+     * @param array $data
+     * @return array
+     */
+    public function updateGroupMembers(array $data): array;
+    public function quitGroup(array $data): array;
+    /**
+     * 加入群
+     * @param array $data
+     * @return array
+     */
+    public function joinGroup(array $data): array;
+    /**
+     * 获取话题列表
+     * @param array $data
+     * @return array
+     */
+    public function getTopicsList(array $data): array;
+    /**
+     * 添加话题
+     * @param array $data
+     * @return array
+     */
+    public function addTopic(array $data): array;
+    /**
+     * 更新话题
+     * @param array $data
+     * @return array
+     */
+    public function updateTopic(array $data): array;
+    /**
+     * 删除话题
+     * @param array $data
+     * @return array
+     */
+    public function delTopic(array $data): array;
+    /**
+     * 获取话题详情
+     * @param array $data
+     * @return array
+     */
+    public function getTopicInfo(array $data): array;
+    /**
+     * 获取话题回复
+     * @param array $data
+     * @return array
+     */
+    public function getTopicReply(array $data): array;
+    /**
+     * 添加话题回复
+     * @param array $data
+     * @return array
+     */
+    public function addReply(array $data): array;
+
+    /**
+     * 群聊天记录
+     * @param array $data
+     * @return array
+     */
+    public function clearGroupRecords(array $data): array;
+    /**
+     * 删除一条聊天记录
+     * @param array $data
+     * @return array
+     */
+    public function clearRecords(array $data): array;
+    /**
+     * 获取聊天记录
+     * @param array $data
+     * @return array
+     */
+    public function getRecord(array $data): array;
+    /**
+     * 撤回聊天记录
+     * @param array $data
+     * @return array
+     */
+    public function recallRecord(array $data): array;
+    /**
+     * 删除topicReply
+     * @param array $data
+     * @return array
+     */
+    public function delReply(array $data): array;
+    /**
+     * 删除topic所有Reply
+     * @param array $data
+     * @return array
+     */
+    public function delAllReply(array $data): array;
+    /**
+     * 管理后台获取所有的topic
+     * @param array $data
+     * @return array
+     */
+    public function getTopicsListAdmin(array $data): array;
+
+    public function applyTopic(array $data): array;
+
+    public function getTopicClassList(array $data): array;
+    public function addTopicClass(array $data): array;
+    public function updateTopicClass(array $data): array;
+    public function deleteTopicClass(array $data): array;
+    public function getTopicClassInfo(array $data): array;
+    public function getBusinessDistrictList(array $data): array;
+
+}

+ 601 - 0
app/JsonRpc/FormService.php

@@ -0,0 +1,601 @@
+<?php
+namespace App\JsonRpc;
+
+
+use Hyperf\RpcServer\Annotation\RpcService;
+use App\Tools\Result;
+use App\Model\GlobalTable;
+use Hyperf\DbConnection\Db;
+use App\Model\GlobalTableField;
+use App\Model\GlobalTableFieldType;
+use App\Model\GlobalTableFieldValue;
+use App\Model\Website;
+use Hyperf\Di\Annotation\Inject;
+use Hyperf\Redis\Redis;
+#[RpcService(name: "FormService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
+class FormService implements FormServiceInterface
+{
+
+    #[Inject]
+    protected Redis $redis;
+    /**
+     * 添加全局表单
+     * @param array $data
+     * @return array|mixed
+     */
+    public function addGlobalTable(array $data): array
+    {
+        // 过滤掉空值
+        $data = array_filter($data, function($value) {
+            return !empty($value);
+        });
+
+        // 检查是否已存在相同名称的记录
+        $globalTable = GlobalTable::on('global')->where(['table'=> $data['table']])->first();
+        if (empty($globalTable)) {
+            $id = GlobalTable::on('global')->insertGetId($data);
+            //给global库创建表 表名为$data['table'] 的值,并初始化一个字段id,类型为int,自增,主键,再初始化一个字段title,类型为varchar,长度为255
+            Db::connection('global')->statement("CREATE TABLE IF NOT EXISTS `{$data['table']}` (
+                `id` int(11) NOT NULL AUTO_INCREMENT,
+                `title` varchar(255) DEFAULT NULL,
+                `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
+                `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+                PRIMARY KEY (`id`)
+            )");
+            //给GlobalTableField表初始化数据
+            GlobalTableField::on('global')->insert([
+                [
+                    'table_id' => $id,
+                    'field_name' => 'id',
+                    'title' => '编号',
+                    'field_type' => '1',
+                    'length' => 255,
+                    'sort' => 0,
+                    'is_check' => 1,
+                    'admin_display' => 1,
+                    'home_display' => 1,
+                    'disable_del' => 1,
+                ],
+                [
+                    'table_id' => $id,
+                    'field_name' => 'title',
+                    'title' => '标题',
+                    'field_type' => '1',
+                    'length' => 255,
+                    'sort' => 0,
+                    'is_check' => 1,
+                    'admin_display' => 1,
+                    'home_display' => 1,
+                    'disable_del' => 1,
+                ],
+                [
+                    'table_id' => $id,
+                    'field_name' => 'updated_at',
+                    'title' => '更新时间',
+                    'field_type' => '1',
+                    'length' => 255,
+                    'sort' => 999,
+                    'is_check' => 1,
+                    'admin_display' => 1,
+                    'home_display' => 0,
+                    'disable_del' => 1,
+                ],
+                [
+                    'table_id' => $id,
+                    'field_name' => 'created_at',
+                    'title' => '创建时间',
+                    'field_type' => '1',
+                    'length' => 255,
+                    'sort' => 1000,
+                    'is_check' => 1,
+                    'admin_display' => 0,
+                    'home_display' => 0,
+                    'disable_del' => 1,
+                ],
+                
+            ]);
+ 
+            return Result::success('添加成功');
+        }
+        return Result::error('表单已存在');
+    }
+    /**
+     * 获取全局表单列表
+     * @param array $data
+     * @return array
+     */
+    public function getGlobalTableList(array $data): array
+    {
+        try {
+            // 构建查询
+            $query = GlobalTable::query()
+                ->when(!empty($data['name']), function($q) use ($data) {
+                    return $q->where('name', 'like', '%' . $data['name'] . '%');
+                });
+            
+            // 分页参数
+            $page = (int)($data['page'] ?? 1);
+            $pageSize = (int)($data['pageSize'] ?? 10);
+            
+            // 先获取总数
+            $total = $query->count();
+            
+            // 获取数据
+            $list = $query->orderBy('updated_at', 'desc')
+                         ->offset(($page - 1) * $pageSize)
+                         ->limit($pageSize)
+                         ->get();
+            
+            // 如果没有数据,直接返回空结果
+            if ($list->isEmpty()) {
+                return Result::success([
+                    'list' => [],
+                    'total' => $total,
+                    'page' => $page,
+                    'pageSize' => $pageSize
+                ]);
+            }
+            
+            // 合并数据并返回
+            return Result::success([
+                'list' => $list,
+                'total' => $total,
+                'page' => $page,
+                'pageSize' => $pageSize
+            ]);
+            
+        } catch (\Throwable $e) {
+            return Result::error('查询失败:' . $e->getMessage());
+        }
+    }
+    /**
+     * 获取全局表单
+     * @param array $data
+     * @return array
+     */
+    public function getGlobalTable(array $data): array
+    {
+        $globalTable = GlobalTable::where('id',$data['id'])->first();
+        return Result::success($globalTable);
+    }
+    /**
+     * 修改全局表单
+     * @param array $data
+     * @return array
+     */
+    public function upGlobalTable(array $data): array   
+    {
+        $globalTable = GlobalTable::where('id',$data['id'])->first();
+        if(empty($globalTable)){
+            return Result::error('表单不存在');
+        }   
+        $data = array_filter($data,function($value){
+            return $value !== null;
+        });
+        GlobalTable::where(['id'=>$data['id']])->update($data);
+        return Result::success('修改成功');
+    }   
+    /**
+     * 删除全局表单
+     * @param array $data
+     * @return array
+     */
+    public function delGlobalTable(array $data): array          
+    {
+        $globalTable = GlobalTable::where('id', $data['id'])->first();
+        if(empty($globalTable)){
+            return Result::error('表单不存在');
+        }
+        //删除global库的表
+        Db::connection('global')->statement("DROP TABLE IF EXISTS `{$globalTable->table}`");
+        //删除GlobalTableField表中table_id为$data['id']的数据
+        GlobalTableField::where('table_id', $data['id'])->delete();
+        GlobalTable::where('id', $data['id'])->delete();
+        return Result::success('删除成功');
+    }
+    /**
+     * 获取表单字段列表
+     * @param array $data
+     * @return array
+     */
+    public function getGlobalTableFieldList(array $data): array
+    {
+        $fields = GlobalTableField::from('global_table_field as a')
+            ->join('global_table_field_type as b', 'a.field_type', '=', 'b.id')
+            ->where('a.table_id', $data['id'])
+            ->whereNotIn('a.field_name',['id','created_at','updated_at'])
+            ->orderBy('a.sort', 'asc')
+            ->select(
+            // global_table_field 所有字段
+                'a.*',
+                // global_table_field_type 字段
+                'b.type_name',
+                'b.type_name_alias',
+                'b.field_type as type_definition'
+            )
+            ->get();
+        return Result::success($fields);
+    }
+    /**
+     * 获取表单字段
+     * @param array $data
+     * @return array    
+     */
+    public function getGlobalTableField(array $data): array
+    {
+        $globalTableField = GlobalTableField::where('id',$data['id'])->first();
+        return Result::success($globalTableField);
+    }
+    /**
+     * 添加表单字段
+     * @param array $data
+     * @return array
+     * @throws \Throwable
+     */
+    public function addGlobalTableField(array $data): array
+    {
+        $globalTable = GlobalTable::where('id',$data['table_id'])->first(); 
+        if(empty($globalTable)){
+            return Result::error('表单不存在');     
+        }
+        //检查是否已存在相同名称的记录
+        $globalTableField = GlobalTableField::where(['table_id'=>$data['table_id'],'field_name'=>$data['field_name']])->first();    
+        if(!empty($globalTableField)){
+            return Result::error('字段已存在');
+        }
+
+        // 检查表中是否已存在该列
+        try {
+            $columns = Db::connection('global')->select("SHOW COLUMNS FROM `{$globalTable->table}`");
+            $columnNames = array_column($columns, 'Field');
+            if (in_array($data['field_name'], $columnNames)) {
+                return Result::error('字段名已存在于数据表中');
+            }
+        } catch (\Throwable $e) {
+            return Result::error('检查字段是否存在时出错:' . $e->getMessage());
+        }
+
+        $globalTableFieldTypeInfo = GlobalTableFieldType::where('id',$data['field_type'])->first();
+        //给global库的表添加字段
+        Db::connection('global')->statement("ALTER TABLE `{$globalTable->table}` ADD COLUMN `{$data['field_name']}` {$globalTableFieldTypeInfo['field_type']}({$data['length']}) COMMENT '{$data['title']}'"); 
+        //给GlobalTableField表添加数据
+        GlobalTableField::create($data);
+        return Result::success('添加成功');
+    }
+    /**
+     * 修改表单字段
+     * @param array $data
+     * @return array
+     * @throws \Throwable
+     */
+    public function upGlobalTableField(array $data): array
+    {
+        $globalTable = GlobalTable::where('id',$data['table_id'])->first(); 
+        if(empty($globalTable)){
+            return Result::error('表单不存在');
+        }
+        //检查是否已存在相同名称的记录
+        $globalTableField = GlobalTableField::where(['table_id'=>$data['table_id'],'field_name'=>$data['field_name']])->first();
+        if(!empty($globalTableField) && $globalTableField->id != $data['id']){
+            return Result::error('字段已存在');
+        }
+        $globalTableFieldTypeInfo = GlobalTableFieldType::where('id',$data['field_type'])->first();
+        //给global库的表修改字段
+        Db::connection('global')->statement("ALTER TABLE `{$globalTable->table}` CHANGE COLUMN `{$data['field_name']}` `{$data['field_name']}` {$globalTableFieldTypeInfo['field_type']}({$data['length']}) COMMENT '{$data['title']}'"); 
+        //给GlobalTableField表修改数据
+        GlobalTableField::where('id',$data['id'])->update($data);
+        return Result::success('修改成功');
+    }
+    /**
+     * 删除表单字段
+     * @param array $data
+     * @return array
+     * @throws \Throwable
+     */
+    public function delGlobalTableField(array $data): array
+    {
+        $tableFieldInfo = GlobalTableField::where('id',$data['id'])->first(); 
+        if(empty($tableFieldInfo)){
+            return Result::error('字段不存在');
+        }
+        $globalTable = GlobalTable::where('id',$tableFieldInfo['table_id'])->first(); 
+        if(empty($globalTable)){
+            return Result::error('表单不存在');
+        }
+        //给global库的表删除字段
+        Db::connection('global')->statement("ALTER TABLE `{$globalTable->table}` DROP COLUMN `{$tableFieldInfo['field_name']}`"); 
+        //给GlobalTableField表删除数据
+        GlobalTableField::where('id',$data['id'])->delete();
+        return Result::success('删除成功');
+    }
+    /**
+     * 获取自定义生成表里面的数据
+     */
+    public function getGlobalTableData(array $data): array
+    {
+        try {
+            //查询global库的表GlobalTableField模型中table_id为$data['id']的数据条件为admin_display=1的数据
+            $globalTableFields = GlobalTableField::where(['table_id'=>$data['id'],'admin_display'=>1])->orderBy('sort','asc')->get();
+            $globalTableFields->transform(function ($field) {
+                $optionValue = [];
+                $optionStr = trim((string) $field->option);
+                if (!empty($optionStr)) {
+                    $options = explode("\n", $optionStr);
+                    foreach ($options as $option) {
+                        $parts = explode('|', $option);
+                        if (count($parts) === 2) {
+                            $optionValue[$parts[1]] = $parts[0];
+                        }
+                    }
+                }
+                $field->option_value = $optionValue;
+                return $field;
+            });
+            
+            //查询global库的表GlobalTable模型中id为$data['id']的数据
+            $globalTable = GlobalTable::where('id',$data['id'])->first(); 
+            if(empty($globalTable)){
+                return Result::error('表单不存在');
+            }
+
+            // 构建查询
+            $query = Db::connection('global')->table($globalTable->table);
+            
+            // 添加title模糊搜索
+            if (!empty($data['title'])) {
+                $query->where('title', 'like', '%' . $data['title'] . '%');
+            }
+
+            // 分页参数
+            $page = (int)($data['page'] ?? 1);
+            $pageSize = (int)($data['pageSize'] ?? 10);
+            
+            // 先获取总数
+            $total = $query->count();
+            
+            // 获取分页数据
+           $list = $query->select($globalTableFields->pluck('field_name')->toArray())
+             ->orderBy('id', 'desc')
+             ->offset(($page - 1) * $pageSize)
+             ->limit($pageSize)
+             ->get();
+
+            // 转换字符串数组为实际数组
+            $list->transform(function ($item) use ($globalTableFields) {
+                foreach ($globalTableFields as $field) {
+                    $fieldName = $field->field_name;
+                    if (isset($item->$fieldName) && is_string($item->$fieldName)) {
+                        // 尝试解析JSON格式的字符串
+                        $decoded = json_decode($item->$fieldName, true);
+                        if (json_last_error() === JSON_ERROR_NONE) {
+                            $item->$fieldName = $decoded;
+                        }
+                        // 如果是简单的逗号分隔字符串,也可以转换为数组
+                        elseif (strpos($item->$fieldName, ',') !== false) {
+                            $item->$fieldName = array_map('trim', explode(',', $item->$fieldName));
+                        }
+                    }
+                }
+                return $item;
+            });
+
+
+            return Result::success([
+                'tableFields' => $globalTableFields,
+                'list' => $list,
+                'total' => $total,
+                'page' => $page,
+                'pageSize' => $pageSize
+            ]);
+        } catch (\Throwable $e) {
+            return Result::error('查询失败:' . $e->getMessage());
+        }
+    }
+    /**
+     * 获取字段类型列表
+     */
+    public function getGlobalTableFieldTypeList(array $data): array
+    {
+        try {
+            $list =  Db::connection('global')->table("global_table_field_type")->get();
+            return Result::success($list);
+        }catch (\Throwable $e){
+            return Result::error('查询失败:' . $e->getMessage());
+        }
+    }
+    /**
+     * 删除自定义表里面的某一条数据
+     */
+    public function delGlobalTableData(array $data): array
+    {
+        try {
+            //查询global库的表GlobalTable模型中id为$data['id']的数据
+            $globalTable = GlobalTable::where('id',$data['table_id'])->first();
+            if(empty($globalTable)){
+                return Result::error('表单不存在');
+            }
+            // 构建查询
+            $query = Db::connection('global')->table($globalTable->table);
+            $query->where('id',$data['id']);
+            $query->delete();
+            return Result::success('删除成功');
+        }catch (\Throwable $e){
+            return Result::error('删除失败:' . $e->getMessage());
+        }
+    }
+    /**
+     * 修改自定义表里面的某一条数据
+     */
+    public function updateGlobalTableData(array $data): array
+    {
+        try {
+            $globalTable = GlobalTable::where('id', $data['table_id'])->first();
+            if (empty($globalTable)) {
+                return Result::error('表单不存在');
+            }
+            unset($data['table_id']);
+            // 转换数组字段为字符串
+            $data = array_map(function ($value) {
+                if (is_array($value)) {
+                    return json_encode($value, JSON_UNESCAPED_UNICODE);
+                }
+                return $value;
+            }, $data);
+            $query = Db::connection('global')->table($globalTable->table);
+            $query->where('id', $data['id'])->update($data);
+            return Result::success('修改成功');
+        } catch (\Throwable $e) {
+            return Result::error('修改失败:' . $e->getMessage());
+        }
+    }
+
+    /**
+     * 查看自定义表里面的某条数据
+     */
+    public function getGlobalTableDataById(array $data): array
+    {
+        try {
+            //查询
+            $globalTable = GlobalTable::where('id',$data['table_id'])->first();
+            if(empty($globalTable)){
+                return Result::error('表单不存在');
+            }
+            $query =  Db::connection('global')->table($globalTable->table);
+            $query->where('id',$data['id']);
+            $dataInfo = $query->first();
+            $globalTableField = GlobalTableField::where(['table_id'=>$data['table_id']])->get();
+            $globalTableField->transform(function ($field) {
+                $optionValue = [];
+                $optionStr = trim((string) $field->option);
+                if (!empty($optionStr)) {
+                    $options = explode("\n", $optionStr);
+                    foreach ($options as $option) {
+                        $parts = explode('|', $option);
+                        if (count($parts) === 2) {
+                            $optionValue[$parts[1]] = $parts[0];
+                        }
+                    }
+                }
+                $field->option_value = $optionValue;
+                return $field;
+            });
+            $return = [
+                'data'=>$dataInfo,
+                'tableFields'=>$globalTableField->toArray(),
+            ];
+            return Result::success($return);
+        }catch (\Throwable $e){
+            return Result::error('查询失败:' . $e->getMessage());
+        }
+    }
+    /**
+     * 查询网站下表单自定义字段
+     */
+    public function getWebGlobalTableFieldList(array $data): array
+    {
+        try {
+            $globalTable = GlobalTable::where('id',$data['table_id'])->first();
+            $websiteInfo = Website::where('id',$data['website_id'])->first();
+            if(empty($websiteInfo)){
+                return Result::error('网站不存在');
+            }else{
+                $globalTable['website_name'] = $websiteInfo['website_name'];
+                $globalTable['suffix'] = $websiteInfo['suffix'];
+            }
+            $fields = GlobalTableField::from('global_table_field as a')
+                ->join('global_table_field_type as b', 'a.field_type', '=', 'b.id')
+                ->where('a.table_id', $data['table_id'])
+                ->where('a.field_name',"<>",'id')
+                ->where('a.home_display', 1)
+                ->orderBy('a.sort', 'asc')
+                ->select(
+                // global_table_field 所有字段
+                    'a.*',
+                    // global_table_field_type 字段
+                    'b.type_name',
+                    'b.type_name_alias',
+                    'b.field_type as type_definition'
+                )
+                ->get();
+            $fields->transform(function ($field) {
+                    $optionValue = [];
+                    $optionStr = trim((string) $field->option);
+                    if (!empty($optionStr)) {
+                        $options = explode("\n", $optionStr);
+                        foreach ($options as $option) {
+                            $parts = explode('|', $option);
+                            if (count($parts) === 2) {
+                                $optionValue[$parts[1]] = $parts[0];
+                            }
+                        }
+                    }
+                    $field->option_value = $optionValue;
+                    return $field;
+                });
+            $config = new \EasySwoole\VerifyCode\Config();
+            $code = new \EasySwoole\VerifyCode\VerifyCode($config);
+            $img_code = '';
+            $characters = '0123456789';
+            $charLength = strlen($characters);
+            for ($i = 0; $i < 4; $i++) {
+                $img_code .= $characters[rand(0, $charLength - 1)];
+            }
+            //重写验证码
+            $result = $code->DrawCode((string)$img_code);
+            $img_code = $result->getImageCode();
+            var_dump("验证码:",$img_code);
+            $code_uniqid = uniqid("code");
+            //写入缓存 用于其他方法验证 并且设置过期时间
+            $this->redis->set($code_uniqid,$img_code,60000);
+            $rep = [
+                'fields' => $fields,
+                'table'=>$globalTable,
+            ];
+            if($globalTable->is_code){
+                $rep['code']['code_uniqid'] = $code_uniqid;
+                $rep['code']['img'] = $result->getImageBase64();
+            }
+            return Result::success($rep);
+        }catch (\Throwable $e){
+            return Result::error('查询失败:' . $e->getMessage());
+        }
+    }
+
+    /**
+     * web端创建数据
+     * @param array $data
+     * @return array
+     */
+    public function addWebGlobalTableData(array $data): array
+    {
+        try {
+            $globalTable = GlobalTable::where('id',$data['otherData']['table_id'])->first();
+            if($globalTable->is_code){
+                if(empty($data['otherData']['code'])){
+                    return Result::error('请输入验证码');
+                }
+                $code = $this->redis->get($data['otherData']['code_uniqid']);   
+                if(empty($code)){
+                    return Result::error('验证码已过期');
+                }
+                if($data['otherData']['code'] != $code){
+                    return Result::error('验证码错误');
+                }
+            }
+            if(empty($globalTable)){
+                return Result::error('表单不存在');
+            }
+            $query = Db::connection('global')->table($globalTable->table);
+            $data['data'] = array_map(function ($value) {
+                if (is_array($value)) {
+                    return json_encode($value, JSON_UNESCAPED_UNICODE);
+                }
+                return $value;
+            }, $data['data']);
+            $query->insert($data['data']);
+            return Result::success([]);
+        }catch (\Throwable $e){
+            return Result::error('添加失败:' . $e->getMessage());
+        }
+    }
+}

+ 91 - 0
app/JsonRpc/FormServiceInterface.php

@@ -0,0 +1,91 @@
+<?php
+namespace App\JsonRpc;
+interface FormServiceInterface
+{
+    
+    /**
+     * @param array $data
+     *  @return array
+    */
+    public function addGlobalTable(array $data):array;
+    /**
+     * @param array $data
+     *  @return array
+    */
+    public function getGlobalTableList(array $data):array;
+    /**
+     * @param array $data
+     *  @return array
+     */
+    public function getGlobalTable(array $data):array;
+    /**
+     * @param array $data
+     *  @return array
+    */
+    public function upGlobalTable(array $data):array;   
+    /**
+     * @param array $data
+     *  @return array
+    */
+    public function delGlobalTable(array $data):array;  
+    
+    /**
+     * @param array $data
+     *  @return array
+    */
+    public function addGlobalTableField(array $data):array;
+    /**
+     * @param array $data
+     *  @return array
+    */
+    public function getGlobalTableFieldList(array $data):array;
+    /**
+     * @param array $data
+     *  @return array
+     */
+    public function getGlobalTableField(array $data):array;
+    /**
+     * @param array $data
+     *  @return array
+    */
+    public function upGlobalTableField(array $data):array;
+    /**
+     * @param array $data
+     *  @return array                   
+     * */
+    public function delGlobalTableField(array $data):array;
+    /**
+     * @param array $data
+     *  @return array
+    */
+    public function getGlobalTableData(array $data):array;
+    /**
+     * @param array $data
+     *  @return array
+    */
+    public function getGlobalTableFieldTypeList(array $data):array;
+    /**
+     * 删除自定义表单的数据
+     * @param array $data
+     *  @return array
+    */
+    public function delGlobalTableData(array $data):array;
+    /**
+     * 获取自定义表里面的数据
+     */
+    public function getGlobalTableDataById(array $data):array;
+
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function updateGlobalTableData(array $data):array;
+    public function getWebGlobalTableFieldList(array $data):array;
+    public function addWebGlobalTableData(array $data):array;
+
+
+
+
+}
+
+

+ 8894 - 0
app/JsonRpc/NewsService.php

@@ -0,0 +1,8894 @@
+<?php
+
+namespace App\JsonRpc;
+
+use App\Model\Article;
+use App\Model\ArticleData;
+use App\Model\Category;
+use App\Model\HistoryToday;
+use App\Model\WebsiteCategory;
+use App\Model\ArticleSurvey;
+use App\Model\District;
+use App\Model\Good;
+use App\Model\JobCompany;
+use App\Model\Website;
+use App\Model\JobRecruiting;
+use App\Model\JobIndustry;
+use App\Model\Book;
+use App\Model\JobPosition;
+use App\Model\Notice;
+use App\Model\JobNature;
+use App\Model\JobEnum;
+use App\Model\User;
+use App\Model\UserRole;
+use App\Model\News;
+use App\Model\UserInfo;
+use App\Model\WebsiteGroup;;
+
+
+use App\Model\JobResume;
+
+use Hyperf\DbConnection\Db;
+use Hyperf\RpcServer\Annotation\RpcService;
+use App\Tools\Result;
+use Directory;
+use Ramsey\Uuid\Uuid;
+use Hyperf\Utils\Random;
+use Fukuball\Jieba\Jieba;
+use Fukuball\Jieba\Finalseg;
+
+use Hyperf\Utils\Collection;
+
+use function Hyperf\Support\retry;
+use App\Tools\PublicData;
+use App\Model\ChatGroups;
+use App\Model\ChatGroupsMember;
+use App\Model\ChatRecords;
+use App\Model\Complaint;
+use Hamcrest\Arrays\IsArray;
+use Hyperf\Codec\Json;
+
+use App\Tools\buildMenuTree;
+use App\Model\JobApply;
+use App\Model\JobHunting;
+use App\Model\JobRemuse;
+use Hyperf\Redis\Redis;
+use Hyperf\Di\Annotation\Inject;
+
+use App\Model\Festival;
+use App\Model\Character;
+use App\Model\Couplet;
+use App\Model\Riddle;
+use App\Model\Idiom;
+use App\Model\WhiteRouter;
+use Illuminate\Support\Facades\Cache;
+
+use App\Model\Company;
+use Hyperf\Paginator\Paginator;
+use App\Model\Project;
+
+use Hyperf\Context\Context;
+use Hyperf\Context\ApplicationContext as ContextApplicationContext;
+use Hyperf\Amqp\Producer;
+
+use App\Amqp\Producer\MqProducer;
+use App\Model\Web;
+
+
+use App\Model\GroupMemberImp;
+use App\Model\GroupImp;
+use App\Model\GroupTalkImp;
+use App\Model\GroupTalkMessagerImp;
+use App\Model\ArticleIgnore;
+
+#[RpcService(name: "NewsService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
+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 = "
+                WITH RECURSIVE parents AS (
+                    SELECT * FROM category WHERE id IN ($idsStr)
+                    UNION ALL
+                    SELECT c.* FROM category c
+                    INNER JOIN parents p ON c.id = p.pid
+                )
+                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();
+    }
+
+    // 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 = "
+            WITH RECURSIVE subcategories AS (
+                SELECT * FROM category WHERE id IN ($idsStr)
+                UNION ALL
+                SELECT c.* FROM category c
+                INNER JOIN subcategories s ON c.pid = s.id
+            )
+            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];
+      }
+    }
+
+    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;
+        }
+      }
+      $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) {
+        Db::rollBack();
+        return Result::error("删除失败");
+      }
+      Db::commit();
+      return Result::success($result);
+    } catch (\Exception $e) {
+      Db::rollBack();
+      return Result::error("删除失败" . $e->getMessage());
+    }
+  }
+
+  /**
+   * @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("更新失败");
+    }
+  }
+  public function getArticleCommend(array $data): array
+  {
+    $where = [
+      'website_id' => $data['website_id'],
+    ];
+    $ids = WebsiteCategory::where($where)->pluck('category_id')->toArray();
+    var_dump($ids);
+    if (empty($ids)) {
+      return Result::error("没有推荐数据");
+    }
+    //id
+    $whereArticle = [];
+    if (isset($data['id'])) {
+      $whereArticle['id'] = $data['id'];
+    }
+    //title  like
+    if (isset($data['title'])) {
+      array_push($whereArticle, ['title', 'like', "%{$data['title']}%"]);
+    }
+    $article = Article::whereIn('catid', values: $ids)->where('status', 1)
+      ->where($whereArticle)
+      ->orderBy('id', 'desc')
+      ->paginate($data['pageSize'], ['*'], 'page', $data['page']);
+
+    if ($article) {
+      $data = [
+        'rows' => $article->items(),
+        'count' => $article->total(),
+      ];
+      return Result::success($data);
+    } 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['catid']) && $data['catid']) {
+      array_push($where,  ['article.catid', '=', $data['catid']]);
+    }
+
+    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];
+    }
+    $startTime = microtime(true);
+    $rep = Article::query()
+      // 预加载相关关联
+      ->with([
+        'category' => function ($query) {
+          $query->select('id', 'name');
+        },
+        'websiteCategory' => function ($query) {
+          $query->select('website_id', 'category_id', 'alias');
+        }
+      ])
+      // 构建where条件
+      ->when(isset($data['id']) && $data['id'], function ($query) use ($data) {
+        $query->where('article.id', '=', $data['id']);
+      })
+      ->when(isset($data['title']) && $data['title'], function ($query) use ($data) {
+        $query->where('article.title', 'like', '%' . $data['title'] . '%');
+      })
+      ->when(isset($data['category_name']) && $data['category_name'], function ($query) use ($data) {
+        // 使用子查询替代左连接进行模糊搜索
+        $query->whereHas('category', function ($subQuery) use ($data) {
+          $subQuery->where('name', 'like', '%' . $data['category_name'] . '%');
+        });
+      })
+      ->when(isset($data['catid']) && $data['catid'], function ($query) use ($data) {
+        $query->where('article.catid', '=', $data['catid']);
+      })
+      ->when(isset($data['author']) && $data['author'], function ($query) use ($data) {
+        $query->where('article.author', '=', $data['author']);
+      })
+      ->when(isset($data['islink']) && $data['islink'] !== "", function ($query) use ($data) {
+        $query->where('article.islink', '=', $data['islink']);
+      })
+      ->when(isset($data['status']) && $data['status'] !== "", function ($query) use ($data) {
+        $query->where('article.status', '=', $data['status']);
+      })
+      ->when(isset($data['status1']) && $data['status1'], function ($query) use ($data) {
+        // 安全地处理JSON字符串
+        $status1 = is_array($data['status1']) ? $data['status1'] : json_decode($data['status1'], true)  ?? [];
+        if (!empty($status1)) {
+          $query->whereIn('article.status', $status1);
+        }
+      })
+      ->select('article.*')
+      // 非管理员限制
+      ->when($type_id != 10000, function ($query) use ($user_id) {
+        // 非管理员只能看自己的文章,同时把 article_ignore 的 c_show_time 一起查出来
+        $query->where('article.admin_user_id', $user_id)
+              ->leftJoin('article_ignore', function ($join) {
+                  // 关联条件:article.id = article_ignore.article_id 且 article.web_site_id = article_ignore.website_id
+                  $join->on('article_ignore.article_id', '=', 'article.id')
+                       ->whereColumn('article_ignore.website_id', 'article.web_site_id');
+              })
+              ->addSelect('article_ignore.article_id','article_ignore.c_show_time'); // 用 addSelect 追加字段,避免覆盖原有 select
+      })
+      // 基础条件
+      ->whereNotIn('article.status', [404])
+      // 排序和分页
+      ->orderBy('article.updated_at', 'desc')
+      ->paginate($data['pageSize'], ['*'], 'page', $data['page']);
+
+    // 获取结果并格式化
+    $data = [
+      'rows' => $rep->items(),
+      'count' => $rep->total(),
+    ];
+    // 执行查询
+    $endTime = microtime(true);
+    $executionTime = ($endTime - $startTime) * 1000;
+
+    echo "查询执行时间: {$executionTime}ms\n";
+    return Result::success($data);
+  }
+
+  /**
+   * @param array $data
+   * @return array
+   */
+  public function addArticle(array $data): array
+  {
+
+    var_dump($data, '----------12-----------1');
+
+    // ------c_show_time********add***1****
+    $is_collect = $data['is_collect'] ?? 0;
+    $user_type = $data['user_type'];
+    unset($data['is_collect']);
+    unset($data['user_type']);
+    // ------c_show_time********add***1****
+    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中提取图片第一个图,正则提取
+        //  -------采集器相关优化-----
+        //    优化正则表达式,仅匹配 src 属性值,避免匹配到多余内容
+        if ($is_collect == 1) {
+          $reg = '/<img.*?src=[\'"]?((?!.*\.gif)[^\'" >]+)[\'"]?.*?>/i';
+        } else {
+          $reg = '/<img.*?src=[\'"]?([^\'" >]+)[\'"]?.*?>/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'] == '') {
+        //提取内容中的描述
+        $content = $data['content'];
+        // 去除 <style> 和 <script> 标签及其内容
+        $content = preg_replace('/<(style|script)[^>]*>.*?<\/\1>/is', '', $content);
+        // 去除所有 HTML 标签
+        $content = strip_tags($content);
+        // 去除 HTML 实体
+        $content = html_entity_decode($content, ENT_QUOTES | ENT_HTML5, 'UTF-8');
+        // 只保留文本和标点符号(去除所有字母数字以外的特殊符号,可根据需要调整正则)
+        $content = preg_replace('/[^\p{L}\p{N}\p{P}\p{Zs}]+/u', '', $content);
+        // 去除多余空白
+        $content = preg_replace('/\s+/u', '', $content);
+        // 截取 100 个字符
+        $articleData['introduce'] = mb_substr($content, 0, 100);
+      }
+      if ($articleData['status'] == 0) {
+        $this->sendMessage([
+          'talk_type' => 100,
+          'title' => $articleData['title'],
+          'content' => '提交了审核',
+          'messageType' => 2,
+        ]);
+      }
+      $id = Article::insertGetId($articleData);
+      if (!$id) {
+        throw new \Exception('文章插入失败');
+      }
+      $articleDataContent = [
+        'article_id' => $id,
+        'content' => $data['content'],
+      ];
+      // 采集器中的文章内容,在添加时,去掉div标签
+      if ($is_collect == 1) {
+        // 采集来的文章,content中可能包含div标签,需要先移除
+        $pattern = '/<\/?div\b(?:[^"\'>]|"[^"]*"|\'[^\']*\')*>/is';
+        $article_data = preg_replace($pattern, '', $data['content']);
+        $$articleDataContent['content'] = $article_data;
+      }
+
+      $contentInsertId = ArticleData::insertGetId($articleDataContent);
+      if (!$contentInsertId) {
+        throw new \Exception('文章内容插入失败');
+      }
+
+
+      //   ------c_show_time********add***2****
+      // 直接使用当前系统时间,不再强制添加8小时
+      $now = date('Y-m-d H:i:s');
+      if ($user_type == 10000 || $is_collect == 1) {
+        // 管理员添加文章时,核心站c端显示时间就是创建时间;非核心站c端显示时间就是此创建时间往后推二十分钟;
+        // 非管理员添加文章时,不做操作只有在审核通过时获取c端显示时间
+        if (!isset($data['catid'])) {
+          throw new \Exception('缺少必要字段:catid');
+        }
+        // 查找网站,若是核心站则返回字段is_core=1,否则返回is_core=0,若是不存在此网站则为is_core=2
+        $web = WebsiteCategory::where('category_id', $data['catid'])
+          ->leftJoin('website', 'website_category.website_id', '=', 'website.id')
+          ->select(
+            'website_id',
+            Db::raw('CASE WHEN website.id IS NULL THEN 2 WHEN JSON_CONTAINS(website.`website_column_arr_id`, \'3\') THEN 1 ELSE 0 END as is_core')
+          )
+          ->get();
+        // $id = 225;   -----测试开启
+        // 采集来的文章,错开时间在两小时之内发布
+        if ($user_type == 10000 && $is_collect == 1) {
+          $web_num = $web->where('is_core', '!=', 2)->count();
+          $waiting_interval = 10;
+          if ($web_num > 12) {
+            // 若网站数量大于12个,则每个网站间隔时间取均值
+            // 防止除数为 0,虽然这里 $web_num 是 count 结果不会为 0,但做健壮性检查
+            $waiting_interval = 120 / max(1, $web_num);
+          }
+          $time = 0;
+        } else {
+          // 非核心站与核心站----显示时间-----间隔
+          $time = 20;
+          // 若不是采集来的文章,则非核心站之间的间隔时间为5分钟;初始时间与当前时间差二十分钟
+          $waiting_interval = 5;
+        }
+        // 将 Hyperf\Database\Model\Collection 转换为数组
+        $webArray = $web->toArray();
+        $article_ignore = array_values(array_filter(array_map(function ($index, $item) use (&$time, $now, $id, $waiting_interval, $is_collect) {
+          // 检查 $item 对象是否有 is_core 属性
+          if (!isset($item['is_core'])) {
+            throw new \Exception('$item 对象缺少 is_core 属性');
+          }
+          // 当 is_core 为 2 时,则表示此网站不存在
+          if ($item['is_core'] == 2) {
+            return null;
+          }
+          if ($is_collect == 1) {
+            // 采集来的文章,错开时间在两小时之内发布
+            // $time = 0;
+            $c_show_time = date('Y-m-d H:i:s', strtotime($now) + $time * 60);
+            $time += $waiting_interval;
+          } else if ($item['is_core'] == 1) {
+            // 当 is_core 为 1 时,则表示此网站是核心站
+            $c_show_time = date('Y-m-d H:i:s', strtotime($now));
+          } else {
+            // 若是is_core为0,则表示此网站不是核心站,需要往后推时间
+            $c_show_time = date('Y-m-d H:i:s', strtotime($now) + $time * 60);
+            if ($item['is_core'] == 0) {
+              $time += $waiting_interval;
+            }
+          }
+
+          return [
+            'article_id' => $id,
+            'website_id' => $item['website_id'],
+            'c_show_time' => $c_show_time,
+            //   'is_core' => $item['is_core'],
+            //   'time' => $time
+          ];
+        }, array_keys($webArray), $webArray)));
+        // Db::commit();
+        // return Result::success($article_ignore);
+        if (!empty($article_ignore)) {
+          $article_ignores = ArticleIgnore::insert($article_ignore);
+          if (!$article_ignores) {
+            throw new \Exception('c端展示时间插入失败');
+          }
+        }
+      }
+      // ------c_show_time********add***2****
+      //处理投票
+      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("投票失败,更新主表失败");
+        }
+      }
+
+
+      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 delArticle(array $data): array
+  {
+    // ------c_show_time********del*******
+    Db::beginTransaction();
+    try {
+      $article = Article::where(['id' => $data['id']])->delete();
+      // 若文章删除失败,抛出异常,后续 SQL 语句不会执行
+      if (!$article) {
+        throw new \Exception("删除失败,文章删除失败");
+      }
+      //survey投票删除
+      ArticleSurvey::where(['art_id' => $data['id']])->delete();  // 修正类名大小写
+      $articleIgnore = ArticleIgnore::where(['article_id' => $data['id']])->delete();
+      $article_data = ArticleData::where(['article_id' => $data['id']])->delete();
+      // 若文章详情删除失败,抛出异常
+      if (!$article_data) {
+        throw new \Exception("删除失败,文章详情删除失败");
+      }
+      Db::commit();  // 所有操作成功,提交事务
+    } catch (\Throwable $ex) {
+      Db::rollBack();
+      var_dump($ex->getMessage());
+      return Result::error("删除失败: " . $ex->getMessage(), 0);
+    }
+    // ------c_show_time********del*******
+    if (!$article) {
+      return Result::error("删除失败");
+    }
+    return Result::success($article);
+  }
+  /**
+   * @param array $data
+   * @return array
+   */
+  public function updateArticle(array $data): array
+  {
+    var_dump($data, '----------12-----------1');
+    Db::beginTransaction();
+    // ------c_show_time********up*******
+    $user_type = isset($data['user_type']) ? $data['user_type'] : 0;
+    // 无论是否改变了c端显示时间或者栏目,都需要将未屏蔽的网站显示时间删除记录
+    // 若是存在交集,则进行修改,若无,则合并(此表中的记录应该包含被屏蔽网站及涉及所有网站的展示时间)
+    $web = WebsiteCategory::where('category_id', $data['catid'])
+      ->leftJoin('website', 'website_category.website_id', '=', 'website.id')
+      ->select(
+        'website_id',
+        Db::raw('CASE WHEN website.id IS NULL THEN 2 WHEN JSON_CONTAINS(website.`website_column_arr_id`, \'3\') THEN 1 ELSE 0 END as is_core')
+      )
+      ->get();
+    // 根据错误信息,问题在于 $web 可能是一个包含对象的集合,不能直接用于 whereNotIn 方法
+    // 先从 $web 集合中提取 website_id 字段的值,再进行删除操作
+    $websiteIds = $web->pluck('website_id')->toArray();
+    $del_article_ignore = ArticleIgnore::where('article_id', $data['id'])->whereNotIn('website_id', $websiteIds)->delete();
+    if ($user_type == 0) {
+      throw new \Exception("用户类型不能为空");
+    }
+    if ($user_type == 10000) {
+      // 查找网站,若是核心站则返回字段is_core=1,否则返回is_core=0,若是不存在此网站则为is_core=2
+      $web = WebsiteCategory::where('category_id', $data['catid'])
+        ->leftJoin('website', 'website_category.website_id', '=', 'website.id')
+        ->select(
+          'website_id',
+          Db::raw('CASE WHEN website.id IS NULL THEN 2 WHEN JSON_CONTAINS(website.`website_column_arr_id`, \'3\') THEN 1 ELSE 0 END as is_core')
+        )
+        ->get();
+      // 非核心站与核心站----显示时间-----间隔
+      $time = 20;
+      // 若不是采集来的文章,则非核心站之间的间隔时间为5分钟;初始时间与当前时间差二十分钟
+      $waiting_interval = 5;
+      $webArray = $web->toArray();
+      if (empty($webArray)) {
+        throw new \Exception('网站分类不存在');
+      }
+      // 直接使用当前系统时间,不再强制添加8小时
+      $now = date('Y-m-d H:i:s');
+      $article_ignore = array_values(array_filter(array_map(function ($index, $item) use (&$time, $now, $data, $waiting_interval) {
+        // 检查 $item 对象是否有 is_core 属性
+        if (!isset($item['is_core'])) {
+          throw new \Exception('$item 对象缺少 is_core 属性');
+        }
+        // 当 is_core 为 2 时,则表示此网站不存在
+        if ($item['is_core'] == 2) {
+          return null;
+        } else if ($item['is_core'] == 1) {
+          // 当 is_core 为 1 时,则表示此网站是核心站
+          $c_show_time = date('Y-m-d H:i:s', strtotime($now));
+        } else {
+          // 若是is_core为0,则表示此网站不是核心站,需要往后推时间
+          $c_show_time = date('Y-m-d H:i:s', strtotime($now) + $time * 60);
+          if ($item['is_core'] == 0) {
+            $time += $waiting_interval;
+          }
+        }
+
+        return [
+          'article_id' => $data['id'],
+          'website_id' => $item['website_id'],
+          'c_show_time' => $c_show_time,
+        ];
+      }, array_keys($webArray), $webArray)));
+
+      if (!empty($article_ignore)) {
+        // 使用 upsert 方法,当 article_id 和 website_id 组合存在时更新 c_show_time,不存在时插入新记录
+        // 使用 upsert 方法,根据 article_id 和 website_id 作为唯一键判断记录是否存在,存在则更新 c_show_time 字段,不存在则新增
+        $article_ignores = ArticleIgnore::upsert(
+          $article_ignore,
+          ['article_id', 'website_id'], // 用于判断记录是否存在的唯一键
+          ['c_show_time'] // 需要更新的字段
+        );
+        if (!$article_ignores) {
+          throw new \Exception('c端展示时间插入失败');
+        }
+      }
+      // Db::commit();
+      // return Result::success($article_ignore);
+    }
+    // ------c_show_time********up*******
+    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'] == '') {
+        //提取内容中的描述
+        $content = $data['content'];
+        // 去除 <style> 和 <script> 标签及其内容
+        $content = preg_replace('/<(style|script)[^>]*>.*?<\/\1>/is', '', $content);
+        // 去除所有 HTML 标签
+        $content = strip_tags($content);
+        // 去除 HTML 实体
+        $content = html_entity_decode($content, ENT_QUOTES | ENT_HTML5, 'UTF-8');
+        // 只保留文本和标点符号(去除所有字母数字以外的特殊符号,可根据需要调整正则)
+        $content = preg_replace('/[^\p{L}\p{N}\p{P}\p{Zs}]+/u', '', $content);
+        // 去除多余空白
+        $content = preg_replace('/\s+/u', '', $content);
+        // 截取 100 个字符
+        $articleData['introduce'] = mb_substr($content, 0, 100);
+      }
+      if ($articleData['status'] == 0) {
+        $this->sendMessage([
+          'talk_type' => 100,
+          'title' => $articleData['title'],
+          'content' => '提交了审核',
+          'messageType' => 2,
+        ]);
+      }
+      $id = Article::where(['id' => $data['id']])->update($articleData);
+      // $articleDataContent = [
+      //   'content' => $data['content'],
+      // ];
+      // 采集来的文章,content中可能包含div标签,需要先移除
+      $pattern = '/<\/?div\b(?:[^"\'>]|"[^"]*"|\'[^\']*\')*>/is';
+      $article_data = preg_replace($pattern, '', $data['content']);
+      $articleDataContent['content'] = $article_data;
+      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]);
+      }
+      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
+  {
+    $articleData = Article::where(['id' => $data['id']])->first();
+    //发送10次
+    // for ($i = 0; $i < 10; $i++) {
+    //   $this->sendMessage([
+    //     'talk_type' => 100,
+    //     'title' => $i . $articleData['title'],
+    //     'content' => '审核通过',
+    //     'messageType' => 2,
+    //     'user_id' => $articleData['admin_user_id'],
+    //   ]);
+    // }
+    // var_dump($data['status'], 'status');
+    // return Result::success();
+
+    if ($data['status'] == 1) {
+      $this->sendMessage([
+        'talk_type' => 101,
+        'title' => $articleData['title'],
+        'content' => '审核通过',
+        'messageType' => 2,
+        'user_id' => $articleData['admin_user_id'],
+      ]);
+    }
+    if ($data['status'] == 2) {
+      $this->sendMessage([
+        'talk_type' => 101,
+        'title' => $articleData['title'],
+        'content' => '审核拒绝',
+        'messageType' => 2,
+        'user_id' => $articleData['admin_user_id'],
+      ]);
+    }
+    if ($data['status'] == 0) {
+      $this->sendMessage([
+        'talk_type' => 100,
+        'title' => $articleData['title'],
+        'content' => '提交了审核',
+        'messageType' => 2,
+      ]);
+    }
+
+
+    $result = Article::where(['id' => $data['id']])->update($data);
+
+    // ------c_show_time********up_status*******
+    // 若是审核通过  则更新c_show_time
+    if ($data['status'] == 1) {
+      // 查找网站,若是核心站则返回字段is_core=1,否则返回is_core=0,若是不存在此网站则为is_core=2
+      $web = Article::where('article.id', $data['id'])
+        ->leftJoin('website_category', 'article.catid', 'website_category.category_id')
+        ->leftJoin('website', 'website_category.website_id', '=', 'website.id')
+        ->select(
+          'website_id',
+          Db::raw('CASE WHEN website.id IS NULL THEN 2 WHEN JSON_CONTAINS(website.`website_column_arr_id`, \'3\') THEN 1 ELSE 0 END as is_core')
+        )
+        ->get();
+      // 非核心站与核心站----显示时间-----间隔
+      $time = 20;
+      // 若不是采集来的文章,则非核心站之间的间隔时间为5分钟;初始时间与当前时间差二十分钟
+      $waiting_interval = 5;
+      $webArray = $web->toArray();
+      if (empty($webArray)) {
+        throw new \Exception('网站分类不存在');
+      }
+      // 直接使用当前系统时间,不再强制添加8小时
+      $now = date('Y-m-d H:i:s');
+      $article_ignore = array_values(array_filter(array_map(function ($index, $item) use (&$time, $now, $data, $waiting_interval) {
+        if (isset($data['ignore_ids'])) {
+          $ignore_website_ids = is_array($data['ignore_ids']) ? $data['ignore_ids'] : json_decode($data['ignore_ids'], true);
+          if (in_array($item['website_id'], $ignore_website_ids)) {
+            $is_ignore = 1;
+          } else {
+            $is_ignore = 0;
+          }
+          return [
+            'article_id' => $data['id'],
+            'website_id' => $item['website_id'],
+            'is_ignore' => $is_ignore,
+          ];
+        } else {
+          // 检查 $item 对象是否有 is_core 属性
+          if (!isset($item['is_core'])) {
+            throw new \Exception('$item 对象缺少 is_core 属性');
+          }
+          // 当 is_core 为 2 时,则表示此网站不存在
+          if ($item['is_core'] == 2) {
+            return null;
+          } else if ($item['is_core'] == 1) {
+            // 当 is_core 为 1 时,则表示此网站是核心站
+            $c_show_time = $now;
+          } else {
+            // 若是is_core为0,则表示此网站不是核心站,需要往后推时间
+            $c_show_time = date('Y-m-d H:i:s', strtotime($now) + $time * 60);
+            if ($item['is_core'] == 0) {
+              $time += $waiting_interval;
+            }
+          }
+
+          return [
+            'article_id' => $data['id'],
+            'website_id' => $item['website_id'],
+            'c_show_time' => $c_show_time,
+          ];
+        }
+      }, array_keys($webArray), $webArray)));
+      if (!empty($article_ignore) && !isset($data['ignore_ids'])) {
+        // 使用 upsert 方法,当 article_id 和 website_id 组合存在时更新 c_show_time,不存在时插入新记录
+        // 使用 upsert 方法,根据 article_id 和 website_id 作为唯一键判断记录是否存在,存在则更新 c_show_time 字段,不存在则新增
+        $websiteIds = $web->pluck('website_id')->toArray();
+        $del_article_ignore = ArticleIgnore::where('article_id', $data['id'])->whereNotIn('website_id', $websiteIds)->delete();
+        $article_ignores = ArticleIgnore::upsert(
+          $article_ignore,
+          ['article_id', 'website_id'], // 用于判断记录是否存在的唯一键
+          ['c_show_time'] // 需要更新的字段
+        );
+        if (!$article_ignores) {
+          throw new \Exception('c端展示时间插入失败');
+        }
+      }
+      if (!empty($data['ignore_ids'])) {
+        // return Result::success($article_ignore);
+        // 从数据库中删除 article_id 为 $data['id'] 且 website_id 在 $website_ids 中的记录
+        if (!empty($article_ignore)) {
+          $article_ignores = ArticleIgnore::upsert(
+            $article_ignore,
+            ['article_id', 'website_id'], // 用于判断记录是否存在的唯一键
+            ['is_ignore'] // 需要更新的字段
+          );
+          // if(!$article_ignores){
+          //   throw new \Exception('屏蔽网站更新失败');
+          // }
+        }
+      }
+    }
+    // ------c_show_time********up_status*******
+
+    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
+  {
+    $website_id = $data['website_id'];
+    $website = Website::where('id', $data['website_id'])->first();
+    if (empty($website)) {
+      return Result::error("网站不存在", 0);
+    }
+    $categorys = $this->processArticlePro($website_id);
+    $catiall = $categorys['catiall'];
+    $categoryIds = $categorys['categoryIds'];
+    $where = [
+      'status' => 1
+    ];
+    // $website_column = $website['column'];
+    if (!empty($website['website_column_arr_id']) && $website['website_column_arr_id'] != '[]') {
+      $website_column = json_decode($website['website_column_arr_id'], true);
+    }
+    $diff_pid_categoryIds = array_values($categorys['diff_pid_categoryIds']);
+    // return Result::success($diff_pid_categoryIds);
+    if (in_array(3, $website_column) && !empty($diff_pid_categoryIds)) {
+      return Result::error("此为核心站,有父级导航" . implode(',', $diff_pid_categoryIds) . "未选择而选择了此子级!", 0);
+    }
+
+    // $website_id = $data['website_id'];
+    $month = date("Y-m-d H:i:s", strtotime("-30 day"));
+    //如果是4:最新资讯(数据库已不存在) 5:资讯推荐(数据库已不存在);
+    // 1:头条资讯;2:轮播图;6:热点资讯;(数据库)
+    switch ($data['level']) {
+      case 1:
+      case 2:
+      case 3:
+      case 6:             //1.头条资讯;2.轮播图;3.推荐图;6.今日热点
+        $query = Article::where($where)
+          ->where('level', 'like', '%' . $data['level'] . '%')
+          ->orderBy('updated_at', 'desc');
+        break;
+      case 4:             //最新资讯
+        $query = Article::where($where)->orderBy('updated_at', 'desc');
+        break;
+      case 5:             //资讯推荐
+        $query = Article::where($where)
+          ->where('updated_at', '>', $month);
+        break;
+      case 7:             //资讯分类
+
+        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 . '%'];
+          }
+          $query = Article::where($where)->where($whereL7)->orderBy('updated_at', 'desc');;
+          break;
+        } else {
+          return Result::error("请输入资讯ID", 0);
+          break;
+        }
+      default:
+        break;
+    }
+    // $whereL7 = [];
+    // if(isset($data['id']) && !empty($data['id'])){
+    //     $keyword = Article::where('id', $data['id'])->value('keyword');
+    //     $keywordArray = explode(',', $keyword);
+
+    //     foreach ($keywordArray as $k => $v) {
+    //         $whereL7[] = ['keyword', 'like', '%' . $v . '%'];
+    //     }
+    // }
+
+    // $query = Article::where($where)
+    //         ->when(isset($data['level']) && !empty($data['level']), function ($query) use ($data,$whereL7) {
+    //             if($data['level'] == 1 || $data['level'] == 2 || $data['level'] == 3 || $data['level'] == 6){
+    //                 $query = $query->where('article.level','like','%'.$data['level'].'%')->orderBy('updated_at','desc');
+    //             }
+    //             if($data['level'] == 7){
+    //                 $query = $query->where($whereL7)->orderBy('updated_at','desc');
+    //             }
+    //             if($data['level'] == 4){
+    //                 $query = $query->inRandomOrder()
+    //                 ->where('updated_at', '>', date("Y-m-d H:i:s", strtotime("-30 day")));
+    //             }
+    //             if($data['level'] == 5){
+    //                 $query = $query->orderBy('updated_at','desc');
+    //             }
+    //         });
+    if ($data['textnum'] > 0) {
+      $query = clone $query;
+      $result['text'] = $query
+        ->whereIn('catid', $categoryIds)
+        ->leftJoinSub(function ($query) use ($website_id) {
+          $query->from('article_ignore')
+            ->where('website_id', $website_id);
+        }, 'article_ignore', function ($join) {
+          $join->on('article_ignore.article_id', '=', 'article.id');
+        })
+        ->where(function ($query) {
+          $query->whereNull('article_ignore.article_id')
+            ->orWhere(function ($subQuery) {
+              $subQuery->whereNotNull('article_ignore.article_id')
+                ->where('article_ignore.is_ignore', 0)
+                ->where(function ($subSubQuery) {
+                  $subSubQuery->where('article_ignore.c_show_time', '<=', date('Y-m-d H:i:s'))
+                    ->orWhereNull('article_ignore.c_show_time');
+                });
+            });
+        })
+        // ->where(function ($query) use ($website_id) {
+        //   $query->whereNull('article_ignore.article_id')
+        //     ->orWhere('article_ignore.website_id', '!=', $website_id);
+        // })
+        ->select(
+          'article.id',
+          'article.title',
+          'article.author',
+          'article.updated_at',
+          'article.introduce',
+          'article.islink',
+          'article.linkurl',
+          'article.copyfrom',
+          'article.cat_arr_id',
+          'article.catid',
+          'article.level',
+          // 'article_ignore.is_ignore',
+          // 'article_ignore.c_show_time',
+        )
+        ->offset($data['placeid'])
+        ->limit($data['textnum'])
+        ->get()->all();
+      foreach ($result['text'] as $k => $v) {
+        $result['text'][$k]->pinyin = $catiall[$v->catid]['pinyin'];
+        $result['text'][$k]->alias = $catiall[$v->catid]['alias'];
+      }
+    }
+    if ($data['imgnum'] > 0) {
+      $query = clone $query;
+      if ($data['textnum'] == 0) {
+        $query = $query->leftJoinSub(function ($query) use ($website_id) {
+          $query->from('article_ignore')
+            ->where('website_id', $website_id);
+        }, 'article_ignore', function ($join) {
+          $join->on('article_ignore.article_id', '=', 'article.id');
+        })
+          ->where(function ($query) {
+            $query->whereNull('article_ignore.article_id')
+              ->orWhere(function ($subQuery) {
+                $subQuery->whereNotNull('article_ignore.article_id')
+                  ->where('article_ignore.is_ignore', 0)
+                  ->where(function ($subSubQuery) {
+                    $subSubQuery->where('article_ignore.c_show_time', '<=', date('Y-m-d H:i:s'))
+                      ->orWhereNull('article_ignore.c_show_time');
+                  });
+              });
+          });
+      }
+      $result['img'] = $query
+        ->whereIn('catid', $categoryIds)
+        ->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',
+          'article.level',
+          // 'article_ignore.is_ignore',
+          // 'article_ignore.c_show_time',
+        )
+        ->offset($data['placeid'])
+        ->limit($data['imgnum'])
+        ->get()->all();
+      foreach ($result['img'] as $k => $v) {
+        $result['img'][$k]->pinyin = $catiall[$v->catid]['pinyin'];
+        $result['img'][$k]->alias = $catiall[$v->catid]['alias'];
+      }
+    }
+
+    if (empty($result)) {
+      return Result::error("暂无相关资讯", 0);
+    }
+    return Result::success($result);
+  }
+  /**
+   * 获取模块新闻
+   * @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 = '[]'");
+        })
+        ->leftJoinSub(function ($query) use ($data) {
+          $query->from('article_ignore')
+            ->where('website_id', $data['website_id']);
+        }, 'article_ignore', function ($join) {
+          $join->on('article_ignore.article_id', '=', 'article.id');
+        })
+        ->where(function ($query) {
+          $query->whereNull('article_ignore.article_id')
+            ->orWhere(function ($subQuery) {
+              $subQuery->whereNotNull('article_ignore.article_id')
+                ->where('article_ignore.is_ignore', 0)
+                ->where(function ($subSubQuery) {
+                  $subSubQuery->where('article_ignore.c_show_time', '<=', date('Y-m-d H:i:s'))
+                    ->orWhereNull('article_ignore.c_show_time');
+                });
+            });
+        })
+        // ->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];
+    $website_id = $data['website_id'];
+    $website = Website::where('id', $data['website_id'])->first();
+    if (empty($website)) {
+      return Result::error("网站不存在", 0);
+    }
+    // $website_column = $website['column'];
+    if (!empty($website['website_column_arr_id']) && $website['website_column_arr_id'] != '[]') {
+      $website_column = json_decode($website['website_column_arr_id'], true);
+    }
+    $categorys = $this->processArticlePro($website_id);
+    $cat_1st_arr = $categorys['cat_1st_arr'];
+    $catiall = $categorys['catiall'];
+    $diff_pid_categoryIds = array_values($categorys['diff_pid_categoryIds']);
+    // return Result::success($diff_pid_categoryIds);
+    if (in_array(3, $website_column) && !empty($diff_pid_categoryIds)) {
+      return Result::error("此为核心站,有父级导航" . implode(',', $diff_pid_categoryIds) . "未选择而选择了此子级!", 0);
+    }
+    if (isset($data['catid']) && !empty($data['catid'])) {
+      $category = WebsiteCategory::where('website_id', $data['website_id'])->where('category_id', $data['catid'])->pluck('category_id');
+      if (empty($category)) {
+        return Result::error("此网站暂无此栏目", 0);
+      }
+      array_push($where, ['catid', '=', $data['catid']]);
+    }
+    // return Result::success($where);
+    $query = Article::where($where)
+      ->leftJoinSub(function ($query) use ($website_id) {
+        $query->from('article_ignore')
+          ->where('website_id', $website_id);
+      }, 'article_ignore', function ($join) {
+        $join->on('article_ignore.article_id', '=', 'article.id');
+      })
+      ->where(function ($query) {
+        $query->whereNull('article_ignore.article_id')
+          ->orWhere(function ($subQuery) {
+            $subQuery->whereNotNull('article_ignore.article_id')
+              ->where('article_ignore.is_ignore', 0)
+              ->where(function ($subSubQuery) {
+                $subSubQuery->where('article_ignore.c_show_time', '<=', date('Y-m-d H:i:s'))
+                  ->orWhereNull('article_ignore.c_show_time');
+              });
+          });
+      })
+      ->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'
+      );
+    $count = $query->count();
+    $rep = $query->orderBy("updated_at", "desc")
+      ->offset(($data['page'] - 1) * $data['pageSize'])
+      ->limit($data['pageSize'])
+      ->get()->all();
+    $categorys = $this->processArticlePro($website_id);
+    $cat_1st_arr = $categorys['cat_1st_arr'];
+    $catiall = $categorys['catiall'];
+    // $web['website_id'] = $data['website_id'];
+    foreach ($rep as $k => $v) {
+      $rep[$k]->category_name = $catiall[$v->catid]['alias'];
+      $rep[$k]->pinyin = $catiall[$v->catid]['pinyin'];
+    }
+    // $rep = $this->processArticles($rep,$web);
+    $data = [
+      'rows' => $rep,
+      '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")
+      ->leftJoin("article_extend", "article_extend.article_id", "article.id")
+      // ->where(function ($query) use ($data) {
+      //   $query->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($data['website_id']) . "') = 0")
+      //     ->orWhereNull("ignore_ids");
+      // })
+      ->leftJoinSub(function ($query) use ($data) {
+        $query->from('article_ignore')
+          ->where('website_id', $data['website_id']);
+      }, 'article_ignore', function ($join) {
+        $join->on('article_ignore.article_id', '=', 'article.id');
+      })
+      ->where(function ($query) {
+        $query->whereNull('article_ignore.article_id')
+          ->orWhere(function ($subQuery) {
+            $subQuery->whereNotNull('article_ignore.article_id')
+              ->where('article_ignore.is_ignore', 0)
+              ->where(function ($subSubQuery) {
+                $subSubQuery->where('article_ignore.c_show_time', '<=', date('Y-m-d H:i:s'))
+                  ->orWhereNull('article_ignore.c_show_time');
+              });
+          });
+      })
+      ->select(
+        'article.*',
+        'article_data.content',
+        'article_data.article_id',
+        'article_extend.website_url',
+        'article_extend.email',
+        'article_extend.contacts',
+        'article_extend.contacts_mobile',
+        'article_extend.contacts_address',
+        'article_extend.zip_code',
+        'article_extend.enterprise_name'
+      )
+      ->first();
+    if (empty($result)) {
+      return Result::error("暂无此新闻!", 0);
+    }
+    if (!empty($result['publiced_at'])) {
+      $result['updated_at'] = $result['publiced_at'];
+    }
+
+    $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']) : [];
+    if (empty($commend_ids)) {
+      $commendArticle = [];
+    } else {
+      //去除不存在的文章ID
+      $commendArticle = Article::whereIn('article.id', $commend_ids)
+        ->leftjoin('website_category', 'website_category.category_id', '=', 'article.catid')
+        ->leftJoinSub(function ($query) use ($data) {
+          $query->from('article_ignore')
+            ->where('website_id', $data['website_id']);
+        }, 'article_ignore', function ($join) {
+          $join->on('article_ignore.article_id', '=', 'article.id');
+        })
+        ->where(function ($query) {
+          $query->whereNull('article_ignore.article_id')
+            ->orWhere(function ($subQuery) {
+              $subQuery->whereNotNull('article_ignore.article_id')
+                ->where('article_ignore.is_ignore', 0)
+                ->where(function ($subSubQuery) {
+                  $subSubQuery->where('article_ignore.c_show_time', '<=', date('Y-m-d H:i:s'))
+                    ->orWhereNull('article_ignore.c_show_time');
+                });
+            });
+        })
+        ->where('article.status', 1)
+        ->where('website_category.website_id', $data['website_id'])
+        ->select('article.id', 'article.cat_arr_id', 'article.title', 'article.catid', 'article.imgurl', 'article.hits', 'article.created_at', 'website_category.alias', 'website_category.alias_pinyin', 'website_category.website_id')
+        ->orderByRaw("FIELD(article.id, " . implode(',', $commend_ids) . ")")
+        // ->orderBy('article.updated_at', 'desc')
+        ->limit(5)
+        ->get();
+      //循环数组,取出cat_arr_id中的不重复值,再从website_category取出alias_pinyin,再将cat_arr_id的json转成路径/隔开
+      foreach ($commendArticle as $k => $v) {
+        $cat_arr_id = json_decode($v->cat_arr_id, true);
+        if (!empty($cat_arr_id) && is_array($cat_arr_id)) {
+          $cat_arr_id = array_unique($cat_arr_id);
+          // 从website_category取出alias_pinyin
+          $cat_arr  = WebsiteCategory::where('website_id', $data['website_id'])
+            ->whereIn('category_id', $cat_arr_id)
+            ->pluck('alias_pinyin', 'category_id')
+            ->toArray();
+
+          // 将cat_arr_id的json转成路径/隔开
+          $path_parts = [];
+          foreach ($cat_arr_id as $cat_id) {
+            if (isset($cat_arr[$cat_id])) {
+              $path_parts[] = $cat_arr[$cat_id];
+            }
+          }
+          $v->alias_pinyin = implode('/', $path_parts);
+        } else {
+          $v->alias_pinyin = '';
+        }
+      }
+    }
+
+    $result['category_id'] = $category['category_id'];
+    $result['cat_name'] = $category['alias'];
+    $result['website_name'] = $category['website_name'] ?? "";
+    $result['suffix'] = $category['suffix'] ?? "";
+    $result['commendArticle'] = $commendArticle;
+    $result['commend_ids'] = $commend_ids;
+    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'];
+            }
+            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'] . '%']);
+    }
+    $survey_type = isset($data['survey_type']) && $data['survey_type'] !== '' ? $data['survey_type'] : null;
+    if (!empty($where)) {
+      // 修复:先关联 article 再按 survey_type 过滤,避免查不到数据
+      $query = ArticleSurvey::select(
+          'art_id as id',
+          Db::raw('MAX(id) as surid'),
+          Db::raw('MAX(survey_name) as survey_name'),
+          Db::raw('MAX(sur_id) as survey_id')
+      )
+      ->groupBy('art_id')
+      ->where($where)
+      ->when(!is_null($survey_type), function ($q) use ($survey_type) {
+          $q->whereIn('art_id', function ($sub) use ($survey_type) {
+              $sub->select('id')
+                  ->from('article')
+                  ->where('survey_type', $survey_type);
+          });
+      })
+      ->with(['article' => function ($query) {
+          $query->select('id', 'survey_type','created_at','updated_at','created_at');
+      }]);
+      ;
+  }else{
+    $query = ArticleSurvey::select(
+        'art_id as id',
+        Db::raw('MAX(id) as surid'),
+        Db::raw('MAX(survey_name) as survey_name'),
+        Db::raw('MAX(sur_id) as survey_id'),
+    )
+    ->groupBy('art_id')
+    ->when(!is_null($survey_type), function ($q) use ($survey_type) {
+          $q->whereIn('art_id', function ($sub) use ($survey_type) {
+              $sub->select('id')
+                  ->from('article')
+                  ->where('survey_type', $survey_type);
+          });
+      })
+    ->with(['article' => function ($query) {
+      $query->select('id', 'survey_type','created_at','updated_at','created_at');
+    }]);
+  }
+      $count = $query->get()->count();
+
+    // 简单写法:直接统计分组后的 art_id 数量
+    $survey = $query->orderBy('id', 'desc')
+      ->limit($data['pageSize'])
+      ->offset(($data['page'] - 1) * $data['pageSize'])
+      ->get();
+    if (empty($survey->toArray())) {
+      return Result::error("暂无调查问卷!", 0);
+    }
+    $survey = array_map(function ($item) {
+      $item['survey_type'] = $item['article']['survey_type'];
+      $item['created_at'] = $item['article']['created_at'];
+      $item['updated_at'] = $item['article']['updated_at'];
+      unset($item['article']);
+      return $item;
+    }, $survey->toArray());
+    $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('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
+  {
+    $website = Website::where('id', $data['website_id'])->first();
+    if (empty($website)) {
+      return Result::error("网站不存在", 0);
+    }
+    // $website_column = $website['column'];
+    if (!empty($website['website_column_arr_id']) && $website['website_column_arr_id'] != '[]') {
+      $website_column = json_decode($website['website_column_arr_id'], true);
+    }
+    $website_id = $data['website_id'];
+    $categorys = $this->processArticlePro($website_id);
+    $diff_pid_categoryIds = array_values($categorys['diff_pid_categoryIds']);
+
+    // return Result::success($diff_pid_categoryIds);
+    if (in_array(3, $website_column) && !empty($diff_pid_categoryIds)) {
+      return Result::error("此为核心站,有父级导航" . implode(',', $diff_pid_categoryIds) . "未选择而选择了此子级!", 0);
+    }
+    // return Result::success(reset($diff_pid_categoryIds) == 0);
+    // $cat_1st_arr = $categorys['cat_1st_arr'];
+    $catiall = $categorys['catiall'];
+    $categoryIds = $categorys['categoryIds'];
+    // return Result::success($categoryIds);
+    $query = Article::where('status', 1)
+      ->whereIn('catid', $categoryIds)
+      ->leftJoinSub(function ($query) use ($website_id) {
+        $query->from('article_ignore')
+          ->where('website_id', $website_id);
+      }, 'article_ignore', function ($join) {
+        $join->on('article_ignore.article_id', '=', 'article.id');
+      })
+      ->where(function ($query) {
+        $query->whereNull('article_ignore.article_id')
+          ->orWhere(function ($subQuery) {
+            $subQuery->whereNotNull('article_ignore.article_id')
+              ->where('article_ignore.is_ignore', 0)
+              ->where(function ($subSubQuery) {
+                $subSubQuery->where('article_ignore.c_show_time', '<=', date('Y-m-d H:i:s'))
+                  ->orWhereNull('article_ignore.c_show_time');
+              });
+          });
+      });
+    // ->get()->all();
+    // return Result::success($query);
+    if (isset($data['cityid']) && !empty($data['cityid'])) {
+      $query->whereRaw("JSON_CONTAINS(article.city_arr_id, '" . intval($data['cityid']) . "')");
+    }
+    if (isset($data['department_id']) && !empty($data['department_id'])) {
+      $query->whereRaw("JSON_CONTAINS(article.department_arr_id, '" . intval($data['department_id']) . "')");
+    }
+    if (isset($data['keyword']) && !empty($data['keyword'])) {
+      $query->where('article.title', 'like', '%' . $data['keyword'] . '%');
+    }
+    // 计算总数
+    $count = $query->count();
+    // return Result::success($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',
+        // 'article_ignore.c_show_time',
+        // 'article_ignore.is_ignore'
+      )
+      ->orderBy("updated_at", "desc")
+      ->offset(($data['page'] - 1) * $data['pageSize'])
+      ->limit($data['pageSize'])
+      ->get();
+    //    return Result::success($articles);
+    foreach ($articles as $k => $v) {
+      $articles[$k]->category_name = $catiall[$v->catid]['alias'];
+      $articles[$k]->pinyin = $catiall[$v->catid]['pinyin'];
+    }
+    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'],
+    ];
+    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 = [];
+      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);
+  }
+  /**
+   * 模块新闻加强plus版 
+   * @param array $data
+   * @return array
+   */
+  public function getWebsiteAllArticle(array $data): array
+  {
+    // return Result::success($data);
+    $time1 = microtime(true);
+    $wetbsite_id = $data['website_id'] ?? 2;
+    $data = json_decode($data['id'], true);
+
+    $website = Website::where('id', $wetbsite_id)->first();
+    if (empty($website)) {
+      return Result::error("网站不存在", 0);
+    }
+    // return Result::success($website);
+    $website_column = $website['website_column_arr_id'] ?? '[]';
+
+    $website_column = json_decode($website_column, true);
+
+    $categorys = $this->processArticlePro($wetbsite_id);
+    $cat_1st_arr = $categorys['cat_1st_arr'];
+    $catiall = $categorys['catiall'];
+
+    // return Result::success($catiall);
+    $diff_pid_categoryIds = $categorys['diff_pid_categoryIds'];
+    if (in_array(3, $website_column) && !empty($diff_pid_categoryIds)) {
+      return Result::error("此为核心站,有父级导航" . implode(',', $diff_pid_categoryIds) . "未选择而选择了此子级!", 0);
+    }
+    $websiteInfoIndexed = $categorys['websiteInfoIndexed'];
+    // return Result::success($categorys);
+    $parent_category = array_column($data, 'parent');
+    $parent_cat = [];
+    $child_category = array_column($data, 'child');
+    if (!empty($parent_category)) {
+      foreach ($parent_category as $key => $value) {
+        $arr = array_map('intval', explode(',', $value));
+        $parent_cat[$key] = $arr[0] ?? 0;
+        $parent_category = $arr[0] ?? 0;
+        $article_imgnum = $arr[1] ?? 0;
+        $article_textnum = $arr[2] ?? 0;
+        if ($parent_category != 0) {
+          $category_arr = array_merge([$parent_category], $cat_1st_arr[$parent_category] ?? [0]);
+          // return Result::success($category_arr);
+          if ($article_imgnum != 0) {
+            $img_article = Article::whereIn('catid', $category_arr)
+              ->where('status', 1)
+              ->where('imgurl', '!=', '')
+              ->leftJoinSub(function ($query) use ($wetbsite_id) {
+                $query->from('article_ignore')
+                  ->where('website_id', $wetbsite_id);
+              }, 'article_ignore', function ($join) {
+                $join->on('article_ignore.article_id', '=', 'article.id');
+              })
+              ->where(function ($query) {
+                $query->whereNull('article_ignore.article_id')
+                  ->orWhere(function ($subQuery) {
+                    $subQuery->whereNotNull('article_ignore.article_id')
+                      ->where('article_ignore.is_ignore', 0)
+                      ->where(function ($subSubQuery) {
+                        $subSubQuery->where('article_ignore.c_show_time', '<=', date('Y-m-d H:i:s'))
+                          ->orWhereNull('article_ignore.c_show_time');
+                      });
+                  });
+              })
+              ->select('article.id', 'article.title', 'article.imgurl', 'article.author', 'article.updated_at', 'article.introduce', 'article.islink', 'article.linkurl', 'article.copyfrom', 'article.cat_arr_id', 'article.catid')
+              ->orderBy('updated_at', 'desc')
+              ->limit($article_imgnum)
+              ->get()->all();
+            foreach ($img_article as $k => $v) {
+              $img_article[$k]->category_name = $catiall[$v->catid]['alias'];
+              $img_article[$k]->pinyin = $catiall[$v->catid]['pinyin'];
+            }
+          } else {
+            $img_article = [];
+          }
+          if ($article_textnum != 0) {
+            $text_article = Article::whereIn('catid', $category_arr)
+              ->where('status', 1)
+              ->leftJoinSub(function ($query) use ($wetbsite_id) {
+                $query->from('article_ignore')
+                  ->where('website_id', $wetbsite_id);
+              }, 'article_ignore', function ($join) {
+                $join->on('article_ignore.article_id', '=', 'article.id');
+              })
+              ->where(function ($query) {
+                $query->whereNull('article_ignore.article_id')
+                  ->orWhere(function ($subQuery) {
+                    $subQuery->whereNotNull('article_ignore.article_id')
+                      ->where('article_ignore.is_ignore', 0)
+                      ->where(function ($subSubQuery) {
+                        $subSubQuery->where('article_ignore.c_show_time', '<=', date('Y-m-d H:i:s'))
+                          ->orWhereNull('article_ignore.c_show_time');
+                      });
+                  });
+              })
+              ->select('id', 'title', 'author', 'updated_at', 'introduce', 'islink', 'linkurl', 'copyfrom', 'cat_arr_id', 'catid')
+              ->orderBy('updated_at', 'desc')
+              ->limit($article_textnum)
+              ->get()->all();
+            foreach ($text_article as $k => $v) {
+              $text_article[$k]->category_name = $catiall[$v->catid]['alias'];
+              $text_article[$k]->pinyin = $catiall[$v->catid]['pinyin'];
+              // $text_article[$k]->alias = $catiall[$v->catid]['alias'];
+            }
+          } else {
+            $text_article = [];
+          }
+          $catiall[$parent_category]['imgnum'] = $img_article;
+          $catiall[$parent_category]['textnum'] = $text_article;
+          $parent[$key] = $catiall[$parent_category];
+        } else {
+          $parent[$key] = '';
+        }
+      }
+    }
+    if (!empty($child_category)) {
+      foreach ($child_category as $key => $value) {
+        $arr = array_map('intval', explode(',', $value));
+        $parent_category = $parent_cat[$key];
+        $child_category = $arr[0] ?? 0;
+        $article_imgnum = $arr[1] ?? 0;
+        $article_textnum = $arr[2] ?? 0;
+
+        if ($child_category != 0) {
+          $all_childcat = $cat_1st_arr[$parent_category];
+          $processedChildCat = array_map(function ($v) use ($websiteInfoIndexed) {
+            // 从 $websiteInfoIndexed 中获取对应的数据
+            $info = $websiteInfoIndexed[$v];
+            // 返回一个包含所需信息的数组
+            return [
+              'alias' => $info->alias,
+              'category_id' => $info->category_id,
+              'aLIas_pinyin' => $info->aLIas_pinyin,
+              'pid' => $info->pid,
+              'type' => $info->type,
+              'cat_arr_id' => $info->category_arr_id ?? ['出错'],
+              'pinyin' => $info->pinyin,
+            ];
+          }, $all_childcat);
+          if ($article_imgnum != 0) {
+            $img_article = Article::where('catid', $child_category)
+              ->where('status', 1)
+              ->where('imgurl', '!=', '')
+              ->leftJoinSub(function ($query) use ($wetbsite_id) {
+                $query->from('article_ignore')
+                  ->where('website_id', $wetbsite_id);
+              }, 'article_ignore', function ($join) {
+                $join->on('article_ignore.article_id', '=', 'article.id');
+              })
+              ->where(function ($query) {
+                $query->whereNull('article_ignore.article_id')
+                  ->orWhere(function ($subQuery) {
+                    $subQuery->whereNotNull('article_ignore.article_id')
+                      ->where('article_ignore.is_ignore', 0)
+                      ->where(function ($subSubQuery) {
+                        $subSubQuery->where('article_ignore.c_show_time', '<=', date('Y-m-d H:i:s'))
+                          ->orWhereNull('article_ignore.c_show_time');
+                      });
+                  });
+              })
+              ->select('id', 'title', 'imgurl', 'author', 'updated_at', 'introduce', 'islink', 'linkurl', 'copyfrom', 'cat_arr_id', 'catid')
+              ->orderBy('updated_at', 'desc')
+              ->limit($article_imgnum)
+              ->get()->all();
+            foreach ($img_article as $k => $v) {
+              // var_dump($v);
+              // var_dump($k);
+              $img_article[$k]->category_name = $catiall[$v->catid]['alias'];
+              $img_article[$k]->pinyin = $catiall[$v->catid]['pinyin'];
+            }
+          } else {
+            $img_article = [];
+          }
+          if ($article_textnum != 0) {
+            $text_article = Article::where('catid', $child_category)
+              ->where('status', 1)
+              ->leftJoinSub(function ($query) use ($wetbsite_id) {
+                $query->from('article_ignore')
+                  ->where('website_id', $wetbsite_id);
+              }, 'article_ignore', function ($join) {
+                $join->on('article_ignore.article_id', '=', 'article.id');
+              })
+              ->where(function ($query) {
+                $query->whereNull('article_ignore.article_id')
+                  ->orWhere(function ($subQuery) {
+                    $subQuery->whereNotNull('article_ignore.article_id')
+                      ->where('article_ignore.is_ignore', 0)
+                      ->where(function ($subSubQuery) {
+                        $subSubQuery->where('article_ignore.c_show_time', '<=', date('Y-m-d H:i:s'))
+                          ->orWhereNull('article_ignore.c_show_time');
+                      });
+                  });
+              })
+              ->select('id', 'title', 'author', 'updated_at', 'introduce', 'islink', 'linkurl', 'copyfrom', 'cat_arr_id', 'catid')
+              ->orderBy('updated_at', 'desc')
+              ->limit($article_textnum)
+              ->get()->all();
+            foreach ($text_article as $k => $v) {
+              // var_dump($v);
+              // var_dump($k);
+              $text_article[$k]->category_name = $catiall[$v->catid]['alias'];
+              // $text_article[$k]->pinyin = $catiall[$v->catid]['pinyin'];
+              $text_article[$k]->pinyin = $catiall[$v->catid]['pinyin'];
+            }
+          } else {
+            $text_article = [];
+          }
+          $catiall[$child_category]['all_childcat'] = $processedChildCat;
+          $catiall[$child_category]['imgnum'] = $img_article;
+          $catiall[$child_category]['textnum'] = $text_article;
+          $child[$key] = $catiall[$child_category];
+          // var_dump($pids);
+        } else {
+          $child[$key] = '';
+        }
+      }
+    }
+    foreach ($parent as $key => $value) {
+      $result[$key] = $value;
+      if (!empty($child[$key])) {
+        // var_dump($child[$key]);
+
+        $result[$key]['child'] = $child[$key];
+        // $value[$key]['child'] = $child[$key];
+      } else {
+        $result[$key]['child'] = [
+          "alias" => null,
+          "category_id" => null,
+          "type" => null,
+          "pinyin" => null,
+          "all_childcat" => [],
+          "imgnum" => [],
+          "textnum" => []
+        ];
+      }
+    }
+    return Result::success($result);
+  }
+
+  /**
+   * 辅助方法:获取文章列表
+   */
+  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');
+    }
+
+    $articles = $query->get();
+
+    return !empty($articles) ? $this->processArticles($articles, $website) : [];
+  }
+  /**
+   * 乡村网-获取特殊新闻模块
+   * @param array $data
+   * @return array
+   */
+  public function getWebsiteArticles(array $data): array
+  {
+    $website_id = $data['website_id'];
+    $website = Website::where('id', $website_id)->first();
+    if (empty($website)) {
+      return Result::error("网站不存在", 0);
+    }
+    // return Result::success($website);
+    $website_column = $website['website_column_arr_id'] ?? '[]';
+    $website_column = json_decode($website_column, true);
+    $catids = json_decode($data['id'], true);
+    $parent_category = array_column($catids, 'parent');
+
+    if (!empty($parent_category) && is_array($parent_category)) {
+      $categorys = $this->processArticlePro($website_id);
+      $diff_pid_categoryIds = $categorys['diff_pid_categoryIds'];
+      if (in_array(3, $website_column) && !empty($diff_pid_categoryIds)) {
+        return Result::error("此为核心站,有父级导航" . implode(',', $diff_pid_categoryIds) . "未选择而选择了此子级!", 0);
+      }
+      $catiall = $categorys['catiall'];
+      $cat_1st_arr = $categorys['cat_1st_arr'];
+      //  return Result::success($categorys);
+      foreach ($parent_category as $key => $value) {
+        $arr = array_map('intval', explode(',', $value));
+        $parent_category = $arr[0] ?? 0;
+        $article_imgnum = $arr[1] ?? 0;
+        $article_textnum = $arr[2] ?? 0;
+        if ($parent_category != 0) {
+          $category_arr = array_merge([$parent_category], $cat_1st_arr[$parent_category] ?? [0]);
+          // return Result::success($category_arr);
+          if ($article_imgnum != 0) {
+            $img_article = Article::whereIn('article.catid', $category_arr)
+              ->where('article.status', 1)
+              ->where('article.imgurl', '!=', '')
+              ->leftJoinSub(function ($query) use ($website_id) {
+                $query->from('article_ignore')
+                  ->where('website_id', $website_id);
+              }, 'article_ignore', function ($join) {
+                $join->on('article_ignore.article_id', '=', 'article.id');
+              })
+              ->where(function ($query) {
+                $query->whereNull('article_ignore.article_id')
+                  ->orWhere(function ($subQuery) {
+                    $subQuery->whereNotNull('article_ignore.article_id')
+                      ->where('article_ignore.is_ignore', 0)
+                      ->where(function ($subSubQuery) {
+                        $subSubQuery->where('article_ignore.c_show_time', '<=', date('Y-m-d H:i:s'))
+                          ->orWhereNull('article_ignore.c_show_time');
+                      });
+                  });
+              })
+              ->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 as category_id'
+              )
+              ->orderBy('updated_at', 'desc')
+              ->limit($article_imgnum)
+              ->get()->all();
+
+            foreach ($img_article as $k => $v) {
+              $img_article[$k]->alias = $catiall[$v->category_id]['alias'];
+              // return Result::success($v);
+
+              $img_article[$k]->aLIas_pinyin = $catiall[$v->category_id]['pinyin'];
+            }
+          } else {
+            $img_article = [];
+          }
+          if ($article_textnum != 0) {
+            $text_article = Article::whereIn('article.catid', $category_arr)
+              ->where('article.status', 1)
+              ->leftJoinSub(function ($query) use ($website_id) {
+                $query->from('article_ignore')
+                  ->where('website_id', $website_id);
+              }, 'article_ignore', function ($join) {
+                $join->on('article_ignore.article_id', '=', 'article.id');
+              })
+              ->where(function ($query) {
+                $query->whereNull('article_ignore.article_id')
+                  ->orWhere(function ($subQuery) {
+                    $subQuery->whereNotNull('article_ignore.article_id')
+                      ->where('article_ignore.is_ignore', 0)
+                      ->where(function ($subSubQuery) {
+                        $subSubQuery->where('article_ignore.c_show_time', '<=', date('Y-m-d H:i:s'))
+                          ->orWhereNull('article_ignore.c_show_time');
+                      });
+                  });
+              })
+              ->select(
+                'article.id',
+                'article.title',
+                'article.author',
+                'article.updated_at',
+                'article.introduce',
+                'article.islink',
+                'article.linkurl',
+                'article.copyfrom',
+                'article.cat_arr_id',
+                'article.catid as category_id'
+              )
+              ->orderBy('updated_at', 'desc')
+              ->limit($article_textnum)
+              ->get()->all();
+            foreach ($text_article as $k => $v) {
+              $text_article[$k]->alias = $catiall[$v->category_id]['alias'];
+              $text_article[$k]->aLIas_pinyin = $catiall[$v->category_id]['pinyin'];
+              // $text_article[$k]->alias = $catiall[$v->catid]['alias'];
+            }
+          } else {
+            $text_article = [];
+          }
+          $catiall[$parent_category]['imgnum'] = $img_article ?? [];
+          $catiall[$parent_category]['textnum'] = $text_article ?? [];
+          $parent[$key] = $catiall[$parent_category];
+        } else {
+          $parent[$key] = [];
+        }
+      }
+    }
+
+    return Result::success($parent);
+  }
+
+
+  // 封装处理商品的路由问题
+  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, true);
+        $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')
+            ->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 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');
+    if (isset($data['ismix']) && $data['ismix'] == 1) {
+      $result['count'] = $query->clone()->count();
+      $result['goods'] = $this->processGoods(
+        $query->clone()
+          ->offset(($data['page'] - 1) * $data['pageSize'])
+          ->limit($data['pageSize'])
+          ->get(),
+        $data
+      );
+    } else {
+      $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);
+  }
+  /**
+   * 获取商品详情
+   * @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);
+  }
+  /**
+   * plus  pro  处理文章路由问题
+   */
+  function processArticlePro($website_id)
+  {
+    // $categorys = WebsiteCategory::where('website_id', $website_id)->get()->all();
+    // // $websiteInfoIndexed = array_column($categorys, null, 'category_id');
+    // // 取出category_id 对应的aLIas_pinyin 
+    // $categoryIds = array_column($categorys, 'category_id');
+    // $categoryPIds = array_column($categorys, 'pid');
+    // $aliasPinyins = array_column($categorys, 'path');
+    // $alias = array_column($categorys, 'alias');
+    // $cat_arr = array_combine($categoryIds, $aliasPinyins);
+    // $cat_alias_arr = array_combine($categoryIds, $categoryPIds);
+    // // return Result::success($cat_arr);
+    // // $catiall = [];
+    // //一级所有子级的记录
+    // $cat_alias_arr = array_combine($categoryIds, $alias);
+    // return [
+    //     'cat_1st_arr' => $cat_alias_arr,
+    //     'catiall' => $cat_arr,
+    //     // 'websiteInfoIndexed' => $websiteInfoIndexed,
+    //     'categoryIds' => $categoryIds,
+    // ];
+    $categorys = WebsiteCategory::where('website_id', $website_id)->get()->all();
+    $websiteInfoIndexed = array_column($categorys, null, 'category_id');
+    // 取出category_id 对应的aLIas_pinyin 
+    $categoryIds = array_column($categorys, 'category_id');
+    $categoryPIds = array_values(array_unique(array_filter(array_column($categorys, 'pid'), function ($pid) {
+      return $pid != 0;
+    })));
+
+    $category_path = array_column($categorys, 'path');
+    $cat_arr = array_combine($categoryIds, $category_path);
+    // return Result::success(array_diff($categoryIds, $categoryPIds));
+    $catiall = [];
+    //一级所有子级的记录
+    $cat_1st_arr = [];
+    foreach ($categorys as $key => $value) {
+      // $category_arr_id = json_decode($value->category_arr_id);
+      // $pinyin_str = '';
+      // // 算出一级  并且算出子级
+      if ($value->pid != 0 && in_array($value->pid, $categoryIds)) {
+        $cat_1st_arr[$value->pid][] = $value->category_id;
+      }
+      // foreach ($category_arr_id as $k => $v) {
+      //     $pinyin_str .= $cat_arr[$v] . '/';
+      // }
+      // $pinyin_str = rtrim($pinyin_str, '/');
+      $catiall[$value->category_id]['alias'] = $value->alias;
+      $catiall[$value->category_id]['category_id'] = $value->category_id;
+      $catiall[$value->category_id]['type'] = $value->type;
+      $catiall[$value->category_id]['pinyin'] = $cat_arr[$value->category_id];
+      $websiteInfoIndexed[$value->category_id]->pinyin = $cat_arr[$value->category_id];
+    }
+    return [
+      'cat_1st_arr' => $cat_1st_arr,
+      'catiall' => $catiall,
+      'websiteInfoIndexed' => $websiteInfoIndexed,
+      'categoryIds' => $categoryIds,
+      'diff_pid_categoryIds' => array_diff($categoryPIds, $categoryIds),
+      'categoryPIds' => $categoryPIds,
+    ];
+  }
+  /**
+   * 封装处理文章的路由问题
+   *  */
+  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;
+    }
+  }
+  // 封装处理由问题
+  function processJob($job, $data)
+  {
+    return $job->map(function ($job) use ($data) {
+      $category = $job->cat_arr_id ?? '';
+      $cityid = $job->city_arr_id ?? '';
+      $city = json_decode($cityid, true);
+      $pinyin = '';
+      $level = json_decode($category, true);
+      // 路由
+      if (!empty($level) && is_array($level)) {
+        $pinyin = WebsiteCategory::whereIn('category_id', $level)
+          ->where('website_id', $data['website_id']) // 添加网站ID条件 
+          ->orderByRaw('FIELD(category_id, ' . implode(',', $level) . ')')
+          ->get(['aLIas_pinyin'])
+          ->pluck('aLIas_pinyin')
+          ->implode('/');
+        if (empty($pinyin)) {
+          $pinyin = $pinyin->aLIas_pinyin ?? '';
+        }
+        $job->pinyin = $pinyin;
+      }
+      // 取职位-城市  市??省
+      if (!empty($city) && is_array($city)) {
+        if (isset($city[1]) && !empty($city[1])) {
+          $city = District::where('id', $city[1])->first(['name']);
+          $job->city_name = $city->name ?? '';
+        } else if (isset($city[0]) && !empty($city[0])) {
+          $city = District::where('id', $city[0])->first(['name']);
+          $job->city_name = $city->name ?? '';
+        } else {
+          $job->city_name = '全国';
+        }
+      }
+      // 获取简历最后一级地区
+      if (isset($job->city_id) && !empty($job->city_id)) {
+        $city = District::where('id', $job->city_id)->first(['name']);
+        $job->hunt_cityname = $city->name ?? '';
+      }
+      // 组合详细地址
+      if (isset($job->address_arr_id) && !empty($job->address_arr_id)) {
+        $address_id = json_decode($job->address_arr_id, true) ?? [];
+        if (is_array($address_id) && !empty($address_id)) {
+          $address = District::whereIn('id', $address_id)
+            ->orderBy('level', 'asc')
+            ->get(['name'])
+            ->pluck('name')
+            ->implode('');
+          // $job->address_name = $address ?? '';
+          $job->address_name = ($address ?? '') . ($job->address ?? '');
+        }
+      }
+      // 取行业
+      if (!empty($job->hy_id) || !empty($job->industry) || !empty($job->company_hy_id || !empty($job->job_industry))) {
+        $hy_name = JobIndustry::when($job, function ($query) use ($job) {
+          if (!empty($job->industry)) {
+            $query->where('hyid', $job->industry);
+          } else if (!empty($job->hy_id)) {
+            $query->where('hyid', $job->hy_id);
+          } else if (!empty($job->company_hy_id)) {
+            $query->where('hyid', $job->company_hy_id);
+          } else {
+            $query->where('hyid', $job->job_industry);
+          }
+        })->first(['hyname']);
+        $job->hy_name = $hy_name->hyname ?? '';
+      }
+      // 取职位类别
+      if ((isset($job->zw_id) && !empty($job->zw_id)) || (isset($job->job) && !empty($job->job)) || (isset($job->job_typename) && !empty($job->job_typename))) {
+        $zwid = $job->job ?? $job->zw_id ?? $job->job_typename;
+        $zw_name = JobPosition::where('zwid', $zwid)->first(['zwname']);
+        $job->zw_name = $zw_name->zwname ?? '';
+      }
+      // 取具体职位
+      if ((isset($job->jtzw_id) && !empty($job->jtzw_id)) || (isset($job->job_name_get) && !empty($job->job_name_get)) || (isset($job->job_name) && !empty($job->job_name))) {
+        $jtzwid = $job->job_name_get ?? $job->jtzw_id ?? $job->job_name;
+        $jtzw_name = JobPosition::where('zwid', $jtzwid)->first(['zwname']);
+        $job->jtzw_name = $jtzw_name->zwname ?? '';
+      }
+      // 取工作经验
+      if (isset($job->experience) && !empty($job->experience)) {
+        $experience = JobEnum::where('egroup', 'years')->where('evalue', $job->experience)->first(['ename']);
+        $job->experience_name = $experience->ename ?? '';
+      }
+      // 取学历
+      if (isset($job->educational) && !empty($job->educational) || isset($job->school_education) && !empty($job->school_education)) {
+        $education = $job->educational ?? $job->school_education;
+        $education = JobEnum::where('egroup', 'education')->where('evalue', $education)->first(['ename']);
+        $job->education_name = $education->ename ?? '';
+      }
+      // 语言
+      if (isset($job->language) && !empty($job->language)) {
+        $language = JobEnum::where('egroup', 'language')->where('evalue', $job->language)->first(['ename']);
+        $job->language_name = $language->ename ?? '';
+      }
+      // 薪资
+      if (isset($job->salary) && !empty($job->salary)) {
+        $salary = JobEnum::where('egroup', 'income')->where('evalue', $job->salary)->first(['ename']);
+        $job->salary_name = $salary->ename ?? '';
+      }
+      // 职位性质
+      if (isset($job->nature_id) && !empty($job->nature_id)) {
+        $job_nature = JobEnum::where('egroup', 'nature')->where('evalue', $job->nature_id)->first(['ename']);
+        $job->job_nature_name = $job_nature->ename ?? '';
+      }
+      // 公司规模
+      if (isset($job->company_size) && !empty($job->company_size)) {
+        $company_size = JobEnum::where('egroup', 'cosize')->where('evalue', $job->company_size)->first(['ename']);
+        $job->company_size_name = $company_size->ename ?? '';
+      }
+      // 公司性质
+      if (isset($job->company_nature) && !empty($job->company_nature)) {
+        $company_nature = JobNature::where('id', $job->company_nature)->first(['nature_name']);
+        $job->company_nature_name = $company_nature->nature_name ?? '';
+      }
+      // $job->pinyin = $pinyin;
+      return $job;
+    });
+  }
+  /**
+   * 获取书籍模块
+   * @param array $data
+   * @return array
+   *  */
+  public function getWebsiteBook(array $data): array
+  {
+    $input['id'] = $data['id'];
+    $input['website_id'] = $data['website_id'];
+    // 将 JSON 字符串转换为 PHP 数组
+    $data = json_decode($input['id'], true);
+    // 使用 array_map 处理每个元素
+    $result = array_map(function ($item) use ($input) {
+      // 检查parent元素是否存在且不是undefined
+      if (isset($item['parent']) && $item['parent'] != 'undefined' && $item['parent'] != "") {
+        list($parentCatId, $parentImgNum, $parentTextNum) = explode(',', $item['parent']);
+        $website = [
+          'website_id' => $input['website_id'],
+        ];
+        // 查询栏目名称
+        $category = WebsiteCategory::where('category_id', $parentCatId)->where($website)->first(['alias', 'category_id', 'aLIas_pinyin']);
+        if (empty($category)) {
+          $parent_alias = '';
+          $parent_pinyin = null;
+          $imgBooks = [];
+          $textBooks = [];
+        } else {
+          $parent_alias = $category->alias ?? '';
+          $parent_pinyin = $category->aLIas_pinyin ? $category->aLIas_pinyin : null;
+          // 查找子分类ID数组
+          $childCategoryIds = WebsiteCategory::where('pid', $parentCatId)->where($website)->pluck('category_id')->toArray();
+          array_push($childCategoryIds, $parentCatId);
+          $childCategoryIds = json_encode(array_values(array_unique($childCategoryIds)));
+          if ($parentImgNum != 0) {
+            // 查询图片新闻
+            $imgBooks = Book::where(function ($query) use ($parentCatId) {
+              $query->whereRaw("JSON_CONTAINS(cat_arr_id, '\"$parentCatId\"')")
+                ->orWhereRaw("JSON_CONTAINS(cat_arr_id, '$parentCatId')");
+            })
+              ->where('book.status', 2)
+              ->where('book.img_url', '!=', '')
+              ->where('book.website_id', $website['website_id'])
+              ->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)
+              ->where('book.website_id', $website['website_id'])
+              ->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', '!=', '')
+              ->where('book.website_id', $website['website_id'])
+              ->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)
+              ->where('book.website_id', $website['website_id'])
+              ->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.catid',
+        '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',
+        'job_hunting.skillList',
+        'job_hunting.slelf_evaluation',
+      )
+      ->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.catid',
+        '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',
+        'job_recruiting.keyword',
+        'job_recruiting.description',
+      )
+      ->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);
+  }
+  /**
+   * 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']]);
+      }
+      if (isset($data['keyword']) && !empty($data['keyword'])) {
+        array_push($recruit_where, ['title', 'like', '%' . $data['keyword'] . '%']);
+      }
+      $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.catid',
+          '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',
+          'job_recruiting.keyword',
+          'job_recruiting.description',
+        )
+        ->orderBy('job_recruiting.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_hunting.job', $data['zw_id']]);
+      }
+      if (isset($data['jtzw_id']) && !empty($data['jtzw_id'])) {
+        array_push($hunt_where, ['job_hunting.job_name_get', $data['jtzw_id']]);
+      }
+      if (isset($data['hy_id']) && !empty($data['hy_id'])) {
+        array_push($hunt_where, ['job_hunting.industry', $data['hy_id']]);
+      }
+      if (isset($data['keyword']) && !empty($data['keyword'])) {
+        array_push($hunt_where, ['job_position.zwname', 'like', '%' . $data['keyword'] . '%']);
+      }
+      $query = JobHunting::where('job_hunting.status', 2)
+        ->where('job_hunting.website_id', $data['website_id'])
+        ->leftJoin('job_position', 'job_hunting.job_name_get', '=', 'job_position.zwid')
+        ->where($hunt_where)
+        // ->when(isset($data['keyword']) &&!empty($data['keyword']), function ($query) use ($data) { 
+        //     $query->where('job_position.zwname','like','%'.$data['keyword'].'%'); 
+        // }) 
+        ->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(
+          'job_hunting.id',
+          'job_hunting.catid',
+          'job_hunting.sexy',
+          'job_hunting.experience',
+          'job_hunting.origin',
+          'job_hunting.industry',
+          'job_hunting.name',
+          'job_hunting.job',
+          'job_hunting.job_name_get',
+          'job_hunting.city_arr_id',
+          'job_hunting.cat_arr_id',
+          'job_hunting.created_at',
+          'job_hunting.updated_at',
+          'job_position.zwname as job_name',
+          'job_hunting.skillList',
+          'job_hunting.slelf_evaluation',
+        )
+        ->orderBy('job_hunting.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);
+  }
+  /**
+   * 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);
+  }
+  /**
+   * 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);
+  }
+  /**
+   * 招工招聘-沟通简历
+   * @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);
+  }
+  /**
+   * 招工招聘  -我的职位(企业会员)
+   * @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']);
+      })
+      ->where('status', 1)
+      ->select('id', 'title', 'website_id', 'user_id', 'updated_at', 'keyword', 'catid', 'description')
+      ->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
+   */
+
+
+  /**
+   * c端  -  验证路由
+   * @param array $data
+   * @return array
+   */
+  public function checkWebsiteRoute(array $data): array
+  {
+    // 测试001111111222
+    $web = Website::where('id', $data['website_id'])->first(['id', 'website_name', 'status']);
+    if (empty($web)) {
+      return Result::error("该网站不存在", 0);
+    } elseif ($web['status'] != 1) {
+      return Result::error("网站已经关闭", 0);
+    }
+    if (isset($data['other_route']) && !empty($data['other_route'])) {
+      $whiteRouterInfo = WhiteRouter::whereJsonContains("website_id", $data['website_id'])->where('router_url', $data['other_route'])->first();
+      // 验证路由是否存在
+      if (empty($whiteRouterInfo)) {
+        $whiteRouterInfo = WhiteRouter::where("router_type", 1)->where('router_url', $data['other_route'])->first();
+      }
+      if (!empty($whiteRouterInfo)) {
+        return Result::success($whiteRouterInfo->toArray());
+      }
+    }
+    // 验证栏目路由
+    $last_category = WebsiteCategory::where('website_id', $data['website_id'])
+      ->where('path', $data['all_route'])
+      ->get()->all();
+    if (count($last_category) == 0) {
+      return Result::error("该栏目不存在", 0);
+    }
+    if (count($last_category) > 1) {
+      return Result::error("该栏目路由存在多个,路由验证失败!", 0);
+    }
+    if (count($last_category) == 1) {
+      $last_category = $last_category[0];
+    }
+
+    // return Result::success($last_category);
+    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(['catid']);
+          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 '审核状态状态:0:未审核;1:已审核;2:已拒绝;',
+          $article = Company::
+            //   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 7:
+          // 项目
+          // `status` int DEFAULT '1' COMMENT '审核状态状态:0:未审核;1:已审核;2:已拒绝;',
+          $article = Project::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;
+        default:
+          return Result::error("该数据不存在", 0);
+          break;
+      }
+      //   return Result::success($article);
+      //   $catid =0 ;
+
+      if (!isset($article['cat_arr_id'])) {
+        $catid = isset($article['catid']) ? $article['catid'] : (isset($article['category_id']) ? $article['category_id'] : null);
+      } else {
+        $catidArray = json_decode($article['cat_arr_id'], true);
+        $catid = !empty($catidArray) ? end($catidArray) : null;
+      }
+      // return Result::success($catid);
+      // //    return Result::success($article['cat_arr_id']);
+      if (empty($catid)) {
+        return Result::error("该栏目路径不存在", 0);
+      }
+
+      $path = WebsiteCategory::where('website_id', $data['website_id'])
+        ->where('category_id', $catid)
+        ->first('path');
+    }
+
+    // else{
+    //     // if ($last_category['pid'] != 0) {
+    //         $cat_arr = json_decode($last_category['category_arr_id'], true);
+    //         $catid = !empty($cat_arr) && is_array($cat_arr) ? end($cat_arr) : null;
+    //         $pinyin = WebsiteCategory::where('website_id', $data['website_id'])
+    //             ->where('category_id',$catid)
+    //             ->where('path',$data['all_route'])
+    //             ->first('path');
+    //     // } else {
+    //     //     $pinyin[0] = $last_category['aLIas_pinyin'];
+    //     // }
+    // }
+    // return Result::success($path);
+    if (!empty($path) && $path['path'] != $data['all_route']) {
+      return Result::error('非法路径!');
+    } else {
+      return Result::success($last_category['path']);
+    }
+  }
+  /**
+   * 招工招聘  -  获取推荐职位
+   * @param array $data
+   * @return array
+   */
+  public function getWebsiteLevelJob(array $data): array
+  {
+    // 状态   0:待审核;1:已审核通过;(只有企业会员需要审核);2:已拒绝;
+    $job = JobRecruiting::where('job_recruiting.website_id', $data['website_id'])
+      ->where('job_recruiting.status', 1)
+      ->where('job_level', $data['job_level'])
+      ->leftJoin('job_company', 'job_recruiting.id', '=', 'job_company.job_id')
+      ->select('job_recruiting.id', 'job_recruiting.title', 'job_recruiting.cat_arr_id', 'job_company.business_name', 'job_recruiting.updated_at')
+      ->orderBy('job_recruiting.updated_at', 'desc')
+      ->limit($data['pageSize'])
+      ->get();
+    $web = ['website_id' => $data['website_id']];
+    if (!empty($job)) {
+      $result = $this->processJob($job, $web);
+    }
+    if (empty($result)) {
+      return Result::error("暂无相关职位信息", 0);
+    }
+    return Result::success($result);
+  }
+
+  /**
+   * 验证导航名称是否重复
+   * @return void
+   */
+
+
+  //20250226  产品列表
+
+  public function getGoodList(array $data): array
+  {
+    var_dump($data, '---------1-2--');
+    $type_id = isset($data['user_type_id']) ? $data['user_type_id'] : '';
+    unset($data['user_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['good.type_id'] = $data['type_id'];
+    }
+    //名称
+    if (isset($data['name']) && $data['name']) {
+      $where[] = ['good.name', 'like', '%' . $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']);
+    var_dump($where, '---------1---');
+    $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);
+  }
+  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;
+    }
+
+    if ($data['imgurl'] == '') {
+      $reg = '/<img.*?src=[\"|\']?(.*?)[\"|\']?\s.*?>/i';
+      preg_match_all($reg, $data['detail'], $matches);
+      if (isset($matches[1][0])) {
+        //截取varchar240
+        $data['imgurl'] = substr($matches[1][0], 0, 240);
+      }
+    }
+    if ($data['keyword'] == '' ||  $data['keyword'] == array()) {
+      //提取标题+内容中的关键词
+      $data['keyword'] = $data['name'];
+      //  . 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'] == '') {
+      //提取内容中的描述
+      $cleaned = preg_replace('/\s+/', '', strip_tags(html_entity_decode($data['detail'], ENT_QUOTES, 'UTF-8')));
+      $data['description'] = mb_substr($cleaned, 0, 100, 'UTF-8');
+      // $data['description'] = substr(preg_replace('/\s+/', '', strip_tags($data['detail'])), 0, 100);
+    }
+    if ($data['status'] == 1) {
+      $this->sendMessage([
+        'talk_type' => 200,
+        'title' => $data['name'],
+        'content' => '提交了审核',
+        'messageType' => 3,
+      ]);
+    }
+
+    $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;
+    }
+
+
+    if ($data['imgurl'] == '') {
+      $reg = '/<img.*?src=[\"|\']?(.*?)[\"|\']?\s.*?>/i';
+      preg_match_all($reg, $data['detail'], $matches);
+      if (isset($matches[1][0])) {
+        //截取varchar240
+        $data['imgurl'] = substr($matches[1][0], 0, 240);
+      }
+    }
+    if ($data['keyword'] == '' ||  $data['keyword'] == array()) {
+      //提取标题+内容中的关键词
+      $data['keyword'] = $data['name'];
+      //  . 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'] == '') {
+      //提取内容中的描述
+      $cleaned = preg_replace('/\s+/', '', strip_tags(html_entity_decode($data['detail'], ENT_QUOTES, 'UTF-8')));
+      $data['description'] = mb_substr($cleaned, 0, 100, 'UTF-8');
+    }
+    if ($data['status'] == 1) {
+      $this->sendMessage([
+        'talk_type' => 200,
+        'title' => $data['name'],
+        'content' => '提交了审核',
+        'messageType' => 3,
+      ]);
+    }
+
+    $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);
+  }
+
+  //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)
+      ->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')
+      ->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.receiver_id', '=', $user_id];
+    }
+
+    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---------');
+    if (isset($data['city_arr_id']) && !empty($data['city_arr_id'])) {
+      if (is_string($data['city_arr_id'])) {
+        // 如果 city_arr_id 是字符串,尝试将其转换为数组,取最后一个数据
+        $cityArr = json_decode($data['city_arr_id'], true);
+        // 确保 $cityArr 是数组
+        if (is_array($cityArr)) {
+          $data['city_id'] = end($cityArr);
+        }
+      } else {
+        // 如果 city_arr_id 不是字符串,直接取最后一个数据
+        if (is_array($data['city_arr_id'])) {
+          $data['city_id'] = end($data['city_arr_id']);
+        }
+      }
+    }
+
+    // 处理求职所绑定栏目
+    if (isset($data['cat_arr_id']) && !empty($data['cat_arr_id'])) {
+      if (is_string($data['cat_arr_id'])) {
+        // 如果 cat_arr_id 是字符串,尝试将其转换为数组,取最后一个数据
+        // 先清理可能存在的无效 JSON 字符
+        $cleanedCatArrStr = trim($data['cat_arr_id']);
+        $catArr = json_decode($cleanedCatArrStr, true);
+        // 检查 JSON 解码是否成功且结果是数组
+        if (json_last_error() === JSON_ERROR_NONE && is_array($catArr)) {
+          $data['catid'] = end($catArr);
+        }
+      } else {
+        // 如果 cat_arr_id 不是字符串,直接取最后一个数据
+        if (is_array($data['cat_arr_id'])) {
+          $data['catid'] = end($data['cat_arr_id']);
+        }
+      }
+    }
+    if ((isset($data['status']) && $data['status'] == 1) || !isset($data['status'])) {
+      $this->sendMessage([
+        'talk_type' => 600,
+        'title' => $data['name'],
+        'content' => '提交了审核',
+        'messageType' => 11,
+      ]);
+    }
+    $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');
+    if (isset($data['city_arr_id']) && !empty($data['city_arr_id']) && is_string($data['city_arr_id'])) {
+      // 如果 city_arr_id 是字符串,尝试将其转换为数组,取最后一个数据
+      $cityArr = json_decode($data['city_arr_id'], true);
+      $data['city_id'] = end($cityArr);
+    } else {
+      // 如果 city_arr_id 不是字符串,直接取最后一个数据
+      $data['city_id'] = end($data['city_arr_id']);
+    }
+    // 处理求职所绑定栏目
+    if (isset($data['cat_arr_id']) && !empty($data['cat_arr_id']) && is_string($data['cat_arr_id'])) {
+      // 如果 cat_arr_id 是字符串,尝试将其转换为数组,取最后一个数据
+      $catArr = json_decode($data['cat_arr_id'], true);
+      $data['catid'] = end($catArr);
+    } else {
+      // 如果 cat_arr_id 不是字符串,直接取最后一个数据
+      $data['catid'] = end($data['cat_arr_id']);
+    }
+    if ((isset($data['status']) && $data['status'] == 1) || !isset($data['status'])) {
+      $this->sendMessage([
+        'talk_type' => 600,
+        'title' => $data['name'],
+        'content' => '提交了审核',
+        'messageType' => 11,
+      ]);
+    }
+    $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();
+    // var_dump($result['re_user_ids'], '--------------------');
+    if (empty($result)) {
+      return Result::error("查询失败", 0);
+    }
+
+    return Result::success($result);
+  }
+  public function readNotice(array $data): array
+  {
+    $result = Notice::where('id', $data['id'])->first();
+    // var_dump($result['re_user_ids'], '--------------------');
+    if (empty($result)) {
+      return Result::error("查询失败", 0);
+    }
+    //判断$requireData['user_id'] ; 是不是在 re_user_ids 中,如果在,就写入read_id,存成数组的json
+    $re_user_ids = json_decode($result['re_user_ids'], true);
+    var_dump($re_user_ids, '--------------1---test---------');
+    var_dump($data, '--------------1---test---------');
+
+    if (is_array($re_user_ids) && in_array($data['user_id'], $re_user_ids)) {
+      //如果已经存在,就不再添加
+      if (isset($result['read_id']) && !empty($result['read_id'])) {
+        $read_id = json_decode($result['read_id'], true);
+        if (!is_array($read_id)) {
+          $read_id = [];
+        }
+        if (!in_array($data['user_id'], $read_id)) {
+          $read_id[] = $data['user_id'];
+          $result['read_id'] = json_encode($read_id);
+          Notice::where('id', $data['id'])->update(['read_id' => json_encode($read_id)]);
+        }
+      } else {
+        //如果不存在,就添加
+        $result['read_id'] = json_encode([$data['user_id']]);
+        Notice::where('id', $data['id'])->update(['read_id' => json_encode([$data['user_id']])]);
+      }
+    }
+    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');
+    // $data['level'] = "1,2,3,4,5";
+    $level = json_decode($data['level'], true);
+    $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");
+        });
+      })
+      ->when(isset($level) && is_array($level), function ($query) use ($level) {
+        $query->whereIn('level', $level);
+      })
+      ->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;
+    $this->sendMessage([
+      'talk_type' => 700,
+      'title' => $data['title'],
+      'content' => '提交了审核',
+      'messageType' => 5,
+    ]);
+    $result = Notice::insertGetId($data);
+
+    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');
+    $this->sendMessage([
+      'talk_type' => 700,
+      'title' => $data['title'],
+      'content' => '提交了审核',
+      'messageType' => 5,
+    ]);
+    $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']];
+    }
+    //type
+    if (isset($data['type']) && !empty($data['type'])) {
+      $where[] = ['notice.type', '=', $data['type']];
+    }
+    var_dump($data, '------------11111-2----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']);
+          });
+        })
+
+        ->when(!empty($data['status1']), function ($query) use ($data) {
+          return $query->whereIn('notice.status', [1, 3]);   //1待审核2已审核3已拒绝
+        })
+        ->orderBy('updated_at', 'desc')
+        ->limit($data['page_size'])
+        ->offset(($data['page'] - 1) * $data['page_size'])
+        ->get();
+      $total = Notice::where($where)
+        ->when(!empty($data['status1']), function ($query) use ($data) {
+          return $query->whereIn('notice.status', [1, 3]);   //1待审核2已审核3已拒绝
+        })
+        // ->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 noticeList(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']];
+    }
+    //type
+    if (isset($data['type']) && !empty($data['type'])) {
+      $where[] = ['notice.type', '=', $data['type']];
+    }
+    var_dump($data, '------------11111-2----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']);
+          });
+        })
+
+        ->when(!empty($data['status1']), function ($query) use ($data) {
+          return $query->whereIn('notice.status', [1, 3]);   //1待审核2已审核3已拒绝
+        })
+        ->orderBy('updated_at', 'desc')
+        ->limit($data['page_size'])
+        ->offset(($data['page'] - 1) * $data['page_size'])
+        ->get();
+      $total = Notice::where($where)
+        ->when(!empty($data['status1']), function ($query) use ($data) {
+          return $query->whereIn('notice.status', [1, 3]);   //1待审核2已审核3已拒绝
+        })
+        // ->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 complaintList(array $data): array
+  {
+    var_dump($data, '---------1---------');
+    $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 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 readComplaint(array $data): array
+  {
+    $result = Complaint::where('id', $data['id'])->first();
+    if (empty($result)) {
+      return Result::error("查询失败", 0);
+    }
+    //判断$requireData['user_id'] ; 是不是在 re_user_ids 中,如果在,就写入read_id,存成数组的json
+    $re_user_ids = json_decode($result['re_user_ids'], true);
+    if (is_array($re_user_ids) && in_array($data['user_id'], $re_user_ids)) {
+      //如果已经存在,就不再添加
+      if (isset($result['read_id']) && !empty($result['read_id'])) {
+        $read_id = json_decode($result['read_id'], true);
+        if (!is_array($read_id)) {
+          $read_id = [];
+        }
+        if (!in_array($data['user_id'], $read_id)) {
+          $read_id[] = $data['user_id'];
+          $result['read_id'] = json_encode($read_id);
+          Complaint::where('id', $data['id'])->update(['read_id' => json_encode($read_id)]);
+        }
+      } else {
+        //如果不存在,就添加
+        $result['read_id'] = json_encode([$data['user_id']]);
+        Complaint::where('id', $data['id'])->update(['read_id' => json_encode([$data['user_id']])]);
+      }
+    }
+    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');
+    $this->sendMessage([
+      'talk_type' => 800,
+      'title' => $data['title'],
+      'content' => '提交了审核',
+      'messageType' => 6,
+    ]);
+    $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']);
+    $this->sendMessage([
+      'talk_type' => 800,
+      'title' => $data['title'],
+      'content' => '提交了审核',
+      'messageType' => 6,
+    ]);
+    $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);
+      }
+    }
+    $complaintInfo = Complaint::where('id', $data['id'])->first();
+    if ($data['status'] == 1) {
+      $this->sendMessage([
+        'talk_type' => 800,
+        'title' => $complaintInfo['title'],
+        'content' => '提交了审核',
+        'messageType' => 6,
+      ]);
+    }
+    if ($data['status'] == 2 && !isset($data['deal'])) {
+      $this->sendMessage([
+        'talk_type' => 801,
+        'title' => $complaintInfo['title'],
+        'content' => '审核通过',
+        'messageType' => 6,
+        'user_id' => $complaintInfo['user_id'],
+      ]);
+      $this->sendMessage([
+        'talk_type' => 802,
+        'title' => $complaintInfo['title'],
+        'content' => '待处理',
+        'messageType' => 6,
+        'user_id' => $complaintInfo['re_user_ids'],
+      ]);
+    }
+    if ($data['status'] == 3 && !isset($data['deal'])) {
+      $this->sendMessage([
+        'talk_type' => 801,
+        'title' => $complaintInfo['title'],
+        'content' => '审核拒绝',
+        'messageType' => 6,
+        'user_id' => $complaintInfo['user_id'],
+      ]);
+    }
+    if ($data['status'] == 2 && isset($data['deal']) && $data['deal'] == 2) {
+      $this->sendMessage([
+        'talk_type' => 802,
+        'title' => $complaintInfo['title'],
+        'content' => '处理中',
+        'messageType' => 6,
+        'user_id' => $complaintInfo['re_user_ids'],
+      ]);
+    }
+    if ($data['status'] == 2 && isset($data['deal']) && $data['deal'] == 4) {
+      $this->sendMessage([
+        'talk_type' => 802,
+        'title' => $complaintInfo['title'],
+        'content' => '不予处理',
+        'messageType' => 6,
+        'user_id' => $complaintInfo['re_user_ids'],
+      ]);
+    }
+    if ($data['status'] == 2 && isset($data['deal']) && $data['deal'] == 3) {
+      $this->sendMessage([
+        'talk_type' => 802,
+        'title' => $complaintInfo['title'],
+        'content' => '已完结',
+        'messageType' => 6,
+        'user_id' => $complaintInfo['re_user_ids'],
+      ]);
+    }
+    $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']);
+    $goodInfo = Good::where('id', $data['id'])->first();
+    if ($data['status'] == 2) {
+      $this->sendMessage([
+        'talk_type' => 201,
+        'title' => $goodInfo['name'],
+        'content' => '审核通过',
+        'messageType' => 3,
+        'user_id' => $goodInfo['user_id'],
+      ]);
+    }
+    if ($data['status'] == 3) {
+      $this->sendMessage([
+        'talk_type' => 201,
+        'title' => $goodInfo['name'],
+        'content' => '审核拒绝',
+        'messageType' => 3,
+        'user_id' => $goodInfo['user_id'],
+      ]);
+    }
+    if ($data['status'] == 1) {
+      $this->sendMessage([
+        'talk_type' => 200,
+        'title' => $goodInfo['name'],
+        'content' => '提交了审核',
+        'messageType' => 3,
+      ]);
+    }
+    $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']);
+    $jogHuntingInfo = JobHunting::where('id', $data['id'])->first();
+    if ($data['status'] == 2) {
+      $this->sendMessage([
+        'talk_type' => 601,
+        'title' => $jogHuntingInfo['name'],
+        'content' => '审核通过',
+        'messageType' => 11,
+        'user_id' => $jogHuntingInfo['user_id'],
+      ]);
+    }
+    if ($data['status'] == 3) {
+      $this->sendMessage([
+        'talk_type' => 601,
+        'title' => $jogHuntingInfo['name'],
+        'content' => '审核拒绝',
+        'messageType' => 11,
+        'user_id' => $jogHuntingInfo['user_id'],
+      ]);
+    }
+    if ($data['status'] == 1) {
+      $this->sendMessage([
+        'talk_type' => 600,
+        'title' => $jogHuntingInfo['name'],
+        'content' => '提交了审核',
+        'messageType' => 11,
+      ]);
+    }
+    $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']);
+    //查询公告
+    $notice = Notice::where('id', $data['id'])->first();
+    if (empty($notice)) {
+      return Result::error("公告不存在", 0);
+    }
+    //$chat_ids 去除掉$data['user_id']
+    $chat_ids = json_decode($notice['re_user_ids'], true);
+    $chat_ids = array_diff($chat_ids, [$notice['user_id']]);
+    //如果公告的状态是2,且是群聊公告,且状态是1,则创建群聊,第一次审核通过的时候处理成群聊
+    if ($data['status'] == 2 && $notice['is_group'] == 1 && ($notice['status'] == 1 || $notice['status'] == 3) && empty($notice['group_id'])) {
+      //chat_group
+      $group_id = PublicData::uuid();
+      $groupData = [
+        'id' => $group_id,
+        'creator_id' => $notice['user_id'],
+        'group_name' => $notice['group_name'] ?? '',
+        'profile' => $notice['profile'] ?? 0,
+      ];
+      var_dump($groupData, '-----------------groupData-------');
+      $groupResult = ChatGroups::insertGetId($groupData);
+      var_dump($groupResult, '-----------------groupid-------');
+      $groupMemberData = [
+        'id' => PublicData::uuid(),
+        'user_id' => $notice['user_id'],
+        'group_id' => $group_id,
+        'leader' => 2,
+      ];
+      $groupMemberResult = ChatGroupsMember::insertGetId($groupMemberData);
+
+      //插入群成员表
+      $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' => $notice['user_id'],
+          'action' => 'recieved',
+          'created_at' => date('Y-m-d H:i:s'),
+        ];
+      }
+      var_dump($groupMemberDataUser, '-----------------groupMemberDataUser-------');
+      ChatGroupsMember::insert($groupMemberDataUser);
+      //插入一条管理员聊天记录
+      $chatData[] = [
+        'user_id' => $notice['user_id'],
+        'msg_type' => 1,
+        'receiver_id' => $group_id,
+        'content' => '通过通知创建群聊',
+        'group_receiver_id' => $notice['user_id'],
+        'action' => 'said',
+        'created_at' => date('Y-m-d H:i:s'),
+      ];
+      var_dump($chatData, '-----------------chatData-------');
+      $chatResult = ChatRecords::insert($chatData);
+      //处理imp
+      $group = [
+        'type' => 1,
+        'name' => $notice['group_name'] ?? '',
+        'profile' => '',
+        'avatar' => '',
+        'creator_id' => $notice['user_id'],
+      ];
+      $groupResult = GroupImp::insertGetId($group);
+      var_dump($groupResult, '获取imp group_id');
+      $groupMember = [
+        'user_id' => $notice['user_id'],
+        'group_id' => $groupResult,
+        'leader' => 1,
+        'join_time' => Date('Y-m-d H:i:s')
+      ];
+      $groupMemberResult = GroupMemberImp::insertGetId($groupMember);
+      $talk_session = [
+        'user_id' => $notice['user_id'],
+        'to_from_id' => $groupResult,
+        'talk_mode' => 2,
+        'created_at' => Date('Y-m-d H:i:s'),
+        'updated_at' => Date('Y-m-d H:i:s'),
+      ];
+      $talk_session_result = GroupTalkImp::insertGetId($talk_session);
+      //被通知人员处理
+      foreach ($chat_ids as $key => $value) {
+        $groupMemberdata[] = [
+          'user_id' => $value,
+          'group_id' => $groupResult,
+          'leader' => 3,
+          'join_time' => Date('Y-m-d H:i:s')
+        ];
+        $talk_sessionData[] = [
+          'user_id' => $value,
+          'to_from_id' => $groupResult,
+          'talk_mode' => 2,
+          'created_at' => Date('Y-m-d H:i:s'),
+          'updated_at' => Date('Y-m-d H:i:s'),
+        ];
+      }
+      $groupResult1 = GroupMemberImp::insert($groupMemberdata);
+      $talk_sessionResult = GroupTalkImp::insert($talk_sessionData);
+      $group_id = $groupResult;
+      //更新result的 group_id
+      $data['group_id'] = $group_id;
+      Notice::where(['id' => $data['id']])->update($data);
+    }
+    if (($data['status'] == 1 || $data['status'] == 3) && $notice['is_group'] == 1 && $notice['status'] == 2 && !empty($notice['group_id'])) {
+      //删除掉信息
+      GroupImp::where('id', $notice['group_id'])->delete();
+      GroupMemberImp::where('group_id', $notice['group_id'])->delete();
+      GroupTalkImp::where('to_from_id', $notice['group_id'])->delete();
+      foreach ($chat_ids as $key => $value) {
+      }
+      //聊天记录删除
+
+      //如果是群聊公告,且已经有群聊id,则更新公告的group_id
+      $data['group_id'] = null;
+      Notice::where(['id' => $data['id']])->update($data);
+    }
+    $result = Notice::where('id', $data['id'])->update($data);
+    $noticeInfo = Notice::where('id', $data['id'])->first();
+    if ($data['status'] == 2) {
+      $this->sendMessage([
+        'talk_type' => 701,
+        'title' => $noticeInfo['title'],
+        'content' => '审核通过',
+        'messageType' => 3,
+        'user_id' => $noticeInfo['user_id'],
+      ]);
+    }
+    if ($data['status'] == 3) {
+      $this->sendMessage([
+        'talk_type' => 701,
+        'title' => $noticeInfo['title'],
+        'content' => '审核拒绝',
+        'messageType' => 3,
+        'user_id' => $noticeInfo['user_id'],
+      ]);
+    }
+    if ($data['status'] == 1) {
+      $this->sendMessage([
+        'talk_type' => 700,
+        'title' => $noticeInfo['title'],
+        'content' => '提交了审核',
+        'messageType' => 3,
+      ]);
+    }
+    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);
+  }
+
+  /**
+   * 验证导航名称是否重复
+   * @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();
+    }
+  }
+
+  //20250226  产品列表
+
+  // 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']]);
+    }
+
+    // 如果 $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
+  {
+    // var_dump('添加招聘进入news------data',$data);
+    // 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);
+    }
+    // var_dump('添加招聘进入news---user---user',$user);
+    // 处理招聘关键词
+    if (isset($data['keyword']) && !empty($data['keyword'])) {
+      $data['keyword'] = str_replace(',', ',', $data['keyword']);
+    } else {
+      Jieba::init(); // 初始化 jieba-php
+      Finalseg::init();
+      $segList = Jieba::cut($data['title']);
+      $segList1 = array_slice($segList, 0, 8);
+      $data['keyword'] = implode(',', $segList1);
+    }
+    if (!isset($data['seo_description']) || empty($data['seo_description'])) {
+      $content = $data['description'];
+      // 去除 <style> 和 <script> 标签及其内容
+      $content = preg_replace('/<(style|script)[^>]*>.*?<\/\1>/is', '', $content);
+      // 去除所有 HTML 标签
+      $content = strip_tags($content);
+      // 去除 HTML 实体
+      $content = html_entity_decode($content, ENT_QUOTES | ENT_HTML5, 'UTF-8');
+      // 只保留文本和标点符号(去除所有字母数字以外的特殊符号,可根据需要调整正则)
+      $content = preg_replace('/[^\p{L}\p{N}\p{P}\p{Zs}]+/u', '', $content);
+      // 去除多余空白
+      $content = preg_replace('/\s+/u', '', $content);
+      // 截取 100 个字符
+      $data['seo_description'] = mb_substr($content, 0, 100);
+    }
+
+    // return Result::success($user);
+    $data['action_id'] = $data['user_id'] ?? null;
+    $data['user_type'] = $user['type_id'] ?? null;
+    $data['cat_arr_id'] = isset($data['cat_arr_id']) && !empty($data['cat_arr_id']) ? array_values(array_unique($data['cat_arr_id'])) : [];
+
+    if (isset($data['cat_arr_id']) && !empty($data['cat_arr_id']) && is_array($data['cat_arr_id'])) {
+      $data['catid'] = end($data['cat_arr_id']);
+    } else {
+      $data['catid'] = 0;
+    }
+    $data['city_arr_id'] = isset($data['city_arr_id']) && !empty($data['city_arr_id']) ? array_values(array_unique($data['city_arr_id'])) : [];
+    $data['cat_arr_id'] = isset($data['cat_arr_id']) && $data['cat_arr_id'] != [] ? json_encode(array_map('intval', $data['cat_arr_id'])) : '[]';
+    $data['city_arr_id'] = isset($data['city_arr_id']) && !empty($data['city_arr_id']) ? json_encode(array_map('intval', $data['city_arr_id'])) : '[]';
+    // 公司地址 管理员必填
+    $data['address_arr_id'] = isset($data['address_arr_id']) && !empty($data['address_arr_id']) ? array_values(array_unique($data['address_arr_id'])) : [];
+    $data['address_arr_id'] = isset($data['address_arr_id']) && $data['address_arr_id'] != [] ? json_encode(array_map('intval', $data['address_arr_id'])) : '[]';
+    // 管理员-企业相关信息
+    $company = [
+      // 'user_id' => $data['user_id']?? null,
+      'business_name' => isset($data['business_name']) && $data['business_name'] !== '' ? $data['business_name'] : null,
+      'company_hy_id' => isset($data['company_hy_id']) && $data['company_hy_id'] !== '' ? $data['company_hy_id'] : null,
+      'company_size' => isset($data['company_size']) && $data['company_size'] !== '' ? $data['company_size'] : null,
+      'company_nature' => isset($data['company_nature']) && $data['company_nature'] !== '' ? $data['company_nature'] : null,
+      'introduction' => isset($data['introduction']) && $data['introduction'] !== '' ? $data['introduction'] : null,
+      'real_name' => isset($data['real_name']) && $data['real_name'] !== '' ? $data['real_name'] : null,
+      'mobile' => isset($data['mobile']) && $data['mobile'] !== '' ? $data['mobile'] : null,
+      'company_url' => isset($data['company_url']) && $data['company_url'] !== '' ? $data['company_url'] : null,
+      'address_arr_id' => isset($data['address_arr_id']) && $data['address_arr_id'] !== '' ? $data['address_arr_id'] : null,
+      'address' => isset($data['address']) && $data['address'] !== '' ? $data['address'] : null,
+      'email' => isset($data['email']) && $data['email'] !== '' ? $data['email'] : null,
+    ];
+    //去掉相关企业信息
+    $job = array_diff_key($data, array_flip(array_keys($company)));
+    // var_dump('添加招聘进入news---job---user',$job);
+    Db::beginTransaction();
+    try {
+      //     // 先添加职位相关信息
+      if ($user['type_id'] == 10000) {
+        $job['status'] = 1;
+      }
+      $job['experience'] = isset($data['experience']) && $data['experience'] !== '' ? $data['experience'] : null;
+      $job['salary'] = isset($data['salary']) && $data['salary'] !== '' ? $data['salary'] : null;
+      $job['number'] = isset($data['number']) && $data['number'] !== '' ? $data['number'] : null;
+      $job['language'] = isset($data['language']) && $data['language'] !== '' ? $data['language'] : null;
+      $job['level'] = isset($data['level']) && $data['level'] !== '' ? $data['level'] : null;
+      $job['job_level'] = isset($data['job_level']) && $data['job_level'] !== '' ? $data['job_level'] : null;
+      $job['educational'] = isset($data['educational']) && $data['educational'] !== '' ? $data['educational'] : null;
+
+      // return Result::success($job);
+      $jobId = JobRecruiting::insertGetId($job);
+      if (empty($jobId)) {
+        Db::rollBack();
+        return Result::error("添加失败");
+      }
+
+      // 添加公司信息
+      $company['user_id'] = isset($data['user_id']) && $data['user_id'] !== '' ? $data['user_id'] : null;
+      $company['job_id'] = $jobId;
+      $company['user_type'] = isset($user['type_id']) && $user['type_id'] !== '' ? $user['type_id'] : null;
+      $company['website_id'] = isset($data['website_id']) && $data['website_id'] !== '' ? $data['website_id'] : null;
+      if ($user['type_id'] == 10000) {
+        // 管理员添加企业信息
+        $companyId = JobCompany::insertGetId($company);
+        if (empty($companyId)) {
+          Db::rollBack();
+          return Result::error("添加失败");
+        }
+      } else {
+        // 企业会员添加企业信息   
+        $company['user_id'] = isset($data['user_id']) && $data['user_id'] !== '' ? $data['user_id'] : null;
+        $company['website_id'] = isset($data['website_id']) && $data['website_id'] !== '' ? $data['website_id'] : null;
+        $company['user_type'] = isset($data['user_type']) && $data['user_type'] !== '' ? $data['user_type'] : null;
+        $company['job_id'] = $jobId;
+        $companyId = JobCompany::insertGetId($company);
+        if (empty($companyId)) {
+          Db::rollBack();
+          return Result::error("添加失败");
+        }
+      }
+      Db::commit();
+      $result = [
+        'job_id' => $jobId,
+        'company_id' => $companyId,
+      ];
+      return Result::success($result);
+    } catch (\Exception $e) {
+      Db::rollBack();
+      return Result::error($e->getMessage(), 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 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);
+    }
+    // 处理招聘关键词
+    if (isset($data['keyword']) && !empty($data['keyword'])) {
+      $data['keyword'] = str_replace(',', ',', $data['keyword']);
+    } else {
+      Jieba::init(); // 初始化 jieba-php
+      Finalseg::init();
+      $segList = Jieba::cut($data['title']);
+      $segList1 = array_slice($segList, 0, 8);
+      $data['keyword'] = implode(',', $segList1);
+    }
+    if (!isset($data['seo_description']) || empty($data['seo_description'])) {
+      $content = $data['description'];
+      // 去除 <style> 和 <script> 标签及其内容
+      $content = preg_replace('/<(style|script)[^>]*>.*?<\/\1>/is', '', $content);
+      // 去除所有 HTML 标签
+      $content = strip_tags($content);
+      // 去除 HTML 实体
+      $content = html_entity_decode($content, ENT_QUOTES | ENT_HTML5, 'UTF-8');
+      // 只保留文本和标点符号(去除所有字母数字以外的特殊符号,可根据需要调整正则)
+      $content = preg_replace('/[^\p{L}\p{N}\p{P}\p{Zs}]+/u', '', $content);
+      // 去除多余空白
+      $content = preg_replace('/\s+/u', '', $content);
+      // 截取 100 个字符
+      $data['seo_description'] = mb_substr($content, 0, 100);
+    }
+    $data['cat_arr_id'] = array_values(array_unique($data['cat_arr_id']));
+    if (isset($data['cat_arr_id']) && !empty($data['cat_arr_id']) && is_array($data['cat_arr_id'])) {
+      $data['catid'] = end($data['cat_arr_id']);
+    } else {
+    }
+    $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' => isset($data['business_name']) && $data['business_name'] !== '' ? $data['business_name'] : null,
+      'company_hy_id' => isset($data['company_hy_id']) && $data['company_hy_id'] !== '' ? $data['company_hy_id'] : null,
+      'company_size' => isset($data['company_size']) && $data['company_size'] !== '' ? $data['company_size'] : null,
+      'company_nature' => isset($data['company_nature']) && $data['company_nature'] !== '' ? $data['company_nature'] : null,
+      'introduction' => isset($data['introduction']) && $data['introduction'] !== '' ? $data['introduction'] : null,
+      'real_name' => isset($data['real_name']) && $data['real_name'] !== '' ? $data['real_name'] : null,
+      'mobile' => isset($data['mobile']) && $data['mobile'] !== '' ? $data['mobile'] : null,
+      'company_url' => isset($data['company_url']) && $data['company_url'] !== '' ? $data['company_url'] : null,
+      'address_arr_id' => isset($data['address_arr_id']) && $data['address_arr_id'] !== '' ? $data['address_arr_id'] : null,
+      'address' => isset($data['address']) && $data['address'] !== '' ? $data['address'] : null,
+      'email' => isset($data['email']) && $data['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;
+      }
+      $data['experience'] = isset($data['experience']) && $data['experience'] !== '' ? $data['experience'] : null;
+      $data['salary'] = isset($data['salary']) && $data['salary'] !== '' ? $data['salary'] : null;
+      $data['number'] = isset($data['number']) && $data['number'] !== '' ? $data['number'] : null;
+      $data['language'] = isset($data['language']) && $data['language'] !== '' ? $data['language'] : null;
+      $data['level'] = isset($data['level']) && $data['level'] !== '' ? $data['level'] : null;
+      $data['job_level'] = isset($data['job_level']) && $data['job_level'] !== '' ? $data['job_level'] : null;
+      $data['educational'] = isset($data['educational']) && $data['educational'] !== '' ? $data['educational'] : null;
+      // return Result::success($job);
+      // Db::rollBack();
+      // return Result::success($company);
+      if ((isset($data['status']) && $data['status'] == 0) || !isset($data['status'])) {
+        $this->sendMessage([
+          'talk_type' => 500,
+          'title' => $data['title'],
+          'content' => '提交了审核',
+          'messageType' => 10,
+        ]);
+      }
+      $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 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'])) : '';
+    $job_company = JobCompany::where('user_id', $data['user_id'])->first();
+    $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'],                   // 企业详细地址
+      // 'email' => $data['email'],                       // 企业邮箱
+    ];
+    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'],                   // 企业详细地址
+        ]);
+        if (empty($result['userinfo'])) {
+          Db::rollBack();
+          return Result::error('修改企业会员信息失败!');
+        }
+        $result['user'] = User::where('id', $data['user_id'])->update([
+          'email' => $data['email'],                       // 企业邮箱
+        ]);
+        if (empty($result['user'])) {
+          Db::rollBack();
+          return Result::error('修改个人中心信息失败!');
+        }
+        // 该企业会员若是未发布招聘信息则暂无该企业会员的企业信息
+        if (!empty($job_company)) {
+          $result['job_company'] = JobCompany::where('user_id', $data['user_id'])->update($company);
+          if (empty($result['job_company'])) {
+            Db::rollBack();
+            return Result::error('修改企业会员信息失败!');
+          }
+        }
+        Db::commit();
+        return Result::success($result);
+      } catch (\Exception $e) {
+        Db::rollBack();
+        return Result::error($e->getMessage(), 0);
+      }
+    } else {
+      return Result::error("用户类型错误", 0);
+    }
+  }
+  /*
+    * 获取省-市
+    * */
+  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 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 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 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 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 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']);
+
+    if ($data['status'] == 1) {
+      $this->sendMessage([
+        'talk_type' => 501,
+        'title' => $job['title'],
+        'content' => '审核通过',
+        'messageType' => 10,
+        'user_id' => $job['user_id'],
+      ]);
+    }
+    if ($data['status'] == 2) {
+      $this->sendMessage([
+        'talk_type' => 501,
+        'title' => $job['title'],
+        'content' => '审核拒绝',
+        'messageType' => 10,
+        'user_id' => $job['user_id'],
+      ]);
+    }
+    if ($data['status'] == 0) {
+      $this->sendMessage([
+        'talk_type' => 500,
+        'title' => $job['title'],
+        'content' => '提交了审核',
+        'messageType' => 10,
+      ]);
+    }
+    $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 readJobApply(array $data): array
+  {
+    $result = JobApply::where('id', $data['id'])->first();
+    if (empty($result)) {
+      return Result::error("查询失败", 0);
+    }
+    $result = JobApply::where('id', $data['id'])->update([
+      'status' => 2,
+    ]);
+    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('receiver_id', $user['id']);
+    })
+      ->pluck('recruit_id');
+    // return Result::success($recruitingId);
+    $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 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);
+  }
+
+  public function readJobResume(array $data): array
+  {
+    $result = JobResume::where('id', $data['id'])->first();
+    if (empty($result)) {
+      return Result::error("查询失败", 0);
+    }
+
+    $result = JobResume::where('id', $data['id'])->update([
+      'status' => 2,
+    ]);
+    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'] == '') {
+      //提取内容中的描述
+      $cleaned = preg_replace('/\s+/', '', strip_tags(html_entity_decode($data['detail'], ENT_QUOTES, 'UTF-8')));
+      $data['description'] = mb_substr($cleaned, 0, 100, 'UTF-8');
+    }
+    var_dump($data, '--');
+    if ($data['status'] == 1) {
+      $this->sendMessage([
+        'talk_type' => 400,
+        'title' => $data['title'],
+        'content' => '提交了审核',
+        'messageType' => 7,
+      ]);
+    }
+    $result = Book::insertGetId($data);
+    if (empty($result)) {
+      return Result::error("添加失败", 0);
+    }
+    return Result::success($result);
+  }
+  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);
+  }
+  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'] == '') {
+      //提取内容中的描述
+      $cleaned = preg_replace('/\s+/', '', strip_tags(html_entity_decode($data['detail'], ENT_QUOTES, 'UTF-8')));
+      $data['description'] = mb_substr($cleaned, 0, 100, 'UTF-8');
+    }
+    $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['status'] == 1) {
+      $this->sendMessage([
+        'talk_type' => 400,
+        'title' => $data['title'],
+        'content' => '提交了审核',
+        'messageType' => 7,
+      ]);
+    }
+    $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']);
+    $bookInfo = Book::where("id", $data["id"])->first();
+    var_dump($bookInfo, '----');
+    if ($data['status'] == 2) {
+      $this->sendMessage([
+        'talk_type' => 401,
+        'title' => $bookInfo['title'],
+        'content' => '审核通过',
+        'messageType' => 7,
+        'user_id' => $bookInfo['user_id'],
+      ]);
+    }
+    if ($data['status'] == 3) {
+      $this->sendMessage([
+        'talk_type' => 401,
+        'title' => $bookInfo['title'],
+        'content' => '审核拒绝',
+        'messageType' => 7,
+        'user_id' => $bookInfo['user_id'],
+      ]);
+    }
+    if ($data['status'] == 1) {
+      $this->sendMessage([
+        'talk_type' => 400,
+        'title' => $bookInfo['title'],
+        'content' => '提交了审核',
+        'messageType' => 7,
+        // 'user_id'=>$bookInfo['user_id'],
+      ]);
+    }
+    $result = Book::where("id", $data["id"])->update($data);
+    if (empty($result)) {
+      return Result::error("更新失败", 0);
+    }
+    return Result::success($result);
+  }
+
+  //20250422  书刊音像
+
+  /**
+   * 贴身宝贝
+   * @param array $data
+   * @return array
+   */
+  public function getWebsiteTsbb(array $data): array
+  {
+    $month = $data['month'] ?? date('m');
+    $day = $data['day'] ?? date('d');
+
+    // 使用缓存键
+    $cacheKey = "tsbb_data_{$month}_{$day}";
+
+    // 尝试从缓存获取数据
+    $container = \Hyperf\Context\ApplicationContext::getContainer();
+    $cache = $container->get(\Psr\SimpleCache\CacheInterface::class);
+
+    if ($cachedData = $cache->get($cacheKey)) {
+      return Result::success(unserialize($cachedData));
+    }
+
+    //查询老黄历
+    try {
+
+      $date = date('Y-m-d');
+      $almanacUrl = "https://www.36jxs.com/api/Commonweal/almanac?sun=" . $date;
+      // 使用 curl 替代 file_get_contents
+      $ch = curl_init();
+      curl_setopt($ch, CURLOPT_URL, $almanacUrl);
+      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+      curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
+      curl_setopt($ch, CURLOPT_TIMEOUT, 10);
+      curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36');
+      curl_setopt($ch, CURLOPT_HTTPHEADER, [
+        'Accept: application/json',
+        'Content-Type: application/json',
+        'Referer: https://www.36jxs.com/'
+      ]);
+      curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
+      curl_setopt($ch, CURLOPT_ENCODING, '');
+
+      $almanacResponse = curl_exec($ch);
+      var_dump("====:", $almanacResponse);
+
+      if (curl_errno($ch)) {
+        var_dump('Curl error:', curl_error($ch));
+        throw new \Exception('Curl error: ' . curl_error($ch));
+      }
+
+      // $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
+
+      curl_close($ch);
+
+      if ($almanacResponse === false) {
+        throw new \Exception('Failed to fetch almanac data');
+      }
+      $almanacData = json_decode($almanacResponse, true);
+      if (json_last_error() !== JSON_ERROR_NONE) {
+        throw new \Exception('Failed to parse almanac data');
+      }
+      $almanacInfo = $almanacData['data'] ?? [];
+    } catch (\Exception $e) {
+      var_dump('Exception:', $e->getMessage());
+      $almanacInfo = [];
+    }
+
+    // 获取历史上的今天数据
+    $historyTodayList = HistoryToday::whereRaw("DATE_FORMAT(year, '%m') = ?", [$month])
+      ->whereRaw("DATE_FORMAT(year, '%d') = ?", [$day])
+      ->orderBy('year', 'asc')
+      ->select("title", "id", "year", DB::raw('1 as type'))
+      ->limit(16)
+      ->get();
+
+    // 获取节日数据 - 从今天开始获取未来4条
+    $festivalList = Festival::whereRaw("DATE_FORMAT(showtime, '%m-%d') >= ?", [$month . '-' . $day])
+      ->orderBy('showtime', 'asc')
+      ->select("title", "id", "showtime", DB::raw('2 as type'))
+      ->limit(16)
+      ->get();
+    //说文解字
+    $chartacterList = Character::orderBy('updated_at', 'desc')
+      ->select("id", "title", "duyin", "bushou", "bihua", DB::raw('3 as type'))
+      ->limit(6)
+      ->get();
+    //谜语沙龙
+    $riddletList = Riddle::orderBy('updated_at', 'desc')
+      ->select("id", "riddle_title", "riddle_bottom", "prompt", DB::raw('4 as type'))
+      ->limit(4)
+      ->get();
+    //成语欣赏
+    $idiomList = Idiom::orderBy('updated_at', 'desc')
+      ->select("id", "title", "duyin", DB::raw('5 as type'))
+      ->limit(32)
+      ->get();
+    //名联赏析
+    $coupletList = Couplet::orderBy('updated_at', 'desc')
+      ->select("id", "first", "second", DB::raw('6 as type'))
+      ->limit(6)
+      ->get();
+    // 获取分类文章数据
+
+    $categoryIds = WebsiteCategory::where(['website_id' => $data['website_id'], 'pid' => 0])
+      ->pluck('category_id')
+      ->toArray();
+
+    $articlesList = [];
+    foreach ($categoryIds as $catid) {
+      // 先查有图片的
+      $withImg = DB::table('article')
+        ->where('status', 1)
+        ->where('catid', $catid)
+        ->whereNotNull('imgurl')
+        ->where('imgurl', '!=', '')
+        ->orderBy('updated_at', 'desc')
+        ->limit(6)
+        ->get();
+
+      $count = $withImg->count();
+      if ($count < 6) {
+        // 不足6条再查无图片的补足
+        $withoutImg = DB::table('article')
+          ->where('status', 1)
+          ->where('catid', $catid)
+          ->where(function ($q) {
+            $q->whereNull('imgurl')->orWhere('imgurl', '');
+          })
+          ->orderBy('updated_at', 'desc')
+          ->limit(6 - $count)
+          ->get();
+        $articles = $withImg->concat($withoutImg);
+      } else {
+        $articles = $withImg;
+      }
+
+      // 组装
+      $category = \App\Model\Category::find($catid);
+      $websiteCategory = WebsiteCategory::where('category_id', $catid)->first();
+      $articlesList[] = [
+        'category_name' => $category ? $category->name : '',
+        'catid' => $catid,
+        'pinyin' => $websiteCategory ? $websiteCategory->aLIas_pinyin : '',
+        'type' => 100,
+        'list' => $articles->map(function ($item) {
+          return [
+            'id' => $item->id,
+            'title' => $item->title,
+            'imgurl' => $item->imgurl,
+            'created_at' => $item->created_at
+          ];
+        })->values()
+      ];
+    }
+
+
+    $result = [
+      'almanac' => $almanacInfo,
+      'historyTodayList' => [
+        'category_name' => '历史上的今天',
+        'list' => $historyTodayList,
+        'type' => 1
+      ],
+      'festivalList' => [
+        'category_name' => '节日预告',
+        'list' => $festivalList,
+        'type' => 2
+      ],
+      'chartacterList' => [
+        'category_name' => '说文解字',
+        'list' => $chartacterList,
+        'type' => 3
+      ],
+      'coupletList' => [
+        'category_name' => '名联赏析',
+        'list' => $coupletList,
+        'type' => 6
+      ],
+      'riddletList' => [
+        'category_name' => '谜语沙龙',
+        'list' => $riddletList,
+        'type' => 4
+      ],
+      'idiomList' => [
+        'category_name' => '成语欣赏',
+        'list' => $idiomList,
+        'type' => 5
+      ],
+      'articlesList' => $articlesList
+    ];
+
+    // 缓存结果,设置1小时过期
+    $cache->set($cacheKey, serialize($result), 3600);
+
+    return Result::success($result);
+  }
+  /**
+   * 获取资讯列表
+   */
+  public function getWebsiteTsbbList(array $data): array
+  {
+    $page = $data['page'] ?? 1;
+    $pageSize = $data['pageSize'] ?? 10;
+
+    // 如果没有传入月份和日期,则使用今天的日期
+    $month = $data['month'] ?? date('m');
+    $day = $data['day'] ?? date('d');
+    $total = 0;
+    $result = [];
+    $data['type'] = intval($data['type']);
+    var_dump("接收参数:", $data);
+    switch ($data['type']) {
+      case 1:
+        $query = HistoryToday::where(function ($q) use ($month, $day) {
+          // 当前月份之后的数据
+          $q->whereRaw("DATE_FORMAT(year, '%m') > ?", [$month])
+            // 或者当前月份且日期大于等于当前日期的数据
+            ->orWhere(function ($q) use ($month, $day) {
+              $q->whereRaw("DATE_FORMAT(year, '%m') = ?", [$month])
+                ->whereRaw("DATE_FORMAT(year, '%d') >= ?", [$day]);
+            });
+        })
+          ->orderByRaw("DATE_FORMAT(year, '%m') ASC, DATE_FORMAT(year, '%d') ASC, year ASC");
+
+        $total = $query->count();
+        $result = $query->select("title", "id", "year", "updated_at", DB::raw('1 as type'))
+          ->offset(($page - 1) * $pageSize)
+          ->limit($pageSize)
+          ->get();
+        break;
+      case 2:
+        $query = Festival::where(function ($q) use ($month, $day) {
+          // 当前月份之后或者当前月份且日期大于等于当前日期的数据
+          $q->whereRaw("DATE_FORMAT(showtime, '%m') > ?", [$month])
+            ->orWhere(function ($q) use ($month, $day) {
+              $q->whereRaw("DATE_FORMAT(showtime, '%m') = ?", [$month])
+                ->whereRaw("DATE_FORMAT(showtime, '%d') >= ?", [$day]);
+            });
+        })->orderByRaw("DATE_FORMAT(showtime, '%m') ASC, DATE_FORMAT(showtime, '%d') ASC, showtime ASC");
+        $total = $query->count();
+        $result = $query->select("title", "id", "updated_at", "showtime", DB::raw('2 as type'))
+          ->offset(($page - 1) * $pageSize)
+          ->limit($pageSize)
+          ->get();
+        break;
+      case 3:
+        $query = Character::orderBy("updated_at",  "desc");
+        $total = $query->count();
+        $result = $query->select("title", "id", "updated_at", DB::raw('3 as type'))
+          ->offset(($page - 1) * $pageSize)
+          ->limit($pageSize)
+          ->get();
+        break;
+      case 4:
+        $query = Riddle::orderBy("updated_at",  "desc");
+        $total = $query->count();
+        $result = $query->select("riddle_title as title", "updated_at", "id", DB::raw('4 as type'))
+          ->offset(($page - 1) * $pageSize)
+          ->limit($pageSize)
+          ->get();
+        break;
+      case 5:
+        $query = Idiom::orderBy("updated_at",  "desc");
+        $total = $query->count();
+        $result = $query->select("title", "id", "updated_at", DB::raw('5 as type'))
+          ->offset(($page - 1) * $pageSize)
+          ->limit($pageSize)
+          ->get();
+        break;
+      case 6:
+        $query = Couplet::orderBy("updated_at",  "desc");
+        $total = $query->count();
+        $result = $query->select("first as title", "updated_at", "id", DB::raw('6 as type'))
+          ->offset(($page - 1) * $pageSize)
+          ->limit($pageSize)
+          ->get();
+        break;
+      default:
+        $query = Article::where(['catid' => $data['catid']])->orderBy("updated_at",  "desc");
+        $total = $query->count();
+        $result = $query->select("title", "id", "updated_at", DB::raw('100 as type'))
+          ->offset(($page - 1) * $pageSize)
+          ->limit($pageSize)
+          ->get();
+    }
+    return Result::success([
+      'list' => $result,
+      'total' => $total,
+      'page' => (int)$page,
+      'pageSize' => (int)$pageSize,
+      'month' => $month,
+      'day' => $day
+    ]);
+  }
+  /**
+   * 1:历史上的今天
+   * 2:节日
+   * 3:文章
+   *
+   * 资讯详情信息
+   */
+  public function getWebsiteTsbbDetail(array $data): array
+  {
+    $data['type'] = intval($data['type']);
+    switch ($data['type']) {
+      case 1:
+        $result = HistoryToday::where("id", $data['id'])->first();
+        break;
+      case 2:
+        $result = Festival::where("id", $data['id'])->first();
+        break;
+      case 3:
+        $result = Character::where("id", $data['id'])->first();
+        break;
+      case 4:
+        $result = Riddle::where("id", $data['id'])->first();
+        break;
+      case 5:
+        $result = Idiom::where("id", $data['id'])->first();
+        break;
+      case 6:
+        $result = Couplet::where("id", $data['id'])->first();
+        break;
+      default:
+        $result = Article::where("id", $data['id'])->select("article.*", "article_data.content")->leftJoin("article_data", "article.id", "=", "article_data.article_id")->first();
+        break;
+    }
+    return Result::success($result);
+  }
+
+
+  /**
+   * 农网导航首页数据
+   */
+  public function getWebsiteNwHomeList(array $data): array
+  {
+    $categoryIds =  WebsiteCategory::where(['website_id' => $data['website_id']])->where("pid", "!=", 0)
+      ->pluck('category_id')
+      ->toArray();
+    // 使用子查询优化
+    $articlesList = DB::table('article')
+      ->select([
+        'article.id',
+        'article.title',
+        'article.imgurl',
+        'article.created_at',
+        'category.name as category_name',
+        'category.id as category_id',
+        'website_category.aLIas_pinyin as pinyin',
+        'parent_wc.aLIas_pinyin as parent_pinyin',
+        DB::raw('100 as type')
+      ])
+      ->join('category', 'article.catid', '=', 'category.id')
+      ->leftJoin('website_category', 'website_category.category_id', '=', 'category.id')
+      ->leftJoin('website_category as parent_wc', function ($join) {
+        $join->on('parent_wc.category_id', '=', 'website_category.pid')
+          ->where('parent_wc.website_id', '=', DB::raw('website_category.website_id'));
+      })
+      ->where('website_category.website_id', $data['website_id'])
+      ->where('article.status', 1)
+      ->whereIn('category.id', $categoryIds)
+      ->orderBy('article.created_at', 'desc')
+      ->get()
+      ->groupBy('category_id')
+      ->map(function ($group) {
+        // 确保第一条数据有图片
+        $firstWithImage = $group->first(function ($item) {
+          return !empty($item->imgurl);
+        });
+
+        if ($firstWithImage) {
+          // 如果有带图片的文章,将其放在第一位
+          $group = $group->filter(function ($item) use ($firstWithImage) {
+            return $item->id !== $firstWithImage->id;
+          })->prepend($firstWithImage);
+        }
+
+        return [
+          'category_name' => $group->first()->category_name,
+          'catid' => $group->first()->category_id,
+          'pinyin' => $group->first()->pinyin,
+          'parent_pinyin' => $group->first()->parent_pinyin,
+          'list' => $group->take(4)->map(function ($item) {
+            return [
+              'id' => $item->id,
+              'title' => $item->title,
+            ];
+          })->values()
+        ];
+      })
+      ->values()
+      ->toArray();
+    return Result::success($articlesList);
+  }
+  /**
+   * 企业管理
+   * @param array $data
+   * @return array
+   */
+  public function getCompanyList(array $data): array
+  {
+    // return Result::success($data);
+    $where = [];
+    $user = User::where('id', $data['user_id'])->first();
+    if (empty($user)) {
+      return Result::error('用户不存在!');
+    }
+    if ($user['type_id'] != 10000) {
+      $where['user_id'] = $data['user_id'];
+    }
+    if (isset($data['title']) && !empty($data['title'])) {
+      array_push($where, ['company.title', 'like', '%' . $data['title'] . '%']);
+    }
+    if (isset($data['website_id']) && !empty($data['website_id'])) {
+      array_push($where, ['website.id', $data['website_id']]);
+    }
+    if (isset($data['ischeck']) && !empty($data['ischeck'])) {
+      if ($data['ischeck'] == 1) {
+        if (isset($data['status']) && $data['status'] != '') {
+          array_push($where, ['company.status', $data['status']]);
+          $query = Company::where($where);
+        } else {
+          $query =  Company::whereIn('company.status', [0, 2]);
+        }
+      } else {
+        $query =  Company::where('company.status', 1);
+      }
+    }
+    $result = $query->where($where)
+      ->leftJoin('website_category', function ($query) {
+        $query->on('website_category.category_id', '=', 'company.category_id')
+          ->on('website_category.website_id', '=', 'company.website_id');
+      })
+      ->leftJoin('website', 'company.website_id', '=', 'website.id')
+      ->select(
+        'company.id',
+        'company.title',
+        'company.website_id',
+        'company.category_id',
+        'website.website_name',
+        'website_category.alias as category_name',
+        'company.status',
+        'company.updated_at',
+        'company.user_id'
+      )
+      ->orderBy('company.updated_at', 'desc')
+      ->paginate($data['pageSize'], ['*'], 'page', $data['page']);
+
+    if ($result->isEmpty()) {
+      return Result::error("暂无企业", 0);
+    }
+    return Result::success($result);
+  }
+  /**
+   * 添加企业
+   * @param array $data
+   * @return array
+   */
+  public function addCompany(array $data): array
+  {
+    $data['category_id'] = isset($data['cat_arr_id']) ? end($data['cat_arr_id']) : '';
+    if (isset($data['cat_arr_id']) && !empty($data['cat_arr_id']) && is_array($data['cat_arr_id'])) {
+      $car_arr_id = array_values(array_unique(array_map('intval', $data['cat_arr_id'])));
+      $data['cat_arr_id'] = json_encode($car_arr_id);
+    } else {
+      $data['cat_arr_id'] = '';
+    }
+    if ($data['imgurl'] == '') {
+      //content中提取图片第一个图,正则提取
+      $reg = '/<img.*?src=[\"|\']?(.*?)[\"|\']?\s.*?>/i';
+      preg_match_all($reg, $data['content'], $matches);
+      if (isset($matches[1][0])) {
+        //截取varchar240
+        $data['imgurl'] = 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['introduce'] == '' || empty($data['introduce'])) {
+      //提取内容中的描述
+      $content = $data['content'];
+      // 去除 <style> 和 <script> 标签及其内容
+      $content = preg_replace('/<(style|script)[^>]*>.*?<\/\1>/is', '', $content);
+      // 去除所有 HTML 标签
+      $content = strip_tags($content);
+      // 去除 HTML 实体
+      $content = html_entity_decode($content, ENT_QUOTES | ENT_HTML5, 'UTF-8');
+      // 只保留文本和标点符号(去除所有字母数字以外的特殊符号,可根据需要调整正则)
+      $content = preg_replace('/[^\p{L}\p{N}\p{P}\p{Zs}]+/u', '', $content);
+      // 去除多余空白
+      $content = preg_replace('/\s+/u', '', $content);
+      // 截取 100 个字符
+      $data['introduce'] = mb_substr($content, 0, 100);
+    }
+    $user = User::where('id', $data['user_id'])->first();
+    if (empty($user)) {
+      return Result::error('用户不存在!');
+    }
+    if ($user['type_id'] == 10000) {
+      $data['status'] = 1;
+    }
+    if (isset($data['level']) && $data['level'] != null) {
+      $data['level'] = intval($data['level']);
+    } else {
+      $data['level'] = null;
+    }
+    if ((isset($data['status']) && $data['status'] == 0) || !isset($data['status'])) {
+      $this->sendMessage([
+        'talk_type' => 900,
+        'title' => $data['title'],
+        'content' => '提交了审核',
+        'messageType' => 8,
+      ]);
+    }
+    $result = Company::insertGetId($data);
+    if ($result) {
+      return Result::success($result);
+    } else {
+      return Result::error('添加失败');
+    }
+  }
+  /**
+   * 更新企业
+   * @param array $data
+   * @return array
+   */
+  public function upCompany(array $data): array
+  {
+    if (isset($data['cat_arr_id']) && !empty($data['cat_arr_id']) && is_array($data['cat_arr_id'])) {
+      $car_arr_id = array_values(array_unique(array_map('intval', $data['cat_arr_id'])));
+      $data['cat_arr_id'] = json_encode($car_arr_id);
+      $data['category_id'] = isset($data['cat_arr_id']) ? end($car_arr_id) : '';
+    } else {
+      $data['cat_arr_id'] = '';
+    }
+    if ($data['imgurl'] == '') {
+      //content中提取图片第一个图,正则提取
+      $reg = '/<img.*?src=[\"|\']?(.*?)[\"|\']?\s.*?>/i';
+      preg_match_all($reg, $data['content'], $matches);
+      if (isset($matches[1][0])) {
+        //截取varchar
+        $data['imgurl'] = 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['introduce'] == '') {
+      //提取内容中的描述
+      $content = $data['content'];
+      // 去除 <style> 和 <script> 标签及其内容
+      $content = preg_replace('/<(style|script)[^>]*>.*?<\/\1>/is', '', $content);
+      // 去除所有 HTML 标签
+      $content = strip_tags($content);
+      // 去除 HTML 实体
+      $content = html_entity_decode($content, ENT_QUOTES | ENT_HTML5, 'UTF-8');
+      // 只保留文本和标点符号(去除所有字母数字以外的特殊符号,可根据需要调整正则)
+      $content = preg_replace('/[^\p{L}\p{N}\p{P}\p{Zs}]+/u', '', $content);
+      // 去除多余空白
+      $content = preg_replace('/\s+/u', '', $content);
+      // 截取 100 个字符
+      $data['introduce'] = mb_substr($content, 0, 100);
+    }
+    if (isset($data['level']) && $data['level'] != null) {
+      $data['level'] = intval($data['level']);
+    } else {
+      $data['level'] = null;
+    }
+    $user = User::where('id', $data['user_id'])->first();
+    if (empty($user)) {
+      return Result::error('用户不存在!');
+    }
+    if ($user['type_id'] == 10000) {
+      $data['status'] = 1;
+    } else {
+      $data['status'] = 0;
+    }
+    if ((isset($data['status']) && $data['status'] == 0) || !isset($data['status'])) {
+      $this->sendMessage([
+        'talk_type' => 900,
+        'title' => $data['title'],
+        'content' => '提交了审核',
+        'messageType' => 8,
+      ]);
+    }
+    $result = Company::where('id', $data['id'])->update($data);
+    if ($result) {
+      return Result::success($result);
+    } else {
+      return Result::error('修改失败');
+    }
+  }
+  /**
+   * 删除企业
+   * @param array $data
+   * @return array
+   */
+  public function delCompany(array $data): array
+  {
+    $result = Company::where('id', $data['id'])->delete();
+    if ($result) {
+      return Result::success($result);
+    } else {
+      return Result::error('删除失败');
+    }
+  }
+  /**
+   * 审核企业
+   * @param array $data
+   * @return array
+   */
+  public function checkCompany(array $data): array
+  {
+    $user = User::where('id', $data['user_id'])->first();
+    if (empty($user)) {
+      return Result::error('用户不存在!');
+    }
+    $company = Company::where('id', $data['id'])->first();
+    if (empty($company)) {
+      return Result::error('企业不存在!');
+    }
+    // 状态:0:未审核 1:已审核 2:已拒绝
+    if ($data['status'] == 2 || $data['status'] == '2') {
+      $this->sendMessage([
+        'talk_type' => 901,
+        'title' => $company['title'],
+        'content' => '审核拒绝',
+        'messageType' => 8,
+        'user_id' => $company['user_id'],
+      ]);
+      $result = Company::where('id', $data['id'])->update(['status' => $data['status'], 'reject_reason' => $data['reason']]);
+    } else {
+      if ($data['status'] == 1) {
+        $this->sendMessage([
+          'talk_type' => 901,
+          'title' => $company['title'],
+          'content' => '审核通过',
+          'messageType' => 8,
+          'user_id' => $company['user_id'],
+        ]);
+      } else if ($data['status'] == 0) {
+        $this->sendMessage([
+          'talk_type' => 900,
+          'title' => $company['title'],
+          'content' => '提交了审核',
+          'messageType' => 8,
+        ]);
+      }
+      $result = Company::where('id', $data['id'])->update(['status' => $data['status']]);
+    }
+    if (empty($result)) {
+      return Result::error('审核失败!');
+    } else {
+      return Result::success($result);
+    }
+  }
+  /**
+   * 获取企业信息
+   * @param array $data
+   * @return array
+   */
+  public function getCompanyInfo(array $data): array
+  {
+    $result = Company::where('id', $data['id'])->first();
+    $city_arr = json_decode($result['city_arr_id']);
+    $result['city_name'] = District::whereIn('id', $city_arr)
+      ->pluck('name')
+      ->implode('-');
+
+    if (empty($result)) {
+      return Result::error('企业不存在!');
+    } else {
+      return Result::success($result);
+    }
+  }
+  /**
+   * @param array $data
+   * @return array
+   */
+  public function getWebsiteCompany(array $data): array
+  {
+    $categorys = json_decode($data['id'], true);
+    $category_arr = $this->processArticlePro($data['website_id']);
+    $cat_1st_arr = $category_arr['cat_1st_arr'];
+    $catiall = $category_arr['catiall'];
+    $categoryIds = $category_arr['categoryIds'];
+    // return Result::success($category_arr);
+    foreach ($categorys as $key => $value) {
+      if (array_key_exists('level', $value)) {
+        $parts = explode(',', $value['level']);
+        $level = $parts[0] ?? null;
+        $imgnum = $parts[1] ?? null;
+        $textnum = $parts[2] ?? null;
+        if (!empty($textnum) && $textnum > 0) {
+          $text_num = Company::where('level', $level)
+            ->whereIn('category_id', $categoryIds)
+            ->where('status', 1)
+            ->select(
+              'company.id',
+              'company.title',
+              'company.description',
+              'company.updated_at',
+              'company.category_id',
+              'company.cat_arr_id'
+            )
+            ->orderBy('updated_at', 'desc')
+            ->limit($textnum)
+            ->get()->all();
+        }
+        if (!empty($imgnum) && $imgnum > 0) {
+          $img_num = Company::where('level', $level)
+            ->whereIn('category_id', $categoryIds)
+            ->where('status', 1)
+            ->where('imgurl', '!=', '')
+            ->whereNotNull('imgurl')
+            ->select(
+              'company.id',
+              'company.title',
+              'company.description',
+              'company.updated_at',
+              'company.imgurl as imgs',
+              'company.category_id',
+              'company.cat_arr_id'
+            )
+            ->orderBy('updated_at', 'desc')
+            ->limit($imgnum)
+            ->get()->all();
+        }
+      }
+      if (array_key_exists('id', $value)) {
+        $parts = explode(',', $value['id']);
+        $category_id = $parts[0] ?? null;
+        $imgnum = $parts[1] ?? null;
+        $textnum = $parts[2] ?? null;
+        $category_arr = array_merge([$category_id], $cat_1st_arr[$category_id] ?? [0]);
+        if (!empty($textnum) && $textnum > 0) {
+          $text_num = Company::whereIn('category_id', $category_arr)
+            // ->where('website_id', $data['website_id'])
+            ->where('status', 1)
+            ->select(
+              'company.id',
+              'company.title',
+              'company.description',
+              'company.updated_at',
+              'company.category_id',
+              'company.cat_arr_id'
+            )
+            ->orderBy('updated_at', 'desc')
+            ->limit($textnum)
+            ->get()->all();
+        }
+        if (!empty($imgnum) && $imgnum > 0) {
+
+          $img_num = Company::whereIn('category_id', $category_arr)
+            // ->where('website_id', $data['website_id'])
+            ->where('status', 1)
+            ->where('imgurl', '!=', '')
+            ->whereNotNull('imgurl')
+            ->select(
+              'company.id',
+              'company.title',
+              'company.description',
+              'company.updated_at',
+              'company.imgurl as imgs',
+              'company.category_id',
+              'company.cat_arr_id'
+            )
+            ->orderBy('updated_at', 'desc')
+            ->limit($imgnum)
+            ->get()->all();
+        }
+      }
+      if (!empty($text_num)) {
+        foreach ($text_num as $k => $v) {
+          $text_num[$k]->category_name = $catiall[$v->category_id]['alias'];
+          $text_num[$k]->pinyin = $catiall[$v->category_id]['pinyin'];
+        }
+      }
+      if (!empty($img_num)) {
+        foreach ($img_num as $k => $v) {
+          $img_num[$k]->category_name = $catiall[$v->category_id]['alias'];
+          $imgurl = json_decode($v['imgs'], true);
+          if (!empty($imgurl)) {
+            $img_num[$k]->imgurl = $imgurl[0];
+          }
+          $img_num[$k]->pinyin = $catiall[$v->category_id]['pinyin'];
+        }
+      }
+      $company[$key]['img_num'] = $img_num ?? [];
+      $company[$key]['text_num'] = $text_num ?? [];
+    }
+
+    if (empty($company)) {
+      return Result::error("暂无相关企业信息", 0);
+    }
+
+    return Result::success($company);
+  }
+  /**
+   * @param array $data
+   * @return array
+   */
+  public function getWebsiteCompanyList(array $data): array
+  {
+    $where['website_id'] = $data['website_id'];
+    $where['status'] = 1;
+    $categoryIds = [];
+    if (isset($data['category_id']) && !empty($data['category_id'])) {
+
+      $category_id = $data['category_id'];
+    }
+    $category_arr = $this->processArticlePro($data['website_id']);
+    $categoryIds = $category_arr['categoryIds'];
+    // return Result::success($cat_1st_arr);
+    $company = Company::when(isset($data['keyword']) && !empty($data['keyword']), function ($query) use ($data) {
+      $query->where('title', 'like', '%' . $data['keyword'] . '%');
+    })
+      ->when(!isset($category_id) || empty($category_id), function ($query) use ($categoryIds) {
+        $query->whereIn('category_id', $categoryIds);
+      })
+      ->when(isset($data['category_id']) && !empty($data['category_id']), function ($query) use ($category_id) {
+        $query->where('category_id', $category_id);
+      })
+      ->where('status',1)
+      ->select('id', 'title', 'introduce', 'description', 'content', 'category_id', 'cat_arr_id', 'updated_at')
+      ->orderBy('updated_at', 'desc')
+      ->paginate($data['pageSize'], ['*'], 'page', $data['page']);
+    if (empty($company)) {
+      return Result::error("暂无相关公司信息", 0);
+    }
+    $result = [
+      'count' => $company->total(),
+      'data' => $company->items(), // 使用 items() 方法替代不存在的 data() 方法
+    ];
+    return Result::success($result);
+  }
+  /**
+   * 获取项目列表
+   * @param array $data
+   * @return array
+   */
+  public function getProjectList(array $data): array
+  {
+    $where = [];
+    $user = User::where('id', $data['user_id'])->first();
+    if (empty($user)) {
+      return Result::error('用户不存在!');
+    }
+    if ($user->type_id != 10000) {
+      array_push($where, ['project.user_id', $data['user_id']]);
+    }
+    $query = Project::query();
+    if (isset($data['website_id']) && !empty($data['website_id'])) {
+      array_push($where, ['project.website_id', $data['website_id']]);
+    }
+    if (isset($data['title']) && !empty($data['title'])) {
+      array_push($where, ['project.title', 'like', '%' . $data['title'] . '%']);
+    }
+    if ($data['status'] != 3) {
+      array_push($where, ['project.status', $data['status']]);
+    }
+    $query = Project::where($where)
+      ->when($data['status'] == 3, function ($query) {
+        $query->whereIn('project.status', [0, 2]);
+      });
+    $count = $query->clone()
+      ->count();
+    $rows = $query->clone()
+      ->leftJoin('website', 'project.website_id', 'website.id')
+      ->leftJoin('website_category', function ($join) {
+        $join->on('project.website_id', '=', 'website_category.website_id')
+          ->on('project.category_id', '=', 'website_category.category_id');
+      })
+      ->select(
+        'project.id',
+        'project.title',
+        'project.updated_at',
+        'project.status',
+        'website.website_name',
+        'website_category.alias as category_name',
+        'project.website_id',
+        'project.user_id'
+      )
+      ->orderBy('project.updated_at', 'desc')
+      ->offset(($data['page'] - 1) * $data['pageSize'])
+      ->limit($data['pageSize'])
+      ->get();
+    if ($rows->isEmpty()) {
+      return Result::error("暂无相关项目信息", 0);
+    }
+    $result = [
+      'count' => $count,
+      'rows' => $rows,
+    ];
+    return Result::success($result);
+  }
+  /**
+   * 添加项目
+   * @param array $data
+   * @return array
+   */
+  public function addProject(array $data): array
+  {
+    $user = User::where('id', $data['user_id'])->first();
+    if (empty($user)) {
+      return Result::error("暂无相关用户信息", 0);
+    }
+    if ($user->type_id == 10000) {
+      $data['status'] = 1;
+    } else {
+      $data['status'] = 0;
+    }
+    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'] == '') {
+      //提取内容中的描述
+      // var_dump(11111);
+      //提取内容中的描述
+      $content = $data['introduce'];
+      // 去除 <style> 和 <script> 标签及其内容
+      $content = preg_replace('/<(style|script)[^>]*>.*?<\/\1>/is', '', $content);
+      // 去除所有 HTML 标签
+      $content = strip_tags($content);
+      // 去除 HTML 实体
+      $content = html_entity_decode($content, ENT_QUOTES | ENT_HTML5, 'UTF-8');
+      // 只保留文本和标点符号(去除所有字母数字以外的特殊符号,可根据需要调整正则)
+      $content = preg_replace('/[^\p{L}\p{N}\p{P}\p{Zs}]+/u', '', $content);
+      // 去除多余空白
+      $content = preg_replace('/\s+/u', '', $content);
+      // 截取 100 个字符
+      $data['description'] = mb_substr($content, 0, 100);
+      // 过滤 HTML 标签并去除空格,然后截取前 100 个字符
+    }
+    if ($data['status'] == 0) {
+      $this->sendMessage([
+        'talk_type' => 1000,
+        'title' => $data['title'],
+        'content' => '提交了审核',
+        'messageType' => 9,
+      ]);
+    }
+    $project = Project::insertGetId($data);
+    if (empty($project)) {
+      return Result::error("暂无相关项目信息", 0);
+    }
+    return Result::success($project);
+  }
+  /**
+   * 更新项目
+   * @param array $data
+   * @return array
+   */
+  public function upProject(array $data): array
+  {
+    $project = Project::where('id', $data['id'])->first();
+    if (empty($project)) {
+      return Result::error("暂无相关项目信息", 0);
+    }
+    $id = $data['id'];
+    unset($data['id']);
+    $user = User::where('id', $data['user_id'])->first();
+    if (empty($user)) {
+      return Result::error("暂无相关用户信息", 0);
+    }
+    if ($user->type_id == 10000) {
+      $data['status'] = 1;
+    } else {
+      $data['status'] = 0;
+    }
+    unset($data['user_id']);
+    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'] == '') {
+      //提取内容中的描述
+      // var_dump(11111);
+      //提取内容中的描述
+      $content = $data['introduce'];
+      // 去除 <style> 和 <script> 标签及其内容
+      $content = preg_replace('/<(style|script)[^>]*>.*?<\/\1>/is', '', $content);
+      // 去除所有 HTML 标签
+      $content = strip_tags($content);
+      // 去除 HTML 实体
+      $content = html_entity_decode($content, ENT_QUOTES | ENT_HTML5, 'UTF-8');
+      // 只保留文本和标点符号(去除所有字母数字以外的特殊符号,可根据需要调整正则)
+      $content = preg_replace('/[^\p{L}\p{N}\p{P}\p{Zs}]+/u', '', $content);
+      // 去除多余空白
+      $content = preg_replace('/\s+/u', '', $content);
+      // 截取 100 个字符
+      $data['description'] = mb_substr($content, 0, 100);
+      // 过滤 HTML 标签并去除空格,然后截取前 100 个字符
+    }
+    if ($data['status'] == 0) {
+      $this->sendMessage([
+        'talk_type' => 1000,
+        'title' => $data['title'],
+        'content' => '提交了审核',
+        'messageType' => 9,
+      ]);
+    }
+    $result = Project::where('id', $id)->update($data);
+    if (empty($result)) {
+      return Result::error("更新失败", 0);
+    }
+    return Result::success($result);
+  }
+  /**
+   * 删除项目
+   * @param array $data
+   * @return array
+   */
+
+  public function delProject(array $data): array
+  {
+    $user = User::where('id', $data['user_id'])->first();
+    if (empty($user)) {
+      return Result::error("暂无相关用户信息", 0);
+    }
+    $project = Project::where('id', $data['id'])->first();
+    if (empty($project)) {
+      return Result::error("暂无相关项目信息", 0);
+    }
+    $result = Project::where('id', $data['id'])->delete();
+    if (empty($result)) {
+      return Result::error("删除失败", 0);
+    }
+    return Result::success($result);
+  }
+  /**
+   * 审核项目
+   * @param array $data
+   * @return array
+   */
+  public function checkProject(array $data): array
+  {
+    $user = User::where('id', $data['user_id'])->first();
+    if (empty($user)) {
+      return Result::error("暂无相关用户信息", 0);
+    }
+    // 0:未审核;   1:已审核;   2:已拒绝;
+    if ($user->type_id != 10000) {
+      if ($data['status'] == 1 || $data['status'] == 2) {
+        return Result::error("此用户权限不足", 0);
+      }
+    }
+    $project = Project::where('id', $data['id'])->first();
+    if (empty($project)) {
+      return Result::error("暂无相关项目信息", 0);
+    }
+    if ($data['status'] == 2) {
+      $this->sendMessage([
+        'talk_type' => 1001,
+        'title' => $project['title'],
+        'content' => '审核拒绝',
+        'messageType' => 9,
+        'user_id' => $project['user_id'],
+      ]);
+      $result = Project::where('id', $data['id'])->update(['status' => $data['status'], 'refuse_reason' => $data['refuse_reason']]);
+    } else {
+      if ($data['status'] == 1) {
+        $this->sendMessage([
+          'talk_type' => 1001,
+          'title' => $project['title'],
+          'content' => '审核通过',
+          'messageType' => 9,
+          'user_id' => $project['user_id'],
+        ]);
+      } else if ($data['status'] == 0) {
+        $this->sendMessage([
+          'talk_type' => 1000,
+          'title' => $project['title'],
+          'content' => '提交了审核',
+          'messageType' => 9,
+        ]);
+      }
+      $result = Project::where('id', $data['id'])->update(['status' => $data['status']]);
+    }
+
+    if (empty($result)) {
+      return Result::error("审核失败", 0);
+    }
+    return Result::success($result);
+  }
+  /**
+   * 获取项目详情
+   * @param array $data
+   * @return array
+   */
+  public function getProjectInfo(array $data): array
+  {
+    $project = Project::where('id', $data['id'])->first();
+    if (empty($project)) {
+      return Result::error("暂无相关项目信息", 0);
+    }
+    return Result::success($project);
+  }
+
+  public function getWebsiteCompanyInfo(array $data): array
+  {
+    $company = Company::where('id', $data['id'])
+      ->leftJoin('job_industry', 'job_industry.hyid', 'company.hy_id')
+      ->where('status', 1)
+      // ->where('website_id', $data['website_id'])
+      ->select('company.*', 'job_industry.hyname as hy_name')
+      ->first();
+    // 企业性质:0:市场监管;1:信访纪检;2:公检法司;3:高关注机构
+    $jobnature_id = $company['jobnature_id'] ?? null;
+    if ($jobnature_id !== null) {
+        switch ($jobnature_id) {
+            case 0:
+                $company->jobnature_name = '市场监督';
+                break;
+            case 1:
+                $company->jobnature_name = '信访纪检';
+                break;
+            case 2:
+                $company->jobnature_name = '公检法司';
+                break;
+            case 3:
+                $company->jobnature_name = '高关注机构';
+                break;
+            default:
+                $company->jobnature_name = '';
+                break;
+        }
+    } else {
+        $company->jobnature_name = '';
+    }
+    $city_arr = $company->city_arr_id;
+    if (!empty($city_arr)) {
+      $city_arr = json_decode($city_arr, true);
+      $cityNames = District::whereIn('id', $city_arr)
+        ->pluck('name')
+        ->implode('-');
+      $company->city_name = $cityNames;
+    } else {
+      $company->city_name = '';
+    }
+    if (empty($company)) {
+      return Result::error("暂无相关公司信息", 0);
+    }
+    return Result::success($company);
+  }
+  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 or $type_id == 2 or $type_id == 3 or $type_id == 4) {
+      //最近的5篇已审的文章
+      $apply_articale = Article::where('status', 1)
+        ->where('admin_user_id', $user_id)
+        ->orderBy('updated_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', 2)
+        ->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();
+
+      //获取5条用户待处理的投诉
+      $complaint_deal = Complaint::where('status', 2)
+        ->where('deal', 1)
+        ->whereJsonContains('re_user_ids', $user_id)
+        ->orderBy('updated_at', 'desc')
+        // ->limit(5)
+        ->get();
+      //获取 被通知者未读信息
+      $notice_unread = Notice::where('status', 2)
+        ->whereJsonContains('re_user_ids', $user_id)
+        //未读消息
+        ->where(function ($query) use ($user_id) {
+          $query->whereJsonDoesntContain('read_id', $user_id)
+            ->orWhereNull('read_id');
+        })
+        ->orderBy('updated_at', 'desc')
+        ->get();
+      $complaint_unread = Complaint::where('status', 2)
+        ->whereJsonContains('re_user_ids', $user_id)
+        //未读消息
+        ->where(function ($query) use ($user_id) {
+          $query->whereJsonDoesntContain('read_id', $user_id)
+            ->orWhereNull('read_id');
+        })
+        ->orderBy('updated_at', 'desc')
+        ->get();
+
+
+      //获取5条用户的yijing审核公司 :0:未审核;1:已审核;2:已拒绝
+
+      $complany = Company::where('status', 1)
+        ->where('user_id', $user_id)
+        ->orderBy('updated_at', 'desc')
+        // ->limit(5)
+        ->get();
+
+
+      //获取5条单聊未读聊天消息
+      // $chat = ChatRecords::where('is_read', 0)
+      //   ->where('user_id', $user_id)
+      //   ->leftJoin('user', 'chat_records.receiver_id', '=', 'user.id')
+
+      //   ->select('chat_records.*', 'user.nickname as nickname', 'user.user_name as user_name')
+      //   ->where('action', 'recieved')
+      //   ->where('talk_type', 1)
+      //   ->orderBy('created_at', 'desc')
+      //   // ->limit(5)
+      //   ->get();
+      //获取5条未读群聊信息
+      // $chat_group = ChatRecords::where('is_read', 0)
+      //   ->leftJoin('chat_groups', 'chat_records.receiver_id', '=', 'chat_groups.id')
+      //   ->select('chat_records.*', 'chat_groups.group_name as user_name')
+      //   ->where('user_id', $user_id)
+      //   ->where('talk_type', 2)
+      //   ->orderBy('created_at', 'desc')
+      //   // ->limit(5)
+      //   ->get();
+
+      //获取5条用户的待审核项目 
+      $project = Project::where('status', 1)
+        ->where('user_id', $user_id)
+        ->orderBy('updated_at', 'desc')
+        // ->limit(5)
+        ->get();
+
+      // count($chat) + count($chat_group) +
+      $count = count($apply_articale) + count($good) + count($notice) + count($complaint) + count($book) + count($job_hunting) + count($job_recruiting) + count($job_apply) + count($job_resume) + count($complaint_deal)
+        + count($complany)
+        + count($project)
+        + count($notice_unread)
+        + count($complaint_unread)
+        // + count($chat) + count($chat_group)
+      ;
+      $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,
+        'complaint_deal' => $complaint_deal,
+        'complany' => $complany,
+        'project' => $project,
+        'notice_unread' => $notice_unread,
+        'complaint_unread' => $complaint_unread,
+        'count' => $count,
+      ];
+    } elseif ($type_id == 12) {
+      //最近的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();
+      //获取5条用户的book
+      $book = Book::where('status', 2)
+        ->where('user_id', $user_id)
+        ->orderBy('updated_at', 'desc')
+        ->limit(5)->get();
+      //获取5条用户的求职
+      //获取5条用户的求职 1
+      //count($chat) + count($chat_group) 
+      $count = count($apply_articale) + count($good);
+      $result = [
+        'apply_articale' => $apply_articale,
+        'chat' => $chat,
+        'chat_group' => $chat_group,
+        'good' => $good,
+        'book' => $book,
+        'count' => $count,
+      ];
+    } elseif ($type_id == 13) {
+      //最近的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($chat) + count($chat_group) +
+      $count =  count($apply_articale) + count($good);
+      $result = [
+        'apply_articale' => $apply_articale,
+        'chat' => $chat,
+        'chat_group' => $chat_group,
+        'good' => $good,
+        'count' => $count,
+      ];
+    } elseif ($type_id == 14) {
+      //最近的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条单聊未读聊天消息
+      //获取5条单聊未读聊天消息
+      // $chat = ChatRecords::where('is_read', 0)
+      //   ->where('user_id', $user_id)
+      //   ->leftJoin('user', 'chat_records.receiver_id', '=', 'user.id')
+
+      //   ->select('chat_records.*', 'user.nickname as nickname', 'user.user_name as user_name')
+      //   ->where('action', 'recieved')
+      //   ->where('talk_type', 1)
+      //   ->orderBy('created_at', 'desc')
+      //   // ->limit(5)
+      //   ->get();
+      // //获取5条未读群聊信息
+      // $chat_group = ChatRecords::where('is_read', 0)
+      //   ->leftJoin('chat_groups', 'chat_records.receiver_id', '=', 'chat_groups.id')
+      //   ->select('chat_records.*', 'chat_groups.group_name as user_name')
+      //   ->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', 0)
+        ->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();
+      //待审核数据com pro
+      $complany = Company::where('status', 0)
+        ->orderBy('updated_at', 'desc')
+        // ->limit(5)
+        ->get();
+      $project = Project::where('status', 0)
+        ->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)
+        + count($complany)
+        + count($project);
+      $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,
+        'complany' => $complany,
+        'project' => $project,
+        'count' => $count,
+      ];
+    } elseif ($type_id == 20000) {
+    }
+    var_dump($type_id, '-----------------test---------');
+    return Result::success($result);
+  }
+  /**
+   * @param array $data
+   * @return array
+   */
+  public function getWebsiteProject(array $data): array
+  {
+    $categorys = json_decode($data['id'], true);
+    if (!empty($categorys)) {
+      $category_arr = $this->processArticlePro($data['website_id']);
+      $cat_1st_arr = $category_arr['cat_1st_arr'];
+      $catiall = $category_arr['catiall'];
+      // return Result::success($catiall);
+      foreach ($categorys as $key => $val) {
+        if (isset($val['level'][0]) && !empty($val['level'][0])) {
+          $level = explode(',', $val['level'])[0];
+          $imgnum = explode(',', $val['level'])[1] ?? null;
+          $textnum = explode(',', $val['level'])[2] ?? null;
+          if ($level == 1) {
+            if (!empty($textnum) && $textnum > 0) {
+              $text_num = Project::where('level', $level)
+                ->where('website_id', $data['website_id'])
+                ->where('status', 1)
+                ->select(
+                  'project.id',
+                  'project.title',
+                  'project.description',
+                  'project.updated_at',
+                  'project.category_id',
+                  'project.cat_arr_id'
+                )
+                ->orderBy('updated_at', 'desc')
+                ->limit($textnum)
+                ->get()->all();
+            }
+            if (!empty($imgnum) && $imgnum > 0) {
+              $img_num = Project::where('level', $level)
+                ->where('website_id', $data['website_id'])
+                ->where('status', 1)
+                ->where('imgurl', '!=', '')
+                ->whereNotNull('imgurl')
+                ->select(
+                  'project.id',
+                  'project.title',
+                  'project.description',
+                  'project.updated_at',
+                  'project.imgurl as imgs',
+                  'project.category_id',
+                  'project.cat_arr_id'
+                )
+                ->orderBy('updated_at', 'desc')
+                ->limit($imgnum)
+                ->get()->all();
+            }
+          } else {
+            if (!empty($textnum) && $textnum > 0) {
+              $text_num = Project::where('website_id', $data['website_id'])
+                ->where('status', 1)
+                ->select(
+                  'project.id',
+                  'project.title',
+                  'project.description',
+                  'project.updated_at',
+                  'project.category_id',
+                  'project.cat_arr_id',
+                  'project.website_id',
+                  'project.updated_at',
+                  'project.created_at'
+                )
+                ->orderBy('updated_at', 'desc')
+                ->limit($textnum)
+                ->get()->all();
+            }
+            if (!empty($imgnum) && $imgnum > 0) {
+              $img_num = Project::where('website_id', $data['website_id'])
+                ->where('status', 1)
+                ->where('imgurl', '!=', '')
+                ->whereNotNull('imgurl')
+                ->select(
+                  'project.id',
+                  'project.title',
+                  'project.description',
+                  'project.updated_at',
+                  'project.imgurl as imgs',
+                  'project.category_id',
+                  'project.cat_arr_id'
+                )
+                ->orderBy('updated_at', 'desc')
+                ->limit($imgnum)
+                ->get()->all();
+            }
+          }
+        }
+        if (isset($val['id'][0]) && !empty($val['id'][0])) {
+          $category_ids = explode(',', $val['id'])[0];
+          $cat_imgnum = explode(',', $val['id'])[1] ?? null;
+          $cat_textnum = explode(',', $val['id'])[2] ?? null;
+          $category_arr = array_merge([$category_ids], $cat_1st_arr[$category_ids] ?? [0]);
+          if (!empty($cat_textnum) && $cat_textnum > 0) {
+            $text_num = Project::whereIn('category_id', $category_arr)
+              ->where('website_id', $data['website_id'])
+              ->where('status', 1)
+              ->select(
+                'project.id',
+                'project.title',
+                'project.description',
+                'project.updated_at',
+                'project.category_id',
+                'project.cat_arr_id'
+              )
+              ->orderBy('updated_at', 'desc')
+              ->limit($cat_textnum)
+              ->get()->all();
+          }
+          if (!empty($cat_imgnum) && $cat_imgnum > 0) {
+            $img_num = Project::whereIn('category_id', $category_arr)
+              ->where('website_id', $data['website_id'])
+              ->where('status', 1)
+              ->where('imgurl', '!=', '')
+              ->whereNotNull('imgurl')
+              ->select(
+                'project.id',
+                'project.title',
+                'project.description',
+                'project.updated_at',
+                'project.imgurl as imgs',
+                'project.category_id',
+                'project.cat_arr_id'
+              )
+              ->orderBy('updated_at', 'desc')
+              ->limit($cat_imgnum)
+              ->get()->all();
+          }
+        }
+        if (!empty($img_num)) {
+          foreach ($img_num as $k => $v) {
+            $img_num[$k]->category_name = $catiall[$v->category_id]['alias'];
+            $imgurl = json_decode($v['imgs'], true);
+            if (!empty($imgurl)) {
+              $img_num[$k]->imgurl = $imgurl[0];
+            }
+            $img_num[$k]->pinyin = $catiall[$v->category_id]['pinyin'];
+          }
+        }
+        if (!empty($text_num)) {
+          foreach ($text_num as $k => $v) {
+            $text_num[$k]->category_name = $catiall[$v->category_id]['alias'];
+            $text_num[$k]->pinyin = $catiall[$v->category_id]['pinyin'];
+          }
+        }
+        $project[$key]['img_num'] = $img_num ?? [];
+        $project[$key]['text_num'] = $text_num ?? [];
+      }
+    }
+    if (empty($project)) {
+      return Result::error("暂无相关项目信息", 0);
+    }
+    return Result::success($project);
+  }
+  /**
+   * @param array $data
+   * @return array
+   */
+  public function getWebsiteProjectInfo(array $data): array
+  {
+    $project = Project::where('id', $data['id'])
+      ->where('status', 1)
+      ->where('website_id', $data['website_id'])
+      ->select('project.*')
+      ->first();
+    if (empty($project)) {
+      return Result::error("暂无相关项目信息", 0);
+    }
+    return Result::success($project);
+  }
+  /**
+   * @param array $data
+   * @return array
+   */
+  public function getWebsiteProjectList(array $data): array
+  {
+    $where = [];
+    if (isset($data['category_id']) && !empty($data['category_id'])) {
+      $where['category_id'] = $data['category_id'];
+    }
+    if (isset($data['keyword']) && !empty($data['keyword'])) {
+      $where[] = ['title', 'like', '%' . $data['keyword'] . '%'];
+    }
+    $query = Project::where($where)
+      ->where('status', 1)
+      ->where('website_id', $data['website_id'])
+      ->select(
+        'project.id',
+        'project.title',
+        'project.description',
+        'project.imgurl as imgs',
+        'project.category_id',
+        'project.cat_arr_id'
+      )
+      ->orderBy('updated_at', 'desc');
+    $count = $query->count();
+    $project = $query->clone()
+      ->offset(($data['page'] - 1) * $data['pageSize'])
+      ->limit($data['pageSize'])
+      ->get()->all();
+    if (empty($project)) {
+      return Result::error("暂无相关项目信息", 0);
+    }
+    $categorys = $this->processArticlePro($data['website_id']);
+    $catiall = $categorys['catiall'];
+    foreach ($project as $key => $val) {
+      $project[$key]->category_name = $catiall[$val->category_id]['alias'];
+      if (!empty($val['imgs'])) {
+        $imgurl = json_decode($val['imgs'], true);
+        if (!empty($imgurl)) {
+          $project[$key]->imgurl = $imgurl[0];
+        }
+      } else {
+        $project[$key]->imgurl = '';
+      }
+
+      $project[$key]->pinyin = $catiall[$val->category_id]['pinyin'];
+    }
+    $result = [
+      'rows' => $project,
+      'count' => $count,
+    ];
+    return Result::success($result);
+  }
+
+  /**
+   * @param array $data
+   * @return array
+   */
+  public function getWebsiteCategoryJob(array $data): array
+  {
+    $categorys = json_decode($data['id'], true);
+    if (!empty($categorys)) {
+      $category_arr = $this->processArticlePro($data['website_id']);
+      $cat_1st_arr = $category_arr['cat_1st_arr'];
+      $catiall = $category_arr['catiall'];
+      foreach ($categorys as $key => $val) {
+        if (isset($val['id']) && !empty($val['id'])) {
+          $catid = explode(',', $val['id'])[0] ?? null;
+          $type = explode(',', $val['id'])[1] ?? null;
+          $textnum = explode(',', $val['id'])[2] ?? null;
+        }
+
+        // 4:招聘;5:求职;
+        if ($textnum > 0 && $type == 4 && !empty($catid)) {
+          // 状态   0:待审核;1:已审核通过;(只有企业会员需要审核);2:已拒绝;
+          $job = JobRecruiting::WhereRaw("JSON_CONTAINS(job_recruiting.cat_arr_id, '" . intval($catid) . "') = 1")
+            ->leftJoin('job_company', 'job_recruiting.id', '=', 'job_company.job_id')
+            ->where('job_recruiting.status', 1)
+            ->where('job_recruiting.website_id', $data['website_id'])
+            ->select(
+              'job_recruiting.id',
+              'job_recruiting.title',
+              'job_company.business_name',
+              'job_recruiting.updated_at',
+              'job_recruiting.cat_arr_id',
+              'job_recruiting.keyword',
+              'job_recruiting.description'
+            )
+            ->orderBy('job_recruiting.updated_at', 'desc')
+
+            ->limit($textnum)
+            ->get()->all();
+        } else if ($textnum > 0 && $type == 5 && !empty($catid)) {
+          // 状态  审核状态,1待审核2已审核3已拒绝
+          $job = JobHunting::WhereRaw("JSON_CONTAINS(job_hunting.cat_arr_id, '" . intval($catid) . "') = 1")
+            ->leftJoin('job_position', 'job_hunting.job_name_get', '=', 'job_position.zwid')
+            ->where('job_hunting.status', 2)
+            ->where('job_hunting.website_id', $data['website_id'])
+            ->select(
+              'job_hunting.id',
+              'job_hunting.name',
+              'job_hunting.cat_arr_id',
+              'job_position.zwname as job_name',
+              'job_hunting.updated_at',
+              // 'job_hunting.keyword',
+              'job_hunting.slelf_evaluation'
+            )
+            ->orderBy('updated_at', 'desc')
+            ->limit($textnum)
+            ->get()->all();
+        } else {
+          $job = [];
+        }
+        //  var_dump($catid.'222uuuuuuu'.$key);
+        if (!empty($job)) {
+          foreach ($job as $k => $value) {
+            if (isset($value->cat_arr_id)) {
+              $catArr = json_decode($value->cat_arr_id, true);
+              $catId = end($catArr);
+            } else {
+              continue;
+            }
+            if (isset($catiall[$catId])) {
+              $job[$k]->pinyin = $catiall[$catId]['pinyin'];
+            }
+          }
+        }
+        // var_dump($catid.'xxxxx'.$key);
+        $result[$key] = $job ?? [];
+      }
+    }
+    if (empty($result)) {
+      return Result::error("暂无相关分类信息", 0);
+    }
+
+    return Result::success($result);
+  }
+  /**
+   * 发送消息
+   * @param array $messageData
+   * @return void
+   */
+  public function sendMessage($messageData)
+  {
+    $msg = [
+      'talk_type' => $messageData['talk_type'],
+      'title' => $messageData['title'],
+      'content' => $messageData['content'],
+      'messageType' => $messageData['messageType'],
+      'user_id' => $messageData['user_id'] ?? '',
+      'time' => microtime(),
+    ];
+    $message = new MqProducer($msg);
+    $producer = ContextApplicationContext::getContainer()->get(Producer::class);
+    $producer->produce($message);
+  }
+  /**
+   * 行业分类管理  ------1121
+   * @param array $data
+   * @return array
+   */
+  public function getJobIndustryList(array $data): array
+  {
+    $page = $data['page'] ?? 1;
+    $page_size = $data['page_size'] ?? 10;
+    if (isset($data['hyname']) && !empty($data['hyname'])) {
+      $where = ['hyname', 'like', '%' . $data['hyname'] . '%'];
+    } else {
+      $where = [];
+    }
+    $rs_query = JobIndustry::when(!empty($where), function ($query) use ($where) {
+      $query->where([$where]); // 修复:将条件包装成二维数组
+    })
+      ->orderBy('updated_at', 'desc');
+    $count = $rs_query->count();
+    $hy = $rs_query->offset(($page - 1) * $page_size)->limit($page_size)->get()->all();
+    $result = [
+      'count' => $count,
+      'list' => $hy,
+    ];
+    if (empty($hy)) {
+      return Result::success('暂无数据');
+    }
+    return Result::success($result);
+  }
+  /**
+   * 添加行业分类
+   * @param array $data
+   * @return array
+   */
+  public function addJobIndustry(array $data): array
+  {
+    $hy_name = JobIndustry::where('hyname', $data['hyname'])->first(['hyid']);
+    if (!empty($hy_name)) {
+      return Result::error('行业分类已存在');
+    }
+    $hy = JobIndustry::insertGetId($data);
+    if (empty($hy)) {
+      return Result::error('添加失败');
+    }
+    return Result::success($hy);
+  }
+  /**
+   * 更新行业分类
+   * @param array $data
+   * @return array
+   */
+  public function upJobIndustry(array $data): array
+  {
+    $hy_query = JobIndustry::get();
+    $hy_ids = $hy_query->pluck('hyid')->toArray();
+    $hy_names = $hy_query->pluck('hyname')->toArray();
+    if (!in_array($data['hyid'], $hy_ids)) {
+      return Result::error('行业分类不存在');
+    }
+    if (isset($data['hyname']) && !empty($data['hyname'])) {
+      $other_key_hy = array_search($data['hyid'], $hy_ids);
+      // return Result::success($other_key_hy);
+      unset($hy_names[$other_key_hy]);
+      if (in_array($data['hyname'], $hy_names)) {
+        return Result::error('行业分类名称已存在');
+      }
+    }
+    $hy = JobIndustry::where('hyid', $data['hyid'])->update($data);
+    if (empty($hy)) {
+      return Result::error('更新失败');
+    }
+    return Result::success($hy);
+  }
+  /**
+   * 删除行业分类
+   * @param array $data
+   * @return array
+   */
+  public function delJobIndustry(array $data): array
+  {
+    $hy_id = JobIndustry::where('hyid', $data['hyid'])->first(['hyid']);
+    if (empty($hy_id)) {
+      return Result::error('行业分类不存在');
+    }
+    $hy = JobIndustry::where('hyid', $data['hyid'])->delete();
+    if (empty($hy)) {
+      return Result::error('删除失败');
+    }
+    return Result::success($hy);
+  }
+  /**
+   * 职位分类-列表
+   * @param array $data
+   * @return array
+   */
+  public function getJobPositionList(array $data): array
+  {
+    $page = $data['page'] ?? 1;
+    $page_size = $data['page_size'] ?? 10;
+    $where = [];
+    if (isset($data['zwname']) && !empty($data['zwname'])) {
+      $zwids = JobPosition::where('zwpid', 0)
+        ->when(!empty($data['zwname']), function ($query) use ($data) {
+          $query->where('zwname', 'like', '%' . $data['zwname'] . '%');
+        })
+        ->orderBy('updated_at', 'desc')
+        ->pluck('zwid')
+        // ->get()
+        ->toArray();
+    }
+    if (isset($data['childname']) && !empty($data['childname'])) {
+      $child_zwids = JobPosition::where('zwpid', '!=', 0)
+        ->when(!empty($data['childname']), function ($query) use ($data) {
+          $query->where('zwname', 'like', '%' . $data['childname'] . '%');
+        })
+        ->orderBy('updated_at', 'desc')
+        ->pluck('zwpid')
+        // ->get()
+        ->toArray();
+      if (isset($zwids) && is_array($zwids) && is_array($child_zwids)) {
+        $child_zwids = array_intersect($zwids, $child_zwids);
+      }
+      $zwids = array_values(array_unique($child_zwids));
+    }
+    $zwids = $zwids ?? null;
+    $count =  JobPosition::when(!empty($zwids), function ($query) use ($zwids) {
+      $query->whereIn('zwid', $zwids);
+    })
+      ->where('zwpid', 0)
+      ->count();
+    $position =  JobPosition::when(!empty($zwids), function ($query) use ($zwids) {
+      $query->whereIn('zwid', $zwids);
+    })
+      ->where('zwpid', 0)
+      ->orderBy('updated_at', 'desc')
+      ->offset(($page - 1) * $page_size)
+      ->limit($page_size)->get()
+      ->map(function ($item) use ($data) {
+        $item->children = $item->where('zwpid', $item->zwid)
+          ->when(!empty($data['childname']), function ($query) use ($data) {
+            $query->where('zwname', 'like', '%' . $data['childname'] . '%');
+          })
+          ->orderBy('updated_at', 'desc')
+          ->get();
+        return $item;
+      })
+      ->all();
+    $result = [
+      'count' => $count,
+      'list' => $position,
+    ];
+    if (empty($result)) {
+      return Result::success('暂无数据');
+    }
+    return Result::success($result);
+  }
+  /**
+   * 职位分类-添加
+   * @param array $data
+   * @return array
+   */
+  public function addJobPosition(array $data): array
+  {
+    $zw_name = JobPosition::where('zwpid', $data['zwpid'])
+      ->where('zwname', $data['zwname'])->first(['zwid']);
+    if (!empty($zw_name)) {
+      return Result::error('职位分类已存在');
+    }
+    $zw = JobPosition::insertGetId($data);
+    if(empty($zw)){
+        return Result::error('添加失败');
+    }
+    return Result::success($zw);
+  }
+  
+  /**
+   * 更新职位分类
+   * @param array $data
+   * @return array
+   */
+  public function upJobPosition(array $data): array
+  {
+    $zw_position = JobPosition::get();
+    if (!in_array($data['zwid'], $zw_position->pluck('zwid')->toArray())) {
+      return Result::error('职位分类不存在');
+    }
+    $zw_name = $zw_position->where('zwid', '!=', $data['zwid'])
+      ->where('zwpid', $data['zwpid'])
+      ->where('zwname', $data['zwname'])->first();
+    if (!empty($zw_name)) {
+      return Result::error('职位分类已存在');
+    }
+    $result = JobPosition::where('zwid', $data['zwid'])->update($data);
+    if (empty($result)) {
+      return Result::error('更新失败');
+    }
+    return Result::success($result);
+  }
+  /**
+   * 删除职位分类
+   * @param array $data
+   * @return array
+   */
+  public function delJobPosition(array $data): array
+  {
+    $zw_jobposition = JobPosition::get();
+    $zw_id = $zw_jobposition->where('zwid', $data['zwid'])->first();
+    if (empty($zw_id)) {
+      return Result::error('职位分类不存在');
+    }
+    if($zw_id->zwpid == 0){
+        $zw_job = JobPosition::where('zwpid', $zw_id->zwid)->first();
+        if(!empty($zw_job)){
+            return Result::error('请先删除子分类');
+        }
+    }
+    $result = JobPosition::where('zwid', $data['zwid'])->delete();
+    if (empty($result)) {
+      return Result::error('删除失败');
+    }
+    return Result::success($result);
+  }
+}

+ 372 - 0
app/JsonRpc/NewsServiceInterface.php

@@ -0,0 +1,372 @@
+<?php
+
+namespace App\JsonRpc;
+
+interface NewsServiceInterface
+{
+    /**
+     * @param array $data
+     *  @return array
+     */
+    public function getCategoryList(array $data): array;
+
+    /**
+     * @param array $data
+     *  @return array
+     */
+    public function myCategoryList(array $data): array;
+    /**
+     * @param array $data
+     *  @return array
+     */
+    public function categoryList(array $data): array;
+
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function addCategory(array $data): array;
+
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function delCategory(array $data): array;
+
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function updateCategory(array $data): array;
+
+    /**
+     * @param string $keyword
+     * @param int $page
+     * @param int $pageSize
+     */
+    public function getArticleList(array $data): array;
+
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function addArticle(array $data): array;
+
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function delArticle(array $data): array;
+
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function updateArticle(array $data): array;
+
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function getArticleInfo(array $data): array;
+
+    /**
+     * 获取导航池信息
+     * @param array $data
+     * @return array
+     */
+    public function getCategoryInfo(array $data): array;
+
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function upArticleStatus(array $data): array;
+
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function getWebsiteModelArticles(array $data): array;
+
+    //20250226  产品列表
+    public function getGoodList(array $data): array;
+    public function getGoodInfo(array $data): array;
+    public function addGood(array $data): array;
+    public function delGood(array $data): array;
+    public function updateGood(array $data): array;
+    //20250226  产品列表
+    //20250306  求职信息
+    public function getJobHuntingList(array $data): array;
+    public function getJobHuntingApply(array $data): array;
+    public function getJobHuntingInfo(array $data): array;
+    public function addJobHunting(array $data): array;
+    public function delJobHunting(array $data): array;
+    public function updateJobHunting(array $data): array;
+    public function getJobHuntingData(array $data): array;
+    //20250306  求职信息
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function checkCategoryName(array $data): array;
+
+    public function getSurveyList(array $data): array;
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function getSurveyInfo(array $data): array;
+
+    //20250324  通知,公告,消息
+    public function getNoticeList(array $data): array;
+    public function getNoticeInfo(array $data): array;
+    public function addNotice(array $data): array;
+    public function updateNotice(array $data): array;
+    public function deleteNotice(array $data): array;
+    public function getComplaintList(array $data): array;
+    public function getComplaintInfo(array $data): array;
+    public function addComplaint(array $data): array;
+    public function updateComplaint(array $data): array;
+    public function deleteComplaint(array $data): array;
+    public function getMSG(array $data): array;
+    //20250324  通知,公告,消息
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function getWebsiteCatidArticle(array $data): array;
+
+
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function getJobRecruitingList(array $data): array;
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function getJobRecruitingInfo(array $data): array;
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function addJobRecruiting(array $data): array;
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function upJobRecruiting(array $data): array;
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function delJobRecruiting(array $data): array;
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function getJobRecruitingArea(array $data): array;
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function getIndustry(array $data): array;
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function getPositionList(array $data): array;
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function getJobNature(array $data): array;
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function getExperience(array $data): array;
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function getEducation(array $data): array;
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function getSalary(array $data): array;
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function getLanguage(array $data): array;
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function getLevel(array $data): array;
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function getCompanySize(array $data): array;
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function getCompanyNature(array $data): array;
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function getJobCompany(array $data): array;
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function upJobCompany(array $data): array;
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function updateGoodStatus(array $data): array;
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function updateJobHuntingStatus(array $data): array;
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function updateNoticeStatus(array $data): array;
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function updateComplaintStatus(array $data): array;
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function getDUser(array $data): array;
+
+    public function checkJobRecruiting(array $data): array;
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function getRecruitingList(array $data): array;
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function getRecruitingInfo(array $data): array;
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function getJobResumeList(array $data): array;
+   
+    
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function myApplyList(array $data): array;
+    
+    
+
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function getWebsiteTsbb(array $data): array;
+    /**
+     *  @param array $data
+     *  @return array
+     */
+    public function getWebsiteTsbbList(array $data): array;
+    /**
+     *      @param array $data
+     *      @return array
+     */
+    public function getWebsiteTsbbDetail(array $data): array;
+
+   
+
+    /**
+     * 农网导航首页
+     * @param array $data
+     * @return array
+     */
+    public function getWebsiteNwHomeList(array $data): array;
+    // --------------企业管理-----------
+    public function getCompanyList(array $data): array;
+    public function addCompany(array $data): array;
+    public function upCompany(array $data): array;
+    public function delCompany(array $data): array;
+    public function checkCompany(array $data): array;
+    public function getCompanyInfo(array $data): array;
+    // --------------项目管理-----------
+    public function getProjectList(array $data): array;
+    public function addProject(array $data): array;
+    public function upProject(array $data): array;
+    public function delProject(array $data): array;
+    public function checkProject(array $data): array;
+    public function getProjectInfo(array $data): array;
+    
+    
+    public function getArticleCommend(array $data): array;
+
+    public function noticeList(array $data): array;
+    public function complaintList(array $data): array;
+    public function readComplaint(array $data): array;
+    public function readJobResume(array $data): array;
+    public function readJobApply(array $data): array;
+    public function readNotice(array $data): array;
+    // 行业分类管理  ------1121
+     /**
+     * @param array $data
+     * @return array
+     */
+    public function getJobIndustryList(array $data):array;
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function addJobIndustry(array $data):array;
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function upJobIndustry(array $data):array;
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function delJobIndustry(array $data):array;
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function getJobPositionList(array $data):array;
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function addJobPosition(array $data):array;
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function upJobPosition(array $data):array;
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function delJobPosition(array $data):array;
+}

+ 30 - 4
app/JsonRpc/PublicRpcService.php

@@ -1974,7 +1974,10 @@ class PublicRpcService implements PublicRpcServiceInterface
                 $add_arr['component_width'] = intval($data['ad_width']);
                 $add_arr['component_height'] = intval($data['ad_height']);
                 $add_arr['ad_type'] = intval($data['ad_type']);
-                // $add_arr['ad_img'] = $data['ad_img'];
+                if(empty($data['ad_img'])){
+                    $data['ad_img'] = $data['component_img'];
+                }
+                $add_arr['ad_img'] = $data['ad_img'];
                 $ad = [
                     'width' => $add_arr['ad_width'],
                     'height' => $add_arr['ad_height'],
@@ -4305,15 +4308,23 @@ class PublicRpcService implements PublicRpcServiceInterface
                 }
                 if (in_array($component_type, [7, 14, 15, 23, 24]) && ($page == 1 || $page == 2)) {
                     if ($page == 1) {
+                        if(!empty($all_cate[$cat_key]['real_category_arr_id'])){
+                            $cat_arr[$cat_key] = $all_cate[$cat_key]['real_category_arr_id'];
+                        }else{
+                            $cat_arr[$cat_key] = $all_cate[$cat_key]['category_arr_id'];
+                        }
                         if (in_array($component_type, [23, 24])) {
                             $componentData[0]['name'] = $all_cate[$cat_key]['alias'];
-                            $componentData[0]['category_arr'] = $all_cate[$cat_key]['category_arr_id'];
+                            $componentData[0]['category_id'] = $all_cate[$cat_key]['category_id'];
+                            $componentData[0]['category_arr'] = $cat_arr[$cat_key];
                             $componentData[1]['name'] = $all_cate[$cat_key + 1]['alias'];
-                            $componentData[1]['category_arr'] = $all_cate[$cat_key + 1]['category_arr_id'];
+                            $componentData[1]['category_id'] = $all_cate[$cat_key + 1]['category_id'];
+                            $componentData[1]['category_arr'] = $cat_arr[$cat_key + 1];
                             $cat_key += 2;
                         } else {
                             $componentData['name'] = $all_cate[$cat_key]['alias'];
-                            $componentData['category_arr'] = $all_cate[$cat_key]['category_arr_id'];
+                            $componentData['category_arr'] = $cat_arr[$cat_key];
+                            $componentData['category_id'] = $all_cate[$cat_key]['category_id'];
                             $cat_key++;
                         }
                     }
@@ -5098,4 +5109,19 @@ class PublicRpcService implements PublicRpcServiceInterface
         }
         return Result::success($result);
     }
+
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function public_server(array $data): array
+    {
+        try {
+            // 这里添加public_server方法的业务逻辑
+            // 由于没有找到原始实现,暂时返回一个基本的成功响应
+            return Result::success($data);
+        } catch (\Exception $e) {
+            return Result::error($e->getMessage(), 0);
+        }
+    }
 }

+ 6 - 0
app/JsonRpc/PublicRpcServiceInterface.php

@@ -250,4 +250,10 @@ interface PublicRpcServiceInterface
     public function delAiChatRecord(array $data): array;
     // 自助建站-ai会话-给模板添加导航
     public function addTemplateCates(array $data): array;
+    
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function public_server(array $data): array;
 }

+ 800 - 0
app/JsonRpc/UserService.php

@@ -0,0 +1,800 @@
+<?php
+
+namespace App\JsonRpc;
+
+use App\Model\ImContact;
+use App\Model\Role;
+use App\Model\RoleLog;
+use App\Model\RoleUser;
+use App\Model\User;
+use App\Model\UserInfo;
+use App\Model\UserLogin;
+use App\Model\WebsiteGroup;
+use App\Model\Wechat;
+use App\Model\UserImp;
+use App\Tools\Result;
+use Hamcrest\Arrays\IsArray;
+use Hyperf\DbConnection\Db;
+use Hyperf\RpcServer\Annotation\RpcService;
+use App\Model\ImGroupMember;
+#[RpcService(name: "UserService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
+class UserService implements UserServiceInterface
+{
+    /**
+     * @param string $name
+     * @param int $gender
+     * @return string
+     */
+
+    public function createUser(array $data): array
+    {
+        //同步imp的用戶信息
+        if (isset($data['type']) && $data['type'] == 'imp') {
+
+            //獲取user的id,user_name,avatar,nickname,組成數據,批量插入imp users中,如果已經存在則替換,密碼用111111加密,加密算法是bcrypt
+            // 获取所有用户数据
+            $users = User::query()->select('id', 'user_name', 'avatar', 'nickname')->get()->toArray();
+
+            if (!empty($users)) {
+                $insertData = [];
+                $now = date('Y-m-d H:i:s');
+
+                // 准备插入数据
+                foreach ($users as $user) {
+                    $insertData[] = [
+                        'id' => $user['id'],
+                        'mobile' => $user['user_name'], // user_name映射到mobile
+                        'nickname' => $user['nickname'] ?? $user['user_name'], // 如果nickname为空则使用user_name
+                        'avatar' => $user['avatar'] ?? '',
+                        'password' => password_hash('111111', PASSWORD_BCRYPT), // 使用bcrypt加密密码
+                        'gender' => 3, // 默认未知性别
+                        'motto' => '',
+                        'email' => $user['email'] ?? '',
+                        'birthday' => '',
+                        'is_robot' => 2, // 非机器人
+                        'status' => 1, // 正常状态
+                        'created_at' => $now,
+                        'updated_at' => $now,
+                    ];
+                }
+                // 批量插入或替换
+                try {
+                    // 使用replace into语法,如果主键存在则替换
+                    $sql = "REPLACE INTO users (id, mobile, nickname, avatar, password, gender, motto, email, birthday, is_robot, status, created_at, updated_at) VALUES ";
+                    $values = [];
+                    foreach ($insertData as $row) {
+                        $values[] = "('" . implode("', '", array_map(fn($v) => addslashes($v), $row)) . "')";
+                    }
+                    $sql .= implode(', ', $values);
+
+                    // 使用imp数据库连接执行SQL
+                    Db::connection('imp')->statement($sql);
+                } catch (\Throwable $e) {
+                    // 记录错误但不中断主流程
+                    var_dump('同步imp用户失败: ' . $e->getMessage());
+                }
+                return Result::success(['同步imp用户成功']);
+            }
+        }
+        Db::beginTransaction();
+        try {
+            $dataUserReq = [
+                'user_name' => $data['user_name'],
+                'password' => md5(md5($data['password']) . $data['salt']),
+                'avatar' => $data['avatar'] ?? 'https://img.bjzxtw.org.cn/master/image/userDefault.jpg',
+                'type_id' => $data['type_id'] ?? '20000',
+                'mobile' => $data['mobile'] ?? '', //手机号
+                'status' => $data['status'] ?? 1,
+                'email' => $data['email'] ?? '',
+                'salt' => $data['salt'],
+                'admin_id' => isset($data['admin_id']) && $data['admin_id'] != '' ? $data['admin_id'] : 0,
+                //                'level_id'=>$data['level_id']??0, //会员等级
+                'nickname' => $data['nickname'] ?? $data['user_name'], //把账号同步到昵称里面
+                'last_login_ip' => $data['last_login_ip'] ?? '',
+                'sszq' => $data['sszq'] ?? '',
+            ];
+            $data['other'] = is_array($data['other']) ?   json_encode($data['other'] ?? []) : $data['other'];
+            $data['city_arr_id'] = is_array($data['city_arr_id']) ?   json_encode($data['city_arr_id'] ?? []) : $data['city_arr_id'];
+            $data['address_arr_id'] = is_array($data['address_arr_id']) ?   json_encode($data['address_arr_id'] ?? []) : $data['address_arr_id'];
+            var_dump("user:", $dataUserReq);
+            $userid = User::query()->insertGetId($dataUserReq);
+            // $data['administrative_unit_arr_id'] = is_array($data['administrative_unit_arr_id']) ?   json_encode($data['administrative_unit_arr_id'] ?? []): $data['administrative_unit_arr_id'];
+            $dataUserInfoReq = [
+                'user_id' => $userid,
+                'id_card' => $data['id_card'] ?? '',
+                'gender' => $data['gender'] ?? 0,
+                'real_name' => $data['real_name'] ?? '',
+                'business_name' => $data['business_name'] ?? '',
+                'job' => $data['job'] ?? '',
+                'city_id' => $data['city_id'] ?? 0,
+                'birthday' => $data['birthday'] ?? '',
+                'number' => $data['number'] ?? '',
+                'city_arr_id' => $data['city_arr_id'] ?? '',
+                'from_time' => $data['from_time'] ?? null,
+                'to_time' => $data['to_time'] ?? null,
+                'long_time' => $data['long_time'] ?? 0,
+                'native_place_id' => $data['native_place_id'] ?? 0,
+                'native_place_arr_id' => $data['native_place_arr_id'] ?? '',
+                'qq' => $data['qq'] ?? '',
+                'zip_code' => $data['zip_code'] ?? '',
+                'address_arr_id' => $data['address_arr_id'] ?? '',
+                'address_id' => $data['address_id'] ?? 0,
+                'address' => $data['address'] ?? '',
+                'other' => $data['other'] ?? '',
+                'remark' => $data['remark'] ?? '',
+                'fax' => $data['fax'] ?? '',
+                'position' => $data['position'] ?? '',
+                'legal_person_real_name' => $data['legal_person_real_name'] ?? '',
+                'legal_person_mobile' => $data['legal_person_mobile'] ?? '',
+                'legal_person_id_card' => $data['legal_person_id_card'] ?? '',
+                'administrative_unit_arr_id' => $data['administrative_unit_arr_id'] ?? '',
+                'administrative_unit_id' => $data['administrative_unit_id'] ?? 0,
+                'department_id' => $data['department_id'] ?? 0,
+                'department_arr_id' => $data['department_arr_id'] ?? '',
+                // 企业会员  相关    公司信息
+                'company_hy_id' => $data['company_hy_id'] ?? 0,
+                'company_size' => $data['company_size'] ?? 0,
+                'company_nature' => $data['company_nature'] ?? 0,
+                'introduction' => $data['introduction'] ?? '',
+                'company_url' => $data['company_url'] ?? '',
+
+            ];
+            var_dump("UserINfo:::", $dataUserInfoReq);
+
+            $userInfoId = UserInfo::query()->insertGetId($dataUserInfoReq);
+            $roleUserData = [
+                'role_id' => isset($data['role_id']) && $data['role_id'] != '' ? $data['role_id'] : 0,
+                'user_id' => $userid,
+                'admin_user_id' => isset($data['admin_id']) && $data['admin_id'] != '' ? $data['admin_id'] : 0,
+            ];
+            RoleUser::insert($roleUserData);
+            var_dump("userInfo:", $userInfoId);
+
+            //处理imp
+            $impUserData = [
+                'id' => $userid, // 将在后面获取
+                'mobile' => $data['user_name'],
+                'nickname' => $data['nickname'] ?? $data['user_name'],
+                'avatar' => $data['avatar'] ?? 'https://img.bjzxtw.org.cn/master/image/userDefault.jpg',
+                'gender' => $data['gender'] ?? 3,
+                'password' => password_hash('111111', PASSWORD_BCRYPT),
+                'motto' => '',
+                'email' => $data['email'] ?? '',
+                'birthday' => $data['birthday'] ?? '',
+                'is_robot' => 2,
+                'status' =>  isset($data['status']) && $data['status'] === 0 ? 2 : ($data['status'] ?? 1), // 当status为0时设置为2,其他情况保持正常
+                'created_at' => date('Y-m-d H:i:s'),
+                'updated_at' => date('Y-m-d H:i:s')
+            ];
+
+            // 使用 REPLACE INTO 实现存在则替换的逻辑
+            Db::connection('imp')->table('users')->updateOrInsert(
+                ['mobile' => $data['user_name']],
+                $impUserData
+            );
+            Db::commit();
+        } catch (\Throwable $ex) {
+            Db::rollBack();
+            var_dump($ex->getMessage());
+            return Result::error("创建失败", 0);
+        }
+        return $userInfoId ? Result::success(["id" => $userid]) : Result::error("创建失败", 0);
+    }
+
+    /**
+     * @return array
+     */
+    public function getUserList(array $data): array
+    {
+        $where = [];
+        if (isset($data['keyword']) && $data['keyword']) {
+            array_push($where, ['user.user_name', 'like', '%' . $data['keyword'] . '%']);
+        }
+        if (isset($data['type_id']) && $data['type_id']) {
+            array_push($where, ['user.type_id', '=', $data['type_id']]);
+        }
+        if (isset($data['status']) && $data['status'] != '' && intval($data['status']) >= 0) {
+            array_push($where, ['user.status', '=', $data['status']]);
+        }
+
+        $result = User::where($where)
+            ->leftJoin('user_info', 'user.id', '=', 'user_info.user_id')
+            ->leftJoin("user_info as user_infoA", 'user.admin_id', "user_infoA.user_id")
+            ->leftJoin("role_user", 'role_user.user_id', "user.id")
+            ->leftJoin("role", 'role.id', "role_user.role_id")
+            ->orderBy("user.id", "desc")->paginate(
+                intval($data['pageSize']),
+                [
+                    'user.id',
+                    'user.admin_id',
+                    'user.user_name',
+                    'user_info.real_name',
+                    'user.mobile',
+                    'user.type_id',
+                    'user.created_at',
+                    'user.status',
+                    'user_infoA.real_name as admin_real_name',
+                    'role.role_name',
+                ],
+                'page',
+                intval($data['page'])
+            );
+
+        $count = $result->total();
+        if (empty($result)) {
+            return Result::error("没有数据", 0);
+        }
+        $rep = $result->items();
+        //1:个人会员 2:政务会员 3:企业会员 4:调研员 10000:管理员 20000:游客
+        $type = ['1' => "个人会员", '2' => "政务会员", '3' => "企业会员", '4' => '调研员', '10000' => '管理员', '20000' => '游客'];
+
+        if ($rep) {
+            foreach ($rep as $k => $v) {
+                $rep[$k]['type_name'] = $type[$v['type_id']];
+                //                $rep[$k]['gender_name'] = $gender[$v['gender']];
+                //                $rep[$k]['status_name'] = $status[$v['status']];
+                //                $rep[$k]['city_id'] = $v['city_id']?json_decode($v['city_id']):[];
+            }
+        }
+        $data = [
+            'rows' => $rep,
+            'count' => $count,
+        ];
+        return Result::success($data);
+    }
+    /**
+     * @param int $id
+     * @return array
+     */
+    public function getUserInfo(int $id): array
+    {
+        $userInfo = Db::table('user')
+            ->leftJoin('user_info', 'user.id', '=', 'user_info.user_id')
+            ->leftJoin('role_user', 'role_user.user_id', '=', 'user.id')
+            ->select(
+                'user.*',
+                'user_info.id as user_info_id',
+                'user_info.real_name',
+                'user_info.id_card',
+                'user_info.birthday',
+                'user_info.gender',
+                'user_info.city_id',
+                'user_info.business_name',
+                'user_info.job',
+                'user_info.number',
+                'user_info.city_arr_id',
+                'user_info.from_time',
+                'user_info.to_time',
+                'user_info.long_time',
+                'user_info.native_place_id',
+                'user_info.native_place_arr_id',
+                'user_info.qq',
+                'user_info.zip_code',
+                'user_info.address_arr_id',
+                'user_info.address_id',
+                'user_info.address',
+                'user_info.other',
+                'user_info.remark',
+                'user_info.fax',
+                'user_info.position',
+                'user_info.legal_person_real_name',
+                'user_info.legal_person_mobile',
+                'user_info.legal_person_id_card',
+                'user_info.administrative_unit_arr_id',
+                'user_info.administrative_unit_id',
+                // 企业会员  相关    公司信息
+                'user_info.company_hy_id',
+                'user_info.company_size',
+                'user_info.company_nature',
+                'user_info.introduction',
+                'user_info.company_url',
+
+                'role_user.role_id',
+                'user_info.department_id',
+                'user_info.department_arr_id',
+
+            )
+            ->where('user.id', '=', $id)->first();
+        $userInfoImp = UserImp::where(['id' => $id])->first();
+        // $impUsers = Db::connection('imp')->select('SHOW TABLES');
+        // var_dump($impUsers);
+        if (empty($userInfo)) {
+            return Result::error("找不到用户", 0, []);
+        }
+        // $userInfo = array_merge($userInfo, $impUsers);
+
+        return Result::success($userInfo);
+    }
+
+    /**
+     * 检测用户是否存在
+     * @param array $data
+     * @return array
+     */
+    public function verifyUserInfo(array $data): array
+    {
+        var_dump("进不进来");
+        if (isset($data['id'])) {
+            $data[] = ['id', "!=", $data['id']];
+            unset($data['id']);
+        }
+        $userInfo = User::query()->where($data)->first();
+        if (empty($userInfo)) {
+            return Result::error("找不到用户", 0);
+        }
+        return Result::success($userInfo->toArray());
+    }
+
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function createUserLogin(array $data): array
+    {
+        $id = UserLogin::insertGetId($data);
+        if (empty($id)) {
+            return Result::error("创建登录日志失败", 0);
+        }
+        return Result::success(["id" => $id]);
+    }
+
+    /**
+     * 更新用户信息和userInfo
+     * @param array $data
+     * @return array
+     */
+    public function updateUser(array $data): array
+    {
+        var_dump($data, "----------------------");
+        Db::beginTransaction();
+        try {
+            $userInfos = User::where(['id' => $data['id']])->first(); //查询用户昵称
+            $dataUserReq = [
+                'user_name' => $data['user_name'],
+                'avatar' => $data['avatar'] ?? '',
+                'type_id' => $data['type_id'] ?? '20000',
+                'mobile' => $data['mobile'] ?? '', //手机号
+                'status' => $data['status'] ?? 1,
+                'email' => $data['email'] ?? '',
+                'admin_id' => $data['admin_id'],
+                'nickname' => $userInfos['nickname'] ?? $data['user_name'], //存在昵称同步一下,不存在取账号
+                'last_login_ip' => $data['last_login_ip'] ?? '',
+                'sszq' => $data['sszq'] ?? '', //网站标识
+            ];
+
+            $userRep = User::where(['id' => $data['id']])->update($dataUserReq);
+            //插入 imp  users
+            $dataImpUserReq = [
+                'mobile' => $data['user_name'],
+            ];
+
+            // 只有在数据存在时才设置字段,避免设置空值
+            if (!empty($data['nickname'])) {
+                $dataImpUserReq['nickname'] = $data['nickname'];
+            }
+
+            if (!empty($data['avatar'])) {
+                $dataImpUserReq['avatar'] = $data['avatar'];
+            }
+
+            if (!empty($data['email'])) {
+                $dataImpUserReq['email'] = $data['email'];
+            }
+            UserImp::where(['id' => $data['id']])->update($dataImpUserReq);
+
+            $data['other'] = is_array($data['other']) ?   json_encode($data['other'] ?? []) : $data['other'];
+            $data['city_arr_id'] = is_array($data['city_arr_id']) ?   json_encode($data['city_arr_id'] ?? []) : $data['city_arr_id'];
+            $data['address_arr_id'] = is_array($data['address_arr_id']) ?   json_encode($data['address_arr_id'] ?? []) : $data['address_arr_id'];
+            var_dump("修改user:", $userRep);
+            $dataUserInfoReq = [
+                'id_card' => $data['id_card'] ?? '',
+                'gender' => $data['gender'] ?? 0,
+                'real_name' => $data['real_name'] ?? '',
+                'job' => $data['job'] ?? '',
+                'city_id' => $data['city_id'] ?? 0,
+                'birthday' => $data['birthday'] ?? '',
+                'number' => $data['number'] ?? '',
+                'city_arr_id' => $data['city_arr_id'] ?? '',
+                'from_time' => $data['from_time'] ?? null,
+                'business_name' => $data['business_name'] ?? '',
+                'to_time' => $data['to_time'] ?? null,
+                'long_time' => $data['long_time'] ?? 0,
+                'native_place_id' => $data['native_place_id'] ?? 0,
+                'native_place_arr_id' => $data['native_place_arr_id'] ?? '',
+                'qq' => $data['qq'] ?? '',
+                'zip_code' => $data['zip_code'] ?? '',
+                'address_arr_id' => $data['address_arr_id'] ?? '',
+                'address_id' => $data['address_id'] ?? 0,
+                'address' => $data['address'] ?? '',
+                'other' => $data['other'] ?? '',
+                'remark' => $data['remark'] ?? '',
+                'fax' => $data['fax'] ?? '',
+                'position' => $data['position'] ?? '',
+                'legal_person_real_name' => $data['legal_person_real_name'] ?? '',
+                'legal_person_mobile' => $data['legal_person_mobile'] ?? '',
+                'legal_person_id_card' => $data['legal_person_id_card'] ?? '',
+                'administrative_unit_arr_id' => $data['administrative_unit_arr_id'] ?? '',
+                'administrative_unit_id' => $data['administrative_unit_id'] ?? 0,
+                'department_id' => $data['department_id'] ?? 0,
+                'department_arr_id' => $data['department_arr_id'] ?? '',
+                // 企业会员  相关    公司信息
+                'company_hy_id' => $data['company_hy_id'] ?? 0,
+                'company_size' => $data['company_size'] ?? 0,
+                'company_nature' => $data['company_nature'] ?? 0,
+                'introduction' => $data['introduction'] ?? '',
+                'company_url' => $data['company_url'] ?? '',
+
+            ];
+
+            $userInfoRep = UserInfo::where(['user_id' => $data['id']])->update($dataUserInfoReq);
+            var_dump("修改userInfo:", $userInfoRep);
+            $roleUserData = [
+                'role_id' => $data['role_id'],
+                'admin_user_id' => $data['admin_id'],
+            ];
+            $resultRoleUserRep = RoleUser::where(['user_id' => $data['id']])->update($roleUserData);
+            var_dump("修改用户角色权限:", $resultRoleUserRep);
+            //处理imp
+
+
+            Db::commit();
+        } catch (\Throwable $ex) {
+            Db::rollBack();
+            var_dump($ex->getMessage());
+            return Result::error("修改失败", 0);
+        }
+        $result = [
+            'user' => $userRep,
+            'userInfo' => $userInfoRep,
+        ];
+        return $result ? Result::success($result) : Result::error("修改失败", 0);
+    }
+
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function updateUserInfo(array $data): array
+    {
+        return [];
+    }
+
+    /**
+     * @param array $data
+     * @return array|int
+     */
+    public function resetPassword(array $data): array
+    {
+        $where = [
+            'id' => $data['id'],
+        ];
+        $data = [
+            'password' => md5(md5($data['password']) . $data['salt']),
+            'salt' => $data['salt'],
+        ];
+        $result = User::where($where)->update($data);
+        if ($result) {
+            return Result::error("修改失败", 0);
+        } else {
+            return Result::success([]);
+        }
+    }
+    /**
+     * @param int $id
+     * @return array
+     */
+    public function delUser(int $id): array
+    {
+        Db::beginTransaction();
+        try {
+//            User::where(['id' => $id])->delete();
+//            UserInfo::where(['user_id' => $id])->delete();
+            Db::commit();
+        } catch (\Throwable $ex) {
+            Db::rollBack();
+            return Result::error("删除失败", 0);
+        }
+        return Result::success([]);
+    }
+
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function addRole(array $data): array
+    {
+        Db::beginTransaction();
+        try {
+            $data['sort'] = intval($data['sort']) ?? 0;
+            Role::insertGetId($data);
+            $logData = [
+                'user_id' => $data['user_id'],
+                'data' => json_encode($data),
+                'type' => 1,
+            ];
+            RoleLog::insertGetId($logData);
+            Db::commit();
+        } catch (\Throwable $ex) {
+            Db::rollBack();
+            return Result::error("新增失败", 0);
+        }
+        return Result::success([]);
+    }
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function delRole(array $data): array
+    {
+        Db::beginTransaction();
+        try {
+            $count = RoleUser::where(['role_id' => $data['id']])->count();
+            if($count>0){
+                Db::rollBack();
+                return Result::error("请先删除该角色下的用户", 0);
+            }
+            $roleInfo = Role::where(['id' => $data['id']])->first();
+            $logData = [
+                'user_id' => $data['user_id'],
+                'data' => json_encode($roleInfo->toArray()),
+                'type' => 2,
+            ];
+            RoleLog::insertGetId($logData);
+            RoleUser::where(['role_id' => $data['id']])->delete();
+            $result = Role::where(['id' => $data['id']])->delete();
+            Db::commit();
+        } catch (\Throwable $ex) {
+            Db::rollBack();
+            return Result::error("删除失败", 0);
+        }
+        return Result::success($result);
+    }
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function updateRole(array $data): array
+    {
+        Db::beginTransaction();
+        try {
+            $result = Role::where(['id' => $data['id']])->update($data);
+            $logData = [
+                'user_id' => $data['user_id'],
+                'data' => json_encode($data),
+                'type' => 3,
+            ];
+            RoleLog::insertGetId($logData);
+            Db::commit();
+        } catch (\Throwable $ex) {
+            Db::rollBack();
+            return Result::error("更新失败");
+        }
+        return Result::success($result);
+    }
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function roleInfo(array $data): array
+    {
+        $roleInfo = Role::where(['id' => $data['id']])->first();
+        if ($roleInfo) {
+            return Result::success($roleInfo->toArray());
+        } else {
+            return Result::error("没有数据");
+        }
+    }
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function roleList(array $data): array
+    {
+        $where = [];
+        if (isset($data['keyword']) && $data['keyword']) {
+            array_push($where, ['role.role_name', 'like', '%' . $data['keyword'] . '%']);
+        }
+        $result = Role::withCount('users')->where($where)->limit($data['pageSize'])->offset(($data['page'] - 1) * $data['pageSize'])->get();
+        $count = Role::where($where)->count();
+        if (empty($result)) {
+            return Result::error("没有数据", 0);
+        }
+        $data = [
+            'rows' => $result->toArray(),
+            'count' => $count,
+        ];
+        return Result::success($data);
+    }
+
+    /**
+     * 获取小程序注册信息
+     * @param array $data
+     * @return array
+     */
+    public function getWechatInfo(array $data): array
+    {
+        $where = [
+            'purePhoneNumber' => $data['purePhoneNumber'],
+            'openid' => $data['openid'],
+        ];
+        $result = Wechat::where($where)->first();
+        var_dump($result);
+        if ($result) {
+            return Result::success($result);
+        } else {
+            return Result::error('没有数据');
+        }
+    }
+
+    /**
+     * 添加小程序 注册信息
+     * @param array $data
+     * @return array
+     */
+    public function addWechatInfo(array $data): array
+    {
+        $result = Wechat::insertGetId($data);
+        if ($result) {
+            return Result::success($result);
+        } else {
+            return Result::error('添加失败');
+        }
+    }
+
+    /**
+     * 修改密码
+     * @param array $data
+     * @return array
+     */
+    public function changePassword(array $data): array
+    {
+        Db::beginTransaction();
+        $userInfo = User::where(['id' => $data['user_id']])->first();
+        // return Result::success($userInfo);
+        try {
+            $dataUserReq = [
+                'password' => md5(md5($data['new_password1']) . $userInfo['salt']),
+            ];
+            if ($userInfo['password'] != md5(md5($data['password']) . $userInfo['salt'])) {
+                Db::rollBack();
+                return Result::error('您输入的密码错误');
+            }
+            $userRep = User::where(['id' => $data['user_id']])->update($dataUserReq);
+
+            $dataImpUserReq = [
+                password_hash($data['new_password1'], PASSWORD_BCRYPT), // 使用bcrypt加密密码
+            ];
+            UserImp::where(['id' => $data['id']])->update($dataImpUserReq);
+            Db::commit();
+        } catch (\Throwable $ex) {
+            Db::rollBack();
+            var_dump($ex->getMessage());
+            return Result::error("创建失败", 0);
+        }
+        return Result::success([]);
+    }
+    /**
+     * 修改用户状态
+     * @param array $data
+     * @return array
+     */
+    public function upUserStatus(array $data): array
+    {
+        $where = [
+            'id' => $data['id'],
+        ];
+        $result = User::where($where)->update($data);
+        if ($result) {
+            return Result::success($result);
+        } else {
+            return Result::error('修改失败');
+        }
+    }
+
+    /**
+     * 修改用户头像昵称
+     * @param array $data
+     * @return array
+     */
+    public function updateUserAvatarNickname(array $data): array
+    {
+        Db::beginTransaction();
+        try {
+            $where1 = [
+                'id' => $data['user_id'],
+            ];
+            $updateData = [];
+            if (!empty($data['nickname'])) {
+                $updateData['nickname'] = $data['nickname'];
+            }
+            if (!empty($data['avatar'])) {
+                $updateData['avatar'] = $data['avatar'];
+            }
+            $result = User::where($where1)->update($updateData);
+            //imp
+            $dataImpUserReq = [
+                'nickname' => $data['nickname'], // 如果nickname为空则使用user_name
+                'avatar' => $data['avatar'] ?? '',
+            ];
+            if (empty($data['nickname'])) {
+                unset($dataImpUserReq['nickname']);
+            }
+            if (empty($data['avatar'])) {
+                unset($dataImpUserReq['avatar']);
+            }
+            UserImp::where(['id' => $data['user_id']])->update($dataImpUserReq);
+
+            $updateData = [];
+            $where = [
+                'user_id' => $data['user_id'],
+            ];
+            if (!empty($data['real_name'])) {
+                $updateData = ['real_name' => $data['real_name']];
+            }
+            $result = UserInfo::where($where)->update($updateData);
+            $result = User::where($where1)->first();
+            Db::commit();
+            return Result::success($result);
+        } catch (\Throwable $ex) {
+            Db::rollBack();
+            var_dump($ex->getMessage());
+            return Result::error("创建失败", 0);
+        }
+    }
+
+    /**
+     * 获取网站组信息
+     * @param array $data
+     * @return array
+     */
+    public function getWebsiteGroupInfo(array $data): array
+    {
+        $result = WebsiteGroup::where(['id' => $data['id']])->first();
+        if ($result) {
+            return Result::success($result);
+        } else {
+            return Result::error('查询失败');
+        }
+    }
+    /**
+     * 根据类型获取用户列表
+     */
+    public function getTypeUserList(array $data): array
+    {
+        $result = User::when($data, function ($query) use ($data) {
+            if (isset($data['type_id']) && $data['type_id']) {
+                $query->where('type_id', $data['type_id']);
+            }
+        })->where('status', 1)->get();
+        if ($result) {
+            return Result::success($result);
+        } else {
+            return Result::error('查询失败');
+        }
+    }
+    /**
+     * 获取群里面的用户,不包含子集
+     */
+    public function getImGroupMember(array $data): array
+    {
+        $result = ImGroupMember::leftjoin("im_group", "im_group.id", "=", "im_group_member.group_id")->when($data, function ($query) use ($data) {
+            if (isset($data['user_id']) && $data['user_id']) {
+                $query->where('im_group_member.user_id', '<>', $data['user_id']);
+            }
+        })
+            ->where('im_group_member.group_id', $data['group_id'])
+            ->select("im_group_member.*", "im_group.group_name")
+            ->get();
+        return Result::success($result??[]);
+    }
+
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function getImContact(array $data): array
+    {
+        $result = ImContact::where($data)->first();
+        return Result::success($result??[]);
+    }
+}

+ 147 - 0
app/JsonRpc/UserServiceInterface.php

@@ -0,0 +1,147 @@
+<?php
+
+namespace App\JsonRpc;
+
+interface UserServiceInterface
+{
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function createUser(array $data): array;
+
+    /**
+     * @param int $id
+     * @return array
+     */
+    public function getUserInfo(int $id): array;
+
+    /**
+     * 获取会员列表
+     * @param array $data
+     * @return array
+     */
+    public function getUserList(array $data): array;
+
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function verifyUserInfo(array $data): array;
+
+    /**
+     * @remark 创建登录日志信息
+     * @param array $data
+     * @return array
+     */
+    public function createUserLogin(array $data): array;
+
+    /**
+     * 更新用户信息
+     * @param array $data
+     * @return array
+     */
+    public function updateUser(array $data): array;
+
+    /**
+     * 更新用户
+     * @param array $data
+     * @return array
+     */
+    public function updateUserInfo(array $data): array;
+
+    /**
+     * 删除用户
+     * @param int $id
+     * @return array
+     */
+    public function delUser(int $id): array;
+
+    /**
+     * 添加角色
+     * @param array $data
+     * @return array
+     */
+    public function addRole(array $data): array;
+
+    /**
+     * 删除角色
+     * @param array $data
+     * @return array
+     */
+    public function delRole(array $data): array;
+
+    /**
+     * 更新角色
+     * @param array $data
+     * @return array
+     */
+    public function updateRole(array $data): array;
+
+    /**
+     * 角色列表
+     * @param array $data
+     * @return array
+     */
+    public function roleList(array $data): array;
+
+    /**
+     * 角色信息
+     * @param array $data
+     * @return array
+     */
+    public function roleInfo(array $data): array;
+
+    /**
+     * 查询是否注册
+     * @param array $data
+     * @return array
+     */
+    public function getWechatInfo(array $data): array;
+
+    /**
+     * 添加注册信息
+     * @param array $data
+     * @return array
+     */
+    public function addWechatInfo(array $data): array;
+
+    /**
+     * 修改密码
+     * @param array $data
+     * @return array
+     */
+    public function changePassword(array $data): array;
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function upUserStatus(array $data): array;
+    public function updateUserAvatarNickname(array $data): array;
+
+    /**
+     * 获取网站组信息
+     * @param array $data
+     * @return array
+     */
+    public function getWebsiteGroupInfo(array $data): array;
+    /**
+     * 根据类型获取用户列表
+     * @param array $data
+     * @return array
+     */
+    public function getTypeUserList(array $data): array;
+    /**
+     * 获取用户信息
+     * @param array $data
+     * @return array
+     */
+    public function getImGroupMember(array $data): array;
+    /**
+     * 获取用户备注信息
+     * @param array $data
+     * @return array
+     */
+    public function getImContact(array $data): array;
+
+}

+ 153 - 502
app/JsonRpc/WebsiteService.php

@@ -63,6 +63,7 @@ use Swoole\Coroutine;
 #[RpcService(name: "WebsiteService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
 class WebsiteService implements WebsiteServiceInterface
 {
+    
     /**
      * 获取网站列表
      * @param string $keyword
@@ -555,103 +556,49 @@ class WebsiteService implements WebsiteServiceInterface
             return Result::success($result);
         }
     }
-
+    
     /**
-     * 查询网站下面的导航
+     *各省市查询  
      * @param array $data
      * @return array
      */
-    public function getWebsiteCategory(array $data): array
+    public function selectWebsiteArea()
     {
-        $where = [
-            'website_id' => $data['website_id'],
-        ];
-        // 使用递归查询构建树状结构
-        $category = WebsiteCategory::where($where)
-            ->with([
-                'children' => function ($query) {
-                    $query->orderBy('sort', 'asc');
-                },
-            ])
-            ->orderBy('sort', 'asc')
-            ->where('pid', 0) // 仅查询顶级节点
-            ->get()->all();
-        if (empty($category)) {
-            return Result::error("查询站点栏目失败", 0);
+        // return Result::success($data);
+        $pid = $data['pid'] ?? 0;
+        $result = District::leftJoin('district as district2', 'district.pid', '=', 'district2.id')
+            ->where('district.pid', $pid)
+            ->where('district.status', 1)
+            ->select('district.*', 'district2.name as pid_name')
+            ->orderBy('district.code')->get();
+        if (empty($result)) {
+            return Result::error("未查询到此地区", 0);
         } else {
-            $count = WebsiteCategory::where($where)->count();
-            $result = [
-                'rep' => $category,
-                'count' => $count,
-            ];
             return Result::success($result);
         }
     }
 
     /**
-     * 查询网站的广告
+     * 获取友情链接
      * @param array $data
      * @return array
      */
-    public function getWebsiteAdvertisement(array $data): array
+
+    public function selectWebsiteLinks(array $data): array
     {
         $where = [
-            'ad_place.status' => 1,
+            'website_id' => $data['website_id'],
+            'status' => 1,
+            'type' => $data['type'],
         ];
-        if (isset($data['ad_tag']) && !empty($data['ad_tag'])) {
-            $now = Carbon::now()->format('Y-m-d H:i:s'); // 获取当前时间
-            $where[] = ['ad_place.ad_tag', 'like', '%' . $data['ad_tag'] . '%'];
-            // return Result::success($where);
-            $result =  AdPlace::where($where)
-                ->leftJoin("ad", function ($join) use ($now) {
-                    $join->on("ad.pid", "=", "ad_place.id")
-                        ->where('ad.status', 1)
-                        ->where('ad.fromtime', '<=', $now)
-                        ->where('ad.totime', '>=', $now);
-                })
-                ->select(
-                    'ad_place.name as place_name',
-                    'ad_place.thumb',
-                    'ad_place.ad_tag',
-                    'ad_place.introduce',
-                    'ad.name as ad_name',
-                    'ad.image_src',
-                    'ad.image_url',
-                    'ad.image_alt',
-                    'ad_place.ad_url'
-                )
-                ->get()->all();
+        $num = $data['num'];
+        $result = Link::where($where)->orderBy('sort')->limit($num)->get();
+        if (!empty($result)) {
+            return Result::success($result);
         } else {
-            $now = Carbon::now()->format('Y-m-d H:i:s'); // 获取当前时间
-            // return Result::success($where);
-            $result =  AdPlace::where($where)
-                ->where('ad_place.website_id', $data['website_id'])
-                ->leftJoin("ad", function ($join) use ($now) {
-                    $join->on("ad.pid", "=", "ad_place.id")
-                        ->where('ad.status', 1)
-                        ->where('ad.fromtime', '<=', $now)
-                        ->where('ad.totime', '>=', $now);
-                })
-                ->select(
-                    'ad_place.name as place_name',
-                    'ad_place.thumb',
-                    'ad_place.ad_tag',
-                    'ad_place.introduce',
-                    'ad.name as ad_name',
-                    'ad.image_src',
-                    'ad.image_url',
-                    'ad.image_alt',
-                    'ad_place.ad_url',
-                )
-                ->get()->all();
-            // return Result::error("请选择广告位!",0);
-        }
-        if (empty($result)) {
-            return Result::error("此广告位不存在!", 0);
+            return Result::error("本网站暂无此类型友情链接", 0);
         }
-        return Result::success($result);
     }
-
     /**
      *
      * @param array $data
@@ -681,139 +628,6 @@ class WebsiteService implements WebsiteServiceInterface
         $result = $depart;
         return Result::success($result);
     }
-
-    /**
-     * 搜索地区
-     * @param array $data
-     * @return array
-     */
-    public function selectWebsiteArea(array $data): array
-    {
-
-        // return Result::success($data);
-        $pid = $data['pid'] ?? 0;
-        $result = District::leftJoin('district as district2', 'district.pid', '=', 'district2.id')
-            ->where('district.pid', $pid)
-            ->where('district.status', 1)
-            ->select('district.*', 'district2.name as pid_name')
-            ->orderBy('district.code')->get();
-        if (empty($result)) {
-            return Result::error("未查询到此地区", 0);
-        } else {
-            return Result::success($result);
-        }
-    }
-
-    /**
-     * 获取栏目
-     * @param array $data
-     * @return array
-     */
-
-    public function getWebsiteModelCategory(array $data): array
-    {
-        // return Result::success($data);
-        $website_id = [
-            'website_id' => $data['website_id'],
-        ];
-        $website_column_arr = Website::where('id', $data['website_id'])->value('website_column_arr_id');
-        if (empty($website_column_arr)) {
-            return Result::error("未查询到此网站所属网系!", 0);
-        }
-        $website_column_arr = json_decode($website_column_arr, true);
-        // return Result::success(!in_array(3,$website_column_arr) && $data['pid'] == 0);
-        // 初始化 $pid 数组
-        // $pid = [];
-        // 以下注释掉的代码是之前的逻辑,用于获取非顶级分类的 pid
-        $pidQuery = WebsiteCategory::where($website_id)
-            ->where('pid', '!=', 0)
-            ->orderBy('sort')
-            ->select('pid', 'category_id', 'alias', 'aLIas_pinyin');
-        $pid = $pidQuery->pluck('pid');
-        $pid = array_values(array_unique($pid->toArray()));
-        // 构建查询语句
-        $query = WebsiteCategory::where($website_id)
-            ->when(!in_array(3, $website_column_arr) && $data['pid'] == 0, function ($query) use ($website_column_arr) {
-                $query->where('is_show', 1);
-            })
-            ->when(in_array(3, $website_column_arr) ||  $data['pid'] != 0, function ($query) use ($data) {
-                $query->where('pid', $data['pid']);
-            })
-            ->offset($data['placeid'])
-            ->limit($data['num'])
-            ->orderBy('sort')
-            ->orderBy('updated_at', 'desc');
-        // 如果 $pid 数组不为空,添加 CASE WHEN 条件
-        if (!empty($pid)) {
-            $placeholders = implode(',', array_fill(0, count($pid), '?'));
-            $query->selectRaw("website_category.*, CASE WHEN website_category.category_id IN ($placeholders) THEN 1 ELSE 0 END AS children_count", $pid);
-        } else {
-            // 如果 $pid 数组为空,不添加 CASE WHEN 条件,添加字段 children_count 并赋值为 0
-            $query->select('website_category.*', DB::raw('0 as children_count'));
-        }
-
-        // 执行查询
-        $placeid = $data['placeid'] - 1;
-        $result = $query->offset($placeid)->limit($data['num'])->get();
-
-        if (!empty($result)) {
-            $pidResults = $pidQuery->get();
-            if (isset($data['type']) && $data['type'] == 1) {
-                $result = $result->map(function ($item) use ($pidResults) {
-                    $children = $pidResults->where('pid', $item->category_id)->map(function ($child) {
-                        if (!empty($child)) {
-                            return $child;
-                        }
-                    });
-                    // 重置索引,使 key 值从 0 开始
-                    $item->children = $children->values();
-                    return $item;
-                });
-            } else {
-                $pidMap = $pidResults->keyBy('pid');
-                $result->each(function ($record) use ($pidMap, $data) {
-                    if ($data['pid'] == 0) {
-                        $record->aLIas_pinyin = $record->path;
-                    }
-                    // $record->aLIas_pinyin = $record->path;
-                    if ($pidMap->has($record->category_id)) {
-                        $pidResult = $pidMap->get($record->category_id);
-                        $record->chilid_id = $pidResult->category_id;
-                        $record->chilid_alias = $pidResult->alias;
-                        // $record->aLIas_pinyin = $pidResult->aLIas_pinyin;
-                    }
-                });
-            }
-
-            return Result::success($result);
-        } else {
-            return Result::error("本网站暂无栏目", 0);
-        }
-    }
-
-
-    /**
-     * 获取友情链接
-     * @param array $data
-     * @return array
-     */
-
-    public function selectWebsiteLinks(array $data): array
-    {
-        $where = [
-            'website_id' => $data['website_id'],
-            'status' => 1,
-            'type' => $data['type'],
-        ];
-        $num = $data['num'];
-        $result = Link::where($where)->orderBy('sort')->limit($num)->get();
-        if (!empty($result)) {
-            return Result::success($result);
-        } else {
-            return Result::error("本网站暂无此类型友情链接", 0);
-        }
-    }
-
     /**
      * 网站首页数据统计, 管理员
      * @return void
@@ -1971,120 +1785,7 @@ class WebsiteService implements WebsiteServiceInterface
         }
         return Result::success($websiteInfo->toArray());
     }
-
-    /**
-     * 获取网站底部基础信息
-     * @param array $data
-     * @return array
-     */
-    public function getWebsiteFootInfo(array $data): array
-    {
-
-        if (isset($data['website_id']) && !empty($data['website_id'])) {
-            $website_head = Website::where('id', $data['website_id'])
-                ->where('status', 1)
-                ->select('id', 'website_name', 'logo', 'title', 'keywords', 'description', 'suffix', 'website_url')
-                ->first();
-            if (empty($website_head)) {
-                return Result::error("找不到网站", 0);
-            }
-        } else {
-            return Result::error("参数错误", 0);
-        }
-        $website_head = Website::where('id', $data['website_id'])
-            ->select('id', 'website_name', 'logo', 'title', 'keywords', 'description', 'suffix', 'website_url')->first();
-        $website_foot = WebsiteTemplateInfo::where('website_id', $data['website_id'])->first();
-        if (empty($website_foot)) {
-            return Result::error("暂无底部基础信息", 0);
-        }
-        $website_head['website_url'] = $website_head['website_url'] ? json_decode($website_head['website_url']) : [];
-        $result = [
-            'website_foot' => $website_foot,
-            'website_head' => $website_head,
-        ];
-        return Result::success($result);
-    }
-    /**
-     * 获取网站底部导航
-     * @param array $data
-     * @return array
-     */
-    public function getWebsiteFooterCategory(array $data): array
-    {
-        if (isset($data['website_id']) && !empty($data['website_id'])) {
-            $website = Website::where('id', $data['website_id'])->where('status', 1)->first();
-            if (empty($website)) {
-                return Result::error("找不到网站", 0);
-            }
-        } else {
-            return Result::error("参数错误", 0);
-        }
-        $result = FooterCategory::where('website_id', $data['website_id'])->get();
-        if (empty($result)) {
-            return Result::error("暂无底部导航", 0);
-        }
-        return Result::success($result->toArray());
-    }
-    /**
-     * 获取网站底部导航列表
-     * @param array $data
-     * @return array
-     */
-    public function getWebsiteFooterCategoryList(array $data): array
-    {
-        if (isset($data['website_id']) && !empty($data['website_id'])) {
-            $website = Website::where('id', $data['website_id'])->where('status', 1)->first();
-            if (empty($website)) {
-                return Result::error("找不到网站", 0);
-            }
-        } else {
-            return Result::error("参数错误", 0);
-        }
-        $footercategory = FooterCategory::where('website_id', $data['website_id'])->where('id', $data['fcat_id'])->first();
-        // '底部导航类型   0:内容型;1:列表型;',
-        if (!isset($footercategory['type']) || $footercategory['type'] == 0) {
-            return Result::error("底部导航id错误", 0);
-        } else {
-            $query = FooterContent::where('fcat_id', $data['fcat_id']);
-            if ($query->count() == 0) {
-                return Result::error("暂无底部导航列表", 0);
-            } elseif ($query->count() == 1) {
-                $result = $query->first();
-            } else {
-                $result = $query->get();
-            }
-        }
-        return Result::success($result);
-    }
-    /**
-     * 获取网站底部导航
-     * @param array $data
-     * @return array
-     */
-    public function getWebsiteFooterCategoryInfo(array $data): array
-    {
-        if (isset($data['website_id']) && !empty($data['website_id'])) {
-            $website = Website::where('id', $data['website_id'])->where('status', 1)->first();
-            if (empty($website)) {
-                return Result::error("找不到网站", 0);
-            }
-        } else {
-            return Result::error("参数错误", 0);
-        }
-        if (isset($data['type']) && $data['type'] == 0) {
-            $fcatid = FooterCategory::where('website_id', $data['website_id'])->where('id', $data['fcat_id'])->first();
-            if (empty($fcatid)) {
-                return Result::error("底部导航id错误", 0);
-            }
-            $result = FooterContent::where('fcat_id', $data['fcat_id'])->first();
-        } else {
-            $result = FooterContent::where('id', $data['fcat_id'])->first();
-        }
-        if (empty($result)) {
-            return Result::error("暂无底部导航内容", 0);
-        }
-        return Result::success($result);
-    }
+    
     /*
      * 搜索网站二级导航
      * @param array $data
@@ -2150,61 +1851,7 @@ class WebsiteService implements WebsiteServiceInterface
         }
         return Result::success($result);
     }
-    /**
-     * 获取网站栏目seo
-     * @param array $data
-     * @return array
-     */
-    public function getWebsiteCategoryHead(array $data): array
-    {
-        if (isset($data['website_id']) && !empty($data['website_id'])) {
-            $website = Website::where('id', $data['website_id'])->where('status', 1)->first();
-            if (empty($website)) {
-                return Result::error("找不到网站", 0);
-            }
-        } else {
-            return Result::error("参数错误", 0);
-        }
-        if (isset($data['catid']) && !empty($data['catid'])) {
-            $result = WebsiteCategory::where('website_id', $data['website_id'])->where('category_id', $data['catid'])->first();
-        }
-        if (empty($result)) {
-            return Result::error("暂无导航", 0);
-        }
-        $result['aLIas_pinyin'] = $result['path'] ?? '';
-        $result['website_name'] = $website['website_name'] ?? '';
-        $result['suffix'] = $website['suffix'] ?? '';
-        return Result::success($result);
-    }
-    /*
-     * 获取某个栏目
-     * @param array $data
-     * @return array
-     * */
-    public function getOneWebsiteCategory(array $data): array
-    {
-        if (isset($data['website_id']) && !empty($data['website_id'])) {
-            $website = Website::where('id', $data['website_id'])->where('status', 1)->first();
-            if (empty($website)) {
-
-                return Result::error("暂无该网站", 0);
-            }
-            $category = WebsiteCategory::where('website_id', $data['website_id'])->where('category_id', $data['category_id'])->first();
-            if (empty($category)) {
-                return Result::error("暂无此导航", 0);
-            }
-            $category['children_count'] = WebsiteCategory::where('website_id', $data['website_id'])->where('pid', $data['category_id'])->count();
-            $parent = WebsiteCategory::where('website_id', $data['website_id'])->where('category_id', $category['pid'])->select('category_id as parent_id', 'alias as parent_name', 'aLIas_pinyin')->first();
-            // return Result::success($parent);
-            // $category['aLIas_pinyin'] = $category['path'] ?? '';
-            $category['parent_id'] = $parent['parent_id'] ?? '';
-            $category['parent_pinyin'] = $parent['aLIas_pinyin'] ?? '';
-            $category['parent_name'] = $parent['parent_name'] ?? '';
-            return Result::success($category);
-        } else {
-            return Result::error("参数错误", 0);
-        }
-    }
+    
 
     // 自助建站--fr-------------------
 
@@ -2772,128 +2419,7 @@ class WebsiteService implements WebsiteServiceInterface
         }
         return Result::success($category);
     }
-    /**
-     * 获取网站栏目信息
-     * @param array $data
-     */
-    public function getWebsiteFootAll(array $data): array
-    {
-        if(!isset($data['is_diyweb']) || empty($data['is_diyweb'])){
-            $website = Website::where('id',$data['website_id'])->where('status',1)->first();
-        }else{
-            $website = Website::where('id',$data['website_id'])->first();
-        }
-        if (empty($website)) {
-            return Result::error("暂无该网站", 0);
-        }
-        // 1:图片 2:文字 3:底部
-        $result['foot_cate'] = FooterCategory::where('website_id', $data['website_id'])->get()->all();
-        $result['link_img'] = Link::where('website_id', $data['website_id'])->where('type', 1)->where('status', 1)->limit($data['link_imgnum'])->orderBy('sort')->get()->all();
-        $result['link_text'] = Link::where('website_id', $data['website_id'])->where('type', 2)->where('status', 1)->limit($data['link_textnum'])->orderBy('sort')->get()->all();
-        $result['link_foot'] = Link::where('website_id', $data['website_id'])->where('type', 3)->where('status', 1)->limit($data['link_footnum'])->orderBy('sort')->get()->all();
-        $result['foot_info'] = WebsiteTemplateInfo::where('website_id', $data['website_id'])->first();
-        if (empty($result)) {
-            return Result::error("暂无此网站信息", 0);
-        }
-        return Result::success($result);
-    }
-    /**
-     * 获取网站顶部信息
-     * @param array $data
-     */
-    public function getWebsiteHead(array $data): array
-    {
-        $result = Website::where('id', $data['website_id'])->where('status', 1)->select('website_name', 'logo')->first();
-        if (empty($result)) {
-            return Result::error("暂无该网站", 0);
-        }
-        return Result::success($result);
-    }
-
-
-    /**
-     * 路由匹配
-     * @param array $data
-     */
-    public function getWebsiteRoute(array $data): array
-    {
-        $website = Website::where('id', $data['website_id'])->where('status', 1)->first();
-        if (empty($website)) {
-            return Result::error("暂无该网站", 0);
-        }
-        if (isset($data['pinyin']) &&!empty($data['pinyin'])) {
-            $result = WebsiteCategory::where('website_id',$data['website_id'])
-            ->where('path',$data['pinyin'])
-            // $result = WebsiteCategory::where('category_id', $category_id)
-                // ->where('website_category.path', $data['pinyin'])
-                // ->leftJoin('website_category as pc', function ($join) use ($data) {
-                //     $join->on('pc.pid', '=', 'website_category.category_id')
-                //         ->where('pc.website_id', '=', $data['website_id']);
-                // })
-                ->select('website_category.category_id', 'website_category.type', 'website_category.alias',)
-                ->first();
-        }
-        if (isset($data['foot_pinyin']) && !empty($data['foot_pinyin'])) {
-            $result = FooterCategory::where('website_id', $data['website_id'])->where('name_pinyin', $data['foot_pinyin'])->first(['id']);
-        }
-        if (!isset($result) || empty($result)) {
-            return Result::error("暂无该导航", 0);
-        }
-        return Result::success($result);
-    }
-    /**
-     * 获取网站栏目信息
-     * @param array $data
-     */
-    public function getWebsiteAllinfo(array $data): array
-    {
-        $website = Website::where('id', $data['website_id'])->where('status', 1)->first();
-        if (empty($website)) {
-            return Result::error("暂无该网站", 0);
-        }
-        if (isset($data['website_id']) && !empty($data['website_id'])) {
-            $website_head = Website::where('id', $data['website_id'])
-                ->where('status', 1)
-                ->select(
-                    'id',
-                    'website_name',
-                    'logo',
-                    'title',
-                    'keywords',
-                    'description',
-                    'suffix',
-                    'website_url',
-                    'ad_key',
-                    'api_url',
-                    'login_url',
-                    'weblog_url'
-                )
-                ->first();
-            if (empty($website_head)) {
-                return Result::error("找不到网站", 0);
-            }
-        } else {
-            return Result::error("参数错误", 0);
-        }
-        $website_foot['foot_info'] = WebsiteTemplateInfo::where('website_id', $data['website_id'])->first();
-        if (empty($website_foot)) {
-            return Result::error("暂无底部基础信息", 0);
-        }
-        $website_head['website_url'] = $website_head['website_url'] ? json_decode($website_head['website_url']) : [];
-        $result['website_head'] = $website_head;
-        $result['website_foot'] = $website_foot;
-
-        // return Result::success($result);
-        // 1:图片 2:文字 3:底部
-        $result['website_foot']['foot_cate'] = FooterCategory::where('website_id', $data['website_id'])->get()->all();
-        $result['website_foot']['link_img'] = Link::where('website_id', $data['website_id'])->where('type', 1)->where('status', 1)->limit($data['link_imgnum'])->orderBy('sort')->get()->all();
-        $result['website_foot']['link_text'] = Link::where('website_id', $data['website_id'])->where('type', 2)->where('status', 1)->limit($data['link_textnum'])->orderBy('sort')->get()->all();
-        $result['website_foot']['link_foot'] = Link::where('website_id', $data['website_id'])->where('type', 3)->where('status', 1)->limit($data['link_footnum'])->orderBy('sort')->get()->all();
-        if (empty($result)) {
-            return Result::error("暂无此网站信息", 0);
-        }
-        return Result::success($result);
-    }
+    
     //20250212  网站标识
     public function addWebsiteGroup(array $data): array
     {
@@ -3306,7 +2832,7 @@ class WebsiteService implements WebsiteServiceInterface
         if (empty($up_img)) {
             return Result::error("修改失败", 0);
         }
-        return Result::success($up_img);
+        return Result::success($img);
         // 将字节转换为更友好的单位
         // $friendlySize = $this->formatFileSize($size);
         // $data['img_size'] = $friendlySize;
@@ -3449,6 +2975,20 @@ class WebsiteService implements WebsiteServiceInterface
     {
         $id = $data['id'];
         unset($data['id']);
+        if(isset($data['img_url']) && !empty($data['img_url'])){
+            $url = $data['img_url'];
+            // 1. 分割路径部分(以 / 为分隔符)
+            $pathSegments = explode('/', parse_url($url, PHP_URL_PATH));
+
+            // 2. 取最后一个元素作为文件名
+            $fileName = end($pathSegments); // 1743041040714597.jpg
+
+            // 3. 分割文件名获取扩展名
+            $fileParts = explode('.', $fileName);
+            $fileType = end($fileParts); // jpg
+            $data['img_type'] = $fileType;
+            $data['name'] = $fileName;
+        }
         $result = WebsiteImg::where('id', $id)->update($data);
         if (empty($result)) {
             return Result::error("修改失败", 0);
@@ -3804,4 +3344,115 @@ class WebsiteService implements WebsiteServiceInterface
         }
         return Result::success($duplicateRecords);
     }
+    /**
+     * 获取栏目
+     * @param array $data
+     * @return array
+     */
+
+    public function getWebsiteModelCategory(array $data): array
+    {
+        // return Result::success($data);
+        $website_id = [
+            'website_id' => $data['website_id'],
+        ];
+        $website_column_arr = Website::where('id', $data['website_id'])->value('website_column_arr_id');
+        if (empty($website_column_arr)) {
+            return Result::error("未查询到此网站所属网系!", 0);
+        }
+        $website_column_arr = json_decode($website_column_arr, true);
+        // return Result::success(!in_array(3,$website_column_arr) && $data['pid'] == 0);
+        // 初始化 $pid 数组
+        // $pid = [];
+        // 以下注释掉的代码是之前的逻辑,用于获取非顶级分类的 pid
+        $pidQuery = WebsiteCategory::where($website_id)
+            ->where('pid', '!=', 0)
+            ->orderBy('sort')
+            ->select('pid', 'category_id', 'alias', 'aLIas_pinyin');
+        $pid = $pidQuery->pluck('pid');
+        $pid = array_values(array_unique($pid->toArray()));
+        // 构建查询语句
+        $query = WebsiteCategory::where($website_id)
+            ->when(!in_array(3, $website_column_arr) && $data['pid'] == 0, function ($query) use ($website_column_arr) {
+                $query->where('is_show', 1);
+            })
+            ->when(in_array(3, $website_column_arr) ||  $data['pid'] != 0, function ($query) use ($data) {
+                $query->where('pid', $data['pid']);
+            })
+            ->offset($data['placeid'])
+            ->limit($data['num'])
+            ->orderBy('sort')
+            ->orderBy('updated_at', 'desc');
+        // 如果 $pid 数组不为空,添加 CASE WHEN 条件
+        if (!empty($pid)) {
+            $placeholders = implode(',', array_fill(0, count($pid), '?'));
+            $query->selectRaw("website_category.*, CASE WHEN website_category.category_id IN ($placeholders) THEN 1 ELSE 0 END AS children_count", $pid);
+        } else {
+            // 如果 $pid 数组为空,不添加 CASE WHEN 条件,添加字段 children_count 并赋值为 0
+            $query->select('website_category.*', DB::raw('0 as children_count'));
+        }
+
+        // 执行查询
+        $placeid = $data['placeid'] - 1;
+        $result = $query->offset($placeid)->limit($data['num'])->get();
+
+        if (!empty($result)) {
+            $pidResults = $pidQuery->get();
+            if (isset($data['type']) && $data['type'] == 1) {
+                $result = $result->map(function ($item) use ($pidResults) {
+                    $children = $pidResults->where('pid', $item->category_id)->map(function ($child) {
+                        if (!empty($child)) {
+                            return $child;
+                        }
+                    });
+                    // 重置索引,使 key 值从 0 开始
+                    $item->children = $children->values();
+                    return $item;
+                });
+            } else {
+                $pidMap = $pidResults->keyBy('pid');
+                $result->each(function ($record) use ($pidMap, $data) {
+                    if ($data['pid'] == 0) {
+                        $record->aLIas_pinyin = $record->path;
+                    }
+                    // $record->aLIas_pinyin = $record->path;
+                    if ($pidMap->has($record->category_id)) {
+                        $pidResult = $pidMap->get($record->category_id);
+                        $record->chilid_id = $pidResult->category_id;
+                        $record->chilid_alias = $pidResult->alias;
+                        // $record->aLIas_pinyin = $pidResult->aLIas_pinyin;
+                    }
+                });
+            }
+
+            return Result::success($result);
+        } else {
+            return Result::error("本网站暂无栏目", 0);
+        }
+    }
+    /**
+     * 获取网站栏目信息
+     * @param array $data
+     */
+    public function getWebsiteFootAll(array $data): array
+    {
+        if(!isset($data['is_diyweb']) || empty($data['is_diyweb'])){
+            $website = Website::where('id',$data['website_id'])->where('status',1)->first();
+        }else{
+            $website = Website::where('id',$data['website_id'])->first();
+        }
+        if (empty($website)) {
+            return Result::error("暂无该网站", 0);
+        }
+        // 1:图片 2:文字 3:底部
+        $result['foot_cate'] = FooterCategory::where('website_id', $data['website_id'])->get()->all();
+        $result['link_img'] = Link::where('website_id', $data['website_id'])->where('type', 1)->where('status', 1)->limit($data['link_imgnum'])->orderBy('sort')->get()->all();
+        $result['link_text'] = Link::where('website_id', $data['website_id'])->where('type', 2)->where('status', 1)->limit($data['link_textnum'])->orderBy('sort')->get()->all();
+        $result['link_foot'] = Link::where('website_id', $data['website_id'])->where('type', 3)->where('status', 1)->limit($data['link_footnum'])->orderBy('sort')->get()->all();
+        $result['foot_info'] = WebsiteTemplateInfo::where('website_id', $data['website_id'])->first();
+        if (empty($result)) {
+            return Result::error("暂无此网站信息", 0);
+        }
+        return Result::success($result);
+    }
 }

+ 16 - 19
app/JsonRpc/WebsiteServiceInterface.php

@@ -47,15 +47,7 @@ interface WebsiteServiceInterface
     public function delWebsiteRoleUser(int $id): array;
     public function getWebsiteId(array $data): array;
 
-    public function getWebsiteCategory(array $data): array;
-
-    public function getWebsiteAdvertisement(array $data): array;
-
-    public function selectWebsiteDepartment(array $data): array;
-
-    public function selectWebsiteArea(array $data): array;
-
-    public function getWebsiteModelCategory(array $data): array;
+    public function selectWebsiteArea();
 
     public function selectWebsiteLinks(array $data): array;
 
@@ -84,14 +76,11 @@ interface WebsiteServiceInterface
     public function updateWebsiteGroup(array $data): array;
     public function getWebsiteNavList(array $data): array;
 
-    public function getWebsiteFootInfo(array $data): array;
-    public function getWebsiteFooterCategory(array $data): array;
-    public function getWebsiteFooterCategoryList(array $data): array;
-    public function getWebsiteFooterCategoryInfo(array $data): array;
+ 
+   
     public function selectWebsiteCategory(array $data): array;
-    public function getWebsiteCategoryHead(array $data): array;
 
-    public function getOneWebsiteCategory(array $data): array;
+
 
 
     public function getWebsiteNavPoolSite(array $data): array;
@@ -131,10 +120,9 @@ interface WebsiteServiceInterface
     // --网站底部基础信息-----------fr----------------------end
     
     public function getWebsiteParentCategory(array $data): array;
-    public function getWebsiteFootAll(array $data): array;
-    public function getWebsiteHead(array $data): array;
+
+    public function selectWebsiteDepartment(array $data): array;
     
-    public function getWebsiteRoute(array $data): array;
 
 
     public function getFooterCategoryList(array $data): array;
@@ -173,7 +161,16 @@ interface WebsiteServiceInterface
      */
     public function updateWebsiteStatus(array $data): array;
 
-    public function getWebsiteAllinfo(array $data): array;
 
     public function delWebsiteUrl(array $data): array;
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function getWebsiteModelCategory(array $data): array;
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function getWebsiteFootAll(array $data): array;
 }

+ 27 - 0
app/Model/AdministrativeUnit.php

@@ -0,0 +1,27 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+
+class AdministrativeUnit extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'administrative_unit';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    protected array $fillable = [];
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+
+}

+ 23 - 0
app/Model/Article.php

@@ -24,4 +24,27 @@ class Article extends Model
      * The attributes that should be cast to native types.
      */
     protected array $casts = [];
+    /**
+     * 定义与分类的多对一关系
+     */
+    public function category()
+    {
+        return $this->belongsTo(Category::class, 'catid', 'id');
+    }
+    /**
+     * 定义与分类的多对一关系
+     */
+    public function websiteCategory()
+    {
+        return $this->belongsTo(WebsiteCategory::class, 'catid', 'category_id');
+    }
+    /**
+     * 定义与分类的多对一关系
+     */
+    public function articleIgnore()
+    {
+        return $this->hasOne(ArticleIgnore::class, 'article_id', 'id')
+                    // ->whereColumn('article_ignore.website_id', 'article.web_site_id')
+                    ;
+    }
 }

+ 27 - 0
app/Model/ArticleIgnore.php

@@ -0,0 +1,27 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class ArticleIgnore extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'article_ignore';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    protected array $fillable = [];
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+}

+ 31 - 0
app/Model/ArticleSurvey.php

@@ -0,0 +1,31 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class ArticleSurvey extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'article_survey';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    protected array $fillable = [];
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+    public function article()
+    {
+        return $this->belongsTo(Article::class, 'id', 'id');
+    }
+}

+ 22 - 0
app/Model/Character.php

@@ -0,0 +1,22 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class Character extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'character';
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+}

+ 29 - 0
app/Model/Contact.php

@@ -0,0 +1,29 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class Contact extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'contact';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    protected array $fillable = [];
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+
+}
+

+ 29 - 0
app/Model/ContactApply.php

@@ -0,0 +1,29 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class ContactApply extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'contact_apply';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    protected array $fillable = [];
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+
+}
+

+ 22 - 0
app/Model/Couplet.php

@@ -0,0 +1,22 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class Couplet extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'couplet';
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+}

+ 22 - 0
app/Model/Festival.php

@@ -0,0 +1,22 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class Festival extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'festival';
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+}

+ 28 - 0
app/Model/GroupImp.php

@@ -0,0 +1,28 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class GroupImp extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $connection = 'imp';
+    protected ?string $table = 'group';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    protected array $fillable = [];
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+}

+ 28 - 0
app/Model/GroupMemberImp.php

@@ -0,0 +1,28 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class GroupMemberImp extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $connection = 'imp';
+    protected ?string $table = 'group_member';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    protected array $fillable = [];
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+}

+ 28 - 0
app/Model/GroupTalkImp.php

@@ -0,0 +1,28 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class GroupTalkImp extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $connection = 'imp';
+    protected ?string $table = 'talk_session';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    protected array $fillable = [];
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+}

+ 28 - 0
app/Model/GroupTalkMessagerImp.php

@@ -0,0 +1,28 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class GroupTalkMessagerImp extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $connection = 'imp';
+    protected ?string $table = 'talk_group_message';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    protected array $fillable = [];
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+}

+ 22 - 0
app/Model/HistoryToday.php

@@ -0,0 +1,22 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class HistoryToday extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'history_today';
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+}

+ 22 - 0
app/Model/Idiom.php

@@ -0,0 +1,22 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class Idiom extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'idiom';
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+}

+ 28 - 0
app/Model/ImContact.php

@@ -0,0 +1,28 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+
+class ImContact extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'im_contact';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    protected array $fillable = [];
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+
+   
+}

+ 27 - 0
app/Model/ImGroup.php

@@ -0,0 +1,27 @@
+<?php
+
+declare (strict_types = 1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class ImGroup extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'im_group';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    protected array $fillable = [];
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+}

+ 27 - 0
app/Model/ImGroupMember.php

@@ -0,0 +1,27 @@
+<?php
+
+declare (strict_types = 1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class ImGroupMember extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'im_group_member';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    protected array $fillable = [];
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+}

+ 27 - 0
app/Model/JobApply.php

@@ -0,0 +1,27 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class JobApply extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'job_apply';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    protected array $fillable = [];
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+}

+ 27 - 0
app/Model/JobCompany.php

@@ -0,0 +1,27 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class JobCompany extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'job_company';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    protected array $fillable = [];
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+}

+ 27 - 0
app/Model/JobEnum.php

@@ -0,0 +1,27 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class JobEnum extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'job_enum';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    protected array $fillable = [];
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+}

+ 27 - 0
app/Model/JobIndustry.php

@@ -0,0 +1,27 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class JobIndustry extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'job_industry';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    protected array $fillable = [];
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+}

+ 27 - 0
app/Model/JobNature.php

@@ -0,0 +1,27 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class JobNature extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'job_nature';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    protected array $fillable = [];
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+}

+ 27 - 0
app/Model/JobPosition.php

@@ -0,0 +1,27 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class JobPosition extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'job_position';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    protected array $fillable = [];
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+}

+ 27 - 0
app/Model/JobRemuse.php

@@ -0,0 +1,27 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class JobRemuse extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'job_resume';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    protected array $fillable = [];
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+}

+ 27 - 0
app/Model/JobResume.php

@@ -0,0 +1,27 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class JobResume extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'job_resume';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    protected array $fillable = [];
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+}

+ 28 - 0
app/Model/Menu.php

@@ -0,0 +1,28 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class Menu extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'menu';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    protected array $fillable = [];
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+
+}

+ 22 - 0
app/Model/Riddle.php

@@ -0,0 +1,22 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class Riddle extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'riddle';
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+}

+ 27 - 0
app/Model/Role.php

@@ -0,0 +1,27 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class Role extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'role';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    protected array $fillable = [];
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+}

+ 27 - 0
app/Model/RoleLog.php

@@ -0,0 +1,27 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class RoleLog extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'role_log';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    protected array $fillable = [];
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+}

+ 32 - 0
app/Model/RoleUser.php

@@ -0,0 +1,32 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class RoleUser extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'role_user';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    protected array $fillable = [];
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+
+    public function role()
+    {
+        return $this->belongsTo(Role::class);
+    }
+}

+ 28 - 0
app/Model/TalkGroup.php

@@ -0,0 +1,28 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class TalkGroup extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'talk_group';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    protected array $fillable = [];
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+
+}

+ 28 - 0
app/Model/TalkGroupMember.php

@@ -0,0 +1,28 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class TalkGroupMember extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'talk_group_member';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    protected array $fillable = [];
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+
+}

+ 29 - 0
app/Model/TalkRecords.php

@@ -0,0 +1,29 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class TalkRecords extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'talk_records';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    protected array $fillable = [];
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+
+}
+

+ 29 - 0
app/Model/TalkRecordsFile.php

@@ -0,0 +1,29 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class TalkRecordsFile extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'talk_records_file';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    protected array $fillable = [];
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+
+}
+

+ 29 - 0
app/Model/TalkSession.php

@@ -0,0 +1,29 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class TalkSession extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'talk_session';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    protected array $fillable = [];
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+
+}
+

+ 28 - 0
app/Model/TalkSessionAssociation.php

@@ -0,0 +1,28 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class TalkSessionAssociation extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'talk_session_association';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    protected array $fillable = [];
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+
+}

+ 28 - 0
app/Model/TalkSessionStatus.php

@@ -0,0 +1,28 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class TalkSessionStatus extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'talk_session_status';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    protected array $fillable = [];
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+
+}

+ 33 - 0
app/Model/UserImp.php

@@ -0,0 +1,33 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class UserImp extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    /**
+     * The connection name for the model.
+     *
+     * @var string
+     */
+    protected ?string $connection = 'imp';
+    protected ?string $table = 'users';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    protected array $fillable = [];
+    protected array $hidden = [];
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+}

+ 27 - 0
app/Model/UserInfo.php

@@ -0,0 +1,27 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class UserInfo extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'user_info';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    protected array $fillable = [];
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+}

+ 27 - 0
app/Model/UserLogin.php

@@ -0,0 +1,27 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class UserLogin extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'user_login';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    protected array $fillable = [];
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+}

+ 27 - 0
app/Model/Web.php

@@ -0,0 +1,27 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class Web extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'web';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    protected array $fillable = [];
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+}

+ 28 - 0
app/Model/Wechat.php

@@ -0,0 +1,28 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class Wechat extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'wechat';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    protected array $fillable = [];
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+
+}

+ 87 - 0
config/autoload/databases.php

@@ -41,4 +41,91 @@ return [
             ],
         ],
     ],
+    'imp' => [
+        'driver' => env('DB_DRIVER', 'mysql'),
+        'host' => env('DB_HOST', 'localhost'),
+        'database' => 'imp',
+        'port' => env('DB_PORT', 3306),
+        'username' => env('DB_USERNAME', 'root'),
+        'password' => env('DB_PASSWORD', ''),
+        'charset' => env('DB_CHARSET', 'utf8'),
+        'collation' => env('DB_COLLATION', 'utf8_unicode_ci'),
+        'prefix' => env('DB_PREFIX', ''),
+        'pool' => [
+            'min_connections' => 1,
+            'max_connections' => 10,
+            'connect_timeout' => 10.0,
+            'wait_timeout' => 3.0,
+            'heartbeat' => -1,
+            'max_idle_time' => (float) env('DB_MAX_IDLE_TIME', 60),
+        ],
+        'variables' => [
+            'time_zone' => '+08:00', // 设置MySQL连接的时区
+        ],
+        'commands' => [
+            'gen:model' => [
+                'path' => 'app/Model',
+                'force_casts' => true,
+                'inheritance' => 'Model',
+            ],
+        ],
+    ],
+    'secondary' => [
+        'driver' => env('DB_DRIVER', 'mysql'),
+        'host' => env('DB_HOST', 'localhost'),
+        'database' => env('DB_DATABASE', 'hyperf'),
+        'port' => env('DB_PORT', 3306),
+        'username' => env('DB_USERNAME', 'root'),
+        'password' => env('DB_PASSWORD', ''),
+        'charset' => env('DB_CHARSET', 'utf8'),
+        'collation' => env('DB_COLLATION', 'utf8_unicode_ci'),
+        'prefix' => env('DB_PREFIX', ''),
+        'pool' => [
+            'min_connections' => 1,
+            'max_connections' => 10,
+            'connect_timeout' => 10.0,
+            'wait_timeout' => 3.0,
+            'heartbeat' => -1,
+            'max_idle_time' => (float) env('DB_MAX_IDLE_TIME', 60),
+        ],
+        'variables' => [
+            'time_zone' => '+08:00', // 设置MySQL连接的时区
+        ],
+        'commands' => [
+            'gen:model' => [
+                'path' => 'app/Model',
+                'force_casts' => true,
+                'inheritance' => 'Model',
+            ],
+        ],
+    ],
+    'global' => [
+        'driver' => env('DB_DRIVER3', 'mysql'),
+        'host' => env('DB_HOST3', 'localhost'),
+        'database' => env('DB_DATABASE3', 'hyperf'),
+        'port' => env('DB_PORT3', 3306),
+        'username' => env('DB_USERNAME3', 'root'),
+        'password' => env('DB_PASSWORD3', ''),
+        'charset' => env('DB_CHARSET3', 'utf8'),
+        'collation' => env('DB_COLLATION3', 'utf8_unicode_ci'),
+        'prefix' => env('DB_PREFIX3', ''),
+        'pool' => [
+            'min_connections' => 1,
+            'max_connections' => 10,
+            'connect_timeout' => 10.0,
+            'wait_timeout' => 3.0,
+            'heartbeat' => -1,
+            'max_idle_time' => (float) env('DB_MAX_IDLE_TIME3', 60),
+        ],
+        'variables' => [
+            'time_zone' => '+08:00', // 设置MySQL连接的时区
+        ],
+        'commands' => [
+            'gen:model' => [
+                'path' => 'app/Model',
+                'force_casts' => true,
+                'inheritance' => 'Model',
+            ],
+        ],
+    ],
 ];