From 7ab0339152ab690c5a16d618c54f169db5642b20 Mon Sep 17 00:00:00 2001 From: lulz1 Date: Fri, 1 Mar 2024 13:21:41 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dtos/trip/HotelScheduleDetail.java | 4 +- .../application/dtos/trip/ScheduleDetail.java | 22 +++++ .../application/out/LoginController.java | 90 +++++++++++-------- .../application/queryies/OrderQuery.java | 20 ++++- .../chint/domain/aggregates/order/Leg.java | 13 +++ .../chint/domain/aggregates/user/User.java | 6 +- .../rest/ly/in/CommonController.java | 1 - 7 files changed, 112 insertions(+), 44 deletions(-) diff --git a/src/main/java/com/chint/application/dtos/trip/HotelScheduleDetail.java b/src/main/java/com/chint/application/dtos/trip/HotelScheduleDetail.java index c5d2f71f..a9b8dc52 100644 --- a/src/main/java/com/chint/application/dtos/trip/HotelScheduleDetail.java +++ b/src/main/java/com/chint/application/dtos/trip/HotelScheduleDetail.java @@ -6,7 +6,7 @@ import lombok.Data; @Data public class HotelScheduleDetail extends ScheduleDetail { private String lastUpdateTime; - private Integer nightCount; + private String nightCount; public static HotelScheduleDetailBuilder builder(){ return new HotelScheduleDetailBuilder(); } @@ -19,7 +19,7 @@ public class HotelScheduleDetail extends ScheduleDetail { return this; } - public HotelScheduleDetailBuilder nightCount(Integer nightCount) { + public HotelScheduleDetailBuilder nightCount(String nightCount) { hotelScheduleDetail.setNightCount(nightCount); return this; } 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 40901620..b150f635 100644 --- a/src/main/java/com/chint/application/dtos/trip/ScheduleDetail.java +++ b/src/main/java/com/chint/application/dtos/trip/ScheduleDetail.java @@ -9,6 +9,9 @@ import java.util.List; @Data public class ScheduleDetail { + + protected Long legId; + protected String serviceProvider; protected String orderState; @@ -114,6 +117,10 @@ public class ScheduleDetail { @JsonProperty("RealScheduleNum") protected String RealScheduleNum; + @JsonProperty("NightCount") + protected String NightCount; + @JsonProperty("RoomCount") + protected String RoomCount; // Constructor, getters and setters @@ -130,6 +137,21 @@ public class ScheduleDetail { return this; } + public ScheduleDetailBuilder legId(Long legId) { + scheduleDetail.setLegId(legId); + return this; + } + + public ScheduleDetailBuilder nightCount(String NightCount) { + scheduleDetail.setNightCount(NightCount); + return this; + } + + public ScheduleDetailBuilder roomCount(String RoomCount) { + scheduleDetail.setRoomCount(RoomCount); + return this; + } + public ScheduleDetailBuilder orderState(String orderState) { scheduleDetail.setOrderState(orderState); return this; diff --git a/src/main/java/com/chint/application/out/LoginController.java b/src/main/java/com/chint/application/out/LoginController.java index 6b4f3f9b..7d83461d 100644 --- a/src/main/java/com/chint/application/out/LoginController.java +++ b/src/main/java/com/chint/application/out/LoginController.java @@ -6,6 +6,7 @@ import com.chint.application.services.login.strategy.PailaLoginStrategy; import com.chint.application.services.login.strategy.PailaMobileLoginStrategy; import com.chint.domain.aggregates.user.User; import com.chint.domain.exceptions.OrderException; +import com.chint.domain.repository.UserRepository; import com.chint.domain.service.SystemDomainService; import com.chint.domain.service.auth.AuthenticateService; import com.chint.domain.value_object.UserLoginParam; @@ -18,15 +19,18 @@ import com.chint.infrastructure.util.Digest; import com.chint.infrastructure.util.Result; import com.chint.interfaces.rest.ctrip.CTripUserSaveRequest; import com.chint.interfaces.rest.ly.LYUserRequest; -import com.chint.interfaces.rest.ly.dto.login.LoginParam; import com.chint.interfaces.rest.user.UserHttpRequest; import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; +import java.time.Duration; +import java.time.LocalDateTime; import java.util.concurrent.CompletableFuture; +@Slf4j @RestController @RequestMapping("/public") public class LoginController { @@ -52,6 +56,9 @@ public class LoginController { @Autowired private PailaMobileLoginStrategy pailaMobileLoginStrategy; + @Autowired + private UserRepository userRepository; + @ApiOperation("财务共享登录") @Transactional @GetMapping("/login") @@ -83,17 +90,7 @@ public class LoginController { //异步执行更新用户信息到同程 User currentUser = userLoginResult.getUser(); - CompletableFuture.runAsync(() -> { - BaseContext.setCurrentUser(currentUser); - lyUserRequest.saveCurrentUser(); - BaseContext.removeCurrentUser(); - }); - //异步执行更新用户信息到携程 - CompletableFuture.runAsync(() -> { - BaseContext.setCurrentUser(currentUser); - cTripUserSaveRequest.saveUserToCTrip(); - BaseContext.removeCurrentUser(); - }); + syncUserInfoToSupplier(currentUser); //清除职级信息 userLoginResult.getUser().setProfLevel(null); @@ -107,7 +104,7 @@ public class LoginController { @ApiOperation("商旅平台单点") @Transactional @PostMapping("/login/sso") - public Result loginSSO(@RequestBody UserLoginParam userLoginParam){ + public Result loginSSO(@RequestBody UserLoginParam userLoginParam) { String employeeNo = pailaLoginStrategy.login(userLoginParam.getCode()); @@ -117,18 +114,7 @@ public class LoginController { //异步执行更新用户信息到同程 User currentUser = userLoginResult.getUser(); - CompletableFuture.runAsync(() -> { - BaseContext.setCurrentUser(currentUser); - lyUserRequest.saveCurrentUser(); - BaseContext.removeCurrentUser(); - }); - //异步执行更新用户信息到携程 - CompletableFuture.runAsync(() -> { - BaseContext.setCurrentUser(currentUser); - cTripUserSaveRequest.saveUserToCTrip(); - BaseContext.removeCurrentUser(); - }); - + syncUserInfoToSupplier(currentUser); //清除职级信息 userLoginResult.getUser().setProfLevel(null); userLoginResult.getUser().setManaLevel(null); @@ -138,7 +124,7 @@ public class LoginController { @ApiOperation("商旅平台移动端单点") @Transactional @PostMapping("/login/sso/mobile") - public Result loginSSOMobile(@RequestBody UserLoginParam userLoginParam){ + public Result loginSSOMobile(@RequestBody UserLoginParam userLoginParam) { String employeeNo = pailaMobileLoginStrategy.login(userLoginParam.getCode()); @@ -148,21 +134,51 @@ public class LoginController { //异步执行更新用户信息到同程 User currentUser = userLoginResult.getUser(); - CompletableFuture.runAsync(() -> { - BaseContext.setCurrentUser(currentUser); - lyUserRequest.saveCurrentUser(); - BaseContext.removeCurrentUser(); - }); - //异步执行更新用户信息到携程 - CompletableFuture.runAsync(() -> { - BaseContext.setCurrentUser(currentUser); - cTripUserSaveRequest.saveUserToCTrip(); - BaseContext.removeCurrentUser(); - }); + syncUserInfoToSupplier(currentUser); //清除职级信息 userLoginResult.getUser().setProfLevel(null); userLoginResult.getUser().setManaLevel(null); return Result.Success(CommonMessageConstant.SUCCESS, userLoginResult); } + + private void syncUserInfoToSupplier(User user) { + // 给定的 LocalDateTime 实例,示例中为2024年3月1日15:00 + LocalDateTime lastSyncTime = user.getSyncTime(); + + if (lastSyncTime == null) { + asyncUser(user); + return; + } + // 获取当前时间 + LocalDateTime now = LocalDateTime.now(); + + // 计算当前时间与给定时间之间的持续时间 + Duration duration = Duration.between(lastSyncTime, now); + + // 判断是否超过一天 + if (duration.toDays() >= 1) { + asyncUser(user); + } else { + log.info("未超过一天,不执行同步。"); + } + } + + private void asyncUser(User user) { + // 如果超过一天,执行同步代码 + CompletableFuture.runAsync(() -> { + BaseContext.setCurrentUser(user); + lyUserRequest.saveCurrentUser(); + BaseContext.removeCurrentUser(); + }); + //异步执行更新用户信息到携程 + CompletableFuture.runAsync(() -> { + BaseContext.setCurrentUser(user); + cTripUserSaveRequest.saveUserToCTrip(); + BaseContext.removeCurrentUser(); + }); + // 发送保存用户同步时间 + user.setSyncTime(LocalDateTime.now()); + userRepository.save(user); + } } diff --git a/src/main/java/com/chint/application/queryies/OrderQuery.java b/src/main/java/com/chint/application/queryies/OrderQuery.java index 7d38946d..c630361e 100644 --- a/src/main/java/com/chint/application/queryies/OrderQuery.java +++ b/src/main/java/com/chint/application/queryies/OrderQuery.java @@ -19,6 +19,7 @@ import com.chint.infrastructure.constant.FSSCConstant; import com.chint.infrastructure.constant.LegConstant; import com.chint.infrastructure.util.BaseContext; import com.chint.infrastructure.util.PageResult; +import com.chint.infrastructure.util.StringCheck; import com.chint.interfaces.rest.user.UserHttpRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; @@ -32,6 +33,7 @@ import java.util.Objects; import java.util.stream.Collectors; import java.util.stream.Stream; +import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_HOTEL; 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.ORDER_STATUS_APPROVAL; @@ -68,6 +70,12 @@ public class OrderQuery { public PageResult pageQuery(OrderQueryData queryData) { + if (StringCheck.isFirstCharacterChinese(queryData.getKeyWord())) { + queryData.setInstructions(queryData.getKeyWord()); + } else { + queryData.setOrderNo(queryData.getKeyWord()); + } + //执行筛选分页查询 List approvalStatusCodes = queryData.getApprovalStatusCodes(); List legTypes = queryData.getLegTypes(); @@ -230,7 +238,9 @@ public class OrderQuery { leg.reloadStatus(); CityEntity originCity; CityEntity destinationCity; - ScheduleDetail.ScheduleDetailBuilder scheduleDetailBuilder = ScheduleDetail.builder(); + ScheduleDetail.ScheduleDetailBuilder scheduleDetailBuilder = ScheduleDetail + .builder() + .legId(leg.getLegId()); if (!leg.getLegType().equals(LegConstant.LEG_TYPE_OTHER)) { if (leg.getOriginLocation() != null) { @@ -256,6 +266,12 @@ public class OrderQuery { } } + if (leg.getLegType().equals(LEG_TYPE_HOTEL)) { + scheduleDetailBuilder + .roomCount("1") + .nightCount(leg.nightCount().toString()); + } + if (leg.getCurrencyType() != null) { scheduleDetailBuilder .currencyName(leg.getCurrencyType().getDescription()) @@ -301,7 +317,7 @@ public class OrderQuery { return switch (legType) { case LegConstant.LEG_TYPE_TRAIN -> FSSCConstant.TRIP_CALLBACK_TRAIN_TYPE; case LegConstant.LEG_TYPE_AIRPLANE -> FSSCConstant.TRIP_CALLBACK_FLIGHT_TYPE; - case LegConstant.LEG_TYPE_HOTEL -> FSSCConstant.TRIP_CALLBACK_HOTEL_TYPE; + case LEG_TYPE_HOTEL -> FSSCConstant.TRIP_CALLBACK_HOTEL_TYPE; case LegConstant.LEG_TYPE_TAXI -> FSSCConstant.TRIP_CALLBACK_OTHER_TYPE; case LegConstant.LEG_TYPE_OTHER -> FSSCConstant.TRIP_CALLBACK_OTHER_TYPE; default -> FSSCConstant.TRIP_CALLBACK_OTHER_TYPE; diff --git a/src/main/java/com/chint/domain/aggregates/order/Leg.java b/src/main/java/com/chint/domain/aggregates/order/Leg.java index b5e6a432..84878f25 100644 --- a/src/main/java/com/chint/domain/aggregates/order/Leg.java +++ b/src/main/java/com/chint/domain/aggregates/order/Leg.java @@ -16,8 +16,10 @@ import org.springframework.data.relational.core.mapping.Column; import org.springframework.data.relational.core.mapping.MappedCollection; import org.springframework.data.relational.core.mapping.Table; +import java.time.LocalDate; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; +import java.time.temporal.ChronoUnit; import java.util.*; import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_OTHER; @@ -212,6 +214,17 @@ public class Leg { .max(Integer::compareTo); } + public Integer nightCount() { + return calculateNightsBetweenDates(LocalDate.from(this.startTime), + LocalDate.from(this.endTime)); + } + + public static int calculateNightsBetweenDates(LocalDate start, LocalDate end) { + // 计算两个日期之间的天数差异,不包括结束日期 + long daysBetween = ChronoUnit.DAYS.between(start, end); + // 将天数差异转换为晚上数量 + return (int) daysBetween; + } // private Leg timeFormatter() { // DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); // String string = this.startTime.toString(); diff --git a/src/main/java/com/chint/domain/aggregates/user/User.java b/src/main/java/com/chint/domain/aggregates/user/User.java index b03120eb..4e2b6112 100644 --- a/src/main/java/com/chint/domain/aggregates/user/User.java +++ b/src/main/java/com/chint/domain/aggregates/user/User.java @@ -11,6 +11,7 @@ import org.springframework.data.annotation.Id; import org.springframework.data.annotation.Transient; import org.springframework.data.relational.core.mapping.Table; +import java.time.LocalDateTime; import java.util.Map; @Data @@ -27,6 +28,7 @@ public class User { private String gender; private String phoneNumber; private String password; + private LocalDateTime syncTime; @Transient private String standardLevel; @Transient @@ -47,7 +49,7 @@ public class User { this.employeeNo = employeeNo; } - public User(Long userId, String employeeNo, Integer employeeLevel, String name, String email, String phoneNumber, UserLoginParam userLoginParam, String standardLevel,String companyCode) { + public User(Long userId, String employeeNo, Integer employeeLevel, String name, String email, String phoneNumber, UserLoginParam userLoginParam, String standardLevel, String companyCode) { this.userId = userId; this.employeeNo = employeeNo; this.employeeLevel = employeeLevel; @@ -80,7 +82,7 @@ public class User { Claim employeeNo = claims.get(AuthMessageConstant.USER_EMPLOYEE_NO); Claim name = claims.get(AuthMessageConstant.USER_NAME); Claim employeeLevel = claims.get(AuthMessageConstant.USER_EMPLOYEE_LEVEL); - // Claim rankCode = claims.get(AuthMessageConstant.USER_RANK_CODE); + // Claim rankCode = claims.get(AuthMessageConstant.USER_RANK_CODE); Claim companyCode = claims.get(AuthMessageConstant.USER_COMPANY_CODE); Claim loginParam = claims.get(AuthMessageConstant.USER_LOGIN_PARAM); Claim standardLevel = claims.get(AuthMessageConstant.USER_STANDARD_LEVEL); diff --git a/src/main/java/com/chint/interfaces/rest/ly/in/CommonController.java b/src/main/java/com/chint/interfaces/rest/ly/in/CommonController.java index 130299e5..de79904f 100644 --- a/src/main/java/com/chint/interfaces/rest/ly/in/CommonController.java +++ b/src/main/java/com/chint/interfaces/rest/ly/in/CommonController.java @@ -34,6 +34,5 @@ public class CommonController { case 6-> carBackController.carBack(notification); default -> new LYNoteResponse("200", "失败"); }; - } } From 12f272a395ae75c89ab055a3f5327d330e0b0087 Mon Sep 17 00:00:00 2001 From: lulz1 Date: Fri, 1 Mar 2024 14:30:36 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chint/application/commands/BPMAuditCommand.java | 5 +++-- .../com/chint/domain/aggregates/system/SystemCode.java | 1 + .../chint/domain/service/LocationDomainService.java | 1 + .../com/chint/domain/service/OrderDomainService.java | 10 ++++++---- .../java/com/chint/interfaces/rest/bpm/BPMRequest.java | 2 +- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/chint/application/commands/BPMAuditCommand.java b/src/main/java/com/chint/application/commands/BPMAuditCommand.java index c2e78137..4182f04f 100644 --- a/src/main/java/com/chint/application/commands/BPMAuditCommand.java +++ b/src/main/java/com/chint/application/commands/BPMAuditCommand.java @@ -1,5 +1,6 @@ package com.chint.application.commands; +import com.chint.domain.aggregates.order.OrderDetail; import com.chint.infrastructure.echo_framework.command.Command; import lombok.Data; @@ -7,7 +8,7 @@ import lombok.Data; public class BPMAuditCommand extends Command { private String orderNo; private Integer productType; - private Object extensionData; + private OrderDetail extensionData; public BPMAuditCommand orderNo(String orderNo) { this.orderNo = orderNo; @@ -19,7 +20,7 @@ public class BPMAuditCommand extends Command { return this; } - public BPMAuditCommand extensionData(Object extensionData) { + public BPMAuditCommand extensionData(OrderDetail extensionData) { this.extensionData = extensionData; return this; } diff --git a/src/main/java/com/chint/domain/aggregates/system/SystemCode.java b/src/main/java/com/chint/domain/aggregates/system/SystemCode.java index 6096622b..f38b2330 100644 --- a/src/main/java/com/chint/domain/aggregates/system/SystemCode.java +++ b/src/main/java/com/chint/domain/aggregates/system/SystemCode.java @@ -9,4 +9,5 @@ public class SystemCode { private Long id; private String systemName; private String systemCode; + private String bpmCode; } diff --git a/src/main/java/com/chint/domain/service/LocationDomainService.java b/src/main/java/com/chint/domain/service/LocationDomainService.java index 738c11d5..b7576d72 100644 --- a/src/main/java/com/chint/domain/service/LocationDomainService.java +++ b/src/main/java/com/chint/domain/service/LocationDomainService.java @@ -32,6 +32,7 @@ public class LocationDomainService { } private List getLocationsByType(LocationParam locationParam, List queryByCityName) { + System.out.println(queryByCityName); Integer cityType = locationParam.getCityType(); return switch (cityType) { case LocationConstant.CITY_TYPE_DOMESTIC -> queryByCityName diff --git a/src/main/java/com/chint/domain/service/OrderDomainService.java b/src/main/java/com/chint/domain/service/OrderDomainService.java index 1d2ef3c3..8793ff43 100644 --- a/src/main/java/com/chint/domain/service/OrderDomainService.java +++ b/src/main/java/com/chint/domain/service/OrderDomainService.java @@ -126,15 +126,17 @@ public class OrderDomainService { Command.of(BPMAuditCommand.class) .orderNo(orderDetail.getOrderNo()) .productType(orderDetail.getProductType()) - .extensionData(orderDetail.getExtensionDataByProductType()) + .extensionData(orderDetail) .sendToQueue(); } - ; } @ListenTo(command = "BPMAuditCommand", order = 0) public void toBpmAudit(BPMAuditCommand command) { - Object data = command.getExtensionData(); + OrderDetail orderDetail = command.getExtensionData(); + Object data = orderDetail.getExtensionDataByProductType(); + RouteOrder routeOrder = routeRepository.queryById(orderDetail.getRouteId()); + String sysCode = routeOrder.getApproveOrderNo().getSysCode(); ExceedStandardDto exceedStandardDto = switch (command.getProductType()) { case LegConstant.LEG_TYPE_TRAIN -> bpmParamFactory.creatAuditParamByTrain((TrainOrderDetail) data); case LegConstant.LEG_TYPE_AIRPLANE -> bpmParamFactory.creatAuditParamByFlight((FlightOrderDetail) data); @@ -143,7 +145,7 @@ public class OrderDomainService { case LegConstant.LEG_TYPE_OTHER -> bpmParamFactory.creatAuditParamByOther((OtherOrderDetail) data); default -> throw new NotFoundException(CommonMessageConstant.NOT_FOUND); }; - DelayDispatch.attemptToSend(() -> bpmRequest.exceedStandard(exceedStandardDto).getSuccess(), + DelayDispatch.attemptToSend(() -> bpmRequest.exceedStandard(exceedStandardDto, sysCode).getSuccess(), 0); } } diff --git a/src/main/java/com/chint/interfaces/rest/bpm/BPMRequest.java b/src/main/java/com/chint/interfaces/rest/bpm/BPMRequest.java index 20971861..53077865 100644 --- a/src/main/java/com/chint/interfaces/rest/bpm/BPMRequest.java +++ b/src/main/java/com/chint/interfaces/rest/bpm/BPMRequest.java @@ -41,7 +41,7 @@ public class BPMRequest { private String XNBPMUrl; //超标申请 - public BPMResponse exceedStandard(ExceedStandardDto exceedStandardDto) { + public BPMResponse exceedStandard(ExceedStandardDto exceedStandardDto , String sysCode ) { if ("H3BPM".equals("XNBPM")) { return XNBPMSubmitWorkflow("JG_AS_CLCESQ", exceedStandardDto); } else { From 786abad90595d13e3d68706702ff929e90028fca Mon Sep 17 00:00:00 2001 From: lulz1 Date: Fri, 1 Mar 2024 14:48:19 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/chint/interfaces/rest/ly/in/HotelBackController.java | 1 + src/test/java/com/chint/RouteApplicationTests.java | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/chint/interfaces/rest/ly/in/HotelBackController.java b/src/main/java/com/chint/interfaces/rest/ly/in/HotelBackController.java index d73c83bf..69b8c7c4 100644 --- a/src/main/java/com/chint/interfaces/rest/ly/in/HotelBackController.java +++ b/src/main/java/com/chint/interfaces/rest/ly/in/HotelBackController.java @@ -61,6 +61,7 @@ public class HotelBackController { //状态映射 command.eventType(mapHotelState(notification.getSubNotifyType())); command.sendToQueue(); + return new LYNoteResponse("100", "成功收到消息"); } return new LYNoteResponse("200", "未收到消息"); diff --git a/src/test/java/com/chint/RouteApplicationTests.java b/src/test/java/com/chint/RouteApplicationTests.java index 5248a35b..799b92db 100644 --- a/src/test/java/com/chint/RouteApplicationTests.java +++ b/src/test/java/com/chint/RouteApplicationTests.java @@ -139,9 +139,9 @@ class RouteApplicationTests { } @Test void loginSign() { - String sfno = "230615020"; + String sfno = "090223001"; String syscode = "FSSC"; - String billcode = "CLSQ20240228"; + String billcode = "CLSQ240226000004"; String companycode = "正泰集团股份有限公司"; String sec = "Superdandan"; String timespan = "1708908662738"; From b7425c7b80e222a05a19356fb58a5c62a8becc6e Mon Sep 17 00:00:00 2001 From: lulz1 Date: Fri, 1 Mar 2024 15:11:43 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../commands/LegApprovalCommand.java | 11 ++------- .../commands/RouteApprovalCommand.java | 24 +++++++++++++++++++ .../services/OrderApplicationService.java | 14 +++++++---- .../service/leg_event/LegEventHandler.java | 9 ++++++- .../service/leg_event/LegEventService.java | 4 +++- .../leg_event/LegEventServiceImpl.java | 13 +++++++--- 6 files changed, 57 insertions(+), 18 deletions(-) create mode 100644 src/main/java/com/chint/application/commands/RouteApprovalCommand.java diff --git a/src/main/java/com/chint/application/commands/LegApprovalCommand.java b/src/main/java/com/chint/application/commands/LegApprovalCommand.java index 552beef4..56e6a1a3 100644 --- a/src/main/java/com/chint/application/commands/LegApprovalCommand.java +++ b/src/main/java/com/chint/application/commands/LegApprovalCommand.java @@ -1,6 +1,5 @@ package com.chint.application.commands; -import com.chint.domain.value_object.ApproveLegData; import com.chint.infrastructure.echo_framework.command.Command; import lombok.Data; @@ -8,17 +7,11 @@ import static com.chint.infrastructure.constant.LegConstant.LEG_EVENT_APPROVAL; @Data public class LegApprovalCommand extends Command { - private Integer LegEventType = LEG_EVENT_APPROVAL; - private Long LegId; - private ApproveLegData data; + private Integer legEventType = LEG_EVENT_APPROVAL; + private Long legId; public LegApprovalCommand legId(Long LegId) { this.setLegId(LegId); return this; } - - public LegApprovalCommand data(ApproveLegData data) { - this.data = data; - return this; - } } diff --git a/src/main/java/com/chint/application/commands/RouteApprovalCommand.java b/src/main/java/com/chint/application/commands/RouteApprovalCommand.java new file mode 100644 index 00000000..2c1c7063 --- /dev/null +++ b/src/main/java/com/chint/application/commands/RouteApprovalCommand.java @@ -0,0 +1,24 @@ +package com.chint.application.commands; + +import com.chint.domain.value_object.ApproveLegData; +import com.chint.infrastructure.echo_framework.command.Command; +import lombok.Data; + +import static com.chint.infrastructure.constant.LegConstant.LEG_EVENT_APPROVAL; + +@Data +public class RouteApprovalCommand extends Command { + private Integer LegEventType = LEG_EVENT_APPROVAL; + private Long LegId; + private ApproveLegData data; + + public RouteApprovalCommand legId(Long LegId) { + this.setLegId(LegId); + return this; + } + + public RouteApprovalCommand data(ApproveLegData data) { + this.data = data; + return this; + } +} diff --git a/src/main/java/com/chint/application/services/OrderApplicationService.java b/src/main/java/com/chint/application/services/OrderApplicationService.java index e7fdef23..080ee19f 100644 --- a/src/main/java/com/chint/application/services/OrderApplicationService.java +++ b/src/main/java/com/chint/application/services/OrderApplicationService.java @@ -28,8 +28,7 @@ import java.util.List; import java.util.Optional; import java.util.concurrent.CompletableFuture; -import static com.chint.infrastructure.constant.RouteConstant.ORDER_STATUS_NOT_ORDERED; -import static com.chint.infrastructure.constant.RouteConstant.ORDER_STATUS_PREPARE; +import static com.chint.infrastructure.constant.RouteConstant.*; @Service public class OrderApplicationService { @@ -77,7 +76,14 @@ public class OrderApplicationService { List legs = processLegData(addLegData.getLegData(), order); RouteOrder routeOrder = orderDomainService.saveOrder(order); - legs.forEach(leg -> Command.of(LegPrepareCommand.class).legId(leg.getLegId()).sendToQueue()); + legs.forEach(leg -> { + Command.of(LegPrepareCommand.class).legId(leg.getLegId()).sendToQueue(); + //如果订单状态已经处于审批中, 那么为这个新增的leg也提交审批状态 + if (order.getOrderStatus() >= ORDER_STATUS_APPROVAL) { + Command.of(LegApprovalCommand.class).legId(leg.getLegId()).sendToQueue(); + } + }); + //异步操作-如果是当前的状态已经进行过匹配,那么就要订单同步到供应商一次 if (order.getOrderStatus() >= ORDER_STATUS_NOT_ORDERED) { @@ -142,7 +148,7 @@ public class OrderApplicationService { @Transactional public void approve(ApproveLegData approveLegData) { - Command.of(LegApprovalCommand.class).data(approveLegData).sendToQueue(); + Command.of(RouteApprovalCommand.class).data(approveLegData).sendToQueue(); } @Transactional diff --git a/src/main/java/com/chint/domain/service/leg_event/LegEventHandler.java b/src/main/java/com/chint/domain/service/leg_event/LegEventHandler.java index a71db450..25c9818d 100644 --- a/src/main/java/com/chint/domain/service/leg_event/LegEventHandler.java +++ b/src/main/java/com/chint/domain/service/leg_event/LegEventHandler.java @@ -72,7 +72,7 @@ public class LegEventHandler implements LegEventService { @Transactional @Override - public void approveLeg(LegApprovalCommand command) { + public void approveRoute(RouteApprovalCommand command) { ApproveLegData data = command.getData(); RouteOrder routeOrder = routeRepository.findByFakeOrderNoAndSysCode(data.getFakeOrderNo(), data.getSysCode()).reloadStatus(); if (routeOrder.getLegItems().isEmpty()) { @@ -135,6 +135,13 @@ public class LegEventHandler implements LegEventService { } } + @Override + public void approveLeg(LegApprovalCommand command) { + Leg leg = legRepository.findByLegId(command.getLegId()); + leg.addEvent(legEventFactory.creatLegEvent(command.getLegEventType())); + legRepository.save(leg); + } + @Transactional @Override public ResultContainer routeUpdateOrder(RouteUpdateOrderCommand command) { diff --git a/src/main/java/com/chint/domain/service/leg_event/LegEventService.java b/src/main/java/com/chint/domain/service/leg_event/LegEventService.java index fd11e376..c774ed8d 100644 --- a/src/main/java/com/chint/domain/service/leg_event/LegEventService.java +++ b/src/main/java/com/chint/domain/service/leg_event/LegEventService.java @@ -8,10 +8,12 @@ public interface LegEventService { void prepareLeg(LegPrepareCommand command); //审批事件要从bpm或其他平台接收到一个真实订单 - void approveLeg(LegApprovalCommand command); + void approveRoute(RouteApprovalCommand command); void syncLeg(LegSyncCommand command); + void approveLeg(LegApprovalCommand command); + //下单事件 ResultContainer orderLeg(LegOrderedCommand command); diff --git a/src/main/java/com/chint/domain/service/leg_event/LegEventServiceImpl.java b/src/main/java/com/chint/domain/service/leg_event/LegEventServiceImpl.java index 2bf4328f..7fe9dea3 100644 --- a/src/main/java/com/chint/domain/service/leg_event/LegEventServiceImpl.java +++ b/src/main/java/com/chint/domain/service/leg_event/LegEventServiceImpl.java @@ -23,10 +23,10 @@ public class LegEventServiceImpl implements LegEventService { //因为审批是针对整个订单的,因此所有订单下属的行程节点触发审批事件 //出发审批提交事件 , 需要生成 差旅单 , 将差旅但提交到供应商 , //根据command里面选择的数据来讲差旅但提交到不同的实现类当中 - @ListenTo(command = "LegApprovalCommand", order = 0) + @ListenTo(command = "RouteApprovalCommand", order = 0) @Override - public void approveLeg(LegApprovalCommand command) { - legEventHandler.approveLeg(command); + public void approveRoute(RouteApprovalCommand command) { + legEventHandler.approveRoute(command); } //这里需要获取同步类,价格routeOrder同步到供应商 @@ -36,6 +36,13 @@ public class LegEventServiceImpl implements LegEventService { legEventHandler.syncLeg(command); } + + @ListenTo(command = "LegApprovalCommand", order = 0) + @Override + public void approveLeg(LegApprovalCommand command) { + legEventHandler.approveLeg(command); + } + //下单时间要求回传,需要付款的金额,以及生成对于的行程订单号,如果没有行程订单号根据地点和时间进行匹配 @ListenTo(command = "LegOrderedCommand", order = 0) @Override From e35d335719c42278da7e758be01b0c2ce5f2d245 Mon Sep 17 00:00:00 2001 From: wanglf3 Date: Fri, 1 Mar 2024 15:47:16 +0800 Subject: [PATCH 5/5] =?UTF-8?q?1.=E5=9B=BD=E9=99=85=E7=83=AD=E9=97=A8?= =?UTF-8?q?=E5=9F=8E=E5=B8=82=E6=B7=BB=E5=8A=A0=20=E5=8F=B0=E5=8C=97=20?= =?UTF-8?q?=E9=A6=99=E6=B8=AF=20=E6=BE=B3=E9=97=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/chint/domain/aggregates/standards/HotCityTag.java | 4 ++++ .../infrastructure/repository/LocationRepositoryImpl.java | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/main/java/com/chint/domain/aggregates/standards/HotCityTag.java b/src/main/java/com/chint/domain/aggregates/standards/HotCityTag.java index c3a297ca..dcecf717 100644 --- a/src/main/java/com/chint/domain/aggregates/standards/HotCityTag.java +++ b/src/main/java/com/chint/domain/aggregates/standards/HotCityTag.java @@ -43,6 +43,10 @@ public class HotCityTag { internationalCitys.add("欧洲_挪威_奥斯陆市_奥斯陆_"); internationalCitys.add("北美洲_美国_加利福尼亚州_旧金山_"); internationalCitys.add("亚洲_新加坡_新加坡_新加坡_"); + internationalCitys.add("亚洲_中国_香港_香港_"); + internationalCitys.add("亚洲_中国_澳门_澳门_"); + internationalCitys.add("亚洲_中国_台湾_台北_"); + } diff --git a/src/main/java/com/chint/infrastructure/repository/LocationRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/LocationRepositoryImpl.java index b468c7b0..8f4db9aa 100644 --- a/src/main/java/com/chint/infrastructure/repository/LocationRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/LocationRepositoryImpl.java @@ -94,6 +94,8 @@ public class LocationRepositoryImpl implements LocationRepository { List hotCities = jdbcLocationRepository.findByLocationPathNameInAndLevel(locationNames,3); return hotCities; + + }