<?php

namespace App\Jobs;

use App\Exceptions\ApiException;
use App\Services\Pay\OrderService;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;

/**
 * Class OrderCloseJob
 * @package App\Jobs
 */
class OrderCloseJob implements ShouldQueue
{
    use Dispatchable;
    use InteractsWithQueue;
    use Queueable;
    use SerializesModels;

    /**
     * Create a new job instance.
     *
     * @param int $order_id
     */
    public function __construct($order_id)
    {
        $this->order_id = $order_id;
    }

    private $order_id;

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        $orderService = new OrderService();
        try {
            $result = $orderService->closeOrder($this->order_id);
        } catch (ApiException $e) {
        } catch (\Exception $e) {
        }
    }
}
