DomainInfoLogic.php
1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
namespace App\Http\Logic\Aside\Project;
use App\Http\Logic\Aside\BaseLogic;
use App\Models\Project\DomainInfo;
use App\Models\Project\Payment;
use MongoDB\Client;
class DomainInfoLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->model = new DomainInfo();
}
public function getDomainInfo($project_id)
{
$project = app(ProjectLogic::class)->getInfo($project_id);
$domain = $project['deploy_optimize']['domain'];
$info = $this->model->where('project_id', $project_id)->first();
//不存在或时间过期了 重新获取信息
$expiration_date = $info['domain_info']['expiration_date'] ?? '';
$end_time = $info['ssl']['end_time'] ?? '';
if(!$info || $expiration_date < date("Y-m-d") || $end_time < date('Y-m-d')){
try {
$mongo = new Client("mongodb://root:globalso8837840@23.228.125.2:27017");
$db = $mongo->globalso_monitor;
$collection = $db->project_v1;
$project_zk = $collection->findOne(['main_url' => $domain]);
$info['domain'] = $domain;
$info['domain_info'] = (array) $project_zk['domain_info'] ?? [];
$info['ssl'] = (array) $project_zk['ssl'] ?? [];
parent::save($info);
}catch (\Exception $e){
return [];
}
}
return $info;
}
}