| | |
| | | import org.yeshi.utils.HttpUtil;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.google.gson.GsonBuilder;
|
| | | import com.google.gson.reflect.TypeToken;
|
| | | import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
|
| | | import com.yeshi.fanli.dto.pdd.PDDGoodsResult;
|
| | |
| | | map.put("sort_type", sf.getSortType() + "");
|
| | | if (sf.getHasCoupon() != null)
|
| | | map.put("with_coupon", sf.getHasCoupon() + "");
|
| | | if (sf.getIsBrand() != null)
|
| | | map.put("is_brand_goods", sf.getIsBrand() + "");
|
| | | if (sf.getCatId() != null)
|
| | | map.put("cat_id", sf.getCatId() + "");
|
| | | if (sf.getKw() != null)
|
| | | map.put("keyword", sf.getKw());
|
| | | map.put("pid", PID_FANLI);
|
| | | String result = baseRequest(map);
|
| | | |
| | | JSONObject json = JSONObject.fromObject(result);
|
| | | JSONObject root = json.optJSONObject("goods_search_response");
|
| | | JSONArray array = root.optJSONArray("goods_list");
|
| | | Type type = new TypeToken<List<PDDGoodsDetail>>() {
|
| | | }.getType();
|
| | | List<PDDGoodsDetail> goodsList = new Gson().fromJson(array.toString(), type);
|
| | | |
| | | Gson gson = new GsonBuilder().disableHtmlEscaping().create();
|
| | | List<PDDGoodsDetail> goodsList = gson.fromJson(array.toString(), type);
|
| | | int totalCount = json.optInt("total_count");
|
| | | return new PDDGoodsResult(totalCount, goodsList);
|
| | | }
|
| | |
| | | System.out.println(result);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取订单
|
| | | * |
| | | * @param page
|
| | | * -页码
|
| | | * @param pageSize-每页数量
|
| | | * @param startTime-开始时间
|
| | | * @param endTime-结束时间
|
| | | * 与开始时间不得大于24小时
|
| | | * @return
|
| | | */
|
| | | public static PDDOrderResult getOrders(int page, int pageSize, long startTime, long endTime) {
|
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("type", "pdd.ddk.order.list.increment.get");
|
| | |
| | | return goodsList.get(0);
|
| | | return null;
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 获取商品详情
|
| | | * |
| | | * @param goodsId
|
| | | */
|
| | | public static String createGenerate(Long goodsId) {
|
| | | JSONArray array = new JSONArray();
|
| | | array.add(goodsId);
|
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("type", "pdd.ddk.phrase.generate");
|
| | | map.put("goods_id_list", array.toString());
|
| | | map.put("p_id", PID_FANLI);
|
| | | String result = baseRequest(map);
|
| | | JSONObject resultJson = JSONObject.fromObject(result);
|
| | | System.out.println(result);
|
| | | JSONObject root = resultJson.optJSONObject("ddk_phrase_generate_response");
|
| | | if (root != null) {
|
| | | array = root.optJSONArray("promotion_phrase_list");
|
| | | JSONObject phraseObject = JSONObject.fromObject( array.get(0));
|
| | | return phraseObject.optString("phrase");
|
| | | }
|
| | | |
| | | return null;
|
| | | }
|
| | |
|
| | | }
|