|
...
|
...
|
@@ -17,6 +17,8 @@ use App\Models\Channel\Zone; |
|
|
|
use App\Models\Com\City;
|
|
|
|
use App\Models\Com\UpdateLog;
|
|
|
|
use App\Models\Devops\ServerConfig;
|
|
|
|
use App\Models\Devops\ServersIp;
|
|
|
|
use App\Models\Domain\DomainCreateTask;
|
|
|
|
use App\Models\Domain\DomainInfo;
|
|
|
|
use App\Models\Domain\DomainInfo as DomainInfoModel;
|
|
|
|
use App\Models\HomeCount\Count;
|
|
...
|
...
|
@@ -1124,22 +1126,75 @@ class ProjectController extends BaseController |
|
|
|
* @time :2024/7/29 17:12
|
|
|
|
*/
|
|
|
|
public function saveSiteStatus(){
|
|
|
|
$projectModel = new Project();
|
|
|
|
$this->request->validate([
|
|
|
|
'project_id'=>'required',
|
|
|
|
'id'=>'required',
|
|
|
|
'site_status'=>'required'
|
|
|
|
],[
|
|
|
|
'project_id.required' => '项目id不能为空',
|
|
|
|
'id.required' => '项目id不能为空',
|
|
|
|
'site_status.required' => '状态不能为空',
|
|
|
|
]);
|
|
|
|
$projectModel->edit(['site_status'=>$this->map['site_status']],['id'=>$this->param['project_id']]);
|
|
|
|
//TODO::通知C端
|
|
|
|
|
|
|
|
//获取项目数据
|
|
|
|
$projectModel = new Project();
|
|
|
|
$projectInfo = $projectModel->read(['id'=>$this->param['id']],['project_type','serve_id','site_status']);
|
|
|
|
if(!$projectInfo){
|
|
|
|
$this->fail('获取项目数据失败');
|
|
|
|
}
|
|
|
|
if($projectInfo['site_status'] == $this->param['site_status']){
|
|
|
|
$this->response('success');
|
|
|
|
}
|
|
|
|
|
|
|
|
//获取域名数据
|
|
|
|
$domainModel = new DomainInfoModel();
|
|
|
|
$domainInfo = $domainModel->read(['project_id'=>$this->param['project_id']]);
|
|
|
|
if($domainInfo !== false){
|
|
|
|
$rs = curl_get('https://'.$domainInfo['domain'].'/api/stop_or_start_website/');
|
|
|
|
@file_put_contents(storage_path('logs/site_status.log'), var_export('通知C端on/off'.$domainInfo['domain'].'.返回结果:'.json_encode($rs), true) . PHP_EOL, FILE_APPEND);
|
|
|
|
$domainInfo = $domainModel->read(['project_id'=>$this->param['id']],['id','domain','amp_status']);
|
|
|
|
if(!$domainInfo){
|
|
|
|
$this->fail('获取域名数据失败');
|
|
|
|
}
|
|
|
|
|
|
|
|
if($this->param['site_status'] == 1){
|
|
|
|
//关闭站点:通知C端
|
|
|
|
curl_get('https://'.$domainInfo['domain'].'/api/stop_or_start_website');
|
|
|
|
}else{
|
|
|
|
//开启站点:创建建站任务
|
|
|
|
$serverIpModel = new ServersIp();
|
|
|
|
$serversIpInfo = $serverIpModel->read(['id' => $projectInfo['serve_id']], ['servers_id']);
|
|
|
|
if(!$serversIpInfo){
|
|
|
|
$this->fail('获取项目所属服务器失败');
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($projectInfo['project_type'] == Project::PROJECT_TYPE_SEO) {
|
|
|
|
$type = DomainCreateTask::TYPE_BLOG;
|
|
|
|
} else {
|
|
|
|
$type = DomainCreateTask::TYPE_MAIN;
|
|
|
|
}
|
|
|
|
|
|
|
|
//创建更新站点证书任务
|
|
|
|
$domainCreateTaskModel = new DomainCreateTask();
|
|
|
|
$task_info = $domainCreateTaskModel->read(['type' => $type, 'domain_id' => $domainInfo['id'], 'status' => ['<', DomainCreateTask::STATUS_SUC]], ['id']);
|
|
|
|
if (!$task_info) {
|
|
|
|
$domainCreateTaskModel->add([
|
|
|
|
'server_id' => $serversIpInfo['servers_id'],
|
|
|
|
'project_id' => $this->param['id'],
|
|
|
|
'domain_id' => $domainInfo['id'],
|
|
|
|
'type' => $type
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if($domainInfo['amp_status']){
|
|
|
|
$task_info_amp = $domainCreateTaskModel->read(['type' => DomainCreateTask::TYPE_AMP, 'domain_id' => $domainInfo['id'], 'status' => ['<', DomainCreateTask::STATUS_SUC]], ['id']);
|
|
|
|
if (!$task_info_amp) {
|
|
|
|
$domainCreateTaskModel->add([
|
|
|
|
'server_id' => $serversIpInfo['servers_id'],
|
|
|
|
'project_id' => $this->param['id'],
|
|
|
|
'domain_id' => $domainInfo['id'],
|
|
|
|
'type' => DomainCreateTask::TYPE_AMP
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$projectModel->edit(['site_status'=>$this->param['site_status']],['id'=>$this->param['id']]);
|
|
|
|
|
|
|
|
$this->response('success');
|
|
|
|
}
|
|
|
|
|
...
|
...
|
|