From c51190b423317c39e16a10ed08578621e3296c07 Mon Sep 17 00:00:00 2001
From: admin <2780501319@qq.com>
Date: 星期六, 29 二月 2020 10:51:17 +0800
Subject: [PATCH] 转链bug修复

---
 fanli/src/main/java/com/yeshi/fanli/service/manger/ClipboardAnalysisManager.java |   66 +++++++++++++++++++++++----------
 1 files changed, 46 insertions(+), 20 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/manger/ClipboardAnalysisManager.java b/fanli/src/main/java/com/yeshi/fanli/service/manger/ClipboardAnalysisManager.java
index 949d64c..6a110ec 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/manger/ClipboardAnalysisManager.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/manger/ClipboardAnalysisManager.java
@@ -1,6 +1,7 @@
 package com.yeshi.fanli.service.manger;
 
-import java.util.Arrays;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
@@ -35,7 +36,6 @@
 import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil;
 import com.yeshi.fanli.util.pinduoduo.PinDuoDuoUtil;
 import com.yeshi.fanli.util.taobao.TaoBaoUtil;
-import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
 import com.yeshi.fanli.vo.msg.TokenVO;
 import com.yeshi.fanli.vo.search.GoodsDocParseResultVO;
 
@@ -139,6 +139,25 @@
 				// 瑙f瀽鍟嗗搧
 				CommonGoods goods = parseLink(text);
 				if (goods == null) {
+					// 鍒ゆ柇閾炬帴涔嬩腑鏄惁鍖呭惈鍙d护
+					try {
+						String newText = URLDecoder.decode(text, "UTF-8");
+						List<String> tokenList = TaoBaoUtil.getTokenListFromTextWithKuoHao(newText);
+						if (tokenList != null && tokenList.size() > 0) {
+							try {
+								goods = parseTaoBaoToken(tokenList.get(0));
+							} catch (TaoBaoTokenParseException e) {
+							}
+							if (goods != null && goods.getGoodsId() != null) {
+								resultListener.onResult(goods);
+								return;
+							}
+						}
+
+					} catch (UnsupportedEncodingException e) {
+						e.printStackTrace();
+					}
+
 					resultListener.none();
 				} else {
 					resultListener.onResult(goods);
@@ -211,15 +230,23 @@
 					return;
 				}
 				if (goods != null && goods.getGoodsId() != null) {
-					resultListener.onResult(new GoodsDocParseResultVO(text, goods));
+					if (tokenList.size() == 1) {// 鍗曚釜鍙d护
+						resultListener.onResult(goods);
+					} else
+						resultListener.onResult(new GoodsDocParseResultVO(text, goods));
 				} else {
 					resultListener.onResult(new GoodsDocParseResultVO(text));
 				}
-
 			}
 
 		} else if (typeSet.size() == 3) {// 鍙d护+閾炬帴+鏂囨湰
-			List<String> tokenList = TaoBaoUtil.getTokenListFromText(text);
+			// 娣樺彛浠�
+			List<String> tokenList = null;
+			if (VersionUtil.greaterThan_2_0_7(platform, version))
+				tokenList = TaoBaoUtil.getTokenListFromTextWithKuoHao(text);
+			else
+				tokenList = TaoBaoUtil.getTokenListFromText(text);
+
 			List<String> urlList = HttpUtil.getUrlListFromText(text);
 			if (text.contains("銆�") && tokenList != null && tokenList.size() == 1 && urlList != null
 					&& urlList.size() == 1) {// Android娣樺疂閾炬帴澶嶅埗
@@ -246,33 +273,32 @@
 
 			} else {// 鏂囨
 
-				String link = null;
 				String token = null;
+				token = tokenList.get(0);
 
-				if (text.indexOf(urlList.get(0)) < text.indexOf(tokenList.get(0)))// 绗竴涓摼鎺ュ湪绗竴涓彛浠ゅ墠闈�
-					link = urlList.get(0);
-				else// 绗竴涓彛浠ゅ湪绗竴涓摼鎺ュ墠闈�
-					token = tokenList.get(0);
-
-				if (!StringUtil.isNullOrEmpty(link)) {
-					CommonGoods goods = parseLink(urlList.get(0));
-					if (goods == null || goods.getGoodsId() == null) {
-						resultListener.onResult(new GoodsDocParseResultVO(text, urlList.get(0)));
-					} else {
-						resultListener.onResult(new GoodsDocParseResultVO(text, goods));
-					}
-				} else {
+				if (!StringUtil.isNullOrEmpty(token)) {
 					CommonGoods goods = null;
 					try {
 						goods = parseTaoBaoToken(token);
 						if (goods != null && goods.getGoodsId() != null) {
-							resultListener.onResult(new GoodsDocParseResultVO(text, goods));
+							// 濡�:http://rd.wechat.com/qrcode/confirm?block_type=101&content=%E3%80%90%E5%8E%9F%E4%BB%B7%E3%80%9120%E5%85%83%0A%E3%80%90%E5%88%B8%E5%90%8E%E4%BB%B7%E3%80%9120%E5%85%83%0A-----------------%0A%E5%BE%A9%E8%A3%BD%E8%BF%99%E6%9D%A1%EF%BC%8C(psNX1UPRJNe)%EF%BC%8C%E8%BF%9B%E5%85%A5%E3%80%90Tao%E5%AE%9D%E3%80%91%E5%8D%B3%E5%8F%AF%E6%8A%A2%E8%B4%AD&lang=zh_CN&scene=37
+							if (text.contains("//rd.wechat.com/qrcode/")) {// 寰俊澶嶅埗杩囨潵鐨�
+								resultListener.onResult(goods);
+							} else
+								resultListener.onResult(new GoodsDocParseResultVO(text, goods));
 						} else {
 							resultListener.onResult(new GoodsDocParseResultVO(text));
 						}
 					} catch (TaoBaoTokenParseException e) {
 						resultListener.onResult(new GoodsDocParseResultVO(text));
 					}
+				} else {
+					CommonGoods goods = parseLink(urlList.get(0));
+					if (goods == null || goods.getGoodsId() == null) {
+						resultListener.onResult(new GoodsDocParseResultVO(text, urlList.get(0)));
+					} else {
+						resultListener.onResult(new GoodsDocParseResultVO(text, goods));
+					}
 				}
 			}
 			return;

--
Gitblit v1.8.0