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");
|
}
|
|
}
|