作者 张关杰

Merge branch 'develop' of http://47.244.231.31:8099/zhl/globalso-v6 into bate

@@ -55,7 +55,7 @@ class UpdateRoute extends Command @@ -55,7 +55,7 @@ class UpdateRoute extends Command
55 */ 55 */
56 public function handle(){ 56 public function handle(){
57 $projectModel = new Project(); 57 $projectModel = new Project();
58 - $list = $projectModel->list(['is_upgrade'=>0,'delete_status'=>0,'id'=>['<',500]]); 58 + $list = $projectModel->list(['id'=>645]);
59 $data = []; 59 $data = [];
60 foreach ($list as $v){ 60 foreach ($list as $v){
61 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; 61 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
@@ -291,7 +291,7 @@ class WebTraffic extends Command @@ -291,7 +291,7 @@ class WebTraffic extends Command
291 }else{ 291 }else{
292 //大于9个月项目 292 //大于9个月项目
293 $startTime = Carbon::now()->addMonths(-9)->startOfDay()->toDateTimeString(); 293 $startTime = Carbon::now()->addMonths(-9)->startOfDay()->toDateTimeString();
294 - $query->whereBetween('pdo.start_date', '<', $startTime); 294 + $query->where('pdo.start_date', '<', $startTime);
295 } 295 }
296 })->select('pdo.project_id')->forPage($page, 500)->get(); 296 })->select('pdo.project_id')->forPage($page, 500)->get();
297 //其他地方在引流的域名 297 //其他地方在引流的域名
@@ -727,7 +727,7 @@ class Translate @@ -727,7 +727,7 @@ class Translate
727 * @return \Illuminate\Http\Client\Response 727 * @return \Illuminate\Http\Client\Response
728 * @time 2022/3/30 15:58 728 * @time 2022/3/30 15:58
729 */ 729 */
730 - public static function translate($texts, $tls) 730 + public static function translate($texts, $tls, $sl = 'auto')
731 { 731 {
732 $action = 'translates'; 732 $action = 'translates';
733 if (is_string($texts)) { 733 if (is_string($texts)) {
@@ -738,7 +738,7 @@ class Translate @@ -738,7 +738,7 @@ class Translate
738 } 738 }
739 $data = [ 739 $data = [
740 'texts' => $texts, 740 'texts' => $texts,
741 - 'sl' => 'auto', 741 + 'sl' => $sl,
742 'tls' => $tls, 742 'tls' => $tls,
743 ]; 743 ];
744 return http_post(self::$url.$action, json_encode($data),self::$header); 744 return http_post(self::$url.$action, json_encode($data),self::$header);
@@ -213,7 +213,7 @@ class OptimizeController extends BaseController @@ -213,7 +213,7 @@ class OptimizeController extends BaseController
213 if(isset($this->map['level']) && !empty($this->map['level'])){ 213 if(isset($this->map['level']) && !empty($this->map['level'])){
214 $query = $query->whereRaw("FIND_IN_SET(?, gl_project.level) > 0", [$this->map['level']]); 214 $query = $query->whereRaw("FIND_IN_SET(?, gl_project.level) > 0", [$this->map['level']]);
215 } 215 }
216 - if(isset($this->map['online_updated_at']) && !empty($this->map['online_updated_at'])){ 216 + if(isset($this->map['online_updated_at']) && !empty($this->map['online_updated_at']) && is_array($this->map['online_updated_at'])){
217 $query = $query->whereBetween('gl_project_deploy_optimize.updated_at', $this->map['online_updated_at']); 217 $query = $query->whereBetween('gl_project_deploy_optimize.updated_at', $this->map['online_updated_at']);
218 } 218 }
219 if(isset($this->map['special'])){ 219 if(isset($this->map['special'])){
@@ -300,4 +300,28 @@ class ComController extends BaseController @@ -300,4 +300,28 @@ class ComController extends BaseController
300 } 300 }
301 $this->response('success',Code::SUCCESS,['url'=>$url_link]); 301 $this->response('success',Code::SUCCESS,['url'=>$url_link]);
302 } 302 }
  303 +
  304 + /**
  305 + * @remark :根据手机号码,获取当前号码拥有的所有项目
  306 + * @name :getMobileProject
  307 + * @author :lyh
  308 + * @method :post
  309 + * @time :2024/2/22 9:32
  310 + */
  311 + public function getMobileProject(){
  312 + $data = [];
  313 + $userModel = new User();
  314 + $list = $userModel->list(['mobile'=>$this->user['mobile'],'project_id'=>['!=',$this->user['project_id']]],'id',['id','project_id']);
  315 + if(!empty($list)){
  316 + $projectModel = new Project();
  317 + foreach ($list as $k => $v){
  318 + $projectInfo = $projectModel->read(['id'=>$v['project_id']],['id','company']);
  319 + //获取当前项目详情
  320 + $data[] = ['project_id'=>$projectInfo['id'],'company'=>$projectInfo['company']];
  321 + }
  322 + }
  323 + //登录选择项目的有效时间
  324 + Cache::add('login-project-'.$this->user['mobile'],1,300);
  325 + $this->response('success',Code::SUCCESS,$data);
  326 + }
303 } 327 }
@@ -17,6 +17,7 @@ use App\Models\Product\ExtendInfo; @@ -17,6 +17,7 @@ use App\Models\Product\ExtendInfo;
17 use App\Models\Product\Keyword; 17 use App\Models\Product\Keyword;
18 use App\Models\Product\KeywordRelated; 18 use App\Models\Product\KeywordRelated;
19 use App\Models\Product\Product; 19 use App\Models\Product\Product;
  20 +use App\Models\RouteMap\RouteMap;
