【代码优化】商城:查询 SF 物流,需要 CustomerName 的情况

This commit is contained in:
YunaiV 2024-08-25 11:00:45 +08:00
parent 456b54d4cb
commit 9bb231eb73
3 changed files with 9 additions and 25 deletions

View File

@ -1,6 +1,5 @@
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;
@ -34,21 +33,4 @@ 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

@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.trade.framework.delivery.core.client.impl.kdniao
import cn.hutool.core.codec.Base64;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.net.URLEncodeUtil;
import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.digest.DigestUtil;
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
import cn.iocoder.yudao.module.trade.framework.delivery.config.TradeExpressProperties;
@ -60,6 +62,11 @@ public class KdNiaoExpressClient implements ExpressClient {
// 发起请求
KdNiaoExpressQueryReqDTO requestDTO = INSTANCE.convert(reqDTO)
.setExpressCode(reqDTO.getExpressCode().toUpperCase());
if (ObjUtil.equal(requestDTO.getExpressCode(), "SF")
&& StrUtil.isBlank(reqDTO.getCustomerName())
&& StrUtil.length(reqDTO.getPhone()) >= 4) {
requestDTO.setCustomerName(StrUtil.subSufByLength(reqDTO.getPhone(), 4));
}
KdNiaoExpressQueryRespDTO respDTO = httpRequest(REAL_TIME_QUERY_URL, REAL_TIME_FREE_REQ_TYPE,
requestDTO, KdNiaoExpressQueryRespDTO.class);

View File

@ -217,13 +217,8 @@ 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)
.setPhone(receiverMobile)
);
return expressClientFactory.getDefaultExpressClient().getExpressTrackList(new ExpressTrackQueryReqDTO()
.setExpressCode(code).setLogisticsNo(logisticsNo).setPhone(receiverMobile));
}
// =================== Order Item ===================