24282 2 yıl önce
ebeveyn
işleme
0c0b301905

+ 31 - 0
hx-kd100/src/main/java/com/fjhx/kd100/constant/KD100Status.java

@@ -0,0 +1,31 @@
+package com.fjhx.kd100.constant;
+
+/**
+ * 物流常量
+ */
+public interface KD100Status {
+
+    // 未找到快递信息
+    public static final Integer STATUS_N = -1;
+    // 在途
+    public static final Integer STATUS_0 = 0;
+    // 揽收
+    public static final Integer STATUS_1 = 1;
+    // 疑难
+    public static final Integer STATUS_2 = 2;
+    // 签收
+    public static final Integer STATUS_3 = 3;
+    // 退签
+    public static final Integer STATUS_4 = 4;
+    // 派件
+    public static final Integer STATUS_5 = 5;
+    // 退回
+    public static final Integer STATUS_6 = 6;
+    // 转投
+    public static final Integer STATUS_7 = 7;
+    // 清关
+    public static final Integer STATUS_8 = 8;
+    // 拒签
+    public static final Integer STATUS_14 = 14;
+
+}

+ 0 - 57
hx-kd100/src/main/java/com/fjhx/kd100/constant/LogisticsConstant.java

@@ -1,57 +0,0 @@
-package com.fjhx.kd100.constant;
-
-/**
- * 物流常量
- */
-public interface LogisticsConstant {
-
-    /**
-     * 状态
-     */
-    class Status {
-        // 未完成 / 未到货
-        public static final Integer STATUS_0 = 0;
-        // 已完成 / 已到货
-        public static final Integer STATUS_1 = 1;
-    }
-
-    /**
-     * 入库状态
-     */
-    class InStockStatus {
-        // 未入库
-        public static final Integer STATUS_10 = 10;
-        // 部分入库
-        public static final Integer STATUS_20 = 20;
-        // 已入库
-        public static final Integer STATUS_30 = 30;
-    }
-
-    /**
-     * 物流状态(快递100的状态)
-     */
-    class KD100Status {
-        // 未找到快递信息
-        public static final Integer STATUS_N = -1;
-        // 在途
-        public static final Integer STATUS_0 = 0;
-        // 揽收
-        public static final Integer STATUS_1 = 1;
-        // 疑难
-        public static final Integer STATUS_2 = 2;
-        // 签收
-        public static final Integer STATUS_3 = 3;
-        // 退签
-        public static final Integer STATUS_4 = 4;
-        // 派件
-        public static final Integer STATUS_5 = 5;
-        // 退回
-        public static final Integer STATUS_6 = 6;
-        // 转投
-        public static final Integer STATUS_7 = 7;
-        // 清关
-        public static final Integer STATUS_8 = 8;
-        // 拒签
-        public static final Integer STATUS_14 = 14;
-    }
-}

+ 48 - 39
hx-kd100/src/main/java/com/fjhx/kd100/util/KD100Util.java

@@ -7,8 +7,8 @@ import cn.hutool.http.HttpStatus;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.annotation.TableName;
+import com.fjhx.kd100.constant.KD100Status;
 import com.fjhx.kd100.constant.Kd100Constant;
-import com.fjhx.kd100.constant.LogisticsConstant;
 import com.fjhx.kd100.entity.config.po.ConfigInfo;
 import com.fjhx.kd100.entity.logistics.po.LogisticsInfo;
 import com.fjhx.kd100.service.config.ConfigInfoService;
@@ -86,11 +86,11 @@ public class KD100Util {
         KD100Result result = KD100Util.queryTrack(com, num);
         String message = result.getMessage();
         if (Objects.equals(message, "查询无结果,请隔段时间再查")) {
-            return saveInfo(com, num, LogisticsConstant.KD100Status.STATUS_N, businessId, businessType, cls);
+            return saveInfo(com, num, KD100Status.STATUS_N, businessId, businessType, cls);
         }
         if (Objects.equals(message, "ok")) {
             Integer state = result.getState();
-            if (!Objects.equals(state, LogisticsConstant.KD100Status.STATUS_3)) {
+            if (!Objects.equals(state, KD100Status.STATUS_3)) {
                 // 如果不是已签收状态,则开启订阅(物流状态跟踪并推送)
                 KD100Util.subscribe(com, num);
             }
@@ -101,42 +101,6 @@ public class KD100Util {
     }
 
     /**
-     * 保存快递信息
-     */
-    private static LogisticsInfo saveInfo(String com, String num, Integer state, Long businessId, Integer businessType, Class<?> cls) {
-
-        LogisticsInfo logisticsInfo = new LogisticsInfo();
-        logisticsInfo.setCompany(com);
-        logisticsInfo.setNumber(num);
-        logisticsInfo.setState(state);
-        logisticsInfo.setBusinessId(businessId);
-        logisticsInfo.setBusinessType(businessType);
-        logisticsInfo.setTableName(getTableName(cls));
-
-        LogisticsInfoService logisticsInfoService = SpringUtil.getBean(LogisticsInfoService.class);
-        logisticsInfoService.save(logisticsInfo);
-        return logisticsInfo;
-    }
-
-    public static String getTableName(Class<?> cls) {
-        Annotation[] annotations = cls.getAnnotations();
-        TableName tableName = null;
-        for (Annotation annotation : annotations) {
-            if (annotation instanceof TableName) {
-                tableName = (TableName) annotation;
-                break;
-            }
-        }
-
-        if (tableName != null) {
-            return tableName.value();
-        } else {
-            String name = cls.getSimpleName();
-            return StrUtil.toUnderlineCase(name);
-        }
-    }
-
-    /**
      * 订阅接口
      *
      * @param com 快递公司编码
@@ -209,10 +173,55 @@ public class KD100Util {
         }
     }
 
+    /**
+     * 获取表名
+     */
+    public static String getTableName(Class<?> cls) {
+        Annotation[] annotations = cls.getAnnotations();
+        TableName tableName = null;
+        for (Annotation annotation : annotations) {
+            if (annotation instanceof TableName) {
+                tableName = (TableName) annotation;
+                break;
+            }
+        }
+
+        if (tableName != null) {
+            return tableName.value();
+        } else {
+            String name = cls.getSimpleName();
+            return StrUtil.toUnderlineCase(name);
+        }
+    }
+
+    /**
+     * 保存快递信息
+     */
+    private static LogisticsInfo saveInfo(String com, String num, Integer state, Long businessId, Integer businessType, Class<?> cls) {
+
+        LogisticsInfo logisticsInfo = new LogisticsInfo();
+        logisticsInfo.setCompany(com);
+        logisticsInfo.setNumber(num);
+        logisticsInfo.setState(state);
+        logisticsInfo.setBusinessId(businessId);
+        logisticsInfo.setBusinessType(businessType);
+        logisticsInfo.setTableName(getTableName(cls));
+
+        LogisticsInfoService logisticsInfoService = SpringUtil.getBean(LogisticsInfoService.class);
+        logisticsInfoService.save(logisticsInfo);
+        return logisticsInfo;
+    }
+
+    /**
+     * 获取kd100回调地址
+     */
     private static String getCallbackUrl() {
         return HxConfig.getHttpUrl() + Kd100Constant.CALLBACK_URL;
     }
 
+    /**
+     * 获取租户快递100配置
+     */
     private static ConfigInfo getConfigInfo() {
         ConfigInfoService configInfoService = SpringUtil.getBean(ConfigInfoService.class);
         String tenantId = SecurityUtils.getTenantId();