Просмотр исходного кода

微调获取皮肤列表及皮肤详情的接口;相关通栏管理的接口进行修改;验证自助建站相关搭建、编辑的流程;

15313670163 1 день назад
Родитель
Сommit
a2b1d9b006

+ 62 - 5
app/JsonRpc/PublicRpcService.php

@@ -787,13 +787,16 @@ class PublicRpcService implements PublicRpcServiceInterface
         return Result::success($result);
     }
     /**
-     * 获取getTemplateClass
+     * 根据风格名称-获取获取所有风格
      * @param array $data
      * @return array
      */
     public function getTemplateClass(array $data): array
     {
-        $result = TemplateClass::get();
+        $result = TemplateClass::where('name','like','%'.$data['template_name'].'%')->get();
+        if(empty($result)){
+            return Result::error("暂无风格", 0);
+        }
         return Result::success($result);
     }
     /**
@@ -911,6 +914,19 @@ class PublicRpcService implements PublicRpcServiceInterface
             return Result::success('更新成功');
         }
     }
+    /**
+     * 根据皮肤名称-获取所有皮肤
+     * @param array $data
+     * @return array
+     */
+    public function getAllTemplate(array $data): array
+    {
+        $result = Template::where('template_name','like','%'.$data['template_name'].'%')->get();
+        if(empty($result)){
+            return Result::error("暂无皮肤", 0);
+        }
+        return Result::success($result);
+    }
     /**
      * 获取通栏列表
      * @param array $data
@@ -929,11 +945,11 @@ class PublicRpcService implements PublicRpcServiceInterface
             array_push($where, ['sector.sector_name', 'like', '%' . $data['sector_name'] . '%']);
         }
         if (isset($data['width']) && !empty($data['width']) && isset($data['height']) && !empty($data['height'])){
-            $size_id = Size::where('width','like','%' .$data['width'].'%')->where('height','like','%' .$data['height'].'%')->value('id')->all();
+            $size_id = Size::where('width','like','%' .$data['width'].'%')->where('height','like','%' .$data['height'].'%')->pluck('id');
         } else if( isset($data['width']) && !empty($data['width'])){
-            $size_id = Size::where('width','like','%' .$data['width'].'%')->value('id')->all();
+            $size_id = Size::where('width','like','%' .$data['width'].'%')->pluck('id');
         }else if( isset($data['height']) && !empty($data['height'])){
-            $size_id = Size::where('height','like','%' .$data['height'].'%')->value('id')->all();
+            $size_id = Size::where('height','like','%' .$data['height'].'%')->pluck('id');
         }else{
             $size_id = [];
         }
@@ -1052,8 +1068,27 @@ class PublicRpcService implements PublicRpcServiceInterface
     public function addSector(array $data): array
     {
         unset($data['user_id']);
+        // 对传入的 page_type 数组进行去重、转换为整数并重新索引
         $data['page_type'] = array_values(array_unique(array_map('intval', $data['page_type'])));
         $data['page_type'] = json_encode($data['page_type']);
+        $template = Template::where('template_id', $data['template_id'])
+            ->whereRaw("JSON_CONTAINS(template.page_type, ?)", [$data['page_type']])
+            ->first();
+        if(empty($template)){
+            return Result::error('皮肤不存在!');
+        }
+        // 皮肤相关信息
+        $data['template_name'] = $template['template_name'];
+        $data['template_id'] = $template['template_id'];
+        // 风格相关信息
+        $template_class = TemplateClass::where('class_id',$template['template_class_id'])->first();
+        if(empty($template_class)){
+            return Result::error('所属风格不存在!');
+        }
+        // $data['sector_keyword'] = json_encode($data['sector_keyword']);
+       $data['template_class_id'] = $template_class['class_id'];
+       $data['template_class_name'] = $template_class['name'];
+
         $result = Sector::insertGetId($data);
         if(empty($result)){
             return Result::error('添加失败');
@@ -1086,8 +1121,30 @@ class PublicRpcService implements PublicRpcServiceInterface
     public function updateSector(array $data): array
     {
         unset($data['user_id']);
+        $sector = Sector::where('id', $data['id'])->first();
+        if(empty($sector)){
+            return Result::error('通栏不存在!');
+        }
+        // 对传入的 page_type 数组进行去重、转换为整数并重新索引
         $data['page_type'] = array_values(array_unique(array_map('intval', $data['page_type'])));
         $data['page_type'] = json_encode($data['page_type']);
+        $template = Template::where('template_id', $data['template_id'])
+            ->whereRaw("JSON_CONTAINS(template.page_type, ?)", [$data['page_type']])
+            ->first();
+        if(empty($template)){
+            return Result::error('皮肤不存在!');
+        }
+        // 皮肤相关信息
+        $data['template_name'] = $template['template_name'];
+        $data['template_id'] = $template['template_id'];
+        // 风格相关信息
+        $template_class = TemplateClass::where('class_id',$template['template_class_id'])->first();
+        if(empty($template_class)){
+            return Result::error('所属风格不存在!');
+        }
+        // $data['sector_keyword'] = json_encode($data['sector_keyword']);
+       $data['template_class_id'] = $template_class['class_id'];
+       $data['template_class_name'] = $template_class['name'];
         $result = Sector::where('id', $data['id'])->update($data);
         if ($result == 1) {
             return Result::success('修改成功');

+ 1 - 2
app/JsonRpc/PublicRpcServiceInterface.php

@@ -181,6 +181,5 @@ interface PublicRpcServiceInterface
 
     public function chooseWebsiteTemplate(array $data): array;
     public function saveWebsiteTemplate(array $data): array;
-    
-
+    public function getAllTemplate(array $data): array;
 }

+ 25 - 59
app/JsonRpc/WebsiteService.php

@@ -1688,11 +1688,11 @@ class WebsiteService implements WebsiteServiceInterface
     }
 
     /**
-     * 添加网站基础信息
+     * 自助建站-验证搭建网站
      * @param array $data
      * @return array
      */
