admin
2025-02-25 30d8e227e8d823b6c38c3b9c90ac2df03b63befe
fanli/src/main/java/com/yeshi/fanli/util/goods/douyin/CSJCPSApiUtil.java
@@ -10,6 +10,7 @@
import org.apache.commons.httpclient.methods.PostMethod;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.yeshi.utils.JsonUtil;
import org.yeshi.utils.StringUtil;
import org.yeshi.utils.TimeUtil;
@@ -25,7 +26,7 @@
 * @date 2022/8/8 15:45
 */
public class CSJCPSApiUtil {
    private static Logger debugLog=LoggerFactory.getLogger("debugLog");
    private static Logger debugLog = LoggerFactory.getLogger("debugLog");
    private static String post(String url, String entity) {
        HttpClient client = new HttpClient();
@@ -49,7 +50,7 @@
    private static String baseRequest(String path, JSONObject data, CSJAppInfo appInfo) {
        String url = "http://ecom.pangolin-sdk-toutiao.com" + path;
        debugLog.info("抖音请求开始:链接-{}",url);
        debugLog.info("抖音请求开始:链接-{}", url);
        com.alibaba.fastjson.JSONObject params = new com.alibaba.fastjson.JSONObject();
        params.put("app_id", appInfo.getAppId());
@@ -261,7 +262,7 @@
     * @param: extra_info 媒体传递扩展参数的字段, 字符只允许字⺟⼤⼩写、数字、 下划线,⻓度不超过20
     * @param: product_ext 商品搜索接⼝返回的 product.ext 字段, 尽量填写
     **/
    public static DYConvertResult goodsConvert(String product_url, String extra_info, String product_ext) {
    public static DYConvertResult goodsConvert(String product_url, String extra_info, String product_ext) throws Exception {
        JSONObject data = new JSONObject();
        data.put("product_url", product_url);
        data.put("external_info", extra_info);
@@ -269,17 +270,18 @@
        //转链类型:1、抖⾳ deep link;2、抖
        //⾳⼆维码;3、抖⾳⼝令。
        //默认返回抖⾳deeplink
        data.put("share_type", "[1,2,3]");
        data.put("share_type", "[1,3,4]");
        String result = baseRequest("/product/link", data);
        System.out.println(result);
        JSONObject resultJson = JSONObject.fromObject(result);
        if (resultJson.optInt("code") != 0) {
            return null;
            throw new Exception(resultJson.optString("desc"));
        }
        JSONObject dataJson = resultJson.optJSONObject("data");
        DYConvertResult bean = new DYConvertResult();
        bean.setDeeplink(dataJson.optString("dy_deeplink"));
        bean.setPassword(dataJson.optString("dy_password"));
        bean.setZlink(dataJson.optString("dy_zlink"));
        if (dataJson.optJSONObject("dy_qr_code") != null) {
            bean.setQrCode(dataJson.optJSONObject("dy_qr_code").optString("url"));
@@ -385,19 +387,33 @@
    }
    public static void main(String[] args) {
        DYOrderFilter filter=new DYOrderFilter();
        filter.setTime_type("update");
        filter.setOrder_type(1);
        filter.setSize(50);
        filter.setCursor("0");
        filter.setStart_time(TimeUtil.convertToTimeTemp("2022-12-18","yyyy-MM-dd")/1000);
        filter.setEnd_time(TimeUtil.convertToTimeTemp("2022-12-19","yyyy-MM-dd")/1000);
        DYOrderResult result = orderList(filter);
    public static JSONObject parseCommand(String command) {
        JSONObject data = new JSONObject();
        data.put("command", command);
        String result = baseRequest("/command_parse", data);
        System.out.println(result);
        // goodsDetails(Arrays.asList(new Long[]{3549871967593209780L}));
       // DYOrder order = getOrderDetail("5005828634543277401", 1);
        JSONObject resultJson = JSONObject.fromObject(result);
        if (resultJson.optInt("code") != 0) {
            return null;
        }
        JSONObject dataJson = resultJson.optJSONObject("data");
        return dataJson;
    }
    public static String parseProductId(String command) {
        JSONObject result = parseCommand(command);
        if (result != null) {
            if (result.optInt("command_type") == 1) {
                return result.optJSONObject("product_info").optString("product_id");
            }
        }
        return null;
    }
    public static void main(String[] args) throws Exception {
        DYConvertResult result =   goodsConvert("https://v.douyin.com/iNTutNyn/","123","132");
        System.out.printf(result.toString());
    }