erp/app/Listeners/GroupQueryListener.php

46 lines
1.0 KiB
PHP
Raw Normal View History

2022-10-24 09:44:43 +08:00
<?php
namespace App\Listeners;
use App\Events\GroupSetEvent;
use App\Models\Shop;
use App\Services\Business\BusinessFactory;
2022-10-25 10:47:36 +08:00
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use App\Jobs\KttQueryGroupStatus;
2022-10-24 09:44:43 +08:00
2022-10-25 10:47:36 +08:00
class GroupQueryListener implements ShouldQueue
2022-10-24 09:44:43 +08:00
{
2022-10-25 10:47:36 +08:00
use InteractsWithQueue;
2022-10-24 09:44:43 +08:00
/**
* Create the event listener.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Handle the event.
*
* @param GroupSetEvent $event
* @return void
*/
public function handle(GroupSetEvent $event)
{
2022-10-25 10:47:36 +08:00
$shops = Shop::query()
->where('plat_id', Shop::$PLAT_KTT)
->where('expires_at', '>', time())
->get()
->toArray();
foreach ($shops as $shop) {
$client = BusinessFactory::init()->make($shop['plat_id'])->setShop($shop);
$client->createGroup($event->groupId);
KttQueryGroupStatus::dispatch($event->groupId, $shop['id'])->delay(5);
}
2022-10-24 09:44:43 +08:00
}
}