From 30d8e227e8d823b6c38c3b9c90ac2df03b63befe Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 25 二月 2025 16:41:22 +0800 Subject: [PATCH] 淘宝转链接口更新 --- fanli/src/main/java/com/yeshi/fanli/service/impl/user/cloud/UserCloudServiceImpl.java | 49 ++++++++++++++++++++++++++++++++----------------- 1 files changed, 32 insertions(+), 17 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/cloud/UserCloudServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/cloud/UserCloudServiceImpl.java index af448fe..9581d0d 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/cloud/UserCloudServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/cloud/UserCloudServiceImpl.java @@ -9,8 +9,12 @@ import javax.annotation.Resource; 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.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.core.task.TaskExecutor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -49,7 +53,7 @@ import com.yeshi.fanli.entity.system.ConfigKeyEnum; import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief; import com.yeshi.fanli.entity.taobao.TaoBaoLink; -import com.yeshi.fanli.exception.goods.ConvertLinkExceptionException; +import com.yeshi.fanli.exception.goods.ConvertLinkException; import com.yeshi.fanli.exception.user.cloud.UserCloudException; import com.yeshi.fanli.exception.user.cloud.UserCloudGoodsException; import com.yeshi.fanli.log.LogHelper; @@ -94,6 +98,8 @@ @Service public class UserCloudServiceImpl implements UserCloudService { + + Logger logger = LoggerFactory.getLogger(UserCloudService.class); @Resource private UserCloudMapper userCloudMapper; @@ -161,6 +167,10 @@ @Resource private TaoBaoLinkManager taoBaoLinkManager; + + + @Resource + private PIDManager pidManager; @Override public UserCloud getValidByUid(Long uid) { @@ -485,10 +495,10 @@ for (CommentInfo commentInfo : comments) { String comment = null; try { - comment = convertLinkManager.convertLinkFromText(commentInfo.getContent(), uid, true,false); + comment = convertLinkManager.convertLinkFromText(user.getSystem(), commentInfo.getContent(), uid, true, false); hasToken = true; - } catch (ConvertLinkExceptionException e) { - if (e.getCode() != ConvertLinkExceptionException.CODE_NONE) { + } catch (ConvertLinkException e) { + if (e.getCode() != ConvertLinkException.CODE_NONE) { throw new UserCloudException(1, e.getMsg()); } } catch (Exception e) { @@ -655,7 +665,7 @@ @Override @Transactional(rollbackFor = Exception.class) - public void sendCustomGoods(Long uid, Long goodsId, Integer goodsType, Long sellerId) throws UserCloudException { + public void sendCustomGoods(Long uid, String goodsId, Integer goodsType, Long sellerId) throws UserCloudException { sendCircleByGoods(uid, goodsId, goodsType, null, sellerId, UserCloudSendRecord.SEND_WAY_MANUAL); } @@ -690,7 +700,7 @@ } } - private void sendCircleByGoods(Long uid, Long goodsId, Integer goodsType, Long storeId, Long sellerId, int way) + private void sendCircleByGoods(Long uid, String goodsId, Integer goodsType, Long storeId, Long sellerId, int way) throws UserCloudException { long begainTime = java.lang.System.currentTimeMillis(); @@ -818,11 +828,11 @@ } else if (goodsType == Constant.SOURCE_TYPE_JD) { sendJDGoods(user, robotId, wxId, goodsId, relationId, listOpen, result.getId()); } else if (goodsType == Constant.SOURCE_TYPE_PDD) { - sendPDDGoods(user, robotId, wxId, goodsId, relationId, listOpen, result.getId()); + sendPDDGoods(user, robotId, wxId, goodsId, relationId, listOpen, result.getId()); } else if (goodsType == Constant.SOURCE_TYPE_VIP) { - sendVIPGoods(user, robotId, wxId, goodsId, relationId, listOpen, result.getId()); + sendVIPGoods(user, robotId, wxId, Long.parseLong(goodsId), relationId, listOpen, result.getId()); } else if (goodsType == Constant.SOURCE_TYPE_SUNING) { - sendSuNingGoods(user, robotId, wxId, goodsId, sellerId, relationId, listOpen, result.getId()); + sendSuNingGoods(user, robotId, wxId, Long.parseLong(goodsId), sellerId, relationId, listOpen, result.getId()); } // 鏇存柊鍙戝崟璁板綍 if (storeId != null) { @@ -861,11 +871,11 @@ * @param listOpen * @throws UserCloudException */ - private void sendTaoBaoGoods(UserInfo user, int robotId, String wxId, Long goodsId, String relationId, + private void sendTaoBaoGoods(UserInfo user, int robotId, String wxId, String goodsId, String relationId, List<UserCloudGroup> listOpen, String pid) throws UserCloudException { TaoBaoLink taoBaoLink = null; try { - taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForShare(user.getId(), goodsId, relationId, null); + taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForShare(user.getSystem(), user.getId(), goodsId, relationId, null); } catch (TaoBaoConvertLinkException e) { LogHelper.errorDetailInfo(e); throw new UserCloudException(1, "璇ュ晢鍝佸凡涓嬫灦"); @@ -918,7 +928,7 @@ * @param listOpen * @throws UserCloudException */ - private void sendJDGoods(UserInfo user, int robotId, String wxId, Long goodsId, String relationId, + private void sendJDGoods(UserInfo user, int robotId, String wxId, String goodsId, String relationId, List<UserCloudGroup> listOpen, String pid) throws UserCloudException { JDGoods jdGoods = jdGoodsCacheUtil.getGoodsInfo(goodsId); if (jdGoods == null) @@ -930,8 +940,13 @@ couponUrl = couponInfo.getLink(); } String materialId = "https://item.jd.com/" + goodsId + ".html"; - String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null,JDApiUtil.POSITION_SHARE + "", - user.getId() + ""); + String jumpLink = null; + try { + jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, pidManager.getPidCache(user.getSystem(), Constant.SOURCE_TYPE_JD, SystemPIDInfo.PidType.share), + user.getId() + ""); + } catch (Exception e) { + logger.warn(String.format("浜笢杞摼鍑洪敊锛歮aterialId-%s couponUrl-%s", materialId, couponUrl), e); + } boolean coupon = false; if (couponInfo != null) { @@ -984,13 +999,13 @@ * @param listOpen * @throws UserCloudException */ - private void sendPDDGoods(UserInfo user, int robotId, String wxId, Long goodsId, String relationId, + private void sendPDDGoods(UserInfo user, int robotId, String wxId, String goodsId, String relationId, List<UserCloudGroup> listOpen, String pid) throws UserCloudException { PDDGoodsDetail goods = pinDuoDuoCacheUtil.getGoodsInfo(goodsId); if (goods == null) throw new UserCloudException(1, "璇ュ晢鍝佸凡涓嬫灦"); - String jumpLink = PinDuoDuoApiUtil.getPromotionUrl(goods.getGoodsSign(), PinDuoDuoApiUtil.PID_SHARE + "", user.getId() + ""); + String jumpLink = PinDuoDuoApiUtil.getPromotionUrl(goods.getGoodsSign(), pidManager.getPidCache(user.getSystem(), Constant.SOURCE_TYPE_PDD, SystemPIDInfo.PidType.share), user.getId() + ""); boolean coupon = true; if (goods.getHasCoupon() == null || !goods.getHasCoupon()) { @@ -1102,7 +1117,7 @@ String couponLink = goods.getCouponInfo().getCouponUrl(); String jumpLink = SuningApiUtil.convertLink(SuningUtil.getProductUrl(sellerId + "", goodsId + ""), - StringUtil.isNullOrEmpty(couponLink) ? null : couponLink, SuningApiUtil.PID_SHARE, user.getId() + ""); + StringUtil.isNullOrEmpty(couponLink) ? null : couponLink, pidManager.getPidCache(user.getSystem(), Constant.SOURCE_TYPE_SUNING, SystemPIDInfo.PidType.share), user.getId() + ""); boolean coupon = false; String couponAmount = ""; -- Gitblit v1.8.0