fix:总订单明细表,高德打车增加目的地和出发地字段

This commit is contained in:
lulz1 2024-05-30 09:21:34 +08:00
parent 57c284fa95
commit 54022987a4
6 changed files with 58 additions and 20 deletions

View File

@ -519,26 +519,28 @@ public class RouteOrder implements Serializable {
public Long matchOrderWithLegId(OrderDetail orderDetail) { public Long matchOrderWithLegId(OrderDetail orderDetail) {
if (this.legItems.isEmpty()) { if (this.legItems == null || this.legItems.isEmpty()) {
return null; return null;
} }
// 定义时间容差例如1天
// Handle taxi legs separately
for (Leg leg : this.legItems) {
if (leg.getLegType().equals(LEG_TYPE_TAXI) && orderDetail.getProductType().equals(LEG_TYPE_TAXI)) {
if (leg.getLegExtensionField() != null && leg.getLegExtensionField().getLocationIdsAsLong() != null) {
if (leg.getLegExtensionField().getLocationIdsAsLong().contains(orderDetail.getOriginId()) ||
leg.getLegExtensionField().getLocationIdsAsLong().contains(orderDetail.getDestinationId())) {
return leg.getLegId();
}
}
}
}
// Define time tolerance (e.g., 2 days)
long tolerance = Duration.ofDays(2).toMillis(); long tolerance = Duration.ofDays(2).toMillis();
List<Leg> potentialMatches = this.legItems.stream() List<Leg> potentialMatches = this.legItems.stream()
.filter(leg -> { .filter(leg -> {
if (leg.getLegType().equals(LEG_TYPE_TAXI) && orderDetail.getProductType().equals(LEG_TYPE_TAXI)) { // Skip taxi legs already handled
if (leg.getLegExtensionField() != null && leg.getLegExtensionField().getLocationIdsAsLong() != null) {
if (leg.getLegExtensionField().getLocationIdsAsLong().contains(orderDetail.getOriginId()) ||
leg.getLegExtensionField().getLocationIdsAsLong().contains(orderDetail.getDestinationId())) {
orderDetail.setLegId(leg.getLegId());
return false;
}
} else {
return false;
}
}
if (leg.getLegType().equals(LEG_TYPE_TAXI)) { if (leg.getLegType().equals(LEG_TYPE_TAXI)) {
return false; return false;
} }
@ -547,14 +549,17 @@ public class RouteOrder implements Serializable {
Location destinationLocation = leg.getDestinationLocation(); Location destinationLocation = leg.getDestinationLocation();
Long orderDetailOriginId = orderDetail.getOriginId(); Long orderDetailOriginId = orderDetail.getOriginId();
Long orderDetailDestinationId = orderDetail.getDestinationId(); Long orderDetailDestinationId = orderDetail.getDestinationId();
return leg.getLegType().equals(orderDetail.getProductType()) &&
(originLocation.getLocationId().equals(orderDetailOriginId) || boolean typeMatches = leg.getLegType().equals(orderDetail.getProductType());
originLocation.getParentLocationId().equals(orderDetailOriginId) || boolean locationMatches = (originLocation.getLocationId().equals(orderDetailOriginId) ||
originLocation.getLocationPath().contains(String.valueOf(orderDetailOriginId))) originLocation.getParentLocationId().equals(orderDetailOriginId) ||
originLocation.getLocationPath().contains(String.valueOf(orderDetailOriginId)))
&& &&
(destinationLocation.getLocationId().equals(orderDetailDestinationId) || (destinationLocation.getLocationId().equals(orderDetailDestinationId) ||
destinationLocation.getParentLocationId().equals(orderDetailDestinationId) || destinationLocation.getParentLocationId().equals(orderDetailDestinationId) ||
destinationLocation.getLocationPath().contains(String.valueOf(orderDetailDestinationId))); destinationLocation.getLocationPath().contains(String.valueOf(orderDetailDestinationId)));
return typeMatches && locationMatches;
}) })
.toList(); .toList();

View File

@ -59,4 +59,5 @@ public interface LocationRepository {
List<Location> findNotChintCityByLevel(String locationNames, Integer level); List<Location> findNotChintCityByLevel(String locationNames, Integer level);
List<Location> findByLocationNameContainingAndIfInternal(String locationName,Integer ifInternal);
} }

View File

@ -40,6 +40,7 @@ public class AmapOrderDataAdapter implements OrderDataAdapter {
@Autowired @Autowired
private AmapOrderDetailRequest orderDetailRequest; private AmapOrderDetailRequest orderDetailRequest;
@Override @Override
public Optional<OrderLegData> adapt(SupplierCallbackData supplierData) { public Optional<OrderLegData> adapt(SupplierCallbackData supplierData) {
AmapOrderDetailResponse amapOrderDetailResponse = (AmapOrderDetailResponse) supplierData.getData(); AmapOrderDetailResponse amapOrderDetailResponse = (AmapOrderDetailResponse) supplierData.getData();
@ -58,6 +59,15 @@ public class AmapOrderDataAdapter implements OrderDataAdapter {
Integer personAmount = data.getPersonAmount(); Integer personAmount = data.getPersonAmount();
price = String.valueOf((enterpriseAmount == null ? 0 : enterpriseAmount) + (personAmount == null ? 0 : personAmount)); price = String.valueOf((enterpriseAmount == null ? 0 : enterpriseAmount) + (personAmount == null ? 0 : personAmount));
} }
Optional<Long> startLocationId = locationRepository
.findByLocationNameContainingAndIfInternal(handlerLocationName(data.getStartCity()), 1).stream().findFirst()
.flatMap(it -> Optional.ofNullable(it.getLocationId()));
Optional<Long> endCityLocationId = locationRepository
.findByLocationNameContainingAndIfInternal(handlerLocationName(data.getEndCity()), 1).stream().findFirst()
.flatMap(it -> Optional.ofNullable(it.getLocationId()));
return Optional.of( return Optional.of(
OrderLegData.builder() OrderLegData.builder()
.productType(LEG_TYPE_TAXI) .productType(LEG_TYPE_TAXI)
@ -75,6 +85,8 @@ public class AmapOrderDataAdapter implements OrderDataAdapter {
.originOrderStatus(supplierData.getOutOrderStatus()) .originOrderStatus(supplierData.getOutOrderStatus())
.destinationName(data.getEndName()) .destinationName(data.getEndName())
.supplierName(SUPPLIER_AMAP) .supplierName(SUPPLIER_AMAP)
.originId(startLocationId.orElse(null))
.originId(endCityLocationId.orElse(null))
.build()); .build());
} }
@ -104,6 +116,17 @@ public class AmapOrderDataAdapter implements OrderDataAdapter {
} }
private String handlerLocationName(String locationName) {
if (locationName == null) {
return null;
}
//如果最后一位是市去掉最后一位
if (locationName.endsWith("")) {
return locationName.substring(0, locationName.length() - 2);
}
return locationName;
}
// AmapOrderDetailResponse response = amapOrderDetailRequest.queryOrderDetail(amapNoteParam.getAmapOrderId()); // AmapOrderDetailResponse response = amapOrderDetailRequest.queryOrderDetail(amapNoteParam.getAmapOrderId());
// AmapOrderDetailResponse.Data data = response.getData(); // AmapOrderDetailResponse.Data data = response.getData();
// //

View File

@ -214,5 +214,10 @@ public class LocationRepositoryImpl implements LocationRepository {
return hotCities; return hotCities;
} }
@Override
public List<Location> findByLocationNameContainingAndIfInternal(String locationName, Integer ifInternal) {
return jdbcLocationRepository.findByLocationNameContainingAndIsInternal(locationName, ifInternal);
}
} }

