备份同步差旅申请的代码

This commit is contained in:
lulz1 2024-04-09 09:54:41 +08:00
parent 6768db0cdc
commit e98af60faa
15 changed files with 209 additions and 425 deletions

View File

@ -22,7 +22,7 @@ public class RouteRequestController {
@Transactional @Transactional
@ApiOperation("同步行程规划单到差旅平台") @ApiOperation("同步行程规划单到差旅平台")
@PostMapping("/sync/whole") @PostMapping("/sync")
public Result<String> syncRouterOrder(@RequestBody SyncLegData syncLegData) { public Result<String> syncRouterOrder(@RequestBody SyncLegData syncLegData) {
routeRequestDomainService.syncRouteRequestToSupplier(syncLegData); routeRequestDomainService.syncRouteRequestToSupplier(syncLegData);
return Result.Success(SUCCESS); return Result.Success(SUCCESS);
@ -30,11 +30,13 @@ public class RouteRequestController {
@Transactional @Transactional
@ApiOperation("取消行程规划单到差旅平台") @ApiOperation("取消行程规划单到差旅平台")
@PostMapping("/sync/wholeee") @PostMapping("/cancel")
public Result<String> cancelWholeRouterOrder(@RequestBody SyncLegData syncLegData) { public Result<String> cancelWholeRouterOrder(@RequestBody SyncLegData syncLegData) {
routeRequestDomainService.cancelRouteRequest(syncLegData); routeRequestDomainService.cancelRouteRequest(syncLegData);
return Result.Success(SUCCESS); return Result.Success(SUCCESS);
} }
} }

View File

@ -1,12 +1,15 @@
package com.chint.application.out; package com.chint.application.out;
import com.chint.application.dtos.response.LegRes;
import com.chint.application.dtos.response.RouteOrderPageRes; import com.chint.application.dtos.response.RouteOrderPageRes;
import com.chint.application.dtos.response.RouteOrderRes; import com.chint.application.dtos.response.RouteOrderRes;
import com.chint.application.dtos.trip.TripCallback; import com.chint.application.dtos.trip.TripCallback;
import com.chint.application.queryies.OrderQuery; import com.chint.application.queryies.OrderQuery;
import com.chint.domain.aggregates.order.RouteOrder; import com.chint.domain.aggregates.order.RouteOrder;
import com.chint.domain.repository.RouteRepository;
import com.chint.domain.repository.UserRepository; import com.chint.domain.repository.UserRepository;
import com.chint.domain.service.LegDomainService;
import com.chint.domain.service.OrderDomainService; import com.chint.domain.service.OrderDomainService;
import com.chint.domain.value_object.*; import com.chint.domain.value_object.*;
import com.chint.infrastructure.cache.RouteCacheService; import com.chint.infrastructure.cache.RouteCacheService;
@ -16,7 +19,6 @@ import com.google.gson.Gson;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
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.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@ -44,6 +46,12 @@ public class OrderOutController {
@Autowired @Autowired
private RouteCacheService routeCacheService; private RouteCacheService routeCacheService;
@Autowired
private LegDomainService legDomainService;
@Autowired
private RouteRepository routeRepository;
@ApiOperation("根据临时单号和系统编码查询订单") @ApiOperation("根据临时单号和系统编码查询订单")
@PostMapping("/query/billcode") @PostMapping("/query/billcode")
public Result<RouteOrderRes> queryOrderByBillCodeAndSysCode(@RequestBody OrderQueryData queryData) { public Result<RouteOrderRes> queryOrderByBillCodeAndSysCode(@RequestBody OrderQueryData queryData) {
@ -75,7 +83,6 @@ public class OrderOutController {
} }
@ApiOperation("查询飞机估算价格") @ApiOperation("查询飞机估算价格")
@PostMapping("/estimate/flight") @PostMapping("/estimate/flight")
public Result<FlightPriceData> estimateFlightPrice(@RequestBody PriceQueryData priceQueryData) { public Result<FlightPriceData> estimateFlightPrice(@RequestBody PriceQueryData priceQueryData) {
@ -107,4 +114,13 @@ public class OrderOutController {
return Result.Success(SUCCESS, orderQuery.queryNotSubmit(queryData)); return Result.Success(SUCCESS, orderQuery.queryNotSubmit(queryData));
} }
@ApiOperation("查询能够同步的行程节点")
@PostMapping("/query/legs")
public Result<List<LegRes>> queryLegs(@RequestBody OrderQueryData queryData) {
RouteOrder routeOrder = routeRepository.queryById(queryData.getRouteId());
return Result.Success(SUCCESS, legDomainService
.queryLegsCanSync(routeOrder, queryData.getSupplierName()).stream().map(LegRes::copyFrom).toList());
}
} }

View File

@ -456,16 +456,17 @@ public class OrderQuery {
} }
} }
if (leg.getLegType().equals(LEG_TYPE_OTHER) && Objects.requireNonNull(leg.getLegExtensionField()).getAmountType().equals(LEG_OTHER_AMOUNT_TYPE_VISA)) { // if (leg.getLegType().equals(LEG_TYPE_OTHER) && Objects.requireNonNull(leg.getLegExtensionField()).getAmountType().equals(LEG_OTHER_AMOUNT_TYPE_VISA)) {
scheduleDetailBuilder.expenseTypeId("6770f575013211eabce29fde958f48e4") // scheduleDetailBuilder.expenseTypeId("6770f575013211eabce29fde958f48e4")
.travelType("LOCAL_OTHER") // .travelType("LOCAL_OTHER")
.scheduleType("VISA"); // .scheduleType("VISA");
} else { // } else {
scheduleDetailBuilder.scheduleType(translateLegType(leg.getLegType())); // scheduleDetailBuilder
} // }
return scheduleDetailBuilder return scheduleDetailBuilder
.scheduleNum(leg.getLegNo()) .scheduleNum(leg.getLegNo())
.scheduleType(translateLegType(leg.getLegType()))
.startDate(simpleFormatter.format(leg.getStartTime())) .startDate(simpleFormatter.format(leg.getStartTime()))
.endDate(simpleFormatter.format(leg.getEndTime())) .endDate(simpleFormatter.format(leg.getEndTime()))
.systemStatus(FSSCConstant.TRIP_CALLBACK_RECEIPT_STATUS) .systemStatus(FSSCConstant.TRIP_CALLBACK_RECEIPT_STATUS)

