From 0912f56a392bdf48315747c64ec0c18bf0aa29a6 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期三, 30 六月 2021 19:07:11 +0800
Subject: [PATCH] 礼金红包兼容

---
 fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoKeApiUtil.java |  204 ++++++++++++++++++---------------------------------
 1 files changed, 72 insertions(+), 132 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoKeApiUtil.java b/fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoKeApiUtil.java
index a7a3d09..cf505a0 100644
--- a/fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoKeApiUtil.java
+++ b/fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoKeApiUtil.java
@@ -1,5 +1,6 @@
 package com.yeshi.fanli.util.taobao;
 
+import com.google.gson.Gson;
 import com.yeshi.common.entity.PageEntity;
 import com.yeshi.common.entity.taobao.TaoBaoShopInfo;
 import com.yeshi.common.entity.taobao.TaoKeAppInfo;
@@ -188,6 +189,8 @@
         if (item.optBoolean("free_shipment"))
             goods.setFreeShipment(1);
 
+        goods.setMaterialLibTypes(item.optString("material_lib_type"));
+
         if (!StringUtil.isNullOrEmpty(item.optString("material_lib_type"))) {
             try {
                 String materialLibType = item.optString("material_lib_type");
@@ -374,7 +377,7 @@
         // 浠庤浆閾炬悳绱�
         TaoBaoGoodsBrief newGoods = specialConvertCoupon(goods.getAuctionId(),
                 new TaoKeAppInfo(TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET,
-                        TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT), specialId, relationId);
+                        TaoBaoConstant.TAOBAO_PID_DEFAULT), specialId, relationId);
 
         if (newGoods != null) {
             goods.setTkRate(newGoods.getTkRate());
@@ -455,7 +458,7 @@
         // 浠庤浆閾炬悳绱�
         TaoBaoGoodsBrief newGoods = specialConvertCoupon(goods.getAuctionId(),
                 new TaoKeAppInfo(TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET,
-                        TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT), null, null);
+                        TaoBaoConstant.TAOBAO_PID_DEFAULT), null, null);
 
         if (newGoods != null) {
             goods.setTkRate(newGoods.getTkRate());
@@ -911,7 +914,13 @@
             map.put("relation_id", relationId);
         }
 
+        if (app != null && app.getPid() != null) {
+            map.put("adzone_id", app.getPid().split("_")[3]);
+
+        }
+
         String resultStr = TaoKeBaseUtil.baseRequestForThreeTimes(map, app);
+        System.out.println(resultStr);
         JSONObject data = JSONObject.fromObject(resultStr);
         if (data.optJSONObject("tbk_dg_material_optional_response") != null
                 && data.optJSONObject("tbk_dg_material_optional_response").optJSONObject("result_list") != null) {
@@ -1533,32 +1542,6 @@
         return result;
     }
 
-    /**
-     * 浠庢窐瀹濋摼鎺ヤ腑瑙f瀽鍟嗗搧ID锛堥珮绾ф帴鍙o級
-     *
-     * @param link
-     * @return
-     */
-    public static String parseAuctionIdFromLink(String link) {
-        Map<String, String> map = new HashMap<>();
-        map.put("method", "taobao.tbk.item.click.extract");
-        map.put("click_url", link + "");
-
-        TaoKeAppInfo app = new TaoKeAppInfo(TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET,
-                TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID);
-        JSONObject resultJSON = null;
-        try {
-            resultJSON = TaoKeBaseUtil.baseRequest(map, app);
-            System.out.println(resultJSON);
-        } catch (TaoKeApiException e) {
-            e.printStackTrace();
-        }
-        if (resultJSON == null)
-            return null;
-
-        return null;
-
-    }
 
     public static String getAccessToken(String code, String appKey, String appSecret) {
         Map<String, String> map = new HashMap<>();
@@ -1796,64 +1779,6 @@
         return null;
     }
 
