admin
2020-02-28 1d9eef9a4ba7caebf73b483e0062f9259dbf22a0
fanli/src/main/java/com/yeshi/fanli/service/manger/ClipboardAnalysisManager.java
@@ -1,5 +1,6 @@
package com.yeshi.fanli.service.manger;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -22,6 +23,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;
@@ -41,6 +43,7 @@
/**
 * 粘贴板解析
 *
 * @author Administrator
 *
 */
@@ -53,15 +56,14 @@
   @Resource
   private TokenRecordService tokenRecordService;
   @Resource
   private TaoBaoTokenAuctionIdMapManager taoBaoTokenAuctionIdMapManager;
   /**
    * @Title: parseContentType
    * @Description: 解析文本的类型
    * @param text
    * @return
    * Set<ClipboardContentType> 返回类型
    * @throws
    * @Title: parseContentType @Description: 解析文本的类型 @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 +87,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 +108,15 @@
   /**
    * 
    * @Title: parse
    * @Description: 解析
    * @param text
    * @param typeSet
    * void 返回类型
    * @throws
    * @Title: parse @Description: 解析 @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);
      // 系统口令
      if (typeSet.contains(ClipboardContentType.systemToken)) {
@@ -165,7 +166,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 +194,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);
               }
@@ -224,7 +232,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://");
@@ -272,12 +281,8 @@
   /**
    * 
    * @Title: parseLink
    * @Description: 解析单链接
    * @param link
    * @return
    * CommonGoods 返回类型
    * @throws
    * @Title: parseLink @Description: 解析单链接 @param link @return CommonGoods
    *         返回类型 @throws
    */
   public CommonGoods parseLink(String link) {
@@ -404,8 +409,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 +427,8 @@
   /**
    * 
    * @Title: analysisDouYin
    * @Description: 抖音解析
    * @param link
    * @return
    * CommonGoods 返回类型
    * @throws
    * @Title: analysisDouYin @Description: 抖音解析 @param link @return CommonGoods
    *         返回类型 @throws
    */
   private TaoBaoGoodsBrief analysisDouYin(String link) {
      String location = HttpUtil.getLocation(link);
@@ -458,6 +458,7 @@
/**
 * 粘贴板解析结果
 *
 * @author Administrator
 *
 */