添加火车退款订单生成代码
This commit is contained in:
parent
0496960b8f
commit
11d7dd053a
|
@ -5,14 +5,14 @@ import com.chint.infrastructure.echo_framework.command.Command;
|
|||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CTripOrderRefundCommand extends Command {
|
||||
public class RefundOrderGenerateCommand extends Command {
|
||||
private String recordId;
|
||||
private String orderNo;
|
||||
private String amount;
|
||||
private String type;
|
||||
private String createTime;
|
||||
|
||||
public CTripOrderRefundCommand Info(String recordId, String orderNo, String amount, String type, String createTime) {
|
||||
public RefundOrderGenerateCommand Info(String recordId, String orderNo, String amount, String type, String createTime) {
|
||||
this.recordId = recordId;
|
||||
this.orderNo = orderNo;
|
||||
this.amount = amount;
|
|
@ -1,6 +1,6 @@
|
|||
package com.chint.application.out;
|
||||
|
||||
import com.chint.application.commands.CTripOrderRefundCommand;
|
||||
import com.chint.application.commands.RefundOrderGenerateCommand;
|
||||
import com.chint.application.dtos.AuthenticationDto;
|
||||
import com.chint.application.dtos.AuthenticationSignDto;
|
||||
import com.chint.application.dtos.OrderDetailQueryParam;
|
||||
|
@ -95,8 +95,8 @@ public class OrderDetailController {
|
|||
}
|
||||
|
||||
|
||||
@TransitionTo(command = "CTripOrderRefundCommand", order = 0)
|
||||
public void generateCTripRefund(CTripOrderRefundCommand command) {
|
||||
@TransitionTo(command = "RefundOrderGenerateCommand", order = 0)
|
||||
public void generateCTripRefund(RefundOrderGenerateCommand command) {
|
||||
orderDetailRepository.findByOrderNo(command.getOrderNo()).ifPresent(orderDetail -> {
|
||||
|
||||
String newOrderNo = command.getOrderNo() + "-" + command.getRecordId();
|
||||
|
@ -124,6 +124,7 @@ public class OrderDetailController {
|
|||
trainOrderDetail.setOrderAmount(command.getAmount());
|
||||
trainOrderDetail.setOrderStatus(type);
|
||||
trainOrderDetail.setOrderNo(newOrderNo);
|
||||
trainOrderDetail.setDetailId(newOrderNo);
|
||||
trainOrderDetail.setCreateTime(command.getCreateTime());
|
||||
trainOrderDetail.setId(null);
|
||||
}
|
||||
|
@ -131,8 +132,8 @@ public class OrderDetailController {
|
|||
FlightOrderDetail flightOrderDetail = orderDetail.getFlightOrderDetail();
|
||||
flightOrderDetail.setOrderAmount(command.getAmount());
|
||||
flightOrderDetail.setOrderStatus(type);
|
||||
// String newDetailOrder = "R" + flightOrderDetail.getOrderNo();
|
||||
flightOrderDetail.setOrderNo(newOrderNo);
|
||||
flightOrderDetail.setDetailId(newOrderNo);
|
||||
flightOrderDetail.setCreateTime(command.getCreateTime());
|
||||
flightOrderDetail.setId(null);
|
||||
}
|
||||
|
@ -140,8 +141,8 @@ public class OrderDetailController {
|
|||
HotelOrderDetail hotelOrderDetail = orderDetail.getHotelOrderDetail();
|
||||
hotelOrderDetail.setOrderAmount(command.getAmount());
|
||||
hotelOrderDetail.setOrderStatus(type);
|
||||
// String newDetailOrder = "R" + hotelOrderDetail.getOrderNo();
|
||||
hotelOrderDetail.setOrderNo(newOrderNo);
|
||||
hotelOrderDetail.setDetailId(newOrderNo);
|
||||
hotelOrderDetail.setCreateTime(command.getCreateTime());
|
||||
hotelOrderDetail.setId(null);
|
||||
List<HotelOrderDetailCustomer> customers = hotelOrderDetail.getCustomers();
|
||||
|
@ -156,13 +157,12 @@ public class OrderDetailController {
|
|||
CarOrderDetail carOrderDetail = orderDetail.getCarOrderDetail();
|
||||
carOrderDetail.setOrderAmount(command.getAmount());
|
||||
carOrderDetail.setOrderStatus(type);
|
||||
// String newDetailOrder = "R" + carOrderDetail.getOrderNo();
|
||||
carOrderDetail.setOrderNo(newOrderNo);
|
||||
carOrderDetail.setDetailId(newOrderNo);
|
||||
carOrderDetail.setCreateTime(command.getCreateTime());
|
||||
carOrderDetail.setId(null);
|
||||
}
|
||||
routeOrder.addOrderDetail(orderDetail);
|
||||
// orderDetailRepository.save(orderDetail);
|
||||
routeRepository.save(routeOrder);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package com.chint.domain.repository;
|
||||
|
||||
import com.chint.domain.aggregates.system.SupplierCallBackLog;
|
||||
|
||||
public interface SupplierCallBackLogRepository {
|
||||
|
||||
SupplierCallBackLog save(SupplierCallBackLog supplierCallBackLog);
|
||||
|
||||
|
||||
}
|
|
@ -226,6 +226,12 @@ public class OrderDomainService {
|
|||
carRefundChangeOrder(orderDetail.getOrderNo());
|
||||
}
|
||||
}
|
||||
|
||||
if(orderDetail.getSupplierName().equals(SUPPLIER_L_Y)){
|
||||
if (!orderEventType.equals(ORDER_EVENT_ETA) && orderDetail.getProductType().equals(LEG_TYPE_TRAIN)){
|
||||
lyTrainRefundGenerate(orderDetail.getOrderNo());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -441,7 +447,7 @@ public class OrderDomainService {
|
|||
if (refundInfo != null && !refundInfo.isEmpty()) {
|
||||
for (FlightRefundInfo flightRefundInfo : refundInfo) {
|
||||
if ("D".equals(flightRefundInfo.getRefundStatus())) {
|
||||
Command.of(CTripOrderRefundCommand.class).Info(
|
||||
Command.of(RefundOrderGenerateCommand.class).Info(
|
||||
String.valueOf(flightRefundInfo.getRefundOrderID()),
|
||||
flightOrderInfoEntity.getBasicInfo().getOrderID(),
|
||||
"-" + flightRefundInfo.getPayCustomerAmount(),
|
||||
|
@ -468,7 +474,7 @@ public class OrderDomainService {
|
|||
if (changeInfo != null && !changeInfo.isEmpty()) {
|
||||
for (ChangeInfo info : changeInfo) {
|
||||
if ("改签成功".equals(info.getCStatus())) {
|
||||
Command.of(CTripOrderRefundCommand.class).Info(
|
||||
Command.of(RefundOrderGenerateCommand.class).Info(
|
||||
String.valueOf(info.getRebookId()),
|
||||
flightOrderInfoEntity.getBasicInfo().getOrderID(),
|
||||
String.valueOf(info.getCFee()),
|
||||
|
@ -487,7 +493,7 @@ public class OrderDomainService {
|
|||
if (refundInfo != null && !refundInfo.isEmpty()) {
|
||||
for (RefundInfo flightRefundInfo : refundInfo) {
|
||||
if (flightOrderInfoEntity.getOrderDetailStatus().equals("Cancelled")) {
|
||||
Command.of(CTripOrderRefundCommand.class).Info(String.valueOf(flightRefundInfo.getRefundInfoID()),
|
||||
Command.of(RefundOrderGenerateCommand.class).Info(String.valueOf(flightRefundInfo.getRefundInfoID()),
|
||||
flightOrderInfoEntity.getOrderID(),
|
||||
"-" + flightRefundInfo.getRefundCustomerAmount(),
|
||||
"4",
|
||||
|
@ -509,7 +515,7 @@ public class OrderDomainService {
|
|||
if ("REFUND".equals(orderFee.getCostScene()) || "AFTER_REFUND".equals(orderFee.getCostScene())) {
|
||||
LocalDateTime localDateTime = LocalDateTime.now();
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
Command.of(CTripOrderRefundCommand.class).Info(
|
||||
Command.of(RefundOrderGenerateCommand.class).Info(
|
||||
String.valueOf(orderFee.getOrderFeeId()),
|
||||
basicInfo.getOrderId(),
|
||||
"-" + orderFee.getAmount(),
|
||||
|
@ -521,7 +527,18 @@ public class OrderDomainService {
|
|||
}
|
||||
|
||||
private void lyTrainRefundGenerate(String orderNo){
|
||||
// lySearchRequest.getTrainOrderDetail()
|
||||
TrainDetailResponse trainOrderDetail = lySearchRequest.getTrainOrderDetail(orderNo);
|
||||
TrainDetailResponse.TrainDetailData data = trainOrderDetail.getData();
|
||||
if (data != null && data.getOrderStatus().equals("T") && data.getItems() != null && !data.getItems().isEmpty()) {
|
||||
TrainDetailResponse.Item item = data.getItems().get(0);
|
||||
//状态为T说明该订单为退款订单, 需要生成退款订单
|
||||
Command.of(RefundOrderGenerateCommand.class).Info(
|
||||
String.valueOf(item.getItemId()),
|
||||
data.getOrderNo(),
|
||||
"-" + item.getRefundAmount(),
|
||||
"4",
|
||||
data.getRefundTime()
|
||||
).sendToQueue();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
package com.chint.infrastructure.repository;
|
||||
|
||||
import com.chint.domain.aggregates.system.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
|
||||
public class SupplierCallBackLogRepositoryImpl implements SupplierCallBackLogRepository {
|
||||
|
||||
@Autowired
|
||||
private JdbcSupplierCallBackLogRepository jdbcSupplierCallBackLogRepository;
|
||||
@Override
|
||||
public SupplierCallBackLog save(SupplierCallBackLog supplierCallBackLog) {
|
||||
return jdbcSupplierCallBackLogRepository.save(supplierCallBackLog);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package com.chint.infrastructure.repository.jdbc;
|
||||
|
||||
import com.chint.domain.aggregates.system.SupplierCallBackLog;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface JdbcSupplierCallBackLogRepository extends CrudRepository<SupplierCallBackLog,Long> {
|
||||
}
|
|
@ -2,10 +2,11 @@ package com.chint.interfaces.rest.ctrip.in;
|
|||
|
||||
import com.chint.application.commands.OrderStatusChangeCommand;
|
||||
import com.chint.domain.aggregates.order.OrderDetail;
|
||||
import com.chint.domain.aggregates.system.SupplierCallBackLog;
|
||||
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.OrderConstant;
|
||||
import com.chint.infrastructure.constant.SupplierNameConstant;
|
||||
import com.chint.infrastructure.echo_framework.command.Command;
|
||||
import com.chint.infrastructure.util.Digest;
|
||||
import com.chint.interfaces.rest.ctrip.CTripOrderSearchRequest;
|
||||
|
@ -22,6 +23,8 @@ 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.SupplierNameConstant.SUPPLIER_C_TRIP;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/public/CTrip")
|
||||
|
@ -37,6 +40,11 @@ public class CTripNoteController {
|
|||
@Autowired
|
||||
private CTripOrderSearchRequest cTripOrderSearchRequest;
|
||||
|
||||
@Autowired
|
||||
private SupplierCallBackLogRepository supplierCallBackLogRepository;
|
||||
|
||||
private Gson gson = new Gson();
|
||||
|
||||
// @PostMapping("/event")
|
||||
// public CTripNoteResponse noteEvent(@RequestBody CTripNotification cTripNotification) {
|
||||
// String putCTripEventSign = Digest.getPutCTripEventSign(cTripNotification);
|
||||
|
@ -60,8 +68,17 @@ public class CTripNoteController {
|
|||
@Transactional
|
||||
@PostMapping("/status")
|
||||
public CTripStatusResponse statusEvent(@RequestBody CTripStatusNotification cTripStatusNotification) {
|
||||
Gson gson = new Gson();
|
||||
log.info(gson.toJson(cTripStatusNotification));
|
||||
String json = gson.toJson(cTripStatusNotification);
|
||||
log.info(json);
|
||||
|
||||
//创建回推日志
|
||||
// SupplierCallBackLog supplierCallBackLog = SupplierCallBackLog
|
||||
// .start()
|
||||
// .supplier(SUPPLIER_C_TRIP)
|
||||
// .callBackJson(json);
|
||||
// supplierCallBackLogRepository.save(supplierCallBackLog);
|
||||
|
||||
|
||||
String productType = cTripStatusNotification.getProductType();
|
||||
String orderStatus = cTripStatusNotification.getOrderStatus();
|
||||
String orderId = cTripStatusNotification.getOrderId();
|
||||
|
@ -78,7 +95,7 @@ public class CTripNoteController {
|
|||
|
||||
public CTripStatusResponse handlerData(String orderId, String orderStatus, String productType) {
|
||||
SupplierCallbackData supplierCallbackData =
|
||||
SupplierCallbackData.of(SupplierNameConstant.SUPPLIER_C_TRIP);
|
||||
SupplierCallbackData.of(SUPPLIER_C_TRIP);
|
||||
SearchOrderResponse response = cTripOrderSearchRequest
|
||||
.searchOrderResponseByOrderId(orderId);
|
||||
supplierCallbackData.data(response);
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
package com.chint.interfaces.rest.ctrip.order;
|
||||
|
||||
import com.chint.application.commands.CTripOrderRefundCommand;
|
||||
import com.chint.domain.aggregates.order.ctrip.CtripCarOrderDetail;
|
||||
import com.chint.domain.aggregates.order.ctrip.CtripFlightOrderDetail;
|
||||
import com.chint.domain.aggregates.order.ctrip.CtripHotelOrderDetail;
|
||||
import com.chint.domain.aggregates.order.ctrip.CtripTrainOrderDetail;
|
||||
import com.chint.domain.repository.CTripOrderDetailRepository;
|
||||
import com.chint.infrastructure.echo_framework.command.Command;
|
||||
import com.chint.interfaces.rest.ctrip.dto.order.OrderCarResponse;
|
||||
import com.chint.interfaces.rest.ctrip.dto.order.OrderFlightResponse;
|
||||
import com.chint.interfaces.rest.ctrip.dto.order.OrderHotelResponse;
|
||||
|
|
|
@ -4,6 +4,8 @@ package com.chint.interfaces.rest.ly.in;
|
|||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.chint.domain.aggregates.order.OrderTravel;
|
||||
import com.chint.domain.aggregates.system.SupplierCallBackLog;
|
||||
import com.chint.domain.repository.SupplierCallBackLogRepository;
|
||||
import com.chint.infrastructure.repository.jdbc.JdbcOrderTravelRepository;
|
||||
import com.chint.interfaces.rest.ly.LYNoteResponse;
|
||||
import com.chint.interfaces.rest.ly.LYPostRequest;
|
||||
|
@ -30,6 +32,8 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_C_TRIP;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/public/common")
|
||||
|
@ -53,10 +57,28 @@ public class CommonController {
|
|||
@Value("${ly.baseUrl}")
|
||||
private String lyBaseUrl;
|
||||
|
||||
private Gson gson = new Gson();
|
||||
|
||||
@Autowired
|
||||
private SupplierCallBackLogRepository supplierCallBackLogRepository;
|
||||
|
||||
private String lyConfirmPath = "/api/DomesticFlight/ConfirmFlightOrderChange";
|
||||
|
||||
@PostMapping("/back")
|
||||
public LYNoteResponse Back(@RequestBody Notification notification) {
|
||||
|
||||
|
||||
String json = gson.toJson(notification);
|
||||
log.info(json);
|
||||
|
||||
//创建回推日志
|
||||
// SupplierCallBackLog supplierCallBackLog = SupplierCallBackLog
|
||||
// .start()
|
||||
// .supplier(SUPPLIER_C_TRIP)
|
||||
// .callBackJson(json);
|
||||
// supplierCallBackLogRepository.save(supplierCallBackLog);
|
||||
|
||||
|
||||
int notifyType = notification.getNotifyType();
|
||||
return switch (notifyType) {
|
||||
|
||||
|
|
Loading…
Reference in New Issue