-    public static void juHuaSuan() {
-        Map<String, String> map = new HashMap<>();
-        map.put("method", "taobao.ju.items.search");
-        map.put("current_page", 1 + "");
-        map.put("page_size", 100 + "");
-        map.put("pid", "mm_124933865_43788020_381938426");
-
-        TaoKeAppInfo app = new TaoKeAppInfo();
-        app.setAppKey("24838852");
-        app.setAppSecret("bc8265e2bf8d8115329d652f9d3d4cd8");
-
-        try {
-            JSONObject json = TaoKeBaseUtil.baseRequest(map, app);
-            System.out.println(json);
-        } catch (TaoKeApiException e) {
-            e.printStackTrace();
-        }
-
-    }
-
-    public static void taoKeContent() {
-        Map<String, String> map = new HashMap<>();
-        map.put("method", "taobao.tbk.content.get");
-        map.put("adzone_id", TaoBaoConstant.TAOBAO_RELATION_PID_DEFAULT.split("_")[3]);
-        map.put("type", "1");
-        map.put("count", "100");
-
-        TaoKeAppInfo app = new TaoKeAppInfo();
-        app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY);
-        app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
-        try {
-            JSONObject json = TaoKeBaseUtil.baseRequest(map, app);
-            System.out.println(json);
-        } catch (TaoKeApiException e) {
-            e.printStackTrace();
-        }
-    }
-
-    public static void taoKeContentSource(String contentId, String source) {
-        Map<String, String> map = new HashMap<>();
-        map.put("method", "taobao.tbk.dg.optimus.material");
-        map.put("adzone_id", TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT.split("_")[3]);
-        map.put("page_size", "10");
-        map.put("page_no", "1");
-        map.put("content_id", contentId);
-        map.put("content_source", source);
-        map.put("material_id", "1");
-
-        TaoKeAppInfo app = new TaoKeAppInfo();
-        app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY);
-        app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
-        try {
-            JSONObject json = TaoKeBaseUtil.baseRequest(map, app);
-            System.out.println(json);
-        } catch (TaoKeApiException e) {
-            e.printStackTrace();
-        }
-    }
 
     // AA5ISJ
 
@@ -1966,55 +1891,17 @@
         }
     }
 
-    public static void getTaoKeContentEffective() {
-        Map<String, String> map = new HashMap<>();
-        map.put("method", "taobao.tbk.dg.optimus.material");
-        map.put("adzone_id", TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID.split("_")[3]);
-        map.put("page_no", "1");
-        map.put("page_size", "20");
-        map.put("content_id", "8872035");
-
-        TaoKeAppInfo app = new TaoKeAppInfo();
-        app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY);
-        app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
-        try {
-            JSONObject json = TaoKeBaseUtil.baseRequest(map, app);
-            System.out.println(json);
-        } catch (TaoKeApiException e) {
-            e.printStackTrace();
-        }
-
-    }
-
-    public static void getTaoKeContent() {
-        Map<String, String> map = new HashMap<>();
-        map.put("method", "taobao.tbk.content.get");
-        map.put("adzone_id", TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID.split("_")[3]);
-        map.put("type", "1");
-
-        TaoKeAppInfo app = new TaoKeAppInfo();
-        app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY);
-        app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
-        try {
-            JSONObject json = TaoKeBaseUtil.baseRequest(map, app);
-            System.out.println(json);
-        } catch (TaoKeApiException e) {
-            e.printStackTrace();
-        }
-
-    }
-
     /**
      * 娣樺彛浠よ浆鍟嗗搧ID
      *
      * @param token
      * @return
      */
