| | |
| | | */ |
| | | public static TaoBaoGoodsBrief getSimpleGoodsInfo(String id) throws TaobaoGoodsDownException { |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("method", "taobao.tbk.item.info.get"); |
| | | //TODO 临时接口 taobao.tbk.item.info.get |
| | | map.put("method", "taobao.tbk.item.info.temporary.get"); |
| | | map.put("num_iids", id + ""); |
| | | String resultStr = TaoKeBaseUtil.baseRequestForThreeTimes(map, true); |
| | | System.out.println(resultStr); |
| | |
| | | throw new TaobaoGoodsDownException(data.optJSONObject("error_response").optInt("code"), "商品下架"); |
| | | } |
| | | |
| | | if (data.optJSONObject("tbk_item_info_get_response") == null) |
| | | //TODO 修改临时接口 tbk_item_info_get_response |
| | | if (data.optJSONObject("tbk_item_info_temporary_get_response") == null) |
| | | return null; |
| | | JSONArray array = data.optJSONObject("tbk_item_info_get_response").optJSONObject("results") |
| | | JSONArray array = data.optJSONObject("tbk_item_info_temporary_get_response").optJSONObject("results") |
| | | .optJSONArray("n_tbk_item"); |
| | | if (array != null && array.size() > 0) { |
| | | JSONObject item = array.optJSONObject(0); |
| | |
| | | if (result != null && result.getTaoBaoGoodsBriefs() != null) |
| | | for (TaoBaoGoodsBrief g : result.getTaoBaoGoodsBriefs()) { |
| | | System.out.println(goods.getAuctionId() + ":" + g.getAuctionId()); |
| | | if (goods.getAuctionId().equals(g.getAuctionId())) { |
| | | if (TaoBaoUtil.isEqual(goods.getAuctionId(),g.getAuctionId())) { |
| | | g.setAuctionId(goods.getAuctionId()); |
| | | g.setCreatetime(new Date()); |
| | | g.setMaterialLibType(goods.getMaterialLibType()); |
| | |
| | | goods.getUserType(), app, null, null); |
| | | if (result != null && result.getTaoBaoGoodsBriefs() != null) |
| | | for (TaoBaoGoodsBrief g : result.getTaoBaoGoodsBriefs()) { |
| | | if (goods.getAuctionId() == g.getAuctionId()|| goods.getAuctionId().equals(g.getAuctionId())) { |
| | | if (TaoBaoUtil.isEqual( goods.getAuctionId() , g.getAuctionId())) { |
| | | g.setAuctionId(goods.getAuctionId()); |
| | | // 判断是否有优惠券 |
| | | if (!StringUtil.isNullOrEmpty(g.getCouponActivityId())) { |
| | |
| | | PageEntity pageEntity = new PageEntity(); |
| | | TaoBaoSearchResult taoBaoSearchResult = new TaoBaoSearchResult(); |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("method", "taobao.tbk.dg.material.optional"); |
| | | //TODO 临时接口taobao.tbk.dg.material.optional |
| | | map.put("method", "taobao.tbk.dg.material.temporary.optional"); |
| | | map.put("page_size", filter.getPageSize() == 0 ? "20" : filter.getPageSize() + ""); |
| | | map.put("page_no", (filter.getPage() <= 0 ? 1 : filter.getPage()) + ""); |
| | | if (!StringUtil.isNullOrEmpty(specialId) && !StringUtil.isNullOrEmpty(relationId)) { |
| | |
| | | } |
| | | |
| | | String resultStr = TaoKeBaseUtil.baseRequestForThreeTimes(map, true); |
| | | // System.out.println("resultStr"+ resultStr); |
| | | System.out.println("resultStr"+ resultStr); |
| | | JSONObject data = JSONObject.fromObject(resultStr); |
| | | if (data.optJSONObject("tbk_dg_material_optional_response") != null |
| | | && data.optJSONObject("tbk_dg_material_optional_response").optJSONObject("result_list") != null) { |
| | | JSONArray array = data.optJSONObject("tbk_dg_material_optional_response").optJSONObject("result_list") |
| | | //TODO 临时接口tbk_dg_material_optional_response |
| | | if (data.optJSONObject("tbk_dg_material_temporary_optional_response") != null |
| | | && data.optJSONObject("tbk_dg_material_temporary_optional_response").optJSONObject("result_list") != null) { |
| | | JSONArray array = data.optJSONObject("tbk_dg_material_temporary_optional_response").optJSONObject("result_list") |
| | | .optJSONArray("map_data"); |
| | | List<TaoBaoGoodsBrief> goodsList = new ArrayList<>(); |
| | | if (array != null) { |
| | |
| | | } |
| | | taoBaoSearchResult.setTaoBaoGoodsBriefs(goodsList); |
| | | |
| | | JSONObject optJSONObject = data.optJSONObject("tbk_dg_material_optional_response"); |
| | | JSONObject optJSONObject = data.optJSONObject("tbk_dg_material_temporary_optional_response"); |
| | | int totalResults = optJSONObject.getInt("total_results"); |
| | | int totalPage = totalResults % pageEntity.getPageSize() == 0 ? totalResults / pageEntity.getPageSize() |
| | | : totalResults / pageEntity.getPageSize() + 1; |
| | |
| | | provcity = provcity.split(" ")[provcity.split(" ").length - 1]; |
| | | TaoBaoSearchResult taoBaoSearchResult = new TaoBaoSearchResult(); |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("method", "taobao.tbk.dg.material.optional"); |
| | | //TODO 临时接口 taobao.tbk.dg.material.optional |
| | | map.put("method", "taobao.tbk.dg.material.temporary.optional"); |
| | | map.put("page_size", 50 + ""); |
| | | map.put("page_no", 1 + ""); |
| | | map.put("start_price", (int) zkPrice.subtract(new BigDecimal(1)).doubleValue() + ""); |
| | |
| | | String resultStr = TaoKeBaseUtil.baseRequestForThreeTimes(map, true); |
| | | System.out.println(resultStr); |
| | | JSONObject data = JSONObject.fromObject(resultStr); |
| | | if (data.optJSONObject("tbk_dg_material_optional_response") != null |
| | | && data.optJSONObject("tbk_dg_material_optional_response").optJSONObject("result_list") != null) { |
| | | JSONArray array = data.optJSONObject("tbk_dg_material_optional_response").optJSONObject("result_list") |
| | | //TODO 临时接口 tbk_dg_material_optional_response |
| | | if (data.optJSONObject("tbk_dg_material_temporary_optional_response") != null |
| | | && data.optJSONObject("tbk_dg_material_temporary_optional_response").optJSONObject("result_list") != null) { |
| | | JSONArray array = data.optJSONObject("tbk_dg_material_temporary_optional_response").optJSONObject("result_list") |
| | | .optJSONArray("map_data"); |
| | | List<TaoBaoGoodsBrief> goodsList = new ArrayList<>(); |
| | | if (array != null) { |
| | |
| | | } |
| | | } |
| | | |
| | | public static void main(String[] args) throws TaobaoGoodsDownException { |
| | | //搜索 |
| | | TaoBaoGoodsBrief goods= searchGoodsDetail("X4g0DS2OK34iwyyI06AQQCg-XQWo4eH00jgRjx3iB0"); |
| | | |
| | | System.out.println(goods); |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | |