admin
2021-05-29 e75b0d79535a6bcd147cca4a54632b70b42afdb9
fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java
@@ -18,7 +18,9 @@
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;
@@ -125,6 +127,10 @@
    @Resource
    private DaTaoKeGoodsDetailV2Service daTaoKeGoodsDetailV2Service;
    @Resource
    private PIDManager pidManager;
    @Override
    public void switchState(String id) throws GoodsEvaluateException {
@@ -546,7 +552,7 @@
        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) {
@@ -557,15 +563,16 @@
                }
                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, "该商品转链失败");
                }
@@ -613,7 +620,7 @@
    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) {
@@ -625,16 +632,19 @@
                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);
        }
@@ -911,7 +921,7 @@
                }
            } 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, "不包含可转链的口令与链接");
                }
@@ -936,7 +946,7 @@
    }
    @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, "请保存第一部分信息");
@@ -981,7 +991,7 @@
        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, "包含不可转链的口令与链接");
@@ -2148,7 +2158,7 @@
        // 生成口令
        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();