CloseVip.php
880 字节
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
<?php
/**
* Created by PhpStorm.
* User: DELL
* Date: 2019/5/31
* Time: 9:25
*/
namespace app\command;
use app\api\model\Student;
use think\console\Input;
use think\console\Output;
use think\console\Command;
class CloseVip extends Command{
protected function configure()
{
$this->setName('CloseVip')->setDescription('关闭vip已经TimeOut的vip用户, 每1分钟执行一次');
}
protected function execute(Input $input, Output $output)
{
$student = new Student();
$where['vip_endtime'] = ['<', time()];
$studentList = $student->listByWhere($where);
$userIds = [];
foreach ($studentList as $v) {
$userIds[] = $v['user_id'];
}
if($userIds) {
$student->updateByIds($userIds, ['vip_level' => 0, 'vip_endtime' => null, 'updatetime' => time()]);
}
}
}