Bläddra i källkod

Merge branch 'web_sannong_fr' into dev

15313670163 2 månader sedan
förälder
incheckning
93d496c9e9
1 ändrade filer med 64 tillägg och 101 borttagningar
  1. 64 101
      app/JsonRpc/WebsiteService.php

+ 64 - 101
app/JsonRpc/WebsiteService.php

@@ -32,7 +32,7 @@ use Hamcrest\Arrays\IsArray;
 use PhpParser\Node\Stmt\Return_;
 use App\Model\WebsiteGroup;
 use function PHPUnit\Framework\isNull;
-
+use App\Model\Component;
 // use Illuminate\Support\Facades\DB;
 #[RpcService(name: "WebsiteService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
 class WebsiteService implements WebsiteServiceInterface
@@ -471,8 +471,7 @@ class WebsiteService implements WebsiteServiceInterface
     public function getWebsiteCategory(array $data): array
     {
         $where = [
-            'website_id' => $data['website_id'],
-            'pid' => 0,
+            'website_id'=>$data['website_id']
         ];
         $result = WebsiteCategory::where($where)->orderBy('sort', 'asc')->get();
         if (empty($result)) {
@@ -1709,69 +1708,70 @@ class WebsiteService implements WebsiteServiceInterface
             Db::rollBack();
             var_dump($ex->getMessage());
             return Result::error("创建失败",0);
-        $website = Website::where('website.id',$data['website_id'])->first();
-        if(empty($website)){
-            return Result::error("请输入正确的网站id!", 0);
-        }
-        if(empty($website['website_column_id'])){
-            return Result::error("请先关联导航池!", 0);
-        }
-         // 获取此网站的底部导航  类型   type:  0:内容型底部导航(只有一条详情内容);1:列表型底部导航(可以有多条详情内容)
-         $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;
-         }
-         $result['foot_type'] = $foot_type;
-         //  友情链接类型'1:图片 2:文字 3:底部';
-         $types = Link::where('website_id', $data['website_id'])->pluck('type')->toArray();
-         $missingTypes = [];
-         if (!in_array(1, $types)) {
-             $missingTypes[] = "文字链接";
-         }
-         if (!in_array(2, $types)) {
-             $missingTypes[] = "图片链接";
-         }
-         if (!in_array(3, $types)) {
-             $missingTypes[] = "底部链接";
-         }
-         if (!empty($missingTypes)) {
-             $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']);
-            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());
+            $website = Website::where('website.id',$data['website_id'])->first();
+            if(empty($website)){
+                return Result::error("请输入正确的网站id!", 0);
+            }
+            if(empty($website['website_column_id'])){
+                return Result::error("请先关联导航池!", 0);
+            }
+            // 获取此网站的底部导航  类型   type:  0:内容型底部导航(只有一条详情内容);1:列表型底部导航(可以有多条详情内容)
+            $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;
+            }
+            $result['foot_type'] = $foot_type;
+            //  友情链接类型'1:图片 2:文字 3:底部';
+            $types = Link::where('website_id', $data['website_id'])->pluck('type')->toArray();
+            $missingTypes = [];
+            if (!in_array(1, $types)) {
+                $missingTypes[] = "文字链接";
+            }
+            if (!in_array(2, $types)) {
+                $missingTypes[] = "图片链接";
+            }
+            if (!in_array(3, $types)) {
+                $missingTypes[] = "底部链接";
+            }
+            if (!empty($missingTypes)) {
+                $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']);
+                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);
                         }
-                        return Result::error("添加失败!", 0);
-                    }
+                    } else {
+                        return Result::error("该网站已经构建过了!", 0);
+                    } 
                 } else {
-                    return Result::error("该网站已经构建过了!", 0);
-                } 
-            } else {
-                return Result::error("请先选择首页和底部导航详情页!", 0);
+                    return Result::error("请先选择首页和底部导航详情页!", 0);
+                }
             }
         }
         if(empty($result)){
@@ -1815,10 +1815,6 @@ class WebsiteService implements WebsiteServiceInterface
                 return $adList;
             }
         }
-    }
-    /**
-     * 预览网站首页模板数据
-     * @param array $data
     }
      /**
      * 获取网站基础信息
@@ -2250,39 +2246,6 @@ class WebsiteService implements WebsiteServiceInterface
         return Result::success();
 
 
-    }
-    //获取传过来的广告列表
-    public function getAdlist($templateList)
-    {
-        if($templateList){
-            $adList = [];
-            foreach ($templateList as $val){
-                if($val){
-                    foreach ($val as $v){
-                        if($v['componentList']){
-                            foreach ($v['componentList'] as $p){
-                                if($p['component_type']==3){
-//                                            var_dump("ppppppppppppp:",$p);
-                                    $adSizeInfo = AdSize::where(['width'=>$p['componentData']['width'],'height'=>$p['componentData']['height']])->first();
-                                    $adSizeInfo = $adSizeInfo->toArray();
-                                    $adData = [
-                                        'website_id'=> $data['webSiteData']['base']['websiteId'],
-                                        'status'=>1,
-                                        'name'=>$p['componentData']['text'],
-                                        'ad_id'=>$p['componentData']['ad_id'],
-                                        'ad_size_id'=>$adSizeInfo['id'],
-                                    ];
-                                    array_push($adList,$adData);
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-            if(count($adList)>0){
-                return $adList;
-            }
-        }
     }
     /**
      * 预览网站首页模板数据