mirror of
https://gitee.com/hzchunfen/erp.git
synced 2025-11-30 22:20:45 +00:00
feat: #10000 妙选订单推送优化
This commit is contained in:
parent
a7842b850d
commit
804162083b
@ -36,6 +36,9 @@ class UpdateBusinessGoodsStock implements ShouldQueue
|
||||
public function handle(Registered $event)
|
||||
{
|
||||
$shops = Shop::query()->where('id', '<>', $this->businessOrderItem->shop_id)->where('status', 1)->get(['id', 'plat_id']);
|
||||
if (empty($shops)) {
|
||||
return;
|
||||
}
|
||||
[$goodsCode, $skuCode] = explode('_', $this->businessOrderItem->external_sku_id);
|
||||
$goodsSku = GoodsSku::query()->where('sku_code', $skuCode)
|
||||
->with(['goods' => function ($query) use ($goodsCode) {
|
||||
|
||||
@ -5,6 +5,7 @@ namespace App\Services\Business;
|
||||
use App\Listeners\UpdateBusinessGoodsStock;
|
||||
use App\Models\BusinessGoodsSku;
|
||||
use App\Models\BusinessOrder;
|
||||
use App\Models\BusinessOrderItem;
|
||||
use App\Models\GoodsSku;
|
||||
use App\Models\Log;
|
||||
use App\Models\Shop;
|
||||
@ -35,21 +36,17 @@ abstract class BusinessClient
|
||||
foreach ($orders as $order) {
|
||||
unset($order['custom_item_list'], $order['logistics_list'], $order['gift_order_list']);
|
||||
$order['shop_id'] = $shopId;
|
||||
$orderRecord = BusinessOrder::query()->where('shop_id', $shopId)->where('order_sn', $order['order_sn'])->first();
|
||||
if (empty($orderRecord)) {
|
||||
$orderRecord->create($order);
|
||||
$orderRecord = BusinessOrder::firstOrNew(['shop_id' => $shopId, 'order_sn' => $order['order_sn']], $order);
|
||||
if (empty($orderRecord->id)) {
|
||||
$orderRecord->save();
|
||||
} else {
|
||||
$orderRecord->update($order);
|
||||
}
|
||||
foreach ($order['sub_order_list'] as $item) {
|
||||
$item['shop_id'] = $shopId;
|
||||
$orderItem = BusinessOrder::query()->where('shop_id', $shopId)
|
||||
->where('business_order_id', $orderRecord->id)
|
||||
->where('goods_id', $item['goods_id'])
|
||||
->where('sku_id', $item['sku_id'])
|
||||
->first();
|
||||
$orderItem = BusinessOrderItem::firstOrNew(['shop_id' => $shopId, 'business_order_id' => $orderRecord->id, 'goods_id' => $item['goods_id'], 'sku_id' => $item['sku_id']], $item);
|
||||
$num = 0;
|
||||
if (empty($orderItem)) {
|
||||
if (empty($orderItem->id)) {
|
||||
if ($item['cancel_status']) {
|
||||
if ($num = $item['goods_number'] - $item['already_cancel_number']) {
|
||||
// 扣库存 $reduceNum
|
||||
@ -59,7 +56,7 @@ abstract class BusinessClient
|
||||
// 扣库存
|
||||
$num = 0 - $item['goods_number'];
|
||||
}
|
||||
$orderItem->create($item);
|
||||
$orderItem->save();
|
||||
} else {
|
||||
if ($item['cancel_status'] !== $orderItem->cancel_status) {
|
||||
if ($item['cancel_status']) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user