PushTask.php 890 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace App\Console\Commands\Push;
  3. use App\Modules\Push\Models\QappPushTask;
  4. use App\Modules\Push\Services\PushService;
  5. use Illuminate\Console\Command;
  6. class PushTask extends Command
  7. {
  8. /**
  9. * The name and signature of the console command.
  10. *
  11. * @var string
  12. */
  13. protected $signature = 'push:task';
  14. /**
  15. * The console command description.
  16. *
  17. * @var string
  18. */
  19. protected $description = '每分钟执行推送任务';
  20. /**
  21. * @return bool
  22. * @throws \App\Exceptions\ApiException
  23. * @throws \GuzzleHttp\Exception\GuzzleException
  24. */
  25. public function handle()
  26. {
  27. // 获取待推送的任务
  28. $pushTask = QappPushTask::getValidTask();
  29. $taskId = getProp($pushTask, 'id');
  30. if (!$taskId) {
  31. return false;
  32. }
  33. PushService::sendMessage($taskId);
  34. }
  35. }