作者 刘锟

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

  1 +<?php
  2 +
  3 +namespace App\Console\Commands\GeneratePDF;
  4 +
  5 +use App\Models\File\PdfFile;
  6 +use App\Models\ProjectAssociation\ProjectAssociation;
  7 +use App\Services\CosService;
  8 +use Barryvdh\DomPDF\Facade\Pdf;
  9 +use Illuminate\Console\Command;
  10 +
  11 +class GeneratePdfData extends Command
  12 +{
  13 +// use CmdSignal;
  14 +
  15 + /**
  16 + * The name and signature of the console command.
  17 + *
  18 + * @var string
  19 + */
  20 + protected $signature = 'generate_pdf_data';
  21 +
  22 + /**
  23 + * The console command description.
  24 + *
  25 + * @var string
  26 + */
  27 + protected $description = '生成v6绑定的aicc用户的pdf备用数据';
  28 +
  29 + // 最大支持5个进程
  30 + public $maxRunNumber = 50;
  31 +
  32 + /**
  33 + * Create a new command instance.
  34 + *
  35 + * @return void
  36 + */
  37 + public function __construct()
  38 + {
  39 + parent::__construct();
  40 + }
  41 +
  42 + public function handle()
  43 + {
  44 + return $this->main();
  45 + }
  46 +
  47 + /**
  48 + * @return int
  49 + */
  50 + public function start(): int
  51 + {
  52 + return $this->main();
  53 + }
  54 +
  55 + /**
  56 + * @return int
  57 + */
  58 + protected function main()
  59 + {
  60 + $month = date('m');
  61 + $list = ProjectAssociation::query()->whereStatus(ProjectAssociation::STATUS_NORMAL)
  62 + ->where('m_status', '!=', $month)->first();
  63 +
  64 + if (is_null($list)) {
  65 + $this->error('没有任务,等待中');
  66 + sleep(60);
  67 + return 0;
  68 + }
  69 + $pdfFile = new PdfFile();
  70 + $bool = $pdfFile->saveData(['pid' => $list->id]);
  71 + if (!$bool) {
  72 + $this->error('生成v6绑定的aicc用户的pdf备用数据添加失败');
  73 + return 0;
  74 + }
  75 + $list->m_status = $month;
  76 + $list->save();
  77 + $this->info('生成v6绑定的aicc用户的pdf备用数据添加成功');
  78 + return 0;
  79 + }
  80 +}
1 <?php 1 <?php
2 2
3 -namespace App\Console\Commands; 3 +namespace App\Console\Commands\GeneratePDF;
4 4
5 -use App\Http\Controllers\File\FileController;  
6 -use App\Models\File\DataFile; 5 +use App\Models\File\PdfFile;
7 use App\Models\ProjectAssociation\ProjectAssociation; 6 use App\Models\ProjectAssociation\ProjectAssociation;
8 use App\Services\CosService; 7 use App\Services\CosService;
9 use Barryvdh\DomPDF\Facade\Pdf; 8 use Barryvdh\DomPDF\Facade\Pdf;
@@ -12,7 +11,7 @@ use Illuminate\Http\File; @@ -12,7 +11,7 @@ use Illuminate\Http\File;
12 11
13 class ProjectFilePDF extends Command 12 class ProjectFilePDF extends Command
14 { 13 {
15 - use CmdSignal; 14 +// use CmdSignal;
16 15
17 /** 16 /**
18 * The name and signature of the console command. 17 * The name and signature of the console command.
@@ -28,14 +27,8 @@ class ProjectFilePDF extends Command @@ -28,14 +27,8 @@ class ProjectFilePDF extends Command
28 */ 27 */
29 protected $description = '网站项目数据,生成PDF文件'; 28 protected $description = '网站项目数据,生成PDF文件';
30 29
31 - protected $ProjectAssociation;  
32 -  
33 - protected $DataFile;  
34 -  
35 protected $time; 30 protected $time;
36 31
37 - protected $fileController;  
38 -  
39 protected $CosService; 32 protected $CosService;
40 33
41 // 最大支持5个进程 34 // 最大支持5个进程
@@ -48,71 +41,89 @@ class ProjectFilePDF extends Command @@ -48,71 +41,89 @@ class ProjectFilePDF extends Command
48 */ 41 */
49 public function __construct() 42 public function __construct()
50 { 43 {
51 - $this->ProjectAssociation = new ProjectAssociation();  
52 - $this->DataFile = new DataFile();  
53 $this->time = date("Y-m"); 44 $this->time = date("Y-m");
54 - $this->fileController = new FileController();  
55 $this->CosService = new CosService(); 45 $this->CosService = new CosService();
56 parent::__construct(); 46 parent::__construct();
57 } 47 }
58 48
59 -// public function handle()  
60 -// {  
61 -// $project_data = [];  
62 -// $html = $this->html($project_data);  
63 -// $filename = hash('md5', $this->time . '-' . '$project_id' . '-' . '$friend_id' . '-' . '$user_id');  
64 -// $this->savePDF($html, $filename);  
65 -//// $this->testStreamPdf($html, $filename);  
66 -//// $file_path = $this->savePDF2($html, $filename);  
67 -// return 0;  
68 -// } 49 + public function handle()
  50 + {
  51 + // 开始时间
  52 + $startTime = microtime(true);
  53 + $html = $this->html([]);
  54 + $filename = hash('md5', $this->time . '-' . random_int(100000, 999999));
  55 + $this->savePDF($html, $filename);
  56 +
  57 + // 结束时间
  58 + $endTime = microtime(true);
  59 +
  60 + // 计算执行时间
  61 + $executionTime = ($endTime - $startTime);
  62 +
  63 + // 输出执行时间
  64 + var_dump("程序执行时间: " . $executionTime . " 秒");
  65 +// return $this->main();
  66 + }
69 67
  68 + /**
  69 + * @return int
  70 + */
70 public function start(): int 71 public function start(): int
71 { 72 {
72 - # 0 - 未生成  
73 - # 1 - 已生成  
74 - # 2 - 其它问题  
75 - $is_pdf = 0;  
76 - $lists = $this->ProjectAssociation::query()->where('is_pdf', $is_pdf)  
77 - ->where('project_id', '!=', 0)  
78 - ->where('friend_id', '!=', 0)  
79 - ->where('user_id', '!=', 0)  
80 - ->where('created_at', 'like', $this->time . '%')->first();  
81 -  
82 - if (is_null($lists)) {  
83 - $this->debug_echo('没有任务,等待中');  
84 - sleep(30); 73 + return $this->main();
  74 + }
  75 +
  76 + /**
  77 + * @return int
  78 + */
  79 + protected function main()
  80 + {
  81 + $list = PdfFile::query()->whereIsPdf(PdfFile::GENERATE_NOT_PDF)->first();
  82 +
  83 + if (is_null($list)) {
  84 + $this->error('没有任务,等待中');
  85 + sleep(60);
  86 + return 0;
  87 + }
  88 + $pid = $list->pid;
  89 + if (empty($pid)) {
  90 + $this->error('数据错误');
  91 + return 0;
  92 + }
  93 + $isExists = ProjectAssociation::query()->whereId($pid)->whereStatus(ProjectAssociation::STATUS_NORMAL)->first();
  94 + if (is_null($isExists)) {
  95 + $this->error('数据已被禁用 —— ' . $pid);
85 return 0; 96 return 0;
86 } 97 }
87 - $key = $this->signature . '-' . $lists->id;  
88 - $count = redis_get($key);  
89 98
90 - $project_id = $lists->project_id;  
91 - $user_id = $lists->user_id;  
92 - $friend_id = $lists->friend_id; 99 + $key = 'generate_pdf_' . $list->id;
  100 + $count = (int)redis_get($key) ?: 0;
  101 + $project_id = $isExists->project_id;
  102 + $user_id = $isExists->user_id;
  103 + $friend_id = $isExists->friend_id;
93 // todo 根据项目查询数据 104 // todo 根据项目查询数据
94 $project_data = []; 105 $project_data = [];
95 $html = $this->html($project_data); 106 $html = $this->html($project_data);
96 $filename = hash('md5', $this->time . '-' . $project_id . '-' . $friend_id . '-' . $user_id); 107 $filename = hash('md5', $this->time . '-' . $project_id . '-' . $friend_id . '-' . $user_id);
97 108
98 - $file_path = $this->savePDF($html, $filename);  
99 - if (empty($file_path)) {  
100 - $this->debug_echo('pdf生成失败!'); 109 + if ($count == 2) {
  110 + $list->is_pdf = PdfFile::GENERATE_OTHER_PDF;
  111 + $list->save();
  112 + $this->error('项目文件数据保存失败! - 其他原因 - ' . $key);
101 return 0; 113 return 0;
102 } 114 }
103 - $isRes = $this->DataFile->saveData(compact('project_id', 'user_id', 'friend_id', 'file_path') + ['time' => $this->time]);  
104 - if (!$isRes) {  
105 - if ($count == 2) {  
106 - $lists->is_pdf = 2;  
107 - $lists->save();  
108 - $this->debug_echo('项目文件数据保存失败! - 其他原因 - ' . $key);  
109 - } else { 115 +
  116 + $file_path = $this->savePDF($html, $filename);
  117 + if (empty($file_path)) {
110 redis_set($key, $count + 1); 118 redis_set($key, $count + 1);
111 - $this->debug_echo('项目文件数据保存失败! - ' . $key);  
112 - } 119 + $this->error('pdf生成失败!');
  120 + return 0;
113 } 121 }
114 - $lists->is_pdf = 1;  
115 - $lists->save(); 122 +
  123 + // 保存文件路径
  124 + $list->file_path = $file_path;
  125 + $list->is_pdf = PdfFile::GENERATE_PDF;
  126 + $list->save();
116 $this->info('项目文件数据保存成功!'); 127 $this->info('项目文件数据保存成功!');
117 return 0; 128 return 0;
118 } 129 }
@@ -131,18 +142,22 @@ class ProjectFilePDF extends Command @@ -131,18 +142,22 @@ class ProjectFilePDF extends Command
131 } 142 }
132 // 指定保存路径和文件名 143 // 指定保存路径和文件名
133 $savePath = $pdf_path . $filename . '.pdf'; 144 $savePath = $pdf_path . $filename . '.pdf';
  145 +
134 if (file_exists($savePath)) { 146 if (file_exists($savePath)) {
135 echo '文件已经存在'; 147 echo '文件已经存在';
136 return 0; 148 return 0;
137 } 149 }
138 150
  151 + $path = '/PDF/' . $this->time;
139 $pdf = PDF::loadHTML($html); 152 $pdf = PDF::loadHTML($html);
140 - $pdf->save($savePath);  
141 153
142 - $path = '/V6/PDF/' . $this->time;  
143 - // 创建一个文件实例  
144 - $file = new File($savePath);  
145 - return $this->CosService->uploadFile($file, $path, $filename . '.pdf'); 154 + // 获取二进制文件
  155 + $binary = $pdf->output(['compres' => 0]);
  156 + // 将文件保存到本地
  157 +// $pdf->save($savePath);
  158 +// $binary = new File($savePath);
  159 +
  160 + return $this->CosService->uploadFile($binary, $path, $filename . '.pdf', true);
146 } 161 }
147 162
148 /** 163 /**
@@ -153,6 +168,6 @@ class ProjectFilePDF extends Command @@ -153,6 +168,6 @@ class ProjectFilePDF extends Command
153 protected function html($item) 168 protected function html($item)
154 { 169 {
155 $font_path = storage_path('fonts\msyh.ttf'); 170 $font_path = storage_path('fonts\msyh.ttf');
156 - return '<html><head><title>Laravel</title><meta http-equiv=\'Content-Type\' content=\'text/html; charset=utf-8\'/><style>body{ font-family: \'msyh\'; } @font-face { font-family: \'msyh\'; font-style: normal; font-weight: normal; src: url(' . $font_path . ') format(\'truetype\'); }</style></head><body><div class=\'container\'><div class=\'content\'><p style=\'font-family: msyh, DejaVu Sans,sans-serif;\'>献给母亲的爱</p><div style=\'font-family: msyh, DejaVu Sans,sans-serif;\' class=\'title\'>Laravel 5中文测试</div><div class=\'title\'>测试三askjdhfkjasdhf</div></div></div></body></html>'; 171 + return '<html><head><title>Laravel</title><meta http-equiv=\'Content-Type\' content=\'text/html; charset=utf-8\'/><style>body{ font-family: \'msyh\'; } @font-face { font-family: \'msyh\'; font-style: normal; font-weight: normal; src: url(' . $font_path . ') format(\'truetype\'); }</style></head><body><div class=\'container\'><div class=\'content\'><p style=\'font-family: msyh, DejaVu Sans,sans-serif;\'>献给母亲的爱</p><div style=\'font-family: msyh, DejaVu Sans,sans-serif;\' class=\'title\'>Laravel 5中文测试sdsd</div><div class=\'title\'>测试三askjdhfkjasdhf</div></div></div></body></html>';
157 } 172 }
158 } 173 }
1 <?php 1 <?php
2 2
3 -namespace App\Console\Commands; 3 +namespace App\Console\Commands\GeneratePDF;
4 4
5 -use App\Models\File\DataFile; 5 +use App\Models\File\PdfFile;
  6 +use App\Models\ProjectAssociation\ProjectAssociation;
6 use Illuminate\Console\Command; 7 use Illuminate\Console\Command;
7 8
8 -class WebsiteData extends Command 9 +class PushAiccData extends Command
9 { 10 {
10 - use CmdSignal; 11 +// use CmdSignal;
11 12
12 /** 13 /**
13 * The name and signature of the console command. 14 * The name and signature of the console command.
14 * 15 *
15 * @var string 16 * @var string
16 */ 17 */
17 - protected $signature = 'website_data'; 18 + protected $signature = 'push_data_to_aicc';
18 19
19 /** 20 /**
20 * The console command description. 21 * The console command description.
@@ -39,41 +40,65 @@ class WebsiteData extends Command @@ -39,41 +40,65 @@ class WebsiteData extends Command
39 parent::__construct(); 40 parent::__construct();
40 } 41 }
41 42
  43 +
  44 + public function handle()
  45 + {
  46 + return $this->main();
  47 + }
  48 +
42 public function start(): int 49 public function start(): int
43 { 50 {
44 - # 0 - 未推送  
45 - # 1 - 已推送  
46 - # 2 - 其他问题  
47 - $status = 0;  
48 - $lists = DataFile::query()->where('status', $status)  
49 - ->where('created_at', 'like', $this->time . '%')->first();  
50 - if (is_null($lists)) {  
51 - $this->debug_echo('没有任务,等待中');  
52 - sleep(30); 51 + return $this->main();
  52 + }
  53 +
  54 + protected function main()
  55 + {
  56 + $list = PdfFile::query()->whereIsPdf(PdfFile::GENERATE_PUSH)->whereIsPush(PdfFile::GENERATE_NOT_PUSH)->first();
  57 + if (is_null($list)) {
  58 + $this->error('向AICC推送 - 没有任务,等待中');
  59 + sleep(60);
53 return 0; 60 return 0;
54 } 61 }
55 62
56 - $key = $this->signature . '-' . $lists->id;  
57 - $count = redis_get($key);  
58 - $data = $lists; 63 + $pid = $list->pid;
  64 + if (empty($pid)) {
  65 + $this->error('向AICC推送数据错误');
  66 + return 0;
  67 + }
  68 + $isExists = ProjectAssociation::query()->whereId($pid)->whereStatus(ProjectAssociation::STATUS_NORMAL)->first();
  69 + if (is_null($isExists)) {
  70 + $this->error('向AICC推送数据已被禁用 —— ' . $pid);
  71 + return 0;
  72 + }
  73 +
  74 + $key = 'push_data_to_aicc_' . $list->id;
  75 + $count = (int)redis_get($key) ?: 0;
  76 +
  77 + $data = $list->toArray();
  78 + $data['project_id'] = $isExists->project_id;
  79 + $data['friend_id'] = $isExists->friend_id;
  80 + $data['user_id'] = $isExists->user_id;
  81 +
59 $url = env('AICC_URL'); 82 $url = env('AICC_URL');
60 $msg = http_post($url, json_encode(compact('data'))); 83 $msg = http_post($url, json_encode(compact('data')));
61 $status_code = 0; 84 $status_code = 0;
62 if ($msg) { 85 if ($msg) {
63 $status_code = (int)$msg['status']; 86 $status_code = (int)$msg['status'];
64 } 87 }
65 - if ($status_code != 200) {  
66 if ($count == 2) { 88 if ($count == 2) {
67 - $lists->status = 2;  
68 - $lists->save(); 89 + $list->is_push = PdfFile::GENERATE_OTHER_PUSH;
  90 + $list->save();
69 $this->debug_echo('项目文件数据保存失败! - 其他原因 - ' . $key); 91 $this->debug_echo('项目文件数据保存失败! - 其他原因 - ' . $key);
70 - } else { 92 + return 0;
  93 + }
  94 +
  95 + if ($status_code != 200) {
71 redis_set($key, $count + 1); 96 redis_set($key, $count + 1);
72 $this->debug_echo('项目文件数据保存失败! - ' . $key); 97 $this->debug_echo('项目文件数据保存失败! - ' . $key);
  98 + return 0;
73 } 99 }
74 - }  
75 - $lists->status = 1;  
76 - $lists->save(); 100 + $list->is_push = PdfFile::GENERATE_PUSH;
  101 + $list->save();
77 $this->info('项目文件数据保存成功!'); 102 $this->info('项目文件数据保存成功!');
78 return 0; 103 return 0;
79 } 104 }
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :UpdateRoute.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/11/20 15:07
  8 + */
  9 +
  10 +namespace App\Console\Commands;
  11 +
  12 +use App\Models\Blog\Blog;
  13 +use App\Models\Blog\BlogCategory;
  14 +use App\Models\News\News;
  15 +use App\Models\News\NewsCategory;
  16 +use App\Models\Product\Category;
  17 +use App\Models\Product\Keyword;
  18 +use App\Models\Product\Product;
  19 +use App\Models\Project\Project;
  20 +use App\Models\RouteMap\RouteMap;
  21 +use App\Models\Template\BTemplateMain;
  22 +use App\Services\ProjectServer;
  23 +use Illuminate\Console\Command;
  24 +use Illuminate\Support\Facades\DB;
  25 +
  26 +/**
  27 + * @remark :更新所有项目的路由
  28 + * @name :UpdateRoute
  29 + * @author :lyh
  30 + * @method :post
  31 + * @time :2023/11/20 15:08
  32 + */
  33 +class UpdateMainHtml extends Command
  34 +{
  35 + /**
  36 + * The name and signature of the console command.
  37 + *
  38 + * @var string
  39 + */
  40 + protected $signature = 'update_main';
  41 +
  42 + /**
  43 + * The console command description.
  44 + *
  45 + * @var string
  46 + */
  47 + protected $description = '洗数据';
  48 +
  49 + /**
  50 + * @remark :统一更新路由
  51 + * @name :handle
  52 + * @author :lyh
  53 + * @method :post
  54 + * @time :2023/11/20 15:13
  55 + */
  56 + public function handle(){
  57 + $projectModel = new Project();
  58 + $list = $projectModel->list(['type'=>['!=',0]]);
  59 + foreach ($list as $v){
  60 + echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
  61 + ProjectServer::useProject($v['id']);
  62 + $this->editMainHtml();
  63 + DB::disconnect('custom_mysql');
  64 + }
  65 + echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
  66 + }
  67 +
  68 + /**
  69 + * @remark :洗数据
  70 + * @name :getMainHtml
  71 + * @author :lyh
  72 + * @method :post
  73 + * @time :2023/12/27 18:03
  74 + */
  75 + public function editMainHtml(){
  76 + $mainModel = new BTemplateMain();
  77 +// $mainModel->edit(['type'=>3],['type'=>4]);
  78 + $mainModel->edit(['type'=>4],['type'=>6]);
  79 + return true;
  80 + }
  81 +}
@@ -29,9 +29,11 @@ class ComController extends BaseController @@ -29,9 +29,11 @@ class ComController extends BaseController
29 public function get_menu(){ 29 public function get_menu(){
30 //根据当前登录用户角色返回用户菜单列表 30 //根据当前登录用户角色返回用户菜单列表
31 $projectMenuModel = new ProjectMenuModel(); 31 $projectMenuModel = new ProjectMenuModel();
  32 + @file_put_contents(storage_path('logs/lyh_error.log'), var_export(11111, true) . PHP_EOL, FILE_APPEND);
32 if($this->user['role_id'] != 0){ 33 if($this->user['role_id'] != 0){
33 $this->map = $this->getNoAdminMenuCondition(); 34 $this->map = $this->getNoAdminMenuCondition();
34 }else{ 35 }else{
  36 + @file_put_contents(storage_path('logs/lyh_error.log'), var_export($this->map, true) . PHP_EOL, FILE_APPEND);
35 $this->map = $this->getAdminMenuCondition(); 37 $this->map = $this->getAdminMenuCondition();
36 } 38 }
37 $lists = $projectMenuModel->list($this->map,'sort'); 39 $lists = $projectMenuModel->list($this->map,'sort');
@@ -45,7 +45,7 @@ class BTemplateController extends BaseController @@ -45,7 +45,7 @@ class BTemplateController extends BaseController
45 'source.required' => 'source不能为空', 45 'source.required' => 'source不能为空',
46 'source_id.required' => 'source_id不能为空', 46 'source_id.required' => 'source_id不能为空',
47 ]); 47 ]);
48 - $info = $BTemplateLogic->getTemplate(); 48 + $info = $BTemplateLogic->getTemplateHtml();
49 $this->response('success',Code::SUCCESS,$info); 49 $this->response('success',Code::SUCCESS,$info);
50 } 50 }
51 51
@@ -138,28 +138,4 @@ class BTemplateController extends BaseController @@ -138,28 +138,4 @@ class BTemplateController extends BaseController
138 $this->response('模板保存成功'); 138 $this->response('模板保存成功');
139 } 139 }
140 140
141 - /**  
142 - * @remark :获取可视化详情页模板数据  
143 - * @name :getDetailInfo  
144 - * @author :lyh  
145 - * @method :post  
146 - * @time :2023/10/24 11:27  
147 - */  
148 - public function getDetailInfo(BTemplateLogic $BTemplateLogic){  
149 - $html = $BTemplateLogic->getDetail();  
150 - $this->response('success',Code::SUCCESS,['html'=>$html]);  
151 - }  
152 -  
153 - /**  
154 - * @remark :保存详情页模板数据  
155 - * @name :saveDetail  
156 - * @author :lyh  
157 - * @method :post  
158 - * @time :2023/10/24 14:47  
159 - */  
160 - public function saveDetail(BTemplateLogic $BTemplateLogic){  
161 - $BTemplateLogic->saveDetail();  
162 - $this->response('success');  
163 - }  
164 -  
165 } 141 }
1 <?php 1 <?php
2 /** 2 /**
3 * @remark : 3 * @remark :
4 - * @name :VisualizationController.php 4 + * @name :InitHtmlController.php
5 * @author :lyh 5 * @author :lyh
6 * @method :post 6 * @method :post
7 - * @time :2023/11/15 9:55 7 + * @time :2023/12/27 10:37
8 */ 8 */
9 9
10 namespace App\Http\Controllers\Bside\Template; 10 namespace App\Http\Controllers\Bside\Template;
11 11
12 use App\Enums\Common\Code; 12 use App\Enums\Common\Code;
13 use App\Http\Controllers\Bside\BaseController; 13 use App\Http\Controllers\Bside\BaseController;
  14 +use App\Http\Logic\Bside\BTemplate\BTemplateLogic;
  15 +use App\Http\Logic\Bside\BTemplate\InitHtmlLogic;
14 use App\Http\Logic\Bside\BTemplate\VisualizationLogic; 16 use App\Http\Logic\Bside\BTemplate\VisualizationLogic;
15 17
16 /** 18 /**
17 - * @remark :定制项目处理  
18 - * @name :VisualizationController 19 + * @remark :初始复合页代码块上传
  20 + * @name :InitHtmlController
19 * @author :lyh 21 * @author :lyh
20 * @method :post 22 * @method :post
21 - * @time :2023/11/15 9:55 23 + * @time :2023/12/27 10:37
22 */ 24 */
23 -class VisualizationController extends BaseController 25 +class InitHtmlController extends BaseController
24 { 26 {
25 /** 27 /**
  28 + * @remark :获取可视化详情页模板数据
  29 + * @name :getDetailInfo
  30 + * @author :lyh
  31 + * @method :post $param (type:类型,2产品 3博客 4新闻 对应扩展模块的id)
  32 + * @time :2023/10/24 11:27
  33 + */
  34 + public function getDetailHtml(InitHtmlLogic $logic){
  35 + $this->request->validate([
  36 + 'type'=>['required'],
  37 + ],[
  38 + 'type.required' => '类型不能为空',
  39 + ]);
  40 + $html = $logic->getDetailHtml();
  41 + $this->response('success',Code::SUCCESS,['html'=>$html]);
  42 + }
  43 +
  44 + /**
  45 + * @remark :保存详情页模板数据
  46 + * @name :saveDetail
  47 + * @author :lyh
  48 + * @method :post $param (type:类型,2产品 3博客 4新闻 对应扩展模块的id)
  49 + * @time :2023/10/24 14:47
  50 + */
  51 + public function saveDetailHtml(InitHtmlLogic $logic){
  52 + $this->request->validate([
  53 + 'type'=>['required'],
  54 + ],[
  55 + 'type.required' => '类型不能为空',
  56 + ]);
  57 + $logic->saveDetailHtml();
  58 + $this->response('success');
  59 + }
  60 +
  61 + /**
26 * @remark :获取当前定制代码块详情 62 * @remark :获取当前定制代码块详情
27 * @name :info 63 * @name :info
28 * @author :lyh 64 * @author :lyh
29 * @method :post 65 * @method :post
30 * @time :2023/11/15 10:26 66 * @time :2023/11/15 10:26
31 */ 67 */
32 - public function info(VisualizationLogic $logic){  
33 - $info = $logic->getVisualizationInfo(); 68 + public function getCustomizedHtml(InitHtmlLogic $logic){
  69 + $this->request->validate([
  70 + 'type'=>['required'],
  71 + ],[
  72 + 'type.required' => '类型不能为空',
  73 + ]);
  74 + $info = $logic->getCustomizedHtml();
34 if($info === false){ 75 if($info === false){
35 $info = []; 76 $info = [];
36 } 77 }
@@ -44,8 +85,13 @@ class VisualizationController extends BaseController @@ -44,8 +85,13 @@ class VisualizationController extends BaseController
44 * @method :post 85 * @method :post
45 * @time :2023/11/15 10:08 86 * @time :2023/11/15 10:08
46 */ 87 */
47 - public function save(VisualizationLogic $logic){  
48 - $logic->saveVisualization(); 88 + public function saveCustomizedHtml(InitHtmlLogic $logic){
  89 + $this->request->validate([
  90 + 'type'=>['required'],
  91 + ],[
  92 + 'type.required' => '类型不能为空',
  93 + ]);
  94 + $logic->saveCustomizedHtml();
49 $this->response('success'); 95 $this->response('success');
50 } 96 }
51 } 97 }
@@ -57,48 +57,42 @@ class BTemplateLogic extends BaseLogic @@ -57,48 +57,42 @@ class BTemplateLogic extends BaseLogic
57 } 57 }
58 58
59 /** 59 /**
60 - * @remark :获取当前选择使用的模板  
61 - * @name :getModuleTemplate  
62 - * @author :lyh  
63 - * @method :post  
64 - * @time :2023/6/29 9:44  
65 - */  
66 - public function getTemplate(){  
67 - $template_id = $this->getSettingTemplate($this->param['source'],$this->param['source_id']);//设置的模版id  
68 - $data = $this->getHtml($template_id,$this->param['source'],$this->param['source_id'],$this->param['is_custom'] ?? 0);  
69 - return $this->success($data);  
70 - }  
71 -  
72 - /**  
73 - * @remark :获取可视化装修的html 60 + * @remark :获取可视化html
74 * @name :getTemplateHtml 61 * @name :getTemplateHtml
75 * @author :lyh 62 * @author :lyh
76 * @method :post 63 * @method :post
77 - * @time :2023/12/13 10:47 64 + * @time :2023/12/27 14:48
78 */ 65 */
79 - public function getHtml($template_id,$source,$source_id,$is_custom){  
80 - $templateInfo = $this->webTemplateInfo($template_id,$source,$source_id,$is_custom); 66 + public function getTemplateHtml(){
  67 + $is_custom = $this->param['is_custom'] ?? 0;//是否为扩展模块
  68 + $is_list = $this->param['is_list'] ?? 0;//是否为列表页
  69 + $template_id = $this->getSettingTemplate($this->param['source'],$is_list);//设置的模版id
  70 + $templateInfo = $this->model->read([
  71 + 'template_id'=>$template_id, 'source'=>$this->param['source'],
  72 + 'project_id'=>$this->user['project_id'], 'source_id'=>$this->param['source_id'],
  73 + 'is_custom'=>$is_custom, 'is_list'=>$is_list
  74 + ]);
81 if($templateInfo === false){ 75 if($templateInfo === false){
82 if($this->user['is_customized'] == BTemplate::SOURCE_VISUALIZATION){//处理定制页面初始数据 76 if($this->user['is_customized'] == BTemplate::SOURCE_VISUALIZATION){//处理定制页面初始数据
83 - $html = $this->isCustomizedPage($source,$source_id);//查看当前页面是否定制 77 + $html = $this->isCustomizedPage($this->param['source'],$is_list);//获取定制页面的html
84 return $this->success(['html'=>$html,'template_id'=>$template_id]); 78 return $this->success(['html'=>$html,'template_id'=>$template_id]);
85 } 79 }
86 - $mainInfo = $this->getCommonMain($source,$source_id,$is_custom);//获取中间部分代码 80 + $mainInfo = $this->getMAinHtml($this->param['source'],$is_custom,$is_list);//获取中间部分代码
87 }else{ 81 }else{
88 if($templateInfo['type'] == BTemplate::ALL_HTML){//返回整个html代码 82 if($templateInfo['type'] == BTemplate::ALL_HTML){//返回整个html代码
89 - $type = $this->getCustomizedType($source, $source_id);//定制获取头部底部类型  
90 - $commonInfo = $this->getCommonPage($type,$this->user['project_id'],0);//获取定制头部 83 + $commonInfo = $this->getCommonHtml($this->param['source'],$is_list,0);//获取定制头部
91 $html = $this->handleAllHtml($commonInfo,$templateInfo['html']); 84 $html = $this->handleAllHtml($commonInfo,$templateInfo['html']);
92 return $this->success(['html'=>$html,'template_id'=>$template_id,'id'=>$templateInfo['id'],'updated_at'=>$templateInfo['updated_at']]); 85 return $this->success(['html'=>$html,'template_id'=>$template_id,'id'=>$templateInfo['id'],'updated_at'=>$templateInfo['updated_at']]);
93 } 86 }
94 $mainInfo = ['main_html'=>$templateInfo['main_html'], 'main_css'=>$templateInfo['main_css']]; 87 $mainInfo = ['main_html'=>$templateInfo['main_html'], 'main_css'=>$templateInfo['main_css']];
95 } 88 }
96 - $commonInfo = $this->getCommonPage($source,$source_id,$template_id);//获取头部 89 + $commonInfo = $this->getCommonHtml($this->param['source'],$is_list,$template_id);//获取定制头部
97 $html = $commonInfo['head_css'].$mainInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other']. 90 $html = $commonInfo['head_css'].$mainInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other'].
98 $commonInfo['head_html'].$mainInfo['main_html'].$commonInfo['footer_html']; 91 $commonInfo['head_html'].$mainInfo['main_html'].$commonInfo['footer_html'];
99 $html = $this->getHeadFooter($html); 92 $html = $this->getHeadFooter($html);
100 $result = ['html'=>$html,'template_id'=>$template_id]; 93 $result = ['html'=>$html,'template_id'=>$template_id];
101 - if($templateInfo !== false){ 94 + if($templateInfo !== false)
  95 + {
102 $result['id'] = $templateInfo['id']; 96 $result['id'] = $templateInfo['id'];
103 $result['updated_at'] = $templateInfo['updated_at']; 97 $result['updated_at'] = $templateInfo['updated_at'];
104 } 98 }
@@ -106,6 +100,43 @@ class BTemplateLogic extends BaseLogic @@ -106,6 +100,43 @@ class BTemplateLogic extends BaseLogic
106 } 100 }
107 101
108 /** 102 /**
  103 + * @remark :获取中间部分的html
  104 + * @name :getMAinHtml
  105 + * @author :lyh
  106 + * @method :post
  107 + * @time :2023/12/27 15:00
  108 + */
  109 + public function getMAinHtml($type,$is_custom,$is_list){
  110 + //获取设置的默认中间部分
  111 + $bTemplateMainModel = new BTemplateMain();
  112 + $mainInfo = $bTemplateMainModel->read(['type'=>$type,'is_list'=>$is_list,'is_custom'=>$is_custom]);
  113 + if($mainInfo === false){
  114 + $main_html = $this->getInitModule($type,$is_custom,$is_list);
  115 + $main_css = "<style id='globalsojs-styles'></style>";
  116 + }else{
  117 + $main_html = $mainInfo['main_html'];
  118 + $main_css = $mainInfo['main_css'];
  119 + }
  120 + return ['main_html'=>$main_html,'main_css'=>$main_css];
  121 + }
  122 +
  123 + /**
  124 + * @remark :默认复合页数据
  125 + * @name :getProductModule
  126 + * @author :lyh
  127 + * @method :post
  128 + * @time :2023/7/27 15:08
  129 + */
  130 + public function getInitModule($type,$is_custom,$is_list){
  131 + if($is_custom == BTemplate::SOURCE_CUSTOM) {
  132 + $type = BTemplate::TYPE_CUSTOM;
  133 + }
  134 + $mainModel = new TemplateTypeMain();
  135 + $info = $mainModel->read(['type'=>$type,'is_list'=>$is_list]);
  136 + return $info['main_html'];
  137 + }
  138 +
  139 + /**
109 * @remark :返回整个html截取代码 140 * @remark :返回整个html截取代码
110 * @name :handleAllHtml 141 * @name :handleAllHtml
111 * @author :lyh 142 * @author :lyh
@@ -129,19 +160,19 @@ class BTemplateLogic extends BaseLogic @@ -129,19 +160,19 @@ class BTemplateLogic extends BaseLogic
129 * @method :post 160 * @method :post
130 * @time :2023/12/13 10:55 161 * @time :2023/12/13 10:55
131 */ 162 */
132 - public function isCustomizedPage($source,$source_id) 163 + public function isCustomizedPage($source,$is_list)
133 { 164 {
134 - $type = $this->getCustomizedType($source, $source_id);//获取定制界面类型 165 + $type = $this->getCustomizedType($source, $is_list);//获取定制界面类型
135 //查看当前页面是否定制,是否开启可视化 166 //查看当前页面是否定制,是否开启可视化
136 $page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面 167 $page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
137 if (in_array($type, $page_array)) {//是定制界面 168 if (in_array($type, $page_array)) {//是定制界面
138 //TODO::获取初始代码 169 //TODO::获取初始代码
139 $bTemplateMainModel = new BTemplateMain(); 170 $bTemplateMainModel = new BTemplateMain();
140 - $customHtmlInfo = $bTemplateMainModel->read(['type'=>$type]); 171 + $customHtmlInfo = $bTemplateMainModel->read(['type'=>$source,'is_list'=>$is_list]);
141 if($customHtmlInfo === false){ 172 if($customHtmlInfo === false){
142 $this->fail('定制页面,请先上传代码块'); 173 $this->fail('定制页面,请先上传代码块');
143 } 174 }
144 - $commonInfo = $this->getCommonPage($type,$this->user['project_id'],0);//获取定制头部 175 + $commonInfo = $this->getCommonHtml($type,$is_list,0);//获取定制头部
145 if($commonInfo !== false){ 176 if($commonInfo !== false){
146 $customHtmlInfo['main_html'] = $this->handleAllHtml($commonInfo,$customHtmlInfo['main_html']); 177 $customHtmlInfo['main_html'] = $this->handleAllHtml($commonInfo,$customHtmlInfo['main_html']);
147 } 178 }
@@ -151,22 +182,34 @@ class BTemplateLogic extends BaseLogic @@ -151,22 +182,34 @@ class BTemplateLogic extends BaseLogic
151 } 182 }
152 183
153 /** 184 /**
154 - * @remark :定制界面根据source+source_id获取type类型 185 + * @remark :根据source获取type类型
155 * @name :getType 186 * @name :getType
156 * @author :lyh 187 * @author :lyh
157 * @method :post 188 * @method :post
158 * @time :2023/11/16 11:20 189 * @time :2023/11/16 11:20
159 */ 190 */
160 - public function getCustomizedType($source,$source_id){ 191 + public function getCustomizedType($source,$is_list){
161 $type = BTemplate::TYPE_ONE; 192 $type = BTemplate::TYPE_ONE;
162 if($source == BTemplate::SOURCE_PRODUCT){ 193 if($source == BTemplate::SOURCE_PRODUCT){
163 - if($source_id == 0){$type = BTemplate::TYPE_THREE;}else{$type = BTemplate::TYPE_TWO;} 194 + if($is_list == BTemplate::IS_LIST){
  195 + $type = BTemplate::TYPE_THREE;
  196 + }else{
  197 + $type = BTemplate::TYPE_TWO;
  198 + }
164 } 199 }
165 if($source == BTemplate::SOURCE_BLOG){ 200 if($source == BTemplate::SOURCE_BLOG){
166 - if($source_id == 0){$type = BTemplate::TYPE_FIVE;}else{$type = BTemplate::TYPE_FOUR;} 201 + if($is_list == BTemplate::IS_LIST){
  202 + $type = BTemplate::TYPE_FIVE;
  203 + }else{
  204 + $type = BTemplate::TYPE_FOUR;
  205 + }
167 } 206 }
168 if($source == BTemplate::SOURCE_NEWS){ 207 if($source == BTemplate::SOURCE_NEWS){
169 - if($source_id == 0){$type = BTemplate::TYPE_SEVEN;}else{$type = BTemplate::TYPE_SIX;} 208 + if($is_list == BTemplate::IS_LIST){
  209 + $type = BTemplate::TYPE_SEVEN;
  210 + }else{
  211 + $type = BTemplate::TYPE_SIX;
  212 + }
170 } 213 }
171 return $type; 214 return $type;
172 } 215 }
@@ -178,13 +221,14 @@ class BTemplateLogic extends BaseLogic @@ -178,13 +221,14 @@ class BTemplateLogic extends BaseLogic
178 * @method :post 221 * @method :post
179 * @time :2023/12/13 10:48 222 * @time :2023/12/13 10:48
180 */ 223 */
181 - public function getSettingTemplate($source,$source_id){ 224 + public function getSettingTemplate($source,$is_list){
  225 + $template_id = 0;
182 if($this->user['is_customized'] == BTemplate::SOURCE_VISUALIZATION) {//定制项目 226 if($this->user['is_customized'] == BTemplate::SOURCE_VISUALIZATION) {//定制项目
183 - $type = $this->getCustomizedType($source, $source_id);//获取定制界面类型 227 + $type = $this->getCustomizedType($source, $is_list);//获取定制界面类型
184 //查看当前页面是否定制,是否开启可视化 228 //查看当前页面是否定制,是否开启可视化
185 $page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面 229 $page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
186 if (in_array($type, $page_array)) {//是定制界面 230 if (in_array($type, $page_array)) {//是定制界面
187 - return 0; 231 + return $this->success($template_id);
188 } 232 }
189 } 233 }
190 $bSettingModel = new Setting(); 234 $bSettingModel = new Setting();
@@ -192,188 +236,237 @@ class BTemplateLogic extends BaseLogic @@ -192,188 +236,237 @@ class BTemplateLogic extends BaseLogic
192 if($info === false){ 236 if($info === false){
193 $this->fail('请先选择模版'); 237 $this->fail('请先选择模版');
194 } 238 }
195 - return $info['template_id']; 239 + $template_id = $info['template_id'];
  240 + return $this->success($template_id);
196 } 241 }
197 242
198 /** 243 /**
199 - * @remark :根据参数获取数据详情  
200 - * @name :webTemplateInfo 244 + * @remark :根据类型获取公共头和底
  245 + * @name :getCommonPage
201 * @author :lyh 246 * @author :lyh
202 * @method :post 247 * @method :post
203 - * @time :2023/7/25 16:41 248 + * @time :2023/10/21 16:55
204 */ 249 */
205 - public function webTemplateInfo($template_id,$source,$source_id,$is_custom = 0){  
206 - //查看当前模板是否已编辑保存web_template  
207 - $TemplateInfo = $this->model->read([  
208 - 'template_id'=>$template_id,  
209 - 'source'=>$source,  
210 - 'project_id'=>$this->user['project_id'],  
211 - 'source_id'=>$source_id,  
212 - 'is_custom'=>$is_custom  
213 - ]);  
214 - return $this->success($TemplateInfo); 250 + public function getCommonHtml($source,$is_list,$template_id){
  251 + $is_head = $this->user['configuration']['is_head'] ?? 0;
  252 + $data = [
  253 + 'template_id' => $template_id,
  254 + 'project_id' => $this->user['project_id']
  255 + ];
  256 + if($template_id == 0){
  257 + $is_head = BTemplate::IS_HEADER;
  258 + }
  259 + if($is_head != BTemplate::IS_NO_HEADER) {
  260 + //查看页面是否设置自定义头部底部
  261 + $pageSettingModel = new PageSetting();
  262 + $pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]);
  263 + if($pageInfo !== false){
  264 + $commonInfo = [];
  265 + if ($source == BTemplate::SOURCE_BLOG) {//产品页
  266 + $commonInfo = $this->getProductCommonHtml($data,$is_list,$pageInfo);
  267 + }
  268 + if ($source == BTemplate::SOURCE_BLOG) {//博客页
  269 + $commonInfo = $this->getBlogCommonHtml($data,$is_list,$pageInfo);
  270 + }
  271 + if ($source == BTemplate::SOURCE_NEWS) {//新闻页
  272 + $commonInfo = $this->getNewsCommonHtml($data,$is_list,$pageInfo);
  273 + }
  274 + if ($source == BTemplate::SOURCE_KEYWORD) {//聚合页
  275 + $commonInfo = $this->getKeywordCommonHtml($data,$pageInfo);
  276 + }
  277 + if(!empty($commonInfo)){
  278 + return $this->success($commonInfo);
  279 + }
  280 + }
  281 + }
  282 + //获取首页公共的头部和底部
  283 + $commonInfo = $this->getHomeCommonHtml($data);
  284 + return $commonInfo;
