From ca53b2a58a60695d56dd2d523aa3658b8482b6de Mon Sep 17 00:00:00 2001
From: yj <Administrator@192>
Date: 星期五, 06 三月 2020 16:20:05 +0800
Subject: [PATCH] 发圈

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java |   65 ++++++++++++++++++++++++++------
 1 files changed, 53 insertions(+), 12 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..4037ccc 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,8 +1472,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) {
@@ -1471,18 +1499,31 @@
 				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()) {
@@ -1492,11 +1533,11 @@
 								styleVO.setColor("#E5005C");
 								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