修复了库存管理逻辑中的错误,优化了库存不足时的异常处理。
This commit is contained in:
parent
6e17d78d52
commit
7eaf64af41
@ -28,22 +28,22 @@ class InventoryTransferLogic extends BaseLogic
|
|||||||
*/
|
*/
|
||||||
public static function add(array $params): bool
|
public static function add(array $params): bool
|
||||||
{
|
{
|
||||||
$one_before_nums=0;
|
$one_before_nums = 0;
|
||||||
$one_after_nums=0;
|
$one_after_nums = 0;
|
||||||
$two_before_nums=0;
|
$two_before_nums = 0;
|
||||||
$two_after_nums=0;
|
$two_after_nums = 0;
|
||||||
if ($params['type'] == 1) {
|
if ($params['type'] == 1) {
|
||||||
$stock = StoreBranchProduct::where('product_id', $params['one_id'])->value('stock');
|
$stock = StoreBranchProduct::where('product_id', $params['one_id'])->value('stock');
|
||||||
$stock_two = StoreBranchProduct::where('product_id', $params['two_id'])->value('stock');
|
$stock_two = StoreBranchProduct::where('product_id', $params['two_id'])->value('stock');
|
||||||
if ($stock < $params['nums']) {
|
if ($stock < $params['nums']) {
|
||||||
self::setError('调拨数量不能大于当前库存');
|
self::setError('调拨数量不能大于当前库存');
|
||||||
return false;
|
return false;
|
||||||
}else{
|
} else {
|
||||||
$one_before_nums=$stock;
|
$one_before_nums = $stock;
|
||||||
$one_after_nums=bcsub($stock,$params['nums']);
|
$one_after_nums = bcsub($stock, $params['nums']);
|
||||||
|
|
||||||
$two_before_nums=$stock_two;
|
$two_before_nums = $stock_two;
|
||||||
$two_after_nums=bcadd($stock_two,$params['nums']);
|
$two_after_nums = bcadd($stock_two, $params['nums']);
|
||||||
}
|
}
|
||||||
} elseif ($params['type'] == 2) {
|
} elseif ($params['type'] == 2) {
|
||||||
$stock = WarehouseProductStorege::where('product_id', $params['product_id'])->where('warehouse_id', $params['one_id'])->value('nums');
|
$stock = WarehouseProductStorege::where('product_id', $params['product_id'])->where('warehouse_id', $params['one_id'])->value('nums');
|
||||||
@ -51,12 +51,12 @@ class InventoryTransferLogic extends BaseLogic
|
|||||||
if ($stock < $params['nums']) {
|
if ($stock < $params['nums']) {
|
||||||
self::setError('调拨数量不能大于当前库存');
|
self::setError('调拨数量不能大于当前库存');
|
||||||
return false;
|
return false;
|
||||||
}else{
|
} else {
|
||||||
$one_before_nums=$stock;
|
$one_before_nums = $stock;
|
||||||
$one_after_nums=bcsub($stock,$params['nums']);
|
$one_after_nums = bcsub($stock, $params['nums']);
|
||||||
|
|
||||||
$two_before_nums=$stock_two;
|
$two_before_nums = $stock_two;
|
||||||
$two_after_nums=bcadd($stock_two,$params['nums']);
|
$two_after_nums = bcadd($stock_two, $params['nums']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
@ -81,8 +81,6 @@ class InventoryTransferLogic extends BaseLogic
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @notes 编辑商品调拨
|
* @notes 编辑商品调拨
|
||||||
|
Loading…
x
Reference in New Issue
Block a user