From 1ae3dc5a7eca13744f0a9e6e9c93bebfdfa41a55 Mon Sep 17 00:00:00 2001
From: yj <Administrator@192>
Date: 星期四, 12 三月 2020 11:12:09 +0800
Subject: [PATCH] 加入缓存 商品更新问题

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java |  102 ++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 88 insertions(+), 14 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 2ca96d5..5e2f0ca 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
@@ -495,16 +495,16 @@
 				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("-", ""));
@@ -1465,6 +1465,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 +1526,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) {
@@ -1527,6 +1566,25 @@
 						continue;
 					}
 
+					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 {
+									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);
+							}
+						}
+					}
+					
+					
 					comment++;
 					CommentInfoEnum typeComment = commentInfoNew.getTypeEnum();
 					if (typeComment != null && typeComment == CommentInfoEnum.goodsCoupon) {
@@ -2195,6 +2253,7 @@
 		ConfigParamsDTO paramsDTO = hongBaoManageService.getShowComputeRate("android", "55");
 		paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
 		GoodsDetailVO goodsNew = GoodsDetailVOFactory.convertJDGoods(jdGoods, paramsDTO);
+		
 		updateGoods(queryExist, goodsNew);
 	}
 	
@@ -2221,7 +2280,12 @@
 			GoodsDetailVO goodsDetailVO = goodsEvaluate.getGoods();
 			if (goodsDetailVO != null && goodsDetailVO.getGoodsId() != null 
 				&& goodsDetailVO.getGoodsId() == goodsId && goodsDetailVO.getGoodsType() == goodsType ) {
-				goodsEvaluate.setGoods(goodsNew);
+				if (goodsDetailVO.getTitle().equalsIgnoreCase(goodsNew.getTitle())) {
+					goodsEvaluate.setGoods(goodsNew);
+				} else {
+					goodsEvaluate.setState(1);
+					goodsEvaluate.setRemarks("鍟嗗搧鏍囬鍙戠敓鍙樺寲涓嬫灦锛�" + goodsDetailVO.getTitle() +" / 鏂帮細" + goodsNew.getTitle());
+				}
 			}
 			
 			// 鏇存柊鍟嗗搧淇℃伅
@@ -2232,11 +2296,21 @@
 
 			for (ImgInfo imgInfo : imgList) {
 				SimpleGoods simpleGoods = imgInfo.getGoods();
-				if (simpleGoods == null) {
+				if (simpleGoods == null || simpleGoods.getGoodsId() != goodsId  
+						|| goodsType != simpleGoods.getGoodsType()) {
 					continue;
 				}
 
-				simpleGoods.setState(0);
+				GoodsDetailVO goodsVO = imgInfo.getGoodsVO();
+				if (goodsVO != null) {
+					if (goodsVO.getTitle().equalsIgnoreCase(goodsNew.getTitle())) {
+						simpleGoods.setState(0);
+					} else {
+						simpleGoods.setState(1);
+						simpleGoods.setRemarks("鍟嗗搧鏍囬鍙戠敓鍙樺寲涓嬫灦锛�" + goodsVO.getTitle() +" / 鏂帮細" + goodsNew.getTitle());
+					}
+				}
+				
 				simpleGoods.setPrice(goodsDetailVO.getCouponPrice());
 				CouponInfoVO couponInfo = goodsDetailVO.getCouponInfo();
 				if (couponInfo == null) {

--
Gitblit v1.8.0