From 2f2860b50f24e5e3598d223db03d43df61d95c97 Mon Sep 17 00:00:00 2001 From: yj <Administrator@192> Date: 星期五, 13 三月 2020 16:31:30 +0800 Subject: [PATCH] Merge branch 'div' of ssh://193.112.35.168:29418/fanli-server into div --- fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java | 243 +++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 205 insertions(+), 38 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 c252c6d..663d431 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 @@ -70,6 +70,7 @@ 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.pinduoduo.PinDuoDuoUtil; import com.yeshi.fanli.util.taobao.DaTaoKeUtil; import com.yeshi.fanli.util.taobao.TaoBaoUtil; import com.yeshi.fanli.util.taobao.TaoKeApiUtil; @@ -165,6 +166,7 @@ record.setId(id); record.setShareNumReal(0); record.setCreateTime(new Date()); + record.setUpdateTime(new Date()); goodsEvaluateDao.save(record); } else { GoodsEvaluate resultObj = goodsEvaluateDao.getById(id); @@ -178,6 +180,7 @@ resultObj.setStartTime(record.getStartTime()); resultObj.setEndTime(record.getEndTime()); resultObj.setTitle(tilte); + resultObj.setUpdateTime(new Date()); goodsEvaluateDao.save(resultObj); } return id; @@ -355,10 +358,8 @@ GoodsDetailVO goodsDetailVO = null; JDGoods jdGoods = null; PDDGoodsDetail pddGoods = null; - BigDecimal fanLiRate = hongBaoManageService.getFanLiRate(); - BigDecimal shareRate = hongBaoManageService.getShareRate(); - BigDecimal vipFanLiRate = hongBaoManageService.getVIPFanLiRate(); - ConfigParamsDTO params = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE, vipFanLiRate); + ConfigParamsDTO params = hongBaoManageService.getShowComputeRate("android", "55"); + params.setBaseFanliRate(hongBaoManageService.getBaseFanliRate()); if (goodsType == Constant.SOURCE_TYPE_TAOBAO) { try { TaoBaoGoodsBrief goodsBrief = redisManager.getTaoBaoGoodsBrief(goodsId); @@ -489,23 +490,29 @@ String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "", "1"); String template = configService.get(ConfigKeyEnum.quickShareJDCommentText.getKey()); + if (jumpLink == null) { + throw new GoodsEvaluateException(1, "璇ュ晢鍝佽浆閾惧け璐�"); + } commentText = template.replace("[閾炬帴]", jumpLink); } else if (goodsType == Constant.SOURCE_TYPE_PDD) { String jumpLink = PinDuoDuoApiUtil.getPromotionUrl(goodsId, PinDuoDuoApiUtil.PID_SHARE + "", "1"); + if (jumpLink == null) { + throw new GoodsEvaluateException(1, "璇ュ晢鍝佽浆閾惧け璐�"); + } String template = configService.get(ConfigKeyEnum.quickSharePDDCommentText.getKey()); commentText = template.replace("[閾炬帴]", jumpLink); } - commentText = commentText.replace("[鍘熶环]", MoneyBigDecimalUtil.getWithNoZera(goodsDetailVO.getZkPrice())+""); - if (!goodsDetailVO.isHasCoupon()) { - commentText = commentText.replace("棰嗗埜鎶㈣喘", "鎶㈣喘"); - commentText = commentText.replace("銆愬埜鍚庝环銆慬鍒稿悗浠穄鍏�", ""); - } else { - commentText = commentText.replace("[鍒稿悗浠穄", MoneyBigDecimalUtil.getWithNoZera(goodsDetailVO.getCouponPrice())+""); - } - - commentText = commentText.replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", - "\r\n"); +// commentText = commentText.replace("[鍘熶环]", MoneyBigDecimalUtil.getWithNoZera(goodsDetailVO.getZkPrice())+""); +// if (!goodsDetailVO.isHasCoupon()) { +// commentText = commentText.replace("棰嗗埜鎶㈣喘", "鎶㈣喘"); +// commentText = commentText.replace("銆愬埜鍚庝环銆慬鍒稿悗浠穄鍏�", ""); +// } else { +// commentText = commentText.replace("[鍒稿悗浠穄", MoneyBigDecimalUtil.getWithNoZera(goodsDetailVO.getCouponPrice())+""); +// } +// +// 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("-", "")); @@ -514,6 +521,7 @@ commentsNew.add(commentInfo); resultObj.setComments(commentsNew); } + resultObj.setUpdateTime(new Date()); goodsEvaluateDao.save(resultObj); // 鍒犻櫎鍥剧墖 @@ -567,10 +575,8 @@ public GoodsDetailVO getGoodsDetailVO(Long goodsId, Integer goodsType) throws GoodsEvaluateException { GoodsDetailVO goodsDetail = null; - BigDecimal fanLiRate = hongBaoManageService.getFanLiRate(); - BigDecimal shareRate = hongBaoManageService.getShareRate(); - BigDecimal vipFanLiRate = hongBaoManageService.getVIPFanLiRate(); - ConfigParamsDTO params = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE, vipFanLiRate); + ConfigParamsDTO params = hongBaoManageService.getShowComputeRate("android", "55"); + params.setBaseFanliRate(hongBaoManageService.getBaseFanliRate()); if (goodsType == Constant.SOURCE_TYPE_TAOBAO) { try { TaoBaoGoodsBrief goodsBrief = redisManager.getTaoBaoGoodsBrief(goodsId); @@ -848,6 +854,7 @@ } resultObj.setComments(comments); + resultObj.setUpdateTime(new Date()); goodsEvaluateDao.save(resultObj); } @@ -1468,6 +1475,45 @@ return goodsEvaluateDao.count(key, state, dynamicType); } + + @Override + public void addRanDomShareCount() { + // 鍙戝湀 + try { + List<GoodsEvaluate> list = goodsEvaluateDao.queryValid(0, Integer.MAX_VALUE, 1); + if (list != null) { + for (GoodsEvaluate goodsEvaluate: list) { + Integer shareNum = goodsEvaluate.getShareNum(); + if (shareNum == null) { + shareNum = 0; + } + goodsEvaluate.setShareNum(shareNum + (int) (Math.random() * 100) + 10); + goodsEvaluateDao.save(goodsEvaluate); + } + } + } catch (Exception e) { + LogHelper.errorDetailInfo(e); + } + + // 绱犳潗 + try { + List<GoodsEvaluate> list = goodsEvaluateDao.queryValid(0, Integer.MAX_VALUE, 2); + if (list != null) { + for (GoodsEvaluate goodsEvaluate: list) { + Integer shareNum = goodsEvaluate.getShareNum(); + if (shareNum == null) { + shareNum = 0; + } + goodsEvaluate.setShareNum(shareNum + (int) (Math.random() * 100) + 10); + goodsEvaluateDao.save(goodsEvaluate); + } + } + } catch (Exception e) { + LogHelper.errorDetailInfo(e); + } + } + + @Override @Cacheable(value = "dynamicCache", key = "'queryValidEvaluateCache-'+#start") public List<GoodsEvaluate> queryValidEvaluateCache(int start, int count) { @@ -1490,7 +1536,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) { @@ -1501,7 +1547,6 @@ List<GoodsEvaluate> listNew = new ArrayList<>(); for (GoodsEvaluate goodsEvaluate : list) { - GoodsEvaluate evaluateNew = new GoodsEvaluate(); try { PropertyUtils.copyProperties(evaluateNew, goodsEvaluate); @@ -1510,12 +1555,13 @@ continue; } - int comment = 0; List<CommentInfo> comments = evaluateNew.getComments(); if (comments != null && comments.size() > 0) { EvaluateEnum typeEnum = evaluateNew.getType(); List<CommentInfo> commentNew = new ArrayList<>(); + boolean singleCoupn = true; + boolean currencyCoupon = true; for (CommentInfo commentInfo : comments) { if (StringUtil.isNullOrEmpty(commentInfo.getContent()) && StringUtil.isNullOrEmpty(commentInfo.getCoupon())) { @@ -1530,7 +1576,25 @@ continue; } - comment++; + if (typeEnum != null && typeEnum == EvaluateEnum.single) { + GoodsDetailVO goods = evaluateNew.getGoods(); + if (goods != null) { + String content = commentInfoNew.getContent(); + if (!StringUtil.isNullOrEmpty(content)) { + content = content.replace("[鍘熶环]", MoneyBigDecimalUtil.getWithNoZera(goods.getZkPrice())+""); + if (goods.isHasCoupon()) { + content = content.replace("[鍒稿悗浠穄",MoneyBigDecimalUtil.getWithNoZera(goods.getCouponPrice())+""); + } else { + singleCoupn = false; + content = content.replace("棰嗗埜鎶㈣喘", "鎶㈣喘"); + content = content.replace("銆愬埜鍚庝环銆慬鍒稿悗浠穄鍏�", ""); + } + content = content.replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n"); + commentInfoNew.setContent(content); + } + } + } + CommentInfoEnum typeComment = commentInfoNew.getTypeEnum(); if (typeComment != null && typeComment == CommentInfoEnum.goodsCoupon) { GoodsDetailVO goods = evaluateNew.getGoods(); @@ -1560,7 +1624,13 @@ commentInfoNew.setTagList(tagListNew); commentNew.add(commentInfoNew); continue; + } else { + currencyCoupon = false; + continue; } + } else { + currencyCoupon = false; + continue; } } @@ -1569,11 +1639,11 @@ evaluateNew.setComments(commentNew); if (typeEnum != null && typeEnum == EvaluateEnum.single) { - if (comment > 0 && commentNew.size() == 0) { // 鎵�鏈夊埜璇勮涓嬫灦 + if (!currencyCoupon && !singleCoupn) { // 鎵�鏈夊埜璇勮涓嬫灦 GoodsDetailVO goods = evaluateNew.getGoods(); if (goods != null) { goods.setState(1); // 璇勮涓嶅瓨鍦� 涓嬫灦 - LogHelper.test("鑾峰彇鍒楄〃鍟嗗搧涓嬫灦1"); + evaluateNew.setRemarks("璇勮楠岃瘉涓嬫灦"); } List<ImgInfo> imgList = evaluateNew.getImgList(); @@ -1582,7 +1652,7 @@ SimpleGoods simpleGoods = imgInfo.getGoods(); if (simpleGoods != null) { simpleGoods.setState(1); - LogHelper.test("鑾峰彇鍒楄〃鍟嗗搧涓嬫灦2"); + simpleGoods.setRemarks("璇勮楠岃瘉涓嬫灦"); } } @@ -1626,11 +1696,8 @@ try { Date now = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - BigDecimal fanLiRate = hongBaoManageService.getFanLiRate(); - BigDecimal shareRate = hongBaoManageService.getShareRate(); - BigDecimal vipFanLiRate = hongBaoManageService.getVIPFanLiRate(); - ConfigParamsDTO paramsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE, - vipFanLiRate); + ConfigParamsDTO params = hongBaoManageService.getShowComputeRate("android", "55"); + params.setBaseFanliRate(hongBaoManageService.getBaseFanliRate()); for (GoodsEvaluate goodsEvaluate : list) { // 鏄惁2涓皬鏃朵箣鍐呭凡鏇存柊 Date updateTime = goodsEvaluate.getUpdateTime(); @@ -1667,10 +1734,11 @@ GoodsDetailVO goods = goodsEvaluate.getGoods(); if (goods != null) { - GoodsDetailVO goodsNew = getGoodsNewInfo(goods.getGoodsId(), goods.getGoodsType(), paramsDTO); + GoodsDetailVO goodsNew = getGoodsNewInfo(goods.getGoodsId(), goods.getGoodsType(), params); if (goodsNew != null) { goodsEvaluate.setGoods(goodsNew); } else { + goodsEvaluate.setRemarks("鏇存柊-浣嶇疆鎵惧埌鍟嗗搧淇℃伅"); goodsEvaluate.setState(0); // 宸插晢鍝佷笅鏋� goods.setState(1); goodsEvaluate.setGoods(goods); @@ -1689,7 +1757,7 @@ } GoodsDetailVO goodsDetailVO = getGoodsNewInfo(simpleGoods.getGoodsId(), simpleGoods.getGoodsType(), - paramsDTO); + params); if (goodsDetailVO != null) { simpleGoods.setPrice(goodsDetailVO.getCouponPrice()); simpleGoods.setState(0); @@ -1703,6 +1771,7 @@ imgInfo.setGoods(simpleGoods); imgInfo.setGoodsVO(goodsDetailVO); } else { + simpleGoods.setRemarks("鏇存柊-浣嶇疆鎵惧埌鍟嗗搧淇℃伅"); simpleGoods.setState(1); imgInfo.setGoods(simpleGoods); GoodsDetailVO goodsVO = imgInfo.getGoodsVO(); @@ -1712,7 +1781,7 @@ } } } - + goodsEvaluate.setImgList(imgList); goodsEvaluate.setUpdateTime(new Date()); goodsEvaluateDao.save(goodsEvaluate); } @@ -1892,11 +1961,9 @@ return false; } - 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); + ConfigParamsDTO paramsDTO = hongBaoManageService.getShowComputeRate("android", "55"); + paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate()); + GoodsDetailVO goodsVO = GoodsDetailVOFactory.convertTaoBao(goodsBrief, paramsDTO); // 鍙戝竷鐢ㄦ埛 ActivityUser user = activityUserService.getRandomByDaTaoKeCid(daTaoKe.getCid()); @@ -2164,4 +2231,104 @@ } return true; } + + @Override + public void updateTaoBaoGoods(TaoBaoGoodsBrief goods) { + try { + if (goods == null) { + return; + } + List<GoodsEvaluate> queryExist = goodsEvaluateDao.queryExist(Constant.SOURCE_TYPE_TAOBAO, goods.getAuctionId()); + if (queryExist == null || queryExist.size() == 0) { + return; + } + + ConfigParamsDTO paramsDTO = hongBaoManageService.getShowComputeRate("android", "55"); + paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate()); + GoodsDetailVO goodsNew = GoodsDetailVOFactory.convertTaoBao(goods, paramsDTO); + updateGoods(queryExist, goodsNew); + + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Override + public void updateJDGoods(JDGoods jdGoods) { + if (jdGoods == null) { + return; + } + List<GoodsEvaluate> queryExist = goodsEvaluateDao.queryExist(Constant.SOURCE_TYPE_JD, jdGoods.getSkuId()); + if (queryExist == null || queryExist.size() == 0) { + return; + } + + ConfigParamsDTO paramsDTO = hongBaoManageService.getShowComputeRate("android", "55"); + paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate()); + GoodsDetailVO goodsNew = GoodsDetailVOFactory.convertJDGoods(jdGoods, paramsDTO); + + updateGoods(queryExist, goodsNew); + } + + @Override + public void updatePDDGoods(PDDGoodsDetail pddGoods) { + if (pddGoods == null) { + return; + } + List<GoodsEvaluate> queryExist = goodsEvaluateDao.queryExist(Constant.SOURCE_TYPE_PDD, pddGoods.getGoodsId()); + if (queryExist == null || queryExist.size() == 0) { + return; + } + + ConfigParamsDTO paramsDTO = hongBaoManageService.getShowComputeRate("android", "55"); + paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate()); + GoodsDetailVO goodsNew = GoodsDetailVOFactory.convertPDDGoods(pddGoods, paramsDTO); + updateGoods(queryExist, goodsNew); + } + + private void updateGoods(List<GoodsEvaluate> listExist, GoodsDetailVO goodsNew) { + long goodsId = goodsNew.getGoodsId(); + int goodsType = goodsNew.getGoodsType(); + for (GoodsEvaluate goodsEvaluate: listExist) { + GoodsDetailVO goodsDetailVO = goodsEvaluate.getGoods(); + if (goodsDetailVO != null && goodsDetailVO.getGoodsId() != null + && goodsDetailVO.getGoodsId() == goodsId && goodsDetailVO.getGoodsType() == goodsType) { + goodsEvaluate.setGoods(goodsNew); + } + + // 鏇存柊鍟嗗搧淇℃伅 + List<ImgInfo> imgList = goodsEvaluate.getImgList(); + if (imgList == null || imgList.size() == 0) { + continue; + } + + for (ImgInfo imgInfo : imgList) { + SimpleGoods simpleGoods = imgInfo.getGoods(); + if (simpleGoods == null || simpleGoods.getGoodsId() != goodsId + || goodsType != simpleGoods.getGoodsType()) { + continue; + } + + + simpleGoods.setState(0); + simpleGoods.setPrice(goodsNew.getCouponPrice()); + CouponInfoVO couponInfo = goodsNew.getCouponInfo(); + if (couponInfo == null) { + simpleGoods.setPrice(goodsNew.getZkPrice()); + } else { + simpleGoods.setPrice(goodsNew.getCouponPrice()); + simpleGoods.setAmount(couponInfo.getAmount()); + } + + imgInfo.setGoods(simpleGoods); + imgInfo.setGoodsVO(goodsNew); + } + + goodsEvaluate.setImgList(imgList); + goodsEvaluate.setUpdateTime(new Date()); + goodsEvaluateDao.save(goodsEvaluate); + } + } + + } -- Gitblit v1.8.0