完成携程按月拉去结算流水接口

This commit is contained in:
Superdandan 2024-04-01 22:13:31 +08:00
parent bc11e0a9c9
commit 814064918e
6 changed files with 136 additions and 114 deletions

View File

@ -1,10 +1,7 @@
package com.chint.application.commands; package com.chint.application.commands;
import com.chint.infrastructure.echo_framework.command.Command; import com.chint.infrastructure.echo_framework.command.Command;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@ -15,4 +12,13 @@ public class OrderRecordGenerateCommand extends Command {
//将昨天的结算数据生成为财务共享需要的数据 //将昨天的结算数据生成为财务共享需要的数据
private LocalDateTime startTime = LocalDateTime.of(LocalDate.now().minusDays(1), LocalTime.MIDNIGHT); private LocalDateTime startTime = LocalDateTime.of(LocalDate.now().minusDays(1), LocalTime.MIDNIGHT);
private LocalDateTime endTime = LocalDateTime.of(LocalDate.now().minusDays(1), LocalTime.MAX); private LocalDateTime endTime = LocalDateTime.of(LocalDate.now().minusDays(1), LocalTime.MAX);
public OrderRecordGenerateCommand startTime(LocalDateTime startTime) {
this.setStartTime(startTime);
return this;
}
public OrderRecordGenerateCommand endTime(LocalDateTime endTime) {
this.setEndTime(endTime);
return this;
}
} }

View File

@ -7,6 +7,7 @@ import com.chint.infrastructure.echo_framework.command.Command;
import com.chint.application.commands.OrderRecordGenerateCommand; import com.chint.application.commands.OrderRecordGenerateCommand;
import com.chint.domain.factoriy.order_record.LyStatementOrder; import com.chint.domain.factoriy.order_record.LyStatementOrder;
import com.chint.infrastructure.echo_framework.command.Command; import com.chint.infrastructure.echo_framework.command.Command;
import com.chint.infrastructure.util.DateTimeUtil;
import com.chint.infrastructure.util.Result; import com.chint.infrastructure.util.Result;
import com.chint.interfaces.rest.ctrip.order.CTripOrderRecordAutoSave; import com.chint.interfaces.rest.ctrip.order.CTripOrderRecordAutoSave;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@ -51,9 +52,13 @@ public class AutoWorkController {
@ApiOperation("拉取按月份的携程流水") @ApiOperation("拉取按月份的携程流水")
@PostMapping("/cTrip/record/save/month") @PostMapping("/cTrip/record/save/month")
public Result<String> autoSaveCTripRecordByMonth(@RequestBody CTripRecordMonthSaveDTO cTripRecordMonthSaveDTO) { public Result<String> autoSaveCTripRecordByMonth(@RequestBody CTripRecordMonthSaveDTO cTripRecordMonthSaveDTO) {
cTripOrderRecordAutoSave.saveAll(); String date = cTripRecordMonthSaveDTO.getDate();
cTripOrderRecordAutoSave.saveAllByDate(date);
//将昨天的结算数据生成为财务共享需要的数据 //将昨天的结算数据生成为财务共享需要的数据
Command.of(OrderRecordGenerateCommand.class).sendToQueue(); Command.of(OrderRecordGenerateCommand.class)
.startTime(DateTimeUtil.firstDayOfMonth(date))
.endTime(DateTimeUtil.endDayOfMonth(date))
.sendToQueue();
return Result.Success(SUCCESS); return Result.Success(SUCCESS);
} }

View File

@ -1,20 +1,35 @@
package com.chint.infrastructure.util; package com.chint.infrastructure.util;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.YearMonth;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
public class DateTimeUtil { public class DateTimeUtil {
private final static DateTimeFormatter formatterMM = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"); private final static DateTimeFormatter formatterMM = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS");
private final static DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); private final static DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
private final static DateTimeFormatter formatterDate = DateTimeFormatter.ofPattern("yyyy-MM-dd"); private final static DateTimeFormatter formatterDate = DateTimeFormatter.ofPattern("yyyy-MM-dd");
private final static DateTimeFormatter formatterDateYYYYMM = DateTimeFormatter.ofPattern("yyyyMM");
private final static DateTimeFormatter formatterDateYYYYMMDD = DateTimeFormatter.ofPattern("yyyyMMdd");
public static String timeToStr(LocalDateTime input) { public static String timeToStr(LocalDateTime input) {
return input.format(formatterDate); return input.format(formatterDate);
} }
public static String timeToStrYYYYMM(LocalDateTime input) {
return input.format(formatterDateYYYYMM);
}
public static DateTimeFormatter formatterDateYYYYMM() {
return formatterDateYYYYMM;
}
public static String timeToStrYYYYMMDD(LocalDateTime input) {
return input.format(formatterDateYYYYMMDD);
}
public static LocalDateTime strToTime(String input) { public static LocalDateTime strToTime(String input) {
return LocalDateTime.parse(input.substring(0, 19), formatter); return LocalDateTime.parse(input.substring(0, 19), formatter);
} }
@ -22,4 +37,20 @@ public class DateTimeUtil {
public static LocalDateTime strToTimeMM(String input) { public static LocalDateTime strToTimeMM(String input) {
return LocalDateTime.parse(input.substring(0, 23), formatterMM); return LocalDateTime.parse(input.substring(0, 23), formatterMM);
} }
public static LocalDateTime firstDayOfMonth(String input) {
// 解析年份和月份
YearMonth yearMonth = YearMonth.parse(input, formatterDateYYYYMM);
// 获取月份的第一天和最后一天
return yearMonth.atDay(1).atStartOfDay();
}
public static LocalDateTime endDayOfMonth(String input) {
// 解析年份和月份
YearMonth yearMonth = YearMonth.parse(input, formatterDateYYYYMM);
// 获取月份的第一天和最后一天
return yearMonth.atEndOfMonth().atTime(23, 59, 59);
}
} }

