作者 刘锟

Merge remote-tracking branch 'origin/master' into akun

正在显示 40 个修改的文件 包含 711 行增加3217 行删除

要显示太多修改。

为保证性能只显示 40 of 40+ 个文件。

  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :ReplaceHtml.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/5/10 17:20
  8 + */
  9 +
  10 +namespace App\Console\Commands\ReplaceHtml;
  11 +
  12 +use App\Models\Template\BTemplate;
  13 +use App\Models\Template\TemplateReplaceHtmlLog;
  14 +use App\Services\ProjectServer;
  15 +use Illuminate\Console\Command;
  16 +use Illuminate\Support\Facades\DB;
  17 +use Illuminate\Support\Facades\Log;
  18 +use App\Models\Template\TemplateReplaceHtml;
  19 +
  20 +class ReplaceHtml extends Command
  21 +{
  22 + /**
  23 + * The name and signature of the console command.
  24 + *
  25 + * @var string
  26 + */
  27 + protected $signature = 'replace_html';
  28 +
  29 + /**
  30 + * The console command description.
  31 + *
  32 + * @var string
  33 + */
  34 + protected $description = '替换html代码生成子任务';
  35 +
  36 + /**
  37 + * Create a new command instance.
  38 + *
  39 + * @return void
  40 + */
  41 + public function __construct()
  42 + {
  43 + parent::__construct();
  44 + }
  45 +
  46 + /**
  47 + * @return bool
  48 + */
  49 + public function handle()
  50 + {
  51 + while (true){
  52 + $replaceHtmlModel = new TemplateReplaceHtml();
  53 + $replaceHtmlList = $replaceHtmlModel->list(['status'=>$replaceHtmlModel::STATUS]);
  54 + if(!empty($replaceHtmlList)){
  55 + foreach ($replaceHtmlList as $k => $v){
  56 + ProjectServer::useProject($v['project_id']);
  57 + echo '开始,任务id:'.$v['id'].PHP_EOL;
  58 + $this->createReplaceHtmlLog($v);
  59 + //修改当前主任务状态为待执行
  60 + $replaceHtmlModel->edit(['status'=>$replaceHtmlModel::STATUS_START],['id'=>$v['id']]);
  61 + echo '结束'.PHP_EOL;
  62 + DB::disconnect('custom_mysql');
  63 + }
  64 + }
  65 + sleep(5);
  66 + return true;
  67 + }
  68 + }
  69 +
  70 + /**
  71 + * @remark :生成子任务
  72 + * @name :createReplaceHtmlLog
  73 + * @author :lyh
  74 + * @method :post
  75 + * @time :2024/5/10 17:26
  76 + */
  77 + public function createReplaceHtmlLog($info){
  78 + //获取当前页面所有数据
  79 + $saveData = [];
  80 + $bTemplateModel = new BTemplate();
  81 + $condition = ['source'=>$info['source'],'template_id'=>$info['template_id'],'is_custom'=>$info['is_custom'],'is_list'=>$info['is_list']];
  82 + $bTemplateList = $bTemplateModel->list($condition,'id',['id']);
  83 + foreach ($bTemplateList as $v){
  84 + $saveData[] = [
  85 + 'replace_id'=>$info['id'],
  86 + 'project_id'=>$info['project_id'],
  87 + 'status'=>0,
  88 + 'old_html'=>$info['old_html'],
  89 + 'html'=>$info['html'],
  90 + 'source'=>$info['source'],
  91 + 'source_id'=>$v['id'],
  92 + 'is_custom'=>$info['is_custom'],
  93 + 'is_list'=>$info['is_list'],
  94 + 'created_at'=>date('Y-m-d H:i:s'),
  95 + 'updated_at'=>date('Y-m-d H:i:s')
  96 + ];
  97 + }
  98 + if(!empty($saveData)){
  99 + $templateHtmlLogModel = new TemplateReplaceHtmlLog();
  100 + $templateHtmlLogModel->insert($saveData);
  101 + }
  102 + return true;
  103 + }
  104 +
  105 +
  106 +}
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :ReplaceHtmlLog.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/5/10 17:53
  8 + */
  9 +
  10 +namespace App\Console\Commands\ReplaceHtml;
  11 +
  12 +use App\Models\Template\BTemplate;
  13 +use App\Models\Template\TemplateReplaceHtml;
  14 +use App\Models\Template\TemplateReplaceHtmlLog;
  15 +use App\Services\ProjectServer;
  16 +use Illuminate\Console\Command;
  17 +use Illuminate\Support\Facades\DB;
  18 +
  19 +class ReplaceHtmlLog extends Command
  20 +{
  21 + /**
  22 + * The name and signature of the console command.
  23 + *
  24 + * @var string
  25 + */
  26 + protected $signature = 'replace_html_log';
  27 +
  28 + /**
  29 + * The console command description.
  30 + *
  31 + * @var string
  32 + */
  33 + protected $description = '替换html代码';
  34 +
  35 + /**
  36 + * Create a new command instance.
  37 + *
  38 + * @return void
  39 + */
  40 + public function __construct()
  41 + {
  42 + parent::__construct();
  43 + }
  44 +
  45 + /**
  46 + * @return bool
  47 + */
  48 + public function handle()
  49 + {
  50 + while (true){
  51 + $replaceHtmlModel = new TemplateReplaceHtml();
  52 + $replaceHtmlList = $replaceHtmlModel->list(['status'=>$replaceHtmlModel::STATUS_START]);
  53 + foreach ($replaceHtmlList as $value){
  54 + echo '开始主任务id:'.$value['id'].PHP_EOL;
  55 + $replaceHtmlLogModel = new TemplateReplaceHtmlLog();
  56 + $replaceHtmlLogList = $replaceHtmlLogModel->list(['replace_id'=>$value['id'],'status'=>$replaceHtmlLogModel::STATUS]);
  57 + ProjectServer::useProject($value['project_id']);
  58 + foreach ($replaceHtmlLogList as $v){
  59 + echo date('Y-m-d H:i:s') . '子任务id :'.$v['id'] . PHP_EOL;
  60 + $this->replaceHtml($v);
  61 + $replaceHtmlLogModel->edit(['status'=>$replaceHtmlLogModel::STATUS_END],['id'=>$v['id']]);
  62 + }
  63 + DB::disconnect('custom_mysql');
  64 + //修改当前主任务状态为待执行
  65 + $replaceHtmlModel->edit(['status'=>$replaceHtmlModel::STATUS_END],['id'=>$value['id']]);
  66 + echo '结束'.PHP_EOL;
  67 + }
  68 + }
  69 + sleep(5);
  70 + return true;
  71 + }
  72 +
  73 + /**
  74 + * @remark :替换html
  75 + * @name :replaceHtml
  76 + * @author :lyh
  77 + * @method :post
  78 + * @time :2024/5/10 17:56
  79 + */
  80 + public function replaceHtml($info){
  81 + $bTemplateModel = new BTemplate();
  82 + $condition = ['source'=>$info['source'],'source_id'=>$info['source_id'],
  83 + 'template_id'=>$info['template_id'],'is_custom'=>$info['is_custom'],'is_list'=>$info['is_list']];
  84 + $old_html = $info['old_html'];
  85 + $html = $info['html'];
  86 + if($info['template_id'] == 0){
  87 + $bTemplateModel->formatQuery($condition)->update(['html' => DB::raw("REPLACE(html, '$old_html', '$html')")]);
  88 + }else{
  89 + $bTemplateModel->formatQuery($condition)->update(['main_html' => DB::raw("REPLACE(main_html, '$old_html', '$html')")]);
  90 + }
  91 + return true;
  92 + }
  93 +}
@@ -53,7 +53,7 @@ class UpdateRoute extends Command @@ -53,7 +53,7 @@ class UpdateRoute extends Command
53 */ 53 */
54 public function handle(){ 54 public function handle(){
55 $projectModel = new Project(); 55 $projectModel = new Project();
56 - $list = $projectModel->list(['id'=>775]); 56 + $list = $projectModel->list(['id'=>688]);
57 $data = []; 57 $data = [];
58 foreach ($list as $v){ 58 foreach ($list as $v){
59 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; 59 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :V6UpdateLogController.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/5/9 16:04
  8 + */
  9 +
  10 +namespace App\Http\Controllers\Aside\Com;
  11 +
  12 +use App\Enums\Common\Code;
  13 +use App\Http\Controllers\Aside\BaseController;
  14 +use App\Http\Logic\Aside\Com\V6UpdateLogLogic;
  15 +use App\Models\Com\V6UpdateLog;
  16 +
  17 +class V6UpdateLogController extends BaseController
  18 +{
  19 + /**
  20 + * @remark :更新日志
  21 + * @name :lists
  22 + * @author :lyh
  23 + * @method :post
  24 + * @time :2024/5/9 16:05
  25 + */
  26 + public function lists(V6UpdateLog $logModel){
  27 + $lists = $logModel->lists($this->map,$this->page,$this->row,$this->order);
  28 + $this->response('success',Code::SUCCESS,$lists);
  29 + }
  30 +
  31 + /**
  32 + * @remark :保存数据
  33 + * @name :save
  34 + * @author :lyh
  35 + * @method :post
  36 + * @time :2024/5/9 16:23
  37 + */
  38 + public function save(V6UpdateLogLogic $logic){
  39 + $this->request->validate([
  40 + 'version_id' => 'required',
  41 + 'remark' => 'required',
  42 + 'updated_date' => 'required',
  43 + ], [
  44 + 'version_id.required' => '版本号version_id不能为空',
  45 + 'remark.required' => '更新内容不能为空',
  46 + 'updated_date.required' => '更新时间不能为空',
  47 + ]);
  48 + $data = $logic->saveV6UpdateLog();
  49 + $this->response('success',Code::SUCCESS,$data);
  50 + }
  51 +
  52 + /**
  53 + * @remark :删除数据
  54 + * @name :del
  55 + * @author :lyh
  56 + * @method :post
  57 + * @time :2024/5/9 16:30
  58 + */
  59 + public function del(V6UpdateLogLogic $logic){
  60 + $this->request->validate([
  61 + 'id' => 'required',
  62 + ], [
  63 + 'id.required' => 'id不能为空',
  64 + ]);
  65 + $logic->delV6UpdateLog();
  66 + $this->response('success');
  67 + }
  68 +}
@@ -12,14 +12,30 @@ namespace App\Http\Controllers\Aside\Template; @@ -12,14 +12,30 @@ namespace App\Http\Controllers\Aside\Template;
12 use App\Enums\Common\Code; 12 use App\Enums\Common\Code;
13 use App\Http\Controllers\Aside\BaseController; 13 use App\Http\Controllers\Aside\BaseController;
14 use App\Http\Logic\Aside\Template\ReplaceHtmlLogic; 14 use App\Http\Logic\Aside\Template\ReplaceHtmlLogic;
  15 +use App\Models\Manage\Manage;
  16 +use App\Models\Project\Project;
15 use App\Models\Template\TemplateReplaceHtml; 17 use App\Models\Template\TemplateReplaceHtml;
16 use App\Models\Template\TemplateReplaceHtmlLog; 18 use App\Models\Template\TemplateReplaceHtmlLog;
17 -use App\Services\ProjectServer;  
18 -use Illuminate\Support\Facades\DB;  
19 19
20 class ReplaceHtmlController extends BaseController 20 class ReplaceHtmlController extends BaseController
21 { 21 {
22 /** 22 /**
  23 + * @remark :获取所有页面类型
  24 + * @name :pageType
  25 + * @author :lyh
  26 + * @method :post
  27 + * @time :2024/5/9 17:06
  28 + */
  29 + public function pageType(ReplaceHtmlLogic $logic){
  30 + $this->request->validate([
  31 + 'project_id'=>'required',
  32 + ],[
  33 + 'project_id.required' => 'project_id不能为空',
  34 + ]);
  35 + $data = $logic->sourceTypeInfo($this->param['project_id']);
  36 + $this->response('success',Code::SUCCESS,$data);
  37 + }
  38 + /**
23 * @remark :替换同一种类型的html代码 39 * @remark :替换同一种类型的html代码
24 * @name :replaceTemplateMainHtml 40 * @name :replaceTemplateMainHtml
25 * @author :lyh 41 * @author :lyh
@@ -28,22 +44,18 @@ class ReplaceHtmlController extends BaseController @@ -28,22 +44,18 @@ class ReplaceHtmlController extends BaseController
28 */ 44 */
29 public function replaceTemplateMainHtml(ReplaceHtmlLogic $logic){ 45 public function replaceTemplateMainHtml(ReplaceHtmlLogic $logic){
30 $this->request->validate([ 46 $this->request->validate([
31 - 'old_html'=>'required', 47 + 'name'=>'required',
32 'html'=>'required', 48 'html'=>'required',
33 - 'type'=>'required',  
34 - 'is_list'=>'required',  
35 - 'is_custom'=>'required', 49 + 'old_html'=>'required',
36 'project_id'=>'required', 50 'project_id'=>'required',
37 ],[ 51 ],[
38 - 'old_html.required' => '需替换的html不能为空', 52 + 'name.required' => '需替换页面标识不能为空',
39 'html.required' => 'html不能为空', 53 'html.required' => 'html不能为空',
40 - 'type.required' => '类型type不能为空',  
41 - 'is_custom.required' => '类型is_custom不能为空',  
42 - 'is_list.required' => '类型is_list不能为空', 54 + 'old_html.required' => '替换前的html不能为空',
43 'project_id.required' => 'project_id不能为空', 55 'project_id.required' => 'project_id不能为空',
44 ]); 56 ]);
45 - $logic->replaceHtml();  
46 - $this->response('success'); 57 + $data = $logic->replaceTemplateMainHtml();
  58 + $this->response('success',Code::SUCCESS,$data);
47 } 59 }
48 60
49 /** 61 /**
@@ -53,25 +65,21 @@ class ReplaceHtmlController extends BaseController @@ -53,25 +65,21 @@ class ReplaceHtmlController extends BaseController
53 * @method :post 65 * @method :post
54 * @time :2024/5/8 10:28 66 * @time :2024/5/8 10:28
55 */ 67 */
56 - public function replaceTemplateLog(TemplateReplaceHtml $replaceModel){  
57 - $this->request->validate([  
58 - 'project_id'=>'required',  
59 - ],[  
60 - 'project_id.required' => 'project_id不能为空',  
61 - ]);  
62 - ProjectServer::useProject($this->param['project_id']); 68 + public function replaceTemplateLog(TemplateReplaceHtml $replaceModel,ReplaceHtmlLogic $logic){
63 $lists = $replaceModel->lists($this->map,$this->page,$this->row,$this->order); 69 $lists = $replaceModel->lists($this->map,$this->page,$this->row,$this->order);
64 if(!empty($lists) && !empty($lists['list'])){ 70 if(!empty($lists) && !empty($lists['list'])){
65 - $templateLogModel = new TemplateReplaceHtmlLog();  
66 foreach ($lists['list'] as $k => $v){ 71 foreach ($lists['list'] as $k => $v){
67 - $v['sub'] = $templateLogModel->list(['replace_id'=>$v['id']]); 72 + $v['project_name'] = (new Project())->getProjectName($v['project_id']);
  73 + $v['operator_name'] = (new Manage())->getName($v['operator_id']);
  74 + $v['source_name'] = $logic->getSourceName($v['source'],$v['is_list'],$v['is_custom'],$v['project_id']);
68 $lists['list'][$k] = $v; 75 $lists['list'][$k] = $v;
69 } 76 }
70 } 77 }
71 - DB::disconnect('custom_mysql');  
72 $this->response('success',Code::SUCCESS,$lists); 78 $this->response('success',Code::SUCCESS,$lists);
73 } 79 }
74 80
  81 +
  82 +
75 /** 83 /**
76 * @remark :还原 84 * @remark :还原
77 * @name :reductionHtml 85 * @name :reductionHtml
@@ -85,7 +93,7 @@ class ReplaceHtmlController extends BaseController @@ -85,7 +93,7 @@ class ReplaceHtmlController extends BaseController
85 ],[ 93 ],[
86 'id.required' => 'id不能为空', 94 'id.required' => 'id不能为空',
87 ]); 95 ]);
88 - $logic->reductionHtml();  
89 - $this->response('success'); 96 + $data = $logic->reductionHtml();
  97 + $this->response('success',Code::SUCCESS,$data);
90 } 98 }
91 } 99 }
@@ -96,8 +96,8 @@ class BlogCategoryController extends BaseController @@ -96,8 +96,8 @@ class BlogCategoryController extends BaseController
96 */ 96 */
97 public function save(BlogCategoryRequest $request,BlogCategoryLogic $blogCategoryLogic){ 97 public function save(BlogCategoryRequest $request,BlogCategoryLogic $blogCategoryLogic){
98 $request->validated(); 98 $request->validated();
99 - $blogCategoryLogic->categorySave();  
100 - $this->response('success'); 99 + $data = $blogCategoryLogic->categorySave();
  100 + $this->response('success',Code::SUCCESS,$data);
101 } 101 }
102 102
103 103
@@ -37,7 +37,8 @@ class BlogController extends BaseController @@ -37,7 +37,8 @@ class BlogController extends BaseController
37 $user = new User(); 37 $user = new User();
38 foreach ($lists['list'] as $k => $v){ 38 foreach ($lists['list'] as $k => $v){
39 $v['category_name'] = $this->categoryName($v['category_id'],$data); 39 $v['category_name'] = $this->categoryName($v['category_id'],$data);
40 - $v['url'] = $this->user['domain'] . getRouteMap(RouteMap::SOURCE_BLOG,$v['id']); 40 + $v['route'] = $v['url'];
  41 + $v['url'] = $this->user['domain'] . getRouteMap(RouteMap::SOURCE_BLOG,$v['id']);;
41 $v['image_link'] = getImageUrl($v['image'],$this->user['storage_type'],$this->user['project_location']); 42 $v['image_link'] = getImageUrl($v['image'],$this->user['storage_type'],$this->user['project_location']);
42 $v['operator_name'] = $user->getName($v['operator_id']); 43 $v['operator_name'] = $user->getName($v['operator_id']);
43 $v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_BLOG,BTemplate::IS_DETAIL,$template_id,$v['id']); 44 $v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_BLOG,BTemplate::IS_DETAIL,$template_id,$v['id']);
@@ -198,8 +199,8 @@ class BlogController extends BaseController @@ -198,8 +199,8 @@ class BlogController extends BaseController
198 */ 199 */
199 public function save(BlogRequest $request,BlogLogic $blogLogic){ 200 public function save(BlogRequest $request,BlogLogic $blogLogic){
200 $request->validated(); 201 $request->validated();
201 - $blogLogic->blogSave();  
202 - $this->response('success'); 202 + $data = $blogLogic->blogSave();
  203 + $this->response('success',Code::SUCCESS,$data);
203 } 204 }
204 205
205 /** 206 /**
@@ -30,8 +30,8 @@ class BlogLabelController extends BaseController @@ -30,8 +30,8 @@ class BlogLabelController extends BaseController
30 */ 30 */
31 public function add(BlogLabelRequest $request,BlogLabelLogic $blogLabelLogic){ 31 public function add(BlogLabelRequest $request,BlogLabelLogic $blogLabelLogic){
32 $request->validated(); 32 $request->validated();
33 - $blogLabelLogic->add_blog_label();  
34 - $this->response('success'); 33 + $data = $blogLabelLogic->add_blog_label();
  34 + $this->response('success',Code::SUCCESS,$data);
35 } 35 }
36 36
37 /** 37 /**
@@ -63,8 +63,8 @@ class BlogLabelController extends BaseController @@ -63,8 +63,8 @@ class BlogLabelController extends BaseController
63 ],[ 63 ],[
64 'id.required' => 'ID不能为空' 64 'id.required' => 'ID不能为空'
65 ]); 65 ]);
66 - $blogLabelLogic->edit_blog_label();  
67 - $this->response('success'); 66 + $data = $blogLabelLogic->edit_blog_label();
  67 + $this->response('success',Code::SUCCESS,$data);
68 } 68 }
69 69
70 /** 70 /**
@@ -135,8 +135,8 @@ class CustomModuleCategoryController extends BaseController @@ -135,8 +135,8 @@ class CustomModuleCategoryController extends BaseController
135 'module_id.required' => '所选模块id不能为空', 135 'module_id.required' => '所选模块id不能为空',
136 'pid.required' => '上级不能为空' 136 'pid.required' => '上级不能为空'
137 ]); 137 ]);
138 - $logic->categorySave();  
139 - $this->response('success'); 138 + $data = $logic->categorySave();
  139 + $this->response('success',Code::SUCCESS,$data);
140 } 140 }
141 141
142 /** 142 /**
@@ -204,8 +204,8 @@ class CustomModuleContentController extends BaseController @@ -204,8 +204,8 @@ class CustomModuleContentController extends BaseController
204 'route.required' => '分类路由不能为空', 204 'route.required' => '分类路由不能为空',
205 'module_id.required' => '所选模块id不能为空' 205 'module_id.required' => '所选模块id不能为空'
206 ]); 206 ]);
207 - $logic->contentSave();  
208 - $this->response('success'); 207 + $data = $logic->contentSave();
  208 + $this->response('success',Code::SUCCESS,$data);
209 } 209 }
210 210
211 /** 211 /**
@@ -264,7 +264,7 @@ class CustomModuleContentController extends BaseController @@ -264,7 +264,7 @@ class CustomModuleContentController extends BaseController
264 * @time :2024/4/28 16:31 264 * @time :2024/4/28 16:31
265 */ 265 */
266 public function copyModuleContent(CustomModuleContentLogic $logic){ 266 public function copyModuleContent(CustomModuleContentLogic $logic){
267 - $logic->copyModuleContentInfo();  
268 - $this->response('success'); 267 + $data = $logic->copyModuleContentInfo();
  268 + $this->response('success',Code::SUCCESS,$data);
269 } 269 }
270 } 270 }
@@ -67,8 +67,8 @@ class CustomModuleController extends BaseController @@ -67,8 +67,8 @@ class CustomModuleController extends BaseController
67 ],[ 67 ],[
68 'name.required' => '模块名称不能为空', 68 'name.required' => '模块名称不能为空',
69 ]); 69 ]);
70 - $logic->customModuleSave();  
71 - $this->response('success'); 70 + $data = $logic->customModuleSave();
  71 + $this->response('success',Code::SUCCESS,$data);
72 } 72 }
73 73
74 /** 74 /**
@@ -85,8 +85,8 @@ class NavController extends BaseController @@ -85,8 +85,8 @@ class NavController extends BaseController
85 */ 85 */
86 public function save(NavRequest $request,NavLogic $logic){ 86 public function save(NavRequest $request,NavLogic $logic){
87 $request->validated(); 87 $request->validated();
88 - $logic->navSave();  
89 - $this->response('success'); 88 + $data = $logic->navSave();
  89 + $this->response('success',Code::SUCCESS,$data);
90 } 90 }
91 91
92 92
@@ -96,8 +96,8 @@ class NewsCategoryController extends BaseController @@ -96,8 +96,8 @@ class NewsCategoryController extends BaseController
96 */ 96 */
97 public function save(NewsCategoryRequest $request,NewsCategoryLogic $newsCategoryLogic){ 97 public function save(NewsCategoryRequest $request,NewsCategoryLogic $newsCategoryLogic){
98 $request->validated(); 98 $request->validated();
99 - $newsCategoryLogic->newsCategorySave();  
100 - $this->response('success'); 99 + $data = $newsCategoryLogic->newsCategorySave();
  100 + $this->response('success',Code::SUCCESS,$data);
101 } 101 }
102 102
103 /** 103 /**
@@ -41,6 +41,7 @@ class NewsController extends BaseController @@ -41,6 +41,7 @@ class NewsController extends BaseController
41 $user = new User(); 41 $user = new User();
42 foreach ($lists['list'] as $k => $v){ 42 foreach ($lists['list'] as $k => $v){
43 $v['category_name'] = $this->categoryName($v['category_id'],$data); 43 $v['category_name'] = $this->categoryName($v['category_id'],$data);
  44 + $v['route'] = $v['url'];
44 $v['url'] = $this->user['domain'].getRouteMap(RouteMap::SOURCE_NEWS,$v['id']); 45 $v['url'] = $this->user['domain'].getRouteMap(RouteMap::SOURCE_NEWS,$v['id']);
45 $v['image_link'] = getImageUrl($v['image'],$this->user['storage_type'],$this->user['project_location']); 46 $v['image_link'] = getImageUrl($v['image'],$this->user['storage_type'],$this->user['project_location']);
46 $v['operator_name'] = $user->getName($v['operator_id']); 47 $v['operator_name'] = $user->getName($v['operator_id']);
@@ -190,8 +191,8 @@ class NewsController extends BaseController @@ -190,8 +191,8 @@ class NewsController extends BaseController
190 */ 191 */
191 public function save(NewsRequest $newsRequest,NewsLogic $newsLogic){ 192 public function save(NewsRequest $newsRequest,NewsLogic $newsLogic){
192 $newsRequest->validated(); 193 $newsRequest->validated();
193 - $newsLogic->newsSave();  
194 - $this->response('success'); 194 + $data = $newsLogic->newsSave();
  195 + $this->response('success',Code::SUCCESS,$data);
195 } 196 }
196 197
197 198
@@ -126,8 +126,8 @@ class CategoryController extends BaseController @@ -126,8 +126,8 @@ class CategoryController extends BaseController
126 public function save(CategoryRequest $request, CategoryLogic $logic) 126 public function save(CategoryRequest $request, CategoryLogic $logic)
127 { 127 {
128 $request->validated(); 128 $request->validated();
129 - $logic->categorySave();  
130 - $this->response('success'); 129 + $data = $logic->categorySave();
  130 + $this->response('success',Code::SUCCESS,$data);
131 } 131 }
132 132
133 /** 133 /**
@@ -378,8 +378,8 @@ class ProductController extends BaseController @@ -378,8 +378,8 @@ class ProductController extends BaseController
378 public function save(ProductRequest $request, ProductLogic $logic) 378 public function save(ProductRequest $request, ProductLogic $logic)
379 { 379 {
380 $request->validated(); 380 $request->validated();
381 - $logic->productSave();  
382 - $this->response('success'); 381 + $data = $logic->productSave();
  382 + $this->response('success',Code::SUCCESS,$data);
383 } 383 }
384 384
385 /** 385 /**
@@ -574,8 +574,8 @@ class ProductController extends BaseController @@ -574,8 +574,8 @@ class ProductController extends BaseController
574 $contents .= $pre_suf_array['prefix_title'][0].' '.implode(', ',$tm_ky).', '.$pre_suf_array['suffix_l'][0]."\r\n"; 574 $contents .= $pre_suf_array['prefix_title'][0].' '.implode(', ',$tm_ky).', '.$pre_suf_array['suffix_l'][0]."\r\n";
575 $new_content = htmlentities($contents); 575 $new_content = htmlentities($contents);
576 } 576 }
577 - if (FALSE == empty($data['new_content'])){  
578 - $productInfo['describe'] = $new_content . $productInfo['$data']; 577 + if (!empty($new_content)){
  578 + $productInfo['content'] = $new_content . $productInfo['content'];
579 } 579 }
580 $this->response('success',Code::SUCCESS,$productInfo); 580 $this->response('success',Code::SUCCESS,$productInfo);
581 } 581 }
@@ -74,8 +74,8 @@ class CustomTemplateController extends BaseController @@ -74,8 +74,8 @@ class CustomTemplateController extends BaseController
74 */ 74 */
75 public function save(CustomTemplateRequest $customTemplateRequest,CustomTemplateLogic $customTemplateLogic){ 75 public function save(CustomTemplateRequest $customTemplateRequest,CustomTemplateLogic $customTemplateLogic){
76 $customTemplateRequest->validated(); 76 $customTemplateRequest->validated();
77 - $customTemplateLogic->customTemplateSave();  
78 - $this->response('success'); 77 + $data = $customTemplateLogic->customTemplateSave();
  78 + $this->response('success',Code::SUCCESS,$data);
79 } 79 }
80 80
81 /** 81 /**
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :V6UpdateLogLogic.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/5/9 16:06
  8 + */
  9 +
  10 +namespace App\Http\Logic\Aside\Com;
  11 +
  12 +use App\Http\Logic\Aside\BaseLogic;
  13 +use App\Models\Com\V6UpdateLog;
  14 +
  15 +class V6UpdateLogLogic extends BaseLogic
  16 +{
  17 + public function __construct()
  18 + {
  19 + parent::__construct();
  20 + $this->model = new V6UpdateLog();
  21 + $this->param = $this->requestAll;
  22 + }
  23 +
  24 + /**
  25 + * @remark :保存数据
  26 + * @name :saveV6UpdateLog
  27 + * @author :lyh
  28 + * @method :post
  29 + * @time :2024/5/9 16:25
  30 + */
  31 + public function saveV6UpdateLog(){
  32 + $this->param['operator_id'] = $this->manager['id'];
  33 + try {
  34 + if(isset($this->param['id']) && !empty($this->param['id'])){
  35 + $id = $this->param['id'];
  36 + $this->model->edit($this->param,['id'=>$id]);
  37 + }else{
  38 + $id = $this->model->addReturnId($this->param);
  39 + }
  40 + }catch (\Exception $e){
  41 + $this->fail('保存失败,请联系管理员');
  42 + }
  43 + return $this->success(['id'=>$id]);
  44 + }
  45 +
  46 + /**
  47 + * @remark :删除更新记录
  48 + * @name :delV6UpdateLog
  49 + * @author :lyh
  50 + * @method :post
  51 + * @time :2024/5/9 16:32
  52 + */
  53 + public function delV6UpdateLog(){
  54 + try {
  55 + $this->model->del($this->param);
  56 + }catch (\Exception $e){
  57 + $this->fail('删除失败,请联系管理员');
  58 + }
  59 + return $this->success();
  60 + }
  61 +}
