|
...
|
...
|
@@ -43,15 +43,14 @@ class ReplaceHtmlLogic extends BaseLogic |
|
|
|
}
|
|
|
|
$template_id = $templateInfo['template_id'];
|
|
|
|
if($typeInfo['is_custom'] == 1){//扩展模块
|
|
|
|
$customModuleModel = new CustomModule();
|
|
|
|
$moduleInfo = $customModuleModel->read(['id'=>$typeInfo['type']],['list_customized','detail_customized']);
|
|
|
|
if($moduleInfo === false){
|
|
|
|
$this->fail('当前扩展模块不存在或已被删除');
|
|
|
|
}
|
|
|
|
if($typeInfo['is_list'] == 1 && $moduleInfo['list_customized'] == 1){
|
|
|
|
$template_id = 0;
|
|
|
|
}
|
|
|
|
if($typeInfo['is_list'] == 0 && $moduleInfo['detail_customized'] == 1){
|
|
|
|
return $this->getCustomTemplateId($typeInfo,$template_id);
|
|
|
|
}
|
|
|
|
//查看当前页面是否为定制
|
|
|
|
if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION) {//定制项目
|
|
|
|
$type = $this->getCustomizedType($typeInfo['source'], $typeInfo['is_list']);//获取定制界面类型
|
|
|
|
//查看当前页面是否定制,是否开启可视化
|
|
|
|
$page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
|
|
|
|
if (in_array($type, $page_array)) {//当前页面是定制界面
|
|
|
|
$template_id = 0;
|
|
|
|
}
|
|
|
|
}
|
|
...
|
...
|
@@ -59,6 +58,61 @@ class ReplaceHtmlLogic extends BaseLogic |
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :获取扩展模块的templateId
|
|
|
|
* @name :getCustomTemplateId
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2024/5/10 14:53
|
|
|
|
*/
|
|
|
|
public function getCustomTemplateId($typeInfo,$template_id){
|
|
|
|
$customModuleModel = new CustomModule();
|
|
|
|
$moduleInfo = $customModuleModel->read(['id'=>$typeInfo['type']],['list_customized','detail_customized']);
|
|
|
|
if($moduleInfo === false){
|
|
|
|
$this->fail('当前扩展模块不存在或已被删除');
|
|
|
|
}
|
|
|
|
if($typeInfo['is_list'] == 1 && $moduleInfo['list_customized'] == 1){
|
|
|
|
$template_id = 0;
|
|
|
|
}
|
|
|
|
if($typeInfo['is_list'] == 0 && $moduleInfo['detail_customized'] == 1){
|
|
|
|
$template_id = 0;
|
|
|
|
}
|
|
|
|
return $this->success($template_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :定制页面头部类型---根据source获取type类型
|
|
|
|
* @name :getType
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/11/16 11:20
|
|
|
|
*/
|
|
|
|
public function getCustomizedType($source,$is_list){
|
|
|
|
$type = BTemplate::TYPE_HOME;
|
|
|
|
if($source == BTemplate::SOURCE_PRODUCT){
|
|
|
|
if($is_list == BTemplate::IS_LIST){
|
|
|
|
$type = BTemplate::TYPE_PRODUCT_LIST;
|
|
|
|
}else{
|
|
|
|
$type = BTemplate::TYPE_PRODUCT_DETAIL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if($source == BTemplate::SOURCE_BLOG){
|
|
|
|
if($is_list == BTemplate::IS_LIST){
|
|
|
|
$type = BTemplate::TYPE_BLOG_LIST;
|
|
|
|
}else{
|
|
|
|
$type = BTemplate::TYPE_BLOG_DETAIL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if($source == BTemplate::SOURCE_NEWS){
|
|
|
|
if($is_list == BTemplate::IS_LIST){
|
|
|
|
$type = BTemplate::TYPE_NEWS_LIST;
|
|
|
|
}else{
|
|
|
|
$type = BTemplate::TYPE_NEWS_DETAIL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $type;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :替换可视化的html代码(按类型)
|
|
|
|
* @name :replaceHtml
|
|
|
|
* @author :lyh
|
|
...
|
...
|
@@ -68,25 +122,26 @@ class ReplaceHtmlLogic extends BaseLogic |
|
|
|
public function replaceTemplateMainHtml(){
|
|
|
|
$data = $this->sourceTypeInfo();
|
|
|
|
$typeInfo = $data[$this->param['name']];
|
|
|
|
if(!isset($typeInfo)){
|
|
|
|
$this->fail('当前类型不存在,请联系管理员');
|
|
|
|
}
|
|
|
|
$template_id = $this->getTemplateId($typeInfo);
|
|
|
|
//查询当前类型所有装修的记录
|
|
|
|
ProjectServer::useProject($this->param['project_id']);
|
|
|
|
$bTemplateModel = new BTemplate();
|
|
|
|
$condition = ['source'=>$typeInfo['source'],'is_custom'=>$typeInfo['is_custom'],
|
|
|
|
'is_list'=>$typeInfo['is_list'], 'template_id'=>$template_id,'main_html'=>['like','%'.$this->param['old_html'].'%']];
|
|
|
|
$list = $bTemplateModel->list($condition);
|
|
|
|
if($typeInfo['source'] == 0){//所有页面
|
|
|
|
$bSettingModel = new Setting();
|
|
|
|
$templateInfo = $bSettingModel->read(['project_id'=>$this->param['project_id']]);
|
|
|
|
if($templateInfo === false){
|
|
|
|
$this->fail('请先选择模版');
|
|
|
|
}
|
|
|
|
$template_id = $templateInfo['template_id'];
|
|
|
|
$condition = ['template_id'=>$template_id,'main_html'=>['like','%'.$this->param['old_html'].'%']];
|
|
|
|
$total_num = $bTemplateModel->formatQuery($condition)->count();
|
|
|
|
}else{
|
|
|
|
$template_id = $this->getTemplateId($typeInfo);
|
|
|
|
$condition = ['source'=>$typeInfo['source'],'is_custom'=>$typeInfo['is_custom'], 'is_list'=>$typeInfo['is_list'],
|
|
|
|
'template_id'=>$template_id,'main_html'=>['like','%'.$this->param['old_html'].'%']];
|
|
|
|
$total_num = $bTemplateModel->formatQuery($condition)->count();
|
|
|
|
}
|
|
|
|
DB::disconnect('custom_mysql');
|
|
|
|
//TODO::生成一条任务记录
|
|
|
|
$total_num = count($list);
|
|
|
|
$replaceId = $this->saveReplaceHtml($this->param,$typeInfo,$template_id,$total_num);
|
|
|
|
foreach ($list as $value){
|
|
|
|
//生成子任务
|
|
|
|
$this->saveReplaceHtmlLog($replaceId,$value);
|
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
return $this->success(['id'=>$replaceId]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
...
|
...
|
@@ -107,73 +162,36 @@ class ReplaceHtmlLogic extends BaseLogic |
|
|
|
'html'=>$param['html'],
|
|
|
|
'project_id'=>$param['project_id'],
|
|
|
|
'total_num'=>$total_num,
|
|
|
|
'operator_id'=>$this->manager['id']
|
|
|
|
];
|
|
|
|
return $this->model->addReturnId($logData);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :保存每条替换记录
|
|
|
|
* @name :saveReplaceHtmlLog
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2024/5/8 9:37
|
|
|
|
*/
|
|
|
|
public function saveReplaceHtmlLog($param,$replace_id,$data){
|
|
|
|
$logData = [
|
|
|
|
'replace_id'=>$replace_id,
|
|
|
|
'source'=>$data['source'],
|
|
|
|
'source_id'=>$data['source_id'],
|
|
|
|
'is_list'=>$data['is_list'],
|
|
|
|
'is_custom'=>$data['is_custom'],
|
|
|
|
'project_id'=>$data['project_id'],
|
|
|
|
'uid'=>$this->user['manager_id'],
|
|
|
|
'status'=>$this->model::STATUS,
|
|
|
|
'old_html'=>$param['old_html'],
|
|
|
|
'html'=>$param['html'],
|
|
|
|
'template_id'=>$data['template_id']
|
|
|
|
];
|
|
|
|
$replaceHtmlModel = new TemplateReplaceHtmlLog();
|
|
|
|
$save_id = $replaceHtmlModel->addReturnId($logData);
|
|
|
|
return $this->success($save_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :还原所有记录
|
|
|
|
* @remark :生成还原记录
|
|
|
|
* @name :reductionHtml
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2024/5/8 10:35
|
|
|
|
*/
|
|
|
|
public function reductionHtml(){
|
|
|
|
$info = $this->model->read(['id'=>$this->param['id']]);
|
|
|
|
$info = $this->model->read(['id'=>$this->param['id'],'status'=>$this->model::STATUS_SUCCESS]);
|
|
|
|
if($info === false){
|
|
|
|
$this->fail('当前数据不存在');
|
|
|
|
}
|
|
|
|
$replaceId = $this->saveResultReplaceHtml($info);
|
|
|
|
ProjectServer::useProject($this->param['project_id']);
|
|
|
|
$replaceLogModel = new TemplateReplaceHtmlLog();
|
|
|
|
$logList = $replaceLogModel->list(['replace_id'=>$this->param['id']]);
|
|
|
|
$replaceArr = [];
|
|
|
|
foreach ($logList as $v){
|
|
|
|
$replaceArr[] = $v['replace_template_id'];
|
|
|
|
}
|
|
|
|
if(!empty($replaceArr)){
|
|
|
|
//查询可视化数据
|
|
|
|
$bTemplateModel = new BTemplate();
|
|
|
|
$templateList = $bTemplateModel->list(['id'=>['in',$replaceArr]]);
|
|
|
|
foreach ($templateList as $value){
|
|
|
|
if($v['type'] == 0){
|
|
|
|
$main_html = str_replace($info['html'],$info['old_html'],$value['main_html']);
|
|
|
|
$this->model->edit(['main_html'=>$main_html],['id'=>$value['id']]);
|
|
|
|
}else{
|
|
|
|
$html = str_replace($info['html'],$info['old_html'],$value['html']);
|
|
|
|
$this->model->edit(['html'=>$html],['id'=>$value['id']]);
|
|
|
|
}
|
|
|
|
if($info['source'] == 0){//当前数据是替换的所有页面
|
|
|
|
$data = $this->sourceTypeInfo();
|
|
|
|
$typeInfo = $data[$this->param['name']];
|
|
|
|
if($typeInfo['source'] != 0){//回滚页面
|
|
|
|
$info['source'] = $typeInfo['source'];
|
|
|
|
$info['is_custom'] = $typeInfo['is_custom'];
|
|
|
|
$info['is_list'] = $typeInfo['is_list'];
|
|
|
|
$replaceId = $this->saveResultReplaceHtml($info);
|
|
|
|
return $this->success(['id'=>$replaceId]);
|
|
|
|
}
|
|
|
|
$this->saveReplaceHtmlLog($replaceId,$value['id']);
|
|
|
|
}
|
|
|
|
DB::disconnect('custom_mysql');
|
|
|
|
return $this->success();
|
|
|
|
$replaceId = $this->saveResultReplaceHtml($info);
|
|
|
|
return $this->success(['id'=>$replaceId]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
...
|
...
|
@@ -185,13 +203,17 @@ class ReplaceHtmlLogic extends BaseLogic |
|
|
|
*/
|
|
|
|
public function saveResultReplaceHtml($info){
|
|
|
|
$logData = [
|
|
|
|
'type'=>$info['type'],
|
|
|
|
'source'=>$info['source'],
|
|
|
|
'is_custom'=>$info['is_custom'],
|
|
|
|
'is_list'=>$info['is_list'],
|
|
|
|
'template_id'=>$info['template_id'],
|
|
|
|
'status'=>$this->model::STATUS,
|
|
|
|
'old_html'=>$info['html'],
|
|
|
|
'html'=>$info['old_html'],
|
|
|
|
'project_id'=>$info['project_id'],
|
|
|
|
'is_rollback'=>1,
|
|
|
|
'rollback_id'=>$info['id'],
|
|
|
|
'operator_id'=>$this->manager['id']
|
|
|
|
];
|
|
|
|
return $this->model->addReturnId($logData);
|
|
|
|
}
|
|
...
|
...
|
@@ -204,8 +226,8 @@ class ReplaceHtmlLogic extends BaseLogic |
|
|
|
* @time :2024/5/9 17:15
|
|
|
|
*/
|
|
|
|
public function sourceTypeInfo(){
|
|
|
|
ProjectServer::useProject($this->param['project_id']);
|
|
|
|
$data = $this->model->sourceType();
|
|
|
|
ProjectServer::useProject($this->param['project_id']);
|
|
|
|
$customModule = new CustomModule();
|
|
|
|
$moduleList = $customModule->list(['project_id'=>$this->param['project_id']],'id',['id','name']);
|
|
|
|
foreach ($moduleList as $value){
|
...
|
...
|
|