| | |
| | | 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;
|
| | |
| | | import com.yeshi.fanli.entity.pdd.PDDOrder;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
| | |
|
| | | /**
|
| | | * 多多进宝商品查询
|
| | | * |
| | | * @param sf
|
| | | * @return
|
| | | */
|
| | |
| | | map.put("keyword", sf.getKw());
|
| | | if (sf.getGoodsIdList() != null)
|
| | | map.put("goods_id_list", "[" + StringUtil.concat(sf.getGoodsIdList(), ",") + "]");
|
| | | |
| | | |
| | |
|
| | | map.put("pid", PID_FANLI);
|
| | | String result = baseRequest(map);
|
| | | JSONObject json = JSONObject.fromObject(result);
|
| | | JSONObject root = json.optJSONObject("goods_search_response");
|
| | | if (root == null) {
|
| | | return null;
|
| | | } |
| | | |
| | | }
|
| | |
|
| | | JSONArray array = root.optJSONArray("goods_list");
|
| | | if (array == null) {
|
| | | return null;
|
| | | }
|
| | | |
| | |
|
| | | Type type = new TypeToken<List<PDDGoodsDetail>>() {
|
| | | }.getType();
|
| | | |
| | |
|
| | | Gson gson = new GsonBuilder().disableHtmlEscaping().create();
|
| | | List<PDDGoodsDetail> goodsList = gson.fromJson(array.toString(), type);
|
| | | int totalCount = root.optInt("total_count");
|
| | | return new PDDGoodsResult(totalCount, goodsList);
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 运营频道商品查询API
|
| | | * 运营频道商品查询API
|
| | | * |
| | | * @param page
|
| | | * @param pageSize
|
| | | * @param channelType 频道类型;0, "1.9包邮", 1, "今日爆款", 2, "品牌清仓", 非必填 ,默认是1
|
| | | * @param channelType
|
| | | * 频道类型;0, "1.9包邮", 1, "今日爆款", 2, "品牌清仓", 非必填 ,默认是1
|
| | | * @return
|
| | | */
|
| | | public static PDDGoodsResult searchByChannelType(Integer page, Integer pageSize, String channelType) {
|
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("type", "pdd.ddk.goods.recommend.get");
|
| | | map.put("offset", (page == null?0:page) + "");
|
| | | map.put("offset", (pageSize == null?Constant.PAGE_SIZE:pageSize) + "");
|
| | | |
| | | map.put("offset", (page == null ? 0 : page) + "");
|
| | | map.put("offset", (pageSize == null ? Constant.PAGE_SIZE : pageSize) + "");
|
| | |
|
| | | if (channelType != null)
|
| | | map.put("channel_type", channelType);
|
| | | |
| | |
|
| | | map.put("pid", PID_FANLI);
|
| | | String result = baseRequest(map);
|
| | | |
| | |
|
| | | JSONObject json = JSONObject.fromObject(result);
|
| | | JSONObject root = json.optJSONObject("goods_basic_detail_response");
|
| | | if (root == null) {
|
| | |
| | | if (array == null) {
|
| | | return null;
|
| | | }
|
| | | |
| | |
|
| | | Type type = new TypeToken<List<PDDGoodsDetail>>() {
|
| | | }.getType();
|
| | | |
| | |
|
| | | Gson gson = new GsonBuilder().disableHtmlEscaping().create();
|
| | | List<PDDGoodsDetail> goodsList = gson.fromJson(array.toString(), type);
|
| | | int totalCount = root.optInt("total");
|
| | | return new PDDGoodsResult(totalCount, goodsList);
|
| | | }
|
| | | |
| | |
|
| | | public static void getGoodsClass() {
|
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("type", "pdd.goods.cats.get");
|
| | | map.put("parent_cat_id", "0");
|
| | | String result = baseRequest(map);
|
| | | |
| | |
|
| | | JSONObject json = JSONObject.fromObject(result);
|
| | | JSONObject root = json.optJSONObject("goods_cats_get_response");
|
| | | JSONArray array = root.optJSONArray("goods_cats_list");
|
| | | }
|
| | | |
| | | |
| | |
|
| | | public static void getThemes(Integer page, Integer pageSize) {
|
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("type", "pdd.ddk.theme.list.get");
|
| | | map.put("page", page + "");
|
| | | map.put("page_size", pageSize + "");
|
| | | map.put("page_size", pageSize + "");
|
| | | String result = baseRequest(map);
|
| | | |
| | |
|
| | | JSONObject json = JSONObject.fromObject(result);
|
| | | JSONObject root = json.optJSONObject("theme_list_get_response");
|
| | | JSONArray array = root.optJSONArray("theme_list");
|
| | |
| | | System.out.println(array.optJSONObject(i).optString("goods_num"));
|
| | | System.out.println("-------------------------------------------");
|
| | | }
|
| | | |
| | |
|
| | | System.out.println(root.optLong("total"));
|
| | | }
|
| | | |
| | | |
| | |
|
| | | public static void getGoodsOpt() {
|
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("type", "pdd.goods.opt.get");
|
| | | map.put("parent_opt_id", "0");
|
| | | String result = baseRequest(map);
|
| | | |
| | |
|
| | | JSONObject json = JSONObject.fromObject(result);
|
| | | JSONObject root = json.optJSONObject("goods_opt_get_response");
|
| | | JSONArray array = root.optJSONArray("goods_opt_list");
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 多多客获取爆款排行商品接口
|
| | | * @param pid 推广位id (非必填)
|
| | | * @param page 从多少位置开始请求;默认值 : 0 (非必填)
|
| | | * @param pageSize 请求数量;默认值 :20 (非必填)
|
| | | * @param sortType 1-实时热销榜;2-实时收益榜 (非必填)
|
| | | * |
| | | * @param pid
|
| | | * 推广位id (非必填)
|
| | | * @param page
|
| | | * 从多少位置开始请求;默认值 : 0 (非必填)
|
| | | * @param pageSize
|
| | | * 请求数量;默认值 :20 (非必填)
|
| | | * @param sortType
|
| | | * 1-实时热销榜;2-实时收益榜 (非必填)
|
| | | * @return
|
| | | */
|
| | | public static PDDGoodsResult getTopList(String pid, Integer page, Integer pageSize, Integer sortType) {
|
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("type", "pdd.ddk.top.goods.list.query");
|
| | | map.put("offset", (page == null? 0: (page-1) * Constant.PAGE_SIZE) +"");
|
| | | map.put("limit", (pageSize == null? Constant.PAGE_SIZE : pageSize) +"");
|
| | | |
| | | map.put("offset", (page == null ? 0 : (page - 1) * Constant.PAGE_SIZE) + "");
|
| | | map.put("limit", (pageSize == null ? Constant.PAGE_SIZE : pageSize) + "");
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(pid))
|
| | | map.put("p_id", pid + "");
|
| | | |
| | |
|
| | | if (sortType != null)
|
| | | map.put("sort_type", sortType + "");
|
| | | |
| | |
|
| | | String result = baseRequest(map);
|
| | | JSONObject json = JSONObject.fromObject(result);
|
| | | JSONObject root = json.optJSONObject("top_goods_list_get_response");
|
| | |
| | | if (array == null) {
|
| | | return null;
|
| | | }
|
| | | |
| | | Type type = new TypeToken<List<PDDGoodsDetail>>() {}.getType();
|
| | | |
| | |
|
| | | Type type = new TypeToken<List<PDDGoodsDetail>>() {
|
| | | }.getType();
|
| | |
|
| | | Gson gson = new GsonBuilder().disableHtmlEscaping().create();
|
| | | List<PDDGoodsDetail> goodsList = gson.fromJson(array.toString(), type);
|
| | | //int totalCount = root.optInt("total");
|
| | | // int totalCount = root.optInt("total");
|
| | | int totalCount = 400; // 默认设置成400
|
| | | return new PDDGoodsResult(totalCount, goodsList);
|
| | | }
|
| | |
|
| | |
|
| | | /**
|
| | | * 商品转链
|
| | |
| | | map.put("p_id", pid);
|
| | | map.put("multi_group", "true");
|
| | | map.put("generate_weapp_webview", "true");
|
| | | // map.put("generate_weiboapp_webview", "true");
|
| | | // map.put("generate_weiboapp_webview", "true");
|
| | | JSONArray array = new JSONArray();
|
| | | array.add(goodsId);
|
| | | map.put("goods_id_list", array.toString());
|
| | |
| | | * 与开始时间不得大于24小时
|
| | | * @return
|
| | | */
|
| | | public static PDDOrderResult getOrders(int page, int pageSize, long startTime, long endTime) {
|
| | | public static PDDOrderResult getOrdersList(int page, int pageSize, long startTime, long endTime) {
|
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("type", "pdd.ddk.order.list.increment.get");
|
| | | map.put("start_update_time", startTime / 1000 + "");
|
| | |
| | | if (root == null) {
|
| | | return null;
|
| | | }
|
| | | |
| | |
|
| | | JSONArray resultArray = root.optJSONArray("goods_details");
|
| | | if (resultArray == null) {
|
| | | return null;
|
| | | }
|
| | | |
| | |
|
| | | Type type = new TypeToken<List<PDDGoodsDetail>>() {
|
| | | }.getType();
|
| | | List<PDDGoodsDetail> goodsList = new Gson().fromJson(resultArray.toString(), type);
|
| | |
| | | return goodsList.get(0);
|
| | | return null;
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 获取商品详情
|
| | | *
|
| | |
| | | JSONObject root = resultJson.optJSONObject("ddk_phrase_generate_response");
|
| | | if (root != null) {
|
| | | array = root.optJSONArray("promotion_phrase_list");
|
| | | JSONObject phraseObject = JSONObject.fromObject( array.get(0));
|
| | | JSONObject phraseObject = JSONObject.fromObject(array.get(0));
|
| | | return phraseObject.optString("phrase");
|
| | | }
|
| | | |
| | |
|
| | | return null;
|
| | | }
|
| | |
|
| | | public static Date getSystemTime() {
|
| | | try {
|
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("type", "pdd.time.get");
|
| | | String result = baseRequest(map);
|
| | | String time = JSONObject.fromObject(result).optJSONObject("time_get_response").optString("time");
|
| | | return new Date(TimeUtil.convertToTimeTemp(time, "yyyy-MM-dd HH:mm:ss"));
|
| | | } catch (Exception e) {
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|