From d6ce66cdef982dfe6f1af7d6d69aa1154b4fa454 Mon Sep 17 00:00:00 2001
From: hexiaohui <hexiaohui@LAPTOP-03V48RSB>
Date: 星期一, 28 一月 2019 22:19:08 +0800
Subject: [PATCH] 订单BUG修改

---
 fanli/src/main/java/com/yeshi/fanli/controller/client/UserMsgController.java |   71 +++++++++++++++++++++++++++--------
 1 files changed, 55 insertions(+), 16 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 69a5013..ff7fb65 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
@@ -11,6 +11,7 @@
 import java.util.Set;
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpSession;
 
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -40,6 +41,7 @@
 import com.yeshi.fanli.exception.goods.CommonGoodsException;
 import com.yeshi.fanli.exception.goods.RecommendUserGoodsException;
 import com.yeshi.fanli.exception.msg.UserSystemMsgException;
+import com.yeshi.fanli.exception.user.UserCustomSettingsException;
 import com.yeshi.fanli.service.inter.goods.CommonGoodsService;
 import com.yeshi.fanli.service.inter.goods.RecommendUserGoodsService;
 import com.yeshi.fanli.service.inter.lable.QualityFactoryService;
@@ -49,6 +51,7 @@
 import com.yeshi.fanli.service.inter.msg.MsgOrderDetailService;
 import com.yeshi.fanli.service.inter.msg.UserMsgReadStateService;
 import com.yeshi.fanli.service.inter.msg.UserSystemMsgService;
+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.StringUtil;
@@ -59,6 +62,7 @@
 import com.yeshi.fanli.vo.msg.UserHomeMsgVO;
 import com.yeshi.fanli.vo.msg.UserMsgVO;
 import com.yeshi.fanli.vo.msg.UserSystemMsgVO;
+import com.yeshi.fanli.vo.user.UserSettingsVO;
 
 import net.sf.json.JSONObject;
 
@@ -95,6 +99,9 @@
 
 	@Resource
 	private QualityFactoryService qualityFactoryService;
+
+	@Resource
+	private UserCustomSettingsService userCustomSettingsService;
 
 	// 娑堟伅鐨勭被鍨�
 	final static String MSG_TYPE_ORDER = "order";
@@ -186,6 +193,16 @@
 		JSONObject data = JSONObject.fromObject(JsonUtil.getApiCommonGson().toJson(num));
 		data.put("totalCount", num.getTypeAccount() + num.getTypeInvite() + num.getTypeMoney() + num.getTypeOrder()
 				+ num.getTypeScore() + num.getTypeSystem());
+
+		try {
+			UserSettingsVO vo = userCustomSettingsService.getMySettings(uid);
+			if (vo != null && vo.getNoNewsRedDot() != null && vo.getNoNewsRedDot() == 1) {
+				data.put("totalCount", 0);
+			}
+		} catch (UserCustomSettingsException e) {
+			e.printStackTrace();
+		}
+
 		out.print(JsonUtil.loadTrueResult(data));
 	}
 
@@ -315,7 +332,7 @@
 	 * @param out
 	 */
 	@RequestMapping(value = "getHomeMsgList", method = RequestMethod.POST)
-	public void getHomeMsgList(AcceptData acceptData, Long uid, int page, PrintWriter out) {
+	public void getHomeMsgList(AcceptData acceptData, Long uid, int page, HttpSession session, PrintWriter out) {
 		if (uid == null) {
 			out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛鏈櫥褰�"));
 			return;
@@ -329,22 +346,24 @@
 				canAdd = true;
 			} else {
 				// 鏄惁鍜屼笂娆¢棿闅旀椂闂磋冻澶�
-				if (System.currentTimeMillis() - goods.getCreateTime().getTime() >= 1000 * 60 * 60 * 8L) {
+				if (System.currentTimeMillis() - goods.getCreateTime().getTime() >= 1000 * 60 * 60 * 4L) {
 					canAdd = true;
 				}
 			}
 
-			if (canAdd) {
+			if (canAdd && session.getAttribute("recommendgoods") == null) {
+				session.setAttribute("recommendgoods", 1);
 				if (hour < 12)
 					addRecommendGoods(uid);
 				else
 					addRecommendGoods(uid, acceptData.getImei(), acceptData.getIdfa());
+				session.removeAttribute("recommendgoods");
 			}
 		}
 
 		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) {
@@ -360,11 +379,17 @@
 			List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
 			for (CommonGoods cg : goods.getGoodsList()) {
 				if (goods.getGoodsList().size() == 1)
-					cg.setPicture(TbImgUtil.getTBSizeImg(cg.getPicture(), 400));
+					cg.setPicture(TbImgUtil.getTBSizeImg(
+							StringUtil.isNullOrEmpty(cg.getPictureWhite()) ? cg.getPicture() : cg.getPictureWhite(),
+							400));
 				else if (goods.getGoodsList().size() == 2)
-					cg.setPicture(TbImgUtil.getTBSizeImg(cg.getPicture(), 320));
+					cg.setPicture(TbImgUtil.getTBSizeImg(
+							StringUtil.isNullOrEmpty(cg.getPictureWhite()) ? cg.getPicture() : cg.getPictureWhite(),
+							320));
 				else if (goods.getGoodsList().size() == 3)
-					cg.setPicture(TbImgUtil.getTBSizeImg(cg.getPicture(), 220));
+					cg.setPicture(TbImgUtil.getTBSizeImg(
+							StringUtil.isNullOrEmpty(cg.getPictureWhite()) ? cg.getPicture() : cg.getPictureWhite(),
+							220));
 				TaoBaoGoodsBrief tbGoods = new TaoBaoGoodsBrief();
 				if (cg.getCouponAmount() == null)
 					tbGoods.setCouponAmount(new BigDecimal(0));
@@ -381,14 +406,21 @@
 			volist.add(vo);
 		}
 
+		Long time = userInfoService.getUserById(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();
@@ -398,8 +430,7 @@
 			UserSystemMsg usm = userSystemMsgService.getLatestUserSystemMsg(uid);
 			if (usm != null)
 				root.put("systemMsg",
-						new UserSystemMsgVO(usm.getId(), usm.getType().name(), usm.getSolved(), usm.getTitle(),
-								usm.getContent(),
+						new UserSystemMsgVO(usm.getId(), usm.getType().name(), usm.getSolved(), "绯荤粺娑堟伅", usm.getTitle(),
 								usm.getTimeTag() == 1 ? "http://img.flqapp.com/resource/msg/icon_emergent.png" : "",
 								"http://img.flqapp.com/resource/msg/icon_msg_system.png",
 								getTimeDesc(now, usm.getCreateTime()), num.getTypeSystem()));
@@ -476,7 +507,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