20 use App\Models\Template\Setting; 21 use App\Models\Template\Setting;
21 use App\Models\Template\BTemplate; 22 use App\Models\Template\BTemplate;
22 use App\Models\User\User; 23 use App\Models\User\User;
@@ -58,7 +59,7 @@ class ProductController extends BaseController @@ -58,7 +59,7 @@ class ProductController extends BaseController
58 $template_id = $this->getTemplateId(BTemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL);//获取模版id 59 $template_id = $this->getTemplateId(BTemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL);//获取模版id
59 $userModel = new User(); 60 $userModel = new User();
60 foreach ($lists['list'] as $k=>$v){ 61 foreach ($lists['list'] as $k=>$v){
61 - $v['url'] = $this->user['domain'].$v['route'].'/'; 62 + $v['url'] = $this->user['domain'] . getRouteMap(RouteMap::SOURCE_PRODUCT,$v['id']);;
62 $v['category_id_text'] = $this->categoryName($v['category_id'],$cate_data); 63 $v['category_id_text'] = $this->categoryName($v['category_id'],$cate_data);
63 $v['keyword_id_text'] = $this->keywordName($v['keyword_id'],$key_data); 64 $v['keyword_id_text'] = $this->keywordName($v['keyword_id'],$key_data);
64 $v['created_uid_text'] = $userModel->getName($v['created_uid']); 65 $v['created_uid_text'] = $userModel->getName($v['created_uid']);
1 -<?php  
2 -/**  
3 - * @remark :  
4 - * @name :UpdateHtml.php  
5 - * @author :lyh  
6 - * @method :post  
7 - * @time :2024/2/2 10:11  
8 - */  
9 -  
10 -namespace App\Http\Controllers\Html;  
11 -  
12 -use App\Http\Controllers\Controller;  
13 -use App\Models\Com\NoticeLog;  
14 -use App\Models\CustomModule\CustomModule;  
15 -use App\Models\Project\Project;  
16 -use App\Models\RouteMap\RouteMap;  
17 -use App\Models\Service\Service as ServiceSettingModel;  
18 -use App\Models\Template\BTemplate;  
19 -use App\Services\ProjectServer;  
20 -use Illuminate\Support\Facades\DB;  
21 -  
22 -class UpdateHtml extends Controller  
23 -{  
24 - protected $param;  
25 - protected $project_id;  
26 - public function __construct($data){  
27 - $this->param = $data;//Todo::传递的参数  
28 - $this->project_id = $data['project_id'];  
29 - }  
30 -  
31 - /**  
32 - * @remark :更新界面  
33 - * @name :updateHtml  
34 - * @author :lyh  
35 - * @method :post  
36 - * @time :2024/2/2 10:12  
37 - */  
38 - public function updateHtml(){  
39 - ProjectServer::useProject($this->project_id);  
40 - if(isset($this->param['route']) && $this->param['route'] == 'all'){  
41 - //TODO::更新所有界面  
42 - }else{  
43 - //TODO::更新单页  
44 - $routeMapModel = new RouteMap();  
45 - }  
46 - DB::disconnect('custom_mysql');  
47 - }  
48 -  
49 - /**  
50 - * @remark :获取页面是否为 定制/非定制 页面  
51 - * @name :getPageHtmlIsCustomized  
52 - * @param :source:类型;is_list:是否为列表页 1:列表页面  
53 - * @author :lyh  
54 - * @method :post  
55 - * @time :2024/2/2 11:03  
56 - */  
57 - public function getPageHtmlIsCustomized($source,$is_list,$is_custom){  
58 - if($is_custom == BTemplate::IS_CUSTOM){  
59 - $customModuleModel = new CustomModule();  
60 - $info = $customModuleModel->read(['id'=>$source]);  
61 - if($info === false){  
62 - $this->fail('当前扩展模块不存在或已被删除');  
63 - }  
64 - //扩展模块定制  
65 - if($is_list == BTemplate::IS_LIST && $info['list_customized'] == BTemplate::IS_VISUALIZATION){  
66 - return BTemplate::IS_VISUALIZATION;  
67 - }  
68 - if($is_list == BTemplate::IS_DETAIL && $info['detail_customized'] == BTemplate::IS_VISUALIZATION){  
69 - return BTemplate::IS_VISUALIZATION;  
70 - }  
71 - }else{  
72 - $type = $this->getCustomizedType($source, $is_list);//获取定制界面类型  
73 - //查看当前页面是否定制,是否开启可视化  
74 - $page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面  
75 - if (in_array($type, $page_array)) {//是定制界面  
76 - return BTemplate::IS_VISUALIZATION;  
77 - }  
78 - }  
79 - return BTemplate::IS_NO_VISUALIZATION;  
80 - }  
81 -  
82 - /**  
83 - * @remark :获取头部底部公共部分代码  
84 - * @name :getTemplateCommon  
85 - * @author :lyh  
86 - * @method :post  
87 - * @time :2024/2/2 11:02  
88 - */  
89 - public function getTemplateCommon(){  
90 -  
91 - }  
92 -  
93 - /**  
94 - * @remark :获取装修中间内容  
95 - * @name :getTemplateMainHtml  
96 - * @author :lyh  
97 - * @method :post  
98 - * @time :2024/2/2 11:01  
99 - */  
100 - public function getTemplateMainHtml(){  
101 -  
102 - }  
103 -  
104 - /**  
105 - * @remark :获取项目详情  
106 - * @name :getProjectInfo  
107 - * @author :lyh  
108 - * @method :post  
109 - * @time :2024/2/2 10:50  
110 - */  
111 - public function getProjectInfo($project_id){  
112 - $projectModel = new Project();  
113 - $info = $projectModel->read(['id'=>$project_id],['id','is_customized']);  
114 - return $info;  
115 - }  
116 -  
117 - /**  
118 - * @remark :拼接获取公共头部底部  
119 - * @name :getHeadFooter  
120 - * @author :lyh  
121 - * @method :post  
122 - * @time :2023/7/21 17:22  
123 - */  
124 - public function getHeadFooter($html){  
125 - //获取公共主题头部底部  
126 - $serviceSettingModel = new ServiceSettingModel();  
127 - $list = $serviceSettingModel->list(['type'=>2],'created_at');  
128 - //拼接html  
129 - foreach ($list as $v){  
130 - if($v['key'] == 'head'){  
131 - $html = $v['values'].$html;  
132 - }  
133 - if($v['key'] == 'footer'){  
134 - $html = $html.$v['values'];  
135 - }  
136 - }  
137 - return $html;  
138 - }  
139 -  
140 - /**  
141 - * @remark :定制页面头部类型---根据source获取type类型  
142 - * @name :getType  
143 - * @author :lyh  
144 - * @method :post  
145 - * @time :2023/11/16 11:20  
146 - */  
147 - public function getCustomizedType($source,$is_list){  
148 - $type = BTemplate::TYPE_HOME;  
149 - if($source == BTemplate::SOURCE_PRODUCT){  
150 - if($is_list == BTemplate::IS_LIST){  
151 - $type = BTemplate::TYPE_PRODUCT_LIST;  
152 - }else{  
153 - $type = BTemplate::TYPE_PRODUCT_DETAIL;  
154 - }  
155 - }  
156 - if($source == BTemplate::SOURCE_BLOG){  
157 - if($is_list == BTemplate::IS_LIST){  
158 - $type = BTemplate::TYPE_BLOG_LIST;  
159 - }else{  
160 - $type = BTemplate::TYPE_BLOG_DETAIL;  
161 - }  
162 - }  
163 - if($source == BTemplate::SOURCE_NEWS){  
164 - if($is_list == BTemplate::IS_LIST){  
165 - $type = BTemplate::TYPE_NEWS_LIST;  
166 - }else{  
167 - $type = BTemplate::TYPE_NEWS_DETAIL;  
168 - }  
169 - }  
170 - return $type;  
171 - }  
172 -}  
@@ -173,7 +173,7 @@ class BaseLogic extends Logic @@ -173,7 +173,7 @@ class BaseLogic extends Logic
173 $data['project_id'] = $this->user['project_id']; 173 $data['project_id'] = $this->user['project_id'];
174 $str = http_build_query($data); 174 $str = http_build_query($data);
175 $url = $this->user['domain'].'api/delHtml/?'.$str; 175 $url = $this->user['domain'].'api/delHtml/?'.$str;
176 - $rs = shell_exec('curl -k '.$url); 176 + shell_exec('curl -k '.$url);
177 // curlGet($url); 177 // curlGet($url);
178 return $this->success(); 178 return $this->success();
179 } 179 }
@@ -88,7 +88,7 @@ class CountLogic extends BaseLogic @@ -88,7 +88,7 @@ class CountLogic extends BaseLogic
88 * @time :2023/5/24 14:03 88 * @time :2023/5/24 14:03
89 */ 89 */
90 public function keyword_data_count(){ 90 public function keyword_data_count(){
91 - $yesterday = date('Y-m-d'); 91 + $yesterday = Carbon::yesterday()->toDateString();
92 $rankDataModel = new RankDataModel(); 92 $rankDataModel = new RankDataModel();
93 $param = [ 93 $param = [
94 'updated_date' => $yesterday, 94 'updated_date' => $yesterday,
@@ -42,16 +42,19 @@ class WebSettingServiceLogic extends BaseLogic @@ -42,16 +42,19 @@ class WebSettingServiceLogic extends BaseLogic
42 $this->param['data'] = Common::uniqueMultiArray($this->param['data']); 42 $this->param['data'] = Common::uniqueMultiArray($this->param['data']);
43 //删除以前的数据 43 //删除以前的数据
44 $this->model->del(['project_id'=>$this->user['project_id']]); 44 $this->model->del(['project_id'=>$this->user['project_id']]);
  45 + $data = [];
45 foreach ($this->param['data'] as $k => $v){ 46 foreach ($this->param['data'] as $k => $v){
46 - if(!isset($v['values']) || empty($v['values'])){  
47 - $v['values'] = ''; 47 + if(isset($v['values']) && empty($v['values'])){
  48 + $v['project_id'] = $this->user['project_id'];
  49 + $v['created_at'] = date('Y-m-d H:i:s');
  50 + $v['updated_at'] = date('Y-m-d H:i:s');
  51 + $data[] = $v;
48 } 52 }
49 - $v['project_id'] = $this->user['project_id'];  
50 - $v['created_at'] = date('Y-m-d H:i:s');  
51 - $v['updated_at'] = date('Y-m-d H:i:s');  
52 - $this->param['data'][$k] = $v;  
53 } 53 }
54 - $this->model->insert($this->param['data']); 54 + if(!empty($data)){
  55 + $this->model->insert($data);
  56 + }
  57 +
55 DB::commit(); 58 DB::commit();
56 }catch (\Exception $e){ 59 }catch (\Exception $e){
57 DB::rollBack(); 60 DB::rollBack();
@@ -386,4 +386,5 @@ class UserLoginLogic @@ -386,4 +386,5 @@ class UserLoginLogic
386 throw new AsideGlobalException($code, $message); 386 throw new AsideGlobalException($code, $message);
387 } 387 }
388 388
  389 +
389 } 390 }
@@ -55,6 +55,8 @@ class RouteMap extends Base @@ -55,6 +55,8 @@ class RouteMap extends Base
55 public static function generateRoute($title, $source, $source_id, $project_id){ 55 public static function generateRoute($title, $source, $source_id, $project_id){
56 if(preg_match('/[\x{4e00}-\x{9fa5}]/u', $title)){ 56 if(preg_match('/[\x{4e00}-\x{9fa5}]/u', $title)){
57 $title = Translate::tran($title, 'en'); 57 $title = Translate::tran($title, 'en');
  58 + }elseif (preg_match('/[а-яА-Я]/u', $title)) {
  59 + $title = Translate::tran($title, 'en');
58 } 60 }
59 $i=1; 61 $i=1;
60 $sign = generateRoute($title); 62 $sign = generateRoute($title);
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: zhl
  5 + * Date: 2024/2/19
  6 + * Time: 15:46
  7 + */
  8 +namespace App\Services;
  9 +
  10 +class CreateHtmlService
  11 +{
  12 + public function __construct(){}
  13 +
  14 + /**
  15 + * 返回最终需要的HTML
  16 + * @return string
  17 + */
  18 + public function getHtml($project, $route, $lang = [], $page = 0)
  19 + {
  20 + // 获取页面信息
  21 + $page_info = $this->getInfoByRoute($route);
  22 +
  23 + // 根据项目和路由信息返回的结果确定当前页面使用5.0还是6.0的页面;
  24 + if ($project && $page_info) {
  25 + $html = $this->getHtmlV6($page_info['master_lang'], $lang = [], $page = 0);
  26 + } else {
  27 + $html = $this->getHtmlV5();
  28 + }
  29 + return $html;
  30 + }
  31 +
  32 + /**
  33 + * 返回5.0页面最终HTML
  34 + * @return string
  35 + */
  36 + public function getHtmlV5()
  37 + {
  38 + $html = '';
  39 + return $html;
  40 + }
  41 +
  42 + /**
  43 + * 返回6.0页面最终HTML
  44 + * @return mixed
  45 + */
  46 + public function getHtmlV6($master_lang, $lang = [], $page = 0)
  47 + {
  48 + // 初始化后续需要渲染页面需要的数据 路由、主语种、tdk、嵌入等信息
  49 +
  50 + $origin_html = $this->originHtml();
  51 + $html = $this->renderData($origin_html, $page);
  52 + $html = $this->plugHead($html);
  53 + $html = $this->processFinal($html);
  54 + /** ... 调用其他方法, 直至返回完整的正确的HTML */
  55 + return $html;
  56 + }
  57 +
  58 + /**
  59 + * 根据路由信息 返回 路由属性及详细信息
  60 + * @param string $route
  61 + * @return array
  62 + */
  63 + public function getInfoByRoute($route)
  64 + {
  65 + // TODO 获取详情需要通过路由查下路由信息, 以及数据信息, 要处理特殊几个路由: top-search、products、news、blog, 这几个如果存在就用查下的信息, 如果不存在要初始化信息
  66 + return [];
  67 + }
  68 +
  69 + /**
  70 + * 获取可视化HTML
  71 + * @return string
  72 + */
  73 + public function originHtml()
  74 + {
  75 + $html = '根据路由查询数据库,并拼装HTML';
  76 + return $html;
  77 + }
  78 +
  79 + /**
  80 + * 补充其他信息
  81 + * TDK mate信息等
  82 + * @param $html
  83 + * @return mixed
  84 + */
  85 + public function plugHead($html)
  86 + {
  87 + /** 渲染tdk信息、 mate信息、 嵌入信息、 图标信息*/
  88 + return $html;
  89 + }
  90 +
  91 + /**
  92 + * 处理最终信息
  93 + * 处理标签、最后代码标识、特殊规则或者字符等
  94 + * @param string $html
  95 + * @return string
  96 + */
  97 + public function processFinal($html)
  98 + {
  99 + return $html;
  100 + }
  101 +
  102 + /**
  103 + * 渲染页面数据
  104 + * @param string $html
  105 + * @return string
  106 + */
  107 + public function renderData($html, $page)
  108 + {
  109 + /**
  110 + * 根据可视化HTML中关键词渲染数据
  111 + * 这个方法还需要进行拆分, 这个功能内容应该会比较多
  112 + * 并且还会根据路由信息和分页信息不同, 渲染不同数据, 只要针对列表页面
  113 + */
  114 + return $html;
  115 + }
  116 +}
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :GeneratePageService.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/2/19 15:54
  8 + */
  9 +
  10 +namespace App\Services;
  11 +
  12 +use App\Models\CustomModule\CustomModule;
  13 +use App\Models\CustomModule\CustomModuleCategory;
  14 +use App\Models\CustomModule\CustomModuleContent;
  15 +use App\Models\Project\Project;
  16 +use App\Models\RouteMap\RouteMap;
  17 +use App\Models\Template\BTemplate;
  18 +use App\Models\Template\BTemplateCommon;
  19 +use App\Models\Template\BTemplateMain;
  20 +use App\Models\Template\Setting;
  21 +use App\Models\Template\Template;
  22 +use App\Models\Template\TemplateTypeMain;
  23 +use Illuminate\Support\Facades\DB;
  24 +
  25 +class GeneratePageService
  26 +{
  27 + protected $route;
  28 +
  29 + protected $param;
  30 +
  31 + protected $project_id = 0;
  32 + public function __construct(){
  33 + $this->param = request()->all();
  34 + $this->route = $this->param['route'];
  35 + $this->project_id = $this->param['project_id'];
  36 + }
  37 +
  38 + /**
  39 + * @remark :生成单页数据
  40 + * @name :generateHtml
  41 + * @author :lyh
  42 + * @method :post
  43 + * @time :2024/2/19 16:57
  44 + */
  45 + public function generateHtml(){
  46 + ProjectServer::useProject($this->project_id);
  47 + $routeMapModel = new RouteMap();
  48 + $routeInfo = $routeMapModel->read(['route'=>$this->param['route']]);
  49 + if($this->param['route'] != RouteMap::SOURCE_INDEX && $routeInfo['source'] == RouteMap::SOURCE_PAGE){
  50 + //页面管理单独处理
  51 + }else{
  52 + $this->handleParam($routeInfo);
  53 + $this->getTemplateHtml();
  54 + }
  55 + DB::disconnect('custom_mysql');
  56 + return true;
  57 + }
  58 +
  59 + /**
  60 + * @remark :生成页面参数处理
  61 + * @name :generateHtml
  62 + * @author :lyh
  63 + * @method :post
  64 + * @time :2024/2/19 16:36
  65 + */
  66 + public function handleParam($routeInfo){
  67 + switch ($routeInfo['source']){
  68 + case RouteMap::SOURCE_PRODUCT:
  69 + $this->param['source'] = BTemplate::SOURCE_PRODUCT;
  70 + $this->param['is_list'] = BTemplate::IS_DETAIL;
  71 + break;
  72 + case RouteMap::SOURCE_PRODUCT_CATE:
  73 + $this->param['source'] = BTemplate::SOURCE_PRODUCT;
  74 + $this->param['is_list'] = BTemplate::IS_LIST;
  75 + break;
  76 + case RouteMap::SOURCE_BLOG:
  77 + $this->param['source'] = BTemplate::SOURCE_BLOG;
  78 + $this->param['is_list'] = BTemplate::IS_DETAIL;
  79 + break;
  80 + case RouteMap::SOURCE_BLOG_CATE:
  81 + $this->param['source'] = BTemplate::SOURCE_BLOG;
  82 + $this->param['is_list'] = BTemplate::IS_LIST;
  83 + break;
  84 + case RouteMap::SOURCE_NEWS:
  85 + $this->param['source'] = BTemplate::SOURCE_NEWS;
  86 + $this->param['is_list'] = BTemplate::IS_DETAIL;
  87 + break;
  88 + case RouteMap::SOURCE_NEWS_CATE:
  89 + $this->param['source'] = BTemplate::SOURCE_NEWS;
  90 + $this->param['is_list'] = BTemplate::IS_LIST;
  91 + break;
  92 + case RouteMap::SOURCE_MODULE:
  93 + $this->param['is_custom'] = BTemplate::IS_CUSTOM;
  94 + //TODO::获取对应模块数据
  95 + $moduleModel = new CustomModuleContent();
  96 + $moduleInfo = $moduleModel->read(['id'=>$routeInfo['source_id']],['module_id']);
  97 + $this->param['source'] = $moduleInfo['id'] ?? 0;
  98 + $this->param['is_list'] = BTemplate::IS_DETAIL;
  99 + break;
  100 + case RouteMap::SOURCE_MODULE_CATE:
  101 + $this->param['is_custom'] = BTemplate::IS_CUSTOM;
  102 + //TODO::获取对应模块数据
  103 + $moduleModel = new CustomModuleCategory();
  104 + $moduleInfo = $moduleModel->read(['id'=>$routeInfo['source_id']],['module_id']);
  105 + $this->param['source'] = $moduleInfo['id'] ?? 0;
  106 + $this->param['is_list'] = BTemplate::IS_LIST;
  107 + break;
  108 + default:
  109 + $this->param['source'] = BTemplate::SOURCE_HOME;
  110 + $this->param['is_list'] = BTemplate::IS_DETAIL;
  111 + break;
  112 + return true;
  113 + }
  114 + }
  115 +
  116 + /**
  117 + * @notes: 请简要描述方法功能
  118 + * @param array $data
  119 + * @return array
  120 + */
  121 + public function success($data = [])
  122 + {
  123 + return $data;
  124 + }
  125 +
  126 + /**
  127 + * @remark :获取html
  128 + * @name :getTemplateHtml
  129 + * @author :lyh
  130 + * @method :post
  131 + */
  132 + public function getTemplateHtml(){
  133 + $is_custom = $this->param['is_custom'] ?? 0;//是否为扩展模块
  134 + $is_list = $this->param['is_list'] ?? 0;//是否为列表页
  135 + $template_id = $this->getSettingTemplate($this->param['source'],$is_list,$is_custom);//设置的模版id
  136 + $templateInfo = $this->webTemplateInfo($this->param['source'],$this->param['source_id'],$template_id,$is_custom,$is_list);
  137 + if($templateInfo === false){
  138 + if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION){//处理定制页面初始数据
  139 + $html = $this->customizedReturnHtml($this->param['source'],$template_id,$is_custom,$is_list);
  140 + if($html !== false){
  141 + return $this->success($html);
  142 + }
  143 + }
  144 + //非定制初始中间部分
  145 + $mainInfo = $this->getMAinHtml($this->param['source'],$is_custom,$is_list);//获取中间部分代码
  146 + }else{
  147 + if($templateInfo['type'] == BTemplate::ALL_HTML){//返回整个html代码
  148 + return $this->getCustomizeAllHtml($templateInfo,$template_id,$is_custom,$is_list);
  149 + }
  150 + $mainInfo = ['main_html'=>$templateInfo['main_html'], 'main_css'=>$templateInfo['main_css']];
  151 + }
  152 + $commonInfo = $this->getCommonHtml($this->param['source'],$is_list,$template_id,$is_custom);//获取非定制头部
  153 + $html = $commonInfo['head_css'].$mainInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other']. $commonInfo['head_html'].$mainInfo['main_html'].$commonInfo['footer_html'];
  154 + $html = $this->getHeadFooter($html);
  155 + $result = ['html'=>$html,'template_id'=>$template_id];
  156 + return $this->success($result);
  157 + }
  158 +
  159 + /**
  160 + * @remark :获取整个html代码
  161 + * @name :getCustomizeAllHtml
  162 + * @author :lyh
  163 + * @method :post
  164 + * @time :2024/1/10 14:15
  165 + */
  166 + public function getCustomizeAllHtml($templateInfo,$template_id,$is_custom,$is_list){
  167 + if($is_custom == BTemplate::IS_CUSTOM){
  168 + $commonInfo = $this->getCustomizedCommonHtml($this->param['source'],$is_custom,$is_list);//获取定制头部
  169 + $html = $this->handleAllHtml($commonInfo,$templateInfo['html']);
  170 + }else{
  171 + $type = $this->getCustomizedType($this->param['source'],$is_list);
  172 + $commonInfo = $this->getCustomizedCommonHtml($type,$is_custom,$is_list);//获取定制头部
  173 + $html = $this->handleAllHtml($commonInfo,$templateInfo['html']);
  174 + }
  175 + return $this->success(['html'=>$html,'template_id'=>$template_id]);
  176 + }
  177 +
  178 + /**
  179 + * @remark :获取装修详情
  180 + * @name :webTemplateInfo
  181 + * @author :lyh
  182 + * @method :post
  183 + * @time :2024/1/10 13:43
  184 + */
  185 + public function webTemplateInfo($source,$source_id,$template_id,$is_custom,$is_list){
  186 + $templateInfo = $this->model->read([
  187 + 'template_id'=>$template_id, 'source'=>$source,
  188 + 'project_id'=>$this->user['project_id'], 'source_id'=>$source_id,
  189 + 'is_custom'=>$is_custom, 'is_list'=>$is_list
  190 + ]);
  191 + return $this->success($templateInfo);
  192 + }
  193 +
  194 + /**
  195 + * @remark :定制页面获取html
  196 + * @name :customizedReturnHtml
  197 + * @author :lyh
  198 + * @method :post
  199 + * @time :2024/1/10 13:46
  200 + */
  201 + public function customizedReturnHtml($source,$template_id,$is_custom,$is_list){
  202 + //TODO::扩展模块定制单独处理
  203 + if($is_custom == BTemplate::IS_CUSTOM){
  204 + $customModuleModel = new CustomModule();
  205 + $info = $customModuleModel->read(['id'=>$source]);
  206 + if($info === false){
  207 + $this->fail('当前扩展模块不存在或已被删除');
  208 + }
  209 + //扩展模块定制
  210 + if($is_list == BTemplate::IS_LIST && $info['list_customized'] == BTemplate::IS_VISUALIZATION){
  211 + $html = $this->customModuleCustomizeHtml($source,$is_list,$is_custom);
  212 + return $this->success(['html'=>$html,'template_id'=>$template_id]);
  213 + }
  214 + if($is_list == BTemplate::IS_DETAIL && $info['detail_customized'] == BTemplate::IS_VISUALIZATION){
  215 + $html = $this->customModuleCustomizeHtml($source,$is_list,$is_custom);
  216 + return $this->success(['html'=>$html,'template_id'=>$template_id]);
  217 + }
  218 + return false;
  219 + }
  220 + //TODO::默认模块定制
  221 + $html = $this->isCustomizedPage($source,$is_list,$is_custom);//获取定制页面的html
  222 + if(!empty($html)){
  223 + return $this->success(['html'=>$html,'template_id'=>$template_id]);
  224 + }
  225 + return false;
  226 + }
  227 +
  228 + /**
  229 + * @remark :扩展模块定制html
  230 + * @name :customModuleInfo
  231 + * @author :lyh
  232 + * @method :post
  233 + * @time :2024/1/10 9:20
  234 + */
  235 + public function customModuleCustomizeHtml($source,$is_list,$is_custom){
  236 + $bTemplateMainModel = new BTemplateMain();
  237 + //TODO::获取初始代码
  238 + $customHtmlInfo = $bTemplateMainModel->read(['type'=>$source,'is_list'=>$is_list,'is_custom'=>$is_custom]);
  239 + if($customHtmlInfo === false){
  240 + $this->fail('定制页面,请先上传代码块');
  241 + }
  242 + $commonInfo = $this->getCustomizedCommonHtml($source,$is_custom,$is_list);//获取定制头部
  243 + if($commonInfo !== false){
  244 + $customHtmlInfo['main_html'] = $this->handleAllHtml($commonInfo,$customHtmlInfo['main_html']);
  245 + }
  246 + return $customHtmlInfo['main_html'];
  247 + }
  248 +
  249 + /**
  250 + * @remark :获取中间部分的html
  251 + * @name :getMAinHtml
  252 + * @author :lyh
  253 + * @method :post
  254 + * @time :2023/12/27 15:00
  255 + */
  256 + public function getMAinHtml($type,$is_custom,$is_list){
  257 + //获取设置的默认中间部分
  258 + $bTemplateMainModel = new BTemplateMain();
  259 + $mainInfo = $bTemplateMainModel->read(['type'=>$type,'is_list'=>$is_list,'is_custom'=>$is_custom]);
  260 + if($mainInfo === false){
  261 + $main_html = $this->getInitModule($type,$is_custom,$is_list);
  262 + $main_css = "<style id='globalsojs-styles'></style>";
  263 + }else{
  264 + $main_html = $mainInfo['main_html'];
  265 + $main_css = $mainInfo['main_css'];
  266 + }
  267 + return ['main_html'=>$main_html,'main_css'=>$main_css];
  268 + }
  269 +
  270 + /**
  271 + * @remark :默认复合页数据
  272 + * @name :getProductModule
  273 + * @author :lyh
  274 + * @method :post
  275 + * @time :2023/7/27 15:08
  276 + */
  277 + public function getInitModule($type,$is_custom,$is_list){
  278 + if($is_custom == BTemplate::IS_CUSTOM) {
  279 + $type = BTemplate::SOURCE_CUSTOM;
  280 + }
  281 + $mainModel = new TemplateTypeMain();
  282 + $info = $mainModel->read(['type'=>$type,'is_list'=>$is_list]);
  283 + return $info['main_html'];
  284 + }
  285 +
  286 + /**
  287 + * @remark :返回整个html截取代码
  288 + * @name :handleAllHtml
  289 + * @author :lyh
  290 + * @method :post
  291 + * @time :2023/12/13 15:39
  292 + */
  293 + public function handleAllHtml($commonInfo,$html){
  294 + if(!empty($commonInfo)){
  295 + $html = preg_replace('/<header\b[^>]*>(.*?)<\/header>/s', $commonInfo['head_html'], $html);
  296 + $html = preg_replace('/<footer\b[^>]*>(.*?)<\/footer>/s', $commonInfo['footer_html'], $html);
  297 + $html = preg_replace('/<style id="globalsojs-header">(.*?)<\/style>/s', $commonInfo['head_css'], $html);
  298 + $html = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', $commonInfo['footer_css'], $html);
  299 + }
  300 + return $html;
  301 + }
  302 +
  303 + /**
  304 + * @remark :页面是否为定制页面获取初始代码
  305 + * @name :watchProjectIsCustomized
  306 + * @author :lyh
  307 + * @method :post
  308 + * @time :2023/12/13 10:55
  309 + */
  310 + public function isCustomizedPage($source,$is_list,$is_custom)
  311 + {
  312 + $type = $this->getCustomizedType($source, $is_list);//获取定制界面类型
  313 + //查看当前页面是否定制,是否开启可视化
  314 + $page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
  315 + if (in_array($type, $page_array)) {//是定制界面
  316 + //TODO::获取初始代码
  317 + $bTemplateMainModel = new BTemplateMain();
  318 + $customHtmlInfo = $bTemplateMainModel->read(['type'=>$source,'is_custom'=>$is_custom,'is_list'=>$is_list]);
  319 + if($customHtmlInfo === false){
  320 + $this->fail('定制页面,请先上传代码块');
  321 + }
  322 + $commonInfo = $this->getCustomizedCommonHtml($type,$is_custom,$is_list);//获取定制头部
  323 + if($commonInfo !== false){
  324 + $customHtmlInfo['main_html'] = $this->handleAllHtml($commonInfo,$customHtmlInfo['main_html']);
  325 + }
  326 + return $customHtmlInfo['main_html'];
  327 + }
  328 + return false;
  329 + }
  330 +
  331 + /**
  332 + * @remark :定制项目获取头部底部
  333 + * @name :getCustomizedCommonHtml
  334 + * @author :lyh
  335 + * @method :post
  336 + * @time :2023/12/29 13:13
  337 + */
  338 + public function getCustomizedCommonHtml($type,$is_custom = 0,$is_list = 0){
  339 + $data = [
  340 + 'template_id' => 0,
  341 + 'project_id' => $this->user['project_id'],
  342 + 'type'=>$type,
  343 + 'is_custom'=>$is_custom,
  344 + 'is_list'=>$is_list
  345 + ];
  346 + $commonTemplateModel = new BTemplateCommon();
  347 + return $commonTemplateModel->read($data);
  348 + }
  349 +
  350 + /**
  351 + * @remark :定制页面头部类型---根据source获取type类型
  352 + * @name :getType
  353 + * @author :lyh
  354 + * @method :post
  355 + * @time :2023/11/16 11:20
  356 + */
  357 + public function getCustomizedType($source,$is_list){
  358 + $type = BTemplate::TYPE_HOME;
  359 + if($source == BTemplate::SOURCE_PRODUCT){
  360 + if($is_list == BTemplate::IS_LIST){
  361 + $type = BTemplate::TYPE_PRODUCT_LIST;
  362 + }else{
  363 + $type = BTemplate::TYPE_PRODUCT_DETAIL;
  364 + }
  365 + }
  366 + if($source == BTemplate::SOURCE_BLOG){
  367 + if($is_list == BTemplate::IS_LIST){
  368 + $type = BTemplate::TYPE_BLOG_LIST;
  369 + }else{
  370 + $type = BTemplate::TYPE_BLOG_DETAIL;
  371 + }
  372 + }
  373 + if($source == BTemplate::SOURCE_NEWS){
  374 + if($is_list == BTemplate::IS_LIST){
  375 + $type = BTemplate::TYPE_NEWS_LIST;
  376 + }else{
  377 + $type = BTemplate::TYPE_NEWS_DETAIL;
  378 + }
  379 + }
  380 + return $type;
  381 + }
  382 +
  383 + /**
  384 + * @remark :获取当前项目设置的模版
  385 + * @name :getSettingTemplate
  386 + * @author :lyh
  387 + * @method :post
  388 + * @time :2023/12/13 10:48
  389 + */
  390 + public function getSettingTemplate($source,$is_list,$is_custom){
  391 + $template_id = 0;
  392 + if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION) {//定制项目
  393 + if($is_custom == BTemplate::IS_CUSTOM){
  394 + $customModuleModel = new CustomModule();
  395 + $info = $customModuleModel->read(['id'=>$source]);
  396 + if($info === false){
  397 + return false;
  398 + }
  399 + if($info['list_customized'] == BTemplate::IS_VISUALIZATION && $is_list == BTemplate::IS_LIST){
  400 + return $this->success($template_id);
  401 + }
  402 + if($info['detail_customized'] == BTemplate::IS_VISUALIZATION && $is_list == BTemplate::IS_DETAIL){
  403 + return $this->success($template_id);
  404 + }
  405 + }else{
  406 + $type = $this->getCustomizedType($source, $is_list);//获取定制界面类型
  407 + //查看当前页面是否定制,是否开启可视化
  408 + $page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
  409 + if (in_array($type, $page_array)) {//是定制界面
  410 + return $this->success($template_id);
  411 + }
  412 + }
  413 + }
  414 + $bSettingModel = new Setting();
  415 + $info = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
  416 + if($info === false){
  417 + $this->fail('请先选择模版');
  418 + }
  419 + $template_id = $info['template_id'];
  420 + return $this->success($template_id);
  421 + }
  422 +
  423 + /**
  424 + * @remark :根据类型获取公共头和底
  425 + * @name :getCommonPage
  426 + * @author :lyh
  427 + * @method :post
  428 + * @time :2023/10/21 16:55
  429 + */
  430 + public function getCommonHtml($source,$is_list,$template_id,$is_custom = 0){
  431 + $type = $this->getType($source,$is_list,$is_custom);
  432 + $data = [
  433 + 'template_id' => $template_id,
  434 + 'project_id' => $this->user['project_id'],
  435 + 'type'=>$type,
  436 + 'is_custom'=>0,
  437 + ];
  438 + $commonTemplateModel = new BTemplateCommon();
  439 + $commonInfo = $commonTemplateModel->read($data);
  440 + if($commonInfo === false){
  441 + $data['type'] = BTemplate::SOURCE_HOME;
  442 + $commonInfo = $commonTemplateModel->read($data);
  443 + }
  444 + return $this->success($commonInfo);
  445 + }
  446 +
  447 +}
