CloseRentOrderJob.php 759 B

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