From 58ee87fd64efdb75d16e396c3d952d3522c3a747 Mon Sep 17 00:00:00 2001 From: yj <Administrator@192> Date: 星期三, 04 三月 2020 17:54:53 +0800 Subject: [PATCH] Merge branch 'div' of ssh://193.112.35.168:29418/fanli-server into div --- fanli/src/main/java/com/yeshi/fanli/service/manger/ClipboardAnalysisManager.java | 136 ++++++++++++++++++++++++++++----------------- 1 files changed, 84 insertions(+), 52 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 d3e0ec7..14fce98 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,5 +1,8 @@ package com.yeshi.fanli.service.manger; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -9,6 +12,10 @@ import javax.annotation.Resource; +import org.apache.commons.httpclient.Header; +import org.apache.commons.httpclient.HttpClient; +import org.apache.commons.httpclient.HttpException; +import org.apache.commons.httpclient.methods.PostMethod; import org.springframework.stereotype.Component; import org.yeshi.utils.HttpUtil; import org.yeshi.utils.NumberUtil; @@ -22,6 +29,7 @@ import com.yeshi.fanli.exception.user.TokenRecordException; import com.yeshi.fanli.service.inter.user.TokenRecordService; import com.yeshi.fanli.service.manger.goods.jd.JDGoodsLinkParseManager; +import com.yeshi.fanli.service.manger.goods.tb.TaoBaoTokenAuctionIdMapManager; import com.yeshi.fanli.util.DouYinUtil; import com.yeshi.fanli.util.StringUtil; import com.yeshi.fanli.util.TokenUtil; @@ -33,7 +41,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; @@ -41,6 +48,7 @@ /** * 绮樿创鏉胯В鏋� + * * @author Administrator * */ @@ -53,15 +61,14 @@ @Resource private TokenRecordService tokenRecordService; + @Resource + private TaoBaoTokenAuctionIdMapManager taoBaoTokenAuctionIdMapManager; + /** - * @Title: parseContentType - * @Description: 瑙f瀽鏂囨湰鐨勭被鍨� - * @param text - * @return - * Set<ClipboardContentType> 杩斿洖绫诲瀷 - * @throws + * @Title: parseContentType @Description: 瑙f瀽鏂囨湰鐨勭被鍨� @param text @return Set + * <ClipboardContentType> 杩斿洖绫诲瀷 @throws */ - public static Set<ClipboardContentType> parseContentType(String originText) { + public static Set<ClipboardContentType> parseContentType(String originText, String platform, String version) { Set<ClipboardContentType> typeSet = new HashSet<>(); StringBuffer textBuffer = new StringBuffer(originText); String text = textBuffer.toString(); @@ -85,14 +92,17 @@ } // 娣樺彛浠� - List<String> taoBaoTokenList = TaoBaoUtil.getTokenListFromText(text); + List<String> taoBaoTokenList = null; + if (VersionUtil.greaterThan_2_0_7(platform, version)) + taoBaoTokenList = TaoBaoUtil.getTokenListFromTextWithKuoHao(text); + else + taoBaoTokenList = TaoBaoUtil.getTokenListFromText(text); if (taoBaoTokenList != null && taoBaoTokenList.size() > 0) { typeSet.add(ClipboardContentType.taoBaoToken); for (String token : taoBaoTokenList) { text = text.replace(token, ""); } } - // 鏂囨湰 if (text != null && text.trim().length() > 0) { typeSet.add(ClipboardContentType.text); @@ -103,19 +113,15 @@ /** * - * @Title: parse - * @Description: 瑙f瀽 - * @param text - * @param typeSet - * void 杩斿洖绫诲瀷 - * @throws + * @Title: parse @Description: 瑙f瀽 @param text @param typeSet void + * 杩斿洖绫诲瀷 @throws */ public void parse(String platform, String version, String text, Long uid, IClipboardAnalysisResult resultListener) { if (text == null) return; text = text.trim(); - Set<ClipboardContentType> typeSet = parseContentType(text); + Set<ClipboardContentType> typeSet = parseContentType(text, platform, version); // 绯荤粺鍙d护 if (typeSet.contains(ClipboardContentType.systemToken)) { @@ -138,6 +144,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); @@ -165,7 +190,11 @@ } } else if (typeSet.size() == 2) { List<String> urlList = HttpUtil.getUrlListFromText(text); - 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); String link = null; String token = null; @@ -189,7 +218,10 @@ resultListener.onResult(new GoodsDocParseResultVO(text, urlList.get(0))); } else { if (VersionUtil.greaterThan_2_0_7(platform, version)) { - resultListener.onResult(new GoodsDocParseResultVO(text, goods)); + if (urlList.size() == 1)// 鍗曢摼鎺�+鏂囨湰 + resultListener.onResult(goods); + else + resultListener.onResult(new GoodsDocParseResultVO(text, goods)); } else { resultListener.onResult(goods); } @@ -203,15 +235,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娣樺疂閾炬帴澶嶅埗 @@ -224,7 +264,8 @@ if (goods == null) { if (text.trim().indexOf("銆�") > -1 && text.trim().indexOf("銆�") > 0) { // 鎴彇鏍囬 - String title = text.trim().substring(text.trim().indexOf("銆�")+1, text.trim().lastIndexOf("銆�")); + String title = text.trim().substring(text.trim().indexOf("銆�") + 1, + text.trim().lastIndexOf("銆�")); goods = new CommonGoods(); goods.setTitle(title); goods.setPicture("http://"); @@ -237,32 +278,31 @@ } 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)); } } } @@ -272,12 +312,8 @@ /** * - * @Title: parseLink - * @Description: 瑙f瀽鍗曢摼鎺� - * @param link - * @return - * CommonGoods 杩斿洖绫诲瀷 - * @throws + * @Title: parseLink @Description: 瑙f瀽鍗曢摼鎺� @param link @return CommonGoods + * 杩斿洖绫诲瀷 @throws */ public CommonGoods parseLink(String link) { @@ -404,8 +440,7 @@ } private CommonGoods parseTaoBaoToken(String token) throws TaoBaoTokenParseException { - - Long auctionId = TaoKeApiUtil.tokenConvertAuctionId(token); + Long auctionId = taoBaoTokenAuctionIdMapManager.getAuctionIdByToken(token); if (auctionId != null) {// TaoBaoGoodsBrief goods = TaoBaoUtil.isAlimama(auctionId + ""); if (goods == null) { @@ -423,12 +458,8 @@ /** * - * @Title: analysisDouYin - * @Description: 鎶栭煶瑙f瀽 - * @param link - * @return - * CommonGoods 杩斿洖绫诲瀷 - * @throws + * @Title: analysisDouYin @Description: 鎶栭煶瑙f瀽 @param link @return CommonGoods + * 杩斿洖绫诲瀷 @throws */ private TaoBaoGoodsBrief analysisDouYin(String link) { String location = HttpUtil.getLocation(link); @@ -458,6 +489,7 @@ /** * 绮樿创鏉胯В鏋愮粨鏋� + * * @author Administrator * */ -- Gitblit v1.8.0