Compare commits
No commits in common. "0c7d51fdaa2da7c2a514c1fb859df03e16a58b4a" and "9f6971ca073ffc9bed1cb6becfedf39256644c9b" have entirely different histories.
0c7d51fdaa
...
9f6971ca07
|
@ -115,18 +115,6 @@ public class OrderOutController {
|
||||||
return Result.Success(SUCCESS, orderQuery.queryNotSubmit(queryData));
|
return Result.Success(SUCCESS, orderQuery.queryNotSubmit(queryData));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("查询行程规划订单自定义字段")
|
|
||||||
@PostMapping("/query/custom/fields")
|
|
||||||
public Result<List<ApproveCustomField>> queryLeg(@RequestBody OrderQueryData queryData) {
|
|
||||||
RouteOrder routeOrder = routeRepository
|
|
||||||
.findByActualOrderNoAndSysCode(queryData.getActualOrderNo(), queryData.getSysCode());
|
|
||||||
List<ApproveCustomField> approveCustomFieldList = routeOrder.getRouteCustomExtensionFieldList()
|
|
||||||
.stream()
|
|
||||||
.map(ApproveCustomField::of)
|
|
||||||
.toList();
|
|
||||||
return Result.Success(SUCCESS, approveCustomFieldList);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation("查询能够同步的行程节点")
|
@ApiOperation("查询能够同步的行程节点")
|
||||||
@PostMapping("/query/legs")
|
@PostMapping("/query/legs")
|
||||||
|
@ -135,7 +123,7 @@ public class OrderOutController {
|
||||||
List<LegRes> legResList = legDomainService
|
List<LegRes> legResList = legDomainService
|
||||||
.queryLegsCanSync(routeOrder, queryData.getSupplierName()).stream().map(LegRes::copyFrom).toList();
|
.queryLegsCanSync(routeOrder, queryData.getSupplierName()).stream().map(LegRes::copyFrom).toList();
|
||||||
legResList.forEach(it -> it.setUserName(userRepository.findByUserEmployeeNo(routeOrder.getUserId()).getName()));
|
legResList.forEach(it -> it.setUserName(userRepository.findByUserEmployeeNo(routeOrder.getUserId()).getName()));
|
||||||
legDomainService.getSupplierName(legResList, routeOrder);
|
legDomainService.getSupplierName(legResList,routeOrder);
|
||||||
return Result.Success(SUCCESS, legResList);
|
return Result.Success(SUCCESS, legResList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,15 +20,4 @@ public class RouteCustomExtensionField implements Serializable {
|
||||||
private Long routeOrderKey;
|
private Long routeOrderKey;
|
||||||
private String fieldName;
|
private String fieldName;
|
||||||
private String fieldValue;
|
private String fieldValue;
|
||||||
private String extension;
|
|
||||||
|
|
||||||
private RouteCustomExtensionField(String fieldName, String fieldValue, String extension) {
|
|
||||||
this.fieldName = fieldName;
|
|
||||||
this.fieldValue = fieldValue;
|
|
||||||
this.extension = extension;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static RouteCustomExtensionField of(String fieldName, String fieldValue, String extension) {
|
|
||||||
return new RouteCustomExtensionField(fieldName, fieldValue, extension);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ import com.chint.domain.factoriy.leg.LegFactory;
|
||||||
import com.chint.domain.service.OrderDomainService;
|
import com.chint.domain.service.OrderDomainService;
|
||||||
import com.chint.domain.service.amount_estimate.EstimateAdapter;
|
import com.chint.domain.service.amount_estimate.EstimateAdapter;
|
||||||
import com.chint.domain.service.supplier.SupplierConstantUtil;
|
import com.chint.domain.service.supplier.SupplierConstantUtil;
|
||||||
import com.chint.domain.value_object.ApproveCustomField;
|
|
||||||
import com.chint.domain.value_object.ApproveRouteData;
|
import com.chint.domain.value_object.ApproveRouteData;
|
||||||
import com.chint.domain.value_object.LegData;
|
import com.chint.domain.value_object.LegData;
|
||||||
import com.chint.domain.value_object.OrderSaveData;
|
import com.chint.domain.value_object.OrderSaveData;
|
||||||
|
@ -163,22 +162,6 @@ public class RouteOrder implements Serializable {
|
||||||
parseAndSetTime(data.getStartTime(), true);
|
parseAndSetTime(data.getStartTime(), true);
|
||||||
parseAndSetTime(data.getEndTime(), false);
|
parseAndSetTime(data.getEndTime(), false);
|
||||||
|
|
||||||
List<ApproveCustomField> approveCustomFieldList = data.getApproveCustomFieldList();
|
|
||||||
if (approveCustomFieldList != null && !approveCustomFieldList.isEmpty()) {
|
|
||||||
if (this.getRouteCustomExtensionFieldList() == null) {
|
|
||||||
this.routeCustomExtensionFieldList = new ArrayList<>();
|
|
||||||
}
|
|
||||||
for (ApproveCustomField approveCustomField : approveCustomFieldList) {
|
|
||||||
String fieldName = approveCustomField.getFieldName();
|
|
||||||
String fieldValue = approveCustomField.getFieldValue();
|
|
||||||
Optional<RouteCustomExtensionField> first = this.routeCustomExtensionFieldList
|
|
||||||
.stream()
|
|
||||||
.filter(it -> it.getFieldName().equals(fieldName))
|
|
||||||
.findFirst();
|
|
||||||
first.ifPresentOrElse(it -> it.setFieldValue(fieldValue),
|
|
||||||
() -> this.routeCustomExtensionFieldList.add(RouteCustomExtensionField.of(fieldName, fieldValue, null)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,9 +18,8 @@ import java.io.Serializable;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.function.Function;
|
import static com.chint.infrastructure.constant.SupplierNameConstant.*;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@Table("route_request")
|
@Table("route_request")
|
||||||
|
@ -80,49 +79,13 @@ public class RouteRequest implements Serializable, EventManageable {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RouteRequest loadLegInfoSelf(RouteOrder routeOrder) {
|
|
||||||
if (this.routeRequestLegList != null && !this.routeRequestLegList.isEmpty()) {
|
|
||||||
List<Leg> legItems = routeOrder.getLegItems();
|
|
||||||
List<Long> list = this.routeRequestLegList.stream().map(RouteRequestLeg::getLegId).toList();
|
|
||||||
List<Leg> legs = legItems.stream().filter(it -> list.contains(it.getLegId())).toList();
|
|
||||||
return reloadGenerateRequestLegs(legs);
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public RouteRequest reloadGenerateRequestLegs(List<Leg> legList) {
|
public RouteRequest reloadGenerateRequestLegs(List<Leg> legList) {
|
||||||
// 创建一个新的临时列表
|
List<RouteRequestLeg> routeRequestLegs = legList.stream().map(RouteRequestLeg::ofLeg).toList();
|
||||||
List<RouteRequestLeg> tempLegList = new ArrayList<>();
|
this.setRouteRequestLegList(routeRequestLegs);
|
||||||
|
|
||||||
// 如果原列表为空,则初始化为空列表
|
|
||||||
if (this.routeRequestLegList == null) {
|
|
||||||
this.routeRequestLegList = new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 创建一个Map从legId到RouteRequestLeg进行快速查找
|
|
||||||
Map<Long, RouteRequestLeg> existingLegsMap = this.routeRequestLegList.stream()
|
|
||||||
.collect(Collectors.toMap(RouteRequestLeg::getLegId, Function.identity()));
|
|
||||||
|
|
||||||
// 遍历传入的leg列表
|
|
||||||
for (Leg leg : legList) {
|
|
||||||
RouteRequestLeg existingLeg = existingLegsMap.get(leg.getLegId());
|
|
||||||
if (existingLeg != null) {
|
|
||||||
// 如果leg已存在,更新非持久化的'leg'字段
|
|
||||||
existingLeg.setLeg(leg);
|
|
||||||
} else {
|
|
||||||
// 如果是新的leg,创建一个新的RouteRequestLeg
|
|
||||||
existingLeg = RouteRequestLeg.ofLeg(leg);
|
|
||||||
}
|
|
||||||
// 将更新或新创建的RouteRequestLeg添加到临时列表中
|
|
||||||
tempLegList.add(existingLeg);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 使用新的临时列表替换旧的leg列表
|
|
||||||
this.routeRequestLegList = tempLegList;
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RouteRequest reloadSupplierInfo() {
|
public RouteRequest reloadSupplierInfo(){
|
||||||
this.setSupplierName(SupplierConstantUtil.translateOrderSupplierName(this.supplier));
|
this.setSupplierName(SupplierConstantUtil.translateOrderSupplierName(this.supplier));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
package com.chint.domain.aggregates.supplier;
|
|
||||||
|
|
||||||
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.io.Serial;
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@Table("supplier")
|
|
||||||
public class Supplier implements Serializable {
|
|
||||||
@Serial
|
|
||||||
private static final long serialVersionUID = 987635285619453614L;
|
|
||||||
@Id
|
|
||||||
private Long id;
|
|
||||||
private String name;
|
|
||||||
private String cnName;
|
|
||||||
@MappedCollection(idColumn = "supplier_id", keyColumn = "supplier_key")
|
|
||||||
private List<SupplierProduct> supplierProductList;
|
|
||||||
}
|
|
|
@ -1,23 +0,0 @@
|
||||||
package com.chint.domain.aggregates.supplier;
|
|
||||||
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import org.springframework.data.annotation.Id;
|
|
||||||
import org.springframework.data.relational.core.mapping.Table;
|
|
||||||
|
|
||||||
import java.io.Serial;
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@Table("supplier_product")
|
|
||||||
public class SupplierProduct implements Serializable {
|
|
||||||
@Serial
|
|
||||||
private static final long serialVersionUID = 1296764923629924614L;
|
|
||||||
@Id
|
|
||||||
private Long id;
|
|
||||||
private Long supplierId;
|
|
||||||
private Long supplierKey;
|
|
||||||
private Integer productType;
|
|
||||||
private Integer ifCanOrder;
|
|
||||||
private String ifCanCancelRule;
|
|
||||||
}
|
|
|
@ -160,20 +160,16 @@ public class LYOrderDetailRecordFactory {
|
||||||
|
|
||||||
private String translateEnSeatToCnSeat(String seatEnName) {
|
private String translateEnSeatToCnSeat(String seatEnName) {
|
||||||
return switch (seatEnName) {
|
return switch (seatEnName) {
|
||||||
case "businessseat" -> "商务座";
|
|
||||||
case "firstseat" -> "一等座";
|
|
||||||
case "secondseat" -> "二等座";
|
case "secondseat" -> "二等座";
|
||||||
|
case "businessseat" -> "商务座";
|
||||||
|
case "hardseat" -> "二等座";
|
||||||
case "softsleeperup" -> "软卧上铺";
|
case "softsleeperup" -> "软卧上铺";
|
||||||
case "hardsleeperup" -> "硬卧上铺";
|
case "hardsleeperup" -> "硬卧上铺";
|
||||||
case "dsleeperup" -> "动卧上铺";
|
case "firstseat" -> "一等座";
|
||||||
case "softsleepermid" -> "软卧中铺";
|
|
||||||
case "hardsleepermid" -> "硬卧中铺";
|
|
||||||
case "dsleepermid" -> "动卧中铺";
|
|
||||||
case "softsleeperdown" -> "软卧下铺";
|
case "softsleeperdown" -> "软卧下铺";
|
||||||
case "hardsleeperdown" -> "硬卧下铺";
|
case "hardsleeperdown" -> "硬卧下铺";
|
||||||
case "dsleeperdown" -> "动卧下铺";
|
case "softsleepermid" -> "软卧中铺";
|
||||||
case "hardseat" -> "硬座";
|
case "hardsleepermid" -> "硬卧中铺";
|
||||||
case "noseat" -> "无座";
|
|
||||||
default -> "未知类型座位";
|
default -> "未知类型座位";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -371,7 +371,6 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
|
||||||
//设置出发地和到达地
|
//设置出发地和到达地
|
||||||
roadTripName(orderTrainRecord, lyOrderTrainRecord.getTripName());
|
roadTripName(orderTrainRecord, lyOrderTrainRecord.getTripName());
|
||||||
orderTrainRecord.setIssueTicketTime(lyOrderTrainRecord.getEnterAccount()) //出票时间 yyyy-MM-dd HH:mm:ss
|
orderTrainRecord.setIssueTicketTime(lyOrderTrainRecord.getEnterAccount()) //出票时间 yyyy-MM-dd HH:mm:ss
|
||||||
.setSeatType(lyOrderTrainRecord.getSeatClass())//座位等级
|
|
||||||
.setTrainNo(lyOrderTrainRecord.getTrainNo()) //车次
|
.setTrainNo(lyOrderTrainRecord.getTrainNo()) //车次
|
||||||
.setUserCode(lyOrderTrainRecord.getPassengerNo())//出行人编码
|
.setUserCode(lyOrderTrainRecord.getPassengerNo())//出行人编码
|
||||||
.setUserName(lyOrderTrainRecord.getPassengerName())//出行人姓名
|
.setUserName(lyOrderTrainRecord.getPassengerName())//出行人姓名
|
||||||
|
@ -408,8 +407,7 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
|
||||||
if (!Objects.isNull(trainOrderDetail)) {
|
if (!Objects.isNull(trainOrderDetail)) {
|
||||||
orderTrainRecord.setParentOrderNo(trainOrderDetail.getParentOrderNo())//父级订单号
|
orderTrainRecord.setParentOrderNo(trainOrderDetail.getParentOrderNo())//父级订单号
|
||||||
.setRunTime(lyOrderDetailRecordFactory.getRunTime(trainOrderDetail.getStartTime(), trainOrderDetail.getArriveTime()))//时长
|
.setRunTime(lyOrderDetailRecordFactory.getRunTime(trainOrderDetail.getStartTime(), trainOrderDetail.getArriveTime()))//时长
|
||||||
.setSeatType(Optional.ofNullable(orderTrainRecord.getSeatType())
|
.setSeatType(trainOrderDetail.getSeatType())// 座位等级
|
||||||
.orElse(trainOrderDetail.getSeatType()))//座位等级
|
|
||||||
.setFromCity(trainOrderDetail.getFromCity()) //出发城市
|
.setFromCity(trainOrderDetail.getFromCity()) //出发城市
|
||||||
.setToCity(trainOrderDetail.getToCity()) //到达城市
|
.setToCity(trainOrderDetail.getToCity()) //到达城市
|
||||||
.setFromStationName(Optional.ofNullable(orderTrainRecord.getFromStationName())
|
.setFromStationName(Optional.ofNullable(orderTrainRecord.getFromStationName())
|
||||||
|
@ -420,11 +418,10 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
|
||||||
} else {
|
} else {
|
||||||
LyOrderDetailTrainRecord lyOrderDetailTrainRecord = lyOrderDetailRecordFactory.queryTrainDetail(orderSerialNo);
|
LyOrderDetailTrainRecord lyOrderDetailTrainRecord = lyOrderDetailRecordFactory.queryTrainDetail(orderSerialNo);
|
||||||
orderTrainRecord.setParentOrderNo(lyOrderDetailTrainRecord.getParentOrderNo())//父级订单号
|
orderTrainRecord.setParentOrderNo(lyOrderDetailTrainRecord.getParentOrderNo())//父级订单号
|
||||||
.setRunTime(lyOrderDetailTrainRecord.getRunTime())//时长
|
.setRunTime(lyOrderDetailTrainRecord.getRunTime()) //时长
|
||||||
.setSeatType(Optional.ofNullable(orderTrainRecord.getSeatType())
|
.setSeatType(lyOrderDetailTrainRecord.getSeatType())// 座位等级
|
||||||
.orElse(lyOrderDetailTrainRecord.getSeatType()))//座位等级
|
.setFromCity(lyOrderDetailTrainRecord.getFromCity()) //出发城市
|
||||||
.setFromCity(lyOrderDetailTrainRecord.getFromCity())//出发城市
|
.setToCity(lyOrderDetailTrainRecord.getToCity()) //到达城市
|
||||||
.setToCity(lyOrderDetailTrainRecord.getToCity())//到达城市
|
|
||||||
.setFromStationName(Optional.ofNullable(orderTrainRecord.getFromStationName())
|
.setFromStationName(Optional.ofNullable(orderTrainRecord.getFromStationName())
|
||||||
.orElse(lyOrderDetailTrainRecord.getFromStationName())) // 出发站
|
.orElse(lyOrderDetailTrainRecord.getFromStationName())) // 出发站
|
||||||
.setToStationName(Optional.ofNullable(orderTrainRecord.getToStationName())
|
.setToStationName(Optional.ofNullable(orderTrainRecord.getToStationName())
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
package com.chint.domain.repository;
|
|
||||||
|
|
||||||
import com.chint.domain.aggregates.supplier.Supplier;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
public interface SupplierRepository {
|
|
||||||
Supplier save(Supplier supplier);
|
|
||||||
Optional<Supplier> findById(Long id);
|
|
||||||
Optional<Supplier> findBySupplierName(String supplierName);
|
|
||||||
}
|
|
|
@ -2,17 +2,17 @@ package com.chint.domain.service;
|
||||||
|
|
||||||
import com.chint.application.dtos.response.LegRes;
|
import com.chint.application.dtos.response.LegRes;
|
||||||
import com.chint.domain.aggregates.order.*;
|
import com.chint.domain.aggregates.order.*;
|
||||||
import com.chint.domain.aggregates.supplier.Supplier;
|
|
||||||
import com.chint.domain.aggregates.supplier.SupplierProduct;
|
|
||||||
import com.chint.domain.exceptions.LegEventException;
|
import com.chint.domain.exceptions.LegEventException;
|
||||||
import com.chint.domain.factoriy.leg_event.LegEventFactory;
|
import com.chint.domain.factoriy.leg_event.LegEventFactory;
|
||||||
import com.chint.domain.repository.*;
|
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 org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
import static com.chint.infrastructure.constant.CommonMessageConstant.LEG_CHANGE_MAX_ERROR;
|
import static com.chint.infrastructure.constant.CommonMessageConstant.LEG_CHANGE_MAX_ERROR;
|
||||||
import static com.chint.infrastructure.constant.LegConstant.*;
|
import static com.chint.infrastructure.constant.LegConstant.*;
|
||||||
|
@ -41,13 +41,6 @@ public class LegDomainService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private OrderDomainService orderDomainService;
|
private OrderDomainService orderDomainService;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SupplierRepository supplierRepository;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SupplierDomainService supplierDomainService;
|
|
||||||
|
|
||||||
|
|
||||||
public Leg legCheckOrder(Leg leg) {
|
public Leg legCheckOrder(Leg leg) {
|
||||||
List<OrderDetail> orderDetailList = orderDetailRepository.findByLegId(leg.getLegId());
|
List<OrderDetail> orderDetailList = orderDetailRepository.findByLegId(leg.getLegId());
|
||||||
orderDetailList.forEach(OrderDetail::reloadStatus);
|
orderDetailList.forEach(OrderDetail::reloadStatus);
|
||||||
|
@ -168,8 +161,9 @@ public class LegDomainService {
|
||||||
List<Leg> legItems = routeOrder.getLegItems();
|
List<Leg> legItems = routeOrder.getLegItems();
|
||||||
legItems = legItems.stream().filter(it -> !it.getLegType().equals(LEG_TYPE_OTHER)).toList();
|
legItems = legItems.stream().filter(it -> !it.getLegType().equals(LEG_TYPE_OTHER)).toList();
|
||||||
|
|
||||||
//通过查看供应商的商品类型,来进行同步
|
// if (supplierName.equals("CTrip")) {
|
||||||
legItems = supplierDomainService.ifCanSync(legItems, supplierName);
|
// legItems = legItems.stream().filter(it -> !it.getLegType().equals(LEG_TYPE_TRAIN)).toList();
|
||||||
|
// }
|
||||||
|
|
||||||
List<Long> alreadySyncLegs = routeOrder.getRouteRequestList()
|
List<Long> alreadySyncLegs = routeOrder.getRouteRequestList()
|
||||||
.stream()
|
.stream()
|
||||||
|
|
|
@ -1,24 +1,19 @@
|
||||||
package com.chint.domain.service;
|
package com.chint.domain.service;
|
||||||
|
|
||||||
import com.chint.domain.aggregates.order.*;
|
import com.chint.domain.aggregates.order.*;
|
||||||
import com.chint.domain.aggregates.supplier.Supplier;
|
|
||||||
import com.chint.domain.aggregates.supplier.SupplierProduct;
|
|
||||||
import com.chint.domain.exceptions.CommandException;
|
import com.chint.domain.exceptions.CommandException;
|
||||||
import com.chint.domain.factoriy.leg_event.LegEventFactory;
|
import com.chint.domain.factoriy.leg_event.LegEventFactory;
|
||||||
import com.chint.domain.factoriy.order.RouteOrderFactory;
|
import com.chint.domain.factoriy.order.RouteOrderFactory;
|
||||||
import com.chint.domain.repository.LegRepository;
|
import com.chint.domain.repository.LegRepository;
|
||||||
import com.chint.domain.repository.RouteRepository;
|
import com.chint.domain.repository.RouteRepository;
|
||||||
import com.chint.domain.repository.RouteRequestRepository;
|
import com.chint.domain.repository.RouteRequestRepository;
|
||||||
import com.chint.domain.repository.SupplierRepository;
|
|
||||||
import com.chint.domain.service.order_sync.SyncAdapter;
|
import com.chint.domain.service.order_sync.SyncAdapter;
|
||||||
import com.chint.domain.value_object.SyncLegData;
|
import com.chint.domain.value_object.SyncLegData;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import static com.chint.infrastructure.constant.LegConstant.*;
|
import static com.chint.infrastructure.constant.LegConstant.*;
|
||||||
import static com.chint.infrastructure.constant.RouteRequestConstant.ROUTE_REQUEST_STATUS_PREPARE;
|
import static com.chint.infrastructure.constant.RouteRequestConstant.ROUTE_REQUEST_STATUS_PREPARE;
|
||||||
|
@ -47,12 +42,6 @@ public class RouteRequestDomainService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private LegEventFactory legEventFactory;
|
private LegEventFactory legEventFactory;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SupplierRepository supplierRepository;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SupplierDomainService supplierDomainService;
|
|
||||||
|
|
||||||
|
|
||||||
// //这里增加一个判断 ,如果这个订单的行程为空,那么就返回给用户提示
|
// //这里增加一个判断 ,如果这个订单的行程为空,那么就返回给用户提示
|
||||||
// if (legItems == null || legItems.isEmpty()) {
|
// if (legItems == null || legItems.isEmpty()) {
|
||||||
|
@ -107,7 +96,6 @@ public class RouteRequestDomainService {
|
||||||
return routeRequest;
|
return routeRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void cancelRouteRequest(SyncLegData syncLegData) {
|
public void cancelRouteRequest(SyncLegData syncLegData) {
|
||||||
Long routeId = syncLegData.getRouteId();
|
Long routeId = syncLegData.getRouteId();
|
||||||
RouteOrder routeOrder = routeRepository.queryById(routeId);
|
RouteOrder routeOrder = routeRepository.queryById(routeId);
|
||||||
|
@ -126,63 +114,11 @@ public class RouteRequestDomainService {
|
||||||
.findFirst();
|
.findFirst();
|
||||||
}
|
}
|
||||||
optionalRouteRequest.ifPresent(it -> {
|
optionalRouteRequest.ifPresent(it -> {
|
||||||
//这里的逻辑为发现 差旅申请单的机票行程节点 如果已经是 下单的状态, 就不进行取消, 因此实际上按照 该差旅申请单的 同步来进行
|
|
||||||
List<Leg> legs = it.loadLegInfoSelf(routeOrder)
|
|
||||||
.getRouteRequestLegList()
|
|
||||||
.stream()
|
|
||||||
.map(RouteRequestLeg::getLeg)
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
Optional<Supplier> supplierOptional = supplierRepository.findBySupplierName(it.getSupplier());
|
|
||||||
Map<Boolean, List<Leg>> collect;
|
|
||||||
if (supplierOptional.isPresent()) {
|
|
||||||
collect = legs
|
|
||||||
.stream()
|
|
||||||
.collect(Collectors.partitioningBy(leg -> supplierDomainService.ifCanCancel(leg,it.getSupplier())));
|
|
||||||
List<Leg> orderedLegs = collect.get(false);
|
|
||||||
if (!orderedLegs.isEmpty()) {
|
|
||||||
it.reloadGenerateRequestLegs(orderedLegs);
|
|
||||||
syncAdapter.of(it.getSupplier()).syncRouteRequest(it);
|
|
||||||
it.addEvent(RouteRequestEvent.sync(it.getSupplier()));
|
|
||||||
List<Leg> notOrderLegs = collect.get(true);
|
|
||||||
notOrderLegs.forEach(leg -> leg.addEvent(legEventFactory.creatLegEvent(LEG_EVENT_APPROVAL)));
|
|
||||||
} else {
|
|
||||||
it.addEvent(RouteRequestEvent.cancel(it.getSupplier()));
|
it.addEvent(RouteRequestEvent.cancel(it.getSupplier()));
|
||||||
getLegInfoFromRouteOrder(it, routeOrder);
|
getLegInfoFromRouteOrder(it, routeOrder);
|
||||||
syncAdapter.of(it.getSupplier()).cancelRouteRequest(it);
|
syncAdapter.of(it.getSupplier()).cancelRouteRequest(it);
|
||||||
it.getRouteRequestLegList()
|
it.getRouteRequestLegList()
|
||||||
.forEach(requestLeg -> requestLeg.getLeg().addEvent(legEventFactory.creatLegEvent(LEG_EVENT_APPROVAL)));
|
.forEach(requestLeg -> requestLeg.getLeg().addEvent(legEventFactory.creatLegEvent(LEG_EVENT_APPROVAL)));
|
||||||
}
|
|
||||||
} else {
|
|
||||||
it.addEvent(RouteRequestEvent.cancel(it.getSupplier()));
|
|
||||||
getLegInfoFromRouteOrder(it, routeOrder);
|
|
||||||
syncAdapter.of(it.getSupplier()).cancelRouteRequest(it);
|
|
||||||
it.getRouteRequestLegList()
|
|
||||||
.forEach(requestLeg -> requestLeg.getLeg().addEvent(legEventFactory.creatLegEvent(LEG_EVENT_APPROVAL)));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Map<Boolean, List<Leg>> collect = legs
|
|
||||||
// .stream()
|
|
||||||
// .collect(Collectors.partitioningBy(leg -> {
|
|
||||||
// Integer legStatus = leg.reloadStatus().getLegStatus();
|
|
||||||
// return (legStatus.equals(LEG_STATUS_ORDERED) || legStatus.equals(LEG_STATUS_PAYED) || legStatus.equals(LEG_STATUS_FINISH))
|
|
||||||
// && leg.getLegType().equals(LEG_TYPE_AIRPLANE);
|
|
||||||
// }));
|
|
||||||
|
|
||||||
// List<Leg> orderedLegs = collect.get(true);
|
|
||||||
// if (!orderedLegs.isEmpty()) {
|
|
||||||
// it.reloadGenerateRequestLegs(orderedLegs);
|
|
||||||
// syncAdapter.of(it.getSupplier()).syncRouteRequest(it);
|
|
||||||
// it.addEvent(RouteRequestEvent.sync(it.getSupplier()));
|
|
||||||
// List<Leg> notOrderLegs = collect.get(false);
|
|
||||||
// notOrderLegs.forEach(leg -> leg.addEvent(legEventFactory.creatLegEvent(LEG_EVENT_APPROVAL)));
|
|
||||||
// } else {
|
|
||||||
// it.addEvent(RouteRequestEvent.cancel(it.getSupplier()));
|
|
||||||
// getLegInfoFromRouteOrder(it, routeOrder);
|
|
||||||
// syncAdapter.of(it.getSupplier()).cancelRouteRequest(it);
|
|
||||||
// it.getRouteRequestLegList()
|
|
||||||
// .forEach(requestLeg -> requestLeg.getLeg().addEvent(legEventFactory.creatLegEvent(LEG_EVENT_APPROVAL)));
|
|
||||||
// }
|
|
||||||
});
|
});
|
||||||
routeRepository.save(routeOrder);
|
routeRepository.save(routeOrder);
|
||||||
}
|
}
|
||||||
|
@ -203,6 +139,7 @@ public class RouteRequestDomainService {
|
||||||
return optionalRouteRequest
|
return optionalRouteRequest
|
||||||
.orElseGet(() -> routeOrderFactory.createRequestWithLeg(routeOrder, legIds, supplier)).reloadStatus();
|
.orElseGet(() -> routeOrderFactory.createRequestWithLeg(routeOrder, legIds, supplier)).reloadStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取目前已经同步到供应商的差旅申请单
|
//获取目前已经同步到供应商的差旅申请单
|
||||||
|
@ -219,7 +156,6 @@ public class RouteRequestDomainService {
|
||||||
return routeRequest.reloadGenerateRequestLegs(legItems);
|
return routeRequest.reloadGenerateRequestLegs(legItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private RouteRequest getLegInfoFromRouteOrder(RouteRequest routeRequest, RouteOrder routeOrder) {
|
private RouteRequest getLegInfoFromRouteOrder(RouteRequest routeRequest, RouteOrder routeOrder) {
|
||||||
List<Leg> legItems = routeOrder.getLegItems();
|
List<Leg> legItems = routeOrder.getLegItems();
|
||||||
routeRequest.getRouteRequestLegList().forEach(it -> {
|
routeRequest.getRouteRequestLegList().forEach(it -> {
|
||||||
|
|
|
@ -1,54 +0,0 @@
|
||||||
package com.chint.domain.service;
|
|
||||||
|
|
||||||
import com.chint.domain.aggregates.order.Leg;
|
|
||||||
import com.chint.domain.aggregates.supplier.Supplier;
|
|
||||||
import com.chint.domain.aggregates.supplier.SupplierProduct;
|
|
||||||
import com.chint.domain.repository.SupplierRepository;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class SupplierDomainService {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SupplierRepository supplierRepository;
|
|
||||||
|
|
||||||
public boolean ifCanCancel(Leg leg, String supplierName) {
|
|
||||||
Optional<Supplier> supplierOptional = supplierRepository.findBySupplierName(supplierName);
|
|
||||||
if (supplierOptional.isPresent()) {
|
|
||||||
Supplier supplier = supplierOptional.get();
|
|
||||||
List<SupplierProduct> supplierProductList = supplier.getSupplierProductList();
|
|
||||||
for (SupplierProduct product : supplierProductList) {
|
|
||||||
if (product.getProductType().equals(leg.getLegType())) {
|
|
||||||
String ifCanCancelRule = product.getIfCanCancelRule();
|
|
||||||
String[] split = ifCanCancelRule.split(",");
|
|
||||||
for (String status : split) {
|
|
||||||
if (status.equals(String.valueOf(leg.getLegStatus()))) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Leg> ifCanSync(List<Leg> legs, String supplierName) {
|
|
||||||
Optional<Supplier> supplierOptional = supplierRepository.findBySupplierName(supplierName);
|
|
||||||
if (supplierOptional.isPresent()) {
|
|
||||||
Supplier supplier = supplierOptional.get();
|
|
||||||
List<Integer> productTypes = supplier
|
|
||||||
.getSupplierProductList()
|
|
||||||
.stream()
|
|
||||||
.filter(it->it.getIfCanOrder().equals(1))
|
|
||||||
.map(SupplierProduct::getProductType)
|
|
||||||
.toList();
|
|
||||||
return legs.stream().filter(it -> productTypes.contains(it.getLegType())).toList();
|
|
||||||
} else {
|
|
||||||
return legs;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,18 +0,0 @@
|
||||||
package com.chint.domain.value_object;
|
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
|
||||||
import com.chint.domain.aggregates.order.RouteCustomExtensionField;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class ApproveCustomField {
|
|
||||||
@ApiModelProperty("自定义字段名")
|
|
||||||
private String fieldName;
|
|
||||||
@ApiModelProperty("自定义字段值")
|
|
||||||
private String fieldValue;
|
|
||||||
|
|
||||||
public static ApproveCustomField of(RouteCustomExtensionField routeCustomExtensionField) {
|
|
||||||
return BeanUtil.copyProperties(routeCustomExtensionField, ApproveCustomField.class);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -31,9 +31,13 @@ public class ApproveRouteData {
|
||||||
private String startTime;
|
private String startTime;
|
||||||
@ApiModelProperty("结束时间")
|
@ApiModelProperty("结束时间")
|
||||||
private String endTime;
|
private String endTime;
|
||||||
@ApiModelProperty("自定义字段")
|
@ApiModelProperty("结束时间")
|
||||||
private List<ApproveCustomField> approveCustomFieldList;
|
private List<ApproveCustomField> approveCustomFieldList;
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
private static class ApproveCustomField{
|
||||||
|
private String fieldName;
|
||||||
|
private String fieldValue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,6 @@ public class OrderQueryData extends BaseQuery {
|
||||||
@ApiModelProperty("需要同步的行程规划单ID")
|
@ApiModelProperty("需要同步的行程规划单ID")
|
||||||
private Long routeId;
|
private Long routeId;
|
||||||
private String billcode;
|
private String billcode;
|
||||||
private String actualOrderNo;
|
|
||||||
private String sysCode;
|
private String sysCode;
|
||||||
private List<Integer> approvalStatusCodes;
|
private List<Integer> approvalStatusCodes;
|
||||||
private List<Integer> legTypes;
|
private List<Integer> legTypes;
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
package com.chint.infrastructure.repository;
|
|
||||||
|
|
||||||
import com.chint.domain.aggregates.supplier.Supplier;
|
|
||||||
import com.chint.domain.repository.SupplierRepository;
|
|
||||||
import com.chint.infrastructure.repository.jdbc.JdbcSupplierRepository;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
|
||||||
import org.springframework.stereotype.Repository;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
@Repository
|
|
||||||
public class SupplierRepositoryImpl implements SupplierRepository {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private JdbcSupplierRepository jdbcSupplierRepository;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Supplier save(Supplier supplier) {
|
|
||||||
return jdbcSupplierRepository.save(supplier);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<Supplier> findById(Long id) {
|
|
||||||
return jdbcSupplierRepository.findById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Cacheable(value = "supplier", key = "#supplierName")
|
|
||||||
@Override
|
|
||||||
public Optional<Supplier> findBySupplierName(String supplierName) {
|
|
||||||
return jdbcSupplierRepository.findByName(supplierName);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
package com.chint.infrastructure.repository.jdbc;
|
|
||||||
|
|
||||||
import com.chint.domain.aggregates.supplier.Supplier;
|
|
||||||
import com.chint.domain.aggregates.system.SupplierCallBackLog;
|
|
||||||
import org.springframework.data.repository.CrudRepository;
|
|
||||||
import org.springframework.stereotype.Repository;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
@Repository
|
|
||||||
public interface JdbcSupplierRepository extends CrudRepository<Supplier,Long> {
|
|
||||||
Optional<Supplier> findByName(String name);
|
|
||||||
}
|
|
|
@ -77,8 +77,8 @@ feishu:
|
||||||
appSecret: fCM2Y15linSjCOeJrIsZQdiW4ufjMFop
|
appSecret: fCM2Y15linSjCOeJrIsZQdiW4ufjMFop
|
||||||
base-url: https://open.feishu.cn
|
base-url: https://open.feishu.cn
|
||||||
#安能
|
#安能
|
||||||
ANAppId: cli_a69d262cb965500b
|
ANAppId: cli_a5739e17577d100b
|
||||||
ANAppSecret: RN2WkwCbANj7joD6NHEeibkCtVIoBZuC
|
ANAppSecret: sNk8C7tf6wI1PcMNdyqjAcWK3m3Wp7dO
|
||||||
|
|
||||||
bpm:
|
bpm:
|
||||||
#集团H3
|
#集团H3
|
||||||
|
|
|
@ -945,7 +945,7 @@ public class LYTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// @Test
|
@Test
|
||||||
void queryFlightDetail() {
|
void queryFlightDetail() {
|
||||||
LyOrderDetailFlightRecord lyOrderDetailFlightRecord = new LyOrderDetailFlightRecord();//创建对象
|
LyOrderDetailFlightRecord lyOrderDetailFlightRecord = new LyOrderDetailFlightRecord();//创建对象
|
||||||
//订单明细数据
|
//订单明细数据
|
||||||
|
@ -974,7 +974,7 @@ public class LYTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Test
|
@Test
|
||||||
void queryHotelDetail() {
|
void queryHotelDetail() {
|
||||||
LyOrderDetailHotelRecord lyOrderDetailHotelRecord = new LyOrderDetailHotelRecord();
|
LyOrderDetailHotelRecord lyOrderDetailHotelRecord = new LyOrderDetailHotelRecord();
|
||||||
HotelDetailResponse hotelOrderDetail = lySearchRequest.getHotelOrderDetail("HO20240308154500794121");
|
HotelDetailResponse hotelOrderDetail = lySearchRequest.getHotelOrderDetail("HO20240308154500794121");
|
||||||
|
@ -995,10 +995,10 @@ public class LYTest {
|
||||||
System.out.println(gson.toJson(lyOrderDetailHotelRecord));
|
System.out.println(gson.toJson(lyOrderDetailHotelRecord));
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Test
|
@Test
|
||||||
void queryTrainDetail() {
|
void queryTrainDetail() {
|
||||||
LyOrderDetailTrainRecord lyOrderDetailTrainRecord = new LyOrderDetailTrainRecord();
|
LyOrderDetailTrainRecord lyOrderDetailTrainRecord = new LyOrderDetailTrainRecord();
|
||||||
TrainDetailResponse trainOrderDetail = lySearchRequest.getTrainOrderDetail("DT24032768242432787");//DT24032768242432787
|
TrainDetailResponse trainOrderDetail = lySearchRequest.getTrainOrderDetail("DT24031266448572670");
|
||||||
TrainDetailResponse.TrainDetailData trainDetailData = trainOrderDetail.getData();
|
TrainDetailResponse.TrainDetailData trainDetailData = trainOrderDetail.getData();
|
||||||
if (trainDetailData == null) {
|
if (trainDetailData == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -1024,7 +1024,7 @@ public class LYTest {
|
||||||
return switch (seatEnName) {
|
return switch (seatEnName) {
|
||||||
case "secondseat" -> "二等座";
|
case "secondseat" -> "二等座";
|
||||||
case "businessseat" -> "商务座";
|
case "businessseat" -> "商务座";
|
||||||
case "hardseat" -> "硬座";
|
case "hardseat" -> "二等座";
|
||||||
case "softsleeperup" -> "软卧上铺";
|
case "softsleeperup" -> "软卧上铺";
|
||||||
case "hardsleeperup" -> "硬卧上铺";
|
case "hardsleeperup" -> "硬卧上铺";
|
||||||
case "firstseat" -> "一等座";
|
case "firstseat" -> "一等座";
|
||||||
|
@ -1037,7 +1037,7 @@ public class LYTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// @Test
|
@Test
|
||||||
void queryCarDetail() {
|
void queryCarDetail() {
|
||||||
LyOrderDetailCarRecord lyOrderDetailCarRecord = new LyOrderDetailCarRecord();
|
LyOrderDetailCarRecord lyOrderDetailCarRecord = new LyOrderDetailCarRecord();
|
||||||
CarDetailResponse carDetailResponse = lySearchRequest.getCarDetailResponse("DC24031466726324898");
|
CarDetailResponse carDetailResponse = lySearchRequest.getCarDetailResponse("DC24031466726324898");
|
||||||
|
@ -1078,7 +1078,7 @@ public class LYTest {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private JdbcLyOrderDetailFlightRecord jdbcLyOrderDetailFlightRecord;
|
private JdbcLyOrderDetailFlightRecord jdbcLyOrderDetailFlightRecord;
|
||||||
// @Test
|
@Test
|
||||||
public void dasfag() {
|
public void dasfag() {
|
||||||
LyOrderDetailFlightRecord orderDetail = jdbcLyOrderDetailFlightRecord.findByOrderNo("123");
|
LyOrderDetailFlightRecord orderDetail = jdbcLyOrderDetailFlightRecord.findByOrderNo("123");
|
||||||
if (orderDetail != null) {
|
if (orderDetail != null) {
|
||||||
|
|
|
@ -265,7 +265,7 @@ class RouteApplicationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void loginSign() {
|
void loginSign() {
|
||||||
String sfno = "240412063";
|
String sfno = "200529132";
|
||||||
String syscode = "FSSC";
|
String syscode = "FSSC";
|
||||||
String billcode = "CLSQ240225000099";
|
String billcode = "CLSQ240225000099";
|
||||||
String companycode = "正泰集团股份有限公司";
|
String companycode = "正泰集团股份有限公司";
|
||||||
|
@ -280,7 +280,7 @@ class RouteApplicationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void loginSignProd() {
|
void loginSignProd() {
|
||||||
String sfno = "240412063";
|
String sfno = "200529132";
|
||||||
String syscode = "FSSC";
|
String syscode = "FSSC";
|
||||||
String billcode = "CLSQ240225000099";
|
String billcode = "CLSQ240225000099";
|
||||||
String companycode = "正泰集团股份有限公司";
|
String companycode = "正泰集团股份有限公司";
|
||||||
|
|
Loading…
Reference in New Issue