| | |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.lang.reflect.Type; |
| | | import java.net.URLEncoder; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.HashMap; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.UUID; |
| | | import java.util.*; |
| | | |
| | | import com.yeshi.fanli.util.Constant; |
| | | import org.apache.commons.httpclient.HttpClient; |
| | | import org.apache.commons.httpclient.HttpException; |
| | | import org.apache.commons.httpclient.methods.PostMethod; |
| | |
| | | |
| | | /** |
| | | * TODO 未完成 唯品会接口 |
| | | * |
| | | * 商品接口链接:https://vop.vip.com/home#/api/method/detail/com.vip.adp.api.open.service.UnionGoodsService-1.3.0/getByGoodsIds |
| | | * @author Administrator |
| | | */ |
| | | public class VipShopApiUtil { |
| | |
| | | private final static String appKey = "f9e7f22f"; |
| | | private final static String appSecret = "9B2291352497FAF42B2DF44BFCF62316"; |
| | | |
| | | //是否采用订单侠转链 |
| | | private final static boolean CONVERT_DINGDANXIA = true; |
| | | |
| | | /** |
| | | * 获取签名 |
| | | * |
| | | * @param params |
| | | * @param systemParams |
| | | * @param taskParams |
| | | * @return |
| | | */ |
| | | private static String getSign(Map<String, String> systemParams, JSONObject taskParams) { |
| | |
| | | if (searchFilter.getFieldName() != null) |
| | | taskParams.put("fieldName", searchFilter.getFieldName() + ""); |
| | | |
| | | //新增参数 |
| | | taskParams.put("chanTag", "default_pid"); |
| | | taskParams.put("openId", "default_open_id"); |
| | | taskParams.put("realCall", "true"); |
| | | |
| | | |
| | | |
| | | |
| | | JSONObject root = new JSONObject(); |
| | | root.put("request", JSONObject.fromObject(taskParams)); |
| | | String result = baseRequest("com.vip.adp.api.open.service.UnionGoodsService", "query", root); |
| | |
| | | taskParams.put("pageSize", 20 + ""); |
| | | taskParams.put("requestId", System.currentTimeMillis() + "_" + UUID.randomUUID()); |
| | | |
| | | //新增参数 |
| | | taskParams.put("chanTag", "default_pid"); |
| | | taskParams.put("openId", "default_open_id"); |
| | | taskParams.put("realCall", "true"); |
| | | |
| | | |
| | | JSONObject root = new JSONObject(); |
| | | root.put("request", JSONObject.fromObject(taskParams)); |
| | |
| | | * @param goodsId |
| | | */ |
| | | public static VIPConvertResultDTO convertLink(String goodsId, String tag) { |
| | | |
| | | if (CONVERT_DINGDANXIA) { |
| | | return DingDanXiaApiUtil.convertLink(goodsId, tag); |
| | | } |
| | | |
| | | JSONObject taskParams = new JSONObject(); |
| | | JSONArray goodsIdArray = new JSONArray(); |
| | | goodsIdArray.add(goodsId); |
| | |
| | | taskParams.put("chanTag", tag); |
| | | taskParams.put("requestId", System.currentTimeMillis() + "_" + UUID.randomUUID()); |
| | | String result = baseRequest("com.vip.adp.api.open.service.UnionUrlService", "genByGoodsId", |
| | | JSONObject.fromObject(taskParams)); |
| | | System.out.println(result); |
| | | JSONObject resultJSON = JSONObject.fromObject(result); |
| | | if (resultJSON.optInt("returnCode") == 0) { |
| | | String re = resultJSON.optJSONObject("result").optJSONArray("urlInfoList").optJSONObject(0).toString(); |
| | | return new Gson().fromJson(re, VIPConvertResultDTO.class); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | public static VIPConvertResultDTO convertLinkByUrl(String url, String tag) { |
| | | |
| | | if (CONVERT_DINGDANXIA) { |
| | | return DingDanXiaApiUtil.convertLinkByUrl(url, tag); |
| | | } |
| | | JSONObject taskParams = new JSONObject(); |
| | | JSONArray urlArray = new JSONArray(); |
| | | urlArray.add(url); |
| | | taskParams.put("urlList", urlArray); |
| | | if (tag != null) { |
| | | taskParams.put("chanTag", tag); |
| | | } |
| | | taskParams.put("requestId", System.currentTimeMillis() + "_" + UUID.randomUUID()); |
| | | String result = baseRequest("com.vip.adp.api.open.service.UnionUrlService", "genByVIPUrl", |
| | | JSONObject.fromObject(taskParams)); |
| | | System.out.println(result); |
| | | JSONObject resultJSON = JSONObject.fromObject(result); |
| | |
| | | JSONObject params = new JSONObject(); |
| | | params.put("goodsIdList", goodsIdList); |
| | | params.put("requestId", UUID.randomUUID()); |
| | | //新增参数 |
| | | params.put("chanTag", "default_pid"); |
| | | JSONObject request = new JSONObject(); |
| | | request.put("openId", "default_open_id"); |
| | | request.put("realCall", "true"); |
| | | params.put("request", request); |
| | | |
| | | String result = baseRequest("com.vip.adp.api.open.service.UnionGoodsService", "getByGoodsIds", |
| | | JSONObject.fromObject(params)); |
| | | System.out.println(result); |
| | |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | // VIPSearchFilter sf=new VIPSearchFilter(); |
| | | // sf.setKeyword("花卉"); |
| | | // sf.setPage(1); |
| | | // sf.setPageSize(Constant.PAGE_SIZE); |
| | | // search(sf); |
| | | |
| | | convertLink("6919237495414585303","437032"); |
| | | getGoodsDetail("6920553939593155215"); |
| | | |
| | | // convertLinkByUrl("https://t.vip.com/T7RyKKCJLj9", "437032"); |
| | | // convertLink("560392904","437032"); |
| | | // getOrderList(VipShopOrderQueryModel.createOrderSn(Arrays.asList(new String[]{"23090254293903"}),1)); |
| | | } |
| | | |
| | | } |