27 lines
767 B
PHP
Raw Normal View History

<?php
namespace App\Services\Business\MiaoXuan;
use App\Models\BusinessOrder;
class Order
{
// 下载订单事件之后去统计 然后更新库存
public static function saveOrders(array $orders)
{
foreach ($orders as $order) {
$orderRecord = BusinessOrder::updateOrCreate(
['shop_id' => $shopId, 'order_sn' => $order['order_sn']],
$order
);
foreach ($order['sub_order_list'] as $item) {
$orderRecord = BusinessOrder::updateOrCreate(
['shop_id' => $shopId, 'business_order_id' => $orderRecord->id, 'goods_id' => $item['goods_id'], 'sku_id' => $item['sku_id']],
$item
);
}
}
}
}