From d4e4207ae9e10797cbd8128368d7c2e217970d44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A2=E8=B6=8A?= <552369664@qq.com> Date: Sun, 25 Aug 2024 08:39:44 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E3=80=91=E5=AF=B9customerName=E5=86=85=E9=83=A8=E5=B1=8F?= =?UTF-8?q?=E8=94=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/dto/ExpressTrackQueryReqDTO.java | 20 ++++++++++++++++++- .../order/TradeOrderQueryServiceImpl.java | 13 +++++++----- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/ExpressTrackQueryReqDTO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/ExpressTrackQueryReqDTO.java index 16662d89d..b9fe1bd18 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/ExpressTrackQueryReqDTO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/ExpressTrackQueryReqDTO.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto; +import cn.hutool.core.util.StrUtil; import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; import lombok.Data; @@ -13,7 +14,7 @@ public class ExpressTrackQueryReqDTO { /** * 快递公司编码 - * + *

* 对应 {@link DeliveryExpressDO#getCode()} */ private String expressCode; @@ -33,4 +34,21 @@ public class ExpressTrackQueryReqDTO { */ private String customerName; + public ExpressTrackQueryReqDTO setExpressCode(String expressCode) { + this.expressCode = expressCode; + updateCustomerName(); + return this; // 返回实体对象 + } + + public ExpressTrackQueryReqDTO setPhone(String phone) { + this.phone = phone; + updateCustomerName(); + return this; // 返回实体对象 + } + + private void updateCustomerName() { + if ("SF".equals(expressCode) && phone != null && phone.length() >= 4) { + this.customerName = phone.substring(phone.length() - 4); + } + } } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryServiceImpl.java index 350156031..a77c04f0e 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryServiceImpl.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryServiceImpl.java @@ -206,7 +206,7 @@ public class TradeOrderQueryServiceImpl implements TradeOrderQueryService { /** * 查询物流轨迹 - * + *

* 缓存的目的:考虑及时性要求不高,但是每次调用需要钱 * * @param code 快递公司编码 @@ -217,10 +217,13 @@ public class TradeOrderQueryServiceImpl implements TradeOrderQueryService { @Cacheable(cacheNames = RedisKeyConstants.EXPRESS_TRACK, key = "#code + '-' + #logisticsNo + '-' + #receiverMobile", condition = "#result != null && #result.length() > 0") public List getExpressTrackList(String code, String logisticsNo, String receiverMobile) { - return expressClientFactory.getDefaultExpressClient().getExpressTrackList( - new ExpressTrackQueryReqDTO().setExpressCode(code).setLogisticsNo(logisticsNo) - // TODO @卢越:1)为什么 customerName 使用 mobile 哈?2)如果使用 mobile,其实可以考虑通过 phone 计算下 - .setPhone(receiverMobile).setCustomerName(StrUtil.subSuf(receiverMobile, receiverMobile.length() - 4))); + return expressClientFactory.getDefaultExpressClient() + .getExpressTrackList( + new ExpressTrackQueryReqDTO() + .setExpressCode(code) + .setLogisticsNo(logisticsNo) + .setPhone(receiverMobile) + ); } // =================== Order Item ===================