@@ -19,6 +19,7 @@ Route::middleware(['bloginauth'])->group(function () { @@ -19,6 +19,7 @@ Route::middleware(['bloginauth'])->group(function () {
19 Route::any('/get_project', [\App\Http\Controllers\Bside\BCom\ComController::class, 'get_project'])->name('get_project'); 19 Route::any('/get_project', [\App\Http\Controllers\Bside\BCom\ComController::class, 'get_project'])->name('get_project');
20 Route::any('/generateToken', [\App\Http\Controllers\Bside\BCom\ComController::class, 'generateToken'])->name('generateToken'); 20 Route::any('/generateToken', [\App\Http\Controllers\Bside\BCom\ComController::class, 'generateToken'])->name('generateToken');
21 Route::any('/getLink', [\App\Http\Controllers\Bside\BCom\ComController::class, 'getLink'])->name('getLink'); 21 Route::any('/getLink', [\App\Http\Controllers\Bside\BCom\ComController::class, 'getLink'])->name('getLink');
  22 + Route::any('/getMobileProject', [\App\Http\Controllers\Bside\BCom\ComController::class, 'getMobileProject'])->name('getMobileProject');
22 //用户相关路由 23 //用户相关路由
23 Route::prefix('user')->group(function () { 24 Route::prefix('user')->group(function () {
24 Route::any('/', [\App\Http\Controllers\Bside\User\UserController::class, 'lists'])->name('user_lists'); 25 Route::any('/', [\App\Http\Controllers\Bside\User\UserController::class, 'lists'])->name('user_lists');