yj
2020-03-13 2f2860b50f24e5e3598d223db03d43df61d95c97
fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java
@@ -166,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);
@@ -179,6 +180,7 @@
         resultObj.setStartTime(record.getStartTime());
         resultObj.setEndTime(record.getEndTime());
         resultObj.setTitle(tilte);
         resultObj.setUpdateTime(new Date());
         goodsEvaluateDao.save(resultObj);
      }
      return id;
@@ -488,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("-", ""));
@@ -513,6 +521,7 @@
         commentsNew.add(commentInfo);
         resultObj.setComments(commentsNew);
      }
      resultObj.setUpdateTime(new Date());
      goodsEvaluateDao.save(resultObj);
      // 删除图片
@@ -845,6 +854,7 @@
      }
      resultObj.setComments(comments);
      resultObj.setUpdateTime(new Date());
      goodsEvaluateDao.save(resultObj);
   }
@@ -1465,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) {
@@ -1487,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) {
@@ -1498,7 +1547,6 @@
      List<GoodsEvaluate> listNew = new ArrayList<>();
      for (GoodsEvaluate goodsEvaluate : list) {
         GoodsEvaluate evaluateNew = new GoodsEvaluate();
         try {
            PropertyUtils.copyProperties(evaluateNew, goodsEvaluate);
@@ -1507,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())) {
@@ -1527,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();
@@ -1558,9 +1625,11 @@
                        commentNew.add(commentInfoNew);
                        continue;
                     } else {
                        currencyCoupon = false;
                        continue;
                     }
                  } else {
                     currencyCoupon = false;
                     continue;
                  }
               }
@@ -1570,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();
@@ -1583,7 +1652,7 @@
                        SimpleGoods simpleGoods = imgInfo.getGoods();
                        if (simpleGoods != null) {
                           simpleGoods.setState(1);
                           LogHelper.test("获取列表商品下架2");
                           simpleGoods.setRemarks("评论验证下架");
                        }
                     }
@@ -1669,6 +1738,7 @@
               if (goodsNew != null) {
                  goodsEvaluate.setGoods(goodsNew);
               } else {
                  goodsEvaluate.setRemarks("更新-位置找到商品信息");
                  goodsEvaluate.setState(0); // 已商品下架
                  goods.setState(1);
                  goodsEvaluate.setGoods(goods);
@@ -1701,6 +1771,7 @@
                  imgInfo.setGoods(simpleGoods);
                  imgInfo.setGoodsVO(goodsDetailVO);
               } else {
                  simpleGoods.setRemarks("更新-位置找到商品信息");
                  simpleGoods.setState(1);
                  imgInfo.setGoods(simpleGoods);
                  GoodsDetailVO goodsVO = imgInfo.getGoodsVO();
@@ -2195,6 +2266,7 @@
      ConfigParamsDTO paramsDTO = hongBaoManageService.getShowComputeRate("android", "55");
      paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
      GoodsDetailVO goodsNew = GoodsDetailVOFactory.convertJDGoods(jdGoods, paramsDTO);
      updateGoods(queryExist, goodsNew);
   }
   
@@ -2220,7 +2292,7 @@
      for (GoodsEvaluate goodsEvaluate: listExist) {
         GoodsDetailVO goodsDetailVO = goodsEvaluate.getGoods();
         if (goodsDetailVO != null && goodsDetailVO.getGoodsId() != null 
            && goodsDetailVO.getGoodsId() == goodsId && goodsDetailVO.getGoodsType() == goodsType ) {
            && goodsDetailVO.getGoodsId() == goodsId && goodsDetailVO.getGoodsType() == goodsType) {
            goodsEvaluate.setGoods(goodsNew);
         }
         
@@ -2232,21 +2304,24 @@
         for (ImgInfo imgInfo : imgList) {
            SimpleGoods simpleGoods = imgInfo.getGoods();
            if (simpleGoods == null) {
            if (simpleGoods == null || simpleGoods.getGoodsId() != goodsId
                  || goodsType != simpleGoods.getGoodsType()) {
               continue;
            }
            simpleGoods.setState(0);
            simpleGoods.setPrice(goodsDetailVO.getCouponPrice());
            CouponInfoVO couponInfo = goodsDetailVO.getCouponInfo();
            simpleGoods.setPrice(goodsNew.getCouponPrice());
            CouponInfoVO couponInfo = goodsNew.getCouponInfo();
            if (couponInfo == null) {
               simpleGoods.setPrice(goodsDetailVO.getZkPrice());
               simpleGoods.setPrice(goodsNew.getZkPrice());
            } else {
               simpleGoods.setPrice(goodsDetailVO.getCouponPrice());
               simpleGoods.setPrice(goodsNew.getCouponPrice());
               simpleGoods.setAmount(couponInfo.getAmount());
            }
            imgInfo.setGoods(simpleGoods);
            imgInfo.setGoodsVO(goodsDetailVO);
            imgInfo.setGoodsVO(goodsNew);
         }
         
         goodsEvaluate.setImgList(imgList);