@@ -10,7 +10,10 @@ @@ -10,7 +10,10 @@
10 namespace App\Http\Logic\Aside\Template; 10 namespace App\Http\Logic\Aside\Template;
11 11
12 use App\Http\Logic\aside\BaseLogic; 12 use App\Http\Logic\aside\BaseLogic;
  13 +use App\Http\Logic\Aside\Project\ProjectLogic;
  14 +use App\Models\CustomModule\CustomModule;
13 use App\Models\Template\BTemplate; 15 use App\Models\Template\BTemplate;
  16 +use App\Models\Template\Setting;
14 use App\Models\Template\TemplateReplaceHtml; 17 use App\Models\Template\TemplateReplaceHtml;
15 use App\Models\Template\TemplateReplaceHtmlLog; 18 use App\Models\Template\TemplateReplaceHtmlLog;
16 use App\Services\ProjectServer; 19 use App\Services\ProjectServer;
@@ -26,32 +29,122 @@ class ReplaceHtmlLogic extends BaseLogic @@ -26,32 +29,122 @@ class ReplaceHtmlLogic extends BaseLogic
26 } 29 }
27 30
28 /** 31 /**
  32 + * @remark :获取模版id
  33 + * @name :getTemplateId
  34 + * @author :lyh
  35 + * @method :post
  36 + * @time :2024/5/9 18:03
  37 + */
  38 + public function getTemplateId($typeInfo){
  39 + //获取当前template_id
  40 + $bSettingModel = new Setting();
  41 + $templateInfo = $bSettingModel->read(['project_id'=>$this->param['project_id']]);
  42 + if($templateInfo === false){
  43 + $this->fail('请先选择模版');
  44 + }
  45 + $template_id = $templateInfo['template_id'];
  46 + if($typeInfo['is_custom'] == 1){//扩展模块
  47 + return $this->getCustomTemplateId($typeInfo,$template_id);
  48 + }
  49 + //获取当前项目详情
  50 + $projectInfo = (new ProjectLogic())->getProjectInfo($this->param['project_id']);
  51 + //查看当前页面是否为定制
  52 + if($projectInfo['is_customized'] == BTemplate::IS_VISUALIZATION) {//定制项目
  53 + $type = $this->getCustomizedType($typeInfo['source'], $typeInfo['is_list']);//获取定制界面类型
  54 + //查看当前页面是否定制,是否开启可视化
  55 + $page_array = (array)$projectInfo['is_visualization']->page_array;//获取所有定制界面
  56 + if (in_array($type, $page_array)) {//当前页面是定制界面
  57 + $template_id = 0;
  58 + }
  59 + }
  60 + return $this->success($template_id);
  61 + }
  62 +
  63 + /**
  64 + * @remark :获取扩展模块的templateId
  65 + * @name :getCustomTemplateId
  66 + * @author :lyh
  67 + * @method :post
  68 + * @time :2024/5/10 14:53
  69 + */
  70 + public function getCustomTemplateId($typeInfo,$template_id){
  71 + $customModuleModel = new CustomModule();
  72 + $moduleInfo = $customModuleModel->read(['id'=>$typeInfo['type']],['list_customized','detail_customized']);
  73 + if($moduleInfo === false){
  74 + $this->fail('当前扩展模块不存在或已被删除');
  75 + }
  76 + if($typeInfo['is_list'] == 1 && $moduleInfo['list_customized'] == 1){
  77 + $template_id = 0;
  78 + }
  79 + if($typeInfo['is_list'] == 0 && $moduleInfo['detail_customized'] == 1){
  80 + $template_id = 0;
  81 + }
  82 + return $this->success($template_id);
  83 + }
  84 +
  85 + /**
  86 + * @remark :定制页面头部类型---根据source获取type类型
  87 + * @name :getType
  88 + * @author :lyh
  89 + * @method :post
  90 + * @time :2023/11/16 11:20
  91 + */
  92 + public function getCustomizedType($source,$is_list){
  93 + $type = BTemplate::TYPE_HOME;
  94 + if($source == BTemplate::SOURCE_PRODUCT){
  95 + if($is_list == BTemplate::IS_LIST){
  96 + $type = BTemplate::TYPE_PRODUCT_LIST;
  97 + }else{
  98 + $type = BTemplate::TYPE_PRODUCT_DETAIL;
  99 + }
  100 + }
  101 + if($source == BTemplate::SOURCE_BLOG){
  102 + if($is_list == BTemplate::IS_LIST){
  103 + $type = BTemplate::TYPE_BLOG_LIST;
  104 + }else{
  105 + $type = BTemplate::TYPE_BLOG_DETAIL;
  106 + }
  107 + }
  108 + if($source == BTemplate::SOURCE_NEWS){
  109 + if($is_list == BTemplate::IS_LIST){
  110 + $type = BTemplate::TYPE_NEWS_LIST;
  111 + }else{
  112 + $type = BTemplate::TYPE_NEWS_DETAIL;
  113 + }
  114 + }
  115 + return $type;
  116 + }
  117 +
  118 + /**
29 * @remark :替换可视化的html代码(按类型) 119 * @remark :替换可视化的html代码(按类型)
30 * @name :replaceHtml 120 * @name :replaceHtml
31 * @author :lyh 121 * @author :lyh
32 * @method :post 122 * @method :post
33 * @time :2024/5/7 15:52 123 * @time :2024/5/7 15:52
34 */ 124 */
35 - public function replaceHtml(){ 125 + public function replaceTemplateMainHtml(){
  126 + $data = $this->sourceTypeInfo($this->param['project_id']);
  127 + $typeInfo = $data[$this->param['name']];
36 ProjectServer::useProject($this->param['project_id']); 128 ProjectServer::useProject($this->param['project_id']);
37 - //TODO::生成一条任务记录  
38 - $replaceId = $this->saveReplaceHtml($this->param);  
39 - //查询当前类型所有装修的记录  
40 - $condition = ['source'=>$this->param['type'],'is_custom'=>$this->param['is_custom'],'is_list'=>$this->param['is_list'],  
41 - 'template_id'=>$this->param['template_id']];  
42 - $list = $this->model->list($condition);  
43 - foreach ($list as $v){  
44 - if($v['type'] == 0){  
45 - $main_html = str_replace($this->param['old_html'],$this->param['html'],$v['main_html']);  
46 - $this->model->edit(['main_html'=>$main_html],['id'=>$v['id']]);  
47 - }else{  
48 - $html = str_replace($this->param['old_html'],$this->param['html'],$v['html']);  
49 - $this->model->edit(['html'=>$html],['id'=>$v['id']]); 129 + $bTemplateModel = new BTemplate();
  130 + if($typeInfo['source'] == 0){//所有页面
  131 + $bSettingModel = new Setting();
  132 + $templateInfo = $bSettingModel->read(['project_id'=>$this->param['project_id']]);
  133 + if($templateInfo === false){
  134 + $this->fail('请先选择模版');
50 } 135 }
51 - $this->saveReplaceHtmlLog($replaceId,$v['id']); 136 + $template_id = $templateInfo['template_id'];
  137 + $condition = ['template_id'=>$template_id,'main_html'=>['like','%'.$this->param['old_html'].'%']];
  138 + $total_num = $bTemplateModel->formatQuery($condition)->count();
  139 + }else{
  140 + $template_id = $this->getTemplateId($typeInfo);
  141 + $condition = ['source'=>$typeInfo['source'],'is_custom'=>$typeInfo['is_custom'], 'is_list'=>$typeInfo['is_list'],
  142 + 'template_id'=>$template_id,'main_html'=>['like','%'.$this->param['old_html'].'%']];
  143 + $total_num = $bTemplateModel->formatQuery($condition)->count();
52 } 144 }
53 DB::disconnect('custom_mysql'); 145 DB::disconnect('custom_mysql');
54 - return $this->success(); 146 + $replaceId = $this->saveReplaceHtml($this->param,$typeInfo,$template_id,$total_num);
  147 + return $this->success(['id'=>$replaceId]);
55 } 148 }
56 149
57 /** 150 /**
@@ -61,70 +154,108 @@ class ReplaceHtmlLogic extends BaseLogic @@ -61,70 +154,108 @@ class ReplaceHtmlLogic extends BaseLogic
61 * @method :post 154 * @method :post
62 * @time :2024/5/8 9:23 155 * @time :2024/5/8 9:23
63 */ 156 */
64 - public function saveReplaceHtml($data,$template_id){ 157 + public function saveReplaceHtml($param,$typeInfo,$template_id,$total_num){
65 $logData = [ 158 $logData = [
66 - 'type'=>$data['type'],  
67 - 'is_custom'=>$data['is_custom'],  
68 - 'is_list'=>$data['is_list'], 159 + 'source'=>$typeInfo['source'],
  160 + 'is_custom'=>$typeInfo['is_custom'],
  161 + 'is_list'=>$typeInfo['is_list'],
69 'template_id'=>$template_id, 162 'template_id'=>$template_id,
70 - 'old_html'=>$data['old_html'],  
71 - 'html'=>$data['html'], 163 + 'status'=>$this->model::STATUS,
  164 + 'old_html'=>$param['old_html'],
  165 + 'html'=>$param['html'],
  166 + 'project_id'=>$param['project_id'],
  167 + 'total_num'=>$total_num,
  168 + 'operator_id'=>$this->manager['id']
72 ]; 169 ];
73 return $this->model->addReturnId($logData); 170 return $this->model->addReturnId($logData);
74 } 171 }
75 172
76 /** 173 /**
77 - * @remark :保存每条替换记录  
78 - * @name :saveReplaceHtmlLog 174 + * @remark :生成还原记录
  175 + * @name :reductionHtml
  176 + * @author :lyh
  177 + * @method :post
  178 + * @time :2024/5/8 10:35
  179 + */
  180 + public function reductionHtml(){
  181 + $info = $this->model->read(['id'=>$this->param['id'],'status'=>$this->model::STATUS_END]);
  182 + if($info === false){
  183 + $this->fail('当前数据不存在');
  184 + }
  185 + if($info['source'] == 0){//当前数据是替换的所有页面
  186 + $data = $this->sourceTypeInfo($info['project_id']);
  187 + $typeInfo = $data[$this->param['name']];
  188 + if($typeInfo['source'] != 0){//回滚页面
  189 + $info['source'] = $typeInfo['source'];
  190 + $info['is_custom'] = $typeInfo['is_custom'];
  191 + $info['is_list'] = $typeInfo['is_list'];
  192 + $replaceId = $this->saveResultReplaceHtml($info);
  193 + return $this->success(['id'=>$replaceId]);
  194 + }
  195 + }
  196 + $replaceId = $this->saveResultReplaceHtml($info);
  197 + return $this->success(['id'=>$replaceId]);
  198 + }
  199 +
  200 + /**
  201 + * @remark :保存还原的html
  202 + * @name :saveResultReplaceHtml
79 * @author :lyh 203 * @author :lyh
80 * @method :post 204 * @method :post
81 - * @time :2024/5/8 9:37 205 + * @time :2024/5/10 10:01
82 */ 206 */
83 - public function saveReplaceHtmlLog($replace_id,$replace_template_id){ 207 + public function saveResultReplaceHtml($info){
84 $logData = [ 208 $logData = [
85 - 'replace_id'=>$replace_id,  
86 - 'replace_template_id'=>$replace_template_id,  
87 - 'uid'=>$this->user['manager_id'], 209 + 'source'=>$info['source'],
  210 + 'is_custom'=>$info['is_custom'],
  211 + 'is_list'=>$info['is_list'],
  212 + 'template_id'=>$info['template_id'],
  213 + 'status'=>$this->model::STATUS,
  214 + 'old_html'=>$info['html'],
  215 + 'html'=>$info['old_html'],
  216 + 'project_id'=>$info['project_id'],
  217 + 'is_rollback'=>1,
  218 + 'rollback_id'=>$info['id'],
  219 + 'operator_id'=>$this->manager['id']
88 ]; 220 ];
89 - $replaceHtmlModel = new TemplateReplaceHtmlLog();  
90 - return $replaceHtmlModel->add($logData); 221 + return $this->model->addReturnId($logData);
91 } 222 }
92 223
93 /** 224 /**
94 - * @remark :还原所有记录  
95 - * @name :reductionHtml 225 + * @remark :替换类型
  226 + * @name :sourceTypeInfo
96 * @author :lyh 227 * @author :lyh
97 * @method :post 228 * @method :post
98 - * @time :2024/5/8 10:35 229 + * @time :2024/5/9 17:15
99 */ 230 */
100 - public function reductionHtml(){  
101 - ProjectServer::useProject($this->param['project_id']);  
102 - //获取当前数据详情  
103 - $info = $this->model->read(['id'=>$this->param['id']]);  
104 - if($info === false){  
105 - $this->fail('当前数据不存在');  
106 - }  
107 - $replaceLogModel = new TemplateReplaceHtmlLog();  
108 - $logList = $replaceLogModel->list(['replace_id'=>$this->param['id']]);  
109 - $replaceArr = [];  
110 - foreach ($logList as $v){  
111 - $replaceArr[] = $v['replace_template_id']; 231 + public function sourceTypeInfo($project_id){
  232 + $data = $this->model->sourceType();
  233 + ProjectServer::useProject($project_id);
  234 + $customModule = new CustomModule();
  235 + $moduleList = $customModule->list(['project_id'=>$project_id],'id',['id','name']);
  236 + foreach ($moduleList as $value){
  237 + $data[$value['name'].'详情'] = ['source'=>$value['id'],'is_list'=>0,'is_custom'=>1];
  238 + $data[$value['name'].'列表'] = ['source'=>$value['id'],'is_list'=>1,'is_custom'=>1];
112 } 239 }
113 - if(!empty($replaceArr)){  
114 - //查询可视化数据  
115 - $bTemplateModel = new BTemplate();  
116 - $templateList = $bTemplateModel->list(['id'=>['in',$replaceArr]]);  
117 - foreach ($templateList as $value){  
118 - if($v['type'] == 0){  
119 - $main_html = str_replace($info['html'],$info['old_html'],$value['main_html']);  
120 - $this->model->edit(['main_html'=>$main_html],['id'=>$v['id']]);  
121 - }else{  
122 - $html = str_replace($info['html'],$info['old_html'],$value['html']);  
123 - $this->model->edit(['html'=>$html],['id'=>$v['id']]);  
124 - } 240 + DB::disconnect('custom_mysql');
  241 + return $this->success($data);
  242 + }
  243 +
  244 + /**
  245 + * @remark :根据类型获取名称
  246 + * @name :getSourceName
  247 + * @author :lyh
  248 + * @method :post
  249 + * @time :2024/5/10 16:55
  250 + */
  251 + public function getSourceName($source,$is_list,$is_custom,$project_id){
  252 + $arr = ['source'=>$source,'is_list'=>$is_list,'is_custom'=>$is_custom];
  253 + $data = $this->sourceTypeInfo($project_id);
  254 + foreach ($data as $k => $v){
  255 + if($v == $arr){
  256 + return $this->success($k);
125 } 257 }
126 } 258 }
127 - DB::disconnect('custom_mysql');  
128 return $this->success(); 259 return $this->success();
129 } 260 }
130 } 261 }
@@ -65,13 +65,14 @@ class CustomTemplateLogic extends BaseLogic @@ -65,13 +65,14 @@ class CustomTemplateLogic extends BaseLogic
65 public function customTemplateSave(){ 65 public function customTemplateSave(){
66 $this->param['url'] = str_replace_url($this->param['url']); 66 $this->param['url'] = str_replace_url($this->param['url']);
67 if(isset($this->param['id']) && !empty($this->param['id'])){ 67 if(isset($this->param['id']) && !empty($this->param['id'])){
  68 + $id = $this->param['id'];
68 $is_upgrade = $this->param['is_upgrade'] ?? 0;//1:5.0数据 0:6.0 69 $is_upgrade = $this->param['is_upgrade'] ?? 0;//1:5.0数据 0:6.0
69 $six_read = $this->param['six_read'] ?? 0;//5.0数据时,是否按6.0显示 70 $six_read = $this->param['six_read'] ?? 0;//5.0数据时,是否按6.0显示
70 if($is_upgrade == 0 || $six_read == 1) { 71 if($is_upgrade == 0 || $six_read == 1) {
71 - $this->param['url'] = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_PAGE, $this->param['id'], $this->user['project_id']); 72 + $this->param['url'] = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_PAGE, $id, $this->user['project_id']);
72 } 73 }
73 $this->editCustomRoute($this->param['url']); 74 $this->editCustomRoute($this->param['url']);
74 - $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); 75 + $rs = $this->model->edit($this->param,['id'=>$id]);
75 }else{ 76 }else{
76 if($this->param['url'] == $this->model::NOT_FOUND_PAGE_URL){ 77 if($this->param['url'] == $this->model::NOT_FOUND_PAGE_URL){
77 $this->fail('404页面已存在'); 78 $this->fail('404页面已存在');
@@ -85,7 +86,7 @@ class CustomTemplateLogic extends BaseLogic @@ -85,7 +86,7 @@ class CustomTemplateLogic extends BaseLogic
85 if($rs === false){ 86 if($rs === false){
86 $this->fail('保存失败,请联系管理员'); 87 $this->fail('保存失败,请联系管理员');
87 } 88 }
88 - return $this->success(); 89 + return $this->success(['id'=>$id]);
89 } 90 }
90 91
91 /** 92 /**
@@ -36,10 +36,11 @@ class BlogCategoryLogic extends BaseLogic @@ -36,10 +36,11 @@ class BlogCategoryLogic extends BaseLogic
36 DB::beginTransaction(); 36 DB::beginTransaction();
37 try { 37 try {
38 if(isset($this->param['id']) && !empty($this->param['id'])){ 38 if(isset($this->param['id']) && !empty($this->param['id'])){
39 - $this->param['alias'] = RouteMap::setRoute($this->param['alias'], RouteMap::SOURCE_BLOG_CATE, $this->param['id'], $this->user['project_id']); 39 + $id = $this->param['id'];
  40 + $this->param['alias'] = RouteMap::setRoute($this->param['alias'], RouteMap::SOURCE_BLOG_CATE, $id, $this->user['project_id']);
40 $route = $this->param['alias']; 41 $route = $this->param['alias'];
41 $this->param['operator_id'] = $this->user['id']; 42 $this->param['operator_id'] = $this->user['id'];
42 - $this->edit($this->param,['id'=>$this->param['id']]); 43 + $this->edit($this->param,['id'=>$id]);
43 }else{ 44 }else{
44 //路由拼接 45 //路由拼接
45 if(!isset($this->param['alias']) || empty($this->param['alias'])){ 46 if(!isset($this->param['alias']) || empty($this->param['alias'])){
@@ -58,7 +59,7 @@ class BlogCategoryLogic extends BaseLogic @@ -58,7 +59,7 @@ class BlogCategoryLogic extends BaseLogic
58 } 59 }
59 $this->addUpdateNotify(RouteMap::SOURCE_BLOG_CATE,$route); 60 $this->addUpdateNotify(RouteMap::SOURCE_BLOG_CATE,$route);
60 $this->curlDelRoute(['new_route'=>$route]); 61 $this->curlDelRoute(['new_route'=>$route]);
61 - return $this->success(); 62 + return $this->success(['id'=>$id]);
62 } 63 }
63 64
64 /** 65 /**
@@ -42,11 +42,8 @@ class BlogLabelLogic extends BaseLogic @@ -42,11 +42,8 @@ class BlogLabelLogic extends BaseLogic
42 $this->param['create_id'] = $this->user['id']; 42 $this->param['create_id'] = $this->user['id'];
43 $this->param['operator_id'] = $this->user['id']; 43 $this->param['operator_id'] = $this->user['id'];
44 $this->param['project_id'] = $this->user['project_id']; 44 $this->param['project_id'] = $this->user['project_id'];
45 - $rs = $this->model->add($this->param);  
46 - if($rs === false){  
47 - $this->fail('error');  
48 - }  
49 - return $this->success(); 45 + $id = $this->model->addReturnId($this->param);
  46 + return $this->success(['id'=>$id]);
50 } 47 }
51 48
52 /** 49 /**
@@ -62,7 +59,7 @@ class BlogLabelLogic extends BaseLogic @@ -62,7 +59,7 @@ class BlogLabelLogic extends BaseLogic
62 if($rs === false){ 59 if($rs === false){
63 $this->fail('error'); 60 $this->fail('error');
64 } 61 }
65 - return $this->success(); 62 + return $this->success(['id'=>$this->param['id']]);
66 } 63 }
67 64
68 /** 65 /**
@@ -34,13 +34,14 @@ class BlogLogic extends BaseLogic @@ -34,13 +34,14 @@ class BlogLogic extends BaseLogic
34 try { 34 try {
35 $this->param = $this->paramProcessing($this->param); 35 $this->param = $this->paramProcessing($this->param);
36 if(isset($this->param['id']) && !empty($this->param['id'])){ 36 if(isset($this->param['id']) && !empty($this->param['id'])){
  37 + $id = $this->param['id'];
37 $is_upgrade = $this->param['is_upgrade'] ?? 0;//1:5.0数据 0:6.0 38 $is_upgrade = $this->param['is_upgrade'] ?? 0;//1:5.0数据 0:6.0
38 $six_read = $this->param['six_read'] ?? 0;//是否按6.0显示 39 $six_read = $this->param['six_read'] ?? 0;//是否按6.0显示
39 if($is_upgrade == 0 || $six_read == 1){ 40 if($is_upgrade == 0 || $six_read == 1){
40 - $this->param['url'] = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_BLOG, $this->param['id'], $this->user['project_id']); 41 + $this->param['url'] = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_BLOG, $id, $this->user['project_id']);
41 } 42 }
42 $route = $this->param['url']; 43 $route = $this->param['url'];
43 - $this->edit($this->param,['id'=>$this->param['id']]); 44 + $this->edit($this->param,['id'=>$id]);
44 }else{ 45 }else{
45 $this->param['sort'] = $this->setNewsSort(); 46 $this->param['sort'] = $this->setNewsSort();
46 $id = $this->model->addReturnId($this->param); 47 $id = $this->model->addReturnId($this->param);
@@ -54,7 +55,7 @@ class BlogLogic extends BaseLogic @@ -54,7 +55,7 @@ class BlogLogic extends BaseLogic
54 } 55 }
55 $this->addUpdateNotify(RouteMap::SOURCE_BLOG,$route); 56 $this->addUpdateNotify(RouteMap::SOURCE_BLOG,$route);
56 $this->curlDelRoute(['new_route'=>$route]); 57 $this->curlDelRoute(['new_route'=>$route]);
57 - return $this->success(); 58 + return $this->success(['id'=>$id]);
58 } 59 }
59 60
60 /** 61 /**
@@ -402,6 +403,7 @@ class BlogLogic extends BaseLogic @@ -402,6 +403,7 @@ class BlogLogic extends BaseLogic
402 $this->model->edit(['category_id'=>$category_ids],['id'=>$id]); 403 $this->model->edit(['category_id'=>$category_ids],['id'=>$id]);
403 } 404 }
404 } 405 }
  406 + DB::connection('custom_mysql')->commit();
405 //对应添加关联表 407 //对应添加关联表
406 }catch (\Exception $e){ 408 }catch (\Exception $e){
407 DB::connection('custom_mysql')->rollBack(); 409 DB::connection('custom_mysql')->rollBack();
@@ -98,11 +98,11 @@ class CustomModuleCategoryLogic extends BaseLogic @@ -98,11 +98,11 @@ class CustomModuleCategoryLogic extends BaseLogic
98 public function categorySave(){ 98 public function categorySave(){
99 $this->param = $this->handleParam($this->param); 99 $this->param = $this->handleParam($this->param);
100 if(isset($this->param['id']) && !empty($this->param['id'])){ 100 if(isset($this->param['id']) && !empty($this->param['id'])){
101 - $this->categoryEdit(); 101 + $data = $this->categoryEdit();
102 }else{ 102 }else{
103 - $this->categoryAdd(); 103 + $data = $this->categoryAdd();
104 } 104 }
105 - return $this->success(); 105 + return $this->success($data);
106 } 106 }
107 107
108 /** 108 /**
@@ -141,7 +141,7 @@ class CustomModuleCategoryLogic extends BaseLogic @@ -141,7 +141,7 @@ class CustomModuleCategoryLogic extends BaseLogic
141 }catch (\Exception $e){ 141 }catch (\Exception $e){
142 $this->fail('系统错误,请联系管理员'); 142 $this->fail('系统错误,请联系管理员');
143 } 143 }
144 - return $this->success(); 144 + return $this->success(['id'=>$id]);
145 } 145 }
146 146
147 /** 147 /**
@@ -152,7 +152,6 @@ class CustomModuleCategoryLogic extends BaseLogic @@ -152,7 +152,6 @@ class CustomModuleCategoryLogic extends BaseLogic
152 * @time :2023/12/5 10:55 152 * @time :2023/12/5 10:55
153 */ 153 */
154 public function categoryEdit(){ 154 public function categoryEdit(){
155 -  
156 $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE_CATE, 155 $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE_CATE,
157 $this->param['id'], $this->user['project_id']); 156 $this->param['id'], $this->user['project_id']);
158 $this->editRoute($this->param['id'],$route); 157 $this->editRoute($this->param['id'],$route);
@@ -160,7 +159,7 @@ class CustomModuleCategoryLogic extends BaseLogic @@ -160,7 +159,7 @@ class CustomModuleCategoryLogic extends BaseLogic
160 if($rs === false){ 159 if($rs === false){
161 $this->fail('系统错误,请连续管理员'); 160 $this->fail('系统错误,请连续管理员');
162 } 161 }
163 - return $this->success(); 162 + return $this->success(['id'=>$this->param['id']]);
164 } 163 }
165 164
166 /** 165 /**
@@ -262,7 +261,7 @@ class CustomModuleCategoryLogic extends BaseLogic @@ -262,7 +261,7 @@ class CustomModuleCategoryLogic extends BaseLogic
262 $param = $this->setContentParams($info); 261 $param = $this->setContentParams($info);
263 $save_id = $this->model->insertGetId($param); 262 $save_id = $this->model->insertGetId($param);
264 $this->copyTemplate($this->param['id'],$info['project_id'],$save_id,$info['module_id']); 263 $this->copyTemplate($this->param['id'],$info['project_id'],$save_id,$info['module_id']);
265 - $this->response('success'); 264 + $this->success(['id'=>$save_id]);
266 } 265 }
267 266
268 /** 267 /**
@@ -121,7 +121,7 @@ class CustomModuleContentLogic extends BaseLogic @@ -121,7 +121,7 @@ class CustomModuleContentLogic extends BaseLogic
121 } 121 }
122 //保存扩展字段 122 //保存扩展字段
123 $this->saveExtendInfo($id,$extend); 123 $this->saveExtendInfo($id,$extend);
124 - return $this->success(); 124 + return $this->success(['id'=>$id]);
125 } 125 }
126 126
127 /** 127 /**
@@ -149,7 +149,7 @@ class CustomModuleContentLogic extends BaseLogic @@ -149,7 +149,7 @@ class CustomModuleContentLogic extends BaseLogic
149 * @time :2023/12/7 15:04 149 * @time :2023/12/7 15:04
150 */ 150 */
151 public function contentAdd(){ 151 public function contentAdd(){
152 - try { 152 +// try {
153 $this->param['sort'] = $this->setNewsSort(); 153 $this->param['sort'] = $this->setNewsSort();
154 $id = $this->model->addReturnId($this->param); 154 $id = $this->model->addReturnId($this->param);
155 $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE, 155 $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE,
@@ -157,9 +157,9 @@ class CustomModuleContentLogic extends BaseLogic @@ -157,9 +157,9 @@ class CustomModuleContentLogic extends BaseLogic
157 $this->addUpdateNotify(RouteMap::SOURCE_MODULE,$route); 157 $this->addUpdateNotify(RouteMap::SOURCE_MODULE,$route);
158 $this->curlDelRoute(['new_route'=>$route]); 158 $this->curlDelRoute(['new_route'=>$route]);
159 $this->edit(['route' => $route], ['id' => $id]); 159 $this->edit(['route' => $route], ['id' => $id]);
160 - }catch (\Exception $e){  
161 - $this->fail('系统错误,请联系管理员');  
162 - } 160 +// }catch (\Exception $e){
  161 +// $this->fail('系统错误,请联系管理员');
  162 +// }
163 return $id; 163 return $id;
164 } 164 }
165 165
@@ -405,7 +405,7 @@ class CustomModuleContentLogic extends BaseLogic @@ -405,7 +405,7 @@ class CustomModuleContentLogic extends BaseLogic
405 $param = $this->setContentParams($info); 405 $param = $this->setContentParams($info);
406 $save_id = $this->model->insertGetId($param); 406 $save_id = $this->model->insertGetId($param);
407 $this->copyTemplate($this->param['id'],$info['project_id'],$save_id,$info['module_id']); 407 $this->copyTemplate($this->param['id'],$info['project_id'],$save_id,$info['module_id']);
408 - $this->response('success'); 408 + return $this->success(['id'=>$save_id]);
409 } 409 }
410 410
411 /** 411 /**
@@ -48,11 +48,11 @@ class CustomModuleLogic extends BaseLogic @@ -48,11 +48,11 @@ class CustomModuleLogic extends BaseLogic
48 public function customModuleSave(){ 48 public function customModuleSave(){
49 $this->param = $this->handleParam($this->param); 49 $this->param = $this->handleParam($this->param);
50 if(isset($this->param['id']) && !empty($this->param['id'])){ 50 if(isset($this->param['id']) && !empty($this->param['id'])){
51 - $this->moduleEdit(); 51 + $data = $this->moduleEdit();
52 }else{ 52 }else{
53 - $this->moduleAdd(); 53 + $data['id'] = $this->model->addReturnId($this->param);
54 } 54 }
55 - return $this->success(); 55 + return $this->success($data);
56 } 56 }
57 57
58 /** 58 /**
@@ -71,21 +71,6 @@ class CustomModuleLogic extends BaseLogic @@ -71,21 +71,6 @@ class CustomModuleLogic extends BaseLogic
71 } 71 }
72 72
73 /** 73 /**
74 - * @remark :新增  
75 - * @name :moduleAdd  
76 - * @author :lyh  
77 - * @method :post  
78 - * @time :2023/12/5 9:39  
79 - */  
80 - public function moduleAdd(){  
81 - $rs = $this->model->add($this->param);  
82 - if($rs === false){  
83 - $this->fail('系统错误,请联系管理员');  
84 - }  
85 - return $this->success();  
86 - }  
87 -  
88 - /**  
89 * @remark :编辑 74 * @remark :编辑
90 * @name :moduleEdit 75 * @name :moduleEdit
91 * @author :lyh 76 * @author :lyh
@@ -97,7 +82,7 @@ class CustomModuleLogic extends BaseLogic @@ -97,7 +82,7 @@ class CustomModuleLogic extends BaseLogic
97 if($rs === false){ 82 if($rs === false){
98 $this->fail('系统错误,请联系管理员'); 83 $this->fail('系统错误,请联系管理员');
99 } 84 }
100 - return $this->success(); 85 + return $this->success(['id'=>$this->param['id']]);
101 } 86 }
102 87
103 /** 88 /**
@@ -94,15 +94,16 @@ class NavLogic extends BaseLogic @@ -94,15 +94,16 @@ class NavLogic extends BaseLogic
94 $data['image'] = str_replace_url(isset($this->param['image']) ? $this->param['image'] : ''); 94 $data['image'] = str_replace_url(isset($this->param['image']) ? $this->param['image'] : '');
95 $data['remark_image'] = str_replace_url(isset($this->param['remark_image']) ? $this->param['remark_image'] : ''); 95 $data['remark_image'] = str_replace_url(isset($this->param['remark_image']) ? $this->param['remark_image'] : '');
96 if(isset($this->param['id']) && !empty($this->param['id'])){ 96 if(isset($this->param['id']) && !empty($this->param['id'])){
  97 + $id = $this->param['id'];
97 $this->handleEditParam();//验证是否可编辑分类 98 $this->handleEditParam();//验证是否可编辑分类
98 - $this->model->edit($data,['id'=>$this->param['id']]); 99 + $this->model->edit($data,['id'=>$id]);
99 }else{ 100 }else{
100 $data['project_id'] = $this->user['project_id']; 101 $data['project_id'] = $this->user['project_id'];
101 - $this->model->add($data); 102 + $id = $this->model->addReturnId($data);
102 } 103 }
103 //编辑菜单后,通知更新 104 //编辑菜单后,通知更新
104 $this->addUpdateNotify(RouteMap::SOURCE_NAV, 'all'); 105 $this->addUpdateNotify(RouteMap::SOURCE_NAV, 'all');
105 - return $this->success(); 106 + return $this->success(['id'=>$id]);
106 } 107 }
107 108
108 /** 109 /**
@@ -47,10 +47,11 @@ class NewsCategoryLogic extends BaseLogic @@ -47,10 +47,11 @@ class NewsCategoryLogic extends BaseLogic
47 DB::beginTransaction(); 47 DB::beginTransaction();
48 try { 48 try {
49 if(isset($this->param['id']) && !empty($this->param['id'])){ 49 if(isset($this->param['id']) && !empty($this->param['id'])){
50 - $this->param['alias'] = RouteMap::setRoute($this->param['alias'], RouteMap::SOURCE_NEWS_CATE, $this->param['id'], $this->user['project_id']); 50 + $id = $this->param['id'];
  51 + $this->param['alias'] = RouteMap::setRoute($this->param['alias'], RouteMap::SOURCE_NEWS_CATE, $id, $this->user['project_id']);
51 $route = $this->param['alias']; 52 $route = $this->param['alias'];
52 $this->param['operator_id'] = $this->user['id']; 53 $this->param['operator_id'] = $this->user['id'];
53 - $this->edit($this->param,['id'=>$this->param['id']]); 54 + $this->edit($this->param,['id'=>$id]);
54 }else{ 55 }else{
55 if(!isset($this->param['alias']) || empty($this->param['alias'])){ 56 if(!isset($this->param['alias']) || empty($this->param['alias'])){
56 $this->param['alias'] = Translate::tran($this->param['name'], 'en'); 57 $this->param['alias'] = Translate::tran($this->param['name'], 'en');
@@ -67,7 +68,7 @@ class NewsCategoryLogic extends BaseLogic @@ -67,7 +68,7 @@ class NewsCategoryLogic extends BaseLogic
67 } 68 }
68 $this->addUpdateNotify(RouteMap::SOURCE_NEWS_CATE,$route); 69 $this->addUpdateNotify(RouteMap::SOURCE_NEWS_CATE,$route);
69 $this->curlDelRoute(['new_route'=>$route]); 70 $this->curlDelRoute(['new_route'=>$route]);
70 - return $this->success(); 71 + return $this->success(['id'=>$id]);
71 } 72 }
72 73
73 /** 74 /**
@@ -65,14 +65,15 @@ class NewsLogic extends BaseLogic @@ -65,14 +65,15 @@ class NewsLogic extends BaseLogic
65 try { 65 try {
66 $this->param = $this->paramProcessing($this->param); 66 $this->param = $this->paramProcessing($this->param);
67 if (isset($this->param['id']) && !empty($this->param['id'])) { 67 if (isset($this->param['id']) && !empty($this->param['id'])) {
  68 + $id = $this->param['id'];
68 $is_upgrade = $this->param['is_upgrade'] ?? 0;//1:5.0数据 0:6.0 69 $is_upgrade = $this->param['is_upgrade'] ?? 0;//1:5.0数据 0:6.0
69 $six_read = $this->param['six_read'] ?? 0;//是否按6.0显示 70 $six_read = $this->param['six_read'] ?? 0;//是否按6.0显示
70 if($is_upgrade == 0 || $six_read == 1) { 71 if($is_upgrade == 0 || $six_read == 1) {
71 - $this->param['url'] = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_NEWS, $this->param['id'], $this->user['project_id']); 72 + $this->param['url'] = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_NEWS, $id, $this->user['project_id']);
72 } 73 }
73 //是否更新路由 74 //是否更新路由
74 $route = $this->param['url']; 75 $route = $this->param['url'];
75 - $this->edit($this->param, ['id' => $this->param['id']]); 76 + $this->edit($this->param, ['id' => $id]);
76 } else { 77 } else {
77 $this->param['sort'] = $this->setNewsSort(); 78 $this->param['sort'] = $this->setNewsSort();
78 $id = $this->model->addReturnId($this->param); 79 $id = $this->model->addReturnId($this->param);
@@ -87,7 +88,7 @@ class NewsLogic extends BaseLogic @@ -87,7 +88,7 @@ class NewsLogic extends BaseLogic
87 } 88 }
88 $this->addUpdateNotify(RouteMap::SOURCE_NEWS,$route); 89 $this->addUpdateNotify(RouteMap::SOURCE_NEWS,$route);
89 $this->curlDelRoute(['new_route'=>$route]); 90 $this->curlDelRoute(['new_route'=>$route]);
90 - return $this->success(); 91 + return $this->success(['id'=>$id]);
91 } 92 }
92 93
93 /** 94 /**
@@ -227,10 +228,6 @@ class NewsLogic extends BaseLogic @@ -227,10 +228,6 @@ class NewsLogic extends BaseLogic
227 $str = ','.implode(',',$category).','; 228 $str = ','.implode(',',$category).',';
228 } 229 }
229 return $str; 230 return $str;
230 -// foreach ($category as $v){  
231 -// $str .= $v.',';  
232 -// }  
233 -// return !empty(trim($str,',')) ? ','.$str.',' : '';  
234 } 231 }
235 232
236 /** 233 /**
@@ -444,10 +441,11 @@ class NewsLogic extends BaseLogic @@ -444,10 +441,11 @@ class NewsLogic extends BaseLogic
444 $newsInfo = $this->model->read(['id'=>$id],['id','category_id']); 441 $newsInfo = $this->model->read(['id'=>$id],['id','category_id']);
445 $category_ids = explode(',',trim($newsInfo['category_id'],',')); 442 $category_ids = explode(',',trim($newsInfo['category_id'],','));
446 $category_ids_arr = array_values(array_unique(array_merge($category_ids,$this->param['category_id']))); 443 $category_ids_arr = array_values(array_unique(array_merge($category_ids,$this->param['category_id'])));
447 - $category_ids = ','.implode(',',$category_ids_arr).',';  
448 - $this->model->edit(['category_id'=>$category_ids],['id'=>$id]); 444 + $category_ids_str = ','.implode(',',$category_ids_arr).',';
  445 + $this->model->edit(['category_id'=>$category_ids_str],['id'=>$id]);
449 } 446 }
450 } 447 }
  448 + DB::connection('custom_mysql')->commit();
451 }catch (\Exception $e){ 449 }catch (\Exception $e){
452 DB::connection('custom_mysql')->rollBack(); 450 DB::connection('custom_mysql')->rollBack();
453 $this->fail('系统错误,请联系管理员'); 451 $this->fail('系统错误,请联系管理员');
@@ -114,29 +114,23 @@ class CategoryLogic extends BaseLogic @@ -114,29 +114,23 @@ class CategoryLogic extends BaseLogic
114 * @time :2023/8/21 17:14 114 * @time :2023/8/21 17:14
115 */ 115 */
116 public function categorySave(){ 116 public function categorySave(){
117 - DB::beginTransaction();  
118 - try {  
119 - $this->param = $this->saveHandleParam($this->param);  
120 - if(isset($this->param['id']) && !empty($this->param['id'])){  
121 - $this->param['route'] = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT_CATE, $this->param['id'], $this->user['project_id']);  
122 - $route = $this->param['route'];  
123 - $this->model->edit($this->param,['id'=>$this->param['id']]);  
124 - }else{  
125 - $this->param['project_id'] = $this->user['project_id'];  
126 - $id = $this->model->addReturnId($this->param);  
127 - $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT_CATE, $id, $this->user['project_id']);  
128 - $this->edit(['route'=>$route],['id'=>$id]);  
129 - }  
130 - //清除缓存  
131 - Common::del_user_cache('product_category',$this->user['project_id']);  
132 - DB::commit();  
133 - } catch (\Exception $e){  
134 - DB::rollBack();  
135 - $this->fail('系统错误,请联系管理员'); 117 + $this->param = $this->saveHandleParam($this->param);
  118 + if(isset($this->param['id']) && !empty($this->param['id'])){
  119 + $id = $this->param['id'];
  120 + $this->param['route'] = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT_CATE, $id, $this->user['project_id']);
  121 + $route = $this->param['route'];
  122 + $this->model->edit($this->param,['id'=>$id]);
  123 + }else{
  124 + $this->param['project_id'] = $this->user['project_id'];
  125 + $id = $this->model->addReturnId($this->param);
  126 + $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT_CATE, $id, $this->user['project_id']);
  127 + $this->edit(['route'=>$route],['id'=>$id]);
