From 24a8d17e007545f7426c48352109aa1a9c6587ee Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期三, 06 五月 2020 12:02:09 +0800 Subject: [PATCH] IOS上线隐藏我的界面的banner与超级会员升级信息 --- fanli/src/main/java/com/yeshi/fanli/util/vip/VipApiUtil.java | 122 +++++++++++++++++++++++++++++++++++----- 1 files changed, 106 insertions(+), 16 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/util/vip/VipApiUtil.java b/fanli/src/main/java/com/yeshi/fanli/util/vip/VipApiUtil.java index 63f336f..7d6ed49 100644 --- a/fanli/src/main/java/com/yeshi/fanli/util/vip/VipApiUtil.java +++ b/fanli/src/main/java/com/yeshi/fanli/util/vip/VipApiUtil.java @@ -9,12 +9,18 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.UUID; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.HttpException; import org.apache.commons.httpclient.methods.PostMethod; import org.yeshi.utils.StringUtil; +import com.google.gson.Gson; +import com.yeshi.fanli.dto.vip.VIPSearchResult; +import com.yeshi.fanli.dto.vip.goods.VIPGoodsInfo; + +import net.sf.json.JSONArray; import net.sf.json.JSONObject; /** @@ -68,18 +74,9 @@ * @param taskParams * @return */ - private static String baseRequest(String service, String method, Map<String, String> taskParams) { + private static String baseRequest(String service, String method, JSONObject taskParams) { Map<String, String> systemParams = getSystemParams(service, method); - JSONObject json = new JSONObject(); - for (Iterator<String> its = taskParams.keySet().iterator(); its.hasNext();) { - String key = its.next(); - String value = taskParams.get(key); - json.put(key, value); - } - JSONObject root = new JSONObject(); - root.put("request",json); - - String sign = getSign(systemParams, root); + String sign = getSign(systemParams, taskParams); systemParams.put("sign", sign); String baseUrl = "https://gw.vipapis.com"; baseUrl += "?"; @@ -94,7 +91,7 @@ baseUrl += key + "=" + value + "&"; } baseUrl = baseUrl.endsWith("&") ? baseUrl.substring(0, baseUrl.length() - 1) : baseUrl; - String result = post(baseUrl, root.toString()); + String result = post(baseUrl, taskParams.toString()); return result; } @@ -116,15 +113,108 @@ return null; } - public static void search() { + public static VIPSearchResult search() { Map<String, String> taskParams = new HashMap<>(); - taskParams.put("keyword","绗旇鏈�"); + taskParams.put("keyword", "澶瑰厠 鐢峰+ 甯﹀附"); taskParams.put("page", "1"); taskParams.put("pageSize", "20"); - taskParams.put("requestId", System.currentTimeMillis() + ""); + taskParams.put("requestId", UUID.randomUUID() + ""); // taskParams.put("priceStart", ""); // taskParams.put("priceEnd", ""); - String result = baseRequest("com.vip.adp.api.open.service.UnionGoodsService", "query", taskParams); + JSONObject root = new JSONObject(); + root.put("request", JSONObject.fromObject(taskParams)); + String result = baseRequest("com.vip.adp.api.open.service.UnionGoodsService", "query", root); + System.out.println(result); + List<VIPGoodsInfo> goodsList = new ArrayList<>(); + JSONObject resultJson = JSONObject.fromObject(result); + Gson gson = new Gson(); + if (resultJson.optInt("returnCode") == 0) { + resultJson = resultJson.optJSONObject("result"); + int count = resultJson.optInt("total"); + JSONArray array = resultJson.optJSONArray("goodsInfoList"); + for (int i = 0; i < array.size(); i++) { + VIPGoodsInfo info = gson.fromJson(array.optJSONObject(i).toString(), VIPGoodsInfo.class); + if (info != null) + goodsList.add(info); + } + return new VIPSearchResult(goodsList, count); + } + return null; + } + + /** + * 鍟嗗搧ID杞摼 + * + * @param goodsId + */ + public static void convertLink(String goodsId, String tag) { + JSONObject taskParams = new JSONObject(); + JSONArray goodsIdArray = new JSONArray(); + goodsIdArray.add(goodsId); + taskParams.put("goodsIdList", goodsIdArray); + taskParams.put("chanTag", tag); + taskParams.put("requestId", UUID.randomUUID() + ""); + String result = baseRequest("com.vip.adp.api.open.service.UnionUrlService", "genByGoodsId", + JSONObject.fromObject(taskParams)); + System.out.println(result); + } + + /** + * 鏍规嵁鍟嗗搧ID鑾峰彇鍟嗗搧璇︽儏 + * + * @param goodsIdList + * @return + */ + public static List<VIPGoodsInfo> getGoodsDetail(List<String> goodsIdList) { + JSONObject params = new JSONObject(); + params.put("goodsIdList", goodsIdList); + params.put("requestId", UUID.randomUUID()); + String result = baseRequest("com.vip.adp.api.open.service.UnionGoodsService", "getByGoodsIds", + JSONObject.fromObject(params)); + System.out.println(result); + JSONObject resultJson = JSONObject.fromObject(result); + Gson gson = new Gson(); + List<VIPGoodsInfo> goodsList = new ArrayList<>(); + if (resultJson.optInt("returnCode") == 0) { + JSONArray array = resultJson.optJSONArray("result"); + for (int i = 0; i < array.size(); i++) { + VIPGoodsInfo info = gson.fromJson(array.optJSONObject(i).toString(), VIPGoodsInfo.class); + if (info != null) + goodsList.add(info); + } + return goodsList; + } + return null; + } + + /** + * 鑾峰彇鍟嗗搧璇︽儏 + * + * @param goodsId + * @return + */ + public static VIPGoodsInfo getGoodsDetail(String goodsId) { + List<String> goodsIdList = new ArrayList<>(); + goodsIdList.add(goodsId); + List<VIPGoodsInfo> goodsList = getGoodsDetail(goodsIdList); + if (goodsList == null || goodsList.size() == 0) + return null; + return goodsList.get(0); + } + + public static void getOrderList() { + JSONObject params = new JSONObject(); + // params.put("status", 1); + params.put("orderTimeStart", System.currentTimeMillis() - 1000 * 60 * 60L); + params.put("orderTimeEnd", System.currentTimeMillis()); + params.put("page", 1); + // params.put("pageSize", ); + // params.put("updateTimeStart", ); + // params.put("updateTimeEnd", ); + params.put("requestId", UUID.randomUUID()); + JSONObject root = new JSONObject(); + root.put("queryModel", params); + String result = baseRequest("com.vip.adp.api.open.service.UnionOrderService", "orderList", root); System.out.println(result); } -- Gitblit v1.8.0