|
|
@@ -728,10 +728,14 @@ public class VoyageApiImpl implements VoyageApi {
|
|
|
Long voyageId = voyageStockLogDO.getVoyageId();
|
|
|
// 获取航次总库存
|
|
|
VoyageStockDO stockDO = voyageStockMapper.selectById(voyageId);
|
|
|
+ log.info("初定还库存操作-当前航次:{}",stockDO.getVoyageName());
|
|
|
+ log.info("初定还库存操作-当前航次退回库存前库存:{}",JSONObject.toJSONString(stockDO));
|
|
|
//还航次总库存
|
|
|
BigDecimal totalNum = voyageStockLogDO.getVirtualNum().add(voyageStockLogDO.getRealNum());
|
|
|
+ log.info("初定还库存操作-还航次总库存:{}",totalNum);
|
|
|
//退回共享库存
|
|
|
if (voyageStockLogDO.getStockType() != null && voyageStockLogDO.getStockType() == 1) {
|
|
|
+ log.info("初定还库存操作-退回共享库存:{}",voyageStockLogDO.getShareNum());
|
|
|
stockDO.setShareNum(stockDO.getShareNum().add(voyageStockLogDO.getShareNum()));
|
|
|
}
|
|
|
//退回虚拟库存
|
|
|
@@ -742,6 +746,7 @@ public class VoyageApiImpl implements VoyageApi {
|
|
|
stockDO.setCanSellNum(stockDO.getCanSellNum().add(totalNum));
|
|
|
// 减去已预订数量
|
|
|
stockDO.setBookNum(stockDO.getBookNum().subtract(totalNum));
|
|
|
+ log.info("初定还库存操作-当前航次退回库存后库存:{}",JSONObject.toJSONString(stockDO));
|
|
|
//更新航次总库存
|
|
|
voyageStockMapper.updateById(stockDO);
|
|
|
productRedisUtils.set(ProductRedisKeyConstants.STOCK_TOTAL_REDIS_KEY_PREFIX + voyageId + "_" + uuid, stockDO);
|
|
|
@@ -767,7 +772,7 @@ public class VoyageApiImpl implements VoyageApi {
|
|
|
Map<String, BigDecimal> virtualNumMap = CollectionUtils.convertMap(detailLogList, item -> item.getRoomModelId() + "_" + item.getFloor(), VoyageStockDetailLogDO::getVirtualNum);
|
|
|
// Map<String, BigDecimal> shareNumMap = CollectionUtils.convertMap(detailLogList, item -> item.getRoomModelId() + "_" + item.getFloor(), VoyageStockDetailLogDO::getShareNum);
|
|
|
Map<String, BigDecimal> totalNumMap = CollectionUtils.convertMap(detailLogList, item -> item.getRoomModelId() + "_" + item.getFloor(), item -> item.getRealNum().add(item.getVirtualNum()));
|
|
|
-
|
|
|
+ log.info("进入初定还库存详情操作,退还前库存详情-stockDetailList:{}", JSONArray.toJSONString(stockDetailList));
|
|
|
stockDetailList.forEach(item -> {
|
|
|
String key = item.getRoomModelId() + "_" + item.getFloor();
|
|
|
BigDecimal totalNum = MapUtils.getBigDecimal(totalNumMap, key);
|
|
|
@@ -782,6 +787,7 @@ public class VoyageApiImpl implements VoyageApi {
|
|
|
item.setShareNum(item.getShareNum().add(totalNum));
|
|
|
}
|
|
|
});
|
|
|
+ log.info("进入初定还库存详情操作,退还后库存详情-stockDetailList:{}", JSONArray.toJSONString(stockDetailList));
|
|
|
voyageStockDetailMapper.updateBatch(stockDetailList);
|
|
|
productRedisUtils.set(ProductRedisKeyConstants.STOCK_DETAIL_REDIS_KEY_PREFIX + voyageId + "_" + uuid, stockDetailList);
|
|
|
|
|
|
@@ -842,6 +848,7 @@ public class VoyageApiImpl implements VoyageApi {
|
|
|
Long storeId = reqDTO.getStoreId();
|
|
|
//总共使用房间数量
|
|
|
BigDecimal totalUseNum = reqDTO.getUseRoomNum()==null?BigDecimal.ZERO:reqDTO.getUseRoomNum();
|
|
|
+ log.info("进入初定扣库存操作-总共使用房间数量:{}", totalUseNum);
|
|
|
Long orderId = reqDTO.getOrderId();
|
|
|
Integer orderStatus = reqDTO.getOrderStatus();
|
|
|
|
|
|
@@ -858,6 +865,7 @@ public class VoyageApiImpl implements VoyageApi {
|
|
|
if (stockDO == null) {
|
|
|
stockDO = voyageStockMapper.selectById(voyageId);
|
|
|
}
|
|
|
+ log.info("进入初定扣库存操作-扣减前航次总库存:{}", JSONObject.toJSONString(stockDO));
|
|
|
if (stockDO == null) {
|
|
|
throw exception(VOYAGE_NO_STOCK);
|
|
|
}
|
|
|
@@ -869,6 +877,7 @@ public class VoyageApiImpl implements VoyageApi {
|
|
|
if (CollectionUtils.isAnyEmpty(stockDetailList)) {
|
|
|
stockDetailList = voyageStockDetailMapper.selectListByVoyageId(voyageId);
|
|
|
}
|
|
|
+ log.info("进入初定扣库存操作-扣减前航次库存详情:{}", JSONObject.toJSONString(stockDetailList));
|
|
|
//判断分销商库存是否存在
|
|
|
VoyageStockDistributeNewDetailReqVO detailReqVO = new VoyageStockDistributeNewDetailReqVO();
|
|
|
detailReqVO.setVoyageId(voyageId);
|
|
|
@@ -880,6 +889,7 @@ public class VoyageApiImpl implements VoyageApi {
|
|
|
if (CollectionUtils.isAnyEmpty(distributeNewRespList)) {
|
|
|
distributeNewRespList = voyageStockDistributeNewService.getDetail(detailReqVO);
|
|
|
}
|
|
|
+ log.info("进入初定扣库存操作-扣减前分销商航次库存详情:{}", JSONObject.toJSONString(distributeNewRespList));
|
|
|
//订单使用房间详情
|
|
|
List<OrderRoomUseDTO> orderRoomList = reqDTO.getOrderRoomList();
|
|
|
Map<String, BigDecimal> roomModelFloorNumMap = orderRoomList.stream()
|
|
|
@@ -890,8 +900,10 @@ public class VoyageApiImpl implements VoyageApi {
|
|
|
));
|
|
|
//分销商未分配库存,扣共享库存
|
|
|
if (CollectionUtils.isAnyEmpty(distributeNewRespList)) {
|
|
|
+ log.info("进入初定扣库存操作-分销商未分配库存,扣减共享库存");
|
|
|
//1共享库存
|
|
|
voyageStockLogDO.setStockType(1);
|
|
|
+ log.info("进入初定扣库存操作-分销商未分配库存,扣减共享库存-共享库存数:{},使用房间数:{}",shareNum,totalUseNum);
|
|
|
//判断共享库存是否充足
|
|
|
if (shareNum.compareTo(totalUseNum) < 0) {
|
|
|
log.error("{}", String.format(VOYAGE_SHARE_STOCK_NOT_ENOUGH.getMsg(), shareNum, totalUseNum));
|
|
|
@@ -911,6 +923,7 @@ public class VoyageApiImpl implements VoyageApi {
|
|
|
if (useNum == null) {
|
|
|
useNum = BigDecimal.ZERO;
|
|
|
}
|
|
|
+ log.info("进入初定扣库存操作-分销商未分配库存,扣减共享库存-房型:{},楼层:{},共享库存数:{},使用房间数:{}",item.getRoomModelName(),item.getFloor(),detailShareNum,useNum);
|
|
|
if (detailShareNum.compareTo(useNum) < 0) {
|
|
|
log.error("{}", String.format(VOYAGE_SHARE_ROOM_NOT_ENOUGH.getMsg(), item.getRoomModelName(), item.getFloor(), detailShareNum, useNum));
|
|
|
throw exception0(VOYAGE_SHARE_ROOM_NOT_ENOUGH.getCode(), String.format(VOYAGE_SHARE_ROOM_NOT_ENOUGH.getMsg(), item.getRoomModelName(), item.getFloor(), detailShareNum, useNum));
|
|
|
@@ -968,6 +981,7 @@ public class VoyageApiImpl implements VoyageApi {
|
|
|
detailLogList.add(voyageStockDetailLogDO);
|
|
|
|
|
|
});
|
|
|
+ log.info("进入初定扣库存操作-分销商未分配库存,扣减共享库存-扣减后航次库存详情:{}",JSONObject.toJSONString(stockDetailList));
|
|
|
voyageStockDetailMapper.updateBatch(stockDetailList);
|
|
|
|
|
|
// 扣总库存
|
|
|
@@ -998,8 +1012,10 @@ public class VoyageApiImpl implements VoyageApi {
|
|
|
// 扣共享库存
|
|
|
stockDO.setShareNum(stockDO.getShareNum().subtract(totalUseNum));
|
|
|
voyageStockLogDO.setShareNum(totalUseNum);
|
|
|
+ log.info("进入初定扣库存操作-分销商未分配库存,扣减共享库存-扣减后航次总库存:{}",JSONObject.toJSONString(stockDO));
|
|
|
voyageStockMapper.updateById(stockDO);
|
|
|
} else {
|
|
|
+ log.info("进入初定扣库存操作-分销商已分配库存,扣减分销商库存");
|
|
|
//2分销商库存
|
|
|
voyageStockLogDO.setStockType(2);
|
|
|
//分销商已分配库存,扣自身库存
|
|
|
@@ -1011,6 +1027,7 @@ public class VoyageApiImpl implements VoyageApi {
|
|
|
if (useNum == null) {
|
|
|
useNum = BigDecimal.ZERO;
|
|
|
}
|
|
|
+ log.info("进入初定扣库存操作-分销商已分配库存,扣减分销商库存-房型:{},楼层:{},分销商库存:{},使用房间数:{}",item.getRoomModelName(),item.getFloor(),canSellNum,useNum);
|
|
|
if (canSellNum.compareTo(useNum) < 0) {
|
|
|
log.error("{}", String.format(VOYAGE_DISTRIBUTOR_ROOM_NOT_ENOUGH.getMsg(), item.getRoomModelName(), item.getFloor(), canSellNum, useNum));
|
|
|
throw exception0(VOYAGE_DISTRIBUTOR_ROOM_NOT_ENOUGH.getCode(), String.format(VOYAGE_DISTRIBUTOR_ROOM_NOT_ENOUGH.getMsg(), item.getRoomModelName(), item.getFloor(), canSellNum, useNum));
|
|
|
@@ -1033,7 +1050,7 @@ public class VoyageApiImpl implements VoyageApi {
|
|
|
item.setBookNum(useNum);
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
+ log.info("进入初定扣库存操作-分销商已分配库存,扣减分销商库存-扣减后分销商航次库存详情:{}",JSONObject.toJSONString(list));
|
|
|
voyageStockDistributeNewMapper.updateBatch(list);
|
|
|
|
|
|
// 库存充足,扣库存详情
|
|
|
@@ -1088,6 +1105,7 @@ public class VoyageApiImpl implements VoyageApi {
|
|
|
detailLogList.add(voyageStockDetailLogDO);
|
|
|
|
|
|
});
|
|
|
+ log.info("进入初定扣库存操作-分销商已分配库存,扣减分销商库存-扣减后航次库存详情:{}",JSONObject.toJSONString(stockDetailList));
|
|
|
voyageStockDetailMapper.updateBatch(stockDetailList);
|
|
|
|
|
|
// 扣总库存
|
|
|
@@ -1119,6 +1137,7 @@ public class VoyageApiImpl implements VoyageApi {
|
|
|
stockDO.setBookNum(stockDO.getBookNum().add(totalUseNum));
|
|
|
// 扣共享库存,此处为分销商库存,不扣共享库存
|
|
|
voyageStockLogDO.setShareNum(BigDecimal.ZERO);
|
|
|
+ log.info("进入初定扣库存操作-分销商已分配库存,扣减分销商库存-扣减后航次总库存:{}",JSONObject.toJSONString(stockDO));
|
|
|
voyageStockMapper.updateById(stockDO);
|
|
|
}
|
|
|
// 添加房间使用记录
|