admin
2024-01-23 81da61b828e29b7745e1382dfbbaeb685dc083ef
fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java
@@ -25,7 +25,7 @@
import com.yeshi.fanli.entity.taobao.TaoBaoLink;
import com.yeshi.fanli.exception.dynamic.ActivityUserException;
import com.yeshi.fanli.exception.dynamic.GoodsEvaluateException;
import com.yeshi.fanli.exception.goods.ConvertLinkExceptionException;
import com.yeshi.fanli.exception.goods.ConvertLinkException;
import com.yeshi.fanli.exception.taobao.TaoBaoConvertLinkException;
import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
import com.yeshi.fanli.lijin.manager.GoodsLijinMnager;
@@ -45,6 +45,8 @@
import com.yeshi.fanli.util.cache.PinDuoDuoCacheUtil;
import com.yeshi.fanli.util.factory.CommonGoodsFactory;
import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
import com.yeshi.fanli.util.goods.douyin.vo.DYGoods;
import com.yeshi.fanli.util.goods.douyin.vo.DYGoodsDetail;
import com.yeshi.fanli.util.jd.JDApiUtil;
import com.yeshi.fanli.util.jd.JDUtil;
import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil;
@@ -437,7 +439,7 @@
        params.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(system));
        if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
            try {
                TaoBaoGoodsBrief goodsBrief = redisManager.getTaoBaoGoodsBrief(Long.parseLong(goodsId));
                TaoBaoGoodsBrief goodsBrief = redisManager.getTaoBaoGoodsBrief(goodsId);
                goodsDetailVO = GoodsDetailVOFactory.convertTaoBao(goodsBrief, params);
            } catch (TaobaoGoodsDownException e) {
                throw new GoodsEvaluateException(1, "商品已下架");
@@ -555,7 +557,7 @@
        String commentText = "";
        if (addComment) {
            if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
                TaoBaoLink taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForShare(system, 1L, Long.parseLong(goodsId), "0", null);
                TaoBaoLink taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForShare(system, 1L, 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) {
@@ -623,7 +625,7 @@
    private String createTokenAndLink(GoodsDetailVO goodsDetailVO, SystemEnum system) throws Exception {
        String commentText = "";
        if (goodsDetailVO.getGoodsType() == Constant.SOURCE_TYPE_TAOBAO) {
            TaoBaoLink taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForShare(system, 1L, Long.parseLong(goodsDetailVO.getGoodsId()), "0", null);
            TaoBaoLink taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForShare(system, 1L, 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) {
@@ -663,7 +665,7 @@
        return commentText.replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n");
    }
    public GoodsDetailVO getGoodsDetailVO(Long goodsId, Integer goodsType, SystemEnum system) throws GoodsEvaluateException {
    public GoodsDetailVO getGoodsDetailVO(String goodsId, Integer goodsType, SystemEnum system) throws GoodsEvaluateException {
        GoodsDetailVO goodsDetail = null;
        GoodsMoneyConfigParamsDTO params = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", system);
        params.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(system));
@@ -679,10 +681,10 @@
                throw new GoodsEvaluateException(1, "商品已下架");
            }
        } else if (goodsType == Constant.SOURCE_TYPE_JD) {
            JDGoods goodsInfo = jdGoodsCacheUtil.getGoodsInfo(goodsId);
            JDGoods goodsInfo = jdGoodsCacheUtil.getGoodsInfo(Long.parseLong(goodsId));
            goodsDetail = GoodsDetailVOFactory.convertJDGoods(goodsInfo, params);
        } else if (goodsType == Constant.SOURCE_TYPE_PDD) {
            PDDGoodsDetail goodsInfo = pinDuoDuoCacheUtil.getGoodsInfo(goodsId);
            PDDGoodsDetail goodsInfo = pinDuoDuoCacheUtil.getGoodsInfo(Long.parseLong(goodsId));
            goodsDetail = GoodsDetailVOFactory.convertPDDGoods(goodsInfo, params);
        }
        if (goodsDetail != null)
@@ -776,7 +778,7 @@
                for (int i = 0; i < goodsArray.length && i < 9; i++) {
                    String goodsids = goodsArray[i];
                    String[] g = goodsids.split("-");
                    GoodsDetailVO goodsDetailVO = getGoodsDetailVO(Long.parseLong(g[0]), Integer.parseInt(g[1]), resultObj.getSystem());
                    GoodsDetailVO goodsDetailVO = getGoodsDetailVO(g[0], Integer.parseInt(g[1]), resultObj.getSystem());
                    if (goodsDetailVO == null) {
                        continue;
                    }
@@ -997,8 +999,8 @@
        if (!StringUtil.isNullOrEmpty(content) && commentInfo.getNeedSpin()) {
            try {
                convertLinkManager.convertLinkFromText(system, content, Constant.LINK_TOKEN_VERIFY_UID, true, false);
            } catch (ConvertLinkExceptionException e) {
                if (ConvertLinkExceptionException.CODE_NONE != e.getCode()) {
            } catch (ConvertLinkException e) {
                if (ConvertLinkException.CODE_NONE != e.getCode()) {
                    throw new GoodsEvaluateException(1, "包含不可转链的口令与链接");
                }
            } catch (Exception e) {
@@ -1965,7 +1967,7 @@
        if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
            TaoBaoGoodsBrief goods;
            try {
                goods = redisManager.getTaoBaoGoodsBrief(Long.parseLong(goodsId));
                goods = redisManager.getTaoBaoGoodsBrief(goodsId);
                if (goods != null) {
                    vo = GoodsDetailVOFactory.convertTaoBao(goods, paramsDTO);
                }
@@ -2001,7 +2003,7 @@
        TaoBaoGoodsBrief goodsBrief = null;
        try {
            goodsBrief = redisManager.getTaoBaoGoodsBrief(Long.parseLong(goodsId));
            goodsBrief = redisManager.getTaoBaoGoodsBrief(goodsId);
        } catch (TaobaoGoodsDownException e) {
            throw new GoodsEvaluateException(1, "商品已下架");
        }
@@ -2133,7 +2135,7 @@
        }
        Date limitDate = DateUtil.reduceDay(new Date(), 7);
        Long goodsId = goodsBrief.getAuctionId();
        String goodsId = goodsBrief.getAuctionId();
        List<GoodsEvaluate> evaluateList = goodsEvaluateDao.queryExistLimitTime(Constant.SOURCE_TYPE_TAOBAO, goodsId + "", limitDate);
        if (evaluateList != null && evaluateList.size() > 0)
            throw new GoodsEvaluateException(1, "该商品已存在");
@@ -2152,7 +2154,7 @@
        // 商品图片信息
        int i = 0;
        List<ImgInfo> imgList = new ArrayList<ImgInfo>();
        List<ImgInfo> imgList = new ArrayList<>();
        for (String img : imgs) {
            ImgInfo imgInfo = new ImgInfo();
@@ -2187,7 +2189,7 @@
        // 生成口令
        String token = null;
        try {
            TaoBaoLink taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForShare(system, Constant.LINK_TOKEN_VERIFY_UID, goodsBrief.getAuctionId(), "1", null);
            TaoBaoLink taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForShare(system, Constant.LINK_TOKEN_VERIFY_UID, goodsBrief.getAuctionId(), Constant.LINK_TOKEN_VERIFY_RELATION_ID, null);
            token = taoBaoLink.getTaoToken();
        } catch (TaoBaoConvertLinkException e) {
            e.printStackTrace();
@@ -2308,22 +2310,22 @@
            throw new GoodsEvaluateException(1, "线报已存在");
        List<String> imgs = new ArrayList<>();
        if (dto.getImageList() != null && dto.getImageList().size() > 0) {
            imgs.addAll(dto.getImageList());
        if (!StringUtil.isNullOrEmpty(dto.getPicUrls())) {
            imgs.addAll(Arrays.asList(dto.getPicUrls().split(",")));
        }
        GoodsDetailVO goods = null;
        //获取图片
        if (dto.getIdList() != null && dto.getIdList().size() > 0) {
        if (!StringUtil.isNullOrEmpty( dto.getItemIds())) {
            Set<String> imgSet = new HashSet<>();
            imgSet.addAll(imgs);
            String id = dto.getIdList().get(0);
            String source = dto.getPlatformType();
            String id = dto.getItemIds().split(",")[0];
            String source = dto.getPlatform();
            switch (source) {
                case "tb":
                case "淘宝":
                    try {
                        TaoBaoGoodsBrief goodsBrief = TaoKeApiUtil.searchGoodsDetail(Long.parseLong(id));
                        TaoBaoGoodsBrief goodsBrief = TaoKeApiUtil.searchGoodsDetail(id);
                        if (goodsBrief != null && goodsBrief.getImgList() != null) {
                            GoodsMoneyConfigParamsDTO params = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", system);
                            goods = GoodsDetailVOFactory.convertTaoBao(goodsBrief, params);
@@ -2340,7 +2342,7 @@
                        e.printStackTrace();
                    }
                    break;
                case "jd": {
                case "京东": {
                    JDGoods jdGoods = JDApiUtil.queryGoodsDetail(Long.parseLong(id));
                    if (jdGoods != null && jdGoods.getImageList() != null) {
                        GoodsMoneyConfigParamsDTO params = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", system);
@@ -2355,7 +2357,7 @@
                    }
                }
                break;
                case "pdd": {
                case "拼多多": {
                    PDDGoodsDetail goodsDetail = PinDuoDuoApiUtil.getGoodsDetail(Long.parseLong(id));
                    if (goodsDetail != null && goodsDetail.getGoodsGalleryUrls() != null) {
                        GoodsMoneyConfigParamsDTO params = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", system);
@@ -2705,7 +2707,7 @@
            }
            for (SystemEnum system : SystemEnum.values()) {
                List<GoodsEvaluate> queryExist = goodsEvaluateDao.queryExist(Constant.SOURCE_TYPE_TAOBAO,
                        goods.getAuctionId() + "", system);
                        goods.getAuctionId(), system);
                if (queryExist == null || queryExist.size() == 0) {
                    continue;
                }
@@ -2777,6 +2779,25 @@
    }
    @Override
    public void updateDYGoods(DYGoodsDetail goods) {
        if (goods == null) {
            return;
        }
        for (SystemEnum system : SystemEnum.values()) {
            List<GoodsEvaluate> queryExist = goodsEvaluateDao.queryExist(Constant.SOURCE_TYPE_DY,
                    goods.getProduct_id()+"", system);
            if (queryExist == null || queryExist.size() == 0) {
                continue;
            }
            GoodsMoneyConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", system);
            paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(system));
            GoodsDetailVO goodsNew = GoodsDetailVOFactory.convertDYGoods(goods, paramsDTO);
            updateGoods(queryExist, goodsNew);
        }
    }
    @Override
    public void updateSuningGoods(SuningGoodsInfo goods) {
        if (goods == null) {
            return;