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.
63 lines
1.6 KiB
63 lines
1.6 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 CheckTrial extends Command
|
|
{
|
|
protected function configure()
|
|
{
|
|
// 指令配置
|
|
$this->setName('checktrial')
|
|
->setDescription('the checktrial 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',2)
|
|
->where('overdue_time','<',time())
|
|
->select();
|
|
|
|
// 更新試用過期用戶
|
|
foreach($e_users as $val){
|
|
$data['overdue_time']=strtotime("+".$agents[$val['agent_id']]['base_days']." days");
|
|
$data['level']=$agents[$val['agent_id']]['base_level'];
|
|
|
|
$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'];
|
|
|
|
$data['status']=1;
|
|
print_r($data);
|
|
Db::name('user')
|
|
->where('id',$val['id'])
|
|
->update($data);
|
|
}
|
|
|
|
// 指令输出
|
|
$output->writeln('檢查試用會員完成');
|
|
}
|
|
}
|