feat: #10000 更新
This commit is contained in:
parent
9c86453d7c
commit
41a809e763
40
app/Events/BusinessOrderCancelEvent.php
Normal file
40
app/Events/BusinessOrderCancelEvent.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use Illuminate\Broadcasting\Channel;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Broadcasting\PresenceChannel;
|
||||
use Illuminate\Broadcasting\PrivateChannel;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class BusinessOrderCancelEvent
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
public $shopId;
|
||||
public $orderSn;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($shopId, $orderSn)
|
||||
{
|
||||
$this->shopId = $shopId;
|
||||
$this->orderSn = $orderSn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the channels the event should broadcast on.
|
||||
*
|
||||
* @return \Illuminate\Broadcasting\Channel|array
|
||||
*/
|
||||
public function broadcastOn()
|
||||
{
|
||||
return new PrivateChannel('channel-name');
|
||||
}
|
||||
}
|
||||
42
app/Events/CreateLogisticEvent.php
Normal file
42
app/Events/CreateLogisticEvent.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use Illuminate\Broadcasting\Channel;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Broadcasting\PresenceChannel;
|
||||
use Illuminate\Broadcasting\PrivateChannel;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class CreateLogisticEvent
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
public $shopId;
|
||||
public $orderSn;
|
||||
public $waybillNo;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($shopId, $orderSn, $waybillNo)
|
||||
{
|
||||
$this->shopId = $shopId;
|
||||
$this->orderSn = $orderSn;
|
||||
$this->waybillNo = $waybillNo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the channels the event should broadcast on.
|
||||
*
|
||||
* @return \Illuminate\Broadcasting\Channel|array
|
||||
*/
|
||||
public function broadcastOn()
|
||||
{
|
||||
return new PrivateChannel('channel-name');
|
||||
}
|
||||
}
|
||||
47
app/Listeners/CancelLogisticListener.php
Normal file
47
app/Listeners/CancelLogisticListener.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Listeners;
|
||||
|
||||
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
|
||||
{
|
||||
public $connection = 'redis';
|
||||
|
||||
public $queue = 'listeners';
|
||||
|
||||
/**
|
||||
* Create the event listener.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param CreateLogisticEvent $event
|
||||
* @return void
|
||||
*/
|
||||
public function handle(CreateLogisticEvent $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);
|
||||
}
|
||||
}
|
||||
39
app/Listeners/CreateLogisticListener.php
Normal file
39
app/Listeners/CreateLogisticListener.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Listeners;
|
||||
|
||||
use App\Events\CreateLogisticEvent;
|
||||
use App\Models\Shop;
|
||||
use App\Services\Business\BusinessFactory;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
|
||||
class CreateLogisticListener implements ShouldQueue
|
||||
{
|
||||
public $connection = 'redis';
|
||||
|
||||
public $queue = 'listeners';
|
||||
|
||||
/**
|
||||
* Create the event listener.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param CreateLogisticEvent $event
|
||||
* @return void
|
||||
*/
|
||||
public function handle(CreateLogisticEvent $event)
|
||||
{
|
||||
$shop = Shop::query()->findOrFail($event->shopId);
|
||||
$client = BusinessFactory::init()->make($shop['plat_id'])->setShop($shop);
|
||||
$client->createLogistic($event->orderSn, $event->waybillNo);
|
||||
}
|
||||
}
|
||||
@ -5,12 +5,16 @@ namespace App\Providers;
|
||||
use App\Events\BusinessOrdersUpdate;
|
||||
use App\Events\GroupSetEvent;
|
||||
use App\Events\StockUpdateEvent;
|
||||
use App\Listeners\CreateLogisticListener;
|
||||
use App\Listeners\GroupQueryListener;
|
||||
use App\Listeners\StockUpdateListener;
|
||||
use App\Listeners\StockWarning;
|
||||
use App\Listeners\CombinationGoodsStockUpdateListener;
|
||||
use App\Listeners\UpdateBusinessGoodsStock;
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
use App\Events\BusinessOrderCancelEvent;
|
||||
use App\Listeners\CancelLogisticListener;
|
||||
use App\Events\CreateLogisticEvent;
|
||||
|
||||
class EventServiceProvider extends ServiceProvider
|
||||
{
|
||||
@ -33,6 +37,12 @@ class EventServiceProvider extends ServiceProvider
|
||||
GroupSetEvent::class => [
|
||||
GroupQueryListener::class,
|
||||
],
|
||||
BusinessOrderCancelEvent::class => [
|
||||
CancelLogisticListener::class
|
||||
],
|
||||
CreateLogisticEvent::class => [
|
||||
CreateLogisticListener::class
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Services\Business;
|
||||
|
||||
use App\Events\BusinessOrderCancelEvent;
|
||||
use App\Events\BusinessOrdersUpdate;
|
||||
use App\Models\BusinessGoodsSku;
|
||||
use App\Models\BusinessOrder;
|
||||
@ -29,6 +30,10 @@ abstract class BusinessClient
|
||||
|
||||
abstract public function bindGoods($goods);
|
||||
|
||||
abstract public function createLogistic($orderSn, $waybillNo);
|
||||
|
||||
abstract public function cancelLogistic($orderSn, $waybillNo);
|
||||
|
||||
abstract public function incrQuantity($businessGoodsSku, $num, $incremental);
|
||||
|
||||
abstract public function downloadOrdersAndSave($beginTime, $endTime, $downloadType = 'default', $page = 1);
|
||||
@ -45,6 +50,9 @@ abstract class BusinessClient
|
||||
} else {
|
||||
$orderRecord->update($order);
|
||||
}
|
||||
if ($order['cancel_status']) {
|
||||
event(new BusinessOrderCancelEvent($shopId, $order['order_sn']));
|
||||
}
|
||||
$goodsSkuNum = 0;
|
||||
foreach ($order['sub_order_list'] as $item) {
|
||||
$item['shop_id'] = $shopId;
|
||||
|
||||
@ -15,6 +15,10 @@ class BusinessFactory
|
||||
$this->platList['妙选'] = MiaoXuan::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $platName
|
||||
* @return BusinessClient
|
||||
*/
|
||||
public function make($platName)
|
||||
{
|
||||
return new $this->platList[$platName];
|
||||
|
||||
@ -262,4 +262,14 @@ class KuaiTuanTuan extends BusinessClient
|
||||
|
||||
return $this->doRequest($type, $appendParams);
|
||||
}
|
||||
|
||||
public function createLogistic($orderSn, $waybillNo)
|
||||
{
|
||||
return Order::createOrderLogistic($orderSn, $waybillNo);
|
||||
}
|
||||
|
||||
public function cancelLogistic($orderSn, $waybillNo)
|
||||
{
|
||||
return Order::deleteOrderLogistic($orderSn, $waybillNo);
|
||||
}
|
||||
}
|
||||
|
||||
@ -57,5 +57,40 @@ class Order
|
||||
|
||||
return [$type, $appendParams];
|
||||
}
|
||||
|
||||
public function getLogisticsCompanies()
|
||||
{
|
||||
$type = 'pdd.logistics.companies.get';
|
||||
|
||||
return [$type, []];
|
||||
}
|
||||
|
||||
|
||||
public static function createOrderLogistic($orderSn, $waybillNo, $logisticsId = '', $logisticsName = '')
|
||||
{
|
||||
// 不支持拆单发货
|
||||
$type = 'pdd.ktt.order.logistic.create';
|
||||
$appendParams = [
|
||||
'logisticsId' => $logisticsId,
|
||||
'logisticsName' => $logisticsName,
|
||||
'orderSn' => $orderSn,
|
||||
// 'subOrderSnList' => [], 发货子单号列表,无子单号视为整单发货
|
||||
'waybillNo' => $waybillNo,
|
||||
];
|
||||
|
||||
return [$type, $appendParams];
|
||||
}
|
||||
|
||||
public static function deleteOrderLogistic($orderSn, $waybillNo)
|
||||
{
|
||||
$type = 'pdd.ktt.order.logistic.delete';
|
||||
$appendParams = [
|
||||
'orderSn' => $orderSn,
|
||||
// 'subOrderSnList' => [], 发货子单号列表,无子单号视为整单发货
|
||||
'waybillNo' => $waybillNo,
|
||||
];
|
||||
|
||||
return [$type, $appendParams];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -47,4 +47,14 @@ class MiaoXuan extends BusinessClient
|
||||
{
|
||||
// TODO: Implement downloadGoods() method.
|
||||
}
|
||||
|
||||
public function createLogistic($orderSn, $waybillNo)
|
||||
{
|
||||
// TODO: Implement createLogistic() method.
|
||||
}
|
||||
|
||||
public function cancelLogistic($orderSn, $waybillNo)
|
||||
{
|
||||
// TODO: Implement cancelLogistic() method.
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Services\Ship;
|
||||
|
||||
use App\Events\CreateLogisticEvent;
|
||||
use App\Models\GoodsSku;
|
||||
use App\Models\ShopShip;
|
||||
use App\Models\Waybill;
|
||||
@ -64,6 +65,7 @@ class WayBillService
|
||||
'participate_no' => $waybill->participate_no,
|
||||
'note' => $waybill->note,
|
||||
];
|
||||
event(new CreateLogisticEvent($shopId, $waybill->order_sn, $data['waybill_code']));
|
||||
}
|
||||
} else {
|
||||
$contents[$waybill->id] = [
|
||||
|
||||
@ -13,7 +13,7 @@ return [
|
||||
|
|
||||
*/
|
||||
|
||||
'name' => env('APP_NAME', 'CFen Erp'),
|
||||
'name' => env('APP_NAME', 'chunfen_erp'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
||||
@ -131,7 +131,7 @@ return [
|
||||
'host' => env('REDIS_HOST', '127.0.0.1'),
|
||||
'password' => env('REDIS_PASSWORD', null),
|
||||
'port' => env('REDIS_PORT', '6379'),
|
||||
'database' => env('REDIS_DB', '0'),
|
||||
'database' => env('REDIS_DB', '10'),
|
||||
],
|
||||
|
||||
'cache' => [
|
||||
@ -139,7 +139,7 @@ return [
|
||||
'host' => env('REDIS_HOST', '127.0.0.1'),
|
||||
'password' => env('REDIS_PASSWORD', null),
|
||||
'port' => env('REDIS_PORT', '6379'),
|
||||
'database' => env('REDIS_CACHE_DB', '1'),
|
||||
'database' => env('REDIS_CACHE_DB', '11'),
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user