售后退款问题修复
This commit is contained in:
@ -16,6 +16,7 @@ import java.io.*;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.*;
|
||||
|
||||
@ -51,15 +52,12 @@ public class KdniaoUtil {
|
||||
|
||||
/**
|
||||
* 获取电子面单信息
|
||||
* @param queryDTO
|
||||
* @param kdniaoElectronicsOrderGoodsDTOList
|
||||
* @return
|
||||
*/
|
||||
public static KdniaoOrderVO getOrderInfo(KdniaoElectronicsOrderDTO queryDTO,
|
||||
List<KdniaoElectronicsOrderGoodsDTO> kdniaoElectronicsOrderGoodsDTOList) {
|
||||
KdniaoOrderVO kdniaoOrderVO = new KdniaoUtil().getEleCtBase(queryDTO,kdniaoElectronicsOrderGoodsDTOList);
|
||||
//todo 由于目前快递鸟订单打印需要申请当地营业网店账号 所有目前这个没法测试 如果有其他用户有可以测试反馈给我们官方
|
||||
if (kdniaoOrderVO.getSuccess() == "false"){
|
||||
if (Objects.equals(kdniaoOrderVO.getSuccess(), "false")){
|
||||
log.error(kdniaoOrderVO.getReason());
|
||||
throw ServiceExceptionUtil.exception(new ErrorCode(999999,kdniaoOrderVO.getReason()));
|
||||
}
|
||||
@ -87,11 +85,11 @@ public class KdniaoUtil {
|
||||
String RequestData = JSON.toJSONString(requestParamMap);
|
||||
// 组装系统级参数
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("RequestData", this.urlEncoder(RequestData, "UTF-8"));
|
||||
params.put("RequestData", this.urlEncoder(RequestData));
|
||||
params.put("EBusinessID", EBusinessID);
|
||||
params.put("RequestType", "8001");//免费1002 收费8001
|
||||
String dataSign = this.encrypt(RequestData, ApiKey, "UTF-8");
|
||||
params.put("DataSign", this.urlEncoder(dataSign, "UTF-8"));
|
||||
params.put("RequestType", "1002");//免费1002 收费8001
|
||||
String dataSign = this.encrypt(RequestData, ApiKey);
|
||||
params.put("DataSign", this.urlEncoder(dataSign));
|
||||
params.put("DataType", "2");
|
||||
// 以form表单形式提交post请求,post请求体中包含了应用级参数和系统级参数
|
||||
String resultJson = this.sendPost(KDNIAO_LOGISTIC_QUERY, params);
|
||||
@ -116,11 +114,11 @@ public class KdniaoUtil {
|
||||
String RequestData = JSON.toJSONString(requestParamMap);
|
||||
// 组装系统级参数
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("RequestData", this.urlEncoder(RequestData, "UTF-8"));
|
||||
params.put("RequestData", this.urlEncoder(RequestData));
|
||||
params.put("EBusinessID", EBusinessID);
|
||||
params.put("RequestType", "1007");
|
||||
String dataSign = this.encrypt(RequestData, ApiKey, "UTF-8");
|
||||
params.put("DataSign", this.urlEncoder(dataSign, "UTF-8"));
|
||||
String dataSign = this.encrypt(RequestData, ApiKey);
|
||||
params.put("DataSign", this.urlEncoder(dataSign));
|
||||
params.put("DataType", "2");
|
||||
|
||||
String resultJson = this.sendPost(KDNIAO_ELECT_QUERY, params);
|
||||
@ -208,17 +206,15 @@ public class KdniaoUtil {
|
||||
* MD5加密
|
||||
* str 内容
|
||||
* charset 编码方式
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private String MD5(String str, String charset) throws Exception {
|
||||
private String MD5(String str) throws Exception {
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
md.update(str.getBytes(charset));
|
||||
md.update(str.getBytes(StandardCharsets.UTF_8));
|
||||
byte[] result = md.digest();
|
||||
StringBuffer sb = new StringBuffer(32);
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
int val = result[i] & 0xff;
|
||||
StringBuilder sb = new StringBuilder(32);
|
||||
for (byte b : result) {
|
||||
int val = b & 0xff;
|
||||
if (val <= 0xf) {
|
||||
sb.append("0");
|
||||
}
|
||||
@ -231,18 +227,14 @@ public class KdniaoUtil {
|
||||
* base64编码
|
||||
* str 内容
|
||||
* charset 编码方式
|
||||
*
|
||||
* @throws UnsupportedEncodingException
|
||||
*/
|
||||
private String base64(String str, String charset) throws UnsupportedEncodingException {
|
||||
String encoded = Base64.encode(str.getBytes(charset));
|
||||
return encoded;
|
||||
private String base64(String str) throws UnsupportedEncodingException {
|
||||
return Base64.encode(str.getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private String urlEncoder(String str, String charset) throws UnsupportedEncodingException {
|
||||
String result = URLEncoder.encode(str, charset);
|
||||
return result;
|
||||
private String urlEncoder(String str) throws UnsupportedEncodingException {
|
||||
return URLEncoder.encode(str, "UTF-8");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -255,11 +247,11 @@ public class KdniaoUtil {
|
||||
* @throws UnsupportedEncodingException ,Exception
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private String encrypt(String content, String keyValue, String charset) throws UnsupportedEncodingException, Exception {
|
||||
private String encrypt(String content, String keyValue) throws UnsupportedEncodingException, Exception {
|
||||
if (keyValue != null) {
|
||||
return base64(MD5(content + keyValue, charset), charset);
|
||||
return base64(MD5(content + keyValue));
|
||||
}
|
||||
return base64(MD5(content, charset), charset);
|
||||
return base64(MD5(content));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -290,7 +282,7 @@ public class KdniaoUtil {
|
||||
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
|
||||
conn.connect();
|
||||
// 获取URLConnection对象对应的输出流
|
||||
out = new OutputStreamWriter(conn.getOutputStream(), "UTF-8");
|
||||
out = new OutputStreamWriter(conn.getOutputStream(), StandardCharsets.UTF_8);
|
||||
// 发送请求参数
|
||||
if (params != null) {
|
||||
StringBuilder param = new StringBuilder();
|
||||
@ -309,13 +301,13 @@ public class KdniaoUtil {
|
||||
out.flush();
|
||||
// 定义BufferedReader输入流来读取URL的响应
|
||||
in = new BufferedReader(
|
||||
new InputStreamReader(conn.getInputStream(), "UTF-8"));
|
||||
new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8));
|
||||
String line;
|
||||
while ((line = in.readLine()) != null) {
|
||||
result.append(line);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.info(e.getMessage());
|
||||
}
|
||||
//使用finally块来关闭输出流、输入流
|
||||
finally {
|
||||
@ -327,7 +319,7 @@ public class KdniaoUtil {
|
||||
in.close();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
log.info(ex.getMessage());
|
||||
}
|
||||
}
|
||||
return result.toString();
|
||||
|
Reference in New Issue
Block a user