<?php

namespace App\Jobs;

use App\Models\Shop;
use App\Services\Business\BusinessFactory;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;

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

    public $groupId;
    public $shopId;

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

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        $shop = Shop::query()->find($this->shopId);
        $client = BusinessFactory::init()->make($shop['plat_id'])->setShop($shop);
        $client->queryGroupStatus($this->groupId);
    }
}
