fix:修改超标原因获取逻辑

This commit is contained in:
lulz1 2024-04-19 09:33:46 +08:00
parent a1b211f311
commit ee3a7afd3a
4 changed files with 47 additions and 10 deletions

View File

@ -40,11 +40,11 @@ public class SystemAnnouncement implements Serializable {
systemAnnouncement.setPostDate(postDate);
}
if (systemAnnouncement.getExpiryDate() == null) {
systemAnnouncement.setExpiryDate(LocalDateTime.now().plusDays(15L));
systemAnnouncement.setExpiryDate(LocalDateTime.now().plusDays(30L));
} else {
LocalDateTime expiryTime = LocalDateTime.of(LocalDate.parse(dto.getExpiryDate(), DateTimeUtil.formatterDate),
LocalTime.MAX);
systemAnnouncement.setPostDate(expiryTime);
systemAnnouncement.setExpiryDate(expiryTime);
}
systemAnnouncement.setStatus("1");
systemAnnouncement.setPriority(0);

View File

@ -75,6 +75,7 @@ public class HotelOrderInfoEntity {
private String CountryName; //国家名
private String ProvinceName; //省名
private String LowPriceRCInfo; //超标原因 可能是一个对象
private String AgreementRCInfo; //超标原因 可能是一个对象
private String TPMaxPrice; //入离日期内差标
// 后续字段含义类似可根据实际情况添加注释

View File

@ -10,7 +10,9 @@ import com.chint.infrastructure.util.Digest;
import com.chint.infrastructure.util.Result;
import com.chint.interfaces.rest.ctrip.CTripOrderSearchRequest;
import com.chint.interfaces.rest.ctrip.dto.put.CTripStatusNotification;
import com.chint.interfaces.rest.ctrip.dto.search.ItineraryEntity;
import com.chint.interfaces.rest.ctrip.dto.search.SearchOrderResponse;
import com.chint.interfaces.rest.ctrip.dto.search.hotel.HotelOrderInfoEntity;
import com.chint.interfaces.rest.ctrip.tools.CTripUtils;
import com.google.gson.Gson;
import lombok.extern.slf4j.Slf4j;
@ -22,6 +24,9 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import static com.chint.infrastructure.constant.LegConstant.*;
import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_C_TRIP;
@Slf4j
@ -42,6 +47,8 @@ public class CTripNoteController {
@Autowired
private SupplierCallBackLogRepository supplierCallBackLogRepository;
private static final String NO_ETA_AVAILABLE = "暂无";
private Gson gson = new Gson();
// @PostMapping("/event")
@ -80,7 +87,7 @@ public class CTripNoteController {
String productType = cTripStatusNotification.getProductType();
if(productType.equals("Train") || productType.equals("OverseaTrain")) {
if (productType.equals("Train") || productType.equals("OverseaTrain")) {
return Result.Success("暂不接受携程火车数据回推");
}
@ -88,7 +95,7 @@ public class CTripNoteController {
String orderId = cTripStatusNotification.getOrderId();
String putCTripSign = Digest.getPutCTripStatusSign(cTripStatusNotification.getCorpId(), productType, orderStatus, orderId, C_TRIP_REQUEST_SECRET);
if (!putCTripSign.equals(cTripStatusNotification.getSign())) {
return Result.error("sign错误");
return Result.error("sign错误");
}
if (orderStatus != null && orderId != null) {
return handlerData(orderId, orderStatus, productType);
@ -102,6 +109,7 @@ public class CTripNoteController {
SupplierCallbackData.of(SUPPLIER_C_TRIP);
SearchOrderResponse response = cTripOrderSearchRequest
.searchOrderResponseByOrderId(orderId);
List<ItineraryEntity> itineraryList = response.getItineraryList();
supplierCallbackData.data(response);
OrderDetail orderDetail = supplierService.handleSupplierCallback(supplierCallbackData);
@ -112,15 +120,18 @@ public class CTripNoteController {
switch (productType) {
case "FlightInternational":
case "FlightDomestic":
command.eventType(CTripUtils.mapFlightStatus(orderStatus));
command.eventType(CTripUtils.mapFlightStatus(orderStatus))
.extension(getETAReason(response, LEG_TYPE_AIRPLANE));
break;
case "HotelMember":
case "HotelContract":
command.eventType(CTripUtils.mapHotelStatus(orderStatus));
command.eventType(CTripUtils.mapHotelStatus(orderStatus))
.extension(getETAReason(response, LEG_TYPE_HOTEL));
break;
case "Train":
case "OverseaTrain":
command.eventType(CTripUtils.mapTrainStatus(orderStatus));
command.eventType(CTripUtils.mapTrainStatus(orderStatus))
.extension(getETAReason(response, LEG_TYPE_TRAIN));
break;
case "CarPickUpInternational":
case "CarRentalDomestic":
@ -128,10 +139,35 @@ public class CTripNoteController {
case "CarPickUpDomesticNew":
case "CarCharterDomestic":
case "BusTicket":
command.eventType(CTripUtils.mapCarStatus(orderStatus));
command.eventType(CTripUtils.mapCarStatus(orderStatus))
.extension(getETAReason(response, LEG_TYPE_TAXI));
break;
}
command.sendToQueue();
return Result.Success("成功收到消息");
}
private String getETAReason(SearchOrderResponse response, Integer productType) {
ItineraryEntity itineraryEntity = response.getItineraryList().get(0);
return switch (productType) {
case LEG_TYPE_TRAIN -> NO_ETA_AVAILABLE;
case LEG_TYPE_AIRPLANE -> NO_ETA_AVAILABLE;
case LEG_TYPE_HOTEL -> {
// 确保行程实体不为空以及酒店订单信息列表不为空且有内容
if (itineraryEntity != null && itineraryEntity.getHotelOrderInfoList() != null && !itineraryEntity.getHotelOrderInfoList().isEmpty()) {
HotelOrderInfoEntity hotelOrderInfoEntity = itineraryEntity.getHotelOrderInfoList().get(0);
// 优先使用低价原因如果为空则使用协议原因
String etaReason = hotelOrderInfoEntity.getLowPriceRCInfo();
if (etaReason == null) {
etaReason = hotelOrderInfoEntity.getAgreementRCInfo();
}
yield etaReason != null ? etaReason : NO_ETA_AVAILABLE;
} else {
yield NO_ETA_AVAILABLE;
}
}
case LEG_TYPE_TAXI -> NO_ETA_AVAILABLE;
default -> NO_ETA_AVAILABLE;
};
}
}

View File

@ -244,10 +244,10 @@ public class CTripTest {
System.out.println(gson.toJson(estimate));
}
// @Test
@Test
void search() {
BaseContext.setCurrentUser(user);
SearchOrderResponse response = orderSearchRequest.searchOrderResponseByOrderId("31108053999");
SearchOrderResponse response = orderSearchRequest.searchOrderResponseByOrderId("30686209959");
System.out.println(response);
}