From 98b1a0affd69bbe63223c21fdd2c404e8bedfccb Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期三, 20 五月 2020 17:25:08 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/div' into 2.1.2

---
 fanli/src/main/java/com/yeshi/fanli/controller/client/v1/UserMsgController.java |  259 +++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 225 insertions(+), 34 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/UserMsgController.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/UserMsgController.java
index 20423fc..3089d9f 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/UserMsgController.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/UserMsgController.java
@@ -39,9 +39,11 @@
 import com.yeshi.fanli.entity.bus.msg.MsgInviteDetail;
 import com.yeshi.fanli.entity.bus.msg.MsgMoneyDetail;
 import com.yeshi.fanli.entity.bus.msg.MsgOrderDetail;
+import com.yeshi.fanli.entity.bus.msg.MsgOrderDetail.MsgTypeOrderTypeEnum;
 import com.yeshi.fanli.entity.bus.msg.MsgOtherDetail;
 import com.yeshi.fanli.entity.bus.msg.UserMsgUnReadNum;
 import com.yeshi.fanli.entity.bus.msg.UserSystemMsg;
+import com.yeshi.fanli.entity.bus.user.UserInfoExtra;
 import com.yeshi.fanli.entity.common.JumpDetailV2;
 import com.yeshi.fanli.entity.goods.CommonGoods;
 import com.yeshi.fanli.entity.goods.RecommendUserGoods;
@@ -59,23 +61,28 @@
 import com.yeshi.fanli.service.inter.goods.RecommendUserGoodsService;
 import com.yeshi.fanli.service.inter.homemodule.SpecialService;
 import com.yeshi.fanli.service.inter.lable.QualityFactoryService;
-import com.yeshi.fanli.service.inter.msg.MsgAccountDetailService;
+import com.yeshi.fanli.service.inter.money.msg.MsgMoneyDetailService;
 import com.yeshi.fanli.service.inter.msg.MsgConfigService;
 import com.yeshi.fanli.service.inter.msg.MsgDeviceReadStateService;
-import com.yeshi.fanli.service.inter.msg.MsgInviteDetailService;
-import com.yeshi.fanli.service.inter.msg.MsgMoneyDetailService;
-import com.yeshi.fanli.service.inter.msg.MsgOrderDetailService;
 import com.yeshi.fanli.service.inter.msg.MsgOtherDetailService;
 import com.yeshi.fanli.service.inter.msg.UserMsgReadStateService;
 import com.yeshi.fanli.service.inter.msg.UserSystemMsgService;
+import com.yeshi.fanli.service.inter.order.msg.MsgOrderDetailService;
 import com.yeshi.fanli.service.inter.push.DeviceActiveService;
 import com.yeshi.fanli.service.inter.push.PushGoodsService;
 import com.yeshi.fanli.service.inter.user.UserCustomSettingsService;
+import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
 import com.yeshi.fanli.service.inter.user.UserInfoService;
+import com.yeshi.fanli.service.inter.user.invite.MsgInviteDetailService;
+import com.yeshi.fanli.service.inter.user.msg.MsgAccountDetailService;
 import com.yeshi.fanli.util.Constant;
+import com.yeshi.fanli.util.RedisKeyEnum;
 import com.yeshi.fanli.util.RedisManager;
 import com.yeshi.fanli.util.StringUtil;
 import com.yeshi.fanli.util.TimeUtil;
+import com.yeshi.fanli.util.VersionUtil;
+import com.yeshi.fanli.util.account.UserUtil;
+import com.yeshi.fanli.util.annotation.RequestSerializableByKey;
 import com.yeshi.fanli.util.factory.CommonGoodsFactory;
 import com.yeshi.fanli.util.factory.msg.UserMsgVOFactory;
 import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
@@ -151,6 +158,9 @@
 	@Resource
 	private MsgDeviceReadStateService msgDeviceReadStateService;
 
+	@Resource
+	private UserInfoExtraService userInfoExtraService;
+
 	// 娑堟伅鐨勭被鍨�
 	final static String MSG_TYPE_ORDER = "order";
 	final static String MSG_TYPE_MONEY = "money";
