|
@@ -22,6 +22,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
22
|
22
|
import org.springframework.beans.factory.annotation.Qualifier;
|
23
|
23
|
import org.springframework.stereotype.Component;
|
24
|
24
|
|
|
25
|
+import java.io.UnsupportedEncodingException;
|
|
26
|
+import java.net.URLEncoder;
|
25
|
27
|
import java.time.LocalDateTime;
|
26
|
28
|
import java.util.Map;
|
27
|
29
|
import java.util.Optional;
|
|
@@ -71,10 +73,11 @@ public class JiangyinServiceManager {
|
71
|
73
|
System.out.println(reqMsg);
|
72
|
74
|
customsRec.setReqMsg(reqMsg);
|
73
|
75
|
String encryptContent = AesEncrypt.encrypt(reqMsg, payload.signKey);
|
|
76
|
+ String xmlContent = urlEncode(encryptContent);
|
74
|
77
|
// 构建参数
|
75
|
78
|
JiangyinServiceParam param = JiangyinServiceParam.builder()
|
76
|
79
|
.signMsg(converter.getSign(encryptContent, payload.signKey))
|
77
|
|
- .content(encryptContent)
|
|
80
|
+ .content(xmlContent)
|
78
|
81
|
// 唯一序号
|
79
|
82
|
.copMsgId(detailVO.getOrder().getSn() + DateUtil.format(LocalDateTime.now(), DatePattern.PURE_DATETIME_PATTERN))
|
80
|
83
|
.sendCode(payload.copCode)
|
|
@@ -97,6 +100,22 @@ public class JiangyinServiceManager {
|
97
|
100
|
return success;
|
98
|
101
|
}
|
99
|
102
|
|
|
103
|
+ public static String urlEncode(String part) {
|
|
104
|
+ try {
|
|
105
|
+ return URLEncoder.encode(part, "UTF-8");
|
|
106
|
+ } catch (UnsupportedEncodingException e) {
|
|
107
|
+ throw unchecked(e);
|
|
108
|
+ }
|
|
109
|
+ }
|
|
110
|
+
|
|
111
|
+ public static RuntimeException unchecked(Exception e) {
|
|
112
|
+ if (e instanceof RuntimeException) {
|
|
113
|
+ return (RuntimeException) e;
|
|
114
|
+ } else {
|
|
115
|
+ return new RuntimeException(e);
|
|
116
|
+ }
|
|
117
|
+ }
|
|
118
|
+
|
100
|
119
|
CustomsPayload getStorePayload(String storeId){
|
101
|
120
|
return Optional.ofNullable(
|
102
|
121
|
payloadCache.computeIfAbsent(storeId, key -> CustomsPayload.fromSetting(storeCustomsMapper.selectById(key)))
|