fix(warehouse): 采购价必须大于0

- 在更新仓库产品库存时,增加对采购价的校验
- 如果采购价小于等于0,抛出"采购价必须大于0"的异常
This commit is contained in:
mkm 2024-11-18 15:24:01 +08:00
parent b51e352305
commit 07a4c928a1

View File

@ -48,6 +48,9 @@ class WarehouseProductLogic extends BaseLogic
if (!$storeProduct) {
throw new BusinessException('商品不存在');
}
if($storeProduct['purchase']<=0){
throw new BusinessException('采购价必须大于0,'.$params['product_id']);
}
$total_price = bcmul($after_nums, $storeProduct['purchase'], 2);
WarehouseProductStorege::update(['nums' => $after_nums, 'total_price' => $total_price], ['id' => $storege['id']]);
}