Compare commits

...

8 Commits

34 changed files with 775 additions and 144 deletions

View File

@ -10,6 +10,7 @@ import static com.chint.infrastructure.constant.LegConstant.LEG_EVENT_NOT_ORDERE
public class LegSyncCommand extends Command { public class LegSyncCommand extends Command {
private Integer LegEventType = LEG_EVENT_NOT_ORDERED; private Integer LegEventType = LEG_EVENT_NOT_ORDERED;
private SyncLegData data; private SyncLegData data;
private Integer ifRouteRequestSync; //是否是差旅申请单同步方式
// public LegSyncCommand legId(Long LegId) { // public LegSyncCommand legId(Long LegId) {
// this.setLegId(LegId); // this.setLegId(LegId);

View File

@ -113,17 +113,14 @@ public class ScheduleDetail {
@JsonProperty("EndCountryCode") @JsonProperty("EndCountryCode")
protected String EndCountryCode; protected String EndCountryCode;
@JsonProperty("EndCountryName") @JsonProperty("EndCountryName")
protected String EndCountryName; protected String EndCountryName;
@JsonProperty("RealScheduleNum") @JsonProperty("RealScheduleNum")
protected String RealScheduleNum; protected String RealScheduleNum;
@JsonProperty("NightCount") @JsonProperty("NightCount")
protected String NightCount; protected String NightCount;
@JsonProperty("RoomCount") @JsonProperty("RoomCount")
protected String RoomCount; protected String RoomCount;
@JsonProperty("AmountTypeName") @JsonProperty("AmountTypeName")
private String amountTypeName; private String amountTypeName;
@JsonProperty("AmountTypeEnName") @JsonProperty("AmountTypeEnName")
@ -136,6 +133,14 @@ public class ScheduleDetail {
private String destinationDescription; private String destinationDescription;
@JsonProperty("EstimatedAmount") @JsonProperty("EstimatedAmount")
private String estimatedAmount; private String estimatedAmount;
@JsonProperty("travelType")
private String travelType;
@JsonProperty("expenseTypeId")
private String expenseTypeId;
@JsonProperty("LocationList") @JsonProperty("LocationList")
@Transient @Transient
private List<LocationRes> locationList; private List<LocationRes> locationList;
@ -150,6 +155,16 @@ public class ScheduleDetail {
private ScheduleDetail scheduleDetail = new ScheduleDetail(); private ScheduleDetail scheduleDetail = new ScheduleDetail();
public ScheduleDetailBuilder expenseTypeId(String expenseTypeId) {
scheduleDetail.setExpenseTypeId(expenseTypeId);
return this;
}
public ScheduleDetailBuilder travelType(String travelType) {
scheduleDetail.setTravelType(travelType);
return this;
}
public ScheduleDetailBuilder serviceProvider(String serviceProvider) { public ScheduleDetailBuilder serviceProvider(String serviceProvider) {
scheduleDetail.setServiceProvider(serviceProvider); scheduleDetail.setServiceProvider(serviceProvider);
return this; return this;

View File

@ -0,0 +1,40 @@
package com.chint.application.in;
import com.chint.domain.service.RouteRequestDomainService;
import com.chint.domain.value_object.SyncLegData;
import com.chint.infrastructure.util.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import static com.chint.infrastructure.constant.CommonMessageConstant.SUCCESS;
@RestController
@RequestMapping("/route/request")
public class RouteRequestController {
@Autowired
private RouteRequestDomainService routeRequestDomainService;
@Transactional
@ApiOperation("同步行程规划单到差旅平台")
@PostMapping("/sync/whole")
public Result<String> syncRouterOrder(@RequestBody SyncLegData syncLegData) {
routeRequestDomainService.syncRouteRequestToSupplier(syncLegData);
return Result.Success(SUCCESS);
}
@Transactional
@ApiOperation("取消行程规划单到差旅平台")
@PostMapping("/sync/whole")
public Result<String> cancelWholeRouterOrder(@RequestBody SyncLegData syncLegData) {
routeRequestDomainService.cancelRouteRequest(syncLegData);
return Result.Success(SUCCESS);
}
}

View File

@ -35,11 +35,11 @@ import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import static com.chint.infrastructure.constant.FSSCConstant.*; import static com.chint.infrastructure.constant.FSSCConstant.*;
import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_HOTEL; import static com.chint.infrastructure.constant.LegConstant.*;
import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_OTHER;
import static com.chint.infrastructure.constant.LocationConstant.LOCATION_LEVEL_CITY; import static com.chint.infrastructure.constant.LocationConstant.LOCATION_LEVEL_CITY;
import static com.chint.infrastructure.constant.LocationConstant.LOCATION_LEVEL_COUNTY; import static com.chint.infrastructure.constant.LocationConstant.LOCATION_LEVEL_COUNTY;
import static com.chint.infrastructure.constant.OrderConstant.*; import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_CANCEL_NAME;
import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_PREPARE_NAME;
import static com.chint.infrastructure.constant.RouteConstant.*; import static com.chint.infrastructure.constant.RouteConstant.*;
@Service @Service
@ -377,8 +377,6 @@ public class OrderQuery {
.type(FSSCConstant.TRIP_CALLBACK_TYPE_APPROVE); .type(FSSCConstant.TRIP_CALLBACK_TYPE_APPROVE);
List<Location> locationListAfterNotNull = locationList.stream().filter(Objects::nonNull).toList(); List<Location> locationListAfterNotNull = locationList.stream().filter(Objects::nonNull).toList();
// List<CityEntity> cityEntities = new ArrayList<>();
for (Location location : locationListAfterNotNull) { for (Location location : locationListAfterNotNull) {
if (location.getLocationEnName() == null) { if (location.getLocationEnName() == null) {
@ -398,10 +396,6 @@ public class OrderQuery {
} }
locationRepository.saveAll(List.of(location)); locationRepository.saveAll(List.of(location));
} }
// CityEntity city = cityRepository.findByCityName(location.getLocationName());
// cityEntities.add(city);
callbackDataBuilder.cityList() callbackDataBuilder.cityList()
.cityName(location.getLocationName()) .cityName(location.getLocationName())
.cityEnName(location.getLocationEnName()) .cityEnName(location.getLocationEnName())
@ -411,18 +405,12 @@ public class OrderQuery {
List<ScheduleDetail> scheduleDetails = legItems.stream() List<ScheduleDetail> scheduleDetails = legItems.stream()
.map(leg -> { .map(leg -> {
leg.reloadStatus(); leg.reloadStatus();
// CityEntity originCity;
// CityEntity destinationCity;
ScheduleDetail.ScheduleDetailBuilder scheduleDetailBuilder = ScheduleDetail ScheduleDetail.ScheduleDetailBuilder scheduleDetailBuilder = ScheduleDetail
.builder() .builder()
.legId(leg.getLegId()); .legId(leg.getLegId());
if (!leg.getLegType().equals(LEG_TYPE_OTHER)) { if (!leg.getLegType().equals(LEG_TYPE_OTHER)) {
Location originLocation = leg.getOriginLocation(); Location originLocation = leg.getOriginLocation();
if (originLocation != null) { if (originLocation != null) {
// originCity = cityEntities.stream().filter(cityEntity -> cityEntity
// .getCityName()
// .equals(leg.getOriginLocation().getLocationName()))
// .findFirst().orElseThrow(() -> new NotFoundException(NOT_FOUND));
scheduleDetailBuilder scheduleDetailBuilder
.startCity(originLocation.getLocationName()) .startCity(originLocation.getLocationName())
.startCityName(originLocation.getLocationName()) .startCityName(originLocation.getLocationName())
@ -468,8 +456,15 @@ public class OrderQuery {
} }
} }
if (leg.getLegType().equals(LEG_TYPE_OTHER) && Objects.requireNonNull(leg.getLegExtensionField()).getAmountType().equals(LEG_OTHER_AMOUNT_TYPE_VISA)) {
scheduleDetailBuilder.expenseTypeId("6770f575013211eabce29fde958f48e4")
.travelType("LOCAL_OTHER")
.scheduleType("VISA");
} else {
scheduleDetailBuilder.scheduleType(translateLegType(leg.getLegType()));
}
return scheduleDetailBuilder return scheduleDetailBuilder
.scheduleType(translateLegType(leg.getLegType()))
.scheduleNum(leg.getLegNo()) .scheduleNum(leg.getLegNo())
.startDate(simpleFormatter.format(leg.getStartTime())) .startDate(simpleFormatter.format(leg.getStartTime()))
.endDate(simpleFormatter.format(leg.getEndTime())) .endDate(simpleFormatter.format(leg.getEndTime()))

View File

@ -1,18 +1,27 @@
package com.chint.domain.aggregates.base; package com.chint.domain.aggregates.base;
import lombok.Data; import lombok.Data;
import org.springframework.data.annotation.Transient;
import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Map; import java.util.Map;
@Data @Data
public abstract class BaseEvent { public abstract class BaseEvent implements Serializable {
@Serial
private static final long serialVersionUID = 2131240986128456190L;
private Integer eventType; private Integer eventType;
@Transient
private transient String eventName; private transient String eventName;
private LocalDateTime happenTime; private LocalDateTime happenTime = LocalDateTime.now();
private String extension;
// 新增抽象方法获取状态码与状态名称的映射表 // 新增抽象方法获取状态码与状态名称的映射表
protected abstract Map<Integer, String> getStatusMappings(); protected abstract Map<Integer, String> getStatusMappings();

View File

@ -1,23 +1,21 @@
package com.chint.domain.aggregates.base; package com.chint.domain.aggregates.base;
import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.NoSuchElementException;
public interface EventManageable { public interface EventManageable {
// 抽象方法获取事件列表 // 抽象方法获取事件列表
List<BaseEvent> getEvents(); List<? extends BaseEvent> getEvents();
// 默认方法添加事件 // 默认方法添加事件
default void addEvent(BaseEvent event) { default void addEvent(BaseEvent event) {
getEvents().add(event); List<BaseEvent> events = (List<BaseEvent>) getEvents();
events.add(event);
} }
// 默认方法获取最新的事件 // 默认方法获取最新的事件
default BaseEvent getLastEvent() { default BaseEvent getLastEvent() {
return getEvents().stream() List<? extends BaseEvent> eventList = getEvents();
.max(Comparator.comparing(BaseEvent::getHappenTime)) return eventList.isEmpty() ? null : eventList.get(eventList.size() - 1);
.orElseThrow(() -> new NoSuchElementException("No events found."));
} }
} }

View File

@ -159,6 +159,14 @@ public class RouteOrder implements Serializable {
return this; return this;
} }
public RouteOrder addRouteRequest(RouteRequest routeRequest) {
if (this.routeRequestList == null) {
this.routeRequestList = new ArrayList<>();
}
this.routeRequestList.add(routeRequest);
return this;
}
public RouteOrder deleteLeg(String legNo) { public RouteOrder deleteLeg(String legNo) {
if (this.legItems == null || this.legItems.isEmpty()) { if (this.legItems == null || this.legItems.isEmpty()) {
return this; return this;

View File

@ -1,7 +1,7 @@
package com.chint.domain.aggregates.order; package com.chint.domain.aggregates.order;
import com.chint.domain.aggregates.base.BaseEntity; import com.chint.domain.aggregates.base.BaseEvent;
import com.chint.domain.aggregates.base.BaseTimeEntity; import com.chint.domain.aggregates.base.EventManageable;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
@ -19,7 +19,7 @@ import java.util.List;
@Data @Data
@Table("route_request") @Table("route_request")
public class RouteRequest implements Serializable { public class RouteRequest implements Serializable, EventManageable {
@Serial @Serial
private static final long serialVersionUID = 7125989663091861990L; private static final long serialVersionUID = 7125989663091861990L;
@ -32,14 +32,17 @@ public class RouteRequest implements Serializable {
private String RouteRequestNo; private String RouteRequestNo;
private String supplier;
@MappedCollection(idColumn = "route_request_id", keyColumn = "route_request_key") @MappedCollection(idColumn = "route_request_id", keyColumn = "route_request_key")
private List<RouteRequestLeg> routeRequestLegList; private List<RouteRequestLeg> routeRequestLegList;
@MappedCollection(idColumn = "route_request_id", keyColumn = "route_request_key") @MappedCollection(idColumn = "route_request_id", keyColumn = "route_request_key")
private List<RouteRequestEvent> eventList; private List<RouteRequestEvent> eventList;
@Transient @MappedCollection(idColumn = "route_request_id")
private String supplier; private RouteRequestFields routeRequestFields;
@Transient @Transient
private Integer status; private Integer status;
@Transient @Transient
@ -54,4 +57,22 @@ public class RouteRequest implements Serializable {
@ApiModelProperty("最后更新时间") @ApiModelProperty("最后更新时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
public LocalDateTime updateTime; public LocalDateTime updateTime;
@Override
public List<RouteRequestEvent> getEvents() {
return this.eventList;
}
public RouteRequest reloadStatus() {
BaseEvent lastEvent = this.getLastEvent().reloadStatus();
this.status = lastEvent.getEventType();
this.statusName = lastEvent.getEventName();
return this;
}
public RouteRequest reloadGenerateRequestLegs(List<Leg> legList) {
List<RouteRequestLeg> routeRequestLegs = legList.stream().map(RouteRequestLeg::ofLeg).toList();
this.setRouteRequestLegList(routeRequestLegs);
return this;
}
} }

View File

@ -1,16 +1,19 @@
package com.chint.domain.aggregates.order; package com.chint.domain.aggregates.order;
import com.chint.domain.aggregates.base.BaseEvent;
import lombok.Data; import lombok.Data;
import org.springframework.data.annotation.Id; import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.mapping.Table; 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.util.Map;
import static com.chint.infrastructure.constant.RouteRequestConstant.*;
@Data @Data
@Table("route_request_event") @Table("route_request_event")
public class RouteRequestEvent implements Serializable { public class RouteRequestEvent extends BaseEvent implements Serializable {
@Serial @Serial
private static final long serialVersionUID = 5421219887361331990L; private static final long serialVersionUID = 5421219887361331990L;
@ -21,10 +24,30 @@ public class RouteRequestEvent implements Serializable {
private Long routeRequestKey; private Long routeRequestKey;
private Integer eventType; @Override
protected Map<Integer, String> getStatusMappings() {
private String extension; return Map.of(ROUTE_REQUEST_STATUS_PREPARE, ROUTE_REQUEST_STATUS_PREPARE_NAME,
ROUTE_REQUEST_STATUS_SYNC, ROUTE_REQUEST_STATUS_SYNC_NAME,
private LocalDateTime happenTime; ROUTE_REQUEST_STATUS_CANCEL, ROUTE_REQUEST_STATUS_CANCEL_NAME);
}
public static RouteRequestEvent prepare(){
RouteRequestEvent routeRequestEvent = new RouteRequestEvent();
routeRequestEvent.setEventType(ROUTE_REQUEST_STATUS_PREPARE);
return routeRequestEvent;
}
public static RouteRequestEvent sync(String supplierName){
RouteRequestEvent routeRequestEvent = new RouteRequestEvent();
routeRequestEvent.setEventType(ROUTE_REQUEST_STATUS_SYNC);
routeRequestEvent.setExtension(supplierName);
return routeRequestEvent;
}
public static RouteRequestEvent cancel(String supplierName){
RouteRequestEvent routeRequestEvent = new RouteRequestEvent();
routeRequestEvent.setEventType(ROUTE_REQUEST_STATUS_CANCEL);
routeRequestEvent.setExtension(supplierName);
return routeRequestEvent;
}
} }

View File

@ -0,0 +1,44 @@
package com.chint.domain.aggregates.order;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.mapping.Table;
import java.io.Serial;
import java.io.Serializable;
@Data
@Table("route_request_fields")
public class RouteRequestFields implements Serializable {
@Serial
private static final long serialVersionUID = 1231256770986228990L;
@Id
private Long id;
private Long routeRequestId;
@ApiModelProperty("差表等级")
private String standardLevel;
@ApiModelProperty("系统标识")
private String sysCode;
@ApiModelProperty("实际单号")
private String actualOrderNo;
@ApiModelProperty("入账公司编码")
private String accountCompany;
@ApiModelProperty("入账公司名称")
private String accountCompanyName;
@ApiModelProperty("入账公司64位编码")
private String accountCompanyCode;
@ApiModelProperty("费用归属部门")
private String belongDeptCode;
@ApiModelProperty("项目名称")
private String projectName;
@ApiModelProperty("成本中心")
private String costCenter;
@ApiModelProperty("申请说明")
private String instructions;
@ApiModelProperty("财务共享订单创建人")
private String creator;
@ApiModelProperty("申请人")
private String userId;
}

View File

@ -79,13 +79,17 @@ public class OrderCarRecord extends OrderBaseRecord {
public OrderCarRecord loadTravelInfo(String startTime, public OrderCarRecord loadTravelInfo(String startTime,
String arriveTime, String arriveTime,
String fromCity, String fromCity,
String toCity String toCity,
String fromStationName,
String toStationName
) { ) {
// 行程信息 // 行程信息
this.setFromCity(fromCity); this.setFromCity(fromCity);
this.setToCity(toCity); this.setToCity(toCity);
this.setStartTime(startTime); this.setStartTime(startTime);
this.setArriveTime(arriveTime); this.setArriveTime(arriveTime);
this.setFromStationName(fromStationName);
this.setToStationName(toStationName);
return this; return this;
} }

View File

@ -20,6 +20,7 @@ public class CTripCarRecord implements Serializable {
private String recordId; private String recordId;
private LocalDateTime createTime; private LocalDateTime createTime;
private String routeOrderNo; private String routeOrderNo;
private String orderDate;
@MappedCollection(idColumn = "c_trip_car_record_id") @MappedCollection(idColumn = "c_trip_car_record_id")
private CTripCarRecordBase cTripCarRecordBase; private CTripCarRecordBase cTripCarRecordBase;
@MappedCollection(idColumn = "c_trip_car_record_id") @MappedCollection(idColumn = "c_trip_car_record_id")

View File

@ -6,11 +6,19 @@ import com.chint.domain.aggregates.order.RouteOrder;
import com.chint.domain.aggregates.order.RouteRequest; import com.chint.domain.aggregates.order.RouteRequest;
import com.chint.domain.value_object.OrderSaveData; import com.chint.domain.value_object.OrderSaveData;
import java.util.List;
public interface OrderFactory { public interface OrderFactory {
RouteOrder createRoute(OrderSaveData orderData); RouteOrder createRoute(OrderSaveData orderData);
RouteOrder createRoute(OrderCreateCommand command); RouteOrder createRoute(OrderCreateCommand command);
ApprovalEvent createApprovalEvent(Integer eventType); ApprovalEvent createApprovalEvent(Integer eventType);
RouteRequest createRequestWithLeg(RouteOrder routeOrder, List<Long> legIds);
RouteRequest createRequestWithAllLeg(RouteOrder routeOrder);
RouteRequest createRequestByRoute(RouteOrder routeOrder); RouteRequest createRequestByRoute(RouteOrder routeOrder);
} }

View File

@ -1,5 +1,6 @@
package com.chint.domain.factoriy.order; package com.chint.domain.factoriy.order;
import cn.hutool.core.bean.BeanUtil;
import com.chint.application.commands.OrderCreateCommand; import com.chint.application.commands.OrderCreateCommand;
import com.chint.domain.aggregates.order.*; import com.chint.domain.aggregates.order.*;
import com.chint.domain.aggregates.user.User; import com.chint.domain.aggregates.user.User;
@ -26,7 +27,6 @@ public class RouteOrderFactory implements OrderFactory {
private String envMark; private String envMark;
@Override @Override
public RouteOrder createRoute(OrderSaveData orderData) { public RouteOrder createRoute(OrderSaveData orderData) {
User currentUser = BaseContext.getCurrentUser(); User currentUser = BaseContext.getCurrentUser();
@ -82,10 +82,42 @@ public class RouteOrderFactory implements OrderFactory {
return approvalEvent; return approvalEvent;
} }
@Override
public RouteRequest createRequestWithLeg(RouteOrder routeOrder, List<Long> legIds) {
RouteRequest requestByRoute = createRequestByRoute(routeOrder);
List<RouteRequestLeg> routeRequestLegs = routeOrder
.getLegItems()
.stream()
.filter(it -> legIds.contains(it.getLegId()))
.map(RouteRequestLeg::ofLeg)
.toList();
requestByRoute.setRouteRequestLegList(routeRequestLegs);
return requestByRoute;
}
@Override
public RouteRequest createRequestWithAllLeg(RouteOrder routeOrder) {
RouteRequest requestByRoute = createRequestByRoute(routeOrder);
List<RouteRequestLeg> routeRequestLegs = routeOrder
.getLegItems()
.stream()
.map(RouteRequestLeg::ofLeg)
.toList();
requestByRoute.setRouteRequestLegList(routeRequestLegs);
return requestByRoute;
}
@Override @Override
public RouteRequest createRequestByRoute(RouteOrder routeOrder) { public RouteRequest createRequestByRoute(RouteOrder routeOrder) {
RouteRequest routeRequest = new RouteRequest(); RouteRequest routeRequest = new RouteRequest();
routeRequest.setRouteRequestNo(OrderNo.generateRouteRequestNo(routeOrder.getRouteOrderNo())); routeRequest.setRouteRequestNo(OrderNo.generateRouteRequestNo(routeOrder.getRouteOrderNo()));
return null; RouteRequestFields routeRequestFields = BeanUtil.copyProperties(routeOrder.getApproveOrderNo(),
RouteRequestFields.class);
routeRequestFields.setUserId(routeOrder.getUserId());
routeRequestFields.setBelongDeptCode(routeOrder.getRouterOrderExtensionField().getBelongDeptCode());
routeRequestFields.setStandardLevel(routeOrder.getStandardLevel());
routeRequest.setRouteRequestFields(routeRequestFields);
routeRequest.addEvent(RouteRequestEvent.prepare());
return routeRequest;
} }
} }

View File

@ -3,10 +3,8 @@ package com.chint.domain.factoriy.order_detail;
import com.chint.domain.aggregates.order.*; import com.chint.domain.aggregates.order.*;
import com.chint.domain.aggregates.user.User; import com.chint.domain.aggregates.user.User;
import com.chint.domain.exceptions.NotFoundException; import com.chint.domain.exceptions.NotFoundException;
import com.chint.domain.repository.LocationRepository; import com.chint.domain.repository.*;
import com.chint.domain.repository.OrderDetailRepository; import com.chint.domain.service.RouteRequestDomainService;
import com.chint.domain.repository.RouteRepository;
import com.chint.domain.repository.UserRepository;
import com.chint.infrastructure.util.BigDecimalCalculator; import com.chint.infrastructure.util.BigDecimalCalculator;
import com.chint.interfaces.rest.ctrip.dto.search.car.*; import com.chint.interfaces.rest.ctrip.dto.search.car.*;
import com.chint.interfaces.rest.ctrip.dto.search.flight.*; import com.chint.interfaces.rest.ctrip.dto.search.flight.*;
@ -46,6 +44,13 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory {
@Autowired @Autowired
private OrderDetailFactory orderDetailFactory; private OrderDetailFactory orderDetailFactory;
@Autowired
private RouteRequestRepository routeRequestRepository;
@Autowired
private RouteRequestDomainService routeRequestDomainService;
@Override @Override
public CarOrderDetail createCarOrderDetail(Object carOrderDetailData) { public CarOrderDetail createCarOrderDetail(Object carOrderDetailData) {
//获取基础信息数据 //获取基础信息数据
@ -53,7 +58,7 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory {
CarBasicInfo carBasicInfo = carQuickOrderInfoEntity.getBasicInfo(); CarBasicInfo carBasicInfo = carQuickOrderInfoEntity.getBasicInfo();
String orderNo = carBasicInfo.getOrderId(); String orderNo = carBasicInfo.getOrderId();
String journeyNo = carBasicInfo.getJourneyID(); String journeyNo = carBasicInfo.getJourneyID();
RouteOrder routeOrder = routeRepository.findByOrderNo(journeyNo); RouteOrder routeOrder = routeRequestDomainService.getRouteOrder(journeyNo);
OrderDetail orderDetail = routeOrder.getOrderDetails() OrderDetail orderDetail = routeOrder.getOrderDetails()
.stream() .stream()
.filter(it -> it.getOrderNo().equals(orderNo)) .filter(it -> it.getOrderNo().equals(orderNo))
@ -156,7 +161,7 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory {
BasicInfo flightOrderBasicInfo = flightOrderInfoEntity.getBasicInfo(); BasicInfo flightOrderBasicInfo = flightOrderInfoEntity.getBasicInfo();
String orderNo = flightOrderBasicInfo.getOrderID(); String orderNo = flightOrderBasicInfo.getOrderID();
String journeyNo = flightOrderBasicInfo.getJourneyID(); String journeyNo = flightOrderBasicInfo.getJourneyID();
RouteOrder routeOrder = routeRepository.findByOrderNo(journeyNo); RouteOrder routeOrder = routeRequestDomainService.getRouteOrder(journeyNo);
Optional<OrderDetail> first = routeOrder Optional<OrderDetail> first = routeOrder
.getOrderDetails() .getOrderDetails()
@ -359,7 +364,7 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory {
Optional<OrderDetail> byOrderNo = orderDetailRepository.findByOrderNo(orderNo); Optional<OrderDetail> byOrderNo = orderDetailRepository.findByOrderNo(orderNo);
String journeyNo = hotelOrderInfoEntity.getJourneyNo(); String journeyNo = hotelOrderInfoEntity.getJourneyNo();
RouteOrder routeOrder = routeRepository.findByOrderNo(journeyNo).reloadStatus(); RouteOrder routeOrder = routeRequestDomainService.getRouteOrder(journeyNo).reloadStatus();
ApproveOrderNo approveOrderNo = null; ApproveOrderNo approveOrderNo = null;
User user = null; User user = null;

View File

@ -6,6 +6,7 @@ import com.chint.domain.aggregates.user.User;
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.domain.repository.UserRepository; import com.chint.domain.repository.UserRepository;
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;
@ -56,8 +57,12 @@ public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory {
@Autowired @Autowired
private OrderDetailFactory orderDetailFactory; private OrderDetailFactory orderDetailFactory;
@Autowired
private RouteRequestRepository routeRequestRepository;
private DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss"); private DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss");
@Override @Override
public CarOrderDetail createCarOrderDetail(Object carOrderDetailData) { public CarOrderDetail createCarOrderDetail(Object carOrderDetailData) {
CarDetailResponse.DataWrapper data = (CarDetailResponse.DataWrapper) carOrderDetailData; CarDetailResponse.DataWrapper data = (CarDetailResponse.DataWrapper) carOrderDetailData;

View File

@ -109,7 +109,10 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
} }
orderCarRecord.loadTravelInfo(startTime, endTime, orderCarRecord.loadTravelInfo(startTime, endTime,
cTripCarQuickInfo.getDepartureCityName(), cTripCarQuickInfo.getDepartureCityName(),
cTripCarQuickInfo.getArrivalCityName()); cTripCarQuickInfo.getArrivalCityName(),
cTripCarQuickInfo.getDepartureCityName() + cTripCarQuickInfo.getDepartureAddressDetail(),
cTripCarQuickInfo.getArrivalCityName() + cTripCarQuickInfo.getArrivalAddressDetail()
);
// 加载车型和运行信息车类型时间里程 // 加载车型和运行信息车类型时间里程
orderCarRecord.loadVehicleAndTravelInfo(cTripCarQuickInfo.getVehicleName(), orderCarRecord.loadVehicleAndTravelInfo(cTripCarQuickInfo.getVehicleName(),
@ -120,7 +123,7 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
String batchNo = cTripCarRecordBase.getBatchNoStartDate().substring(0, 6); String batchNo = cTripCarRecordBase.getBatchNoStartDate().substring(0, 6);
orderCarRecord.loadFinancialInfo(batchNo, orderCarRecord.loadFinancialInfo(batchNo,
cTripCarRecordBase.getSubAccCheckBatchNo(), cTripCarRecordBase.getSubAccCheckBatchNo(),
String.valueOf(cTripCarRecordBase.getAmount()), String.valueOf(cTripCarRecordBase.getRealAmount()),
String.valueOf(cTripCarRecordBase.getRealAmountHasPost())); String.valueOf(cTripCarRecordBase.getRealAmountHasPost()));
// 加载费用细节, 未税金额税费服务费取消费额外费用额外费用名称 , 携程马上用车产品没有税费和额外费用字段 // 加载费用细节, 未税金额税费服务费取消费额外费用额外费用名称 , 携程马上用车产品没有税费和额外费用字段
@ -172,7 +175,7 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
carOrderDetail.getOriginalOrderNo()) carOrderDetail.getOriginalOrderNo())
.loadBasicOrderInfo(carOrderDetail.getOrderNo(), .loadBasicOrderInfo(carOrderDetail.getOrderNo(),
carOrderDetail.getOrderStatus(), carOrderDetail.getOrderStatus(),
carOrderDetail.getCreateTime()); cTripCarRecord.getOrderDate());
}, () -> orderCarRecord.loadComplianceInfoNot() }, () -> orderCarRecord.loadComplianceInfoNot()
.loadRelatedOrderInfo(cTripCarRecordBase.getOrderId(), .loadRelatedOrderInfo(cTripCarRecordBase.getOrderId(),
cTripCarRecord.getRecordId(), cTripCarRecord.getRecordId(),
@ -182,7 +185,7 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
String.valueOf(cTripCarRecordBase.getOrderId())) String.valueOf(cTripCarRecordBase.getOrderId()))
.loadBasicOrderInfo(String.valueOf(cTripCarRecordBase.getOrderId()), .loadBasicOrderInfo(String.valueOf(cTripCarRecordBase.getOrderId()),
"", "",
cTripCarRecordBase.getCreateTime())); cTripCarRecord.getOrderDate()));
//这里添加归属部门编号 , 这里兼容测试环境 如果行程规划单已经有这个值 那么直接取 没有的话查找用户的部门获取 //这里添加归属部门编号 , 这里兼容测试环境 如果行程规划单已经有这个值 那么直接取 没有的话查找用户的部门获取
Optional<RouterOrderExtensionField> routerOrderExtensionField = byOrderNo Optional<RouterOrderExtensionField> routerOrderExtensionField = byOrderNo

View File

@ -105,7 +105,7 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
//公共字段校验 //公共字段校验
flightFieldCheck(orderFlightRecord, lyOrderFlightRecord); flightFieldCheck(orderFlightRecord, lyOrderFlightRecord);
orderFlightRecord.setDetailId(lyOrderFlightRecord.getBillOrderNo())//防重标识 orderFlightRecord.setDetailId(lyOrderFlightRecord.getBillOrderNo())//防重标识
.setTicketClerk(lyOrderFlightRecord.getReserveManName())//票务员 // .setTicketClerk(lyOrderFlightRecord.getReserveManName())//票务员
.setAccountPeriod(getAccountPeriod(lyOrderFlightRecord.getStatementCode()))//账期号 .setAccountPeriod(getAccountPeriod(lyOrderFlightRecord.getStatementCode()))//账期号
.setBillNo(lyOrderFlightRecord.getBillOrderNo())//账单号 .setBillNo(lyOrderFlightRecord.getBillOrderNo())//账单号
.setOrderNo(lyOrderFlightRecord.getOrderSerialNo())//订单号 .setOrderNo(lyOrderFlightRecord.getOrderSerialNo())//订单号
@ -150,7 +150,7 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
.setBookOrgCode1(lyOrderFlightRecord.getPassengerDepartment()) //出行人组织架构信息1 .setBookOrgCode1(lyOrderFlightRecord.getPassengerDepartment()) //出行人组织架构信息1
.setBookOrgCode2(lyOrderFlightRecord.getPassengerDepartment()) //出行人组织架构信息2 .setBookOrgCode2(lyOrderFlightRecord.getPassengerDepartment()) //出行人组织架构信息2
.setBookOrgCode3(lyOrderFlightRecord.getPassengerDepartment()) //出行人组织架构信息3 .setBookOrgCode3(lyOrderFlightRecord.getPassengerDepartment()) //出行人组织架构信息3
.setOfflineCcomyCode(lyOrderFlightRecord.getPassengerCostCenter()) //成本中心 // .setOfflineCcomyCode(lyOrderFlightRecord.getPassengerCostCenter()) //成本中心
.setOrderStatus("") //结算状态 .setOrderStatus("") //结算状态
// .setExpenseOrderAmount("") //订单金额 // .setExpenseOrderAmount("") //订单金额
// .setSettleOrderFlag() //订单对账状态 // .setSettleOrderFlag() //订单对账状态
@ -195,7 +195,7 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
//公共字段校验 //公共字段校验
hotelFieldCheck(orderHotelRecord, lyOrderHotelRecord); hotelFieldCheck(orderHotelRecord, lyOrderHotelRecord);
orderHotelRecord.setDetailId(lyOrderHotelRecord.getBillOrderNo())//防重标识 orderHotelRecord.setDetailId(lyOrderHotelRecord.getBillOrderNo())//防重标识
.setTicketClerk(lyOrderHotelRecord.getReserveManName()) //票务员 // .setTicketClerk(lyOrderHotelRecord.getReserveManName()) //票务员
.setAccountPeriod(getAccountPeriod(lyOrderHotelRecord.getStatementCode())) //账期号 .setAccountPeriod(getAccountPeriod(lyOrderHotelRecord.getStatementCode())) //账期号
.setBillNo(lyOrderHotelRecord.getBillOrderNo()) //账单号结算单号 .setBillNo(lyOrderHotelRecord.getBillOrderNo()) //账单号结算单号
.setOrderNo(lyOrderHotelRecord.getOrderSerialNo()) //订单号 .setOrderNo(lyOrderHotelRecord.getOrderSerialNo()) //订单号
@ -232,13 +232,13 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
.setTaxAmt("") //税费 .setTaxAmt("") //税费
.setInvoiceType(readInvoiceType(lyOrderHotelRecord.getCustomerInvoiceType())) //供应商发票类型 .setInvoiceType(readInvoiceType(lyOrderHotelRecord.getCustomerInvoiceType())) //供应商发票类型
.setInvoiceFee("") //开票手续费 .setInvoiceFee("") //开票手续费
.setCustodayFee("") //托管费 .setCustodayFee(String.valueOf(lyOrderHotelRecord.getServiceAmount()))//托管费
.setNoTaxCusFee("") //托管费不含税 .setNoTaxCusFee("") //托管费不含税
.setTaxCusFee("") //托管费税费 .setTaxCusFee("") //托管费税费
.setRoomTypeName(lyOrderHotelRecord.getBedType()) //房型 .setRoomTypeName(lyOrderHotelRecord.getBedType()) //房型
.setOrderSource(StringUtils.isNotBlank(lyOrderHotelRecord.getOutApplayOrderNo()) ? "Y" : "N") //预订来源线上/线下 .setOrderSource(StringUtils.isNotBlank(lyOrderHotelRecord.getOutApplayOrderNo()) ? "Y" : "N") //预订来源线上/线下
.setBookOrgCode1(lyOrderHotelRecord.getPassengerDepartment()) //入住人组织架构信息1 .setBookOrgCode1(lyOrderHotelRecord.getPassengerDepartment()) //入住人组织架构信息1
.setOfflineCcomyCode(lyOrderHotelRecord.getPassengerCostCenter()) //成本中心 // .setOfflineCcomyCode(lyOrderHotelRecord.getPassengerCostCenter()) //成本中心
.setOrderStatus("") //结算状态 .setOrderStatus("") //结算状态
// .setExpenseOrderAmount("") //订单金额 // .setExpenseOrderAmount("") //订单金额
// .setSettleOrderFlag() //订单对账状态 // .setSettleOrderFlag() //订单对账状态
@ -259,7 +259,7 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
//酒店订单明细字段赋值 //酒店订单明细字段赋值
private void setHotelRecordDetail(OrderHotelRecord orderHotelRecord, HotelOrderDetail hotelOrderDetail) { private void setHotelRecordDetail(OrderHotelRecord orderHotelRecord, HotelOrderDetail hotelOrderDetail) {
orderHotelRecord.setHotelAddress(hotelOrderDetail.getHotelAddress()) //酒店地址 orderHotelRecord.setHotelAddress(hotelOrderDetail.getHotelAddress()) //酒店地址
.setIsAgreement("".equals(hotelOrderDetail.getAgreementHotel()) ? "1" : "0") //是否协议酒店0否1是 .setIsAgreement(hotelOrderDetail.getAgreementHotel()) //是否协议酒店0否1是
.setRoomCount(Integer.parseInt(StringUtils.isBlank(hotelOrderDetail.getRoomCount()) ? "1" : hotelOrderDetail.getRoomCount())) //房间数 .setRoomCount(Integer.parseInt(StringUtils.isBlank(hotelOrderDetail.getRoomCount()) ? "1" : hotelOrderDetail.getRoomCount())) //房间数
.setStarRate(hotelOrderDetail.getStarRate()) //星级 .setStarRate(hotelOrderDetail.getStarRate()) //星级
.setBookOrgCode2(hotelOrderDetail.getBOOK_ORG_STRUCT_2()) //入住人组织架构信息2 .setBookOrgCode2(hotelOrderDetail.getBOOK_ORG_STRUCT_2()) //入住人组织架构信息2
@ -280,7 +280,7 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
//公共字段校验 //公共字段校验
trainFieldCheck(orderTrainRecord, lyOrderTrainRecord); trainFieldCheck(orderTrainRecord, lyOrderTrainRecord);
orderTrainRecord.setDetailId(lyOrderTrainRecord.getBillOrderNo())//防重标识 orderTrainRecord.setDetailId(lyOrderTrainRecord.getBillOrderNo())//防重标识
.setTicketClerk(lyOrderTrainRecord.getReserveManName()) //票务员 // .setTicketClerk(lyOrderTrainRecord.getReserveManName()) //票务员
.setAccountPeriod(getAccountPeriod(lyOrderTrainRecord.getStatementCode())) //账期号 .setAccountPeriod(getAccountPeriod(lyOrderTrainRecord.getStatementCode())) //账期号
.setBillNo(lyOrderTrainRecord.getBillOrderNo()) //账单号 .setBillNo(lyOrderTrainRecord.getBillOrderNo()) //账单号
.setOrderNo(lyOrderTrainRecord.getOrderSerialNo()) //订单号 .setOrderNo(lyOrderTrainRecord.getOrderSerialNo()) //订单号
@ -303,18 +303,16 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
.setReturnFee(String.valueOf(lyOrderTrainRecord.getRefundFee())) //退票手续费 .setReturnFee(String.valueOf(lyOrderTrainRecord.getRefundFee())) //退票手续费
.setNoTaxAmt("") //未税金额 .setNoTaxAmt("") //未税金额
.setTaxAmt("") //税额 .setTaxAmt("") //税额
.setOrderAmount(String.valueOf(lyOrderTrainRecord.getToBePayAmount())) //结算总额 .setOrderAmount(String.valueOf(lyOrderTrainRecord.getToBePayAmount())); //结算总额
.setFromCity(lyOrderTrainRecord.getTripName()) //出发城市 //设置出发地和到达地
.setFromStationName(lyOrderTrainRecord.getTripName()) //出发站 roadTripName(orderTrainRecord, lyOrderTrainRecord.getTripName());
.setToCity(lyOrderTrainRecord.getTripName()) //到达城市 orderTrainRecord.setIssueTicketTime(lyOrderTrainRecord.getEnterAccount()) //出票时间 yyyy-MM-dd HH:mm:ss
.setToStationName(lyOrderTrainRecord.getTripName()) //到达站
.setIssueTicketTime(lyOrderTrainRecord.getEnterAccount()) //出票时间 yyyy-MM-dd HH:mm:ss
.setTrainNo(lyOrderTrainRecord.getTrainNo()) //车次 .setTrainNo(lyOrderTrainRecord.getTrainNo()) //车次
.setUserCode(lyOrderTrainRecord.getPassengerNo())//出行人编码 .setUserCode(lyOrderTrainRecord.getPassengerNo())//出行人编码
.setUserName(lyOrderTrainRecord.getPassengerName())//出行人姓名 .setUserName(lyOrderTrainRecord.getPassengerName())//出行人姓名
.setOrderSource(StringUtils.isNotBlank(lyOrderTrainRecord.getOutApplayOrderNo()) ? "Y" : "N")//预订来源线上 / 线下 .setOrderSource(StringUtils.isNotBlank(lyOrderTrainRecord.getOutApplayOrderNo()) ? "Y" : "N")//预订来源线上 / 线下
.setBookOrgCode1(lyOrderTrainRecord.getPassengerDepartment())//出行人组织架构信息1 .setBookOrgCode1(lyOrderTrainRecord.getPassengerDepartment())//出行人组织架构信息1
.setOfflineCcomyCode(lyOrderTrainRecord.getPassengerCostCenter())//成本中心 // .setOfflineCcomyCode(lyOrderTrainRecord.getPassengerCostCenter())//成本中心
// .setOrderStatus() //结算状态 // .setOrderStatus() //结算状态
// .setExpenseOrderAmount() //订单金额 // .setExpenseOrderAmount() //订单金额
// .setSettleOrderFlag() //订单对账状态 // .setSettleOrderFlag() //订单对账状态
@ -346,10 +344,26 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
orderTrainRecord.setParentOrderNo(trainOrderDetail.getParentOrderNo())//父级订单号 orderTrainRecord.setParentOrderNo(trainOrderDetail.getParentOrderNo())//父级订单号
.setRunTime(trainOrderDetail.getRunTime()) //时长 .setRunTime(trainOrderDetail.getRunTime()) //时长
.setSeatType(trainOrderDetail.getSeatType())// 座位等级 .setSeatType(trainOrderDetail.getSeatType())// 座位等级
.setFromCity(trainOrderDetail.getFromCity()) //出发城市
.setToCity(trainOrderDetail.getToCity()) //到达城市
.setFromStationName(Optional.ofNullable(orderTrainRecord.getFromStationName())
.orElse(trainOrderDetail.getFromStationName())) // 出发站
.setToStationName(Optional.ofNullable(orderTrainRecord.getToStationName())
.orElse(trainOrderDetail.getToStationName())) // 到达站
.setSeatType(trainOrderDetail.getSeatType())// 座位等级
.setBookOrgCode2(trainOrderDetail.getBOOK_ORG_STRUCT_2())//出行人组织架构信息2 .setBookOrgCode2(trainOrderDetail.getBOOK_ORG_STRUCT_2())//出行人组织架构信息2
.setBookOrgCode3(trainOrderDetail.getBOOK_ORG_STRUCT_3());//出行人组织架构信息3 .setBookOrgCode3(trainOrderDetail.getBOOK_ORG_STRUCT_3());//出行人组织架构信息3
} }
//设置出发 到达站
private void roadTripName(OrderTrainRecord orderTrainRecord, String tripName) {
String[] tripNames = tripName.split("-");
if (tripNames.length == 2) {
orderTrainRecord.setFromStationName(tripNames[0])// 出发站
.setToStationName(tripNames[1]);// 到达站
}
}
private void createCarOrder(OrderCarRecord orderCarRecord, LyOrderCarRecord lyOrderCarRecord) { private void createCarOrder(OrderCarRecord orderCarRecord, LyOrderCarRecord lyOrderCarRecord) {
String orderSerialNo = lyOrderCarRecord.getOrderSerialNo();//订单号 String orderSerialNo = lyOrderCarRecord.getOrderSerialNo();//订单号
AtomicReference<OrderDetail> orderDetailRef = new AtomicReference<>(); AtomicReference<OrderDetail> orderDetailRef = new AtomicReference<>();
@ -363,7 +377,7 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
//公共字段校验 //公共字段校验
carFieldCheck(orderCarRecord, lyOrderCarRecord); carFieldCheck(orderCarRecord, lyOrderCarRecord);
orderCarRecord.setDetailId(lyOrderCarRecord.getBillOrderNo())//防重标识 orderCarRecord.setDetailId(lyOrderCarRecord.getBillOrderNo())//防重标识
.setTicketClerk(lyOrderCarRecord.getReserveManName()) //票务员 // .setTicketClerk(lyOrderCarRecord.getReserveManName()) //票务员
.setAccountPeriod(getAccountPeriod(lyOrderCarRecord.getStatementCode())) //账期号 .setAccountPeriod(getAccountPeriod(lyOrderCarRecord.getStatementCode())) //账期号
.setBillNo(lyOrderCarRecord.getBillOrderNo()); //账单号 .setBillNo(lyOrderCarRecord.getBillOrderNo()); //账单号
orderCarRecord.setReceiptsNum(getReceiptsNum(lyOrderCarRecord.getOutApplayOrderNo(), routeOrder))//关联申请单号 orderCarRecord.setReceiptsNum(getReceiptsNum(lyOrderCarRecord.getOutApplayOrderNo(), routeOrder))//关联申请单号
@ -391,7 +405,7 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
.setComyPayAmt(String.valueOf(lyOrderCarRecord.getToBePayAmount())) //公司统付金额 .setComyPayAmt(String.valueOf(lyOrderCarRecord.getToBePayAmount())) //公司统付金额
.setBookOrgCode1(lyOrderCarRecord.getPassengerDepartment()) //用车人组织架构信息1 .setBookOrgCode1(lyOrderCarRecord.getPassengerDepartment()) //用车人组织架构信息1
.setPaymentType(String.valueOf(getPaymentType(lyOrderCarRecord.getPayType()))) //"付款方式0公司统付 1个人付 2混付" .setPaymentType(String.valueOf(getPaymentType(lyOrderCarRecord.getPayType()))) //"付款方式0公司统付 1个人付 2混付"
.setOfflineCcomyCode(lyOrderCarRecord.getPassengerDepartment()) //成本中心 // .setOfflineCcomyCode(lyOrderCarRecord.getPassengerDepartment()) //成本中心
.setOrderSource(StringUtils.isNotBlank(lyOrderCarRecord.getOutApplayOrderNo()) ? "Y" : "N") //预订来源线上/线下 .setOrderSource(StringUtils.isNotBlank(lyOrderCarRecord.getOutApplayOrderNo()) ? "Y" : "N") //预订来源线上/线下
// .setExpenseOrderAmount() //订单金额 // .setExpenseOrderAmount() //订单金额
// .setSettleOrderFlag() //订单对账状态 // .setSettleOrderFlag() //订单对账状态
@ -485,7 +499,8 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
if (StringUtils.isBlank(orderFlightRecord.getProjectOrderNo())) { if (StringUtils.isBlank(orderFlightRecord.getProjectOrderNo())) {
findProjectOrderNo(tripSubmitItemList).ifPresent(orderFlightRecord::setProjectOrderNo);//项目订单号 findProjectOrderNo(tripSubmitItemList).ifPresent(orderFlightRecord::setProjectOrderNo);//项目订单号
} }
//成本中心
findCostCenter(tripSubmitItemList).ifPresent(orderFlightRecord::setOfflineCcomyCode);
} }
public void hotelFieldCheck(OrderHotelRecord orderHotelRecord, LyOrderHotelRecord lyOrderHotelRecord) { public void hotelFieldCheck(OrderHotelRecord orderHotelRecord, LyOrderHotelRecord lyOrderHotelRecord) {
@ -508,7 +523,8 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
if (StringUtils.isBlank(orderHotelRecord.getProjectOrderNo())) { if (StringUtils.isBlank(orderHotelRecord.getProjectOrderNo())) {
findProjectOrderNo(tripSubmitItemList).ifPresent(orderHotelRecord::setProjectOrderNo);//项目订单号 findProjectOrderNo(tripSubmitItemList).ifPresent(orderHotelRecord::setProjectOrderNo);//项目订单号
} }
//成本中心
findCostCenter(tripSubmitItemList).ifPresent(orderHotelRecord::setOfflineCcomyCode);
} }
public void trainFieldCheck(OrderTrainRecord orderTrainRecord, LyOrderTrainRecord lyOrderTrainRecord) { public void trainFieldCheck(OrderTrainRecord orderTrainRecord, LyOrderTrainRecord lyOrderTrainRecord) {
@ -531,7 +547,8 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
if (StringUtils.isBlank(orderTrainRecord.getProjectOrderNo())) { if (StringUtils.isBlank(orderTrainRecord.getProjectOrderNo())) {
findProjectOrderNo(tripSubmitItemList).ifPresent(orderTrainRecord::setProjectOrderNo);//项目订单号 findProjectOrderNo(tripSubmitItemList).ifPresent(orderTrainRecord::setProjectOrderNo);//项目订单号
} }
//成本中心
findCostCenter(tripSubmitItemList).ifPresent(orderTrainRecord::setOfflineCcomyCode);
} }
public void carFieldCheck(OrderCarRecord orderCarRecord, LyOrderCarRecord lyOrderCarRecord) { public void carFieldCheck(OrderCarRecord orderCarRecord, LyOrderCarRecord lyOrderCarRecord) {
@ -554,7 +571,8 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
if (StringUtils.isBlank(orderCarRecord.getProjectOrderNo())) { if (StringUtils.isBlank(orderCarRecord.getProjectOrderNo())) {
findProjectOrderNo(tripSubmitItemList).ifPresent(orderCarRecord::setProjectOrderNo);//项目订单号 findProjectOrderNo(tripSubmitItemList).ifPresent(orderCarRecord::setProjectOrderNo);//项目订单号
} }
//成本中心
findCostCenter(tripSubmitItemList).ifPresent(orderCarRecord::setOfflineCcomyCode);
} }
//对应所属系统 //对应所属系统
@ -599,6 +617,13 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
.map(TripSubmitItemList::getContent); .map(TripSubmitItemList::getContent);
} }
//成本中心
public Optional<String> findCostCenter(List<TripSubmitItemList> tripSubmitItemList) {
return tripSubmitItemList.stream()
.filter(item -> LY_CUSTOM5.equals(item.getCode()))
.findFirst()
.map(TripSubmitItemList::getContent);
}
//获取财务共享单号 //获取财务共享单号
private String getReceiptsNum(String outApplayOrderNo, RouteOrder routeOrder) { private String getReceiptsNum(String outApplayOrderNo, RouteOrder routeOrder) {

View File

@ -8,6 +8,8 @@ import java.util.List;
public interface LegRepository { public interface LegRepository {
Leg save(Leg leg); Leg save(Leg leg);
List<Leg> findByIds(List<Long> legIds);
void deleteById(Leg leg); void deleteById(Leg leg);
void deleteByLegNo(String legNo); void deleteByLegNo(String legNo);

View File

@ -0,0 +1,8 @@
package com.chint.domain.repository;
import com.chint.domain.aggregates.order.RouteRequest;
public interface RouteRequestRepository {
RouteRequest findByRouteRequestNo(String routeRequestNo);
}

View File

@ -1,12 +1,10 @@
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.LegEvent;
import com.chint.domain.aggregates.order.OrderDetail;
import com.chint.domain.aggregates.order.RouteOrder;
import com.chint.domain.exceptions.LegEventException; import com.chint.domain.exceptions.LegEventException;
import com.chint.domain.factoriy.leg_event.LegEventFactory; import com.chint.domain.factoriy.leg_event.LegEventFactory;
import com.chint.domain.repository.LegRepository; import com.chint.domain.repository.LegRepository;
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 com.chint.infrastructure.constant.LegConstant;
@ -34,6 +32,9 @@ public class LegDomainService {
@Autowired @Autowired
private RouteRepository routeRepository; private RouteRepository routeRepository;
@Autowired
private LocationRepository locationRepository;
public Leg legCheckOrder(Leg leg) { public Leg legCheckOrder(Leg leg) {
List<OrderDetail> orderDetailList = orderDetailRepository.findByLegId(leg.getLegId()); List<OrderDetail> orderDetailList = orderDetailRepository.findByLegId(leg.getLegId());
orderDetailList.forEach(OrderDetail::reloadStatus); orderDetailList.forEach(OrderDetail::reloadStatus);
@ -115,4 +116,29 @@ public class LegDomainService {
} }
return leg; return leg;
} }
public List<Leg> queryLocation(List<Leg> list) {
list.forEach(leg -> {
LegExtensionField legExtensionField = leg.getLegExtensionField();
if (legExtensionField != null && legExtensionField.getLocationIds() != null) {
List<Long> locationIdsAsLong;
if (legExtensionField.getLocationIds().startsWith("[")) {
locationIdsAsLong = legExtensionField.getLocationIdsAsLongFromArray();
} else {
locationIdsAsLong = legExtensionField.getLocationIdsAsLong();
}
List<Location> byNameList = locationRepository.findByNameList(locationIdsAsLong);
legExtensionField.setLocationList(byNameList);
}
if (leg.getOriginId() != null) {
leg.setOriginLocation(locationRepository.findByLocationId(leg.getOriginId()));
}
if (leg.getDestinationId() != null) {
leg.setDestinationLocation(locationRepository.findByLocationId(leg.getDestinationId()));
}
});
return list;
}
} }

View File

@ -0,0 +1,125 @@
package com.chint.domain.service;
import com.chint.domain.aggregates.order.Leg;
import com.chint.domain.aggregates.order.RouteOrder;
import com.chint.domain.aggregates.order.RouteRequest;
import com.chint.domain.aggregates.order.RouteRequestEvent;
import com.chint.domain.factoriy.order.RouteOrderFactory;
import com.chint.domain.repository.LegRepository;
import com.chint.domain.repository.RouteRepository;
import com.chint.domain.repository.RouteRequestRepository;
import com.chint.domain.service.order_sync.SyncAdapter;
import com.chint.domain.value_object.SyncLegData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Optional;
import static com.chint.infrastructure.constant.RouteRequestConstant.ROUTE_REQUEST_STATUS_PREPARE;
@Service
public class RouteRequestDomainService {
@Autowired
private SyncAdapter syncAdapter;
@Autowired
private RouteOrderFactory routeOrderFactory;
@Autowired
private RouteRepository routeRepository;
@Autowired
private LegDomainService legDomainService;
@Autowired
private LegRepository legRepository;
@Autowired
private RouteRequestRepository routeRequestRepository;
public RouteRequest syncRouteRequestToSupplier(SyncLegData syncLegData) {
RouteOrder routeOrder = routeRepository.queryById(syncLegData.getRouteId());
List<Long> legIds = syncLegData.getLegIds();
RouteRequest routeRequest = getRouteRequest(routeOrder, legIds, syncLegData.getSupplierName());
if (routeRequest.getStatus().equals(ROUTE_REQUEST_STATUS_PREPARE)) {
//如果是刚生成的订单需要加入行程规划单当中
//保存供应商信息
routeRequest.setSupplier(syncLegData.getSupplierName());
routeOrder.addRouteRequest(routeRequest);
} else {
//如果是不是刚生成的需要调整差旅申请单的行程
loadLegInfo(routeRequest, routeOrder, legIds);
}
syncAdapter.of(syncLegData.getSupplierName()).syncRouteRequest(routeRequest);
routeRequest.addEvent(RouteRequestEvent.sync(syncLegData.getSupplierName()));
//通过保存聚合根来保存差旅申请单
routeRepository.save(routeOrder);
return routeRequest;
}
public void cancelRouteRequest(SyncLegData syncLegData) {
Long routeId = syncLegData.getRouteId();
RouteOrder routeOrder = routeRepository.queryById(routeId);
Optional<RouteRequest> optionalRouteRequest;
if (syncLegData.getRouteRequestId() != null) {
//如果指定的对应的差旅申请单 那么取消对应的差旅申请单
optionalRouteRequest = routeOrder.getRouteRequestList()
.stream()
.filter(it -> it.getId().equals(syncLegData.getRouteRequestId()))
.findFirst();
} else {
//如果指定的行程单号和供应商 该供应商对应的差旅申请单
optionalRouteRequest = routeOrder.getRouteRequestList()
.stream()
.filter(it -> it.getSupplier().equals(syncLegData.getSupplierName()))
.findFirst();
}
optionalRouteRequest.ifPresent(it -> {
it.addEvent(RouteRequestEvent.cancel(it.getSupplier()));
syncAdapter.of(it.getSupplier()).cancelRouteRequest(it);
});
routeRepository.save(routeOrder);
}
//获取目前已经同步到供应商的差旅申请单
private RouteRequest getRouteRequest(RouteOrder routeOrder, List<Long> legIds, String supplier) {
Optional<RouteRequest> optionalRouteRequest = routeOrder
.getRouteRequestList()
.stream()
.filter(it -> it.getSupplier().equals(supplier))
.findFirst();
if (legIds == null || legIds.isEmpty()) {
List<Long> allLegIds = routeOrder.getLegItems().stream().map(Leg::getLegId).toList();
return optionalRouteRequest
.orElseGet(() -> routeOrderFactory.createRequestWithLeg(routeOrder, allLegIds)).reloadStatus();
} else {
return optionalRouteRequest
.orElseGet(() -> routeOrderFactory.createRequestWithLeg(routeOrder, legIds)).reloadStatus();
}
}
//获取目前已经同步到供应商的差旅申请单
private RouteRequest loadLegInfo(RouteRequest routeRequest, RouteOrder routeOrder, List<Long> legIds) {
List<Leg> legItems = routeOrder.getLegItems();
routeRequest.getRouteRequestLegList().forEach(it ->
legItems.stream()
.filter(leg -> legIds.contains(leg.getLegId()))
.filter(leg -> leg.getLegId().equals(it.getLegId()))
.findFirst()
.ifPresent(it::setLeg));
return routeRequest;
}
public RouteOrder getRouteOrder(String journeyNo) {
RouteOrder byOrderNo = routeRepository.findByOrderNo(journeyNo);
if (byOrderNo == null) {
RouteRequest byRouteRequestNo = routeRequestRepository.findByRouteRequestNo(journeyNo);
byOrderNo = routeRepository.queryById(byRouteRequestNo.getRouteId());
}
return byOrderNo;
}
}

View File

@ -13,6 +13,7 @@ import com.chint.domain.factoriy.order.RouteOrderFactory;
import com.chint.domain.factoriy.order_detail.OrderDetailFactory; import com.chint.domain.factoriy.order_detail.OrderDetailFactory;
import com.chint.domain.repository.*; import com.chint.domain.repository.*;
import com.chint.domain.service.OrderDomainService; import com.chint.domain.service.OrderDomainService;
import com.chint.domain.service.RouteRequestDomainService;
import com.chint.domain.service.order_sync.SyncAdapter; import com.chint.domain.service.order_sync.SyncAdapter;
import com.chint.domain.value_object.ApprovalSimpleData; import com.chint.domain.value_object.ApprovalSimpleData;
import com.chint.domain.value_object.ApproveRouteData; import com.chint.domain.value_object.ApproveRouteData;
@ -88,6 +89,9 @@ public class LegEventHandler implements LegEventService {
@Autowired @Autowired
private OrderDomainService orderDomainService; private OrderDomainService orderDomainService;
@Autowired
private RouteRequestDomainService routeRequestDomainService;
@Value("${chint.envMark}") @Value("${chint.envMark}")
private String envMark; private String envMark;
@ -218,7 +222,7 @@ public class LegEventHandler implements LegEventService {
public ResultContainer routeUpdateOrder(RouteUpdateOrderCommand command) { public ResultContainer routeUpdateOrder(RouteUpdateOrderCommand command) {
OrderLegData data = command.getData(); OrderLegData data = command.getData();
String orderNo = data.getSelfOrderNo(); String orderNo = data.getSelfOrderNo();
RouteOrder routeOrder = routeRepository.findByOrderNo(orderNo); RouteOrder routeOrder = routeRequestDomainService.getRouteOrder(orderNo);
//获取行程规划单创建者作为该订单 //获取行程规划单创建者作为该订单
String employeeNo = routeOrder.getUserId(); String employeeNo = routeOrder.getUserId();
User byUserEmployeeNo = userRepository.findByUserEmployeeNo(employeeNo); User byUserEmployeeNo = userRepository.findByUserEmployeeNo(employeeNo);

View File

@ -65,7 +65,7 @@ public class CTripOrderSyncAdapter implements SupplierOrderSync {
@Override @Override
public boolean syncSupplierOrder(RouteOrder order) { public boolean syncSupplierOrder(RouteOrder order) {
log.info("开始同步程订单"); log.info("开始同步程订单");
ApprovalRequest approvalRequestParam = getApprovalRequestParam(order); ApprovalRequest approvalRequestParam = getApprovalRequestParam(order);
ApprovalResult approval = approvalRequest.approval(approvalRequestParam); ApprovalResult approval = approvalRequest.approval(approvalRequestParam);
return approval.getSetApprovalResult().getStatus().getSuccess(); return approval.getSetApprovalResult().getStatus().getSuccess();
@ -73,28 +73,51 @@ public class CTripOrderSyncAdapter implements SupplierOrderSync {
@Override @Override
public boolean cancelSyncSupplierOrder(RouteOrder order) { public boolean cancelSyncSupplierOrder(RouteOrder order) {
log.info("开始取消程订单"); log.info("开始取消程订单");
ApprovalRequest approvalRequestParam = getApprovalRequestParam(order); ApprovalRequest approvalRequestParam = getApprovalRequestParam(order);
ApprovalResult approval = approvalRequest.cancelApprovalOrder(approvalRequestParam); ApprovalResult approval = approvalRequest.cancelApprovalOrder(approvalRequestParam);
return approval.getSetApprovalResult().getStatus().getSuccess(); return approval.getSetApprovalResult().getStatus().getSuccess();
} }
private ApprovalRequest getApprovalRequestParam(RouteOrder order) { @Override
public boolean syncRouteRequest(RouteRequest routeRequest) {
log.info("开始同步携程订单");
ApprovalRequest approvalRequestParam = getApprovalRequestParam(routeRequest);
ApprovalResult approval = approvalRequest.approval(approvalRequestParam);
return approval.getSetApprovalResult().getStatus().getSuccess();
}
ApproveOrderNo approveOrderNo = order.getApproveOrderNo(); @Override
RankInfo rankInfo = RankInfo.of(order.getStandardLevel()); public boolean cancelRouteRequest(RouteRequest routeRequest) {
String employeeNo = String.valueOf(order.getUserId()); log.info("开始取消携程订单");
ApprovalRequest approvalRequestParam = getApprovalRequestParam(routeRequest);
ApprovalResult approval = approvalRequest.cancelApprovalOrder(approvalRequestParam);
return approval.getSetApprovalResult().getStatus().getSuccess();
}
private ApprovalRequest getApprovalRequestParam(RouteRequest routeRequest) {
RouteRequestFields routeRequestFields = routeRequest.getRouteRequestFields();
List<RouteRequestLeg> routeRequestLegList = routeRequest.getRouteRequestLegList();
String employeeNo = routeRequestFields.getUserId();
ApprovalRequest approvalRequestParam = ApprovalRequest ApprovalRequest approvalRequestParam = ApprovalRequest
.buildApproval(order.getRouteOrderNo(), String.valueOf(employeeNo), rankInfo) .buildApproval(routeRequest.getRouteRequestNo(), employeeNo,
.addExtendField(approveOrderNo.getAccountCompanyCode()) RankInfo.of(routeRequestFields.getStandardLevel()))
.addExtendField(approveOrderNo.getAccountCompanyName()) .addExtendField(routeRequestFields.getAccountCompanyCode())
.addExtendField(approveOrderNo.getSysCode()) .addExtendField(routeRequestFields.getAccountCompanyName())
.addExtendField(routeRequestFields.getSysCode())
.addExtendField("暂无") .addExtendField("暂无")
.addExtendField(approveOrderNo.getProjectName()); .addExtendField(routeRequestFields.getProjectName());
List<Leg> legList = routeRequestLegList.stream().map(RouteRequestLeg::getLeg).toList();
return generateApprovalRequestLegInfo(legList, employeeNo, approvalRequestParam);
}
private ApprovalRequest generateApprovalRequestLegInfo(List<Leg> legList, String employeeNo, ApprovalRequest approvalRequestParam) {
Map<Integer, List<Leg>> collect = orderDomainService.queryLocation( Map<Integer, List<Leg>> collect = orderDomainService.queryLocation(
order.getLegItems() legList.stream()
.stream() .filter(leg -> leg.getLegType().equals(LEG_TYPE_HOTEL) ||
.filter(leg -> leg.getLegType().equals(LEG_TYPE_HOTEL) || leg.getLegType().equals(LEG_TYPE_AIRPLANE) || leg.getLegType().equals(LEG_TYPE_TAXI)) leg.getLegType().equals(LEG_TYPE_AIRPLANE) ||
leg.getLegType().equals(LEG_TYPE_TAXI))
.toList() .toList()
) )
.stream().collect(Collectors.groupingBy(Leg::getLegType)); .stream().collect(Collectors.groupingBy(Leg::getLegType));
@ -109,6 +132,21 @@ public class CTripOrderSyncAdapter implements SupplierOrderSync {
return approvalRequestParam; return approvalRequestParam;
} }
private ApprovalRequest getApprovalRequestParam(RouteOrder order) {
ApproveOrderNo approveOrderNo = order.getApproveOrderNo();
RankInfo rankInfo = RankInfo.of(order.getStandardLevel());
String employeeNo = String.valueOf(order.getUserId());
ApprovalRequest approvalRequestParam = ApprovalRequest
.buildApproval(order.getRouteOrderNo(), String.valueOf(employeeNo), rankInfo)
.addExtendField(approveOrderNo.getAccountCompanyCode())
.addExtendField(approveOrderNo.getAccountCompanyName())
.addExtendField(approveOrderNo.getSysCode())
.addExtendField("暂无")
.addExtendField(approveOrderNo.getProjectName());
List<Leg> legList = order.getLegItems();
return generateApprovalRequestLegInfo(legList, employeeNo, approvalRequestParam);
}
private List<HotelEndorsementDetail> generateHotelList(List<Leg> legs, String employeeNo) { private List<HotelEndorsementDetail> generateHotelList(List<Leg> legs, String employeeNo) {
List<HotelEndorsementDetail> hotelList = new ArrayList<>(); List<HotelEndorsementDetail> hotelList = new ArrayList<>();
legs.forEach(leg -> { legs.forEach(leg -> {

View File

@ -51,6 +51,14 @@ public class LYOrderSyncAdapter implements SupplierOrderSync {
return flag; return flag;
} }
@Override
public boolean syncRouteRequest(RouteRequest routeRequest) {
log.info("开始同步同程订单");
Boolean flag = synchronizationNew(routeRequest, "1");
log.info("flag = " + flag);
return flag;
}
@Override @Override
public boolean cancelSyncSupplierOrder(RouteOrder order) { public boolean cancelSyncSupplierOrder(RouteOrder order) {
//作废状态2 //作废状态2
@ -61,51 +69,118 @@ public class LYOrderSyncAdapter implements SupplierOrderSync {
return flag; return flag;
} }
@Override
public boolean cancelRouteRequest(RouteRequest routeRequest) {
log.info("开始同步同程订单");
Boolean flag = synchronizationNew(routeRequest, "2");
log.info("flag = " + flag);
return flag;
}
//同步同程订单 //同步同程订单
private Boolean synchronization(RouteOrder order, String tag) { private Boolean synchronization(RouteOrder order, String tag) {
String supplierOrderSyncUrl = lyBaseUrl + L_Y_ORDER_PATH;//请求地址
//1.设置订单参数 //1.设置订单参数
SupplierOrderParam param = new SupplierOrderParam();//参数 SupplierOrderParam param = new SupplierOrderParam();//参数
//成本中心
this.setCostCenter(param, order); this.setCostCenter(param, order);
param.setOutEmployeeIdType(0);//外部员工ID类型默认为0 //设置订单基本数据
// param.setOutTravelApplyNo(order.getApproveOrderNo().getActualOrderNo());//审批订单号 loadBaseData(param, order.getRouteOrderNo(), tag);
param.setOutTravelApplyNo(order.getRouteOrderNo());//审批订单号 //设置时间
param.setTravelApplyType(1); //差旅类型1 普通差旅,2 福利差旅 loadTime(param, order.getCreateTime(), order.getUpdateTime());
param.setStatus(Integer.valueOf(tag));//状态1通过2作废
//日期格式化
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
String applyTime = order.getCreateTime().format(formatter);
String updateTime = order.getUpdateTime().format(formatter);
param.setTravelApplyTime(applyTime);//开始创建时间
param.setTravelUpdateTime(updateTime);//最后更新时间
param.setOperationType(1);//1新增2更新
//获取用户信息 //获取用户信息
// User user = "1".equals(tag) ? BaseContext.getCurrentUser() : userRepository.findByUserEmployeeNo(order.getUserId());
// param.setOutEmployeeId(String.valueOf("1".equals(tag) ? user.getEmployeeNo() : order.getUserId()));//用户id
User user = userRepository.findByUserEmployeeNo(order.getUserId()); User user = userRepository.findByUserEmployeeNo(order.getUserId());
param.setOutEmployeeId(order.getUserId());//用户id //设置用户信息和预定类型
param.setTravelDescription("同程订单");//描述信息 loadUserAndProducts(param, order);
param.setBookableProducts(getLegType(order));//1:国内机票,2:国际机票,3:国内酒店,4:海外酒店,5:火车票,6:用车
//2.同程的行程节点集合 //2.同程的行程节点集合
List<AOSItem> aosItems = getAosItems(order); List<AOSItem> aosItems = getAosItems(order);
//3.差旅人信息 //3.差旅人信息
List<AOSPerson> aosPeople = readAosPeople(user, order.getUserId());
//4.前置差旅政策
List<AOSPreTravelPolicy> aosPreTravelPolicies = readAOSPreTravelPolicy(order.getStandardLevel());
return sendRequest(param, aosItems, aosPeople, aosPreTravelPolicies);
}
//新同步同程订单
private Boolean synchronizationNew(RouteRequest routeRequest, String tag) {
//1.设置订单参数
SupplierOrderParam param = new SupplierOrderParam();//参数
this.readCostCenter(param, routeRequest);
//设置订单基本数据
loadBaseData(param, routeRequest.getRouteRequestNo(), tag);
//设置时间
loadTime(param, routeRequest.getCreateTime(), routeRequest.getUpdateTime());
//获取用户信息
User user = userRepository.findByUserEmployeeNo(routeRequest.getRouteRequestFields().getUserId());
loadNewUserAndProducts(param, routeRequest);
//2.同程的行程节点集合
List<AOSItem> aosItems = roadAosItems(routeRequest);
//3.差旅人信息
List<AOSPerson> aosPeople = readAosPeople(user, routeRequest.getRouteRequestFields().getUserId());
//4.前置差旅政策
List<AOSPreTravelPolicy> aosPreTravelPolicies = readAOSPreTravelPolicy(routeRequest.getRouteRequestFields().getStandardLevel());
return sendRequest(param, aosItems, aosPeople, aosPreTravelPolicies);
}
//基本数据
private void loadBaseData(SupplierOrderParam param, String orderNo, String tag) {
param.setOutEmployeeIdType(0);//外部员工ID类型默认为0
param.setOutTravelApplyNo(orderNo);//审批订单号
param.setTravelApplyType(1); //差旅类型1 普通差旅,2 福利差旅
param.setStatus(Integer.valueOf(tag));//状态1通过2作废
}
//设置时间
private void loadTime(SupplierOrderParam param, LocalDateTime createTime, LocalDateTime updateTime) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
String applyTime = createTime.format(formatter);
String editTime = updateTime.format(formatter);
param.setTravelApplyTime(applyTime);//开始创建时间
param.setTravelUpdateTime(editTime);//最后更新时间
param.setOperationType(1);//1新增2更新
}
//用户和预定类型
private void loadUserAndProducts(SupplierOrderParam param, RouteOrder order) {
param.setOutEmployeeId(order.getUserId());//用户id
param.setTravelDescription("同程订单");//描述信息
param.setBookableProducts(getLegType(order));//1:国内机票,2:国际机票,3:国内酒店,4:海外酒店,5:火车票,6:用车
}
//新对象用户和预定类型
private void loadNewUserAndProducts(SupplierOrderParam param, RouteRequest routeRequest) {
param.setOutEmployeeId(routeRequest.getRouteRequestFields().getUserId());//用户id
param.setTravelDescription("同程订单");//描述信息
param.setBookableProducts(roadLegType(routeRequest));//1:国内机票,2:国际机票,3:国内酒店,4:海外酒店,5:火车票,6:用车
}
//差旅人信息
private List<AOSPerson> readAosPeople(User user, String userId) {
List<AOSPerson> aosPeople = new ArrayList<>(); List<AOSPerson> aosPeople = new ArrayList<>();
AOSPerson aosPerson = new AOSPerson(); AOSPerson aosPerson = new AOSPerson();
aosPerson.setName(user.getName());//用户名 aosPerson.setName(user.getName());//用户名
aosPerson.setRelation(0);//0:内部员工1:配偶2:子女3:父母4:面试候选人5:实习生6:外部宾客 aosPerson.setRelation(0);//0:内部员工1:配偶2:子女3:父母4:面试候选人5:实习生6:外部宾客
aosPerson.setPassengerType(0);//0:成人, 1:儿童, 2:婴儿 aosPerson.setPassengerType(0);//0:成人, 1:儿童, 2:婴儿
// aosPerson.setOutEmployeeId(String.valueOf("1".equals(tag) ? user.getEmployeeNo() : order.getUserId()));//SF号(长工号) aosPerson.setOutEmployeeId(userId);//SF号(长工号)
aosPerson.setOutEmployeeId(order.getUserId());//SF号(长工号)
aosPeople.add(aosPerson); aosPeople.add(aosPerson);
//4.前置差旅政策 return aosPeople;
}
//前置差旅政策
private List<AOSPreTravelPolicy> readAOSPreTravelPolicy(String standardLevel) {
List<AOSPreTravelPolicy> aosPreTravelPolicies = new ArrayList<>(); List<AOSPreTravelPolicy> aosPreTravelPolicies = new ArrayList<>();
for (int i = 1; i < 7; i++) { for (int i = 1; i < 7; i++) {
AOSPreTravelPolicy aosPreTravelPolicy = new AOSPreTravelPolicy(); AOSPreTravelPolicy aosPreTravelPolicy = new AOSPreTravelPolicy();
aosPreTravelPolicy.setPolicyCode(order.getStandardLevel());//一般指客户经理提供的差旅政策标题 aosPreTravelPolicy.setPolicyCode(standardLevel);//一般指客户经理提供的差旅政策标题
aosPreTravelPolicy.setProductTypeId(i);//产品ID 1国内机票2国际机票3国内酒店4海外酒店5火车票6用车 aosPreTravelPolicy.setProductTypeId(i);//产品ID 1国内机票2国际机票3国内酒店4海外酒店5火车票6用车
aosPreTravelPolicies.add(aosPreTravelPolicy); aosPreTravelPolicies.add(aosPreTravelPolicy);
} }
return aosPreTravelPolicies;
}
//发送请求
private Boolean sendRequest(SupplierOrderParam param, List<AOSItem> aosItems, List<AOSPerson> aosPeople, List<AOSPreTravelPolicy> aosPreTravelPolicies) {
String supplierOrderSyncUrl = lyBaseUrl + L_Y_ORDER_PATH;//请求地址
param.setItemList(aosItems); // 同程节点内容 param.setItemList(aosItems); // 同程节点内容
param.setPersonList(aosPeople);// 同程信息实际出行人 param.setPersonList(aosPeople);// 同程信息实际出行人
param.setPreTravelPolicyList(aosPreTravelPolicies);// 同程政策 param.setPreTravelPolicyList(aosPreTravelPolicies);// 同程政策
@ -130,12 +205,6 @@ public class LYOrderSyncAdapter implements SupplierOrderSync {
//同程Leg集合解析 //同程Leg集合解析
private List<AOSItem> getAosItems(RouteOrder order) { private List<AOSItem> getAosItems(RouteOrder order) {
List<AOSItem> aosItems = new ArrayList<>();
AOSItem aosItem = new AOSItem();
LocalDateTime startDate = LocalDateTime.MAX;
LocalDateTime endDate = LocalDateTime.MIN;
StringBuilder departCityStr = new StringBuilder();
StringBuilder arriveCityStr = new StringBuilder();
//提取所有行程节点信息 //提取所有行程节点信息
List<Leg> legItems = order.getLegItems().stream().filter( List<Leg> legItems = order.getLegItems().stream().filter(
leg -> (leg.getLegType().equals(LEG_TYPE_TRAIN) || leg -> (leg.getLegType().equals(LEG_TYPE_TRAIN) ||
@ -143,6 +212,82 @@ public class LYOrderSyncAdapter implements SupplierOrderSync {
leg.getLegType().equals(LEG_TYPE_HOTEL) || leg.getLegType().equals(LEG_TYPE_HOTEL) ||
leg.getLegType().equals(LEG_TYPE_TAXI))) leg.getLegType().equals(LEG_TYPE_TAXI)))
.toList(); .toList();
return readAosItems(legItems);
}
//获取行程节点类型
public String getLegType(RouteOrder order) {
return order.getLegItems()
.stream()
.map(Leg::getLegType)
.distinct()
.map(legType -> switch (legType) {
case LEG_TYPE_TRAIN -> 5;
case LEG_TYPE_AIRPLANE -> 1;
case LEG_TYPE_HOTEL -> 3;
case LEG_TYPE_TAXI -> 6;
default -> legType;
})
.map(Object::toString)
.collect(Collectors.joining(","));
}
//新对象成本中心
private SupplierOrderParam readCostCenter(SupplierOrderParam param, RouteRequest routeRequest) {
RouteRequestFields routeRequestFields = routeRequest.getRouteRequestFields();
param.addCostCenter(routeRequestFields.getSysCode())
.addCostCenter(routeRequestFields.getAccountCompanyCode())
.addCostCenter(routeRequestFields.getAccountCompanyName())
.addCostCenter(routeRequestFields.getProjectName());
return param;
}
//新对象获取行程节点类型
public String roadLegType(RouteRequest routeRequest) {
return routeRequest.getRouteRequestLegList()
.stream()
.map(routeRequestLeg -> Optional.ofNullable(routeRequestLeg.getLeg())
.map(Leg::getLegType)
.orElse(-1))
.distinct()
.map(legType -> switch (legType) {
case LEG_TYPE_TRAIN -> 5;
case LEG_TYPE_AIRPLANE -> 1;
case LEG_TYPE_HOTEL -> 3;
case LEG_TYPE_TAXI -> 6;
default -> legType;
})
.map(Object::toString)
.collect(Collectors.joining(","));
}
//新对象同程Leg集合解析
private List<AOSItem> roadAosItems(RouteRequest routeRequest) {
//提取所有行程节点信息
List<Leg> legItems = routeRequest.getRouteRequestLegList().stream()
.map(routeRequestLeg -> Optional.ofNullable(routeRequestLeg.getLeg())
.filter(
leg -> (leg.getLegType().equals(LEG_TYPE_TRAIN) ||
leg.getLegType().equals(LEG_TYPE_AIRPLANE) ||
leg.getLegType().equals(LEG_TYPE_HOTEL) ||
leg.getLegType().equals(LEG_TYPE_TAXI)))
.orElse(null)).filter(Objects::nonNull)
.toList(); // 转换为 List
return readAosItems(legItems);
}
//新对象同程Leg集合解析
private List<AOSItem> readAosItems(List<Leg> legItems) {
List<AOSItem> aosItems = new ArrayList<>();
AOSItem aosItem = new AOSItem();
LocalDateTime startDate = LocalDateTime.MAX;
LocalDateTime endDate = LocalDateTime.MIN;
StringBuilder departCityStr = new StringBuilder();
StringBuilder arriveCityStr = new StringBuilder();
orderDomainService.queryLocation(legItems); orderDomainService.queryLocation(legItems);
for (Leg leg : legItems) { for (Leg leg : legItems) {
//开始时间 //开始时间
@ -198,24 +343,6 @@ public class LYOrderSyncAdapter implements SupplierOrderSync {
return aosItems; return aosItems;
} }
//获取行程节点类型
public String getLegType(RouteOrder order) {
return order.getLegItems()
.stream()
.map(Leg::getLegType)
.distinct()
.map(legType -> switch (legType) {
case LEG_TYPE_TRAIN -> 5;
case LEG_TYPE_AIRPLANE -> 1;
case LEG_TYPE_HOTEL -> 3;
case LEG_TYPE_TAXI -> 6;
default -> legType;
})
.map(Object::toString)
.collect(Collectors.joining(","));
}
public Location getCityLocation(Location location) { public Location getCityLocation(Location location) {
if (location.getLocationType().equals(LOCATION_TYPE_CITY)) { if (location.getLocationType().equals(LOCATION_TYPE_CITY)) {
return location; return location;
@ -235,6 +362,7 @@ public class LYOrderSyncAdapter implements SupplierOrderSync {
} }
} }
//去重 //去重
public String removeDuplicates(StringBuilder stringBuilder) { public String removeDuplicates(StringBuilder stringBuilder) {
String cityStr = String.valueOf(stringBuilder); String cityStr = String.valueOf(stringBuilder);

View File

@ -2,10 +2,14 @@ package com.chint.domain.service.order_sync;
import com.chint.domain.aggregates.order.RouteOrder; import com.chint.domain.aggregates.order.RouteOrder;
import com.chint.domain.aggregates.order.RouteRequest;
import com.chint.domain.factoriy.order.RouteOrderFactory; import com.chint.domain.factoriy.order.RouteOrderFactory;
public interface SupplierOrderSync { public interface SupplierOrderSync {
boolean syncSupplierOrder(RouteOrder order); boolean syncSupplierOrder(RouteOrder order);
boolean syncRouteRequest(RouteRequest routeRequest);
boolean cancelSyncSupplierOrder(RouteOrder order); boolean cancelSyncSupplierOrder(RouteOrder order);
boolean cancelRouteRequest(RouteRequest routeRequest);
} }

View File

@ -7,7 +7,9 @@ import java.util.List;
@Data @Data
public class SyncLegData { public class SyncLegData {
private Long routeId; private Long routeId;
private Long routeRequestId;
private List<Long> routeIds; private List<Long> routeIds;
private List<Long> legIds;
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

@ -11,4 +11,7 @@ public class OrderRecordConstant {
//项目订单号 //项目订单号
public static final String LY_CUSTOM4 = "Custom4"; public static final String LY_CUSTOM4 = "Custom4";
//成本中心
public static final String LY_CUSTOM5 = "CostCenter";
} }

View File

@ -0,0 +1,10 @@
package com.chint.infrastructure.constant;
public class RouteRequestConstant {
public static final int ROUTE_REQUEST_STATUS_PREPARE = 0;
public static final String ROUTE_REQUEST_STATUS_PREPARE_NAME = "未同步";
public static final int ROUTE_REQUEST_STATUS_SYNC = 1;
public static final String ROUTE_REQUEST_STATUS_SYNC_NAME = "已同步";
public static final int ROUTE_REQUEST_STATUS_CANCEL = 2;
public static final String ROUTE_REQUEST_STATUS_CANCEL_NAME = "已取消";
}

View File

@ -29,6 +29,11 @@ public class LegRepositoryImpl implements LegRepository {
return leg; return leg;
} }
@Override
public List<Leg> findByIds(List<Long> legIds) {
return null;
}
@Override @Override
public void deleteById(Leg leg) { public void deleteById(Leg leg) {
routeCacheService.invalidateRouteCache(leg.getRouteId()); routeCacheService.invalidateRouteCache(leg.getRouteId());

View File

@ -0,0 +1,19 @@
package com.chint.infrastructure.repository;
import com.chint.domain.aggregates.order.RouteRequest;
import com.chint.domain.repository.RouteRequestRepository;
import com.chint.infrastructure.repository.jdbc.JdbcRouteRequestRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
@Repository
public class RouteRequestRepositoryImpl implements RouteRequestRepository {
@Autowired
private JdbcRouteRequestRepository jdbcRouteRequestRepository;
@Override
public RouteRequest findByRouteRequestNo(String routeRequestNo) {
return jdbcRouteRequestRepository.findByRouteRequestNo(routeRequestNo);
}
}

View File

@ -0,0 +1,11 @@
package com.chint.infrastructure.repository.jdbc;
import com.chint.domain.aggregates.order.RouteRequest;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface JdbcRouteRequestRepository extends CrudRepository<RouteRequest, Long> {
RouteRequest findByRouteRequestNo(String routeRequestNo);
}

View File

@ -2,6 +2,7 @@ package com.chint.interfaces.rest.ctrip.order;
import com.chint.domain.aggregates.order.order_record.ctrip_order_record.*; import com.chint.domain.aggregates.order.order_record.ctrip_order_record.*;
import com.chint.domain.repository.CTripOrderDetailRepository; import com.chint.domain.repository.CTripOrderDetailRepository;
import com.chint.infrastructure.util.DateTimeUtil;
import com.chint.interfaces.rest.ctrip.dto.order.OrderCarResponse; import com.chint.interfaces.rest.ctrip.dto.order.OrderCarResponse;
import com.chint.interfaces.rest.ctrip.dto.order.OrderFlightResponse; import com.chint.interfaces.rest.ctrip.dto.order.OrderFlightResponse;
import com.chint.interfaces.rest.ctrip.dto.order.OrderHotelResponse; import com.chint.interfaces.rest.ctrip.dto.order.OrderHotelResponse;
@ -190,6 +191,8 @@ public class CTripOrderRecordAutoSave {
//补充额外的字段 //补充额外的字段
OrderCarResponse.CarOrderCorpInfo corpInfo = it.getOrderDetail().getCorpInfo(); OrderCarResponse.CarOrderCorpInfo corpInfo = it.getOrderDetail().getCorpInfo();
record.setRouteOrderNo(corpInfo.getJouneryId()); record.setRouteOrderNo(corpInfo.getJouneryId());
String orderDate = it.getOrderDetail().getOrderBaseInfo().getOrderDate();
record.setOrderDate(DateTimeUtil.timeToStrCommon(DateTimeUtil.strToTime(orderDate)));
return record; return record;
}).toList(); }).toList();
cTripOrderDetailRepository.saveAllCTripCarRecord(list); cTripOrderDetailRepository.saveAllCTripCarRecord(list);

View File

@ -290,6 +290,12 @@ public class UserHttpRequestImpl implements UserHttpRequest {
//根据入账公司没有找到部门编码的话直接获取主岗编码 //根据入账公司没有找到部门编码的话直接获取主岗编码
deptCode = user.lowestDeptCode(); deptCode = user.lowestDeptCode();
} }
if (deptCode == null) {
//如果还是空的话 就返回null
return null;
}
//清除部门编码里面的字母 //清除部门编码里面的字母
return deptCode.replaceAll("\\D", ""); return deptCode.replaceAll("\\D", "");
} }