下单扣取库存
This commit is contained in:
parent
b02f92c54f
commit
47e176b45a
|
|
@ -48,4 +48,7 @@ public interface TbProductMapper {
|
||||||
|
|
||||||
@Update("update tb_product set stock_number=stock_number-#{num} WHERE id=#{id} and stock_number-#{num} > 0")
|
@Update("update tb_product set stock_number=stock_number-#{num} WHERE id=#{id} and stock_number-#{num} > 0")
|
||||||
int decrStock(String id, int num);
|
int decrStock(String id, int num);
|
||||||
|
|
||||||
|
@Update("update tb_product set stock_number=stock_number-#{num} WHERE id=#{id}")
|
||||||
|
int decrStockUnCheck(String id, int num);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,4 +46,7 @@ public interface TbProductSkuMapper {
|
||||||
|
|
||||||
@Update("update tb_product_sku set stock_number=stock_number-#{num} WHERE id=#{id} and stock_number-#{num} > 0")
|
@Update("update tb_product_sku set stock_number=stock_number-#{num} WHERE id=#{id} and stock_number-#{num} > 0")
|
||||||
int decrStock(String id, int num);
|
int decrStock(String id, int num);
|
||||||
|
|
||||||
|
@Update("update tb_product_sku set stock_number=stock_number-#{num} WHERE id=#{id} ")
|
||||||
|
int decrStockUnCheck(String id, int num);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -136,13 +136,21 @@ public class ProductService {
|
||||||
public void decrStock(String productId, String skuId, int decrNum) {
|
public void decrStock(String productId, String skuId, int decrNum) {
|
||||||
TbProductWithBLOBs product = tbProductMapper.selectByPrimaryKey(Integer.valueOf(productId));
|
TbProductWithBLOBs product = tbProductMapper.selectByPrimaryKey(Integer.valueOf(productId));
|
||||||
if (product.getIsDistribute() == 1) {
|
if (product.getIsDistribute() == 1) {
|
||||||
|
if (product.getIsStock() == 1) {
|
||||||
if (tbProductMapper.decrStock(productId, decrNum) < 1) {
|
if (tbProductMapper.decrStock(productId, decrNum) < 1) {
|
||||||
throw new MsgException("库存不足,下单失败");
|
throw new MsgException("库存不足,下单失败");
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
|
tbProductMapper.decrStockUnCheck(productId, decrNum);
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
if (product.getIsStock() == 1) {
|
||||||
if (tbProductSkuMapper.decrStock(String.valueOf(skuId), decrNum) < 1) {
|
if (tbProductSkuMapper.decrStock(String.valueOf(skuId), decrNum) < 1) {
|
||||||
throw new MsgException("库存不足,下单失败");
|
throw new MsgException("库存不足,下单失败");
|
||||||
}
|
}
|
||||||
|
}else {
|
||||||
|
tbProductSkuMapper.decrStockUnCheck(String.valueOf(skuId), decrNum);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue