From 21c1c197ec0dba6da332bf4119c262267dcfb191 Mon Sep 17 00:00:00 2001 From: yujian <yujian@163.com> Date: 星期二, 26 五月 2020 10:29:03 +0800 Subject: [PATCH] 粉丝信息同步调整 --- fanli/src/main/java/com/yeshi/fanli/util/vipshop/VipShopApiUtil.java | 70 ++++++++++++++++++++++++++--------- 1 files changed, 52 insertions(+), 18 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/util/vipshop/VipShopApiUtil.java b/fanli/src/main/java/com/yeshi/fanli/util/vipshop/VipShopApiUtil.java index 62c956b..098bf5e 100644 --- a/fanli/src/main/java/com/yeshi/fanli/util/vipshop/VipShopApiUtil.java +++ b/fanli/src/main/java/com/yeshi/fanli/util/vipshop/VipShopApiUtil.java @@ -2,6 +2,7 @@ import java.io.IOException; import java.io.UnsupportedEncodingException; +import java.lang.reflect.Type; import java.net.URLEncoder; import java.util.ArrayList; import java.util.Collections; @@ -17,8 +18,13 @@ import org.yeshi.utils.StringUtil; import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; +import com.yeshi.fanli.dto.vip.VIPSearchFilter; import com.yeshi.fanli.dto.vip.VIPSearchResult; import com.yeshi.fanli.dto.vip.goods.VIPGoodsInfo; +import com.yeshi.fanli.dto.vipshop.VipShopOrderQueryModel; +import com.yeshi.fanli.dto.vipshop.VipShopQueryOrderResultDTO; +import com.yeshi.fanli.entity.vipshop.VipShopOrder; import net.sf.json.JSONArray; import net.sf.json.JSONObject; @@ -113,14 +119,31 @@ return null; } - public static VIPSearchResult search() { + /** + * 鎼滅储 + * @Title: search + * @Description: + * @param searchFilter + * @return + * VIPSearchResult 杩斿洖绫诲瀷 + * @throws + */ + public static VIPSearchResult search(VIPSearchFilter searchFilter) { Map<String, String> taskParams = new HashMap<>(); - taskParams.put("keyword", "澶瑰厠 鐢峰+ 甯﹀附"); - taskParams.put("page", "1"); - taskParams.put("pageSize", "20"); - taskParams.put("requestId", UUID.randomUUID() + ""); - // taskParams.put("priceStart", ""); - // taskParams.put("priceEnd", ""); + taskParams.put("keyword", searchFilter.getKeyword()); + taskParams.put("page", searchFilter.getPage() + ""); + taskParams.put("pageSize", searchFilter.getPageSize() + ""); + taskParams.put("requestId", System.currentTimeMillis() + "_" + UUID.randomUUID()); + if (searchFilter.getPriceStart() != null) + taskParams.put("priceStart", searchFilter.getPriceStart()); + + if (searchFilter.getPriceEnd() != null) + taskParams.put("priceEnd", searchFilter.getPriceEnd()); + if (searchFilter.getOrder() != null) + taskParams.put("order", searchFilter.getOrder() + ""); + if (searchFilter.getFieldName() != null) + taskParams.put("fieldName", searchFilter.getFieldName() + ""); + JSONObject root = new JSONObject(); root.put("request", JSONObject.fromObject(taskParams)); String result = baseRequest("com.vip.adp.api.open.service.UnionGoodsService", "query", root); @@ -147,16 +170,21 @@ * * @param goodsId */ - public static void convertLink(String goodsId, String tag) { + public static String 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() + ""); + 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) { + return resultJSON.optJSONObject("result").optJSONArray("urlInfoList").optJSONObject(0).optString("url"); + } + return null; } /** @@ -202,20 +230,26 @@ 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", ); + public static VipShopQueryOrderResultDTO getOrderList(VipShopOrderQueryModel query) { + JSONObject params = JSONObject.fromObject(new Gson().toJson(query)); 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); + JSONObject json = JSONObject.fromObject(result); + if (json.optInt("returnCode") == 0) { + JSONObject resultJson = json.optJSONObject("result"); + int total = resultJson.optInt("total"); + JSONArray array = JSONArray.fromObject(resultJson.optJSONArray("orderInfoList")); + if (array != null) { + Type type = new TypeToken<ArrayList<VipShopOrder>>() { + }.getType(); + List<VipShopOrder> orderList = new Gson().fromJson(array.toString(), type); + return new VipShopQueryOrderResultDTO(orderList, total); + } + } + return null; } } -- Gitblit v1.8.0