修改签证回传给财务共享的参数
This commit is contained in:
parent
a1acf27785
commit
652553fc64
|
@ -10,6 +10,7 @@ import static com.chint.infrastructure.constant.LegConstant.LEG_EVENT_NOT_ORDERE
|
|||
public class LegSyncCommand extends Command {
|
||||
private Integer LegEventType = LEG_EVENT_NOT_ORDERED;
|
||||
private SyncLegData data;
|
||||
private Integer ifRouteRequestSync; //是否是差旅申请单同步方式
|
||||
|
||||
// public LegSyncCommand legId(Long LegId) {
|
||||
// this.setLegId(LegId);
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
package com.chint.application.in;
|
||||
|
||||
import com.chint.domain.value_object.SyncLegData;
|
||||
import com.chint.infrastructure.util.Result;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/route/request")
|
||||
public class RouteRequestController {
|
||||
|
||||
@Transactional
|
||||
@ApiOperation("根据整个行程规划单到差旅平台")
|
||||
@PostMapping("/sync/whole")
|
||||
public Result<String> syncByWholeRouterOrder(@RequestBody SyncLegData syncLegData) {
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -432,11 +432,6 @@ public class OrderQuery {
|
|||
.nightCount(leg.nightCount().toString());
|
||||
}
|
||||
|
||||
// if (leg.getLegType().equals(LEG_TYPE_OTHER) && leg.getLegExtensionField().getAmountType().equals(LEG_OTHER_AMOUNT_TYPE_VISA)) {
|
||||
// scheduleDetailBuilder.expenseTypeId("6770f575013211eabce29fde958f48e4")
|
||||
// .travelType("LOCAL_OTHER");
|
||||
// }
|
||||
|
||||
if (leg.getCurrencyType() != null) {
|
||||
scheduleDetailBuilder
|
||||
.currencyName(leg.getCurrencyType().getDescription())
|
||||
|
@ -461,8 +456,15 @@ public class OrderQuery {
|
|||
}
|
||||
}
|
||||
|
||||
if (leg.getLegType().equals(LEG_TYPE_OTHER) && Objects.requireNonNull(leg.getLegExtensionField()).getAmountType().equals(LEG_OTHER_AMOUNT_TYPE_VISA)) {
|
||||
scheduleDetailBuilder.expenseTypeId("6770f575013211eabce29fde958f48e4")
|
||||
.travelType("LOCAL_OTHER")
|
||||
.scheduleType("visa");
|
||||
} else {
|
||||
scheduleDetailBuilder.scheduleType(translateLegType(leg.getLegType()));
|
||||
}
|
||||
|
||||
return scheduleDetailBuilder
|
||||
.scheduleType(translateLegType(leg.getLegType()))
|
||||
.scheduleNum(leg.getLegNo())
|
||||
.startDate(simpleFormatter.format(leg.getStartTime()))
|
||||
.endDate(simpleFormatter.format(leg.getEndTime()))
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.chint.domain.aggregates.base;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.data.annotation.Transient;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
@ -15,6 +16,7 @@ public abstract class BaseEvent implements Serializable {
|
|||
|
||||
private Integer eventType;
|
||||
|
||||
@Transient
|
||||
private transient String eventName;
|
||||
|
||||
private LocalDateTime happenTime = LocalDateTime.now();
|
||||
|
|
|
@ -159,6 +159,14 @@ public class RouteOrder implements Serializable {
|
|||
return this;
|
||||
}
|
||||
|
||||
public RouteOrder addRouteRequest(RouteRequest routeRequest) {
|
||||
if (this.routeRequestList == null) {
|
||||
this.routeRequestList = new ArrayList<>();
|
||||
}
|
||||
this.routeRequestList.add(routeRequest);
|
||||
return this;
|
||||
}
|
||||
|
||||
public RouteOrder deleteLeg(String legNo) {
|
||||
if (this.legItems == null || this.legItems.isEmpty()) {
|
||||
return this;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.chint.domain.aggregates.order;
|
||||
|
||||
import com.chint.domain.aggregates.base.BaseEvent;
|
||||
import com.chint.domain.aggregates.base.EventManageable;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
@ -31,6 +32,7 @@ public class RouteRequest implements Serializable, EventManageable {
|
|||
|
||||
private String RouteRequestNo;
|
||||
|
||||
private String supplier;
|
||||
|
||||
@MappedCollection(idColumn = "route_request_id", keyColumn = "route_request_key")
|
||||
private List<RouteRequestLeg> routeRequestLegList;
|
||||
|
@ -40,8 +42,7 @@ public class RouteRequest implements Serializable, EventManageable {
|
|||
|
||||
@MappedCollection(idColumn = "route_request_id")
|
||||
private RouteRequestFields routeRequestFields;
|
||||
@Transient
|
||||
private String supplier;
|
||||
|
||||
@Transient
|
||||
private Integer status;
|
||||
@Transient
|
||||
|
@ -61,4 +62,17 @@ public class RouteRequest implements Serializable, EventManageable {
|
|||
public List<RouteRequestEvent> getEvents() {
|
||||
return this.eventList;
|
||||
}
|
||||
|
||||
public RouteRequest reloadStatus() {
|
||||
BaseEvent lastEvent = this.getLastEvent().reloadStatus();
|
||||
this.status = lastEvent.getEventType();
|
||||
this.statusName = lastEvent.getEventName();
|
||||
return this;
|
||||
}
|
||||
|
||||
public RouteRequest reloadGenerateRequestLegs(List<Leg> legList) {
|
||||
List<RouteRequestLeg> routeRequestLegs = legList.stream().map(RouteRequestLeg::ofLeg).toList();
|
||||
this.setRouteRequestLegList(routeRequestLegs);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,4 +30,24 @@ public class RouteRequestEvent extends BaseEvent implements Serializable {
|
|||
ROUTE_REQUEST_STATUS_SYNC, ROUTE_REQUEST_STATUS_SYNC_NAME,
|
||||
ROUTE_REQUEST_STATUS_CANCEL, ROUTE_REQUEST_STATUS_CANCEL_NAME);
|
||||
}
|
||||
|
||||
public static RouteRequestEvent prepare(){
|
||||
RouteRequestEvent routeRequestEvent = new RouteRequestEvent();
|
||||
routeRequestEvent.setEventType(ROUTE_REQUEST_STATUS_PREPARE);
|
||||
return routeRequestEvent;
|
||||
}
|
||||
|
||||
public static RouteRequestEvent sync(String supplierName){
|
||||
RouteRequestEvent routeRequestEvent = new RouteRequestEvent();
|
||||
routeRequestEvent.setEventType(ROUTE_REQUEST_STATUS_SYNC);
|
||||
routeRequestEvent.setExtension(supplierName);
|
||||
return routeRequestEvent;
|
||||
}
|
||||
|
||||
public static RouteRequestEvent cancel(String supplierName){
|
||||
RouteRequestEvent routeRequestEvent = new RouteRequestEvent();
|
||||
routeRequestEvent.setEventType(ROUTE_REQUEST_STATUS_CANCEL);
|
||||
routeRequestEvent.setExtension(supplierName);
|
||||
return routeRequestEvent;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,8 @@ public class RouteRequestFields implements Serializable {
|
|||
private String accountCompanyName;
|
||||
@ApiModelProperty("入账公司64位编码")
|
||||
private String accountCompanyCode;
|
||||
@ApiModelProperty("费用归属部门")
|
||||
private String belongDeptCode;
|
||||
@ApiModelProperty("项目名称")
|
||||
private String projectName;
|
||||
@ApiModelProperty("成本中心")
|
||||
|
|
|
@ -79,13 +79,17 @@ public class OrderCarRecord extends OrderBaseRecord {
|
|||
public OrderCarRecord loadTravelInfo(String startTime,
|
||||
String arriveTime,
|
||||
String fromCity,
|
||||
String toCity
|
||||
String toCity,
|
||||
String fromStationName,
|
||||
String toStationName
|
||||
) {
|
||||
// 行程信息
|
||||
this.setFromCity(fromCity);
|
||||
this.setToCity(toCity);
|
||||
this.setStartTime(startTime);
|
||||
this.setArriveTime(arriveTime);
|
||||
this.setFromStationName(fromStationName);
|
||||
this.setToStationName(toStationName);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ public class CTripCarRecord implements Serializable {
|
|||
private String recordId;
|
||||
private LocalDateTime createTime;
|
||||
private String routeOrderNo;
|
||||
private String orderDate;
|
||||
@MappedCollection(idColumn = "c_trip_car_record_id")
|
||||
private CTripCarRecordBase cTripCarRecordBase;
|
||||
@MappedCollection(idColumn = "c_trip_car_record_id")
|
||||
|
|
|
@ -6,11 +6,19 @@ import com.chint.domain.aggregates.order.RouteOrder;
|
|||
import com.chint.domain.aggregates.order.RouteRequest;
|
||||
import com.chint.domain.value_object.OrderSaveData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface OrderFactory {
|
||||
RouteOrder createRoute(OrderSaveData orderData);
|
||||
|
||||
RouteOrder createRoute(OrderCreateCommand command);
|
||||
|
||||
ApprovalEvent createApprovalEvent(Integer eventType);
|
||||
|
||||
RouteRequest createRequestWithLeg(RouteOrder routeOrder, List<Long> legIds);
|
||||
|
||||
RouteRequest createRequestWithAllLeg(RouteOrder routeOrder);
|
||||
|
||||
RouteRequest createRequestByRoute(RouteOrder routeOrder);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.chint.domain.factoriy.order;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.chint.application.commands.OrderCreateCommand;
|
||||
import com.chint.domain.aggregates.order.*;
|
||||
import com.chint.domain.aggregates.user.User;
|
||||
|
@ -26,7 +27,6 @@ public class RouteOrderFactory implements OrderFactory {
|
|||
private String envMark;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public RouteOrder createRoute(OrderSaveData orderData) {
|
||||
User currentUser = BaseContext.getCurrentUser();
|
||||
|
@ -82,10 +82,42 @@ public class RouteOrderFactory implements OrderFactory {
|
|||
return approvalEvent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RouteRequest createRequestWithLeg(RouteOrder routeOrder, List<Long> legIds) {
|
||||
RouteRequest requestByRoute = createRequestByRoute(routeOrder);
|
||||
List<RouteRequestLeg> routeRequestLegs = routeOrder
|
||||
.getLegItems()
|
||||
.stream()
|
||||
.filter(it -> legIds.contains(it.getLegId()))
|
||||
.map(RouteRequestLeg::ofLeg)
|
||||
.toList();
|
||||
requestByRoute.setRouteRequestLegList(routeRequestLegs);
|
||||
return requestByRoute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RouteRequest createRequestWithAllLeg(RouteOrder routeOrder) {
|
||||
RouteRequest requestByRoute = createRequestByRoute(routeOrder);
|
||||
List<RouteRequestLeg> routeRequestLegs = routeOrder
|
||||
.getLegItems()
|
||||
.stream()
|
||||
.map(RouteRequestLeg::ofLeg)
|
||||
.toList();
|
||||
requestByRoute.setRouteRequestLegList(routeRequestLegs);
|
||||
return requestByRoute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RouteRequest createRequestByRoute(RouteOrder routeOrder) {
|
||||
RouteRequest routeRequest = new RouteRequest();
|
||||
routeRequest.setRouteRequestNo(OrderNo.generateRouteRequestNo(routeOrder.getRouteOrderNo()));
|
||||
return null;
|
||||
RouteRequestFields routeRequestFields = BeanUtil.copyProperties(routeOrder.getApproveOrderNo(),
|
||||
RouteRequestFields.class);
|
||||
routeRequestFields.setUserId(routeOrder.getUserId());
|
||||
routeRequestFields.setBelongDeptCode(routeOrder.getRouterOrderExtensionField().getBelongDeptCode());
|
||||
routeRequestFields.setStandardLevel(routeOrder.getStandardLevel());
|
||||
routeRequest.setRouteRequestFields(routeRequestFields);
|
||||
routeRequest.addEvent(RouteRequestEvent.prepare());
|
||||
return routeRequest;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -109,7 +109,10 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
|
|||
}
|
||||
orderCarRecord.loadTravelInfo(startTime, endTime,
|
||||
cTripCarQuickInfo.getDepartureCityName(),
|
||||
cTripCarQuickInfo.getArrivalCityName());
|
||||
cTripCarQuickInfo.getArrivalCityName(),
|
||||
cTripCarQuickInfo.getDepartureCityName() + cTripCarQuickInfo.getDepartureAddressDetail(),
|
||||
cTripCarQuickInfo.getArrivalCityName() + cTripCarQuickInfo.getArrivalAddressDetail()
|
||||
);
|
||||
|
||||
// 加载车型和运行信息,车类型,时间,里程
|
||||
orderCarRecord.loadVehicleAndTravelInfo(cTripCarQuickInfo.getVehicleName(),
|
||||
|
@ -120,7 +123,7 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
|
|||
String batchNo = cTripCarRecordBase.getBatchNoStartDate().substring(0, 6);
|
||||
orderCarRecord.loadFinancialInfo(batchNo,
|
||||
cTripCarRecordBase.getSubAccCheckBatchNo(),
|
||||
String.valueOf(cTripCarRecordBase.getAmount()),
|
||||
String.valueOf(cTripCarRecordBase.getRealAmount()),
|
||||
String.valueOf(cTripCarRecordBase.getRealAmountHasPost()));
|
||||
|
||||
// 加载费用细节, 未税金额,税费,服务费,取消费,额外费用,额外费用名称 , 携程马上用车产品没有税费和额外费用字段
|
||||
|
@ -172,7 +175,7 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
|
|||
carOrderDetail.getOriginalOrderNo())
|
||||
.loadBasicOrderInfo(carOrderDetail.getOrderNo(),
|
||||
carOrderDetail.getOrderStatus(),
|
||||
carOrderDetail.getCreateTime());
|
||||
cTripCarRecord.getOrderDate());
|
||||
}, () -> orderCarRecord.loadComplianceInfoNot()
|
||||
.loadRelatedOrderInfo(cTripCarRecordBase.getOrderId(),
|
||||
cTripCarRecord.getRecordId(),
|
||||
|
@ -182,7 +185,7 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
|
|||
String.valueOf(cTripCarRecordBase.getOrderId()))
|
||||
.loadBasicOrderInfo(String.valueOf(cTripCarRecordBase.getOrderId()),
|
||||
"",
|
||||
cTripCarRecordBase.getCreateTime()));
|
||||
cTripCarRecord.getOrderDate()));
|
||||
|
||||
//这里添加归属部门编号 , 这里兼容测试环境 , 如果行程规划单已经有这个值 , 那么直接取, 没有的话,查找用户的部门获取
|
||||
Optional<RouterOrderExtensionField> routerOrderExtensionField = byOrderNo
|
||||
|
|
|
@ -8,6 +8,8 @@ import java.util.List;
|
|||
public interface LegRepository {
|
||||
Leg save(Leg leg);
|
||||
|
||||
List<Leg> findByIds(List<Long> legIds);
|
||||
|
||||
void deleteById(Leg leg);
|
||||
void deleteByLegNo(String legNo);
|
||||
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
package com.chint.domain.service;
|
||||
|
||||
import com.chint.domain.aggregates.order.Leg;
|
||||
import com.chint.domain.aggregates.order.LegEvent;
|
||||
import com.chint.domain.aggregates.order.OrderDetail;
|
||||
import com.chint.domain.aggregates.order.RouteOrder;
|
||||
import com.chint.domain.aggregates.order.*;
|
||||
import com.chint.domain.exceptions.LegEventException;
|
||||
import com.chint.domain.factoriy.leg_event.LegEventFactory;
|
||||
import com.chint.domain.repository.LegRepository;
|
||||
import com.chint.domain.repository.LocationRepository;
|
||||
import com.chint.domain.repository.OrderDetailRepository;
|
||||
import com.chint.domain.repository.RouteRepository;
|
||||
import com.chint.infrastructure.constant.LegConstant;
|
||||
|
@ -34,6 +32,9 @@ public class LegDomainService {
|
|||
@Autowired
|
||||
private RouteRepository routeRepository;
|
||||
|
||||
@Autowired
|
||||
private LocationRepository locationRepository;
|
||||
|
||||
public Leg legCheckOrder(Leg leg) {
|
||||
List<OrderDetail> orderDetailList = orderDetailRepository.findByLegId(leg.getLegId());
|
||||
orderDetailList.forEach(OrderDetail::reloadStatus);
|
||||
|
@ -115,4 +116,29 @@ public class LegDomainService {
|
|||
}
|
||||
return leg;
|
||||
}
|
||||
|
||||
public List<Leg> queryLocation(List<Leg> list) {
|
||||
list.forEach(leg -> {
|
||||
LegExtensionField legExtensionField = leg.getLegExtensionField();
|
||||
if (legExtensionField != null && legExtensionField.getLocationIds() != null) {
|
||||
List<Long> locationIdsAsLong;
|
||||
if (legExtensionField.getLocationIds().startsWith("[")) {
|
||||
locationIdsAsLong = legExtensionField.getLocationIdsAsLongFromArray();
|
||||
} else {
|
||||
locationIdsAsLong = legExtensionField.getLocationIdsAsLong();
|
||||
}
|
||||
List<Location> byNameList = locationRepository.findByNameList(locationIdsAsLong);
|
||||
legExtensionField.setLocationList(byNameList);
|
||||
}
|
||||
if (leg.getOriginId() != null) {
|
||||
leg.setOriginLocation(locationRepository.findByLocationId(leg.getOriginId()));
|
||||
}
|
||||
|
||||
if (leg.getDestinationId() != null) {
|
||||
leg.setDestinationLocation(locationRepository.findByLocationId(leg.getDestinationId()));
|
||||
}
|
||||
|
||||
});
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
package com.chint.domain.service;
|
||||
|
||||
import com.chint.domain.aggregates.order.Leg;
|
||||
import com.chint.domain.aggregates.order.RouteOrder;
|
||||
import com.chint.domain.aggregates.order.RouteRequest;
|
||||
import com.chint.domain.aggregates.order.RouteRequestEvent;
|
||||
import com.chint.domain.factoriy.order.RouteOrderFactory;
|
||||
import com.chint.domain.repository.LegRepository;
|
||||
import com.chint.domain.repository.RouteRepository;
|
||||
import com.chint.domain.service.order_sync.SyncAdapter;
|
||||
import com.chint.domain.value_object.SyncLegData;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static com.chint.infrastructure.constant.RouteRequestConstant.ROUTE_REQUEST_STATUS_PREPARE;
|
||||
|
||||
@Service
|
||||
public class RouteRequestDomainService {
|
||||
|
||||
@Autowired
|
||||
private SyncAdapter syncAdapter;
|
||||
|
||||
@Autowired
|
||||
private RouteOrderFactory routeOrderFactory;
|
||||
|
||||
@Autowired
|
||||
private RouteRepository routeRepository;
|
||||
|
||||
@Autowired
|
||||
private LegDomainService legDomainService;
|
||||
|
||||
@Autowired
|
||||
private LegRepository legRepository;
|
||||
|
||||
|
||||
public RouteRequest syncRouteRequestToSupplier(SyncLegData syncLegData) {
|
||||
RouteOrder routeOrder = routeRepository.queryById(syncLegData.getRouteId());
|
||||
List<Long> legIds = syncLegData.getLegIds();
|
||||
RouteRequest routeRequest = getRouteRequest(routeOrder, legIds, syncLegData.getSupplierName());
|
||||
if (routeRequest.getStatus().equals(ROUTE_REQUEST_STATUS_PREPARE)) {
|
||||
//如果是刚生成的订单需要加入行程规划单当中
|
||||
//保存供应商信息
|
||||
routeRequest.setSupplier(syncLegData.getSupplierName());
|
||||
routeOrder.addRouteRequest(routeRequest);
|
||||
} else {
|
||||
//如果是不是刚生成的,需要调整差旅申请单的行程
|
||||
loadLegInfo(routeRequest, routeOrder, legIds);
|
||||
}
|
||||
syncAdapter.of(syncLegData.getSupplierName()).syncRouteRequest(routeRequest);
|
||||
routeRequest.addEvent(RouteRequestEvent.sync(syncLegData.getSupplierName()));
|
||||
//通过保存聚合根来保存差旅申请单
|
||||
routeRepository.save(routeOrder);
|
||||
return routeRequest;
|
||||
}
|
||||
|
||||
|
||||
//获取目前已经同步到供应商的差旅申请单
|
||||
private RouteRequest getRouteRequest(RouteOrder routeOrder, List<Long> legIds, String supplier) {
|
||||
Optional<RouteRequest> optionalRouteRequest = routeOrder
|
||||
.getRouteRequestList()
|
||||
.stream()
|
||||
.filter(it -> it.getSupplier().equals(supplier))
|
||||
.findFirst();
|
||||
if (legIds == null || legIds.isEmpty()) {
|
||||
List<Long> allLegIds = routeOrder.getLegItems().stream().map(Leg::getLegId).toList();
|
||||
return optionalRouteRequest
|
||||
.orElseGet(() -> routeOrderFactory.createRequestWithLeg(routeOrder, allLegIds)).reloadStatus();
|
||||
} else {
|
||||
return optionalRouteRequest
|
||||
.orElseGet(() -> routeOrderFactory.createRequestWithLeg(routeOrder, legIds)).reloadStatus();
|
||||
}
|
||||
}
|
||||
|
||||
//获取目前已经同步到供应商的差旅申请单
|
||||
private RouteRequest loadLegInfo(RouteRequest routeRequest, RouteOrder routeOrder, List<Long> legIds) {
|
||||
List<Leg> legItems = routeOrder.getLegItems();
|
||||
routeRequest.getRouteRequestLegList().forEach(it ->
|
||||
legItems.stream()
|
||||
.filter(leg -> legIds.contains(leg.getLegId()))
|
||||
.filter(leg -> leg.getLegId().equals(it.getLegId()))
|
||||
.findFirst()
|
||||
.ifPresent(it::setLeg));
|
||||
return routeRequest;
|
||||
}
|
||||
}
|
|
@ -65,16 +65,15 @@ public class CTripOrderSyncAdapter implements SupplierOrderSync {
|
|||
|
||||
@Override
|
||||
public boolean syncSupplierOrder(RouteOrder order) {
|
||||
log.info("开始同步协程订单");
|
||||
log.info("开始同步携程订单");
|
||||
ApprovalRequest approvalRequestParam = getApprovalRequestParam(order);
|
||||
ApprovalResult approval = approvalRequest.approval(approvalRequestParam);
|
||||
return approval.getSetApprovalResult().getStatus().getSuccess();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean cancelSyncSupplierOrder(RouteOrder order) {
|
||||
log.info("开始取消协程订单");
|
||||
log.info("开始取消携程订单");
|
||||
ApprovalRequest approvalRequestParam = getApprovalRequestParam(order);
|
||||
ApprovalResult approval = approvalRequest.cancelApprovalOrder(approvalRequestParam);
|
||||
return approval.getSetApprovalResult().getStatus().getSuccess();
|
||||
|
@ -82,30 +81,43 @@ public class CTripOrderSyncAdapter implements SupplierOrderSync {
|
|||
|
||||
@Override
|
||||
public boolean syncRouteRequest(RouteRequest routeRequest) {
|
||||
return false;
|
||||
log.info("开始同步携程订单");
|
||||
ApprovalRequest approvalRequestParam = getApprovalRequestParam(routeRequest);
|
||||
ApprovalResult approval = approvalRequest.approval(approvalRequestParam);
|
||||
return approval.getSetApprovalResult().getStatus().getSuccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean cancelRouteRequest(RouteRequest routeRequest) {
|
||||
return false;
|
||||
log.info("开始取消携程订单");
|
||||
ApprovalRequest approvalRequestParam = getApprovalRequestParam(routeRequest);
|
||||
ApprovalResult approval = approvalRequest.cancelApprovalOrder(approvalRequestParam);
|
||||
return approval.getSetApprovalResult().getStatus().getSuccess();
|
||||
}
|
||||
|
||||
private ApprovalRequest getApprovalRequestParam(RouteOrder order) {
|
||||
|
||||
ApproveOrderNo approveOrderNo = order.getApproveOrderNo();
|
||||
RankInfo rankInfo = RankInfo.of(order.getStandardLevel());
|
||||
String employeeNo = String.valueOf(order.getUserId());
|
||||
private ApprovalRequest getApprovalRequestParam(RouteRequest routeRequest) {
|
||||
RouteRequestFields routeRequestFields = routeRequest.getRouteRequestFields();
|
||||
List<RouteRequestLeg> routeRequestLegList = routeRequest.getRouteRequestLegList();
|
||||
String employeeNo = routeRequestFields.getUserId();
|
||||
ApprovalRequest approvalRequestParam = ApprovalRequest
|
||||
.buildApproval(order.getRouteOrderNo(), String.valueOf(employeeNo), rankInfo)
|
||||
.addExtendField(approveOrderNo.getAccountCompanyCode())
|
||||
.addExtendField(approveOrderNo.getAccountCompanyName())
|
||||
.addExtendField(approveOrderNo.getSysCode())
|
||||
.buildApproval(routeRequest.getRouteRequestNo(), employeeNo,
|
||||
RankInfo.of(routeRequestFields.getStandardLevel()))
|
||||
.addExtendField(routeRequestFields.getAccountCompanyCode())
|
||||
.addExtendField(routeRequestFields.getAccountCompanyName())
|
||||
.addExtendField(routeRequestFields.getSysCode())
|
||||
.addExtendField("暂无")
|
||||
.addExtendField(approveOrderNo.getProjectName());
|
||||
.addExtendField(routeRequestFields.getProjectName());
|
||||
List<Leg> legList = routeRequestLegList.stream().map(RouteRequestLeg::getLeg).toList();
|
||||
return generateApprovalRequestLegInfo(legList, employeeNo, approvalRequestParam);
|
||||
}
|
||||
|
||||
private ApprovalRequest generateApprovalRequestLegInfo(List<Leg> legList, String employeeNo, ApprovalRequest approvalRequestParam) {
|
||||
Map<Integer, List<Leg>> collect = orderDomainService.queryLocation(
|
||||
order.getLegItems()
|
||||
.stream()
|
||||
.filter(leg -> leg.getLegType().equals(LEG_TYPE_HOTEL) || leg.getLegType().equals(LEG_TYPE_AIRPLANE) || leg.getLegType().equals(LEG_TYPE_TAXI))
|
||||
legList.stream()
|
||||
.filter(leg -> leg.getLegType().equals(LEG_TYPE_HOTEL) ||
|
||||
leg.getLegType().equals(LEG_TYPE_AIRPLANE) ||
|
||||
leg.getLegType().equals(LEG_TYPE_TAXI))
|
||||
.toList()
|
||||
)
|
||||
.stream().collect(Collectors.groupingBy(Leg::getLegType));
|
||||
|
@ -120,6 +132,21 @@ public class CTripOrderSyncAdapter implements SupplierOrderSync {
|
|||
return approvalRequestParam;
|
||||
}
|
||||
|
||||
private ApprovalRequest getApprovalRequestParam(RouteOrder order) {
|
||||
ApproveOrderNo approveOrderNo = order.getApproveOrderNo();
|
||||
RankInfo rankInfo = RankInfo.of(order.getStandardLevel());
|
||||
String employeeNo = String.valueOf(order.getUserId());
|
||||
ApprovalRequest approvalRequestParam = ApprovalRequest
|
||||
.buildApproval(order.getRouteOrderNo(), String.valueOf(employeeNo), rankInfo)
|
||||
.addExtendField(approveOrderNo.getAccountCompanyCode())
|
||||
.addExtendField(approveOrderNo.getAccountCompanyName())
|
||||
.addExtendField(approveOrderNo.getSysCode())
|
||||
.addExtendField("暂无")
|
||||
.addExtendField(approveOrderNo.getProjectName());
|
||||
List<Leg> legList = order.getLegItems();
|
||||
return generateApprovalRequestLegInfo(legList, employeeNo, approvalRequestParam);
|
||||
}
|
||||
|
||||
private List<HotelEndorsementDetail> generateHotelList(List<Leg> legs, String employeeNo) {
|
||||
List<HotelEndorsementDetail> hotelList = new ArrayList<>();
|
||||
legs.forEach(leg -> {
|
||||
|
|
|
@ -8,6 +8,7 @@ import java.util.List;
|
|||
public class SyncLegData {
|
||||
private Long routeId;
|
||||
private List<Long> routeIds;
|
||||
private List<Long> legIds;
|
||||
private String supplierName;
|
||||
public static SyncLegData of( Long routeId,String supplierName){
|
||||
SyncLegData syncLegData = new SyncLegData();
|
||||
|
|
|
@ -29,6 +29,11 @@ public class LegRepositoryImpl implements LegRepository {
|
|||
return leg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Leg> findByIds(List<Long> legIds) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteById(Leg leg) {
|
||||
routeCacheService.invalidateRouteCache(leg.getRouteId());
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.chint.interfaces.rest.ctrip.order;
|
|||
|
||||
import com.chint.domain.aggregates.order.order_record.ctrip_order_record.*;
|
||||
import com.chint.domain.repository.CTripOrderDetailRepository;
|
||||
import com.chint.infrastructure.util.DateTimeUtil;
|
||||
import com.chint.interfaces.rest.ctrip.dto.order.OrderCarResponse;
|
||||
import com.chint.interfaces.rest.ctrip.dto.order.OrderFlightResponse;
|
||||
import com.chint.interfaces.rest.ctrip.dto.order.OrderHotelResponse;
|
||||
|
@ -190,6 +191,8 @@ public class CTripOrderRecordAutoSave {
|
|||
//补充额外的字段
|
||||
OrderCarResponse.CarOrderCorpInfo corpInfo = it.getOrderDetail().getCorpInfo();
|
||||
record.setRouteOrderNo(corpInfo.getJouneryId());
|
||||
String orderDate = it.getOrderDetail().getOrderBaseInfo().getOrderDate();
|
||||
record.setOrderDate(DateTimeUtil.timeToStrCommon(DateTimeUtil.strToTime(orderDate)));
|
||||
return record;
|
||||
}).toList();
|
||||
cTripOrderDetailRepository.saveAllCTripCarRecord(list);
|
||||
|
|
Loading…
Reference in New Issue