1.修改携程打车数据赋值

This commit is contained in:
wanglf3 2024-03-14 18:57:07 +08:00
parent 735aef85cb
commit 22e086e0dc
2 changed files with 74 additions and 2 deletions

View File

@ -1,5 +1,6 @@
package com.chint.application.out;
import com.chint.application.commands.CTripOrderRefundCommand;
import com.chint.application.dtos.AuthenticationDto;
import com.chint.application.dtos.AuthenticationSignDto;
import com.chint.application.dtos.OrderDetailQueryParam;
@ -7,10 +8,12 @@ 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;
import com.chint.domain.service.auth.AuthenticateService;
import com.chint.infrastructure.echo_framework.annotation.TransitionTo;
import com.chint.infrastructure.util.Digest;
import com.chint.infrastructure.util.PageResult;
import com.chint.infrastructure.util.Result;
@ -26,8 +29,12 @@ 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")
@ -48,6 +55,8 @@ public class OrderDetailController {
@Autowired
private OrderDetailQuery orderDetailPageQuery;
@ApiOperation("订单明细认证接口")
@PostMapping("/public/authentication")
public Result<OrderSearchResult> queryAuthentication(@RequestBody AuthenticationDto authenticationDto) {
@ -78,7 +87,7 @@ public class OrderDetailController {
String sign = Digest.md5(+productType + systemType + startTime + endTime + pageSize + pageNum);
System.out.println(sign);
if (StringUtils.isNotBlank(orgsign) && orgsign.equals(sign)) {
return orderDetailPageQuery.orderDetailInfoPageQuery(authenticationDto);
return orderDetailPageQuery.orderDetailInfoPageQuery(authenticationDto);
} else {
return Result.error("签名错误");
}
@ -92,4 +101,67 @@ public class OrderDetailController {
}
@TransitionTo(command = "CTripOrderRefundCommand", order = 0)
public void generateCTripRefund(CTripOrderRefundCommand command) {
orderDetailRepository.findByOrderNo(command.getOrderNo()).ifPresent(orderDetail -> {
String newOrderNo = "R" + orderDetail.getOrderNo();
Optional<OrderDetail> byOrderNo = orderDetailRepository.findByOrderNo(newOrderNo);
if (byOrderNo.isPresent()) {
return;
}
Integer productType = orderDetail.getProductType();
orderDetail.setOrderId(null);
orderDetail.setOrderNo(newOrderNo);
OrderEvent orderEvent = new OrderEvent();
orderEvent.setEventType(ORDER_EVENT_REFUND);
orderEvent.setHappenTime(LocalDateTime.now());
orderEvent.setOutStatus(ORDER_EVENT_REFUND_NAME);
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.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.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.setCreateTime(command.getCreateTime());
hotelOrderDetail.setId(null);
List<HotelOrderDetailCustomer> customers = hotelOrderDetail.getCustomers();
List<HotelOrderDetailCustomer> newCustomers = new ArrayList<>();
for (HotelOrderDetailCustomer customer : customers) {
customer.setId(null);
newCustomers.add(customer);
}
hotelOrderDetail.setCustomers(newCustomers);
}
if (productType == 3) {
CarOrderDetail carOrderDetail = orderDetail.getCarOrderDetail();
carOrderDetail.setOrderAmount(command.getAmount());
carOrderDetail.setOrderStatus("4");
String newDetailOrder = "R" + carOrderDetail.getOrderNo();
carOrderDetail.setOrderNo(newDetailOrder);
carOrderDetail.setCreateTime(command.getCreateTime());
carOrderDetail.setId(null);
}
orderDetailRepository.save(orderDetail);
});
}
}

View File

@ -204,7 +204,7 @@ public class CTripTest {
@Test
void search() {
BaseContext.setCurrentUser(user);
SearchOrderResponse response = orderSearchRequest.searchOrderResponseByOrderId("31022448436");
SearchOrderResponse response = orderSearchRequest.searchOrderResponseByOrderId("29821751403");
System.out.println(response);
response = orderSearchRequest.searchOrderResponseByOrderId("31018642992");