View File

@ -13,9 +13,11 @@ import java.util.List;
public interface JdbcLocationRepository extends CrudRepository<Location, Long> { public interface JdbcLocationRepository extends CrudRepository<Location, Long> {
Location findByCityIdAndLocationShortName(Long cityId, String locationShortName); Location findByCityIdAndLocationShortName(Long cityId, String locationShortName);
List<Location> findByLocationType(Integer locationType); List<Location> findByLocationType(Integer locationType);
List<Location> findByCityIdAndLocationType(Long cityId, Integer locationType); List<Location> findByCityIdAndLocationType(Long cityId, Integer locationType);
List<Location> findByCityId(Long cityId); List<Location> findByCityId(Long cityId);
Location findByLocationId(Long locationId); Location findByLocationId(Long locationId);
@ -68,4 +70,5 @@ public interface JdbcLocationRepository extends CrudRepository<Location, Long> {
List<Location> findByLevelAndIsInternal(Integer level, Integer isInternal); List<Location> findByLevelAndIsInternal(Integer level, Integer isInternal);
List<Location> findByLocationNameContainingAndIsInternal(String locationName, Integer isInternal);
} }

View File

@ -95,8 +95,9 @@ public class AmapTest {
*/ */
@Test @Test
public void queryorderDetail() { public void queryorderDetail() {
AmapOrderDetailResponse orderDetailResponse = orderDetailRequest.queryOrderDetail("40920084001340019626730137"); Gson gson = new Gson();
System.out.println("orderDetailResponse = " + orderDetailResponse); AmapOrderDetailResponse orderDetailResponse = orderDetailRequest.queryOrderDetail("40184156001340013649231865");
System.out.println(gson.toJson(orderDetailResponse));
} }
/** /**