From e1a62ec62e7331d97af9302e90e1ce44af8235eb Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期三, 27 一月 2021 15:26:55 +0800 Subject: [PATCH] 拼多多授权绑定 --- fanli/src/main/java/com/yeshi/fanli/util/pinduoduo/PinDuoDuoApiUtil.java | 41 ++++++++++++++++++++++++++++++++++++++--- 1 files changed, 38 insertions(+), 3 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/util/pinduoduo/PinDuoDuoApiUtil.java b/fanli/src/main/java/com/yeshi/fanli/util/pinduoduo/PinDuoDuoApiUtil.java index a9c442d..6f65b64 100644 --- a/fanli/src/main/java/com/yeshi/fanli/util/pinduoduo/PinDuoDuoApiUtil.java +++ b/fanli/src/main/java/com/yeshi/fanli/util/pinduoduo/PinDuoDuoApiUtil.java @@ -79,10 +79,11 @@ * @param sf * @return */ - public static PDDGoodsResult searchGoods(PDDSearchFilter sf) { + public static PDDGoodsResult searchGoods(PDDSearchFilter sf, String customerParamters) { Gson gson = new GsonBuilder().disableHtmlEscaping().create(); Map<String, String> map = new HashMap<>(); map.put("type", "pdd.ddk.goods.search"); + map.put("custom_parameters", customerParamters); if (sf.getOptId() != null) map.put("opt_id", sf.getOptId() + ""); if (sf.getPage() != null) @@ -110,6 +111,7 @@ map.put("pid", PID_FANLI); String result = baseRequest(map); + System.out.println(result); JSONObject json = JSONObject.fromObject(result); JSONObject root = json.optJSONObject("goods_search_response"); if (root == null) { @@ -134,7 +136,7 @@ Long[] ids = new Long[goodsIds.size()]; goodsIds.toArray(ids); filter.setGoodsIdList(ids); - PDDGoodsResult result = searchGoods(filter); + PDDGoodsResult result = searchGoods(filter, Constant.PDD_SEARCH_CUSTOMER_PARAMS); if (result != null) return result.getGoodsList(); return null; @@ -307,6 +309,18 @@ return null; } + + public static PDDPromotionUrl convertResourceUrl(String pid) { + Map<String, String> map = new HashMap<>(); + map.put("type", "pdd.ddk.resource.url.gen"); + map.put("pid", pid); + map.put("resource_type", "39998"); + map.put("url", "https://mobile.yangkeduo.com/attendance.html?_pdd_fs=1&_pdd_tc=ffffff&_pdd_sbs=1&type=1&id=155075"); + String result = baseRequest(map); + System.out.println(result); + return null; + } + /** * 寰俊灏忕▼搴忚浆閾� @Title: convertWXMP @Description: @param goodsId @param * pid @param customParams @return PDDPromotionUrl 杩斿洖绫诲瀷 @throws @@ -349,7 +363,7 @@ * @return */ public static String getPromotionUrl(Long goodsId, String pid, String customParams) { - PDDPromotionUrl promotion = convert(goodsId, pid, customParams,false); + PDDPromotionUrl promotion = convert(goodsId, pid, customParams, false); if (promotion != null) { return promotion.getShortUrl(); } @@ -548,4 +562,25 @@ } else return true; } + + + public static String getAuthLink(String pid, String customParameters) { + Map<String, String> map = new HashMap<>(); + map.put("type", "pdd.ddk.rp.prom.url.generate"); + map.put("channel_type", 10 + ""); + map.put("custom_parameters", customParameters); + map.put("p_id_list", "[\"" + pid + "\"]"); + String result = baseRequest(map); + JSONObject resultJson = JSONObject.fromObject(result); + JSONArray array = resultJson.optJSONObject("rp_promotion_url_generate_response").optJSONArray("url_list"); + if (array != null && array.size() > 0) { + JSONObject item = array.optJSONObject(0); + String url = item.optString("url"); + if (StringUtil.isNullOrEmpty(url)) { + url = item.optString("mobile_url"); + } + return url; + } + return null; + } } -- Gitblit v1.8.0