From 54c250656c2e471ad48ecaa8ccce16ec9d7eb8bd Mon Sep 17 00:00:00 2001 From: yujian <yujian@163.com> Date: 星期二, 03 十二月 2019 13:52:38 +0800 Subject: [PATCH] Merge branch 'div' of ssh://193.112.35.168:29418/fanli-server into div --- fanli/src/main/java/com/yeshi/fanli/util/jd/JDApiUtil.java | 84 +++++++++++++++++++++++++++-------------- 1 files changed, 55 insertions(+), 29 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/util/jd/JDApiUtil.java b/fanli/src/main/java/com/yeshi/fanli/util/jd/JDApiUtil.java index e43684c..540be68 100644 --- a/fanli/src/main/java/com/yeshi/fanli/util/jd/JDApiUtil.java +++ b/fanli/src/main/java/com/yeshi/fanli/util/jd/JDApiUtil.java @@ -114,7 +114,7 @@ * * @return */ - public static String convertLink(String materialId, String couponUrl, String positionId, String ext1) { + public static String convertLink1(String materialId, String couponUrl, String positionId, String ext1) { JSONObject json = new JSONObject(); json.put("materialId", materialId); json.put("siteId", APP_ID); @@ -142,23 +142,37 @@ return resultJson.optJSONObject("data").optString("clickURL"); } - /** - * 杞摼鎺�-鐭繛鎺� - * - * @param materialId - * @param couponUrl - * @param positionId - * @param ext1 - * @return - */ - public static String convertShortLink(String materialId, String couponUrl, String positionId, String ext1) { - String url = convertLink(materialId, couponUrl, positionId, ext1); - // 鏆傛椂娉ㄩ噴 - // if (!StringUtil.isNullOrEmpty(url)) { - // url = HttpUtil.getShortLink(url); - // } - return url; + public static String convertLinkWithSubUnionId(String materialId, String couponUrl, String positionId, + String subUnionId) { + JSONObject json = new JSONObject(); + json.put("materialId", materialId); + json.put("siteId", APP_ID); + json.put("positionId", positionId); + + if (!StringUtil.isNullOrEmpty(couponUrl)) + json.put("couponUrl", couponUrl); + + if (!StringUtil.isNullOrEmpty(subUnionId)) + json.put("subUnionId", subUnionId); + + //1锛氶暱閾撅紝 2 锛氱煭閾� 锛�3锛� 闀块摼+鐭摼 + json.put("chainType", 3); + JSONObject root = new JSONObject(); + root.put("promotionCodeReq", json); + + String result = baseRequest2("jd.union.open.promotion.bysubunionid.get", null, root); + + JSONObject resultJson = JSONObject.fromObject(result); + result = resultJson.optJSONObject("jd_union_open_promotion_bysubunionid_get_response").optString("result"); + System.out.println(result); + if (result == null) { + return null; + } + + resultJson = JSONObject.fromObject(result); + return resultJson.optJSONObject("data").optString("shortURL"); } + public static JDGoods queryGoodsDetail(Long skuId) { List<Long> skuIdList = new ArrayList<>(); @@ -417,18 +431,20 @@ } }; Collections.sort(couponInfoList, cm); -// if (couponInfoList.size() > 0) { -// // 璁剧疆鍒镐俊鎭负鏈�鎺ヨ繎鐨勪竴涓� -// for (int i = couponInfoList.size() - 1; i >= 0; i--) { -// if (couponInfoList.get(i).getQuota().compareTo(goods.getPrice()) <= 0) { -// goods.setCouponInfo(couponInfoList.get(i)); -// break; -// } -// } -// if (goods.getCouponInfo() == null) -// goods.setCouponInfo(couponInfoList.get(0)); -// } -// + // if (couponInfoList.size() > 0) { + // // 璁剧疆鍒镐俊鎭负鏈�鎺ヨ繎鐨勪竴涓� + // for (int i = couponInfoList.size() - 1; i >= 0; i--) { + // if + // (couponInfoList.get(i).getQuota().compareTo(goods.getPrice()) + // <= 0) { + // goods.setCouponInfo(couponInfoList.get(i)); + // break; + // } + // } + // if (goods.getCouponInfo() == null) + // goods.setCouponInfo(couponInfoList.get(0)); + // } + // goods.setCouponInfoList(couponInfoList); } @@ -679,4 +695,14 @@ return null; } + public static void test() { + JSONObject json = new JSONObject(); + json.put("materialId", "https://item.jd.com/32376790478.html"); + json.put("ext1", "437032"); + JSONObject root = new JSONObject(); + root.put("promotionCodeReq", json); + String result = baseRequest2("jd.union.open.promotion.bysubunionid.get", null, root); + System.out.println(result); + } + } -- Gitblit v1.8.0