View File

@ -15,6 +15,7 @@ import org.springframework.data.relational.core.mapping.Table;
import java.io.Serial; import java.io.Serial;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List; import java.util.List;
@Data @Data
@ -60,6 +61,9 @@ public class RouteRequest implements Serializable, EventManageable {
@Override @Override
public List<RouteRequestEvent> getEvents() { public List<RouteRequestEvent> getEvents() {
if( this.eventList == null){
this.eventList = new ArrayList<>();
}
return this.eventList; return this.eventList;
} }

View File

@ -92,6 +92,8 @@ public class RouteOrderFactory implements OrderFactory {
.map(RouteRequestLeg::ofLeg) .map(RouteRequestLeg::ofLeg)
.toList(); .toList();
requestByRoute.setRouteRequestLegList(routeRequestLegs); requestByRoute.setRouteRequestLegList(routeRequestLegs);
requestByRoute.setCreateTime(LocalDateTime.now());
requestByRoute.setUpdateTime(LocalDateTime.now());
return requestByRoute; return requestByRoute;
} }
@ -114,7 +116,9 @@ public class RouteOrderFactory implements OrderFactory {
RouteRequestFields routeRequestFields = BeanUtil.copyProperties(routeOrder.getApproveOrderNo(), RouteRequestFields routeRequestFields = BeanUtil.copyProperties(routeOrder.getApproveOrderNo(),
RouteRequestFields.class); RouteRequestFields.class);
routeRequestFields.setUserId(routeOrder.getUserId()); routeRequestFields.setUserId(routeOrder.getUserId());
routeRequestFields.setBelongDeptCode(routeOrder.getRouterOrderExtensionField().getBelongDeptCode()); if(routeOrder.getRouterOrderExtensionField() != null){
routeRequestFields.setBelongDeptCode(routeOrder.getRouterOrderExtensionField().getBelongDeptCode());
}
routeRequestFields.setStandardLevel(routeOrder.getStandardLevel()); routeRequestFields.setStandardLevel(routeOrder.getStandardLevel());
routeRequest.setRouteRequestFields(routeRequestFields); routeRequest.setRouteRequestFields(routeRequestFields);
routeRequest.addEvent(RouteRequestEvent.prepare()); routeRequest.addEvent(RouteRequestEvent.prepare());

View File

@ -90,6 +90,7 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory {
}); });
} }
carOrderDetail.setTrvaleSysType(TRAVAL_SYS_TYPE_CTRIP);
return updateCarOrderDetailData(carOrderDetail, carOrderDetailData); return updateCarOrderDetailData(carOrderDetail, carOrderDetailData);
} }
@ -185,6 +186,7 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory {
} }
}); });
flightOrderDetail.setTrvaleSysType(TRAVAL_SYS_TYPE_CTRIP);
updateFlightOrderDetailData(flightOrderDetail, flightOrderInfoEntity); updateFlightOrderDetailData(flightOrderDetail, flightOrderInfoEntity);
return flightOrderDetail; return flightOrderDetail;
} }
@ -522,6 +524,7 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory {
.findFirst(); .findFirst();
first1.ifPresent(orderEvent -> hotelOrderDetail.setOverStandardReason(orderEvent.getExtension())); first1.ifPresent(orderEvent -> hotelOrderDetail.setOverStandardReason(orderEvent.getExtension()));
hotelOrderDetail.setTrvaleSysType(TRAVAL_SYS_TYPE_CTRIP);
return hotelOrderDetail; return hotelOrderDetail;
} }

View File