-    public static Long tokenConvertAuctionId(String token) throws TaoBaoTokenParseException {
+    public static TokenConvertResult tokenConvert(String token) throws TaoBaoTokenParseException {
         Map<String, String> map = new HashMap<>();
         map.put("method", "taobao.tbk.tpwd.convert");
         map.put("password_content", token);
-        map.put("adzone_id", TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT.split("_")[3]);
+        map.put("adzone_id", TaoBaoConstant.TAOBAO_PID_DEFAULT.split("_")[3]);
         TaoKeAppInfo app = new TaoKeAppInfo();
         app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY);
         app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
@@ -2024,7 +1911,10 @@
             System.out.println(json.toString());
 
             try {
-                return json.optJSONObject("tbk_tpwd_convert_response").optJSONObject("data").optLong("num_iid");
+                JSONObject data = json.optJSONObject("tbk_tpwd_convert_response").optJSONObject("data");
+                Gson gson = new Gson();
+
+                return gson.fromJson(data.toString(), TokenConvertResult.class);
             } catch (Exception e) {
 
                 return null;
@@ -2045,6 +1935,8 @@
     }
 
     // 娣樼ぜ閲戝垱寤�
+    //{"result":{"msg_code":"FAIL_CHECK_ITEM_DAILY_SEND_NUM_CHECK_ERROR","msg_info":"浠婃棩璇ュ晢鍝佹窐绀奸噾鍒涘缓鏁板凡瓒呬笂闄愶紝璇锋偍鏄庢棩鍐嶈瘯","success":false},"request_id":"10p30v02qadkq"}
+    //{"result":{"msg_code":"ASSET_ACCOUNT_BALANCE_NOT_ENOUGH","msg_info":"璐︽埛棰勭畻涓嶈冻","success":false},"request_id":"5caz9izr7jqp"}
     public static TaoLiJinDTO createTaoLiJin(Long auctionId, String name, BigDecimal perface, int totalNum,
                                              Date sendStartTime, Date sendEndTime, Date useStartTime, Date useEndTime, TaoKeAppInfo app)
             throws TaoLiJinCreateException, TaoKeApiException {
@@ -2156,7 +2048,7 @@
         Map<String, String> map = new HashMap<>();
         map.put("method", "taobao.tbk.itemid.coupon.get");
         map.put("platform", 2 + "");
-        map.put("pid", TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID);
+        map.put("pid", TaoBaoConstant.TAOBAO_PID_DEFAULT);
         map.put("num_iids", auctionId + "");
         TaoKeAppInfo app = new TaoKeAppInfo();
         app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY);
@@ -2174,8 +2066,7 @@
      *
      * @return
      */
-    public static Date getTaoBaoSystemTime() {
-        Map<String, String> map = new HashMap<>();
+    public static Date getTaoBaoSystemTime() {   Map<String, String> map = new HashMap<>();
         map.put("method", "taobao.time.get");
         try {
             JSONObject json = TaoKeBaseUtil.baseRequest(map, false);
@@ -2185,6 +2076,7 @@
             e.printStackTrace();
         }
         return null;
+
     }
 
     /**
@@ -2261,13 +2153,13 @@
         map.put("method", "taobao.tbk.itemid.coupon.get");
         map.put("platform", auctionId + "");
         map.put("num_iids", auctionId + "");
-        map.put("pid", TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT);
+        map.put("pid", TaoBaoConstant.TAOBAO_PID_DEFAULT);
 
         List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
         JSONObject resultJSON = null;
         try {
             resultJSON = TaoKeBaseUtil.baseRequest(map, new TaoKeAppInfo(TaoBaoConstant.TAOBAO_AUTH_APPKEY,
-                    TaoBaoConstant.TAOBAO_AUTH_APPSECRET, TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT));
+                    TaoBaoConstant.TAOBAO_AUTH_APPSECRET, TaoBaoConstant.TAOBAO_PID_DEFAULT));
 
             JSONObject response = resultJSON.optJSONObject("tbk_dg_optimus_material_response");
             if (response != null && response.optJSONObject("result_list") != null) {
@@ -2331,6 +2223,54 @@
         public BigDecimal coupon_start_fee;// 鍒歌捣濮嬮噾棰�
     }
 
+    public static class TokenConvertResult {
+        private Long num_iid;//	鍟嗗搧Id
+        private String click_url;//鍟嗗搧娣樺杞摼
+        private String seller_id;//搴楅摵鍗栧ID
+        private String origin_url;//鍏ュ弬娣樺彛浠ゅ搴斿師濮嬮摼鎺�
+        private String origin_pid;//鍏ュ弬娣樺彛浠ゆ帹骞块摼鎺ヤ腑鐨刾id锛屽鏋滀笉灞炰簬褰撳墠璋冪敤鐨勬帹骞胯�呭垯灞曠ず鈥�0鈥�
+
+        public Long getNum_iid() {
+            return num_iid;
+        }
+
+        public void setNum_iid(Long num_iid) {
+            this.num_iid = num_iid;
+        }
+
+        public String getClick_url() {
+            return click_url;
+        }
+
+        public void setClick_url(String click_url) {
+            this.click_url = click_url;
+        }
+
+        public String getSeller_id() {
+            return seller_id;
+        }
+
+        public void setSeller_id(String seller_id) {
+            this.seller_id = seller_id;
+        }
+
+        public String getOrigin_url() {
+            return origin_url;
+        }
+
+        public void setOrigin_url(String origin_url) {
+            this.origin_url = origin_url;
+        }
+
+        public String getOrigin_pid() {
+            return origin_pid;
+        }
+
+        public void setOrigin_pid(String origin_pid) {
+            this.origin_pid = origin_pid;
+        }
+    }
+
 }
 
 

--
Gitblit v1.8.0