同步机票退款代码

This commit is contained in:
lulz1 2024-03-14 20:54:08 +08:00
parent a321c011c4
commit 255a59639e
2 changed files with 43 additions and 1 deletions

View File

@ -107,6 +107,9 @@ public class OrderDetailController {
}
RouteOrder routeOrder = routeRepository.queryById(orderDetail.getRouteId());
if(routeOrder.getOrderDetails().stream().map(OrderDetail::getOrderNo).toList().contains(newOrderNo)){
return;
}
Integer productType = orderDetail.getProductType();
orderDetail.setOrderId(null);
orderDetail.setOrderNo(newOrderNo);
@ -115,6 +118,7 @@ public class OrderDetailController {
orderEvent.setHappenTime(LocalDateTime.now());
orderEvent.setOutStatus(orderEvent.translateOrderEvent(Integer.parseInt(type)));
orderDetail.setOrderEventList(List.of(orderEvent));
orderDetail.setPrice(command.getAmount());
if (productType == 0) {
TrainOrderDetail trainOrderDetail = orderDetail.getTrainOrderDetail();
trainOrderDetail.setOrderAmount(command.getAmount());

View File

@ -25,6 +25,7 @@ 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.flight.ChangeInfo;
import com.chint.interfaces.rest.ctrip.dto.search.flight.FlightOrderInfoEntity;
import com.chint.interfaces.rest.ctrip.dto.search.flight.FlightRefundInfo;
import com.chint.interfaces.rest.user.UserHttpRequest;
import jakarta.annotation.PostConstruct;
import lombok.extern.slf4j.Slf4j;
@ -87,6 +88,7 @@ public class OrderDomainService {
@Autowired
private CTripOrderSearchRequest cTripOrderSearchRequest;
private Set<String> companyBlackList = new HashSet<>();
public RouteOrder saveOrder(RouteOrder routeOrder) {
@ -198,8 +200,13 @@ public class OrderDomainService {
.extensionData(orderDetail)
.reason(command.getExtension())
.sendToQueue();
}
if (orderDetail.getProductType().equals(LEG_TYPE_AIRPLANE)) {
generateRefundAndChangeOrder(orderDetail.getOrderNo());
}
}
}
@ListenTo(command = "BPMAuditCommand", order = 0)
@ -353,4 +360,35 @@ public class OrderDomainService {
}
return false;
}
private void generateRefundAndChangeOrder(String orderNo) {
SearchOrderResponse response = cTripOrderSearchRequest.searchOrderResponseByOrderId(orderNo);
FlightOrderInfoEntity flightOrderInfoEntity = response.getItineraryList().get(0).getFlightOrderInfoList().get(0);
List<FlightRefundInfo> refundInfo = flightOrderInfoEntity.getRefundInfo();
if (refundInfo != null && !refundInfo.isEmpty()) {
for (FlightRefundInfo flightRefundInfo : refundInfo) {
if (flightRefundInfo.getRefundStatus().equals("D")) {
Command.of(CTripOrderRefundCommand.class).Info(String.valueOf(flightRefundInfo.getRefundOrderID()),
flightOrderInfoEntity.getBasicInfo().getOrderID(),
"-" + flightRefundInfo.getPayCustomerAmount(),
"4",
flightRefundInfo.getRefundAplyTime()).sendToQueue();
}
}
}
List<ChangeInfo> changeInfo = flightOrderInfoEntity.getPassengerInfo().get(0).getSequenceInfo().get(0).getChangeInfo();
if (changeInfo != null && !changeInfo.isEmpty()) {
for (ChangeInfo info : changeInfo) {
if (info.getCStatus().equals("改签成功")) {
Command.of(CTripOrderRefundCommand.class).Info(
String.valueOf(info.getRebookId()),
flightOrderInfoEntity.getBasicInfo().getOrderID(),
String.valueOf(info.getCFee()),
"3",
info.getRebookedTime()
).sendToQueue();
}
}
}
}
}