From 8ce7c720e4e7a604b0ff770349b5556f39d37759 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期一, 13 九月 2021 11:44:38 +0800
Subject: [PATCH] 好省呗应用兼容

---
 fanli/src/main/java/com/yeshi/fanli/util/vipshop/VipShopApiUtil.java |   37 ++++++++++++++++++++++++++++++++++---
 1 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/util/vipshop/VipShopApiUtil.java b/fanli/src/main/java/com/yeshi/fanli/util/vipshop/VipShopApiUtil.java
index dcfd6c4..bfb6fab 100644
--- a/fanli/src/main/java/com/yeshi/fanli/util/vipshop/VipShopApiUtil.java
+++ b/fanli/src/main/java/com/yeshi/fanli/util/vipshop/VipShopApiUtil.java
@@ -40,6 +40,9 @@
     private final static String appKey = "f9e7f22f";
     private final static String appSecret = "9B2291352497FAF42B2DF44BFCF62316";
 
+    //鏄惁閲囩敤璁㈠崟渚犺浆閾�
+    private final static boolean CONVERT_DINGDANXIA = true;
+
     /**
      * 鑾峰彇绛惧悕
      *
@@ -209,6 +212,11 @@
      * @param goodsId
      */
     public static VIPConvertResultDTO convertLink(String goodsId, String tag) {
+
+        if (CONVERT_DINGDANXIA) {
+            return DingDanXiaApiUtil.convertLink(goodsId, tag);
+        }
+
         JSONObject taskParams = new JSONObject();
         JSONArray goodsIdArray = new JSONArray();
         goodsIdArray.add(goodsId);
@@ -216,6 +224,31 @@
         taskParams.put("chanTag", tag);
         taskParams.put("requestId", System.currentTimeMillis() + "_" + UUID.randomUUID());
         String result = baseRequest("com.vip.adp.api.open.service.UnionUrlService", "genByGoodsId",
+                JSONObject.fromObject(taskParams));
+        System.out.println(result);
+        JSONObject resultJSON = JSONObject.fromObject(result);
+        if (resultJSON.optInt("returnCode") == 0) {
+            String re = resultJSON.optJSONObject("result").optJSONArray("urlInfoList").optJSONObject(0).toString();
+            return new Gson().fromJson(re, VIPConvertResultDTO.class);
+        }
+        return null;
+    }
+
+
+    public static VIPConvertResultDTO convertLinkByUrl(String url, String tag) {
+
+        if (CONVERT_DINGDANXIA) {
+            return DingDanXiaApiUtil.convertLinkByUrl(url, tag);
+        }
+        JSONObject taskParams = new JSONObject();
+        JSONArray urlArray = new JSONArray();
+        urlArray.add(url);
+        taskParams.put("urlList", urlArray);
+        if (tag != null) {
+            taskParams.put("chanTag", tag);
+        }
+        taskParams.put("requestId", System.currentTimeMillis() + "_" + UUID.randomUUID());
+        String result = baseRequest("com.vip.adp.api.open.service.UnionUrlService", "genByVIPUrl",
                 JSONObject.fromObject(taskParams));
         System.out.println(result);
         JSONObject resultJSON = JSONObject.fromObject(result);
@@ -292,9 +325,7 @@
     }
 
     public static void main(String[] args) {
-
-        convertLink("6919237495414585303","437032");
-
+        convertLinkByUrl("https://t.vip.com/T7RyKKCJLj9", "437032");
     }
 
 }

--
Gitblit v1.8.0