<?php

namespace App\Jobs;

use App\Services\LogService;
use App\Services\StoreService;
use App\Store;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;

class StoreCreateInstantBill implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;


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

    /**
     * Execute the job.
     *
     * @param StoreService $service
     * @return void
     */
    public function handle(StoreService $service)
    {
        try{
            $service->createInstantBill($this->store);
        }catch (\Exception $e){
            LogService::log(__METHOD__,"ERROR-入库生成即时账单",$this->store->toJson()." | ".$e->getMessage());
        }
    }
}
