admin
2024-06-24 5d3b3b74afd2ac4cf21697fc38367b2f88170e9f
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
package com.taoke.autopay.utils.order;
 
import com.taoke.autopay.dto.DYOrderDto;
import com.taoke.autopay.exception.KeyOrderException;
import com.taoke.autopay.utils.HttpUtil;
import com.taoke.autopay.utils.JsonUtil;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
 
/**
 * @author hxh
 * @title: DYOrderApi
 * @description: 抖音订单接口
 * @date 2024/6/14 17:47
 */
public class DYOrderApi {
    private static Logger logger = LoggerFactory.getLogger("dyorderApiLogger");
 
    private static String requestByOrderNo1(String orderNo) {
        String url = String.format("https://api.youihuo.com/open/order.getFreeOrder?apiKey=sTIFFTyunIFZfp5i4V6g19PN9biudl4v&orderId=%s", orderNo);
        String result = HttpUtil.get(url);
        return result;
    }
 
    public static DYOrderDto getOrderDetail(String orderNo) throws KeyOrderException {
        String result = requestByOrderNo1(orderNo);
        JSONObject root = JSONObject.fromObject(result);
        if (root.optInt("code") != 1000) {
            logger.error(String.format("抖音订单查询出错:%s - %s",orderNo, result));
            throw new KeyOrderException(root.optString("message"));
        }
       JSONObject data = root.optJSONObject("data");
       return  JsonUtil.getSimpleGson().fromJson(data.toString(),DYOrderDto.class);
    }
 
    public static void main(String[] args) throws Exception {
        DYOrderDto dto = (DYOrderApi.getOrderDetail("6931134387948820382"));
        System.out.println("123123");
    }
 
}