作者 刘锟

合并分支 'akun' 到 'master'

Akun



查看合并请求 !1594
... ... @@ -11,6 +11,7 @@ namespace App\Http\Logic\Bside\SeoSetting;
use App\Helper\Arr;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Devops\ServerConfig;
use App\Models\Devops\Servers;
use App\Models\Devops\ServersIp;
use App\Models\Domain\DomainCreateTask;
... ... @@ -81,27 +82,30 @@ class DomainSettingLogic extends BaseLogic
$this->fail('主域名填写错误');
}
if ($this->param['type'] = WebSetting::SEO_TYPE_PUBLIC) {
//获取项目详情
$project_model = new Project();
$project_info = $project_model->read(['id' => $this->user['project_id']], ['company']);
if (!$project_info) {
$this->fail('获取项目数据失败');
}
$server_ip_model = new ServersIp();
$domain_model = new DomainInfo();
$server_model = new Servers();
$optimize_model = new DeployOptimize();
if ($this->param['type'] = WebSetting::SEO_TYPE_PUBLIC) {
//公共服务器
$record = $this->param['record'] ?? '';
if (empty($record)) {
$this->fail('解析记录不能为空');
}
//获取解析服务器详情
$server_ip_model = new ServersIp();
$record_info = $server_ip_model->read(['domain' => $record], ['id', 'servers_id', 'ip', 'domain', 'total']);
if (!$record_info) {
$this->fail('解析记录不存在');
}
//获取项目详情
$project_model = new Project();
$project_info = $project_model->read(['id' => $this->user['project_id']], ['company']);
if (!$project_info) {
$this->fail('获取项目数据失败');
}
//构建blog二级域名
$domain_array = explode('.', $domain);
if (count($domain_array) == 1) {
... ... @@ -129,13 +133,11 @@ class DomainSettingLogic extends BaseLogic
}
//添加域名到域名管理
$domain_model = new DomainInfo();
$info = $domain_model->read(['domain' => $blog_domain]);
if ($info === false) {
$id = $domain_model->addReturnId(['domain' => $blog_domain, 'project_id' => $this->user['project_id'], 'belong_to' => 2, 'status' => 1, 'remark' => $project_info['company']]);
//保存优化设置
$optimize_model = new DeployOptimize();
$optimize_model->edit(['domain' => $id], ['project_id' => $this->user['project_id']]);
//保存项目ip
... ... @@ -143,7 +145,6 @@ class DomainSettingLogic extends BaseLogic
//变更ip使用数量
$server_ip_model->edit(['total' => $record_info['total'] + 1], ['id' => $record_info['id']]);
$server_model = new Servers();
$server_model->edit(['being_number' => $record_info['total'] + 1], ['id' => $record_info['servers_id']]);
//创建建站任务
... ... @@ -161,14 +162,21 @@ class DomainSettingLogic extends BaseLogic
DB::rollBack();
$this->fail('保存失败,请联系管理员');
}
} else {
//个人服务器
$ftp = $this->param['ftp'] ?? [];
if (empty($ftp) || empty($ftp['url']) || empty($ftp['username']) || empty($ftp['password']) || empty($ftp['port'])) {
$this->fail('ftp信息填写未完整');
}
//获取自建站服务器详情
$record_info = $server_ip_model->read(['servers_id' => ServerConfig::SELF_SITE_ID], ['id', 'servers_id', 'total']);
if (!$record_info) {
$this->fail('解析记录不存在');
}
DB::beginTransaction();
try {
//保存一条主域名记录
$setting_info = $this->model->read(['project_id' => $this->user['project_id']]);
if ($setting_info === false) {
... ... @@ -176,7 +184,32 @@ class DomainSettingLogic extends BaseLogic
} else {
$this->model->edit(['seo_type' => WebSetting::SEO_TYPE_OWN, 'seo_domain' => $domain, 'seo_ftp' => Arr::a2s($ftp)], ['id' => $setting_info['id']]);
}
//添加域名到域名管理
$info = $domain_model->read(['domain' => $domain]);
if ($info === false) {
$id = $domain_model->addReturnId(['domain' => $domain, 'project_id' => $this->user['project_id'], 'belong_to' => 2, 'status' => 1, 'remark' => $project_info['company']]);
//保存优化设置
$optimize_model = new DeployOptimize();
$optimize_model->edit(['domain' => $id], ['project_id' => $this->user['project_id']]);
//保存项目ip
$project_model->edit(['serve_id' => $record_info['id']], ['id' => $this->user['project_id']]);
//变更ip使用数量
$server_ip_model->edit(['total' => $record_info['total'] + 1], ['id' => $record_info['id']]);
$server_model = new Servers();
$server_model->edit(['being_number' => $record_info['total'] + 1], ['id' => $record_info['servers_id']]);
}
DB::commit();
} catch (\Exception $e) {
DB::rollBack();
$this->fail('保存失败,请联系管理员');
}
}
return $this->success();
}
}
... ...