|
...
|
...
|
@@ -2,6 +2,7 @@ |
|
|
|
|
|
|
|
namespace App\Console\Commands\Domain;
|
|
|
|
|
|
|
|
use App\Models\Geo\GeoCount;
|
|
|
|
use App\Models\Project\DeployBuild;
|
|
|
|
use App\Models\Project\DeployOptimize;
|
|
|
|
use App\Models\Project\Project;
|
|
...
|
...
|
@@ -58,17 +59,6 @@ class RemainDay extends Command |
|
|
|
*/
|
|
|
|
protected $description = '网站服务剩余时长';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new command instance.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
$this->project = new Project();
|
|
|
|
$this->deployBuild = new DeployBuild();
|
|
|
|
parent::__construct();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return bool
|
|
...
|
...
|
@@ -79,20 +69,21 @@ class RemainDay extends Command |
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :普通项目剩余服务时常
|
|
|
|
* @name :saveRemainDay
|
|
|
|
* @remark :计算剩余服务时常
|
|
|
|
* @name :_action
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/4/2 10:48
|
|
|
|
* @time :2025/11/4 10:59
|
|
|
|
*/
|
|
|
|
public function saveRemainDay(){
|
|
|
|
$list = $this->project->list(['extend_type'=>Project::TYPE_ZERO,'type'=>['in',[Project::TYPE_TWO,Project::TYPE_THREE,Project::TYPE_FOUR,Project::TYPE_SIX]]],'id',['id','type','level','uptime','remain_day','is_remain_today','pause_days','finish_remain_day','bm_finish_remain_day']);
|
|
|
|
public function _action(){
|
|
|
|
$projectModel = new Project();
|
|
|
|
$deployBuildModel = new DeployBuild();
|
|
|
|
$list = $projectModel->list(['extend_type'=>Project::TYPE_ZERO,'type'=>['in',[Project::TYPE_TWO,Project::TYPE_THREE,Project::TYPE_FOUR,Project::TYPE_SIX]]],'id',['id','type','level','uptime','remain_day','version','is_remain_today','pause_days','finish_remain_day','bm_finish_remain_day','geo_qualify_num']);
|
|
|
|
foreach ($list as $item){
|
|
|
|
$deploy_build = $deployBuildModel->read(['project_id'=>$item['id']],['service_duration','seo_service_duration','plan','seo_plan']);
|
|
|
|
echo 'start->项目id:' . $item['id'] . '执行时间:'. date('Y-m-d H:i:s') . PHP_EOL;
|
|
|
|
$deploy_build = $this->deployBuild->read(['project_id'=>$item['id']],['service_duration','seo_service_duration','plan','seo_plan']);
|
|
|
|
//todo::暂停的项目停止计时
|
|
|
|
if(in_array($item['id'],$this->ceaseProjectId)){//暂停的项目
|
|
|
|
if(($item['type'] == Project::TYPE_TWO) && ($item['is_remain_today'] == 1)){
|
|
|
|
$pause_days = $item['pause_days'] + 1;
|
|
...
|
...
|
@@ -111,15 +102,14 @@ class RemainDay extends Command |
|
|
|
//白帽版本单独计算
|
|
|
|
$this->seoRemainDay($deploy_build,$item);
|
|
|
|
//默认版本统计
|
|
|
|
if($deploy_build['service_duration'] == 0){
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$this->remainDay($item,$deploy_build);
|
|
|
|
echo 'end->项目id:' . $item['id'] . '执行时间:'. date('Y-m-d H:i:s') . PHP_EOL;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :白帽版本单独计算
|
|
|
|
* @name :seoRemainDay
|
|
...
|
...
|
@@ -140,13 +130,7 @@ class RemainDay extends Command |
|
|
|
$compliance_day = floor($diff / (60 * 60 * 24));
|
|
|
|
$seo_remain_day = $deploy_build['seo_service_duration'] - $compliance_day;
|
|
|
|
}
|
|
|
|
if($deploy_build['plan'] == 0 && $seo_remain_day < 0 && $deploy_build['seo_service_duration'] != 0){//只有白帽版本的项目且剩余服务时常为0,放入未续费中
|
|
|
|
// $this->project->edit(['seo_remain_day'=>$seo_remain_day,'finish_remain_day'=>$compliance_day ?? 0,'extend_type'=>Project::TYPE_FIVE],['id'=>$item['id']]);
|
|
|
|
$this->project->edit(['seo_remain_day'=>$seo_remain_day,'bm_finish_remain_day'=>$compliance_day ?? 0],['id'=>$item['id']]);
|
|
|
|
}else{
|
|
|
|
//同时包括白帽版本+默认版本的项目
|
|
|
|
$this->project->edit(['seo_remain_day'=>$seo_remain_day,'bm_finish_remain_day'=>$compliance_day ?? 0],['id'=>$item['id']]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
...
|
...
|
@@ -160,6 +144,10 @@ class RemainDay extends Command |
|
|
|
* @time :2025/4/25 14:31
|
|
|
|
*/
|
|
|
|
public function remainDay($item,$deploy_build){
|
|
|
|
//默认版本统计
|
|
|
|
if($deploy_build['service_duration'] == 0){
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
//默认版本计算剩余服务时常
|
|
|
|
if($item['type'] == Project::TYPE_TWO || $item['type'] == Project::TYPE_FOUR){
|
|
|
|
if(in_array($item['id'],$this->projectId)){//已开始优化的时间结算
|
|
...
|
...
|
@@ -173,6 +161,14 @@ class RemainDay extends Command |
|
|
|
$remain_day = $deploy_build['service_duration'] - $compliance_day;
|
|
|
|
}else{
|
|
|
|
$compliance_day = ($item['finish_remain_day'] ?? 0);
|
|
|
|
//todo::7.5版本单独计算
|
|
|
|
if($item['version'] == 7.5 && $deploy_build['seo_plan'] != 0 && $deploy_build['plan'] != 0){
|
|
|
|
$geoCountModel = new GeoCount();
|
|
|
|
$is_qualify = $geoCountModel->where('project_id', $item['id'])->orderBy('id', 'desc')->value('is_qualify');
|
|
|
|
if($compliance_day > 0 && $is_qualify > 0){
|
|
|
|
$compliance_day = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$remain_day = $deploy_build['service_duration'] - $compliance_day;
|
|
|
|
}
|
|
|
|
}else{
|
...
|
...
|
|