供应商信息回推出现报错日志保存功能
This commit is contained in:
parent
b38b8ba3a3
commit
7a81b68b9b
|
@ -0,0 +1,18 @@
|
|||
package com.chint.application.commands;
|
||||
|
||||
import com.chint.infrastructure.echo_framework.command.Command;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SupplierCallBackErrorCommand extends Command {
|
||||
private Exception e;
|
||||
private String supplierName;
|
||||
private String requestBody;
|
||||
|
||||
public SupplierCallBackErrorCommand info(String supplierName, String requestBody, Exception e) {
|
||||
this.setSupplierName(supplierName);
|
||||
this.setRequestBody(requestBody);
|
||||
this.setE(e);
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -10,11 +10,9 @@ import com.chint.domain.repository.ClientRepository;
|
|||
import com.chint.domain.repository.OrderDetailRepository;
|
||||
import com.chint.domain.repository.RouteRepository;
|
||||
import com.chint.domain.service.auth.AuthenticateService;
|
||||
import com.chint.domain.value_object.OrderQueryData;
|
||||
import com.chint.domain.value_object.RouteOrderDetail;
|
||||
import com.chint.infrastructure.echo_framework.annotation.TransitionTo;
|
||||
import com.chint.infrastructure.export.OrderDetailExportFactory;
|
||||
import com.chint.infrastructure.export.OrderDetailWriter;
|
||||
import com.chint.infrastructure.util.Digest;
|
||||
import com.chint.infrastructure.util.PageResult;
|
||||
import com.chint.infrastructure.util.Result;
|
||||
|
@ -81,7 +79,6 @@ public class OrderDetailController {
|
|||
private OrderDetailExportFactory orderDetailExportFactory;
|
||||
|
||||
|
||||
|
||||
@ApiOperation("订单明细认证接口")
|
||||
@PostMapping("/public/authentication")
|
||||
public Result<Token> queryAuthentication(@RequestBody AuthenticationDto authenticationDto) {
|
||||
|
@ -232,6 +229,7 @@ public class OrderDetailController {
|
|||
|
||||
addOrderEvent(orderDetail, command.getType(), LocalDateTime.now());
|
||||
orderDetail.setPrice(command.getAmount());
|
||||
orderDetail.setCreateTime(LocalDateTime.now());
|
||||
|
||||
processProductSpecificDetails(orderDetail, command, newOrderNo);
|
||||
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
package com.chint.domain.aggregates.supplier;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.relational.core.mapping.Column;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@Table("supplier_call_back_log")
|
||||
public class SupplierCallBackLog {
|
||||
@Id
|
||||
private Long id;
|
||||
private String supplierName;
|
||||
private LocalDateTime happenTime;
|
||||
private String callBackJson;
|
||||
|
||||
public static SupplierCallBackLog start() {
|
||||
SupplierCallBackLog supplierCallBackLog = new SupplierCallBackLog();
|
||||
supplierCallBackLog.setHappenTime(LocalDateTime.now());
|
||||
return supplierCallBackLog;
|
||||
}
|
||||
|
||||
public SupplierCallBackLog supplier(String supplierName) {
|
||||
this.supplierName = supplierName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SupplierCallBackLog callBackJson(String callBackJson) {
|
||||
this.callBackJson = callBackJson;
|
||||
return this;
|
||||
}
|
||||
|
||||
public static SupplierCallBackLog fromException(String supplierName, String requestBody, Exception e) {
|
||||
SupplierCallBackLog log = SupplierCallBackLog.start();
|
||||
log.setSupplierName(supplierName);
|
||||
|
||||
StringWriter sw = new StringWriter();
|
||||
e.printStackTrace(new PrintWriter(sw));
|
||||
String exceptionDetails = sw.toString();
|
||||
|
||||
log.setCallBackJson("Exception: " + e.getMessage() + "\nRequestBody:\n" + requestBody + "\nStack Trace:\n" + exceptionDetails);
|
||||
return log;
|
||||
}
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
package com.chint.domain.aggregates.system;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@Table("supplier_call_back_log")
|
||||
public class SupplierCallBackLog {
|
||||
@Id
|
||||
private Long id;
|
||||
private String supplierName;
|
||||
private LocalDateTime happenTime;
|
||||
private String callBackJson;
|
||||
|
||||
public static SupplierCallBackLog start(){
|
||||
SupplierCallBackLog supplierCallBackLog = new SupplierCallBackLog();
|
||||
supplierCallBackLog.setHappenTime(LocalDateTime.now());
|
||||
return supplierCallBackLog;
|
||||
}
|
||||
|
||||
public SupplierCallBackLog supplier(String supplierName){
|
||||
this.supplierName = supplierName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SupplierCallBackLog callBackJson(String callBackJson){
|
||||
this.callBackJson = callBackJson;
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -1,10 +1,9 @@
|
|||
package com.chint.domain.repository;
|
||||
|
||||
import com.chint.domain.aggregates.system.SupplierCallBackLog;
|
||||
import com.chint.domain.aggregates.supplier.SupplierCallBackLog;
|
||||
|
||||
public interface SupplierCallBackLogRepository {
|
||||
|
||||
SupplierCallBackLog save(SupplierCallBackLog supplierCallBackLog);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
package com.chint.domain.service;
|
||||
|
||||
import com.chint.application.commands.SupplierCallBackErrorCommand;
|
||||
import com.chint.domain.aggregates.order.Leg;
|
||||
import com.chint.domain.aggregates.supplier.Supplier;
|
||||
import com.chint.domain.aggregates.supplier.SupplierCallBackLog;
|
||||
import com.chint.domain.aggregates.supplier.SupplierProduct;
|
||||
import com.chint.domain.repository.SupplierCallBackLogRepository;
|
||||
import com.chint.domain.repository.SupplierRepository;
|
||||
import com.chint.infrastructure.echo_framework.annotation.ListenTo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
@ -16,6 +20,9 @@ public class SupplierDomainService {
|
|||
@Autowired
|
||||
private SupplierRepository supplierRepository;
|
||||
|
||||
@Autowired
|
||||
private SupplierCallBackLogRepository supplierCallBackLogRepository;
|
||||
|
||||
public boolean ifCanCancel(Leg leg, String supplierName) {
|
||||
Optional<Supplier> supplierOptional = supplierRepository.findBySupplierName(supplierName);
|
||||
if (supplierOptional.isPresent()) {
|
||||
|
@ -43,7 +50,7 @@ public class SupplierDomainService {
|
|||
List<Integer> productTypes = supplier
|
||||
.getSupplierProductList()
|
||||
.stream()
|
||||
.filter(it->it.getIfCanOrder().equals(1))
|
||||
.filter(it -> it.getIfCanOrder().equals(1))
|
||||
.map(SupplierProduct::getProductType)
|
||||
.toList();
|
||||
return legs.stream().filter(it -> productTypes.contains(it.getLegType())).toList();
|
||||
|
@ -51,4 +58,11 @@ public class SupplierDomainService {
|
|||
return legs;
|
||||
}
|
||||
}
|
||||
|
||||
@ListenTo(command = "SupplierCallBackErrorCommand", order = 0)
|
||||
public void supplierCallBackError(SupplierCallBackErrorCommand command) {
|
||||
SupplierCallBackLog supplierCallBackLog = SupplierCallBackLog
|
||||
.fromException(command.getSupplierName(), command.getRequestBody(), command.getE());
|
||||
supplierCallBackLogRepository.save(supplierCallBackLog);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
package com.chint.infrastructure.repository;
|
||||
|
||||
import com.chint.domain.aggregates.system.SupplierCallBackLog;
|
||||
import com.chint.domain.aggregates.supplier.SupplierCallBackLog;
|
||||
import com.chint.domain.repository.SupplierCallBackLogRepository;
|
||||
import com.chint.infrastructure.repository.jdbc.JdbcSupplierCallBackLogRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.chint.infrastructure.repository.jdbc;
|
||||
|
||||
import com.chint.domain.aggregates.system.SupplierCallBackLog;
|
||||
import com.chint.domain.aggregates.supplier.SupplierCallBackLog;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.chint.infrastructure.repository.jdbc;
|
||||
|
||||
import com.chint.domain.aggregates.supplier.Supplier;
|
||||
import com.chint.domain.aggregates.system.SupplierCallBackLog;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.chint.interfaces.rest.amap.in;
|
||||
|
||||
import com.chint.application.commands.OrderStatusChangeCommand;
|
||||
import com.chint.application.commands.SupplierCallBackErrorCommand;
|
||||
import com.chint.domain.aggregates.order.OrderDetail;
|
||||
import com.chint.domain.service.supplier.SupplierService;
|
||||
import com.chint.domain.value_object.SupplierCallbackData;
|
||||
|
@ -21,6 +22,7 @@ import org.springframework.web.util.UriUtils;
|
|||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_TAXI;
|
||||
import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_AMAP;
|
||||
|
@ -42,6 +44,7 @@ public class AmapNoteController {
|
|||
|
||||
@PostMapping("/status")
|
||||
public AmapNoteResponse statusEvent(@RequestBody String in) {
|
||||
String requestBody = in;
|
||||
String[] split = in.split("=");
|
||||
in = UriUtils.decode(split[1], StandardCharsets.UTF_8);
|
||||
// 拆分成键值对
|
||||
|
@ -69,21 +72,28 @@ public class AmapNoteController {
|
|||
|
||||
if (checkCarStatus(data.getShowStatus())) {
|
||||
|
||||
Integer eventType = mapCarStatus(data.getShowStatus());
|
||||
try {
|
||||
Integer eventType = mapCarStatus(data.getShowStatus());
|
||||
|
||||
SupplierCallbackData supplierCallbackData = SupplierCallbackData.of(SUPPLIER_AMAP)
|
||||
.data(response)
|
||||
.productType(LEG_TYPE_TAXI)
|
||||
.outOrderStatus(String.valueOf(data.getShowStatus()))
|
||||
.selfOrderStatus(eventType);
|
||||
OrderDetail orderDetail = supplierService.handleSupplierCallback(supplierCallbackData);
|
||||
SupplierCallbackData supplierCallbackData = SupplierCallbackData.of(SUPPLIER_AMAP)
|
||||
.data(response)
|
||||
.productType(LEG_TYPE_TAXI)
|
||||
.outOrderStatus(String.valueOf(data.getShowStatus()))
|
||||
.selfOrderStatus(eventType);
|
||||
OrderDetail orderDetail = supplierService.handleSupplierCallback(supplierCallbackData);
|
||||
|
||||
Command.of(OrderStatusChangeCommand.class)
|
||||
.orderDetail(orderDetail)
|
||||
.orderNo(data.getAmapOrderId())
|
||||
.outStatus(String.valueOf(data.getShowStatus()))
|
||||
.eventType(eventType)
|
||||
.sendToQueue();
|
||||
Command.of(OrderStatusChangeCommand.class)
|
||||
.orderDetail(orderDetail)
|
||||
.orderNo(data.getAmapOrderId())
|
||||
.outStatus(String.valueOf(data.getShowStatus()))
|
||||
.eventType(eventType)
|
||||
.sendToQueue();
|
||||
} catch (Exception e) {
|
||||
//如果推送异常,将异常信息保存到数据库
|
||||
CompletableFuture.runAsync(() -> Command.of(SupplierCallBackErrorCommand.class)
|
||||
.info(SUPPLIER_AMAP, requestBody, e).sendToQueue());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return AmapNoteResponse.success("接收成功");
|
||||
} else {
|
||||
|
|
|
@ -2,16 +2,15 @@ package com.chint.interfaces.rest.ctrip.in;
|
|||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.chint.application.commands.OrderStatusChangeCommand;
|
||||
import com.chint.application.commands.SupplierCallBackErrorCommand;
|
||||
import com.chint.domain.aggregates.order.OrderDetail;
|
||||
import com.chint.domain.repository.SupplierCallBackLogRepository;
|
||||
import com.chint.domain.service.supplier.SupplierService;
|
||||
import com.chint.domain.value_object.SupplierCallbackData;
|
||||
import com.chint.infrastructure.constant.CTripConstant;
|
||||
import com.chint.infrastructure.echo_framework.command.Command;
|
||||
import com.chint.infrastructure.util.Digest;
|
||||
import com.chint.infrastructure.util.Result;
|
||||
import com.chint.interfaces.rest.ctrip.CTripOrderSearchRequest;
|
||||
import com.chint.interfaces.rest.ctrip.dto.ctrip.CtripBack;
|
||||
import com.chint.interfaces.rest.ctrip.dto.put.CTripStatusNotification;
|
||||
import com.chint.interfaces.rest.ctrip.dto.search.ItineraryEntity;
|
||||
import com.chint.interfaces.rest.ctrip.dto.search.SearchOrderResponse;
|
||||
|
@ -32,8 +31,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static com.chint.infrastructure.constant.CTripConstant.C_TRIP_BACK;
|
||||
import static com.chint.infrastructure.constant.LegConstant.*;
|
||||
import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_REFUND;
|
||||
import static com.chint.infrastructure.constant.OrderConstant.ORDER_STATUS_REFUSE_MSG;
|
||||
|
@ -64,26 +65,6 @@ public class CTripNoteController {
|
|||
|
||||
private Gson gson = new Gson();
|
||||
|
||||
// @PostMapping("/event")
|
||||
// public CTripNoteResponse noteEvent(@RequestBody CTripNotification cTripNotification) {
|
||||
// String putCTripEventSign = Digest.getPutCTripEventSign(cTripNotification);
|
||||
// if (!putCTripEventSign.equals(cTripNotification.getSign())) {
|
||||
// return new CTripNoteResponse("1", "sign错误");
|
||||
// }
|
||||
//
|
||||
// if (cTripNotification.getContent() != null && cTripNotification.getPreEmployeeID() != null) {
|
||||
// //成功触发消息,需要查询对于的订单信息,調用订单查询的服务来查询该订单详情
|
||||
// SupplierCallbackData supplierCallbackData =
|
||||
// SupplierCallbackData.of(SUPPLIER_C_TRIP, cTripNotification.getPreEmployeeID());
|
||||
// SearchOrderResponse response = cTripOrderSearchRequest
|
||||
// .searchOrderResponseByOrderId(cTripNotification.getBusinessId());
|
||||
// supplierCallbackData.data(response);
|
||||
// supplierService.handleSupplierCallback(supplierCallbackData);
|
||||
// return new CTripNoteResponse("0", "成功收到消息");
|
||||
// }
|
||||
// return new CTripNoteResponse("1", "未收到消息");
|
||||
// }
|
||||
|
||||
|
||||
@PostMapping("/status")
|
||||
public Result<String> statusEvent(@RequestBody CTripStatusNotification cTripStatusNotification) {
|
||||
|
@ -111,15 +92,10 @@ public class CTripNoteController {
|
|||
return Result.error("sign错误");
|
||||
}
|
||||
if (orderStatus != null && orderId != null) {
|
||||
CtripBack notification = new CtripBack();
|
||||
notification.setOrderStatus(orderStatus);
|
||||
notification.setOrderId(orderId);
|
||||
notification.setLegType(legType);
|
||||
String ctripBack = gson.toJson(notification);
|
||||
log.info("存入Redis{}", ctripBack);
|
||||
redisTemplate.opsForList().leftPush(CTripConstant.C_TRIP_BACK, ctripBack);
|
||||
String note = gson.toJson(cTripStatusNotification);
|
||||
log.info("存入Redis{}", note);
|
||||
redisTemplate.opsForList().leftPush(C_TRIP_BACK, note);
|
||||
return Result.Success("成功收到消息");
|
||||
// return handlerData(orderId, orderStatus, legType);
|
||||
}
|
||||
return Result.error("未收到消息");
|
||||
}
|
||||
|
@ -130,22 +106,33 @@ public class CTripNoteController {
|
|||
public void scanCtripPendingMsg() {
|
||||
int i = 0;
|
||||
while (true) {
|
||||
Object object = redisTemplate.opsForList().rightPop(CTripConstant.C_TRIP_BACK, 1, TimeUnit.SECONDS);
|
||||
Object object = redisTemplate.opsForList().rightPop(C_TRIP_BACK, 1, TimeUnit.SECONDS);
|
||||
if (null == object) {
|
||||
return;
|
||||
}
|
||||
CtripBack notification = gson.fromJson(String.valueOf(object), CtripBack.class);
|
||||
handlerData(notification.getOrderId(), notification.getOrderStatus(), notification.getLegType());
|
||||
CTripStatusNotification notification = gson.fromJson(String.valueOf(object), CTripStatusNotification.class);
|
||||
try {
|
||||
handlerData(notification);
|
||||
} catch (Exception e) {
|
||||
//如果推送异常,将异常信息保存到数据库
|
||||
CompletableFuture.runAsync(() -> Command.of(SupplierCallBackErrorCommand.class)
|
||||
.info(SUPPLIER_C_TRIP, gson.toJson(notification), e).sendToQueue());
|
||||
e.printStackTrace();
|
||||
}
|
||||
i++;
|
||||
if (i > 5) {
|
||||
log.info("CtripBack处理结束");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Result<String> handlerData(String orderId, String orderStatus, Integer legType) {
|
||||
public Result<String> handlerData(CTripStatusNotification cTripStatusNotification) {
|
||||
String productType = cTripStatusNotification.getProductType();
|
||||
Integer legType = translateLegType(productType);
|
||||
String orderStatus = cTripStatusNotification.getOrderStatus();
|
||||
String orderId = cTripStatusNotification.getOrderId();
|
||||
|
||||
SupplierCallbackData supplierCallbackData =
|
||||
SupplierCallbackData.of(SUPPLIER_C_TRIP);
|
||||
SearchOrderResponse response = cTripOrderSearchRequest
|
||||
|
|
|
@ -3,9 +3,11 @@ package com.chint.interfaces.rest.ly.in;
|
|||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.chint.application.commands.SupplierCallBackErrorCommand;
|
||||
import com.chint.domain.aggregates.order.OrderTravel;
|
||||
import com.chint.domain.repository.SupplierCallBackLogRepository;
|
||||
import com.chint.infrastructure.constant.CommonMessageConstant;
|
||||
import com.chint.infrastructure.echo_framework.command.Command;
|
||||
import com.chint.infrastructure.repository.jdbc.JdbcOrderTravelRepository;
|
||||
import com.chint.interfaces.rest.base.PostRequest;
|
||||
import com.chint.interfaces.rest.ly.LYNoteResponse;
|
||||
|
@ -20,6 +22,7 @@ import com.chint.interfaces.rest.ly.dto.strokepush.StrokePushResult;
|
|||
import com.chint.interfaces.rest.ly.dto.strokepush.TrainChange.TrainChangeParam;
|
||||
import com.chint.interfaces.rest.ly.dto.strokepush.TrainChange.TrainChangeRequest;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
@ -37,6 +40,9 @@ import java.util.Objects;
|
|||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_C_TRIP;
|
||||
import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_L_Y;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/public/common")
|
||||
|
@ -113,17 +119,25 @@ public class CommonController {
|
|||
if (null == object) {
|
||||
return;
|
||||
}
|
||||
// String msg = JSON.toJSONString(object);
|
||||
Notification notification = gson.fromJson(String.valueOf(object), Notification.class);
|
||||
int notifyType = notification.getNotifyType();
|
||||
switch (notifyType) {
|
||||
//进行订单数据回推
|
||||
case 1 -> getOrderFlight(notification);
|
||||
case 3 -> getOrderHotel(notification);
|
||||
case 5 -> getOrderTrain(notification);
|
||||
case 6 -> getOrderCar(notification);
|
||||
default -> LYNoteResponse.success();
|
||||
};
|
||||
|
||||
try {
|
||||
Notification notification = gson.fromJson(String.valueOf(object), Notification.class);
|
||||
int notifyType = notification.getNotifyType();
|
||||
switch (notifyType) {
|
||||
//进行订单数据回推
|
||||
case 1 -> getOrderFlight(notification);
|
||||
case 3 -> getOrderHotel(notification);
|
||||
case 5 -> getOrderTrain(notification);
|
||||
case 6 -> getOrderCar(notification);
|
||||
default -> LYNoteResponse.success();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//如果推送异常,将异常信息保存到数据库
|
||||
CompletableFuture.runAsync(() -> Command.of(SupplierCallBackErrorCommand.class)
|
||||
.info(SUPPLIER_L_Y, String.valueOf(object), e).sendToQueue());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
i++;
|
||||
if (i > 5) {
|
||||
log.info("CommonBack处理结束");
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.chint.interfaces.rest.ly.in;
|
|||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.chint.application.commands.OrderStatusChangeCommand;
|
||||
import com.chint.application.commands.SupplierCallBackErrorCommand;
|
||||
import com.chint.domain.aggregates.order.OrderDetail;
|
||||
import com.chint.domain.aggregates.order.OrderTravel;
|
||||
import com.chint.domain.exceptions.NotFoundException;
|
||||
|
@ -86,34 +87,41 @@ public class LYETAController {
|
|||
}
|
||||
|
||||
|
||||
List<SupplierCallbackData> supplierCallbackDataList = handlerETACallBackData(lyETAPush);
|
||||
try {
|
||||
List<SupplierCallbackData> supplierCallbackDataList = handlerETACallBackData(lyETAPush);
|
||||
|
||||
for (SupplierCallbackData supplierCallbackData : supplierCallbackDataList) {
|
||||
OrderDetail orderDetail = supplierService.handleSupplierCallback(supplierCallbackData);
|
||||
orderTravelRepository.save(OrderTravel.of(orderDetail.getOrderNo(), approvalOrderId));
|
||||
for (SupplierCallbackData supplierCallbackData : supplierCallbackDataList) {
|
||||
OrderDetail orderDetail = supplierService.handleSupplierCallback(supplierCallbackData);
|
||||
orderTravelRepository.save(OrderTravel.of(orderDetail.getOrderNo(), approvalOrderId));
|
||||
|
||||
if (supplierCallbackData.getExtension() != null) {
|
||||
//发送超标事件
|
||||
Command.of(OrderStatusChangeCommand.class)
|
||||
.orderDetail(orderDetail)
|
||||
.outStatus("超标")
|
||||
.extension(supplierCallbackData.getExtension())
|
||||
.eventType(ORDER_EVENT_ETA)
|
||||
.orderNo(orderDetail.getOrderNo())
|
||||
.sendToQueue();
|
||||
}
|
||||
|
||||
int subNotifyType = lyETAPush.getSubNotifyType();
|
||||
if (subNotifyType == 2 || subNotifyType == 4 || subNotifyType == 6) {
|
||||
//如果推送类是2,4,6还要触发改签事件
|
||||
Command.of(OrderStatusChangeCommand.class)
|
||||
.orderDetail(orderDetail)
|
||||
.outStatus("改签")
|
||||
.extension(supplierCallbackData.getExtension())
|
||||
.eventType(ORDER_EVENT_CHANGE)
|
||||
.orderNo(orderDetail.getOrderNo())
|
||||
.sendToQueue();
|
||||
if (supplierCallbackData.getExtension() != null) {
|
||||
//发送超标事件
|
||||
Command.of(OrderStatusChangeCommand.class)
|
||||
.orderDetail(orderDetail)
|
||||
.outStatus("超标")
|
||||
.extension(supplierCallbackData.getExtension())
|
||||
.eventType(ORDER_EVENT_ETA)
|
||||
.orderNo(orderDetail.getOrderNo())
|
||||
.sendToQueue();
|
||||
}
|
||||
|
||||
int subNotifyType = lyETAPush.getSubNotifyType();
|
||||
if (subNotifyType == 2 || subNotifyType == 4 || subNotifyType == 6) {
|
||||
//如果推送类是2,4,6还要触发改签事件
|
||||
Command.of(OrderStatusChangeCommand.class)
|
||||
.orderDetail(orderDetail)
|
||||
.outStatus("改签")
|
||||
.extension(supplierCallbackData.getExtension())
|
||||
.eventType(ORDER_EVENT_CHANGE)
|
||||
.orderNo(orderDetail.getOrderNo())
|
||||
.sendToQueue();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//如果推送异常,将异常信息保存到数据库
|
||||
CompletableFuture.runAsync(() -> Command.of(SupplierCallBackErrorCommand.class)
|
||||
.info(SUPPLIER_L_Y, gson.toJson(lyETAPush), e).sendToQueue());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return LYNoteResponse.success();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue