Compare commits
8 Commits
35e4a71cfb
...
afd80ca727
Author | SHA1 | Date |
---|---|---|
lulz1 | afd80ca727 | |
lulz1 | 81f8299d6a | |
lulz1 | 67f89d754f | |
dengwc | 2579d6997e | |
dengwc | 7c9098dca0 | |
lulz1 | 652553fc64 | |
lulz1 | a1acf27785 | |
lulz1 | f891922bee |
|
@ -10,6 +10,7 @@ import static com.chint.infrastructure.constant.LegConstant.LEG_EVENT_NOT_ORDERE
|
|||
public class LegSyncCommand extends Command {
|
||||
private Integer LegEventType = LEG_EVENT_NOT_ORDERED;
|
||||
private SyncLegData data;
|
||||
private Integer ifRouteRequestSync; //是否是差旅申请单同步方式
|
||||
|
||||
// public LegSyncCommand legId(Long LegId) {
|
||||
// this.setLegId(LegId);
|
||||
|
|
|
@ -113,17 +113,14 @@ public class ScheduleDetail {
|
|||
|
||||
@JsonProperty("EndCountryCode")
|
||||
protected String EndCountryCode;
|
||||
|
||||
@JsonProperty("EndCountryName")
|
||||
protected String EndCountryName;
|
||||
|
||||
@JsonProperty("RealScheduleNum")
|
||||
protected String RealScheduleNum;
|
||||
@JsonProperty("NightCount")
|
||||
protected String NightCount;
|
||||
@JsonProperty("RoomCount")
|
||||
protected String RoomCount;
|
||||
|
||||
@JsonProperty("AmountTypeName")
|
||||
private String amountTypeName;
|
||||
@JsonProperty("AmountTypeEnName")
|
||||
|
@ -136,6 +133,14 @@ public class ScheduleDetail {
|
|||
private String destinationDescription;
|
||||
@JsonProperty("EstimatedAmount")
|
||||
private String estimatedAmount;
|
||||
|
||||
@JsonProperty("travelType")
|
||||
private String travelType;
|
||||
|
||||
@JsonProperty("expenseTypeId")
|
||||
private String expenseTypeId;
|
||||
|
||||
|
||||
@JsonProperty("LocationList")
|
||||
@Transient
|
||||
private List<LocationRes> locationList;
|
||||
|
@ -150,6 +155,16 @@ public class 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) {
|
||||
scheduleDetail.setServiceProvider(serviceProvider);
|
||||
return this;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -35,11 +35,11 @@ import java.util.stream.Collectors;
|
|||
import java.util.stream.Stream;
|
||||
|
||||
import static com.chint.infrastructure.constant.FSSCConstant.*;
|
||||
import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_HOTEL;
|
||||
import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_OTHER;
|
||||
import static com.chint.infrastructure.constant.LegConstant.*;
|
||||
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.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.*;
|
||||
|
||||
@Service
|
||||
|
@ -153,8 +153,8 @@ public class OrderQuery {
|
|||
.toList();
|
||||
|
||||
//这里按照业务要求,尝试进行自动确认结束行程
|
||||
orders.forEach(it->{
|
||||
if(it.getIfCanBeFinished().equals("1") && !it.getOrderStatus().equals(ORDER_STATUS_FINISH)){
|
||||
orders.forEach(it -> {
|
||||
if (it.getIfCanBeFinished().equals("1") && !it.getOrderStatus().equals(ORDER_STATUS_FINISH)) {
|
||||
orderDomainService.finishOrder(it.getRouteId());
|
||||
}
|
||||
});
|
||||
|
@ -377,8 +377,6 @@ public class OrderQuery {
|
|||
.type(FSSCConstant.TRIP_CALLBACK_TYPE_APPROVE);
|
||||
|
||||
List<Location> locationListAfterNotNull = locationList.stream().filter(Objects::nonNull).toList();
|
||||
|
||||
// List<CityEntity> cityEntities = new ArrayList<>();
|
||||
for (Location location : locationListAfterNotNull) {
|
||||
|
||||
if (location.getLocationEnName() == null) {
|
||||
|
@ -398,10 +396,6 @@ public class OrderQuery {
|
|||
}
|
||||
locationRepository.saveAll(List.of(location));
|
||||
}
|
||||
|
||||
|
||||
// CityEntity city = cityRepository.findByCityName(location.getLocationName());
|
||||
// cityEntities.add(city);
|
||||
callbackDataBuilder.cityList()
|
||||
.cityName(location.getLocationName())
|
||||
.cityEnName(location.getLocationEnName())
|
||||
|
@ -411,18 +405,12 @@ public class OrderQuery {
|
|||
List<ScheduleDetail> scheduleDetails = legItems.stream()
|
||||
.map(leg -> {
|
||||
leg.reloadStatus();
|
||||
// CityEntity originCity;
|
||||
// CityEntity destinationCity;
|
||||
ScheduleDetail.ScheduleDetailBuilder scheduleDetailBuilder = ScheduleDetail
|
||||
.builder()
|
||||
.legId(leg.getLegId());
|
||||
if (!leg.getLegType().equals(LEG_TYPE_OTHER)) {
|
||||
Location originLocation = leg.getOriginLocation();
|
||||
if (originLocation != null) {
|
||||
// originCity = cityEntities.stream().filter(cityEntity -> cityEntity
|
||||
// .getCityName()
|
||||
// .equals(leg.getOriginLocation().getLocationName()))
|
||||
// .findFirst().orElseThrow(() -> new NotFoundException(NOT_FOUND));
|
||||
scheduleDetailBuilder
|
||||
.startCity(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
|
||||
.scheduleType(translateLegType(leg.getLegType()))
|
||||
.scheduleNum(leg.getLegNo())
|
||||
.startDate(simpleFormatter.format(leg.getStartTime()))
|
||||
.endDate(simpleFormatter.format(leg.getEndTime()))
|
||||
|
|
|
@ -1,18 +1,27 @@
|
|||
package com.chint.domain.aggregates.base;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.data.annotation.Transient;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
public abstract class BaseEvent {
|
||||
public abstract class BaseEvent implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 2131240986128456190L;
|
||||
|
||||
private Integer eventType;
|
||||
|
||||
@Transient
|
||||
private transient String eventName;
|
||||
|
||||
private LocalDateTime happenTime;
|
||||
private LocalDateTime happenTime = LocalDateTime.now();
|
||||
|
||||
private String extension;
|
||||
|
||||
// 新增抽象方法:获取状态码与状态名称的映射表
|
||||
protected abstract Map<Integer, String> getStatusMappings();
|
||||
|
|
|
@ -1,23 +1,21 @@
|
|||
package com.chint.domain.aggregates.base;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
public interface EventManageable {
|
||||
|
||||
// 抽象方法:获取事件列表
|
||||
List<BaseEvent> getEvents();
|
||||
List<? extends BaseEvent> getEvents();
|
||||
|
||||
// 默认方法:添加事件
|
||||
default void addEvent(BaseEvent event) {
|
||||
getEvents().add(event);
|
||||
List<BaseEvent> events = (List<BaseEvent>) getEvents();
|
||||
events.add(event);
|
||||
}
|
||||
|
||||
// 默认方法:获取最新的事件
|
||||
default BaseEvent getLastEvent() {
|
||||
return getEvents().stream()
|
||||
.max(Comparator.comparing(BaseEvent::getHappenTime))
|
||||
.orElseThrow(() -> new NoSuchElementException("No events found."));
|
||||
List<? extends BaseEvent> eventList = getEvents();
|
||||
return eventList.isEmpty() ? null : eventList.get(eventList.size() - 1);
|
||||
}
|
||||
}
|
|
@ -159,6 +159,14 @@ public class RouteOrder implements Serializable {
|
|||
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) {
|
||||
if (this.legItems == null || this.legItems.isEmpty()) {
|
||||
return this;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.chint.domain.aggregates.order;
|
||||
|
||||
import com.chint.domain.aggregates.base.BaseEntity;
|
||||
import com.chint.domain.aggregates.base.BaseTimeEntity;
|
||||
import com.chint.domain.aggregates.base.BaseEvent;
|
||||
import com.chint.domain.aggregates.base.EventManageable;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
@ -19,7 +19,7 @@ import java.util.List;
|
|||
|
||||
@Data
|
||||
@Table("route_request")
|
||||
public class RouteRequest implements Serializable {
|
||||
public class RouteRequest implements Serializable, EventManageable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 7125989663091861990L;
|
||||
|
@ -32,14 +32,17 @@ public class RouteRequest implements Serializable {
|
|||
|
||||
private String RouteRequestNo;
|
||||
|
||||
private String supplier;
|
||||
|
||||
@MappedCollection(idColumn = "route_request_id", keyColumn = "route_request_key")
|
||||
private List<RouteRequestLeg> routeRequestLegList;
|
||||
|
||||
@MappedCollection(idColumn = "route_request_id", keyColumn = "route_request_key")
|
||||
private List<RouteRequestEvent> eventList;
|
||||
|
||||
@Transient
|
||||
private String supplier;
|
||||
@MappedCollection(idColumn = "route_request_id")
|
||||
private RouteRequestFields routeRequestFields;
|
||||
|
||||
@Transient
|
||||
private Integer status;
|
||||
@Transient
|
||||
|
@ -54,4 +57,22 @@ public class RouteRequest implements Serializable {
|
|||
@ApiModelProperty("最后更新时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
package com.chint.domain.aggregates.order;
|
||||
|
||||
import com.chint.domain.aggregates.base.BaseEvent;
|
||||
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;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.chint.infrastructure.constant.RouteRequestConstant.*;
|
||||
|
||||
@Data
|
||||
@Table("route_request_event")
|
||||
public class RouteRequestEvent implements Serializable {
|
||||
public class RouteRequestEvent extends BaseEvent implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 5421219887361331990L;
|
||||
|
@ -21,10 +24,30 @@ public class RouteRequestEvent implements Serializable {
|
|||
|
||||
private Long routeRequestKey;
|
||||
|
||||
private Integer eventType;
|
||||
@Override
|
||||
protected Map<Integer, String> getStatusMappings() {
|
||||
return Map.of(ROUTE_REQUEST_STATUS_PREPARE, ROUTE_REQUEST_STATUS_PREPARE_NAME,
|
||||
ROUTE_REQUEST_STATUS_SYNC, ROUTE_REQUEST_STATUS_SYNC_NAME,
|
||||
ROUTE_REQUEST_STATUS_CANCEL, ROUTE_REQUEST_STATUS_CANCEL_NAME);
|
||||
}
|
||||
|
||||
private String extension;
|
||||
public static RouteRequestEvent prepare(){
|
||||
RouteRequestEvent routeRequestEvent = new RouteRequestEvent();
|
||||
routeRequestEvent.setEventType(ROUTE_REQUEST_STATUS_PREPARE);
|
||||
return routeRequestEvent;
|
||||
}
|
||||
|
||||
private LocalDateTime happenTime;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -79,13 +79,17 @@ public class OrderCarRecord extends OrderBaseRecord {
|
|||
public OrderCarRecord loadTravelInfo(String startTime,
|
||||
String arriveTime,
|
||||
String fromCity,
|
||||
String toCity
|
||||
String toCity,
|
||||
String fromStationName,
|
||||
String toStationName
|
||||
) {
|
||||
// 行程信息
|
||||
this.setFromCity(fromCity);
|
||||
this.setToCity(toCity);
|
||||
this.setStartTime(startTime);
|
||||
this.setArriveTime(arriveTime);
|
||||
this.setFromStationName(fromStationName);
|
||||
this.setToStationName(toStationName);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -165,10 +169,10 @@ public class OrderCarRecord extends OrderBaseRecord {
|
|||
|
||||
// 加载超标信息
|
||||
public OrderCarRecord loadComplianceInfo(OrderDetail orderDetail) {
|
||||
orderDetail.getETAEvent().ifPresentOrElse(it->{
|
||||
orderDetail.getETAEvent().ifPresentOrElse(it -> {
|
||||
this.setOverStandard("是");
|
||||
this.setOverStandardReason(it.getExtension());
|
||||
},()->{
|
||||
}, () -> {
|
||||
this.setOverStandard("否");
|
||||
this.setOverStandardReason("");
|
||||
});
|
||||
|
|
|
@ -20,6 +20,7 @@ public class CTripCarRecord implements Serializable {
|
|||
private String recordId;
|
||||
private LocalDateTime createTime;
|
||||
private String routeOrderNo;
|
||||
private String orderDate;
|
||||
@MappedCollection(idColumn = "c_trip_car_record_id")
|
||||
private CTripCarRecordBase cTripCarRecordBase;
|
||||
@MappedCollection(idColumn = "c_trip_car_record_id")
|
||||
|
|
|
@ -6,11 +6,19 @@ import com.chint.domain.aggregates.order.RouteOrder;
|
|||
import com.chint.domain.aggregates.order.RouteRequest;
|
||||
import com.chint.domain.value_object.OrderSaveData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface OrderFactory {
|
||||
RouteOrder createRoute(OrderSaveData orderData);
|
||||
|
||||
RouteOrder createRoute(OrderCreateCommand command);
|
||||
|
||||
ApprovalEvent createApprovalEvent(Integer eventType);
|
||||
|
||||
RouteRequest createRequestWithLeg(RouteOrder routeOrder, List<Long> legIds);
|
||||
|
||||
RouteRequest createRequestWithAllLeg(RouteOrder routeOrder);
|
||||
|
||||
RouteRequest createRequestByRoute(RouteOrder routeOrder);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.chint.domain.factoriy.order;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.chint.application.commands.OrderCreateCommand;
|
||||
import com.chint.domain.aggregates.order.*;
|
||||
import com.chint.domain.aggregates.user.User;
|
||||
|
@ -26,7 +27,6 @@ public class RouteOrderFactory implements OrderFactory {
|
|||
private String envMark;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public RouteOrder createRoute(OrderSaveData orderData) {
|
||||
User currentUser = BaseContext.getCurrentUser();
|
||||
|
@ -82,10 +82,42 @@ public class RouteOrderFactory implements OrderFactory {
|
|||
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
|
||||
public RouteRequest createRequestByRoute(RouteOrder routeOrder) {
|
||||
RouteRequest routeRequest = new RouteRequest();
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,10 +3,8 @@ package com.chint.domain.factoriy.order_detail;
|
|||
import com.chint.domain.aggregates.order.*;
|
||||
import com.chint.domain.aggregates.user.User;
|
||||
import com.chint.domain.exceptions.NotFoundException;
|
||||
import com.chint.domain.repository.LocationRepository;
|
||||
import com.chint.domain.repository.OrderDetailRepository;
|
||||
import com.chint.domain.repository.RouteRepository;
|
||||
import com.chint.domain.repository.UserRepository;
|
||||
import com.chint.domain.repository.*;
|
||||
import com.chint.domain.service.RouteRequestDomainService;
|
||||
import com.chint.infrastructure.util.BigDecimalCalculator;
|
||||
import com.chint.interfaces.rest.ctrip.dto.search.car.*;
|
||||
import com.chint.interfaces.rest.ctrip.dto.search.flight.*;
|
||||
|
@ -46,6 +44,13 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory {
|
|||
@Autowired
|
||||
private OrderDetailFactory orderDetailFactory;
|
||||
|
||||
@Autowired
|
||||
private RouteRequestRepository routeRequestRepository;
|
||||
|
||||
@Autowired
|
||||
private RouteRequestDomainService routeRequestDomainService;
|
||||
|
||||
|
||||
@Override
|
||||
public CarOrderDetail createCarOrderDetail(Object carOrderDetailData) {
|
||||
//获取基础信息数据
|
||||
|
@ -53,7 +58,7 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory {
|
|||
CarBasicInfo carBasicInfo = carQuickOrderInfoEntity.getBasicInfo();
|
||||
String orderNo = carBasicInfo.getOrderId();
|
||||
String journeyNo = carBasicInfo.getJourneyID();
|
||||
RouteOrder routeOrder = routeRepository.findByOrderNo(journeyNo);
|
||||
RouteOrder routeOrder = routeRequestDomainService.getRouteOrder(journeyNo);
|
||||
OrderDetail orderDetail = routeOrder.getOrderDetails()
|
||||
.stream()
|
||||
.filter(it -> it.getOrderNo().equals(orderNo))
|
||||
|
@ -76,7 +81,7 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory {
|
|||
orderFeeList.forEach(it -> {
|
||||
if (it.getFeeName().equals("取消费")) {
|
||||
carOrderDetail.setCancellationFee(it.getAmount().toString());
|
||||
if(it.getAmount() > 0){
|
||||
if (it.getAmount() > 0) {
|
||||
carOrderDetail.setOrderStatus(FSSC_CAR_STATUS_REFUND);
|
||||
} else {
|
||||
carOrderDetail.setOrderStatus(FSSC_ORDER_STATUS_CANCEL);
|
||||
|
@ -156,7 +161,7 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory {
|
|||
BasicInfo flightOrderBasicInfo = flightOrderInfoEntity.getBasicInfo();
|
||||
String orderNo = flightOrderBasicInfo.getOrderID();
|
||||
String journeyNo = flightOrderBasicInfo.getJourneyID();
|
||||
RouteOrder routeOrder = routeRepository.findByOrderNo(journeyNo);
|
||||
RouteOrder routeOrder = routeRequestDomainService.getRouteOrder(journeyNo);
|
||||
|
||||
Optional<OrderDetail> first = routeOrder
|
||||
.getOrderDetails()
|
||||
|
@ -359,7 +364,7 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory {
|
|||
Optional<OrderDetail> byOrderNo = orderDetailRepository.findByOrderNo(orderNo);
|
||||
String journeyNo = hotelOrderInfoEntity.getJourneyNo();
|
||||
|
||||
RouteOrder routeOrder = routeRepository.findByOrderNo(journeyNo).reloadStatus();
|
||||
RouteOrder routeOrder = routeRequestDomainService.getRouteOrder(journeyNo).reloadStatus();
|
||||
ApproveOrderNo approveOrderNo = null;
|
||||
User user = null;
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.chint.domain.aggregates.user.User;
|
|||
import com.chint.domain.exceptions.NotFoundException;
|
||||
import com.chint.domain.repository.OrderDetailRepository;
|
||||
import com.chint.domain.repository.RouteRepository;
|
||||
import com.chint.domain.repository.RouteRequestRepository;
|
||||
import com.chint.domain.repository.UserRepository;
|
||||
import com.chint.interfaces.rest.ly.dto.carorderdatapushback.PriceDetail;
|
||||
import com.chint.interfaces.rest.ly.dto.hotelorderdatapushbach.Resident;
|
||||
|
@ -56,8 +57,12 @@ public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory {
|
|||
@Autowired
|
||||
private OrderDetailFactory orderDetailFactory;
|
||||
|
||||
@Autowired
|
||||
private RouteRequestRepository routeRequestRepository;
|
||||
|
||||
private DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss");
|
||||
|
||||
|
||||
@Override
|
||||
public CarOrderDetail createCarOrderDetail(Object carOrderDetailData) {
|
||||
CarDetailResponse.DataWrapper data = (CarDetailResponse.DataWrapper) carOrderDetailData;
|
||||
|
|
|
@ -109,7 +109,10 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
|
|||
}
|
||||
orderCarRecord.loadTravelInfo(startTime, endTime,
|
||||
cTripCarQuickInfo.getDepartureCityName(),
|
||||
cTripCarQuickInfo.getArrivalCityName());
|
||||
cTripCarQuickInfo.getArrivalCityName(),
|
||||
cTripCarQuickInfo.getDepartureCityName() + cTripCarQuickInfo.getDepartureAddressDetail(),
|
||||
cTripCarQuickInfo.getArrivalCityName() + cTripCarQuickInfo.getArrivalAddressDetail()
|
||||
);
|
||||
|
||||
// 加载车型和运行信息,车类型,时间,里程
|
||||
orderCarRecord.loadVehicleAndTravelInfo(cTripCarQuickInfo.getVehicleName(),
|
||||
|
@ -120,7 +123,7 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
|
|||
String batchNo = cTripCarRecordBase.getBatchNoStartDate().substring(0, 6);
|
||||
orderCarRecord.loadFinancialInfo(batchNo,
|
||||
cTripCarRecordBase.getSubAccCheckBatchNo(),
|
||||
String.valueOf(cTripCarRecordBase.getAmount()),
|
||||
String.valueOf(cTripCarRecordBase.getRealAmount()),
|
||||
String.valueOf(cTripCarRecordBase.getRealAmountHasPost()));
|
||||
|
||||
// 加载费用细节, 未税金额,税费,服务费,取消费,额外费用,额外费用名称 , 携程马上用车产品没有税费和额外费用字段
|
||||
|
@ -172,7 +175,7 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
|
|||
carOrderDetail.getOriginalOrderNo())
|
||||
.loadBasicOrderInfo(carOrderDetail.getOrderNo(),
|
||||
carOrderDetail.getOrderStatus(),
|
||||
carOrderDetail.getCreateTime());
|
||||
cTripCarRecord.getOrderDate());
|
||||
}, () -> orderCarRecord.loadComplianceInfoNot()
|
||||
.loadRelatedOrderInfo(cTripCarRecordBase.getOrderId(),
|
||||
cTripCarRecord.getRecordId(),
|
||||
|
@ -182,7 +185,7 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
|
|||
String.valueOf(cTripCarRecordBase.getOrderId()))
|
||||
.loadBasicOrderInfo(String.valueOf(cTripCarRecordBase.getOrderId()),
|
||||
"",
|
||||
cTripCarRecordBase.getCreateTime()));
|
||||
cTripCarRecord.getOrderDate()));
|
||||
|
||||
//这里添加归属部门编号 , 这里兼容测试环境 , 如果行程规划单已经有这个值 , 那么直接取, 没有的话,查找用户的部门获取
|
||||
Optional<RouterOrderExtensionField> routerOrderExtensionField = byOrderNo
|
||||
|
|
|
@ -105,7 +105,7 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
|
|||
//公共字段校验
|
||||
flightFieldCheck(orderFlightRecord, lyOrderFlightRecord);
|
||||
orderFlightRecord.setDetailId(lyOrderFlightRecord.getBillOrderNo())//防重标识
|
||||
.setTicketClerk(lyOrderFlightRecord.getReserveManName())//票务员
|
||||
// .setTicketClerk(lyOrderFlightRecord.getReserveManName())//票务员
|
||||
.setAccountPeriod(getAccountPeriod(lyOrderFlightRecord.getStatementCode()))//账期号
|
||||
.setBillNo(lyOrderFlightRecord.getBillOrderNo())//账单号
|
||||
.setOrderNo(lyOrderFlightRecord.getOrderSerialNo())//订单号
|
||||
|
@ -150,7 +150,7 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
|
|||
.setBookOrgCode1(lyOrderFlightRecord.getPassengerDepartment()) //出行人组织架构信息1
|
||||
.setBookOrgCode2(lyOrderFlightRecord.getPassengerDepartment()) //出行人组织架构信息2
|
||||
.setBookOrgCode3(lyOrderFlightRecord.getPassengerDepartment()) //出行人组织架构信息3
|
||||
.setOfflineCcomyCode(lyOrderFlightRecord.getPassengerCostCenter()) //成本中心
|
||||
// .setOfflineCcomyCode(lyOrderFlightRecord.getPassengerCostCenter()) //成本中心
|
||||
.setOrderStatus("") //结算状态
|
||||
// .setExpenseOrderAmount("") //订单金额
|
||||
// .setSettleOrderFlag() //订单对账状态
|
||||
|
@ -195,7 +195,7 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
|
|||
//公共字段校验
|
||||
hotelFieldCheck(orderHotelRecord, lyOrderHotelRecord);
|
||||
orderHotelRecord.setDetailId(lyOrderHotelRecord.getBillOrderNo())//防重标识
|
||||
.setTicketClerk(lyOrderHotelRecord.getReserveManName()) //票务员
|
||||
// .setTicketClerk(lyOrderHotelRecord.getReserveManName()) //票务员
|
||||
.setAccountPeriod(getAccountPeriod(lyOrderHotelRecord.getStatementCode())) //账期号
|
||||
.setBillNo(lyOrderHotelRecord.getBillOrderNo()) //账单号(结算单号)
|
||||
.setOrderNo(lyOrderHotelRecord.getOrderSerialNo()) //订单号
|
||||
|
@ -232,13 +232,13 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
|
|||
.setTaxAmt("") //税费
|
||||
.setInvoiceType(readInvoiceType(lyOrderHotelRecord.getCustomerInvoiceType())) //供应商发票类型
|
||||
.setInvoiceFee("") //开票手续费
|
||||
.setCustodayFee("") //托管费
|
||||
.setCustodayFee(String.valueOf(lyOrderHotelRecord.getServiceAmount()))//托管费
|
||||
.setNoTaxCusFee("") //托管费不含税
|
||||
.setTaxCusFee("") //托管费税费
|
||||
.setRoomTypeName(lyOrderHotelRecord.getBedType()) //房型
|
||||
.setOrderSource(StringUtils.isNotBlank(lyOrderHotelRecord.getOutApplayOrderNo()) ? "Y" : "N") //预订来源:线上/线下
|
||||
.setBookOrgCode1(lyOrderHotelRecord.getPassengerDepartment()) //入住人组织架构信息1
|
||||
.setOfflineCcomyCode(lyOrderHotelRecord.getPassengerCostCenter()) //成本中心
|
||||
// .setOfflineCcomyCode(lyOrderHotelRecord.getPassengerCostCenter()) //成本中心
|
||||
.setOrderStatus("") //结算状态
|
||||
// .setExpenseOrderAmount("") //订单金额
|
||||
// .setSettleOrderFlag() //订单对账状态
|
||||
|
@ -259,7 +259,7 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
|
|||
//酒店订单明细字段赋值
|
||||
private void setHotelRecordDetail(OrderHotelRecord orderHotelRecord, HotelOrderDetail hotelOrderDetail) {
|
||||
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())) //房间数
|
||||
.setStarRate(hotelOrderDetail.getStarRate()) //星级
|
||||
.setBookOrgCode2(hotelOrderDetail.getBOOK_ORG_STRUCT_2()) //入住人组织架构信息2
|
||||
|
@ -280,7 +280,7 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
|
|||
//公共字段校验
|
||||
trainFieldCheck(orderTrainRecord, lyOrderTrainRecord);
|
||||
orderTrainRecord.setDetailId(lyOrderTrainRecord.getBillOrderNo())//防重标识
|
||||
.setTicketClerk(lyOrderTrainRecord.getReserveManName()) //票务员
|
||||
// .setTicketClerk(lyOrderTrainRecord.getReserveManName()) //票务员
|
||||
.setAccountPeriod(getAccountPeriod(lyOrderTrainRecord.getStatementCode())) //账期号
|
||||
.setBillNo(lyOrderTrainRecord.getBillOrderNo()) //账单号
|
||||
.setOrderNo(lyOrderTrainRecord.getOrderSerialNo()) //订单号
|
||||
|
@ -303,18 +303,16 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
|
|||
.setReturnFee(String.valueOf(lyOrderTrainRecord.getRefundFee())) //退票手续费
|
||||
.setNoTaxAmt("") //未税金额
|
||||
.setTaxAmt("") //税额
|
||||
.setOrderAmount(String.valueOf(lyOrderTrainRecord.getToBePayAmount())) //结算总额
|
||||
.setFromCity(lyOrderTrainRecord.getTripName()) //出发城市
|
||||
.setFromStationName(lyOrderTrainRecord.getTripName()) //出发站
|
||||
.setToCity(lyOrderTrainRecord.getTripName()) //到达城市
|
||||
.setToStationName(lyOrderTrainRecord.getTripName()) //到达站
|
||||
.setIssueTicketTime(lyOrderTrainRecord.getEnterAccount()) //出票时间 yyyy-MM-dd HH:mm:ss
|
||||
.setOrderAmount(String.valueOf(lyOrderTrainRecord.getToBePayAmount())); //结算总额
|
||||
//设置出发地和到达地
|
||||
roadTripName(orderTrainRecord, lyOrderTrainRecord.getTripName());
|
||||
orderTrainRecord.setIssueTicketTime(lyOrderTrainRecord.getEnterAccount()) //出票时间 yyyy-MM-dd HH:mm:ss
|
||||
.setTrainNo(lyOrderTrainRecord.getTrainNo()) //车次
|
||||
.setUserCode(lyOrderTrainRecord.getPassengerNo())//出行人编码
|
||||
.setUserName(lyOrderTrainRecord.getPassengerName())//出行人姓名
|
||||
.setOrderSource(StringUtils.isNotBlank(lyOrderTrainRecord.getOutApplayOrderNo()) ? "Y" : "N")//预订来源:线上 / 线下
|
||||
.setBookOrgCode1(lyOrderTrainRecord.getPassengerDepartment())//出行人组织架构信息1
|
||||
.setOfflineCcomyCode(lyOrderTrainRecord.getPassengerCostCenter())//成本中心
|
||||
// .setOfflineCcomyCode(lyOrderTrainRecord.getPassengerCostCenter())//成本中心
|
||||
// .setOrderStatus() //结算状态
|
||||
// .setExpenseOrderAmount() //订单金额
|
||||
// .setSettleOrderFlag() //订单对账状态
|
||||
|
@ -346,10 +344,26 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
|
|||
orderTrainRecord.setParentOrderNo(trainOrderDetail.getParentOrderNo())//父级订单号
|
||||
.setRunTime(trainOrderDetail.getRunTime()) //时长
|
||||
.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
|
||||
.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) {
|
||||
String orderSerialNo = lyOrderCarRecord.getOrderSerialNo();//订单号
|
||||
AtomicReference<OrderDetail> orderDetailRef = new AtomicReference<>();
|
||||
|
@ -363,7 +377,7 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
|
|||
//公共字段校验
|
||||
carFieldCheck(orderCarRecord, lyOrderCarRecord);
|
||||
orderCarRecord.setDetailId(lyOrderCarRecord.getBillOrderNo())//防重标识
|
||||
.setTicketClerk(lyOrderCarRecord.getReserveManName()) //票务员
|
||||
// .setTicketClerk(lyOrderCarRecord.getReserveManName()) //票务员
|
||||
.setAccountPeriod(getAccountPeriod(lyOrderCarRecord.getStatementCode())) //账期号
|
||||
.setBillNo(lyOrderCarRecord.getBillOrderNo()); //账单号
|
||||
orderCarRecord.setReceiptsNum(getReceiptsNum(lyOrderCarRecord.getOutApplayOrderNo(), routeOrder))//关联申请单号
|
||||
|
@ -391,7 +405,7 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
|
|||
.setComyPayAmt(String.valueOf(lyOrderCarRecord.getToBePayAmount())) //公司统付金额
|
||||
.setBookOrgCode1(lyOrderCarRecord.getPassengerDepartment()) //用车人组织架构信息1
|
||||
.setPaymentType(String.valueOf(getPaymentType(lyOrderCarRecord.getPayType()))) //"付款方式0:公司统付 1:个人付 2:混付"
|
||||
.setOfflineCcomyCode(lyOrderCarRecord.getPassengerDepartment()) //成本中心
|
||||
// .setOfflineCcomyCode(lyOrderCarRecord.getPassengerDepartment()) //成本中心
|
||||
.setOrderSource(StringUtils.isNotBlank(lyOrderCarRecord.getOutApplayOrderNo()) ? "Y" : "N") //预订来源:线上/线下
|
||||
// .setExpenseOrderAmount() //订单金额
|
||||
// .setSettleOrderFlag() //订单对账状态
|
||||
|
@ -485,7 +499,8 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
|
|||
if (StringUtils.isBlank(orderFlightRecord.getProjectOrderNo())) {
|
||||
findProjectOrderNo(tripSubmitItemList).ifPresent(orderFlightRecord::setProjectOrderNo);//项目订单号
|
||||
}
|
||||
|
||||
//成本中心
|
||||
findCostCenter(tripSubmitItemList).ifPresent(orderFlightRecord::setOfflineCcomyCode);
|
||||
}
|
||||
|
||||
public void hotelFieldCheck(OrderHotelRecord orderHotelRecord, LyOrderHotelRecord lyOrderHotelRecord) {
|
||||
|
@ -508,7 +523,8 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
|
|||
if (StringUtils.isBlank(orderHotelRecord.getProjectOrderNo())) {
|
||||
findProjectOrderNo(tripSubmitItemList).ifPresent(orderHotelRecord::setProjectOrderNo);//项目订单号
|
||||
}
|
||||
|
||||
//成本中心
|
||||
findCostCenter(tripSubmitItemList).ifPresent(orderHotelRecord::setOfflineCcomyCode);
|
||||
}
|
||||
|
||||
public void trainFieldCheck(OrderTrainRecord orderTrainRecord, LyOrderTrainRecord lyOrderTrainRecord) {
|
||||
|
@ -531,7 +547,8 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
|
|||
if (StringUtils.isBlank(orderTrainRecord.getProjectOrderNo())) {
|
||||
findProjectOrderNo(tripSubmitItemList).ifPresent(orderTrainRecord::setProjectOrderNo);//项目订单号
|
||||
}
|
||||
|
||||
//成本中心
|
||||
findCostCenter(tripSubmitItemList).ifPresent(orderTrainRecord::setOfflineCcomyCode);
|
||||
}
|
||||
|
||||
public void carFieldCheck(OrderCarRecord orderCarRecord, LyOrderCarRecord lyOrderCarRecord) {
|
||||
|
@ -554,7 +571,8 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
|
|||
if (StringUtils.isBlank(orderCarRecord.getProjectOrderNo())) {
|
||||
findProjectOrderNo(tripSubmitItemList).ifPresent(orderCarRecord::setProjectOrderNo);//项目订单号
|
||||
}
|
||||
|
||||
//成本中心
|
||||
findCostCenter(tripSubmitItemList).ifPresent(orderCarRecord::setOfflineCcomyCode);
|
||||
}
|
||||
|
||||
//对应所属系统
|
||||
|
@ -599,6 +617,13 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
|
|||
.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) {
|
||||
|
|
|
@ -8,6 +8,8 @@ import java.util.List;
|
|||
public interface LegRepository {
|
||||
Leg save(Leg leg);
|
||||
|
||||
List<Leg> findByIds(List<Long> legIds);
|
||||
|
||||
void deleteById(Leg leg);
|
||||
void deleteByLegNo(String legNo);
|
||||
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
package com.chint.domain.repository;
|
||||
|
||||
|
||||
import com.chint.domain.aggregates.order.RouteRequest;
|
||||
|
||||
public interface RouteRequestRepository {
|
||||
RouteRequest findByRouteRequestNo(String routeRequestNo);
|
||||
}
|
|
@ -1,12 +1,10 @@
|
|||
package com.chint.domain.service;
|
||||
|
||||
import com.chint.domain.aggregates.order.Leg;
|
||||
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.aggregates.order.*;
|
||||
import com.chint.domain.exceptions.LegEventException;
|
||||
import com.chint.domain.factoriy.leg_event.LegEventFactory;
|
||||
import com.chint.domain.repository.LegRepository;
|
||||
import com.chint.domain.repository.LocationRepository;
|
||||
import com.chint.domain.repository.OrderDetailRepository;
|
||||
import com.chint.domain.repository.RouteRepository;
|
||||
import com.chint.infrastructure.constant.LegConstant;
|
||||
|
@ -34,6 +32,9 @@ public class LegDomainService {
|
|||
@Autowired
|
||||
private RouteRepository routeRepository;
|
||||
|
||||
@Autowired
|
||||
private LocationRepository locationRepository;
|
||||
|
||||
public Leg legCheckOrder(Leg leg) {
|
||||
List<OrderDetail> orderDetailList = orderDetailRepository.findByLegId(leg.getLegId());
|
||||
orderDetailList.forEach(OrderDetail::reloadStatus);
|
||||
|
@ -115,4 +116,29 @@ public class LegDomainService {
|
|||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -13,6 +13,7 @@ import com.chint.domain.factoriy.order.RouteOrderFactory;
|
|||
import com.chint.domain.factoriy.order_detail.OrderDetailFactory;
|
||||
import com.chint.domain.repository.*;
|
||||
import com.chint.domain.service.OrderDomainService;
|
||||
import com.chint.domain.service.RouteRequestDomainService;
|
||||
import com.chint.domain.service.order_sync.SyncAdapter;
|
||||
import com.chint.domain.value_object.ApprovalSimpleData;
|
||||
import com.chint.domain.value_object.ApproveRouteData;
|
||||
|
@ -88,6 +89,9 @@ public class LegEventHandler implements LegEventService {
|
|||
@Autowired
|
||||
private OrderDomainService orderDomainService;
|
||||
|
||||
@Autowired
|
||||
private RouteRequestDomainService routeRequestDomainService;
|
||||
|
||||
@Value("${chint.envMark}")
|
||||
private String envMark;
|
||||
|
||||
|
@ -218,7 +222,7 @@ public class LegEventHandler implements LegEventService {
|
|||
public ResultContainer routeUpdateOrder(RouteUpdateOrderCommand command) {
|
||||
OrderLegData data = command.getData();
|
||||
String orderNo = data.getSelfOrderNo();
|
||||
RouteOrder routeOrder = routeRepository.findByOrderNo(orderNo);
|
||||
RouteOrder routeOrder = routeRequestDomainService.getRouteOrder(orderNo);
|
||||
//获取行程规划单创建者作为该订单
|
||||
String employeeNo = routeOrder.getUserId();
|
||||
User byUserEmployeeNo = userRepository.findByUserEmployeeNo(employeeNo);
|
||||
|
|
|
@ -65,7 +65,7 @@ public class CTripOrderSyncAdapter implements SupplierOrderSync {
|
|||
|
||||
@Override
|
||||
public boolean syncSupplierOrder(RouteOrder order) {
|
||||
log.info("开始同步协程订单");
|
||||
log.info("开始同步携程订单");
|
||||
ApprovalRequest approvalRequestParam = getApprovalRequestParam(order);
|
||||
ApprovalResult approval = approvalRequest.approval(approvalRequestParam);
|
||||
return approval.getSetApprovalResult().getStatus().getSuccess();
|
||||
|
@ -73,28 +73,51 @@ public class CTripOrderSyncAdapter implements SupplierOrderSync {
|
|||
|
||||
@Override
|
||||
public boolean cancelSyncSupplierOrder(RouteOrder order) {
|
||||
log.info("开始取消协程订单");
|
||||
log.info("开始取消携程订单");
|
||||
ApprovalRequest approvalRequestParam = getApprovalRequestParam(order);
|
||||
ApprovalResult approval = approvalRequest.cancelApprovalOrder(approvalRequestParam);
|
||||
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();
|
||||
RankInfo rankInfo = RankInfo.of(order.getStandardLevel());
|
||||
String employeeNo = String.valueOf(order.getUserId());
|
||||
@Override
|
||||
public boolean cancelRouteRequest(RouteRequest routeRequest) {
|
||||
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
|
||||
.buildApproval(order.getRouteOrderNo(), String.valueOf(employeeNo), rankInfo)
|
||||
.addExtendField(approveOrderNo.getAccountCompanyCode())
|
||||
.addExtendField(approveOrderNo.getAccountCompanyName())
|
||||
.addExtendField(approveOrderNo.getSysCode())
|
||||
.buildApproval(routeRequest.getRouteRequestNo(), employeeNo,
|
||||
RankInfo.of(routeRequestFields.getStandardLevel()))
|
||||
.addExtendField(routeRequestFields.getAccountCompanyCode())
|
||||
.addExtendField(routeRequestFields.getAccountCompanyName())
|
||||
.addExtendField(routeRequestFields.getSysCode())
|
||||
.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(
|
||||
order.getLegItems()
|
||||
.stream()
|
||||
.filter(leg -> leg.getLegType().equals(LEG_TYPE_HOTEL) || leg.getLegType().equals(LEG_TYPE_AIRPLANE) || leg.getLegType().equals(LEG_TYPE_TAXI))
|
||||
legList.stream()
|
||||
.filter(leg -> leg.getLegType().equals(LEG_TYPE_HOTEL) ||
|
||||
leg.getLegType().equals(LEG_TYPE_AIRPLANE) ||
|
||||
leg.getLegType().equals(LEG_TYPE_TAXI))
|
||||
.toList()
|
||||
)
|
||||
.stream().collect(Collectors.groupingBy(Leg::getLegType));
|
||||
|
@ -109,6 +132,21 @@ public class CTripOrderSyncAdapter implements SupplierOrderSync {
|
|||
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) {
|
||||
List<HotelEndorsementDetail> hotelList = new ArrayList<>();
|
||||
legs.forEach(leg -> {
|
||||
|
|
|
@ -51,6 +51,14 @@ public class LYOrderSyncAdapter implements SupplierOrderSync {
|
|||
return flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean syncRouteRequest(RouteRequest routeRequest) {
|
||||
log.info("开始同步同程订单");
|
||||
Boolean flag = synchronizationNew(routeRequest, "1");
|
||||
log.info("flag = " + flag);
|
||||
return flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean cancelSyncSupplierOrder(RouteOrder order) {
|
||||
//作废状态2
|
||||
|
@ -61,51 +69,118 @@ public class LYOrderSyncAdapter implements SupplierOrderSync {
|
|||
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) {
|
||||
String supplierOrderSyncUrl = lyBaseUrl + L_Y_ORDER_PATH;//请求地址
|
||||
//1.设置订单参数
|
||||
SupplierOrderParam param = new SupplierOrderParam();//参数
|
||||
//成本中心
|
||||
this.setCostCenter(param, order);
|
||||
param.setOutEmployeeIdType(0);//外部员工ID类型,默认为0
|
||||
// param.setOutTravelApplyNo(order.getApproveOrderNo().getActualOrderNo());//审批订单号
|
||||
param.setOutTravelApplyNo(order.getRouteOrderNo());//审批订单号
|
||||
param.setTravelApplyType(1); //差旅类型:1 普通差旅,2 福利差旅
|
||||
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更新
|
||||
//设置订单基本数据
|
||||
loadBaseData(param, order.getRouteOrderNo(), tag);
|
||||
//设置时间
|
||||
loadTime(param, order.getCreateTime(), order.getUpdateTime());
|
||||
//获取用户信息
|
||||
// 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());
|
||||
param.setOutEmployeeId(order.getUserId());//用户id
|
||||
param.setTravelDescription("同程订单");//描述信息
|
||||
param.setBookableProducts(getLegType(order));//1:国内机票,2:国际机票,3:国内酒店,4:海外酒店,5:火车票,6:用车
|
||||
//设置用户信息和预定类型
|
||||
loadUserAndProducts(param, order);
|
||||
//2.同程的行程节点集合
|
||||
List<AOSItem> aosItems = getAosItems(order);
|
||||
//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<>();
|
||||
AOSPerson aosPerson = new AOSPerson();
|
||||
aosPerson.setName(user.getName());//用户名
|
||||
aosPerson.setRelation(0);//0:内部员工,1:配偶,2:子女,3:父母,4:面试候选人,5:实习生,6:外部宾客
|
||||
aosPerson.setPassengerType(0);//0:成人, 1:儿童, 2:婴儿
|
||||
// aosPerson.setOutEmployeeId(String.valueOf("1".equals(tag) ? user.getEmployeeNo() : order.getUserId()));//SF号(长工号)
|
||||
aosPerson.setOutEmployeeId(order.getUserId());//SF号(长工号)
|
||||
aosPerson.setOutEmployeeId(userId);//SF号(长工号)
|
||||
aosPeople.add(aosPerson);
|
||||
//4.前置差旅政策
|
||||
return aosPeople;
|
||||
}
|
||||
|
||||
//前置差旅政策
|
||||
private List<AOSPreTravelPolicy> readAOSPreTravelPolicy(String standardLevel) {
|
||||
List<AOSPreTravelPolicy> aosPreTravelPolicies = new ArrayList<>();
|
||||
for (int i = 1; i < 7; i++) {
|
||||
AOSPreTravelPolicy aosPreTravelPolicy = new AOSPreTravelPolicy();
|
||||
aosPreTravelPolicy.setPolicyCode(order.getStandardLevel());//一般指客户经理提供的差旅政策标题
|
||||
aosPreTravelPolicy.setPolicyCode(standardLevel);//一般指客户经理提供的差旅政策标题
|
||||
aosPreTravelPolicy.setProductTypeId(i);//产品ID 1:国内机票,2:国际机票,3:国内酒店,4:海外酒店,5:火车票,6:用车
|
||||
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.setPersonList(aosPeople);// 同程信息(实际出行人)
|
||||
param.setPreTravelPolicyList(aosPreTravelPolicies);// 同程政策
|
||||
|
@ -130,12 +205,6 @@ public class LYOrderSyncAdapter implements SupplierOrderSync {
|
|||
|
||||
//同程Leg集合解析
|
||||
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(
|
||||
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_TAXI)))
|
||||
.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);
|
||||
for (Leg leg : legItems) {
|
||||
//开始时间
|
||||
|
@ -198,24 +343,6 @@ public class LYOrderSyncAdapter implements SupplierOrderSync {
|
|||
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) {
|
||||
if (location.getLocationType().equals(LOCATION_TYPE_CITY)) {
|
||||
return location;
|
||||
|
@ -235,6 +362,7 @@ public class LYOrderSyncAdapter implements SupplierOrderSync {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
//去重
|
||||
public String removeDuplicates(StringBuilder stringBuilder) {
|
||||
String cityStr = String.valueOf(stringBuilder);
|
||||
|
|
|
@ -2,10 +2,14 @@ package com.chint.domain.service.order_sync;
|
|||
|
||||
|
||||
import com.chint.domain.aggregates.order.RouteOrder;
|
||||
import com.chint.domain.aggregates.order.RouteRequest;
|
||||
import com.chint.domain.factoriy.order.RouteOrderFactory;
|
||||
|
||||
public interface SupplierOrderSync {
|
||||
boolean syncSupplierOrder(RouteOrder order);
|
||||
|
||||
boolean syncRouteRequest(RouteRequest routeRequest);
|
||||
|
||||
boolean cancelSyncSupplierOrder(RouteOrder order);
|
||||
boolean cancelRouteRequest(RouteRequest routeRequest);
|
||||
}
|
||||
|
|
|
@ -7,7 +7,9 @@ import java.util.List;
|
|||
@Data
|
||||
public class SyncLegData {
|
||||
private Long routeId;
|
||||
private Long routeRequestId;
|
||||
private List<Long> routeIds;
|
||||
private List<Long> legIds;
|
||||
private String supplierName;
|
||||
public static SyncLegData of( Long routeId,String supplierName){
|
||||
SyncLegData syncLegData = new SyncLegData();
|
||||
|
|
|
@ -11,4 +11,7 @@ public class OrderRecordConstant {
|
|||
//项目订单号
|
||||
public static final String LY_CUSTOM4 = "Custom4";
|
||||
|
||||
//成本中心
|
||||
public static final String LY_CUSTOM5 = "CostCenter";
|
||||
|
||||
}
|
||||
|
|
|
@ -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 = "已取消";
|
||||
}
|
|
@ -29,6 +29,11 @@ public class LegRepositoryImpl implements LegRepository {
|
|||
return leg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Leg> findByIds(List<Long> legIds) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteById(Leg leg) {
|
||||
routeCacheService.invalidateRouteCache(leg.getRouteId());
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
|
||||
}
|
|
@ -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.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.OrderFlightResponse;
|
||||
import com.chint.interfaces.rest.ctrip.dto.order.OrderHotelResponse;
|
||||
|
@ -81,7 +82,7 @@ public class CTripOrderRecordAutoSave {
|
|||
OrderFlightResponse.FlightOrderBaseInfo orderBaseInfo = it.getOrderBaseInfo();
|
||||
record.setRouteOrderNo(orderBaseInfo.getJourneyID());
|
||||
OrderFlightResponse.FlightOrderPassenger orderPassengerInfo = it.getOrderPassengerInfo();
|
||||
if(orderPassengerInfo != null){
|
||||
if (orderPassengerInfo != null) {
|
||||
record.setTicketNo(orderPassengerInfo.getTicketNo());
|
||||
}
|
||||
return record;
|
||||
|
@ -190,6 +191,8 @@ public class CTripOrderRecordAutoSave {
|
|||
//补充额外的字段
|
||||
OrderCarResponse.CarOrderCorpInfo corpInfo = it.getOrderDetail().getCorpInfo();
|
||||
record.setRouteOrderNo(corpInfo.getJouneryId());
|
||||
String orderDate = it.getOrderDetail().getOrderBaseInfo().getOrderDate();
|
||||
record.setOrderDate(DateTimeUtil.timeToStrCommon(DateTimeUtil.strToTime(orderDate)));
|
||||
return record;
|
||||
}).toList();
|
||||
cTripOrderDetailRepository.saveAllCTripCarRecord(list);
|
||||
|
|
|
@ -196,7 +196,7 @@ public class UserHttpRequestImpl implements UserHttpRequest {
|
|||
.findFirst()
|
||||
.ifPresent(it -> {
|
||||
User byUserEmployeeNo = userRepository.findByUserEmployeeNo(user.getEmployeeNo());
|
||||
if(byUserEmployeeNo == null){
|
||||
if (byUserEmployeeNo == null) {
|
||||
userRepository.save(
|
||||
getDataFromUserSFData(user, it)
|
||||
);
|
||||
|
@ -290,6 +290,12 @@ public class UserHttpRequestImpl implements UserHttpRequest {
|
|||
//根据入账公司没有找到部门编码的话,直接获取主岗编码
|
||||
deptCode = user.lowestDeptCode();
|
||||
}
|
||||
|
||||
if (deptCode == null) {
|
||||
//如果还是空的话 , 就返回null
|
||||
return null;
|
||||
}
|
||||
|
||||
//清除部门编码里面的字母
|
||||
return deptCode.replaceAll("\\D", "");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue