| | |
| | | import org.springframework.stereotype.Component;
|
| | | import org.yeshi.utils.StringUtil;
|
| | |
|
| | | import com.yeshi.fanli.dto.pdd.PDDPromotionUrl;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.entity.taobao.TaoKeAppInfo;
|
| | | import com.yeshi.fanli.exception.goods.ConvertLinkExceptionException;
|
| | |
| | | import com.yeshi.fanli.util.TaoBaoConstant;
|
| | | import com.yeshi.fanli.util.jd.JDApiUtil;
|
| | | import com.yeshi.fanli.util.jd.JDUtil;
|
| | | 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;
|
| | |
|
| | |
| | | for (String link : linkSet) {
|
| | | if (linkMap.get(link) == null)
|
| | | throw new Exception("京东转链失败");
|
| | | newText = newText.replace(link, linkMap.get(link));
|
| | | }
|
| | |
|
| | | return newText;
|
| | | }
|
| | |
|
| | | public String convertPDDLinkFromText(String text, Long uid, boolean share) throws Exception {
|
| | |
|
| | | StringBuilder builder = new StringBuilder(text);
|
| | | String newText = builder.toString();
|
| | | // 京东转链
|
| | | // 提取京东所有的链接
|
| | | List<String> pddShortLink = PinDuoDuoUtil.getPDDShortLinksFromText(text);
|
| | | Set<String> linkSet = new HashSet<>();
|
| | | Map<String, String> linkMap = new HashMap<>();
|
| | | if (pddShortLink != null && pddShortLink.size() > 0) {
|
| | | linkSet.addAll(pddShortLink);
|
| | | for (String shortLink : linkSet) {
|
| | | String goodsId = PinDuoDuoUtil.getPDDGoodsId(shortLink);
|
| | | if (!StringUtil.isNullOrEmpty(goodsId)) {
|
| | | PDDPromotionUrl pddUrl = PinDuoDuoApiUtil.convert(Long.parseLong(goodsId),
|
| | | share ? PinDuoDuoApiUtil.PID_SHARE : PinDuoDuoApiUtil.PID_FANLI, uid + "");
|
| | | if (pddUrl != null) {
|
| | | linkMap.put(shortLink, pddUrl.getShortUrl());
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | | }
|
| | |
|
| | | for (String link : linkSet) {
|
| | | if (linkMap.get(link) == null)
|
| | | throw new Exception("拼多多转链失败");
|
| | | newText = newText.replace(link, linkMap.get(link));
|
| | | }
|
| | |
|
| | |
| | | public String convertLinkFromText(String text, Long uid, boolean share)
|
| | | throws ConvertLinkExceptionException, Exception {
|
| | | String newText = convertJDLinkFromText(text, uid, share);
|
| | | newText = convertLinkFromText(text, uid, share);
|
| | | newText = convertTBLinkFromText(newText, uid, share);
|
| | | if (text.equalsIgnoreCase(newText))
|
| | | throw new ConvertLinkExceptionException(ConvertLinkExceptionException.CODE_NONE, "不包含可转链的口令与链接");
|