| | |
| | | import javax.imageio.ImageIO; |
| | | |
| | | import com.yeshi.fanli.entity.SystemEnum; |
| | | import com.yeshi.fanli.entity.SystemPIDInfo; |
| | | import com.yeshi.fanli.exception.taobao.TaoBaoConvertLinkException; |
| | | import com.yeshi.fanli.service.manger.PIDManager; |
| | | import com.yeshi.fanli.service.manger.goods.TaoBaoLinkManager; |
| | | import org.apache.commons.beanutils.PropertyUtils; |
| | | import org.springframework.cache.annotation.CacheEvict; |
| | |
| | | |
| | | @Resource |
| | | private DaTaoKeGoodsDetailV2Service daTaoKeGoodsDetailV2Service; |
| | | |
| | | |
| | | @Resource |
| | | private PIDManager pidManager; |
| | | |
| | | @Override |
| | | public void switchState(String id) throws GoodsEvaluateException { |
| | |
| | | String commentText = ""; |
| | | if (addComment) { |
| | | if (goodsType == Constant.SOURCE_TYPE_TAOBAO) { |
| | | TaoBaoLink taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForShare(1L, Long.parseLong(goodsId), "0", null); |
| | | TaoBaoLink taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForShare(system, 1L, Long.parseLong(goodsId), "0", null); |
| | | String template = configService.getValue(ConfigKeyEnum.quickShareTBCommentText.getKey(), system); |
| | | commentText = template.replace("[淘口令]", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken())); |
| | | } else if (goodsType == Constant.SOURCE_TYPE_JD) { |
| | |
| | | } |
| | | String materialId = "https://item.jd.com/" + goodsId + ".html"; |
| | | String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, |
| | | JDApiUtil.POSITION_SHARE + "", "1"); |
| | | pidManager.getPidCache(system, Constant.SOURCE_TYPE_JD, SystemPIDInfo.PidType.share), "1"); |
| | | String template = configService.getValue(ConfigKeyEnum.quickShareJDCommentText.getKey(), system); |
| | | if (jumpLink == null) { |
| | | throw new GoodsEvaluateException(1, "该商品转链失败"); |
| | | } |
| | | commentText = template.replace("[链接]", jumpLink); |
| | | } else if (goodsType == Constant.SOURCE_TYPE_PDD) { |
| | | PDDGoodsDetail goodsDetail = PinDuoDuoApiUtil.getGoodsDetail(Long.parseLong(goodsId), PinDuoDuoApiUtil.PID_SHARE + "", "1"); |
| | | String jumpLink = PinDuoDuoApiUtil.getPromotionUrl(goodsDetail.getGoodsSign(), PinDuoDuoApiUtil.PID_SHARE + "", "1"); |
| | | String sharePid = pidManager.getPidCache(system, Constant.SOURCE_TYPE_PDD, SystemPIDInfo.PidType.share); |
| | | PDDGoodsDetail goodsDetail = PinDuoDuoApiUtil.getGoodsDetail(Long.parseLong(goodsId), sharePid, "1"); |
| | | String jumpLink = PinDuoDuoApiUtil.getPromotionUrl(goodsDetail.getGoodsSign(), sharePid, "1"); |
| | | if (jumpLink == null) { |
| | | throw new GoodsEvaluateException(1, "该商品转链失败"); |
| | | } |
| | |
| | | private String createTokenAndLink(GoodsDetailVO goodsDetailVO, SystemEnum system) throws Exception { |
| | | String commentText = ""; |
| | | if (goodsDetailVO.getGoodsType() == Constant.SOURCE_TYPE_TAOBAO) { |
| | | TaoBaoLink taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForShare(1L, Long.parseLong(goodsDetailVO.getGoodsId()), "0", null); |
| | | TaoBaoLink taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForShare(system, 1L, Long.parseLong(goodsDetailVO.getGoodsId()), "0", null); |
| | | String template = configService.getValue(ConfigKeyEnum.quickShareTBCommentText.getKey(), system); |
| | | commentText = template.replace("[淘口令]", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken())); |
| | | } else if (goodsDetailVO.getGoodsType() == Constant.SOURCE_TYPE_JD) { |
| | |
| | | couponUrl = couponInfo.getLink(); |
| | | } |
| | | String materialId = "https://item.jd.com/" + goodsDetailVO.getGoodsId() + ".html"; |
| | | String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, JDApiUtil.POSITION_SHARE + "", |
| | | String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, pidManager.getPidCache(system, Constant.SOURCE_TYPE_JD, SystemPIDInfo.PidType.share), |
| | | "1"); |
| | | String template = configService.getValue(ConfigKeyEnum.quickShareJDCommentText.getKey(), system); |
| | | commentText = template.replace("[链接]", jumpLink); |
| | | } else if (goodsDetailVO.getGoodsType() == Constant.SOURCE_TYPE_PDD) { |
| | | |
| | | String sharePid = pidManager.getPidCache(system, Constant.SOURCE_TYPE_PDD, SystemPIDInfo.PidType.share); |
| | | |
| | | PDDGoodsDetail goodsDetail = PinDuoDuoApiUtil.getGoodsDetail(Long.parseLong(goodsDetailVO.getGoodsId()), |
| | | PinDuoDuoApiUtil.PID_SHARE + "", "1"); |
| | | sharePid, "1"); |
| | | |
| | | String jumpLink = PinDuoDuoApiUtil.getPromotionUrl(goodsDetail.getGoodsSign(), |
| | | PinDuoDuoApiUtil.PID_SHARE + "", "1"); |
| | | sharePid, "1"); |
| | | String template = configService.getValue(ConfigKeyEnum.quickSharePDDCommentText.getKey(), system); |
| | | commentText = template.replace("[链接]", jumpLink); |
| | | } |
| | |
| | | } |
| | | } else if (i == 0 && kind == 1) { |
| | | try { |
| | | convertLinkManager.convertLinkFromText(content, Constant.LINK_TOKEN_VERIFY_UID, true, false); |
| | | convertLinkManager.convertLinkFromText(system, content, Constant.LINK_TOKEN_VERIFY_UID, true, false); |
| | | } catch (Exception e) { |
| | | throw new GoodsEvaluateException(1, "不包含可转链的口令与链接"); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void saveCurrencyCoupon(String pid, int kind, CommentInfo commentInfo) |
| | | public void saveCurrencyCoupon(SystemEnum system, String pid, int kind, CommentInfo commentInfo) |
| | | throws GoodsEvaluateException, Exception { |
| | | if (StringUtil.isNullOrEmpty(pid)) { |
| | | throw new GoodsEvaluateException(1, "请保存第一部分信息"); |
| | |
| | | String content = commentInfo.getContent(); |
| | | if (!StringUtil.isNullOrEmpty(content) && commentInfo.getNeedSpin()) { |
| | | try { |
| | | convertLinkManager.convertLinkFromText(content, Constant.LINK_TOKEN_VERIFY_UID, true, false); |
| | | convertLinkManager.convertLinkFromText(system, content, Constant.LINK_TOKEN_VERIFY_UID, true, false); |
| | | } catch (ConvertLinkExceptionException e) { |
| | | if (ConvertLinkExceptionException.CODE_NONE != e.getCode()) { |
| | | throw new GoodsEvaluateException(1, "包含不可转链的口令与链接"); |
| | |
| | | // 生成口令 |
| | | String token = null; |
| | | try { |
| | | TaoBaoLink taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForShare(Constant.LINK_TOKEN_VERIFY_UID, goodsBrief.getAuctionId(), "1", null); |
| | | TaoBaoLink taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForShare(system, Constant.LINK_TOKEN_VERIFY_UID, goodsBrief.getAuctionId(), "1", null); |
| | | token = taoBaoLink.getTaoToken(); |
| | | } catch (TaoBaoConvertLinkException e) { |
| | | e.printStackTrace(); |