CheckAchievement.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\command;
  12. use app\model\user\User;
  13. use app\services\user\AwardIntegralServices;
  14. use Swoole\Process;
  15. use think\console\Command;
  16. use think\console\Input;
  17. use think\console\Output;
  18. /**
  19. * 重置密码
  20. * Class ResetAdminPwd
  21. * @package app\command
  22. */
  23. class CheckAchievement extends Command
  24. {
  25. protected function configure()
  26. {
  27. // 指令配置
  28. $this->setName('checkAchievement')
  29. ->setDescription('Check User Achievement');
  30. }
  31. /**
  32. * @param Input $input
  33. * @param Output $output
  34. * @return int|void|null
  35. */
  36. protected function execute(Input $input, Output $output)
  37. {
  38. $process = new Process(function () use ($output) {
  39. /** @var AwardIntegralServices $service */
  40. $service = app()->make(AwardIntegralServices::class);
  41. $users = User::where('level', '>', 0)->select();
  42. foreach ($users as $v) {
  43. $achievement = $service->getAchievement($v['uid']);
  44. $month_achievement = $service->getLastMonthAchievement($v['uid']);
  45. $output->info($this->log($v['uid'] . '总业绩:' . $achievement . '月业绩:' . $month_achievement));
  46. }
  47. });
  48. $process->start();
  49. Process::wait(true);
  50. $output->info('处理完毕');
  51. }
  52. protected function log($str)
  53. {
  54. return date('Y-m-d H:i:s') . ' ' . $str . PHP_EOL;
  55. }
  56. }