@ -99,6 +99,8 @@ public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory {
} }
}); });
} }
carOrderDetail.setTrvaleSysType(TRAVAL_SYS_TYPE_LY);
return updateCarOrderDetailData(carOrderDetail, data); return updateCarOrderDetailData(carOrderDetail, data);
} }
@ -307,6 +309,8 @@ public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory {
//这里根据同程自带的字段进行状态映射 //这里根据同程自带的字段进行状态映射
flightOrderDetail.setOrderStatus(FSSC_FLIGHT_STATUS_REFUND); flightOrderDetail.setOrderStatus(FSSC_FLIGHT_STATUS_REFUND);
} }
flightOrderDetail.setTrvaleSysType(TRAVAL_SYS_TYPE_LY);
return updateFlightOrderDetailData(flightOrderDetail, flightOrderDetailData); return updateFlightOrderDetailData(flightOrderDetail, flightOrderDetailData);
} }
@ -403,6 +407,8 @@ public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory {
hotelOrderDetail.setOrderStatus(FSSC_HOTEL_STATUS_SUCCESS); hotelOrderDetail.setOrderStatus(FSSC_HOTEL_STATUS_SUCCESS);
} }
hotelOrderDetail.setTrvaleSysType(TRAVAL_SYS_TYPE_LY);
return updateHotelOrderDetailData(hotelOrderDetail, data); return updateHotelOrderDetailData(hotelOrderDetail, data);
} }
@ -502,156 +508,6 @@ public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory {
} }
private HotelOrderDetail convertHotelOrderDetail(HotelDetailResponse.Data data) {
HotelDetailResponse.OrderInfo orderInfo = data.getOrderInfo();
HotelDetailResponse.HotelInfo hotelInfo = data.getHotelInfo();
List<HotelDetailResponse.Room> roomList = data.getRoomList();
HotelDetailResponse.Room room = null;
if (!data.getRoomList().isEmpty()) {
room = roomList.get(0);
}
OrderDetail orderDetail = orderDetailRepository.findByOrderNo(orderInfo.getOrderSerialNo())
.orElseThrow(() -> new NotFoundException(NOT_FOUND));
RouteOrder routeOrder = routeRepository.queryById(orderDetail.getRouteId());
String standardLevel = routeOrder.getStandardLevel();
// PriceQueryData priceQueryData = new PriceQueryData();
// priceQueryData.setDepartCity(hotelInfo.getCityName());
// priceQueryData.setDepartDate(hotelInfo.getCheckInDate());
// priceQueryData.setArriveDate(hotelInfo.getCheckOutDate());
// HotelPriceData hotelPriceData = estimatePrice.queryHotelPrice(priceQueryData);
String sysCode = routeOrder.getApproveOrderNo().getSysCode();
HotelOrderDetail hotelOrderDetail = new HotelOrderDetail();
hotelOrderDetail.setTrvaleSysType(TRAVAL_SYS_TYPE_LY);
if (sysCode != null) {
if (sysCode.equals(BELONG_SYS_CODE_FSSC)) {
hotelOrderDetail.setBelongSysType(BELONG_SYS_TYPE_FSSC);
}
if (sysCode.equals(BELONG_SYS_CODE_H3BPM)) {
hotelOrderDetail.setBelongSysType(BELONG_SYS_TYPE_H3BPM);
}
if (sysCode.equals(BELONG_SYS_CODE_XNFSSC)) {
hotelOrderDetail.setBelongSysType(BELONG_SYS_TYPE_XNFSSC);
}
if (sysCode.equals(BELONG_SYS_CODE_ANFSSC)) {
hotelOrderDetail.setBelongSysType(BELONG_SYS_TYPE_ANFSSC);
}
}
String EmployeeNo = routeOrder.getUserId();
User user = userRepository.findByUserEmployeeNo(EmployeeNo);
if (orderInfo != null) {
hotelOrderDetail.setOrderNo(orderInfo.getOrderSerialNo())
.setDetailId(orderInfo.getOrderSerialNo())
// .setSupplier(SUPPLIER_L_Y_EXTENSION_NAME)
.setReceiptsNum(routeOrder.getRouteOrderNo())
.setOrderAmount(String.valueOf(orderInfo.getBusinessAmount()))
.setCreateTime(orderInfo.getCreateTime())
.setCheckInCity(hotelInfo.getCityName())
.setHotelName(hotelInfo.getHotelName())
.setContactPhone(hotelInfo.getHotelTel())
.setHotelAddress(hotelInfo.getHotelAddress())
.setCheckInDate(hotelInfo.getCheckInDate())
.setDepartureDate(hotelInfo.getCheckOutDate())
.setNightCount(String.valueOf(hotelInfo.getNightNum()))
.setRoomCount(String.valueOf(hotelInfo.getRoomNum()))
.setRoomTypeName(hotelInfo.getRoomName())
.setPaymentType(String.valueOf(orderInfo.getPaymentType()))
.setCompanyAmount(String.valueOf(orderInfo.getCompanyPrice()))
.setPersonalAmount(String.valueOf(orderInfo.getPersonalPrice()))
.setCompanyRefundAmount(String.valueOf(orderInfo.getCompanyRefundPrice()))
.setPersonalRefundAmount(String.valueOf(orderInfo.getPersonalRefundPrice()))
.setOrderAmount(String.valueOf(orderInfo.getTotalPrice()))
.setPreServiceFee(String.valueOf(orderInfo.getServicePrice()))
.setPostServiceFee(String.valueOf(orderInfo.getAfterSettlementServicePrice()))
.setRefundAmount(String.valueOf(orderInfo.getRefundPrice()))
.setAgreementHotel(orderInfo.getProtocolType() == 0 ? "" : "");
// .setBookingName(orderInfo.getContactName()) //预订人名字和电话使用contact是否正确
// .setBookingUserPhone(orderInfo.getContactPhone())
// .setNightRates() //nightrates 是hotelInfo
// .setStarRate("4")
// .setBOOK_ORG_STRUCT_1("Org A")
// .setBOOK_ORG_STRUCT_2("Org B")
// .setBOOK_ORG_STRUCT_3("Org C")
}
if (user != null) {
hotelOrderDetail.setBookingUserCode(user.getEmployeeNo());
hotelOrderDetail.setBookingName(user.getName());
hotelOrderDetail.setBookingUserPhone(user.getPhoneNumber());
}
ApproveOrderNo approveOrderNo = routeOrder.getApproveOrderNo();
if (approveOrderNo != null) {
// hotelOrderDetail.setAccountCompanyId(approveOrderNo.getAccountCompany());
hotelOrderDetail.setAccountCompanyId(approveOrderNo.getAccountCompanyCode());
hotelOrderDetail.setAccountCompanyName(approveOrderNo.getAccountCompanyName());
hotelOrderDetail.setCostCenter(approveOrderNo.getCostCenter());
hotelOrderDetail.setProjectOrderNo(approveOrderNo.getProjectName());
}
Optional<OrderDetail> first1 = routeOrder
.getOrderDetails()
.stream()
.filter(it -> it.getOrderNo().equals(hotelOrderDetail.getOrderNo()))
.findFirst();
first1.ifPresent(it -> {
OrderEvent lastEvent = it.getLastEvent();
if (lastEvent != null) {
hotelOrderDetail.setOrderStatus(lastEvent.mapToHotelOrderDetailStatus());
} else {
//如果订单事件为空那么就需要重新根据查询到的订单信息重新进行映射
Integer orderStatus = orderInfo.getOrderStatus();
hotelOrderDetail.setOrderStatus(
OrderEvent.mapToHotelOrderDetailStatus(
LYOrderUtil.mapHotelStatus(orderStatus.toString())
)
);
}
}
);
Optional<Integer> firstOrderEvent = orderDetail.getOrderEventList()
.stream()
.map(OrderEvent::getEventType)
.filter(it -> it.equals(ORDER_EVENT_ETA))
.findFirst();
if (firstOrderEvent.isEmpty()) {
hotelOrderDetail.setOverStandard(""); //
} else {
hotelOrderDetail.setOverStandard(""); //
}
Optional<OrderEvent> first2 = orderDetail.getOrderEventList()
.stream()
.findFirst();
first2.ifPresent(orderEvent -> hotelOrderDetail.setOverStandardReason(orderEvent.getExtension()));
List<Resident> residentList = data.getResidentList();
if (residentList != null && !residentList.isEmpty()) {
for (Resident resident : residentList) {
HotelOrderDetailCustomer customer = new HotelOrderDetailCustomer();
customer.setUserName(resident.getName());
customer.setPhone(resident.getContactPhone());
customer.setUserCode(resident.getEmployeeCode());
hotelOrderDetail.addCustomer(customer);
}
}
if (room != null) {
hotelOrderDetail.setStandardItems(room.getDayStandardPrice());
}
return hotelOrderDetail;
}
@Override @Override
public TrainOrderDetail createTrainOrderDetail(Object trainOrderDetailData) { public TrainOrderDetail createTrainOrderDetail(Object trainOrderDetailData) {
// 获取对象的Class对象 // 获取对象的Class对象
@ -685,6 +541,7 @@ public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory {
} }
); );
trainOrderDetail.setTrvaleSysType(TRAVAL_SYS_TYPE_LY);
return updateTrainOrderDetailData(trainOrderDetail, trainDetailData); return updateTrainOrderDetailData(trainOrderDetail, trainDetailData);
} }
@ -766,197 +623,6 @@ public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory {
} }
private TrainOrderDetail convertTrainOrderDetail(TrainDetailResponse.TrainDetailData trainDetailData) {
// TrainDetailResponse.TrainDetailData trainDetailData = trainDetailResponse.getData();
List<TrainDetailResponse.Item> items = trainDetailData.getItems();
TrainDetailResponse.Item item = null;
TrainDetailResponse.ChangeInfo changeInfo = null;
if (!trainDetailData.getItems().isEmpty()) {
item = items.get(0);
changeInfo = item.getChangeInfo();
}
TrainDetailResponse.ChangeItem changeItem = null;
if (changeInfo != null) {
changeItem = changeInfo.getChangeItem();
}
Optional<OrderDetail> byOrderNo = orderDetailRepository.findByOrderNo(trainDetailData.getOrderNo());
TrainOrderDetail trainOrderDetail;
if (byOrderNo.isPresent()) {
if (byOrderNo.get().getTrainOrderDetail() == null) {
trainOrderDetail = new TrainOrderDetail();
} else {
return byOrderNo.get().getTrainOrderDetail();
}
} else {
trainOrderDetail = new TrainOrderDetail();
}
OrderDetail orderDetail = byOrderNo.get();
RouteOrder routeOrder = routeRepository.queryById(byOrderNo.get().getRouteId());
String sysCode = routeOrder.getApproveOrderNo().getSysCode();
trainOrderDetail.setTrvaleSysType(TRAVAL_SYS_TYPE_LY);
if (sysCode != null) {
if (sysCode.equals(BELONG_SYS_CODE_FSSC)) {
trainOrderDetail.setBelongSysType(BELONG_SYS_TYPE_FSSC);
}
if (sysCode.equals(BELONG_SYS_CODE_H3BPM)) {
trainOrderDetail.setBelongSysType(BELONG_SYS_TYPE_H3BPM);
}
if (sysCode.equals(BELONG_SYS_CODE_XNFSSC)) {
trainOrderDetail.setBelongSysType(BELONG_SYS_TYPE_XNFSSC);
}
if (sysCode.equals(BELONG_SYS_CODE_ANFSSC)) {
trainOrderDetail.setBelongSysType(BELONG_SYS_TYPE_ANFSSC);
}
}
if (trainDetailData != null) {
trainOrderDetail.setOrderNo(trainDetailData.getOrderNo());
trainOrderDetail.setDetailId(trainDetailData.getOrderNo());
trainOrderDetail.setParentOrderNo(trainDetailData.getParentOrderSerialNo());
Optional<OrderDetail> first1 = routeOrder
.getOrderDetails()
.stream()
.filter(it -> it.getOrderNo().equals(trainDetailData.getOrderNo()))
.findFirst();
first1.ifPresent(it -> {
OrderEvent lastEvent = it.getLastEvent();
if (trainDetailData.getIsChangedOrder().equals(1)) {
trainOrderDetail.setOrderStatus(FSSC_TRAIN_STATUS_CHANGE);
}
if (lastEvent != null) {
trainOrderDetail.setOrderStatus(lastEvent.mapToTrainOrderDetailStatus());
} else {
//如果订单事件为空那么就需要重新根据查询到的订单信息重新进行映射
String orderStatus = trainDetailData.getOrderStatus();
trainOrderDetail.setOrderStatus(
OrderEvent.mapToTrainOrderDetailStatus(
LYOrderUtil.mapTrainStatus(orderStatus)
)
);
}
if (!trainOrderDetail.getOrderStatus().equals(FSSC_TRAIN_STATUS_CHANGE)
&& !trainOrderDetail.getOrderStatus().equals(FSSC_ORDER_STATUS_CANCEL)) {
trainOrderDetail.setOrderStatus(FSSC_TRAIN_STATUS_SUCCESS);
}
}
);
String EmployeeNo = routeOrder.getUserId();
User user = userRepository.findByUserEmployeeNo(EmployeeNo);
if (user != null) {
trainOrderDetail.setBookingUserCode(user.getEmployeeNo());
trainOrderDetail.setBookingName(user.getName());
trainOrderDetail.setBookingUserPhone(user.getPhoneNumber());
}
trainOrderDetail.setReceiptsNum(routeOrder.getRouteOrderNo());
trainOrderDetail.setCreateTime(trainDetailData.getOutTicketTime());
trainOrderDetail.setStartTime(trainDetailData.getPlanBeginDate());
trainOrderDetail.setArriveTime(trainDetailData.getPlanEndDate());
trainOrderDetail.setFromStationName(trainDetailData.getFromStation());
trainOrderDetail.setToStationName(trainDetailData.getToStation());
trainOrderDetail.setTrainNo(trainDetailData.getTrainNo());
trainOrderDetail.setFromCity(trainDetailData.getDepartCity());
trainOrderDetail.setToCity(trainDetailData.getArriveCity());
trainOrderDetail.setOrderAmount(String.valueOf(trainDetailData.getTotalAmount()));
trainOrderDetail.setPersonalAmount(trainDetailData.getPersonalPrice().toString());
trainOrderDetail.setCompanyAmount(trainDetailData.getCompanyPrice().toString());
trainOrderDetail.setUserCode(trainDetailData.getEmployeeCode());
trainOrderDetail.setPaymentType(trainDetailData.getPaymentType().toString());
List<TrainDetailResponse.TravelData.SubmitItem> submitItemList =
trainDetailData.getTravelData().getSubmitItemList();
ApproveOrderNo approveOrderNo = routeOrder.getApproveOrderNo();
if (approveOrderNo != null) {
trainOrderDetail.setAccountCompanyId(approveOrderNo.getAccountCompanyCode());
trainOrderDetail.setAccountCompanyName(approveOrderNo.getAccountCompanyName());
trainOrderDetail.setCostCenter(approveOrderNo.getCostCenter());
trainOrderDetail.setProjectOrderNo(approveOrderNo.getProjectName());
}
}
if (item != null) {
trainOrderDetail.setPreServiceFee(String.valueOf(item.getServiceCharge()));
trainOrderDetail.setPostServiceFee(String.valueOf(item.getAfterServiceCharge()));
trainOrderDetail.setRefundAmount(String.valueOf(item.getRefundAmountCor()));
if (item.getSeatClass().equals("secondseat")) {
trainOrderDetail.setSeatType("二等座");
}
if (item.getSeatClass().equals("businessseat")) {
trainOrderDetail.setSeatType("商务座");
}
if (item.getSeatClass().equals("hardseat")) {
trainOrderDetail.setSeatType("硬座");
}
if (item.getSeatClass().equals("softsleeperup")) {
trainOrderDetail.setSeatType("软卧");
}
if (item.getSeatClass().equals("hardsleeperup")) {
trainOrderDetail.setSeatType("硬卧");
}
if (item.getSeatClass().equals("firstseat")) {
trainOrderDetail.setSeatType("一等座");
}
trainOrderDetail.setSeatName(item.getSeatNo());
trainOrderDetail.setTicketPrice(String.valueOf(item.getTicketPrice()));
trainOrderDetail.setRefundCost(String.valueOf(item.getRefundFee()));
trainOrderDetail.setRefundPrice(String.valueOf(item.getRefundAmountCor()));
trainOrderDetail.setChangeCost(String.valueOf(item.getServiceCharge()));
trainOrderDetail.setPhone(item.getPassengerPhone());
trainOrderDetail.setUserName(item.getPassengerName());
}
if (changeItem != null) {
trainOrderDetail.setChangeDifference(String.valueOf(changeItem.getChangePrice()));
trainOrderDetail.setChangeDifference(String.valueOf(changeItem.getChangePrice()));
}
// trainOrderDetail.setSupplier(SUPPLIER_L_Y_EXTENSION_NAME);
Optional<Integer> firstOrderEvent = orderDetail.getOrderEventList()
.stream()
.map(OrderEvent::getEventType)
.filter(it -> it.equals(ORDER_EVENT_ETA))
.findFirst();
if (firstOrderEvent.isEmpty()) {
trainOrderDetail.setOverStandard(""); //
} else {
trainOrderDetail.setOverStandard(""); //
}
Optional<OrderEvent> first2 = orderDetail.getOrderEventList()
.stream()
.findFirst();
first2.ifPresent(orderEvent -> trainOrderDetail.setOverStandardReason(orderEvent.getExtension()));
// trainOrderDetail.setOriginalOrderNo("originalOrderNo"); //
// trainOrderDetail.setBookingUserPhone(trainDetailData.getContactInfo().getPersonMobile() != null ?
// trainDetailData.getContactInfo().getPersonMobile() :
// trainDetailData.getContactInfo().getPersonTelephone()); //不确定是否是这个字段文档没写猜测
// trainOrderDetail.setScheduleNum(""); //
// trainOrderDetail.setRunTime(""); //
// trainOrderDetail.setTickets(trainDetailData.getTicketNo()); //ChangeInfo.changeItem里面的数据
// trainOrderDetail.setStandardItems("policyName"); //
// trainOrderDetail.setBOOK_ORG_STRUCT_1(""); //
// trainOrderDetail.setBOOK_ORG_STRUCT_2(""); //
// trainOrderDetail.setBOOK_ORG_STRUCT_3(""); //
// trainOrderDetail.setInsuranceFee(""); //
return trainOrderDetail;
}
private String translateEnSeatToCnSeat(String seatEnName) { private String translateEnSeatToCnSeat(String seatEnName) {
return switch (seatEnName) { return switch (seatEnName) {
case "secondseat" -> "二等座"; case "secondseat" -> "二等座";

View File

@ -62,12 +62,12 @@ public class OrderDetailFactoryImpl implements OrderDetailFactory {
baseOrderExtension.setBookingUserPhone(user.getPhoneNumber()); baseOrderExtension.setBookingUserPhone(user.getPhoneNumber());
//配置供应商信息 //配置供应商信息
String supplierName = routeOrder.getSupplierName(); // String supplierName = routeOrder.getSupplierName();
if (supplierName.equals(SUPPLIER_C_TRIP)) { // if (supplierName.equals(SUPPLIER_C_TRIP)) {
baseOrderExtension.setTrvaleSysType(TRAVAL_SYS_TYPE_CTRIP); // baseOrderExtension.setTrvaleSysType(TRAVAL_SYS_TYPE_CTRIP);
} else { // } else {
baseOrderExtension.setTrvaleSysType(TRAVAL_SYS_TYPE_LY); // baseOrderExtension.setTrvaleSysType(TRAVAL_SYS_TYPE_LY);
} // }
ApproveOrderNo approveOrderNo = routeOrder.getApproveOrderNo(); ApproveOrderNo approveOrderNo = routeOrder.getApproveOrderNo();
if (approveOrderNo != null) { if (approveOrderNo != null) {

View File

@ -17,52 +17,52 @@ public class OrderRecordFactory {
@Autowired @Autowired
private UserRepository userRepository; private UserRepository userRepository;
public OrderRecordBasic buildWithRouteOrder(RouteOrder routeOrder) { // public OrderRecordBasic buildWithRouteOrder(RouteOrder routeOrder) {
routeOrder.reloadStatus(); // routeOrder.reloadStatus();
OrderRecordBasic orderRecordBasic = new OrderRecordBasic(); // OrderRecordBasic orderRecordBasic = new OrderRecordBasic();
//
//完成身份信息 // //完成身份信息
String userId = routeOrder.getUserId(); // String userId = routeOrder.getUserId();
User user = userRepository.findByUserEmployeeNo(userId); // User user = userRepository.findByUserEmployeeNo(userId);
orderRecordBasic.loadBookingInfo(user.getEmployeeNo(), // orderRecordBasic.loadBookingInfo(user.getEmployeeNo(),
user.getName(), // user.getName(),
user.getPhoneNumber(), // user.getPhoneNumber(),
user.getEmployeeNo(), // user.getEmployeeNo(),
user.getPhoneNumber()); // user.getPhoneNumber());
//
//
//配置供应商信息 // //配置供应商信息
String supplierName = routeOrder.getSupplierName(); // String supplierName = routeOrder.getSupplierName();
if (supplierName.equals(SUPPLIER_C_TRIP)) { // if (supplierName.equals(SUPPLIER_C_TRIP)) {
orderRecordBasic.setTrvaleSysType(TRAVAL_SYS_TYPE_CTRIP); // orderRecordBasic.setTrvaleSysType(TRAVAL_SYS_TYPE_CTRIP);
} else { // } else {
orderRecordBasic.setTrvaleSysType(TRAVAL_SYS_TYPE_LY); // orderRecordBasic.setTrvaleSysType(TRAVAL_SYS_TYPE_LY);
} // }
//
ApproveOrderNo approveOrderNo = routeOrder.getApproveOrderNo(); // ApproveOrderNo approveOrderNo = routeOrder.getApproveOrderNo();
if (approveOrderNo != null) { // if (approveOrderNo != null) {
orderRecordBasic.setAccountCompanyId(approveOrderNo.getAccountCompanyCode()); // orderRecordBasic.setAccountCompanyId(approveOrderNo.getAccountCompanyCode());
orderRecordBasic.setAccountCompanyName(approveOrderNo.getAccountCompanyName()); // orderRecordBasic.setAccountCompanyName(approveOrderNo.getAccountCompanyName());
orderRecordBasic.setProjectOrderNo(approveOrderNo.getProjectName()); // orderRecordBasic.setProjectOrderNo(approveOrderNo.getProjectName());
String sysCode = routeOrder.getApproveOrderNo().getSysCode(); // String sysCode = routeOrder.getApproveOrderNo().getSysCode();
if (sysCode != null) { // if (sysCode != null) {
if (sysCode.equals(BELONG_SYS_CODE_FSSC)) { // if (sysCode.equals(BELONG_SYS_CODE_FSSC)) {
orderRecordBasic.setBelongSysType(BELONG_SYS_TYPE_FSSC); // orderRecordBasic.setBelongSysType(BELONG_SYS_TYPE_FSSC);
} // }
if (sysCode.equals(BELONG_SYS_CODE_H3BPM)) { // if (sysCode.equals(BELONG_SYS_CODE_H3BPM)) {
orderRecordBasic.setBelongSysType(BELONG_SYS_TYPE_H3BPM); // orderRecordBasic.setBelongSysType(BELONG_SYS_TYPE_H3BPM);
} // }
if (sysCode.equals(BELONG_SYS_CODE_XNFSSC)) { // if (sysCode.equals(BELONG_SYS_CODE_XNFSSC)) {
orderRecordBasic.setBelongSysType(BELONG_SYS_TYPE_XNFSSC); // orderRecordBasic.setBelongSysType(BELONG_SYS_TYPE_XNFSSC);
} // }
if (sysCode.equals(BELONG_SYS_CODE_ANFSSC)) { // if (sysCode.equals(BELONG_SYS_CODE_ANFSSC)) {
orderRecordBasic.setBelongSysType(BELONG_SYS_TYPE_ANFSSC); // orderRecordBasic.setBelongSysType(BELONG_SYS_TYPE_ANFSSC);
} // }
} else { // } else {
orderRecordBasic.setBelongSysType(BELONG_SYS_TYPE_NOT); // orderRecordBasic.setBelongSysType(BELONG_SYS_TYPE_NOT);
} // }
} // }
return orderRecordBasic; // return orderRecordBasic;
} // }
} }

View File

@ -7,7 +7,6 @@ import com.chint.domain.repository.LegRepository;
import com.chint.domain.repository.LocationRepository; import com.chint.domain.repository.LocationRepository;
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.infrastructure.constant.LegConstant;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -16,6 +15,7 @@ import java.util.List;
import static com.chint.infrastructure.constant.CommonMessageConstant.LEG_CHANGE_MAX_ERROR; import static com.chint.infrastructure.constant.CommonMessageConstant.LEG_CHANGE_MAX_ERROR;
import static com.chint.infrastructure.constant.LegConstant.*; import static com.chint.infrastructure.constant.LegConstant.*;
import static com.chint.infrastructure.constant.OrderConstant.*; import static com.chint.infrastructure.constant.OrderConstant.*;
import static com.chint.infrastructure.constant.RouteConstant.APPROVAL_EVENT_PREPARE;
import static com.chint.infrastructure.constant.RouteConstant.ORDER_STATUS_PREPARE; import static com.chint.infrastructure.constant.RouteConstant.ORDER_STATUS_PREPARE;
@Service @Service
@ -70,8 +70,7 @@ public class LegDomainService {
} }
if (leg.getLegStatus().equals(LEG_STATUS_CHANGE)) {
if(leg.getLegStatus().equals(LEG_STATUS_CHANGE)){
//如果发现该订单 //如果发现该订单
LegEvent legEvent = legEventFactory.creatLegEvent(LEG_EVENT_APPROVAL); LegEvent legEvent = legEventFactory.creatLegEvent(LEG_EVENT_APPROVAL);
leg.addEvent(legEvent); leg.addEvent(legEvent);
@ -141,4 +140,24 @@ public class LegDomainService {
}); });
return list; return list;
} }
public RouteOrder checkLegIfStartApproval(RouteOrder routeOrder) {
routeOrder.reloadStatus();
List<Leg> legItems = routeOrder.getLegItems();
legItems.forEach(it -> {
if (!routeOrder.getApprovalStatusCode().equals(APPROVAL_EVENT_PREPARE) && it.getLegStatus().equals(LEG_STATUS_PREPARE)) {
it.addEvent(legEventFactory.creatLegEvent(LEG_EVENT_APPROVAL));
}
});
return routeOrder;
}
public List<Leg> queryLegsCanSync(RouteOrder routeOrder, String supplierName) {
List<Leg> legItems = routeOrder.getLegItems();
legItems = legItems.stream().filter(it -> !it.getLegType().equals(LEG_TYPE_OTHER)).toList();
if (supplierName.equals("CTrip")) {
legItems = legItems.stream().filter(it -> !it.getLegType().equals(LEG_TYPE_TRAIN)).toList();
}
return legItems;
}
} }

View File

@ -1,9 +1,8 @@
package com.chint.domain.service; package com.chint.domain.service;
import com.chint.domain.aggregates.order.Leg; import com.chint.domain.aggregates.order.*;
import com.chint.domain.aggregates.order.RouteOrder; import com.chint.domain.exceptions.CommandException;
import com.chint.domain.aggregates.order.RouteRequest; import com.chint.domain.factoriy.leg_event.LegEventFactory;
import com.chint.domain.aggregates.order.RouteRequestEvent;
import com.chint.domain.factoriy.order.RouteOrderFactory; import com.chint.domain.factoriy.order.RouteOrderFactory;
import com.chint.domain.repository.LegRepository; import com.chint.domain.repository.LegRepository;
import com.chint.domain.repository.RouteRepository; import com.chint.domain.repository.RouteRepository;
@ -16,6 +15,7 @@ import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import static com.chint.infrastructure.constant.LegConstant.*;
import static com.chint.infrastructure.constant.RouteRequestConstant.ROUTE_REQUEST_STATUS_PREPARE; import static com.chint.infrastructure.constant.RouteRequestConstant.ROUTE_REQUEST_STATUS_PREPARE;
@Service @Service
@ -39,9 +39,27 @@ public class RouteRequestDomainService {
@Autowired @Autowired
private RouteRequestRepository routeRequestRepository; private RouteRequestRepository routeRequestRepository;
@Autowired
private LegEventFactory legEventFactory;
// //这里增加一个判断 如果这个订单的行程为空那么就返回给用户提示
// if (legItems == null || legItems.isEmpty()) {
// throw new CommandException("订单的行程不能为空");
// }
// List<Leg> needSyncLegs = legItems.stream().filter(it -> !it.getLegType().equals(LEG_TYPE_OTHER)).toList();
// if (needSyncLegs.isEmpty()) {
// throw new CommandException("有所选的行程规划单不存在需要同步的行程");
// }
//
// //这里order所有的leg触发sync事件
// legItems.forEach(leg -> leg.getEventList().add(
// legEventFactory.creatLegEvent(command.getLegEventType())
// ));
public RouteRequest syncRouteRequestToSupplier(SyncLegData syncLegData) { public RouteRequest syncRouteRequestToSupplier(SyncLegData syncLegData) {
RouteOrder routeOrder = routeRepository.queryById(syncLegData.getRouteId()); RouteOrder routeOrder = routeRepository.queryById(syncLegData.getRouteId());
legDomainService.checkLegIfStartApproval(routeOrder);
List<Long> legIds = syncLegData.getLegIds(); List<Long> legIds = syncLegData.getLegIds();
RouteRequest routeRequest = getRouteRequest(routeOrder, legIds, syncLegData.getSupplierName()); RouteRequest routeRequest = getRouteRequest(routeOrder, legIds, syncLegData.getSupplierName());
if (routeRequest.getStatus().equals(ROUTE_REQUEST_STATUS_PREPARE)) { if (routeRequest.getStatus().equals(ROUTE_REQUEST_STATUS_PREPARE)) {
@ -53,8 +71,26 @@ public class RouteRequestDomainService {
//如果是不是刚生成的需要调整差旅申请单的行程 //如果是不是刚生成的需要调整差旅申请单的行程
loadLegInfo(routeRequest, routeOrder, legIds); loadLegInfo(routeRequest, routeOrder, legIds);
} }
List<Leg> legs = routeRequest.getRouteRequestLegList()
.stream()
.map(RouteRequestLeg::getLeg)
.toList();
if (legs.isEmpty()) {
throw new CommandException("订单的行程不能为空");
}
List<Leg> needSyncLegs = legs.stream().filter(it -> !it.getLegType().equals(LEG_TYPE_OTHER)).toList();
if (needSyncLegs.isEmpty()) {
throw new CommandException("有所选的行程规划单不存在需要同步的行程");
}
legs.forEach(it -> it.addEvent(legEventFactory.creatLegEvent(LEG_EVENT_NOT_ORDERED)));
//这里执行同步
syncAdapter.of(syncLegData.getSupplierName()).syncRouteRequest(routeRequest); syncAdapter.of(syncLegData.getSupplierName()).syncRouteRequest(routeRequest);
routeRequest.addEvent(RouteRequestEvent.sync(syncLegData.getSupplierName())); routeRequest.addEvent(RouteRequestEvent.sync(syncLegData.getSupplierName()));
//通过保存聚合根来保存差旅申请单 //通过保存聚合根来保存差旅申请单
routeRepository.save(routeOrder); routeRepository.save(routeOrder);
return routeRequest; return routeRequest;
@ -79,7 +115,10 @@ public class RouteRequestDomainService {
} }
optionalRouteRequest.ifPresent(it -> { optionalRouteRequest.ifPresent(it -> {
it.addEvent(RouteRequestEvent.cancel(it.getSupplier())); it.addEvent(RouteRequestEvent.cancel(it.getSupplier()));
getLegInfoFromRouteOrder(it, routeOrder);
syncAdapter.of(it.getSupplier()).cancelRouteRequest(it); syncAdapter.of(it.getSupplier()).cancelRouteRequest(it);
it.getRouteRequestLegList()
.forEach(requestLeg -> requestLeg.getLeg().addEvent(legEventFactory.creatLegEvent(LEG_EVENT_APPROVAL)));
}); });
routeRepository.save(routeOrder); routeRepository.save(routeOrder);
} }
@ -105,15 +144,27 @@ public class RouteRequestDomainService {
//获取目前已经同步到供应商的差旅申请单 //获取目前已经同步到供应商的差旅申请单
private RouteRequest loadLegInfo(RouteRequest routeRequest, RouteOrder routeOrder, List<Long> legIds) { private RouteRequest loadLegInfo(RouteRequest routeRequest, RouteOrder routeOrder, List<Long> legIds) {
List<Leg> legItems = routeOrder.getLegItems(); List<Leg> legItems = routeOrder.getLegItems();
routeRequest.getRouteRequestLegList().forEach(it -> List<RouteRequestLeg> list = legItems.stream()
legItems.stream() .filter(leg -> legIds.contains(leg.getLegId()))
.filter(leg -> legIds.contains(leg.getLegId())) .map(RouteRequestLeg::ofLeg)
.filter(leg -> leg.getLegId().equals(it.getLegId())) .toList();
.findFirst() routeRequest.setRouteRequestLegList(list);
.ifPresent(it::setLeg));
return routeRequest; return routeRequest;
} }
private RouteRequest getLegInfoFromRouteOrder(RouteRequest routeRequest, RouteOrder routeOrder) {
List<Leg> legItems = routeOrder.getLegItems();
routeRequest.getRouteRequestLegList().forEach(it -> {
for (Leg leg : legItems) {
if (leg.getLegId().equals(it.getLegId())) {
it.setLeg(leg);
}
}
});
return routeRequest;
}
public RouteOrder getRouteOrder(String journeyNo) { public RouteOrder getRouteOrder(String journeyNo) {
RouteOrder byOrderNo = routeRepository.findByOrderNo(journeyNo); RouteOrder byOrderNo = routeRepository.findByOrderNo(journeyNo);
if (byOrderNo == null) { if (byOrderNo == null) {
@ -122,4 +173,6 @@ public class RouteRequestDomainService {
} }
return byOrderNo; return byOrderNo;
} }
} }

View File

@ -321,8 +321,15 @@ public class LegEventHandler implements LegEventService {
.stream() .stream()
.filter(it -> !it.getLegType().equals(LEG_TYPE_OTHER)) .filter(it -> !it.getLegType().equals(LEG_TYPE_OTHER))
.toList(); .toList();
if (!list.isEmpty() && !syncAdapter.of(routeOrder.getSupplierName()).cancelSyncSupplierOrder(routeOrder)) {
throw new CommandException("订单取消失败"); List<RouteRequest> routeRequestList = routeOrder.getRouteRequestList();
if(routeRequestList != null && !routeRequestList.isEmpty()) {
routeRequestList.forEach(it->syncAdapter.of(it.getSupplier()).cancelRouteRequest(it));
} else {
if (!list.isEmpty() && !syncAdapter.of(routeOrder.getSupplierName()).cancelSyncSupplierOrder(routeOrder)) {
throw new CommandException("订单取消失败");
}
} }
} }
LegEvent legEvent = legEventFactory.creatLegEvent(command.getLegEventType()); LegEvent legEvent = legEventFactory.creatLegEvent(command.getLegEventType());

