| | |
| | | import java.net.URLEncoder;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Collections;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | | import java.util.Iterator;
|
| | | import java.util.List;
|
| | |
| | | public static String SECRET_KEY = "fb49bc6ecac5458ba5394fc2969d7c56";
|
| | | private static String SERVER_URL = "https://router.jd.com/api";
|
| | |
|
| | | public static Long POSITION_FANLI = 1834339426L;
|
| | | public static Long POSITION_SHARE = 1834289924L;
|
| | | public static Long POSITION_COUPON = 1859510742L;
|
| | | public static long POSITION_FANLI = 1834339426L;
|
| | | public static long POSITION_SHARE = 1834289924L;
|
| | | public static long POSITION_COUPON = 1859510742L;
|
| | |
|
| | | // 订单查询类型
|
| | | public static int ORDER_TYPE_CREATETIME = 1;// 下单时间
|
| | |
| | | return result;
|
| | | }
|
| | |
|
| | | |
| | | private static String baseRequest2(String method, String accessToken, JSONObject params) {
|
| | | Map<String, String> baseMap = new HashMap<String, String>();
|
| | | baseMap.put("param_json", params.toString());
|
| | |
| | |
|
| | | /**
|
| | | * 转链接-短连接
|
| | | * |
| | | * @param materialId
|
| | | * @param couponUrl
|
| | | * @param positionId
|
| | |
| | | }
|
| | | return url;
|
| | | }
|
| | | |
| | |
|
| | | public static JDGoods queryGoodsDetail(Long skuId) {
|
| | | List<Long> skuIdList = new ArrayList<>();
|
| | |
| | |
|
| | | /**
|
| | | * 关键词商品查询接口【申请】
|
| | | * |
| | | * @param skuIdList
|
| | | * @return
|
| | | */
|
| | |
| | | JSONObject jsonDTO = new JSONObject();
|
| | | jsonDTO.put("goodsReqDTO", json);
|
| | |
|
| | | |
| | | String result = baseRequest2("jd.union.open.goods.query", null, jsonDTO);
|
| | | System.out.println(result);
|
| | | JSONObject resultJson = JSONObject.fromObject(result);
|
| | |
| | | return searchResult;
|
| | | }
|
| | |
|
| | | |
| | | |
| | | |
| | | private static JDGoods parseJDGoods(JSONObject json) {
|
| | | JDGoods goods = new JDGoods();
|
| | |
|
| | |
| | | goods.setSkuName(json.optString("skuName"));
|
| | | goods.setIsHot(json.optInt("isHot"));
|
| | |
|
| | | |
| | | // 价格信息
|
| | | Object priceInfo = json.get("priceInfo");
|
| | | JSONObject priceInfoJson = JSONObject.fromObject(priceInfo);
|
| | |
| | | jdshopInfo.setShopName(shopInfoJson.optString("shopName"));
|
| | | goods.setShopInfo(jdshopInfo);
|
| | |
|
| | | |
| | | // 分类信息
|
| | | Object category = json.get("categoryInfo");
|
| | | JSONObject categoryJson = JSONObject.fromObject(category);
|
| | |
| | | categoryInfo.setCid3(categoryJson.optLong("cid3"));
|
| | | categoryInfo.setCid3Name(categoryJson.optString("cid3Name"));
|
| | | goods.setCategoryInfo(categoryInfo);
|
| | | |
| | |
|
| | | // 图片信息
|
| | | List<String> imageList = new ArrayList<String>();
|
| | |
| | | goods.setPinGouInfo(jdPinGouInfo);
|
| | | }
|
| | | }
|
| | | |
| | | |
| | |
|
| | | // 券信息
|
| | | Object coupon = json.get("couponInfo");
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | |
| | | |
| | | return goods;
|
| | | }
|
| | |
|
| | |
|
| | | /**
|
| | | * 获取推广商品信息接口
|
| | | * |
| | | * @param skuIdList
|
| | | * @return
|
| | | */
|
| | |
| | | JDGoods goods = new JDGoods();
|
| | | goods.setPrice(StringUtil.isNullOrEmpty(json.optString("wlUnitPrice"))
|
| | | ? new BigDecimal(json.optString("unitPrice")) : new BigDecimal(json.optString("wlUnitPrice")));
|
| | |
|
| | |
|
| | | BigDecimal commisionRatioWl = new BigDecimal(json.optString("commisionRatioWl"));
|
| | | if (commisionRatioWl.compareTo(new BigDecimal(0)) > 0) {
|
| | |
| | | return goods;
|
| | | }
|
| | |
|
| | | |
| | | public static JDSearchResult getJingFenGoods(int pageIndex, int eliteId) {
|
| | | JDSearchResult searchResult = new JDSearchResult();
|
| | | List<JDGoods> list = new ArrayList<>();
|
| | |
| | |
|
| | | JSONObject jsonDTO = new JSONObject();
|
| | | jsonDTO.put("goodsReq", json);
|
| | | |
| | |
|
| | | String result = baseRequest2("jd.union.open.goods.jingfen.query", null, jsonDTO);
|
| | | System.out.println(result);
|
| | |
| | | return searchResult;
|
| | | }
|
| | |
|
| | | |
| | | public static JDSearchResult getGoodsClass() {
|
| | | JDSearchResult searchResult = new JDSearchResult();
|
| | | List<JDGoods> list = new ArrayList<>();
|
| | |
| | |
|
| | | JSONObject jsonDTO = new JSONObject();
|
| | | jsonDTO.put("req", json);
|
| | | |
| | |
|
| | | String result = baseRequest2("jd.union.open.category.goods.get", null, jsonDTO);
|
| | | System.out.println(result);
|
| | |
| | | return searchResult;
|
| | | }
|
| | |
|
| | |
|
| | | public static JDGoods getGoodsDetail(Long skuId) {
|
| | | List<Long> skuIdList = new ArrayList<>();
|
| | | skuIdList.add(skuId);
|
| | |
| | | return null;
|
| | | }
|
| | |
|
| | | public static JDOrderResult getOrder(int page, int pageSize, String time, int type) {
|
| | | /**
|
| | | * 获取订单列表
|
| | | * |
| | | * @param page
|
| | | * @param pageSize
|
| | | * @param time
|
| | | * @param type
|
| | | * 时间类型 1-下单时间 2-完成时间 3-更新时间
|
| | | * @return
|
| | | */
|
| | | public static JDOrderResult getOrderList(int page, int pageSize, Date time, int type) {
|
| | | JSONObject json = new JSONObject();
|
| | | JSONObject orderReq = new JSONObject();
|
| | | orderReq.put("pageNo", page);
|
| | | orderReq.put("pageSize", pageSize);
|
| | | orderReq.put("type", type);
|
| | | orderReq.put("time", time);
|
| | | orderReq.put("time", TimeUtil.getGernalTime(time.getTime(), "yyyyMMddHH"));
|
| | |
|
| | | json.put("orderReq", orderReq);
|
| | | String result = baseRequest("jd.union.open.order.query", null, json);
|
| | | String result = baseRequest2("jd.union.open.order.query", null, json);
|
| | | try {
|
| | | System.out.println(new String(result.getBytes("GBK"), "UTF-8"));
|
| | | System.out.println(new String(result.getBytes("ISO-8859-1"), "UTF-8"));
|
| | | } catch (UnsupportedEncodingException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | JSONObject root = JSONObject.fromObject(result).optJSONObject("jd_union_open_order_query_response");
|
| | | if (root.optInt("code") == 0) {
|
| | | boolean hasMore = root.optBoolean("hasMore");
|