admin
2022-08-25 146dbd5ed24c1fe63766aa45e0ce602caa39748e
fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoKeApiUtil.java
@@ -115,7 +115,8 @@
     */
    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);
@@ -126,9 +127,10 @@
            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);
@@ -365,7 +367,7 @@
        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());
@@ -430,7 +432,7 @@
                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())) {
@@ -639,7 +641,8 @@
        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)) {
@@ -753,11 +756,12 @@
        }
        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) {
@@ -769,7 +773,7 @@
            }
            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;
@@ -833,7 +837,8 @@
            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() + "");
@@ -853,9 +858,10 @@
        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) {
@@ -2276,6 +2282,14 @@
        }
    }
    public static  void main(String[] args) throws TaobaoGoodsDownException {
        //搜索
        TaoBaoGoodsBrief goods=  searchGoodsDetail("X4g0DS2OK34iwyyI06AQQCg-XQWo4eH00jgRjx3iB0");
        System.out.println(goods);
    }
}