| | |
| | | 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.dto.pdd.PDDShopDetail;
|
| | | import com.yeshi.fanli.dto.pdd.PDDShopResult;
|
| | | import com.yeshi.fanli.entity.pdd.PDDOrder;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
| | | map.put("keyword", sf.getKw());
|
| | | if (sf.getGoodsIdList() != null)
|
| | | map.put("goods_id_list", "[" + StringUtil.concat(sf.getGoodsIdList(), ",") + "]");
|
| | |
|
| | | if (sf.getMerchantType() != null)
|
| | | map.put("merchant_type", sf.getMerchantType() + "");
|
| | | map.put("pid", PID_FANLI);
|
| | | String result = baseRequest(map);
|
| | | JSONObject json = JSONObject.fromObject(result);
|
| | |
| | | * @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);
|
| | |
| | | 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;
|
| | | }
|
| | |
|
| | |
| | | map.put("page", page + "");
|
| | | map.put("page_size", pageSize + "");
|
| | | String result = baseRequest(map);
|
| | | System.out.println(result);
|
| | | JSONObject json = JSONObject.fromObject(result);
|
| | | JSONObject root = json.optJSONObject("order_list_get_response");
|
| | | if (root != null) {
|
| | |
| | | }.getType();
|
| | | List<PDDOrder> orderList = new Gson().fromJson(array.toString(), type);
|
| | | return new PDDOrderResult(totalCount, orderList);
|
| | | }
|
| | | 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;
|
| | | }
|
| | |
| | | return null;
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 获取商品详情
|
| | | * |
| | | * @param goodsId
|
| | | */
|
| | | 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 +"");
|
| | | if (page != null)
|
| | | map.put("page_number", page +"");
|
| | | |
| | | if (page != null)
|
| | | 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();
|
| | | List<PDDShopDetail> listShop = new Gson().fromJson(array.toString(), type);
|
| | | return new PDDShopResult(totalCount, listShop);
|
| | | }
|
| | | return null;
|
| | | }
|
| | | }
|