|
@@ -9,6 +9,17 @@ |
|
@@ -9,6 +9,17 @@ |
|
9
|
|
9
|
|
|
10
|
namespace App\Console\Commands\ReplaceHtml;
|
10
|
namespace App\Console\Commands\ReplaceHtml;
|
|
11
|
|
11
|
|
|
|
|
12
|
+use App\Models\Blog\Blog;
|
|
|
|
13
|
+use App\Models\Blog\BlogCategory;
|
|
|
|
14
|
+use App\Models\CustomModule\CustomModule;
|
|
|
|
15
|
+use App\Models\CustomModule\CustomModuleCategory;
|
|
|
|
16
|
+use App\Models\CustomModule\CustomModuleContent;
|
|
|
|
17
|
+use App\Models\News\News;
|
|
|
|
18
|
+use App\Models\News\NewsCategory;
|
|
|
|
19
|
+use App\Models\Product\Category;
|
|
|
|
20
|
+use App\Models\Product\Product;
|
|
|
|
21
|
+use App\Models\RouteMap\RouteMap;
|
|
|
|
22
|
+use App\Models\Template\BCustomTemplate;
|
|
12
|
use App\Models\Template\BTemplate;
|
23
|
use App\Models\Template\BTemplate;
|
|
13
|
use App\Models\Template\TemplateReplaceHtmlLog;
|
24
|
use App\Models\Template\TemplateReplaceHtmlLog;
|
|
14
|
use App\Services\ProjectServer;
|
25
|
use App\Services\ProjectServer;
|
|
@@ -52,10 +63,14 @@ class ReplaceHtml extends Command |
|
@@ -52,10 +63,14 @@ class ReplaceHtml extends Command |
|
52
|
$replaceHtmlModel = new TemplateReplaceHtml();
|
63
|
$replaceHtmlModel = new TemplateReplaceHtml();
|
|
53
|
$replaceHtmlList = $replaceHtmlModel->list(['status'=>$replaceHtmlModel::STATUS]);
|
64
|
$replaceHtmlList = $replaceHtmlModel->list(['status'=>$replaceHtmlModel::STATUS]);
|
|
54
|
if(!empty($replaceHtmlList)){
|
65
|
if(!empty($replaceHtmlList)){
|
|
55
|
- foreach ($replaceHtmlList as $k => $v){
|
66
|
+ foreach ($replaceHtmlList as $v){
|
|
56
|
ProjectServer::useProject($v['project_id']);
|
67
|
ProjectServer::useProject($v['project_id']);
|
|
57
|
echo '开始,任务id:'.$v['id'].PHP_EOL;
|
68
|
echo '开始,任务id:'.$v['id'].PHP_EOL;
|
|
|
|
69
|
+ if($v['source'] == 9){//单页面
|
|
|
|
70
|
+ $this->createReplacePageHtmlLog($v);
|
|
|
|
71
|
+ }else{
|
|
58
|
$this->createReplaceHtmlLog($v);
|
72
|
$this->createReplaceHtmlLog($v);
|
|
|
|
73
|
+ }
|
|
59
|
//修改当前主任务状态为待执行
|
74
|
//修改当前主任务状态为待执行
|
|
60
|
$replaceHtmlModel->edit(['status'=>$replaceHtmlModel::STATUS_START],['id'=>$v['id']]);
|
75
|
$replaceHtmlModel->edit(['status'=>$replaceHtmlModel::STATUS_START],['id'=>$v['id']]);
|
|
61
|
echo '结束'.PHP_EOL;
|
76
|
echo '结束'.PHP_EOL;
|
|
@@ -68,6 +83,40 @@ class ReplaceHtml extends Command |
|
@@ -68,6 +83,40 @@ class ReplaceHtml extends Command |
|
68
|
}
|
83
|
}
|
|
69
|
|
84
|
|
|
70
|
/**
|
85
|
/**
|
|
|
|
86
|
+ * @remark :生成单页面记录
|
|
|
|
87
|
+ * @name :createReplacePageHtmlLog
|
|
|
|
88
|
+ * @author :lyh
|
|
|
|
89
|
+ * @method :post
|
|
|
|
90
|
+ * @time :2024/5/13 11:40
|
|
|
|
91
|
+ */
|
|
|
|
92
|
+ public function createReplacePageHtmlLog($info){
|
|
|
|
93
|
+ $saveData = [];
|
|
|
|
94
|
+ $customTemplateModel = new BCustomTemplate();
|
|
|
|
95
|
+ $list = $customTemplateModel->list(['status'=>BCustomTemplate::STATUS_ACTIVE]);
|
|
|
|
96
|
+ foreach ($list as $v){
|
|
|
|
97
|
+ $saveData[] = [
|
|
|
|
98
|
+ 'replace_id'=>$info['id'],
|
|
|
|
99
|
+ 'project_id'=>$info['project_id'],
|
|
|
|
100
|
+ 'status'=>0,
|
|
|
|
101
|
+ 'old_html'=>$info['old_html'],
|
|
|
|
102
|
+ 'html'=>$info['html'],
|
|
|
|
103
|
+ 'source'=>9,
|
|
|
|
104
|
+ 'source_id'=>$v['id'],
|
|
|
|
105
|
+ 'is_rollback'=>$info['is_rollback'],
|
|
|
|
106
|
+ 'template_id'=>$info['template_id'],
|
|
|
|
107
|
+ 'name'=>$v['name'],
|
|
|
|
108
|
+ 'created_at'=>date('Y-m-d H:i:s'),
|
|
|
|
109
|
+ 'updated_at'=>date('Y-m-d H:i:s')
|
|
|
|
110
|
+ ];
|
|
|
|
111
|
+ }
|
|
|
|
112
|
+ if(!empty($saveData)){
|
|
|
|
113
|
+ $templateHtmlLogModel = new TemplateReplaceHtmlLog();
|
|
|
|
114
|
+ $templateHtmlLogModel->insert($saveData);
|
|
|
|
115
|
+ }
|
|
|
|
116
|
+ return true;
|
|
|
|
117
|
+ }
|
|
|
|
118
|
+
|
|
|
|
119
|
+ /**
|
|
71
|
* @remark :生成子任务
|
120
|
* @remark :生成子任务
|
|
72
|
* @name :createReplaceHtmlLog
|
121
|
* @name :createReplaceHtmlLog
|
|
73
|
* @author :lyh
|
122
|
* @author :lyh
|
|
@@ -75,34 +124,198 @@ class ReplaceHtml extends Command |
|
@@ -75,34 +124,198 @@ class ReplaceHtml extends Command |
|
75
|
* @time :2024/5/10 17:26
|
124
|
* @time :2024/5/10 17:26
|
|
76
|
*/
|
125
|
*/
|
|
77
|
public function createReplaceHtmlLog($info){
|
126
|
public function createReplaceHtmlLog($info){
|
|
78
|
- //获取当前页面所有数据
|
|
|
|
79
|
- $saveData = [];
|
|
|
|
80
|
$bTemplateModel = new BTemplate();
|
127
|
$bTemplateModel = new BTemplate();
|
|
81
|
- $condition = ['source'=>$info['source'],'template_id'=>$info['template_id'],'is_custom'=>$info['is_custom'],'is_list'=>$info['is_list']];
|
128
|
+ $condition = ['template_id'=>$info['template_id'],'is_custom'=>$info['is_custom'],'is_list'=>$info['is_list']];
|
|
|
|
129
|
+ if($info['source'] != BTemplate::STATUS){
|
|
|
|
130
|
+ $condition['source'] = $info['source'];
|
|
|
|
131
|
+ }
|
|
82
|
$bTemplateList = $bTemplateModel->list($condition,'id',['id','source_id']);
|
132
|
$bTemplateList = $bTemplateModel->list($condition,'id',['id','source_id']);
|
|
|
|
133
|
+ $saveData = [];
|
|
83
|
foreach ($bTemplateList as $v){
|
134
|
foreach ($bTemplateList as $v){
|
|
84
|
- $saveData[] = [
|
135
|
+ $source_id = $v['source'] == 1 ? 0 : $v['source_id'];
|
|
|
|
136
|
+ $name = $this->getSourceName($v['source'],$source_id,$v['is_list'],$v['is_custom']);
|
|
|
|
137
|
+ $saveData[] = $this->saveData($info,$v,$source_id,$name);
|
|
|
|
138
|
+ }
|
|
|
|
139
|
+ if(!empty($saveData)){
|
|
|
|
140
|
+ $templateHtmlLogModel = new TemplateReplaceHtmlLog();
|
|
|
|
141
|
+ $templateHtmlLogModel->insert($saveData);
|
|
|
|
142
|
+ }
|
|
|
|
143
|
+ return true;
|
|
|
|
144
|
+ }
|
|
|
|
145
|
+
|
|
|
|
146
|
+ /**
|
|
|
|
147
|
+ * @remark :组装数据
|
|
|
|
148
|
+ * @name :saveData
|
|
|
|
149
|
+ * @author :lyh
|
|
|
|
150
|
+ * @method :post
|
|
|
|
151
|
+ * @time :2024/5/13 11:29
|
|
|
|
152
|
+ */
|
|
|
|
153
|
+ public function saveData($info,$v,$source_id,$name){
|
|
|
|
154
|
+ return [
|
|
85
|
'replace_id'=>$info['id'],
|
155
|
'replace_id'=>$info['id'],
|
|
86
|
'project_id'=>$info['project_id'],
|
156
|
'project_id'=>$info['project_id'],
|
|
87
|
'status'=>0,
|
157
|
'status'=>0,
|
|
88
|
'old_html'=>$info['old_html'],
|
158
|
'old_html'=>$info['old_html'],
|
|
89
|
'html'=>$info['html'],
|
159
|
'html'=>$info['html'],
|
|
90
|
- 'source'=>$info['source'],
|
|
|
|
91
|
- 'source_id'=>$info['source'] == 1 ? 0 : $v['source_id'],
|
|
|
|
92
|
- 'is_custom'=>$info['is_custom'],
|
|
|
|
93
|
- 'is_list'=>$info['is_list'],
|
160
|
+ 'source'=>$v['source'],
|
|
|
|
161
|
+ 'source_id'=>$source_id,
|
|
|
|
162
|
+ 'is_custom'=>$v['is_custom'],
|
|
|
|
163
|
+ 'is_list'=>$v['is_list'],
|
|
94
|
'is_rollback'=>$info['is_rollback'],
|
164
|
'is_rollback'=>$info['is_rollback'],
|
|
95
|
'template_id'=>$info['template_id'],
|
165
|
'template_id'=>$info['template_id'],
|
|
|
|
166
|
+ 'name'=>$name,
|
|
96
|
'created_at'=>date('Y-m-d H:i:s'),
|
167
|
'created_at'=>date('Y-m-d H:i:s'),
|
|
97
|
'updated_at'=>date('Y-m-d H:i:s')
|
168
|
'updated_at'=>date('Y-m-d H:i:s')
|
|
98
|
];
|
169
|
];
|
|
99
|
}
|
170
|
}
|
|
100
|
- if(!empty($saveData)){
|
|
|
|
101
|
- $templateHtmlLogModel = new TemplateReplaceHtmlLog();
|
|
|
|
102
|
- $templateHtmlLogModel->insert($saveData);
|
171
|
+
|
|
|
|
172
|
+ /**
|
|
|
|
173
|
+ * @remark :生成子任务获取对应数据id名称
|
|
|
|
174
|
+ * @name :getSourceName
|
|
|
|
175
|
+ * @author :lyh
|
|
|
|
176
|
+ * @method :post
|
|
|
|
177
|
+ * @time :2024/5/13 10:47
|
|
|
|
178
|
+ */
|
|
|
|
179
|
+ public function getSourceName($source,$source_id,$is_list,$is_custom){
|
|
|
|
180
|
+ if($is_custom == 1){//扩展模块
|
|
|
|
181
|
+ return $this->getCustomName($source,$source_id,$is_list);
|
|
103
|
}
|
182
|
}
|
|
104
|
- return true;
|
183
|
+ if($source == BTemplate::SOURCE_HOME){
|
|
|
|
184
|
+ return '';
|
|
|
|
185
|
+ }elseif ($source == BTemplate::SOURCE_PRODUCT){
|
|
|
|
186
|
+ return $this->getProductName($source_id,$is_list);
|
|
|
|
187
|
+ }elseif ($source == BTemplate::SOURCE_BLOG){
|
|
|
|
188
|
+ return $this->getBlogName($source_id,$is_list);
|
|
|
|
189
|
+ }elseif ($source == BTemplate::SOURCE_NEWS){
|
|
|
|
190
|
+ return $this->getNewsName($source_id,$is_list);
|
|
|
|
191
|
+ }else {//单页面管理
|
|
|
|
192
|
+ return $this->getPageName($source_id);
|
|
|
|
193
|
+ }
|
|
|
|
194
|
+ return false;
|
|
|
|
195
|
+ }
|
|
|
|
196
|
+
|
|
|
|
197
|
+ /**
|
|
|
|
198
|
+ * @remark :获取单页面名称
|
|
|
|
199
|
+ * @name :getPageName
|
|
|
|
200
|
+ * @author :lyh
|
|
|
|
201
|
+ * @method :post
|
|
|
|
202
|
+ * @time :2024/5/13 11:10
|
|
|
|
203
|
+ */
|
|
|
|
204
|
+ public function getPageName($source_id){
|
|
|
|
205
|
+ $customTemplateModel = new BCustomTemplate();
|
|
|
|
206
|
+ $info = $customTemplateModel->read(['id'=>$source_id]);
|
|
|
|
207
|
+ if($info === false){
|
|
|
|
208
|
+ return false;
|
|
|
|
209
|
+ }
|
|
|
|
210
|
+ return $info['name'];
|
|
|
|
211
|
+ }
|
|
|
|
212
|
+
|
|
|
|
213
|
+ /**
|
|
|
|
214
|
+ * @remark :获取新闻名称
|
|
|
|
215
|
+ * @name :getNewsName
|
|
|
|
216
|
+ * @author :lyh
|
|
|
|
217
|
+ * @method :post
|
|
|
|
218
|
+ * @time :2024/5/13 11:07
|
|
|
|
219
|
+ */
|
|
|
|
220
|
+ public function getNewsName($source_id,$is_list){
|
|
|
|
221
|
+ if($is_list == BTemplate::IS_LIST){
|
|
|
|
222
|
+ $cateModel = new NewsCategory();
|
|
|
|
223
|
+ $cateInfo = $cateModel->read(['id'=>$source_id]);
|
|
|
|
224
|
+ if($cateInfo === false){
|
|
|
|
225
|
+ return false;
|
|
|
|
226
|
+ }
|
|
|
|
227
|
+ $name = $cateInfo['name'];
|
|
|
|
228
|
+ }else{
|
|
|
|
229
|
+ $newsModel = new News();
|
|
|
|
230
|
+ $newsInfo = $newsModel->read(['id'=>$source_id]);
|
|
|
|
231
|
+ if($newsInfo === false){
|
|
|
|
232
|
+ return false;
|
|
|
|
233
|
+ }
|
|
|
|
234
|
+ $name = $newsInfo['name'];
|
|
|
|
235
|
+ }
|
|
|
|
236
|
+ return $name;
|
|
|
|
237
|
+ }
|
|
|
|
238
|
+
|
|
|
|
239
|
+ /**
|
|
|
|
240
|
+ * @remark :获取blog名称
|
|
|
|
241
|
+ * @name :getBlogName
|
|
|
|
242
|
+ * @author :lyh
|
|
|
|
243
|
+ * @method :post
|
|
|
|
244
|
+ * @time :2024/5/13 11:05
|
|
|
|
245
|
+ */
|
|
|
|
246
|
+ public function getBlogName($source_id,$is_list){
|
|
|
|
247
|
+ if($is_list == BTemplate::IS_LIST){
|
|
|
|
248
|
+ $cateModel = new BlogCategory();
|
|
|
|
249
|
+ $cateInfo = $cateModel->read(['id'=>$source_id]);
|
|
|
|
250
|
+ if($cateInfo === false){
|
|
|
|
251
|
+ return false;
|
|
|
|
252
|
+ }
|
|
|
|
253
|
+ $name = $cateInfo['name'];
|
|
|
|
254
|
+ }else{
|
|
|
|
255
|
+ $blogModel = new Blog();
|
|
|
|
256
|
+ $productInfo = $blogModel->read(['id'=>$source_id]);
|
|
|
|
257
|
+ if($productInfo === false){
|
|
|
|
258
|
+ return false;
|
|
|
|
259
|
+ }
|
|
|
|
260
|
+ $name = $productInfo['name'];
|
|
|
|
261
|
+ }
|
|
|
|
262
|
+ return $name;
|
|
105
|
}
|
263
|
}
|
|
106
|
|
264
|
|
|
|
|
265
|
+ /**
|
|
|
|
266
|
+ * @remark :获取产品名称
|
|
|
|
267
|
+ * @name :getProductName
|
|
|
|
268
|
+ * @author :lyh
|
|
|
|
269
|
+ * @method :post
|
|
|
|
270
|
+ * @time :2024/5/13 11:00
|
|
|
|
271
|
+ */
|
|
|
|
272
|
+ public function getProductName($source_id,$is_list){
|
|
|
|
273
|
+ if($is_list == BTemplate::IS_LIST){
|
|
|
|
274
|
+ $cateModel = new Category();
|
|
|
|
275
|
+ $cateInfo = $cateModel->read(['id'=>$source_id]);
|
|
|
|
276
|
+ if($cateInfo === false){
|
|
|
|
277
|
+ return false;
|
|
|
|
278
|
+ }
|
|
|
|
279
|
+ $name = $cateInfo['title'];
|
|
|
|
280
|
+ }else{
|
|
|
|
281
|
+ $productModel = new Product();
|
|
|
|
282
|
+ $productInfo = $productModel->read(['id'=>$source_id]);
|
|
|
|
283
|
+ if($productInfo === false){
|
|
|
|
284
|
+ return false;
|
|
|
|
285
|
+ }
|
|
|
|
286
|
+ $name = $productInfo['title'];
|
|
|
|
287
|
+ }
|
|
|
|
288
|
+ return $name;
|
|
|
|
289
|
+ }
|
|
107
|
|
290
|
|
|
|
|
291
|
+ /**
|
|
|
|
292
|
+ * @remark :获取扩展模块名称
|
|
|
|
293
|
+ * @name :getCustomName
|
|
|
|
294
|
+ * @author :lyh
|
|
|
|
295
|
+ * @method :post
|
|
|
|
296
|
+ * @time :2024/5/13 10:55
|
|
|
|
297
|
+ */
|
|
|
|
298
|
+ public function getCustomName($source,$source_id,$is_list){
|
|
|
|
299
|
+ $customModuleModel = new CustomModule();
|
|
|
|
300
|
+ $moduleInfo = $customModuleModel->read(['id'=>$source]);
|
|
|
|
301
|
+ if($moduleInfo === false){
|
|
|
|
302
|
+ return false;
|
|
|
|
303
|
+ }
|
|
|
|
304
|
+ if($is_list == BTemplate::IS_LIST){
|
|
|
|
305
|
+ $categoryModel = new CustomModuleCategory();
|
|
|
|
306
|
+ $cateInfo = $categoryModel->read(['id'=>$source_id],['id','name']);
|
|
|
|
307
|
+ if($cateInfo === false){
|
|
|
|
308
|
+ return false;
|
|
|
|
309
|
+ }
|
|
|
|
310
|
+ $name = $cateInfo['name'];
|
|
|
|
311
|
+ }else{
|
|
|
|
312
|
+ $contentModel = new CustomModuleContent();
|
|
|
|
313
|
+ $contentInfo = $contentModel->read(['id'=>$source_id],['id','name']);
|
|
|
|
314
|
+ if($contentInfo === false){
|
|
|
|
315
|
+ return false;
|
|
|
|
316
|
+ }
|
|
|
|
317
|
+ $name = $contentInfo['name'];
|
|
|
|
318
|
+ }
|
|
|
|
319
|
+ return $name;
|
|
|
|
320
|
+ }
|
|
108
|
} |
321
|
} |