admin
2020-11-03 f71ae35c5b20e51c5fba91284cc436076c9c73df
fanli/src/main/java/com/yeshi/fanli/util/jd/JDApiUtil.java
@@ -13,6 +13,7 @@
import java.util.List;
import java.util.Map;
import com.sun.istack.NotNull;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.PostMethod;
@@ -143,15 +144,19 @@
      return resultJson.optJSONObject("data").optString("clickURL");
   }
   public static String convertLinkWithSubUnionId(String materialId, String couponUrl, String positionId,
    public static String convertLinkWithSubUnionId(@NotNull String materialId, String couponUrl, String giftCouponKey, @NotNull String positionId,
         String subUnionId) {
      String log = "京东转链出错:";
      try {
         JSONObject json = new JSONObject();
         json.put("materialId", materialId);
         json.put("siteId", APP_ID);
         json.put("positionId", positionId);
            json.put("materialId", materialId);
            if (!StringUtil.isNullOrEmpty(giftCouponKey)) {
                json.put("giftCouponKey", giftCouponKey);
            }
         if (!StringUtil.isNullOrEmpty(couponUrl))
            json.put("couponUrl", couponUrl);
@@ -228,7 +233,7 @@
   /**
    * 关键词商品查询接口【申请】
    * 
    * @param skuIdList
     * @param filter
    * @return
    */
   public static JDSearchResult queryByKey(JDFilter filter) {
@@ -656,8 +661,7 @@
    * @param page
    * @param pageSize
    * @param time
    * @param type
    *            时间类型 1-下单时间 2-完成时间 3-更新时间
     * @param type     时间类型 1-下单时间 2-完成时间 3-更新时间
    * @return
    */
   public static JDOrderResult getOrderList(int page, int pageSize, Date time, int type) {
@@ -717,6 +721,71 @@
      return null;
   }
    public static String createLiJin(String sku) {
        JSONObject json = new JSONObject();
        JSONObject couponReq = new JSONObject();
        couponReq.put("skuMaterialId", sku);
        couponReq.put("discount", 10);
        couponReq.put("amount", 5);
        couponReq.put("receiveStartTime", TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd HH"));
        couponReq.put("receiveEndTime", TimeUtil.getGernalTime(System.currentTimeMillis() + 1000 * 60 * 2, "yyyy-MM-dd HH"));
        couponReq.put("isSpu", 0);
        couponReq.put("expireType", 2);
        couponReq.put("useStartTime", TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd"));
        couponReq.put("useEndTime", TimeUtil.getGernalTime(System.currentTimeMillis() + 1000 * 60 * 60L * 24, "yyyy-MM-dd"));
        couponReq.put("share", 1);
        couponReq.put("contentMatch", 0);
        json.put("couponReq", couponReq);
        String result = baseRequest2("jd.union.open.coupon.gift.get", null, json);
        System.out.println(result);
        JSONObject root = JSONObject.fromObject(result).optJSONObject("jd_union_open_coupon_gift_get_response");
        if (root.optInt("code") == 0) {
            boolean hasMore = root.optBoolean("hasMore");
            root = JSONObject.fromObject(root.optString("result"));
            if (root.optInt("code") == 200 && root.optJSONObject("data") != null) {
                JSONObject data = root.optJSONObject("data");
                String giftCouponKey = data.optString("giftCouponKey");
                return giftCouponKey;
            }
        }
        return null;
    }
    public static void toolConvert() {
        JSONObject json = new JSONObject();
        JSONObject couponReq = new JSONObject();
        couponReq.put("materialId", "https://item.jd.com/71751967284.html");
        couponReq.put("unionId", "2011217145");
//        couponReq.put("pid", "2011217145_4100059717_3003005722");
        couponReq.put("subUnionId", "123_437032");
        couponReq.put("giftCouponKey","123123123123");
        json.put("promotionCodeReq", couponReq);
        String result = baseRequest2("jd.union.open.promotion.byunionid.get", null, json);
        System.out.println(result);
    }
    public static void toolOrder() {
        JSONObject json = new JSONObject();
        JSONObject couponReq = new JSONObject();
        couponReq.put("pageIndex", 1);
        couponReq.put("pageSize", 20);
        couponReq.put("type", 3);
        couponReq.put("startTime", "2020-10-31 16:00:00");
        couponReq.put("endTime", "2020-10-31 16:55:00");
//        couponReq.put("key", "026eea846250e0dcbcacd750faf07de0");
//        couponReq.put("pid", "2011217145_4100059717_3003005722");
        couponReq.put("childUnionId", "2011217145");
        json.put("orderReq", couponReq);
        String result = baseRequest2("jd.union.open.order.row.query", null, json);
        System.out.println(result);
    }
   public static void test() {
      JSONObject json = new JSONObject();
      json.put("materialId", "https://item.jd.com/32376790478.html");