From 4fe5f879c1b2919099a6e193ab4db8d25725ca40 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 26 二月 2019 10:16:20 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 fanli/src/main/java/com/yeshi/fanli/controller/client/UserMsgController.java |   49 +++++++++++++++++++++++++++++++++++++------------
 1 files changed, 37 insertions(+), 12 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/UserMsgController.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/UserMsgController.java
index b449b32..363f51c 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/client/UserMsgController.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/UserMsgController.java
@@ -54,6 +54,7 @@
 import com.yeshi.fanli.service.inter.user.UserCustomSettingsService;
 import com.yeshi.fanli.service.inter.user.UserInfoService;
 import com.yeshi.fanli.util.Constant;
+import com.yeshi.fanli.util.RedisManager;
 import com.yeshi.fanli.util.StringUtil;
 import com.yeshi.fanli.util.TimeUtil;
 import com.yeshi.fanli.util.factory.CommonGoodsFactory;
@@ -102,6 +103,9 @@
 
 	@Resource
 	private UserCustomSettingsService userCustomSettingsService;
+
+	@Resource
+	private RedisManager redisManager;
 
 	// 娑堟伅鐨勭被鍨�
 	final static String MSG_TYPE_ORDER = "order";
@@ -163,8 +167,13 @@
 			List<MsgInviteDetail> detailList3 = msgInviteDetailService.listMsgInviteDetail(uid, page);
 			count = msgInviteDetailService.countMsgInviteDetail(uid);
 			if (detailList3 != null)
-				for (MsgInviteDetail detail : detailList3)
-					list.add(UserMsgVOFactory.create(detail));
+				for (MsgInviteDetail detail : detailList3) {
+					UserMsgVO vo = UserMsgVOFactory.create(detail);
+					if (vo != null)
+						list.add(vo);
+					else
+						count--;
+				}
 			break;
 		}
 
@@ -351,8 +360,9 @@
 				}
 			}
 
-			if (canAdd && session.getAttribute("recommendgoods") == null) {
-				session.setAttribute("recommendgoods", 1);
+			String key = "recommend-goods-user-" + uid;
+			if (canAdd && StringUtil.isNullOrEmpty(redisManager.getCommonString(key))) {
+				redisManager.cacheCommonString(key, "1", 20);
 				if (hour < 12)
 					addRecommendGoods(uid);
 				else
@@ -363,7 +373,7 @@
 
 		List<UserHomeMsgVO> volist = new ArrayList<>();
 		List<RecommendUserGoods> list = recommendUserGoodsService.listRecommend(uid, page, Constant.PAGE_SIZE);
-		long count = recommendUserGoodsService.countRecommend(uid) + 1;// 璁$畻娆㈣繋璇殑鏁伴噺
+		long count = recommendUserGoodsService.countRecommend(uid);//
 
 		Date now = new Date();
 		for (RecommendUserGoods goods : list) {
@@ -406,14 +416,21 @@
 			volist.add(vo);
 		}
 
+		Long time = userInfoService.selectByPKey(uid).getCreatetime();
+		if (time > TimeUtil.convertToTimeTemp("2019-01-28", "yyyy-MM-dd"))
+			count++;// 璁$畻娆㈣繋璇殑鏁伴噺
+
 		if (volist.size() > 0 && volist.size() < Constant.PAGE_SIZE) {
 			// 娣诲姞娆㈣繋璇�
-			UserHomeMsgVO vo = new UserHomeMsgVO();
-			vo.setContent("鎭枩浣狅紝鎴愪负杩斿埄鍒哥殑鐢ㄦ埛\n鐙浼樻儬鍒稿府浣犵渷閽憋紱\n鍙備笌濂栭噾娲诲姩甯綘璧氶挶锛沑n璁╄繑鍒╁埜鎴愪负浣犵殑鐪侀挶鍔╂墜鍚э紒");
-			vo.setTitle("鏂颁汉娆㈣繋");
-			vo.setCreateTime(getTimeDesc(now, new Date(userInfoService.getUserById(uid).getCreatetime())));
-			vo.setType(UserHomeMsgVO.TYPE_WELCOME);
-			volist.add(vo);
+			// 鍒涘缓鏃堕棿鍦�28鍙峰悗鐨勬墠鏈夋柊浜烘杩�
+			if (time > TimeUtil.convertToTimeTemp("2019-01-28", "yyyy-MM-dd")) {
+				UserHomeMsgVO vo = new UserHomeMsgVO();
+				vo.setContent("鎭枩浣狅紝鎴愪负杩斿埄鍒哥殑鐢ㄦ埛\n鐙浼樻儬鍒稿府浣犵渷閽憋紱\n鍙備笌濂栭噾娲诲姩甯綘璧氶挶锛沑n璁╄繑鍒╁埜鎴愪负浣犵殑鐪侀挶鍔╂墜鍚э紒");
+				vo.setTitle("鏂颁汉娆㈣繋");
+				vo.setCreateTime(getTimeDesc(now, new Date(time)));
+				vo.setType(UserHomeMsgVO.TYPE_WELCOME);
+				volist.add(vo);
+			}
 		}
 
 		JSONObject root = new JSONObject();
@@ -500,7 +517,15 @@
 			out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛鏈櫥褰�"));
 			return;
 		}
-		userMsgReadStateService.setAllMsgRead(uid);
+
+		UserMsgUnReadNum num = userMsgReadStateService.getReadStateByUid(uid);
+		int totalNum = num.getTypeAccount() + num.getTypeInvite() + num.getTypeMoney() + num.getTypeOrder()
+				+ num.getTypeScore() + num.getTypeSystem();
+		if (totalNum == 0) {
+			out.print(JsonUtil.loadFalseResult(1, "娌℃湁鏈娑堟伅"));
+			return;
+		} else
+			userMsgReadStateService.setAllMsgRead(uid);
 		out.print(JsonUtil.loadTrueResult(""));
 	}
 

--
Gitblit v1.8.0