调整发货导入
parent
d3a700596f
commit
ed71860457
|
|
@ -68,14 +68,6 @@ class OrderPackageService
|
|||
$package->shipping_number = $params['shipping_number'];
|
||||
//保存发货单
|
||||
$package->save();
|
||||
//保存发货单商品
|
||||
OrderPackageProduct::insert(array_map(function ($value) use ($package) {
|
||||
return array_merge($value, [
|
||||
'order_package_id' => $package->id,
|
||||
'created_at' => $package->created_at,
|
||||
'updated_at' => $package->created_at,
|
||||
]);
|
||||
}, $packageProducts));
|
||||
|
||||
if (app_settings('kuaidi100.is_use')) {
|
||||
$kuaidi100Service = new Kuaidi100Service();
|
||||
|
|
@ -83,14 +75,30 @@ class OrderPackageService
|
|||
}
|
||||
} else {
|
||||
//更新现有的包裹商品
|
||||
foreach ($packageProducts as $packageProduct) {
|
||||
OrderPackageProduct::where([
|
||||
foreach ($packageProducts as $key => $packageProduct) {
|
||||
//如果包裹商品已存在则更新
|
||||
$_package_product = OrderPackageProduct::where([
|
||||
'order_package_id'=>$package->id,
|
||||
'order_product_id'=>$packageProduct['order_product_id'],
|
||||
])->increment('quantity', $packageProduct['quantity']);
|
||||
])->first();
|
||||
if ($_package_product) {
|
||||
$_package_product->increment('quantity', $packageProduct['quantity']);
|
||||
unset($packageProducts[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//保存新增发货单商品
|
||||
if (count($packageProducts) > 0) {
|
||||
OrderPackageProduct::insert(array_map(function ($value) use ($package) {
|
||||
return array_merge($value, [
|
||||
'order_package_id' => $package->id,
|
||||
'created_at' => $package->created_at,
|
||||
'updated_at' => $package->created_at,
|
||||
]);
|
||||
}, $packageProducts));
|
||||
}
|
||||
|
||||
//更新订单状态
|
||||
if (!OrderProduct::where('order_id', $order->id)->where('remain_quantity', '>', 0)->exists()) {
|
||||
$order->update([
|
||||
|
|
|
|||
Loading…
Reference in New Issue