作者 lyh

gx

@@ -67,12 +67,12 @@ class ReplaceHtml extends Command @@ -67,12 +67,12 @@ class ReplaceHtml extends Command
67 ProjectServer::useProject($v['project_id']); 67 ProjectServer::useProject($v['project_id']);
68 echo '开始,任务id:'.$v['id'].PHP_EOL; 68 echo '开始,任务id:'.$v['id'].PHP_EOL;
69 if($v['source'] == 9){//单页面 69 if($v['source'] == 9){//单页面
70 - $this->createReplacePageHtmlLog($v); 70 + $count = $this->createReplacePageHtmlLog($v);
71 }else{ 71 }else{
72 - $this->createReplaceHtmlLog($v); 72 + $count = $this->createReplaceHtmlLog($v);
73 } 73 }
74 //修改当前主任务状态为待执行 74 //修改当前主任务状态为待执行
75 - $replaceHtmlModel->edit(['status'=>$replaceHtmlModel::STATUS_START],['id'=>$v['id']]); 75 + $replaceHtmlModel->edit(['status'=>$replaceHtmlModel::STATUS_START,'count'=>$count],['id'=>$v['id']]);
76 echo '结束'.PHP_EOL; 76 echo '结束'.PHP_EOL;
77 DB::disconnect('custom_mysql'); 77 DB::disconnect('custom_mysql');
78 } 78 }
@@ -113,7 +113,7 @@ class ReplaceHtml extends Command @@ -113,7 +113,7 @@ class ReplaceHtml extends Command
113 $templateHtmlLogModel = new TemplateReplaceHtmlLog(); 113 $templateHtmlLogModel = new TemplateReplaceHtmlLog();
114 $templateHtmlLogModel->insert($saveData); 114 $templateHtmlLogModel->insert($saveData);
115 } 115 }
116 - return true; 116 + return count($saveData);
117 } 117 }
118 118
119 /** 119 /**
@@ -125,10 +125,15 @@ class ReplaceHtml extends Command @@ -125,10 +125,15 @@ class ReplaceHtml extends Command
125 */ 125 */
126 public function createReplaceHtmlLog($info){ 126 public function createReplaceHtmlLog($info){
127 $bTemplateModel = new BTemplate(); 127 $bTemplateModel = new BTemplate();
128 - $condition = ['template_id'=>$info['template_id'],'is_custom'=>$info['is_custom'],'is_list'=>$info['is_list']];  
129 - if($info['source'] != BTemplate::STATUS){ 128 + $condition = ['is_custom'=>$info['is_custom'], 'is_list'=>$info['is_list'], 'template_id'=>$info['template_id']];
  129 + if($info['source'] != 0){
130 $condition['source'] = $info['source']; 130 $condition['source'] = $info['source'];
131 } 131 }
  132 + if($info['template_id'] != 0){
  133 + $condition['main_html'] = ['like','%'.$info['old_html'].'%'];
  134 + }else{
  135 + $condition['html'] = ['like','%'.$info['old_html'].'%'];
  136 + }
132 $bTemplateList = $bTemplateModel->list($condition,'id',['id','source_id']); 137 $bTemplateList = $bTemplateModel->list($condition,'id',['id','source_id']);
133 $saveData = []; 138 $saveData = [];
134 foreach ($bTemplateList as $v){ 139 foreach ($bTemplateList as $v){
@@ -140,7 +145,7 @@ class ReplaceHtml extends Command @@ -140,7 +145,7 @@ class ReplaceHtml extends Command
140 $templateHtmlLogModel = new TemplateReplaceHtmlLog(); 145 $templateHtmlLogModel = new TemplateReplaceHtmlLog();
141 $templateHtmlLogModel->insert($saveData); 146 $templateHtmlLogModel->insert($saveData);
142 } 147 }
143 - return true; 148 + return count($saveData);
144 } 149 }
145 150
146 /** 151 /**
@@ -126,7 +126,6 @@ class ReplaceHtmlLogic extends BaseLogic @@ -126,7 +126,6 @@ class ReplaceHtmlLogic extends BaseLogic
126 $data = $this->sourceTypeInfo($this->param['project_id']); 126 $data = $this->sourceTypeInfo($this->param['project_id']);
127 $typeInfo = $data[$this->param['name']]; 127 $typeInfo = $data[$this->param['name']];
128 ProjectServer::useProject($this->param['project_id']); 128 ProjectServer::useProject($this->param['project_id']);
129 - $bTemplateModel = new BTemplate();  
130 if($typeInfo['source'] == 0){//所有页面 129 if($typeInfo['source'] == 0){//所有页面
131 $bSettingModel = new Setting(); 130 $bSettingModel = new Setting();
132 $templateInfo = $bSettingModel->read(['project_id'=>$this->param['project_id']]); 131 $templateInfo = $bSettingModel->read(['project_id'=>$this->param['project_id']]);
@@ -134,18 +133,11 @@ class ReplaceHtmlLogic extends BaseLogic @@ -134,18 +133,11 @@ class ReplaceHtmlLogic extends BaseLogic
134 $this->fail('请先选择模版'); 133 $this->fail('请先选择模版');
135 } 134 }
136 $template_id = $templateInfo['template_id']; 135 $template_id = $templateInfo['template_id'];
137 - $condition = ['template_id'=>$template_id,'main_html'=>['like','%'.$this->param['old_html'].'%']];  
138 - $total_num = $bTemplateModel->formatQuery($condition)->count();  
139 -  
140 }else{ 136 }else{
141 $template_id = $this->getTemplateId($typeInfo); 137 $template_id = $this->getTemplateId($typeInfo);
142 - $condition = ['source'=>$typeInfo['source'],'is_custom'=>$typeInfo['is_custom'], 'is_list'=>$typeInfo['is_list'],  
143 - 'template_id'=>$template_id,'main_html'=>['like','%'.$this->param['old_html'].'%']];  
144 - $total_num = $bTemplateModel->formatQuery($condition)->count();  
145 - @file_put_contents(storage_path('logs/lyh_error.log'), var_export($total_num, true) . PHP_EOL, FILE_APPEND);  
146 } 138 }
147 DB::disconnect('custom_mysql'); 139 DB::disconnect('custom_mysql');
148 - $replaceId = $this->saveReplaceHtml($this->param,$typeInfo,$template_id,$total_num ?? 0); 140 + $replaceId = $this->saveReplaceHtml($this->param,$typeInfo,$template_id);
149 return $this->success(['id'=>$replaceId]); 141 return $this->success(['id'=>$replaceId]);
150 } 142 }
151 143
@@ -156,7 +148,7 @@ class ReplaceHtmlLogic extends BaseLogic @@ -156,7 +148,7 @@ class ReplaceHtmlLogic extends BaseLogic
156 * @method :post 148 * @method :post
157 * @time :2024/5/8 9:23 149 * @time :2024/5/8 9:23
158 */ 150 */
159 - public function saveReplaceHtml($param,$typeInfo,$template_id,$total_num){ 151 + public function saveReplaceHtml($param,$typeInfo,$template_id){
160 $logData = [ 152 $logData = [
161 'source'=>$typeInfo['source'], 153 'source'=>$typeInfo['source'],
162 'is_custom'=>$typeInfo['is_custom'], 154 'is_custom'=>$typeInfo['is_custom'],
@@ -166,7 +158,7 @@ class ReplaceHtmlLogic extends BaseLogic @@ -166,7 +158,7 @@ class ReplaceHtmlLogic extends BaseLogic
166 'old_html'=>$param['old_html'], 158 'old_html'=>$param['old_html'],
167 'html'=>$param['html'], 159 'html'=>$param['html'],
168 'project_id'=>$param['project_id'], 160 'project_id'=>$param['project_id'],
169 - 'total_num'=>$total_num, 161 + 'total_num'=>0,
170 'operator_id'=>$this->manager['id'] 162 'operator_id'=>$this->manager['id']
171 ]; 163 ];
172 return $this->model->addReturnId($logData); 164 return $this->model->addReturnId($logData);