Browse Source

江阴综服平台订单报关接口对接 暂存

郑杰 2 years ago
parent
commit
e59deb709d

+ 3 - 249
buyer-api/src/test/java/cn/lili/buyer/test/customs/CustomsTest.java

@@ -2,7 +2,6 @@ package cn.lili.buyer.test.customs;
2 2
 
3 3
 import cn.hutool.core.util.XmlUtil;
4 4
 import cn.hutool.json.JSONUtil;
5
-import cn.lili.common.utils.XmlMapUtils;
6 5
 import org.w3c.dom.Document;
7 6
 import org.w3c.dom.Element;
8 7
 
@@ -47,254 +46,6 @@ public class CustomsTest {
47 46
                 "\t\t\t<ceb:note>test</ceb:note>\n" +
48 47
                 "\t\t</ceb:OrderList>\n" +
49 48
                 "\t</ceb:Order>\n" +
50
-                "        <ceb:Order>\n" +
51
-                "\t\t<ceb:OrderHead>\n" +
52
-                "\t\t\t<ceb:guid>704ea0f1-b229-4e89-9f2f-c2e550e95c86</ceb:guid>\n" +
53
-                "\t\t\t<ceb:appType>1</ceb:appType>\n" +
54
-                "\t\t\t<ceb:appTime>20180507153001</ceb:appTime>\n" +
55
-                "\t\t\t<ceb:appStatus>2</ceb:appStatus>\n" +
56
-                "\t\t\t<ceb:orderType>E</ceb:orderType>\n" +
57
-                "\t\t\t<ceb:orderNo>order2018050711340001</ceb:orderNo>\n" +
58
-                "\t\t\t<ceb:ebpCode>1105910159</ceb:ebpCode>\n" +
59
-                "\t\t\t<ceb:ebpName>东方物通科技(北京)有限公司</ceb:ebpName>\n" +
60
-                "\t\t\t<ceb:ebcCode>1105910159</ceb:ebcCode>\n" +
61
-                "\t\t\t<ceb:ebcName>东方物通科技(北京)有限公司</ceb:ebcName>\n" +
62
-                "\t\t\t<ceb:goodsValue>12345678912345.12345</ceb:goodsValue>\n" +
63
-                "\t\t\t<ceb:freight>0</ceb:freight>\n" +
64
-                "\t\t\t<ceb:currency>142</ceb:currency>\n" +
65
-                "\t\t\t<ceb:note>test</ceb:note>\n" +
66
-                "\t\t</ceb:OrderHead>\n" +
67
-                "\t\t<ceb:OrderList>\n" +
68
-                "\t\t\t<ceb:gnum>1</ceb:gnum>\n" +
69
-                "\t\t\t<ceb:itemNo>AF001-001</ceb:itemNo>\n" +
70
-                "\t\t\t<ceb:itemName>小米盒子</ceb:itemName>\n" +
71
-                "\t\t\t<ceb:itemDescribe>小米盒子</ceb:itemDescribe>\n" +
72
-                "\t\t\t<ceb:barCode>2345123</ceb:barCode>\n" +
73
-                "\t\t\t<ceb:unit>aaa</ceb:unit>\n" +
74
-                "\t\t\t<ceb:currency>aaa</ceb:currency>\n" +
75
-                "\t\t\t<ceb:qty>100</ceb:qty>\n" +
76
-                "\t\t\t<ceb:price>20</ceb:price>\n" +
77
-                "\t\t\t<ceb:totalPrice>2000</ceb:totalPrice>\n" +
78
-                "\t\t\t<ceb:note>test</ceb:note>\n" +
79
-                "\t\t</ceb:OrderList>\n" +
80
-                "\t</ceb:Order>\n" +
81
-                "    <ceb:Order>\n" +
82
-                "\t\t<ceb:OrderHead>\n" +
83
-                "\t\t\t<ceb:guid>704ea0f1-b229-4e89-9f2f-c2e550e95c86</ceb:guid>\n" +
84
-                "\t\t\t<ceb:appType>1</ceb:appType>\n" +
85
-                "\t\t\t<ceb:appTime>20180507153001</ceb:appTime>\n" +
86
-                "\t\t\t<ceb:appStatus>2</ceb:appStatus>\n" +
87
-                "\t\t\t<ceb:orderType>E</ceb:orderType>\n" +
88
-                "\t\t\t<ceb:orderNo>order2018050711340001</ceb:orderNo>\n" +
89
-                "\t\t\t<ceb:ebpCode>1105910159</ceb:ebpCode>\n" +
90
-                "\t\t\t<ceb:ebpName>东方物通科技(北京)有限公司</ceb:ebpName>\n" +
91
-                "\t\t\t<ceb:ebcCode>1105910159</ceb:ebcCode>\n" +
92
-                "\t\t\t<ceb:ebcName>东方物通科技(北京)有限公司</ceb:ebcName>\n" +
93
-                "\t\t\t<ceb:goodsValue>12345678912345.12345</ceb:goodsValue>\n" +
94
-                "\t\t\t<ceb:freight>0</ceb:freight>\n" +
95
-                "\t\t\t<ceb:currency>142</ceb:currency>\n" +
96
-                "\t\t\t<ceb:note>test</ceb:note>\n" +
97
-                "\t\t</ceb:OrderHead>\n" +
98
-                "\t\t<ceb:OrderList>\n" +
99
-                "\t\t\t<ceb:gnum>1</ceb:gnum>\n" +
100
-                "\t\t\t<ceb:itemNo>AF001-001</ceb:itemNo>\n" +
101
-                "\t\t\t<ceb:itemName>小米盒子</ceb:itemName>\n" +
102
-                "\t\t\t<ceb:itemDescribe>小米盒子</ceb:itemDescribe>\n" +
103
-                "\t\t\t<ceb:barCode>2345123</ceb:barCode>\n" +
104
-                "\t\t\t<ceb:unit>aaa</ceb:unit>\n" +
105
-                "\t\t\t<ceb:currency>aaa</ceb:currency>\n" +
106
-                "\t\t\t<ceb:qty>100</ceb:qty>\n" +
107
-                "\t\t\t<ceb:price>20</ceb:price>\n" +
108
-                "\t\t\t<ceb:totalPrice>2000</ceb:totalPrice>\n" +
109
-                "\t\t\t<ceb:note>test</ceb:note>\n" +
110
-                "\t\t</ceb:OrderList>\n" +
111
-                "\t</ceb:Order>\n" +
112
-                "    <ceb:Order>\n" +
113
-                "\t\t<ceb:OrderHead>\n" +
114
-                "\t\t\t<ceb:guid>704ea0f1-b229-4e89-9f2f-c2e550e95c86</ceb:guid>\n" +
115
-                "\t\t\t<ceb:appType>1</ceb:appType>\n" +
116
-                "\t\t\t<ceb:appTime>20180507153001</ceb:appTime>\n" +
117
-                "\t\t\t<ceb:appStatus>2</ceb:appStatus>\n" +
118
-                "\t\t\t<ceb:orderType>E</ceb:orderType>\n" +
119
-                "\t\t\t<ceb:orderNo>order2018050711340001</ceb:orderNo>\n" +
120
-                "\t\t\t<ceb:ebpCode>1105910159</ceb:ebpCode>\n" +
121
-                "\t\t\t<ceb:ebpName>东方物通科技(北京)有限公司</ceb:ebpName>\n" +
122
-                "\t\t\t<ceb:ebcCode>1105910159</ceb:ebcCode>\n" +
123
-                "\t\t\t<ceb:ebcName>东方物通科技(北京)有限公司</ceb:ebcName>\n" +
124
-                "\t\t\t<ceb:goodsValue>12345678912345.12345</ceb:goodsValue>\n" +
125
-                "\t\t\t<ceb:freight>0</ceb:freight>\n" +
126
-                "\t\t\t<ceb:currency>142</ceb:currency>\n" +
127
-                "\t\t\t<ceb:note>test</ceb:note>\n" +
128
-                "\t\t</ceb:OrderHead>\n" +
129
-                "\t\t<ceb:OrderList>\n" +
130
-                "\t\t\t<ceb:gnum>1</ceb:gnum>\n" +
131
-                "\t\t\t<ceb:itemNo>AF001-001</ceb:itemNo>\n" +
132
-                "\t\t\t<ceb:itemName>小米盒子</ceb:itemName>\n" +
133
-                "\t\t\t<ceb:itemDescribe>小米盒子</ceb:itemDescribe>\n" +
134
-                "\t\t\t<ceb:barCode>2345123</ceb:barCode>\n" +
135
-                "\t\t\t<ceb:unit>aaa</ceb:unit>\n" +
136
-                "\t\t\t<ceb:currency>aaa</ceb:currency>\n" +
137
-                "\t\t\t<ceb:qty>100</ceb:qty>\n" +
138
-                "\t\t\t<ceb:price>20</ceb:price>\n" +
139
-                "\t\t\t<ceb:totalPrice>2000</ceb:totalPrice>\n" +
140
-                "\t\t\t<ceb:note>test</ceb:note>\n" +
141
-                "\t\t</ceb:OrderList>\n" +
142
-                "\t</ceb:Order>\n" +
143
-                "    <ceb:Order>\n" +
144
-                "\t\t<ceb:OrderHead>\n" +
145
-                "\t\t\t<ceb:guid>704ea0f1-b229-4e89-9f2f-c2e550e95c86</ceb:guid>\n" +
146
-                "\t\t\t<ceb:appType>1</ceb:appType>\n" +
147
-                "\t\t\t<ceb:appTime>20180507153001</ceb:appTime>\n" +
148
-                "\t\t\t<ceb:appStatus>2</ceb:appStatus>\n" +
149
-                "\t\t\t<ceb:orderType>E</ceb:orderType>\n" +
150
-                "\t\t\t<ceb:orderNo>order2018050711340001</ceb:orderNo>\n" +
151
-                "\t\t\t<ceb:ebpCode>1105910159</ceb:ebpCode>\n" +
152
-                "\t\t\t<ceb:ebpName>东方物通科技(北京)有限公司</ceb:ebpName>\n" +
153
-                "\t\t\t<ceb:ebcCode>1105910159</ceb:ebcCode>\n" +
154
-                "\t\t\t<ceb:ebcName>东方物通科技(北京)有限公司</ceb:ebcName>\n" +
155
-                "\t\t\t<ceb:goodsValue>12345678912345.12345</ceb:goodsValue>\n" +
156
-                "\t\t\t<ceb:freight>0</ceb:freight>\n" +
157
-                "\t\t\t<ceb:currency>142</ceb:currency>\n" +
158
-                "\t\t\t<ceb:note>test</ceb:note>\n" +
159
-                "\t\t</ceb:OrderHead>\n" +
160
-                "\t\t<ceb:OrderList>\n" +
161
-                "\t\t\t<ceb:gnum>1</ceb:gnum>\n" +
162
-                "\t\t\t<ceb:itemNo>AF001-001</ceb:itemNo>\n" +
163
-                "\t\t\t<ceb:itemName>小米盒子</ceb:itemName>\n" +
164
-                "\t\t\t<ceb:itemDescribe>小米盒子</ceb:itemDescribe>\n" +
165
-                "\t\t\t<ceb:barCode>2345123</ceb:barCode>\n" +
166
-                "\t\t\t<ceb:unit>aaa</ceb:unit>\n" +
167
-                "\t\t\t<ceb:currency>aaa</ceb:currency>\n" +
168
-                "\t\t\t<ceb:qty>100</ceb:qty>\n" +
169
-                "\t\t\t<ceb:price>20</ceb:price>\n" +
170
-                "\t\t\t<ceb:totalPrice>2000</ceb:totalPrice>\n" +
171
-                "\t\t\t<ceb:note>test</ceb:note>\n" +
172
-                "\t\t</ceb:OrderList>\n" +
173
-                "\t</ceb:Order>\n" +
174
-                "\t<ceb:Order>\n" +
175
-                "\t\t<ceb:OrderHead>\n" +
176
-                "\t\t\t<ceb:guid>704ea0f1-b229-4e89-9f2f-c2e550e95c86</ceb:guid>\n" +
177
-                "\t\t\t<ceb:appType>1</ceb:appType>\n" +
178
-                "\t\t\t<ceb:appTime>20180507153001</ceb:appTime>\n" +
179
-                "\t\t\t<ceb:appStatus>2</ceb:appStatus>\n" +
180
-                "\t\t\t<ceb:orderType>E</ceb:orderType>\n" +
181
-                "\t\t\t<ceb:orderNo>order2018050711340001</ceb:orderNo>\n" +
182
-                "\t\t\t<ceb:ebpCode>1105910159</ceb:ebpCode>\n" +
183
-                "\t\t\t<ceb:ebpName>东方物通科技(北京)有限公司</ceb:ebpName>\n" +
184
-                "\t\t\t<ceb:ebcCode>1105910159</ceb:ebcCode>\n" +
185
-                "\t\t\t<ceb:ebcName>东方物通科技(北京)有限公司</ceb:ebcName>\n" +
186
-                "\t\t\t<ceb:goodsValue>12345678912345.12345</ceb:goodsValue>\n" +
187
-                "\t\t\t<ceb:freight>0</ceb:freight>\n" +
188
-                "\t\t\t<ceb:currency>142</ceb:currency>\n" +
189
-                "\t\t\t<ceb:note>test</ceb:note>\n" +
190
-                "\t\t</ceb:OrderHead>\n" +
191
-                "\t\t<ceb:OrderList>\n" +
192
-                "\t\t\t<ceb:gnum>1</ceb:gnum>\n" +
193
-                "\t\t\t<ceb:itemNo>AF001-001</ceb:itemNo>\n" +
194
-                "\t\t\t<ceb:itemName>小米盒子</ceb:itemName>\n" +
195
-                "\t\t\t<ceb:itemDescribe>小米盒子</ceb:itemDescribe>\n" +
196
-                "\t\t\t<ceb:barCode>2345123</ceb:barCode>\n" +
197
-                "\t\t\t<ceb:unit>aaa</ceb:unit>\n" +
198
-                "\t\t\t<ceb:currency>aaa</ceb:currency>\n" +
199
-                "\t\t\t<ceb:qty>100</ceb:qty>\n" +
200
-                "\t\t\t<ceb:price>20</ceb:price>\n" +
201
-                "\t\t\t<ceb:totalPrice>2000</ceb:totalPrice>\n" +
202
-                "\t\t\t<ceb:note>test</ceb:note>\n" +
203
-                "\t\t</ceb:OrderList>\n" +
204
-                "\t</ceb:Order>\n" +
205
-                "        <ceb:Order>\n" +
206
-                "\t\t<ceb:OrderHead>\n" +
207
-                "\t\t\t<ceb:guid>704ea0f1-b229-4e89-9f2f-c2e550e95c86</ceb:guid>\n" +
208
-                "\t\t\t<ceb:appType>1</ceb:appType>\n" +
209
-                "\t\t\t<ceb:appTime>20180507153001</ceb:appTime>\n" +
210
-                "\t\t\t<ceb:appStatus>2</ceb:appStatus>\n" +
211
-                "\t\t\t<ceb:orderType>E</ceb:orderType>\n" +
212
-                "\t\t\t<ceb:orderNo>order2018050711340001</ceb:orderNo>\n" +
213
-                "\t\t\t<ceb:ebpCode>1105910159</ceb:ebpCode>\n" +
214
-                "\t\t\t<ceb:ebpName>东方物通科技(北京)有限公司</ceb:ebpName>\n" +
215
-                "\t\t\t<ceb:ebcCode>1105910159</ceb:ebcCode>\n" +
216
-                "\t\t\t<ceb:ebcName>东方物通科技(北京)有限公司</ceb:ebcName>\n" +
217
-                "\t\t\t<ceb:goodsValue>12345678912345.12345</ceb:goodsValue>\n" +
218
-                "\t\t\t<ceb:freight>0</ceb:freight>\n" +
219
-                "\t\t\t<ceb:currency>142</ceb:currency>\n" +
220
-                "\t\t\t<ceb:note>test</ceb:note>\n" +
221
-                "\t\t</ceb:OrderHead>\n" +
222
-                "\t\t<ceb:OrderList>\n" +
223
-                "\t\t\t<ceb:gnum>1</ceb:gnum>\n" +
224
-                "\t\t\t<ceb:itemNo>AF001-001</ceb:itemNo>\n" +
225
-                "\t\t\t<ceb:itemName>小米盒子</ceb:itemName>\n" +
226
-                "\t\t\t<ceb:itemDescribe>小米盒子</ceb:itemDescribe>\n" +
227
-                "\t\t\t<ceb:barCode>2345123</ceb:barCode>\n" +
228
-                "\t\t\t<ceb:unit>aaa</ceb:unit>\n" +
229
-                "\t\t\t<ceb:currency>aaa</ceb:currency>\n" +
230
-                "\t\t\t<ceb:qty>100</ceb:qty>\n" +
231
-                "\t\t\t<ceb:price>20</ceb:price>\n" +
232
-                "\t\t\t<ceb:totalPrice>2000</ceb:totalPrice>\n" +
233
-                "\t\t\t<ceb:note>test</ceb:note>\n" +
234
-                "\t\t</ceb:OrderList>\n" +
235
-                "\t</ceb:Order>\n" +
236
-                "    <ceb:Order>\n" +
237
-                "\t\t<ceb:OrderHead>\n" +
238
-                "\t\t\t<ceb:guid>704ea0f1-b229-4e89-9f2f-c2e550e95c86</ceb:guid>\n" +
239
-                "\t\t\t<ceb:appType>1</ceb:appType>\n" +
240
-                "\t\t\t<ceb:appTime>20180507153001</ceb:appTime>\n" +
241
-                "\t\t\t<ceb:appStatus>2</ceb:appStatus>\n" +
242
-                "\t\t\t<ceb:orderType>E</ceb:orderType>\n" +
243
-                "\t\t\t<ceb:orderNo>order2018050711340001</ceb:orderNo>\n" +
244
-                "\t\t\t<ceb:ebpCode>1105910159</ceb:ebpCode>\n" +
245
-                "\t\t\t<ceb:ebpName>东方物通科技(北京)有限公司</ceb:ebpName>\n" +
246
-                "\t\t\t<ceb:ebcCode>1105910159</ceb:ebcCode>\n" +
247
-                "\t\t\t<ceb:ebcName>东方物通科技(北京)有限公司</ceb:ebcName>\n" +
248
-                "\t\t\t<ceb:goodsValue>12345678912345.12345</ceb:goodsValue>\n" +
249
-                "\t\t\t<ceb:freight>0</ceb:freight>\n" +
250
-                "\t\t\t<ceb:currency>142</ceb:currency>\n" +
251
-                "\t\t\t<ceb:note>test</ceb:note>\n" +
252
-                "\t\t</ceb:OrderHead>\n" +
253
-                "\t\t<ceb:OrderList>\n" +
254
-                "\t\t\t<ceb:gnum>1</ceb:gnum>\n" +
255
-                "\t\t\t<ceb:itemNo>AF001-001</ceb:itemNo>\n" +
256
-                "\t\t\t<ceb:itemName>小米盒子</ceb:itemName>\n" +
257
-                "\t\t\t<ceb:itemDescribe>小米盒子</ceb:itemDescribe>\n" +
258
-                "\t\t\t<ceb:barCode>2345123</ceb:barCode>\n" +
259
-                "\t\t\t<ceb:unit>aaa</ceb:unit>\n" +
260
-                "\t\t\t<ceb:currency>aaa</ceb:currency>\n" +
261
-                "\t\t\t<ceb:qty>100</ceb:qty>\n" +
262
-                "\t\t\t<ceb:price>20</ceb:price>\n" +
263
-                "\t\t\t<ceb:totalPrice>2000</ceb:totalPrice>\n" +
264
-                "\t\t\t<ceb:note>test</ceb:note>\n" +
265
-                "\t\t</ceb:OrderList>\n" +
266
-                "\t</ceb:Order>\n" +
267
-                "    <ceb:Order>\n" +
268
-                "\t\t<ceb:OrderHead>\n" +
269
-                "\t\t\t<ceb:guid>704ea0f1-b229-4e89-9f2f-c2e550e95c86</ceb:guid>\n" +
270
-                "\t\t\t<ceb:appType>1</ceb:appType>\n" +
271
-                "\t\t\t<ceb:appTime>20180507153001</ceb:appTime>\n" +
272
-                "\t\t\t<ceb:appStatus>2</ceb:appStatus>\n" +
273
-                "\t\t\t<ceb:orderType>E</ceb:orderType>\n" +
274
-                "\t\t\t<ceb:orderNo>order2018050711340001</ceb:orderNo>\n" +
275
-                "\t\t\t<ceb:ebpCode>1105910159</ceb:ebpCode>\n" +
276
-                "\t\t\t<ceb:ebpName>东方物通科技(北京)有限公司</ceb:ebpName>\n" +
277
-                "\t\t\t<ceb:ebcCode>1105910159</ceb:ebcCode>\n" +
278
-                "\t\t\t<ceb:ebcName>东方物通科技(北京)有限公司</ceb:ebcName>\n" +
279
-                "\t\t\t<ceb:goodsValue>12345678912345.12345</ceb:goodsValue>\n" +
280
-                "\t\t\t<ceb:freight>0</ceb:freight>\n" +
281
-                "\t\t\t<ceb:currency>142</ceb:currency>\n" +
282
-                "\t\t\t<ceb:note>test</ceb:note>\n" +
283
-                "\t\t</ceb:OrderHead>\n" +
284
-                "\t\t<ceb:OrderList>\n" +
285
-                "\t\t\t<ceb:gnum>1</ceb:gnum>\n" +
286
-                "\t\t\t<ceb:itemNo>AF001-001</ceb:itemNo>\n" +
287
-                "\t\t\t<ceb:itemName>小米盒子</ceb:itemName>\n" +
288
-                "\t\t\t<ceb:itemDescribe>小米盒子</ceb:itemDescribe>\n" +
289
-                "\t\t\t<ceb:barCode>2345123</ceb:barCode>\n" +
290
-                "\t\t\t<ceb:unit>aaa</ceb:unit>\n" +
291
-                "\t\t\t<ceb:currency>aaa</ceb:currency>\n" +
292
-                "\t\t\t<ceb:qty>100</ceb:qty>\n" +
293
-                "\t\t\t<ceb:price>20</ceb:price>\n" +
294
-                "\t\t\t<ceb:totalPrice>2000</ceb:totalPrice>\n" +
295
-                "\t\t\t<ceb:note>test</ceb:note>\n" +
296
-                "\t\t</ceb:OrderList>\n" +
297
-                "\t</ceb:Order>\n" +
298 49
                 "    <ceb:Order>\n" +
299 50
                 "\t\t<ceb:OrderHead>\n" +
300 51
                 "\t\t\t<ceb:guid>704ea0f1-b229-4e89-9f2f-c2e550e95c86</ceb:guid>\n" +
@@ -398,6 +149,7 @@ public class CustomsTest {
398 149
 
399 150
 
400 151
         // XMLString转Map
152
+        System.out.println(xml);
401 153
         Map<String, Object> map = XmlUtil.xmlToMap(xml);
402 154
         System.out.println(JSONUtil.toJsonStr(map));
403 155
 
@@ -413,5 +165,7 @@ public class CustomsTest {
413 165
         // 转String
414 166
         String xmlString = XmlUtil.toStr(ceb);
415 167
         System.out.println();
168
+
169
+        //requestMsg.setBaseTransfer();
416 170
     }
417 171
 }

+ 30 - 0
framework/src/main/java/cn/lili/modules/order/customs/CustomPayload.java

@@ -0,0 +1,30 @@
1
+package cn.lili.modules.order.customs;
2
+
3
+import lombok.ToString;
4
+
5
+@ToString
6
+public enum CustomPayload {
7
+    JiangyinXingguang("DXPENT0000474373", "DXP", "江阴星光进出口有限公司", "3216960A23", "dcits123456", "test");
8
+
9
+    CustomPayload(String dxpId, String dxpMode, String copName, String copCode, String signKey, String note) {
10
+        this.dxpId = dxpId;
11
+        this.dxpMode = dxpMode;
12
+        this.copName = copName;
13
+        this.copCode = copCode;
14
+        this.signKey = signKey;
15
+        this.note = note;
16
+    }
17
+
18
+    /** 向中国电子口岸数据中心申请数据交换平台的用户编号 */
19
+    public String dxpId;
20
+    /** 默认为DXP,指中国电子口岸数据交换平台 */
21
+    public String dxpMode;
22
+    /** 报文传输的企业名称 */
23
+    public String copCode;
24
+    /** 报文传输的企业代码(海关编码,需要与接入客户端的企业身份一致) */
25
+    public String copName;
26
+    /** 签名key */
27
+    public String signKey;
28
+    /** 备注 */
29
+    public String note;
30
+}

+ 15 - 0
framework/src/main/java/cn/lili/modules/order/customs/CustomsExchange.java

@@ -0,0 +1,15 @@
1
+package cn.lili.modules.order.customs;
2
+
3
+import cn.lili.modules.order.order.entity.vo.OrderDetailVO;
4
+import lombok.AllArgsConstructor;
5
+import lombok.Data;
6
+import lombok.NoArgsConstructor;
7
+
8
+@Data
9
+@NoArgsConstructor
10
+@AllArgsConstructor
11
+public class CustomsExchange {
12
+    private String guid;
13
+
14
+    private OrderDetailVO orderDetailVO;
15
+}

+ 49 - 0
framework/src/main/java/cn/lili/modules/order/customs/JiangyinServiceManager.java

@@ -0,0 +1,49 @@
1
+package cn.lili.modules.order.customs;
2
+
3
+import cn.hutool.core.date.DatePattern;
4
+import cn.hutool.core.date.DateUtil;
5
+import cn.hutool.http.HttpUtil;
6
+import cn.hutool.json.JSONUtil;
7
+import cn.lili.modules.order.customs.converter.CustomsReqConverter;
8
+import cn.lili.modules.order.order.entity.vo.OrderDetailVO;
9
+import lombok.extern.slf4j.Slf4j;
10
+import org.springframework.beans.factory.annotation.Autowired;
11
+import org.springframework.stereotype.Component;
12
+
13
+import java.time.LocalDateTime;
14
+
15
+@Slf4j
16
+@Component
17
+public class JiangyinServiceManager {
18
+
19
+    private static final String JIANGYIN_ORDER_PUSH_URL = "http://117.80.148.225:8010/webapi-jiangyin/api/custom/platReceiveOf9710";
20
+
21
+    private final CustomsReqConverter converter;
22
+
23
+    @Autowired
24
+    public JiangyinServiceManager(CustomsReqConverter converter) {
25
+        this.converter = converter;
26
+    }
27
+
28
+    public void push(OrderDetailVO detailVO){
29
+        // 企业凭证相关(后续动态获取)
30
+        CustomPayload payload = CustomPayload.JiangyinXingguang;
31
+        log.info("method input param: {}, payload: {}", JSONUtil.toJsonStr(detailVO), payload.toString());
32
+        // 报文内容
33
+        String content = converter.toReq(detailVO, payload);
34
+        // 构建参数
35
+        JiangyinServiceParam param = JiangyinServiceParam.builder()
36
+                .signMsg(converter.getSign(content, payload.signKey))
37
+                .content(content)
38
+                // 唯一序号
39
+                .copMsgId(detailVO.getOrder().getSn() + DateUtil.format(LocalDateTime.now(), DatePattern.PURE_DATETIME_PATTERN))
40
+                .sendCode(payload.copCode)
41
+                .build();
42
+        // 开始调用
43
+        String bodyStr = JSONUtil.toJsonStr(param);
44
+        log.info("request body: {}", bodyStr);
45
+        String res = HttpUtil.post(JIANGYIN_ORDER_PUSH_URL, bodyStr, 30000);
46
+        log.info("response msg: {}", res);
47
+    }
48
+}
49
+

+ 19 - 0
framework/src/main/java/cn/lili/modules/order/customs/JiangyinServiceParam.java

@@ -0,0 +1,19 @@
1
+package cn.lili.modules.order.customs;
2
+
3
+import lombok.Builder;
4
+import lombok.Data;
5
+
6
+@Data
7
+@Builder
8
+public class JiangyinServiceParam {
9
+    /** 数字签名 */
10
+    String signMsg;
11
+    /** 报文内容 */
12
+    String content;
13
+    /** 消息类型 */
14
+    final String msgType = "CEB303Message";
15
+    /** 用户自定义生成报文唯一序号 */
16
+    String copMsgId;
17
+    /** 发送方代码(企业海关10位编码) */
18
+    String sendCode;
19
+}

+ 12 - 0
framework/src/main/java/cn/lili/modules/order/customs/converter/CustomsReqConverter.java

@@ -0,0 +1,12 @@
1
+package cn.lili.modules.order.customs.converter;
2
+
3
+import cn.lili.modules.order.customs.CustomPayload;
4
+import cn.lili.modules.order.order.entity.vo.OrderDetailVO;
5
+
6
+public interface CustomsReqConverter{
7
+    /** 生成报文 */
8
+    String toReq(OrderDetailVO order, CustomPayload payload);
9
+
10
+    /** 获取签名 */
11
+    String getSign(String content, String key);
12
+}

+ 199 - 0
framework/src/main/java/cn/lili/modules/order/customs/converter/JiangyinServiceReqConverter.java

@@ -0,0 +1,199 @@
1
+package cn.lili.modules.order.customs.converter;
2
+
3
+import cn.hutool.core.date.DatePattern;
4
+import cn.hutool.core.date.DateUtil;
5
+import cn.hutool.core.util.XmlUtil;
6
+import cn.hutool.crypto.digest.DigestUtil;
7
+import cn.lili.modules.goods.entity.dos.Goods;
8
+import cn.lili.modules.goods.entity.dto.GoodsSearchParams;
9
+import cn.lili.modules.goods.service.GoodsService;
10
+import cn.lili.modules.order.customs.CustomPayload;
11
+import cn.lili.modules.order.customs.CustomsExchange;
12
+import cn.lili.modules.order.order.entity.dos.OrderItem;
13
+import cn.lili.modules.order.order.entity.vo.OrderDetailVO;
14
+import org.springframework.beans.factory.annotation.Autowired;
15
+import org.springframework.stereotype.Component;
16
+import org.w3c.dom.Document;
17
+import org.w3c.dom.Element;
18
+
19
+import java.time.LocalDateTime;
20
+import java.util.*;
21
+import java.util.stream.Collectors;
22
+
23
+@Component
24
+public class JiangyinServiceReqConverter implements CustomsReqConverter{
25
+    /** 报文前缀 */
26
+    private static final String CEB_PREFIX = "ceb:";
27
+    private static final String DS_PREFIX = "ds:";
28
+
29
+
30
+    private final GoodsService goodsService;
31
+
32
+    @Autowired
33
+    public JiangyinServiceReqConverter(GoodsService goodsService) {
34
+        this.goodsService = goodsService;
35
+    }
36
+
37
+    @Override
38
+    public String toReq(OrderDetailVO order, CustomPayload payload) {
39
+        final String guid = UUID.randomUUID().toString();
40
+        System.out.println(guid);;
41
+        CustomsExchange exchange = new CustomsExchange(guid, order);
42
+        // map解析
43
+        Map<String, Object> m = orderToMap(order, payload);
44
+        Document ceb = XmlUtil.mapToXml(m, "ceb:CEB303Message");
45
+        // 添加首个Node的属性
46
+        Element element = ceb.getDocumentElement();
47
+        element.setAttribute("guid", "311af125-6fed-4603-8c5d-49b1fa4b4b9b");
48
+        element.setAttribute("version", "1.0");
49
+        element.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
50
+        element.setAttribute("xmlns:ceb", "http://www.chinaport.gov.cn/ceb");
51
+        //
52
+        Element signature = (Element)element.getLastChild();
53
+        signature.setAttribute("xmlns:ds", "http://www.w3.org/2000/09/xmldsig#");
54
+        ceb.setXmlStandalone(true);
55
+        // 转String
56
+        return XmlUtil.toStr(ceb);
57
+    }
58
+
59
+    @Override
60
+    public String getSign(String content, String key) {
61
+        try {
62
+            return DigestUtil.md5Hex(content + key).toUpperCase();
63
+        } catch (Exception e) {
64
+            e.printStackTrace();
65
+        }
66
+        throw new RuntimeException("gen sign failed.");
67
+    }
68
+
69
+    /**
70
+     * 根据订单详情生成符合报文格式的Map
71
+     * @param order 订单详情
72
+     * @param payload 存根(企业凭证相关)
73
+     * @return 符合报文格式的Map
74
+     */
75
+    private Map<String, Object> orderToMap(OrderDetailVO order, CustomPayload payload){
76
+        final String guid = UUID.randomUUID().toString();
77
+        System.out.println(guid);;
78
+        CustomsExchange exchange = new CustomsExchange(guid, order);
79
+
80
+        Map<String, Object> reqMap = new HashMap<>();
81
+        // 1. ceb:order
82
+        reqMap.put(CEB_PREFIX + "Order", order(exchange, payload));
83
+        // 2. ceb:baseTransfer
84
+        reqMap.put(CEB_PREFIX + "BaseTransfer", baseTransfer(payload));
85
+
86
+        return reqMap;
87
+    }
88
+
89
+
90
+    /**
91
+     * 生成订单报文部分
92
+     * @param exchange 交换数据(业务)
93
+     * @param payload 存根(企业凭证相关)
94
+     * @return 报文List数据
95
+     */
96
+    private List<Map<String, Object>> order(CustomsExchange exchange, CustomPayload payload){
97
+        final String timeStr = DateUtil.format(LocalDateTime.now(), DatePattern.PURE_DATETIME_PATTERN);
98
+        List<Map<String, Object>> orderList = new ArrayList<>(0);
99
+        Optional.ofNullable(exchange.getOrderDetailVO().getOrderItems()).ifPresent(items -> {
100
+            // 批量获取商品信息
101
+            String ids = items.stream().map(OrderItem::getGoodsId).collect(Collectors.joining());
102
+            GoodsSearchParams params = new GoodsSearchParams();
103
+            params.setId(ids);
104
+            Map<String, String> id2Unit = goodsService.queryListByParams(params).stream()
105
+                    .collect(Collectors.toMap(Goods::getId, Goods::getGoodsUnit));
106
+            for (int i = 0; i < items.size(); i++) {
107
+                OrderItem item = items.get(i);
108
+                Map<String, Object> itemMap = new HashMap<>();
109
+                Map<String, Object> orderHead = new HashMap<>(32);
110
+                // 1. 表头
111
+                // 电商平台名称
112
+                orderHead.put(CEB_PREFIX + "ebpName", "速贸云");
113
+                // 电商平台代码
114
+                orderHead.put(CEB_PREFIX + "ebpCode", "无");
115
+                // 电商企业名称
116
+                orderHead.put(CEB_PREFIX + "ebcName", payload.copName);
117
+                // 电商企业代码 (电商企业的海关注册登记编号)
118
+                orderHead.put(CEB_PREFIX + "ebcCode", payload.copCode);
119
+                // 系统唯一序号
120
+                orderHead.put(CEB_PREFIX + "guid", exchange.getGuid());
121
+                // 业务状态 (1 - 暂存, 2 - 报送)默认为2
122
+                orderHead.put(CEB_PREFIX + "appStatus", "2");
123
+                // 商品价格 (商品实际价格,含非现金抵扣金额)
124
+                orderHead.put(CEB_PREFIX + "goodsValue", String.valueOf(item.getFlowPrice()));
125
+                // 企业报送类型 (1 - 新增, 2 - 变更, 3 - 删除)默认为1
126
+                orderHead.put(CEB_PREFIX + "appType", "2");
127
+                // 运杂费(不包含在商品价格中的运杂费,无则填写0)
128
+                orderHead.put(CEB_PREFIX + "freight", "0");
129
+                // 订单类型 (I - 进口, E - 9610出口, B - 9710出口, W - 9810出口)
130
+                orderHead.put(CEB_PREFIX + "orderType", "B");
131
+                // 订单编号 (交易平台订单编号,长度不能超过60位)
132
+                orderHead.put(CEB_PREFIX + "orderNo", exchange.getOrderDetailVO().getOrder().getSn());
133
+                // 企业报送时间(格式YYYYMMDDhhmmss)
134
+                orderHead.put(CEB_PREFIX + "appTime", timeStr);
135
+                // 币制 (限定为人民币 - 142)
136
+                orderHead.put(CEB_PREFIX + "currency", "142");
137
+                // 备注
138
+                orderHead.put(CEB_PREFIX + "note", "");
139
+
140
+                Map<String, Object> orderLists = new HashMap<>(32);
141
+                // 2. 表体
142
+                // 商品序号(从1开始递增序号)
143
+                orderLists.put(CEB_PREFIX + "gnum", i + 1);
144
+                // 企业商品货号(SKU编号,最长30位)
145
+                orderLists.put(CEB_PREFIX + "itemNo", item.getSkuId());
146
+                // 企业商品名称(中文名称)
147
+                orderLists.put(CEB_PREFIX + "itemName", item.getGoodsName());
148
+                // 企业商品描述
149
+                orderLists.put(CEB_PREFIX + "itemDescribe", item.getGoodsName());
150
+                // 商品条形码 (非必填)
151
+                orderLists.put(CEB_PREFIX + "barCode", "");
152
+                // 单位
153
+                // TODO 单位映射 必填
154
+                orderLists.put(CEB_PREFIX + "unit", id2Unit.get(item.getGoodsId()));
155
+                // 币制 (限定为人民币 - 142)
156
+                orderLists.put(CEB_PREFIX + "currency", "142");
157
+                // 数量
158
+                orderLists.put(CEB_PREFIX + "qty", item.getNum());
159
+                // 单价
160
+                orderLists.put(CEB_PREFIX + "price", item.getGoodsPrice());
161
+                // 商品价格 (商品实际价格,含非现金抵扣金额)
162
+                orderLists.put(CEB_PREFIX + "totalPrice", String.valueOf(item.getFlowPrice()));
163
+                // 备注
164
+                orderLists.put(CEB_PREFIX + "note", "");
165
+
166
+                // 放入订单列表
167
+                itemMap.put(CEB_PREFIX + "OrderHead", orderHead);
168
+                itemMap.put(CEB_PREFIX + "OrderList", orderLists);
169
+                orderList.add(itemMap);
170
+            }
171
+        });
172
+
173
+        return orderList;
174
+    }
175
+
176
+    /**
177
+     * 基础报文传输Map列表
178
+     * @param payload 存根信息
179
+     * @return 基础报文传输Map列表
180
+     */
181
+    private List<Map<String, Object>> baseTransfer(CustomPayload payload){
182
+        List<Map<String, Object>> transfers = new ArrayList<>();
183
+        Map<String, Object> transfer = new HashMap<>(8);
184
+        // 传输企业代码
185
+        transfer.put(CEB_PREFIX + "copCode", payload.copCode);
186
+        // 传输企业名称
187
+        transfer.put(CEB_PREFIX + "copName", payload.copName);
188
+        // 报文传输模式
189
+        transfer.put(CEB_PREFIX + "dxpMode", "DXP");
190
+        // 报文传输编号
191
+        // TODO 待平台方确认
192
+        transfer.put(CEB_PREFIX + "dxpId", payload.dxpId);
193
+        // 备注
194
+        transfer.put(CEB_PREFIX + "note", "");
195
+        transfers.add(transfer);
196
+        return transfers;
197
+    }
198
+
199
+}

+ 7 - 0
framework/src/main/java/cn/lili/modules/order/order/service/OrderService.java

@@ -174,6 +174,13 @@ public interface OrderService extends IService<Order> {
174 174
     Traces getTraces(String orderSn);
175 175
 
176 176
     /**
177
+     * 订单推送海关
178
+     *
179
+     * @param orderSn 订单编号
180
+     */
181
+    void customsPush(String orderSn);
182
+
183
+    /**
177 184
      * 订单核验
178 185
      *
179 186
      * @param verificationCode 验证码

+ 13 - 0
framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java

@@ -19,6 +19,7 @@ import cn.lili.common.utils.SnowFlake;
19 19
 import cn.lili.modules.goods.entity.dto.GoodsCompleteMessage;
20 20
 import cn.lili.modules.member.entity.dto.MemberAddressDTO;
21 21
 import cn.lili.modules.order.cart.entity.dto.TradeDTO;
22
+import cn.lili.modules.order.customs.JiangyinServiceManager;
22 23
 import cn.lili.modules.order.order.aop.OrderLogPoint;
23 24
 import cn.lili.modules.order.order.entity.dos.Order;
24 25
 import cn.lili.modules.order.order.entity.dos.OrderItem;
@@ -142,6 +143,9 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
142 143
     @Autowired
143 144
     private TradeService tradeService;
144 145
 
146
+    @Autowired
147
+    private JiangyinServiceManager jiangyinServiceManager;
148
+
145 149
     @Override
146 150
     @Transactional(rollbackFor = Exception.class)
147 151
     public void intoDB(TradeDTO tradeDTO) {
@@ -446,6 +450,15 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
446 450
     }
447 451
 
448 452
     @Override
453
+    @OrderLogPoint(description = "'订单['+#orderSn+']申请报关'", orderSn = "#orderSn")
454
+    public void customsPush(String orderSn) {
455
+        //获取订单信息
456
+        OrderDetailVO detailVO = this.queryDetail(orderSn);
457
+        // 海关平台推送
458
+        jiangyinServiceManager.push(detailVO);
459
+    }
460
+
461
+    @Override
449 462
     @OrderLogPoint(description = "'订单['+#orderSn+']核销,核销码['+#verificationCode+']'", orderSn = "#orderSn")
450 463
     public Order take(String orderSn, String verificationCode) {
451 464
 

+ 7 - 0
seller-api/src/main/java/cn/lili/controller/order/OrderStoreController.java

@@ -174,4 +174,11 @@ public class OrderStoreController {
174 174
     public ResultMessage<List<OrderExportDTO>> queryExportOrder(OrderSearchParams orderSearchParams) {
175 175
         return ResultUtil.data(orderService.queryExportOrder(orderSearchParams));
176 176
     }
177
+
178
+    @ApiOperation(value = "申请报关")
179
+    @PostMapping(path = "/customs/push/{orderSn}")
180
+    public ResultMessage<Object> customsPush(@NotBlank(message = "订单编号不能为空") @PathVariable String orderSn) {
181
+        orderService.customsPush(orderSn);
182
+        return ResultUtil.data("推送成功");
183
+    }
177 184
 }