| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <?php
- declare (strict_types = 1);
- namespace app\api\command;
- use app\common\service\UserService;
- use think\console\Command;
- use think\console\Input;
- use think\console\Output;
- /**
- * 用户自动升级 by wes 每间隔10分钟运行一次
- * Class AutoUpdateUserLevel
- * @package app\api\command
- */
- class AutoUpdateUserLevel extends Command
- {
- protected $cacheTime = 86400; // 一天
- protected function configure()
- {
- $this->setName('auto_update_user_level')
- ->setDescription('the auto_update_user_level command');
- }
- /**
- * 处理用户自动升级
- * @param Input $input
- * @param Output $output
- * @return int
- */
- protected function execute(Input $input, Output $output)
- {
- $result = UserService::make()->updateLevel();
- if(is_array($result)){
- echo json_encode($result, 256)."\n";
- }else{
- echo json_encode(['code'=>500,'msg'=> $result?$result:'处理失败',date('Y-m-d H:i:s')], 256)."\n";
- }
- return true;
- }
- }
|