|
@@ -43,6 +43,28 @@ class ReplaceHtmlLogic extends BaseLogic |
|
@@ -43,6 +43,28 @@ class ReplaceHtmlLogic extends BaseLogic |
|
43
|
}
|
43
|
}
|
|
44
|
$template_id = $templateInfo['template_id'];
|
44
|
$template_id = $templateInfo['template_id'];
|
|
45
|
if($typeInfo['is_custom'] == 1){//扩展模块
|
45
|
if($typeInfo['is_custom'] == 1){//扩展模块
|
|
|
|
46
|
+ return $this->getCustomTemplateId($typeInfo,$template_id);
|
|
|
|
47
|
+ }
|
|
|
|
48
|
+ //查看当前页面是否为定制
|
|
|
|
49
|
+ if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION) {//定制项目
|
|
|
|
50
|
+ $type = $this->getCustomizedType($typeInfo['source'], $typeInfo['is_list']);//获取定制界面类型
|
|
|
|
51
|
+ //查看当前页面是否定制,是否开启可视化
|
|
|
|
52
|
+ $page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
|
|
|
|
53
|
+ if (in_array($type, $page_array)) {//当前页面是定制界面
|
|
|
|
54
|
+ $template_id = 0;
|
|
|
|
55
|
+ }
|
|
|
|
56
|
+ }
|
|
|
|
57
|
+ return $this->success($template_id);
|
|
|
|
58
|
+ }
|
|
|
|
59
|
+
|
|
|
|
60
|
+ /**
|
|
|
|
61
|
+ * @remark :获取扩展模块的templateId
|
|
|
|
62
|
+ * @name :getCustomTemplateId
|
|
|
|
63
|
+ * @author :lyh
|
|
|
|
64
|
+ * @method :post
|
|
|
|
65
|
+ * @time :2024/5/10 14:53
|
|
|
|
66
|
+ */
|
|
|
|
67
|
+ public function getCustomTemplateId($typeInfo,$template_id){
|
|
46
|
$customModuleModel = new CustomModule();
|
68
|
$customModuleModel = new CustomModule();
|
|
47
|
$moduleInfo = $customModuleModel->read(['id'=>$typeInfo['type']],['list_customized','detail_customized']);
|
69
|
$moduleInfo = $customModuleModel->read(['id'=>$typeInfo['type']],['list_customized','detail_customized']);
|
|
48
|
if($moduleInfo === false){
|
70
|
if($moduleInfo === false){
|
|
@@ -54,11 +76,43 @@ class ReplaceHtmlLogic extends BaseLogic |
|
@@ -54,11 +76,43 @@ class ReplaceHtmlLogic extends BaseLogic |
|
54
|
if($typeInfo['is_list'] == 0 && $moduleInfo['detail_customized'] == 1){
|
76
|
if($typeInfo['is_list'] == 0 && $moduleInfo['detail_customized'] == 1){
|
|
55
|
$template_id = 0;
|
77
|
$template_id = 0;
|
|
56
|
}
|
78
|
}
|
|
57
|
- }
|
|
|
|
58
|
return $this->success($template_id);
|
79
|
return $this->success($template_id);
|
|
59
|
}
|
80
|
}
|
|
60
|
|
81
|
|
|
61
|
/**
|
82
|
/**
|
|
|
|
83
|
+ * @remark :定制页面头部类型---根据source获取type类型
|
|
|
|
84
|
+ * @name :getType
|
|
|
|
85
|
+ * @author :lyh
|
|
|
|
86
|
+ * @method :post
|
|
|
|
87
|
+ * @time :2023/11/16 11:20
|
|
|
|
88
|
+ */
|
|
|
|
89
|
+ public function getCustomizedType($source,$is_list){
|
|
|
|
90
|
+ $type = BTemplate::TYPE_HOME;
|
|
|
|
91
|
+ if($source == BTemplate::SOURCE_PRODUCT){
|
|
|
|
92
|
+ if($is_list == BTemplate::IS_LIST){
|
|
|
|
93
|
+ $type = BTemplate::TYPE_PRODUCT_LIST;
|
|
|
|
94
|
+ }else{
|
|
|
|
95
|
+ $type = BTemplate::TYPE_PRODUCT_DETAIL;
|
|
|
|
96
|
+ }
|
|
|
|
97
|
+ }
|
|
|
|
98
|
+ if($source == BTemplate::SOURCE_BLOG){
|
|
|
|
99
|
+ if($is_list == BTemplate::IS_LIST){
|
|
|
|
100
|
+ $type = BTemplate::TYPE_BLOG_LIST;
|
|
|
|
101
|
+ }else{
|
|
|
|
102
|
+ $type = BTemplate::TYPE_BLOG_DETAIL;
|
|
|
|
103
|
+ }
|
|
|
|
104
|
+ }
|
|
|
|
105
|
+ if($source == BTemplate::SOURCE_NEWS){
|
|
|
|
106
|
+ if($is_list == BTemplate::IS_LIST){
|
|
|
|
107
|
+ $type = BTemplate::TYPE_NEWS_LIST;
|
|
|
|
108
|
+ }else{
|
|
|
|
109
|
+ $type = BTemplate::TYPE_NEWS_DETAIL;
|
|
|
|
110
|
+ }
|
|
|
|
111
|
+ }
|
|
|
|
112
|
+ return $type;
|
|
|
|
113
|
+ }
|
|
|
|
114
|
+
|
|
|
|
115
|
+ /**
|
|
62
|
* @remark :替换可视化的html代码(按类型)
|
116
|
* @remark :替换可视化的html代码(按类型)
|
|
63
|
* @name :replaceHtml
|
117
|
* @name :replaceHtml
|
|
64
|
* @author :lyh
|
118
|
* @author :lyh
|
|
@@ -68,25 +122,26 @@ class ReplaceHtmlLogic extends BaseLogic |
|
@@ -68,25 +122,26 @@ class ReplaceHtmlLogic extends BaseLogic |
|
68
|
public function replaceTemplateMainHtml(){
|
122
|
public function replaceTemplateMainHtml(){
|
|
69
|
$data = $this->sourceTypeInfo();
|
123
|
$data = $this->sourceTypeInfo();
|
|
70
|
$typeInfo = $data[$this->param['name']];
|
124
|
$typeInfo = $data[$this->param['name']];
|
|
71
|
- if(!isset($typeInfo)){
|
|
|
|
72
|
- $this->fail('当前类型不存在,请联系管理员');
|
|
|
|
73
|
- }
|
|
|
|
74
|
- $template_id = $this->getTemplateId($typeInfo);
|
|
|
|
75
|
- //查询当前类型所有装修的记录
|
|
|
|
76
|
ProjectServer::useProject($this->param['project_id']);
|
125
|
ProjectServer::useProject($this->param['project_id']);
|
|
77
|
$bTemplateModel = new BTemplate();
|
126
|
$bTemplateModel = new BTemplate();
|
|
78
|
- $condition = ['source'=>$typeInfo['source'],'is_custom'=>$typeInfo['is_custom'],
|
|
|
|
79
|
- 'is_list'=>$typeInfo['is_list'], 'template_id'=>$template_id,'main_html'=>['like','%'.$this->param['old_html'].'%']];
|
|
|
|
80
|
- $list = $bTemplateModel->list($condition);
|
127
|
+ if($typeInfo['source'] == 0){//所有页面
|
|
|
|
128
|
+ $bSettingModel = new Setting();
|
|
|
|
129
|
+ $templateInfo = $bSettingModel->read(['project_id'=>$this->param['project_id']]);
|
|
|
|
130
|
+ if($templateInfo === false){
|
|
|
|
131
|
+ $this->fail('请先选择模版');
|
|
|
|
132
|
+ }
|
|
|
|
133
|
+ $template_id = $templateInfo['template_id'];
|
|
|
|
134
|
+ $condition = ['template_id'=>$template_id,'main_html'=>['like','%'.$this->param['old_html'].'%']];
|
|
|
|
135
|
+ $total_num = $bTemplateModel->formatQuery($condition)->count();
|
|
|
|
136
|
+ }else{
|
|
|
|
137
|
+ $template_id = $this->getTemplateId($typeInfo);
|
|
|
|
138
|
+ $condition = ['source'=>$typeInfo['source'],'is_custom'=>$typeInfo['is_custom'], 'is_list'=>$typeInfo['is_list'],
|
|
|
|
139
|
+ 'template_id'=>$template_id,'main_html'=>['like','%'.$this->param['old_html'].'%']];
|
|
|
|
140
|
+ $total_num = $bTemplateModel->formatQuery($condition)->count();
|
|
|
|
141
|
+ }
|
|
81
|
DB::disconnect('custom_mysql');
|
142
|
DB::disconnect('custom_mysql');
|
|
82
|
- //TODO::生成一条任务记录
|
|
|
|
83
|
- $total_num = count($list);
|
|
|
|
84
|
$replaceId = $this->saveReplaceHtml($this->param,$typeInfo,$template_id,$total_num);
|
143
|
$replaceId = $this->saveReplaceHtml($this->param,$typeInfo,$template_id,$total_num);
|
|
85
|
- foreach ($list as $value){
|
|
|
|
86
|
- //生成子任务
|
|
|
|
87
|
- $this->saveReplaceHtmlLog($replaceId,$value);
|
|
|
|
88
|
- }
|
|
|
|
89
|
- return $this->success();
|
144
|
+ return $this->success(['id'=>$replaceId]);
|
|
90
|
}
|
145
|
}
|
|
91
|
|
146
|
|
|
92
|
/**
|
147
|
/**
|
|
@@ -107,73 +162,36 @@ class ReplaceHtmlLogic extends BaseLogic |
|
@@ -107,73 +162,36 @@ class ReplaceHtmlLogic extends BaseLogic |
|
107
|
'html'=>$param['html'],
|
162
|
'html'=>$param['html'],
|
|
108
|
'project_id'=>$param['project_id'],
|
163
|
'project_id'=>$param['project_id'],
|
|
109
|
'total_num'=>$total_num,
|
164
|
'total_num'=>$total_num,
|
|
|
|
165
|
+ 'operator_id'=>$this->manager['id']
|
|
110
|
];
|
166
|
];
|
|
111
|
return $this->model->addReturnId($logData);
|
167
|
return $this->model->addReturnId($logData);
|
|
112
|
}
|
168
|
}
|
|
113
|
|
169
|
|
|
114
|
/**
|
170
|
/**
|
|
115
|
- * @remark :保存每条替换记录
|
|
|
|
116
|
- * @name :saveReplaceHtmlLog
|
|
|
|
117
|
- * @author :lyh
|
|
|
|
118
|
- * @method :post
|
|
|
|
119
|
- * @time :2024/5/8 9:37
|
|
|
|
120
|
- */
|
|
|
|
121
|
- public function saveReplaceHtmlLog($param,$replace_id,$data){
|
|
|
|
122
|
- $logData = [
|
|
|
|
123
|
- 'replace_id'=>$replace_id,
|
|
|
|
124
|
- 'source'=>$data['source'],
|
|
|
|
125
|
- 'source_id'=>$data['source_id'],
|
|
|
|
126
|
- 'is_list'=>$data['is_list'],
|
|
|
|
127
|
- 'is_custom'=>$data['is_custom'],
|
|
|
|
128
|
- 'project_id'=>$data['project_id'],
|
|
|
|
129
|
- 'uid'=>$this->user['manager_id'],
|
|
|
|
130
|
- 'status'=>$this->model::STATUS,
|
|
|
|
131
|
- 'old_html'=>$param['old_html'],
|
|
|
|
132
|
- 'html'=>$param['html'],
|
|
|
|
133
|
- 'template_id'=>$data['template_id']
|
|
|
|
134
|
- ];
|
|
|
|
135
|
- $replaceHtmlModel = new TemplateReplaceHtmlLog();
|
|
|
|
136
|
- $save_id = $replaceHtmlModel->addReturnId($logData);
|
|
|
|
137
|
- return $this->success($save_id);
|
|
|
|
138
|
- }
|
|
|
|
139
|
-
|
|
|
|
140
|
- /**
|
|
|
|
141
|
- * @remark :还原所有记录
|
171
|
+ * @remark :生成还原记录
|
|
142
|
* @name :reductionHtml
|
172
|
* @name :reductionHtml
|
|
143
|
* @author :lyh
|
173
|
* @author :lyh
|
|
144
|
* @method :post
|
174
|
* @method :post
|
|
145
|
* @time :2024/5/8 10:35
|
175
|
* @time :2024/5/8 10:35
|
|
146
|
*/
|
176
|
*/
|
|
147
|
public function reductionHtml(){
|
177
|
public function reductionHtml(){
|
|
148
|
- $info = $this->model->read(['id'=>$this->param['id']]);
|
178
|
+ $info = $this->model->read(['id'=>$this->param['id'],'status'=>$this->model::STATUS_SUCCESS]);
|
|
149
|
if($info === false){
|
179
|
if($info === false){
|
|
150
|
$this->fail('当前数据不存在');
|
180
|
$this->fail('当前数据不存在');
|
|
151
|
}
|
181
|
}
|
|
|
|
182
|
+ if($info['source'] == 0){//当前数据是替换的所有页面
|
|
|
|
183
|
+ $data = $this->sourceTypeInfo();
|
|
|
|
184
|
+ $typeInfo = $data[$this->param['name']];
|
|
|
|
185
|
+ if($typeInfo['source'] != 0){//回滚页面
|
|
|
|
186
|
+ $info['source'] = $typeInfo['source'];
|
|
|
|
187
|
+ $info['is_custom'] = $typeInfo['is_custom'];
|
|
|
|
188
|
+ $info['is_list'] = $typeInfo['is_list'];
|
|
152
|
$replaceId = $this->saveResultReplaceHtml($info);
|
189
|
$replaceId = $this->saveResultReplaceHtml($info);
|
|
153
|
- ProjectServer::useProject($this->param['project_id']);
|
|
|
|
154
|
- $replaceLogModel = new TemplateReplaceHtmlLog();
|
|
|
|
155
|
- $logList = $replaceLogModel->list(['replace_id'=>$this->param['id']]);
|
|
|
|
156
|
- $replaceArr = [];
|
|
|
|
157
|
- foreach ($logList as $v){
|
|
|
|
158
|
- $replaceArr[] = $v['replace_template_id'];
|
|
|
|
159
|
- }
|
|
|
|
160
|
- if(!empty($replaceArr)){
|
|
|
|
161
|
- //查询可视化数据
|
|
|
|
162
|
- $bTemplateModel = new BTemplate();
|
|
|
|
163
|
- $templateList = $bTemplateModel->list(['id'=>['in',$replaceArr]]);
|
|
|
|
164
|
- foreach ($templateList as $value){
|
|
|
|
165
|
- if($v['type'] == 0){
|
|
|
|
166
|
- $main_html = str_replace($info['html'],$info['old_html'],$value['main_html']);
|
|
|
|
167
|
- $this->model->edit(['main_html'=>$main_html],['id'=>$value['id']]);
|
|
|
|
168
|
- }else{
|
|
|
|
169
|
- $html = str_replace($info['html'],$info['old_html'],$value['html']);
|
|
|
|
170
|
- $this->model->edit(['html'=>$html],['id'=>$value['id']]);
|
|
|
|
171
|
- }
|
190
|
+ return $this->success(['id'=>$replaceId]);
|
|
172
|
}
|
191
|
}
|
|
173
|
- $this->saveReplaceHtmlLog($replaceId,$value['id']);
|
|
|
|
174
|
}
|
192
|
}
|
|
175
|
- DB::disconnect('custom_mysql');
|
|
|
|
176
|
- return $this->success();
|
193
|
+ $replaceId = $this->saveResultReplaceHtml($info);
|
|
|
|
194
|
+ return $this->success(['id'=>$replaceId]);
|
|
177
|
}
|
195
|
}
|
|
178
|
|
196
|
|
|
179
|
/**
|
197
|
/**
|
|
@@ -185,13 +203,17 @@ class ReplaceHtmlLogic extends BaseLogic |
|
@@ -185,13 +203,17 @@ class ReplaceHtmlLogic extends BaseLogic |
|
185
|
*/
|
203
|
*/
|
|
186
|
public function saveResultReplaceHtml($info){
|
204
|
public function saveResultReplaceHtml($info){
|
|
187
|
$logData = [
|
205
|
$logData = [
|
|
188
|
- 'type'=>$info['type'],
|
206
|
+ 'source'=>$info['source'],
|
|
189
|
'is_custom'=>$info['is_custom'],
|
207
|
'is_custom'=>$info['is_custom'],
|
|
190
|
'is_list'=>$info['is_list'],
|
208
|
'is_list'=>$info['is_list'],
|
|
191
|
'template_id'=>$info['template_id'],
|
209
|
'template_id'=>$info['template_id'],
|
|
|
|
210
|
+ 'status'=>$this->model::STATUS,
|
|
192
|
'old_html'=>$info['html'],
|
211
|
'old_html'=>$info['html'],
|
|
193
|
'html'=>$info['old_html'],
|
212
|
'html'=>$info['old_html'],
|
|
194
|
'project_id'=>$info['project_id'],
|
213
|
'project_id'=>$info['project_id'],
|
|
|
|
214
|
+ 'is_rollback'=>1,
|
|
|
|
215
|
+ 'rollback_id'=>$info['id'],
|
|
|
|
216
|
+ 'operator_id'=>$this->manager['id']
|
|
195
|
];
|
217
|
];
|
|
196
|
return $this->model->addReturnId($logData);
|
218
|
return $this->model->addReturnId($logData);
|
|
197
|
}
|
219
|
}
|
|
@@ -204,8 +226,8 @@ class ReplaceHtmlLogic extends BaseLogic |
|
@@ -204,8 +226,8 @@ class ReplaceHtmlLogic extends BaseLogic |
|
204
|
* @time :2024/5/9 17:15
|
226
|
* @time :2024/5/9 17:15
|
|
205
|
*/
|
227
|
*/
|
|
206
|
public function sourceTypeInfo(){
|
228
|
public function sourceTypeInfo(){
|
|
207
|
- ProjectServer::useProject($this->param['project_id']);
|
|
|
|
208
|
$data = $this->model->sourceType();
|
229
|
$data = $this->model->sourceType();
|
|
|
|
230
|
+ ProjectServer::useProject($this->param['project_id']);
|
|
209
|
$customModule = new CustomModule();
|
231
|
$customModule = new CustomModule();
|
|
210
|
$moduleList = $customModule->list(['project_id'=>$this->param['project_id']],'id',['id','name']);
|
232
|
$moduleList = $customModule->list(['project_id'=>$this->param['project_id']],'id',['id','name']);
|
|
211
|
foreach ($moduleList as $value){
|
233
|
foreach ($moduleList as $value){
|