| | |
| | | package com.yeshi.fanli.service.manger;
|
| | |
|
| | | import java.io.UnsupportedEncodingException;
|
| | | import java.net.URLDecoder;
|
| | | import java.util.HashSet;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
| | | import com.yeshi.fanli.entity.jd.JDGoods;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.exception.taobao.TaoBaoTokenParseException;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
|
| | | 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.Constant;
|
| | | import com.yeshi.fanli.util.DouYinUtil;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TokenUtil;
|
| | | import com.yeshi.fanli.util.Utils;
|
| | |
| | | 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;
|
| | |
|
| | |
| | |
|
| | | /**
|
| | | * 粘贴板解析
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | |
| | | @Resource
|
| | | private TokenRecordService tokenRecordService;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoTokenAuctionIdMapManager taoBaoTokenAuctionIdMapManager;
|
| | |
|
| | | @Resource
|
| | | private RedisManager redisManager;
|
| | |
|
| | | /**
|
| | | * @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();
|
| | |
| | | }
|
| | |
|
| | | // 淘口令
|
| | | 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);
|
| | |
| | |
|
| | | /**
|
| | | *
|
| | | * @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)) {
|
| | |
| | | // 解析商品
|
| | | 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);
|
| | |
| | | }
|
| | | } 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;
|
| | |
| | | link = urlList.get(0);
|
| | | else// 第一个口令在第一个链接前面
|
| | | token = tokenList.get(0);
|
| | |
|
| | | } else if (typeSet.contains(ClipboardContentType.link) && typeSet.contains(ClipboardContentType.text)) {// 链接+文本
|
| | | link = urlList.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)));
|
| | | if (tokenList.size() == 0 && urlList.size() == 2
|
| | | && urlList.get(0).indexOf("://uland.taobao.com") > -1
|
| | | && urlList.get(1).indexOf("?id=") > -1) {// 有2个链接的文案,第一个是店铺券链接,其中二个是淘宝商品详情
|
| | | CommonGoods goods1 = parseLink(urlList.get(1));
|
| | | if (goods1 != null && goods1.getGoodsType() == Constant.SOURCE_TYPE_TAOBAO) {
|
| | | resultListener.onResult(goods1);
|
| | | } else {
|
| | | resultListener.onResult(new GoodsDocParseResultVO(text, urlList.get(0)));
|
| | | }
|
| | |
|
| | | } else if (urlList.size() > 1)
|
| | | resultListener.onResult(new GoodsDocParseResultVO(text, urlList.get(0)));
|
| | | else {// 单链接
|
| | | // 判断是否包含可转链的链接
|
| | | if (!isContainsLinkConvert(link))
|
| | | resultListener.none();
|
| | | else
|
| | | resultListener.onResult(new GoodsDocParseResultVO(text, link));
|
| | | }
|
| | | } 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);
|
| | | }
|
| | |
| | | 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.startsWith("【") && tokenList != null && tokenList.size() == 1 && urlList != null
|
| | | if (text.contains("【") && tokenList != null && tokenList.size() == 1 && urlList != null
|
| | | && urlList.size() == 1) {// Android淘宝链接复制
|
| | | CommonGoods goods = null;
|
| | | try {
|
| | |
| | | e1.printStackTrace();
|
| | | }
|
| | | if (goods == null) {
|
| | | if (text.trim().indexOf("【") == 0 && text.trim().indexOf("】") > 0) {
|
| | | if (text.trim().indexOf("【") > -1 && text.trim().indexOf("】") > 0) {
|
| | | // 截取标题
|
| | | String title = text.trim().substring(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://");
|
| | |
| | |
|
| | | } 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));
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | /**
|
| | | *
|
| | | * @Title: parseLink
|
| | | * @Description: 解析单链接
|
| | | * @param link
|
| | | * @return |
| | | * CommonGoods 返回类型
|
| | | * @throws
|
| | | * @Title: parseLink @Description: 解析单链接 @param link @return CommonGoods
|
| | | * 返回类型 @throws
|
| | | */
|
| | | public CommonGoods parseLink(String link) {
|
| | |
|
| | | SimpleCommonGoods simpleGoods = parseGoodsIdFromLink(link);
|
| | | if (simpleGoods == null) {
|
| | | return null;
|
| | | }
|
| | |
|
| | | CommonGoods commonGoods = null;
|
| | | if (simpleGoods.getGoodsType() == Constant.SOURCE_TYPE_TAOBAO) {
|
| | | TaoBaoGoodsBrief goods = null;
|
| | | try {
|
| | | goods = redisManager.getTaoBaoGoodsBrief(Long.parseLong(simpleGoods.getGoodsId()));
|
| | | } catch (NumberFormatException e) {
|
| | | e.printStackTrace();
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | if (goods != null) {
|
| | | commonGoods = CommonGoodsFactory.create(goods);
|
| | | } else {
|
| | | goods = TaoBaoUtil.getTmallGoodsInfo(simpleGoods.getGoodsId());
|
| | | if (goods != null) {
|
| | | commonGoods = new CommonGoods();
|
| | | commonGoods.setTitle(goods.getTitle());
|
| | | commonGoods.setPicture(goods.getPictUrl());
|
| | | } else {
|
| | | // TODO 根据淘宝商品ID解析标题与图片
|
| | | }
|
| | | }
|
| | |
|
| | | } else if (simpleGoods.getGoodsType() == Constant.SOURCE_TYPE_JD) {
|
| | | // 优先采用高级接口请求数据
|
| | | JDGoods jdGoods = null;
|
| | | try {
|
| | | // 防止高级接口被收回
|
| | | jdGoods = JDApiUtil.queryGoodsDetail(Long.parseLong(simpleGoods.getGoodsId()));
|
| | | } catch (Exception e) {
|
| | | }
|
| | | if (jdGoods == null) {
|
| | | jdGoods = JDApiUtil.getGoodsDetail(Long.parseLong(simpleGoods.getGoodsId()));
|
| | | }
|
| | | if (jdGoods != null) {
|
| | | commonGoods = CommonGoodsFactory.create(jdGoods);
|
| | | } else {// 商品并未参与推广
|
| | | jdGoods = JDUtil.getSimpleGoodsInfo(simpleGoods.getGoodsId());
|
| | | if (jdGoods != null) {
|
| | | commonGoods = new CommonGoods();
|
| | | commonGoods.setTitle(jdGoods.getSkuName());
|
| | | commonGoods.setPicture(jdGoods.getPicUrl());
|
| | | }
|
| | | }
|
| | | } else if (simpleGoods.getGoodsType() == Constant.SOURCE_TYPE_PDD) {
|
| | | PDDGoodsDetail goods = PinDuoDuoApiUtil.getGoodsDetail(Long.parseLong(simpleGoods.getGoodsId()));
|
| | | if (goods != null) {
|
| | | commonGoods = CommonGoodsFactory.create(goods);
|
| | | } else {
|
| | | goods = PinDuoDuoUtil.getPDDGoodsInfo(simpleGoods.getGoodsId());
|
| | | if (goods != null) {
|
| | | commonGoods = new CommonGoods();
|
| | | commonGoods.setTitle(goods.getGoodsName());
|
| | | commonGoods.setPicture(goods.getGoodsThumbnailUrl());
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | return commonGoods;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 从链接中解析商品ID
|
| | | * |
| | | * @return
|
| | | */
|
| | | public SimpleCommonGoods parseGoodsIdFromLink(String link) {
|
| | |
|
| | | String jdId = parseJDSkuIdFromLink(link);
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(jdId)) {
|
| | | return new SimpleCommonGoods(jdId, Constant.SOURCE_TYPE_JD);
|
| | | }
|
| | |
|
| | | // 解析拼多多
|
| | | String pddId = PinDuoDuoUtil.getPDDGoodsId(link);
|
| | | if (!StringUtil.isNullOrEmpty(pddId)) {
|
| | | return new SimpleCommonGoods(pddId, Constant.SOURCE_TYPE_PDD);
|
| | | }
|
| | | // 解析淘宝
|
| | | String auctionId = parseTBAuctionIdFromLink(link);
|
| | | if (!StringUtil.isNullOrEmpty(auctionId)) {
|
| | | return new SimpleCommonGoods(auctionId, Constant.SOURCE_TYPE_TAOBAO);
|
| | | }
|
| | |
|
| | | return null;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 从链接中解析京东商品的SKUID
|
| | | * |
| | | * @param link
|
| | | * @return
|
| | | */
|
| | | public String parseJDSkuIdFromLink(String link) {
|
| | | // 解析其他商品
|
| | | String jdId = JDUtil.getJDGoodsId(link);
|
| | |
|
| | | // 微信链接
|
| | | if (StringUtil.isNullOrEmpty(jdId)) {
|
| | | jdId = JDUtil.getJDGoodsIdByWeiXin(link);
|
| | | }
|
| | |
|
| | | // 领券短连接
|
| | | if (StringUtil.isNullOrEmpty(jdId) && link.contains("u.jd.com")) {
|
| | | jdId = jdGoodsLinkParseManager.parseGoodsIdByJDShortUrl(link);
|
| | | }
|
| | |
|
| | | return jdId;
|
| | | }
|
| | |
|
| | | public String parseTBAuctionIdFromLink(String link) {
|
| | | TaoBaoGoodsBrief tb = null;
|
| | | String auctionId = null;
|
| | | if (link.startsWith("https://a.m.taobao.com/i"))// 淘宝账号未登录状态
|
| | | {
|
| | | link = link.substring("https://a.m.taobao.com/i".length(), link.indexOf(".htm"));
|
| | | if (NumberUtil.isNumeric(link)) {
|
| | | tb = TaoBaoUtil.isAlimama(link);
|
| | | auctionId = link + "";
|
| | | }
|
| | | } else if (link.contains("ju.taobao.com") || link.contains(".juhuasuan.com")) {// 聚划算
|
| | | int index = link.indexOf("item_id");
|
| | |
| | | else {
|
| | | id = link.substring(link.indexOf("=" + 1));
|
| | | }
|
| | | tb = TaoBaoUtil.isAlimama(id);
|
| | | if (tb == null) {
|
| | | tb = new TaoBaoGoodsBrief(Long.parseLong(id));
|
| | | }
|
| | | auctionId = id;
|
| | | }
|
| | | } else if (link.contains("http://zmnxbc.com")) { // 手机端天猫APP分享
|
| | | tb = TaoBaoUtil.parsePhoneShareUrlByTM(link);
|
| | | if (tb != null)
|
| | | auctionId = tb.getAuctionId() + "";
|
| | | } else if (link.contains("h5.m.taobao") || link.contains("detail.m.tmall") || link.contains("item.taobao")
|
| | | || link.contains("detail.tmall")) { // 手机页面和电脑页面
|
| | | Map<String, String> map = Utils.parseURL(link);
|
| | | String id = "";
|
| | | id = map.get("id").replace("}", "");
|
| | | tb = TaoBaoUtil.isAlimama(id);
|
| | | if (tb == null) {
|
| | | tb = new TaoBaoGoodsBrief(Long.parseLong(id));
|
| | | }
|
| | | auctionId = id;
|
| | | } else if (link.contains("v.douyin.com")) { // 抖音
|
| | | tb = analysisDouYin(link);
|
| | | if (tb != null) {
|
| | | if (!StringUtil.isNullOrEmpty(tb.getAuctionUrl())) {// 抖音解析到淘宝商品链接
|
| | | return parseLink(tb.getAuctionUrl());
|
| | | CommonGoods goods = parseLink(tb.getAuctionUrl());
|
| | | if (goods != null) {
|
| | | auctionId = goods.getGoodsId() + "";
|
| | | }
|
| | | }
|
| | | }
|
| | | } else {
|
| | | tb = TaoBaoUtil.parsePhoneShareUrlByTB(link);
|
| | | if (tb != null)
|
| | | auctionId = tb.getAuctionId() + "";
|
| | | }
|
| | |
|
| | | // 没解析到淘宝相关商品
|
| | | if (tb == null) {
|
| | | String goodsId = TaoBaoUtil.getGoodsIdByPhoneShareUrl(link);
|
| | | if (!StringUtil.isNullOrEmpty(goodsId)) {
|
| | | tb = TaoBaoUtil.isAlimama(goodsId);
|
| | | if (tb == null) {
|
| | | tb = new TaoBaoGoodsBrief(Long.parseLong(goodsId));
|
| | | }
|
| | | }
|
| | | }
|
| | | return auctionId;
|
| | |
|
| | | CommonGoods commonGoods = null;
|
| | |
|
| | | // 淘宝商品解析结束
|
| | | if (tb != null) {
|
| | | if (StringUtil.isNullOrEmpty(tb.getTitle())) {
|
| | | tb = TaoBaoUtil.getTaoBaoGoodsBriefNotInPub(tb.getId());
|
| | | if (tb != null) {
|
| | | commonGoods = new CommonGoods();
|
| | | commonGoods.setPicture(tb.getPictUrl());
|
| | | commonGoods.setTitle(tb.getTitle());
|
| | | }
|
| | | } else {
|
| | | commonGoods = CommonGoodsFactory.create(tb);
|
| | | }
|
| | | } else {
|
| | | // 解析其他商品
|
| | | String jdId = JDUtil.getJDGoodsId(link);
|
| | |
|
| | | // 微信链接
|
| | | if (StringUtil.isNullOrEmpty(jdId)) {
|
| | | jdId = JDUtil.getJDGoodsIdByWeiXin(link);
|
| | | }
|
| | |
|
| | | // 领券短连接
|
| | | if (StringUtil.isNullOrEmpty(jdId) && link.contains("u.jd.com")) {
|
| | | jdId = jdGoodsLinkParseManager.parseGoodsIdByJDShortUrl(link);
|
| | | }
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(jdId)) {
|
| | | JDGoods goods = JDApiUtil.getGoodsDetail(Long.parseLong(jdId));
|
| | | if (goods != null) {
|
| | | // 高级接口 -- 信息更完整
|
| | | JDGoods jdGoods = JDApiUtil.queryGoodsDetail(Long.parseLong(jdId));
|
| | | if (jdGoods != null) {
|
| | | commonGoods = CommonGoodsFactory.create(jdGoods);
|
| | | } else {
|
| | | commonGoods = CommonGoodsFactory.create(goods);
|
| | | }
|
| | | } else {
|
| | | goods = JDUtil.getSimpleGoodsInfo(jdId);
|
| | | if (goods != null) {
|
| | | commonGoods = new CommonGoods();
|
| | | commonGoods.setTitle(goods.getSkuName());
|
| | | commonGoods.setPicture(goods.getPicUrl());
|
| | | }
|
| | | }
|
| | | } else {
|
| | | String pddId = PinDuoDuoUtil.getPDDGoodsId(link);
|
| | | if (!StringUtil.isNullOrEmpty(pddId)) {
|
| | | PDDGoodsDetail goods = PinDuoDuoApiUtil.getGoodsDetail(Long.parseLong(pddId));
|
| | | if (goods != null) {
|
| | | commonGoods = CommonGoodsFactory.create(goods);
|
| | | } else {
|
| | | goods = PinDuoDuoUtil.getPDDGoodsInfo(pddId);
|
| | | if (goods != null) {
|
| | | commonGoods = new CommonGoods();
|
| | | commonGoods.setTitle(goods.getGoodsName());
|
| | | commonGoods.setPicture(goods.getGoodsThumbnailUrl());
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | return commonGoods;
|
| | | }
|
| | |
|
| | | 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) {
|
| | |
| | |
|
| | | /**
|
| | | *
|
| | | * @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);
|
| | |
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | private boolean isContainsLinkConvert(String link) {
|
| | | if (link.contains(".jd.com"))
|
| | | return true;
|
| | | else if (link.contains(".taobao.com") || link.contains(".tmall"))
|
| | | return true;
|
| | | else if (link.contains(".pinduoduo.com") || link.contains(".yangkeduo.com"))
|
| | | return true;
|
| | | return false;
|
| | | }
|
| | |
|
| | | class SimpleCommonGoods {
|
| | | private String goodsId;
|
| | | private int goodsType;
|
| | |
|
| | | public SimpleCommonGoods(String goodsId, int goodsType) {
|
| | | this.goodsId = goodsId;
|
| | | this.goodsType = goodsType;
|
| | | }
|
| | |
|
| | | public String getGoodsId() {
|
| | | return goodsId;
|
| | | }
|
| | |
|
| | | public void setGoodsId(String goodsId) {
|
| | | this.goodsId = goodsId;
|
| | | }
|
| | |
|
| | | public int getGoodsType() {
|
| | | return goodsType;
|
| | | }
|
| | |
|
| | | public void setGoodsType(int goodsType) {
|
| | | this.goodsType = goodsType;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 粘贴板解析结果
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|