Merge pull request 'feat(StoreProductController, WarehouseProductLists, StoreStorageSend): Update stock management logic, optimize inventory checking, adjust storage management methods' (#101) from dev into rose

Reviewed-on: #101
This commit is contained in:
mkm 2024-08-04 17:51:17 +08:00
commit dadeb89d09

View File

@ -103,23 +103,11 @@ class StoreProductController extends BaseAdminController
$warehouse_id = $this->request->post('warehouse_id');
if (count($store_arr) == 1) {
$store_id = $store_arr[0];
foreach ($product_arr as $key => $arr) {
$nums= WarehouseProductStorege::where('warehouse_id',$warehouse_id)->where('product_id',$arr['product_id'])->value('nums');
if($nums<$arr['stock']){
return $this->fail('商品ID'.$arr['product_id'].'库存不足');
}
}
foreach ($product_arr as $key => $arr) {
Redis::send('store-storage', ['product_arr' => $arr, 'store_id' => $store_id,'stock_type'=>$stock_type, 'admin_id' => $this->adminId,'warehouse_id'=>$warehouse_id]);
}
} else {
foreach ($product_arr as $key => $arr) {
foreach ($product_arr as $key => $arr) {
$nums= WarehouseProductStorege::where('warehouse_id',$warehouse_id)->where('product_id',$arr['product_id'])->value('nums');
if($nums<$arr['stock']){
return $this->fail('商品ID'.$arr['product_id'].'库存不足');
}
}
foreach ($store_arr as $k => $store_id) {
Redis::send('store-storage', ['product_arr' => $arr, 'store_id' => $store_id,'stock_type'=>$stock_type, 'admin_id' => $this->adminId,'warehouse_id'=>$warehouse_id]);
}