From c6037befc88e7e92e93fb928ce20078b6fe293d8 Mon Sep 17 00:00:00 2001 From: yj <Administrator@192> Date: 星期六, 07 三月 2020 12:02:24 +0800 Subject: [PATCH] 发圈倒计时 --- fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java | 73 ++++++++++++++++++++++++++++-------- 1 files changed, 57 insertions(+), 16 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 f566dfb..3b7c417 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 @@ -1072,6 +1072,7 @@ listImg.add(imgVideo); } + int totalImg = 0; if (!StringUtil.isNullOrEmpty(activityPic) || !StringUtil.isNullOrEmpty(imgInfo.getActivityUrl())) { if (imgactivity != null) { imgactivity.setUrl(activityPic); @@ -1095,8 +1096,21 @@ imgactivity.setH(imgactivity.getH()); } listImg.add(imgactivity); + totalImg ++; } - resultObj.setLineNum(1); + + int lineNum = 0; + if (totalImg > 0) { + if (totalImg == 1) { + lineNum = 1; + } else if (totalImg <= 4) { + lineNum = 2; + } else { + lineNum = 3; + } + } + + resultObj.setLineNum(lineNum); resultObj.setImgList(listImg); goodsEvaluateDao.save(resultObj); } @@ -1213,6 +1227,7 @@ listImg.add(imgActivity); } + int totalImg = 0; // 缂栬緫鍥剧墖 if (!StringUtil.isNullOrEmpty(picUrls)) { String[] pics = picUrls.split(","); @@ -1234,6 +1249,7 @@ imgInfo0.setW(1); imgInfo0.setH(1); listImg.add(imgInfo0); + totalImg ++; continue; } } @@ -1244,6 +1260,7 @@ String url = imgInfo.getUrl(); if (picLink.equals(url)) { listImg.add(imgInfo); + totalImg ++; break; } } @@ -1267,7 +1284,19 @@ listDel.add(listOld.get(j)); } } - resultObj.setLineNum(1); + + int lineNum = 0; + if (totalImg > 0) { + if (totalImg == 1) { + lineNum = 1; + } else if (totalImg <= 4) { + lineNum = 2; + } else { + lineNum = 3; + } + } + + resultObj.setLineNum(lineNum); resultObj.setImgList(listImg); goodsEvaluateDao.save(resultObj); @@ -1443,15 +1472,14 @@ } @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) { list = new ArrayList<>(); } Date now = new Date(); - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); List<GoodsEvaluate> listNew = new ArrayList<>(); for (GoodsEvaluate goodsEvaluate : list) { @@ -1471,32 +1499,45 @@ List<CommentInfo> commentNew = new ArrayList<>(); for (CommentInfo commentInfo : comments) { + if (StringUtil.isNullOrEmpty(commentInfo.getContent()) && + StringUtil.isNullOrEmpty(commentInfo.getCoupon())) { + continue; + } + + CommentInfo commentInfoNew = new CommentInfo(); + try { + PropertyUtils.copyProperties(commentInfoNew, commentInfo); + } catch (Exception e) { + e.printStackTrace(); + continue; + } + comment++; - CommentInfoEnum typeComment = commentInfo.getTypeEnum(); + CommentInfoEnum typeComment = commentInfoNew.getTypeEnum(); if (typeComment != null && typeComment == CommentInfoEnum.goodsCoupon) { GoodsDetailVO goods = evaluateNew.getGoods(); - if (goods.isHasCoupon()) { - commentNew.add(commentInfo); + if (goods != null && goods.isHasCoupon()) { + commentNew.add(commentInfoNew); continue; } } - String coupon = commentInfo.getCoupon(); - String endTime = commentInfo.getEndTime(); + String coupon = commentInfoNew.getCoupon(); + String endTime = commentInfoNew.getEndTime(); if (!StringUtil.isNullOrEmpty(coupon) && !StringUtil.isNullOrEmpty(endTime)) { Date endDay = sdf.parse(endTime); if (endDay.getTime() > now.getTime()) { - int daysBetween = DateUtil.daysBetween(now, endDay); - if (daysBetween > 0) { + String daysBetween = DateUtil.dateDiff5(now, endDay); + if (!StringUtil.isNullOrEmpty(daysBetween)) { ClientTextStyleVO styleVO = new ClientTextStyleVO(); styleVO.setColor("#E5005C"); - styleVO.setContent(daysBetween + "澶╁悗杩囨湡"); + styleVO.setContent(daysBetween + "鍚庤繃鏈�"); - List<ClientTextStyleVO> tagList = commentInfo.getTagList(); + List<ClientTextStyleVO> tagList = commentInfoNew.getTagList(); tagList.add(styleVO); - commentInfo.setTagList(tagList); + commentInfoNew.setTagList(tagList); - commentNew.add(commentInfo); + commentNew.add(commentInfoNew); continue; } } -- Gitblit v1.8.0