1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <?php
- namespace App\Console\Commands\Push;
- use App\Modules\Push\Models\QappPushTask;
- use App\Modules\Push\Services\PushService;
- use Illuminate\Console\Command;
- class PushTask extends Command
- {
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'push:task';
- /**
- * The console command description.
- *
- * @var string
- */
- protected $description = '每分钟执行推送任务';
- /**
- * @return bool
- * @throws \App\Exceptions\ApiException
- * @throws \GuzzleHttp\Exception\GuzzleException
- */
- public function handle()
- {
- // 获取待推送的任务
- $pushTask = QappPushTask::getValidTask();
- $taskId = getProp($pushTask, 'id');
- if (!$taskId) {
- return false;
- }
- PushService::sendMessage($taskId);
- }
- }
|