yujian
2020-06-29 ec60e757d358636dcac1589c44a66f3e276fe58c
fanli/src/main/java/com/yeshi/fanli/util/pinduoduo/PinDuoDuoApiUtil.java
@@ -80,6 +80,7 @@
    * @return
    */
   public static PDDGoodsResult searchGoods(PDDSearchFilter sf) {
      Gson gson = new GsonBuilder().disableHtmlEscaping().create();
      Map<String, String> map = new HashMap<>();
      map.put("type", "pdd.ddk.goods.search");
      if (sf.getOptId() != null)
@@ -102,6 +103,11 @@
         map.put("goods_id_list", "[" + StringUtil.concat(sf.getGoodsIdList(), ",") + "]");
      if (sf.getMerchantType() != null)
         map.put("merchant_type", sf.getMerchantType() + "");
      if (sf.getRangeList() != null && sf.getRangeList().size() > 0) {
         map.put("range_list",gson.toJson(sf.getRangeList()).toString());
      }
      map.put("pid", PID_FANLI);
      String result = baseRequest(map);
      JSONObject json = JSONObject.fromObject(result);
@@ -118,7 +124,6 @@
      Type type = new TypeToken<List<PDDGoodsDetail>>() {
      }.getType();
      Gson gson = new GsonBuilder().disableHtmlEscaping().create();
      List<PDDGoodsDetail> goodsList = gson.fromJson(array.toString(), type);
      int totalCount = root.optInt("total_count");
      return new PDDGoodsResult(totalCount, goodsList);
@@ -278,6 +283,7 @@
      map.put("p_id", pid);
      map.put("multi_group", "true");
      map.put("generate_weapp_webview", "true");
      // map.put("generate_weiboapp_webview", "true");
      JSONArray array = new JSONArray();
      array.add(goodsId);
@@ -303,6 +309,39 @@
   }
   /**
    * 微信小程序转链 @Title: convertWXMP @Description: @param goodsId @param
    * pid @param customParams @return PDDPromotionUrl 返回类型 @throws
    */
   public static String convertWXMP(Long goodsId, String pid, String customParams) {
      Map<String, String> map = new HashMap<>();
      map.put("type", "pdd.ddk.goods.promotion.url.generate");
      map.put("p_id", pid);
      map.put("multi_group", "true");
      map.put("generate_we_app", "true");
      JSONArray array = new JSONArray();
      array.add(goodsId);
      map.put("goods_id_list", array.toString());
      if (!StringUtil.isNullOrEmpty(customParams)) {
         map.put("custom_parameters", customParams);
      }
      String result = baseRequest(map);
      JSONObject root = JSONObject.fromObject(result);
      JSONObject json = root.optJSONObject("goods_promotion_url_generate_response");
      if (json == null) {
         return null;
      }
      JSONArray resultArray = json.optJSONArray("goods_promotion_url_list");
      if (resultArray != null && resultArray.size() > 0) {
         JSONObject weApp = resultArray.optJSONObject(0).optJSONObject("we_app_info");
         if (weApp != null)
            return weApp.optString("page_path");
      }
      return null;
   }
   /**
    * 商品转链
    * 
    * @param goodsId