同步退款代码

This commit is contained in:
lulz1 2024-03-14 19:39:48 +08:00
parent 22e086e0dc
commit a321c011c4
5 changed files with 29 additions and 26 deletions

View File

@ -6,15 +6,18 @@ import lombok.Data;
@Data
public class CTripOrderRefundCommand extends Command {
private String recordId;
private String orderNo;
private String amount;
private String type;
private String createTime;
public CTripOrderRefundCommand Info(String orderNo, String amount, String createTime) {
public CTripOrderRefundCommand Info(String recordId, String orderNo, String amount, String type, String createTime) {
this.recordId = recordId;
this.orderNo = orderNo;
this.amount = amount;
this.createTime = createTime;
this.type = type;
return this;
}
}

View File

@ -8,7 +8,6 @@ import com.chint.application.dtos.OrderSearchResult;
import com.chint.application.dtos.response.OrderDetailRes;
import com.chint.application.queryies.OrderDetailQuery;
import com.chint.domain.aggregates.order.*;
import com.chint.domain.exceptions.NotFoundException;
import com.chint.domain.repository.ClientRepository;
import com.chint.domain.repository.OrderDetailRepository;
import com.chint.domain.repository.RouteRepository;
@ -26,15 +25,11 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import static com.chint.infrastructure.constant.CommonMessageConstant.NOT_FOUND;
import static com.chint.infrastructure.constant.CommonMessageConstant.SUCCESS;
import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_REFUND;
import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_REFUND_NAME;
@RestController
@RequestMapping("/OrderDetail")
@ -56,7 +51,6 @@ public class OrderDetailController {
private OrderDetailQuery orderDetailPageQuery;
@ApiOperation("订单明细认证接口")
@PostMapping("/public/authentication")
public Result<OrderSearchResult> queryAuthentication(@RequestBody AuthenticationDto authenticationDto) {
@ -104,43 +98,46 @@ public class OrderDetailController {
@TransitionTo(command = "CTripOrderRefundCommand", order = 0)
public void generateCTripRefund(CTripOrderRefundCommand command) {
orderDetailRepository.findByOrderNo(command.getOrderNo()).ifPresent(orderDetail -> {
String newOrderNo = "R" + orderDetail.getOrderNo();
String newOrderNo = command.getOrderNo() + "-" + command.getRecordId();
String type = command.getType();
Optional<OrderDetail> byOrderNo = orderDetailRepository.findByOrderNo(newOrderNo);
if (byOrderNo.isPresent()) {
return;
}
RouteOrder routeOrder = routeRepository.queryById(orderDetail.getRouteId());
Integer productType = orderDetail.getProductType();
orderDetail.setOrderId(null);
orderDetail.setOrderNo(newOrderNo);
OrderEvent orderEvent = new OrderEvent();
orderEvent.setEventType(ORDER_EVENT_REFUND);
orderEvent.setEventType(Integer.valueOf(type));
orderEvent.setHappenTime(LocalDateTime.now());
orderEvent.setOutStatus(ORDER_EVENT_REFUND_NAME);
orderEvent.setOutStatus(orderEvent.translateOrderEvent(Integer.parseInt(type)));
orderDetail.setOrderEventList(List.of(orderEvent));
if (productType == 0) {
TrainOrderDetail trainOrderDetail = orderDetail.getTrainOrderDetail();
trainOrderDetail.setOrderAmount(command.getAmount());
trainOrderDetail.setOrderStatus("4");
String newDetailOrder = "R" + trainOrderDetail.getOrderNo();
trainOrderDetail.setOrderNo(newDetailOrder);
trainOrderDetail.setOrderStatus(type);
trainOrderDetail.setOrderNo(newOrderNo);
trainOrderDetail.setCreateTime(command.getCreateTime());
trainOrderDetail.setId(null);
}
if (productType == 1) {
FlightOrderDetail flightOrderDetail = orderDetail.getFlightOrderDetail();
flightOrderDetail.setOrderAmount(command.getAmount());
flightOrderDetail.setOrderStatus("4");
String newDetailOrder = "R" + flightOrderDetail.getOrderNo();
flightOrderDetail.setOrderNo(newDetailOrder);
flightOrderDetail.setOrderStatus(type);
// String newDetailOrder = "R" + flightOrderDetail.getOrderNo();
flightOrderDetail.setOrderNo(newOrderNo);
flightOrderDetail.setCreateTime(command.getCreateTime());
flightOrderDetail.setId(null);
}
if (productType == 2) {
HotelOrderDetail hotelOrderDetail = orderDetail.getHotelOrderDetail();
hotelOrderDetail.setOrderAmount(command.getAmount());
hotelOrderDetail.setOrderStatus("4");
String newDetailOrder = "R" + hotelOrderDetail.getOrderNo();
hotelOrderDetail.setOrderNo(newDetailOrder);
hotelOrderDetail.setOrderStatus(type);
// String newDetailOrder = "R" + hotelOrderDetail.getOrderNo();
hotelOrderDetail.setOrderNo(newOrderNo);
hotelOrderDetail.setCreateTime(command.getCreateTime());
hotelOrderDetail.setId(null);
List<HotelOrderDetailCustomer> customers = hotelOrderDetail.getCustomers();
@ -154,13 +151,15 @@ public class OrderDetailController {
if (productType == 3) {
CarOrderDetail carOrderDetail = orderDetail.getCarOrderDetail();
carOrderDetail.setOrderAmount(command.getAmount());
carOrderDetail.setOrderStatus("4");
String newDetailOrder = "R" + carOrderDetail.getOrderNo();
carOrderDetail.setOrderNo(newDetailOrder);
carOrderDetail.setOrderStatus(type);
// String newDetailOrder = "R" + carOrderDetail.getOrderNo();
carOrderDetail.setOrderNo(newOrderNo);
carOrderDetail.setCreateTime(command.getCreateTime());
carOrderDetail.setId(null);
}
orderDetailRepository.save(orderDetail);
routeOrder.addOrderDetail(orderDetail);
// orderDetailRepository.save(orderDetail);
routeRepository.save(routeOrder);
});
}

View File

@ -11,7 +11,6 @@ public class SequenceInfo {
private List<TicketInfo> TicketInfo;
// Getters and setters
private List<ChangeInfo> ChangeInfo;
}

View File

@ -151,6 +151,6 @@ public class CTripOrderRecordAutoSave {
public void checkIfRefund(String orderNo, String amount, String createTime) {
System.out.println("开始触发创建携程退款订单");
Command.of(CTripOrderRefundCommand.class).Info(orderNo, amount, createTime).sendToQueue();
// Command.of(CTripOrderRefundCommand.class).Info(orderNo, amount, createTime).sendToQueue();
}
}

View File

@ -109,6 +109,8 @@ public class CommonController {
Object notifyData = notification.notifyData;
int subNotifyType = notification.getSubNotifyType();
if (Objects.nonNull(notifyData)) {
JSONObject jsonObj = JSON.parseObject(notifyData.toString());
ResultBackTrain orderTrain = jsonObj.toJavaObject(ResultBackTrain.class);