Kernel.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace App\Console;
  3. use App\Models\Order;
  4. use Illuminate\Console\Scheduling\Schedule;
  5. use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
  6. class Kernel extends ConsoleKernel
  7. {
  8. /**
  9. * The Artisan commands provided by your application.
  10. *
  11. * @var array
  12. */
  13. protected $commands = [
  14. //
  15. ];
  16. /**
  17. * Define the application's command schedule.
  18. *
  19. * @param \Illuminate\Console\Scheduling\Schedule $schedule
  20. * @return void
  21. */
  22. protected function schedule(Schedule $schedule)
  23. {
  24. $schedule->call(function () {
  25. $timestamp = now()->timestamp;
  26. Order::query()->whereNotNull('freeze_expired_at')->where('freeze_expired_at', '<=', $timestamp)
  27. ->chunk(100, function ($orders) {
  28. foreach ($orders as $order) {
  29. \product_storehouse_order_free_up($order->id);
  30. }
  31. });
  32. })->everyMinute();
  33. }
  34. /**
  35. * Register the commands for the application.
  36. *
  37. * @return void
  38. */
  39. protected function commands()
  40. {
  41. $this->load(__DIR__ . '/Commands');
  42. require base_path('routes/console.php');
  43. }
  44. }