admin
2021-06-30 0912f56a392bdf48315747c64ec0c18bf0aa29a6
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;
@@ -376,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());
@@ -457,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());
@@ -919,6 +920,7 @@
        }
        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) {
@@ -1540,32 +1542,6 @@
        return result;
    }
    /**
     * 从淘宝链接中解析商品ID(高级接口)
     *
     * @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<>();
@@ -1803,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
@@ -1973,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);
@@ -2031,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;
@@ -2165,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);
@@ -2183,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);
@@ -2194,6 +2076,7 @@
            e.printStackTrace();
        }
        return null;
    }
    /**
@@ -2270,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) {
@@ -2340,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;//入参淘口令推广链接中的pid,如果不属于当前调用的推广者则展示“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;
        }
    }
}