| | |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.yeshi.fanli.entity.dy.DYOrder; |
| | | import com.yeshi.fanli.util.goods.douyin.vo.*; |
| | | import net.sf.json.JSONObject; |
| | | import org.apache.commons.httpclient.HttpClient; |
| | | import org.apache.commons.httpclient.HttpException; |
| | | import org.apache.commons.httpclient.methods.PostMethod; |
| | | import org.yeshi.utils.JsonUtil; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.yeshi.utils.StringUtil; |
| | | import org.yeshi.utils.TimeUtil; |
| | | |
| | | import java.io.IOException; |
| | | import java.lang.reflect.Type; |
| | |
| | | * @date 2022/8/8 15:45 |
| | | */ |
| | | public class CSJCPSApiUtil { |
| | | private static Logger debugLog=LoggerFactory.getLogger("debugLog"); |
| | | |
| | | private static String post(String url, String entity) { |
| | | HttpClient client = new HttpClient(); |
| | | client.getHostConfiguration().setProxy("192.168.3.122", 8888); |
| | | //client.getHostConfiguration().setProxy("192.168.3.122", 8888); |
| | | PostMethod method = new PostMethod(url); |
| | | method.addRequestHeader("Content-Type", "application/json;charset=UTF-8"); |
| | | method.setRequestHeader("Content-Type", "application/json;charset=UTF-8"); |
| | |
| | | |
| | | private static String baseRequest(String path, JSONObject data, CSJAppInfo appInfo) { |
| | | String url = "http://ecom.pangolin-sdk-toutiao.com" + path; |
| | | |
| | | debugLog.info("抖音请求开始:链接-{}",url); |
| | | |
| | | com.alibaba.fastjson.JSONObject params = new com.alibaba.fastjson.JSONObject(); |
| | | params.put("app_id", appInfo.getAppId()); |
| | | params.put("timestamp", System.currentTimeMillis() / 1000); |
| | |
| | | } |
| | | |
| | | if (filter.getThird_cids() != null) { |
| | | data.put("third_cids", JSONObject.fromObject(filter.getThird_cids())); |
| | | data.put("third_cids", new Gson().toJson(filter.getThird_cids())); |
| | | } |
| | | |
| | | if (filter.getPrice_min() != null) { |
| | |
| | | } |
| | | |
| | | |
| | | public static DYGoodsDetail goodsDetail(Long goodsId) { |
| | | List<DYGoodsDetail> list = goodsDetails(Arrays.asList(new Long[]{goodsId})); |
| | | if (list == null || list.size() == 0) { |
| | | return null; |
| | | } else { |
| | | return list.get(0); |
| | | } |
| | | } |
| | | |
| | | |
| | | public static DYOrderResult orderList(DYOrderFilter filter) { |
| | | JSONObject data = JSONObject.fromObject(new Gson().toJson( filter)); |
| | | JSONObject data = JSONObject.fromObject(new Gson().toJson(filter)); |
| | | |
| | | |
| | | String result = baseRequest("/order/search", data); |
| | |
| | | return null; |
| | | } |
| | | JSONObject dataJson = resultJson.optJSONObject("data"); |
| | | return new Gson().fromJson(dataJson.toString(),DYOrderResult.class); |
| | | return new Gson().fromJson(dataJson.toString(), DYOrderResult.class); |
| | | } |
| | | |
| | | public static DYOrder getOrderDetail(String orderId,int orderType){ |
| | | DYOrderFilter filter=new DYOrderFilter(); |
| | | public static DYOrder getOrderDetail(String orderId, int orderType) { |
| | | DYOrderFilter filter = new DYOrderFilter(); |
| | | filter.setOrder_type(orderType); |
| | | filter.setOrder_ids(Arrays.asList(new String[]{orderId})); |
| | | DYOrderResult result= orderList(filter); |
| | | if(result==null){ |
| | | DYOrderResult result = orderList(filter); |
| | | if (result == null) { |
| | | return null; |
| | | } |
| | | |
| | | if(result.getOrders()==null||result.getOrders().size()<=0){ |
| | | if (result.getOrders() == null || result.getOrders().size() <= 0) { |
| | | return null; |
| | | } |
| | | return result.getOrders().get(0); |
| | | } |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @return com.yeshi.fanli.util.goods.douyin.vo.DYAggregateH5Result |
| | | * @author hxh |
| | | * @description 聚合页H5 |
| | | * @date 15:48 2022/9/30 |
| | | * @param: filter |
| | | * @return com.yeshi.fanli.util.goods.douyin.vo.DYAggregateH5Result |
| | | **/ |
| | | public static DYAggregateH5Result aggregateH5(DYAggregateH5Filter filter) { |
| | | JSONObject data = new JSONObject(); |
| | | if (filter.getDevice() != null) { |
| | | data.put("device", new Gson().toJson(filter.getDevice())); |
| | | } |
| | | if(filter.getExternal_info()!=null){ |
| | | if (filter.getExternal_info() != null) { |
| | | data.put("external_info", filter.getExternal_info()); |
| | | } |
| | | |
| | | if(filter.getMaterial_id()!=null){ |
| | | if (filter.getMaterial_id() != null) { |
| | | data.put("material_id", filter.getMaterial_id()); |
| | | } |
| | | |
| | | if(filter.getProduct_url()!=null){ |
| | | if (filter.getProduct_url() != null) { |
| | | data.put("product_url", filter.getProduct_url()); |
| | | } |
| | | |
| | |
| | | return null; |
| | | } |
| | | JSONObject dataJson = resultJson.optJSONObject("data"); |
| | | return new Gson().fromJson(dataJson.toString(),DYAggregateH5Result.class); |
| | | return new Gson().fromJson(dataJson.toString(), DYAggregateH5Result.class); |
| | | } |
| | | |
| | | |
| | | public static void main(String[] args) { |
| | | goodsDetails(Arrays.asList(new Long[]{3549871967593209780L})); |
| | | getOrderDetail("4984002890650177191",1); |
| | | // 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); |
| | | // System.out.println(result); |
| | | goodsDetails(Arrays.asList(new Long[]{3549871967593209780L})); |
| | | // DYOrder order = getOrderDetail("5005828634543277401", 1); |
| | | |
| | | } |
| | | |