同步代码

This commit is contained in:
lulz1 2024-02-26 19:20:08 +08:00
parent 25c65d0986
commit 5b8a9a3ac2
13 changed files with 136 additions and 11 deletions

View File

@ -11,8 +11,10 @@ public class ApproveOrderNo {
private String sysCode; private String sysCode;
@ApiModelProperty("实际单号") @ApiModelProperty("实际单号")
private String actualOrderNo; private String actualOrderNo;
@ApiModelProperty("入账公司") @ApiModelProperty("入账公司编码")
private String accountCompany; private String accountCompany;
@ApiModelProperty("入账公司名称")
private String accountCompanyName;
@ApiModelProperty("申请说明") @ApiModelProperty("申请说明")
private String instructions; private String instructions;
@ApiModelProperty("财务共享订单创建人") @ApiModelProperty("财务共享订单创建人")

View File

@ -23,6 +23,7 @@ public class OrderDetail {
@Id @Id
private Long orderId; // 使用 order_id 作为主键 private Long orderId; // 使用 order_id 作为主键
private Long legId; // 使用行程节点关联leg private Long legId; // 使用行程节点关联leg
private Long routeId;
private String orderNo; private String orderNo;
private String supplierName; private String supplierName;
private Integer productType; // 商品类型 private Integer productType; // 商品类型

View File

@ -32,6 +32,8 @@ public class User {
@Transient @Transient
private String companyCode; private String companyCode;
@Transient @Transient
private String companyName;
@Transient
private String workStatus; private String workStatus;
@Transient @Transient
private String manaLevel; private String manaLevel;

View File

@ -55,6 +55,7 @@ public class RouteOrderFactory implements OrderFactory {
approveOrderNo.setSysCode(loginParam.getSyscode()); approveOrderNo.setSysCode(loginParam.getSyscode());
approveOrderNo.setFakeOrderNo(loginParam.getBillcode()); approveOrderNo.setFakeOrderNo(loginParam.getBillcode());
approveOrderNo.setAccountCompany(currentUser.getCompanyCode()); approveOrderNo.setAccountCompany(currentUser.getCompanyCode());
approveOrderNo.setAccountCompanyName(currentUser.getCompanyName());
routeOrder.setApproveOrderNo(approveOrderNo); routeOrder.setApproveOrderNo(approveOrderNo);
routeOrder.setBookingTime(LocalDateTime.now()); routeOrder.setBookingTime(LocalDateTime.now());
return routeOrder; return routeOrder;

View File

@ -1,17 +1,45 @@
package com.chint.domain.factoriy.order_detail; package com.chint.domain.factoriy.order_detail;
import com.chint.domain.aggregates.order.*; import com.chint.domain.aggregates.order.*;
import com.chint.domain.aggregates.user.User;
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.hotel.HotelOrderInfoEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Optional;
import static com.chint.infrastructure.constant.OrderConstant.ORDER_DETAIL_STATUS_SUCCESS;
@Component @Component
public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory { public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory {
@Autowired
private OrderDetailRepository orderDetailRepository;
@Autowired
private RouteRepository routeRepository;
@Autowired
private UserRepository userRepository;
@Autowired
private LocationRepository locationRepository;
@Override @Override
public CarOrderDetail createCarOrderDetail(Object carOrderDetailData) { public CarOrderDetail createCarOrderDetail(Object carOrderDetailData) {
return null; return null;
} }
@Override @Override
public TrainOrderDetail createTrainOrderDetail(Object trainOrderDetailData) { public TrainOrderDetail createTrainOrderDetail(Object trainOrderDetailData) {
return null; return null;
} }
@ -22,7 +50,45 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory{
@Override @Override
public HotelOrderDetail createHotelOrderDetail(Object hotelOrderDetailData) { public HotelOrderDetail createHotelOrderDetail(Object hotelOrderDetailData) {
return null;
HotelOrderInfoEntity hotelOrderInfoEntity = (HotelOrderInfoEntity) hotelOrderDetailData;
String orderNo = hotelOrderInfoEntity.getOrderID();
Optional<OrderDetail> byOrderNo = orderDetailRepository.findByOrderNo(orderNo);
String journeyNo = hotelOrderInfoEntity.getJourneyNo();
RouteOrder routeOrder = routeRepository.findByOrderNo(journeyNo);
ApproveOrderNo approveOrderNo = routeOrder.getApproveOrderNo();
HotelOrderDetail hotelOrderDetail = new HotelOrderDetail();
hotelOrderDetail.setOrderNo(orderNo); //订单号
hotelOrderDetail.setOverStandard(null); //是否超标
hotelOrderDetail.setOrderStatus(ORDER_DETAIL_STATUS_SUCCESS);
hotelOrderDetail.setAccountCompanyId(approveOrderNo.getAccountCompany());
hotelOrderDetail.setAccountCompanyName(approveOrderNo.getAccountCompanyName());
hotelOrderDetail.setReceiptsNum(journeyNo);
byOrderNo.flatMap(orderDetail -> routeOrder.getLegItems()
.stream()
.filter(it -> byOrderNo.get().getLegId().equals(it.getLegId()))
.findFirst()).ifPresent(it ->
hotelOrderDetail.setScheduleNum(it.getLegNo()));
Long EmployeeNo = routeOrder.getUserId();
User user = userRepository.findByUserEmployeeNo(EmployeeNo);
String cityName = hotelOrderInfoEntity.getCityName();
hotelOrderDetail.setBookingUserCode(String.valueOf(user.getEmployeeNo()));
hotelOrderDetail.setBookingName(user.getName());
hotelOrderDetail.setBookingUserPhone(user.getPhoneNumber());
hotelOrderDetail.setCreateTime(hotelOrderInfoEntity.getOrderDate());
hotelOrderDetail.setCheckInCity(cityName);
hotelOrderDetail.setHotelName(hotelOrderInfoEntity.getHotelName());
hotelOrderDetail.setContactPhone(hotelOrderInfoEntity.getTelephone());
hotelOrderDetail.setHotelAddress(locationRepository.locationPathByName(cityName)
+ hotelOrderInfoEntity.getDistrictName() + hotelOrderInfoEntity.getAddress());
hotelOrderDetail.setStarRate(hotelOrderInfoEntity.getStar());
hotelOrderDetail.setCheckInDate(hotelOrderInfoEntity.getStartTime());
hotelOrderDetail.setDepartureDate(hotelOrderInfoEntity.getEndTime());
// hotelOrderDetail.setNightCount(hotelOrderInfoEntity.);
return hotelOrderDetail;
} }
@Override @Override

View File

@ -20,4 +20,6 @@ public interface LocationRepository {
List<Location> findByName(LocationParam locationParam); List<Location> findByName(LocationParam locationParam);
List<Location> findByName(String localName); List<Location> findByName(String localName);
String locationPathByName(String localName);
} }

View File

@ -55,6 +55,7 @@ public class CTripOrderDataAdapter implements OrderDataAdapter {
Location byName = locationRepository.findByName(hotelOrderInfoEntity.getCityName()).get(0); Location byName = locationRepository.findByName(hotelOrderInfoEntity.getCityName()).get(0);
return builder.productType(LegConstant.LEG_TYPE_HOTEL) return builder.productType(LegConstant.LEG_TYPE_HOTEL)
.hotelOrderDetailData(hotelOrderInfoEntity)
.currencyCode(hotelOrderInfoEntity.getCurrency()) .currencyCode(hotelOrderInfoEntity.getCurrency())
.orderTime(hotelOrderInfoEntity.getOrderDate()) .orderTime(hotelOrderInfoEntity.getOrderDate())
.startTime(hotelOrderInfoEntity.getStartTime()) .startTime(hotelOrderInfoEntity.getStartTime())

View File

@ -39,31 +39,31 @@ public class SupplierServiceImpl implements SupplierService {
Optional<OrderLegData> data = orderDataAdapterSelector.of(supplierName).adapt(callbackData); Optional<OrderLegData> data = orderDataAdapterSelector.of(supplierName).adapt(callbackData);
if (data.isPresent()) { if (data.isPresent()) {
//获取使用RouteUpdateOrderCommand命令创建的orderDetail //获取使用RouteUpdateOrderCommand命令创建的orderDetail
Properties properties = Command.of(RouteUpdateOrderCommand.class).data(data.get()).sendToQueue(); OrderLegData orderLegData = data.get();
Properties properties = Command.of(RouteUpdateOrderCommand.class).data(orderLegData).sendToQueue();
ResultContainer byPropertyName = properties.findByPropertyName(RESULT_ORDER_DETAIL); ResultContainer byPropertyName = properties.findByPropertyName(RESULT_ORDER_DETAIL);
OrderDetail orderDetail = (OrderDetail) byPropertyName.getValue(); OrderDetail orderDetail = (OrderDetail) byPropertyName.getValue();
Integer productType = data.get().getProductType(); Integer productType = orderLegData.getProductType();
OrderExtensionFactory orderExtensionFactory = orderExtensionCreator OrderExtensionFactory orderExtensionFactory = orderExtensionCreator
.of(supplierName); .of(supplierName);
Object callbackDataData = callbackData.getData();
//根据产品的不同类型添加不同的扩展字段 //根据产品的不同类型添加不同的扩展字段
switch (productType) { switch (productType) {
case LegConstant.LEG_TYPE_TRAIN -> orderDetail.addTrainOrderData( case LegConstant.LEG_TYPE_TRAIN -> orderDetail.addTrainOrderData(
orderExtensionFactory.createTrainOrderDetail(callbackDataData) orderExtensionFactory.createTrainOrderDetail(orderLegData.getTrainOrderDetailData())
); );
case LegConstant.LEG_TYPE_AIRPLANE -> orderDetail.addFlightOrderData( case LegConstant.LEG_TYPE_AIRPLANE -> orderDetail.addFlightOrderData(
orderExtensionFactory.createFlightOrderDetail(callbackDataData) orderExtensionFactory.createFlightOrderDetail(orderLegData.getFlightOrderDetailData())
); );
case LegConstant.LEG_TYPE_HOTEL -> orderDetail.addHotelOrderData( case LegConstant.LEG_TYPE_HOTEL -> orderDetail.addHotelOrderData(
orderExtensionFactory.createHotelOrderDetail(callbackDataData) orderExtensionFactory.createHotelOrderDetail(orderLegData.getHotelOrderDetailData())
); );
case LegConstant.LEG_TYPE_TAXI -> orderDetail.addCarOrderData( case LegConstant.LEG_TYPE_TAXI -> orderDetail.addCarOrderData(
orderExtensionFactory.createCarOrderDetail(callbackDataData) orderExtensionFactory.createCarOrderDetail(orderLegData.getCarOrderDetailData())
); );
case LegConstant.LEG_TYPE_OTHER -> orderDetail.addOtherOrderData( case LegConstant.LEG_TYPE_OTHER -> orderDetail.addOtherOrderData(
orderExtensionFactory.createOtherOrderDetail(callbackDataData) orderExtensionFactory.createOtherOrderDetail(orderLegData.getOtherOrderDetailData())
); );
} }
//对orderDetail进行保存 //对orderDetail进行保存

View File

@ -47,6 +47,11 @@ public class OrderLegData {
this.destinationId = builder.destinationId; this.destinationId = builder.destinationId;
this.originOrderStatus = builder.originOrderStatus; this.originOrderStatus = builder.originOrderStatus;
this.currencyCode = builder.currencyCode; this.currencyCode = builder.currencyCode;
this.carOrderDetailData = builder.carOrderDetailData;
this.trainOrderDetailData = builder.trainOrderDetailData;
this.hotelOrderDetailData = builder.hotelOrderDetailData;
this.flightOrderDetailData = builder.flightOrderDetailData;
this.otherOrderDetailData = builder.otherOrderDetailData;
} }
public static Builder builder() { public static Builder builder() {
@ -71,10 +76,36 @@ public class OrderLegData {
private Long destinationId; private Long destinationId;
private String currencyCode; private String currencyCode;
private Object carOrderDetailData;
private Object trainOrderDetailData;
private Object hotelOrderDetailData;
private Object flightOrderDetailData;
private Object otherOrderDetailData;
public Builder() { public Builder() {
} }
public Builder carOrderDetailData(Object carOrderDetailData) {
this.carOrderDetailData = carOrderDetailData;
return this;
}
public Builder trainOrderDetailData(Object trainOrderDetailData) {
this.trainOrderDetailData = trainOrderDetailData;
return this;
}
public Builder hotelOrderDetailData(Object hotelOrderDetailData) {
this.hotelOrderDetailData = hotelOrderDetailData;
return this;
}
public Builder flightOrderDetailData(Object flightOrderDetailData) {
this.flightOrderDetailData = flightOrderDetailData;
return this;
}
public Builder otherOrderDetailData(Object otherOrderDetailData) {
this.otherOrderDetailData = otherOrderDetailData;
return this;
}
public Builder currencyCode(String currencyCode) { public Builder currencyCode(String currencyCode) {
this.currencyCode = currencyCode; this.currencyCode = currencyCode;
return this; return this;

View File

@ -20,4 +20,12 @@ public class OrderConstant {
public static final String ORDER_EVENT_ETA_NAME = "超标"; public static final String ORDER_EVENT_ETA_NAME = "超标";
public static final int ORDER_EVENT_UNKNOWN = -99; public static final int ORDER_EVENT_UNKNOWN = -99;
public static final String ORDER_EVENT_UNKNOWN_NAME = "未知事件"; public static final String ORDER_EVENT_UNKNOWN_NAME = "未知事件";
//这批字段用于
public static final String ORDER_DETAIL_STATUS_SUCCESS = "1";
public static final String ORDER_DETAIL_STATUS_HALF = "4";
public static final String ORDER_EVENT_UNKNOWN_FAIL = "3";
} }

View File

@ -70,4 +70,10 @@ public class LocationRepositoryImpl implements LocationRepository {
public List<Location> findByName(String localName) { public List<Location> findByName(String localName) {
return jdbcLocationRepository.findByLocationNameContaining(localName); return jdbcLocationRepository.findByLocationNameContaining(localName);
} }
@Override
public String locationPathByName(String localName) {
Location byLocationName = jdbcLocationRepository.findByLocationName(localName);
return byLocationName.getLocationPathName().replace("_", "");
}
} }

View File

@ -19,5 +19,8 @@ public interface JdbcLocationRepository extends CrudRepository<Location, Long> {
Page<Location> findAllByLevel(Integer level, Pageable pageable); Page<Location> findAllByLevel(Integer level, Pageable pageable);
List<Location> findByFirstPinYin(String firstPinYin); List<Location> findByFirstPinYin(String firstPinYin);
List<Location> findByLocationNameContaining(String locationName); List<Location> findByLocationNameContaining(String locationName);
Location findByLocationName(String locationName);
} }

View File

@ -108,6 +108,7 @@ public class UserHttpRequestImpl implements UserHttpRequest {
if (fromJson.size() == 1) { if (fromJson.size() == 1) {
UserDataDTO userData = fromJson.get(0); UserDataDTO userData = fromJson.get(0);
user.setCompanyCode(userData.getCompany()); user.setCompanyCode(userData.getCompany());
user.setCompanyName(userData.getCompany_cn());
user.setWorkStatus(userData.getStatus()); user.setWorkStatus(userData.getStatus());
user.setGender(userData.getGender()); user.setGender(userData.getGender());
user.setName(userData.getUname()); user.setName(userData.getUname());
@ -134,6 +135,7 @@ public class UserHttpRequestImpl implements UserHttpRequest {
user.setGender(userData.getGender()); user.setGender(userData.getGender());
user.setName(userData.getUname()); user.setName(userData.getUname());
user.setPhoneNumber(userData.getMobilePhone()); user.setPhoneNumber(userData.getMobilePhone());
user.setCompanyName(userData.getCompany_cn());
} }
); );
fromJson.stream() fromJson.stream()