|
@@ -153,6 +153,11 @@ class ProductInventoryService extends Service
|
|
$stock[$key] = $value;
|
|
$stock[$key] = $value;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //仓库
|
|
|
|
+ $store_map = Storehouse::whereIn('id',array_unique(array_column($array,'storehouse_id')))
|
|
|
|
+ ->pluck('title','id')
|
|
|
|
+ ->toArray();
|
|
|
|
+
|
|
//产品字典
|
|
//产品字典
|
|
$pro = Product::whereIn('id',$product_id)
|
|
$pro = Product::whereIn('id',$product_id)
|
|
->pluck('title','id')
|
|
->pluck('title','id')
|
|
@@ -161,10 +166,13 @@ class ProductInventoryService extends Service
|
|
$tmp = explode(',',$key);
|
|
$tmp = explode(',',$key);
|
|
//产品ID
|
|
//产品ID
|
|
$product_id = $tmp[0];
|
|
$product_id = $tmp[0];
|
|
|
|
+ //仓库id
|
|
|
|
+ $storehouse_id = $tmp[1];
|
|
|
|
+ $storehouse_title = $store_map[$storehouse_id] ?? "";
|
|
//产品名称
|
|
//产品名称
|
|
$pro_title = $pro[$product_id] ?? '';
|
|
$pro_title = $pro[$product_id] ?? '';
|
|
if(! $pro_title) return [false,'异常产品数据'];
|
|
if(! $pro_title) return [false,'异常产品数据'];
|
|
- if(! isset($stock[$key])) return [false,'产品:'. $pro_title .'暂无库存'];
|
|
|
|
|
|
+ if(! isset($stock[$key])) return [false,'当前仓库' . $storehouse_title .' 的产品:'. $pro_title .'暂无库存'];
|
|
//产品库存
|
|
//产品库存
|
|
$stock_product = $stock[$key];
|
|
$stock_product = $stock[$key];
|
|
|
|
|
|
@@ -172,7 +180,7 @@ class ProductInventoryService extends Service
|
|
$save_data = $product_save[$key] ?? 0;//已保存数量
|
|
$save_data = $product_save[$key] ?? 0;//已保存数量
|
|
$tmp_lock = ($stock_product['lock_number'] > 0 ? $stock_product['lock_number'] : 0) - $save_data;
|
|
$tmp_lock = ($stock_product['lock_number'] > 0 ? $stock_product['lock_number'] : 0) - $save_data;
|
|
$number = $stock_product['number'] - ($tmp_lock > 0 ? $tmp_lock : 0);
|
|
$number = $stock_product['number'] - ($tmp_lock > 0 ? $tmp_lock : 0);
|
|
- if($value > $number) return [false, $pro_title. '数量不足,当前有效库存数量:' . $number];
|
|
|
|
|
|
+ if($value > $number) return [false, $pro_title. '数量不足,当前仓库:'. $storehouse_title . '的有效库存数量:' . $number];
|
|
}
|
|
}
|
|
|
|
|
|
return [true,''];
|
|
return [true,''];
|