完成部分订单明细字段

This commit is contained in:
Superdandan 2024-02-26 22:28:16 +08:00
parent 5b8a9a3ac2
commit c6e1cff665
5 changed files with 119 additions and 4 deletions

View File

@ -3,8 +3,11 @@ package com.chint.domain.aggregates.order;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.mapping.MappedCollection;
import org.springframework.data.relational.core.mapping.Table;
import java.util.List;
@Data
@Table("hotel_order_detail")
public class HotelOrderDetail {
@ -105,7 +108,8 @@ public class HotelOrderDetail {
private String refundAmount;
// 入住人信息
private String customers;
@MappedCollection(idColumn = "hotel_order_detail_id", keyColumn = "hotel_order_detail_key")
private List<HotelOrderDetailCustomer> customers;
// 入住人性别
private String gender;

View File

@ -0,0 +1,14 @@
package com.chint.domain.aggregates.order;
import lombok.Data;
import org.springframework.data.relational.core.mapping.Table;
@Data
@Table("hotel_order_detail")
public class HotelOrderDetailCustomer {
private Long id;
private String userName;
private String userCode;
private String phone;
}

View File

@ -40,6 +40,21 @@ public class OrderEvent {
};
}
public String mapToFlightOrderDetailStatus(){
return switch (this.eventType) {
case OrderConstant.ORDER_EVENT_PREPARE -> "0";
case OrderConstant.ORDER_EVENT_PAYED -> "1";
case OrderConstant.ORDER_EVENT_CHANGE -> "2";
case OrderConstant.ORDER_EVENT_CANCEL -> "3";
case OrderConstant.ORDER_EVENT_ORDERED -> "0";
case OrderConstant.ORDER_EVENT_REFUND -> "3";
case OrderConstant.ORDER_EVENT_UNKNOWN -> "0";
case OrderConstant.ORDER_EVENT_FINISH -> "1";
case OrderConstant.ORDER_EVENT_ETA -> "0";
default -> "未知事件";
};
}
public OrderEvent reloadStatus() {
this.setEventName(translateOrderEvent(this.eventType));
return this;

View File

@ -6,13 +6,17 @@ import com.chint.domain.repository.LocationRepository;
import com.chint.domain.repository.OrderDetailRepository;
import com.chint.domain.repository.RouteRepository;
import com.chint.domain.repository.UserRepository;
import com.chint.interfaces.rest.ctrip.dto.search.flight.FlightOrderInfoEntity;
import com.chint.interfaces.rest.ctrip.dto.search.hotel.HotelOrderInfoEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import static com.chint.infrastructure.constant.OrderConstant.ORDER_DETAIL_STATUS_SUCCESS;
import static com.chint.infrastructure.constant.UtilConstant.KEEP_TWO_DECIMAL_ZERO;
@Component
public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory {
@ -45,6 +49,41 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory {
@Override
public FlightOrderDetail createFlightOrderDetail(Object flightOrderDetailData) {
FlightOrderInfoEntity flightOrderInfoEntity = (FlightOrderInfoEntity) flightOrderDetailData;
String orderNo = flightOrderInfoEntity.getBasicInfo().getOrderID();
String journeyNo = flightOrderInfoEntity.getBasicInfo().getJourneyID();
RouteOrder routeOrder = routeRepository.findByOrderNo(journeyNo);
Optional<OrderDetail> first = routeOrder
.getOrderDetails()
.stream()
.filter(orderDetail -> orderDetail.getOrderNo().equals(orderNo))
.findFirst();
FlightOrderDetail flightOrderDetail = new FlightOrderDetail();
flightOrderDetail.setOrderNo(orderNo);
first.ifPresent(orderDetail ->
flightOrderDetail.setOrderStatus(orderDetail.getLastEvent().mapToFlightOrderDetailStatus())
);
ApproveOrderNo approveOrderNo = routeOrder.getApproveOrderNo();
flightOrderDetail.setAccountCompanyId(approveOrderNo.getAccountCompany());
flightOrderDetail.setAccountCompanyName(approveOrderNo.getAccountCompanyName());
flightOrderDetail.setReceiptsNum(journeyNo);
first.flatMap(orderDetail -> routeOrder.getLegItems()
.stream()
.filter(it -> first.get().getLegId().equals(it.getLegId()))
.findFirst()).ifPresent(it ->
flightOrderDetail.setScheduleNum(it.getLegNo()));
Long EmployeeNo = routeOrder.getUserId();
User user = userRepository.findByUserEmployeeNo(EmployeeNo);
flightOrderDetail.setBookingUserCode(String.valueOf(user.getEmployeeNo()));
flightOrderDetail.setBookingName(user.getName());
flightOrderDetail.setBookingUserPhone(user.getPhoneNumber());
return null;
}
@ -85,9 +124,50 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory {
hotelOrderDetail.setHotelAddress(locationRepository.locationPathByName(cityName)
+ hotelOrderInfoEntity.getDistrictName() + hotelOrderInfoEntity.getAddress());
hotelOrderDetail.setStarRate(hotelOrderInfoEntity.getStar());
hotelOrderDetail.setCheckInDate(hotelOrderInfoEntity.getStartTime());
hotelOrderDetail.setDepartureDate(hotelOrderInfoEntity.getEndTime());
// hotelOrderDetail.setNightCount(hotelOrderInfoEntity.);
hotelOrderDetail.setCheckInDate(hotelOrderInfoEntity.getStartTime()); //入住日期
hotelOrderDetail.setDepartureDate(hotelOrderInfoEntity.getEndTime()); //离店日期 "2022-09-10"
hotelOrderDetail.setNightCount(hotelOrderInfoEntity.getQuantity()); //退订夜间数
hotelOrderDetail.setRoomCount(hotelOrderInfoEntity.getQuantity()); //退订夜间数
hotelOrderDetail.setRoomTypeName(hotelOrderInfoEntity.getRoomName()); //房型
hotelOrderDetail.setPaymentType("1"); //付款方式 0公司统付1个人付 2混付
if (Double.parseDouble(hotelOrderInfoEntity.getSettlementACCNTAmt()) > 0) {
hotelOrderDetail.setCompanyAmount(hotelOrderInfoEntity.getSettlementACCNTAmt());
hotelOrderDetail.setCompanyRefundAmount(KEEP_TWO_DECIMAL_ZERO);
} else {
//如果公司统付为负数 那么表示退款
hotelOrderDetail.setCompanyAmount(KEEP_TWO_DECIMAL_ZERO);
hotelOrderDetail.setCompanyRefundAmount(hotelOrderInfoEntity.getSettlementACCNTAmt());
}
if (Double.parseDouble(hotelOrderInfoEntity.getSettlementPersonAmt()) > 0) {
hotelOrderDetail.setPersonalAmount(hotelOrderInfoEntity.getSettlementPersonAmt());
hotelOrderDetail.setPersonalRefundAmount(KEEP_TWO_DECIMAL_ZERO);
} else {
hotelOrderDetail.setPersonalAmount(KEEP_TWO_DECIMAL_ZERO);
hotelOrderDetail.setPersonalRefundAmount(hotelOrderInfoEntity.getSettlementPersonAmt());
}
if (Double.parseDouble(hotelOrderInfoEntity.getAmount()) > 0) {
hotelOrderDetail.setOrderAmount(hotelOrderInfoEntity.getAmount());
hotelOrderDetail.setRefundAmount(KEEP_TWO_DECIMAL_ZERO);
} else {
hotelOrderDetail.setOrderAmount(KEEP_TWO_DECIMAL_ZERO);
hotelOrderDetail.setRefundAmount(hotelOrderInfoEntity.getAmount());
}
hotelOrderDetail.setPreServiceFee(hotelOrderInfoEntity.getFrontendServiceFee());
hotelOrderDetail.setPostServiceFee(hotelOrderInfoEntity.getServicefee());
List<HotelOrderDetailCustomer> customers = new ArrayList<>();
HotelOrderDetailCustomer hotelOrderDetailCustomer = new HotelOrderDetailCustomer();
hotelOrderDetailCustomer.setUserCode(user.getEmployeeNo().toString());
hotelOrderDetailCustomer.setUserName(user.getName());
hotelOrderDetailCustomer.setPhone(user.getPhoneNumber());
customers.add(hotelOrderDetailCustomer);
hotelOrderDetail.setCustomers(customers);
hotelOrderDetail.setSupplier(routeOrder.getSupplierCNName() + "预定");
return hotelOrderDetail;
}

View File

@ -66,6 +66,8 @@ public class HotelOrderInfoEntity {
private String HotelConfirmNo; // 酒店确认号
private String JourneyNo; // 旅程编号
private String CostCenter; // 成本中心
private String Quantity; //夜间数量
private String Servicefee;
// 后续字段含义类似可根据实际情况添加注释
private List<ClientInfo> ClientInfo; // 客户信息列表
}