admin
2019-07-09 b5624f9e80d4fa8d9bb42f759b47f8059ba6a0eb
Merge remote-tracking branch 'origin/master'
1个文件已修改
40 ■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/util/dataoke/DaTaoKeApiUtil.java 40 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/dataoke/DaTaoKeApiUtil.java
@@ -162,7 +162,16 @@
                    JSONObject data = JSONObject
                            .fromObject(els.get(i).html().replace("var brandData =", "").trim().split("};")[0] + "}");
                    taoBaoShopDTO = convertTaoBaoShopDTO(data);
                    taoBaoShopDTO = new TaoBaoShopDTO();
                    JSONObject item = data.optJSONObject("act");
                    taoBaoShopDTO.setSellerId(item.optLong("seller_id"));
                    taoBaoShopDTO.setBrandId(item.optString("brand_id"));
                    taoBaoShopDTO.setBrandDes(item.optString("brand_des"));
                    taoBaoShopDTO.setUserType(0);
                    // 商品信息
                    taoBaoShopDTO = getDynamicShopGoods(brandId, taoBaoShopDTO);
                    break;
                }
            }
@@ -409,21 +418,31 @@
        return StringUtil.Md5(signStr).toUpperCase();
    }
    public static TaoBaoShopDTO convertTaoBaoShopDTO(JSONObject data) {
        TaoBaoShopDTO taoBaoShopDTO = new TaoBaoShopDTO();
        JSONObject item = data.optJSONObject("act");
        taoBaoShopDTO.setSellerId(item.optLong("seller_id"));
        taoBaoShopDTO.setBrandId(item.optString("brand_id"));
        taoBaoShopDTO.setBrandDes(item.optString("brand_des"));
    /**
     * 获取店铺下前4个商品、店铺介绍
     *
     * @param brandId
     * @return
     */
    public static TaoBaoShopDTO getDynamicShopGoods(String brandId, TaoBaoShopDTO taoBaoShopDTO) {
        if (brandId == null) {
            return taoBaoShopDTO;
        }
        int userType = 0;
        List<TaoBaoGoodsBrief> listGoods = new ArrayList<TaoBaoGoodsBrief>();
        JSONArray arrayGoods = data.optJSONArray("goods");
        String result = HttpUtil.get("http://www.dataoke.com/brandGoods?id=" + brandId +"&page=1");
        JSONObject json = JSONObject.fromObject(result);
        JSONArray arrayGoods = json.optJSONArray("goods");
        for (int i = 0; i < arrayGoods.size(); i++) {
            if (i >= 2) {
                break;
            }
            JSONObject itemGoods = arrayGoods.optJSONObject(i);
            TaoBaoGoodsBrief taoBaoGoods = new TaoBaoGoodsBrief();
            taoBaoGoods.setAuctionId(itemGoods.optLong("goodsid"));
            taoBaoGoods.setBiz30day(itemGoods.optInt("xiaoliang"));
@@ -448,10 +467,11 @@
            userType = itemGoods.optInt("istmall");
        }
        taoBaoShopDTO.setListGoods(listGoods);
        taoBaoShopDTO.setUserType(userType);
        taoBaoShopDTO.setListGoods(listGoods);
        return taoBaoShopDTO;
    }
    public static int RANK_TYPE_TIME = 1;// 实时
    public static int RANK_TYPE_DAY = 2;// 全天榜