Commit 88dd69ae2a81134536eaa2b30d2001f2a2deaf67
1 parent
a220cbdd
调整订单位置逻辑,新增根据发收件地址获取机构ID的功能
Showing
1 changed file
with
56 additions
and
6 deletions
sl-express-ms-oms-service/src/main/java/com/sl/ms/oms/service/impl/OrderServiceImpl.java
| @@ -101,13 +101,13 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OrderEntity> impl | @@ -101,13 +101,13 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OrderEntity> impl | ||
| 101 | log.info("订单信息入库:{}", order); | 101 | log.info("订单信息入库:{}", order); |
| 102 | 102 | ||
| 103 | // 订单位置 | 103 | // 订单位置 |
| 104 | - OrderLocationEntity orderLocation = buildOrderLocation(order); | ||
| 105 | - if (StrUtil.isNotEmpty(mailingSaveDTO.getSendLocation())) { | ||
| 106 | - orderLocation.setSendLocation(mailingSaveDTO.getSendLocation()); | ||
| 107 | - } | ||
| 108 | - if (StrUtil.isNotEmpty(mailingSaveDTO.getReceiptLocation())) { | ||
| 109 | - orderLocation.setReceiveLocation(mailingSaveDTO.getReceiptLocation()); | 104 | + OrderLocationEntity orderLocation; |
| 105 | + if (StrUtil.isNotEmpty(mailingSaveDTO.getSendLocation()) && StrUtil.isNotEmpty(mailingSaveDTO.getReceiptLocation())) { | ||
| 106 | + orderLocation = buildOrderLocationWithMall(order, mailingSaveDTO.getSendLocation(), mailingSaveDTO.getReceiptLocation()); | ||
| 107 | + } else { | ||
| 108 | + orderLocation = buildOrderLocation(order); | ||
| 110 | } | 109 | } |
| 110 | + | ||
| 111 | log.info("订单位置为:{}", orderLocation); | 111 | log.info("订单位置为:{}", orderLocation); |
| 112 | 112 | ||
| 113 | // 计算运费 | 113 | // 计算运费 |
| @@ -320,6 +320,27 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OrderEntity> impl | @@ -320,6 +320,27 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OrderEntity> impl | ||
| 320 | } | 320 | } |
| 321 | 321 | ||
| 322 | /** | 322 | /** |
| 323 | + * 根据经纬度计算网点 | ||
| 324 | + * | ||
| 325 | + * @param location 经纬度 | ||
| 326 | + */ | ||
| 327 | + private String getAgencyIdWithMall(String location) throws SLException { | ||
| 328 | + | ||
| 329 | + log.info("地址和坐标-->" + location); | ||
| 330 | + | ||
| 331 | + double lng = Double.parseDouble(location.split(",")[0]); // 经度 | ||
| 332 | + double lat = Double.parseDouble(location.split(",")[1]); // 纬度 | ||
| 333 | + | ||
| 334 | + List<ServiceScopeDTO> serviceScopeDTOS = agencyScopeFeign.queryListByLocation(1, lng, lat); | ||
| 335 | + if (CollectionUtils.isEmpty(serviceScopeDTOS)) { | ||
| 336 | + log.error("地址不在服务范围"); | ||
| 337 | + throw new SLException("地址不在服务范围"); | ||
| 338 | + } | ||
| 339 | + | ||
| 340 | + return String.valueOf(serviceScopeDTOS.get(0).getBid()); | ||
| 341 | + } | ||
| 342 | + | ||
| 343 | + /** | ||
| 323 | * 合并地址 | 344 | * 合并地址 |
| 324 | * | 345 | * |
| 325 | * @param entity 订单 | 346 | * @param entity 订单 |
| @@ -434,6 +455,35 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OrderEntity> impl | @@ -434,6 +455,35 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OrderEntity> impl | ||
| 434 | } | 455 | } |
| 435 | 456 | ||
| 436 | /** | 457 | /** |
| 458 | + * 根据发收件人地址获取起止机构ID 调用机构范围微服务(中瑞商城) | ||
| 459 | + * | ||
| 460 | + * @param order 订单 | ||
| 461 | + * @return 位置信息 | ||
| 462 | + */ | ||
| 463 | + private OrderLocationEntity buildOrderLocationWithMall(OrderEntity order, String sendLocation, String receiveAgentLocation) { | ||
| 464 | + String sendAgentId = getAgencyIdWithMall(sendLocation); | ||
| 465 | + | ||
| 466 | + String receiveAgentId = getAgencyIdWithMall(receiveAgentLocation); | ||
| 467 | + | ||
| 468 | + // 线路规划逻辑耗时较长,影响下单接口响应时间 下单时暂不进行判断是否存在线路 | ||
| 469 | +// if (ObjectUtil.notEqual(sendAgentId, receiveAgentId)) { | ||
| 470 | +// //根据起始机构规划运输路线 | ||
| 471 | +// TransportLineNodeDTO transportLineNodeDTO = this.transportLineFeign.queryPathByDispatchMethod(Long.parseLong(sendAgentId), Long.parseLong(receiveAgentId)); | ||
| 472 | +// if (ObjectUtil.isEmpty(transportLineNodeDTO) || CollUtil.isEmpty(transportLineNodeDTO.getNodeList())) { | ||
| 473 | +// throw new SLException("暂不支持寄件收件地址,没有对应的路线"); | ||
| 474 | +// } | ||
| 475 | +// } | ||
| 476 | + | ||
| 477 | + OrderLocationEntity orderLocationEntity = new OrderLocationEntity(); | ||
| 478 | + orderLocationEntity.setOrderId(order.getId()); | ||
| 479 | + orderLocationEntity.setSendLocation(sendLocation); | ||
| 480 | + orderLocationEntity.setSendAgentId(Long.parseLong(sendAgentId)); | ||
| 481 | + orderLocationEntity.setReceiveLocation(receiveAgentLocation); | ||
| 482 | + orderLocationEntity.setReceiveAgentId(Long.parseLong(receiveAgentId)); | ||
| 483 | + return orderLocationEntity; | ||
| 484 | + } | ||
| 485 | + | ||
| 486 | + /** | ||
| 437 | * 取件 | 487 | * 取件 |
| 438 | * | 488 | * |
| 439 | * @param orderEntity 订单 | 489 | * @param orderEntity 订单 |