库存校验改为共享库存校验

This commit is contained in:
2024-10-10 15:11:35 +08:00
parent 4425812590
commit 1aa729dc91

View File

@@ -895,16 +895,15 @@ public class CartService {
log.info("下单,开始校验库存预警,购物车id:{}", cart.getId());
CompletableFuture.runAsync(() -> checkWarnLineAndSendMsg(tbProduct, tbProduct1, cart.getNumber()));
log.info("开始修改库存商品id{},商品名:{}", tbProduct1.getId(), tbProduct1.getName());
// 修改库存
try {
// 首次下单扣除库存
if (StrUtil.isBlank(cart.getOrderId())) {
if (tbProduct1.getIsStock() == 1) {
productService.updateStock(tbProduct.getProductId(), tbProduct.getId(), cart.getNumber(), tbProduct1.getIsDistribute() == 1);
productService.updateStock(tbProduct.getProductId(), tbProduct.getId(), cart.getNumber(), true);
} else {
productService.updateStockAndNoCheck(tbProduct.getProductId(), tbProduct.getId(), cart.getNumber(), tbProduct1.getIsDistribute() == 1);
productService.updateStockAndNoCheck(tbProduct.getProductId(), tbProduct.getId(), cart.getNumber(), true);
}
}
@@ -914,7 +913,7 @@ public class CartService {
jsonObject1.put("msg", tbProduct1.getName() + "库存不足");
jsonObject1.put("data", new ArrayList<>());
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), tableCartKey, jsonObject.getString("userId"), true);
continue;
throw new MsgException((String) jsonObject1.get("msg"));
}
saleAmount = saleAmount.add(tbProduct.getSalePrice());
} else {