Bläddra i källkod

回调接口暴露,先打印至日志,打印日志的报文供调试,后续需要的话手动计算解密存储至DB

郑杰 2 år sedan
förälder
incheckning
a733396c83

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

@@ -72,7 +72,6 @@ public class JiangyinServiceManager {
72 72
         // 开始调用
73 73
         Map<String, Object> paramMap = BeanUtil.beanToMap(param);
74 74
         log.info("request body: {}", paramMap);
75
-//        String res = "";
76 75
         String res = HttpUtil.post(JIANGYIN_ORDER_PUSH_URL, paramMap, 30000);
77 76
         log.info("response msg: {}", res);
78 77
         customsRec.setResMsg(res);

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

@@ -291,4 +291,11 @@ public interface OrderService extends IService<Order> {
291 291
      * @return 是否成功
292 292
      */
293 293
     boolean checkFictitiousOrder(String pintuanId, Integer requiredNum, Boolean fictitious);
294
+
295
+    /**
296
+     * 保存回执报文
297
+     * @param content 回执报文
298
+     * @param copMsgId 企业消息ID
299
+     */
300
+    void saveCustomsCallback(String content, String copMsgId);
294 301
 }

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

@@ -63,6 +63,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
63 63
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
64 64
 import com.baomidou.mybatisplus.core.metadata.IPage;
65 65
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
66
+import lombok.extern.slf4j.Slf4j;
66 67
 import org.apache.poi.ss.util.CellRangeAddressList;
67 68
 import org.apache.rocketmq.spring.core.RocketMQTemplate;
68 69
 import org.springframework.beans.factory.annotation.Autowired;
@@ -84,6 +85,7 @@ import java.util.stream.Collectors;
84 85
  * @author Chopper
85 86
  * @since 2020/11/17 7:38 下午
86 87
  */
88
+@Slf4j
87 89
 @Service
88 90
 public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements OrderService {
89 91
 
@@ -468,6 +470,13 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
468 470
     }
469 471
 
470 472
     @Override
473
+    public void saveCustomsCallback(String content, String copMsgId) {
474
+        // 根据copMsgId取出企业对应报关元数据
475
+        // 解密存储
476
+        log.info("receive callback message: [{}, {}]", content, copMsgId);
477
+    }
478
+
479
+    @Override
471 480
     @OrderLogPoint(description = "'订单['+#orderSn+']核销,核销码['+#verificationCode+']'", orderSn = "#orderSn")
472 481
     public Order take(String orderSn, String verificationCode) {
473 482
 

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

@@ -180,4 +180,15 @@ public class OrderStoreController {
180 180
     public ResultMessage<Object> customsPush(@NotBlank(message = "订单编号不能为空") @PathVariable String orderSn) {
181 181
         return ResultUtil.data(orderService.customsPush(orderSn)? "推送成功" : "推送失败");
182 182
     }
183
+
184
+    @ApiOperation(value = "报关回调接口")
185
+    @PostMapping(path = "/customs/callback")
186
+    public ResultMessage<Object> customsCallback(String signMsg, String content, String msgType, String copMsgId) {
187
+        log.info("callback param:[{},{},{},{}]", signMsg, content, msgType, copMsgId);
188
+        // String key = CustomPayload.JiangyinXingguang.signKey;
189
+        // Assert.isTrue(signMsg.equals(AesEncrypt.decrypt(content + key, key)));
190
+        // TODO 验签
191
+        orderService.saveCustomsCallback(content, copMsgId);
192
+        return ResultUtil.success();
193
+    }
183 194
 }

+ 1 - 0
seller-api/src/main/resources/application.yml

@@ -121,6 +121,7 @@ ignored:
121 121
     - /source/**
122 122
     - /store/passport/login/**
123 123
     - /store/passport/login/refresh/**
124
+    - /store/order/order/customs/callback
124 125
     - /druid/**
125 126
     - /swagger-ui.html
126 127
     - /doc.html