From f891922beeba2b522648b99c887643ac9e770f18 Mon Sep 17 00:00:00 2001 From: lulz1 Date: Mon, 8 Apr 2024 09:10:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=AD=BE=E8=AF=81=E5=9B=9E?= =?UTF-8?q?=E4=BC=A0=E7=BB=99=E8=B4=A2=E5=8A=A1=E5=85=B1=E4=BA=AB=E7=9A=84?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/dtos/trip/ScheduleDetail.java | 21 ++++++++-- .../application/queryies/OrderQuery.java | 27 +++++------- .../domain/aggregates/base/BaseEvent.java | 11 ++++- .../aggregates/base/EventManageable.java | 12 +++--- .../domain/aggregates/order/RouteRequest.java | 13 ++++-- .../aggregates/order/RouteRequestEvent.java | 19 +++++---- .../aggregates/order/RouteRequestFields.java | 42 +++++++++++++++++++ .../order_sync/CTripOrderSyncAdapter.java | 11 +++++ .../order_sync/LYOrderSyncAdapter.java | 10 +++++ .../service/order_sync/SupplierOrderSync.java | 4 ++ .../constant/RouteRequestConstant.java | 10 +++++ 11 files changed, 140 insertions(+), 40 deletions(-) create mode 100644 src/main/java/com/chint/domain/aggregates/order/RouteRequestFields.java create mode 100644 src/main/java/com/chint/infrastructure/constant/RouteRequestConstant.java diff --git a/src/main/java/com/chint/application/dtos/trip/ScheduleDetail.java b/src/main/java/com/chint/application/dtos/trip/ScheduleDetail.java index 3d052ea8..2229ee18 100644 --- a/src/main/java/com/chint/application/dtos/trip/ScheduleDetail.java +++ b/src/main/java/com/chint/application/dtos/trip/ScheduleDetail.java @@ -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 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; diff --git a/src/main/java/com/chint/application/queryies/OrderQuery.java b/src/main/java/com/chint/application/queryies/OrderQuery.java index 56002faf..ee1b7450 100644 --- a/src/main/java/com/chint/application/queryies/OrderQuery.java +++ b/src/main/java/com/chint/application/queryies/OrderQuery.java @@ -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 locationListAfterNotNull = locationList.stream().filter(Objects::nonNull).toList(); - -// List 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 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()) @@ -444,6 +432,11 @@ public class OrderQuery { .nightCount(leg.nightCount().toString()); } + if (leg.getLegType().equals(LEG_TYPE_OTHER) && leg.getLegExtensionField().getAmountType().equals(LEG_OTHER_AMOUNT_TYPE_VISA)) { + scheduleDetailBuilder.expenseTypeId("6770f575013211eabce29fde958f48e4") + .travelType("LOCAL_OTHER"); + } + if (leg.getCurrencyType() != null) { scheduleDetailBuilder .currencyName(leg.getCurrencyType().getDescription()) diff --git a/src/main/java/com/chint/domain/aggregates/base/BaseEvent.java b/src/main/java/com/chint/domain/aggregates/base/BaseEvent.java index 4e38f653..6da859ab 100644 --- a/src/main/java/com/chint/domain/aggregates/base/BaseEvent.java +++ b/src/main/java/com/chint/domain/aggregates/base/BaseEvent.java @@ -2,17 +2,24 @@ package com.chint.domain.aggregates.base; import lombok.Data; +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; private transient String eventName; - private LocalDateTime happenTime; + private LocalDateTime happenTime = LocalDateTime.now(); + + private String extension; // 新增抽象方法:获取状态码与状态名称的映射表 protected abstract Map getStatusMappings(); diff --git a/src/main/java/com/chint/domain/aggregates/base/EventManageable.java b/src/main/java/com/chint/domain/aggregates/base/EventManageable.java index 38c8454a..07dd32b5 100644 --- a/src/main/java/com/chint/domain/aggregates/base/EventManageable.java +++ b/src/main/java/com/chint/domain/aggregates/base/EventManageable.java @@ -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 getEvents(); + List getEvents(); // 默认方法:添加事件 default void addEvent(BaseEvent event) { - getEvents().add(event); + List events = (List) getEvents(); + events.add(event); } // 默认方法:获取最新的事件 default BaseEvent getLastEvent() { - return getEvents().stream() - .max(Comparator.comparing(BaseEvent::getHappenTime)) - .orElseThrow(() -> new NoSuchElementException("No events found.")); + List eventList = getEvents(); + return eventList.isEmpty() ? null : eventList.get(eventList.size() - 1); } } \ No newline at end of file diff --git a/src/main/java/com/chint/domain/aggregates/order/RouteRequest.java b/src/main/java/com/chint/domain/aggregates/order/RouteRequest.java index e2c3a66f..3dc86a58 100644 --- a/src/main/java/com/chint/domain/aggregates/order/RouteRequest.java +++ b/src/main/java/com/chint/domain/aggregates/order/RouteRequest.java @@ -1,7 +1,6 @@ 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.EventManageable; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -19,7 +18,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,12 +31,15 @@ public class RouteRequest implements Serializable { private String RouteRequestNo; + @MappedCollection(idColumn = "route_request_id", keyColumn = "route_request_key") private List routeRequestLegList; @MappedCollection(idColumn = "route_request_id", keyColumn = "route_request_key") private List eventList; + @MappedCollection(idColumn = "route_request_id") + private RouteRequestFields routeRequestFields; @Transient private String supplier; @Transient @@ -54,4 +56,9 @@ public class RouteRequest implements Serializable { @ApiModelProperty("最后更新时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") public LocalDateTime updateTime; + + @Override + public List getEvents() { + return this.eventList; + } } diff --git a/src/main/java/com/chint/domain/aggregates/order/RouteRequestEvent.java b/src/main/java/com/chint/domain/aggregates/order/RouteRequestEvent.java index 983776c6..eab2d678 100644 --- a/src/main/java/com/chint/domain/aggregates/order/RouteRequestEvent.java +++ b/src/main/java/com/chint/domain/aggregates/order/RouteRequestEvent.java @@ -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,10 @@ public class RouteRequestEvent implements Serializable { private Long routeRequestKey; - private Integer eventType; - - private String extension; - - private LocalDateTime happenTime; - + @Override + protected Map 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); + } } diff --git a/src/main/java/com/chint/domain/aggregates/order/RouteRequestFields.java b/src/main/java/com/chint/domain/aggregates/order/RouteRequestFields.java new file mode 100644 index 00000000..a7e3a081 --- /dev/null +++ b/src/main/java/com/chint/domain/aggregates/order/RouteRequestFields.java @@ -0,0 +1,42 @@ +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 projectName; + @ApiModelProperty("成本中心") + private String costCenter; + @ApiModelProperty("申请说明") + private String instructions; + @ApiModelProperty("财务共享订单创建人") + private String creator; + @ApiModelProperty("申请人") + private String userId; +} diff --git a/src/main/java/com/chint/domain/service/order_sync/CTripOrderSyncAdapter.java b/src/main/java/com/chint/domain/service/order_sync/CTripOrderSyncAdapter.java index 5eb285f2..49fac8f3 100644 --- a/src/main/java/com/chint/domain/service/order_sync/CTripOrderSyncAdapter.java +++ b/src/main/java/com/chint/domain/service/order_sync/CTripOrderSyncAdapter.java @@ -71,6 +71,7 @@ public class CTripOrderSyncAdapter implements SupplierOrderSync { return approval.getSetApprovalResult().getStatus().getSuccess(); } + @Override public boolean cancelSyncSupplierOrder(RouteOrder order) { log.info("开始取消协程订单"); @@ -79,6 +80,16 @@ public class CTripOrderSyncAdapter implements SupplierOrderSync { return approval.getSetApprovalResult().getStatus().getSuccess(); } + @Override + public boolean syncRouteRequest(RouteRequest routeRequest) { + return false; + } + + @Override + public boolean cancelRouteRequest(RouteRequest routeRequest) { + return false; + } + private ApprovalRequest getApprovalRequestParam(RouteOrder order) { ApproveOrderNo approveOrderNo = order.getApproveOrderNo(); diff --git a/src/main/java/com/chint/domain/service/order_sync/LYOrderSyncAdapter.java b/src/main/java/com/chint/domain/service/order_sync/LYOrderSyncAdapter.java index dba727b3..df3c74ea 100644 --- a/src/main/java/com/chint/domain/service/order_sync/LYOrderSyncAdapter.java +++ b/src/main/java/com/chint/domain/service/order_sync/LYOrderSyncAdapter.java @@ -51,6 +51,11 @@ public class LYOrderSyncAdapter implements SupplierOrderSync { return flag; } + @Override + public boolean syncRouteRequest(RouteRequest routeRequest) { + return false; + } + @Override public boolean cancelSyncSupplierOrder(RouteOrder order) { //作废状态2 @@ -61,6 +66,11 @@ public class LYOrderSyncAdapter implements SupplierOrderSync { return flag; } + @Override + public boolean cancelRouteRequest(RouteRequest routeRequest) { + return false; + } + //同步同程订单 private Boolean synchronization(RouteOrder order, String tag) { String supplierOrderSyncUrl = lyBaseUrl + L_Y_ORDER_PATH;//请求地址 diff --git a/src/main/java/com/chint/domain/service/order_sync/SupplierOrderSync.java b/src/main/java/com/chint/domain/service/order_sync/SupplierOrderSync.java index 66ea3ce0..fbe24a21 100644 --- a/src/main/java/com/chint/domain/service/order_sync/SupplierOrderSync.java +++ b/src/main/java/com/chint/domain/service/order_sync/SupplierOrderSync.java @@ -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); } diff --git a/src/main/java/com/chint/infrastructure/constant/RouteRequestConstant.java b/src/main/java/com/chint/infrastructure/constant/RouteRequestConstant.java new file mode 100644 index 00000000..346fd6be --- /dev/null +++ b/src/main/java/com/chint/infrastructure/constant/RouteRequestConstant.java @@ -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 = "已取消"; +}