feat:增加换货单的逻辑,已发货短信模板更改
This commit is contained in:
@@ -55,7 +55,7 @@ public class ExpressQueryUtils {
|
||||
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("Authorization", "APPCODE " + appCode);
|
||||
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
|
||||
headers.setContentType(MediaType.parseMediaType("application/x-www-form-urlencoded; charset=UTF-8"));
|
||||
|
||||
MultiValueMap<String, String> body = new LinkedMultiValueMap<>();
|
||||
body.add("expressNo", expressNo);
|
||||
@@ -75,21 +75,46 @@ public class ExpressQueryUtils {
|
||||
return result;
|
||||
} catch (HttpStatusCodeException e) {
|
||||
int status = e.getRawStatusCode();
|
||||
log.error("调用阿里云物流查询失败 expressNo={} status={}", expressNo, status, e);
|
||||
String caError = e.getResponseHeaders() != null
|
||||
? e.getResponseHeaders().getFirst("X-Ca-Error-Message") : null;
|
||||
log.warn("调用阿里云物流查询失败 expressNo={} status={} caError={}", expressNo, status, caError);
|
||||
result.put("errorCode", "HTTP_" + status);
|
||||
if (status == 403) {
|
||||
result.put("errorMsg", "物流查询服务授权失效(HTTP 403),请在阿里云 API 市场续费快递查询接口并更新 express.ali.app-code");
|
||||
} else {
|
||||
if (status == 403)
|
||||
{
|
||||
result.put("errorMsg", buildExpress403Message(caError));
|
||||
}
|
||||
else
|
||||
{
|
||||
String errorBody = e.getResponseBodyAsString();
|
||||
result.put("errorMsg", StringUtils.isNotEmpty(errorBody) ? errorBody : ("物流查询请求失败,HTTP状态码:" + status));
|
||||
}
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.error("调用阿里云物流查询失败 expressNo={}", expressNo, e);
|
||||
result.put("errorCode", "EXCEPTION");
|
||||
result.put("errorMsg", e.getMessage());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
private String buildExpress403Message(String caError)
|
||||
{
|
||||
if (StringUtils.isEmpty(caError))
|
||||
{
|
||||
return "物流查询未授权(HTTP 403):请在阿里云 API 市场购买「快递物流查询」接口,"
|
||||
+ "并使用该商品对应的 AppCode 配置 express.ali.app-code(不能与实名认证等其它 API 混用)";
|
||||
}
|
||||
if (caError.contains("Quota") || caError.contains("quota") || caError.contains("exhausted"))
|
||||
{
|
||||
return "物流查询套餐次数已用完(HTTP 403),请在阿里云 API 市场续费快递查询接口";
|
||||
}
|
||||
if (caError.contains("Unauthorized") || caError.contains("Invalid AppCode") || caError.contains("not exists"))
|
||||
{
|
||||
return "物流查询 AppCode 无效或未订阅该 API(HTTP 403),请更新 express.ali.app-code 为快递查询商品的 AppCode";
|
||||
}
|
||||
return "物流查询未授权(HTTP 403):" + caError;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user