From f6b2ffd1ee095af84be4a517876b483867a86292 Mon Sep 17 00:00:00 2001 From: lulz1 Date: Wed, 24 Apr 2024 16:02:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=AB=98=E5=BE=B7=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order_sync/AmapOrderSyncAdapter.java | 26 +++++++++++++++++++ .../service/order_sync/SupplierOrderSync.java | 2 -- .../service/order_sync/SyncAdapter.java | 7 +++-- .../infrastructure/constant/AmapConstant.java | 4 +++ .../constant/SupplierNameConstant.java | 6 +++++ .../rest/amap/AmapLocationRequest.java | 19 ++++++++++++++ .../interfaces/rest/amap/AmapUserRequest.java | 23 +++++++++++++++- .../dto/location/LocationRequestParam.java | 8 ++++++ .../amap/dto/location/LocationResponse.java | 4 +++ 9 files changed, 94 insertions(+), 5 deletions(-) create mode 100644 src/main/java/com/chint/domain/service/order_sync/AmapOrderSyncAdapter.java create mode 100644 src/main/java/com/chint/interfaces/rest/amap/AmapLocationRequest.java create mode 100644 src/main/java/com/chint/interfaces/rest/amap/dto/location/LocationRequestParam.java create mode 100644 src/main/java/com/chint/interfaces/rest/amap/dto/location/LocationResponse.java diff --git a/src/main/java/com/chint/domain/service/order_sync/AmapOrderSyncAdapter.java b/src/main/java/com/chint/domain/service/order_sync/AmapOrderSyncAdapter.java new file mode 100644 index 00000000..7db9e9c6 --- /dev/null +++ b/src/main/java/com/chint/domain/service/order_sync/AmapOrderSyncAdapter.java @@ -0,0 +1,26 @@ +package com.chint.domain.service.order_sync; + +import com.chint.domain.aggregates.order.RouteOrder; +import com.chint.domain.aggregates.order.RouteRequest; + +public class AmapOrderSyncAdapter implements SupplierOrderSync{ + @Override + public boolean syncSupplierOrder(RouteOrder order) { + return false; + } + + @Override + public boolean syncRouteRequest(RouteRequest routeRequest) { + return false; + } + + @Override + public boolean cancelSyncSupplierOrder(RouteOrder order) { + return false; + } + + @Override + public boolean cancelRouteRequest(RouteRequest routeRequest) { + return false; + } +} 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 fbe24a21..c9dfcd24 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 @@ -7,9 +7,7 @@ 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/domain/service/order_sync/SyncAdapter.java b/src/main/java/com/chint/domain/service/order_sync/SyncAdapter.java index df0de861..12ade713 100644 --- a/src/main/java/com/chint/domain/service/order_sync/SyncAdapter.java +++ b/src/main/java/com/chint/domain/service/order_sync/SyncAdapter.java @@ -6,6 +6,8 @@ import com.chint.infrastructure.constant.SupplierNameConstant; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import static com.chint.infrastructure.constant.SupplierNameConstant.*; + @Component public class SyncAdapter { @@ -17,8 +19,9 @@ public class SyncAdapter { public SupplierOrderSync of(String supplierName) { return switch (supplierName) { - case SupplierNameConstant.SUPPLIER_C_TRIP -> cTripOrderSyncAdapter; - case SupplierNameConstant.SUPPLIER_L_Y -> lyOrderSyncAdapter; + case SUPPLIER_C_TRIP -> cTripOrderSyncAdapter; + case SUPPLIER_L_Y -> lyOrderSyncAdapter; + case SUPPLIER_AMAP -> lyOrderSyncAdapter; default -> throw new NotFoundException(CommonMessageConstant.NOT_FOUND); }; } diff --git a/src/main/java/com/chint/infrastructure/constant/AmapConstant.java b/src/main/java/com/chint/infrastructure/constant/AmapConstant.java index 2b61e89f..4bbd5113 100644 --- a/src/main/java/com/chint/infrastructure/constant/AmapConstant.java +++ b/src/main/java/com/chint/infrastructure/constant/AmapConstant.java @@ -14,6 +14,10 @@ public class AmapConstant { public static final String FINISHED_ORDER_URL = "/ws/car/open/enterprise/bill/detail/list";//企业完单数据分页查询 public static final String CANCEL_AN_ORDER_URL = "/ws/car/open/enterprise/cancelOrder";//取消订单 + //订单详情地址,查询城市信息 + public static final String AMAP_LOCATION_PATH = "/ws/boss/enterprise/openapi/city/query";//取消订单 + + //登录路径 public static final String AMAP_LOGIN_PATH = "/node"; } diff --git a/src/main/java/com/chint/infrastructure/constant/SupplierNameConstant.java b/src/main/java/com/chint/infrastructure/constant/SupplierNameConstant.java index b4d88ca5..33494e9c 100644 --- a/src/main/java/com/chint/infrastructure/constant/SupplierNameConstant.java +++ b/src/main/java/com/chint/infrastructure/constant/SupplierNameConstant.java @@ -5,8 +5,14 @@ public class SupplierNameConstant { public static final String SUPPLIER_C_TRIP_CN_NAME = "携程"; public static final String SUPPLIER_C_TRIP_EXTENSION_NAME = "携程预定"; public static final String SUPPLIER_C_TRIP_BPM_NAME = "携程商旅"; + public static final String SUPPLIER_L_Y = "LY"; public static final String SUPPLIER_L_Y_CN_NAME = "同程"; public static final String SUPPLIER_L_Y_EXTENSION_NAME = "同程预定"; public static final String SUPPLIER_L_Y_BPM_NAME = "同程商旅"; + + public static final String SUPPLIER_AMAP = "Amap"; + public static final String SUPPLIER_AMAP_CN_NAME = "高德"; + public static final String SUPPLIER_AMAP_EXTENSION_NAME = "高德预定"; + public static final String SUPPLIER_AMAP_BPM_NAME = "高德商旅"; } diff --git a/src/main/java/com/chint/interfaces/rest/amap/AmapLocationRequest.java b/src/main/java/com/chint/interfaces/rest/amap/AmapLocationRequest.java new file mode 100644 index 00000000..7944b6ed --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/amap/AmapLocationRequest.java @@ -0,0 +1,19 @@ +package com.chint.interfaces.rest.amap; + +import com.chint.interfaces.rest.amap.request.AmapRequest; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; + +@Service +public class AmapLocationRequest { + + @Autowired + private AmapRequest amapRequest; + + @Value("${amap.baseUrl}") + private String BaseUrl; + + +// public +} diff --git a/src/main/java/com/chint/interfaces/rest/amap/AmapUserRequest.java b/src/main/java/com/chint/interfaces/rest/amap/AmapUserRequest.java index e738cc75..d1a4fa32 100644 --- a/src/main/java/com/chint/interfaces/rest/amap/AmapUserRequest.java +++ b/src/main/java/com/chint/interfaces/rest/amap/AmapUserRequest.java @@ -1,21 +1,27 @@ package com.chint.interfaces.rest.amap; +import com.chint.application.commands.UserLoginCommand; import com.chint.domain.aggregates.user.User; import com.chint.domain.repository.UserNameRepository; +import com.chint.infrastructure.echo_framework.annotation.ListenTo; import com.chint.interfaces.rest.amap.dto.UserQueryResponse; import com.chint.interfaces.rest.amap.request.AmapRequest; import com.chint.interfaces.rest.user.UserHttpRequest; +import com.chint.interfaces.rest.user.UserSync; import lombok.Data; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import java.util.List; +import java.util.concurrent.CompletableFuture; import static com.chint.infrastructure.constant.AmapConstant.*; +@Slf4j @Component -public class AmapUserRequest { +public class AmapUserRequest implements UserSync { @Autowired private AmapRequest amapRequest; @@ -59,6 +65,21 @@ public class AmapUserRequest { return amapRequest.post(updateUserUrl, baseRequestParam, BaseResponse.class); } + + @ListenTo(command = "UserLoginCommand",order = 3) + @Override + public User syncUserInfoToSupplier(UserLoginCommand command) { + User user = command.getUser(); + // 如果超过一天,执行同步代码 + if (user.checkSyncTime()) { + log.info("开始往高德同步用户信息"); + CompletableFuture.runAsync(() -> syncUser(command.getUser())); + } else { + log.info("未超过一天,不执行高德同步"); + } + return user; + } + @Data public static class UserParam extends BaseRequestParam { private String userId; // 用户Id diff --git a/src/main/java/com/chint/interfaces/rest/amap/dto/location/LocationRequestParam.java b/src/main/java/com/chint/interfaces/rest/amap/dto/location/LocationRequestParam.java new file mode 100644 index 00000000..5d94b914 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/amap/dto/location/LocationRequestParam.java @@ -0,0 +1,8 @@ +package com.chint.interfaces.rest.amap.dto.location; + +import lombok.Data; + +@Data +public class LocationRequestParam { + private String keywords; +} diff --git a/src/main/java/com/chint/interfaces/rest/amap/dto/location/LocationResponse.java b/src/main/java/com/chint/interfaces/rest/amap/dto/location/LocationResponse.java new file mode 100644 index 00000000..a5761fa0 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/amap/dto/location/LocationResponse.java @@ -0,0 +1,4 @@ +package com.chint.interfaces.rest.amap.dto.location; + +public class LocationResponse { +}