fix:修复酒店明细间夜问题

This commit is contained in:
lulz1 2024-07-12 13:07:22 +08:00
parent c630d51c66
commit ac5a8ed996
5 changed files with 58 additions and 31 deletions

View File

@ -1,13 +1,10 @@
package com.chint.domain.factoriy.order_detail; package com.chint.domain.factoriy.order_detail;
import com.chint.application.queryies.estimate.EstimatePrice;
import com.chint.domain.aggregates.order.*; import com.chint.domain.aggregates.order.*;
import com.chint.domain.exceptions.NotFoundException; import com.chint.domain.exceptions.NotFoundException;
import com.chint.domain.repository.OrderDetailRepository; import com.chint.domain.repository.OrderDetailRepository;
import com.chint.domain.repository.RouteRepository; import com.chint.domain.repository.RouteRepository;
import com.chint.domain.repository.RouteRequestRepository; import com.chint.infrastructure.util.DateTimeUtil;
import com.chint.domain.repository.UserRepository;
import com.chint.interfaces.rest.data_center.user.UserHttpRequest;
import com.chint.interfaces.rest.ly.dto.carorderdatapushback.PriceDetail; import com.chint.interfaces.rest.ly.dto.carorderdatapushback.PriceDetail;
import com.chint.interfaces.rest.ly.dto.hotelorderdatapushbach.Resident; import com.chint.interfaces.rest.ly.dto.hotelorderdatapushbach.Resident;
import com.chint.interfaces.rest.ly.dto.search.response.car.CarDetailResponse; import com.chint.interfaces.rest.ly.dto.search.response.car.CarDetailResponse;
@ -18,6 +15,7 @@ import com.chint.interfaces.rest.ly.tools.LYOrderUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.time.Duration;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@ -342,7 +340,17 @@ public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory {
HotelDetailResponse.HotelInfo hotelInfo = data.getHotelInfo(); HotelDetailResponse.HotelInfo hotelInfo = data.getHotelInfo();
List<HotelDetailResponse.RefundInfo> refundInfoList = data.getRefundInfoList(); List<HotelDetailResponse.RefundInfo> refundInfoList = data.getRefundInfoList();
if (hotelInfo != null && orderInfo != null) { if (hotelInfo != null && orderInfo != null) {
String originalCheckInDate = orderInfo.getOriginalCheckInDate();
String originalCheckOutDate = orderInfo.getOriginalCheckOutDate();
Long days = null;
if (originalCheckInDate != null && originalCheckOutDate != null) {
Duration duration = Duration.between(DateTimeUtil.strToTime(originalCheckInDate), DateTimeUtil.strToTime(originalCheckOutDate));
days = duration.toDays();
}
hotelOrderDetail.setOrderNo(orderInfo.getOrderSerialNo()) hotelOrderDetail.setOrderNo(orderInfo.getOrderSerialNo())
.setDetailId(orderInfo.getOrderSerialNo()) .setDetailId(orderInfo.getOrderSerialNo())
.setSupplier(SUPPLIER_L_Y_EXTENSION_NAME) .setSupplier(SUPPLIER_L_Y_EXTENSION_NAME)
@ -353,7 +361,7 @@ public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory {
.setHotelAddress(hotelInfo.getHotelAddress()) .setHotelAddress(hotelInfo.getHotelAddress())
.setCheckInDate(hotelInfo.getCheckInDate()) .setCheckInDate(hotelInfo.getCheckInDate())
.setDepartureDate(hotelInfo.getCheckOutDate()) .setDepartureDate(hotelInfo.getCheckOutDate())
.setNightCount(String.valueOf(hotelInfo.getNightNum())) .setNightCount(days == null ? String.valueOf(hotelInfo.getNightNum()) : days.toString())
.setRoomCount(String.valueOf(hotelInfo.getRoomNum())) .setRoomCount(String.valueOf(hotelInfo.getRoomNum()))
.setRoomTypeName(hotelInfo.getRoomName()) .setRoomTypeName(hotelInfo.getRoomName())
.setPreServiceFee(String.valueOf(orderInfo.getServicePrice())) .setPreServiceFee(String.valueOf(orderInfo.getServicePrice()))

View File

@ -31,6 +31,7 @@ import com.chint.interfaces.rest.ctrip.dto.search.car.CarBasicInfo;
import com.chint.interfaces.rest.ctrip.dto.search.car.CarQuickOrderInfoEntity; import com.chint.interfaces.rest.ctrip.dto.search.car.CarQuickOrderInfoEntity;
import com.chint.interfaces.rest.ctrip.dto.search.car.OrderFee; import com.chint.interfaces.rest.ctrip.dto.search.car.OrderFee;
import com.chint.interfaces.rest.ctrip.dto.search.flight.*; import com.chint.interfaces.rest.ctrip.dto.search.flight.*;
import com.chint.interfaces.rest.ctrip.dto.search.hotel.ClientInfo;
import com.chint.interfaces.rest.ctrip.dto.search.hotel.HotelOrderInfoEntity; import com.chint.interfaces.rest.ctrip.dto.search.hotel.HotelOrderInfoEntity;
import com.chint.interfaces.rest.ctrip.dto.search.hotel.RefundInfo; import com.chint.interfaces.rest.ctrip.dto.search.hotel.RefundInfo;
import com.chint.interfaces.rest.ly.dto.search.response.car.CarDetailResponse; import com.chint.interfaces.rest.ly.dto.search.response.car.CarDetailResponse;
@ -40,6 +41,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.time.Duration;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
@ -437,7 +439,8 @@ public class SupplierServiceImpl implements SupplierService {
hotelOrderInfoEntity.getOrderID(), hotelOrderInfoEntity.getOrderID(),
"-" + hotelRefundInfo.getRefundCustomerAmount(), "-" + hotelRefundInfo.getRefundCustomerAmount(),
"4", "4",
DateTimeUtil.timeToStrCommon(LocalDateTime.now())); DateTimeUtil.timeToStrCommon(LocalDateTime.now()))
.data(outOrderDetailData);
commands.add(command); commands.add(command);
} }
} }
@ -601,7 +604,7 @@ public class SupplierServiceImpl implements SupplierService {
String newOrderNo = generateNewOrderNo(command); String newOrderNo = generateNewOrderNo(command);
OrderDetail copied = getOrCreateOrderDetail(newOrderNo, orderDetail, routeOrder); OrderDetail copied = getOrCreateOrderDetail(newOrderNo, orderDetail, routeOrder);
copied.setOrderNo(newOrderNo); copied.setOrderNo(newOrderNo);
addOrderEvent(orderDetail, command.getType(), LocalDateTime.now()); addOrderEvent(copied, command.getType(), LocalDateTime.now());
copied.setPrice(command.getAmount()); copied.setPrice(command.getAmount());
copied.setCreateTime(LocalDateTime.now()); copied.setCreateTime(LocalDateTime.now());
processProductSpecificDetails(copied, command, newOrderNo); processProductSpecificDetails(copied, command, newOrderNo);
@ -704,9 +707,43 @@ public class SupplierServiceImpl implements SupplierService {
customer.setId(null); customer.setId(null);
newCustomers.add(customer); newCustomers.add(customer);
} }
LocalDateTime originCheckOutTime = null;
LocalDateTime newCheckOutTime = null;
hotelOrderDetail.setCustomers(newCustomers); hotelOrderDetail.setCustomers(newCustomers);
if (orderDetail.getSupplierName().equals(SUPPLIER_L_Y)) { if (orderDetail.getSupplierName().equals(SUPPLIER_L_Y)) {
hotelOrderDetail = supplierAdapterSelector.of(SUPPLIER_L_Y, OrderExtensionFactory.class).updateHotelOrderDetailData(hotelOrderDetail, command.getOrderInfo()); HotelDetailResponse.Data orderInfo = (HotelDetailResponse.Data) command.getOrderInfo();
hotelOrderDetail = supplierAdapterSelector.of(SUPPLIER_L_Y, OrderExtensionFactory.class)
.updateHotelOrderDetailData(hotelOrderDetail, orderInfo);
List<HotelDetailResponse.Room> roomList = orderInfo.getRoomList();
if (roomList != null && roomList.size() > 1) {
HotelDetailResponse.Room originRoomProduct = roomList.get(0);
HotelDetailResponse.Room newRoomProduct = roomList.get(1);
originCheckOutTime = DateTimeUtil.strToTime(originRoomProduct.getCheckOutDate());
newCheckOutTime = DateTimeUtil.strToTime(newRoomProduct.getCheckOutDate());
}
}
if (orderDetail.getSupplierName().equals(SUPPLIER_C_TRIP)) {
SearchOrderResponse orderInfo =(SearchOrderResponse) command.getOrderInfo();
List<ItineraryEntity> itineraryList = orderInfo.getItineraryList();
if(itineraryList!=null && !itineraryList.isEmpty()){
List<HotelOrderInfoEntity> hotelOrderInfoList = itineraryList.get(0).getHotelOrderInfoList();
if(hotelOrderInfoList != null && !hotelOrderInfoList.isEmpty()){
HotelOrderInfoEntity hotelOrderInfoEntity = hotelOrderInfoList.get(0);
originCheckOutTime = DateTimeUtil.strToTime(hotelOrderInfoEntity.getEndTime());
List<ClientInfo> clientInfoList = hotelOrderInfoEntity.getClientInfo();
if(clientInfoList != null && !clientInfoList.isEmpty()){
ClientInfo clientInfo = clientInfoList.get(0);
if(clientInfo != null && clientInfo.getActualDepartureTime() != null){
newCheckOutTime = DateTimeUtil.strToTime(clientInfo.getActualDepartureTime());
}
}
}
}
}
if (originCheckOutTime != null && newCheckOutTime != null) {
Duration duration = Duration.between(newCheckOutTime, originCheckOutTime);
long days = duration.toDays();
hotelOrderDetail.setNightCount("-" + days);
} }
hotelOrderDetail.setDetailId(newOrderNo); hotelOrderDetail.setDetailId(newOrderNo);
orderDetail.setHotelOrderDetail(hotelOrderDetail); orderDetail.setHotelOrderDetail(hotelOrderDetail);

View File

@ -92,27 +92,6 @@ public class LYETAController {
supplierCallbackData.subNotifyType(String.valueOf(subNotifyType)).notifyType(L_Y_NOTIFY_ETA); supplierCallbackData.subNotifyType(String.valueOf(subNotifyType)).notifyType(L_Y_NOTIFY_ETA);
OrderDetail orderDetail = supplierService.handleSupplierCallback(supplierCallbackData); OrderDetail orderDetail = supplierService.handleSupplierCallback(supplierCallbackData);
orderTravelRepository.save(OrderTravel.of(orderDetail.getOrderNo(), approvalOrderId)); orderTravelRepository.save(OrderTravel.of(orderDetail.getOrderNo(), approvalOrderId));
// if (supplierCallbackData.getExtension() != null) {
// //发送超标事件
// Command.of(OrderStatusChangeCommand.class)
// .orderDetail(orderDetail)
// .outStatus("超标")
// .extension(supplierCallbackData.getExtension())
// .eventType(ORDER_EVENT_ETA)
// .orderNo(orderDetail.getOrderNo())
// .sendToQueue();
// }
//
// if (subNotifyType == 2 || subNotifyType == 4 || subNotifyType == 6) {
// //如果推送类是2,4,6还要触发改签事件
// Command.of(OrderStatusChangeCommand.class)
// .orderDetail(orderDetail)
// .outStatus("改签")
// .extension(supplierCallbackData.getExtension())
// .eventType(ORDER_EVENT_CHANGE)
// .orderNo(orderDetail.getOrderNo())
// .sendToQueue();
// }
} }
} catch (Exception e) { } catch (Exception e) {
//如果推送异常将异常信息保存到数据库 //如果推送异常将异常信息保存到数据库

View File

@ -829,7 +829,7 @@ public class LYTest {
@Test @Test
void searchHotel() { void searchHotel() {
HotelDetailResponse hotelOrderDetail = lySearchRequest.getHotelOrderDetail("HO20240415140900363081"); HotelDetailResponse hotelOrderDetail = lySearchRequest.getHotelOrderDetail("HO20240409171200880790");
Gson gson = new Gson(); Gson gson = new Gson();
String json = gson.toJson(hotelOrderDetail); String json = gson.toJson(hotelOrderDetail);
System.out.println(json); System.out.println(json);

View File

@ -1242,7 +1242,8 @@ class RouteApplicationTests {
@Test @Test
void deleteByOrderId() { void deleteByOrderId() {
orderDetailRepository.deleteById(3138L); orderDetailRepository.deleteById(3181L);
orderDetailRepository.deleteById(3180L);
} }
// @Test // @Test
@ -1556,4 +1557,6 @@ class RouteApplicationTests {
System.out.println(parts[5]); System.out.println(parts[5]);
} }
} }
} }