<?php

namespace iBrand\EC\Open\Core\Jobs;

use Carbon\Carbon;
use iBrand\Component\Order\Models\Order;
use iBrand\EC\Open\Core\Processor\OrderProcessor;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;

class AutoCancelOrder implements ShouldQueue
{
    use InteractsWithQueue, Queueable, SerializesModels;

    protected $order;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct(Order $order)
    {
        $this->order = $order;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle(OrderProcessor $orderProcessor)
    {
        $orderProcessor->cancel($this->order, '超时未付款自动取消');
    }
}