-    public function addWebsiteTemplateintel(array $data): array
+    public function checkWebsiteBuild(array $data): array
     {
         $website = Website::where('website.id', $data['website_id'])->first();
         if (empty($website)) {
@@ -1705,10 +1705,16 @@ class WebsiteService implements WebsiteServiceInterface
         $foot_type = FooterCategory::where('website_id', $data['website_id'])->pluck('type')->toArray();
         if (empty($foot_type)) {
             return Result::error("请先关联底部导航池!", 0);
-        } elseif (in_array(1, $foot_type)) {
-            $foot_type = 1;
-        } else {
-            $foot_type = 0;
+        }
+        if (!in_array(1, $foot_type) ) {
+            $missingTypes[] = "列表型底部导航";
+        } 
+        if (!in_array(0, $foot_type) ) {
+            $missingTypes[] = "内容型底部导航";
+        } 
+        if (!empty($missingTypes)) {
+            $errorMessage = "请先添加" . implode(" 和 ", $missingTypes) . "!";
+            return Result::error($errorMessage, 0);
         }
         $result['foot_type'] = $foot_type;
         //  友情链接类型'1:图片 2:文字 3:底部';
@@ -1727,70 +1733,30 @@ class WebsiteService implements WebsiteServiceInterface
             $errorMessage = "请先添加 " . implode(" 和 ", $missingTypes) . "!";
             return Result::error($errorMessage, 0);
         }
-        if (isset($data['page_type'])) {
-            // 删除重复元素并重新索引数组
-            $data['page_type'] = array_unique($data['page_type']);
-            $data['page_type'] = array_values($data['page_type']);
-            // 1:首页 2:分类页 3:列表页 4:详情页 5:搜索页 6:特殊列表 7:特殊详情页
-            if (in_array(1, $data['page_type']) && in_array(7, $data['page_type'])) {
-                // 数组中同时包含值为 1(首页) 和值为 7 (底部导航详情页)的元素
-                $info = WebsiteTemplateInfo::where('website_id', $data['website_id'])->first();
-                if (empty($info)) {
-                    // 将数组转换为 JSON 字符串
-                    $data['page_type'] = json_encode($data['page_type']) ?? '';
-                    // 操作状态:1:填写完成基础信息;2:选择完成模板;0:未构建
-                    $data['action_id'] = 1;
-                    try {
-                        $result = WebsiteTemplateInfo::insertGetId($data);
-                    } catch (\Exception $e) {
-                        if ($e->getCode() == 22001) {
-                            $errorMessage = $e->getMessage();
-                            return Result::error("请检查表单,某个字段超出了长度限制!");
-                        } else {
-                            // 处理其他类型的数据库错误
-                            return Result::error("插入操作失败: " . $e->getMessage());
-                        }
-                        return Result::error("添加失败!", 0);
-                    }
-                } else {
-                    return Result::error("该网站已经构建过了!", 0);
-                }
-            } else {
-                return Result::error("请先选择首页和底部导航详情页!", 0);
-            }
-        }
-        if (empty($result)) {
-            return Result::error("添加失败!", 0);
-        } else {
-            return Result::success($result);
-        }
+        return Result::success($result);
     }
     /**
-     * 获取网站基础信息
+     * 自助建站-验证编辑网站
      * @return array
      * 
      */
-    public function getWebsiteTemplateintel(array $data): array
+    public function checkWebsiteEdit(array $data): array
     {
 
-        $result = WebsiteTemplateInfo::where('website_template_info.website_id', $data['website_id'])
-            ->leftJoin('footer_category', 'footer_category.website_id', 'website_template_info.website_id')
-            ->leftJoin('website', 'website.id', 'website_template_info.website_id')
-            ->select(
-                "website_template_info.*",
-                "footer_category.type",
-                "website.website_name",
-                "website.id as website_id"
-            )
-            ->first();
-        if (empty($result['website_name'])) {
+        $result = WebsiteTemplateInfo::where('website_template_info.website_id', $data['website_id'])->first();
+        if (empty($result)) {
             return Result::error("请输入正确的网站id!", 0);
         }
-        if ($result) {
+        // 订单状态:1:通过;2:驳回;3:撤回;4:修改;5:过期;6:待审核;7:结束
+        $order = Order::where('website_id', $data['website_id'])->where('status', 1)->first();
+        if(!empty($order)){
+            return Result::error("此网站的广告位正在使用中,暂不可编辑!", 0);
+        }
+        if ($result['page_type']) {
             $result['page_type'] = json_decode($result['page_type'], true);
-            return Result::success($result);
+            return Result::success('网站编辑验证通过!');
         } else {
-            return Result::error("请先添加网站基础信息!", 0);
+            return Result::error("请先选择网站页面类型!", 0);
         }
     }
     /**

+ 2 - 2
app/JsonRpc/WebsiteServiceInterface.php

@@ -114,8 +114,8 @@ interface WebsiteServiceInterface
 
     // --自助建站-----------fr----------------------start
     public function getWebsiteintel(array $data): array;
-    public function addWebsiteTemplateintel(array $data): array;
-    public function getWebsiteTemplateintel(array $data): array;
+    public function checkWebsiteBuild(array $data): array;
+    public function checkWebsiteEdit(array $data): array;
     public function upWebsiteTemplateintel(array $data): array;
     public function getAllTemplateClass(array $data): array;
     public function getWebsiteTemplateList(array $data): array;