From 7ce92ff4ff754d62632a0d1254730cb32487aee6 Mon Sep 17 00:00:00 2001
From: yujian <yujian@123.com>
Date: 星期二, 14 五月 2019 14:12:38 +0800
Subject: [PATCH] 动态
---
fanli/src/main/java/com/yeshi/fanli/controller/client/UserMsgController.java | 337 +++++++++++++++++++++++++++++++++++++++----------------
1 files changed, 238 insertions(+), 99 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 ec28afe..542d64b 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
@@ -30,37 +30,46 @@
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
+import com.yeshi.fanli.dto.msg.MsgCommonDTO;
import com.yeshi.fanli.entity.accept.AcceptData;
import com.yeshi.fanli.entity.bus.homemodule.Special;
import com.yeshi.fanli.entity.bus.lable.QualityFactory;
import com.yeshi.fanli.entity.bus.msg.MsgAccountDetail;
+import com.yeshi.fanli.entity.bus.msg.MsgDeviceReadState;
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.MsgOtherDetail;
import com.yeshi.fanli.entity.bus.msg.UserMsgUnReadNum;
import com.yeshi.fanli.entity.bus.msg.UserSystemMsg;
+import com.yeshi.fanli.entity.common.JumpDetailV2;
import com.yeshi.fanli.entity.goods.CommonGoods;
import com.yeshi.fanli.entity.goods.RecommendUserGoods;
-import com.yeshi.fanli.entity.system.BusinessSystem;
+import com.yeshi.fanli.entity.push.DeviceActive;
+import com.yeshi.fanli.entity.push.PushGoods;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult;
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.common.JumpDetailV2Service;
import com.yeshi.fanli.service.inter.config.BusinessSystemService;
import com.yeshi.fanli.service.inter.goods.CommonGoodsService;
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.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.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.UserInfoService;
import com.yeshi.fanli.util.Constant;
@@ -70,6 +79,7 @@
import com.yeshi.fanli.util.factory.CommonGoodsFactory;
import com.yeshi.fanli.util.factory.msg.UserMsgVOFactory;
import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
+import com.yeshi.fanli.vo.msg.UserCommonMsgVO;
import com.yeshi.fanli.vo.msg.UserHomeMsgVO;
import com.yeshi.fanli.vo.msg.UserMsgCenter;
import com.yeshi.fanli.vo.msg.UserMsgVO;
@@ -122,10 +132,24 @@
@Resource
private RedisManager redisManager;
-
+
@Resource
private SpecialService specialService;
-
+
+ @Resource
+ private JumpDetailV2Service jumpDetailV2Service;
+
+ @Resource
+ private PushGoodsService pushGoodsService;
+
+ @Resource
+ private DeviceActiveService deviceActiveService;
+
+ @Resource
+ private MsgConfigService msgConfigService;
+
+ @Resource
+ private MsgDeviceReadStateService msgDeviceReadStateService;
// 娑堟伅鐨勭被鍨�
final static String MSG_TYPE_ORDER = "order";
@@ -398,7 +422,8 @@
*/
@RequestMapping(value = "getHomeMsgList", method = RequestMethod.POST)
public void getHomeMsgList(AcceptData acceptData, Long uid, int page, HttpSession session, PrintWriter out) {
-
+ if (uid != null && uid == 0)
+ uid = null;
String device = acceptData.getDevice();
if (device == null || device.trim().length() == 0) {
out.print(JsonUtil.loadFalseResult("璁惧鍙蜂笉鑳戒负绌�"));
@@ -522,8 +547,7 @@
root.put("count", count);
out.print(JsonUtil.loadTrueResult(root));
}
-
-
+
/**
* 鑾峰彇娑堟伅鍒楄〃
*
@@ -535,127 +559,200 @@
*/
@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) {
- out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛鏈櫥褰�"));
- return;
- }
-
- BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
- acceptData.getPackages());
- if (system == null) {
- out.print(JsonUtil.loadFalseResult(1, "绯荤粺涓嶅瓨鍦�"));
- return;
- }
-
- int page = 1;
- List<UserMsgVO> list = new ArrayList<>();
- List<MsgOrderDetail> detailList = msgOrderDetailService.listMsgOrderDetail(uid, page);
- if (detailList != null && detailList.size() > 0) {
- for (MsgOrderDetail detail : detailList) {
- UserMsgVO userMsgVO = UserMsgVOFactory.create(detail);
- userMsgVO.setType(MSG_TYPE_ORDER);
- list.add(userMsgVO);
- }
- }
-
- List<MsgMoneyDetail> detailList1 = msgMoneyDetailService.listMsgMoneyDetail(uid, page);
- if (detailList1 != null && detailList1.size() > 0) {
- for (MsgMoneyDetail detail : detailList1) {
- UserMsgVO userMsgVO = UserMsgVOFactory.create(detail);
- userMsgVO.setType(MSG_TYPE_MONEY);
- list.add(userMsgVO);
- }
- }
-
- List<MsgAccountDetail> detailList2 = msgAccountDetailService.listMsgAccountDetail(uid, page);
- if (detailList2 != null && detailList2.size() > 0) {
- for (MsgAccountDetail detail : detailList2) {
- UserMsgVO userMsgVO = UserMsgVOFactory.create(detail);
- userMsgVO.setType(MSG_TYPE_ACCOUNT);
- list.add(userMsgVO);
- }
- }
-
- List<MsgInviteDetail> detailList3 = msgInviteDetailService.listMsgInviteDetail(uid, page);
- if (detailList3 != null && detailList3.size() > 0) {
- for (MsgInviteDetail detail : detailList3) {
- UserMsgVO userMsgVO = UserMsgVOFactory.create(detail);
- if (userMsgVO != null) {
- userMsgVO.setType(MSG_TYPE_INVITE);
- list.add(userMsgVO);
- }
- }
- }
-
- List<MsgOtherDetail> detailList4 = msgOtherDetailService.listMsgOtherDetail(uid, page);
- if (detailList4 != null && detailList4.size() > 0) {
- for (MsgOtherDetail detail : detailList4) {
- UserMsgVO userMsgVO = UserMsgVOFactory.create(detail);
- if (userMsgVO != null) {
- userMsgVO.setType(MSG_TYPE_OTHER);
- list.add(userMsgVO);
- }
- }
- }
-
List<UserMsgCenter> listCenter = new ArrayList<>();
-
+
+ // 鍗曟潯娑堟伅
+ List<UserCommonMsgVO> commonMsgList = new ArrayList<>();
+
+ commonMsgList.add(new UserCommonMsgVO("http://img.flqapp.com/resource/msg/icon_kefu.png", "浜哄伐瀹㈡湇", new Date(),
+ UserCommonMsgVO.TYPE_KEFU, "", false, null, null));
+
+ // 鎺ㄨ崘璁板綍
+ DeviceActive deviceActive = deviceActiveService.getDeviceByDeviceAndPlatform(acceptData.getDevice(),
+ acceptData.getDevice(), acceptData.getPlatform());
+ if (deviceActive != null) {
+ // 璁惧娉ㄥ唽鏃堕棿
+ Date createTime = deviceActive.getCreateTime();
+ List<PushGoods> list = pushGoodsService.listHistoryByPushTime(0, 1, uid, createTime);
+ if (list != null && list.size() > 0) {
+ commonMsgList.add(new UserCommonMsgVO("http://img.flqapp.com/resource/msg/icon_recommend.png", "鎺ㄨ崘璁板綍",
+ list.get(0).getCreateTime(), UserCommonMsgVO.TYPE_RECOMMEND, list.get(0).getContent(), false,
+ jumpDetailV2Service.getByTypeCache("recommend_list"), null));
+ }
+ }
+
+ long currentTime = System.currentTimeMillis();
+ // 杩斿埄鍒稿皬鍔╂墜
+ MsgCommonDTO zhuShouMsg = msgConfigService.getZhuShouMsg();
+ if (zhuShouMsg != null) {
+
+ boolean read = false;
+
+ MsgDeviceReadState state = msgDeviceReadStateService.getByDeviceAndPlatformAndType(
+ UserCommonMsgVO.TYPE_ZHUSHOU, acceptData.getDevice(),
+ acceptData.getPlatform().equalsIgnoreCase("android") ? 1 : 2);
+ if (state != null && state.getReadTime() != null
+ && zhuShouMsg.getUpdateTime().getTime() < state.getReadTime().getTime())
+ read = true;
+ // 鏌ヨ鏄惁宸茶
+
+ if ((zhuShouMsg.getStartTime() != null && currentTime < zhuShouMsg.getStartTime().getTime())
+ || (zhuShouMsg.getEndTime() != null && currentTime > zhuShouMsg.getEndTime().getTime())) {
+ // 涓嶆樉绀�
+ } else
+ commonMsgList.add(new UserCommonMsgVO(zhuShouMsg.getIcon(), zhuShouMsg.getTitle(),
+ zhuShouMsg.getUpdateTime(), UserCommonMsgVO.TYPE_ZHUSHOU, zhuShouMsg.getContent(), read,
+ zhuShouMsg.getJumpDetail(), zhuShouMsg.getParams()));
+ }
+
+ // 瀹樺浠诲姟
+ if (uid != null) {
+ MsgCommonDTO guanXuanMsg = msgConfigService.getGuanXuanMsg();
+ if (guanXuanMsg != null) {
+ boolean read = false;
+ UserMsgUnReadNum num = userMsgReadStateService.getReadStateByUid(uid);
+ if (num != null && (num.getGuanXuanReadTime() != null
+ && guanXuanMsg.getUpdateTime().getTime() < num.getGuanXuanReadTime().getTime()))
+ read = true;
+ // 鏌ヨ鏄惁宸茶
+ if ((guanXuanMsg.getStartTime() != null && currentTime < guanXuanMsg.getStartTime().getTime())
+ || (guanXuanMsg.getEndTime() != null && currentTime > guanXuanMsg.getEndTime().getTime())) {
+ // 涓嶆樉绀�
+ } else
+ commonMsgList.add(new UserCommonMsgVO(guanXuanMsg.getIcon(), guanXuanMsg.getTitle(),
+ guanXuanMsg.getUpdateTime(), UserCommonMsgVO.TYPE_GUANXUAN, guanXuanMsg.getContent(), read,
+ guanXuanMsg.getJumpDetail(), guanXuanMsg.getParams()));
+ }
+ }
+
+ //
+
+ // list = pushGoodsService.listHistoryByPushTime(0, 1, uid, createTime);
+
+ // 1銆佹椿鍔ㄥ尯鍩�
List<Special> listSpecial = specialService.listByPlaceKey("msg_activities");
if (listSpecial != null && listSpecial.size() > 0) {
- for (Special special: listSpecial) {
+ for (Special special : listSpecial) {
+
+ boolean needLogin = special.isJumpLogin();
+ JumpDetailV2 jumpDetail = special.getJumpDetail();
+ if (jumpDetail != null) {
+ jumpDetail.setNeedLogin(needLogin);
+ special.setJumpDetail(jumpDetail);
+ }
+
UserMsgCenter msgCenter = new UserMsgCenter();
msgCenter.setSpecial(special);
listCenter.add(msgCenter);
}
}
-
- if (list.size() > 0 ) {
- // 鏃堕棿鎺掑簭
- listSort(list);
-
- if (list.size() >= 20 ) {
- list = list.subList(0, 19);
+
+ // 2銆佹秷鎭尯鍩�
+ if (uid != null && uid > 0) {
+ int page = 1;
+ List<UserMsgVO> list = new ArrayList<>();
+ List<MsgOrderDetail> detailList = msgOrderDetailService.listMsgOrderDetail(uid, page);
+ if (detailList != null && detailList.size() > 0) {
+ for (MsgOrderDetail detail : detailList) {
+ UserMsgVO userMsgVO = UserMsgVOFactory.create(detail);
+ userMsgVO.setType(MSG_TYPE_ORDER);
+ list.add(userMsgVO);
+ }
}
-
- for (UserMsgVO userMsgVO: list) {
- UserMsgCenter userMsgCenter = new UserMsgCenter();
- userMsgCenter.setUserMsg(userMsgVO);
- listCenter.add(userMsgCenter);
+
+ List<MsgMoneyDetail> detailList1 = msgMoneyDetailService.listMsgMoneyDetail(uid, page);
+ if (detailList1 != null && detailList1.size() > 0) {
+ for (MsgMoneyDetail detail : detailList1) {
+ UserMsgVO userMsgVO = UserMsgVOFactory.create(detail);
+ userMsgVO.setType(MSG_TYPE_MONEY);
+ list.add(userMsgVO);
+ }
+ }
+
+ List<MsgAccountDetail> detailList2 = msgAccountDetailService.listMsgAccountDetail(uid, page);
+ if (detailList2 != null && detailList2.size() > 0) {
+ for (MsgAccountDetail detail : detailList2) {
+ UserMsgVO userMsgVO = UserMsgVOFactory.create(detail);
+ userMsgVO.setType(MSG_TYPE_ACCOUNT);
+ list.add(userMsgVO);
+ }
+ }
+
+ List<MsgInviteDetail> detailList3 = msgInviteDetailService.listMsgInviteDetail(uid, page);
+ if (detailList3 != null && detailList3.size() > 0) {
+ for (MsgInviteDetail detail : detailList3) {
+ UserMsgVO userMsgVO = UserMsgVOFactory.create(detail);
+ if (userMsgVO != null) {
+ userMsgVO.setType(MSG_TYPE_INVITE);
+ list.add(userMsgVO);
+ }
+ }
+ }
+
+ List<MsgOtherDetail> detailList4 = msgOtherDetailService.listMsgOtherDetail(uid, page);
+ if (detailList4 != null && detailList4.size() > 0) {
+ for (MsgOtherDetail detail : detailList4) {
+ UserMsgVO userMsgVO = UserMsgVOFactory.create(detail);
+ if (userMsgVO != null) {
+ userMsgVO.setType(MSG_TYPE_OTHER);
+ list.add(userMsgVO);
+ }
+ }
+ }
+
+ if (list.size() > 0) {
+ // 鏃堕棿鎺掑簭
+ listSort(list);
+
+ if (list.size() >= 20) {
+ list = list.subList(0, 19);
+ }
+
+ for (UserMsgVO userMsgVO : list) {
+ UserMsgCenter userMsgCenter = new UserMsgCenter();
+ userMsgCenter.setUserMsg(userMsgVO);
+ listCenter.add(userMsgCenter);
+ }
}
}
-
-
- // 娣诲姞娆㈣繋璇�
+
+ // 3銆佹坊鍔犳杩庤
Long time = (uid == null ? System.currentTimeMillis() : userInfoService.selectByPKey(uid).getCreatetime());
// 鍒涘缓鏃堕棿鍦�28鍙峰悗鐨勬墠鏈夋柊浜烘杩�
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("createTime",new Date(time));
+ map.put("createTime", new Date(time));
UserMsgCenter msgCenternre = new UserMsgCenter();
msgCenternre.setWelcomeMsg(map);
listCenter.add(msgCenternre);
}
-
+
GsonBuilder builder = new GsonBuilder();
builder = getTimeDescJsonBuilder(builder);
-
JSONObject root = new JSONObject();
-
- UserMsgUnReadNum num = userMsgReadStateService.getReadStateByUid(uid);
- UserSystemMsg usm = userSystemMsgService.getLatestUserSystemMsg(uid);
- if (usm != null) {
- root.put("systemMsg", 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(new Date(), usm.getCreateTime()), num.getTypeSystem()));
+
+ if (uid != null && uid > 0) {
+ UserMsgUnReadNum num = userMsgReadStateService.getReadStateByUid(uid);
+ UserSystemMsg usm = userSystemMsgService.getLatestUserSystemMsg(uid);
+ if (usm != null) {
+ root.put("systemMsg",
+ 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(new Date(), usm.getCreateTime()), num.getTypeSystem()));
+ }
}
-
+
root.put("list", builder.create().toJson(listCenter));
+ root.put("commonList", builder.create().toJson(commonMsgList));
root.put("count", listCenter.size());
out.print(JsonUtil.loadTrueResult(root));
}
-
public static void listSort(List<UserMsgVO> list) {
Collections.sort(list, new Comparator<UserMsgVO>() {
@@ -671,8 +768,7 @@
}
});
}
-
-
+
/**
* 鑾峰彇绯荤粺娑堟伅鍒楄〃
*
@@ -742,6 +838,16 @@
return;
}
+ // 鍒濆鍖栬鍙栫姸鎬�
+ msgDeviceReadStateService.initReadState(acceptData.getDevice(),
+ "android".equalsIgnoreCase(acceptData.getPlatform()) ? 1 : 2, UserCommonMsgVO.TYPE_RECOMMEND);
+ msgDeviceReadStateService.initReadState(acceptData.getDevice(),
+ "android".equalsIgnoreCase(acceptData.getPlatform()) ? 1 : 2, UserCommonMsgVO.TYPE_ZHUSHOU);
+
+ // 璁剧疆璁惧娑堟伅鎵�鏈夊凡璇�
+ msgDeviceReadStateService.setAllMsgRead(acceptData.getDevice(),
+ "android".equalsIgnoreCase(acceptData.getPlatform()) ? 1 : 2);
+
UserMsgUnReadNum num = userMsgReadStateService.getReadStateByUid(uid);
int totalNum = num.getTypeAccount() + num.getTypeInvite() + num.getTypeMoney() + num.getTypeOrder()
+ num.getTypeScore() + num.getTypeSystem() + num.getTypeOther();
@@ -753,4 +859,37 @@
out.print(JsonUtil.loadTrueResult(""));
}
+ /**
+ * 闃呰閫氱敤娑堟伅
+ *
+ * @param acceptData
+ * @param uid
+ * @param out
+ */
+ @RequestMapping(value = "readCommonMsg", method = RequestMethod.POST)
+ public void readCommonMsg(AcceptData acceptData, Long uid, String type, PrintWriter out) {
+ if (StringUtil.isNullOrEmpty(type)) {
+ out.print(JsonUtil.loadFalseResult(2, "璇蜂笂浼爐ype"));
+ return;
+ }
+ if (type.equalsIgnoreCase(UserCommonMsgVO.TYPE_GUANXUAN)) {
+ if (uid != null) {
+ UserMsgUnReadNum num = userMsgReadStateService.getReadStateByUid(uid);
+ UserMsgUnReadNum update = new UserMsgUnReadNum();
+ update.setId(num.getId());
+ update.setGuanXuanReadTime(new Date());
+ update.setUpdateTime(new Date());
+ userMsgReadStateService.updateSelective(update);
+ }
+
+ } else if (type.equalsIgnoreCase(UserCommonMsgVO.TYPE_RECOMMEND)) {
+ msgDeviceReadStateService.setDeviceMsgRead(UserCommonMsgVO.TYPE_RECOMMEND, acceptData.getDevice(),
+ (acceptData.getPlatform().equalsIgnoreCase("android") ? 1 : 2));
+ } else if (type.equalsIgnoreCase(UserCommonMsgVO.TYPE_ZHUSHOU)) {
+ msgDeviceReadStateService.setDeviceMsgRead(UserCommonMsgVO.TYPE_RECOMMEND, acceptData.getDevice(),
+ (acceptData.getPlatform().equalsIgnoreCase("android") ? 1 : 2));
+ }
+ out.print(JsonUtil.loadTrueResult(""));
+ }
+
}
--
Gitblit v1.8.0