From 81da61b828e29b7745e1382dfbbaeb685dc083ef Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 23 一月 2024 17:17:55 +0800 Subject: [PATCH] 抖音转链修改 --- fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java | 71 +++++++++++++++++++++++------------ 1 files changed, 46 insertions(+), 25 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java index 5d34421..843f4a7 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java +++ b/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 @@ // 鐢熸垚鍙d护 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; -- Gitblit v1.8.0