mirror of
https://gitee.com/hzchunfen/erp.git
synced 2025-11-30 22:20:45 +00:00
commit
6371835479
@ -79,17 +79,11 @@ class GoodsCombinationController extends Controller
|
||||
->whereIn('id', $itemIds)
|
||||
->pluck('stock', 'id')
|
||||
->toArray();
|
||||
$stock = 0;
|
||||
$stock = [];
|
||||
foreach ($combinationGoods as $item) {
|
||||
$num = (int)($skus[$item['item_id']] / $item['item_num']);
|
||||
if (0 === $stock) {
|
||||
$stock = $num;
|
||||
continue;
|
||||
}
|
||||
if ($num < $stock) {
|
||||
$stock = $num;
|
||||
}
|
||||
$stock[] = (int)($skus[$item['item_id']] / $item['item_num']);
|
||||
}
|
||||
$stock = min($stock);
|
||||
$status = $stock ? (5 < $stock ? 1 : 2) : 0;
|
||||
if ($id = $request->input('id')) {
|
||||
$sku = GoodsSku::query()->findOrFail($id);
|
||||
|
||||
@ -55,17 +55,11 @@ class CombinationGoodsImport implements ToArray, SkipsEmptyRows, WithStartRow
|
||||
->get(['id', 'external_sku_id', 'stock'])
|
||||
->toArray();
|
||||
$skus = ArrayUtils::index($skus, 'external_sku_id');
|
||||
$stock = 0;
|
||||
$stock = [];
|
||||
foreach ($info['item'] as $item) {
|
||||
$num = (int)($skus[$item['item_code']]['stock'] / $item['item_num']);
|
||||
if (0 === $stock) {
|
||||
$stock = $num;
|
||||
continue;
|
||||
}
|
||||
if ($num < $stock) {
|
||||
$stock = $num;
|
||||
}
|
||||
$stock[] = (int)($skus[$item['item_code']]['stock'] / $item['item_num']);
|
||||
}
|
||||
$stock = min($stock);
|
||||
$status = $stock ? (5 < $stock ? 1 : 2) : 0;
|
||||
$sku = GoodsSku::query()->updateOrCreate(
|
||||
['external_sku_id' => $info['external_sku_id'], 'is_combination' => 1],
|
||||
|
||||
@ -75,17 +75,11 @@ class CombinationGoodsStockUpdateListener
|
||||
->with('goodsSkuItem:id,stock')
|
||||
->where('goods_sku_id', $goodsSkuId)
|
||||
->get();
|
||||
$stock = 0;
|
||||
$stock = [];
|
||||
foreach ($combinationGoods as $goods) {
|
||||
$num = $goods['goodsSkuItem']['stock'] / $goods['item_num'];
|
||||
if (0 === $stock) {
|
||||
$stock = $num;
|
||||
continue;
|
||||
}
|
||||
if ($num < $stock) {
|
||||
$stock = $num;
|
||||
}
|
||||
$stock[] = (int)($goods['goodsSkuItem']['stock'] / $goods['item_num']);
|
||||
}
|
||||
$stock = min($stock);
|
||||
GoodsSku::query()->where('id', $goodsSkuId)->update(['stock' => $stock]);
|
||||
$updateIds[] = $goodsSkuId;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user