正在显示
1 个修改的文件
包含
62 行增加
和
7 行删除
| @@ -17,6 +17,8 @@ use App\Models\Channel\Zone; | @@ -17,6 +17,8 @@ use App\Models\Channel\Zone; | ||
| 17 | use App\Models\Com\City; | 17 | use App\Models\Com\City; |
| 18 | use App\Models\Com\UpdateLog; | 18 | use App\Models\Com\UpdateLog; |
| 19 | use App\Models\Devops\ServerConfig; | 19 | use App\Models\Devops\ServerConfig; |
| 20 | +use App\Models\Devops\ServersIp; | ||
| 21 | +use App\Models\Domain\DomainCreateTask; | ||
| 20 | use App\Models\Domain\DomainInfo; | 22 | use App\Models\Domain\DomainInfo; |
| 21 | use App\Models\Domain\DomainInfo as DomainInfoModel; | 23 | use App\Models\Domain\DomainInfo as DomainInfoModel; |
| 22 | use App\Models\HomeCount\Count; | 24 | use App\Models\HomeCount\Count; |
| @@ -1124,7 +1126,6 @@ class ProjectController extends BaseController | @@ -1124,7 +1126,6 @@ class ProjectController extends BaseController | ||
| 1124 | * @time :2024/7/29 17:12 | 1126 | * @time :2024/7/29 17:12 |
| 1125 | */ | 1127 | */ |
| 1126 | public function saveSiteStatus(){ | 1128 | public function saveSiteStatus(){ |
| 1127 | - $projectModel = new Project(); | ||
| 1128 | $this->request->validate([ | 1129 | $this->request->validate([ |
| 1129 | 'id'=>'required', | 1130 | 'id'=>'required', |
| 1130 | 'site_status'=>'required' | 1131 | 'site_status'=>'required' |
| @@ -1132,14 +1133,68 @@ class ProjectController extends BaseController | @@ -1132,14 +1133,68 @@ class ProjectController extends BaseController | ||
| 1132 | 'id.required' => '项目id不能为空', | 1133 | 'id.required' => '项目id不能为空', |
| 1133 | 'site_status.required' => '状态不能为空', | 1134 | 'site_status.required' => '状态不能为空', |
| 1134 | ]); | 1135 | ]); |
| 1135 | - $projectModel->edit(['site_status'=>$this->map['site_status']],['id'=>$this->param['id']]); | ||
| 1136 | - //TODO::通知C端 | 1136 | + |
| 1137 | + //获取项目数据 | ||
| 1138 | + $projectModel = new Project(); | ||
| 1139 | + $projectInfo = $projectModel->read(['id'=>$this->param['id']],['project_type','serve_id','site_status']); | ||
| 1140 | + if(!$projectInfo){ | ||
| 1141 | + $this->fail('获取项目数据失败'); | ||
| 1142 | + } | ||
| 1143 | + if($projectInfo['site_status'] == $this->param['site_status']){ | ||
| 1144 | + $this->response('success'); | ||
| 1145 | + } | ||
| 1146 | + | ||
| 1147 | + //获取域名数据 | ||
| 1137 | $domainModel = new DomainInfoModel(); | 1148 | $domainModel = new DomainInfoModel(); |
| 1138 | - $domainInfo = $domainModel->read(['project_id'=>$this->param['id']]); | ||
| 1139 | - if($domainInfo !== false){ | ||
| 1140 | - $rs = curl_get('https://'.$domainInfo['domain'].'/api/stop_or_start_website?site_status='.$this->map['site_status']); | ||
| 1141 | - @file_put_contents(storage_path('logs/site_status.log'), var_export('通知C端on/off'.$domainInfo['domain'].'.返回结果:'.json_encode($rs), true) . PHP_EOL, FILE_APPEND); | 1149 | + $domainInfo = $domainModel->read(['project_id'=>$this->param['id']],['id','domain','amp_status']); |
| 1150 | + if($domainInfo){ | ||
| 1151 | + $this->fail('获取域名数据失败'); | ||
| 1142 | } | 1152 | } |
| 1153 | + | ||
| 1154 | + if($this->map['site_status'] == 1){ | ||
| 1155 | + //关闭站点:通知C端 | ||
| 1156 | + curl_get('https://'.$domainInfo['domain'].'/api/stop_or_start_website'); | ||
| 1157 | + }else{ | ||
| 1158 | + //开启站点:创建建站任务 | ||
| 1159 | + $serverIpModel = new ServersIp(); | ||
| 1160 | + $serversIpInfo = $serverIpModel->read(['id' => $projectInfo['serve_id']], ['servers_id']); | ||
| 1161 | + if(!$serversIpInfo){ | ||
| 1162 | + $this->fail('获取项目所属服务器失败'); | ||
| 1163 | + } | ||
| 1164 | + | ||
| 1165 | + if ($projectInfo['project_type'] == Project::PROJECT_TYPE_SEO) { | ||
| 1166 | + $type = DomainCreateTask::TYPE_BLOG; | ||
| 1167 | + } else { | ||
| 1168 | + $type = DomainCreateTask::TYPE_MAIN; | ||
| 1169 | + } | ||
| 1170 | + | ||
| 1171 | + //创建更新站点证书任务 | ||
| 1172 | + $domainCreateTaskModel = new DomainCreateTask(); | ||
| 1173 | + $task_info = $domainCreateTaskModel->read(['type' => $type, 'domain_id' => $domainInfo['id'], 'status' => ['<', DomainCreateTask::STATUS_SUC]], ['id']); | ||
| 1174 | + if (!$task_info) { | ||
| 1175 | + $domainCreateTaskModel->add([ | ||
| 1176 | + 'server_id' => $serversIpInfo['servers_id'], | ||
| 1177 | + 'project_id' => $this->param['id'], | ||
| 1178 | + 'domain_id' => $domainInfo['id'], | ||
| 1179 | + 'type' => $type | ||
| 1180 | + ]); | ||
| 1181 | + } | ||
| 1182 | + | ||
| 1183 | + if($domainInfo['amp_status']){ | ||
| 1184 | + $task_info_amp = $domainCreateTaskModel->read(['type' => DomainCreateTask::TYPE_AMP, 'domain_id' => $domainInfo['id'], 'status' => ['<', DomainCreateTask::STATUS_SUC]], ['id']); | ||
| 1185 | + if (!$task_info_amp) { | ||
| 1186 | + $domainCreateTaskModel->add([ | ||
| 1187 | + 'server_id' => $serversIpInfo['servers_id'], | ||
| 1188 | + 'project_id' => $this->param['id'], | ||
| 1189 | + 'domain_id' => $domainInfo['id'], | ||
| 1190 | + 'type' => DomainCreateTask::TYPE_AMP | ||
| 1191 | + ]); | ||
| 1192 | + } | ||
| 1193 | + } | ||
| 1194 | + } | ||
| 1195 | + | ||
| 1196 | + $projectModel->edit(['site_status'=>$this->param['site_status']],['id'=>$this->param['id']]); | ||
| 1197 | + | ||
| 1143 | $this->response('success'); | 1198 | $this->response('success'); |
| 1144 | } | 1199 | } |
| 1145 | 1200 |
-
请 注册 或 登录 后发表评论