|
@@ -1573,7 +1573,10 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
String wareStockNumberKey = storeId + sku + prodBarcode;
|
|
|
String warehouseStockMapKey = Constants.WAREHOUSE_STOCK_MAP_KEY + "_" + storeId;
|
|
|
String redisCacheWareQuantity = JedisUtil.hget(warehouseStockMapKey, wareStockNumberKey);
|
|
|
+ // 保税仓或缓存中的保税仓库存
|
|
|
Integer wareQuantity = 0;
|
|
|
+ // 保税仓库存
|
|
|
+ Integer realWareQuantity = 0;
|
|
|
Integer exitRegionNumber = goods.getExitRegionNumber();
|
|
|
String stockNum = goods.getStockNum();
|
|
|
Integer sellVolume = Objects.isNull(goods.getSellVolume()) ? 1 : goods.getSellVolume();
|
|
@@ -1639,15 +1642,19 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
WareQueryStockResponseDTO.WareQueryStockResponseItemDTO itemDTO = items.get(0);
|
|
|
// 仓库可用库存
|
|
|
wareQuantity = itemDTO.getQuantity();
|
|
|
+ realWareQuantity = wareQuantity;
|
|
|
JedisUtil.hset(warehouseStockMapKey, wareStockNumberKey, String.valueOf(wareQuantity));
|
|
|
} else {
|
|
|
wareQuantity = Integer.parseInt(redisCacheWareQuantity);
|
|
|
+ // 如果是缓存中有该商品保税仓的库存可用数缓存,因为这个可用数已经是经过计算的,所以这里需要加上购买数
|
|
|
+ // 避免下面提示的是计算过后的库存可用数,以致于出现误解
|
|
|
+ realWareQuantity = wareQuantity + goods.getSellVolume();
|
|
|
}
|
|
|
// 保税仓库存 + 展销店库存 - 出区数 >= 购买数
|
|
|
if (!((wareQuantity + Integer.parseInt(stockNum) - exitRegionNumber) > sellVolume)) {
|
|
|
// 库存不足
|
|
|
- log.error("商品条码:【{}】,sku:【{}】,门店库存:【{}】,保税仓库存:【{}】,出区数:【{}】,该商品仓库库存不足!", prodBarcode, sku, stockNum, wareQuantity, exitRegionNumber);
|
|
|
- throw new ServiceException(String.format("商品条码:【%s】,sku:【%s】,门店库存:【%s】,保税仓库存:【%s】,出区数:【%s】,该商品仓库库存不足!", prodBarcode, sku, stockNum, wareQuantity, exitRegionNumber));
|
|
|
+ log.error("商品条码:【{}】,sku:【{}】,门店库存:【{}】,保税仓库存:【{}】,出区数:【{}】,该商品仓库库存不足!", prodBarcode, sku, stockNum, realWareQuantity, exitRegionNumber);
|
|
|
+ throw new ServiceException(String.format("商品条码:【%s】,sku:【%s】,门店库存:【%s】,保税仓库存:【%s】,出区数:【%s】,该商品仓库库存不足!", prodBarcode, sku, stockNum, realWareQuantity, exitRegionNumber));
|
|
|
} else {
|
|
|
JedisUtil.hset(warehouseStockMapKey, wareStockNumberKey, String.valueOf(wareQuantity - sellVolume));
|
|
|
}
|