136 } 128 }
  129 + //清除缓存
  130 + Common::del_user_cache('product_category',$this->user['project_id']);
137 $this->addUpdateNotify(RouteMap::SOURCE_PRODUCT_CATE,$route); 131 $this->addUpdateNotify(RouteMap::SOURCE_PRODUCT_CATE,$route);
138 $this->curlDelRoute(['new_route'=>$route]); 132 $this->curlDelRoute(['new_route'=>$route]);
139 - return $this->success(); 133 + return $this->success(['id'=>$id]);
140 } 134 }
141 135
142 /** 136 /**
@@ -147,14 +141,14 @@ class CategoryLogic extends BaseLogic @@ -147,14 +141,14 @@ class CategoryLogic extends BaseLogic
147 * @time :2023/12/22 17:28 141 * @time :2023/12/22 17:28
148 */ 142 */
149 public function saveHandleParam($param){ 143 public function saveHandleParam($param){
150 - if(isset($this->param['describe_image']) && !empty($this->param['describe_image'])){  
151 - foreach ($this->param['describe_image'] as $k => $v){ 144 + if(isset($param['describe_image']) && !empty($param['describe_image'])){
  145 + foreach ($param['describe_image'] as $k => $v){
152 $v = str_replace_url($v); 146 $v = str_replace_url($v);
153 - $this->param['describe_image'][$k] = $v; 147 + $param['describe_image'][$k] = $v;
154 } 148 }
155 - $this->param['describe_image'] = json_encode($this->param['describe_image']); 149 + $param['describe_image'] = json_encode($param['describe_image']);
156 }else{ 150 }else{
157 - $this->param['describe_image'] = json_encode([]); 151 + $param['describe_image'] = json_encode([]);
158 } 152 }
159 return $this->success($param); 153 return $this->success($param);
160 } 154 }
@@ -45,7 +45,7 @@ class ProductLogic extends BaseLogic @@ -45,7 +45,7 @@ class ProductLogic extends BaseLogic
45 $category_ids = $this->handleCategory(); 45 $category_ids = $this->handleCategory();
46 //处理其他字段 46 //处理其他字段
47 $this->param = $this->handleSaveParam($this->param); 47 $this->param = $this->handleSaveParam($this->param);
48 - try { 48 +// try {
49 if(isset($this->param['id']) && !empty($this->param['id'])){ 49 if(isset($this->param['id']) && !empty($this->param['id'])){
50 $is_upgrade = $this->param['is_upgrade'] ?? 0;//1:5.0数据 0:6.0 50 $is_upgrade = $this->param['is_upgrade'] ?? 0;//1:5.0数据 0:6.0
51 $six_read = $this->param['six_read'] ?? 0;//是否按6.0显示 51 $six_read = $this->param['six_read'] ?? 0;//是否按6.0显示
@@ -66,13 +66,13 @@ class ProductLogic extends BaseLogic @@ -66,13 +66,13 @@ class ProductLogic extends BaseLogic
66 CategoryRelated::saveRelated($id, $category_ids); 66 CategoryRelated::saveRelated($id, $category_ids);
67 //保存扩展字段 67 //保存扩展字段
68 $this->saveExtendInfo($id,$extend); 68 $this->saveExtendInfo($id,$extend);
69 - }catch (\Exception $e){  
70 - Log::info('错误信息---'.$e->getMessage());  
71 - $this->fail('系统错误请联系管理员');  
72 - } 69 +// }catch (\Exception $e){
  70 +// Log::info('错误信息---'.$e->getMessage());
  71 +// $this->fail('系统错误,请联系管理员');
  72 +// }
73 $this->addUpdateNotify(RouteMap::SOURCE_PRODUCT,$route); 73 $this->addUpdateNotify(RouteMap::SOURCE_PRODUCT,$route);
74 $this->curlDelRoute(['new_route'=>$route]); 74 $this->curlDelRoute(['new_route'=>$route]);
75 - return $this->success(); 75 + return $this->success(['id'=>$id]);
76 } 76 }
77 77
78 /** 78 /**
@@ -280,7 +280,7 @@ class TranslateLogic extends BaseLogic @@ -280,7 +280,7 @@ class TranslateLogic extends BaseLogic
280 // $this->fail('系统错误请联系管理员'); 280 // $this->fail('系统错误请联系管理员');
281 // } 281 // }
282 $this->handleRoute($this->param['url']); 282 $this->handleRoute($this->param['url']);
283 - return $this->success($rs); 283 + return $this->success();
284 } 284 }
285 285
286 /** 286 /**
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :V6UpdateLog.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/5/9 16:08
  8 + */
  9 +
  10 +namespace App\Models\Com;
  11 +
  12 +use App\Models\Base;
  13 +
  14 +/**
  15 + * @remark :
  16 + * @name :V6UpdateLog
  17 + * @author :lyh
  18 + * @method :post
  19 + * @time :2024/5/9 16:09
  20 + */
  21 +class V6UpdateLog extends Base
  22 +{
  23 + protected $table = 'gl_v6_update_log';
  24 +}
@@ -15,20 +15,7 @@ class Project extends Base @@ -15,20 +15,7 @@ class Project extends Base
15 { 15 {
16 //设置关联表名 16 //设置关联表名
17 protected $table = 'gl_project'; 17 protected $table = 'gl_project';
18 - public static $domainEndSlash = 1; //斜杠结尾  
19 - public static $projectLocationZero = 0; //普通项目  
20 - public static $projectLocationDangerous = 1; //危险项目  
21 - public static $storageTypeZero = 0; //默认腾讯压缩存储桶  
22 - public static $storageTypeOne = 1; //非压缩存储桶  
23 - //项目标识集合  
24 - public static $blockItems = "blockitems"; //html循环项父级标识  
25 - public static $blockAttrItems = "[blockitems]"; //html循环项父级属性标识  
26 - public static $blockItem = "blockitem"; //html循环项标识  
27 - public static $blockAttrItem = "[blockitem]"; //html循环项属性标识  
28 - public static $productListBlock = "productlistblock"; //html产品列表标识  
29 - public static $newListBlock = "newlistblock"; //html新闻列表标识  
30 - public static $blogListBlock = "bloglistblock"; //html博客列表标识  
31 - public static $productCategoryListBlock = "productcategorylistblock"; //html产品分类列表标识 18 +
32 const DATABASE_NAME_FIX = 'gl_data_'; 19 const DATABASE_NAME_FIX = 'gl_data_';
33 20
34 const CUSTOMIZED_ONE = 1;//定制项目 21 const CUSTOMIZED_ONE = 1;//定制项目
@@ -14,6 +14,29 @@ use App\Models\Base; @@ -14,6 +14,29 @@ use App\Models\Base;
14 class TemplateReplaceHtml extends Base 14 class TemplateReplaceHtml extends Base
15 { 15 {
16 protected $table = 'gl_replace_html'; 16 protected $table = 'gl_replace_html';
17 - //连接数据库  
18 - protected $connection = 'custom_mysql'; 17 +
  18 + const STATUS = 0;
  19 + const STATUS_START = 1;
  20 + const STATUS_END = 2;
  21 +
  22 + /**
  23 + * @remark :默认类型
  24 + * @name :sourceType
  25 + * @author :lyh
  26 + * @method :post
  27 + * @time :2024/5/9 17:07
  28 + */
  29 + public function sourceType(){
  30 + return [
  31 + '所有页面'=>['source'=>0,'is_list'=>0,'is_custom'=>0],
  32 + '首页'=>['source'=>1,'is_list'=>0,'is_custom'=>0],
  33 + '产品详情'=>['source'=>2,'is_list'=>0,'is_custom'=>0],
  34 + '产品列表'=>['source'=>2,'is_list'=>1,'is_custom'=>0],
  35 + '新闻详情'=>['source'=>4,'is_list'=>0,'is_custom'=>0],
  36 + '新闻列表'=>['source'=>4,'is_list'=>1,'is_custom'=>0],
  37 + '博客详情'=>['source'=>3,'is_list'=>0,'is_custom'=>0],
  38 + '博客列表'=>['source'=>3,'is_list'=>1,'is_custom'=>0],
  39 +// '单页面'=>['source'=>9,'is_list'=>0,'is_custom'=>0],
  40 + ];
  41 + }
19 } 42 }
@@ -14,6 +14,8 @@ use App\Models\Base; @@ -14,6 +14,8 @@ use App\Models\Base;
14 class TemplateReplaceHtmlLog extends Base 14 class TemplateReplaceHtmlLog extends Base
15 { 15 {
16 protected $table = 'gl_replace_html_log'; 16 protected $table = 'gl_replace_html_log';
17 - //连接数据库  
18 - protected $connection = 'custom_mysql'; 17 +
  18 + const STATUS = 0;
  19 + const STATUS_START = 1;
  20 + const STATUS_END = 2;
19 } 21 }
1 -<?php  
2 -  
3 -  
4 -namespace App\Services\Html;  
5 -  
6 -  
7 -use App\Models\Blog\Blog;  
8 -use App\Models\News\News;  
9 -use App\Models\Product\Category;  
10 -use App\Models\Product\CategoryRelated;  
11 -use App\Models\Product\Keyword;  
12 -use App\Models\Product\Product;  
13 -use App\Models\RouteMap\RouteMap;  
14 -use App\Models\WebSetting\SettingNum;  
15 -use App\Models\WebSetting\WebSetting;  
16 -use App\Models\WebSetting\WebSettingAmp;  
17 -use App\Models\WebSetting\WebSettingSeo;  
18 -  
19 -class AmpService  
20 -{  
21 - /**  
22 - * 获取首页html  
23 - * @param $project  
24 - * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View  
25 - * @author Akun  
26 - * @date 2024/03/14 15:04  
27 - */  
28 - public static function getIndexHtml($project)  
29 - {  
30 - //站点配置  
31 - $project_config = self::getProjectConfig($project->id);  
32 -  
33 - //产品所有分类  
34 - $category = self::getProductsCategory($project->id);  
35 -  
36 - //排序最前的3个产品  
37 - $products = self::getProductsList($project->id, 1, 3)['data'];  
38 -  
39 - //排序最前的3篇新闻  
40 - $news = self::getNewsBlogList($project->id, 1, 1, 3)['data'];  
41 -  
42 - //排序最前的3篇博客  
43 - $blogs = AmpService::getNewsBlogList($project->id, 2, 1, 3)['data'];  
44 -  
45 - //当前页面地址  
46 - $current_url = self::getCurrentUrl($project->domain);  
47 -  
48 - return view('amp/index', compact('project_config', 'category', 'products', 'news', 'blogs', 'current_url'));  
49 - }  
50 -  
51 - /**  
52 - * 获取路由页html  
53 - * @param $project  
54 - * @param $route  
55 - * @param $source  
56 - * @param $page  
57 - * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View  
58 - * @author Akun  
59 - * @date 2024/03/14 15:05  
60 - */  
61 - public static function getHtmlByRoute($project, $route, $source, $page)  
62 - {  
63 - //站点配置  
64 - $project_config = self::getProjectConfig($project->id);  
65 -  
66 - //产品所有分类  
67 - $category = self::getProductsCategory($project->id);  
68 -  
69 - //固定菜单页面  
70 - if ($route == '404') {  
71 - //404页面  
72 - $current_url = self::getCurrentUrl($project->domain, '/404/');  
73 - return view('amp/404', compact('project_config', 'category', 'current_url'));  
74 - } elseif ($route == 'contact-us') {  
75 - //contact-us页面  
76 - $current_url = self::getCurrentUrl($project->domain, '/contact-us/');  
77 - return view('amp/contact', compact('project_config', 'category', 'current_url'));  
78 - } elseif ($route == 'about-us') {  
79 - //about-us页面  
80 - $current_url = self::getCurrentUrl($project->domain, '/aboout-us/');  
81 - return view('amp/about', compact('project_config', 'category', 'current_url'));  
82 - } elseif ($route == 'products') {  
83 - //产品列表  
84 - $products = self::getProductsList($project->id, $page, 8);  
85 -  
86 - //当前分类详情  
87 - $category_info = self::getCategoryInfo($project->id, 0);  
88 -  
89 - $current_url = self::getCurrentUrl($project->domain, '/' . $category_info['route'] . '/' . ($page > 1 ? $page . '/' : ''));  
90 -  
91 - return view('amp/products', compact('project_config', 'category', 'products', 'category_info', 'page', 'current_url'));  
92 - } elseif ($route == 'news') {  
93 - //新闻列表  
94 - $news = self::getNewsBlogList($project->id, 1, $page, 5);  
95 -  
96 - $current_url = self::getCurrentUrl($project->domain, '/news/' . ($page > 1 ? $page . '/' : ''));  
97 - return view('amp/news', compact('project_config', 'category', 'news', 'page', 'current_url'));  
98 - } elseif ($route == 'blog') {  
99 - //博客列表  
100 - $blogs = self::getNewsBlogList($project->id, 2, $page, 5);  
101 -  
102 - $current_url = self::getCurrentUrl($project->domain, '/blog/' . ($page > 1 ? $page . '/' : ''));  
103 - return view('amp/blogs', compact('project_config', 'category', 'blogs', 'page', 'current_url'));  
104 - } elseif (strpos($route, 'top-search') !== false) {  
105 - //top-search页面  
106 - $pageService = new PageService();  
107 - $search_list = $pageService->getProductKeywordsByLetter($project, $route, $page);  
108 -  
109 - //处理路由后缀为-tag的关键词  
110 - foreach ($search_list['pageInfo']['pageListData'] as &$v) {  
111 - if (substr($v['route'], -4, 4) == '-tag') {  
112 - $v['route'] = substr($v['route'], 0, -4);  
113 - }  
114 - }  
115 -  
116 - //俄语站没有首字母筛选  
117 - if ($project->serve_id == 3) {  
118 - $search_list['keywordsLabel'] = [];  
119 - }  
120 -  
121 - $total_page = count($search_list['pageInfo']['pageNum']);  
122 - $search_list['pageInfo']['center_pages'] = page_init($page, $total_page);  
123 - $search_list['pageInfo']['prev'] = max($page - 1, 1);  
124 - $search_list['pageInfo']['next'] = min($page + 1, $total_page);  
125 -  
126 - $current_url = self::getCurrentUrl($project->domain, '/' . $route . '/' . ($page > 1 ? $page . '/' : ''));  
127 - return view('amp/top_search', compact('project_config', 'category', 'search_list', 'page', 'route', 'current_url'));  
128 - } else {  
129 - //剩下的页面:产品分类,产品详情,新闻详情,关键词详情  
130 - $map = ['route' => $route];  
131 - if ($source) {  
132 - $map['source'] = $source;  
133 - }  
134 - $route_info = RouteMap::where($map)->orderByRaw("FIELD(source, 'product_category','product','news','blog','product_keyword')")->first();  
135 - if (!$route_info) {  
136 - //特殊情况:关键词后缀为-tag  
137 - $map['route'] = $route . '-tag';  
138 - $map['source'] = 'product_keyword';  
139 - $route_info = RouteMap::where($map)->first();  
140 - }  
141 - if (!$route_info) {  
142 - $current_url = self::getCurrentUrl($project->domain, '/404/');  
143 - return view('amp/404', compact('project_config', 'category', 'current_url'));  
144 - }  
145 -  
146 - switch ($route_info->source) {  
147 - case 'product_category':  
148 - //产品列表  
149 - $products = self::getProductsList($project->id, $page, 8, $route_info->source_id);  
150 -  
151 - //当前分类详情  
152 - $category_info = self::getCategoryInfo($project->id, $route_info->source_id);  
153 -  
154 - $current_url = self::getCurrentUrl($project->domain, '/' . $category_info['route'] . '/' . ($page > 1 ? $page . '/' : ''));  
155 - return view('amp/products', compact('project_config', 'category', 'products', 'category_info', 'page', 'current_url'));  
156 - case 'product':  
157 - //获取产品详情  
158 - $product_info = self::getProductInfo($project->id, $route_info->source_id);  
159 -  
160 - //获取关联产品  
161 - $relate_products = self::getRelateProducts($project->id, $product_info['id'], $product_info['category_id'], 8);  
162 -  
163 - $current_url = self::getCurrentUrl($project->domain, '/' . $product_info['route'] . '/');  
164 - return view('amp/product_info', compact('project_config', 'category', 'product_info', 'relate_products', 'current_url'));  
165 - case 'news':  
166 - //新闻详情  
167 - $news_info = self::getNewsBlogInfo($project->id, 1, $route_info->source_id);  
168 -  
169 - $current_url = self::getCurrentUrl($project->domain, '/news/' . $news_info['url'] . '/');  
170 - return view('amp/news_info', compact('project_config', 'category', 'news_info', 'current_url'));  
171 - case 'blog':  
172 - //博客详情  
173 - $blog_info = self::getNewsBlogInfo($project->id, 2, $route_info->source_id);  
174 -  
175 - $current_url = self::getCurrentUrl($project->domain, '/blog/' . $blog_info['url'] . '/');  
176 - return view('amp/blog_info', compact('project_config', 'category', 'blog_info', 'current_url'));  
177 - case 'product_keyword':  
178 - //获取关键词详情  
179 - $tag_info = self::getTagInfo($project->id, $route_info->source_id);  
180 -  
181 - //获取关联产品和热门产品  
182 - $pageService = new PageService();  
183 - $products = $pageService->getRecommendAndHotProducts($project, $tag_info['route']) ?: [];  
184 -  
185 - //获取关联新闻  
186 - $news = self::getNewsBlogList($project->id, 1, 1, 2)['data'];  
187 -  
188 - //随机获取关键词列表  
189 - $relate_tags = self::getRelateTags($project->id);  
190 -  
191 - $current_url = self::getCurrentUrl($project->domain, '/' . $tag_info['route'] . '/');  
192 - return view('amp/tag', compact('project_config', 'category', 'tag_info', 'products', 'news', 'relate_tags', 'current_url'));  
193 - default:  
194 - $current_url = self::getCurrentUrl($project->domain, '/404/');  
195 - return view('amp/404', compact('project_config', 'category', 'current_url'));  
196 - }  
197 - }  
198 - }  
199 -  
200 - /**  
201 - * 拼接当前页面完整路径  
202 - * @param $domain  
203 - * @param $path  
204 - * @return string  
205 - * @author Akun  
206 - * @date 2024/03/15 15:48  
207 - */  
208 - public static function getCurrentUrl($domain, $path = '')  
209 - {  
210 - $host_array = explode('.', $domain);  
211 - if (count($host_array) <= 2) {  
212 - array_unshift($host_array, 'm');  
213 - } else {  
214 - $host_array[0] = 'm';  
215 - }  
216 - $amp_domain = implode('.', $host_array);  
217 -  
218 - return 'https://' . $amp_domain . $path;  
219 - }  
220 -  
221 - /**  
222 - * 获取站点amp配置  
223 - * @param $project_id  
224 - * @return mixed  
225 - * @author Akun  
226 - * @date 2024/01/26 16:07  
227 - */  
228 - public static function getProjectConfig($project_id)  
229 - {  
230 - $config_amp = WebSettingAmp::where('project_id', $project_id)->first();  
231 -  
232 - $config_index = WebSetting::where('project_id', $project_id)->first();  
233 -  
234 - $config_seo = WebSettingSeo::where('project_id', $project_id)->first();  
235 -  
236 - $show_news = News::where('project_id', $project_id)->where('status', 1)->count('id');  
237 -  
238 - $show_blogs = Blog::where('project_id', $project_id)->where('status', 1)->count('id');  
239 -  
240 - return [  
241 - 'show_news' => $show_news,  
242 - 'show_blogs' => $show_blogs,  
243 - 'top_backgroundcolor' => $config_amp->top_backgroundcolor ?? '',  
244 - 'web_icon' => $config_amp->web_icon ?? '',  
245 - 'top_logo' => $config_amp->top_logo ?? [],  
246 - 'index_banner' => $config_amp->index_banner ?? [],  
247 - 'index_intro' => $config_amp->index_intro ?? '',  
248 - 'company_image' => $config_amp->company_image ?? [],  
249 - 'company_about' => $config_amp->company_about ?? '',  
250 - 'company_email' => $config_amp->company_email ?? '',  
251 - 'company_address' => $config_amp->company_address ?? '',  
252 - 'company_tel' => $config_amp->company_tel ?? '',  
253 - 'third_code' => $config_amp->third_code ?? '',  
254 - 'index_title' => $config_index->title ?? '',  
255 - 'index_description' => $config_index->remark ?? '',  
256 - 'index_keywords' => $config_index->keyword ?? '',  
257 - 'single_page_suffix' => $config_seo->single_page_suffix ?? '',  
258 - 'tab_suffix' => $config_seo->tab_suffix ?? '',  
259 - 'tab_prefix' => $config_seo->tab_prefix ?? '',  
260 - 'product_cate_suffix' => $config_seo->product_cate_suffix ?? '',  
261 - 'product_cate_prefix' => $config_seo->product_cate_prefix ?? '',  
262 - 'product_suffix' => $config_seo->product_suffix ?? '',  
263 - 'product_prefix' => $config_seo->product_prefix ?? '',  
264 - ];  
265 - }  
266 -  
267 - /**  
268 - * 获取分类列表  
269 - * @param $project_id  
270 - * @return array  
271 - * @author Akun  
272 - * @date 2024/01/29 11:25  
273 - */  
274 - public static function getProductsCategory($project_id)  
275 - {  
276 - $category = [];  
277 - $result = Category::where('project_id', $project_id)->where('title', '!=', 'Featured Products')->where('status', 1)->orderBy("sort", "desc")->orderBy("id", "desc")->get();  
278 - if ($result->count() > 0) {  
279 - $result_tree = list_to_tree($result->toArray());  
280 - foreach ($result_tree as $cate) {  
281 - if ($cate['title'] == 'Products' || $cate['title'] == 'products') {  
282 - foreach ($cate['_child'] as $child) {  
283 - $category[] = $child;  
284 - }  
285 - } else {  
286 - $category[] = $cate;  
287 - }  
288 - }  
289 - }  
290 -  
291 -  
292 - return $category;  
293 - }  
294 -  
295 - /**  
296 - * 获取分类详情  
297 - * @param $project_id  
298 - * @param $category_id  
299 - * @return array  
300 - * @author Akun  
301 - * @date 2024/01/29 11:31  
302 - */  
303 - public static function getCategoryInfo($project_id, $category_id)  
304 - {  
305 - if ($category_id > 0) {  
306 - $category_info = Category::where('project_id', $project_id)->where('id', $category_id)->first();  
307 - } else {  
308 - $category_info = Category::where('project_id', $project_id)->whereIn('title', ['Products', 'products'])->first();  
309 - if ($category_info) {  
310 - $category_info->id = 0;  
311 - } else {  
312 - return [  
313 - 'id' => 0,  
314 - 'route' => 'products',  
315 - 'title' => 'Products',  
316 - 'keywords' => '',  
317 - 'describe' => '',  
318 - 'seo_title' => '',  
319 - 'seo_keywords' => '',  
320 - 'seo_description' => '',  
321 - ];  
322 - }  
323 - }  
324 -  
325 - return [  
326 - 'id' => $category_info->id ?? 0,  
327 - 'route' => $category_info->route ?? '',  
328 - 'title' => $category_info->title ?? '',  
329 - 'keywords' => $category_info->keywords ?? '',  
330 - 'describe' => $category_info->describe ?? '',  
331 - 'seo_title' => $category_info->seo_title ?? '',  
332 - 'seo_keywords' => $category_info->seo_keywords ?? '',  
333 - 'seo_description' => $category_info->seo_des ?? '',  
334 - ];  
335 - }  
336 -  
337 - /**  
338 - * 根据分类id获取产品id  
339 - * @param $category_id  
340 - * @return mixed  
341 - * @author Akun  
342 - * @date 2024/01/29 11:26  
343 - */  
344 - public static function getProductIdByCategory($category_id)  
345 - {  
346 - return CategoryRelated::where('cate_id', $category_id)->pluck('product_id')->toArray();  
347 - }  
348 -  
349 - /**  
350 - * 获取产品列表  
351 - * @param int $project_id  
352 - * @param int $page  
353 - * @param int $limit  
354 - * @param int $category_id  
355 - * @param string $search  
356 - * @return array  
357 - * @author Akun  
358 - * @date 2024/01/26 16:07  
359 - */  
360 - public static function getProductsList($project_id, $page = 1, $limit = 20, $category_id = 0, $search = '')  
361 - {  
362 - $total_page = 0;  
363 - $products = [];  
364 -  
365 - $model = Product::where('project_id', $project_id)->where('status', 1);  
366 - //根据分类id获取关联的产品id  
367 - if ($category_id > 0) {  
368 - $product_ids = self::getProductIdByCategory($category_id);  
369 - if ($product_ids) {  
370 - $model = $model->whereIn('id', $product_ids);  
371 - }  
372 - } else {  
373 - //获取所有产品需要排除掉Featured Products分类  
374 - $fp_cate_id = Category::where('title', 'Featured Products')->value('id');  
375 - $model->where('category_id', '!=', ',' . $fp_cate_id . ',');  
376 - }  
377 - //搜索条件  
378 - if ($search) {  
379 - if (strpos($search, '\\') !== false) {  
380 - $search = str_replace('\\', '\\\\', $search);  
381 - }  
382 - $model = $model->where('title', 'like', "%$search%");  
383 - }  
384 -  
385 - $count = $model->count('id');  
386 - if ($count > 0) {  
387 - $total_page = (int)ceil($count / $limit);  
388 -  
389 - //获取产品自定义排序规则  
390 - $sort_rule = self::getProductSortRule($project_id);  
391 - foreach ($sort_rule as $rk => $rv) {  
392 - $model = $model->orderBy($rk, $rv);  
393 - }  
394 -  
395 - $result = $model->select(['id', 'title', 'thumb', 'intro', 'content', 'route'])->offset(($page - 1) * $limit)->limit($limit)->get();  
396 - if ($result->count() > 0) {  
397 - foreach ($result as $value) {  
398 - $thumb = [];  
399 - if ($value->thumb) {  
400 - $thumb_arr = json_decode($value->thumb, true);  
401 - $thumb = [  
402 - 'alt' => (isset($thumb_arr['alt']) && $thumb_arr['alt']) ? $thumb_arr['alt'] : $value->title,  
403 - 'url' => getImageUrl($thumb_arr['url'] ?? '')  
404 - ];  
405 - }  
406 - $intro = $value->intro ?: $value->content;  
407 - $intro = strip_tags(special2str($intro));  
408 - $products[] = [  
409 - 'id' => $value->id,  
410 - 'title' => $value->title,  
411 - 'thumb' => $thumb,  
412 - 'route' => $value->route,  
413 - 'intro' => strlen($intro) > 200 ? substr($intro, 0, 200) . '...' : $intro,  
414 - ];  
415 - }  
416 - }  
417 - }  
418 -  
419 - $pre = max($page - 1, 1);  
420 - $next = min($page + 1, $total_page);  
421 - $center_pages = page_init($page, $total_page);  
422 -  
423 - return ['data' => $products, 'total_page' => $total_page, 'prev' => $pre, 'next' => $next, 'center_pages' => $center_pages];  
424 - }  
425 -  
426 - /**  
427 - * 获取产品自定义排序规则  
428 - * @param $project_id  
429 - * @return array|string[]  
430 - * @author Akun  
431 - * @date 2024/03/21 11:13  
432 - */  
433 - public static function getProductSortRule($project_id)  
434 - {  
435 - $order_list = [];  
436 - $orderDataFirst = SettingNum::where('project_id', $project_id)->where('type', 10)->first();  
437 - if ($orderDataFirst && $orderDataFirst->data) {  
438 - $orderData = json_decode($orderDataFirst->data, true);  
439 - foreach ($orderData as $key => $orderDataItem) {  
440 - $orderKey = $key == "created_at" ? "send_time" : $key;  
441 - $order_list[$orderKey] = $orderDataItem;  
442 - if ($key != "id") {  
443 - $order_list['id'] = 'desc';  
444 - }  
445 - }  
446 - } else {  
447 - $order_list = [  
448 - 'sort' => 'desc',  
449 - 'id' => 'desc'  
450 - ];  
451 - }  
452 -  
453 - return $order_list;  
454 - }  
455 -  
456 - /**  
457 - * 获取产品详情  
458 - * @param $project_id  
459 - * @param $id  
460 - * @return array  
461 - * @author Akun  
462 - * @date 2024/01/30 9:22  
463 - */  
464 - public static function getProductInfo($project_id, $id)  
465 - {  
466 - $gallery = [];  
467 - $seo = [  
468 - 'title' => '',  
469 - 'keywords' => '',  
470 - 'description' => ''  
471 - ];  
472 - $product_info = Product::where('project_id', $project_id)->where('status', 1)->where('id', $id)->first();  
473 - if ($product_info) {  
474 - if ($product_info->gallery) {  
475 - $gallery_arr = json_decode($product_info->gallery, true);  
476 - foreach ($gallery_arr as $vg) {  
477 - $gallery[] = [  
478 - 'alt' => (isset($vg['alt']) && $vg['alt']) ? $vg['alt'] : $product_info->title,  
479 - 'url' => getImageUrl($vg['url'] ?? '')  
480 - ];  
481 - }  
482 - }  
483 -  
484 - if ($product_info->seo_mate) {  
485 - $seo_arr = json_decode($product_info->seo_mate, true);  
486 - $seo['title'] = $seo_arr['title'] ?? '';  
487 - $seo['keywords'] = $seo_arr['keywords'] ?? '';  
488 - $seo['description'] = $seo_arr['description'] ?? '';  
489 - }  
490 - }  
491 -  
492 - return [  
493 - 'id' => $product_info->id ?? 0,  
494 - 'route' => $product_info->route ?? '',  
495 - 'gallery' => $gallery,  
496 - 'title' => $product_info->title ?? '',  
497 - 'intro' => $product_info->intro ?? '',  
498 - 'content' => $product_info->content ?? '',  
499 - 'seo' => $seo,  
500 - 'category_id' => $product_info->category_id ?? ''  
501 - ];  
502 - }  
503 -  
504 - /**  
505 - * 获取关联产品  
506 - * @param $project_id  
507 - * @param $id  
508 - * @param $category_id  
509 - * @param $limit  
510 - * @return array  
511 - * @author Akun  
512 - * @date 2024/01/30 9:34  
513 - */  
514 - public static function getRelateProducts($project_id, $id, $category_id, $limit = 2)  
515 - {  
516 - if (is_string($category_id)) {  
517 - $category_id = explode(',', $category_id);  
518 - }  
519 -  
520 - $relate_ids = CategoryRelated::whereIn('cate_id', $category_id)->where('product_id', '!=', $id)->limit($limit)->pluck('product_id')->toArray();  
521 -  
522 - $relate_products = [];  
523 - if ($relate_ids) {  
524 - $result = Product::where('project_id', $project_id)->whereIn('id', $relate_ids)->where('status', 1)->orderBy('sort', 'desc')->limit(8)->get();  
525 - if ($result->count() == 0) {  
526 - $result = Product::where('project_id', $project_id)->where('status', 1)->inRandomOrder()->take(8)->get();  
527 - }  
528 - if ($result->count() > 0) {  
529 - foreach ($result as $value) {  
530 - $thumb = '';  
531 - if ($value->thumb) {  
532 - $thumb_arr = json_decode($value->thumb, true);  
533 - $thumb = [  
534 - 'alt' => (isset($thumb_arr['alt']) && $thumb_arr['alt']) ? $thumb_arr['alt'] : $value->title,  
535 - 'url' => getImageUrl($thumb_arr['url'] ?? '')  
536 - ];  
537 - }  
538 - $relate_products[] = [  
539 - 'id' => $value->id,  
540 - 'route' => $value->route,  
541 - 'title' => $value->title,  
542 - 'thumb' => $thumb  
543 - ];  
544 - }  
545 - }  
546 - }  
547 -  
548 - return $relate_products;  
549 - }  
550 -  
551 - /**  
552 - * 获取新闻博客列表  
553 - * @param $project_id  
554 - * @param int $type  
555 - * @param int $page  
556 - * @param int $limit  
557 - * @return array  
558 - * @author Akun  
559 - * @date 2024/01/26 16:38  
560 - */  
561 - public static function getNewsBlogList($project_id, $type = 1, $page = 1, $limit = 10)  
562 - {  
563 - $total_page = 0;  
564 - $news = [];  
565 -  
566 - if ($type == 1) {  
567 - $model = new News();  
568 - } else {  
569 - $model = new Blog();  
570 - }  
571 - $count = $model->where('project_id', $project_id)->where('status', 1)->count('id');  
572 - if ($count > 0) {  
573 - $total_page = (int)ceil($count / $limit);  
574 -  
575 - $result = $model->select(['id', 'name', 'image', 'remark', 'text', 'release_at', 'created_at', 'url'])->where('project_id', $project_id)->where('status', 1)->orderBy('sort', 'desc')->orderBy('id', 'desc')->offset(($page - 1) * $limit)->limit($limit)->get();  
576 - if ($result->count() > 0) {  
577 - foreach ($result as $value) {  
578 - $remark = $value->remark ?: $value->text;  
579 - $remark = strip_tags(special2str($remark));  
580 - $news[] = [  
581 - 'type' => $type,  
582 - 'id' => $value->id,  
583 - 'name' => $value->name,  
584 - 'url' => $value->url,  
585 - 'image' => getImageUrl($value->image),  
586 - 'remark' => strlen($remark) > 200 ? substr($remark, 0, 200) . '...' : $remark,  
587 - 'release_at' => $value->release_at ? $value->release_at : $value->created_at  
588 - ];  
589 - }  
590 - }  
591 - }  
592 -  
593 - $pre = max($page - 1, 1);  
594 - $next = min($page + 1, $total_page);  
595 - $center_pages = page_init($page, $total_page);  
596 -  
597 -  
598 - return ['data' => $news, 'total_page' => $total_page, 'prev' => $pre, 'next' => $next, 'center_pages' => $center_pages];  
599 - }  
600 -  
601 - /**  
602 - * 获取新闻博客详情  
603 - * @param $project_id  
604 - * @param $type  
605 - * @param $id  
606 - * @return array  
607 - * @author Akun  
608 - * @date 2024/01/30 11:17  
609 - */  
610 - public static function getNewsBlogInfo($project_id, $type, $id)  
611 - {  
612 - if ($type == 1) {  
613 - $model = new News();  
614 - } else {  
615 - $model = new Blog();  
616 - }  
617 -  
618 - $news_info = $model->where('project_id', $project_id)->where('status', 1)->where('id', $id)->first();  
619 -  
620 - $release_at = '';  
621 - if (isset($news_info->release_at) && $news_info->release_at) {  
622 - $release_at = $news_info->release_at;  
623 - } elseif (isset($news_info->created_at) && $news_info->created_at) {  
624 - $release_at = $news_info->created_at;  
625 - }  
626 -  
627 - return [  
628 - 'id' => $news_info->id ?? 0,  
629 - 'name' => $news_info->name ?? '',  
630 - 'sort' => $news_info->sort ?? 0,  
631 - 'url' => $news_info->url ?? 0,  
632 - 'text' => $news_info->text ?? '',  
633 - 'image' => getImageUrl($news_info->image ?? ''),  
634 - 'seo_title' => $news_info->seo_title ?? '',  
635 - 'seo_keywords' => $news_info->seo_keywords ?? '',  
636 - 'seo_description' => $news_info->seo_description ?? '',  
637 - 'release_at' => $release_at  
638 - ];  
639 - }  
640 -  
641 - /**  
642 - * 获取关键词详情  
643 - * @param $project_id  
644 - * @param $id  
645 - * @return array  
646 - * @author Akun  
647 - * @date 2024/01/30 16:17  
648 - */  
649 - public static function getTagInfo($project_id, $id)  
650 - {  
651 - $tag_info = Keyword::where('project_id', $project_id)->where('status', 1)->where('id', $id)->first();  
652 -  
653 - return [  
654 - 'id' => $tag_info->id ?? 0,  
655 - 'route' => $tag_info->route ?? '',  
656 - 'title' => $tag_info->title ?? '',  
657 - 'keyword_title' => $tag_info->keyword_title ?? '',  
658 - 'keyword_content' => $tag_info->keyword_content ?? '',  
659 - 'seo_title' => $tag_info->seo_title ?? '',  
660 - 'seo_keywords' => $tag_info->seo_keywords ?? '',  
661 - 'seo_description' => $tag_info->seo_description ?? '',  
662 - ];  
663 - }  
664 -  
665 - /**  
666 - * 获取关联关键词  
667 - * @param $project_id  
668 - * @return mixed  
669 - * @author Akun  
670 - * @date 2024/01/30 18:30  
671 - */  
672 - public static function getRelateTags($project_id)  
673 - {  
674 - return Keyword::select(['id', 'title', 'route'])->where('project_id', $project_id)->where('status', 1)->inRandomOrder()->take(10)->get()->toArray();  
675 - }  
676 -}  
1 -<?php  
2 -  
3 -  
4 -namespace App\Services\Html;  
5 -  
6 -use App\Helper\Translate;  
7 -use App\Models\Com\UpdateProgress;  
8 -use App\Models\Project\DeployBuild;  
9 -use App\Models\Project\DeployOptimize;  
10 -use App\Models\Project\DomainInfo;  
11 -use App\Models\Project\Project;  
12 -use App\Models\RouteMap\RouteMap;  
13 -use App\Models\WebSetting\Proofreading;  
14 -use App\Models\WebSetting\WebLanguage;  
15 -use App\Models\WebSetting\WebProofreading;  
16 -use App\Models\WebSetting\WebSetting;  
17 -use App\Models\WebSetting\WebSettingCountry;  
18 -use App\Models\WebSetting\WebSettingHtml;  
19 -use App\Models\WebSetting\WebSettingText;  
20 -use App\Models\WebSetting\WebTemplateCommon;  
21 -use App\Services\ProjectServer;  
22 -use Illuminate\Support\Facades\Redis;  
23 -use phpQuery;  
24 -  
25 -/**  
26 - * 生成静态页相关  
27 - */  
28 -class CommonService  
29 -{  
30 -  
31 - /**  
32 - * 翻译  
33 - */  
34 - public function webHtmlTranslate($project,$content, $lang,$domain)  
35 - {  
36 - //翻译过滤器  
37 - $lang = $lang == "zh-ct" ? "zh-TW" : $lang;  
38 - $tlsList = Translate::$tls_list;  
39 - if (isset($tlsList[$lang])){  
40 - $main_lang = $project->main_lang_id;  
41 - $mainLangInfo = WebLanguage::getProjectMainLang($main_lang);  
42 - $master_lang = $mainLangInfo ? $mainLangInfo->short : 'en';  
43 - //翻译  
44 - if ($master_lang != 'en') {  
45 - $result = Translate::translate($content, $lang, $master_lang);  
46 - $content = $result[0]['texts'] ?? '';  
47 - } else {  
48 - $content = Translate::tran($content, $lang);  
49 - }  
50 - // 翻译有时会返回空数据 再翻译一次 FIXME 后续需要重新封装  
51 - if (empty($content)) {  
52 - $result = Translate::translate($content, $lang, $master_lang);  
53 - $content = $result[0]['texts'] ?? '';  
54 - }  
55 -  
56 - //翻译校对  
57 - $content = $this->translationProofread($project,$content,$lang,$domain);  
58 - }  
59 - return $content;  
60 - }  
61 -  
62 - /**  
63 - * 翻译校对  
64 - */  
65 - public function translationProofread($project, $content, $lang,$domain)  
66 - {  
67 - $webProofreading = Proofreading::where("project_id",$project->id)->where("alias",$lang)->get();  
68 - if (!empty($webProofreading)){  
69 - foreach ($webProofreading as $item){  
70 - $content = str_ireplace($item->text,$item->translate,$content);  
71 - }  
72 - }  
73 - return $content;  
74 - }  
75 -  
76 - /**  
77 - * 处理第三方代码  
78 - */  
79 - public function thirdPartyCodeHandle($project,$content,$route,$routeMap=null): string  
80 - {  
81 - if (Redis::get("project_".$project->id."_third_party_code") != null){  
82 - $webSettingHtml = json_decode(Redis::get("project_".$project->id."_third_party_code"));  
83 - }else{  
84 - $webSettingHtml = WebSettingHtml::where("project_id",$project->id)->first();  
85 - Redis::set("project_".$project->id."_third_party_code", json_encode($webSettingHtml));  
86 - Redis::expire("project_".$project->id."_third_party_code", WebSetting::$redisExpireTime);  
87 - }  
88 - $phpQueryDom = phpQuery::newDocument($content);  
89 - //网站icon  
90 - $webIcon = WebSetting::where("project_id",$project->id)->first();  
91 - if (!empty($webIcon)){  
92 - $iconDom = $phpQueryDom->find("link[rel=icon]");  
93 - if (count($iconDom) >= 1){  
94 - if (isset($webIcon->web_site_icon) && !empty($webIcon->web_site_icon) && $webIcon->web_site_icon != "" && $webIcon->web_site_icon != 0){  
95 - $iconDom->attr("href",$webIcon->web_site_icon);  
96 - }else{  
97 - $iconDom->attr("href","");  
98 - }  
99 - }  
100 - }  
101 - //第三方代码(网页顶部,中间,底部),以后启用位置  
102 - if (!empty($webSettingHtml)) {  
103 - $phpQueryDom->find('head')->append($webSettingHtml->head_html?:'');  
104 - $phpQueryDom->find('body')->append($webSettingHtml->body_html?:'');  
105 - $phpQueryDom->find('html')->append($webSettingHtml->footer_html?:'');  
106 - }  
107 - //A端添加的网站追踪代码  
108 - $deployOptimize = DeployOptimize::where("project_id",$project->id)->first();  
109 - if (!empty($deployOptimize)){  
110 - if (isset($deployOptimize->meta) && !empty($deployOptimize->meta)){  
111 - $phpQueryDom->find('head')->append($deployOptimize->meta);  
112 - }  
113 - }  
114 - //首页头部独立样式  
115 - if ($route == "index"){  
116 - $phpQueryDom->find('header')->attr("headerprivate","");  
117 - }  
118 - //处理header顶部搜索跳转链接  
119 - $phpQueryDom->find('header form')->attr("action", "/search/");  
120 - //C端访问埋点  
121 - $isBodyEnd = $phpQueryDom->find('body')->eq(0);  
122 - if (count($isBodyEnd)>=1){  
123 - $phpQueryDom->find('body')->append("<script src='https://ecdn6.globalso.com/public/customerVisit.min.js'></script>");  
124 - }else{  
125 - $phpQueryDom->find('html')->append("<script src='https://ecdn6.globalso.com/public/customerVisit.min.js'></script>");  
126 - }  
127 - $data = date("Y-m-d H:i:s");  
128 - $phpQueryDom->find('html')->append("<!-- Globalso Cache file was created on ".$data." -->");  
129 - //这个功能其他类型页面移到面包屑导航处理  
130 - if ($route == "index" || (!empty($routeMap) && $routeMap->source == RouteMap::SOURCE_PAGE)){  
131 - $phpQueryDom->find('head')->append('<script>var currentPage = "'.$route.'"</script>');  
132 - }  
133 - if ($route == "search"){  
134 - //暂时先去掉小语种按钮显示  
135 - $phpQueryDom->find(".change-language")->remove();  
136 - $phpQueryDom->find('head')->append('<meta name="robots" content="noindex, nofollow"/>');  
137 - }  
138 - $phpQueryDom->find('body')->attr("unevents","");  
139 - $content = $phpQueryDom->htmlOuter();  
140 - unset($phpQueryDom);  
141 - phpQuery::unloadDocuments();  
142 - //处理全部内容,如果有上线正式域名,则把所有的测试域名替换为正式域名  
143 - $projectDomainInfo = DomainInfo::where("project_id",$project->id)->first();  
144 - if (!empty($projectDomainInfo)){  
145 - $deployBuild = DeployBuild::where("project_id",$project->id)->first();  
146 - if (!empty($deployBuild)){  
147 - $parsedUrl = parse_url($deployBuild->test_domain);  
148 - $domain = $projectDomainInfo->domain;  
149 - $testDomain = $parsedUrl['host'];  
150 - if ($domain != '' && $testDomain != ''){  
151 - $content = str_replace($testDomain,$domain,$content);  
152 - }  
153 - }  
154 - }  
155 - return $content;  
156 - }  
157 -  
158 - /**  
159 - * 处理锚文本  
160 - */  
161 - public function anchorTextHandle($project,$route,$content): string  
162 - {  
163 - $source = "";  
164 - //解析路由  
165 - if ($route != "index"){  
166 - $routerNewsMap = RouteMap::where("project_id",$project->id)->where("route",$route)->first();  
167 - if (!empty($routerNewsMap)){  
168 - $source = $routerNewsMap->source;  
169 - }  
170 - }else{  
171 - $source = "index";  
172 - }  
173 -  
174 - //判断来源类型  
175 - switch ($source) {  
176 - case 'news_category' || 'news':  
177 - $num = 4;  
178 - break;  
179 - case 'product_category' || 'product':  
180 - $num = 2;  
181 - break;  
182 - case 'blog_category' || 'blog':  
183 - $num = 6;  
184 - break;  
185 - case 'page':  
186 - $num = 1;  
187 - break;  
188 - default:  
189 - $num = 1;  
190 - }  
191 -  
192 - //网站设置锚文本  
193 - $webSetting = WebSetting::getWebSetting($project);  
194 - if (!empty($webSetting)){  
195 - $anchorIsEnable = $webSetting->anchor_is_enable;  
196 - if ($anchorIsEnable == 0){  
197 - $anchorSetting = $webSetting->anchor_setting;  
198 - $anchorSettingArr = explode(',', substr($anchorSetting, 1, -1));  
199 - foreach ($anchorSettingArr as $item){  
200 - $itemArr = explode('"', substr($item, 1, -1));  
201 - $tracingText[] = intval($itemArr[0]);  
202 - }  
203 - if (in_array($num, $tracingText)) {  
204 - $webSettingText = WebSettingText::getWebSettingText($project);  
205 - $phpQueryDom=phpQuery::newDocument($content);  
206 - $mainElement = $phpQueryDom->find('main');  
207 - $con = $mainElement->html();  
208 - if (!empty($webSettingText)){  
209 - foreach ($webSettingText as $v){  
210 - $con = str_replace( $v->key_words, '<a target="_blank" href="'. $v->url.'">'. $v->key_words.'</a>', $con);  
211 - }  
212 - }  
213 - $mainElement->html($con);  
214 - return $phpQueryDom->htmlOuter();  
215 - }  
216 - }  
217 - }  
218 - return $content;  
219 - }  
220 -  
221 - /**  
222 - * 链接项目  
223 - */  
224 - public function connectProject($updateData)  
225 - {  
226 - $project = null;  
227 - $projectIn = Project::getProjectByDomain($updateData->domain);  
228 - if (!empty($projectIn)){  
229 - $project = Project::where("id",$projectIn->project_id)->first();  
230 - if (!empty($project)){  
231 - $project->domain = $updateData->domain;  
232 - }  
233 - ProjectServer::useProject($project->id);  
234 - }  
235 - return $project;  
236 - }  
237 -  
238 - /**  
239 - * 获取小语种更新国家  
240 - */  
241 - public function getMinorLanguage($updateData)  
242 - {  
243 - $minorLanguage = [];  
244 - $updateProgressQuery = UpdateProgress::find($updateData->id);  
245 - if (!empty($updateProgressQuery)){  
246 - $extends = $updateProgressQuery->extends;  
247 - if (!empty($extends)){  
248 - $extends = json_decode($extends);  
249 - if (isset($extends->language) && !empty($extends->language)){  
250 - $language = $extends->language;  
251 - foreach ($language as $lang){  
252 - $minorLanguage[] = (int)$lang;  
253 - }  
254 - }  
255 - }  
256 - }  
257 - return WebSettingCountry::whereIn("id", $minorLanguage)->get();  
258 - }  
259 -}  
1 -<?php  
2 -  
3 -namespace App\Services\Html;  
4 -  
5 -  
6 -  
7 -use phpDocumentor\Reflection\Project;  
8 -  
9 -/**  
10 - * 生成页面  
11 - */  
12 -class CreateHtmlService{  
13 - /**  
14 - * 获取页面  
15 - */  
16 - public function getHtml($projectId, $route, $lang = "", $page = null)  
17 - {  
18 - $project = Project::find($projectId);  
19 - $createPageService = new CreatePageService();  
20 - return $createPageService->getPageByLangRoutePage($project,$route,$page);  
21 - }  
22 -}  
1 -<?php  
2 -  
3 -  
4 -namespace App\Services\Html;  
5 -  
6 -use App\Models\Blog\Blog;  
7 -use App\Models\Collect\CollectTask;  
8 -use App\Models\Com\Notify;  
9 -use App\Models\Com\UpdateNotify;  
10 -use App\Models\Com\UpdateProgress;  
11 -use App\Models\CustomModule\CustomModuleContent;  
12 -use App\Models\CustomModule\CustomModuleCategory;  
13 -use App\Models\News\News;  
14 -use App\Models\News\NewsCategory;  
15 -use App\Models\Product\Category;  
16 -use App\Models\Product\CategoryRelated;  
17 -use App\Models\Product\Keyword;  
18 -use App\Models\Product\Product;  
19 -use App\Models\Project\CountryCustom;  
20 -use App\Models\Project\DeployBuild;  
21 -use App\Models\Project\Project;  
22 -use App\Models\Project\UpdateMasterWebsiteModel;  
23 -use App\Models\Project\UpdateMinorLanguagesModel;  
24 -use App\Models\RouteMap\RouteMap;  
25 -use App\Models\Template\BCustomTemplate;  
26 -use App\Models\Template\BTemplate;  
27 -use App\Models\Template\Setting;  
28 -use App\Models\WebSetting\SettingNum;  
29 -use App\Models\WebSetting\WebLanguage;  
30 -use App\Repositories\StaticHtmlRepository;  
31 -use Illuminate\Support\Facades\File;  
32 -use phpQuery;  
33 -use stdClass;  
34 -  
35 -/**  
36 - * C端生成页面服务  
37 - */  
38 -class CreatePageService{  
39 -  
40 - /**  
41 - * 获取升级项目小语种采集的页面  
42 - * @param $project  
43 - * @param $route  
44 - * @param $source  
45 - * @param $lang  
46 - * @return string  
47 - * @author Akun  
48 - * @date 2024/01/08 11:40  
49 - */  
50 - public function getMinorLanguagePage($project,$route,$source,$lang){  
51 - if($project['update_info']['is_language_update'] == 0){  
52 - return '';  
53 - }  
54 - if ($source == 'news' || $source == 'blog' || $source == 'product' || $source == 'page' || $source == 'module'){  
55 - $routerMap = RouteMap::where("project_id",$project->id)->where("route",$route)->where("source",$source)->first();  
56 - }elseif($source == ''){  
57 - $routerMap = RouteMap::where("project_id",$project->id)->where("route",$route)->whereIn("source",["product","page","module"])->orderBy('source','desc')->first();  
58 - }else{  
59 - return '';  
60 - }  
61 - if($routerMap) {  
62 - switch ($routerMap->source) {  
63 - //产品详情  
64 - case RouteMap::SOURCE_PRODUCT:  
65 - $detail = Product::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",1)->first();  
66 - break;  
67 - //博客详情  
68 - case RouteMap::SOURCE_BLOG:  
69 - $detail = Blog::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",1)->first();  
70 - break;  
71 - //新闻详情  
72 - case RouteMap::SOURCE_NEWS:  
73 - $detail = News::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",1)->first();  
74 - break;  
75 - //自定义模块详情  
76 - case RouteMap::SOURCE_MODULE:  
77 - $detail = Module::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",0)->first();  
78 - break;  
79 - default:  
80 - //单页详情  
81 - $detail = BCustomTemplate::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",1)->first();  
82 - }  
83 - if($detail && $detail->six_read){  
84 - return $this->getOldHtml($project,$routerMap,$project['update_info']['old_domain_test'],$project['update_info']['old_domain_online'],$lang);  
85 - }else{  
86 - return '';  
87 - }  
88 - }else{  
89 - return '';  
90 - }  
91 - }  
92 -  
93 - /**  
94 - * 根据语言,路由,分页数,获取页面内容  
95 - */  
96 - public function getPageByLangRoutePage($project,$route,$page=null,$source=""): string  
97 - {  
98 - $html = "";  
99 - $page = $page == null ? null : (int)$page;  
100 - $router = $route == "" ? "404" : $route;  
101 - $productKeywordRouter = new Keyword();  
102 - $productKeywordRouters = $productKeywordRouter->product_keyword_route;  
103 - if (in_array($router, $productKeywordRouters)) {  
104 - $html = $this->getProductKeywordListPage($project,$router,$page);  
105 - unset($productKeywordRouter);  
106 - } else {  
107 - //新增:products,news,blog 三个路由为C端固定路由,数据库路由表没有路由也可以访问或调数据  
108 - if ($router == "products" || $router == "news" || $router == "blog"){  
109 - $routerMap = RouteMap::where("project_id",$project->id)->where("route",$router)->first();  
110 - $routerMapRegular = new stdClass();  
111 - if (empty($routerMap)){  
112 - if ($router == "products"){  
113 - $routerMapRegular->source = RouteMap::SOURCE_PRODUCT_CATE;  
114 - $routerMapRegular->route = "products";  
115 - }  
116 - if ($router == "news"){  
117 - $routerMapRegular->source = RouteMap::SOURCE_NEWS_CATE;  
118 - $routerMapRegular->route = "news";  
119 - }  
120 - if ($router == "blog"){  
121 - $routerMapRegular->source = RouteMap::SOURCE_BLOG_CATE;  
122 - $routerMapRegular->route = "blog";  
123 - }  
124 - $routerMapRegular->source_id = 0;  
125 - $routerMapRegular->project_id = $project->id;  
126 - $routerMap = $routerMapRegular;  
127 - unset($routerMapRegular);  
128 - }  
129 - }else{  
130 - if ($project->update_info["is_update"] == 1){  
131 - if ($source != ""){  
132 - //$source可能值:news,blog,news_category,blog_category  
133 - $routerMap = RouteMap::where("project_id",$project->id)->where("route",$router)->where("source",$source)->first();  
134 - }else{  
135 - //product_category,product,page,product_keyword,module_category,module  
136 - $routerMap = RouteMap::where("project_id",$project->id)->where("route",$router)->whereIn("source",["product","product_category","page","module_category","module","product_keyword"])->orderByRaw("FIELD(source, 'product_category','product','module_category','module','page','product_keyword')")->first();  
137 - }  
138 - if (empty($routerMap)){  
139 - $routerMap = RouteMap::where("project_id",$project->id)->where("route",$router)->first();  
140 - }  
141 - }else{  
142 - //6.0  
143 - $routerMap = RouteMap::where("project_id",$project->id)->where("route",$router)->first();  
144 - }  
145 - }  
146 -  
147 - if (!empty($routerMap)){  
148 - $type = $routerMap->source;  
149 - switch ($type) {  
150 - //产品详情  
151 - case RouteMap::SOURCE_PRODUCT:  
152 - $html = $this->getProductPage($project,$routerMap);  
153 - break;  
154 - //产品列表  
155 - case RouteMap::SOURCE_PRODUCT_CATE:  
156 - $html = $this->getProductListPage($project,$routerMap,$page);  
157 - break;  
158 - //博客详情  
159 - case RouteMap::SOURCE_BLOG:  
160 - $html = $this->getBlogPage($project,$routerMap);  
161 - break;  
162 - //博客列表  
163 - case RouteMap::SOURCE_BLOG_CATE:  
164 - $html = $this->getBlogListPage($project,$routerMap,$page);  
165 - break;  
166 - //新闻详情  
167 - case RouteMap::SOURCE_NEWS:  
168 - $html = $this->getNewsPage($project,$routerMap);  
169 - break;  
170 - //新闻列表  
171 - case RouteMap::SOURCE_NEWS_CATE:  
172 - $html = $this->getNewsListPage($project,$routerMap,$page);  
173 - break;  
174 - //自定义模块列表  
175 - case RouteMap::SOURCE_MODULE_CATE:  
176 - $html = $this->getModuleListPage($project,$routerMap,$page);  
177 - break;  
178 - //自定义模块详情  
179 - case RouteMap::SOURCE_MODULE:  
180 - $html = $this->getModulePage($project,$routerMap);  
181 - break;  
182 - //聚合页  
183 - case RouteMap::SOURCE_PRODUCT_KEYWORD:  
184 - $html = $this->getProductKeywordPage($project,$routerMap);  
185 - break;  
186 - case RouteMap::SOURCE_PAGE:  
187 - if ($router == RouteMap::SOURCE_INDEX){  
188 - //首页  
189 - $html = $this->getIndexPage($project,$routerMap);  
190 - }else{  
191 - //单页面  
192 - $html = $this->getSinglePage($project,$routerMap);  
193 - }  
194 - break;  
195 - default:  
196 - $html = $this->getSinglePage($project,$routerMap);  
197 - }  
198 - }  
199 - }  
200 - return $html;  
201 - }  
202 -  
203 - /**  
204 - * 获取首页html  
205 - */  
206 - public function getIndexPage($project,$routerMap): string  
207 - {  
208 - $pageService = new PageService();  
209 - $commonService = new CommonService();  
210 - $tdkService = new TdkService();  
211 - //首页模板  
212 - $info = Setting::where("project_id",$project->id)->first();  
213 - if (empty($info)){  
214 - return "";  
215 - }  
216 - $webIndexTemplate = BTemplate::where("project_id",$project->id)->where("template_id",$info->template_id)->where("source",1)->first();  
217 - if (!empty($webIndexTemplate)){  
218 - $html = $pageService->isAndGetVisualizationHtml($project,RouteMap::SOURCE_INDEX,$routerMap);  
219 - if ($html == ""){  
220 - //组装首页页面  
221 - $html = $pageService->assembleIndexPage($project,$webIndexTemplate);  
222 - }  
223 - //公共处理  
224 - $html = $pageService->publicHtmlHandle($html,$project->id);  
225 - $isVisual = $pageService->isOpenVisualization($project,RouteMap::SOURCE_INDEX);  
226 - if ((int)$isVisual == 1 || $isVisual == null){  
227 - //产品,产品分类,新闻,博客(section模板通用数据模块处理)  
228 - $html = $pageService->generalTemplateProcessingForDataModules($html,$project->id);  
229 - }  
230 - //第三方  
231 - $html = $commonService->thirdPartyCodeHandle($project,$html,RouteMap::SOURCE_INDEX);  
232 - //TDK处理  
233 - $html = $tdkService->pageTdkHandle($project,$html,RouteMap::SOURCE_INDEX,$routerMap);  
234 - if (!empty($html)){  
235 - return $this->pageUrlHandle($project,$routerMap,$html);  
236 - }else{  
237 - return "";  
238 - }  
239 - }else{  
240 - return "";  
241 - }  
242 - }  
243 -  
244 - /**  
245 - * 获取产品列表页html  
246 - */  
247 - public function getProductListPage($project,$routerMap,$page): string  
248 - {  
249 - $pageService = new PageService();  
250 - $commonService = new CommonService();  
251 - $tdkService = new TdkService();  
252 - //公共拼接页面方法  
253 - $webCustomHtml = $pageService->publicMontagePage($project,RouteMap::SOURCE_PRODUCT_CATE,$routerMap);  
254 - //公共面包屑导航,左侧导航处理,内页banner背景图,列表页分页  
255 - $webCustomHtml = $pageService->publicMdAndLeftNavInnerImageListDetailsDataHandle($webCustomHtml,$project,RouteMap::SOURCE_PRODUCT_CATE,$routerMap,$page);  
256 - //是否开启可视化  
257 - $isVisual = $pageService->isOpenVisualization($project,RouteMap::SOURCE_PRODUCT_CATE);  
258 - if ((int)$isVisual == 1 || $isVisual == null){  
259 - //产品,产品分类,新闻,博客(section模板通用数据模块处理)  
260 - $webCustomHtml = $pageService->generalTemplateProcessingForDataModules($webCustomHtml,$project->id);  
261 - }  
262 - $webCustomHtml = $tdkService->pageTdkHandle($project,$webCustomHtml,RouteMap::SOURCE_PRODUCT_CATE,$routerMap);  
263 - $webCustomHtml = $pageService->publicHtmlHandle($webCustomHtml,$project->id);  
264 - unset($pageService);  
265 - $html = $commonService->thirdPartyCodeHandle($project,$webCustomHtml,$routerMap->route);  
266 - //处理URL等,处理html链接a标签href  
267 - if (!empty($html)){  
268 - return $this->pageUrlHandle($project,$routerMap,$html,"",$page);  
269 - }else{  
270 - return "";  
271 - }  
272 - }  
273 -  
274 - /**  
275 - * 获取产品页html  
276 - */  
277 - public function getProductPage($project,$routerMap,$lang=''): string  
278 - {  
279 - $pageService = new PageService();  
280 - $commonService = new CommonService();  
281 - $products_detail = Product::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",1)->whereNotNull('route')->first();  
282 - if($project['update_info']['is_update'] && $products_detail && $products_detail->six_read){  
283 - return $this->getOldHtml($project,$routerMap,$project['update_info']['old_domain_test'],$project['update_info']['old_domain_online'],$lang);  
284 - }else{  
285 - $products_detail = $pageService->productDataHandle($project,$products_detail);  
286 - if (!empty($products_detail)){  
287 - //公共拼接页面方法  
288 - $webCustomHtml = $pageService->publicMontagePage($project,RouteMap::SOURCE_PRODUCT,$routerMap);  
289 - //公共面包屑导航,左侧导航处理,内页banner背景图,列表页分页  
290 - $webCustomHtml = $pageService->publicMdAndLeftNavInnerImageListDetailsDataHandle($webCustomHtml,$project,"product",$routerMap,null);  
291 - $isVisual = $pageService->isOpenVisualization($project,RouteMap::SOURCE_PRODUCT);  
292 - if ((int)$isVisual == 1 || $isVisual == null){  
293 - //产品,产品分类,新闻,博客(section模板通用数据模块处理)  
294 - $webCustomHtml = $pageService->generalTemplateProcessingForDataModules($webCustomHtml,$project->id);  
295 - }  
296 - $webCustomHtml = $pageService->productsDetailTdkHandle($project,$webCustomHtml,$products_detail);  
297 - $webCustomHtml = $pageService->publicHtmlHandle($webCustomHtml,$project->id);  
298 - unset($pageService);  
299 - $html = $commonService->thirdPartyCodeHandle($project,$webCustomHtml,$routerMap->route);  
300 - //处理URL等,处理html链接a标签href  
301 - if (!empty($html)){  
302 - return $this->pageUrlHandle($project,$routerMap,$html);  
303 - }else{  
304 - return "";  
305 - }  
306 - }else{  
307 - return "";  
308 - }  
309 - }  
310 - }  
311 -  
312 - /**  
313 - * 获取产品关键词页html  
314 - */  
315 - public function getProductKeywordPage($project,$routerMap): string  
316 - {  
317 - $pageService = new PageService();  
318 - $commonService = new CommonService();  
319 - $keywordModel = new Keyword();  
320 - $tdkService = new TdkService();  
321 - $routePath = $routerMap->route;  
322 -  
323 - //公共头部底部  
324 - $publicTemplate = $pageService->getPublicTemplate($project);  
325 - $headerHtml = $publicTemplate->headerHtml;  
326 - $footerHtml = $publicTemplate->footerHtml;  
327 - //关键词详情  
328 - $keywordsDetails = $pageService->getKeywordDetails($project, $routerMap->route);  
329 - if (!empty($keywordsDetails)){  
330 - if (!empty($keywordsDetails->embed_code)){  
331 - $videoUrl = $keywordsDetails->embed_code;  
332 - preg_match('/src="([^"]+)"/', $videoUrl, $matches);  
333 - $src = $matches[1];  
334 - $keywordsDetails->video = $src;  
335 - }  
336 - //随机获取关键词列表  
337 - $productsKeywordsList = $keywordModel->getProductsKeywordsList($project);  
338 - //调整为相关产品  
339 - $productsRecommendAndHot = $pageService->getRecommendAndHotProducts($project,$routePath);  
340 - //博客新闻数据  
341 - $blogT = $pageService->getProductsBlogNews($project);  
342 - $viewPath = isset($keywordsDetails->video) && !empty($keywordsDetails->video) ? "products/products_video_keywords" : "products/products_keywords";  
343 - $html = view($viewPath, compact("headerHtml", "footerHtml", "routePath", "productsKeywordsList", "productsRecommendAndHot", "blogT","keywordsDetails"))->__toString();  
344 - $html = $pageService->publicHtmlHandle($html, $project->id);  
345 - //生成静态页  
346 - $webCustomHtml = $commonService->thirdPartyCodeHandle($project, $html, $routerMap->route);  
347 - //TDK  
348 - unset($html,$productsKeywordsList,$productsRecommendAndHot,$blogT);  
349 - $html = $tdkService->pageTdkHandle($project,$webCustomHtml,RouteMap::SOURCE_PRODUCT_KEYWORD,$routerMap);  
350 - //处理URL等,处理html链接a标签href  
351 - if (!empty($html)){  
352 - return $this->pageUrlHandle($project,$routerMap,$html);  
353 - }else{  
354 - return "";  
355 - }  
356 - }else{  
357 - return "";  
358 - }  
359 - }  
360 -  
361 - /**  
362 - * 获取产品新闻列表页html  
363 - */  
364 - public function getNewsListPage($project,$routerMap,$page): string  
365 - {  
366 - $pageService = new PageService();  
367 - $commonService = new CommonService();  
368 - $tdkService = new TdkService();  
369 - $routePath = $routerMap->route;  
370 - //公共拼接页面方法  
371 - $webCustomHtml = $pageService->publicMontagePage($project,RouteMap::SOURCE_NEWS_CATE,$routerMap);  
372 - //公共面包屑导航,左侧导航处理,内页banner背景图,列表页分页  
373 - $webCustomHtml = $pageService->publicMdAndLeftNavInnerImageListDetailsDataHandle($webCustomHtml,$project,RouteMap::SOURCE_NEWS_CATE,$routerMap,$page);  
374 - $isVisual = $pageService->isOpenVisualization($project,RouteMap::SOURCE_NEWS_CATE);  
375 - if ((int)$isVisual == 1 || $isVisual == null){  
376 - //产品,产品分类,新闻,博客(section模板通用数据模块处理)  
377 - $webCustomHtml = $pageService->generalTemplateProcessingForDataModules($webCustomHtml,$project->id);  
378 - }  
379 - $webCustomHtml = $tdkService->pageTdkHandle($project,$webCustomHtml,RouteMap::SOURCE_NEWS_CATE,$routerMap);  
380 - $webCustomHtml = $pageService->publicHtmlHandle($webCustomHtml,$project->id);  
381 - unset($pageService);  
382 - $html = $commonService->thirdPartyCodeHandle($project,$webCustomHtml,$routePath);  
383 - //处理URL等,处理html链接a标签href  
384 - if (!empty($html)){  
385 - return $this->pageUrlHandle($project,$routerMap,$html,"",$page);  
386 - }else{  
387 - return "";  
388 - }  
389 -  
390 - }  
391 -  
392 - /**  
393 - * 自定义模块列表  
394 - */  
395 - public function getModuleListPage($project,$routerMap,$page): string  
396 - {  
397 - $pageService = new PageService();  
398 - $commonService = new CommonService();  
399 - $tdkService = new TdkService();  
400 - $routePath = $routerMap->route;  
401 - //公共拼接页面方法  
402 - $webCustomHtml = $pageService->publicMontagePage($project,RouteMap::SOURCE_MODULE_CATE,$routerMap);  
403 - //公共面包屑导航,左侧导航处理,内页banner背景图,列表页分页  
404 - $webCustomHtml = $pageService->publicMdAndLeftNavInnerImageListDetailsDataHandle($webCustomHtml,$project,RouteMap::SOURCE_MODULE_CATE,$routerMap,$page);  
405 - $moduleCategoryInfo = CustomModuleCategory::getModuleCategoryAndExtendById($project->id,$routerMap->source_id);  
406 - if (isset($moduleCategoryInfo->getExtend->list_visualization) && $moduleCategoryInfo->getExtend->list_visualization == 1){  
407 - //产品,产品分类,新闻,博客(section模板通用数据模块处理)  
408 - $webCustomHtml = $pageService->generalTemplateProcessingForDataModules($webCustomHtml,$project->id);  
409 - }  
410 -  
411 - $webCustomHtml = $tdkService->pageTdkHandle($project,$webCustomHtml,RouteMap::SOURCE_MODULE_CATE,$routerMap);  
412 - $webCustomHtml = $pageService->publicHtmlHandle($webCustomHtml,$project->id);  
413 - unset($pageService);  
414 - $html = $commonService->thirdPartyCodeHandle($project,$webCustomHtml,$routePath);  
415 - //处理URL等,处理html链接a标签href  
416 - if (!empty($html)){  
417 - return $this->pageUrlHandle($project,$routerMap,$html,"",$page);  
418 - }else{  
419 - return "";  
420 - }  
421 - }  
422 -  
423 - /**  
424 - * 获取新闻页html  
425 - */  
426 - public function getNewsPage($project,$routerMap,$lang=''): string  
427 - {  
428 - $pageService = new PageService();  
429 - $commonService = new CommonService();  
430 - $tdkService = new TdkService();  
431 - //页面路由  
432 - $routePath = $routerMap->route;  
433 - $news_detail = News::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",1)->first();  
434 - if (!empty($news_detail)){  
435 - if($project['update_info']['is_update'] && $news_detail->six_read){  
436 - return $this->getOldHtml($project,$routerMap,$project['update_info']['old_domain_test'],$project['update_info']['old_domain_online'],$lang);  
437 - }else{  
438 - //公共拼接页面方法  
439 - $webCustomHtml = $pageService->publicMontagePage($project,RouteMap::SOURCE_NEWS,$routerMap);  
440 - //公共面包屑导航,左侧导航处理,内页banner背景图,列表页分页  
441 - $webCustomHtml = $pageService->publicMdAndLeftNavInnerImageListDetailsDataHandle($webCustomHtml,$project,RouteMap::SOURCE_NEWS,$routerMap,null);  
442 - $isVisual = $pageService->isOpenVisualization($project,RouteMap::SOURCE_NEWS);  
443 - if ((int)$isVisual == 1 || $isVisual == null){  
444 - //产品,产品分类,新闻,博客(section模板通用数据模块处理)  
445 - $webCustomHtml = $pageService->generalTemplateProcessingForDataModules($webCustomHtml,$project->id);  
446 - }  
447 - //TDK处理  
448 - $webCustomHtml = $tdkService->pageTdkHandle($project,$webCustomHtml,RouteMap::SOURCE_NEWS,$routerMap);  
449 - //网页公共部分  
450 - $webCustomHtml = $pageService->publicHtmlHandle($webCustomHtml,$project->id);  
451 - unset($pageService);  
452 - $html = $commonService->thirdPartyCodeHandle($project,$webCustomHtml,$routePath);  
453 - //处理URL等,处理html链接a标签href  
454 - if (!empty($html)){  
455 - return $this->pageUrlHandle($project,$routerMap,$html);  
456 - }else{  
457 - return "";  
458 - }  
459 - }  
460 - }else{  
461 - return "";  
462 - }  
463 - }  
464 -  
465 - /**  
466 - * 自定义模块详情  
467 - */  
468 - public function getModulePage($project,$routerMap,$lang=''): string  
469 - {  
470 - $pageService = new PageService();  
471 - $commonService = new CommonService();  
472 - $tdkService = new TdkService();  
473 - //页面路由  
474 - $routePath = $routerMap->route;  
475 - $module_detail = CustomModuleContent::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",0)->first();  
476 - if (!empty($module_detail)){  
477 - if($project['update_info']['is_update'] && $module_detail->six_read){  
478 - return $this->getOldHtml($project,$routerMap,$project['update_info']['old_domain_test'],$project['update_info']['old_domain_online'],$lang);  
479 - }else{  
480 - //公共拼接页面方法  
481 - $webCustomHtml = $pageService->publicMontagePage($project,RouteMap::SOURCE_MODULE,$routerMap);  
482 - //公共面包屑导航,左侧导航处理,内页banner背景图,列表页分页  
483 - $webCustomHtml = $pageService->publicMdAndLeftNavInnerImageListDetailsDataHandle($webCustomHtml,$project,RouteMap::SOURCE_MODULE,$routerMap,null);  
484 - $moduleCategoryInfo = CustomModuleContent::getModuleCategory($project->id,$module_detail);  
485 - if (isset($moduleCategoryInfo->getExtend->detail_visualization) && $moduleCategoryInfo->getExtend->detail_visualization == 1){  
486 - //产品,产品分类,新闻,博客(section模板通用数据模块处理)  
487 - $webCustomHtml = $pageService->generalTemplateProcessingForDataModules($webCustomHtml,$project->id);  
488 - }  
489 - //TDK处理  
490 - $webCustomHtml = $tdkService->pageTdkHandle($project,$webCustomHtml,RouteMap::SOURCE_MODULE,$routerMap);  
491 - //网页公共部分  
492 - $webCustomHtml = $pageService->publicHtmlHandle($webCustomHtml,$project->id);  
493 - unset($pageService);  
494 - $html = $commonService->thirdPartyCodeHandle($project,$webCustomHtml,$routePath);  
495 - //处理URL等,处理html链接a标签href  
496 - if (!empty($html)){  
497 - return $this->pageUrlHandle($project,$routerMap,$html);  
498 - }else{  
499 - return "";  
500 - }  
501 - }  
502 - }else{  
503 - return "";  
504 - }  
505 - }  
506 -  
507 - /**  
508 - * 获取博客列表页html  
509 - */  
510 - public function getBlogListPage($project,$routerMap,$page): string  
511 - {  
512 - $pageService = new PageService();  
513 - $commonService = new CommonService();  
514 - $tdkService = new TdkService();  
515 - //公共拼接页面方法  
516 - $webCustomHtml = $pageService->publicMontagePage($project,RouteMap::SOURCE_BLOG_CATE,$routerMap);  
517 - //公共面包屑导航,左侧导航处理,内页banner背景图,列表页分页  
518 - $webCustomHtml = $pageService->publicMdAndLeftNavInnerImageListDetailsDataHandle($webCustomHtml,$project,RouteMap::SOURCE_BLOG_CATE,$routerMap,$page);  
519 - $isVisual = $pageService->isOpenVisualization($project,RouteMap::SOURCE_BLOG_CATE);  
520 - if ((int)$isVisual == 1 || $isVisual == null){  
521 - //产品,产品分类,新闻,博客(section模板通用数据模块处理)  
522 - $webCustomHtml = $pageService->generalTemplateProcessingForDataModules($webCustomHtml,$project->id);  
523 - }  
524 - $webCustomHtml = $tdkService->pageTdkHandle($project,$webCustomHtml,RouteMap::SOURCE_BLOG_CATE,$routerMap);  
525 - $webCustomHtml = $pageService->publicHtmlHandle($webCustomHtml,$project->id);  
526 - unset($pageService);  
527 - $html = $commonService->thirdPartyCodeHandle($project,$webCustomHtml,$routerMap->route);  
528 - //处理URL等,处理html链接a标签href  
529 - if (!empty($html)){  
530 - return $this->pageUrlHandle($project,$routerMap,$html,"",$page);  
531 - }else{  
532 - return "";  
533 - }  
534 - }  
535 -  
536 - /**  
537 - * 获取博客页html  
538 - */  
539 - public function getBlogPage($project,$routerMap,$lang=''): string  
540 - {  
541 - $pageService = new PageService();  
542 - $commonService = new CommonService();  
543 - $tdkService = new TdkService();  
544 - $blog_detail = Blog::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",1)->first();  
545 - if (!empty($blog_detail)){  
546 - if($project['update_info']['is_update'] && $blog_detail->six_read){  
547 - return $this->getOldHtml($project,$routerMap,$project['update_info']['old_domain_test'],$project['update_info']['old_domain_online'],$lang);  
548 - }else{  
549 - //公共拼接页面方法  
550 - $webCustomHtml = $pageService->publicMontagePage($project,RouteMap::SOURCE_BLOG,$routerMap);  
551 - //公共面包屑导航,左侧导航处理,内页banner背景图,列表页分页  
552 - $webCustomHtml = $pageService->publicMdAndLeftNavInnerImageListDetailsDataHandle($webCustomHtml,$project,RouteMap::SOURCE_BLOG,$routerMap,null);  
553 - $isVisual = $pageService->isOpenVisualization($project,RouteMap::SOURCE_BLOG);  
554 - if ((int)$isVisual == 1 || $isVisual == null){  
555 - //产品,产品分类,新闻,博客(section模板通用数据模块处理)  
556 - $webCustomHtml = $pageService->generalTemplateProcessingForDataModules($webCustomHtml,$project->id);  
557 - }  
558 - $webCustomHtml = $tdkService->pageTdkHandle($project,$webCustomHtml,RouteMap::SOURCE_BLOG,$routerMap);  
559 - $webCustomHtml = $pageService->publicHtmlHandle($webCustomHtml,$project->id);  
560 - unset($pageService);  
561 - //生成静态页  
562 - $html = $commonService->thirdPartyCodeHandle($project,$webCustomHtml,$routerMap->route);  
563 - //处理URL等,处理html链接a标签href  
564 - if (!empty($html)){  
565 - return $this->pageUrlHandle($project,$routerMap,$html);  
566 - }else{  
567 - return "";  
568 - }  
569 - }  
570 - }else{  
571 - return "";  
572 - }  
573 - }  
574 -  
575 - /**  
576 - * 获取单页面html  
577 - */  
578 - public function getSinglePage($project,$routerMap,$lang=''): string  
579 - {  
580 - $pageService = new PageService();  
581 - $commonService = new CommonService();  
582 - $tdkService = new TdkService();  
583 - //页面路由  
584 - $routePath = $routerMap->route;  
585 - $webCustom = BCustomTemplate::where("id",$routerMap->source_id)->where("status",1)->first();  
586 - if (!empty($webCustom)){  
587 - if($project['update_info']['is_update'] && $webCustom->six_read){  
588 - return $this->getOldHtml($project,$routerMap,$project['update_info']['old_domain_test'],$project['update_info']['old_domain_online'],$lang);  
589 - }else{  
590 - //公共拼接页面方法  
591 - $content = $pageService->publicMontagePage($project,RouteMap::SOURCE_PAGE,$routerMap);  
592 - //公共左侧导航处理  
593 - $phpQueryDom=phpQuery::newDocument($content);  
594 - $pageService->leftNavSideNavHandle($project,RouteMap::SOURCE_PAGE,$phpQueryDom,$routerMap);  
595 - $content = $phpQueryDom->htmlOuter();  
596 - unset($phpQueryDom);  
597 - //产品,产品分类,新闻,博客(section模板通用数据模块处理)  
598 - $content = $pageService->generalTemplateProcessingForDataModules($content,$project->id);  
599 - //生成静态页  
600 - $content = $tdkService->pageTdkHandle($project,$content,RouteMap::SOURCE_PAGE,$routerMap);  
601 - $content = $pageService->publicHtmlHandle($content,$project->id);  
602 - unset($pageService);  
603 - $html = $commonService->thirdPartyCodeHandle($project,$content,$routePath,$routerMap);  
604 - //处理URL等,处理html链接a标签href  
605 - if (!empty($html)){  
606 - return $this->pageUrlHandle($project,$routerMap,$html);  
607 - }else{  
608 - return "";  
609 - }  
610 - }  
611 - }else{  
612 - return "";  
613 - }  
614 - }  
615 -  
616 - /**  
617 - * 获取关键词列表页面  
618 - */  
619 - public function getProductKeywordListPage($project,$router,$page): string  
620 - {  
621 - if (isset($router->route) && $router->route != null) {  
622 - $routePath = $router->route;  
623 - } else {  
624 - $routePath = $router;  
625 - }  
626 - //公共头部底部  
627 - $pageService = new PageService();  
628 - $commonService = new CommonService();  
629 - $publicTemplate = $pageService->getPublicTemplate($project);  
630 - $headerHtml = $publicTemplate->headerHtml;  
631 - $footerHtml = $publicTemplate->footerHtml;  
632 -  
633 - //获取字母开头关键词列表  
634 - $keywords = $pageService->getProductKeywordsByLetter($project,$router,$page);  
635 - $html = view("products/products_keywords_list",compact("headerHtml","footerHtml","keywords","routePath"))->__toString();  
636 - $html = $pageService->publicHtmlHandle($html, $project->id);  
637 - //生成静态页  
638 - $webCustomHtml = $commonService->thirdPartyCodeHandle($project, $html, $routePath);  
639 - //top-search TDK处理,分页link索引处理  
640 - $webCustomHtml = $pageService->productKeywordListTdkHandle($webCustomHtml,$project,$routePath,$keywords,$page);  
641 - //处理URL等,处理html链接a标签href  
642 - if (!empty($html)){  
643 - $webCustomHtml = $this->pageUrlHandle($project,$routePath,$webCustomHtml);  
644 - }else{  
645 - return "";  
646 - }  
647 - unset($keywords);  
648 - unset($html);  
649 - return $webCustomHtml;  
650 - }  
651 -  
652 - /**  
653 - * TODO:处理URL等,处理html链接a标签href,获取最终html  
654 - */  
655 - public function pageUrlHandle($project,$routerMap,$html,$lang="",$page=null): string  
656 - {  
657 - if (isset($routerMap->route) && $routerMap->route != null) {  
658 - $route = $routerMap->route;  
659 - } else {  
660 - $route = $routerMap;  
661 - }  
662 - $pageService = new PageService();  
663 - $phpQueryDom=phpQuery::newDocument($html);  
664 - $domainEnd = $project->domain_end;  
665 - //主站a链接处理  
666 - $this->masterWebATagHandle($phpQueryDom,$project,$domainEnd);  
667 - //html 标签处理  
668 - $this->htmlTagHandle($phpQueryDom,$project);  
669 - //国家  
670 - $webCountry = $pageService->getCountryList($project->id);  
671 - //语种 alternate  
672 - $this->setHrefLang($phpQueryDom,$project,$route,$page,$lang,$webCountry);  
673 - //以-tag的聚合页结尾的路由加上 <meta name="robots" content="noindex">  
674 - $this->setTagRobotsNoindex($phpQueryDom,$routerMap);  
675 - //<meta name="cookie_consent_banner" content="参数值"> 配置  
676 - $this->setCookieConsentBanner($phpQueryDom,$project);  
677 -  
678 - $html = $phpQueryDom->htmlOuter();  
679 - unset($phpQueryDom);  
680 - phpQuery::unloadDocuments();  
681 -  
682 - //根据配置读取不同的资源路径功能  
683 - $html = $this->setResourcePath($project,$html);  
684 - //网站语种列表  
685 - return $pageService->publicCountryLanguageHandle($html,$project,$route);  
686 - }  
687 -  
688 - /**  
689 - * html 标签处理  
690 - */  
691 - public function htmlTagHandle($phpQueryDom,$project)  
692 - {  
693 - $phpQueryDom->find("html")->attr("dir","ltr");  
694 - $mainLang = WebLanguage::getProjectMainLang($project->main_lang_id);  
695 - if ($mainLang->short == "ru"){  
696 - $phpQueryDom->find('main .keyword_search')->remove();  
697 - }  
698 - $lang = $mainLang ? $mainLang->short : 'en';  
699 - $phpQueryDom->find("html")->attr("lang",$lang);  
700 - }  
701 -  
702 - /**  
703 - * 888项目禁用鼠标右键点击,查看元素  
704 - */  
705 - public function prohibitRightMouseClick($phpQueryDom,$project)  
706 - {  
707 - if ($project->id == 888){  
708 - $phpQueryDom->find("body")->attr("ondragstart","window.event.returnValue=false");  
709 - $phpQueryDom->find("body")->attr("oncontextmenu","window.event.returnValue=false");  
710 - $phpQueryDom->find("body")->attr("onselectstart","event.returnValue=false");  
711 - }  
712 - }  
713 -  
714 - /**  
715 - *主站a链接处理  
716 - */  
717 - public function masterWebATagHandle($phpQueryDom,$project,$domainEnd)  
718 - {  
719 - foreach ($phpQueryDom->find('a') as $a) {  
720 - $href = pq($a)->attr('href');  
721 - //a标签href字符串是否有http://或者https://等协议头,有的话不做处理  
722 - if (strpos($href, 'http://') !== false || strpos($href, 'https://') !== false || strpos($href, 'javascript') !== false || strpos($href, 'javasctipt') !== false || strpos($href, '#') !== false || empty($href) || strpos($href, '.zip') !== false || strpos($href, '.txt') !== false || strpos($href, 'tel:') !== false || strpos($href, 'mailto') !== false || strpos($href, '.pdf') !== false || strpos($href, '.tar') !== false || strpos($href, '.jpg') !== false || strpos($href, '.png') !== false || strpos($href, '.jpeg') !== false || strpos($href, '.xml') !== false || strpos($href, 'skype:') !== false || strpos($href, 'whatsapp:') !== false) {  
723 - $domain = $project->domain;  
724 - $domain = str_replace("http://","",$domain);  
725 - $domain = str_replace("https://","",$domain);  
726 - $domain = str_replace("/","",$domain);  
727 - $domainArr = parse_url($domain);  
728 - if (strpos($href, '#') !== false || strpos($href, '.xml') !== false){}else{  
729 - if (isset($domainArr["path"]) && !empty($domainArr["path"])){  
730 - if (strpos($href, 'http://') !== false || strpos($href, 'https://') !== false){  
731 - $domain = $domainArr["path"];  
732 - if (strpos($href, $domain) !== false){  
733 - $href = str_replace("http://","",$href);  
734 - $href = str_replace("https://","",$href);  
735 - $href = str_replace($domain,"",$href);  
736 - if ($domainEnd == Project::$domainEndSlash){  
737 - //以斜杠结尾  
738 - $href = substr($href, -1) === '/' ? $href : $href . "/";  
739 - }else{  
740 - //不以斜杠结尾  
741 - if (substr($href, -1) === '/') {  
742 - if ($href != "/"){  
743 - $href = rtrim($href, '/');  
744 - }  
745 - }  
746 - }  
747 - }  
748 - }  
749 - }  
750 - }  
751 - pq($a)->attr('href', $href);  
752 - }else{  
753 - if ($domainEnd == Project::$domainEndSlash){  
754 - //以斜杠结尾  
755 - $href = substr($href, -1) === '/' ? $href : $href . "/";  
756 - if (strpos($href, ".html") !== false || strpos($href, ".htm") !== false){  
757 - $href = rtrim($href, '/');  
758 - }  
759 - }else{  
760 - //不以斜杠结尾  
761 - if (substr($href, -1) === '/') {  
762 - if ($href != "/"){  
763 - $href = rtrim($href, '/');  
764 - }  
765 - }  
766 - }  
767 - }  
768 - pq($a)->attr('href', $href);  
769 - }  
770 - }  
771 -  
772 - /**  
773 - * <meta name="cookie_consent_banner" content="参数值"> 配置  
774 - */  
775 - public function setCookieConsentBanner($phpQueryDom,$project)  
776 - {  
777 - $deployBuildInfo = DeployBuild::where("project_id",$project->id)->first();  
778 - if (!empty($deployBuildInfo)){  
779 - $phpQueryDom->find('head')->append('<meta name="cookie_consent_banner" content="'.$deployBuildInfo->cookie_consent_banner.'">');  
780 - }  
781 - }  
782 -  
783 - /**  
784 - * 语种 alternate  
785 - */  
786 - public function setHrefLang($phpQueryDom,$project,$route,$page,$lang,$webCountry)  
787 - {  
788 - //处理源代码语言url  
789 - $countryUrl = [];  
790 - $createPageService = new CreatePageService();  
791 - $domain = $createPageService->domainHandle($project->domain);  
792 - $mainLang = WebLanguage::getProjectMainLang($project->main_lang_id);  
793 - if (!empty($webCountry)) {  
794 - foreach ($webCountry as $key => $item) {  
795 - //语种列表调整,新增自定义跳转链接  
796 - if (isset($item->country_custom) && !empty($item->country_custom)){  
797 - if ($item->country_custom->is_create == 1){  
798 - $page = (int)$page != null && (int)$page != 0 ? (int)$page . "/" : "";  
799 - if (!empty($mainLang) && $item->short != $mainLang->short){  
800 - $countryUrl[$key]["url"] = "https://" . $item->country_custom->custom_domain . "/" . $route . "/" . $page;  
801 - }else{  
802 - $countryUrl[$key]["url"] = "https://" . $domain . "/" . $route . "/" . $page;  
803 - }  
804 - }else{  
805 - $countryUrl[$key]["url"] = "https://" . $item->country_custom->custom_domain . "/";  
806 - }  
807 - $countryUrl[$key]["alias"] = $item->short;  
808 - }else{  
809 - if (!empty($mainLang) && $item->short != $mainLang->short){  
810 - $langShort = $item->short."/";  
811 - }else{  
812 - $langShort = "";  
813 - }  
814 - if ((int)$page != null) {  
815 - $countryUrl[$key]["url"] = "https://" . $domain . "/" .$langShort . $route . "/" . (int)$page . "/";  
816 - } else {  
817 - $countryUrl[$key]["url"] = $route == "index" ? "https://" . $domain . "/" . $langShort : "https://" . $domain . "/" . $langShort. $route . "/";  
818 - }  
819 - $countryUrl[$key]["alias"] = $item->short;  
820 - }  
821 - }  
822 - }  
823 - //路径  
824 - if ($route == "index") {  
825 - $webUrl = "https://" . $domain . "/";  
826 - } else {  
827 - if ((int)$page != null || (int)$page != 0) {  
828 - if ($lang != "") {  
829 - $langShort = $lang == "en" ? "" : $lang."/";  
830 - $webUrl = "https://" . $domain . "/" .$langShort. $route . "/" . (int)$page . "/";  
831 - } else {  
832 - $webUrl = "https://" . $domain . "/" . $route . "/" . (int)$page . "/";  
833 - }  
834 - } else {  
835 - if ($lang != "") {  
836 - $langShort = $lang == "en" ? "" : $lang."/";  
837 - $webUrl = "https://" . $domain . "/" . $langShort . $route . "/";  
838 - } else {  
839 - $webUrl = "https://" . $domain . "/" . $route . "/";  
840 - }  
841 - }  
842 - }  
843 - $phpQueryDom->find('head')->append("<meta property='og:url' content='$route'/>");  
844 - $phpQueryDom->find('head')->append("<link rel='canonical' href='$webUrl' />");  
845 - if (!empty($countryUrl)){  
846 - foreach ($countryUrl as $item){  
847 - if (isset($item['alias']) && isset($item['url'])){  
848 - $phpQueryDom->find('head')->append("<link rel='alternate' hreflang='".$item['alias']."' href='".$item['url']."'>");  
849 - }  
850 - }  
851 - }  
852 - }  
853 -  
854 - /**  
855 - * 以-tag的聚合页结尾的路由加上 <meta name="robots" content="noindex">  
856 - */  
857 - public function setTagRobotsNoindex($phpQueryDom,$routerMap)  
858 - {  
859 - if (isset($routerMap->source) && $routerMap->source == RouteMap::SOURCE_PRODUCT_KEYWORD){  
860 - $routerSuffix = substr($routerMap->route, -4);  
861 - $routerLength = strlen($routerMap->route);  
862 - if ($routerLength >= 4 && $routerSuffix == "-tag"){  
863 - $phpQueryDom->find('head')->append('<meta name="robots" content="noindex,nofollow">');  
864 - }  
865 - }  
866 - }  
867 -  
868 - /**  
869 - * 配置资源路径  
870 - */  
871 - public function setResourcePath($project,$html)  
872 - {  
873 - $projectLocation = $project->project_location;  
874 - $storageType = $project->storage_type;  
875 - $cos = config('filesystems.disks.cos');  
876 - if ($projectLocation == Project::$projectLocationZero){  
877 - //普通项目  
878 - if ($storageType == Project::$storageTypeZero){  
879 - //压缩项目  
880 - $html = str_replace($cos['cdn1'],$cos['cdn'],$html);  
881 - }else{  
882 - //非压缩项目  
883 - $html = str_replace($cos['cdn'],$cos['cdn1'],$html);  
884 - }  
885 - }else{  
886 - $s3 = config('filesystems.disks.s3');  
887 - //危险项目  
888 - $html = str_replace($cos['cdn1'],$s3['cdn'],$html);  
889 - $html = str_replace($cos['cdn'],$s3['cdn'],$html);  
890 - }  
891 - return $html;  
892 - }  
893 -  
894 - /**  
895 - * 放入文件  
896 - */  
897 - public function putHtmlToPageFile($project,$lang,$route,$page,$html,$routeType=""): bool  
898 - {  
899 - if (empty($html) || $html == ""){  
900 - return true;  
901 - }  
902 - if (strpos($route, '.php') !== false || strpos($route, '.env') !== false || strpos($route, '.jpg') !== false || strpos($route, '.asp') !== false || strpos($route, '.png') !== false || strpos($route, '.gif') !== false ){  
903 - return true;  
904 - }  
905 - $domain = $project->domain;  
906 - $domain = str_replace("https://","",$domain);  
907 - $domain = str_replace("http://","",$domain);  
908 - $domain = str_replace("/","",$domain);  
909 - $originLang = $lang;  
910 - $lang = $lang == "zh-TW" ? "zh-ct" : $lang;  
911 - $lang = $lang=="" ? "" : "/".$lang;  
912 - $page = $page == null || (int)$page == 1 ? null : "/".(int)$page;  
913 -  
914 - //是否是5.0升级项目  
915 - if (isset($project->update_info["is_update"]) && $project->update_info["is_update"] == 1){  
916 - //5.0生成路径  
917 - $path = $this->getProjectRoutePath5($project,$domain,$route,$routeType,$lang,$page);  
918 - }else{  
919 - //6.0生成路径  
920 - $path = $this->getProjectRoutePath6($project,$domain,$route,$routeType,$lang,$page);  
921 - }  
922 - try {  
923 - //$filePath = iconv("UTF-8", "GBK", $path);  
924 - $filePath = $path;  
925 - if (!file_exists(public_path($filePath))) {  
926 - mkdir(public_path($filePath), 0777, true);  
927 - }  
928 - if (strpos($route, ".html") !== false || strpos($route, ".htm") !== false) {  
929 - file_put_contents(public_path($filePath . ".html"), $html);  
930 - chmod(public_path($filePath . ".html"), 0777);  
931 - }else{  
932 - file_put_contents(public_path($filePath . "/index.html"), $html);  
933 - chmod(public_path($filePath . "/index.html"), 0777);  
934 - }  
935 - } catch (\Exception $e) {  
936 - return true;  
937 - }  
938 -  
939 - return true;  
940 - }  
941 -  
942 - /**  
943 - * 6.0生成路径  
944 - */  
945 - public function getProjectRoutePath6($project,$domain,$route,$routeType,$lang,$page): string  
946 - {  
947 - if ($routeType == "news" || $routeType == "blogs"){  
948 - if ($routeType == "blogs"){  
949 - $routerMap = RouteMap::where("project_id",$project->id)->where("route",$route)->whereIn('path', ['blog','blogs',''])->first();  
950 - }else{  
951 - $routerMap = RouteMap::where("project_id",$project->id)->where("route",$route)->where("path",$routeType)->first();  
952 - }  
953 - }else{  
954 - $routerMap = RouteMap::where("project_id",$project->id)->where("route",$route)->first();  
955 - }  
956 - if (!empty($routerMap)){  
957 - if ($routerMap->source == "news"){  
958 - $route = "/news/".$route;  
959 - }elseif($routerMap->source == "blog"){  
960 - $route = "/blogs/".$route;  
961 - }elseif($routerMap->source == "module"){  
962 - $modules = CustomModuleContent::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",0)->first();  
963 - $moduleCategoryInfo = CustomModuleContent::getModuleCategory($project->id,$modules);  
964 - if (isset($moduleCategoryInfo->route) && !empty($moduleCategoryInfo->route)){  
965 - $route = "/".$moduleCategoryInfo->route."/".$route;  
966 - }  
967 - }else{  
968 - $route = $route == "index" ? "" : "/".$route;  
969 - }  
970 - }else{  
971 - $route = $route == "index" ? "" : "/".$route;  
972 - }  
973 - $route = str_replace(".html","",$route);  
974 - $route = str_replace(".htm","",$route);  
975 - return $domain.$lang.$route.$page;  
976 - }  
977 -  
978 - /**  
979 - * 5.0生成路径  
980 - */  
981 - public function getProjectRoutePath5($project,$domain,$route,$routeType,$lang,$page): string  
982 - {  
983 - if ($routeType == "news" || $routeType == "blogs"){  
984 - if ($routeType == "blogs"){  
985 - $routerMap = RouteMap::where("project_id",$project->id)->where("route",$route)->whereIn('path', ['blog','blogs',''])->first();  
986 - }else{  
987 - $routerMap = RouteMap::where("project_id",$project->id)->where("route",$route)->where("path",$routeType)->first();  
988 - }  
989 - }else{  
990 - $routerMap = RouteMap::where("project_id",$project->id)->where("route",$route)->where("path","")->first();  
991 - if (empty($routerMap)){  
992 - $routerMap = RouteMap::where("project_id",$project->id)->where("route",$route)->first();  
993 - }  
994 - }  
995 - if (!empty($routerMap)){  
996 - if ($routerMap->source == "news"){  
997 - $route = "/news/".$route;  
998 - }elseif($routerMap->source == "blog" || $routerMap->source == "blogs"){  
999 - $route = "/blogs/".$route;  
1000 - }elseif ($routerMap->source == "news_category"){  
1001 - if ($route == "news"){  
1002 - $route = $page == null || $page == 1 ? "/".$route : "/".$route . "/page";  
1003 - }else{  
1004 - $route = $page == null || $page == 1 ? "/news_catalog/".$route : "/news_catalog/".$route."/page";  
1005 - }  
1006 - }elseif ($routerMap->source == "blog_category"){  
1007 - if ($route == "blog"){  
1008 - $route = $page == null || $page == 1 ? "/".$route : "/".$route."/page";  
1009 - }else{  
1010 - $route = $page == null || $page == 1 ? "/blog_catalog/".$route : "/blog_catalog/".$route."/page";  
1011 - }  
1012 - }elseif ($routerMap->source == "product_category"){  
1013 - $route = $page == null || $page == 1 ? "/".$route : "/".$route."/page";  
1014 - }elseif ($routerMap->source == "module_category"){  
1015 - $moduleCategory = CustomModuleCategory::getModuleCategoryAndExtendById($project->id,$routerMap->source_id);  
1016 - if (!empty($moduleCategory->getExtend->route)){  
1017 - if ($moduleCategory->getExtend->route == $route){  
1018 - $route = "/".$moduleCategory->route;  
1019 - }else{  
1020 - $route = "/".$moduleCategory->getExtend->route."_catalog/".$moduleCategory->route."/page";  
1021 - }  
1022 - }else{  
1023 - $route = "/".$moduleCategory->route."/page";  
1024 - }  
1025 - }elseif ($routerMap->source == "module"){  
1026 - $modules = CustomModuleContent::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",0)->first();  
1027 - $moduleCategoryInfo = CustomModuleContent::getModuleCategory($project->id,$modules);  
1028 - if (isset($moduleCategoryInfo->getExtend->route) && !empty($moduleCategoryInfo->getExtend->route)){  
1029 - $route = "/".$moduleCategoryInfo->route."/".$modules->route;  
1030 - }else{  
1031 - $route = "/".$modules->route;  
1032 - }  
1033 - }else{  
1034 - $route = $route == "index" ? "" : "/".$route;  
1035 - }  
1036 - }else{  
1037 - if ($route == "products"){  
1038 - if ($page == null || $page == 1){  
1039 - $route = "/".$route;  
1040 - }else{  
1041 - $route = "/".$route."/page";  
1042 - }  
1043 - }elseif ($route == "news"){  
1044 - $route = $page == null || $page == 1 ? "/".$route : "/".$route;  
1045 - }elseif ($route == "blog"){  
1046 - $route = $page == null || $page == 1 ? "/blog_catalog/".$route : "/blog_catalog/".$route."/page";  
1047 - }else{  
1048 - $route = $route == "index" ? "" : "/".$route;  
1049 - }  
1050 - }  
1051 - $route = str_replace(".html","",$route);  
1052 - $route = str_replace(".htm","",$route);  
1053 - return $domain.$lang.$route.$page;  
1054 - }  
1055 -  
1056 - /**  
1057 - * 从主站拿页面  
1058 - */  
1059 - public function getHtmlToPageFile($project,$lang,$route,$page,$routeType = "")  
1060 - {  
1061 - $domain = $project->domain;  
1062 - $domain = str_replace("https://","",$domain);  
1063 - $domain = str_replace("http://","",$domain);  
1064 - $domain = str_replace("/","",$domain);  
1065 - $lang = $lang=="" ? "" : "/".$lang;  
1066 - $page = $page == null || (int)$page == 1 ? null : "/".(int)$page;  
1067 -  
1068 - //是否是5.0升级项目  
1069 - if (isset($project->update_info["is_update"]) && $project->update_info["is_update"] == 1){  
1070 - //取5.0生成路径  
1071 - $path = $this->getProjectRoutePagePath5($project,$domain,$route,$routeType,$lang,$page);  
1072 - }else{  
1073 - //取6.0生成路径  
1074 - $path = $this->getProjectRoutePagePath6($project,$domain,$route,$routeType,$lang,$page);  
1075 - }  
1076 -  
1077 - try {  
1078 - $filePath = iconv("UTF-8", "GBK", $path);  
1079 - if (file_exists(public_path($filePath . "/index.html"))) {  
1080 - $html = file_get_contents(public_path($filePath . "/index.html"));  
1081 - }else{  
1082 - $html = "";  
1083 - }  
1084 - } catch (\Exception $e) {  
1085 - $html = "";  
1086 - }  
1087 - return $html;  
1088 - }  
1089 -  
1090 - /**  
1091 - * 拿6.0页面  
1092 - */  
1093 - public function getProjectRoutePagePath6($project,$domain,$route,$routeType,$lang,$page): string  
1094 - {  
1095 - if ($routeType == "news" || $routeType == "blogs"){  
1096 - if ($routeType == "blogs"){  
1097 - $routerMap = RouteMap::where("project_id",$project->id)->where("route",$route)->whereIn('path', ['blog','blogs',''])->first();  
1098 - }else{  
1099 - $routerMap = RouteMap::where("project_id",$project->id)->where("route",$route)->where("path",$routeType)->first();  
1100 - }  
1101 -  
1102 - }else{  
1103 - $routerMap = RouteMap::where("project_id",$project->id)->where("route",$route)->where("path","")->first();  
1104 - if (empty($routerMap)){  
1105 - $routerMap = RouteMap::where("project_id",$project->id)->where("route",$route)->first();  
1106 - }  
1107 - }  
1108 - if (!empty($routerMap)){  
1109 - if ($routerMap->source == "news"){  
1110 - $route = "/news/".$route;  
1111 - }elseif($routerMap->source == "blog"){  
1112 - $route = "/blogs/".$route;  
1113 - }elseif($routerMap->source == "module"){  
1114 - $modules = CustomModuleContent::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",0)->first();  
1115 - $moduleCategoryInfo = CustomModuleContent::getModuleCategory($project->id,$modules);  
1116 - if (isset($moduleCategoryInfo->route) && !empty($moduleCategoryInfo->route)){  
1117 - $route = "/".$moduleCategoryInfo->route."/".$route;  
1118 - }  
1119 - }else{  
1120 - $route = $route == "index" ? "" : "/".$route;  
1121 - }  
1122 - }else{  
1123 - $route = $route == "index" ? "" : "/".$route;  
1124 - }  
1125 - return $domain.$lang.$route.$page;  
1126 - }  
1127 -  
1128 - /**  
1129 - * 拿5.0页面  
1130 - */  
1131 - public function getProjectRoutePagePath5($project,$domain,$route,$routeType,$lang,$page): string  
1132 - {  
1133 - if ($routeType == "news" || $routeType == "blogs"){  
1134 - if ($routeType == "blogs"){  
1135 - $routerMap = RouteMap::where("project_id",$project->id)->where("route",$route)->whereIn('path', ['blog','blogs',''])->first();  
1136 - }else{  
1137 - $routerMap = RouteMap::where("project_id",$project->id)->where("route",$route)->where("path",$routeType)->first();  
1138 - }  
1139 -  
1140 - }else{  
1141 - $routerMap = RouteMap::where("project_id",$project->id)->where("route",$route)->where("path","")->first();  
1142 - if (empty($routerMap)){  
1143 - $routerMap = RouteMap::where("project_id",$project->id)->where("route",$route)->first();  
1144 - }  
1145 - }  
1146 - if (!empty($routerMap)){  
1147 - if ($routerMap->source == "news"){  
1148 - $route = "/news/".$route;  
1149 - }elseif($routerMap->source == "blog" || $routerMap->source == "blogs"){  
1150 - $route = "/blogs/".$route;  
1151 - }elseif ($routerMap->source == "news_category"){  
1152 - $route = "/news_catalog/".$route."/page";  
1153 - }elseif ($routerMap->source == "blog_category"){  
1154 - $route = "/blog_catalog/".$route."/page";  
1155 - }elseif ($routerMap->source == "product_category"){  
1156 - $route = "/".$route."/page";  
1157 - }elseif ($routerMap->source == "module"){  
1158 - $modules = CustomModuleContent::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",0)->first();  
1159 - $moduleCategoryInfo = CustomModuleContent::getModuleCategory($project->id,$modules);  
1160 - if (isset($moduleCategoryInfo->getExtend->route) && !empty($moduleCategoryInfo->getExtend->route)){  
1161 - $route = "/".$moduleCategoryInfo->getExtend->route."_catalog/".$moduleCategoryInfo->route."/page";  
1162 - }else{  
1163 - $route = "/extend_catalog/".$moduleCategoryInfo->route."/page";  
1164 - }  
1165 - }else{  
1166 - $route = $route == "index" ? "" : "/".$route;  
1167 - }  
1168 - }else{  
1169 - $route = $route == "index" ? "" : "/".$route;  
1170 - }  
1171 - return $domain.$lang.$route.$page;  
1172 - }  
1173 -  
1174 - /**  
1175 - * 翻译  
1176 - */  
1177 - public function translateWebPage($project,$html,$lang,$domain,$route="",$page=null,$countryLang=null): string  
1178 - {  
1179 - if (empty($html) || $html == ""){  
1180 - return $html;  
1181 - }  
1182 - $staticHtmlRepository = new StaticHtmlRepository();  
1183 - try {  
1184 -//非主站处理html语言  
1185 - $htmlOld = $this->langUrlHandle($project,$lang,$html,$route,$page,$countryLang);  
1186 - $phpQueryDomOld = phpQuery::newDocument($htmlOld);  
1187 - $langDomContent = $phpQueryDomOld->find("header .change-language")->eq(0)->html();  
1188 - $footerFormDomContent = $phpQueryDomOld->find(".form-footer-inquiry-block")->eq(0)->html();  
1189 - $mainFormDomContent = $phpQueryDomOld->find(".section-form-wrap-block")->eq(0)->html();  
1190 - $popFormDomContent = $phpQueryDomOld->find(".pop-box.inquiry-box")->eq(0)->html();  
1191 - $topSearchDomContent = $phpQueryDomOld->find("main .top-search-title-first-letter-list")->eq(0)->html();  
1192 - $langDomContent5 = $phpQueryDomOld->find(".prisna-wp-translate-seo")->eq(0)->html();  
1193 - unset($phpQueryDomOld);  
1194 - phpQuery::unloadDocuments();  
1195 -  
1196 - $newHtml = "";  
1197 - if ($lang != '') {  
1198 - //翻译测试成功,用下面第二红最新翻译  
1199 -// 第一种翻译  
1200 -// $commonService = new CommonService();  
1201 -// $htmlNew = $commonService->webHtmlTranslate($project,$htmlOld,$lang,$domain);  
1202 -// 第二种翻译  
1203 - $htmlNew = $staticHtmlRepository->getTranHtml($project,$htmlOld,$lang,$route,$page);  
1204 - $phpQueryDomNew = phpQuery::newDocument($htmlNew);  
1205 - unset($htmlOld);  
1206 - $phpQueryDomNew->find("header .change-language")->eq(0)->html($langDomContent);  
1207 - //取消根据翻译状态,翻译tag状态显示主站小语种列表功能(2024.02.27)  
1208 -// $phpQueryDomNew->find("header div[data-module=2]")->find(".change-language-cont")->removeAttr("style");  
1209 - $phpQueryDomNew->find(".form-footer-inquiry-block")->eq(0)->html($footerFormDomContent);  
1210 - $phpQueryDomNew->find(".section-form-wrap-block")->eq(0)->html($mainFormDomContent);  
1211 - $phpQueryDomNew->find(".pop-box.inquiry-box")->eq(0)->html($popFormDomContent);  
1212 - $phpQueryDomNew->find("main .top-search-title-first-letter-list")->eq(0)->html($topSearchDomContent);  
1213 - $phpQueryDomNew->find(".prisna-wp-translate-seo")->eq(0)->html($langDomContent5);  
1214 - $newHtml = $phpQueryDomNew->htmlOuter();  
1215 - unset($phpQueryDomNew,$htmlNew,$langDomContent,$footerFormDomContent,$mainFormDomContent,$popFormDomContent);  
1216 - }  
1217 - phpQuery::unloadDocuments();  
1218 - } catch (\Exception $e) {  
1219 - $newHtml = $staticHtmlRepository->getTranHtml($project,$html,$lang,$route,$page);  
1220 - }  
1221 -  
1222 - return $newHtml;  
1223 - }  
1224 -  
1225 - /**  
1226 - * 小语种url处理  
1227 - */  
1228 - public function langUrlHandle($project,$lang,$html,$route="",$page=null,$countryLang=null)  
1229 - {  
1230 -// $html = str_replace("\n","",$html);  
1231 - $content = $html;  
1232 - //主站翻译,不进行小语种链接和页面处理  
1233 - if ($project->is_lang_translate == 1){  
1234 - $langInfo = WebLanguage::getProjectMainLang($project->main_lang_id);  
1235 - if ($langInfo->short == $lang){  
1236 - return $content;  
1237 - }  
1238 - }  
1239 - //当前语言国徽背景图片处理  
1240 - if ($lang != ""){  
1241 - $oldLang = $lang;  
1242 - $oldRoute = $route;  
1243 - $phpQueryDom = phpQuery::newDocument($content);  
1244 - //去掉小语种搜索框  
1245 - $phpQueryDom->find("header .search")->remove();  
1246 - $phpQueryDom->find("header .btn--search")->remove();  
1247 - $phpQueryDom->find("header .btn-search")->remove();  
1248 - $phpQueryDom->find("header .head-search")->remove();  
1249 -  
1250 - $page = $page == null ? "" : $page."/";  
1251 - $route = $route == "index" || $route == "" ? "" : $route."/";  
1252 - $lang = $lang."/";  
1253 - $langUrl = "https://".$project->domain."/".$lang.$route.$page;  
1254 - $phpQueryDom->find("link[rel=canonical]")->attr("href",$langUrl);  
1255 -  
1256 - //翻译版块当前小语种显示  
1257 - $countryDom = $phpQueryDom->find("header div[data-module=2]");  
1258 - $langInfo = WebLanguage::where("short",$oldLang)->first();  
1259 - if (!empty($langInfo)){  
1260 - $countryDom->find(".change-language-title span")->text($langInfo->english);  
1261 - }  
1262 - $oldTwLang = $oldLang == "zh-ct" ? "zh-TW" : $oldLang;  
1263 - $countryDom->find(".change-language-title .country-flag")->attr("class","country-flag language-flag-".$oldTwLang);  
1264 -  
1265 - //html 标签处理  
1266 - if ($oldLang == "ar" || $oldLang == "ug"){  
1267 - $phpQueryDom->find("html")->attr("dir","rtl");  
1268 - }else{  
1269 - $phpQueryDom->find("html")->attr("dir","ltr");  
1270 - }  
1271 -  
1272 - $phpQueryDom->find("html")->attr("lang",$oldLang);  
1273 - //1:2级目录 2:2级域名  
1274 - $linkingFormat = 1;  
1275 - $mainLang = null;  
1276 - $projectBuild = $project->deployBuild;  
1277 - if (!empty($projectBuild)){  
1278 - $linkingFormat = $projectBuild->linking_format;  
1279 - }  
1280 -  
1281 - if (isset($project->main_lang_id) && !empty($project->main_lang_id)){  
1282 - $mainLang = WebLanguage::getProjectMainLang($project->main_lang_id);  
1283 - }  
1284 - //小语种自定义跳转  
1285 - $countryCustomInfo = CountryCustom::getCountryCustomByProjectId($project->id);  
1286 - $countryCustomInfoNew = [];  
1287 - if (!empty($countryCustomInfo)){  
1288 - foreach ($countryCustomInfo as $countryCustomInfoItem){  
1289 - if (isset($countryCustomInfoItem->country_custom_language->short)){  
1290 - $countryCustomInfoNew[$countryCustomInfoItem->country_custom_language->short]["custom_domain"] = $countryCustomInfoItem->custom_domain;  
1291 - }  
1292 - }  
1293 - }  
1294 - // 1、处理A标签跳过图标 2、获取图标HTML a标签处理完成 还原图标HTML  
1295 - //a标签路径问题  
1296 - foreach ($phpQueryDom->find('a') as $a) {  
1297 - $class =pq($a)->attr('class');  
1298 - if (strpos($class, 'language-flag') !== false){  
1299 - continue;  
1300 - }  
1301 - $href = pq($a)->attr('href');  
1302 - //a标签href字符串是否有http://或者https://等协议头,有的话不做处理  
1303 - if (strpos($href, 'http://') !== false || strpos($href, 'https://') !== false || strpos($href,'javascript') !== false || strpos($href, 'javasctipt') !== false || $href == "#" || empty($href) || strpos($href, '.zip') !== false || strpos($href, '.txt') !== false || strpos($href, 'tel:') !== false || strpos($href, 'mailto') !== false || strpos($href, '.pdf') !== false || strpos($href, '.tar') !== false || strpos($href, '.jpg') !== false || strpos($href, '.png') !== false || strpos($href, '.jpeg') !== false || strpos($href, '.xml') !== false || strpos($href, 'skype:') !== false || strpos($href, 'whatsapp:') !== false) {  
1304 - }else{  
1305 - if ($lang != ''){  
1306 - if (!empty($mainLang)){  
1307 - if ($lang != $mainLang->short){  
1308 - //小语种自定义链接  
1309 - if (isset($countryCustomInfoNew[$oldLang])){  
1310 - continue;  
1311 - }  
1312 - if ($linkingFormat == 1){  
1313 - $hrefNew = '/'.$lang . ltrim($href, '/');  
1314 - }else{  
1315 - $hrefNew = '/' . ltrim($href, '/');  
1316 - }  
1317 - }else{  
1318 - $hrefNew = '/' . ltrim($href, '/');  
1319 - }  
1320 - pq($a)->attr('href', $hrefNew);  
1321 - }  
1322 - }  
1323 - }  
1324 - }  
1325 -  
1326 - $data = date("Y-m-d H:i:s");  
1327 - $phpQueryDom->find('html')->append("<!-- Globalso translate Cache file was created on ".$data." -->");  
1328 - $content = $phpQueryDom->htmlOuter();  
1329 - unset($html,$phpQueryDom);  
1330 - phpQuery::unloadDocuments();  
1331 - return $content;  
1332 - }  
1333 - return $content;  
1334 - }  
1335 -  
1336 - /**  
1337 - * 生成robots  
1338 - * @param Project $project  
1339 - * @return bool  
1340 - */  
1341 - public function createRobots($project)  
1342 - {  
1343 - if (!empty($project)){  
1344 - $robotTxtPath = public_path($project->domain."/robots.txt");  
1345 - $createSitemapService = new CreateSitemapService();  
1346 - //A端是否开启允许robots爬虫爬取  
1347 - if ($project->robots == 0){  
1348 - $sitemapContent = $this->getRefuseRobotsStr($project->domain);  
1349 - }else{  
1350 - $sitemapContent = $this->getAllowRobotsStr($project->domain);  
1351 - }  
1352 - $domainPath = public_path($project->domain);  
1353 - if (!file_exists($domainPath)){  
1354 - mkdir($domainPath, 0777, true);  
1355 - }  
1356 - $res = $createSitemapService->putSitemapFile($robotTxtPath,$sitemapContent);  
1357 - if ($res){  
1358 - return true;  
1359 - }  
1360 - }  
1361 - return true;  
1362 - }  
1363 -  
1364 - /**  
1365 - * 生成允许爬虫爬取robots内容  
1366 - * @param $domain  
1367 - * @return string  
1368 - */  
1369 - public function getAllowRobotsStr($domain)  
1370 - {  
1371 - $domain_arr = config('custom.robots_disallow_domain');  
1372 - $disallow = '';  
1373 - if (in_array($domain, $domain_arr)) {  
1374 - $langArr = WebLanguage::pluck('short');  
1375 - foreach ($langArr as $val) {  
1376 - if ($val == 'en')  
1377 - continue;  
1378 - $disallow .= 'Disallow: /' . $val . '/' . PHP_EOL;  
1379 - }  
1380 - }  
1381 - $trans_string = is_file(public_path($domain . '/trans_sitemap.xml')) ? "Sitemap: https://".$domain."/trans_sitemap.xml" : '';  
1382 - return "User-agent: *  
1383 -Allow: /  
1384 -Disallow: /404/  
1385 -  
1386 -".$disallow."  
1387 -User-agent: MSNBot  
1388 -Disallow: /  
1389 -User-agent: YoudaoBot  
1390 -Disallow: /  
1391 -User-agent: JikeSpider  
1392 -Disallow: /  
1393 -User-agent: EasouSpider  
1394 -Disallow: /  
1395 -User-agent: AhrefsBot  
1396 -Disallow: /  
1397 -User-agent: MJ12bot  
1398 -Disallow: /  
1399 -User-agent: YYSpider  
1400 -Disallow: /  
1401 -User-agent: Teoma  
1402 -Disallow: /  
1403 -User-agent: rogerbot  
1404 -Disallow: /  
1405 -User-agent: exabot  
1406 -Disallow: /  
1407 -User-agent: DotBot  
1408 -Disallow: /  
1409 -User-agent: gigabot  
1410 -Disallow: /  
1411 -User-agent: BLEXBot  
1412 -Disallow: /  
1413 -User-agent: DOCOMO Sprider  
1414 -Disallow: /  
1415 -User-agent: Applebot  
1416 -Disallow: /  
1417 -User-agent: SeznamBot  
1418 -Disallow: /  
1419 -User-agent: SemrushBot  
1420 -Disallow: /  
1421 -  
1422 -Sitemap: https://".$domain."/sitemap.xml  
1423 -$trans_string";  
1424 - }  
1425 -  
1426 - /**  
1427 - * 获取允许爬虫爬取robots内容  
1428 - */  
1429 - public function getRefuseRobotsStr($domain): string  
1430 - {  
1431 - return "User-agent: *  
1432 -Disallow: /";  
1433 - }  
1434 -  
1435 - /**  
1436 - * 升级项目,并且以老版本展示  
1437 - * @param $project  
1438 - * @param $routerMap  
1439 - * @param $old_domain_test  
1440 - * @param $old_domain_online  
1441 - * @param $language  
1442 - * @return string  
1443 - * @author Akun  
1444 - * @date 2023/11/29 14:52  
1445 - */  
1446 - public function getOldHtml($project, $routerMap, $old_domain_test, $old_domain_online, $language=''){  
1447 - $collect_info = CollectTask::where('project_id',$project->id)->where('language',$language)->where('source',$routerMap->source)->where('source_id',$routerMap->source_id)->where('status',CollectTask::STATUS_COM)->first();  
1448 - if($collect_info){  
1449 - $html = $collect_info->html;  
1450 - if(strpos($html,'404 Not Found') !== false){  
1451 - return '';  
1452 - }  
1453 - //替换域名  
1454 - $html = str_replace("http://".$old_domain_test,"",$html);  
1455 - $html = str_replace("https://".$old_domain_test,"",$html);  
1456 - $html = str_replace("http://".$old_domain_online,"",$html);  
1457 - $html = str_replace("https://".$old_domain_online,"",$html);  
1458 -// //暂时隐藏小语种  
1459 -// $html = str_replace('<div class="change-language ensemble">','<div class="change-language ensemble" style="display: none">',$html);  
1460 -// $html = str_replace('<div class="language_more">','<div class="language_more" style="display: none">',$html);  
1461 - //处理搜索  
1462 - preg_match_all('/<form\s+[^>]*?action\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $html, $result_search);  
1463 - $search = $result_search[2] ?? [];  
1464 - foreach ($search as $vc) {  
1465 - if((strpos($vc,'search.php') !== false) || (strpos($vc,'index.php') !== false)){  
1466 - $html = str_replace($vc,'/search/',$html);  
1467 - }  
1468 - }  
1469 - //增加统计代码  
1470 - $html = str_replace('</body>','<script src="https://ecdn6.globalso.com/public/customerVisit.min.js"></script></body>',$html);  
1471 - return $html;  
1472 - }else{  
1473 - return '';  
1474 - }  
1475 - }  
1476 -  
1477 - /**  
1478 - * 更新获取路由  
1479 - */  
1480 - public function getRouters($updateNotifyData,$pageNum): array  
1481 - {  
1482 - $routers = null;  
1483 - $perPage = 100;  
1484 - $offset = ($pageNum - 1) * $perPage;  
1485 - $updateNotifyQuery = UpdateNotify::where("project_id",$updateNotifyData->project_id);  
1486 - if ($updateNotifyData->route == Notify::ROUTE_ALL){  
1487 - //所有更新  
1488 - if ($updateNotifyData->type == Notify::TYPE_MASTER){  
1489 - $updateNotifyQuery->where("status","<",2)->update(['status' => 2]);  
1490 - $routers = RouteMap::where("project_id",$updateNotifyData->project_id)->offset($offset)->limit($perPage)->get()->sortBy(function($item) {  
1491 - return array_search($item->source, ['page', 'product_category', 'product', 'news_category', 'news', 'blog_category', 'blog', 'product_keyword']);  
1492 - });  
1493 - }else{  
1494 - $updateNotifyQuery->where("minor_languages_status","<",2)->update(['minor_languages_status' => 2]);  
1495 - $routers = RouteMap::where("project_id",$updateNotifyData->project_id)->where("source","!=","product_keyword")->offset($offset)->limit($perPage)->get()->sortBy(function($item) {  
1496 - return array_search($item->source, ['page', 'product_category', 'product', 'news_category', 'news', 'blog_category', 'blog']);  
1497 - });  
1498 - }  
1499 - }else if($updateNotifyData->route == Notify::ROUTE_PRODUCT_KEYWORD){  
1500 - //产品聚合页更新  
1501 - $routers = RouteMap::where("project_id",$updateNotifyData->project_id)->where("source","product_keyword")->offset($offset)->limit($perPage)->get();  
1502 - }else if($updateNotifyData->route == Notify::ROUTE_PRODUCT_VIDEO_KEYWORD){  
1503 - //产品视频聚合页更新  
1504 - $videoKeywordIdList = Keyword::where("project_id",$updateNotifyData->project_id)->where("status",1)->whereNotNull("route")->whereNotNull("video")->pluck("id")->toArray();  
1505 - if (!empty($videoKeywordIdList)){  
1506 - $routers = RouteMap::where("project_id",$updateNotifyData->project_id)->where("source","product_keyword")->whereIn("source_id",$videoKeywordIdList)->offset($offset)->limit($perPage)->get();  
1507 - }  
1508 - }else if($updateNotifyData->route == Notify::ROUTE_NOT_TRANSLATE){  
1509 - //漏翻译  
1510 - if ($updateNotifyData->type == Notify::TYPE_MINOR){  
1511 - $routers = RouteMap::where("project_id",$updateNotifyData->project_id)->offset($offset)->limit($perPage)->get()->sortBy(function($item) {  
1512 - return array_search($item->source, ['page', 'product_category', 'product', 'news_category', 'news', 'blog_category', 'blog', 'product_keyword']);  
1513 - });  
1514 - }  
1515 - }else if($updateNotifyData->route == Notify::ROUTE_NEED){  
1516 - //按需更新  
1517 - if ($updateNotifyData->type == Notify::TYPE_MASTER){  
1518 - $routers = $updateNotifyQuery->where("status","<",2)->offset($offset)->limit($perPage)->get();  
1519 - $updateNotifyQuery->where("status","<",2)->update(['status' => 2]);  
1520 - }else{  
1521 - $routers = $updateNotifyQuery->where("minor_languages_status","<",2)->offset($offset)->limit($perPage)->get();  
1522 - $updateNotifyQuery->where("minor_languages_status","<",2)->update(['minor_languages_status' => 2]);  
1523 - }  
1524 - }else{  
1525 - //按url更新  
1526 - $urlArrMap = [];  
1527 - $dataJson = json_decode($updateNotifyData->data);  
1528 - $urlArr = $dataJson->url;  
1529 - if (!empty($urlArr)){  
1530 - if (count($urlArr) != 0){  
1531 - foreach ($urlArr as $key => $item){  
1532 - if (strpos($item, 'http://') !== false || strpos($item, 'https://') !== false) {  
1533 - $pathUrl = parse_url($item);  
1534 - if (isset($pathUrl["path"])){  
1535 - $pathUrl = $pathUrl["path"];  
1536 - if ($pathUrl == "/"){  
1537 - $urlArrMap[] = "index";  
1538 - }  
1539 - }else{  
1540 - $urlArrMap[] = "index";  
1541 - }  
1542 - $pathInfo = urldecode($pathUrl);  
1543 - $pageService = new PageService();  
1544 - $analysisRouteArr = $pageService->analysisRoute($pathInfo);  
1545 - if (isset($analysisRouteArr["router"])){  
1546 - $urlArrMap[] = $analysisRouteArr["router"];  
1547 - }  
1548 - }else{  
1549 - $urlArrMap[] = $item;  
1550 - }  
1551 - }  
1552 - }  
1553 - $pageNum = 0;  
1554 - }  
1555 -  
1556 - $routeNew = [];  
1557 - if (!empty($urlArrMap)){  
1558 - foreach ($urlArrMap as $v){  
1559 - $routerItem = RouteMap::where("project_id",$updateNotifyData->project_id)->where("route",$v)->first();  
1560 - if (!empty($routerItem)){  
1561 - $routeNew[] = $v;  
1562 - }  
1563 - }  
1564 - }  
1565 - if (!empty($routeNew)){  
1566 - $routeNew = array_values(array_unique(array_filter($routeNew)));  
1567 - $routers = RouteMap::where("project_id",$updateNotifyData->project_id)->whereIn("route",$routeNew)->get();  
1568 - }  
1569 - }  
1570 - $routersInfo["routers"] = $routers;  
1571 - $routersInfo["pageNum"] = $pageNum;  
1572 - return $routersInfo;  
1573 - }  
1574 -  
1575 - /**  
1576 - * 数据详情入库数据处理  
1577 - */  
1578 - public function htmlPageQueryDataHandle($routers,$updateNotifyData,$task_id,$isHasData = true)  
1579 - {  
1580 - $page = null;  
1581 - $updateData = [];  
1582 - $data = json_decode($updateNotifyData->data, true);  
1583 - $updateNotifyData->domain = $data['domain'];  
1584 - if ($updateNotifyData->route == Notify::ROUTE_ALL || $updateNotifyData->route == Notify::ROUTE_URL || $updateNotifyData->route == Notify::ROUTE_PRODUCT_KEYWORD || $updateNotifyData->route == Notify::ROUTE_NOT_TRANSLATE){  
1585 - //全部更新  
1586 - if ($isHasData && !empty($routers) && !$routers->isEmpty()){  
1587 - foreach ($routers as $item){  
1588 - $count = $this->isListAndGetCount($item,$updateNotifyData);  
1589 - if ($count == 0 || $item->route == "index"){  
1590 - $updateData['project_id'] = $updateNotifyData->project_id;  
1591 - $updateData['id'] = $task_id;  
1592 - $updateData['type'] = $item->source;  
1593 - $updateData['route'] = $item->route;  
1594 - $updateData['page'] = $page;  
1595 - $updateData['domain'] =$updateNotifyData->domain;  
1596 - $updateDataJson = json_encode($updateData);  
1597 - //更新页面  
1598 - $this->pushHtmlPage($updateNotifyData,$updateDataJson,$task_id);  
1599 - }else{  
1600 - for ($i = 1; $i <= $count; $i++) {  
1601 - if ($i == 1){  
1602 - $updateData['page'] = null;  
1603 - }else{  
1604 - $updateData['page'] = $i;  
1605 - }  
1606 - $updateData['project_id'] = $updateNotifyData->project_id;  
1607 - $updateData['id'] = $task_id;  
1608 - $updateData['type'] = $item->source;  
1609 - $updateData['route'] = $item->route;  
1610 - $updateData['domain'] =$updateNotifyData->domain;  
1611 - $updateDataJson = json_encode($updateData);  
1612 - //更新页面  
1613 - $this->pushHtmlPage($updateNotifyData,$updateDataJson,$task_id);  
1614 - }  
1615 - }  
1616 - }  
1617 - }  
1618 -  
1619 - if (!$isHasData){  
1620 - //判断products,news,blog三个列表页是否存在路由,不存在主动更新  
1621 - //手动更新所有关键词列表页(自定义top-search系列页面)  
1622 - $this->checkProductsNewsBlogListAndGetCount($updateNotifyData,$task_id);  
1623 - if ($updateNotifyData->type == Notify::TYPE_MASTER){  
1624 - $this->productKeywordListAdnGetCount($updateNotifyData,$task_id);  
1625 - }else{  
1626 - if ($updateNotifyData->route == Notify::ROUTE_PRODUCT_KEYWORD){  
1627 - $this->productKeywordListAdnGetCount($updateNotifyData,$task_id);  
1628 - }  
1629 - }  
1630 - }  
1631 - }else{  
1632 - //按需更新  
1633 - if ($isHasData && !empty($routers) && !$routers->isEmpty()){  
1634 - foreach ($routers as $item){  
1635 - $count = $this->isListAndGetCount($item,$updateNotifyData);  
1636 - if ($count == 0 || $item->type == "index"){  
1637 - $updateData['project_id'] = $updateNotifyData->project_id;  
1638 - $updateData['id'] = $task_id;  
1639 - if ($item->type == "index"){  
1640 - $updateData['type'] = "page";  
1641 - $updateData['route'] = "index";  
1642 - }else{  
1643 - $updateData['type'] = $item->type;  
1644 - $updateData['route'] = $item->route;  
1645 - }  
1646 - $updateData['page'] = $page;  
1647 - $updateData['domain'] =$updateNotifyData->domain;  
1648 - $updateDataJson = json_encode($updateData);  
1649 - //更新页面  
1650 - $this->pushHtmlPage($updateNotifyData,$updateDataJson,$task_id);  
1651 - }else{  
1652 - for ($i = 1; $i <= $count; $i++) {  
1653 - if ($i == 1){  
1654 - $updateData['page'] = null;  
1655 - }else{  
1656 - $updateData['page'] = $i;  
1657 - }  
1658 - $updateData['project_id'] = $updateNotifyData->project_id;  
1659 - $updateData['id'] = $task_id;  
1660 - $updateData['type'] = $item->type;  
1661 - $updateData['route'] = $item->route;  
1662 - $updateData['domain'] =$updateNotifyData->domain;  
1663 - $updateDataJson = json_encode($updateData);  
1664 - //更新页面  
1665 - $this->pushHtmlPage($updateNotifyData,$updateDataJson,$task_id);  
1666 - }  
1667 - }  
1668 - }  
1669 - }  
1670 -  
1671 - if (!$isHasData){  
1672 - //判断products,news,blog三个列表页是否存在路由,不存在主动更新  
1673 - $this->checkProductsNewsBlogListAndGetCount($updateNotifyData,$task_id);  
1674 - }  
1675 -  
1676 - }  
1677 - unset($routers);  
1678 - }  
1679 -  
1680 - /**  
1681 - * 是否是列表,并返回页数  
1682 - */  
1683 - public function isListAndGetCount($router,$updateNotifyData)  
1684 - {  
1685 - $count = 0;  
1686 - $newsQuery = News::where("project_id",$updateNotifyData->project_id)->select("id")->where("status",1);  
1687 - $blogQuery = Blog::where("project_id",$updateNotifyData->project_id)->select("id")->where("status",1);  
1688 - $productsQuery = Product::where("project_id",$updateNotifyData->project_id)->select("id")->where("status",1)->whereNotNull('route');  
1689 - if ($updateNotifyData->route == Notify::ROUTE_ALL || $updateNotifyData->route == Notify::ROUTE_URL){  
1690 - if ($router->source == "news_category"){  
1691 - if ($router->route == "news"){  
1692 - $count = $newsQuery->count();  
1693 - }else{  
1694 - $count = $newsQuery->where("category_id","like","%".",".$router->source_id.","."%")->count();  
1695 - }  
1696 - }  
1697 - if ($router->source == "blog_category"){  
1698 - if ($router->route == "blog"){  
1699 - $count = $blogQuery->count();  
1700 - }else{  
1701 - $count = $blogQuery->where("category_id","like","%".",".$router->source_id.","."%")->count();  
1702 - }  
1703 -  
1704 - }  
1705 - if ($router->source == "product_category"){  
1706 - if ($router->route == "products"){  
1707 - $count =$productsQuery->count();  
1708 - }else{  
1709 - $ids = [];  
1710 - $productCategoryList = Category::getAllSonCategoryById($updateNotifyData->project_id,(int)$router->source_id);  
1711 - if (!empty($productCategoryList)){  
1712 - $productList = CategoryRelated::whereIn("cate_id",$productCategoryList)->get();  
1713 - if (!empty($productList)){  
1714 - foreach ($productList as $productV){  
1715 - $ids[] = $productV->product_id;  
1716 - }  
1717 - }  
1718 - }  
1719 - $count =$productsQuery->whereIn("id",$ids)->count();  
1720 - }  
1721 -  
1722 - }  
1723 - }else{  
1724 - $routerMap = RouteMap::where("project_id",$updateNotifyData->project_id)->where("route",$router->route)->first();  
1725 - if (!empty($routerMap)){  
1726 - if ($router->type == "news_category"){  
1727 - if ($router->route == "news"){  
1728 - $count = $newsQuery->count();  
1729 - }else{  
1730 - $count = $newsQuery->where("category_id","like","%".",".$routerMap->source_id.","."%")->count();  
1731 - }  
1732 - }  
1733 - if ($router->type == "blog_category"){  
1734 - if ($router->route == "blog"){  
1735 - $count = $blogQuery->count();  
1736 - }else{  
1737 - $count = $blogQuery->where("category_id","like","%".",".$routerMap->source_id.","."%")->count();  
1738 - }  
1739 -  
1740 - }  
1741 - if ($router->type == "product_category"){  
1742 - if ($router->route == "products"){  
1743 - $count = $productsQuery->count();  
1744 - }else{  
1745 - $count = $productsQuery->where("category_id","like","%,".(string)$routerMap->source_id.",%")->count();  
1746 - }  
1747 -  
1748 - }  
1749 - }  
1750 - }  
1751 -  
1752 - if ($count != 0){  
1753 - if ($router->type == "product_category"){  
1754 - $webSettingNum = SettingNum::where("project_id",$updateNotifyData->project_id)->where("type",SettingNum::$productListType)->orderBy("id","desc")->first();  
1755 - if (!empty($webSettingNum)){  
1756 - $perPage = (int)$webSettingNum->num;  
1757 - }else{  
1758 - $perPage = Category::$productCategoryPagePercent; //产品每页条数  
1759 - }  
1760 - $total = (int)ceil($count / $perPage); //产品分类总页数  
1761 - }elseif($router->type == "news_category"){  
1762 - $webSettingNum = SettingNum::where("project_id",$updateNotifyData->project_id)->where("type",SettingNum::$newsListType)->orderBy("id","desc")->first();  
1763 - if (!empty($webSettingNum)){  
1764 - $perPage = (int)$webSettingNum->num;  
1765 - }else{  
1766 - $perPage = NewsCategory::$newsCategoryPagePercent; //新闻每页条数  
1767 - }  
1768 - $total = (int)ceil($count / $perPage); //新闻总页数  
1769 - }else{  
1770 - $webSettingNum = SettingNum::where("project_id",$updateNotifyData->project_id)->where("type",SettingNum::$blogListType)->orderBy("id","desc")->first();  
1771 - if (!empty($webSettingNum)){  
1772 - $perPage = (int)$webSettingNum->num;  
1773 - }else{  
1774 - $perPage = NewsCategory::$newsCategoryPagePercent; //博客每页条数  
1775 - }  
1776 - $total = (int)ceil($count / $perPage); //博客总页数  
1777 - }  
1778 - $count = $total;  
1779 - }  
1780 - return $count;  
1781 -  
1782 - }  
1783 -  
1784 - /**  
1785 - * 需要更新的页面,主站页面或者小语种页面  
1786 - */  
1787 - public function pushHtmlPage($updateNotifyData, $updateDataJson,$taskId)  
1788 - {  
1789 - //更新页面  
1790 - $mysqlData["created_at"] = now();  
1791 - $mysqlData["updated_at"] = now();  
1792 - $mysqlData["data"] =$updateDataJson;  
1793 - $mysqlData["task_id"] =$taskId;  
1794 - $data = json_decode($updateDataJson);  
1795 - if (!empty($data->page)){  
1796 - $page =",分页:".$data->page;  
1797 - }else{  
1798 - $page = "";  
1799 - }  
1800 - echo "创建项目路由:任务ID:" . $taskId .",项目ID:".$data->project_id.",域名:".$data->domain.",路由:".$data->route.$page. PHP_EOL;  
1801 -  
1802 - if ($updateNotifyData->type == Notify::TYPE_MASTER){  
1803 - UpdateMasterWebsiteModel::insertGetId($mysqlData);  
1804 - }else{  
1805 - UpdateMinorLanguagesModel::insertGetId($mysqlData);  
1806 - }  
1807 - }  
1808 -  
1809 - /**  
1810 - * 判断products,news,blog三个列表页是否存在路由,不存在主动更新  
1811 - */  
1812 - public function checkProductsNewsBlogListAndGetCount($updateNotifyData,$task_id)  
1813 - {  
1814 - $productsCount = 0;  
1815 - $newsCount = 0;  
1816 - $blogCount = 0;  
1817 - //产品  
1818 - $routerProductsMap = RouteMap::where("project_id",$updateNotifyData->project_id)->where("route","products")->first();  
1819 - if (empty($routerProductsMap)){  
1820 - $productsCount = Product::where("project_id",$updateNotifyData->project_id)->select("id")->where("status",1)->whereNotNull('route')->orderBy("id","DESC")->count();  
1821 - if ($productsCount != 0){  
1822 - $webSettingNum = SettingNum::where("project_id",$updateNotifyData->project_id)->where("type",SettingNum::$productListType)->orderBy("id","desc")->first();  
1823 - if (!empty($webSettingNum)){  
1824 - $perPage = (int)$webSettingNum->num;  
1825 - }else{  
1826 - $perPage = Category::$productCategoryPagePercent; //产品每页条数  
1827 - }  
1828 - $productsTotal = (int)ceil($productsCount / $perPage);  
1829 - if ($productsTotal>=1){  
1830 - for ($i = 1; $i <= $productsTotal; $i++) {  
1831 - $updateData = [];  
1832 - if ($i == 1){  
1833 - $updateData['page'] = null;  
1834 - }else{  
1835 - $updateData['page'] = $i;  
1836 - }  
1837 - $updateData['project_id'] = $updateNotifyData->project_id;  
1838 - $updateData['id'] = $task_id;  
1839 - $updateData['type'] = "product_category";  
1840 - $updateData['route'] = "products";  
1841 - $updateData['domain'] =$updateNotifyData->domain;  
1842 - $updateDataJson = json_encode($updateData);  
1843 - //更新页面  
1844 - $this->pushHtmlPage($updateNotifyData,$updateDataJson,$task_id);  
1845 - }  
1846 - }  
1847 - }  
1848 - }  
1849 -  
1850 - //新闻  
1851 - $routerNewsMap = RouteMap::where("project_id",$updateNotifyData->project_id)->where("route","news")->first();  
1852 - if (empty($routerNewsMap)){  
1853 - $newsCount = News::where("project_id",$updateNotifyData->project_id)->select("id")->where("status",1)->orderBy("id","DESC")->count();  
1854 - $webSettingNum = SettingNum::where("project_id",$updateNotifyData->project_id)->where("type",SettingNum::$newsListType)->orderBy("id","desc")->first();  
1855 - if (!empty($webSettingNum)){  
1856 - $perPage = (int)$webSettingNum->num;  
1857 - }else{  
1858 - $perPage = NewsCategory::$newsCategoryPagePercent;  
1859 - }  
1860 - $NewsTotal = (int)ceil($newsCount / $perPage);  
1861 - if ($NewsTotal>=1){  
1862 - for ($i = 1; $i <= $NewsTotal; $i++) {  
1863 - $updateData = [];  
1864 - if ($i == 1){  
1865 - $updateData['page'] = null;  
1866 - }else{  
1867 - $updateData['page'] = $i;  
1868 - }  
1869 - $updateData['project_id'] = $updateNotifyData->project_id;  
1870 - $updateData['id'] = $task_id;  
1871 - $updateData['type'] = "news_category";  
1872 - $updateData['route'] = "news";  
1873 - $updateData['domain'] =$updateNotifyData->domain;  
1874 - $updateDataJson = json_encode($updateData);  
1875 - //更新页面  
1876 - $this->pushHtmlPage($updateNotifyData,$updateDataJson,$task_id);  
1877 - }  
1878 - }  
1879 - }  
1880 -  
1881 - //博客  
1882 - $routerBlogMap = RouteMap::where("project_id",$updateNotifyData->project_id)->where("route","blog")->first();  
1883 - if (empty($routerBlogMap)){  
1884 - $blogCount = Blog::where("project_id",$updateNotifyData->project_id)->select("id")->where("status",1)->orderBy("id","DESC")->count();  
1885 - $webSettingNum = SettingNum::where("project_id",$updateNotifyData->project_id)->where("type",SettingNum::$blogListType)->orderBy("id","desc")->first();  
1886 - if (!empty($webSettingNum)){  
1887 - $perPage = (int)$webSettingNum->num;  
1888 - }else{  
1889 - $perPage = NewsCategory::$newsCategoryPagePercent;  
1890 - }  
1891 - $BlogTotal = (int)ceil($blogCount / $perPage);  
1892 - if ($BlogTotal>=1){  
1893 - for ($i = 1; $i <= $BlogTotal; $i++) {  
1894 - $updateData = [];  
1895 - if ($i == 1){  
1896 - $updateData['page'] = null;  
1897 - }else{  
1898 - $updateData['page'] = $i;  
1899 - }  
1900 - $updateData['project_id'] = $updateNotifyData->project_id;  
1901 - $updateData['id'] = $task_id;  
1902 - $updateData['type'] = "blog_category";  
1903 - $updateData['route'] = "blog";  
1904 - $updateData['domain'] =$updateNotifyData->domain;  
1905 - $updateDataJson = json_encode($updateData);  
1906 - //更新页面  
1907 - $this->pushHtmlPage($updateNotifyData,$updateDataJson,$task_id);  
1908 - }  
1909 - }  
1910 - }  
1911 -  
1912 - }  
1913 -  
1914 - /**  
1915 - * 手动更新所有关键词列表页(自定义top-search系列页面)  
1916 - */  
1917 - public function productKeywordListAdnGetCount($updateNotifyData,$task_id)  
1918 - {  
1919 - $productKeywordInfo = $this->projectProductKeywordsDataAndHandle($updateNotifyData->project_id);  
1920 - if (isset($productKeywordInfo["productKeywordListInfo"]) && !empty($productKeywordInfo["productKeywordListInfo"])){  
1921 - foreach ($productKeywordInfo["productKeywordListInfo"] as $productKeywordItem){  
1922 - if ($productKeywordItem['total']>=1){  
1923 - for ($i = 1; $i <= $productKeywordItem['total']; $i++) {  
1924 - if ($i == 1){  
1925 - $updateData['page'] = null;  
1926 - }else{  
1927 - $updateData['page'] = $i;  
1928 - }  
1929 - $updateData['project_id'] = $updateNotifyData->project_id;  
1930 - $updateData['id'] = $task_id;  
1931 - $updateData['type'] = "product_keyword_list";  
1932 - $updateData['route'] = $productKeywordItem['route'];  
1933 - $updateData['domain'] =$updateNotifyData->domain;  
1934 - $updateDataJson = json_encode($updateData);  
1935 - //更新页面  
1936 - $this->pushHtmlPage($updateNotifyData,$updateDataJson,$task_id);  
1937 - }  
1938 - }  
1939 - }  
1940 - }  
1941 - unset($productKeywordInfo);  
1942 - }  
1943 -  
1944 - /**  
1945 - * 获取更新进度表  
1946 - */  
1947 - public function getUpdateProgress($projectId,$type)  
1948 - {  
1949 - $updateProgressQuery = UpdateProgress::where("project_id",(int)$projectId)->orderBy("id","desc");  
1950 - if ($type == "master_website"){  
1951 - $updateProgressQuery = $updateProgressQuery->where("type",1)->first();  
1952 - }else{  
1953 - $updateProgressQuery = $updateProgressQuery->where("type",2)->first();  
1954 - }  
1955 - return $updateProgressQuery;  
1956 - }  
1957 -  
1958 - /**  
1959 - * 项目产品关键词列表路由,及数据处理  
1960 - */  
1961 - public function projectProductKeywordsDataAndHandle($projectId): array  
1962 - {  
1963 - $keywordsArr = [];  
1964 - $keywordModel = new Keyword();  
1965 - $keywords = $keywordModel->where("project_id",$projectId)->get();  
1966 -  
1967 - if (!empty($keywords)){  
1968 - foreach ($keywords->toArray() as $item){  
1969 - $firstLetter = mb_strtolower(mb_substr($item['title'], 0, 1, 'utf-8'), 'utf-8');  
1970 - $keywordsArr["top-search"][] = $item;  
1971 - if (in_array($firstLetter, $keywordModel->routeZ)){  
1972 - $keywordsArr["top-search-0"][] = $item;  
1973 - }else{  
1974 - $keywordsArr["top-search-".$firstLetter][] = $item;  
1975 - }  
1976 - }  
1977 - }  
1978 - return [  
1979 - "productKeywordListInfo"=>$this->projectProductKeywordsDataAndTotalPageHandle($keywordsArr),  
1980 - "productKeywords"=>$keywords,  
1981 - ];  
1982 - }  
1983 -  
1984 - /**  
1985 - * 项目产品关键词列表路由数据及总页数  
1986 - */  
1987 - public function projectProductKeywordsDataAndTotalPageHandle($data): array  
1988 - {  
1989 - $projectProjectKeywords = [];  
1990 - $perPage = 80;  
1991 - if (!empty($data)){  
1992 - foreach ($data as $key => $item){  
1993 - $count = count($item);  
1994 - $total = (int)ceil($count / $perPage);  
1995 - $projectProjectKeywords[$key]["route"] =$key;  
1996 - $projectProjectKeywords[$key]["total"] =$total;  
1997 - }  
1998 - }  
1999 - return $projectProjectKeywords;  
2000 - }  
2001 -  
2002 - /**  
2003 - * 站点域名处理  
2004 - */  
2005 - public function domainHandle($domain)  
2006 - {  
2007 - $langDomain = str_replace("http://","",$domain);  
2008 - $langDomain = str_replace("https://","",$langDomain);  
2009 - $langDomain = str_replace("/","",$langDomain);  
2010 - return $langDomain;  
2011 - }  
2012 -  
2013 - /**  
2014 - * 小语种自定义创建站点目录页面拷贝  
2015 - */  
2016 - public function copyPageMinorWebsiteToCreateDomainDirectory($project)  
2017 - {  
2018 - $countryCustomInfo = CountryCustom::with("countryCustomLanguage")->where("language_id","!=",$project->main_lang_id)->where("project_id",$project->id)->where("status",1)->where("is_create",1)->get();  
2019 - if (!empty($countryCustomInfo)){  
2020 - $langDomain = $this->domainHandle($project->domain);  
2021 - foreach ($countryCustomInfo as $countryCustomInfoItem){  
2022 - $publicLangPath = public_path($langDomain."/".$countryCustomInfoItem->countryCustomLanguage->short);  
2023 - $publicCreatePath = public_path($countryCustomInfoItem->custom_domain);  
2024 - if (file_exists($publicLangPath)){  
2025 - if (!file_exists($publicCreatePath)){  
2026 - mkdir($publicCreatePath,0777);  
2027 - }  
2028 - File::copyDirectory($publicLangPath, $publicCreatePath);  
2029 - }  
2030 - }  
2031 - }  
2032 - }  
2033 -}