From 3824cbcaec6e6c67418d5280a53e9c2fedeef6f9 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期四, 11 七月 2019 16:34:13 +0800
Subject: [PATCH] 订单bug,分享爆款自购修改

---
 fanli/src/main/java/com/yeshi/fanli/util/taobao/DaTaoKeUtil.java |  107 ++++++++++++++++++-----------------------------------
 1 files changed, 37 insertions(+), 70 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 7349511..81a08be 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
@@ -5,8 +5,6 @@
 import java.math.BigDecimal;
 import java.net.URLEncoder;
 import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
 import java.util.List;
 
 import org.jsoup.Jsoup;
@@ -20,10 +18,10 @@
 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.entity.taobao.dataoke.DaTaoKeDetailV2;
 import com.yeshi.fanli.tag.PageEntity;
 import com.yeshi.fanli.util.MoneyBigDecimalUtil;
 import com.yeshi.fanli.util.StringUtil;
-import com.yeshi.fanli.util.TimeUtil;
 
 import net.sf.json.JSONArray;
 import net.sf.json.JSONObject;
@@ -366,64 +364,25 @@
 	 * 
 	 * @return
 	 */
-	public static List<TaoBaoGoodsBrief> getDingDongQiang() {
-		List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
+	public static List<DaTaoKeDetail> getDingDongQiang() {
+		List<DaTaoKeDetail> goodsList = new ArrayList<>();
 		try {
-			Document doc = Jsoup.connect("http://dataoke.yeshitv.com/index.php?r=ddq/wap")
+			Document doc = Jsoup.connect("http://www.dataoke.com/ddq")
 					.userAgent(
 							"Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.92 Mobile Safari/537.36")
 					.get();
-			Elements els = doc.getElementsByTag("script");
-			for (int i = 0; i < els.size(); i++) {
-				Element item = els.get(i);
-				if (item.toString().length() > 5000) {
-					String html = item.html();
-					int endIndex = html.indexOf("} ;") + 1;
-					int startIndex = html.indexOf("data =");
-					String json = html.substring(startIndex + "data =".length(), endIndex).trim();
-					JSONObject root = JSONObject.fromObject(json);
-					Iterator<String> keys = root.keySet().iterator();
-					List<String> ids = new ArrayList<>();
-					while (keys.hasNext()) {
-						String key = keys.next();
-						JSONArray array = root.optJSONObject(key).optJSONArray("list");
-						for (int j = 0; j < array.size(); j++) {
-							if (TimeUtil.convertToTimeTemp(array.optJSONObject(j).optString("paiqi"),
-									"yyyy-MM-dd HH:mm:ss") < System.currentTimeMillis())
-								ids.add(array.optJSONObject(j).optString("id"));
-						}
-					}
-					Collections.shuffle(ids);
-					List<Long> goodsIdList = new ArrayList<>();
-					ids.parallelStream().forEach(id -> {
-						try {
-							long auctionId = getAuctionId(Long.parseLong(id));
-							goodsIdList.add(auctionId);
-						} catch (Exception e) {
-						}
-					});
-
-					goodsIdList.parallelStream().forEach(goods -> {
-						try {
-							TaoBaoGoodsBrief gds = TaoKeApiUtil.searchGoodsDetail(goods);
-							if (gds != null)
-								goodsList.add(gds);
-						} catch (Exception e) {
-
-						}
-
-					});
-
-				}
-
+			Elements items = doc.getElementsByClass("main").get(0).getElementsByClass("clearfix").get(0)
+					.getElementsByTag("li");
+			for (int i = 0; i < items.size(); i++) {
+				DaTaoKeDetail detail = new DaTaoKeDetail();
+				String id = items.get(i).getElementsByTag("a").get(0).attr("href").split("\\?")[1].replace("id=", "");
+				detail.setId(Long.parseLong(id));
+				goodsList.add(detail);
 			}
+		} catch (Exception e) {
 
-		} catch (IOException e) {
-			e.printStackTrace();
 		}
-
 		return goodsList;
-
 	}
 
 	//
@@ -536,36 +495,44 @@
 		// 鏍囬+鍒稿悗浠�+鍖呴偖+鎻忚堪
 		String desc = detail.getdTitle();
 		desc += "\n";
-		desc += String.format("鍒稿悗浠�%s銆�%s鍏冦�戝寘閭鏉� ",Math.random()>0.5?"馃挵":"", MoneyBigDecimalUtil.getWithNoZera(detail.getPrice()).toString())
-				+ (Math.random()>0.5?getRandomCommonEmoji():"");
+		desc += String.format("鍒稿悗浠�%s銆�%s鍏冦�戝寘閭鏉� ", Math.random() > 0.5 ? "馃挵" : "",
+				MoneyBigDecimalUtil.getWithNoZera(detail.getPrice()).toString())
+				+ (Math.random() > 0.5 ? getRandomCommonEmoji() : "");
 		desc += "\n";
-//		desc += detail.getIntroduce();
-		String introduce = detail.getIntroduce().replace("锛�", ",").replace("銆�", ",").replace("锛�", ",")
-				.replace(",", ",");
-		introduce=introduce.replace(",,,", ",").replace(",,", ",");
-		
+		// desc += detail.getIntroduce();
+		String introduce = detail.getIntroduce().replace("锛�", ",").replace("銆�", ",").replace("锛�", ",").replace(",",
+				",");
+		introduce = introduce.replace(",,,", ",").replace(",,", ",");
+
 		String[] sts = introduce.split(",");
 		introduce = "";
 		for (int i = 0; i < sts.length; i++) {
 			if (i % 2 == 1) {// 闇�瑕佹崲琛�
-				introduce += sts[i] + (Math.random()>0.5?getRandomCommonEmoji():i==sts.length-1?"":"锛�") + "\n";
+				introduce += sts[i] + (Math.random() > 0.5 ? getRandomCommonEmoji() : i == sts.length - 1 ? "" : "锛�")
+						+ "\n";
 			} else
-				introduce += sts[i] + (Math.random()>0.5?getRandomCommonEmoji():i==sts.length-1?"":"锛�");
+				introduce += sts[i] + (Math.random() > 0.5 ? getRandomCommonEmoji() : i == sts.length - 1 ? "" : "锛�");
 		}
-		desc+=introduce;
+		desc += introduce;
 		return desc;
 	}
 
 	public static TaoBaoGoodsBrief filterTaoBaoGoods(TaoBaoGoodsBrief goods, DaTaoKeDetail detail) {
-		if (detail != null) {
+		if (detail != null && goods != null) {
 			// 閲嶆柊璁剧疆鏍囬涓庡埜浠锋牸
 			goods.setTitle(detail.getdTitle());
-			goods.setCouponAmount(detail.getQuanPrice());
-			if (new BigDecimal(detail.getQuanCondition()).compareTo(new BigDecimal(0)) > 0)
-				goods.setCouponInfo(String.format("婊�%s鍏冨噺%s鍏�", detail.getQuanCondition(),
-						MoneyBigDecimalUtil.getWithNoZera(detail.getQuanPrice()).toString()));
-			else
-				goods.setCouponInfo(String.format("%s鍏冩棤鏉′欢鍒�", detail.getQuanPrice()));
+			if (!StringUtil.isNullOrEmpty(detail.getPic()))
+				goods.setPictUrlWhite(detail.getPic());
+		}
+		return goods;
+	}
+
+	public static TaoBaoGoodsBrief filterTaoBaoGoods(TaoBaoGoodsBrief goods, DaTaoKeDetailV2 detail) {
+		if (detail != null && goods != null) {
+			// 閲嶆柊璁剧疆鏍囬涓庡埜浠锋牸
+			goods.setTitle(detail.getDtitle());
+			if (!StringUtil.isNullOrEmpty(detail.getMainPic()))
+				goods.setPictUrlWhite(detail.getMainPic());
 		}
 		return goods;
 	}

--
Gitblit v1.8.0