From 0a222ebb8159439c0fe54222dc43fb74962a50e5 Mon Sep 17 00:00:00 2001 From: yj <Administrator@192> Date: 星期六, 07 三月 2020 20:41:33 +0800 Subject: [PATCH] 发圈 --- fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java | 159 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 156 insertions(+), 3 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 3b7c417..ea1b116 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 @@ -44,6 +44,7 @@ import com.yeshi.fanli.entity.system.ConfigKeyEnum; import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief; import com.yeshi.fanli.entity.taobao.TaoBaoLink; +import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetailV2; import com.yeshi.fanli.exception.dynamic.ActivityUserException; import com.yeshi.fanli.exception.dynamic.GoodsEvaluateException; import com.yeshi.fanli.exception.goods.ConvertLinkExceptionException; @@ -54,6 +55,7 @@ import com.yeshi.fanli.service.inter.dynamic.GoodsEvaluateService; import com.yeshi.fanli.service.inter.goods.ShareGoodsService; import com.yeshi.fanli.service.inter.order.config.HongBaoManageService; +import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailV2Service; import com.yeshi.fanli.service.manger.goods.ConvertLinkManager; import com.yeshi.fanli.util.Constant; import com.yeshi.fanli.util.FilePathEnum; @@ -66,7 +68,9 @@ import com.yeshi.fanli.util.jd.JDApiUtil; import com.yeshi.fanli.util.jd.JDUtil; import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil; +import com.yeshi.fanli.util.taobao.DaTaoKeUtil; import com.yeshi.fanli.util.taobao.TaoBaoUtil; +import com.yeshi.fanli.util.taobao.TaoKeApiUtil; import com.yeshi.fanli.vo.goods.CouponInfoVO; import com.yeshi.fanli.vo.goods.GoodsDetailVO; import com.yeshi.fanli.vo.msg.ClientTextStyleVO; @@ -103,6 +107,11 @@ @Resource private ConvertLinkManager convertLinkManager; + + @Resource + private DaTaoKeGoodsDetailV2Service daTaoKeGoodsDetailV2Service; + + @Override public String saveHead(MultipartFile file, GoodsEvaluate record) throws GoodsEvaluateException { @@ -110,6 +119,7 @@ if (state == null) { state = 0; } + record.setState(state); String tilte = record.getTitle(); if (StringUtil.isNullOrEmpty(tilte)) { @@ -161,6 +171,7 @@ if (resultObj == null) throw new GoodsEvaluateException(1, "淇敼鍐呭宸蹭笉瀛樺湪"); + resultObj.setState(record.getState()); resultObj.setUser(record.getUser()); resultObj.setShareNum(record.getShareNum()); resultObj.setWeight(record.getWeight()); @@ -427,6 +438,8 @@ if (totalImg > 0) { if (totalImg == 1) { lineNum = 1; + } else if (totalImg == 3) { + lineNum = 3; } else if (totalImg <= 4) { lineNum = 2; } else { @@ -752,6 +765,8 @@ if (totalImg > 0) { if (totalImg == 1) { lineNum = 1; + } else if (totalImg == 3) { + lineNum = 3; } else if (totalImg <= 4) { lineNum = 2; } else { @@ -1103,6 +1118,8 @@ if (totalImg > 0) { if (totalImg == 1) { lineNum = 1; + } else if (totalImg == 3) { + lineNum = 3; } else if (totalImg <= 4) { lineNum = 2; } else { @@ -1241,7 +1258,7 @@ ImgInfo imgInfo0 = new ImgInfo(); imgInfo0.setId(UUID.randomUUID().toString().replace("-", "")); - imgInfo0.setLarge(true); + imgInfo0.setLarge(false); imgInfo0.setPid(pid); imgInfo0.setUrl(picLink); imgInfo0.setUrlHD(picLink); @@ -1289,6 +1306,8 @@ if (totalImg > 0) { if (totalImg == 1) { lineNum = 1; + } else if (totalImg == 3) { + lineNum = 3; } else if (totalImg <= 4) { lineNum = 2; } else { @@ -1472,7 +1491,7 @@ } @Override - @Cacheable(value = "dynamicCache", key = "'queryMaterialsCache-'+#start+'-'+#type") +// @Cacheable(value = "dynamicCache", key = "'queryMaterialsCache-'+#start+'-'+#type") public List<GoodsEvaluate> queryMaterialsCache(int start, int count, int type) throws Exception { List<GoodsEvaluate> list = goodsEvaluateDao.queryValid(start, count, type); if (list == null) { @@ -1790,7 +1809,9 @@ } imgInfo.setGoods(simpleGoods); - TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(1L, goodsVO.getGoodsId(), null); + TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(1L, goodsVO.getGoodsId(), "0"); + +// TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(Constant.LINK_TOKEN_VERIFY_UID, goodsVO.getGoodsId(), null); String template = configService.get(ConfigKeyEnum.quickShareTBCommentText.getKey()); String commentText = template.replace("[娣樺彛浠", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken())); @@ -1826,4 +1847,136 @@ } } + + @Override + public void addGoodsEvaluateByDaTaoKe() { + try { + List<DaTaoKeDetailV2> list = daTaoKeGoodsDetailV2Service.getGoodsNotInList(1L, null, 1); + if (list == null || list.size() == 0) { + return; + } + + DaTaoKeDetailV2 daTaoKe = list.get(0); + TaoBaoGoodsBrief goodsBrief = redisManager.getTaoBaoGoodsBrief(daTaoKe.getGoodsId()); + if (goodsBrief == null) { + return; + } + + BigDecimal fanLiRate = hongBaoManageService.getFanLiRate(); + BigDecimal shareRate = hongBaoManageService.getShareRate(); + BigDecimal vipFanLiRate = hongBaoManageService.getVIPFanLiRate(); + ConfigParamsDTO params = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE, vipFanLiRate); + GoodsDetailVO goodsVO = GoodsDetailVOFactory.convertTaoBao(goodsBrief, params); + // 鍙戝竷鐢ㄦ埛 + ActivityUser user = activityUserService.getRandomByDaTaoKeCid(daTaoKe.getCid()); + + String desc = DaTaoKeUtil.getDesc(daTaoKe); + if (!StringUtil.isNullOrEmpty(desc)) { + int index = desc.lastIndexOf("\n"); + String newDesc = desc.substring(index + 1); + if (StringUtil.isNullOrEmpty(newDesc)) { + desc = desc.substring(0, index); + } + } + + GoodsEvaluate goodsEvaluate = new GoodsEvaluate(); + goodsEvaluate.setId(UUID.randomUUID().toString().replace("-", "")); + goodsEvaluate.setUser(user); + goodsEvaluate.setTitle(desc); + goodsEvaluate.setState(1); + goodsEvaluate.setDynamicType(1); + goodsEvaluate.setType(EvaluateEnum.single); + + goodsEvaluate.setShareNum((int) (Math.random() * 5000) + 1000); + goodsEvaluate.setShareNumReal(0); + goodsEvaluate.setWeight(0.0); + goodsEvaluate.setStartTime(new Date()); + goodsEvaluate.setEndTime(DateUtil.plusDayDate(3, new Date())); + goodsEvaluate.setPublishTime(new Date()); + goodsEvaluate.setCreateTime(new Date()); + goodsEvaluate.setUpdateTime(new Date()); + + + List<ImgInfo> imgList = new ArrayList<>(); + + int lineNum = 0; + if (imgList.size() > 0) { + if (imgList.size() == 1) { + lineNum = 1; + } else if (imgList.size() == 3) { + lineNum = 3; + } else if (imgList.size() <= 4) { + lineNum = 2; + } else { + lineNum = 3; + } + } + goodsEvaluate.setLineNum(lineNum); + + int i = 0; + List<String> imgs = goodsBrief.getImgList(); + for (String img : imgs) { + ImgInfo imgInfo = new ImgInfo(); + imgInfo.setH(1); + imgInfo.setW(1); + imgInfo.setLarge(false); + imgInfo.setUrl(img); + imgInfo.setUrlHD(img); + if (i != 0) { + imgInfo.setType(ImgEnum.img); + } else { + imgInfo.setType(ImgEnum.goods); + SimpleGoods simpleGoods = new SimpleGoods(); + simpleGoods.setGoodsId(goodsVO.getGoodsId()); + simpleGoods.setGoodsType(goodsVO.getGoodsType()); + simpleGoods.setState(goodsVO.getState()); + CouponInfoVO couponInfo = goodsVO.getCouponInfo(); + if (couponInfo == null) { + simpleGoods.setPrice(goodsVO.getZkPrice()); + } else { + simpleGoods.setPrice(goodsVO.getCouponPrice()); + simpleGoods.setAmount(couponInfo.getAmount()); + } + imgInfo.setGoods(simpleGoods); + + //TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(Constant.LINK_TOKEN_VERIFY_UID, goodsVO.getGoodsId(), null); + + String token = shareGoodsService.createTaoBaoToken(Constant.LINK_TOKEN_VERIFY_UID, goodsBrief); + + String template = configService.get(ConfigKeyEnum.quickShareTBCommentText.getKey()); + String commentText = template.replace("[娣樺彛浠", TaoBaoUtil.filterTaoToken(token)); + + commentText = commentText.replace("[鍘熶环]", goodsVO.getZkPrice().toString()); + if (!goodsVO.isHasCoupon()) { + commentText = commentText.replace("棰嗗埜鎶㈣喘", "鎶㈣喘"); + commentText = commentText.replace("銆愬埜鍚庝环銆慬鍒稿悗浠穄鍏�", ""); + } else { + commentText = commentText.replace("[鍒稿悗浠穄", goodsVO.getCouponPrice().toString()); + } + commentText = commentText.replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n") + .replace("\r\n\r\n", "\r\n"); + + CommentInfo commentInfo = new CommentInfo(); + commentInfo.setId(UUID.randomUUID().toString().replace("-", "")); + commentInfo.setContent(commentText); + commentInfo.setTypeEnum(CommentInfoEnum.goodsCoupon); + commentInfo.setType(CommentInfoEnum.goodsCoupon.getDesc()); + + List<CommentInfo> commentsNew = new ArrayList<>(); + commentsNew.add(commentInfo); + goodsEvaluate.setComments(commentsNew); + + goodsEvaluate.setGoods(goodsVO); + } + + imgList.add(imgInfo); + i ++; + } + goodsEvaluate.setImgList(imgList); + goodsEvaluateDao.save(goodsEvaluate); + } catch (Exception e) { + e.printStackTrace(); + LogHelper.errorDetailInfo(e); + } + } } -- Gitblit v1.8.0