| | |
| | | import javax.annotation.Resource; |
| | | |
| | | import com.yeshi.fanli.util.*; |
| | | import com.yeshi.fanli.util.goods.douyin.CSJCPSApiUtil; |
| | | import com.yeshi.fanli.util.goods.douyin.DYUtil; |
| | | import com.yeshi.fanli.util.goods.douyin.vo.DYGoodsDetail; |
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil; |
| | | import com.yeshi.goods.facade.utils.taobao.DaTaoKeApiUtil; |
| | | import org.jsoup.Jsoup; |
| | | import org.springframework.stereotype.Component; |
| | | import org.yeshi.utils.HttpUtil; |
| | | import org.yeshi.utils.NumberUtil; |
| | |
| | | |
| | | Set<ClipboardContentType> typeSet = parseContentType(text, platform, version); |
| | | //新版口令 |
| | | Long goodsId = null; |
| | | String goodsId = null; |
| | | if (text.contains("https://m.tb.cn/")) { |
| | | try { |
| | | TaoKeApiUtil.TokenConvertResult result = TaoKeApiUtil.tokenConvert(text); |
| | | if (result != null) { |
| | | goodsId = result.getNum_iid(); |
| | | } |
| | | } catch (TaoBaoTokenParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | if (goodsId == null) { |
| | | Long auctionId = DaTaoKeApiUtil.parseTaoBaoToken(text); |
| | | if (auctionId != null) { |
| | | typeSet.add(ClipboardContentType.taoBaoToken); |
| | | goodsId = auctionId; |
| | | String tempGoodsId = DaTaoKeApiUtil.parseGoodsIdFromToken(text); |
| | | if (tempGoodsId != null) { |
| | | goodsId = tempGoodsId; |
| | | typeSet.add(ClipboardContentType.taoBaoToken); |
| | | } else { |
| | | try { |
| | | TaoKeApiUtil.TokenConvertResult result = TaoKeApiUtil.tokenConvert(text); |
| | | if (result != null) { |
| | | goodsId = result.getNum_iid(); |
| | | typeSet.add(ClipboardContentType.taoBaoToken); |
| | | } |
| | | } catch (TaoBaoTokenParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | |
| | | } catch (UnsupportedEncodingException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | //TODO 解析链接中的title |
| | | // Jsoup.connect(text).get(); |
| | | |
| | | |
| | | resultListener.none(); |
| | | } else { |
| | |
| | | if (simpleGoods.getGoodsType() == Constant.SOURCE_TYPE_TAOBAO) { |
| | | TaoBaoGoodsBrief goods = null; |
| | | try { |
| | | goods = redisManager.getTaoBaoGoodsBrief(Long.parseLong(simpleGoods.getGoodsId())); |
| | | goods = redisManager.getTaoBaoGoodsBrief(simpleGoods.getGoodsId()); |
| | | } catch (NumberFormatException e) { |
| | | e.printStackTrace(); |
| | | } catch (TaobaoGoodsDownException e) { |
| | |
| | | if (goods != null) { |
| | | commonGoods = CommonGoodsFactory.create(goods); |
| | | } |
| | | }else if (simpleGoods.getGoodsType() == Constant.SOURCE_TYPE_DY) { |
| | | DYGoodsDetail goods = CSJCPSApiUtil.goodsDetail(Long.parseLong( simpleGoods.getGoodsId())); |
| | | if (goods != null) { |
| | | commonGoods = CommonGoodsFactory.create(goods); |
| | | } |
| | | } |
| | | |
| | | return commonGoods; |
| | |
| | | String vipId = VipShopUtil.parseGoodsIdByUrl(link); |
| | | if (!StringUtil.isNullOrEmpty(vipId)) { |
| | | return new SimpleCommonGoods(vipId, Constant.SOURCE_TYPE_VIP); |
| | | } |
| | | String dyProductId= DYUtil.parseProdectIdFromLink(link); |
| | | if (!StringUtil.isNullOrEmpty(dyProductId)) { |
| | | return new SimpleCommonGoods(dyProductId, Constant.SOURCE_TYPE_DY); |
| | | } |
| | | |
| | | // 解析淘宝 |
| | |
| | | } |
| | | |
| | | private CommonGoods parseTaoBaoToken(String token) throws TaoBaoTokenParseException { |
| | | Long auctionId = taoBaoTokenAuctionIdMapManager.getAuctionIdByToken(token); |
| | | String auctionId = taoBaoTokenAuctionIdMapManager.getAuctionIdByToken(token); |
| | | if (auctionId != null) {// |
| | | return getTaoBaoGoods(auctionId); |
| | | } else { |
| | |
| | | } |
| | | } |
| | | |
| | | private CommonGoods getTaoBaoGoods(Long auctionId) { |
| | | private CommonGoods getTaoBaoGoods(String auctionId) { |
| | | TaoBaoGoodsBrief goods = TaoBaoUtil.isAlimama(auctionId + ""); |
| | | if (goods == null) { |
| | | goods = TaoBaoUtil.getTaoBaoGoodsBriefNotInPub(auctionId); |