View File

@ -1,6 +1,7 @@
package com.chint.domain.value_object; package com.chint.domain.value_object;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@ -9,6 +10,7 @@ import java.util.List;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@Data @Data
public class OrderQueryData extends BaseQuery { public class OrderQueryData extends BaseQuery {
@ApiModelProperty("需要同步的行程规划单ID")
private Long routeId; private Long routeId;
private String billcode; private String billcode;
private String sysCode; private String sysCode;
@ -17,5 +19,6 @@ public class OrderQueryData extends BaseQuery {
private String orderNo; private String orderNo;
private String instructions; private String instructions;
private String keywords; private String keywords;
@ApiModelProperty("供应商标识")
private String supplierName; private String supplierName;
} }

View File

@ -1,15 +1,21 @@
package com.chint.domain.value_object; package com.chint.domain.value_object;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.util.List; import java.util.List;
@Data @Data
public class SyncLegData { public class SyncLegData {
@ApiModelProperty("需要同步的行程规划单ID")
private Long routeId; private Long routeId;
@ApiModelProperty("差旅申请单ID")
private Long routeRequestId; private Long routeRequestId;
@ApiModelProperty("批量同步的行程规划单ID")
private List<Long> routeIds; private List<Long> routeIds;
@ApiModelProperty("需要同步的行程节点ID")
private List<Long> legIds; private List<Long> legIds;
@ApiModelProperty("供应商标识")
private String supplierName; private String supplierName;
public static SyncLegData of( Long routeId,String supplierName){ public static SyncLegData of( Long routeId,String supplierName){
SyncLegData syncLegData = new SyncLegData(); SyncLegData syncLegData = new SyncLegData();

View File

@ -48,10 +48,10 @@ logging:
#正式 #正式
ly: ly:
appId: zhengtai appId: zhengtai
account: ab9fe0c19dd64a99b936fded72c3bb94 account: 4f9cb1080b564dd0a94aa95f7a19c8b5
password: glHRJJ9JMUwNfQ8OwAQi password: 1fD3SutgzfS48qznYQiq
secret: MnghmYJpM1U2RaLx secret: WOHzCMvHd823iHgH
baseUrl: https://api.dttrip.cn/openapi baseUrl: https://api.qa.dttrip.cn/openapi
ifForwardRequest: false ifForwardRequest: false
forwardRequestBaseUrl: https://secureqrdev-t.chint.com/llz forwardRequestBaseUrl: https://secureqrdev-t.chint.com/llz