View File

@ -4,7 +4,7 @@ import com.chint.interfaces.rest.ctrip.dto.Authentification;
import lombok.Data; import lombok.Data;
@Data @Data
public class OrderFlightParam { public class OrderRecordParam {
private String AppKey; private String AppKey;
private String Ticket; private String Ticket;
@ -25,18 +25,18 @@ public class OrderFlightParam {
private Integer pageSize; private Integer pageSize;
private String[] subBatchNoList; private String[] subBatchNoList;
// public static OrderFlightParam of(String requestId, String locale) { // public static OrderRecordParam of(String requestId, String locale) {
// OrderFlightParam countryParam = new OrderFlightParam(); // OrderRecordParam countryParam = new OrderRecordParam();
// countryParam.requestId = requestId; // countryParam.requestId = requestId;
// countryParam.locale = locale; // countryParam.locale = locale;
// return countryParam; // return countryParam;
// } // }
public static OrderFlightParam of (String accountId, public static OrderRecordParam of (String accountId,
String dateFrom, String dateFrom,
String dateTo, String dateTo,
String batchNo) { String batchNo) {
OrderFlightParam countryParam = new OrderFlightParam(); OrderRecordParam countryParam = new OrderRecordParam();
countryParam.accountid = accountId; countryParam.accountid = accountId;
countryParam.datefrom = dateFrom; countryParam.datefrom = dateFrom;
@ -54,7 +54,7 @@ public class OrderFlightParam {
return countryParam; return countryParam;
} }
public OrderFlightParam auth(Authentification authentification) { public OrderRecordParam auth(Authentification authentification) {
this.auth = authentification; this.auth = authentification;
return this; return this;
} }
@ -64,7 +64,7 @@ public class OrderFlightParam {
return accountid; return accountid;
} }
public OrderFlightParam setAccountId(String accountId) { public OrderRecordParam setAccountId(String accountId) {
this.accountid = accountId; this.accountid = accountId;
return this; return this;
} }
@ -73,7 +73,7 @@ public class OrderFlightParam {
return datefrom; return datefrom;
} }
public OrderFlightParam setDateFrom(String dateFrom) { public OrderRecordParam setDateFrom(String dateFrom) {
this.datefrom = dateFrom; this.datefrom = dateFrom;
return this; return this;
} }
@ -82,7 +82,7 @@ public class OrderFlightParam {
return dateto; return dateto;
} }
public OrderFlightParam setDateTo(String dateTo) { public OrderRecordParam setDateTo(String dateTo) {
this.dateto = dateTo; this.dateto = dateTo;
return this; return this;
} }
@ -91,7 +91,7 @@ public class OrderFlightParam {
return batchno; return batchno;
} }
public OrderFlightParam setBatchNo(String batchNo) { public OrderRecordParam setBatchNo(String batchNo) {
this.batchno = batchNo; this.batchno = batchNo;
return this; return this;
} }
@ -100,7 +100,7 @@ public class OrderFlightParam {
return recordId; return recordId;
} }
public OrderFlightParam setRecordId(String recordId) { public OrderRecordParam setRecordId(String recordId) {
this.recordId = recordId; this.recordId = recordId;
return this; return this;
} }
@ -109,7 +109,7 @@ public class OrderFlightParam {
return orderId; return orderId;
} }
public OrderFlightParam setOrderId(String orderId) { public OrderRecordParam setOrderId(String orderId) {
this.orderId = orderId; this.orderId = orderId;
return this; return this;
} }
@ -118,7 +118,7 @@ public class OrderFlightParam {
return isCompensation; return isCompensation;
} }
public OrderFlightParam setCompensation(Boolean compensation) { public OrderRecordParam setCompensation(Boolean compensation) {
isCompensation = compensation; isCompensation = compensation;
return this; return this;
} }
@ -127,7 +127,7 @@ public class OrderFlightParam {
return payType; return payType;
} }
public OrderFlightParam setPayType(String payType) { public OrderRecordParam setPayType(String payType) {
this.payType = payType; this.payType = payType;
return this; return this;
} }
@ -136,7 +136,7 @@ public class OrderFlightParam {
return pageIndex; return pageIndex;
} }
public OrderFlightParam setPageIndex(Integer pageIndex) { public OrderRecordParam setPageIndex(Integer pageIndex) {
this.pageIndex = pageIndex; this.pageIndex = pageIndex;
return this; return this;
} }
@ -145,7 +145,7 @@ public class OrderFlightParam {
return pageSize; return pageSize;
} }
public OrderFlightParam setPageSize(Integer pageSize) { public OrderRecordParam setPageSize(Integer pageSize) {
this.pageSize = pageSize; this.pageSize = pageSize;
return this; return this;
} }
@ -154,7 +154,7 @@ public class OrderFlightParam {
return subBatchNoList; return subBatchNoList;
} }
public OrderFlightParam setSubBatchNoList(String[] subBatchNoList) { public OrderRecordParam setSubBatchNoList(String[] subBatchNoList) {
this.subBatchNoList = subBatchNoList; this.subBatchNoList = subBatchNoList;
return this; return this;
} }
@ -163,7 +163,7 @@ public class OrderFlightParam {
return journeyNoList; return journeyNoList;
} }
public OrderFlightParam setJourneyNoList(String[] journeyNoList) { public OrderRecordParam setJourneyNoList(String[] journeyNoList) {
this.journeyNoList = journeyNoList; this.journeyNoList = journeyNoList;
return this; return this;
} }

