rkljw 3 ngày trước cách đây
mục cha
commit
d8230a8182

+ 303 - 66
app/JsonRpc/PublicRpcService.php

@@ -1,4 +1,5 @@
 <?php
+
 namespace App\JsonRpc;
 
 use _PHPStan_62c6a0a8b\OndraM\CiDetector\Env;
@@ -17,6 +18,13 @@ use App\Service\MinioService;
 use Hyperf\Redis\Redis;
 use Overtrue\ChineseCalendar\Calendar;
 
+use App\Model\TemplateClass;
+use App\Model\Template;
+use App\Model\WebsiteTemplate;
+use App\Model\WebsiteTemplateInfo;
+use App\Model\Sector;
+use App\Model\Component;
+
 #[RpcService(name: "PublicRpcService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
 class PublicRpcService implements PublicRpcServiceInterface
 {
@@ -29,24 +37,24 @@ class PublicRpcService implements PublicRpcServiceInterface
     public function getDistrictList(array $data): array
     {
         $where = [];
-       if(isset($data['keyWord'])){
-           $where = [
-               ['name','like','%'.$data['keyWord'].'%']
-           ];
+        if (isset($data['keyWord'])) {
+            $where = [
+                ['name', 'like', '%' . $data['keyWord'] . '%']
+            ];
         }
         $result  = [];
-        if(isset($data['pageSize'])){
-            $rep = District::where($where)->limit($data['pageSize'])->offset(($data['page']-1)*$data['pageSize'])->orderBy("code","asc")->get();
+        if (isset($data['pageSize'])) {
+            $rep = District::where($where)->limit($data['pageSize'])->offset(($data['page'] - 1) * $data['pageSize'])->orderBy("code", "asc")->get();
             $count = District::where($where)->count();
             $result = [
-                'rows'=>$rep,
-                'count'=>$count
+                'rows' => $rep,
+                'count' => $count
 
             ];
-        }else{
-            $result = District::where($data)->orderBy("code","asc")->get();
+        } else {
+            $result = District::where($data)->orderBy("code", "asc")->get();
         }
-        return $result?Result::success($result):Result::error("没有查到数据");
+        return $result ? Result::success($result) : Result::error("没有查到数据");
     }
 
     /**
@@ -148,12 +156,14 @@ class PublicRpcService implements PublicRpcServiceInterface
                 ->leftJoin("letter_type as type_e", "letter_of_complaint.nature_level3", "type_e.id")
                 ->leftJoin("letter_type as type_d", "letter_of_complaint.status", "type_d.id")
 
-                ->select("letter_of_complaint.*",
+                ->select(
+                    "letter_of_complaint.*",
                     "type_a.type_name as nature_name",
                     "type_b.type_name as nature_name1",
                     "type_c.type_name as nature_name0",
                     "type_d.type_name as status_name",
-                    "type_e.type_name as nature_name3")
+                    "type_e.type_name as nature_name3"
+                )
                 ->limit($data['pageSize'])->offset(($data['page'] - 1) * $data['pageSize'])->orderBy("letter_of_complaint.id", "desc")->get();
             $count = LetterOfComplaint::where($where)->count();
             if ($rep) {
@@ -184,12 +194,14 @@ class PublicRpcService implements PublicRpcServiceInterface
                 ->leftJoin("letter_type as type_e", "letter_of_complaint.nature_level3", "type_e.id")
                 ->leftJoin("letter_type as type_d", "letter_of_complaint.status", "type_d.id")
 
-                ->select("letter_of_complaint.*",
+                ->select(
+                    "letter_of_complaint.*",
                     "type_a.type_name as nature_name",
                     "type_b.type_name as nature_name1",
                     "type_c.type_name as nature_name0",
                     "type_d.type_name as status_name",
-                    "type_e.type_name as nature_name3")
+                    "type_e.type_name as nature_name3"
+                )
                 ->orderBy("letter_of_complaint.id", "desc")->get();
         }
         return $result ? Result::success($result) : Result::error("没有查到数据");
@@ -285,12 +297,14 @@ class PublicRpcService implements PublicRpcServiceInterface
             ->leftJoin("letter_type as type_e", "letter_of_complaint.nature_level3", "type_e.id")
             ->leftJoin("letter_type as type_d", "letter_of_complaint.status", "type_d.id")
 
-            ->select("letter_of_complaint.*",
+            ->select(
+                "letter_of_complaint.*",
                 "type_a.type_name as nature_name",
                 "type_b.type_name as nature_name1",
                 "type_c.type_name as nature_name0",
                 "type_d.type_name as status_name",
-                "type_e.type_name as nature_name3")
+                "type_e.type_name as nature_name3"
+            )
             ->first();
         return Result::success($result);
     }
@@ -302,12 +316,12 @@ class PublicRpcService implements PublicRpcServiceInterface
      */
     public function delLetterOfComplaint(array $data): array
     {
-        $result = LetterOfComplaint::when($data,function ($query) use ($data){
-            if(isset($data['id']) && !empty($data['id'])){
-                $query->where(['id'=>$data['id']]);
+        $result = LetterOfComplaint::when($data, function ($query) use ($data) {
+            if (isset($data['id']) && !empty($data['id'])) {
+                $query->where(['id' => $data['id']]);
             }
-            if(isset($data['user_id']) && !empty($data['user_id'])){
-                $query->where(['user_id'=>$data['user_id']]);
+            if (isset($data['user_id']) && !empty($data['user_id'])) {
+                $query->where(['user_id' => $data['user_id']]);
             }
         })->delete();
         if (empty($result)) {
@@ -327,10 +341,10 @@ class PublicRpcService implements PublicRpcServiceInterface
         if (isset($data['type'])) {
             array_push($where, ['type', '=', $data['type']]);
         }
-        if (isset($data['pid']) && $data['pid']>0) {
+        if (isset($data['pid']) && $data['pid'] > 0) {
             array_push($where, ['pid', '=', $data['pid']]);
         }
-        $result = LetterType::where($where)->orderBy('sort','asc')->get();
+        $result = LetterType::where($where)->orderBy('sort', 'asc')->get();
         return $result ? Result::success($result) : Result::error("没有查到数据");
     }
     /**
@@ -391,7 +405,6 @@ class PublicRpcService implements PublicRpcServiceInterface
         } else {
             return Result::error("您不能处理其他人已经接过的案件", 0);
         }
-
     }
 
     /**
@@ -480,20 +493,20 @@ class PublicRpcService implements PublicRpcServiceInterface
      * @param array $data
      * @return array
      */
-    public function getDepartment(array $data) :array
+    public function getDepartment(array $data): array
     {
         $where = [];
-        if(isset($data['pid'])){
+        if (isset($data['pid'])) {
             $where  = [
-                'pid'=>$data['pid']??0
+                'pid' => $data['pid'] ?? 0
             ];
         }
-        $result = Department::when(!empty($where),function ($query) use ($where){
+        $result = Department::when(!empty($where), function ($query) use ($where) {
             $query->where($where);
-        })->orderBy("sort","desc")->get();
+        })->orderBy("sort", "desc")->get();
         if (empty($result)) {
             return Result::error("查询失败", 0);
-        }else{
+        } else {
             return Result::success($result);
         }
     }
@@ -503,11 +516,11 @@ class PublicRpcService implements PublicRpcServiceInterface
      * @param array $data
      * @return array
      */
-    public function getBuckets(array $data) :array
+    public function getBuckets(array $data): array
     {
         $result = new MinioService();
         // 调用服务层的方法获取存储桶列表
-        $bucketsResponse =$result->listBuckets();
+        $bucketsResponse = $result->listBuckets();
         // 直接返回服务层生成的响应
         return Result::success($bucketsResponse['data']);
     }
@@ -517,16 +530,15 @@ class PublicRpcService implements PublicRpcServiceInterface
      * @param array $data
      * @return array
      */
-    public function uploadFile(array $data) :array
+    public function uploadFile(array $data): array
     {
         $result = new MinioService();
         $rep = $result->uploadFile($data);
-        if($rep['code']==200){
+        if ($rep['code'] == 200) {
             return Result::success($rep['data']);
-        }else{
+        } else {
             return Result::error("上传失败!");
         }
-
     }
 
     /**
@@ -534,22 +546,25 @@ class PublicRpcService implements PublicRpcServiceInterface
      * @param array $data
      * @return array
      */
-    public function getBlackWordList(array $data) :array
+    public function getBlackWordList(array $data): array
     {
         $result = BlackWord::when($data, function ($query) use ($data) {
-            if (isset($data['name']) && $data['name']){
-                $query->where('black_word.name', 'like', '%'.$data['name'].'%');
+            if (isset($data['name']) && $data['name']) {
+                $query->where('black_word.name', 'like', '%' . $data['name'] . '%');
             }
-        })->orderBy('black_word.id','desc')
-            ->paginate(intval($data['pageSize']),
+        })->orderBy('black_word.id', 'desc')
+            ->paginate(
+                intval($data['pageSize']),
                 [
                     'black_word.*',
                 ],
-                'page', intval($data['page']));
+                'page',
+                intval($data['page'])
+            );
         $count = $result->total();
         $returnData = [
-            'rows'=>$result->items(),
-            'count'=>$count
+            'rows' => $result->items(),
+            'count' => $count
         ];
         return Result::success($returnData);
     }
@@ -559,12 +574,12 @@ class PublicRpcService implements PublicRpcServiceInterface
      * @param array $data
      * @return array
      */
-    public function addBlackWord(array $data) :array
+    public function addBlackWord(array $data): array
     {
         Db::beginTransaction();
         try {
-            $info = BlackWord::where(['name'=>$data['name']])->first();
-            if($info){
+            $info = BlackWord::where(['name' => $data['name']])->first();
+            if ($info) {
                 Db::rollBack();
                 return  Result::error("该黑名单已存在", 0);
             }
@@ -574,29 +589,28 @@ class PublicRpcService implements PublicRpcServiceInterface
             $this->redis->sAdd($redisKey, $data['name']);
             Db::commit();
             return Result::success(["id" => $result]);
-        }catch (\Exception $e){
+        } catch (\Exception $e) {
             Db::rollBack();
-            return Result::error("创建失败".$e->getMessage(), 0);
+            return Result::error("创建失败" . $e->getMessage(), 0);
         }
-
     }
     /**
      * 删除黑名单
      * @param array $data
      * @return array
      */
-    public function delBlackWord(array $data) :array
+    public function delBlackWord(array $data): array
     {
         Db::beginTransaction();
         try {
-            BlackWord::where(['name'=>$data['name']])->delete();
+            BlackWord::where(['name' => $data['name']])->delete();
             $redisKey = 'black_word';
             $this->redis->sRem($redisKey, $data['name']);
             Db::commit();
             return Result::success([]);
-        }catch (\Exception $e){
+        } catch (\Exception $e) {
             Db::rollBack();
-            return Result::error("删除失败".$e->getMessage(), 0);
+            return Result::error("删除失败" . $e->getMessage(), 0);
         }
     }
 
@@ -605,34 +619,144 @@ class PublicRpcService implements PublicRpcServiceInterface
      * @param array $data
      * @return array
      */
-    public function upBlackWord(array $data) :array
+    public function upBlackWord(array $data): array
     {
         Db::beginTransaction();
         try {
-            $checkInfo = BlackWord::where(['name'=>$data['name']])->first();
-            if($checkInfo){
+            $checkInfo = BlackWord::where(['name' => $data['name']])->first();
+            if ($checkInfo) {
                 Db::rollBack();
                 return Result::error("该违禁词已经存在", 0);
             }
-            $blackWordInfo = BlackWord::where(['id'=>$data['id']])->first();
-            if($blackWordInfo){
+            $blackWordInfo = BlackWord::where(['id' => $data['id']])->first();
+            if ($blackWordInfo) {
                 //先删除redis
                 $blackWordInfo = $blackWordInfo->toArray();
                 $redisKey = 'black_word';
                 $this->redis->sRem($redisKey, $blackWordInfo['name']);
                 $this->redis->sAdd($redisKey, $data['name']);
-                BlackWord::where(['id'=>$data['id']])->update(['name'=>$data['name']]);
+                BlackWord::where(['id' => $data['id']])->update(['name' => $data['name']]);
                 Db::commit();
                 return Result::success([]);
-            }else{
+            } else {
                 Db::rollBack();
                 return Result::error("系统错误", 0);
             }
-        }catch (\Exception $e){
+        } catch (\Exception $e) {
             Db::rollBack();
-            return Result::error("修改失败".$e->getMessage(), 0);
+            return Result::error("修改失败" . $e->getMessage(), 0);
+        }
+    }
+    /**
+     * 获取getTemplateClass
+     * @param array $data
+     * @return array
+     */
+    public function getTemplateClass(array $data): array
+    {
+        $result = TemplateClass::get();
+        return Result::success($result);
+    }
+    public function getTemplateList(array $data): array
+    {
+        $where = [];
+        if (!empty($data['template_class_id'])) {
+            $where['template_class_id'] = $data['template_class_id'];
+        }
+        if (!empty($data['template_name'])) {
+            $where['template_name'] = $data['template_name'];
+        }
+        $result = Template::where($where)
+            ->leftJoin('template_class', 'template.template_class_id', 'template_class.id')
+            ->select('template.*', 'template_class.name as template_class_name')
+            ->orderBy('template.id', 'desc')
+            ->paginate($data['page_size'], ['*'], 'mypage_name', $data['page']);
+        // 使用 items 方法获取分页数据
+        // $items = collect($result->items());
+        // $items->each(function ($item) {
+        //     $item['template_content'] = json_decode($item['template_content'], true);
+        // });
+        return Result::success($result);
+    }
+    public function getTemplateInfo(array $data): array
+    {
+        $result = Template::where('template.id', $data['id'])
+            ->leftJoin('template_class', 'template.template_class_id', 'template_class.id')
+            ->select('template.*', 'template_class.name as template_class_name')
+            ->first();
+        return Result::success($result);
+    }
+    public function addTemplate(array $data): array
+    {
+        var_dump($data);
+        unset($data['user_id']);
+        $result = Template::insertGetId($data);
+        if ($result) {
+            $returData = Template::where('id', $result)->first();
+            return Result::success($returData);
+        } else {
+            return Result::error("添加失败", 0);
+        }
+    }
+    public function delTemplate(array $data): array
+    {
+        $result = Template::where('id', $data['id'])->delete();
+        var_dump($result, '-------------------delete');
+        if ($result) {
+            return Result::success($result);
+        } else {
+            return Result::error("删除失败", 0);
+        }
+    }
+    public function updateTemplate(array $data): array
+    {
+        unset($data['user_id']);
+        $result = Template::where('id', $data['id'])->update($data);
+        var_dump($result, '-------------------update');
+        if (!$result) {
+            return Result::error("更新失败", 0);
+        } else {
+            return Result::success('更新成功');
         }
     }
+    public function getSectorList(array $data): array
+    {
+        $where = [];
+        if (!empty($data['template_class_id'])) {
+            $where['template_class.id'] = $data['template_class_id'];
+        }
+        if (!empty($data['template_class_name'])) {
+            $where[] = ['template_class.name', 'like', '%' . $data['template_class_name'] . '%'];
+        }
+
+        if (!empty($data['sector_name'])) {
+            if (!empty($data['sector_name'])) {
+                // $where['sector_name'] = $data['sector_name'];
+                $where[] = ['sector.sector_name', 'like', '%' . $data['sector_name'] . '%'];
+            }
+        }
+
+        $result = Sector::where($where)
+            ->leftJoin('template', 'template.id', '=', 'sector.template_id')
+            ->leftJoin('template_class', 'template_class.id', '=', 'sector.template_id') // 添加这一行
+            ->select('sector.*', 'sector.sector_name', 'template.template_name', 'template_class.name as template_class_name', 'template_class.id as template_class_id') // 修改这一行
+            ->orderBy('sector.id', 'desc')
+            ->paginate($data['page_size'], ['*'], 'mypage_name', $data['page']);
+
+        return Result::success($result);
+    }
+    public function getSectorInfo(array $data): array
+    {
+        $where = [];
+        $where[] = ['sector.id', '=', $data['id']];
+        $result = Sector::where($where)
+            ->leftJoin('template', 'template.id', '=', 'sector.template_id')
+            ->leftJoin('template_class', 'template_class.id', '=', 'template.template_class_id') // 添加这一行
+            ->select('sector.*', 'template.template_name', 'template_class.name as template_class_name', 'template_class.id as template_class_id') // 修改这一行
+            ->orderBy('sector.id', 'desc')
+            ->get();
+        return Result::success($result);
+    }
 
     /**
      * 获取经纬度信息
@@ -673,7 +797,7 @@ class PublicRpcService implements PublicRpcServiceInterface
         $day = $data['day'] ?? date('d');
         // 使用缓存键
         $cacheKey = "tsbb_data_weather_{$month}_{$day}";
-        
+
         // 尝试从缓存获取数据
         $container = \Hyperf\Context\ApplicationContext::getContainer();
         $cache = $container->get(\Psr\SimpleCache\CacheInterface::class);
@@ -708,6 +832,119 @@ class PublicRpcService implements PublicRpcServiceInterface
         return Result::success($result);
     }
 
+    public function addSector(array $data): array
+    {
+        unset($data['user_id']);
+        // $data['page_type'] = json_encode($data['page_type']);
+        $result = Sector::insertGetId($data);
+        return Result::success();
+    }
+    public function delSector(array $data): array
+    {
+        $result = Sector::where('id', $data['id'])->delete();
+        if ($result == 1) {
+            return Result::success('删除成功');
+        } else {
+            return Result::error('删除失败');
+        }
+    }
+    public function updateSector(array $data): array
+    {
+        unset($data['user_id']);
+        $result = Sector::where('id', $data['id'])->update($data);
+        if ($result == 1) {
+            return Result::success('修改成功');
+        } else {
+            return Result::error('修改失败');
+        }
+    }
+    public function getComponentList(array $data): array
+    {
+        var_dump($data, '---------');
+        $where = [];
+        // $where[] = ['sector.id', '=', $data['id']];
+        if (!empty($data['template_class_id'])) {
+            $where['template_class.id'] = $data['template_class_id'];
+        }
+        if (!empty($data['component_name'])) {
+            $where['component.component_name'] = $data['component_name'];
+        }
+        if (!empty($data['sector_id'])) {
+            $where['sector.id'] = $data['sector_id'];
+        };
+
+        $result = Component::where($where)
+            ->leftJoin('template', 'template.id', '=', 'component.template_id')
+            ->leftJoin('template_class', 'template_class.id', '=', 'template.template_class_id') // 添加这一行
+            ->leftJoin('sector', 'sector.id', '=', 'component.sector_id')
+            ->select('template_class.name as template_class_name', 'template.template_name as template_name', 'template_class.id as template_class_id', 'sector.sector_name as sector_name', 'component.*', 'sector.id as sector_id') // 修改这一行)
+            ->orderBy('sector.updated_at', 'desc')
+            ->orderBy('sector.created_at', 'desc')
+            ->paginate($data['page_size'], ['*'], 'mypage_name', $data['page']);
+        return Result::success($result);
+    }
+    public function getComponentInfo(array $data): array
+    {
+        $where = [];
+        $result = Component::where($where)
+            ->leftJoin('template', 'template.id', '=', 'component.template_id')
+            ->leftJoin('template_class', 'template_class.id', '=', 'template.template_class_id') // 添加这一行
+            ->leftJoin('sector', 'sector.id', '=', 'component.sector_id')
+            ->select('template_class.name as template_class_name', 'template.template_name as template_name', 'sector.sector_name as sector_name', 'component.*')
+            ->get();
+        return Result::success($result);
+    }
+    public function addComponent(array $data): array
+    {
+        unset($data['user_id']);
+        $result = Component::insertGetId($data);
+        if ($result) {
+            return Result::success($result);
+        } else {
+            return Result::error('添加失败');
+        }
+    }
+    public function delComponent(array $data): array
+    {
+        $result = Component::where('id', $data['id'])->delete();
+        return Result::success($result);
+    }
+    public function updateComponent(array $data): array
+    {
+        $result = Component::where('id', $data['id'])->update($data);
+        return Result::success($result);
+    }
+    public function getWebsiteTemplateList(array $data): array
+    {
+        $where = [];
 
-}
+        $result = WebsiteTemplateInfo::where($where)
+            ->leftJoin('website', 'website_template_info.website_id', '=', 'website.id')
+            ->select('website_template_info.*', 'website.website_name')
+            ->orderBy('website_template_info.id', 'desc')
+            ->paginate($data['page_size'], ['*'], 'page', $data['page']);
+        if ($result) {
+            return Result::success($result);
+        } else {
+            return Result::error('暂无数据');
+        }
+    }
+    public function getWebsiteTemplateInfo(array $data)
+    {
+        $where = [];
+        if (isset($data['id'])) {
+            $where[] = ['id', '=', $data['id']];
+        }
+        $result = WebsiteTemplateInfo::where($where)
+            ->leftJoin('website', 'website_template_info.website_id', '=', 'website.id')
+            ->leftJoin('website_template', 'website_template_info.template_id', '=', 'website_template.id')
+            ->select('website_template_info.*', 'website.website_name')
+            ->get();
+        if ($result) {
+            return Result::success($result);
+        } else {
+            return Result::error('暂无数据');
+        }
+    }
 
+}

+ 19 - 0
app/JsonRpc/PublicRpcServiceInterface.php

@@ -144,6 +144,25 @@ interface PublicRpcServiceInterface
      * @param array $data
      * @return array
      */
+
+    public function getTemplateList(array $data);
+    public function getTemplateInfo(array $data);
+    public function addTemplate(array $data);
+    public function delTemplate(array $data);
+    public function updateTemplate(array $data);
+    public function getSectorList(array $data);
+    public function getSectorInfo(array $data);
+    public function addSector(array $data);
+    public function delSector(array $data);
+    public function updateSector(array $data);
+    public function getComponentList(array $data);
+    public function getComponentInfo(array $data);
+    public function addComponent(array $data);
+    public function delComponent(array $data);
+    public function updateComponent(array $data);
+    public function getWebsiteTemplateList(array $data);
+    public function getWebsiteTemplateInfo(array $data);
+
     public function uploadFile(array $data): array;
     public function getBlackWordList(array $data): array;
     public function addBlackWord(array $data): array;

+ 410 - 165
app/JsonRpc/WebsiteService.php

@@ -23,6 +23,15 @@ use App\Model\WebsiteRole;
 use App\Model\WebsiteRoleUser;
 use App\Model\Website;
 use App\Model\WebsiteColumn;
+use App\Model\Good;
+use App\Model\Book;
+use App\Model\JobRecruiting;
+use App\Model\JobHunting;
+use App\Model\Notice;
+use App\Model\Complaint;
+use App\Model\Order;
+use App\Model\WebsiteImg;
+use Hyperf\HttpServer\Contract\RequestInterface;
 
 use Hyperf\DbConnection\Db;
 use Hyperf\RpcServer\Annotation\RpcService;
@@ -35,7 +44,7 @@ use App\Model\Sector;
 use PhpParser\Node\Stmt\Return_;
 use function PHPUnit\Framework\isNull;
 use Overtrue\Pinyin\Pinyin;
-
+use App\Tools\buildTree;
 #[RpcService(name: "WebsiteService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
 class WebsiteService implements WebsiteServiceInterface
 {
@@ -519,27 +528,28 @@ class WebsiteService implements WebsiteServiceInterface
             $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')
-            ->get()->all();
-            if(empty($result)){
-                return Result::error("此广告位不存在!",0);
-            } 
-        }else{
-            return Result::error("请选择广告位!",0);
+                ->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'
+                )
+                ->get()->all();
+            if (empty($result)) {
+                return Result::error("此广告位不存在!", 0);
+            }
+        } else {
+            return Result::error("请选择广告位!", 0);
         }
         return Result::success($result);
     }
@@ -584,7 +594,11 @@ class WebsiteService implements WebsiteServiceInterface
 
         // return Result::success($data);
         $pid = $data['pid'] ?? 0;
-        $result = District::where('pid', $pid)->where('status', 1)->orderBy('code')->get();
+        $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 {
@@ -592,62 +606,77 @@ class WebsiteService implements WebsiteServiceInterface
         }
     }
 
-    /**
+     /**
      * 获取栏目
      * @param array $data
      * @return array
      */
 
-    public function getWebsiteModelCategory(array $data): array
-    {
-        // return Result::success($data);
-        $website_id = [
-            'website_id' => $data['website_id'],
-        ];
-        // 初始化 $pid 数组
-        // $pid = [];
-        // 以下注释掉的代码是之前的逻辑,用于获取非顶级分类的 pid
-        $pidQuery = WebsiteCategory::where($website_id)
-            ->where('pid', '!=', 0)
-            ->orderBy('sort')
-            ->select('pid', 'category_id', 'alias');
-        $pid = $pidQuery->pluck('pid');
-        $pid = array_values(array_unique($pid->toArray()));
-
-        // 构建查询语句
-        $query = WebsiteCategory::where($website_id)
-            ->where('pid', $data['pid'])
-            ->offset($data['placeid'])
-            ->limit($data['num'])
-            ->orderBy('sort');
-        // 如果 $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();
-            $pidMap = $pidResults->keyBy('pid');
-            $result->each(function ($record) use ($pidMap) {
-                if ($pidMap->has($record->category_id)) {
-                    $pidResult = $pidMap->get($record->category_id);
-                    $record->chilid_id = $pidResult->category_id;
-                    $record->chilid_alias = $pidResult->alias;
-                }
-            });
-            return Result::success($result);
-        } else {
-            return Result::error("本网站暂无栏目", 0);
-        }
-    }
+     public function getWebsiteModelCategory(array $data): array
+     {
+         // return Result::success($data);
+         $website_id = [
+             'website_id' => $data['website_id'],
+         ];
+         // 初始化 $pid 数组
+         // $pid = [];
+         // 以下注释掉的代码是之前的逻辑,用于获取非顶级分类的 pid
+         $pidQuery = WebsiteCategory::where($website_id)
+             ->where('pid', '!=', 0)
+             ->orderBy('sort')
+             ->select('pid', 'category_id', 'alias');
+         $pid = $pidQuery->pluck('pid');
+         $pid = array_values(array_unique($pid->toArray()));
+ 
+         // 构建查询语句
+         $query = WebsiteCategory::where($website_id)
+             ->where('pid', $data['pid'])
+             ->offset($data['placeid'])
+             ->limit($data['num'])
+             ->orderBy('sort');
+         // 如果 $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) {
+                    if ($pidMap->has($record->category_id)) {
+                        $pidResult = $pidMap->get($record->category_id);
+                        $record->chilid_id = $pidResult->category_id;
+                        $record->chilid_alias = $pidResult->alias;
+                    }
+                });
+             }
+             
+             return Result::success($result);
+         } else {
+             return Result::error("本网站暂无栏目", 0);
+         }
+     }
+ 
 
     /**
      * 获取友情链接
@@ -681,8 +710,34 @@ class WebsiteService implements WebsiteServiceInterface
         switch ($data['type_id']) {
             case 4:
                 $result = Db::select('SELECT  DATE(created_at) AS date,COUNT(*) AS total_count FROM  letter_of_complaint  WHERE  created_at >= CURDATE() - INTERVAL 30 DAY  GROUP BY  DATE(created_at)  ORDER BY  date ASC;');
-                return Result::success($result);
-                break;
+                $res = [];
+                //查询已审核文章
+                $user_id = $data['user_id'];
+                $article = Article::where('status', 1)
+                    ->where('admin_user_id', $user_id)
+                    ->orderBy('updated_at', 'desc')
+                    ->limit(10)
+                    ->get();
+                $res['letterOfComplaintList'] = $result;
+                $res['article'] = $article;
+                $res['article']['count'] = Article::whereNotIn('status', ['404'])->where('admin_user_id', $user_id)->count();
+                $res['good']['count'] =  Good::where([])->where('user_id', $user_id)->count();
+                $res['book']['count'] = Book::where([])->where('user_id', $user_id)->count();
+                $res['jobHunting']['count'] = JobHunting::where([])->where('user_id', $user_id)->count();
+                $res['jobRecruiting']['count'] = JobRecruiting::where([])->where('user_id', $user_id)->count();
+                $res['complaint']['count'] = Complaint::where([])->where('user_id', $user_id)->count();
+                $res['notice']['count'] = Notice::where([])->where('user_id', $user_id)->count();
+
+                //待审核数据
+                $res['apply']['article'] = Article::where(['status' => 0])->where('admin_user_id', $user_id)->count();   //
+                $res['apply']['good'] = Good::where(['status' => 1])->where('user_id', $user_id)->count();
+                $res['apply']['book'] = Book::where(['status' => 1])->where('user_id', $user_id)->count();
+                $res['apply']['jobHunting'] = JobHunting::where(['status' => 1])->where('user_id', $user_id)->count();
+                $res['apply']['jobRecruiting'] = JobRecruiting::where(['status' => 0])->where('user_id', $user_id)->count();
+                $res['apply']['complaint'] = Complaint::where(['status' => 1])->where('user_id', $user_id)->count();
+                $res['apply']['notice'] = Notice::where(['status' => 1])->where('user_id', $user_id)->count();
+
+                return Result::success($res);
             case 10000:
                 $res = [];
                 //网站
@@ -694,17 +749,56 @@ class WebsiteService implements WebsiteServiceInterface
                 //导航池
                 $res['category']['count'] = 0;
                 $res['category']['growth_rate'] = 0;
+                //商品
+                $res['good']['count'] = 0;
+                $res['book']['count'] = 0;
+                $res['jobHunting']['count'] = 0;
+                $res['jobRecruiting']['count'] = 0;
                 //近一月数据
                 $res['monthArticle'] = [];
                 //用户类型
                 $res['userType'] = [];
                 $res['website']['count'] = Website::where([])->count();
-                $res['article']['count'] = Article::whereNotIn('status', ['404'])->count();
+                $res['article']['count'] = Article::whereIn('status', [1])->count();
                 $res['category']['count'] = Category::where([])->count();
-                $res['monthArticle'] = Db::select('SELECT  DATE(created_at) AS date,COUNT(*) AS total_count FROM  article  WHERE  created_at >= CURDATE() - INTERVAL 30 DAY  GROUP BY  DATE(created_at)  ORDER BY  date ASC;');
+                $res['good']['count'] =  Good::whereIn('status', [2])->count();
+                $res['book']['count'] = Book::whereIn('status', [2])->count();
+                $res['jobHunting']['count'] = JobHunting::whereIn('status', [2])->count();
+                $res['jobRecruiting']['count'] = JobRecruiting::whereIn('status', [1])->count();
+                $res['complaint']['count'] = Complaint::whereIn('status', [2])->count();
+                $res['notice']['count'] = Notice::whereIn('status', [2])->count();
+
+                // $res['monthArticle'] = Db::select('SELECT  DATE(created_at) AS date,COUNT(*) AS total_count FROM  article  WHERE  created_at >= CURDATE() - INTERVAL 30 DAY  GROUP BY  DATE(created_at)  ORDER BY  date ASC;');
+                $res['monthArticle'] = Db::select(' SELECT  DATE(article.created_at) AS date,COUNT(*) AS count ,user.type_id FROM  article left JOIN user on article.admin_user_id = user.id  WHERE
+                 article.status =1 and   article.created_at >= CURDATE() - INTERVAL 30 DAY  GROUP BY  DATE(article.created_at),`user`.type_id  ORDER BY  date ASC');
+
+                $res['monthGood'] = Db::select(' SELECT  DATE(good.created_at) AS date,COUNT(*) AS count ,user.type_id FROM  good left JOIN user on good.user_id = user.id  WHERE
+                 good.status =2 and   good.created_at >= CURDATE() - INTERVAL 30 DAY  GROUP BY  DATE(good.created_at),`user`.type_id  ORDER BY  date ASC');
+
+                $res['monthBook'] = Db::select(' SELECT  DATE(book.created_at) AS date,COUNT(*) AS count ,user.type_id FROM  book left JOIN user on book.user_id = user.id  WHERE   book.status =2 and  book.created_at >= CURDATE() - INTERVAL 30 DAY  GROUP BY  DATE(book.created_at),`user`.type_id  ORDER BY  date ASC');
+
+                $res['monthJobHunting'] = Db::select(' SELECT  DATE(job_hunting.created_at) AS date,COUNT(*) AS count ,user.type_id FROM  job_hunting left JOIN user on job_hunting.user_id = user.id  WHERE   job_hunting.status =2 and  job_hunting.created_at >= CURDATE() - INTERVAL 30 DAY  GROUP BY  DATE(job_hunting.created_at),`user`.type_id  ORDER BY  date ASC');
+
+                $res['monthJobRecruiting'] = Db::select(' SELECT  DATE(job_recruiting.created_at) AS date,COUNT(*) AS count ,user.type_id FROM  job_recruiting left JOIN user on job_recruiting.user_id = user.id  WHERE  job_recruiting.status =1 and   job_recruiting.created_at >= CURDATE() - INTERVAL 30 DAY  GROUP BY  DATE(job_recruiting.created_at),`user`.type_id  ORDER BY  date ASC');
+
+
+
                 $res['userType'] = User::where([])->selectRaw("count(*) as counts,type_id")->groupBy('type_id')->get();
+
+                //待审核数据
+                $res['apply']['article'] = Article::where(['status' => 0])->count();   //
+                $res['apply']['good'] = Good::where(['status' => 1])->count();
+                $res['apply']['book'] = Book::where(['status' => 1])->count();
+                $res['apply']['jobHunting'] = JobHunting::where(['status' => 1])->count();
+                $res['apply']['jobRecruiting'] = JobRecruiting::where(['status' => 0])->count();
+                $res['apply']['complaint'] = Complaint::where(['status' => 1])->count();
+                $res['apply']['notice'] = Notice::where(['status' => 1])->count(); //订单状态:1:通过;2:驳回;3:撤回;4:修改;5:过期;6:待审核;7:结束',
+                $res['apply']['order'] = Order::where(['status' => 6])->count();
+
                 return Result::success($res);
             case 1:
+            case 2:
+            case 3:
                 $res = [];
                 //查询已审核文章
                 $user_id = $data['user_id'];
@@ -713,7 +807,26 @@ class WebsiteService implements WebsiteServiceInterface
                     ->orderBy('updated_at', 'desc')
                     ->limit(10)
                     ->get();
+
                 $res['article'] = $article;
+                $res['website']['count'] = Website::where([])->count();
+                $res['article']['count'] = Article::whereIn('status', [1])->count();
+                $res['category']['count'] = Category::where([])->count();
+                $res['good']['count'] =  Good::whereIn('status', [2])->count();
+                $res['book']['count'] = Book::whereIn('status', [2])->count();
+                $res['jobHunting']['count'] = JobHunting::whereIn('status', [2])->count();
+                $res['jobRecruiting']['count'] = JobRecruiting::whereIn('status', [1])->count();
+                $res['complaint']['count'] = Complaint::whereIn('status', [2])->count();
+                $res['notice']['count'] = Notice::whereIn('status', [2])->count();
+
+                //待审核数据
+                $res['apply']['article'] = Article::where(['status' => 0])->where('admin_user_id', $user_id)->count();   //
+                $res['apply']['good'] = Good::where(['status' => 1])->where('user_id', $user_id)->count();
+                $res['apply']['book'] = Book::where(['status' => 1])->where('user_id', $user_id)->count();
+                $res['apply']['jobHunting'] = JobHunting::where(['status' => 1])->where('user_id', $user_id)->count();
+                $res['apply']['jobRecruiting'] = JobRecruiting::where(['status' => 0])->where('user_id', $user_id)->count();
+                $res['apply']['complaint'] = Complaint::where(['status' => 1])->where('user_id', $user_id)->count();
+                $res['apply']['notice'] = Notice::where(['status' => 1])->where('user_id', $user_id)->count();
                 return Result::success($res);
         }
 
@@ -1003,87 +1116,76 @@ class WebsiteService implements WebsiteServiceInterface
      */
     public function upWebsiteCategory(array $data): array
     {
-
-        var_dump("更新数据:", $data);
         $pinyin = new Pinyin();
         Db::beginTransaction();
         try {
-            if ($data['category_arr_id']) {
-                $oldCategoryList = WebsiteCategory::where(['website_id' => $data['website_id']])->get();
-                if ($oldCategoryList) {
-                    $oldCategoryList = $oldCategoryList->toArray();
-                    $oldCategoryListIds = [];
-                    foreach ($oldCategoryList as $val) {
-                        array_push($oldCategoryListIds, $val['category_id']);
-                    }
-                    $newCategoryListIds = [];
-                    foreach ($data['category_arr_id'] as $v) {
-                        array_push($newCategoryListIds, end($v));
-                    }
-                    $differenceIDS = array_merge(array_diff($oldCategoryListIds, $newCategoryListIds), array_diff($newCategoryListIds, $oldCategoryListIds));
-                    if ($differenceIDS) {
-                        foreach ($differenceIDS as $v) {
-                            WebsiteCategory::where(['website_id' => $data['website_id'], 'category_id' => $v])->delete();
-                        }
-                    }
-                    foreach ($data['category_arr_id'] as $key => $value) {
-                        $info = Category::where(['id' => end($value)])->first();
-                        $info = $info->toArray();
-                        // 假设 $data、$value 和 $info 是已经定义好的变量
-                        $attributes = [
-                            'website_id' => $data['website_id'],
-                            'category_id' => end($value),
-                        ];
-                        // 先复制一份要更新或创建的数据
-                        $aLIas_pinyin = $pinyin->permalink($info['name'], '');
-                        var_dump($aLIas_pinyin, '别名');
-                        $values = [
-                            'website_id' => $data['website_id'],
-                            'name' => $info['name'] ?? '',
-                            'alias' => $info['name'] ?? '',
-                            'aLIas_pinyin' => $aLIas_pinyin ?? '',
-                            'sort' => $info['sort'] ?? 0,
-                            'pid' => $info['pid'] ?? 0,
-                            'pid_arr' => $info['pid_arr'] ?? json_encode([]),
-                            'seo_title' => $info['seo_title'] ?? "",
-                            'seo_keywords' => $info['seo_keywords'] ?? "",
-                            'seo_description' => $info['seo_description'] ?? "",
-                            'is_url' => $info['is_url'] ?? 0,
-                            'web_url' => $info['web_url'] ?? '',
-                            'category_id' => end($value),
-                            'category_arr_id' => $value ? json_encode($value) : json_encode([])
-                        ];
-                        // 检查数据库中是否已有该记录
-                        $existingRecord = WebsiteCategory::where($attributes)->first();
-                        if ($existingRecord && $existingRecord->name) {
-                            unset($values['name']);
-                        }
-                        if ($existingRecord && $existingRecord->sort >= 0) {
-                            unset($values['sort']);
-                        }
-                        if ($existingRecord && $existingRecord->seo_title) {
-                            unset($values['seo_title']);
-                        }
-                        if ($existingRecord && $existingRecord->seo_keywords) {
-                            unset($values['seo_keywords']);
-                        }
-                        if ($existingRecord && $existingRecord->seo_description) {
-                            unset($values['seo_description']);
-                        }
-                        if ($existingRecord && $existingRecord->alias) {
-                            unset($values['alias']);
-                        }
-                        // 执行 updateOrCreate 操作
-                        var_dump("更新数据:",  $values);
-                        WebsiteCategory::updateOrCreate($attributes, $values);
-                    }
+            if (!empty($data['category_arr_id'])) {
+                $websiteId = $data['website_id'];
+                // 1. 获取旧的 category_id 列表
+                $oldCategoryListIds = WebsiteCategory::where('website_id', $websiteId)->pluck('category_id')->toArray();
+                // 2. 获取新的 category_id 列表(去重)
+                $newCategoryListIds = [];
+                foreach ($data['category_arr_id'] as $arr) {
+                    $lastId = end($arr);
+                    $newCategoryListIds[] = $lastId;
+                }
+                $newCategoryListIds = array_unique($newCategoryListIds);
+                // 3. 需要删除的 category_id
+                $toDelete = array_diff($oldCategoryListIds, $newCategoryListIds);
+                if (!empty($toDelete)) {
+                    WebsiteCategory::where('website_id', $websiteId)
+                        ->whereIn('category_id', $toDelete)
+                        ->delete();
+                }
+                // 4. 批量查出所有需要的 category 信息
+                $categories = Category::whereIn('id', $newCategoryListIds)->get()->keyBy('id');
+                // 5. 组装 upsertData,确保 category_id 不重复
+                $upsertData = [];
+                $handledCategoryIds = [];
+                foreach ($data['category_arr_id'] as $arr) {
+                    $categoryId = end($arr);
+                    if (!isset($categories[$categoryId]) || in_array($categoryId, $handledCategoryIds)) continue;
+                    $info = $categories[$categoryId];
+                    $aLIas_pinyin = $pinyin->permalink($info->name, '');
+                    $upsertData[] = [
+                        'website_id' => $websiteId,
+                        'category_id' => $categoryId,
+                        'name' => $info->name ?? '',
+                        'alias' => $info->name ?? '',
+                        'aLIas_pinyin' => $aLIas_pinyin ?? '',
+                        'sort' => $info->sort ?? 0,
+                        'pid' => $info->pid ?? 0,
+                        'pid_arr' => $info->pid_arr ?? json_encode([]),
+                        'seo_title' => $info->seo_title ?? "",
+                        'seo_keywords' => $info->seo_keywords ?? "",
+                        'seo_description' => $info->seo_description ?? "",
+                        'is_url' => $info->is_url ?? 0,
+                        'web_url' => $info->web_url ?? '',
+                        'type' => $info->type ?? 1,
+                        'category_arr_id' => json_encode($arr)
+                    ];
+                    $handledCategoryIds[] = $categoryId;
+                }
+                // 6. upsert
+                if (!empty($upsertData)) {
+                    WebsiteCategory::upsert(
+                        $upsertData,
+                        ['website_id', 'category_id'],
+                        [
+                            'aLIas_pinyin',
+                            'pid',
+                            'pid_arr',
+                            'is_url',
+                            'web_url',
+                            'category_arr_id'
+                        ]
+                    );
                 }
             }
             Db::commit();
             return Result::success();
         } catch (\Throwable $ex) {
             Db::rollBack();
-            //            var_dump($ex->getMessage());
             return Result::error("修改失败" . $ex->getMessage(), 0);
         }
     }
@@ -1353,7 +1455,7 @@ class WebsiteService implements WebsiteServiceInterface
         }
         $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();
+        $website_foot = WebsiteTemplateInfo::where('website_id', $data['website_id'])->first();
         if (empty($website_foot)) {
             return Result::error("暂无底部基础信息", 0);
         }
@@ -1526,7 +1628,7 @@ class WebsiteService implements WebsiteServiceInterface
             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();
+            $result = WebsiteCategory::where('website_id', $data['website_id'])->where('category_id', $data['catid'])->first();
         }
         if (empty($result)) {
             return Result::error("暂无导航", 0);
@@ -2157,13 +2259,13 @@ class WebsiteService implements WebsiteServiceInterface
             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);
+        $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);
     }
@@ -2191,12 +2293,18 @@ class WebsiteService implements WebsiteServiceInterface
         if (empty($website)) {
             return Result::error("暂无该网站", 0);
         }
-        // return Result::success($data);
-        if (isset($data['pinyin']) && !empty($data['pinyin'])) {
-            $result = WebsiteCategory::where('website_id', $data['website_id'])->where('aLIas_pinyin', $data['pinyin'])->first(['category_id']);
+        if (isset($data['pinyin']) &&!empty($data['pinyin'])) {
+            $result = WebsiteCategory::where('website_category.website_id', $data['website_id'])
+                ->where('website_category.aLIas_pinyin', $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.alias', DB::raw('CASE WHEN pc.category_id IS NOT NULL THEN 1 ELSE 0 END as children_count'))
+                ->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($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);
@@ -2300,6 +2408,7 @@ class WebsiteService implements WebsiteServiceInterface
     }
     public function getWebsiteNavList(array $data): array
     {
+        $data['type'] = isset($data['type']) ? $data['type'] : 1;
         $where = [];
         if (isset($data['website_id']) && !empty($data['website_id'])) {
             array_push($where, ['website_id', '=', $data['website_id']]);
@@ -2307,13 +2416,35 @@ class WebsiteService implements WebsiteServiceInterface
         if (isset($data['pid'])) {
             array_push($where, ['pid', '=', $data['pid']]);
         }
-        $list = WebsiteCategory::query()->where($where)->get();
+        if (isset($data['type']) && !empty($data['type'])) {
+            array_push($where, ['type', '=', $data['type']]);
+        }
+        // 根据站点和type获取websiteCategory 中的id
+        $websiteCategoryids = WebsiteCategory::query()
+            ->where('website_id', '=', $data['website_id'])
+            ->where('type', '=', $data['type'])
+            ->pluck('category_arr_id')->toArray();
+        var_dump($websiteCategoryids, '------获取websiteCategory 中的id');
+        //合并去重
+        $category_ids = [];
+        foreach ($websiteCategoryids as $key => $value) {
+            $v = json_decode($value, true);
+            $category_ids = array_unique(array_merge($category_ids, $v));
+        }
+        // var_dump($category_ids, '------获取websiteCategory 中的id');
+        //根据pid取出所有的websiteCategory 中的id
+        $list = WebsiteCategory::query()
+            ->where('website_id', '=', $data['website_id'])
+            ->where('pid', '=', $data['pid'])
+            ->whereIn('category_id', $category_ids)
+            ->get();
         if (empty($list)) {
             return Result::error("获取失败", 0);
         } else {
             return Result::success($list);
         }
     }
+
     // 20250307 根据网站标识获和导航获取站点
 
     public function getWebsiteNavPoolSite(array $data): array
@@ -2448,4 +2579,118 @@ class WebsiteService implements WebsiteServiceInterface
             return Result::error("没有数据");
         }
     }
+    // --自助建站-----------20250522fr----------------------start
+    /**
+     * 获取网站模板下的板块信息
+      * @param array $data
+     * @return array
+     */
+    public function getStaticResourceList(array $data): array
+    {
+        // return Result::success($data);
+        $where = [];
+        if(isset($data['keyword']) &&!empty($data['keyword'])){
+            $where = ['img_alias' => $data['keyword'],'name' => ['like', '%'. $data['keyword']. '%']];
+        }
+        if(isset($data['type']) &&!empty($data['type'])){
+            $where = ['type' => $data['type']];
+        }
+        if(isset($data['website_id']) &&!empty($data['website_id'])){
+            $where = ['website_id' => $data['website_id']];
+        }
+        // return Result::success($where);
+        $query = WebsiteImg::when(!empty($where), function ($query) use ($where) {
+            $query->where($where);
+        })
+        ->orderBy('updated_at', 'desc');
+        $count = $query->count();
+        $row = $query->limit($data['pageSize'])->offset(($data['page'] - 1) * $data['pageSize'])->get();
+        if (empty($row)) {
+            return Result::error("没有查找到相关数据", 0);
+        } else {
+            $result = [
+                'row' => $row,
+                'count' => $count,
+            ];}
+        return Result::success($result);
+    }
+    /**
+     * 添加网站模板下的板块信息
+     * @param array $data
+     */
+    public function addStaticResource(array $data): array
+    {
+        // $file = $data['img_url']->file('image');
+        // $size = $file->getSize();
+        $img_data = [
+            'website_id' => $data['website_id'],
+            'img_alias' => $data['img_alias'],
+            'img_url' => $data['img_url'],
+            'img_size' => $data['img_size'],
+        ];
+        $img = WebsiteImg::insertGetId($img_data);
+        if (empty($img)) {
+            return Result::error("添加失败", 0);
+        }
+        $img_id['id'] = $img;
+        $url = WebsiteImg::where($img_id)->value('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
+        
+        
+        $img_datas = [
+            'img_type' => $fileType,
+            'name' => $fileName
+        ];
+        $up_img = WebsiteImg::where($img_id)->update($img_datas);
+        if (empty($up_img)) {
+            return Result::error("修改失败", 0);
+        }
+        return Result::success($up_img);
+        // 将字节转换为更友好的单位
+        // $friendlySize = $this->formatFileSize($size);
+        // $data['img_size'] = $friendlySize;
+
+
+    }
+    /**
+     * 修改网站模板下的板块信息
+     * @param array $data
+     */
+    public function delStaticResource(array $data): array
+    {
+        $where = [
+            'id' => $data['id'],
+        ];
+        $result = WebsiteImg::where($where)->delete();
+        if (empty($result)) {
+            
+            return Result::error("修改失败", 0);
+        }
+        return Result::success($result);
+    }
+    /**
+     * 获取网站模板下的板块信息
+     * @param array $data
+     */
+    public function getStaticResourceInfo(array $data): array
+    {
+        $where = [
+            'id' => $data['id'],
+        ];
+        $result = WebsiteImg::where($where)->first();
+        if (empty($result)) {
+            return Result::error("没有查找到相关数据", 0);
+        }
+        return Result::success($result);
+    }
+    // --自助建站-----------20250522fr----------------------end
 }

+ 7 - 0
app/JsonRpc/WebsiteServiceInterface.php

@@ -139,8 +139,15 @@ interface WebsiteServiceInterface
     
     public function getWebsiteRoute(array $data): array;
 
+
     public function getFooterCategoryList(array $data): array;
     public function getFooterContentList(array $data): array;
     public function getFooterContentInfo(array $data): array;
 
+
+    // --自助建站-----------20250522fr----------------------start
+    public function getStaticResourceList(array $data): array;
+    public function addStaticResource(array $data): array;
+    public function delStaticResource(array $data): array;
+    public function getStaticResourceInfo(array $data): array;
 }

+ 27 - 0
app/Model/Book.php

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

+ 31 - 0
app/Model/Complaint.php

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

+ 29 - 0
app/Model/Good.php

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

+ 27 - 0
app/Model/JobHunting.php

@@ -0,0 +1,27 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class JobHunting extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'job_hunting';
+
+    /**
+     * 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/JobRecruiting.php

@@ -0,0 +1,27 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class JobRecruiting extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'job_recruiting';
+
+    /**
+     * 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/Notice.php

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

+ 29 - 0
app/Model/Order.php

@@ -0,0 +1,29 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class Order extends Model
+{
+
+    public bool $timestamps = true;
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'order';
+
+    /**
+     * 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/WebsiteImg.php

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

+ 47 - 25
app/Tools/Result.php

@@ -1,26 +1,48 @@
-<?php
-namespace App\Tools;
-use App\Constants\ErrorCode;
-class Result
-{
-    public static function success($data = [])
-    {
-        return static::result(ErrorCode::SUCCESS, ErrorCode::getMessage(ErrorCode::SUCCESS), $data);
-    }
-    public static function error($message = '', $code = ErrorCode::ERROR, $data = [])
-    {
-        if (empty($message)) {
-            return static::result($code, ErrorCode::getMessage($code), $data);
-        } else {
-            return static::result($code, $message, $data);
-        }
-    }
-    protected static function result($code, $message, $data)
-    {
-        return [
-            'code' => $code,
-            'message' => $message,
-            'data' => $data,
-        ];
-    }
+<?php
+namespace App\Tools;
+use App\Constants\ErrorCode;
+class Result
+{
+    public static function success($data = [])
+    {
+        return static::result(ErrorCode::SUCCESS, ErrorCode::getMessage(ErrorCode::SUCCESS), $data);
+    }
+    public static function error($message = '', $code = ErrorCode::ERROR, $data = [])
+    {
+        if (empty($message)) {
+            return static::result($code, ErrorCode::getMessage($code), $data);
+        } else {
+            return static::result($code, $message, $data);
+        }
+    }
+    protected static function result($code, $message, $data)
+    {
+        return [
+            'code' => $code,
+            'message' => $message,
+            'data' => $data,
+        ];
+    }
+    /**
+     * 递归查询
+     * @param $menuItems
+     * @param $parentId
+     * @return array
+     */
+    public static  function buildMenuTree($menuItems, $parentId = 0) {
+        $tree = [];
+        foreach ($menuItems as $item) {
+            if ($item['pid'] == $parentId) {
+                // 找到子菜单
+                $children = self::buildMenuTree($menuItems, $item['category_id']);
+                // 如果子菜单存在,则添加到当前菜单的children中
+                if ($children) {
+                    $item['children'] = $children;
+                }
+                // 将当前菜单添加到树中
+                $tree[] = $item;
+            }
+        }
+        return $tree;
+    }
 }

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 0
runtime/container/scan.cache


+ 0 - 1
runtime/hyperf.pid

@@ -1 +0,0 @@
-19507

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác