DailyTask.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace App\Console\Commands;
  3. use Illuminate\Console\Command;
  4. use Illuminate\Support\Facades\Log;
  5. use App\Jobs\Manager\Process\LowPriceGoodsJobs;
  6. use App\Jobs\Manager\Process\ViolationProductJobs;
  7. use App\Jobs\Manager\Process\ViolationStoreJobs;
  8. /**
  9. * 定时任务
  10. * @author 唐远望
  11. * @version 1.0
  12. * @date 2025-12-10
  13. */
  14. class DailyTask extends Command
  15. {
  16. /**
  17. * 命令名称和签名
  18. *
  19. * @var string
  20. */
  21. protected $signature = 'task:daily';
  22. /**
  23. * 命令描述
  24. *
  25. * @var string
  26. */
  27. protected $description = '每天12点执行的定时任务';
  28. /**
  29. * 执行命令
  30. *
  31. * @return int
  32. */
  33. public function handle()
  34. {
  35. $this->info('开始执行每日任务...');
  36. try {
  37. // 示例:记录日志
  38. $this->info('每日任务执行完成!');
  39. return Command::SUCCESS;
  40. } catch (\Exception $e) {
  41. Log::error('每日定时任务执行失败: ' . $e->getMessage());
  42. $this->error('任务执行失败: ' . $e->getMessage());
  43. return Command::FAILURE;
  44. }
  45. }
  46. }