CloseOrderJob.php 727 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace App\Jobs;
  3. use App\Models\DepositOrder;
  4. use Carbon\Carbon;
  5. use Illuminate\Database\Eloquent\Model;
  6. class CloseOrderJob extends Job
  7. {
  8. protected $model = '';
  9. /**
  10. * Create a new job instance.
  11. *
  12. * @return void
  13. */
  14. public function __construct(Model $model, Carbon $delay)
  15. {
  16. $this->model = $model;
  17. // 设置延迟的时间,delay() 方法的参数代表多少秒之后执行
  18. $this->delay($delay);
  19. }
  20. /**
  21. * Execute the job.
  22. *
  23. * @return void
  24. */
  25. public function handle()
  26. {
  27. if ((int)$this->model->pay_status === DepositOrder::PAY_STATUS_OK) {
  28. return;
  29. }
  30. $this->model->delete();
  31. }
  32. }