|
@@ -1,4 +1,4 @@
|
|
|
-package cn.iocoder.yudao.module.trade.framework.delivery.core.client.impl;
|
|
|
+package cn.iocoder.yudao.module.trade.framework.delivery.core.client.impl.kd100;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.util.HexUtil;
|
|
@@ -6,8 +6,8 @@ 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;
|
|
|
import cn.iocoder.yudao.module.trade.framework.delivery.core.client.ExpressClient;
|
|
|
-import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressQueryReqDTO;
|
|
|
-import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressQueryRespDTO;
|
|
|
+import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackQueryReqDTO;
|
|
|
+import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackRespDTO;
|
|
|
import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.kd100.Kd100ExpressQueryReqDTO;
|
|
|
import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.kd100.Kd100ExpressQueryRespDTO;
|
|
|
import lombok.AllArgsConstructor;
|
|
@@ -36,29 +36,28 @@ import static cn.iocoder.yudao.module.trade.framework.delivery.core.client.conve
|
|
|
public class Kd100ExpressClient implements ExpressClient {
|
|
|
|
|
|
private static final String REAL_TIME_QUERY_URL = "https://poll.kuaidi100.com/poll/query.do";
|
|
|
+
|
|
|
private final RestTemplate restTemplate;
|
|
|
private final TradeExpressProperties.Kd100Config config;
|
|
|
|
|
|
@Override
|
|
|
- public List<ExpressQueryRespDTO> getExpressTrackList(ExpressQueryReqDTO reqDTO) {
|
|
|
+ public List<ExpressTrackRespDTO> getExpressTrackList(ExpressTrackQueryReqDTO reqDTO) {
|
|
|
// 发起查询
|
|
|
Kd100ExpressQueryReqDTO kd100ReqParam = INSTANCE.convert2(reqDTO);
|
|
|
kd100ReqParam.setExpressCode(kd100ReqParam.getExpressCode().toLowerCase()); // 快递公司编码需要转成小写
|
|
|
Kd100ExpressQueryRespDTO respDTO = requestExpressQuery(REAL_TIME_QUERY_URL, kd100ReqParam,
|
|
|
Kd100ExpressQueryRespDTO.class);
|
|
|
log.debug("[getExpressTrackList][快递 100 接口 查询接口返回 {}]", respDTO);
|
|
|
+
|
|
|
// 处理结果
|
|
|
if (Objects.equals("false", respDTO.getResult())) {
|
|
|
log.error("[getExpressTrackList][快递 100 接口 返回失败 {}]", respDTO.getMessage());
|
|
|
throw exception(EXPRESS_API_QUERY_FAILED, respDTO.getMessage());
|
|
|
}
|
|
|
- // TODO @jason:convertList2 如果空,应该返回 list 了; @芋艿 为了避免返回 null
|
|
|
- if (CollUtil.isNotEmpty(respDTO.getTracks())) {
|
|
|
- return INSTANCE.convertList2(respDTO.getTracks());
|
|
|
- } else {
|
|
|
+ if (CollUtil.isEmpty(respDTO.getTracks())) {
|
|
|
return Collections.emptyList();
|
|
|
}
|
|
|
-
|
|
|
+ return INSTANCE.convertList2(respDTO.getTracks());
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -85,7 +84,6 @@ public class Kd100ExpressClient implements ExpressClient {
|
|
|
log.debug("[sendExpressQueryReq][快递 100 接口的请求参数: {}]", requestBody);
|
|
|
// 发送请求
|
|
|
HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<>(requestBody, headers);
|
|
|
- // TODO @jason:可以使用 restTemplate 的 post 方法哇 @芋艿 为了获取接口的原始返回。用exchange 便于查问题。
|
|
|
ResponseEntity<String> responseEntity = restTemplate.exchange(url, HttpMethod.POST, requestEntity, String.class);
|
|
|
log.debug("[sendExpressQueryReq][快递 100 接口响应结果 {}]", responseEntity);
|
|
|
|
|
@@ -98,7 +96,6 @@ public class Kd100ExpressClient implements ExpressClient {
|
|
|
|
|
|
private String generateReqSign(String param, String key, String customer) {
|
|
|
String plainText = String.format("%s%s%s", param, key, customer);
|
|
|
- // TODO @芋艿。 这里需要转换成大写, 没有对应方法
|
|
|
return HexUtil.encodeHexStr(DigestUtil.md5(plainText), false);
|
|
|
}
|
|
|
|