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

This commit is contained in:
卢越 2024-08-25 08:39:44 +08:00
parent 0f51229954
commit d4e4207ae9
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;
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 {
/**
* 快递公司编码
*
* <p>
* 对应 {@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);
}
}
}

View File

@ -206,7 +206,7 @@ public class TradeOrderQueryServiceImpl implements TradeOrderQueryService {
/**
* 查询物流轨迹
*
* <p>
* 缓存的目的考虑及时性要求不高但是每次调用需要钱
*
* @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<ExpressTrackRespDTO> 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 ===================