From 1adf7ae2be5ddef2155eac92c01161a6663b3987 Mon Sep 17 00:00:00 2001 From: huangxh3 Date: Thu, 22 Feb 2024 13:21:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=9B=9E=E6=8E=A8=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E6=98=A0=E5=B0=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/aggregates/order/OrderEvent.java | 1 + .../infrastructure/constant/Constant.java | 3 ++- .../rest/ly/in/CarBackController.java | 12 ++++++++++-- .../rest/ly/in/FlyBackController.java | 16 ++++++++++++++-- .../rest/ly/in/HotelBackController.java | 18 +++++++----------- .../rest/ly/in/TrainBackController.java | 14 ++++++++++++-- 6 files changed, 46 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/chint/domain/aggregates/order/OrderEvent.java b/src/main/java/com/chint/domain/aggregates/order/OrderEvent.java index ba5c41c4..1b831ac2 100644 --- a/src/main/java/com/chint/domain/aggregates/order/OrderEvent.java +++ b/src/main/java/com/chint/domain/aggregates/order/OrderEvent.java @@ -35,6 +35,7 @@ public class OrderEvent { case ORDER_EVENT_ORDERED -> ORDER_EVENT_ORDERED_NAME; case ORDER_EVENT_REFUND -> ORDER_EVENT_REFUND_NAME; case ORDER_EVENT_UNKNOWN -> ORDER_EVENT_UNKNOWN_NAME; + case ORDER_EVENT_FINISH -> ORDER_EVENT_FINISH_NAME; default -> "未知事件"; }; } diff --git a/src/main/java/com/chint/infrastructure/constant/Constant.java b/src/main/java/com/chint/infrastructure/constant/Constant.java index 70f1234b..5dc2bd15 100644 --- a/src/main/java/com/chint/infrastructure/constant/Constant.java +++ b/src/main/java/com/chint/infrastructure/constant/Constant.java @@ -115,7 +115,6 @@ public class Constant { public static final int PRODUCT_TYPE_TRAIN_CAR = 2; //用车 public static final int PRODUCT_TYPE_TRAIN_HOTEL = 3; //酒店 - // 规划节点事件 public static final int LEG_EVENT_PREPARE = 0; public static final String LEG_EVENT_PREPARE_NAME = "初始事件"; @@ -142,6 +141,8 @@ public class Constant { public static final int ORDER_EVENT_CHANGE = 3; public static final String ORDER_EVENT_CHANGE_NAME = "改签"; public static final int ORDER_EVENT_REFUND = 4; + public static final int ORDER_EVENT_FINISH = 5; + public static final String ORDER_EVENT_FINISH_NAME = "已完成"; public static final String ORDER_EVENT_REFUND_NAME = "退票"; public static final int ORDER_EVENT_CANCEL = -1; public static final String ORDER_EVENT_CANCEL_NAME = "取消"; diff --git a/src/main/java/com/chint/interfaces/rest/ly/in/CarBackController.java b/src/main/java/com/chint/interfaces/rest/ly/in/CarBackController.java index 214bbdf2..5a5adbcb 100644 --- a/src/main/java/com/chint/interfaces/rest/ly/in/CarBackController.java +++ b/src/main/java/com/chint/interfaces/rest/ly/in/CarBackController.java @@ -17,8 +17,7 @@ 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.Constant.PRODUCT_TYPE_TRAIN_CAR; -import static com.chint.infrastructure.constant.Constant.SUPPLIER_L_Y; +import static com.chint.infrastructure.constant.Constant.*; /** * 用车数据回推控制层 @@ -50,10 +49,19 @@ public class CarBackController { OrderStatusChangeCommand command = Command.of(OrderStatusChangeCommand.class) .orderNo(serialNo) .outStatus(String.valueOf(notification.getSubNotifyType())); + + command.eventType(carStatus(notification.getSubNotifyType())); command.sendToQueue(); return new CTripNoteResponse("0", "成功收到消息"); } return new CTripNoteResponse("1", "未收到消息"); } + public Integer carStatus(Integer status) { + return switch (status) { + case 1 -> ORDER_EVENT_FINISH; // 用车订单完成 + default -> + -99; + }; + } } diff --git a/src/main/java/com/chint/interfaces/rest/ly/in/FlyBackController.java b/src/main/java/com/chint/interfaces/rest/ly/in/FlyBackController.java index 39f85857..621c465d 100644 --- a/src/main/java/com/chint/interfaces/rest/ly/in/FlyBackController.java +++ b/src/main/java/com/chint/interfaces/rest/ly/in/FlyBackController.java @@ -17,8 +17,7 @@ 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.Constant.PRODUCT_TYPE_FLY; -import static com.chint.infrastructure.constant.Constant.SUPPLIER_L_Y; +import static com.chint.infrastructure.constant.Constant.*; /** * 机票订单数据回推控制层 @@ -50,9 +49,22 @@ public class FlyBackController { OrderStatusChangeCommand command = Command.of(OrderStatusChangeCommand.class) .orderNo(serialNo) .outStatus(String.valueOf(notification.getSubNotifyType())); + command.eventType(mapFlightStatus(notification.getSubNotifyType())); command.sendToQueue(); return new CTripNoteResponse("0", "成功收到消息"); } return new CTripNoteResponse("1", "未收到消息"); } + + public Integer mapFlightStatus(Integer status) { + return switch (status) { + case 1,2,4,5,7,9,11,13 -> ORDER_EVENT_ORDERED; // 已下单 + case 3,12 -> ORDER_EVENT_REFUND; // 退票 + case 6,8 -> ORDER_EVENT_CANCEL; // 取消 + default -> + // 处理未知或未映射的状态 + -99; + }; + } + } 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 71a8b497..2ea537bc 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 @@ -17,8 +17,7 @@ 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.Constant.PRODUCT_TYPE_TRAIN_HOTEL; -import static com.chint.infrastructure.constant.Constant.SUPPLIER_L_Y; +import static com.chint.infrastructure.constant.Constant.*; /** * 酒店订单数据回推控制层 @@ -55,7 +54,7 @@ public class HotelBackController { .orderNo(serialNo) .outStatus(String.valueOf(notification.getSubNotifyType())); //状态映射 - command.eventType(mapState(notification.getSubNotifyType())); + command.eventType(mapHotelState(notification.getSubNotifyType())); command.sendToQueue(); return new CTripNoteResponse("0", "成功收到消息"); } @@ -63,15 +62,12 @@ public class HotelBackController { } - public Integer mapState(int subNotifyType) { + public Integer mapHotelState(Integer subNotifyType) { return switch (subNotifyType) { - case 1 -> 1;//确认中 - case 2 -> 2;//待入住 - case 3 -> 2;//已退房 - case 4 -> 2;//已取消 - case 5 -> 2;//预定失败 - case 6 -> 2;//已变更 - default -> 0; + case 1 -> ORDER_EVENT_PAYED;//确认中 + case 2,3,6 -> ORDER_EVENT_ORDERED;//待入住,已变更,已退房 + case 4,5 -> ORDER_EVENT_CANCEL;//已取消,预定失败 + default -> -99; }; } } diff --git a/src/main/java/com/chint/interfaces/rest/ly/in/TrainBackController.java b/src/main/java/com/chint/interfaces/rest/ly/in/TrainBackController.java index 0fa99cc7..d119a097 100644 --- a/src/main/java/com/chint/interfaces/rest/ly/in/TrainBackController.java +++ b/src/main/java/com/chint/interfaces/rest/ly/in/TrainBackController.java @@ -16,8 +16,7 @@ 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.Constant.PRODUCT_TYPE_TRAIN; -import static com.chint.infrastructure.constant.Constant.SUPPLIER_L_Y; +import static com.chint.infrastructure.constant.Constant.*; /** * 火车票订单数据回推控制层 @@ -47,10 +46,21 @@ public class TrainBackController { OrderStatusChangeCommand command = Command.of(OrderStatusChangeCommand.class) .orderNo(serialNo) .outStatus(String.valueOf(notification.getSubNotifyType())); + command.eventType(mapTrainState(notification.getSubNotifyType())); command.sendToQueue(); return new CTripNoteResponse("0", "成功收到消息"); } return new CTripNoteResponse("1", "未收到消息"); } + public Integer mapTrainState(Integer status) { + return switch (status) { + case 1,2,5,10,12 -> ORDER_EVENT_ORDERED; // 已下单 + case 3 -> ORDER_EVENT_REFUND; // 退票 + case 6,11,13 -> ORDER_EVENT_CANCEL; // 取消 + default -> + // 处理未知或未映射的状态 + -99; + }; + } }