erp/app/Listeners/GroupQueryListener.php

38 lines
826 B
PHP

<?php
namespace App\Listeners;
use App\Events\GroupSetEvent;
use App\Models\Groups;
use App\Models\Shop;
use App\Services\Business\BusinessFactory;
class GroupQueryListener
{
/**
* Create the event listener.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Handle the event.
*
* @param GroupSetEvent $event
* @return void
*/
public function handle(GroupSetEvent $event)
{
$shopId = Groups::query()->where('group_id', $event->groupId)->value('shop_id');
$shop = Shop::query()->find($shopId);
$client = BusinessFactory::init()->make($shop['plat_id'])->setShopWithId($shop['id']);
$client->createGroup($event->groupId);
sleep(1);
$client->queryGroupStatus($event->groupId);
}
}