作者 lyh

gx

<?php
namespace App\Console\Commands\Domain;
use App\Exceptions\AsideGlobalException;
use App\Exceptions\BsideGlobalException;
use App\Http\Logic\Aside\Domain\DomainInfoLogic;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Console\Command;
class DomainTime extends Command
{
public $error = 0;
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'domain_time';
/**
* The console command description.
*
* @var string
*/
protected $description = '域名定时任务 更新域名|证书到期时间';
/**
* @name :(定时执行)handle
* @author :lyh
* @method :post
* @time :2023/5/12 14:48
*/
public function handle()
{
echo $this->update_domain_time();
}
/**
* 更新域名|证书到期时间
* @return int|mixed|void
* @throws AsideGlobalException
* @throws BsideGlobalException|GuzzleException
*/
protected function update_domain_time()
{
$domainCon = new DomainInfoLogic();
$all = $domainCon->getAllDomain();
$all = $all->toArray();
if ( empty( $all ) ) {
$this->info( '未获取到数据' );
return;
}
foreach ( $all as $item ) {
$domain = $item['domain'];
// 域名到期时间
$domainT = $domainCon->getDomainTime( $domain );
if ( $domainT ) {
$domain_time = $item['domain_end_time'];
$domainValidFrom = $domainT['validFrom'];
$domainValidTo = $domainT['validTo'];
if ( strtotime( $domain_time ) < strtotime( $domainValidTo ) ) {
$this->info( $domain . '域名到期时间更新成功' );
$domainCon->updateDomain( $item['id'], [ 'domain_end_time' => $domainValidTo ] );
}
} else {
$this->error++;
$this->info( $domain . '域名到期时间获取失败' );
}
// 证书到期时间
$certificateT = $domainCon->getDomainCertificateTime( $domain );
if ( $certificateT ) {
$certificate_time = $item['certificate_end_time'];
$certificateValidFrom = $certificateT['validFrom'];
$certificateValidTo = $certificateT['validTo'];
if ( strtotime( $certificate_time ) < strtotime( $certificateValidTo ) ) {
$this->info( $domain . '证书到期时间更新成功' );
$domainCon->updateDomain( $item['id'], [ 'certificate_end_time' => $certificateValidTo ] );
}
} else {
$this->error++;
$this->info( $domain . '证书到期时间获取失败' );
}
}
return $this->error;
}
}
... ... @@ -193,109 +193,6 @@ class ComController extends BaseController
}
public function ceshi(){
$model = new Service();
$info = $model->read(['type'=>5]);
$values = json_decode($info['values']);
$values = array_reverse($values);
foreach ($values as $k => $v){
$v = (array)$v;
$data = [
'name'=>$v['name'],
'mobile'=>$v['mobile'],
'password'=>'$2y$10$ZNHxlIddWiQzQbIIzFgYJOsPlQ4n0cwWl8Sea53qvQvDXtu3WeYMC',
'created_at'=>date('Y-m-d H:i:s'),
'updated_at'=>date('Y-m-d H:i:s'),
];
$manager_id = DB::table('gl_manage')->insertGetId($data);
if($v['sex'] == '女'){
$v['sex'] = 2;
}else{
$v['sex'] = 1;
}
$education = [
'专科' => 1,
'大专' => 1,
'中专' => 0,
'本科' => 2,
'自考本科'=>0,
'全日制本科'=>2,
'本科在读'=>2,
'大学本科'=>2,
'硕士研究生' => 3,
'硕士'=>3,
'其他' => 0,
];
$belong_group = [
'-' => 0,
'KA组' => 1,
'A组' => 2,
'B组' => 3,
'C组'=>4,
'D组'=>5,
'E组'=>6,
'F组'=>7,
'G组' => 8,
'H组'=>9,
'GA组' => 10,
'GB组' => 11,
'GC组' => 12,
'前端组' => 13,
'后端组' => 14,
'黑格组' => 15,
'售后组' => 16,
'其他' => 0,
];
//获取入职岗位
$entryPositionModel = new EntryPosition();
$entry_position = $entryPositionModel->read(['name'=>$v['entry_position']]);
if($entry_position !== false){
$entry_position = $entry_position['id'];
}else{
$entry_position = '';
}
//获取级别
$jobLevelModel = new JobLevel();
$p_level = $jobLevelModel->read(['name'=>$v['p_level']]);
if($entry_position !== false){
$p_level = $p_level['id'];
}else{
$p_level = '';
}
$manager_data = [
'manage_id'=>$manager_id ?? '',
'name'=>$v['name'],
'id_card'=>$v['id_card'],
'mobile'=>$v['mobile'],
'birthday'=>$v['birthday'],
'address'=>$v['address'],
'sex'=>$v['sex'],
'nationality'=>$v['nationality'],
'belong_group'=>$belong_group[$v['belong_group']],
'education'=>isset($education[$v['education']]) ? $education[$v['education']] : 0,
'major'=>$v['major'],
'graduate_school'=>$v['graduate_school'],
'english_level'=>$v['english_level'],
'entry_position'=>$entry_position,
'p_level'=>$p_level,
'residential_address'=>$v['residential_address'],
'emergency_contact'=>$v['emergency_contact'],
'career_history'=>json_encode((array)$v['career_history']),
'learning_history'=>json_encode((array)$v['learning_history']),
'bank_card'=>$v['bank_card'],
'photo_gallery'=>json_encode((array)$v['photo_gallery']),
'id_card_gallery'=>json_encode((array)$v['id_card_gallery']),
'certificate_gallery'=>json_encode((array)$v['certificate_gallery']),
'dangyuan'=>$v['dangyuan'],
'dangzhibu'=>$v['dangzhibu'],
'dang_address'=>$v['dang_address'],
'join_date'=>$v['join_date'],
'status'=>($v['status'] == '在职') ? 1 : 2,
'computer_account'=>$v['computer_account'],
'qq_account'=>$v['qq_account']
];
$hrModel = new ManageHr();
$hrModel->add($manager_data);
}
return 1;
}
}
... ...