!1052 【代码优化】对customerName内部屏蔽

Merge pull request !1052 from 卢越/master-jdk17
This commit is contained in:
芋道源码 2024-08-25 02:53:45 +00:00 committed by Gitee
commit 456b54d4cb
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 27 additions and 6 deletions

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto; 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 cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO;
import lombok.Data; import lombok.Data;
@ -13,7 +14,7 @@ public class ExpressTrackQueryReqDTO {
/** /**
* 快递公司编码 * 快递公司编码
* * <p>
* 对应 {@link DeliveryExpressDO#getCode()} * 对应 {@link DeliveryExpressDO#getCode()}
*/ */
private String expressCode; private String expressCode;
@ -33,4 +34,21 @@ public class ExpressTrackQueryReqDTO {
*/ */
private String customerName; 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);
}
}
} }

View File

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