215 } 285 }
216 286
217 /** 287 /**
218 - * @remark :获取中间公共部分  
219 - * @name :getCommonMain 288 + * @remark :获取首页头部底部
  289 + * @name :getHomeCommonHtml
220 * @author :lyh 290 * @author :lyh
221 * @method :post 291 * @method :post
222 - * @time :2023/10/24 15:58 292 + * @time :2023/12/27 16:11
223 */ 293 */
224 - public function getCommonMain($source,$source_id,$is_custom){  
225 - $data = [];  
226 - if($is_custom == BTemplate::SOURCE_CUSTOM){  
227 - if($source_id != 0){$type = BTemplate::TYPE_CUSTOM_DETAIL;}else{$type = BTemplate::TYPE_CUSTOM_LIST;}  
228 - }else{  
229 - if ($source == BTemplate::SOURCE_PRODUCT) {if ($source_id != 0) {$type = BTemplate::TYPE_TWO;} else {$type = BTemplate::TYPE_THREE;}}  
230 - if ($source == BTemplate::SOURCE_BLOG) {if ($source_id != 0) {$type = BTemplate::TYPE_FOUR;} else {$type = BTemplate::TYPE_FIVE;}}  
231 - if ($source == BTemplate::SOURCE_NEWS) {if ($source_id != 0) {$type = BTemplate::TYPE_SIX;} else {$type = BTemplate::TYPE_SEVEN;}}  
232 - if ($source == BTemplate::SOURCE_KEYWORD) {$type = BTemplate::TYPE_EIGHT;} 294 + public function getHomeCommonHtml($data){
  295 + $data['type'] = BTemplate::SOURCE_HOME;
  296 + $commonTemplateModel = new BTemplateCommon();
  297 + return $commonTemplateModel->read($data);
233 } 298 }
234 - //查询有没有公共详情模板  
235 - $bTemplateMainModel = new BTemplateMain();  
236 - $mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'type'=>$type]);  
237 - if($mainInfo === false){  
238 - $data['main_html'] = $this->getModule($type);  
239 - $data['main_css'] = "<style id='globalsojs-styles'></style>";  
240 - }else{  
241 - $data['main_html'] = $mainInfo['main_html'];  
242 - $data['main_css'] = $mainInfo['main_css']; 299 +
  300 + /**
  301 + * @remark :聚合页
  302 + * @name :getKeywordCommonHtml
  303 + * @author :lyh
  304 + * @method :post
  305 + * @time :2023/12/27 16:09
  306 + */
  307 + public function getKeywordCommonHtml($data,$pageInfo){
  308 + $commonInfo = [];
  309 + $commonTemplateModel = new BTemplateCommon();
  310 + $data['type'] = BTemplate::TYPE_EIGHT;
  311 + if ($pageInfo['polymerization'] != 0) {
  312 + $commonInfo = $commonTemplateModel->read($data);
  313 + if($commonInfo === false){
  314 + $commonInfo = [];
243 } 315 }
244 - return $data; 316 + }
  317 + return $this->success($commonInfo);
245 } 318 }
246 319
247 /** 320 /**
248 - * @remark :根据类型获取公共头和底  
249 - * @name :getCommonPage 321 + * @remark :产品头部底部
  322 + * @name :getProductCommonHtml
250 * @author :lyh 323 * @author :lyh
251 * @method :post 324 * @method :post
252 - * @time :2023/10/21 16:55 325 + * @time :2023/12/27 16:01
253 */ 326 */
254 - public function getCommonPage($source,$source_id,$template_id){  
255 - if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) {  
256 - //查看页面是否设置自定义头部底部  
257 - $pageSettingModel = new PageSetting();  
258 - $pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]);  
259 - if ($pageInfo != false) { 327 + public function getProductCommonHtml($data,$is_list,$pageInfo){
  328 + $commonInfo = [];
260 $commonTemplateModel = new BTemplateCommon(); 329 $commonTemplateModel = new BTemplateCommon();
261 - $data = [  
262 - 'template_id' => $template_id,  
263 - 'project_id' => $this->user['project_id']  
264 - ];  
265 - if ($source == BTemplate::SOURCE_PRODUCT) {//产品页  
266 - if($source_id != 0){$data['type'] = BTemplate::TYPE_TWO;if ($pageInfo['product_details'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}  
267 - else {$data['type'] = BTemplate::TYPE_THREE;if ($pageInfo['product_list'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}}  
268 - if ($source == BTemplate::SOURCE_BLOG) {//博客页  
269 - if ($source_id != 0) {$data['type'] = BTemplate::TYPE_FOUR;if ($pageInfo['blog_details'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}  
270 - else {$data['type'] = BTemplate::TYPE_FIVE;if ($pageInfo['blog_list'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}}  
271 - if ($source == BTemplate::SOURCE_NEWS) {//新闻页  
272 - if ($source_id != 0) {$data['type'] = BTemplate::TYPE_SIX;if ($pageInfo['news_details'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}  
273 - else {$data['type'] = BTemplate::TYPE_SEVEN;if ($pageInfo['news_list'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}}  
274 - if ($source == BTemplate::SOURCE_KEYWORD) {//聚合页  
275 - $data['type'] = BTemplate::TYPE_EIGHT;if ($pageInfo['polymerization'] != 0) {$commonInfo = $commonTemplateModel->read($data);}} 330 + if($is_list == BTemplate::IS_LIST){
  331 + $data['type'] = BTemplate::TYPE_THREE;
  332 + if ($pageInfo['product_list'] != 0) {
  333 + $commonInfo = $commonTemplateModel->read($data);
  334 + if($commonInfo === false){
  335 + $commonInfo = [];
276 } 336 }
277 } 337 }
278 - //获取首页公共的头部和底部  
279 - if(!isset($commonInfo) || $commonInfo === false){  
280 - $commonTemplateModel = new BTemplateCommon();  
281 - $commonInfo = $commonTemplateModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>BTemplate::TYPE_ONE]); 338 + } else {
  339 + $data['type'] = BTemplate::TYPE_TWO;
  340 + if ($pageInfo['product_details'] != 0) {
  341 + $commonInfo = $commonTemplateModel->read($data);
  342 + if($commonInfo === false){
  343 + $commonInfo = [];
  344 + }
282 } 345 }
283 - return $commonInfo; 346 + }
  347 + return $this->success($commonInfo);
284 } 348 }
285 349
286 /** 350 /**
287 - * @remark :保存修改后的模版  
288 - * @name :templateSave 351 + * @remark :博客头部
  352 + * @name :getBlogCommonHtml
289 * @author :lyh 353 * @author :lyh
290 * @method :post 354 * @method :post
291 - * @time :2023/6/29 11:05 355 + * @time :2023/12/27 16:05
292 */ 356 */
293 - public function templateSave(){  
294 - //演示项目不允许修改  
295 - $this->showProjectNoEdit($this->param['source']);  
296 - DB::beginTransaction();  
297 - try {  
298 - $this->param = $this->handleDefaultString($this->param);//设置默认字符  
299 - $templateInfo = $this->webTemplateInfo($this->param['template_id'],$this->param['source'],  
300 - $this->param['source_id'],$this->param['is_custom']);  
301 - if($templateInfo === false){//执行新增  
302 - $this->templateAddHtml($this->param['html'], $this->param['source'], $this->param['source_id'],  
303 - $this->param['template_id'], $this->param['section_list_id'], $this->param['is_custom']);  
304 - }else{//执行编辑  
305 - $this->templateEditHtml($this->param['html'],$this->param['source'],$this->param['source_id'],  
306 - $this->param['template_id'],$this->param['section_list_id'], $this->param['is_custom']); 357 + public function getBlogCommonHtml($data,$is_list,$pageInfo){
  358 + $commonInfo = [];
  359 + $commonTemplateModel = new BTemplateCommon();
  360 + if ($is_list == BTemplate::IS_LIST) {
  361 + $data['type'] = BTemplate::TYPE_SEVEN;
  362 + if ($pageInfo['blog_list'] != 0) {
  363 + $commonInfo = $commonTemplateModel->read($data);
  364 + if($commonInfo === false){
  365 + $commonInfo = [];
  366 + }
  367 + }
  368 + } else {
  369 + $data['type'] = BTemplate::TYPE_SIX;
  370 + if ($pageInfo['blog_details'] != 0) {
  371 + $commonInfo = $commonTemplateModel->read($data);
  372 + if($commonInfo === false){
  373 + $commonInfo = [];
307 } 374 }
308 - //更新头部信息  
309 - $this->saveCommonHtml($this->param['html'],$this->param['source'],$this->param['source_id'],$this->param['template_id']);  
310 - $this->setOperationRecords($this->param['html'],$this->param['source'],$this->param['source_id'],$this->param['template_id'],$this->param['is_custom']);  
311 - DB::commit();  
312 - }catch (\Exception $e){  
313 - DB::rollBack();  
314 - $this->fail('系统错误,请联系管理员');  
315 } 375 }
316 - //通知更新  
317 - $this->homeOrProduct($this->param['source'],$this->param['source_id'],$this->param['is_custom']);  
318 - return $this->success(); 376 + }
  377 + return $this->success($commonInfo);
319 } 378 }
320 379
321 /** 380 /**
322 - * @remark :保存数据时设置默认字符  
323 - * @name :saveDefaultString 381 + * @remark :新闻头部
  382 + * @name :getNewsCommonHtml
324 * @author :lyh 383 * @author :lyh
325 * @method :post 384 * @method :post
326 - * @time :2023/12/15 10:30 385 + * @time :2023/12/27 16:07
327 */ 386 */
328 - public function handleDefaultString($param){  
329 - if(!isset($param['template_id'])){  
330 - $param['template_id'] = 0; 387 + public function getNewsCommonHtml($data,$is_list,$pageInfo){
  388 + $commonInfo = [];
  389 + $commonTemplateModel = new BTemplateCommon();
  390 + if ($is_list == BTemplate::IS_LIST) {
  391 + $data['type'] = BTemplate::TYPE_SEVEN;
  392 + if ($pageInfo['news_list'] != 0) {
  393 + $commonInfo = $commonTemplateModel->read($data);
  394 + if($commonInfo === false){
  395 + $commonInfo = [];
331 } 396 }
332 - if(!isset($param['is_custom'])){  
333 - $param['is_custom'] = 0;  
334 } 397 }
335 - if(!isset($param['section_list_id'])){  
336 - $param['section_list_id'] = ''; 398 + } else {
  399 + $data['type'] = BTemplate::TYPE_SIX;
  400 + if ($pageInfo['news_details'] != 0) {
  401 + $commonInfo = $commonTemplateModel->read($data);
  402 + if($commonInfo === false){
  403 + $commonInfo = [];
337 } 404 }
338 - return $this->success($param); 405 + }
  406 + }
  407 + return $this->success($commonInfo);
339 } 408 }
340 409
341 /** 410 /**
342 - * @remark :可视化添加数据  
343 - * @name :templateAddHtml 411 + * @remark :保存修改后的模版
  412 + * @name :templateSave
344 * @author :lyh 413 * @author :lyh
345 * @method :post 414 * @method :post
346 - * @time :2023/12/15 10:15 415 + * @time :2023/6/29 11:05
347 */ 416 */
348 - public function templateAddHtml($html,$source,$source_id,$template,$section_list_id,$is_custom){ 417 + public function templateSave(){
  418 + //演示项目不允许修改
  419 + $this->showProjectNoEdit($this->param['source']);
  420 + $this->param = $this->handleDefaultString($this->param);//设置默认数据
  421 + $templateInfo = $this->model->read([
  422 + 'template_id'=>$this->param['template_id'],
  423 + 'source'=>$this->param['source'],
  424 + 'source_id'=>$this->param['source_id'],
  425 + 'is_custom'=>$this->param['is_custom'],
  426 + 'is_list'=>$this->param['is_list']
  427 + ]);
  428 + if($templateInfo === false){//执行新增
349 $data = [ 429 $data = [
350 - 'source'=>$source, 'source_id'=>$source_id,'type'=>BTemplate::PAGE_HTML,  
351 - 'template_id'=>$template, 'project_id'=>$this->user['project_id'],  
352 - 'section_list_id'=>$section_list_id,'is_custom'=>$is_custom, 430 + 'source'=>$this->param['source'], 'source_id'=>$this->param['source_id'],'type'=>BTemplate::PAGE_HTML,
  431 + 'template_id'=>$this->param['template_id'], 'project_id'=>$this->user['project_id'],
  432 + 'section_list_id'=>$this->param['section_list_id'],'is_custom'=>$this->param['is_custom'],
  433 + 'is_list'=>$this->param['is_list']
353 ]; 434 ];
354 - $data = $this->handleVisualizationParam($html,$source,$source_id,$data); 435 + $data = $this->handleVisualizationParam($this->param['html'],$this->param['source'],$this->param['is_list'],$data);
355 $this->model->add($data); 436 $this->model->add($data);
356 - return true; 437 + }else{//执行编辑
  438 + $condition = [
  439 + 'source'=>$this->param['source'], 'source_id'=>$this->param['source'],
  440 + 'is_custom'=>$this->param['is_custom'], 'template_id'=>$this->param['template_id'],
  441 + 'is_list'=>$this->param['is_list']
  442 + ];
  443 + $data = [
  444 + 'section_list_id'=>$this->param['section_list_id']
  445 + ];
  446 + $data = $this->handleVisualizationParam($this->param['html'],$this->param['source'],$this->param['is_list'],$data);
  447 + $this->model->edit($data,$condition);
  448 + }
  449 + //更新头部信息
  450 + $this->saveCommonHtml($this->param['html'],$this->param['source'],$this->param['is_list'],$this->param['template_id']);
  451 + $this->setOperationRecords($this->param['html'],$this->param['source'],$this->param['source_id'],$this->param['template_id'],$this->param['is_custom']);
  452 + //通知更新
  453 + $this->homeOrProduct($this->param['source'],$this->param['source_id'],$this->param['is_custom'],$this->param['is_list']);
  454 + return $this->success();
357 } 455 }
358 456
359 /** 457 /**
360 - * @remark :可视化更新html  
361 - * @name :templateEditHtml 458 + * @remark :保存数据时设置默认字符
  459 + * @name :saveDefaultString
362 * @author :lyh 460 * @author :lyh
363 * @method :post 461 * @method :post
364 - * @time :2023/12/15 10:26 462 + * @time :2023/12/15 10:30
365 */ 463 */
366 - public function templateEditHtml($html,$source,$source_id,$template,$section_list_id,$is_custom){  
367 - $condition = [  
368 - 'source'=>$source, 'source_id'=>$source_id,  
369 - 'is_custom'=>$is_custom, 'template_id'=>$template  
370 - ];  
371 - $data = [  
372 - 'section_list_id'=>$section_list_id  
373 - ];  
374 - $data = $this->handleVisualizationParam($html,$source,$source_id,$data);  
375 - $this->model->edit($data,$condition);  
376 - return true; 464 + public function handleDefaultString($param){
  465 + $param['template_id'] = $param['template_id'] ?? 0;
  466 + $param['is_custom'] = $param['is_custom'] = 0;
  467 + $param['section_list_id'] = $param['section_list_id'] ?? '';
  468 + $param['is_list'] = $param['is_list'] ?? 0;
  469 + return $this->success($param);
377 } 470 }
378 471
379 /** 472 /**
@@ -383,9 +476,9 @@ class BTemplateLogic extends BaseLogic @@ -383,9 +476,9 @@ class BTemplateLogic extends BaseLogic
383 * @method :post 476 * @method :post
384 * @time :2023/12/15 10:59 477 * @time :2023/12/15 10:59
385 */ 478 */
386 - public function handleVisualizationParam($html,$source, $source_id,$data){ 479 + public function handleVisualizationParam($html,$source, $is_list,$data){
387 if($this->user['is_customized'] == BTemplate::SOURCE_VISUALIZATION){//定制项目 480 if($this->user['is_customized'] == BTemplate::SOURCE_VISUALIZATION){//定制项目
388 - $type = $this->getCustomizedType($source, $source_id);//获取定制界面类型 481 + $type = $this->getCustomizedType($source, $is_list);//获取定制界面类型
389 //查看当前页面是否定制,是否开启可视化 482 //查看当前页面是否定制,是否开启可视化
390 $page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面 483 $page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
391 if (in_array($type, $page_array)) {//当前页面是定制界面 484 if (in_array($type, $page_array)) {//当前页面是定制界面
@@ -412,8 +505,8 @@ class BTemplateLogic extends BaseLogic @@ -412,8 +505,8 @@ class BTemplateLogic extends BaseLogic
412 * @method :post 505 * @method :post
413 * @time :2023/12/13 17:05 506 * @time :2023/12/13 17:05
414 */ 507 */
415 - public function saveCommonHtml($html,$source,$source_id,$template_id){  
416 - $type = $this->getType($source,$source_id,$template_id);//获取头部类型1-9(首页到自定义页面) 508 + public function saveCommonHtml($html,$source,$is_list,$template_id){
  509 + $type = $this->getType($source,$is_list,$template_id);//获取头部类型1-9(首页到自定义页面)
417 $templateCommonModel = new BTemplateCommon(); 510 $templateCommonModel = new BTemplateCommon();
418 $commonInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type]);//查看当前头部是否存在 511 $commonInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type]);//查看当前头部是否存在
419 $handleInfo = $this->handleCommonParam($html); 512 $handleInfo = $this->handleCommonParam($html);
@@ -482,32 +575,34 @@ class BTemplateLogic extends BaseLogic @@ -482,32 +575,34 @@ class BTemplateLogic extends BaseLogic
482 return $this->success($param); 575 return $this->success($param);
483 } 576 }
484 /** 577 /**
485 - * @remark :获取设置的类型 578 + * @remark :保存时获取获取设置的类型
486 * @name :getType 579 * @name :getType
487 * @author :lyh 580 * @author :lyh
488 * @method :post 581 * @method :post
489 * @time :2023/10/21 17:29 582 * @time :2023/10/21 17:29
490 */ 583 */
491 - public function getType($source,$source_id,$template_id){  
492 - $type = 1;//首页公共头部底部 584 + public function getType($source,$is_list,$template_id){
  585 + $type = BTemplate::SOURCE_HOME;//首页公共头部底部
  586 + $is_head = $this->user['configuration']['is_head'] ?? BTemplate::IS_NO_HEADER;
493 if($template_id == 0){//保存上传的代码块时,默认为独立头部 587 if($template_id == 0){//保存上传的代码块时,默认为独立头部
494 - $this->user['configuration']['is_head'] == 1; 588 + $is_head == BTemplate::IS_HEADER;
495 } 589 }
496 //查看页面是否设置自定义头部底部 590 //查看页面是否设置自定义头部底部
497 - if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) { 591 + if($is_head != BTemplate::IS_NO_HEADER) {
498 $pageSettingModel = new PageSetting(); 592 $pageSettingModel = new PageSetting();
499 $pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]); 593 $pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]);
500 - if ($pageInfo !== false) {  
501 - if ($source == BTemplate::SOURCE_PRODUCT) {if ($source_id != 0) {if ($pageInfo['product_details'] != 0) {$type = BTemplate::TYPE_TWO;}} 594 + if ($pageInfo === false) {
  595 + return $this->success($type);
  596 + }
  597 + if ($source == BTemplate::SOURCE_PRODUCT) {if ($is_list == 0) {if ($pageInfo['product_details'] != 0) {$type = BTemplate::TYPE_TWO;}}
502 else {if ($pageInfo['product_list'] != 0) {$type = BTemplate::TYPE_THREE;}}} 598 else {if ($pageInfo['product_list'] != 0) {$type = BTemplate::TYPE_THREE;}}}
503 - if ($source == BTemplate::SOURCE_BLOG) {if ($source_id != 0) {if ($pageInfo['blog_details'] != 0) {$type = BTemplate::TYPE_FOUR;}} 599 + if ($source == BTemplate::SOURCE_BLOG) {if ($is_list == 0) {if ($pageInfo['blog_details'] != 0) {$type = BTemplate::TYPE_FOUR;}}
504 else {if ($pageInfo['blog_list'] != 0) {$type = BTemplate::TYPE_FIVE;}}} 600 else {if ($pageInfo['blog_list'] != 0) {$type = BTemplate::TYPE_FIVE;}}}
505 - if ($source == BTemplate::SOURCE_NEWS) {if ($source_id != 0) {if ($pageInfo['news_details'] != 0) {$type = BTemplate::TYPE_SIX;}} 601 + if ($source == BTemplate::SOURCE_NEWS) {if ($is_list == 0) {if ($pageInfo['news_details'] != 0) {$type = BTemplate::TYPE_SIX;}}
506 else {if ($pageInfo['news_list'] != 0) {$type = BTemplate::TYPE_SEVEN;}}} 602 else {if ($pageInfo['news_list'] != 0) {$type = BTemplate::TYPE_SEVEN;}}}
507 if ($source == BTemplate::SOURCE_KEYWORD) {if ($pageInfo['polymerization'] != 0) {$type = BTemplate::TYPE_EIGHT;}} 603 if ($source == BTemplate::SOURCE_KEYWORD) {if ($pageInfo['polymerization'] != 0) {$type = BTemplate::TYPE_EIGHT;}}
508 } 604 }
509 - }  
510 - return $type; 605 + return $this->success($type);
511 } 606 }
512 607
513 /** 608 /**
@@ -518,6 +613,9 @@ class BTemplateLogic extends BaseLogic @@ -518,6 +613,9 @@ class BTemplateLogic extends BaseLogic
518 * @time :2023/8/23 11:16 613 * @time :2023/8/23 11:16
519 */ 614 */
520 public function setOperationRecords($html,$source,$source_id,$template_id,$is_custom,$type = 0){ 615 public function setOperationRecords($html,$source,$source_id,$template_id,$is_custom,$type = 0){
  616 + if($source != BTemplate::SOURCE_HOME){
  617 + return true;
  618 + }
521 $data = [ 619 $data = [
522 'template_id'=>$template_id, 620 'template_id'=>$template_id,
523 'project_id'=>$this->user['project_id'], 621 'project_id'=>$this->user['project_id'],
@@ -547,23 +645,39 @@ class BTemplateLogic extends BaseLogic @@ -547,23 +645,39 @@ class BTemplateLogic extends BaseLogic
547 * @method :post 645 * @method :post
548 * @time :2023/7/31 16:05 646 * @time :2023/7/31 16:05
549 */ 647 */
550 - public function homeOrProduct($source,$source_id = 0,$is_custom = 0){ 648 + public function homeOrProduct($source,$source_id = 0,$is_custom = 0,$is_list = 0){
551 if($is_custom == 0){ 649 if($is_custom == 0){
552 if($source == BTemplate::SOURCE_HOME){ 650 if($source == BTemplate::SOURCE_HOME){
553 RouteMap::setRoute('index', RouteMap::SOURCE_PAGE, 0, $this->user['project_id']); 651 RouteMap::setRoute('index', RouteMap::SOURCE_PAGE, 0, $this->user['project_id']);
554 $type = RouteMap::SOURCE_PAGE; 652 $type = RouteMap::SOURCE_PAGE;
555 }elseif($source == BTemplate::SOURCE_PRODUCT){ 653 }elseif($source == BTemplate::SOURCE_PRODUCT){
  654 + if($is_list == BTemplate::IS_LIST){
  655 + $type = RouteMap::SOURCE_PRODUCT_CATE;
  656 + }else{
556 $type = RouteMap::SOURCE_PRODUCT; 657 $type = RouteMap::SOURCE_PRODUCT;
  658 + }
557 }elseif($source == BTemplate::SOURCE_BLOG){ 659 }elseif($source == BTemplate::SOURCE_BLOG){
  660 + if($is_list == BTemplate::IS_LIST){
  661 + $type = RouteMap::SOURCE_BLOG_CATE;
  662 + }else{
558 $type = RouteMap::SOURCE_BLOG; 663 $type = RouteMap::SOURCE_BLOG;
  664 + }
559 }elseif($source == BTemplate::SOURCE_NEWS){ 665 }elseif($source == BTemplate::SOURCE_NEWS){
  666 + if($is_list == BTemplate::IS_LIST){
  667 + $type = RouteMap::SOURCE_NEWS_CATE;
  668 + }else{
560 $type = RouteMap::SOURCE_NEWS; 669 $type = RouteMap::SOURCE_NEWS;
  670 + }
561 }else{ 671 }else{
562 $type = 'all'; 672 $type = 'all';
563 } 673 }
564 }else{ 674 }else{
  675 + if($is_list == BTemplate::IS_LIST){
  676 + $type = RouteMap::SOURCE_MODULE_CATE;
  677 + }else{
565 $type = RouteMap::SOURCE_MODULE; 678 $type = RouteMap::SOURCE_MODULE;
566 } 679 }
  680 + }
567 $route = RouteMap::getRoute($type,$source_id,$this->user['project_id']); 681 $route = RouteMap::getRoute($type,$source_id,$this->user['project_id']);
568 $this->addUpdateNotify($type,$route); 682 $this->addUpdateNotify($type,$route);
569 return $this->curlDelRoute(['route'=>$route,'new_route'=>$route]); 683 return $this->curlDelRoute(['route'=>$route,'new_route'=>$route]);
@@ -615,19 +729,6 @@ class BTemplateLogic extends BaseLogic @@ -615,19 +729,6 @@ class BTemplateLogic extends BaseLogic
615 } 729 }
616 730
617 /** 731 /**
618 - * @remark :默认产品模块  
619 - * @name :getProductModule  
620 - * @author :lyh  
621 - * @method :post  
622 - * @time :2023/7/27 15:08  
623 - */  
624 - public function getModule($type){  
625 - $mainModel = new TemplateTypeMain();  
626 - $info = $mainModel->read(['type'=>$type]);  
627 - return $info['main_html'];  
628 - }  
629 -  
630 - /**  
631 * @remark :设置主题公共head 732 * @remark :设置主题公共head
632 * @name :setHeadInfo 733 * @name :setHeadInfo
633 * @author :lyh 734 * @author :lyh
@@ -823,134 +924,4 @@ class BTemplateLogic extends BaseLogic @@ -823,134 +924,4 @@ class BTemplateLogic extends BaseLogic
823 } 924 }
824 return $this->success(); 925 return $this->success();
825 } 926 }
826 -  
827 - /**  
828 - * @remark :获取详情模板详情  
829 - * @name :getDetail  
830 - * @author :lyh  
831 - * @method :post  
832 - * @time :2023/10/24 11:29  
833 - */  
834 - public function getDetail(){  
835 - $bSettingModel = new Setting();  
836 - $bSettingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']]);  
837 - if($bSettingInfo === false){  
838 - $this->fail('请先设置模板');  
839 - }  
840 - $is_custom = $this->param['is_custom'] ?? 0;//扩展模块详情模版  
841 - $commonInfo = $this->getTypeCommonHtml($bSettingInfo['template_id'],$this->param['type'],$is_custom);  
842 - //获取设置的默认中间部分  
843 - $bTemplateMainModel = new BTemplateMain();  
844 - $mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'type'=>$this->param['type'],'is_custom'=>$is_custom]);  
845 - if($mainInfo === false){  
846 - if($is_custom == BTemplate::SOURCE_CUSTOM) {  
847 - $this->param['type'] = BTemplate::TYPE_CUSTOM_DETAIL;  
848 - }  
849 - $main_html = $this->getModule($this->param['type']);  
850 - $main_style = "<style id='globalsojs-styles'></style>";  
851 - }else{  
852 - $main_html = $mainInfo['main_html'];  
853 - $main_style = $mainInfo['main_css'];  
854 - }  
855 - $html = $commonInfo['head_css'].$main_style.$commonInfo['footer_css'].$commonInfo['other'].  
856 - $commonInfo['head_html'].$main_html.$commonInfo['footer_html'];  
857 - $html = $this->getHeadFooter($html);//组装数据  
858 - return $this->success($html);  
859 - }  
860 -  
861 - /**  
862 - * @remark :根据type获取html  
863 - * @name :getHeaderFooter  
864 - * @author :lyh  
865 - * @method :post  
866 - * @time :2023/12/15 18:06  
867 - */  
868 - public function getTypeCommonHtml($template_id,$type,$is_custom){  
869 - //获取首页公共部分  
870 - $templateCommonModel = new BTemplateCommon();  
871 - $commonInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>1]);  
872 - if($is_custom == BTemplate::SOURCE_CUSTOM){  
873 - return $this->success($commonInfo);  
874 - }  
875 - //判断当前项目是否有设置独立头部的权限  
876 - if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) {  
877 - //有权限时,获取独立头部  
878 - $commonTypeInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type]);  
879 - if($commonTypeInfo !== false){  
880 - $commonInfo = $commonTypeInfo;  
881 - }  
882 - }  
883 - return $this->success($commonInfo);  
884 - }  
885 -  
886 - /**  
887 - * @remark :保存详情模板数据  
888 - * @name :saveDetail  
889 - * @author :lyh  
890 - * @method :post  
891 - * @time :2023/10/24 11:53  
892 - */  
893 - public function saveDetail(){  
894 - $bSettingModel = new Setting();  
895 - $bSettingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']]);  
896 - if($bSettingInfo === false){  
897 - $this->fail('请先设置模板');  
898 - }  
899 - $is_custom = $this->param['is_custom'] ?? 0;//扩展模块详情模版  
900 - $data = [  
901 - 'main_html'=>characterTruncation($this->param['html'],'/<main\b[^>]*>(.*?)<\/main>/s'),  
902 - 'main_css'=>characterTruncation($this->param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s'),  
903 - ];  
904 - $data['section_list_id'] = $this->param['section_list_id'];  
905 - //保存中间部分  
906 - $bTemplateMainModel = new BTemplateMain();  
907 - $mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'type'=>$this->param['type'],'is_custom'=>$is_custom]);  
908 - if($mainInfo === false){  
909 - $data['project_id'] = $this->user['project_id'];  
910 - $data['type'] = $this->param['type'];  
911 - $data['is_custom'] = $is_custom;  
912 - $bTemplateMainModel->add($data);  
913 - }else{  
914 - $bTemplateMainModel->edit($data,['id'=>$mainInfo['id']]);  
915 - }  
916 - $this->saveDetailCommonHtml($is_custom,$this->param['type'],$bSettingInfo['template_id'],$this->param['html']);  
917 - return $this->success();  
918 - }  
919 -  
920 - /**  
921 - * @remark :保存详情页模版头部底部  
922 - * @name :saveDetailCommonHtml  
923 - * @author :lyh  
924 - * @method :post  
925 - * @time :2023/12/15 18:12  
926 - */  
927 - public function saveDetailCommonHtml($is_custom,$type,$template_id,$html){  
928 - $publicData = [  
929 - 'head_html' => characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s'),  
930 - 'head_css' => characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'),  
931 - 'footer_html' => characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'),  
932 - 'footer_css' => characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'),  
933 - 'other'=>str_replace('<header','',characterTruncation($html,"/<link id=\"google-fonts-link\"(.*?)<header/s")),  
934 - ];  
935 - //查看当前模板是否有独立头部,有独立头部,更新独立头部,无独立头部,更新公共头部  
936 - if($is_custom == BTemplate::SOURCE_CUSTOM){//扩展模块  
937 - $this->user['configuration']['is_head'] = BTemplate::SOURCE_NO_CUSTOM;  
938 - }  
939 - $templateCommonModel = new BTemplateCommon();  
940 - if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) {  
941 - $templateCommonInfo = $templateCommonModel->read(['type'=>$type,'project_id'=>$this->user['project_id'],'template_id'=>$template_id]);  
942 - if($templateCommonInfo === false){  
943 - $publicData['type'] = $type;  
944 - $publicData['project_id'] = $this->user['project_id'];  
945 - $publicData['template_id'] = $template_id;  
946 - $templateCommonModel->add($publicData);  
947 - }else{  
948 - $templateCommonModel->edit($publicData,['id'=>$templateCommonInfo['id']]);  
949 - }  
950 - }else{  
951 - //更新首页头部底部  
952 - $templateCommonModel->edit($publicData,['type'=>1,'project_id'=>$this->user['project_id'],'template_id'=>$template_id]);  
953 - }  
954 - return true;  
955 - }  
956 } 927 }
@@ -29,7 +29,7 @@ class CustomTemplateLogic extends BaseLogic @@ -29,7 +29,7 @@ class CustomTemplateLogic extends BaseLogic
29 * @time :2023/6/29 15:46 29 * @time :2023/6/29 15:46
30 */ 30 */
31 public function customTemplateLists($map,$page,$row,$order = 'created_at'){ 31 public function customTemplateLists($map,$page,$row,$order = 'created_at'){
32 - $filed = ['id','name','status','url','title','keywords','description','project_id','created_at','updated_at']; 32 + $filed = ['id','name','status','url','title','keywords','description','project_id','is_upgrade','six_read','created_at','updated_at'];
33 $map['deleted_status'] = 0; 33 $map['deleted_status'] = 0;
34 $map['project_id'] = $this->user['project_id']; 34 $map['project_id'] = $this->user['project_id'];
35 $lists = $this->model->lists($map,$page,$row,$order,$filed); 35 $lists = $this->model->lists($map,$page,$row,$order,$filed);
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :InitHtmlLogic.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/12/27 10:39
  8 + */
  9 +
  10 +namespace App\Http\Logic\Bside\BTemplate;
  11 +
  12 +use App\Http\Logic\Bside\BaseLogic;
  13 +use App\Models\Service\Service as ServiceSettingModel;
  14 +use App\Models\Template\BTemplate;
  15 +use App\Models\Template\BTemplateCommon;
  16 +use App\Models\Template\BTemplateMain;
  17 +use App\Models\Template\Setting;
  18 +use App\Models\Template\TemplateTypeMain;
  19 +
  20 +class InitHtmlLogic extends BaseLogic
  21 +{
  22 + public function __construct()
  23 + {
  24 + parent::__construct();
  25 + $this->param = $this->requestAll;
  26 + }
  27 +
  28 + /**
  29 + * @remark :获取非定制项目复合页数据
  30 + * @name :getDetailHtml
  31 + * @author :lyh
  32 + * @method :post $param (type:类型,2产品 3博客 4新闻 对应扩展模块的id)
  33 + * @time :2023/12/27 10:50
  34 + */
  35 + public function getDetailHtml(){
  36 + $template_id = $this->getTemplateId();
  37 + $is_custom = $this->param['is_custom'] ?? 0;//TODO::1:代表扩展模块
  38 + $is_list = $this->param['is_list'] ?? 0;//TODO::1:代表分类列表模块
  39 + //获取设置的默认中间部分
  40 + $bTemplateMainModel = new BTemplateMain();
  41 + $mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'type'=>$this->param['type'],'is_list'=>$is_list,'is_custom'=>$is_custom]);
  42 + if($mainInfo === false){
  43 + $main_html = $this->getInitModule($this->param['type'],$is_custom,$is_list);
  44 + $main_style = "<style id='globalsojs-styles'></style>";
  45 + }else{
  46 + $main_html = $mainInfo['main_html'];
  47 + $main_style = $mainInfo['main_css'];
  48 + }
  49 + $commonInfo = $this->getTypeCommonHtml($template_id,$this->param['type'],$is_custom,$is_list); //获取头部
  50 + $html = $commonInfo['head_css'].$main_style.$commonInfo['footer_css'].$commonInfo['other'].$commonInfo['head_html'].$main_html.$commonInfo['footer_html'];
  51 + $html = $this->getHeadFooter($html);//组装数据
  52 + return $this->success($html);
  53 + }
  54 +
  55 + /**
  56 + * @remark :拼接获取公共头部底部
  57 + * @name :getHeadFooter
  58 + * @author :lyh
  59 + * @method :post
  60 + * @time :2023/7/21 17:22
  61 + */
  62 + public function getHeadFooter($html){
  63 + //获取公共主题头部底部
  64 + $serviceSettingModel = new ServiceSettingModel();
  65 + $list = $serviceSettingModel->list(['type'=>2],'created_at');
  66 + //拼接html
  67 + foreach ($list as $v){
  68 + if($v['key'] == 'head'){
  69 + $html = $v['values'].$html;
  70 + }
  71 + if($v['key'] == 'footer'){
  72 + $html = $html.$v['values'];
  73 + }
  74 + }
  75 + return $html;
  76 + }
  77 +
  78 + /**
  79 + * @remark :保存复合页数据
  80 + * @name :saveDetailHtml
  81 + * @author :lyh
  82 + * @method :post
  83 + * @time :2023/12/27 11:57
  84 + */
  85 + public function saveDetailHtml(){
  86 + $template_id = $this->getTemplateId();
  87 + $is_custom = $this->param['is_custom'] ?? 0;//TODO::1:代表扩展模块
  88 + $is_list = $this->param['is_list'] ?? 0;//TODO::1:代表分类列表模块
  89 + //保存中间部分
  90 + $bTemplateMainModel = new BTemplateMain();
  91 + $mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'type'=>$this->param['type'],'is_custom'=>$is_custom,'is_list'=>$is_list]);
  92 + if($mainInfo === false){
  93 + $data = [
  94 + 'main_html'=>characterTruncation($this->param['html'],'/<main\b[^>]*>(.*?)<\/main>/s'),
  95 + 'main_css'=>characterTruncation($this->param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s'),
  96 + 'section_list_id'=>$this->param['section_list_id'] ?? '',
  97 + 'project_id'=>$this->user['project_id'],
  98 + 'type'=>$this->param['type'],
  99 + 'is_custom'=>$is_custom,
  100 + 'is_list'=>$is_list
  101 + ];
  102 + $bTemplateMainModel->add($data);
  103 + }else{
  104 + $data = [
  105 + 'main_html'=>characterTruncation($this->param['html'],'/<main\b[^>]*>(.*?)<\/main>/s'),
  106 + 'main_css'=>characterTruncation($this->param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s'),
  107 + 'section_list_id'=>$this->param['section_list_id'] ?? '',
  108 + ];
  109 + $bTemplateMainModel->edit($data,['id'=>$mainInfo['id']]);
  110 + }
  111 + $this->saveDetailCommonHtml($this->param['html'],$this->param['type'],$template_id,$is_custom,$is_list);
  112 + return $this->success();
  113 + }
  114 + /**
  115 + * @remark :保存详情页模版头部底部
  116 + * @name :saveDetailCommonHtml
  117 + * @author :lyh
  118 + * @method :post
  119 + * @time :2023/12/15 18:12
  120 + */
  121 + public function saveDetailCommonHtml($html,$type,$template_id,$is_custom,$is_list){
  122 + $publicData = $this->handleCommonParam($html);
  123 + $templateCommonModel = new BTemplateCommon();
  124 + //查看当前模板是否有独立头部,有独立头部,更新独立头部,无独立头部,更新公共头部
  125 + $is_head = $this->user['configuration']['is_head'] ?? 0;
  126 + if($is_custom == BTemplate::SOURCE_CUSTOM){//todo::扩展模块无独立头部底部
  127 + $is_head = BTemplate::IS_NO_HEADER;
  128 + }
  129 + if($is_head == BTemplate::IS_HEADER) {
  130 + //有独立头部,更新独立头部
  131 + $commonType = $this->getHeaderType($type,$is_list);
  132 + $templateCommonInfo = $templateCommonModel->read(['project_id'=>$this->user['project_id'],'template_id'=>$template_id,'type'=>$commonType]);
  133 + if($templateCommonInfo === false){
  134 + $publicData['type'] = $type;
  135 + $publicData['project_id'] = $this->user['project_id'];
  136 + $publicData['template_id'] = $template_id;
  137 + $templateCommonModel->add($publicData);
  138 + }else{
  139 + $templateCommonModel->edit($publicData,['id'=>$templateCommonInfo['id']]);
  140 + }
  141 + }else{
  142 + //更新首页头部底部
  143 + $templateCommonModel->edit($publicData,['type'=>BTemplate::SOURCE_HOME,'project_id'=>$this->user['project_id'],'template_id'=>$template_id]);
  144 + }
  145 + return $this->success();
  146 + }
  147 +
  148 + /**
  149 + * @remark :保存时字符串处理
  150 + * @name :handleCommonParam
  151 + * @author :lyh
  152 + * @method :post
  153 + * @time :2023/6/29 15:35
  154 + */
  155 + public function handleCommonParam($html){
  156 + //字符串截取
  157 + $param['head_html'] = characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s');
  158 + $param['footer_html'] = characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s');
  159 + $param['head_css'] = characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s');
  160 + $param['footer_css'] = characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s');
  161 + $footer_other = str_replace('<header','',characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<header/s'));
  162 + $param['other'] = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other);
  163 + return $this->success($param);
  164 + }
  165 +
  166 + /**
  167 + * @remark :默认复合页数据
  168 + * @name :getProductModule
  169 + * @author :lyh
  170 + * @method :post
  171 + * @time :2023/7/27 15:08
  172 + */
  173 + public function getInitModule($type,$is_custom,$is_list){
  174 + if($is_custom == BTemplate::SOURCE_CUSTOM) {
  175 + $type = BTemplate::TYPE_CUSTOM;
  176 + }
  177 + $mainModel = new TemplateTypeMain();
  178 + $info = $mainModel->read(['type'=>$type,'is_list'=>$is_list]);
  179 + return $info['main_html'];
  180 + }
  181 +
  182 + /**
  183 + * @remark :根据type获取头部html
  184 + * @name :getHeaderFooter
  185 + * @author :lyh
  186 + * @method :post
  187 + * @time :2023/12/15 18:06
  188 + */
  189 + public function getTypeCommonHtml($template_id,$type,$is_custom,$is_list){
  190 + //判断当前项目是否有设置独立头部的权限
  191 + $is_head = $this->user['configuration']['is_head'] ?? 0;
  192 + if($is_custom == BTemplate::SOURCE_CUSTOM){//todo::拓展模块默认取首页
  193 + $is_head = BTemplate::IS_NO_HEADER;
  194 + }
  195 + //获取首页公共部分
  196 + $templateCommonModel = new BTemplateCommon();
  197 + if($is_head == BTemplate::IS_HEADER) {
  198 + //有独立头部,获取独立头部
  199 + $commonType = $this->getHeaderType($type,$is_list);
  200 + $commonInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$commonType]);
  201 + if($commonInfo !== false){
  202 + return $this->success($commonInfo);
  203 + }
  204 + }
  205 + //首页头底
  206 + $commonInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>BTemplate::SOURCE_HOME]);
  207 + return $this->success($commonInfo);
  208 + }
  209 +
  210 + /**
  211 + * @remark :独立头部获取头部底部类型
  212 + * @name :getHeaderType
  213 + * @author :lyh
  214 + * @method :post
  215 + * @time :2023/12/27 11:36
  216 + */
  217 + public function getHeaderType($type,$is_list){
  218 + $resultType = BTemplate::SOURCE_HOME;
  219 + if($type == BTemplate::SOURCE_PRODUCT){
  220 + if($is_list == BTemplate::IS_LIST){
  221 + $resultType = BTemplate::TYPE_THREE;
  222 + }else{
  223 + $resultType = BTemplate::TYPE_TWO;
  224 + }
  225 + }
  226 + if($type == BTemplate::SOURCE_BLOG){
  227 + if($is_list == BTemplate::IS_LIST){
  228 + $resultType = BTemplate::TYPE_FIVE;
  229 + }else{
  230 + $resultType = BTemplate::TYPE_FOUR;
  231 + }
  232 + }
  233 + if($type == BTemplate::SOURCE_NEWS){
  234 + if($is_list == BTemplate::IS_LIST){
  235 + $resultType = BTemplate::TYPE_SEVEN;
  236 + }else{
  237 + $resultType = BTemplate::TYPE_SIX;
  238 + }
  239 + }
  240 + return $this->success($resultType);
  241 + }
  242 +
  243 + /**
  244 + * @remark :获取模版id
  245 + * @name :getTemplateId
  246 + * @author :lyh
  247 + * @method :post
  248 + * @time :2023/12/27 10:51
  249 + */
  250 + public function getTemplateId(){
  251 + $bSettingModel = new Setting();
  252 + $bSettingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']],['id','template_id']);
  253 + if($bSettingInfo === false){
  254 + $this->fail('请先设置模板');
  255 + }
  256 + return $this->success($bSettingInfo['template_id']);
  257 + }
  258 +
  259 + /**
  260 + * @remark :获取代码块
  261 + * @name :getVisualizationInfo
  262 + * @author :lyh
  263 + * @method :post
  264 + * @time :2023/11/17 14:44
  265 + */
  266 + public function getCustomizedHtml(){
  267 + $is_list = $this->param['is_list'] ?? 0;
  268 + $bTemplateMainModel = new BTemplateMain();
  269 + $info = $bTemplateMainModel->read(['type'=>$this->param['type'],'is_list'=>$is_list]);
  270 + if($info === false){
  271 + $html = '';
  272 + }else{
  273 + $html = $info['main_html'];
  274 + }
  275 + return $this->success(['html'=>$html]);
  276 + }
  277 +
  278 + /**
  279 + * @remark :保存定制html
  280 + * @name :saveHtml
  281 + * @author :lyh
  282 + * @method :post
  283 + * @time :2023/11/15 10:12
  284 + */
  285 + public function saveCustomizedHtml(){
  286 + try {
  287 + $is_list = $this->param['is_list'] ?? 0;
  288 + $bTemplateMainModel = new BTemplateMain();
  289 + $mainInfo = $bTemplateMainModel->read(['type'=>$this->param['type'],'is_list'=>$is_list]);
  290 + if($mainInfo === false){
  291 + $mainData = [
  292 + 'project_id'=>$this->user['project_id'],
  293 + 'type'=>$this->param['type'],
  294 + 'is_list'=>$is_list,
  295 + 'main_html'=>$this->param['html']
  296 + ];
  297 + $bTemplateMainModel->add($mainData);
  298 + }else{
  299 + $bTemplateMainModel->edit(['main_html'=>$this->param['html']],['id'=>$mainInfo['id']]);
  300 + }
  301 + }catch (\Exception $exception){
  302 + $this->fail('保存失败,请联系开发人员');
  303 + }
  304 + return $this->success();
  305 + }
  306 +}
