yujian
2020-01-18 f4a0f2acc63d7785eab108419a4e16f5f688cb95
fanli/src/main/java/com/yeshi/fanli/util/pinduoduo/PinDuoDuoApiUtil.java
@@ -124,6 +124,17 @@
      return new PDDGoodsResult(totalCount, goodsList);
   }
   public static List<PDDGoodsDetail> listGoodsDetail(List<Long> goodsIds) {
      PDDSearchFilter filter = new PDDSearchFilter();
      Long[] ids = new Long[goodsIds.size()];
      goodsIds.toArray(ids);
      filter.setGoodsIdList(ids);
      PDDGoodsResult result = searchGoods(filter);
      if (result != null)
         return result.getGoodsList();
      return null;
   }
   /**
    * 运营频道商品查询API
    * 
@@ -267,6 +278,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);
@@ -287,6 +299,39 @@
         }.getType();
         Gson gson = new GsonBuilder().disableHtmlEscaping().create();
         return gson.fromJson(resultArray.optJSONObject(0).toString(), type);
      }
      return null;
   }
   /**
    * 微信小程序转链 @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;
   }
@@ -435,36 +480,36 @@
      return null;
   }
   /**
    * 获取商品详情
    * 
    * @param goodsId
    */
   public static PDDShopResult getShopList(Integer page,Long catId) {
   public static PDDShopResult getShopList(Integer page, Long catId) {
      JSONArray arrayType = new JSONArray();
      arrayType.add(3);
      Map<String, String> map = new HashMap<>();
      map.put("type", "pdd.ddk.merchant.list.get");
      if (catId != null)
         map.put("cat_id", catId +"");
         map.put("cat_id", catId + "");
      if (page != null)
         map.put("page_number", page +"");
         map.put("page_number", page + "");
      if (page != null)
         map.put("page_number", page +"");
         map.put("page_number", page + "");
      map.put("merchant_type_list", arrayType.toString());
      String result = baseRequest(map);
      JSONObject resultJson = JSONObject.fromObject(result);
      JSONObject root = resultJson.optJSONObject("merchant_list_response");
      if (root != null) {
         int totalCount = root.optInt("total");
         JSONArray array = root.optJSONArray("mall_search_info_vo_list");
         Type type = new TypeToken<List<PDDShopDetail>>() {}.getType();
         Type type = new TypeToken<List<PDDShopDetail>>() {
         }.getType();
         List<PDDShopDetail> listShop = new Gson().fromJson(array.toString(), type);
         return new PDDShopResult(totalCount, listShop);
      }