View File

@ -1,5 +1,6 @@
package com.chint.interfaces.rest.ctrip.order; package com.chint.interfaces.rest.ctrip.order;
import com.chint.infrastructure.util.DateTimeUtil;
import com.chint.interfaces.rest.base.PostRequest; import com.chint.interfaces.rest.base.PostRequest;
import com.chint.interfaces.rest.ctrip.CTripTicketRequest; import com.chint.interfaces.rest.ctrip.CTripTicketRequest;
import com.chint.interfaces.rest.ctrip.dto.Authentification; import com.chint.interfaces.rest.ctrip.dto.Authentification;
@ -8,10 +9,8 @@ import jakarta.annotation.PostConstruct;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
@ -49,6 +48,8 @@ public class CTripOrderDetailRequest {
private String carOrderUrl; private String carOrderUrl;
private DateTimeFormatter formatter =
@PostConstruct @PostConstruct
private void init() { private void init() {
this.flightOrderUrl = C_TRIP_BASE_URL + C_TRIP_ORDER_FLIGHT_PATH; this.flightOrderUrl = C_TRIP_BASE_URL + C_TRIP_ORDER_FLIGHT_PATH;
@ -58,35 +59,27 @@ public class CTripOrderDetailRequest {
} }
public OrderFlightResponse getFlightOrder() { public OrderFlightResponse getFlightOrder() {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd"); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
LocalDateTime localDateTime = LocalDateTime.now().minusDays(1L); LocalDateTime localDateTime = LocalDateTime.now().minusDays(1L);
return getFlightOrder(formatter.format(localDateTime), formatter.format(localDateTime)); return getFlightOrder(formatter.format(localDateTime), formatter.format(localDateTime));
} }
public OrderFlightResponse getFlightOrderByDate(String date) {
return getFlightOrder(DateTimeUtil.timeToStrYYYYMMDD(DateTimeUtil.firstDayOfMonth(date)),
DateTimeUtil.timeToStrYYYYMMDD(DateTimeUtil.endDayOfMonth(date)));
}
public OrderFlightResponse getFlightOrder(String dateFrom, String dateTo) { public OrderFlightResponse getFlightOrder(String dateFrom, String dateTo) {
String substring = dateFrom.substring(0, 6); return postRequest.post(flightOrderUrl, getParamByDateFromAndDateTo(dateFrom, dateTo),
String dateFromNew = substring + "01";
String batchNo = C_TRIP_CORP_ID + "_" + C_TRIP_ACCOUNT_ID + "_" + dateFromNew;
OrderFlightParam orderFlightParam = OrderFlightParam.of(
C_TRIP_ACCOUNT_ID,
dateFrom,
dateTo,
batchNo
);
orderFlightParam.auth(Authentification.midOf(C_TRIP_APP_KEY, ticketRequest.loadTicket()));
orderFlightParam.setAppKey(C_TRIP_APP_KEY);
orderFlightParam.setTicket(ticketRequest.loadTicket());
OrderFlightResponse orderFlightResponse = postRequest.post(flightOrderUrl, orderFlightParam,
OrderFlightResponse.class); OrderFlightResponse.class);
return orderFlightResponse;
} }
public OrderHotelResponse getHotelOrderByDate(String date) {
return getHotelOrder(DateTimeUtil.timeToStrYYYYMMDD(DateTimeUtil.firstDayOfMonth(date)),
DateTimeUtil.timeToStrYYYYMMDD(DateTimeUtil.endDayOfMonth(date)));
}
public OrderHotelResponse getHotelOrder() { public OrderHotelResponse getHotelOrder() {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd"); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
@ -95,30 +88,14 @@ public class CTripOrderDetailRequest {
} }
public OrderHotelResponse getHotelOrder(String dateFrom, String dateTo) { public OrderHotelResponse getHotelOrder(String dateFrom, String dateTo) {
return postRequest.post(hotelOrderUrl, getParamByDateFromAndDateTo(dateFrom, dateTo),
String substring = dateFrom.substring(0, 6);
String dateFromNew = substring + "01";
String batchNo = C_TRIP_CORP_ID + "_" + C_TRIP_ACCOUNT_ID + "_" + dateFromNew;
OrderFlightParam orderFlightParam = OrderFlightParam.of(
C_TRIP_ACCOUNT_ID,
dateFrom,
dateTo,
batchNo
);
orderFlightParam.auth(Authentification.midOf(C_TRIP_APP_KEY, ticketRequest.loadTicket()));
orderFlightParam.setAppKey(C_TRIP_APP_KEY);
orderFlightParam.setTicket(ticketRequest.loadTicket());
OrderHotelResponse orderFlightResponse = postRequest.post(hotelOrderUrl, orderFlightParam,
OrderHotelResponse.class); OrderHotelResponse.class);
return orderFlightResponse;
} }
public OrderTrainResponse getTrainOrderByDate(String date) {
return getTrainOrder(DateTimeUtil.timeToStrYYYYMMDD(DateTimeUtil.firstDayOfMonth(date)),
DateTimeUtil.timeToStrYYYYMMDD(DateTimeUtil.endDayOfMonth(date)));
}
public OrderTrainResponse getTrainOrder() { public OrderTrainResponse getTrainOrder() {
@ -126,57 +103,41 @@ public class CTripOrderDetailRequest {
LocalDateTime localDateTime = LocalDateTime.now().minusDays(1L); LocalDateTime localDateTime = LocalDateTime.now().minusDays(1L);
return getTrainOrder(formatter.format(localDateTime), formatter.format(localDateTime)); return getTrainOrder(formatter.format(localDateTime), formatter.format(localDateTime));
} }
public OrderTrainResponse getTrainOrder(String dateFrom, String dateTo) { public OrderTrainResponse getTrainOrder(String dateFrom, String dateTo) {
return postRequest.post(trainOrderUrl, getParamByDateFromAndDateTo(dateFrom, dateTo),
String substring = dateFrom.substring(0, 6);
String dateFromNew = substring + "01";
String batchNo = C_TRIP_CORP_ID + "_" + C_TRIP_ACCOUNT_ID + "_" + dateFromNew;
OrderFlightParam orderFlightParam = OrderFlightParam.of(
C_TRIP_ACCOUNT_ID,
dateFrom,
dateTo,
batchNo
);
orderFlightParam.auth(Authentification.midOf(C_TRIP_APP_KEY, ticketRequest.loadTicket()));
orderFlightParam.setAppKey(C_TRIP_APP_KEY);
orderFlightParam.setTicket(ticketRequest.loadTicket());
OrderTrainResponse orderTrainResponse = postRequest.post(trainOrderUrl, orderFlightParam,
OrderTrainResponse.class); OrderTrainResponse.class);
return orderTrainResponse;
} }
public OrderCarResponse getCarOrderByDate(String date) {
return getCarOrder(DateTimeUtil.timeToStrYYYYMMDD(DateTimeUtil.firstDayOfMonth(date)),
DateTimeUtil.timeToStrYYYYMMDD(DateTimeUtil.endDayOfMonth(date)));
}
public OrderCarResponse getCarOrder() { public OrderCarResponse getCarOrder() {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd"); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
LocalDateTime localDateTime = LocalDateTime.now().minusDays(1L); LocalDateTime localDateTime = LocalDateTime.now().minusDays(1L);
return getCarOrder(formatter.format(localDateTime), formatter.format(localDateTime)); return getCarOrder(formatter.format(localDateTime), formatter.format(localDateTime));
} }
public OrderCarResponse getCarOrder(String dateFrom, String dateTo){
public OrderCarResponse getCarOrder(String dateFrom, String dateTo) {
return postRequest.post(carOrderUrl, getParamByDateFromAndDateTo(dateFrom, dateTo),
OrderCarResponse.class);
}
private OrderRecordParam getParamByDateFromAndDateTo(String dateFrom, String dateTo) {
String substring = dateFrom.substring(0, 6); String substring = dateFrom.substring(0, 6);
String dateFromNew = substring + "01"; String dateFromNew = substring + "01";
String batchNo = C_TRIP_CORP_ID + "_" + C_TRIP_ACCOUNT_ID + "_" + dateFromNew; String batchNo = C_TRIP_CORP_ID + "_" + C_TRIP_ACCOUNT_ID + "_" + dateFromNew;
OrderFlightParam orderFlightParam = OrderFlightParam.of( OrderRecordParam orderFlightParam = OrderRecordParam.of(
C_TRIP_ACCOUNT_ID, C_TRIP_ACCOUNT_ID,
dateFrom, dateFrom,
dateTo, dateTo,
batchNo batchNo
); );
orderFlightParam.auth(Authentification.midOf(C_TRIP_APP_KEY, ticketRequest.loadTicket())); orderFlightParam.auth(Authentification.midOf(C_TRIP_APP_KEY, ticketRequest.loadTicket()));
orderFlightParam.setAppKey(C_TRIP_APP_KEY); orderFlightParam.setAppKey(C_TRIP_APP_KEY);
orderFlightParam.setTicket(ticketRequest.loadTicket()); orderFlightParam.setTicket(ticketRequest.loadTicket());
OrderCarResponse orderCarResponse = postRequest.post(carOrderUrl, orderFlightParam, return orderFlightParam;
OrderCarResponse.class);
return orderCarResponse;
} }
} }

View File

@ -12,6 +12,7 @@ import org.springframework.stereotype.Component;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Component @Component
@ -26,18 +27,25 @@ public class CTripOrderRecordAutoSave {
public void saveAll() { public void saveAll() {
this.cTripFlightRecordAutoSave(); this.cTripFlightRecordAutoSave(Optional.empty());
this.cTripHotelRecordAutoSave(); this.cTripHotelRecordAutoSave(Optional.empty());
this.cTripTrainRecordAutoSave(); this.cTripTrainRecordAutoSave(Optional.empty());
this.cTripCarRecordAutoSave(); this.cTripCarRecordAutoSave(Optional.empty());
} }
public void saveByDate(){ public void saveAllByDate(String date) {
this.cTripFlightRecordAutoSave(Optional.of(date));
this.cTripHotelRecordAutoSave(Optional.of(date));
this.cTripTrainRecordAutoSave(Optional.of(date));
this.cTripCarRecordAutoSave(Optional.of(date));
} }
public void cTripFlightRecordAutoSave() { public void cTripFlightRecordAutoSave(Optional<String> date) {
OrderFlightResponse flightOrder = cTripOrderDetailRequest.getFlightOrder();
OrderFlightResponse flightOrder = date
.flatMap(it -> Optional.ofNullable(cTripOrderDetailRequest.getFlightOrderByDate(it)))
.orElseGet(() -> cTripOrderDetailRequest.getFlightOrder());
List<OrderFlightResponse.FlightOrderAccountSettlementInfo> flightOrderAccountSettlementList = flightOrder List<OrderFlightResponse.FlightOrderAccountSettlementInfo> flightOrderAccountSettlementList = flightOrder
.getFlightOrderAccountSettlementList(); .getFlightOrderAccountSettlementList();
if (flightOrderAccountSettlementList != null && !flightOrderAccountSettlementList.isEmpty()) { if (flightOrderAccountSettlementList != null && !flightOrderAccountSettlementList.isEmpty()) {
@ -73,8 +81,12 @@ public class CTripOrderRecordAutoSave {
} }
public void cTripHotelRecordAutoSave() { public void cTripHotelRecordAutoSave(Optional<String> date) {
OrderHotelResponse hotelOrder = cTripOrderDetailRequest.getHotelOrder();
OrderHotelResponse hotelOrder = date
.flatMap(it -> Optional.ofNullable(cTripOrderDetailRequest.getHotelOrderByDate(it)))
.orElseGet(() -> cTripOrderDetailRequest.getHotelOrder());
List<OrderHotelResponse.HotelAccountSettlementInfo> lstHtlSettlement = hotelOrder.getLstHtlSettlement(); List<OrderHotelResponse.HotelAccountSettlementInfo> lstHtlSettlement = hotelOrder.getLstHtlSettlement();
if (lstHtlSettlement != null && !lstHtlSettlement.isEmpty()) { if (lstHtlSettlement != null && !lstHtlSettlement.isEmpty()) {
List<CTripHotelRecord> list = lstHtlSettlement.stream() List<CTripHotelRecord> list = lstHtlSettlement.stream()
@ -106,8 +118,12 @@ public class CTripOrderRecordAutoSave {
} }
public void cTripTrainRecordAutoSave() { public void cTripTrainRecordAutoSave(Optional<String> date) {
OrderTrainResponse trainOrder = cTripOrderDetailRequest.getTrainOrder();
OrderTrainResponse trainOrder = date
.flatMap(it -> Optional.ofNullable(cTripOrderDetailRequest.getTrainOrderByDate(it)))
.orElseGet(() -> cTripOrderDetailRequest.getTrainOrder());
List<OrderTrainResponse.CorpTrainAccountSettlement> lstTrainSettlement = trainOrder.getLstTrainSettlement(); List<OrderTrainResponse.CorpTrainAccountSettlement> lstTrainSettlement = trainOrder.getLstTrainSettlement();
if (lstTrainSettlement != null && !lstTrainSettlement.isEmpty()) { if (lstTrainSettlement != null && !lstTrainSettlement.isEmpty()) {
List<CTripTrainRecord> list = lstTrainSettlement.stream() List<CTripTrainRecord> list = lstTrainSettlement.stream()
@ -133,8 +149,11 @@ public class CTripOrderRecordAutoSave {
} }
} }
public void cTripCarRecordAutoSave() { public void cTripCarRecordAutoSave(Optional<String> date) {
OrderCarResponse carOrder = cTripOrderDetailRequest.getCarOrder(); OrderCarResponse carOrder = date
.flatMap(it -> Optional.ofNullable(cTripOrderDetailRequest.getCarOrderByDate(it)))
.orElseGet(() -> cTripOrderDetailRequest.getCarOrder());
List<OrderCarResponse.CarOrderAccountSettlementDetail> settlementList = carOrder.getCarOrderAccountSettlementList(); List<OrderCarResponse.CarOrderAccountSettlementDetail> settlementList = carOrder.getCarOrderAccountSettlementList();
if (settlementList != null && !settlementList.isEmpty()) { if (settlementList != null && !settlementList.isEmpty()) {
List<CTripCarRecord> list = settlementList.stream() List<CTripCarRecord> list = settlementList.stream()