admin
2019-07-18 2a671d23fa0e5c979a8b6459b4914481cd10c353
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/UserMsgController.java
@@ -76,6 +76,7 @@
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.factory.CommonGoodsFactory;
import com.yeshi.fanli.util.factory.msg.UserMsgVOFactory;
import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
@@ -189,8 +190,12 @@
         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());
               list.add(UserMsgVOFactory.create(detail, jumpDetailV2Service.getByTypeCache("order_search"),
                     params));
            }
         break;
      case MSG_TYPE_MONEY:
         userMsgReadStateService.readMoneyMsg(uid);
@@ -292,7 +297,12 @@
               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);
         }
         out.print(JsonUtil.loadTrueResult(data));
@@ -302,6 +312,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())) {
@@ -576,6 +592,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;
   }
   /**
    * 获取消息列表
    * 
@@ -600,7 +645,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 +658,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 +680,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 +699,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));
         }
      }
@@ -695,7 +737,10 @@
         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());
               UserMsgVO userMsgVO = UserMsgVOFactory.create(detail,
                     jumpDetailV2Service.getByTypeCache("order_search"), params);
               userMsgVO.setType(MSG_TYPE_ORDER);
               list.add(userMsgVO);
            }
@@ -935,4 +980,24 @@
      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(""));
   }
}