供应商信息回推出现报错日志保存功能

This commit is contained in:
lulz1 2024-05-14 13:47:43 +08:00
parent b38b8ba3a3
commit 7a81b68b9b
13 changed files with 189 additions and 128 deletions

View File

@ -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;
}
}

View File

@ -10,11 +10,9 @@ import com.chint.domain.repository.ClientRepository;
import com.chint.domain.repository.OrderDetailRepository; import com.chint.domain.repository.OrderDetailRepository;
import com.chint.domain.repository.RouteRepository; import com.chint.domain.repository.RouteRepository;
import com.chint.domain.service.auth.AuthenticateService; import com.chint.domain.service.auth.AuthenticateService;
import com.chint.domain.value_object.OrderQueryData;
import com.chint.domain.value_object.RouteOrderDetail; import com.chint.domain.value_object.RouteOrderDetail;
import com.chint.infrastructure.echo_framework.annotation.TransitionTo; import com.chint.infrastructure.echo_framework.annotation.TransitionTo;
import com.chint.infrastructure.export.OrderDetailExportFactory; import com.chint.infrastructure.export.OrderDetailExportFactory;
import com.chint.infrastructure.export.OrderDetailWriter;
import com.chint.infrastructure.util.Digest; import com.chint.infrastructure.util.Digest;
import com.chint.infrastructure.util.PageResult; import com.chint.infrastructure.util.PageResult;
import com.chint.infrastructure.util.Result; import com.chint.infrastructure.util.Result;
@ -81,7 +79,6 @@ public class OrderDetailController {
private OrderDetailExportFactory orderDetailExportFactory; private OrderDetailExportFactory orderDetailExportFactory;
@ApiOperation("订单明细认证接口") @ApiOperation("订单明细认证接口")
@PostMapping("/public/authentication") @PostMapping("/public/authentication")
public Result<Token> queryAuthentication(@RequestBody AuthenticationDto authenticationDto) { public Result<Token> queryAuthentication(@RequestBody AuthenticationDto authenticationDto) {
@ -232,6 +229,7 @@ public class OrderDetailController {
addOrderEvent(orderDetail, command.getType(), LocalDateTime.now()); addOrderEvent(orderDetail, command.getType(), LocalDateTime.now());
orderDetail.setPrice(command.getAmount()); orderDetail.setPrice(command.getAmount());
orderDetail.setCreateTime(LocalDateTime.now());
processProductSpecificDetails(orderDetail, command, newOrderNo); processProductSpecificDetails(orderDetail, command, newOrderNo);

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -1,10 +1,9 @@
package com.chint.domain.repository; package com.chint.domain.repository;
import com.chint.domain.aggregates.system.SupplierCallBackLog; import com.chint.domain.aggregates.supplier.SupplierCallBackLog;
public interface SupplierCallBackLogRepository { public interface SupplierCallBackLogRepository {
SupplierCallBackLog save(SupplierCallBackLog supplierCallBackLog); SupplierCallBackLog save(SupplierCallBackLog supplierCallBackLog);
} }

View File

@ -1,9 +1,13 @@
package com.chint.domain.service; package com.chint.domain.service;
import com.chint.application.commands.SupplierCallBackErrorCommand;
import com.chint.domain.aggregates.order.Leg; import com.chint.domain.aggregates.order.Leg;
import com.chint.domain.aggregates.supplier.Supplier; 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.aggregates.supplier.SupplierProduct;
import com.chint.domain.repository.SupplierCallBackLogRepository;
import com.chint.domain.repository.SupplierRepository; import com.chint.domain.repository.SupplierRepository;
import com.chint.infrastructure.echo_framework.annotation.ListenTo;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -16,6 +20,9 @@ public class SupplierDomainService {
@Autowired @Autowired
private SupplierRepository supplierRepository; private SupplierRepository supplierRepository;
@Autowired
private SupplierCallBackLogRepository supplierCallBackLogRepository;
public boolean ifCanCancel(Leg leg, String supplierName) { public boolean ifCanCancel(Leg leg, String supplierName) {
Optional<Supplier> supplierOptional = supplierRepository.findBySupplierName(supplierName); Optional<Supplier> supplierOptional = supplierRepository.findBySupplierName(supplierName);
if (supplierOptional.isPresent()) { if (supplierOptional.isPresent()) {
@ -43,7 +50,7 @@ public class SupplierDomainService {
List<Integer> productTypes = supplier List<Integer> productTypes = supplier
.getSupplierProductList() .getSupplierProductList()
.stream() .stream()
.filter(it->it.getIfCanOrder().equals(1)) .filter(it -> it.getIfCanOrder().equals(1))
.map(SupplierProduct::getProductType) .map(SupplierProduct::getProductType)
.toList(); .toList();
return legs.stream().filter(it -> productTypes.contains(it.getLegType())).toList(); return legs.stream().filter(it -> productTypes.contains(it.getLegType())).toList();
@ -51,4 +58,11 @@ public class SupplierDomainService {
return legs; 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);
}
} }

View File

@ -1,10 +1,9 @@
package com.chint.infrastructure.repository; 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.domain.repository.SupplierCallBackLogRepository;
import com.chint.infrastructure.repository.jdbc.JdbcSupplierCallBackLogRepository; import com.chint.infrastructure.repository.jdbc.JdbcSupplierCallBackLogRepository;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.annotation.Id;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
@Repository @Repository

View File

@ -1,6 +1,6 @@
package com.chint.infrastructure.repository.jdbc; 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.data.repository.CrudRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;

View File

@ -1,7 +1,6 @@
package com.chint.infrastructure.repository.jdbc; package com.chint.infrastructure.repository.jdbc;
import com.chint.domain.aggregates.supplier.Supplier; import com.chint.domain.aggregates.supplier.Supplier;
import com.chint.domain.aggregates.system.SupplierCallBackLog;
import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;

View File

@ -1,6 +1,7 @@
package com.chint.interfaces.rest.amap.in; package com.chint.interfaces.rest.amap.in;
import com.chint.application.commands.OrderStatusChangeCommand; 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.OrderDetail;
import com.chint.domain.service.supplier.SupplierService; import com.chint.domain.service.supplier.SupplierService;
import com.chint.domain.value_object.SupplierCallbackData; import com.chint.domain.value_object.SupplierCallbackData;
@ -21,6 +22,7 @@ import org.springframework.web.util.UriUtils;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; 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.LegConstant.LEG_TYPE_TAXI;
import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_AMAP; import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_AMAP;
@ -42,6 +44,7 @@ public class AmapNoteController {
@PostMapping("/status") @PostMapping("/status")
public AmapNoteResponse statusEvent(@RequestBody String in) { public AmapNoteResponse statusEvent(@RequestBody String in) {
String requestBody = in;
String[] split = in.split("="); String[] split = in.split("=");
in = UriUtils.decode(split[1], StandardCharsets.UTF_8); in = UriUtils.decode(split[1], StandardCharsets.UTF_8);
// 拆分成键值对 // 拆分成键值对
@ -69,21 +72,28 @@ public class AmapNoteController {
if (checkCarStatus(data.getShowStatus())) { if (checkCarStatus(data.getShowStatus())) {
Integer eventType = mapCarStatus(data.getShowStatus()); try {
Integer eventType = mapCarStatus(data.getShowStatus());
SupplierCallbackData supplierCallbackData = SupplierCallbackData.of(SUPPLIER_AMAP) SupplierCallbackData supplierCallbackData = SupplierCallbackData.of(SUPPLIER_AMAP)
.data(response) .data(response)
.productType(LEG_TYPE_TAXI) .productType(LEG_TYPE_TAXI)
.outOrderStatus(String.valueOf(data.getShowStatus())) .outOrderStatus(String.valueOf(data.getShowStatus()))
.selfOrderStatus(eventType); .selfOrderStatus(eventType);
OrderDetail orderDetail = supplierService.handleSupplierCallback(supplierCallbackData); OrderDetail orderDetail = supplierService.handleSupplierCallback(supplierCallbackData);
Command.of(OrderStatusChangeCommand.class) Command.of(OrderStatusChangeCommand.class)
.orderDetail(orderDetail) .orderDetail(orderDetail)
.orderNo(data.getAmapOrderId()) .orderNo(data.getAmapOrderId())
.outStatus(String.valueOf(data.getShowStatus())) .outStatus(String.valueOf(data.getShowStatus()))
.eventType(eventType) .eventType(eventType)
.sendToQueue(); .sendToQueue();
} catch (Exception e) {
//如果推送异常将异常信息保存到数据库
CompletableFuture.runAsync(() -> Command.of(SupplierCallBackErrorCommand.class)
.info(SUPPLIER_AMAP, requestBody, e).sendToQueue());
e.printStackTrace();
}
return AmapNoteResponse.success("接收成功"); return AmapNoteResponse.success("接收成功");
} else { } else {

View File

@ -2,16 +2,15 @@ package com.chint.interfaces.rest.ctrip.in;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import com.chint.application.commands.OrderStatusChangeCommand; 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.OrderDetail;
import com.chint.domain.repository.SupplierCallBackLogRepository; import com.chint.domain.repository.SupplierCallBackLogRepository;
import com.chint.domain.service.supplier.SupplierService; import com.chint.domain.service.supplier.SupplierService;
import com.chint.domain.value_object.SupplierCallbackData; 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.echo_framework.command.Command;
import com.chint.infrastructure.util.Digest; import com.chint.infrastructure.util.Digest;
import com.chint.infrastructure.util.Result; import com.chint.infrastructure.util.Result;
import com.chint.interfaces.rest.ctrip.CTripOrderSearchRequest; 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.put.CTripStatusNotification;
import com.chint.interfaces.rest.ctrip.dto.search.ItineraryEntity; import com.chint.interfaces.rest.ctrip.dto.search.ItineraryEntity;
import com.chint.interfaces.rest.ctrip.dto.search.SearchOrderResponse; 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 org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit; 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.LegConstant.*;
import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_REFUND; import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_REFUND;
import static com.chint.infrastructure.constant.OrderConstant.ORDER_STATUS_REFUSE_MSG; import static com.chint.infrastructure.constant.OrderConstant.ORDER_STATUS_REFUSE_MSG;
@ -64,26 +65,6 @@ public class CTripNoteController {
private Gson gson = new Gson(); 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") @PostMapping("/status")
public Result<String> statusEvent(@RequestBody CTripStatusNotification cTripStatusNotification) { public Result<String> statusEvent(@RequestBody CTripStatusNotification cTripStatusNotification) {
@ -111,15 +92,10 @@ public class CTripNoteController {
return Result.error("sign错误"); return Result.error("sign错误");
} }
if (orderStatus != null && orderId != null) { if (orderStatus != null && orderId != null) {
CtripBack notification = new CtripBack(); String note = gson.toJson(cTripStatusNotification);
notification.setOrderStatus(orderStatus); log.info("存入Redis{}", note);
notification.setOrderId(orderId); redisTemplate.opsForList().leftPush(C_TRIP_BACK, note);
notification.setLegType(legType);
String ctripBack = gson.toJson(notification);
log.info("存入Redis{}", ctripBack);
redisTemplate.opsForList().leftPush(CTripConstant.C_TRIP_BACK, ctripBack);
return Result.Success("成功收到消息"); return Result.Success("成功收到消息");
// return handlerData(orderId, orderStatus, legType);
} }
return Result.error("未收到消息"); return Result.error("未收到消息");
} }
@ -130,22 +106,33 @@ public class CTripNoteController {
public void scanCtripPendingMsg() { public void scanCtripPendingMsg() {
int i = 0; int i = 0;
while (true) { 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) { if (null == object) {
return; return;
} }
CtripBack notification = gson.fromJson(String.valueOf(object), CtripBack.class); CTripStatusNotification notification = gson.fromJson(String.valueOf(object), CTripStatusNotification.class);
handlerData(notification.getOrderId(), notification.getOrderStatus(), notification.getLegType()); try {
handlerData(notification);
} catch (Exception e) {
//如果推送异常将异常信息保存到数据库
CompletableFuture.runAsync(() -> Command.of(SupplierCallBackErrorCommand.class)
.info(SUPPLIER_C_TRIP, gson.toJson(notification), e).sendToQueue());
e.printStackTrace();
}
i++; i++;
if (i > 5) { if (i > 5) {
log.info("CtripBack处理结束");
return; 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 supplierCallbackData =
SupplierCallbackData.of(SUPPLIER_C_TRIP); SupplierCallbackData.of(SUPPLIER_C_TRIP);
SearchOrderResponse response = cTripOrderSearchRequest SearchOrderResponse response = cTripOrderSearchRequest

View File

@ -3,9 +3,11 @@ package com.chint.interfaces.rest.ly.in;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.chint.application.commands.SupplierCallBackErrorCommand;
import com.chint.domain.aggregates.order.OrderTravel; import com.chint.domain.aggregates.order.OrderTravel;
import com.chint.domain.repository.SupplierCallBackLogRepository; import com.chint.domain.repository.SupplierCallBackLogRepository;
import com.chint.infrastructure.constant.CommonMessageConstant; import com.chint.infrastructure.constant.CommonMessageConstant;
import com.chint.infrastructure.echo_framework.command.Command;
import com.chint.infrastructure.repository.jdbc.JdbcOrderTravelRepository; import com.chint.infrastructure.repository.jdbc.JdbcOrderTravelRepository;
import com.chint.interfaces.rest.base.PostRequest; import com.chint.interfaces.rest.base.PostRequest;
import com.chint.interfaces.rest.ly.LYNoteResponse; 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.TrainChangeParam;
import com.chint.interfaces.rest.ly.dto.strokepush.TrainChange.TrainChangeRequest; import com.chint.interfaces.rest.ly.dto.strokepush.TrainChange.TrainChangeRequest;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
@ -37,6 +40,9 @@ import java.util.Objects;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit; 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 @Slf4j
@RestController @RestController
@RequestMapping("/public/common") @RequestMapping("/public/common")
@ -113,17 +119,25 @@ public class CommonController {
if (null == object) { if (null == object) {
return; return;
} }
// String msg = JSON.toJSONString(object);
Notification notification = gson.fromJson(String.valueOf(object), Notification.class); try {
int notifyType = notification.getNotifyType(); Notification notification = gson.fromJson(String.valueOf(object), Notification.class);
switch (notifyType) { int notifyType = notification.getNotifyType();
//进行订单数据回推 switch (notifyType) {
case 1 -> getOrderFlight(notification); //进行订单数据回推
case 3 -> getOrderHotel(notification); case 1 -> getOrderFlight(notification);
case 5 -> getOrderTrain(notification); case 3 -> getOrderHotel(notification);
case 6 -> getOrderCar(notification); case 5 -> getOrderTrain(notification);
default -> LYNoteResponse.success(); 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++; i++;
if (i > 5) { if (i > 5) {
log.info("CommonBack处理结束"); log.info("CommonBack处理结束");

View File

@ -2,6 +2,7 @@ package com.chint.interfaces.rest.ly.in;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import com.chint.application.commands.OrderStatusChangeCommand; 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.OrderDetail;
import com.chint.domain.aggregates.order.OrderTravel; import com.chint.domain.aggregates.order.OrderTravel;
import com.chint.domain.exceptions.NotFoundException; 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) { for (SupplierCallbackData supplierCallbackData : supplierCallbackDataList) {
OrderDetail orderDetail = supplierService.handleSupplierCallback(supplierCallbackData); OrderDetail orderDetail = supplierService.handleSupplierCallback(supplierCallbackData);
orderTravelRepository.save(OrderTravel.of(orderDetail.getOrderNo(), approvalOrderId)); orderTravelRepository.save(OrderTravel.of(orderDetail.getOrderNo(), approvalOrderId));
if (supplierCallbackData.getExtension() != null) { if (supplierCallbackData.getExtension() != null) {
//发送超标事件 //发送超标事件
Command.of(OrderStatusChangeCommand.class) Command.of(OrderStatusChangeCommand.class)
.orderDetail(orderDetail) .orderDetail(orderDetail)
.outStatus("超标") .outStatus("超标")
.extension(supplierCallbackData.getExtension()) .extension(supplierCallbackData.getExtension())
.eventType(ORDER_EVENT_ETA) .eventType(ORDER_EVENT_ETA)
.orderNo(orderDetail.getOrderNo()) .orderNo(orderDetail.getOrderNo())
.sendToQueue(); .sendToQueue();
} }
int subNotifyType = lyETAPush.getSubNotifyType(); int subNotifyType = lyETAPush.getSubNotifyType();
if (subNotifyType == 2 || subNotifyType == 4 || subNotifyType == 6) { if (subNotifyType == 2 || subNotifyType == 4 || subNotifyType == 6) {
//如果推送类是2,4,6还要触发改签事件 //如果推送类是2,4,6还要触发改签事件
Command.of(OrderStatusChangeCommand.class) Command.of(OrderStatusChangeCommand.class)
.orderDetail(orderDetail) .orderDetail(orderDetail)
.outStatus("改签") .outStatus("改签")
.extension(supplierCallbackData.getExtension()) .extension(supplierCallbackData.getExtension())
.eventType(ORDER_EVENT_CHANGE) .eventType(ORDER_EVENT_CHANGE)
.orderNo(orderDetail.getOrderNo()) .orderNo(orderDetail.getOrderNo())
.sendToQueue(); .sendToQueue();
}
} }
} catch (Exception e) {
//如果推送异常将异常信息保存到数据库
CompletableFuture.runAsync(() -> Command.of(SupplierCallBackErrorCommand.class)
.info(SUPPLIER_L_Y, gson.toJson(lyETAPush), e).sendToQueue());
e.printStackTrace();
} }
return LYNoteResponse.success(); return LYNoteResponse.success();
} }