1 -<?php  
2 -/**  
3 - * @remark :  
4 - * @name :VisualizationLogic.php  
5 - * @author :lyh  
6 - * @method :post  
7 - * @time :2023/11/15 10:09  
8 - */  
9 -  
10 -namespace App\Http\Logic\Bside\BTemplate;  
11 -  
12 -use App\Http\Logic\Bside\BaseLogic;  
13 -use App\Models\Blog\Blog;  
14 -use App\Models\News\News;  
15 -use App\Models\Product\Product;  
16 -use App\Models\Project\PageSetting;  
17 -use App\Models\RouteMap\RouteMap;  
18 -use App\Models\Service\Service as ServiceSettingModel;  
19 -use App\Models\Template\BTemplate;  
20 -use App\Models\Template\BTemplateCommon;  
21 -use App\Models\Template\BTemplateLog;  
22 -use App\Models\Template\BTemplateMain;  
23 -use App\Models\Template\Setting;  
24 -use App\Models\Template\Template;  
25 -use App\Models\Template\TemplateTypeMain;  
26 -use App\Models\Visualization\Visualization;  
27 -  
28 -class VisualizationLogic extends BaseLogic  
29 -{  
30 - public function __construct()  
31 - {  
32 - parent::__construct();  
33 - $this->model = new BTemplateMain();  
34 - $this->param = $this->requestAll;  
35 - }  
36 -  
37 - /**  
38 - * @remark :获取代码块  
39 - * @name :getVisualizationInfo  
40 - * @author :lyh  
41 - * @method :post  
42 - * @time :2023/11/17 14:44  
43 - */  
44 - public function getVisualizationInfo(){  
45 - $bTemplateMainModel = new BTemplateMain();  
46 - $info = $bTemplateMainModel->read(['type'=>$this->param['type']]);  
47 - if($info === false){  
48 - $html = '';  
49 - }else{  
50 - $html = $info['main_html'];  
51 - }  
52 - return $this->success(['html'=>$html]);  
53 - }  
54 -  
55 - /**  
56 - * @remark :保存定制html  
57 - * @name :saveHtml  
58 - * @author :lyh  
59 - * @method :post  
60 - * @time :2023/11/15 10:12  
61 - */  
62 - public function saveVisualization(){  
63 - try {  
64 - $type = $this->param['type'];  
65 - $bTemplateMainModel = new BTemplateMain();  
66 - $mainInfo = $bTemplateMainModel->read(['type'=>$type]);  
67 - if($mainInfo === false){  
68 - $mainData = [  
69 - 'project_id'=>$this->user['project_id'],  
70 - 'type'=>$type,  
71 - 'main_html'=>$this->param['html']  
72 - ];  
73 - $bTemplateMainModel->add($mainData);  
74 - }else{  
75 - $bTemplateMainModel->edit(['main_html'=>$this->param['html']],['id'=>$mainInfo['id']]);  
76 - }  
77 - }catch (\Exception $e){  
78 - $this->fail('系统错误,请联系管理员');  
79 - }  
80 - return $this->success();  
81 - }  
82 -}  
1 -<?php  
2 -  
3 -namespace App\Models\File;  
4 -  
5 -use App\Models\Base;  
6 -  
7 -class DataFile extends Base  
8 -{  
9 - protected $table = 'gl_data_file';  
10 -  
11 - public function saveData(array $data): bool  
12 - {  
13 - # v6项目ID  
14 - $project_id = (int)$data['project_id'] ?? 0;  
15 - $isRes = self::query()->where('project_id', $project_id)->where('created_at', 'like', $data['time'] . '%')->first();  
16 - if (!$isRes) {  
17 - $isRes = new self();  
18 - $isRes->project_id = $project_id;  
19 - # AICC用户ID  
20 - $isRes->user_id = $data['user_id'];  
21 - # 第三方朋友ID  
22 - $isRes->friend_id = $data['friend_id'];  
23 - # 生成文件路径  
24 - $isRes->file_path = $data['file_path'];  
25 - }  
26 - return $isRes->save();  
27 - }  
28 -  
29 - /**  
30 - * @param int $page  
31 - * @param int $perPage  
32 - * @return array  
33 - */  
34 - public function allData(int $page = 1, int $perPage = 15)  
35 - {  
36 - $lists = self::query()->paginate($perPage, ['*'], 'page', $page);  
37 - $items = $lists->Items();  
38 - $totalPage = $lists->lastPage();  
39 - $total = $lists->total();  
40 - $currentPage = $lists->currentPage();  
41 - return compact('total', 'items', 'totalPage', 'currentPage');  
42 - }  
43 -  
44 -}  
  1 +<?php
  2 +
  3 +namespace App\Models\File;
  4 +
  5 +use App\Models\Base;
  6 +
  7 +/**
  8 + * App\Models\File\PdfFile
  9 + *
  10 + * @property int $id
  11 + * @property int $pid AICC用户ID
  12 + * @property string $file_path 生成文件路径
  13 + * @property int $is_pdf 0 - 未生成 1 - 已生成 2 - 其它问题
  14 + * @property int|null $is_push 0 - 未推送 1 - 已推送 2 - 其他问题
  15 + * @property \Illuminate\Support\Carbon|null $created_at
  16 + * @property \Illuminate\Support\Carbon|null $updated_at
  17 + * @method \Illuminate\Database\Eloquent\Builder|PdfFile newModelQuery()
  18 + * @method \Illuminate\Database\Eloquent\Builder|PdfFile newQuery()
  19 + * @method static \Illuminate\Database\Eloquent\Builder|PdfFile query()
  20 + * @method \Illuminate\Database\Eloquent\Builder|PdfFile whereCreatedAt($value)
  21 + * @method \Illuminate\Database\Eloquent\Builder|PdfFile whereFilePath($value)
  22 + * @method \Illuminate\Database\Eloquent\Builder|PdfFile whereId($value)
  23 + * @method \Illuminate\Database\Eloquent\Builder|PdfFile whereIsPdf($value)
  24 + * @method \Illuminate\Database\Eloquent\Builder|PdfFile whereIsPush($value)
  25 + * @method \Illuminate\Database\Eloquent\Builder|PdfFile wherePid($value)
  26 + * @method \Illuminate\Database\Eloquent\Builder|PdfFile whereUpdatedAt($value)
  27 + * @mixin \Eloquent
  28 + */
  29 +class PdfFile extends Base
  30 +{
  31 + protected $table = 'gl_pdf_file';
  32 +
  33 + /** @var int PDF - 未生成 */
  34 + const GENERATE_NOT_PDF = 0;
  35 +
  36 + /** @var int PDF - 已生成 */
  37 + const GENERATE_PDF = 1;
  38 +
  39 + /** @var int PDF - 其它问题 */
  40 + const GENERATE_OTHER_PDF = 2;
  41 +
  42 + /** @var int AICC - 未推送 */
  43 + const GENERATE_NOT_PUSH = 0;
  44 + /** @var int AICC - 已推送 */
  45 + const GENERATE_PUSH = 1;
  46 + /** @var int AICC - 其他问题 */
  47 + const GENERATE_OTHER_PUSH = 2;
  48 +
  49 + public function saveData(array $data): bool
  50 + {
  51 + # v6项目ID
  52 + $pid = (int)$data['pid'] ?? 0;
  53 + $time = $data['time'] ?? date('Y-m-d');
  54 + $isRes = self::query()->wherePid($pid)->where('created_at', 'like', $time . '%')->first();
  55 + if (!$isRes) {
  56 + $isRes = new self();
  57 + $isRes->pid = $pid;
  58 + # 生成文件路径
  59 + $isRes->file_path = $data['file_path'] ?? '';
  60 + }
  61 + return $isRes->save();
  62 + }
  63 +
  64 +}
@@ -5,10 +5,47 @@ namespace App\Models\ProjectAssociation; @@ -5,10 +5,47 @@ namespace App\Models\ProjectAssociation;
5 use Illuminate\Database\Eloquent\Builder; 5 use Illuminate\Database\Eloquent\Builder;
6 use Illuminate\Database\Eloquent\Model; 6 use Illuminate\Database\Eloquent\Model;
7 7
  8 +/**
  9 + * App\Models\ProjectAssociation\ProjectAssociation
  10 + *
  11 + * @property int $id
  12 + * @property int $project_id V6项目ID
  13 + * @property int $friend_id AICC朋友ID
  14 + * @property int $user_id AICC用户ID
  15 + * @property string|null $nickname AICC朋友昵称
  16 + * @property string|null $user_name AICC用户姓名
  17 + * @property string|null $image AICC朋友头像
  18 + * @property int|null $status 1 - 正常, 0 - 禁用
  19 + * @property int|null $m_status 统计当月是否生成数据
  20 + * @property \Illuminate\Support\Carbon|null $created_at
  21 + * @property \Illuminate\Support\Carbon|null $updated_at
  22 + * @method Builder|ProjectAssociation newModelQuery()
  23 + * @method Builder|ProjectAssociation newQuery()
  24 + * @method static Builder|ProjectAssociation query()
  25 + * @method Builder|ProjectAssociation whereCreatedAt($value)
  26 + * @method Builder|ProjectAssociation whereFriendId($value)
  27 + * @method Builder|ProjectAssociation whereId($value)
  28 + * @method Builder|ProjectAssociation whereImage($value)
  29 + * @method Builder|ProjectAssociation whereMStatus($value)
  30 + * @method Builder|ProjectAssociation whereNickname($value)
  31 + * @method Builder|ProjectAssociation whereProjectId($value)
  32 + * @method Builder|ProjectAssociation whereStatus($value)
  33 + * @method Builder|ProjectAssociation whereUpdatedAt($value)
  34 + * @method Builder|ProjectAssociation whereUserId($value)
  35 + * @method Builder|ProjectAssociation whereUserName($value)
  36 + * @mixin \Eloquent
  37 + */
8 class ProjectAssociation extends Model 38 class ProjectAssociation extends Model
9 { 39 {
  40 +
10 protected $table = 'gl_project_association'; 41 protected $table = 'gl_project_association';
11 42
  43 + /** @var int 数据状态 - 正常 */
  44 + const STATUS_NORMAL = 1;
  45 +
  46 + /** @var int 数据状态 - 禁用 */
  47 + const STATUS_DISABLED = 0;
  48 +
12 /** 49 /**
13 * 保存|修改数据 50 * 保存|修改数据
14 * @param array $data 51 * @param array $data
@@ -36,8 +36,10 @@ class BTemplate extends Base @@ -36,8 +36,10 @@ class BTemplate extends Base
36 const TYPE_SEVEN = 7;//新闻列表 36 const TYPE_SEVEN = 7;//新闻列表
37 const TYPE_EIGHT = 8;//自定义页面 37 const TYPE_EIGHT = 8;//自定义页面
38 38
39 - const TYPE_CUSTOM_DETAIL = 11;//扩展详情  
40 - const TYPE_CUSTOM_LIST = 12;//扩展列表 39 + const TYPE_CUSTOM = 7;//扩展详情
  40 + const IS_LIST = 1;//列表页
  41 + const IS_HEADER = 1;//独立头部底部
  42 + const IS_NO_HEADER = 0;//非独立头部底部
41 43
42 protected $table = 'gl_web_template'; 44 protected $table = 'gl_web_template';
43 //连接数据库 45 //连接数据库
@@ -21,7 +21,7 @@ class CosService @@ -21,7 +21,7 @@ class CosService
21 * @method :post 21 * @method :post
22 * @time :2023/7/19 15:28 22 * @time :2023/7/19 15:28
23 */ 23 */
24 - public function uploadFile(&$files,$path,$filename) 24 + public function uploadFile(&$files,$path,$filename, $binary = false)
25 { 25 {
26 $cos = config('filesystems.disks.cos'); 26 $cos = config('filesystems.disks.cos');
27 $cosClient = new Client([ 27 $cosClient = new Client([
@@ -32,10 +32,11 @@ class CosService @@ -32,10 +32,11 @@ class CosService
32 ], 32 ],
33 ]); 33 ]);
34 $key = $path.'/'.$filename; 34 $key = $path.'/'.$filename;
  35 + $Body = $binary ? $files : fopen($files->getRealPath(), 'r');
35 $cosClient->putObject([ 36 $cosClient->putObject([
36 'Bucket' => $cos['bucket'], 37 'Bucket' => $cos['bucket'],
37 'Key' => $key, 38 'Key' => $key,
38 - 'Body' => fopen($files->getRealPath(), 'r'), 39 + 'Body' => $Body,
39 ]); 40 ]);
40 return $key; 41 return $key;
41 } 42 }
@@ -23,6 +23,7 @@ @@ -23,6 +23,7 @@
23 "swooletw/laravel-swoole": "^2.13" 23 "swooletw/laravel-swoole": "^2.13"
24 }, 24 },
25 "require-dev": { 25 "require-dev": {
  26 + "barryvdh/laravel-ide-helper": "^2.13",
26 "facade/ignition": "^2.5", 27 "facade/ignition": "^2.5",
27 "fakerphp/faker": "^1.9.1", 28 "fakerphp/faker": "^1.9.1",
28 "laravel/sail": "^1.0.1", 29 "laravel/sail": "^1.0.1",
@@ -341,12 +341,12 @@ Route::middleware(['bloginauth'])->group(function () { @@ -341,12 +341,12 @@ Route::middleware(['bloginauth'])->group(function () {
341 }); 341 });
342 }); 342 });
343 343
344 - //定制项目上传代码块  
345 - Route::prefix('visualization')->group(function () {  
346 - Route::any('/info', [\App\Http\Controllers\Bside\Template\VisualizationController::class, 'info'])->name('visualization_info');  
347 - Route::any('/save', [\App\Http\Controllers\Bside\Template\VisualizationController::class, 'save'])->name('visualization_save');  
348 - Route::any('/getHtml', [\App\Http\Controllers\Bside\Template\VisualizationController::class, 'getHtml'])->name('visualization_getHtml');  
349 - Route::any('/saveHtml', [\App\Http\Controllers\Bside\Template\VisualizationController::class, 'saveHtml'])->name('visualization_saveHtml'); 344 + //初始代码块
  345 + Route::prefix('init_html')->group(function () {
  346 + Route::any('/getCustomizedHtml', [\App\Http\Controllers\Bside\Template\InitHtmlController::class, 'getCustomizedHtml'])->name('init_getCustomizedHtml');
  347 + Route::any('/saveCustomizedHtml', [\App\Http\Controllers\Bside\Template\InitHtmlController::class, 'saveCustomizedHtml'])->name('init_saveCustomizedHtml');
  348 + Route::any('/getDetailHtml', [\App\Http\Controllers\Bside\Template\InitHtmlController::class, 'getDetailHtml'])->name('init_getDetailHtml');
  349 + Route::any('/saveDetailHtml', [\App\Http\Controllers\Bside\Template\InitHtmlController::class, 'saveDetailHtml'])->name('init_saveDetailHtml');
350 }); 350 });
351 351
352 // 自定义页面,专题页 352 // 自定义页面,专题页
@@ -434,6 +434,7 @@ Route::middleware(['bloginauth'])->group(function () { @@ -434,6 +434,7 @@ Route::middleware(['bloginauth'])->group(function () {
434 //自定义模板 434 //自定义模板
435 Route::prefix('custom_module')->group(function () { 435 Route::prefix('custom_module')->group(function () {
436 Route::any('/', [\App\Http\Controllers\Bside\CustomModule\CustomModuleController::class, 'lists'])->name('custom_lists'); 436 Route::any('/', [\App\Http\Controllers\Bside\CustomModule\CustomModuleController::class, 'lists'])->name('custom_lists');
  437 + Route::any('/info', [\App\Http\Controllers\Bside\CustomModule\CustomModuleController::class, 'info'])->name('custom_info');
437 Route::any('/save', [\App\Http\Controllers\Bside\CustomModule\CustomModuleController::class, 'save'])->name('custom_save'); 438 Route::any('/save', [\App\Http\Controllers\Bside\CustomModule\CustomModuleController::class, 'save'])->name('custom_save');
438 Route::any('/del', [\App\Http\Controllers\Bside\CustomModule\CustomModuleController::class, 'del'])->name('custom_del'); 439 Route::any('/del', [\App\Http\Controllers\Bside\CustomModule\CustomModuleController::class, 'del'])->name('custom_del');
439 440