You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.4 KiB
61 lines
1.4 KiB
<?php
|
|
declare (strict_types = 1);
|
|
|
|
namespace app\command;
|
|
|
|
use think\console\Command;
|
|
use think\console\Input;
|
|
use think\console\input\Argument;
|
|
use think\console\input\Option;
|
|
use think\console\Output;
|
|
|
|
use think\facade\Db;
|
|
|
|
class CheckExpire extends Command
|
|
{
|
|
protected function configure()
|
|
{
|
|
// 指令配置
|
|
$this->setName('checkexpire')
|
|
->setDescription('the checkexpire command');
|
|
}
|
|
|
|
protected function execute(Input $input, Output $output)
|
|
{
|
|
// 取得代理資料
|
|
$t_agents = Db::name('agent')->select();
|
|
|
|
foreach($t_agents as $val){
|
|
$agents[$val['id']] = $val;
|
|
}
|
|
|
|
// 取得過期用戶
|
|
$e_users = Db::name('user')
|
|
->where('status',1)
|
|
->where('overdue_time','<',time())
|
|
->select();
|
|
|
|
// 更新過期用戶
|
|
foreach($e_users as $val){
|
|
$data['level']=0;
|
|
$data['status']=1;
|
|
|
|
$level_option = Db::name('user_level')
|
|
->where('agent_id',$val['agent_id'])
|
|
->where('level_id',$data['level'])
|
|
->find();
|
|
|
|
$data['nc_type']=$level_option['nc_type'];
|
|
$data['nc_func']=$level_option['nc_func'];
|
|
|
|
|
|
Db::name('user')
|
|
->where('id',$val['id'])
|
|
->update($data);
|
|
}
|
|
|
|
// 指令输出
|
|
$output->writeln('checkexpire');
|
|
}
|
|
}
|