Runrecord.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace app\admin\command;
  3. use think\console\Command;
  4. use think\console\Input;
  5. use think\console\Output;
  6. use think\Exception;
  7. use think\Loader;
  8. class Runrecord extends Command
  9. {
  10. protected $model = null;
  11. protected function configure()
  12. {
  13. $this
  14. ->setName('Runrecord')
  15. ->addArgument('action')
  16. ->setDescription('命令行执行定时任务')//运行 "php think list" 时的简短描述
  17. ->setHelp("执行接口 参数为api (api/index/index)");
  18. }
  19. protected function execute(Input $input, Output $output)
  20. {
  21. $action= $input->getArgument('action');
  22. switch ($action){
  23. case "upincome"://更新用户收益
  24. while (true) {
  25. $result= action("api/index/upincome");
  26. $output->writeln('131');
  27. sleep(600);
  28. }
  29. break;
  30. case "runrecord"://记录广告收益
  31. while (true) {
  32. $result= action("api/index/runrecord");
  33. $output->writeln($result);
  34. sleep(60);
  35. }
  36. break;
  37. }
  38. }
  39. }