mirror of
https://gitee.com/hzchunfen/erp.git
synced 2025-12-01 06:30:49 +00:00
46 lines
1.1 KiB
PHP
46 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Listeners;
|
|
|
|
use App\Events\CancelLogisticEvent;
|
|
use App\Events\CreateLogisticEvent;
|
|
use App\Models\Shop;
|
|
use App\Models\Waybill;
|
|
use App\Services\Business\BusinessFactory;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
|
|
class CancelLogisticListener implements ShouldQueue
|
|
{
|
|
|
|
/**
|
|
* Create the event listener.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct()
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Handle the event.
|
|
*
|
|
* @param CreateLogisticEvent $event
|
|
* @return void
|
|
*/
|
|
public function handle(CancelLogisticEvent $event)
|
|
{
|
|
$waybillNo = Waybill::query()
|
|
->where('shop_id', $event->shopId)
|
|
->where('order_sn', $event->orderSn)
|
|
->value('waybill_code');
|
|
if (empty($waybillNo)) {
|
|
return;
|
|
}
|
|
$shop = Shop::query()->findOrFail($event->shopId);
|
|
$client = BusinessFactory::init()->make($shop['plat_id'])->setShop($shop);
|
|
$client->cancelLogistic($event->orderSn, $event->waybillNo);
|
|
}
|
|
}
|