admin
2025-02-25 30d8e227e8d823b6c38c3b9c90ac2df03b63befe
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, "该商品已下架");
@@ -884,7 +894,7 @@
        String couponAmount = "";
        if (coupon) {
            description = goods.getDescription();
            quanPrice = TaoBaoUtil.getAfterUseCouplePrice(goods) + "";
            quanPrice = TaoBaoUtil.getCouponPrice(goods) + "";
            couponAmount = MoneyBigDecimalUtil.getWithNoZera(goods.getCouponAmount()).toString();
        }
        String sales = TaoBaoUtil.getSaleCount(goods.getBiz30day());
@@ -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("京东转链出错:materialId-%s  couponUrl-%s", materialId, couponUrl), e);
        }
        boolean coupon = false;
        if (couponInfo != null) {
@@ -941,7 +956,7 @@
        String quanPrice = "";
        String couponAmount = "";
        if (coupon) {
            quanPrice = BigDecimalUtil.getWithNoZera(JDUtil.getQuanPrice(jdGoods)).toString() + "";
            quanPrice = BigDecimalUtil.getWithNoZera(JDUtil.getCouponPrice(jdGoods)).toString() + "";
            couponAmount = BigDecimalUtil.getWithNoZera(couponInfo.getDiscount()).toString();
        }
@@ -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()) {
@@ -1003,7 +1018,7 @@
            BigDecimal hundred = new BigDecimal(100);
            BigDecimal amount = MoneyBigDecimalUtil.div(new BigDecimal(goods.getCouponDiscount()), hundred);
            quanPrice = BigDecimalUtil.getWithNoZera(amount).toString();
            couponAmount = BigDecimalUtil.getWithNoZera(PinDuoDuoUtil.getQuanPrice(goods)).toString();
            couponAmount = BigDecimalUtil.getWithNoZera(PinDuoDuoUtil.getCouponPrice(goods)).toString();
        }
        String sales = goods.getSalesTip();
@@ -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 = "";