Pārlūkot izejas kodu

Merge branch 'master' of http://git.bjzxtw.org.cn:3000/zxt/public_producer

LiuJ 1 dienu atpakaļ
vecāks
revīzija
724da2abea
2 mainītis faili ar 150 papildinājumiem un 51 dzēšanām
  1. 111 51
      app/JsonRpc/PublicRpcService.php
  2. 39 0
      app/JsonRpc/WebsiteService.php

+ 111 - 51
app/JsonRpc/PublicRpcService.php

@@ -903,8 +903,12 @@ class PublicRpcService implements PublicRpcServiceInterface
         if (!empty($rector)) {
             return Result::error("此皮肤已被绑定通栏,不可删除", 0);
         }
-        $template = WebsiteTemplateInfo::where('template_id', $data['id'])->first();
-        if (empty($template)) {
+        $template = Template::where('id', $data['id'])->first();
+        if(empty($template)){
+            return Result::error("此皮肤不存在!", 0);
+        }
+        $web_template = WebsiteTemplateInfo::where('template_id', $template['template_id'])->first();
+        if (!empty($web_template)) {
             return Result::error("此皮肤已被绑定网站,不可删除", 0);
         }
         if ($template->type == 1) {
@@ -1043,13 +1047,34 @@ class PublicRpcService implements PublicRpcServiceInterface
 
     public function getSectorInfo(array $data): array
     {
-        $where = [];
+        // $where = [];
         $where[] = ['sector.id', '=', $data['id']];
         $result = Sector::where($where)
-            ->leftJoin('size', 'size.id', '=', 'sector.size_id')
-            ->select('sector.*', 'size.width', 'size.height')
+            ->leftJoin('template', 'template.template_id', '=', 'sector.template_id')
+            ->select('sector.*','template.template_name','template.template_id')
             ->orderBy('sector.id', 'desc')
             ->first();
+         $result['component'] = SectorComponent::where('sector_component.sector_id', $data['id'])
+        ->leftJoin('component', 'component.component_type', '=', 'sector_component.component_id')
+        ->select('component.component_type','sector_component.sort_id','component.component_name')
+        ->get()->all();
+
+        // $sorts = array_values(array_unique(array_column($components, 'sort_id')));
+        // $result['component'] = $components;
+        $result['place'] = SectorPlace::where('sector_place.sector_type', $result['place_type'])
+        ->where('sector_place.type_id',1)
+        ->select('sector_place.sector_img','sector_place.map')
+        ->first();
+        // $key_num = 0;
+        // foreach($result['place'] as $key => $value){
+        //     if($value['type_id'] == 1){
+        //         $sector_place['sector_plate'] = $value;
+        //     }else{
+        //         $sector_place['component_place'][$key_num] = $value;
+        //         $key_num++;
+        //     }
+        // }
+        // $result['place'] = $sector_place;
         if (empty($result)) {
             return Result::error('此通栏不存在!');
         }
@@ -1319,7 +1344,7 @@ class PublicRpcService implements PublicRpcServiceInterface
         $data['sector_code'] = json_encode($sector_code);
         Db::beginTransaction();
         try {
-            $com_sector = SectorComponent::where('sector_id', $data['sector_id'])->pluck('component_id');
+            $com_sector = SectorComponent::where('sector_id', $sector['sector_id'])->pluck('component_id');
             if(empty($com_sector)){
                 Db::rollBack();
                 return Result::error('通栏解除组件关联失败!');
@@ -1329,7 +1354,7 @@ class PublicRpcService implements PublicRpcServiceInterface
             //         Db::rollBack();
             //         return Result::error('通栏解除组件关联失败!');
             // }
-            $del_SectorComponent = SectorComponent::where('sector_id', $data['sector_id'])->delete();
+            $del_SectorComponent = SectorComponent::where('sector_id', $sector['sector_id'])->delete();
             if(empty($del_SectorComponent)){
                 Db::rollBack();
                 return Result::error('通栏解除组件关联失败!');
@@ -1961,28 +1986,54 @@ class PublicRpcService implements PublicRpcServiceInterface
         // return Result::success($data);
         // 1:首页 2:频道页 3:列表页 4:详情页 5:搜索页 6:特殊列表 7:特殊详情页'
         if ($data['is_search'] == 1) {
-            $page_type = json_encode([1, 2, 3, 4, 5, 6, 7]);
+            $page_type = json_encode([1,2,3,4,5,6,7]);
         } else {
-            $page_type = json_encode([1, 2, 3, 4, 6, 7]);
+            $page_type = json_encode([1,2,3,4,6,7]);
         }
         // 0:未构建;1:已填写基础信息;2:已选择模板;    action_id
         $website_template_info = WebsiteTemplateInfo::where('website_id', $data['website_id'])->first();
-        // return Result::success($website_template_info);
-
-        // return Result::success(empty($website_template_info));
-        if (empty($website_template_info)) {
-            $result = WebsiteTemplateInfo::insertGetId(['website_id' => $data['website_id'], 'page_type' => $page_type, 'user_id' => $data['user_id']]);
-        } else {
-            if ($website_template_info['status'] == 2) {
-                return Result::error('网站已应用,不可再次修改!');
+        $website_template = WebsiteTemplate::where('website_id', $data['website_id'])->first();
+        Db::beginTransaction();
+        try{
+            if (empty($website_template_info)) {
+                $result['template_info'] = WebsiteTemplateInfo::create([
+                    'website_id' => $data['website_id'],
+                    'page_type' => $page_type,
+                    'user_id' => $data['user_id']
+                ])->id;
+            } else {
+                if ($website_template_info['status'] == 2) {
+                    Db::rollBack();
+                    return Result::error('网站已应用,不可再次修改!');
+                }
+                $result['template_info'] = WebsiteTemplateInfo::where('website_id', $data['website_id'])->update(['page_type' => $page_type, 'action_id' => 1, 'user_id' => $data['user_id']]);
             }
-            $result = WebsiteTemplateInfo::where('website_id', $data['website_id'])->update(['page_type' => $page_type], ['action_id' => 1, 'user_id' => $data['user_id']]);
-        }
-        if ($result) {
+            if (!$result['template_info']) {
+                Db::rollBack();
+                return Result::error('网站所选页面添加失败');
+            }
+            if(empty($website_template)){
+                $result['template'] = WebsiteTemplate::insertGetId([
+                    'website_id' => $data['website_id'],
+                    'page_type' => $page_type,
+                    'user_id' => $data['user_id'],
+                ]);
+            }else{
+                $result['template'] = WebsiteTemplate::where('website_id', $data['website_id'])->update([
+                    'page_type' => $page_type,
+                ]);
+            }
+            if(!$result['template']){
+                Db::rollBack();
+                return Result::error('添加网站预制模版信息失败!');
+            }
+            Db::commit();
             return Result::success($result);
-        } else {
+        }catch(\Exception $e){
+            Db::rollBack();
             return Result::error('添加失败');
         }
+        
     }
     /**
      * 自助建站---流程---3.选择皮肤列表
@@ -2067,10 +2118,25 @@ class PublicRpcService implements PublicRpcServiceInterface
             return Result::error('未查询到皮肤!');
         }
         // 0:未构建;1:已填写基础信息;2:已选择模板;    action_id
-        $web_template = WebsiteTemplateInfo::where('website_id', $data['website_id'])->update(['template_id' => $data['template_id'], 'action_id' => 2]);
-        if ($web_template) {
-            return Result::success($web_template);
-        } else {
+        // 分别更新 WebsiteTemplateInfo 和 WebsiteTemplate 表
+        Db::beginTransaction();
+        try {
+            $reuslt['template_info'] = WebsiteTemplateInfo::where('website_id', $data['website_id'])
+            ->update(['template_id' => $data['template_id'],'action_id' => 2,'user_id'=> $data['user_id']]);
+            if(empty($reuslt['template_info'])){
+                Db::rollBack();
+                return Result::error('选择皮肤失败!');
+            }
+            $result['template'] = WebsiteTemplate::where('website_id', $data['website_id'])
+            ->update(['template_id' => $data['template_id'],'user_id'=> $data['user_id']]);
+            if(empty($result['template'])){
+                Db::rollBack();
+                return Result::error('网站模版选择皮肤失败!');
+            }
+            Db::commit();
+            return Result::success($result);
+        } catch (\Exception $e) {
+            Db::rollBack();
             return Result::error('选择皮肤失败!');
         }
     }
@@ -2098,22 +2164,14 @@ class PublicRpcService implements PublicRpcServiceInterface
         try {
             Db::beginTransaction();
             if (empty($template_info)) {
-                $template = WebsiteTemplate::insertGetId([
-                    'website_id' => $data['website_id'],
-                    'template_data' => $data['template_data'],
-                    'user_id' => $data['user_id'],
-                    'canvas_data' => $data['canvas_data'],
-                    'page_type' => $website_template_info['page_type'],
-                    'template_id' => $website_template_info['template_id'],
-                ]);
+                Db::rollback();
+                return Result::error('该网站不存在已保存的模版!');
             } else {
                 $template = WebsiteTemplate::where('website_id', $data['website_id'])->update(
                     [
                         'template_data' => $data['template_data'],
                         'user_id' => $data['user_id'],
                         'canvas_data' => $data['canvas_data'],
-                        'page_type' => $website_template_info['page_type'],
-                        'template_id' => $website_template_info['template_id'],
                     ]
                 );
             }
@@ -2124,7 +2182,7 @@ class PublicRpcService implements PublicRpcServiceInterface
                 $tempalte_info = WebsiteTemplateInfo::where('website_id', $data['website_id'])->update(['status' => 1]);
                 if (empty($tempalte_info)) {
                     Db::rollback();
-                    return Result::error('保存失败!');
+                    return Result::error('网站搭建状态保存失败!');
                 }
                 Db::commit();
             }
@@ -2146,9 +2204,11 @@ class PublicRpcService implements PublicRpcServiceInterface
         }
         $template = WebsiteTemplate::where('website_id', $data['website_id'])
             ->first(['website_id', 'template_id', 'page_type', 'template_data', 'canvas_data']);
+       
         if (empty($template)) {
             return Result::error('未查询到模版!');
         }
+         $template['page_type'] = json_decode($template['page_type'],true);
         return Result::success($template);
     }
 
@@ -2171,20 +2231,21 @@ class PublicRpcService implements PublicRpcServiceInterface
             array_push($where,['sector_place.name', 'like', '%'.$data['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'].'%')->pluck('id');
+            array_push($where,['sector_place.width','like','%'.$data['width'].'%']);
+            array_push($where,['sector_place.height','like','%'.$data['height'].'%']);
         } else if( isset($data['width']) && !empty($data['width'])){
-            $size_id = Size::where('width','like','%' .$data['width'].'%')->pluck('id');
+            array_push($where,['sector_place.width','like','%'.$data['width'].'%']);
         }else if( isset($data['height']) && !empty($data['height'])){
-            $size_id = Size::where('height','like','%' .$data['height'].'%')->pluck('id');
+            array_push($where,['sector_place.height','like','%'.$data['height'].'%']);
         }else{
             $size_id = [];
         }
         $sector_place = SectorPlace::where($where)
-            ->when(!empty($size_id), function ($query) use ($size_id) {
-                $query->whereIn('sector_place.size_id', $size_id);
-            })
-            ->leftJoin('size','sector_place.size_id','=','size.id')
-            ->select('sector_place.*','size.width','size.height');
+            // ->when(!empty($size_id), function ($query) use ($size_id) {
+            //     $query->whereIn('sector_place.size_id', $size_id);
+            // })
+            // ->leftJoin('size','sector_place.size_id','=','size.id')
+            ->select('sector_place.*');
         $result['count'] = $sector_place->count();
         $result['row'] =$sector_place->paginate($data['page_size'], ['*'], 'page', $data['page']);
         if(empty($result['count'])){
@@ -2409,7 +2470,9 @@ class PublicRpcService implements PublicRpcServiceInterface
             $where['component_num'] = $data['component_num'];
         }
        $sector_place = SectorPlace::where($where)
-    //    ->select('sector_place.*','size.width','size.height')
+       ->when($data['type_id'] == 2, function($query) use($data){
+            $query->orderBy('sort_id','asc');
+       })
        ->get()->all();
        if($data['type_id'] == 2){
            foreach($sector_place as $key => $value){
@@ -2461,7 +2524,7 @@ class PublicRpcService implements PublicRpcServiceInterface
             $sector['sector_component.sector_id'] = $data['sector_id'];
             $sector['sector_component.sort_id'] = $data['sort_id'];
             $where = SectorComponent::where($sector)->pluck('component_id')->toArray();
-            $component = Component::whereIn('id',$where)->get()->all();
+            $component = Component::whereIn('component_type',$where)->get()->all();
         }else{
             if(isset($data['type_id']) && !empty($data['type_id'])){
                 $where['component.type_id'] = $data['type_id'];
@@ -2495,12 +2558,9 @@ class PublicRpcService implements PublicRpcServiceInterface
         if(isset($data['page_type']) && !empty($data['page_type'])){
             array_push($where,['page_type', 'like', '%'.$data['page_type'].'%']);
         }
-        if(isset($data['status']) && !empty($data['status'])){
-            array_push($where,['status','!=',0]);
-        }
         $sector = Sector::where($where)
-        ->leftJoin('size','sector.size_id','=','size.id')
-        ->select('sector.*','size.width','size.height')
+        // ->leftJoin('size','sector.size_id','=','size.id')
+        ->select('sector.*')
         ->get()->all();
         if(empty($sector)){
             return Result::error('通栏不存在!');

+ 39 - 0
app/JsonRpc/WebsiteService.php

@@ -3099,6 +3099,45 @@ class WebsiteService implements WebsiteServiceInterface
         }
         return Result::success($result);
     }
+    /**
+     * 自助建站-修改网站应用状态
+     * @param array $data
+     */
+    public function upWebsiteStatus(array $data): array
+    {
+        $where = [
+            'website_id' => $data['website_id'],
+        ];
+        $website_template = WebsiteTemplate::where($where)->first();
+        unset($data['website_id']);
+        if($data['status'] == 2){
+            $template_status = 6;
+        }else{
+            $template_status = 1;
+
+        }
+        if (empty($website_template)) {
+            return Result::error("网站预制模板获取失败", 0);
+        } else {
+            Db::beginTransaction();
+            try {
+                $result['website_template'] = WebsiteTemplate::where($where)->update(['status'=>$template_status]);
+                if (empty($result['website_template'])) {
+                    return Result::error("修改网站模板状态失败", 0);
+                }
+                $result['website_template_info'] = WebsiteTemplateInfo::where($where)->update(['status'=>$data['status']]);
+                if (empty($result['website_template_info'])) {
+                    return Result::error("修改网站基础信息状态失败", 0);
+                }
+                Db::commit();
+                return Result::success($result);
+            } catch (\Exception $e) {
+                Db::rollBack();
+                return Result::error($e->getMessage(), 0);
+            }
+        }
+    }
+
     // --自助建站-----------20250522fr----------------------end
 
     /**