瀏覽代碼

报文模型方式生成报文
- Map方式生成的报文无法保证字段顺序,针对报文建立模型
- 对比历史成功订单,货币应为美元(502)
- 对比历史成功订单,商品名称为原商品名称货号之前部分字符串

郑杰 3 年之前
父節點
當前提交
6556b14cb2

+ 77 - 0
framework/src/main/java/cn/lili/common/utils/JaxbUtils.java

@@ -0,0 +1,77 @@
1
+package cn.lili.common.utils;
2
+
3
+import javax.xml.bind.JAXBContext;
4
+import javax.xml.bind.Marshaller;
5
+import javax.xml.bind.Unmarshaller;
6
+import java.io.StringReader;
7
+import java.io.StringWriter;
8
+import java.util.ArrayList;
9
+import java.util.List;
10
+
11
+/**
12
+ * java2xml 工具类
13
+ */
14
+public class JaxbUtils {
15
+    /**
16
+     * JavaBean转换成xml
17
+     * 默认编码UTF-8
18
+     *
19
+     * @param obj
20
+     * @return
21
+     */
22
+    public static String convertToXml(Object obj) {
23
+        return convertToXml(obj, "UTF-8");
24
+    }
25
+
26
+    /**
27
+     * JavaBean转换成xml
28
+     *
29
+     * @param obj
30
+     * @param encoding
31
+     * @return
32
+     */
33
+    public static String convertToXml(Object obj, String encoding) {
34
+        String result = null;
35
+        try {
36
+            JAXBContext context = JAXBContext.newInstance(obj.getClass());
37
+            Marshaller marshaller = context.createMarshaller();
38
+            //格式化xml格式
39
+            marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
40
+
41
+            marshaller.setProperty(Marshaller.JAXB_ENCODING, encoding);
42
+            //去掉生成xml的默认报文头
43
+            marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
44
+
45
+            StringWriter writer = new StringWriter();
46
+            // 由于不能优雅的去掉 standalone="yes" 所以只能去掉整个头部,然后手动插入一个符合条件的头部   该行为不优雅需要进行升级
47
+            writer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "\n");
48
+            marshaller.marshal(obj, writer);
49
+            result = writer.toString();
50
+        } catch (Exception e) {
51
+            e.printStackTrace();
52
+        }
53
+        return result;
54
+    }
55
+
56
+    /**
57
+     * xml转换成JavaBean
58
+     *
59
+     * @param xml
60
+     * @param c
61
+     * @return
62
+     */
63
+    @SuppressWarnings("unchecked")
64
+    public static <T> T converyToJavaBean(String xml, Class<T> c) {
65
+        T t = null;
66
+        try {
67
+            JAXBContext context = JAXBContext.newInstance(c);
68
+            Unmarshaller unmarshaller = context.createUnmarshaller();
69
+            t = (T) unmarshaller.unmarshal(new StringReader(xml));
70
+        } catch (Exception e) {
71
+            e.printStackTrace();
72
+        }
73
+        return t;
74
+    }
75
+}
76
+
77
+

+ 14 - 0
framework/src/main/java/cn/lili/common/utils/StringUtils.java

@@ -176,6 +176,20 @@ public class StringUtils extends StrUtil {
176 176
         return str;
177 177
     }
178 178
 
179
+    /**
180
+     * 查询字符串中首个数字出现的位置
181
+     * @param str 查询的字符串
182
+     * @return 若存在,返回位置索引,否则返回-1;
183
+     */
184
+    public static int findFirstIndexNumberOfStr(String str){
185
+        int i = -1;
186
+        Matcher matcher = Pattern.compile("[A-Za-z0-9]").matcher(str);
187
+        if(matcher.find()) {
188
+            i = matcher.start();
189
+        }
190
+        return i;
191
+    }
192
+
179 193
 }
180 194
 
181 195
 

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

@@ -5,6 +5,8 @@ import lombok.AllArgsConstructor;
5 5
 import lombok.Data;
6 6
 import lombok.NoArgsConstructor;
7 7
 
8
+import java.util.Map;
9
+
8 10
 @Data
9 11
 @NoArgsConstructor
10 12
 @AllArgsConstructor
@@ -12,4 +14,8 @@ public class CustomsExchange {
12 14
     private String guid;
13 15
 
14 16
     private OrderDetailVO orderDetailVO;
17
+
18
+    private String appTime;
19
+
20
+    private Map<String, String> id2Unit;
15 21
 }

+ 7 - 2
framework/src/main/java/cn/lili/modules/order/customs/JiangyinServiceManager.java

@@ -17,6 +17,7 @@ import cn.lili.modules.order.order.mapper.OrderMapper;
17 17
 import com.dcits.app.encrypt.AESEncrypt;
18 18
 import lombok.extern.slf4j.Slf4j;
19 19
 import org.springframework.beans.factory.annotation.Autowired;
20
+import org.springframework.beans.factory.annotation.Qualifier;
20 21
 import org.springframework.stereotype.Component;
21 22
 
22 23
 import java.time.LocalDateTime;
@@ -38,7 +39,9 @@ public class JiangyinServiceManager {
38 39
     private final OrderCustomsMapper orderCustomsMapper;
39 40
 
40 41
     @Autowired
41
-    public JiangyinServiceManager(CustomsReqConverter converter, OrderMapper orderMapper, OrderCustomsMapper orderCustomsMapper) {
42
+    public JiangyinServiceManager(@Qualifier("jiangyinServiceBeanReqConverter") CustomsReqConverter converter,
43
+                                  OrderMapper orderMapper,
44
+                                  OrderCustomsMapper orderCustomsMapper) {
42 45
         this.converter = converter;
43 46
         this.orderMapper = orderMapper;
44 47
         this.orderCustomsMapper = orderCustomsMapper;
@@ -53,8 +56,9 @@ public class JiangyinServiceManager {
53 56
         OrderCustoms customsRec = new OrderCustoms();
54 57
         log.info("method input param: {}, payload: {}", JSONUtil.toJsonStr(detailVO), payload.toString());
55 58
         // 报文内容(密文)
56
-        CustomsExchange exchange = new CustomsExchange(UUID.randomUUID().toString(), detailVO);
59
+        CustomsExchange exchange = new CustomsExchange(UUID.randomUUID().toString(), detailVO ,null, null);
57 60
         final String reqMsg = converter.toReq(exchange, payload);
61
+        System.out.println(reqMsg);
58 62
         customsRec.setReqMsg(reqMsg);
59 63
         String encryptContent = AESEncrypt.encrypt(reqMsg, payload.signKey);
60 64
         // 构建参数
@@ -68,6 +72,7 @@ public class JiangyinServiceManager {
68 72
         // 开始调用
69 73
         Map<String, Object> paramMap = BeanUtil.beanToMap(param);
70 74
         log.info("request body: {}", paramMap);
75
+//        String res = "";
71 76
         String res = HttpUtil.post(JIANGYIN_ORDER_PUSH_URL, paramMap, 30000);
72 77
         log.info("response msg: {}", res);
73 78
         customsRec.setResMsg(res);

+ 29 - 0
framework/src/main/java/cn/lili/modules/order/customs/NameSpace.java

@@ -0,0 +1,29 @@
1
+package cn.lili.modules.order.customs;
2
+
3
+/**
4
+ * xml 命名空间
5
+ */
6
+public class NameSpace {
7
+
8
+    /**
9
+     * order 订单节点
10
+     */
11
+    public static final String NAMESPACE_CEB_URI = "http://www.chinaport.gov.cn/ceb";
12
+
13
+
14
+    /**
15
+     * dep终端节点报文
16
+     */
17
+    public static final String NAMESPACE_DXP_URI = "http://www.chinaport.gov.cn/dxp";
18
+
19
+    /**
20
+     * xsi规范
21
+     */
22
+    public static final String NAMESPACE_XSI_URI = "http://www.w3.org/2001/XMLSchema-instance";
23
+
24
+    /**
25
+     * 签名节点xml
26
+     */
27
+    public static final String NAMESPACE_DS_URL = "http://www.w3.org/2000/09/xmldsig#";
28
+
29
+}

+ 72 - 0
framework/src/main/java/cn/lili/modules/order/customs/converter/JiangyinServiceBeanReqConverter.java

@@ -0,0 +1,72 @@
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.common.exception.ServiceException;
8
+import cn.lili.common.utils.JaxbUtils;
9
+import cn.lili.modules.goods.entity.dos.Goods;
10
+import cn.lili.modules.goods.entity.dto.GoodsSearchParams;
11
+import cn.lili.modules.goods.service.GoodsService;
12
+import cn.lili.modules.order.customs.CustomPayload;
13
+import cn.lili.modules.order.customs.CustomsExchange;
14
+import cn.lili.modules.order.customs.model.CEB303Message;
15
+import cn.lili.modules.order.order.entity.dos.OrderItem;
16
+import org.springframework.beans.factory.annotation.Autowired;
17
+import org.springframework.stereotype.Component;
18
+
19
+import java.time.LocalDateTime;
20
+import java.util.Map;
21
+import java.util.Optional;
22
+import java.util.stream.Collectors;
23
+
24
+import static cn.lili.common.enums.ResultCode.ORDER_CUSTOMS_ERROR;
25
+
26
+@Component
27
+public class JiangyinServiceBeanReqConverter implements CustomsReqConverter{
28
+
29
+    private final GoodsService goodsService;
30
+
31
+    @Autowired
32
+    public JiangyinServiceBeanReqConverter(GoodsService goodsService) {
33
+        this.goodsService = goodsService;
34
+    }
35
+
36
+    @Override
37
+    public String toReq(CustomsExchange exchange, CustomPayload payload) {
38
+        return JaxbUtils.convertToXml(converterToMsg(exchange, payload));
39
+    }
40
+
41
+    @Override
42
+    public String getSign(String content, String key) {
43
+        try {
44
+            return DigestUtil.md5Hex(content + key).toUpperCase();
45
+        } catch (Exception e) {
46
+            e.printStackTrace();
47
+        }
48
+        throw new ServiceException(ORDER_CUSTOMS_ERROR, "签名生成失败");
49
+    }
50
+
51
+    @Override
52
+    public boolean checkSuccess(String resStr) {
53
+        Map<String, Object> map = XmlUtil.xmlToMap(resStr);
54
+        return Optional
55
+                .ofNullable(map.get("success"))
56
+                .map(String::valueOf)
57
+                .filter("true"::equalsIgnoreCase)
58
+                .isPresent();
59
+    }
60
+
61
+    private CEB303Message converterToMsg(CustomsExchange exchange, CustomPayload payload){
62
+        exchange.setAppTime(DateUtil.format(LocalDateTime.now(), DatePattern.PURE_DATETIME_PATTERN));
63
+        // 批量获取商品信息
64
+        String ids = exchange.getOrderDetailVO().getOrderItems().stream().map(OrderItem::getGoodsId).collect(Collectors.joining(","));
65
+        GoodsSearchParams params = new GoodsSearchParams();
66
+        params.setId(ids);
67
+        exchange.setId2Unit(
68
+                goodsService.queryListByParams(params).stream().collect(Collectors.toMap(Goods::getId, Goods::getGoodsUnit))
69
+        );
70
+        return new CEB303Message(exchange, payload);
71
+    }
72
+}

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

@@ -79,7 +79,7 @@ public class JiangyinServiceReqConverter implements CustomsReqConverter{
79 79
      * @return 符合报文格式的Map
80 80
      */
81 81
     private Map<String, Object> orderToMap(CustomsExchange exchange, CustomPayload payload){
82
-        Map<String, Object> reqMap = new HashMap<>();
82
+        Map<String, Object> reqMap = new LinkedHashMap<>();
83 83
         // 1. ceb:order
84 84
         reqMap.put(CEB_PREFIX + "Order", order(exchange, payload));
85 85
         // 2. ceb:baseTransfer
@@ -95,7 +95,7 @@ public class JiangyinServiceReqConverter implements CustomsReqConverter{
95 95
      * @return 报文List数据
96 96
      */
97 97
     private List<Map<String, Object>> order(CustomsExchange exchange, CustomPayload payload){
98
-        final String timeStr = DateUtil.format(LocalDateTime.now(), DatePattern.PURE_DATETIME_PATTERN);
98
+        exchange.setAppTime(DateUtil.format(LocalDateTime.now(), DatePattern.PURE_DATETIME_PATTERN));
99 99
         List<Map<String, Object>> orderList = new ArrayList<>(0);
100 100
         Optional.ofNullable(exchange.getOrderDetailVO().getOrderItems()).ifPresent(items -> {
101 101
             // 批量获取商品信息
@@ -110,34 +110,34 @@ public class JiangyinServiceReqConverter implements CustomsReqConverter{
110 110
                         Map<String, Object> itemMap = new HashMap<>();
111 111
                         Map<String, Object> orderHead = new HashMap<>(32);
112 112
                         // 1. 表头
113
-                        // 电商平台名称
114
-                        orderHead.put(CEB_PREFIX + "ebpName", "速贸云");
115
-                        // 电商平台代码
116
-                        orderHead.put(CEB_PREFIX + "ebpCode", "无");
117
-                        // 电商企业名称
118
-                        orderHead.put(CEB_PREFIX + "ebcName", payload.copName);
119
-                        // 电商企业代码 (电商企业的海关注册登记编号)
120
-                        orderHead.put(CEB_PREFIX + "ebcCode", payload.copCode);
121 113
                         // 系统唯一序号
122 114
                         orderHead.put(CEB_PREFIX + "guid", exchange.getGuid());
123
-                        // 业务状态 (1 - 暂存, 2 - 报送)默认为2
124
-                        orderHead.put(CEB_PREFIX + "appStatus", "1");
125
-                        // 商品价格 (商品实际价格,含非现金抵扣金额)
126
-                        orderHead.put(CEB_PREFIX + "goodsValue", String.valueOf(item.getFlowPrice()));
127 115
                         // 企业报送类型 (1 - 新增, 2 - 变更, 3 - 删除)默认为1
128 116
                         orderHead.put(CEB_PREFIX + "appType", "1");
129
-                        // 运杂费(不包含在商品价格中的运杂费,无则填写0)
130
-                        orderHead.put(CEB_PREFIX + "freight", "0");
117
+                        // 企业报送时间(格式YYYYMMDDhhmmss)
118
+                        orderHead.put(CEB_PREFIX + "appTime", exchange.getAppTime());
119
+                        // 业务状态 (1 - 暂存, 2 - 报送)默认为2
120
+                        orderHead.put(CEB_PREFIX + "appStatus", "2");
131 121
                         // 订单类型 (I - 进口, E - 9610出口, B - 9710出口, W - 9810出口)
132 122
                         orderHead.put(CEB_PREFIX + "orderType", "B");
133 123
                         // 订单编号 (交易平台订单编号,长度不能超过60位)
134 124
                         orderHead.put(CEB_PREFIX + "orderNo", exchange.getOrderDetailVO().getOrder().getSn());
135
-                        // 企业报送时间(格式YYYYMMDDhhmmss)
136
-                        orderHead.put(CEB_PREFIX + "appTime", timeStr);
125
+                        // 电商平台代码
126
+                        orderHead.put(CEB_PREFIX + "ebpCode", "无");
127
+                        // 电商平台名称
128
+                        orderHead.put(CEB_PREFIX + "ebpName", "速贸云");
129
+                        // 电商企业代码 (电商企业的海关注册登记编号)
130
+                        orderHead.put(CEB_PREFIX + "ebcCode", payload.copCode);
131
+                        // 电商企业名称
132
+                        orderHead.put(CEB_PREFIX + "ebcName", payload.copName);
133
+                        // 商品价格 (商品实际价格,含非现金抵扣金额)
134
+                        orderHead.put(CEB_PREFIX + "goodsValue", String.valueOf(item.getFlowPrice()));
135
+                        // 运杂费(不包含在商品价格中的运杂费,无则填写0)
136
+                        orderHead.put(CEB_PREFIX + "freight", "0");
137 137
                         // 币制 (限定为人民币 - 142)
138 138
                         orderHead.put(CEB_PREFIX + "currency", "142");
139 139
                         // 备注
140
-                        orderHead.put(CEB_PREFIX + "note", "");
140
+                        orderHead.put(CEB_PREFIX + "note", "test");
141 141
 
142 142
                         Map<String, Object> orderLists = new HashMap<>(32);
143 143
                         // 2. 表体
@@ -163,7 +163,7 @@ public class JiangyinServiceReqConverter implements CustomsReqConverter{
163 163
                         // 商品价格 (商品实际价格,含非现金抵扣金额)
164 164
                         orderLists.put(CEB_PREFIX + "totalPrice", String.valueOf(item.getFlowPrice()));
165 165
                         // 备注
166
-                        orderLists.put(CEB_PREFIX + "note", "");
166
+                        orderLists.put(CEB_PREFIX + "note", "test");
167 167
 
168 168
                         // 放入订单列表
169 169
                         itemMap.put(CEB_PREFIX + "OrderHead", orderHead);

+ 54 - 0
framework/src/main/java/cn/lili/modules/order/customs/model/BaseTransfer.java

@@ -0,0 +1,54 @@
1
+package cn.lili.modules.order.customs.model;
2
+
3
+import lombok.AllArgsConstructor;
4
+import lombok.Builder;
5
+import lombok.Data;
6
+import lombok.NoArgsConstructor;
7
+
8
+import javax.xml.bind.annotation.XmlAccessType;
9
+import javax.xml.bind.annotation.XmlAccessorType;
10
+import javax.xml.bind.annotation.XmlElement;
11
+import javax.xml.bind.annotation.XmlRootElement;
12
+
13
+import static cn.lili.modules.order.customs.NameSpace.NAMESPACE_CEB_URI;
14
+
15
+@Builder
16
+@Data
17
+@AllArgsConstructor
18
+@NoArgsConstructor
19
+@XmlAccessorType(XmlAccessType.FIELD)
20
+@XmlRootElement(name = "BaseTransfer ", namespace = NAMESPACE_CEB_URI)
21
+public class BaseTransfer {
22
+
23
+    /**
24
+     * 传输企业代码  报文传输的企业代码(需要与接入客户端的企 业身份一致)
25
+     */
26
+    @XmlElement(namespace = NAMESPACE_CEB_URI)
27
+    private String copCode;
28
+
29
+    /**
30
+     * 传输企业名称
31
+     */
32
+    @XmlElement(namespace = NAMESPACE_CEB_URI)
33
+    private String copName;
34
+
35
+    /**
36
+     * 报文传输模式  默认为DXP;指中国电子口岸数据交换平台
37
+     */
38
+    @XmlElement(namespace = NAMESPACE_CEB_URI)
39
+    private String dxpMode;
40
+
41
+    /**
42
+     * 报文传输编号  向中国电子口岸数据中心申请数据交换平台 的用户编号
43
+     */
44
+    @XmlElement(namespace = NAMESPACE_CEB_URI)
45
+    private String dxpId;
46
+
47
+    /**
48
+     * 备注
49
+     */
50
+    @XmlElement(namespace = NAMESPACE_CEB_URI)
51
+    private String note;
52
+}
53
+
54
+

+ 48 - 0
framework/src/main/java/cn/lili/modules/order/customs/model/CEB303Message.java

@@ -0,0 +1,48 @@
1
+package cn.lili.modules.order.customs.model;
2
+
3
+import cn.lili.modules.order.customs.CustomPayload;
4
+import cn.lili.modules.order.customs.CustomsExchange;
5
+import lombok.Builder;
6
+import lombok.Data;
7
+import lombok.NoArgsConstructor;
8
+
9
+import javax.xml.bind.annotation.*;
10
+
11
+import static cn.lili.modules.order.customs.NameSpace.NAMESPACE_CEB_URI;
12
+
13
+
14
+/**
15
+ * 海关出口订单报文
16
+ */
17
+@Data
18
+@NoArgsConstructor
19
+@XmlAccessorType(XmlAccessType.FIELD)
20
+@XmlRootElement(name = "CEB303Message" , namespace = NAMESPACE_CEB_URI)
21
+public class CEB303Message {
22
+
23
+    @XmlAttribute(name = "guid")
24
+    private String guid;
25
+
26
+    @XmlAttribute(name = "version")
27
+    private String version;
28
+
29
+    @XmlElement(name = "Order", namespace = NAMESPACE_CEB_URI)
30
+    private Order order;
31
+
32
+    @XmlElement(name = "BaseTransfer", namespace = NAMESPACE_CEB_URI)
33
+    private BaseTransfer baseTransfer;
34
+
35
+    public CEB303Message(CustomsExchange exchange, CustomPayload payload){
36
+        this.guid = exchange.getGuid();
37
+        this.order = new Order(exchange, payload);
38
+        this.baseTransfer = BaseTransfer.builder()
39
+                .copCode(payload.copCode)
40
+                .copName(payload.copName)
41
+                .dxpMode("DXP")
42
+                .dxpId(payload.dxpId)
43
+                .build();
44
+        this.version = "1.0";
45
+    }
46
+
47
+}
48
+

+ 81 - 0
framework/src/main/java/cn/lili/modules/order/customs/model/Order.java

@@ -0,0 +1,81 @@
1
+package cn.lili.modules.order.customs.model;
2
+
3
+import cn.lili.common.enums.JGS20Unit;
4
+import cn.lili.modules.order.customs.CustomPayload;
5
+import cn.lili.modules.order.customs.CustomsExchange;
6
+import cn.lili.modules.order.order.entity.dos.OrderItem;
7
+import lombok.Data;
8
+import lombok.NoArgsConstructor;
9
+
10
+import javax.xml.bind.annotation.XmlAccessType;
11
+import javax.xml.bind.annotation.XmlAccessorType;
12
+import javax.xml.bind.annotation.XmlElement;
13
+import javax.xml.bind.annotation.XmlRootElement;
14
+import java.math.BigDecimal;
15
+import java.util.LinkedList;
16
+import java.util.List;
17
+
18
+import static cn.lili.modules.order.customs.NameSpace.NAMESPACE_CEB_URI;
19
+
20
+/**
21
+ * 订单业务节点
22
+ */
23
+@Data
24
+@NoArgsConstructor
25
+@XmlAccessorType(XmlAccessType.FIELD)
26
+@XmlRootElement(name = "Order ", namespace = NAMESPACE_CEB_URI)
27
+public class Order {
28
+
29
+    @XmlElement(name = "OrderHead", namespace = NAMESPACE_CEB_URI)
30
+    private OrderHead orderHead;
31
+
32
+    @XmlElement(name = "OrderList", namespace = NAMESPACE_CEB_URI)
33
+    private List<OrderList> orderList;
34
+
35
+    public Order(CustomsExchange exchange, CustomPayload payload){
36
+        this.orderHead = OrderHead.builder()
37
+                .guid(exchange.getGuid())
38
+                .appType("1")
39
+                .appTime(exchange.getAppTime())
40
+                .appStatus("2")
41
+                .orderType("B")
42
+                .orderNo(exchange.getOrderDetailVO().getOrder().getSn())
43
+                .ebpCode("无")
44
+                .ebpName("速贸云")
45
+                .ebcCode(payload.copCode)
46
+                .ebcName(payload.copName)
47
+                .goodsValue(BigDecimal.valueOf(exchange.getOrderDetailVO().getOrder().getFlowPrice()))
48
+                .freight(BigDecimal.ZERO)
49
+                .currency("502")
50
+                .build();
51
+        this.orderList = new LinkedList<>();
52
+        final List<OrderItem> orderItems = exchange.getOrderDetailVO().getOrderItems();
53
+        String cnName;
54
+
55
+        for (int i = 0; i < orderItems.size(); i++) {
56
+            OrderItem item = orderItems.get(i);
57
+            cnName = exchange.getId2Unit().get(item.getGoodsId());
58
+
59
+            orderList.add(
60
+                    OrderList.builder()
61
+                            .gnum(i + 1)
62
+                            .itemNo(item.getGoodsCode())
63
+                            .itemName(item.getGoodsShortName())
64
+                            .itemDescribe("")
65
+                            .barCode("")
66
+                            .unit(JGS20Unit.ofCnName(cnName).code)
67
+                            .currency("502")
68
+                            .qty(item.getNum())
69
+                            .price(BigDecimal.valueOf(item.getGoodsPrice()))
70
+                            .totalPrice(BigDecimal.valueOf(item.getFlowPrice()))
71
+                            .note("")
72
+                            .build()
73
+            );
74
+        }
75
+    }
76
+
77
+}
78
+
79
+
80
+
81
+

+ 111 - 0
framework/src/main/java/cn/lili/modules/order/customs/model/OrderHead.java

@@ -0,0 +1,111 @@
1
+package cn.lili.modules.order.customs.model;
2
+
3
+
4
+
5
+import lombok.AllArgsConstructor;
6
+import lombok.Builder;
7
+import lombok.Data;
8
+import lombok.NoArgsConstructor;
9
+
10
+import javax.xml.bind.annotation.XmlAccessType;
11
+import javax.xml.bind.annotation.XmlAccessorType;
12
+import javax.xml.bind.annotation.XmlElement;
13
+import javax.xml.bind.annotation.XmlRootElement;
14
+import java.math.BigDecimal;
15
+
16
+import static cn.lili.modules.order.customs.NameSpace.NAMESPACE_CEB_URI;
17
+
18
+@Builder
19
+@Data
20
+@NoArgsConstructor
21
+@AllArgsConstructor
22
+@XmlAccessorType(XmlAccessType.FIELD)
23
+@XmlRootElement(name = "OrderHead ", namespace = NAMESPACE_CEB_URI)
24
+public class OrderHead {
25
+
26
+    /**
27
+     * 系统唯一序号 企业系统生成36位唯一序号 (英文字母大写)
28
+     */
29
+    @XmlElement(namespace = NAMESPACE_CEB_URI)
30
+    private String guid;
31
+
32
+    /**
33
+     * 报送类型 企业报送类型。1-新增 2-变 更 3-删除。
34
+     */
35
+    @XmlElement(namespace = NAMESPACE_CEB_URI)
36
+    private String appType;
37
+
38
+    /**
39
+     * 报送时间 格式:YYYYMMDDhhmmss。
40
+     */
41
+    @XmlElement(namespace = NAMESPACE_CEB_URI)
42
+    private String appTime;
43
+
44
+    /**
45
+     * 报送状态  企业报送状态。1-暂存,2-申 报。填写2时,Signature节点必须 填写。
46
+     */
47
+    @XmlElement(namespace = NAMESPACE_CEB_URI)
48
+    private String appStatus;
49
+
50
+    /**
51
+     * 订单类型
52
+     */
53
+    @XmlElement(namespace = NAMESPACE_CEB_URI)
54
+    private String orderType;
55
+
56
+    /**
57
+     * 订单编号
58
+     */
59
+    @XmlElement(namespace = NAMESPACE_CEB_URI)
60
+    private String orderNo;
61
+
62
+    /**
63
+     * 电商平台代码
64
+     */
65
+    @XmlElement(namespace = NAMESPACE_CEB_URI)
66
+    private String ebpCode;
67
+
68
+    /**
69
+     * 电商平台名称
70
+     */
71
+    @XmlElement(namespace = NAMESPACE_CEB_URI)
72
+    private String ebpName;
73
+
74
+    /**
75
+     * 电商
76
+     * 企业代码
77
+     */
78
+    @XmlElement(namespace = NAMESPACE_CEB_URI)
79
+    private String ebcCode;
80
+
81
+    /**
82
+     * 电商企业名称
83
+     */
84
+    @XmlElement(namespace = NAMESPACE_CEB_URI)
85
+    private String ebcName;
86
+
87
+    /**
88
+     * 商品金额
89
+     */
90
+    @XmlElement(namespace = NAMESPACE_CEB_URI)
91
+    private BigDecimal goodsValue;
92
+
93
+    /**
94
+     * 运杂费
95
+     */
96
+    @XmlElement(namespace = NAMESPACE_CEB_URI)
97
+    private BigDecimal freight;
98
+
99
+    /**
100
+     * 币制
101
+     */
102
+    @XmlElement(namespace = NAMESPACE_CEB_URI)
103
+    private String currency;
104
+
105
+    /**
106
+     * 备注
107
+     */
108
+    @XmlElement(namespace = NAMESPACE_CEB_URI)
109
+    private String note;
110
+
111
+}

+ 90 - 0
framework/src/main/java/cn/lili/modules/order/customs/model/OrderList.java

@@ -0,0 +1,90 @@
1
+package cn.lili.modules.order.customs.model;
2
+
3
+
4
+import lombok.AllArgsConstructor;
5
+import lombok.Builder;
6
+import lombok.Data;
7
+import lombok.NoArgsConstructor;
8
+
9
+import javax.xml.bind.annotation.XmlAccessType;
10
+import javax.xml.bind.annotation.XmlAccessorType;
11
+import javax.xml.bind.annotation.XmlElement;
12
+import javax.xml.bind.annotation.XmlRootElement;
13
+import java.math.BigDecimal;
14
+
15
+import static cn.lili.modules.order.customs.NameSpace.NAMESPACE_CEB_URI;
16
+
17
+@Builder
18
+@Data
19
+@NoArgsConstructor
20
+@AllArgsConstructor
21
+@XmlAccessorType(XmlAccessType.FIELD)
22
+@XmlRootElement(name = "OrderList ", namespace = NAMESPACE_CEB_URI)
23
+public class OrderList {
24
+
25
+    /**
26
+     * 序号 从1开始递增
27
+     */
28
+    @XmlElement(namespace = NAMESPACE_CEB_URI)
29
+    private Integer gnum;
30
+
31
+    /**
32
+     * 企业商品货号
33
+     */
34
+    @XmlElement(namespace = NAMESPACE_CEB_URI)
35
+    private String itemNo;
36
+
37
+    /**
38
+     * 企业商品名称
39
+     */
40
+    @XmlElement(namespace = NAMESPACE_CEB_URI)
41
+    private String itemName;
42
+
43
+    /**
44
+     * 企业商品描述
45
+     */
46
+    @XmlElement(namespace = NAMESPACE_CEB_URI)
47
+    private String itemDescribe;
48
+
49
+    /**
50
+     * 条形码 否
51
+     */
52
+    @XmlElement(namespace = NAMESPACE_CEB_URI)
53
+    private String barCode;
54
+
55
+    /**
56
+     * 计量单位
57
+     */
58
+    @XmlElement(namespace = NAMESPACE_CEB_URI)
59
+    private String unit;
60
+
61
+    /**
62
+     * 币制
63
+     */
64
+    @XmlElement(namespace = NAMESPACE_CEB_URI)
65
+    private String currency;
66
+
67
+    /**
68
+     * 数量
69
+     */
70
+    @XmlElement(namespace = NAMESPACE_CEB_URI)
71
+    private Integer qty;
72
+
73
+    /**
74
+     * 单价
75
+     */
76
+    @XmlElement(namespace = NAMESPACE_CEB_URI)
77
+    private BigDecimal price;
78
+
79
+    /**
80
+     * 总价
81
+     */
82
+    @XmlElement(namespace = NAMESPACE_CEB_URI)
83
+    private BigDecimal totalPrice;
84
+
85
+    /**
86
+     * 备注
87
+     */
88
+    @XmlElement(namespace = NAMESPACE_CEB_URI)
89
+    private String note;
90
+}

+ 14 - 0
framework/src/main/java/cn/lili/modules/order/customs/model/package-info.java

@@ -0,0 +1,14 @@
1
+@XmlSchema(
2
+        xmlns = {
3
+                @XmlNs(prefix = "ceb", namespaceURI = NAMESPACE_CEB_URI),
4
+                @XmlNs(prefix = "xsi", namespaceURI = NAMESPACE_XSI_URI)
5
+        }
6
+)
7
+package cn.lili.modules.order.customs.model;
8
+
9
+import javax.xml.bind.annotation.XmlNs;
10
+import javax.xml.bind.annotation.XmlSchema;
11
+
12
+import static cn.lili.modules.order.customs.NameSpace.NAMESPACE_CEB_URI;
13
+import static cn.lili.modules.order.customs.NameSpace.NAMESPACE_XSI_URI;
14
+

+ 17 - 0
framework/src/main/java/cn/lili/modules/order/order/entity/dos/OrderItem.java

@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
4 4
 import cn.hutool.json.JSONUtil;
5 5
 import cn.lili.common.utils.BeanUtil;
6 6
 import cn.lili.common.utils.SnowFlake;
7
+import cn.lili.common.utils.StringUtils;
7 8
 import cn.lili.modules.order.cart.entity.dto.TradeDTO;
8 9
 import cn.lili.modules.order.cart.entity.vo.CartSkuVO;
9 10
 import cn.lili.modules.order.cart.entity.vo.CartVO;
@@ -154,4 +155,20 @@ public class OrderItem extends BaseEntity {
154 155
         this.priceDetail = JSONUtil.toJsonStr(priceDetail);
155 156
     }
156 157
 
158
+    /**
159
+     * @return 商品名称
160
+     */
161
+    public String getGoodsShortName(){
162
+        return goodsName.substring(0, StringUtils.findFirstIndexNumberOfStr(goodsName));
163
+    }
164
+
165
+    /**
166
+     * @return 商品货号
167
+     */
168
+    public String getGoodsCode(){
169
+        int i = StringUtils.findFirstIndexNumberOfStr(goodsName);
170
+        int endIdx = goodsName.indexOf(" ");
171
+        return goodsName.substring(i, endIdx == -1 ? goodsName.length() : endIdx);
172
+    }
173
+
157 174
 }