|
@@ -156,6 +156,12 @@ public class PolicyServiceImpl implements PolicyService {
|
|
|
public List<PolicyRespVO> getUsablePolicyByVoyageId(Long voyageId, Long orderId) {
|
|
public List<PolicyRespVO> getUsablePolicyByVoyageId(Long voyageId, Long orderId) {
|
|
|
List<OrderPolicyDTO> orderPolicyList = tradeApi.getOrderPolicyList(orderId);
|
|
List<OrderPolicyDTO> orderPolicyList = tradeApi.getOrderPolicyList(orderId);
|
|
|
List<Long> orderPolicyIds = CollectionUtils.convertList(orderPolicyList, OrderPolicyDTO::getPolicyId);
|
|
List<Long> orderPolicyIds = CollectionUtils.convertList(orderPolicyList, OrderPolicyDTO::getPolicyId);
|
|
|
|
|
+ Map<Long, BigDecimal> orderPolicyUseNumMap = orderPolicyList.stream()
|
|
|
|
|
+ .filter(item -> item.getPolicyId() != null)
|
|
|
|
|
+ .collect(Collectors.toMap(OrderPolicyDTO::getPolicyId,
|
|
|
|
|
+ item -> item.getPreUseNum() != null ? item.getPreUseNum()
|
|
|
|
|
+ : Optional.ofNullable(item.getRealUseNum()).orElse(BigDecimal.ZERO),
|
|
|
|
|
+ BigDecimal::add));
|
|
|
VoyageDO voyage = voyageService.getVoyage(voyageId);
|
|
VoyageDO voyage = voyageService.getVoyage(voyageId);
|
|
|
LocalDateTime boardingTime = voyage.getBoardingTime();
|
|
LocalDateTime boardingTime = voyage.getBoardingTime();
|
|
|
List<PolicyDetailDO> policyDetails = policyDetailMapper.selectListByVoyageId(voyageId);
|
|
List<PolicyDetailDO> policyDetails = policyDetailMapper.selectListByVoyageId(voyageId);
|
|
@@ -179,7 +185,8 @@ public class PolicyServiceImpl implements PolicyService {
|
|
|
List<Integer> countryIds = CollectionUtils.convertList(areaCountryListByAreaIds, AreaCountryDTO::getCountryId);
|
|
List<Integer> countryIds = CollectionUtils.convertList(areaCountryListByAreaIds, AreaCountryDTO::getCountryId);
|
|
|
policyRespVO.setCountryIds(countryIds);
|
|
policyRespVO.setCountryIds(countryIds);
|
|
|
policyRespVO.setRoomModelIds(policyDetailDO.getRoomModelIds());
|
|
policyRespVO.setRoomModelIds(policyDetailDO.getRoomModelIds());
|
|
|
- policyRespVO.setSurplusNum(policyDetailDO.getSurplusNum());
|
|
|
|
|
|
|
+ policyRespVO.setSurplusNum(policyDetailDO.getSurplusNum().add(
|
|
|
|
|
+ orderPolicyUseNumMap.getOrDefault(policyRespVO.getId(), BigDecimal.ZERO)));
|
|
|
}
|
|
}
|
|
|
if(Objects.equals(policyRespVO.getStatus(), CommonStatusEnum.DISABLE.getStatus())) {
|
|
if(Objects.equals(policyRespVO.getStatus(), CommonStatusEnum.DISABLE.getStatus())) {
|
|
|
policyRespVO.setCanAddRoom(false);
|
|
policyRespVO.setCanAddRoom(false);
|
|
@@ -207,4 +214,4 @@ public class PolicyServiceImpl implements PolicyService {
|
|
|
return policyMapper.selectList(policyIds);
|
|
return policyMapper.selectList(policyIds);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-}
|
|
|
|
|
|
|
+}
|