修复同步订单代码逻辑
This commit is contained in:
parent
b4d8f012ca
commit
3656d28727
|
@ -21,11 +21,16 @@ import static com.chint.infrastructure.constant.Constant.SUCCESS;
|
|||
public class OrderOutController {
|
||||
|
||||
|
||||
|
||||
|
||||
@Autowired
|
||||
private OrderQuery orderQuery;
|
||||
|
||||
@ApiOperation("根据临时单号查询订单")
|
||||
@PostMapping("/query/billcode")
|
||||
public Result<RouteOrder> queryOrderByBillCode(@RequestBody OrderQueryData queryData) {
|
||||
return Result.Success(SUCCESS, orderQuery.queryByBillCode(queryData.getBillcode()).reloadStatus());
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("查询行程规划订单详情")
|
||||
@PostMapping("/query")
|
||||
public Result<RouteOrder> queryOrder(@RequestBody OrderQueryData queryData) {
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
package com.chint.application.queryies;
|
||||
|
||||
import com.chint.domain.aggregates.order.RouteOrder;
|
||||
import com.chint.domain.aggregates.user.User;
|
||||
import com.chint.domain.repository.RouteRepository;
|
||||
import com.chint.domain.service.OrderDomainService;
|
||||
import com.chint.domain.value_object.OrderQueryData;
|
||||
import com.chint.infrastructure.util.BaseContext;
|
||||
import com.chint.infrastructure.util.PageResult;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -36,4 +34,8 @@ public class OrderQuery {
|
|||
orderDomainService.queryLocation(routeOrder.getLegItems());
|
||||
return routeOrder;
|
||||
}
|
||||
|
||||
public RouteOrder queryByBillCode(String billCode) {
|
||||
return routeRepository.findByFakeOrderNo(billCode);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ public class LegEventServiceImpl implements LegEventService {
|
|||
@Override
|
||||
public void syncLeg(LegSyncCommand command) {
|
||||
SyncLegData data = command.getData();
|
||||
RouteOrder routeOrder = routeRepository.queryById(data.getRouteId());
|
||||
RouteOrder routeOrder = routeRepository.queryById(data.getRouteId()).reloadStatus();
|
||||
if (routeOrder.getOrderStatus().equals(ORDER_STATUS_APPROVAL)) {
|
||||
String supplierName = data.getSupplierName();
|
||||
routeOrder.setSupplierName(supplierName);
|
||||
|
@ -85,9 +85,9 @@ public class LegEventServiceImpl implements LegEventService {
|
|||
routeOrder.getLegItems().forEach(leg -> leg.getEventList().add(
|
||||
legEventFactory.creatLegEvent(command.getLegEventType())
|
||||
));
|
||||
syncAdapter.of(supplierName).syncSupplierOrder(routeOrder.reloadStatus());
|
||||
//保存routeOrder的状态
|
||||
routeRepository.save(routeOrder);
|
||||
syncAdapter.of(supplierName).syncSupplierOrder(routeOrder.reloadStatus());
|
||||
} else {
|
||||
throw new CommandException("订单未提交审批");
|
||||
}
|
||||
|
|
|
@ -8,10 +8,17 @@ import com.chint.domain.repository.LocationRepository;
|
|||
import com.chint.infrastructure.util.BaseContext;
|
||||
import com.chint.interfaces.rest.ctrip.CTripApprovalRequest;
|
||||
import com.chint.interfaces.rest.ctrip.dto.approval.ApprovalRequest;
|
||||
import com.chint.interfaces.rest.ctrip.dto.approval.PassengerDetail;
|
||||
import com.chint.interfaces.rest.ctrip.dto.approval.hotel.HotelEndorsementDetail;
|
||||
import com.chint.interfaces.rest.ctrip.dto.approval.quick.RankInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.chint.infrastructure.constant.Constant.LEG_TYPE_HOTEL;
|
||||
|
||||
@Component
|
||||
public class CTripOrderSyncAdapter implements SupplierOrderSync {
|
||||
|
||||
|
@ -26,13 +33,29 @@ public class CTripOrderSyncAdapter implements SupplierOrderSync {
|
|||
|
||||
@Override
|
||||
public void syncSupplierOrder(RouteOrder order) {
|
||||
// User currentUser = BaseContext.getCurrentUser();
|
||||
// ApproveOrderNo approveOrderNo = order.getApproveOrderNo();
|
||||
// new RankInfo()
|
||||
// ApprovalRequest.buildApproval(currentUser.getEmployeeNo(), approveOrderNo.getActualOrderNo(), )
|
||||
//
|
||||
// approvalRequest.approval()
|
||||
//
|
||||
// System.out.println("开始同步协程订单");
|
||||
System.out.println("开始同步协程订单");
|
||||
User currentUser = BaseContext.getCurrentUser();
|
||||
ApproveOrderNo approveOrderNo = order.getApproveOrderNo();
|
||||
RankInfo rankInfo = RankInfo.of(currentUser.getRankCode());
|
||||
List<String> cityCode = new ArrayList<>();
|
||||
List<HotelEndorsementDetail> hotelList = new ArrayList<>();
|
||||
order.getLegItems().forEach(
|
||||
leg -> {
|
||||
cityCode.add(
|
||||
cityRepository.findByCityName(leg.getOriginLocation().getLocationName()).getCity()
|
||||
);
|
||||
if (leg.getLegType().equals(LEG_TYPE_HOTEL)) {
|
||||
hotelList.add(
|
||||
HotelEndorsementDetail.of(cityCode.stream().distinct().toList())
|
||||
.passenger(PassengerDetail.of(String.valueOf(currentUser.getEmployeeNo())))
|
||||
.starTime(leg.getStartTime())
|
||||
.endTime(leg.getEndTime())
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
ApprovalRequest approvalRequestParam = ApprovalRequest.buildApproval(String.valueOf(currentUser.getEmployeeNo()), approveOrderNo.getActualOrderNo(), rankInfo)
|
||||
.withHotel(hotelList);
|
||||
approvalRequest.approval(approvalRequestParam);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,4 +6,6 @@ import lombok.Data;
|
|||
@Data
|
||||
public class OrderQueryData extends BaseQuery {
|
||||
private Long routeId;
|
||||
|
||||
private String billcode;
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ public class RouteRepositoryImpl implements RouteRepository {
|
|||
return jdbcRouteRepository.findByRouteId(orderId);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public RouteOrder findByFakeOrderNo(String fakeOrderNo) {
|
||||
return jdbcRouteRepository.findByApproveOrderNo_FakeOrderNo(fakeOrderNo);
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
package com.chint.infrastructure.util;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
public class DateTimeUtil {
|
||||
|
||||
public static String timeToStr(LocalDateTime input) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
return input.format(formatter);
|
||||
}
|
||||
}
|
|
@ -1,7 +1,10 @@
|
|||
package com.chint.interfaces.rest.ctrip.dto.approval;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class PassengerDetail {
|
||||
|
||||
// 姓名 - 必填
|
||||
|
@ -62,4 +65,10 @@ public class PassengerDetail {
|
|||
|
||||
// Getters and setters for each field would be included below...
|
||||
|
||||
public static PassengerDetail of(String employeeNo) {
|
||||
PassengerDetail passengerDetail = new PassengerDetail();
|
||||
passengerDetail.setEID(employeeNo);
|
||||
return passengerDetail;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,71 +1,103 @@
|
|||
package com.chint.interfaces.rest.ctrip.dto.approval.hotel;
|
||||
|
||||
import com.chint.infrastructure.util.DateTimeUtil;
|
||||
import com.chint.interfaces.rest.ctrip.dto.approval.CurrencyType;
|
||||
import com.chint.interfaces.rest.ctrip.dto.approval.PassengerDetail;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Data
|
||||
public class HotelEndorsementDetail {
|
||||
|
||||
|
||||
// 产品类型
|
||||
private HotelProductTypeEnum productType;
|
||||
|
||||
|
||||
// 入住开始日期 - 格式: yyyy-MM-dd
|
||||
private String checkInDateBegin;
|
||||
|
||||
|
||||
// 入住结束日期 - 格式: yyyy-MM-dd
|
||||
private String checkInDateEnd;
|
||||
|
||||
|
||||
// 离店开始日期 - 格式: yyyy-MM-dd
|
||||
private String checkOutDateBegin;
|
||||
|
||||
|
||||
// 离店结束日期 - 格式: yyyy-MM-dd
|
||||
private String checkOutDateEnd;
|
||||
|
||||
|
||||
// 乘客列表
|
||||
private List<PassengerDetail> passengerList;
|
||||
|
||||
|
||||
// 入住国家ID列表
|
||||
private List<String> checkInCountryIds;
|
||||
|
||||
|
||||
// 入住国家代码列表
|
||||
private List<String> checkInCountryCodes;
|
||||
|
||||
|
||||
// 入住城市代码列表
|
||||
private List<String> checkInCityCodes;
|
||||
|
||||
|
||||
// 最高价格
|
||||
private String maxPrice;
|
||||
|
||||
|
||||
// 最低价格
|
||||
private String minPrice;
|
||||
|
||||
|
||||
// 货币类型 - 默认CNY
|
||||
private CurrencyType currency;
|
||||
|
||||
|
||||
// 最大星级
|
||||
private String maxStarRating;
|
||||
|
||||
|
||||
// 最小星级
|
||||
private String minStarRating;
|
||||
|
||||
|
||||
// 平均价格
|
||||
private String averagePrice;
|
||||
|
||||
|
||||
// 房间数量
|
||||
private int roomCount;
|
||||
|
||||
|
||||
// 跳过的字段位 - 用于标记不包含的字段
|
||||
private long skipFields;
|
||||
|
||||
|
||||
// 总房晚数
|
||||
private int totalRoomNightCount;
|
||||
|
||||
|
||||
// 房晚价格
|
||||
private String roomNightPrice;
|
||||
|
||||
|
||||
// 预验证字段位 - 用于标记需要预验证的字段
|
||||
private long preVerifyFields;
|
||||
|
||||
// Getters and setters...
|
||||
|
||||
public static HotelEndorsementDetail of(List<String> cityCodes) {
|
||||
HotelEndorsementDetail hotelEndorsementDetail = new HotelEndorsementDetail();
|
||||
hotelEndorsementDetail.setCheckInCityCodes(cityCodes);
|
||||
return hotelEndorsementDetail;
|
||||
}
|
||||
|
||||
public HotelEndorsementDetail passenger(PassengerDetail passengerDetail) {
|
||||
if (this.passengerList == null) {
|
||||
this.passengerList = new ArrayList<>();
|
||||
}
|
||||
this.passengerList.add(passengerDetail);
|
||||
return this;
|
||||
}
|
||||
|
||||
public HotelEndorsementDetail starTime(LocalDateTime startTime) {
|
||||
this.checkInDateBegin = DateTimeUtil.timeToStr(startTime);
|
||||
this.checkOutDateBegin = DateTimeUtil.timeToStr(startTime);
|
||||
return this;
|
||||
}
|
||||
|
||||
public HotelEndorsementDetail endTime(LocalDateTime endTime) {
|
||||
this.checkInDateEnd = DateTimeUtil.timeToStr(endTime);
|
||||
this.checkOutDateEnd = DateTimeUtil.timeToStr(endTime);
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -47,8 +47,8 @@ public class UserHttpRequestImpl implements UserHttpRequest {
|
|||
level = level.substring(0, level.length() - 3) + "M0";
|
||||
}
|
||||
TravelRankDTO loadTravelRank = loadTravelRank(new TravelRankParam(level));
|
||||
user.setRankCode(loadTravelRank.getLEVEL_MAPPING_CODE());
|
||||
// user.setRankCode("M0");
|
||||
// user.setRankCode(loadTravelRank.getLEVEL_MAPPING_CODE());
|
||||
user.setRankCode("测试职级");
|
||||
return user;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue