From 8f45af9d6cdae97f4f265d2f2a123d990cf1bb1d Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期一, 06 五月 2019 17:57:07 +0800
Subject: [PATCH] 设备未读消息处理,分类BUG修改

---
 fanli/src/main/java/com/yeshi/fanli/util/taobao/DaTaoKeUtil.java |   89 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 88 insertions(+), 1 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/util/taobao/DaTaoKeUtil.java b/fanli/src/main/java/com/yeshi/fanli/util/taobao/DaTaoKeUtil.java
index 9db75a2..c705aba 100644
--- a/fanli/src/main/java/com/yeshi/fanli/util/taobao/DaTaoKeUtil.java
+++ b/fanli/src/main/java/com/yeshi/fanli/util/taobao/DaTaoKeUtil.java
@@ -19,6 +19,7 @@
 import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
 import com.yeshi.fanli.entity.taobao.TaoBaoHead;
 import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult;
+import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetail;
 import com.yeshi.fanli.tag.PageEntity;
 import com.yeshi.fanli.util.StringUtil;
 import com.yeshi.fanli.util.TimeUtil;
@@ -33,6 +34,25 @@
  *
  */
 public class DaTaoKeUtil {
+
+	public static List<GoodsClass> goodsClasses;
+	static {
+		goodsClasses = new ArrayList<>();
+		goodsClasses.add(new GoodsClass(4L, "灞呭鏃ョ敤"));
+		goodsClasses.add(new GoodsClass(6L, "缇庨"));
+		goodsClasses.add(new GoodsClass(2L, "姣嶅┐"));
+		goodsClasses.add(new GoodsClass(3L, "缇庡"));
+		goodsClasses.add(new GoodsClass(1L, "濂宠"));
+		goodsClasses.add(new GoodsClass(8L, "鏁扮爜瀹剁數"));
+		goodsClasses.add(new GoodsClass(7L, "鏂囧ū杞﹀搧"));
+		goodsClasses.add(new GoodsClass(10L, "鍐呰。"));
+		goodsClasses.add(new GoodsClass(14L, "瀹惰瀹剁汉"));
+		goodsClasses.add(new GoodsClass(5L, "闉嬪搧"));
+		goodsClasses.add(new GoodsClass(9L, "鐢疯"));
+		goodsClasses.add(new GoodsClass(12L, "閰嶉グ"));
+		goodsClasses.add(new GoodsClass(13L, "鎴峰杩愬姩"));
+		goodsClasses.add(new GoodsClass(11L, "绠卞寘"));
+	}
 
 	public static final String HOST = "http://dataoke.yeshitv.com";
 
@@ -78,7 +98,7 @@
 		int[] ids = new int[] { 1, 9, 10, 2, 3, 4, 5, 6, 7, 8 };
 		for (int i = 0; i < names.length; i++) {
 			GoodsClass gc = new GoodsClass();
-			gc.setId(Long.parseLong(ids[i]+""));
+			gc.setId(Long.parseLong(ids[i] + ""));
 			gc.setName(names[i]);
 			list.add(gc);
 		}
@@ -344,4 +364,71 @@
 		return couponList;
 	}
 
+	private static List<DaTaoKeDetail> parseCurrent(String url) {
+		try {
+			Document doc = Jsoup.connect(url)
+					.userAgent(
+							"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36")
+					.get();
+			Elements items = doc.getElementsByClass("goods-list").get(0).getElementsByClass("goods-item");
+			for (int i = 0; i < items.size(); i++) {
+				Long id = Long.parseLong(items.get(i).attr("id").replace("goods-items_", ""));
+				String currentSale = items.get(i).getElementsByClass("goods-item-content").get(0)
+						.getElementsByClass("goods-info").get(0).getElementsByClass("tg-show").get(0)
+						.getElementsByTag("b").get(0).text();
+
+				System.out.println(id + "-" + currentSale);
+
+			}
+
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+
+		// TODO 闇�瑕佽繑鍥炲��
+		return null;
+	}
+
+	// 鑾峰彇瀹炴椂姒滃崟
+	/**
+	 * 鑾峰彇瀹炴椂閿�閲忔
+	 * 
+	 * @param cid
+	 * @return
+	 */
+	public static List<DaTaoKeDetail> getCurrentSalesRank(Long cid) {
+		String url = null;
+		if (cid == null)
+			url = "http://www.dataoke.com/top_sell";
+		else
+			url = String.format("http://www.dataoke.com/top_sell?cid=%s&type=1", cid);
+		return parseCurrent(url);
+	}
+
+	/**
+	 * 鍏ㄥぉ閿�閲忔
+	 * 
+	 * @param cid
+	 * @return
+	 */
+	public static List<DaTaoKeDetail> getCurrentDaySalesRank(Long cid) {
+		String url = null;
+		if (cid == null)
+			url = "http://www.dataoke.com/top_all";
+		else
+			url = String.format("http://www.dataoke.com/top_all?cid=%s", cid);
+		return parseCurrent(url);
+	}
+
+	/**
+	 * 鑾峰彇鐑帹姒�
+	 * 
+	 * @param cid
+	 * @return
+	 */
+	public static List<DaTaoKeDetail> getCurrentHotSalesRank() {
+		String url = "http://www.dataoke.com/top_tui";
+		return parseCurrent(url);
+	}
+
 }

--
Gitblit v1.8.0