下单扣取库存

This commit is contained in:
2024-07-04 17:00:33 +08:00
parent b02f92c54f
commit 47e176b45a
3 changed files with 18 additions and 4 deletions

View File

@@ -136,12 +136,20 @@ public class ProductService {
public void decrStock(String productId, String skuId, int decrNum) {
TbProductWithBLOBs product = tbProductMapper.selectByPrimaryKey(Integer.valueOf(productId));
if (product.getIsDistribute() == 1) {
if (tbProductMapper.decrStock(productId, decrNum) < 1) {
throw new MsgException("库存不足,下单失败");
if (product.getIsStock() == 1) {
if (tbProductMapper.decrStock(productId, decrNum) < 1) {
throw new MsgException("库存不足,下单失败");
}
}else {
tbProductMapper.decrStockUnCheck(productId, decrNum);
}
}else {
if (tbProductSkuMapper.decrStock(String.valueOf(skuId), decrNum) < 1) {
throw new MsgException("库存不足,下单失败");
if (product.getIsStock() == 1) {
if (tbProductSkuMapper.decrStock(String.valueOf(skuId), decrNum) < 1) {
throw new MsgException("库存不足,下单失败");
}
}else {
tbProductSkuMapper.decrStockUnCheck(String.valueOf(skuId), decrNum);
}
}
}