// +---------------------------------------------------------------------- namespace app\command; use app\model\user\User; use app\services\user\AwardIntegralServices; use Swoole\Process; use think\console\Command; use think\console\Input; use think\console\Output; /** * 重置密码 * Class ResetAdminPwd * @package app\command */ class CheckAchievement extends Command { protected function configure() { // 指令配置 $this->setName('checkAchievement') ->setDescription('Check User Achievement'); } /** * @param Input $input * @param Output $output * @return int|void|null */ protected function execute(Input $input, Output $output) { $process = new Process(function () use ($output) { /** @var AwardIntegralServices $service */ $service = app()->make(AwardIntegralServices::class); $users = User::where('level', '>', 0)->select(); foreach ($users as $v) { $achievement = $service->getAchievement($v['uid']); $month_achievement = $service->getLastMonthAchievement($v['uid']); if ($month_achievement < $achievement / 10) { $output->info($this->log($v['uid'] . '总业绩:' . $achievement . '月业绩:' . $month_achievement)); $output->info($this->log($v['uid'] . '月业绩未达标,执行降级')); } } }); $process->start(); Process::wait(true); $output->info('处理完毕'); } protected function log($str) { return date('Y-m-d H:i:s') . ' ' . $str . PHP_EOL; } }