修复同步订单代码逻辑

This commit is contained in:
lulz1 2024-02-06 15:56:12 +08:00
parent b4d8f012ca
commit 3656d28727
10 changed files with 122 additions and 36 deletions

View File

@ -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) {

View File

@ -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);
}
}

View File

@ -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("订单未提交审批");
}

View File

@ -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);
}
}

View File

@ -6,4 +6,6 @@ import lombok.Data;
@Data
public class OrderQueryData extends BaseQuery {
private Long routeId;
private String billcode;
}

View File

@ -26,6 +26,7 @@ public class RouteRepositoryImpl implements RouteRepository {
return jdbcRouteRepository.findByRouteId(orderId);
}
@Override
public RouteOrder findByFakeOrderNo(String fakeOrderNo) {
return jdbcRouteRepository.findByApproveOrderNo_FakeOrderNo(fakeOrderNo);

View File

@ -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);
}
}

View File

@ -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;
}
}

View File

@ -1,10 +1,16 @@
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 {
// 产品类型
@ -68,4 +74,30 @@ public class HotelEndorsementDetail {
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;
}
}

View File

@ -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;
}