yujian
2019-08-27 d8359ddb48dab5cc797a9d552e11fde571f4920c
fanli/src/main/java/com/yeshi/fanli/util/pinduoduo/PinDuoDuoApiUtil.java
@@ -19,6 +19,7 @@
import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
import com.yeshi.fanli.dto.pdd.PDDGoodsResult;
import com.yeshi.fanli.dto.pdd.PDDOrderResult;
import com.yeshi.fanli.dto.pdd.PDDPromotionUrl;
import com.yeshi.fanli.dto.pdd.PDDSearchFilter;
import com.yeshi.fanli.entity.pdd.PDDOrder;
import com.yeshi.fanli.util.Constant;
@@ -257,7 +258,7 @@
    * @param customParams
    * @return
    */
   public static String convert(Long goodsId, String pid, String customParams) {
   public static PDDPromotionUrl convert(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);
@@ -278,8 +279,28 @@
         return null;
      }
      JSONArray resultArray = json.optJSONArray("goods_promotion_url_list");
      if (resultArray != null && resultArray.size() > 0)
         return resultArray.optJSONObject(0).optString("short_url");
      if (resultArray != null && resultArray.size() > 0) {
         Type type = new TypeToken<PDDPromotionUrl>() {
         }.getType();
         Gson gson = new GsonBuilder().disableHtmlEscaping().create();
         return gson.fromJson(resultArray.optJSONObject(0).toString(), type);
      }
      return null;
   }
   /**
    * 商品转链
    *
    * @param goodsId
    * @param pid
    * @param customParams
    * @return
    */
   public static String getPromotionUrl(Long goodsId, String pid, String customParams) {
      PDDPromotionUrl promotion = convert(goodsId, pid, customParams);
      if (promotion != null) {
         return promotion.getShortUrl();
      }
      return null;
   }
@@ -328,6 +349,20 @@
      return null;
   }
   public static PDDOrder getOrderDetail(String orderSn) {
      Map<String, String> map = new HashMap<>();
      map.put("type", "pdd.ddk.order.detail.get");
      map.put("order_sn", orderSn);
      String result = baseRequest(map);
      System.out.println(result);
      JSONObject json = JSONObject.fromObject(result);
      JSONObject root = json.optJSONObject("order_detail_response");
      if (root != null) {
         return new Gson().fromJson(root.toString(), PDDOrder.class);
      }
      return null;
   }
   /**
    * 获取商品详情
    *