From 573c491b4a1ba60e12a5678a01c1546c0077c1ee Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 30 七月 2019 09:07:42 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 fanli/src/main/java/com/yeshi/fanli/controller/client/v1/DynamicRecommendController.java |   63 ++++++++++++++++++++++++++++++-
 1 files changed, 61 insertions(+), 2 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/DynamicRecommendController.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/DynamicRecommendController.java
index f071f6f..6e5432b 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/DynamicRecommendController.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/DynamicRecommendController.java
@@ -20,6 +20,8 @@
 import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
 import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult;
 import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetail;
+import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
+import com.yeshi.fanli.log.LogHelper;
 import com.yeshi.fanli.service.inter.config.ConfigService;
 import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
 import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
@@ -28,6 +30,7 @@
 import com.yeshi.fanli.util.StringUtil;
 import com.yeshi.fanli.util.Utils;
 import com.yeshi.fanli.util.taobao.TaoBaoUtil;
+import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
 
 import net.sf.json.JSONObject;
 
@@ -64,7 +67,6 @@
 		TaoBaoGoodsBrief tb = null;
 		String URL_REGEX = "(((http|https)://)|(www\\.))[a-zA-Z0-9\\._-]+\\.[a-zA-Z]{2,6}(:[0-9]{1,4})?(/[a-zA-Z0-9\\&%_\\./-~-]*)?";
 
-		
 		Pattern p = Pattern.compile(URL_REGEX);
 		Matcher matcher = p.matcher(url);
 		if (!matcher.find()) {// 涓嶅寘鍚摼鎺�
@@ -150,10 +152,23 @@
 		Pattern p = Pattern.compile(URL_REGEX);
 		Matcher matcher = p.matcher(text);
 		if (!matcher.find()) {// 涓嶅寘鍚摼鎺�
+			// 瑙f瀽娣樺彛浠�
+			if (analysisTaoToken(text, out))
+				return;
 			// 鍟嗗搧璇︽儏
 			// 鍙戠幇
 			// 娌℃湁閾炬帴锛屾爣棰樿繃闀夸篃涓嶅鐞�
-			if (text.length() > 50) {
+			if (text.startsWith("銆�") && text.contains("銆�")) {
+				int end = text.indexOf("銆�");
+				if (end > 2)
+					text = text.substring(1, end);
+			}
+
+			LogHelper.test("鏍规嵁绮樿创鏉挎帹鑽�:" + text);
+
+		
+
+			if (text.length() > 80) {
 				out.print(JsonUtil.loadFalseResult("鍊艰繃闀�"));
 				return;
 			}
@@ -249,4 +264,48 @@
 		out.print(JsonUtil.loadTrueResult(root));
 	}
 
+	/**
+	 * 瑙f瀽娣樺彛浠�
+	 * 
+	 * @param text
+	 * @param out
+	 * @return
+	 */
+	private boolean analysisTaoToken(String text, PrintWriter out) {
+		String token = StringUtil.picUpTaoToken(text);
+		if (!StringUtil.isNullOrEmpty(token)) {
+			Long auctionId = TaoKeApiUtil.tokenConvertAuctionId(token);
+			if (auctionId != null) {
+				TaoBaoGoodsBrief tb = null;
+				try {
+					tb = TaoKeApiUtil.getSimpleGoodsInfo(auctionId);
+				} catch (TaobaoGoodsDownException e) {
+					e.printStackTrace();
+				}
+
+				if (tb != null) {
+					JSONObject data = new JSONObject();
+					JSONObject taoBaoGoodsJSON = new JSONObject();
+					taoBaoGoodsJSON.put("title", tb.getTitle());
+					taoBaoGoodsJSON.put("zkPrice", tb.getZkPrice());
+					taoBaoGoodsJSON.put("auctionId", tb.getAuctionId());
+					taoBaoGoodsJSON.put("url", "http://item.taobao.com/item.htm?id=" + tb.getAuctionId());
+					data.put("taoBaoGoodsBrief", taoBaoGoodsJSON);
+					if (!StringUtil.isNullOrEmpty(tb.getPictUrl())) {
+						if (tb.getImgList() == null)
+							tb.setImgList(new ArrayList<>());
+						tb.getImgList().add(0, TbImgUtil.getTBSize220Img(tb.getPictUrl()));
+					}
+					data.put("tbImgs", tb.getImgList());
+					JSONObject root = new JSONObject();
+					root.put("type", 1);
+					root.put("data", data);
+					out.print(JsonUtil.loadTrueResult(root));
+					return true;
+				}
+			}
+		}
+		return false;
+	}
+
 }

--
Gitblit v1.8.0