admin
2019-04-26 8e30aa7c1f0384f09278699318b4902b815b42a7
fanli/src/main/java/com/yeshi/fanli/controller/client/UserMsgController.java
@@ -122,10 +122,9 @@
   @Resource
   private RedisManager redisManager;
   @Resource
   private SpecialService specialService;
   // 消息的类型
   final static String MSG_TYPE_ORDER = "order";
@@ -398,7 +397,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 +522,7 @@
      root.put("count", count);
      out.print(JsonUtil.loadTrueResult(root));
   }
   /**
    * 获取消息列表
    * 
@@ -535,27 +534,29 @@
    */
   @RequestMapping(value = "getHomeMsgListNew", method = RequestMethod.POST)
   public void getHomeMsgListNew(AcceptData acceptData, Long uid, PrintWriter out) {
      if (uid != null && uid == 0)
         uid = null;
      List<UserMsgCenter> listCenter = new ArrayList<>();
      // 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);
         }
      }
      // 2、消息区域
      if (uid != null && uid > 0) {
         int page = 1;
@@ -608,23 +609,23 @@
               }
            }
         }
         if (list.size() > 0 ) {
         if (list.size() > 0) {
            // 时间排序
            listSort(list);
            if (list.size() >= 20 ) {
            if (list.size() >= 20) {
               list = list.subList(0, 19);
            }
            for (UserMsgVO userMsgVO: list) {
            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号后的才有新人欢迎
@@ -632,30 +633,32 @@
         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();
      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("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("count", listCenter.size());
      out.print(JsonUtil.loadTrueResult(root));
   }
   public static void listSort(List<UserMsgVO> list) {
      Collections.sort(list, new Comparator<UserMsgVO>() {
@@ -671,8 +674,7 @@
         }
      });
   }
   /**
    * 获取系统消息列表
    *