admin
2020-06-20 0ab8a2ea521a838124f517daf4e61dee971a6d4c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package com.ks.tool.bkz.util.tb;
 
import com.ks.tool.bkz.util.HttpUtil;
import com.ks.tool.bkz.vo.tb.ZheTaoKeConvertResult;
import net.sf.json.JSONObject;
 
import java.util.HashMap;
import java.util.Map;
 
public class ZheTaoKeApiUtil {
 
    private static String baseRequest(String baseUrl, Map<String, String> params) {
        params.put("appkey", "fe65b15d74d84c75b99578543da75264");
        String result = HttpUtil.get(baseUrl, params, null);
        return result;
    }
 
    /**
     * 获取淘口令
     * @param auctionId
     * @return
     */
    public static ZheTaoKeConvertResult getTkl(Long auctionId) {
        try {
            Map<String, String> params = new HashMap<>();
            params.put("sid", "34116");
            params.put("pid", "mm_106929643_20324269_81478350");
            params.put("num_iid", auctionId + "");
            params.put("signurl", 5 + "");
            String result = baseRequest("https://api.zhetaoke.com:10001/api/open_gaoyongzhuanlian.ashx", params);
            JSONObject resultJson = JSONObject.fromObject(result);
            if (resultJson.optInt("status") == 200) {
                JSONObject item= resultJson.optJSONArray("content").optJSONObject(0);
                return new ZheTaoKeConvertResult(item.optString("taobao_url"),item.optString("tkl"),item.optLong("tao_id"));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
 
 
}