@@ -169,7 +179,6 @@
 	 */
 	@RequestMapping(value = "getMsgList", method = RequestMethod.POST)
 	public void getMsgList(AcceptData acceptData, Long uid, int page, String type, PrintWriter out) {
-
 		if (uid == null) {
 			out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛鏈櫥褰�"));
 			return;
@@ -189,24 +198,38 @@
 			List<MsgOrderDetail> detailList = msgOrderDetailService.listMsgOrderDetail(uid, page);
 			count = msgOrderDetailService.countMsgOrderDetail(uid);
 			if (detailList != null)
-				for (MsgOrderDetail detail : detailList)
-					list.add(UserMsgVOFactory.create(detail));
+				for (MsgOrderDetail detail : detailList) {
+					JSONObject params = new JSONObject();
+					params.put("orderNo", detail.getOrderId());
+					if (detail.getType() == MsgTypeOrderTypeEnum.invite	|| detail.getType() == MsgTypeOrderTypeEnum.orderInvite)
+						params.put("orderHideNo", UserUtil.filterOrderId(detail.getOrderId()));
+					
+					UserMsgVO msgVO = UserMsgVOFactory.create(detail, jumpDetailV2Service.getByTypeCache("order_search"), params);
+					msgVO.setType(MSG_TYPE_ORDER);
+					list.add(msgVO);
+				}
 			break;
 		case MSG_TYPE_MONEY:
 			userMsgReadStateService.readMoneyMsg(uid);
 			List<MsgMoneyDetail> detailList1 = msgMoneyDetailService.listMsgMoneyDetail(uid, page);
 			count = msgMoneyDetailService.countMsgMoneyDetail(uid);
 			if (detailList1 != null)
-				for (MsgMoneyDetail detail : detailList1)
-					list.add(UserMsgVOFactory.create(detail));
+				for (MsgMoneyDetail detail : detailList1) {
+					UserMsgVO msgVO = UserMsgVOFactory.create(detail);
+					msgVO.setType(MSG_TYPE_MONEY);
+					list.add(msgVO);
+				}
 			break;
 		case MSG_TYPE_ACCOUNT:
 			userMsgReadStateService.readAccountMsg(uid);
 			List<MsgAccountDetail> detailList2 = msgAccountDetailService.listMsgAccountDetail(uid, page);
 			count = msgAccountDetailService.countMsgAccountDetail(uid);
 			if (detailList2 != null)
-				for (MsgAccountDetail detail : detailList2)
-					list.add(UserMsgVOFactory.create(detail));
+				for (MsgAccountDetail detail : detailList2) {
+					UserMsgVO msgVO = UserMsgVOFactory.create(detail);
+					msgVO.setType(MSG_TYPE_ACCOUNT);
+					list.add(msgVO);
+				}
 			break;
 		case MSG_TYPE_INVITE:
 			userMsgReadStateService.readInviteMsg(uid);
@@ -215,10 +238,12 @@
 			if (detailList3 != null)
 				for (MsgInviteDetail detail : detailList3) {
 					UserMsgVO vo = UserMsgVOFactory.create(detail);
-					if (vo != null)
+					if (vo != null) {
+						vo.setType(MSG_TYPE_INVITE);
 						list.add(vo);
-					else
+					} else {
 						count--;
+					}
 				}
 			break;
 		case MSG_TYPE_OTHER:
@@ -228,10 +253,12 @@
 			if (detailList4 != null)
 				for (MsgOtherDetail detail : detailList4) {
 					UserMsgVO vo = UserMsgVOFactory.create(detail);
-					if (vo != null)
+					if (vo != null) {
+						vo.setType(MSG_TYPE_OTHER);
 						list.add(vo);
-					else
+					} else {
 						count--;
+					}
 				}
 			break;
 		}
@@ -251,6 +278,7 @@
 	 * @param uid
 	 * @param out
 	 */
+	@RequestSerializableByKey(key = "#acceptData.device")
 	@RequestMapping(value = "getUnReadMsgCount", method = RequestMethod.POST)
 	public void getUnReadMsgCount(AcceptData acceptData, Long uid, PrintWriter out) {
 		GsonBuilder androidBuilder = new GsonBuilder().registerTypeAdapter(Integer.class,
@@ -292,9 +320,14 @@
 					data.put("totalCount", 0);
 				}
 			} catch (UserCustomSettingsException e) {
-				e.printStackTrace();
 			}
 
+			if (VersionUtil.greaterThan_1_5_50(acceptData.getPlatform(), acceptData.getVersion())) {
+				int totalCount = msgDeviceReadStateService.getUnReadCount(acceptData.getDevice(),
+						"android".equalsIgnoreCase(acceptData.getPlatform()) ? 1 : 2, MsgDeviceReadState.TYPE_KEFU);
+				data.put("totalCount", totalCount);
+			}
+			data.put("mineCount", 0);
 			out.print(JsonUtil.loadTrueResult(data));
 			return;
 		}
