| | |
| | | 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;
|
| | |
| | | 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;
|
| | |
|
| | |
| | | // 解析商品
|
| | | CommonGoods goods = parseLink(text);
|
| | | if (goods == null) {
|
| | | // 判断链接之中是否包含口令
|
| | | 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);
|
| | |
| | | return;
|
| | | }
|
| | | if (goods != null && goods.getGoodsId() != null) {
|
| | | resultListener.onResult(new GoodsDocParseResultVO(text, goods));
|
| | | if (tokenList.size() == 1) {// 单个口令
|
| | | resultListener.onResult(goods);
|
| | | } else
|
| | | resultListener.onResult(new GoodsDocParseResultVO(text, goods));
|
| | | } else {
|
| | | resultListener.onResult(new GoodsDocParseResultVO(text));
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | } else if (typeSet.size() == 3) {// 口令+链接+文本
|
| | | 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淘宝链接复制
|
| | |
| | |
|
| | | } 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;
|