|
@@ -307,7 +307,7 @@ public class VoyageApiImpl implements VoyageApi {
|
|
|
Collectors.mapping(OrderRoomUseDTO::getNum, Collectors.reducing(BigDecimal.ZERO, BigDecimal::add)) // 直接使用BigDecimal的reduce操作进行求和
|
|
Collectors.mapping(OrderRoomUseDTO::getNum, Collectors.reducing(BigDecimal.ZERO, BigDecimal::add)) // 直接使用BigDecimal的reduce操作进行求和
|
|
|
));
|
|
));
|
|
|
//分销商未分配库存,扣共享库存
|
|
//分销商未分配库存,扣共享库存
|
|
|
- if (distributeNewResps.isEmpty()) {
|
|
|
|
|
|
|
+ if (CollectionUtils.isAnyEmpty(distributeNewResps)) {
|
|
|
//1共享库存
|
|
//1共享库存
|
|
|
voyageStockLogDO.setStockType(1);
|
|
voyageStockLogDO.setStockType(1);
|
|
|
//判断共享库存是否充足
|
|
//判断共享库存是否充足
|
|
@@ -569,6 +569,7 @@ public class VoyageApiImpl implements VoyageApi {
|
|
|
Long distributorId = voyageStockLogDO.getDistributorId();
|
|
Long distributorId = voyageStockLogDO.getDistributorId();
|
|
|
//找到初定时扣库存详情的记录
|
|
//找到初定时扣库存详情的记录
|
|
|
List<VoyageStockDetailLogDO> detailLogList = voyageStockDetailLogMapper.selectListByOrder(orderId, TradeOrderStatusEnum.YD.getStatus());
|
|
List<VoyageStockDetailLogDO> detailLogList = voyageStockDetailLogMapper.selectListByOrder(orderId, TradeOrderStatusEnum.YD.getStatus());
|
|
|
|
|
+ Integer stockType = detailLogList.get(0).getStockType();
|
|
|
if (detailLogList != null && !detailLogList.isEmpty()) {
|
|
if (detailLogList != null && !detailLogList.isEmpty()) {
|
|
|
//退还航次库存详情
|
|
//退还航次库存详情
|
|
|
List<VoyageStockDetailDO> stockDetailList = voyageStockDetailMapper.selectListByVoyageId(voyageId);
|
|
List<VoyageStockDetailDO> stockDetailList = voyageStockDetailMapper.selectListByVoyageId(voyageId);
|
|
@@ -583,10 +584,13 @@ public class VoyageApiImpl implements VoyageApi {
|
|
|
item.setCanSellNum(item.getCanSellNum().add(totalNumMap.get(key)));
|
|
item.setCanSellNum(item.getCanSellNum().add(totalNumMap.get(key)));
|
|
|
item.setRealTotalNum(item.getRealTotalNum().add(realNumMap.get(key)));
|
|
item.setRealTotalNum(item.getRealTotalNum().add(realNumMap.get(key)));
|
|
|
item.setVirtualNum(item.getVirtualNum().add(virtualNumMap.get(key)));
|
|
item.setVirtualNum(item.getVirtualNum().add(virtualNumMap.get(key)));
|
|
|
|
|
+ if(stockType == 1) {//共享库存要还回库存详情
|
|
|
|
|
+ item.setShareNum(item.getShareNum().add(totalNumMap.get(key)));
|
|
|
|
|
+ }
|
|
|
});
|
|
});
|
|
|
voyageStockDetailMapper.updateBatch(stockDetailList);
|
|
voyageStockDetailMapper.updateBatch(stockDetailList);
|
|
|
|
|
|
|
|
- Integer stockType = detailLogList.get(0).getStockType();
|
|
|
|
|
|
|
+
|
|
|
//2:还分销商库存
|
|
//2:还分销商库存
|
|
|
if (stockType == 2) {
|
|
if (stockType == 2) {
|
|
|
//判断分销商库存是否存在
|
|
//判断分销商库存是否存在
|
|
@@ -680,7 +684,7 @@ public class VoyageApiImpl implements VoyageApi {
|
|
|
Collectors.mapping(OrderRoomUseDTO::getNum, Collectors.reducing(BigDecimal.ZERO, BigDecimal::add))
|
|
Collectors.mapping(OrderRoomUseDTO::getNum, Collectors.reducing(BigDecimal.ZERO, BigDecimal::add))
|
|
|
));
|
|
));
|
|
|
//分销商未分配库存,扣共享库存
|
|
//分销商未分配库存,扣共享库存
|
|
|
- if (distributeNewRespList.isEmpty()) {
|
|
|
|
|
|
|
+ if (CollectionUtils.isAnyEmpty(distributeNewRespList)) {
|
|
|
//1共享库存
|
|
//1共享库存
|
|
|
voyageStockLogDO.setStockType(1);
|
|
voyageStockLogDO.setStockType(1);
|
|
|
//判断共享库存是否充足
|
|
//判断共享库存是否充足
|
|
@@ -690,12 +694,14 @@ public class VoyageApiImpl implements VoyageApi {
|
|
|
//判断航次房型楼层库存是否充足
|
|
//判断航次房型楼层库存是否充足
|
|
|
// 判断库存是否充足
|
|
// 判断库存是否充足
|
|
|
stockDetailList.forEach(item -> {
|
|
stockDetailList.forEach(item -> {
|
|
|
- BigDecimal canSellNum = item.getCanSellNum();
|
|
|
|
|
|
|
+ //这个地方使用共享库存,不使用可销售数
|
|
|
|
|
+// BigDecimal canSellNum = item.getCanSellNum();
|
|
|
|
|
+ BigDecimal detailShareNum = item.getShareNum();
|
|
|
BigDecimal useNum = roomModelFloorNumMap.get(item.getRoomModelId() + "_" + item.getFloor());
|
|
BigDecimal useNum = roomModelFloorNumMap.get(item.getRoomModelId() + "_" + item.getFloor());
|
|
|
if (useNum == null) {
|
|
if (useNum == null) {
|
|
|
useNum = BigDecimal.ZERO;
|
|
useNum = BigDecimal.ZERO;
|
|
|
}
|
|
}
|
|
|
- if (canSellNum.compareTo(useNum) < 0) {
|
|
|
|
|
|
|
+ if (detailShareNum.compareTo(useNum) < 0) {
|
|
|
log.error(String.format(VOYAGE_SHARE_ROOM_NOT_ENOUGH.getMsg(), item.getRoomModelName(), item.getFloor()));
|
|
log.error(String.format(VOYAGE_SHARE_ROOM_NOT_ENOUGH.getMsg(), item.getRoomModelName(), item.getFloor()));
|
|
|
throw exception0(VOYAGE_SHARE_ROOM_NOT_ENOUGH.getCode(), String.format(VOYAGE_SHARE_ROOM_NOT_ENOUGH.getMsg(), item.getRoomModelName(), item.getFloor()));
|
|
throw exception0(VOYAGE_SHARE_ROOM_NOT_ENOUGH.getCode(), String.format(VOYAGE_SHARE_ROOM_NOT_ENOUGH.getMsg(), item.getRoomModelName(), item.getFloor()));
|
|
|
}
|
|
}
|
|
@@ -722,6 +728,8 @@ public class VoyageApiImpl implements VoyageApi {
|
|
|
|
|
|
|
|
// 减可售房间数
|
|
// 减可售房间数
|
|
|
item.setCanSellNum(item.getCanSellNum().subtract(useNum));
|
|
item.setCanSellNum(item.getCanSellNum().subtract(useNum));
|
|
|
|
|
+ // 减共享房间数
|
|
|
|
|
+ item.setShareNum(item.getShareNum().subtract(useNum));
|
|
|
// 减虚拟房间数,此处初定,先扣虚拟库存,虚拟库存不足再扣实际库存
|
|
// 减虚拟房间数,此处初定,先扣虚拟库存,虚拟库存不足再扣实际库存
|
|
|
if (item.getVirtualNum().compareTo(useNum) >= 0) {
|
|
if (item.getVirtualNum().compareTo(useNum) >= 0) {
|
|
|
voyageStockDetailLogDO.setVirtualNum(useNum);
|
|
voyageStockDetailLogDO.setVirtualNum(useNum);
|