@@ -303,6 +336,12 @@
 		int totalCount = num.getTypeAccount() + num.getTypeInvite() + num.getTypeMoney() + num.getTypeOrder()
 				+ num.getTypeScore() + num.getTypeSystem() + num.getTypeOther();
 
+		// 1.5.50鍙婁互鍚庣殑鐗堟湰闇�瑕佹坊鍔犺澶囨湭璇绘秷鎭�
+		if (VersionUtil.greaterThan_1_5_50(acceptData.getPlatform(), acceptData.getVersion())) {
+			totalCount += msgDeviceReadStateService.getUnReadCount(acceptData.getDevice(),
+					"android".equalsIgnoreCase(acceptData.getPlatform()) ? 1 : 2, MsgDeviceReadState.TYPE_KEFU);
+		}
+
 		JSONObject data = null;
 		if ("android".equalsIgnoreCase(acceptData.getPlatform())) {
 			data = JSONObject.fromObject(androidBuilder.excludeFieldsWithoutExposeAnnotation().create().toJson(num));
@@ -310,6 +349,18 @@
 			data = JSONObject.fromObject(JsonUtil.getApiCommonGson().toJson(num));
 		}
 		data.put("totalCount", totalCount);
+		// "鎴戠殑"閫夐」瑙掓爣
+		int welfareCenterNews = 0;
+		if (uid != null) {
+			UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
+			if (userInfoExtra != null) {
+				if (userInfoExtra.getCouponNews() != null) {
+					welfareCenterNews = userInfoExtra.getCouponNews();
+				}
+			}
+		}
+
+		data.put("mineCount", welfareCenterNews);
 
 		try {
 			UserSettingsVO vo = userCustomSettingsService.getMySettings(uid);
@@ -363,7 +414,7 @@
 	}
 
 	private void addRecommendGoods(Long uid, String device, String imei, String idfa) {
-		TaoBaoSearchResult result = TaoKeApiUtil.guessDeviceLike(1, 50, imei, idfa);
+		TaoBaoSearchResult result = TaoKeApiUtil.guessDeviceLike(1, 50, imei, idfa,"");
 		if (result != null && result.getTaoBaoGoodsBriefs() != null) {
 			for (int i = 0; i < result.getTaoBaoGoodsBriefs().size(); i++) {
 				if (result.getTaoBaoGoodsBriefs().get(i).getCouponAmount() == null
@@ -452,6 +503,9 @@
 	public void getHomeMsgList(AcceptData acceptData, Long uid, int page, HttpSession session, PrintWriter out) {
 		if (uid != null && uid == 0)
 			uid = null;
+		if (uid != null)
+			userSystemMsgService.syncSystemZNX(uid);
+
 		String device = acceptData.getDevice();
 		if (device == null || device.trim().length() == 0) {
 			out.print(JsonUtil.loadFalseResult("璁惧鍙蜂笉鑳戒负绌�"));
@@ -476,7 +530,7 @@
 			}
 
 			// String key = "recommend-goods-user-" + uid;
-			String key = "recommend-goods-user-" + device;
+			String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.recommendGoodsUser, device);
 			if (Constant.IS_OUTNET) {
 				if (canAdd && StringUtil.isNullOrEmpty(redisManager.getCommonString(key))) {
 					if (Constant.IS_OUTNET)
@@ -551,7 +605,9 @@
 			// 鍒涘缓鏃堕棿鍦�28鍙峰悗鐨勬墠鏈夋柊浜烘杩�
 			if ((time > TimeUtil.convertToTimeTemp("2019-01-28", "yyyy-MM-dd") || uid == null)) {
 				UserHomeMsgVO vo = new UserHomeMsgVO();
-				vo.setContent("鎭枩浣狅紝鎴愪负杩斿埄鍒哥殑鐢ㄦ埛\n鐙浼樻儬鍒稿府浣犵渷閽憋紱\n鍙備笌濂栭噾娲诲姩甯綘璧氶挶锛沑n璁╄繑鍒╁埜鎴愪负浣犵殑鐪侀挶鍔╂墜鍚э紒");
+				vo.setContent(String.format("鎭枩浣狅紝鎴愪负%s鐨勭敤鎴穃n鐙浼樻儬鍒稿府浣犵渷閽憋紱\n鍙備笌濂栭噾娲诲姩甯綘璧氶挶锛沑n璁�%s鎴愪负浣犵殑鐪侀挶鍔╂墜鍚э紒",
+						Constant.getAppName(acceptData.getPlatform(), acceptData.getVersion()),
+						Constant.getAppName(acceptData.getPlatform(), acceptData.getVersion())));
 				vo.setTitle("鏂颁汉娆㈣繋");
 				vo.setCreateTime(getTimeDesc(now, new Date(time)));
 				vo.setType(UserHomeMsgVO.TYPE_WELCOME);
@@ -576,6 +632,35 @@
 		out.print(JsonUtil.loadTrueResult(root));
 	}
 
+	private UserCommonMsgVO getKeFuMsg(AcceptData acceptData) {
+		MsgDeviceReadState kefuState = msgDeviceReadStateService.getByDeviceAndPlatformAndType(
+				UserCommonMsgVO.TYPE_KEFU, acceptData.getDevice(),
+				acceptData.getPlatform().equalsIgnoreCase("android") ? 1 : 2);
+		// 浜哄伐瀹㈡湇
+		UserCommonMsgVO vo = new UserCommonMsgVO("http://img.flqapp.com/resource/msg/icon_kefu.png", "浜哄伐瀹㈡湇", new Date(),
+				UserCommonMsgVO.TYPE_KEFU, "", false, null, null, 0);
+		if (kefuState != null) {
+			vo.setUnReadCount(kefuState.getUnReadCount() == null ? 0 : kefuState.getUnReadCount());
+			if (!StringUtil.isNullOrEmpty(kefuState.getLatestContent()))
+				vo.setLatestMsg(kefuState.getLatestContent());
+
+			if (vo.getUnReadCount() != null && vo.getUnReadCount() > 0)
+				vo.setRead(false);
+			else
+				vo.setRead(true);
+
+			if (kefuState.getLatestContentTime() != null)
+				vo.setTime(kefuState.getLatestContentTime());
+
+		} else
+			vo.setRead(true);
+
+		if (StringUtil.isNullOrEmpty(vo.getLatestMsg()))
+			vo.setLatestMsg("[鐐瑰嚮鎵撳紑浜哄伐瀹㈡湇]");
+
+		return vo;
+	}
+
 	/**
 	 * 鑾峰彇娑堟伅鍒楄〃
 	 * 
@@ -585,10 +670,14 @@
 	 * @param type
 	 * @param out
 	 */
+	@RequestSerializableByKey(key = "#acceptData.device")
 	@RequestMapping(value = "getHomeMsgListNew", method = RequestMethod.POST)
 	public void getHomeMsgListNew(AcceptData acceptData, Long uid, PrintWriter out) {
 		if (uid != null && uid == 0)
 			uid = null;
+		if (uid != null) {
+			userSystemMsgService.syncSystemZNX(uid);
+		}
 
 		List<UserMsgCenter> listCenter = new ArrayList<>();
 
@@ -600,7 +689,7 @@
 		// 瀹樺浠诲姟
 		if (uid != null) {
 			MsgCommonDTO guanXuanMsg = msgConfigService.getGuanXuanMsg();
-			if (guanXuanMsg != null&&guanXuanMsg.getShow()==true) {
+			if (guanXuanMsg != null && guanXuanMsg.getShow() == true) {
 				boolean read = false;
 				UserMsgUnReadNum num = userMsgReadStateService.getReadStateByUid(uid);
 				if (num != null && (num.getGuanXuanReadTime() != null
@@ -613,16 +702,14 @@
 				} else
 					commonMsgList.add(new UserCommonMsgVO(guanXuanMsg.getIcon(), guanXuanMsg.getTitle(),
 							guanXuanMsg.getUpdateTime(), UserCommonMsgVO.TYPE_GUANXUAN, guanXuanMsg.getContent(), read,
-							guanXuanMsg.getJumpDetail(), guanXuanMsg.getParams()));
+							guanXuanMsg.getJumpDetail(), guanXuanMsg.getParams(), 0));
 			}
 		}
 
-		// 杩斿埄鍒稿皬鍔╂墜
+		// 鏉挎牀蹇渷灏忓姪鎵�
 		MsgCommonDTO zhuShouMsg = msgConfigService.getZhuShouMsg();
-		if (zhuShouMsg != null&&zhuShouMsg.getShow()==true) {
-
+		if (zhuShouMsg != null && zhuShouMsg.getShow() == true) {
 			boolean read = false;
-
 			MsgDeviceReadState state = msgDeviceReadStateService.getByDeviceAndPlatformAndType(
 					UserCommonMsgVO.TYPE_ZHUSHOU, acceptData.getDevice(),
 					acceptData.getPlatform().equalsIgnoreCase("android") ? 1 : 2);
@@ -637,12 +724,11 @@
 			} else
 				commonMsgList.add(new UserCommonMsgVO(zhuShouMsg.getIcon(), zhuShouMsg.getTitle(),
 						zhuShouMsg.getUpdateTime(), UserCommonMsgVO.TYPE_ZHUSHOU, zhuShouMsg.getContent(), read,
-						zhuShouMsg.getJumpDetail(), zhuShouMsg.getParams()));
+						zhuShouMsg.getJumpDetail(), zhuShouMsg.getParams(), 0));
 		}
 
 		// 浜哄伐瀹㈡湇
-		commonMsgList.add(new UserCommonMsgVO("http://img.flqapp.com/resource/msg/icon_kefu.png", "浜哄伐瀹㈡湇", new Date(),
-				UserCommonMsgVO.TYPE_KEFU, "", false, null, null));
+		commonMsgList.add(getKeFuMsg(acceptData));
 
 		// 鎺ㄨ崘璁板綍
 		DeviceActive deviceActive = deviceActiveService.getDeviceByDeviceAndPlatform(acceptData.getDevice(),
@@ -657,12 +743,12 @@
 						acceptData.getPlatform().equalsIgnoreCase("android") ? 1 : 2);
 				boolean read = false;
 				if (state != null && state.getReadTime() != null
-						&& list.get(0).getCreateTime().getTime() < state.getReadTime().getTime())
+						&& list.get(0).getPushTime().getTime() < state.getReadTime().getTime())
 					read = true;
 
 				commonMsgList.add(new UserCommonMsgVO("http://img.flqapp.com/resource/msg/icon_recommend.png", "鎺ㄨ崘璁板綍",
-						list.get(0).getCreateTime(), UserCommonMsgVO.TYPE_RECOMMEND, list.get(0).getContent(), read,
-						jumpDetailV2Service.getByTypeCache("recommend_list"), null));
+						list.get(0).getPushTime(), UserCommonMsgVO.TYPE_RECOMMEND, list.get(0).getContent(), read,
+						jumpDetailV2Service.getByTypeCache("recommend_list"), null, 0));
 			}
 		}
 
@@ -671,7 +757,10 @@
 		// list = pushGoodsService.listHistoryByPushTime(0, 1, uid, createTime);
 
 		// 1銆佹椿鍔ㄥ尯鍩�
-		List<Special> listSpecial = specialService.listByPlaceKey("msg_activities");
+		int platformCode = Constant.getPlatformCode(acceptData.getPlatform());
+
+		List<Special> listSpecial = specialService.listByPlaceKey("msg_activities", platformCode,
+				Integer.parseInt(acceptData.getVersion()));
 		if (listSpecial != null && listSpecial.size() > 0) {
 			for (Special special : listSpecial) {
 
@@ -695,7 +784,12 @@
 			List<MsgOrderDetail> detailList = msgOrderDetailService.listMsgOrderDetail(uid, page);
 			if (detailList != null && detailList.size() > 0) {
 				for (MsgOrderDetail detail : detailList) {
-					UserMsgVO userMsgVO = UserMsgVOFactory.create(detail);
+					JSONObject params = new JSONObject();
+					params.put("orderNo", detail.getOrderId());
+					if (detail.getType() == MsgTypeOrderTypeEnum.invite	|| detail.getType() == MsgTypeOrderTypeEnum.orderInvite)
+						params.put("orderHideNo", UserUtil.filterOrderId(detail.getOrderId()));
+					UserMsgVO userMsgVO = UserMsgVOFactory.create(detail,
+							jumpDetailV2Service.getByTypeCache("order_search"), params);
 					userMsgVO.setType(MSG_TYPE_ORDER);
 					list.add(userMsgVO);
 				}
@@ -763,7 +857,10 @@
 		if ((time > TimeUtil.convertToTimeTemp("2019-01-28", "yyyy-MM-dd") || uid == null)) {
 			Map<String, Object> map = new HashMap<String, Object>();
 			map.put("title", "鏂颁汉娆㈣繋");
-			map.put("content", "鎭枩浣狅紝鎴愪负杩斿埄鍒哥殑鐢ㄦ埛\n鐙浼樻儬鍒稿府浣犵渷閽憋紱\n鍙備笌濂栭噾娲诲姩甯綘璧氶挶锛沑n璁╄繑鍒╁埜鎴愪负浣犵殑鐪侀挶鍔╂墜鍚э紒");
+			map.put("content",
+					String.format("鎭枩浣狅紝鎴愪负%s鐨勭敤鎴穃n鐙浼樻儬鍒稿府浣犵渷閽憋紱\n鍙備笌濂栭噾娲诲姩甯綘璧氶挶锛沑n璁�%s鎴愪负浣犵殑鐪侀挶鍔╂墜鍚э紒",
+							Constant.getAppName(acceptData.getPlatform(), acceptData.getVersion()),
+							Constant.getAppName(acceptData.getPlatform(), acceptData.getVersion())));
 			map.put("createTime", new Date(time));
 			UserMsgCenter msgCenternre = new UserMsgCenter();
 			msgCenternre.setWelcomeMsg(map);
@@ -789,6 +886,30 @@
 			}
 		}
 
+		/**
+		 * 鎻愰啋澶у浘
+		 */
+		if (!"douyin".equalsIgnoreCase(acceptData.getChannel())) {
+			MsgCommonDTO notify = msgConfigService.getNotifyMsg();
+
+			if (notify != null && notify.getShow() == true) {
+				boolean read = false;
+				MsgDeviceReadState state = msgDeviceReadStateService.getByDeviceAndPlatformAndType(
+						UserCommonMsgVO.TYPE_NOTIFY, acceptData.getDevice(),
+						acceptData.getPlatform().equalsIgnoreCase("android") ? 1 : 2);
+				if (state != null && state.getReadTime() != null
+						&& zhuShouMsg.getUpdateTime().getTime() < state.getReadTime().getTime())
+					read = true;
+				if (notify.getJumpDetail() == null)
+					read = true;
+				// 鏌ヨ鏄惁宸茶
+				UserCommonMsgVO vo = new UserCommonMsgVO(notify.getIcon(), notify.getTitle(), notify.getUpdateTime(),
+						UserCommonMsgVO.TYPE_NOTIFY, notify.getContent(), read, notify.getJumpDetail(),
+						notify.getParams(), 0);
+				vo.setPicture(notify.getPicture());
+				root.put("notifyMsg", builder.create().toJson(vo));
+			}
+		}
 		root.put("list", builder.create().toJson(listCenter));
 		root.put("commonList", builder.create().toJson(commonMsgList));
 		root.put("count", listCenter.size());
@@ -935,4 +1056,74 @@
 		out.print(JsonUtil.loadTrueResult(""));
 	}
 
+	/**
+	 * 涓婁紶鏈�杩戠殑瀹㈡湇娑堟伅
+	 * 
+	 * @param acceptData
+	 * @param content
+	 * @param time
+	 * @param out
+	 */
+	@RequestMapping(value = "uploadLatestKeFuMsg", method = RequestMethod.POST)
+	public void uploadLatestKeFuMsg(AcceptData acceptData, String content, Long datetime, PrintWriter out) {
+
+		if (StringUtil.isNullOrEmpty(content) || datetime == null) {
+			out.print(JsonUtil.loadFalseResult("鍙傛暟涓嶅畬鏁�"));
+			return;
+		}
+		msgDeviceReadStateService.addUnreadDeviceMsg(MsgDeviceReadState.TYPE_KEFU, acceptData.getDevice(),
+				"android".equalsIgnoreCase(acceptData.getPlatform()) ? 1 : 2, 0, content, new Date(datetime));
+		out.print(JsonUtil.loadTrueResult(""));
+	}
+
+	
+	/**
+	 * 鍒犻櫎娑堟伅
+	 * @param acceptData
+	 * @param type
+	 * @param id
+	 * @param out
+	 */
+	@RequestMapping(value = "deleteMsg", method = RequestMethod.POST)
+	public void deleteMsg(AcceptData acceptData, String type, Long id, Long uid, PrintWriter out) {
+		if (StringUtil.isNullOrEmpty(type) || id == null || uid == null) {
+			out.print(JsonUtil.loadFalseResult("鍙傛暟涓嶅畬鏁�"));
+			return;
+		}
+		
+		switch (type) {
+		case MSG_TYPE_ORDER:
+			MsgOrderDetail msgOrderDetail  = msgOrderDetailService.selectByPrimaryKey(id);
+			if (msgOrderDetail != null && msgOrderDetail.getUser().getId().longValue() == uid.longValue()) {
+				msgOrderDetailService.deleteByPrimaryKey(id);
+			}
+			break;
+		case MSG_TYPE_MONEY:
+			MsgMoneyDetail moneyDetail  = msgMoneyDetailService.selectByPrimaryKey(id);
+			if (moneyDetail != null && moneyDetail.getUser().getId().longValue() == uid.longValue()) {
+				msgMoneyDetailService.deleteByPrimaryKey(id);
+			}
+			break;
+		case MSG_TYPE_ACCOUNT:
+			MsgAccountDetail accountDetail  = msgAccountDetailService.selectByPrimaryKey(id);
+			if (accountDetail != null && accountDetail.getUser().getId().longValue() == uid.longValue()) {
+				msgAccountDetailService.deleteByPrimaryKey(id);
+			}
+			break;
+		case MSG_TYPE_INVITE:
+			MsgInviteDetail inviteDetail  = msgInviteDetailService.selectByPrimaryKey(id);
+			if (inviteDetail != null && inviteDetail.getUser().getId().longValue() == uid.longValue()) {
+				msgInviteDetailService.deleteByPrimaryKey(id);
+			}
+			break;
+		case MSG_TYPE_OTHER:
+			MsgOtherDetail otherDetail  = msgOtherDetailService.selectByPrimaryKey(id);
+			if (otherDetail != null && otherDetail.getUser().getId().longValue() == uid.longValue()) {
+				msgOtherDetailService.deleteByPrimaryKey(id);
+			}
+			break;
+		}
+		out.print(JsonUtil.loadTrueResult(""));
+	}
+	
 }

--
Gitblit v1.8.0