CheckProductPicTasksCommand.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace App\Console\Commands;
  3. use App\Services\Anime\AnimeService;
  4. use Illuminate\Console\Command;
  5. class CheckProductPicTasksCommand extends Command
  6. {
  7. /**
  8. * The name and signature of the console command.
  9. *
  10. * @var string
  11. */
  12. protected $signature = 'Anime:checkProductPicTasks';
  13. /**
  14. * The console command description.
  15. *
  16. * @var string
  17. */
  18. protected $description = '检查产品图片生成任务状态并更新产品记录';
  19. protected $animeService;
  20. public function __construct(AnimeService $animeService)
  21. {
  22. parent::__construct();
  23. $this->animeService = $animeService;
  24. }
  25. /**
  26. * Execute the console command.
  27. *
  28. * @return int
  29. */
  30. public function handle()
  31. {
  32. dLog('command')->info('====================开始检查产品图片生成任务状态====================');
  33. $time_start = microtime(true);
  34. $stats = $this->animeService->checkProductPicTasks();
  35. $time_end = microtime(true);
  36. $this->info('检查完成: ' . json_encode($stats, JSON_UNESCAPED_UNICODE));
  37. dLog('command')->info('产品图片生成任务检查完成', [
  38. 'stats' => $stats,
  39. 'cost_time' => round($time_end - $time_start, 2)
  40. ]);
  41. dLog('command')->info('====================结束检查产品图片生成任务状态====================');
  42. return 0;
  43. }
  44. }