| | |
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Calendar;
|
| | | import java.util.Collections;
|
| | | import java.util.Comparator;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | | import java.util.HashSet;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.Set;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
| | | 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.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;
|
| | |
| | | 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;
|
| | | import com.yeshi.fanli.vo.msg.UserSystemMsgVO;
|
| | | import com.yeshi.fanli.vo.user.UserSettingsVO;
|
| | |
| | | @RequestMapping("api/v1/user/msg")
|
| | | public class UserMsgController {
|
| | |
|
| | | @Resource
|
| | | private BusinessSystemService businessSystemService;
|
| | | @Resource
|
| | | private MsgOrderDetailService msgOrderDetailService;
|
| | |
|
| | |
| | |
|
| | | @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";
|
| | |
| | | return;
|
| | | }
|
| | | UserMsgUnReadNum num = userMsgReadStateService.getReadStateByUid(uid);
|
| | | JSONObject data = JSONObject.fromObject(JsonUtil.getApiCommonGson().toJson(num));
|
| | | data.put("totalCount", num.getTypeAccount() + num.getTypeInvite() + num.getTypeMoney() + num.getTypeOrder()
|
| | | + num.getTypeScore() + num.getTypeSystem()+num.getTypeOther());
|
| | |
|
| | | GsonBuilder androidBuilder = new GsonBuilder().registerTypeAdapter(Integer.class,
|
| | | new JsonSerializer<Integer>() {
|
| | | @Override
|
| | | public JsonElement serialize(Integer value, Type theType, JsonSerializationContext context) {
|
| | | if (value == null) {
|
| | | return new JsonPrimitive("0");
|
| | | } else {
|
| | | if (value >= 100)
|
| | | return new JsonPrimitive("99+");
|
| | | else
|
| | | return new JsonPrimitive(value);
|
| | | }
|
| | | }
|
| | | });
|
| | | int totalCount = num.getTypeAccount() + num.getTypeInvite() + num.getTypeMoney() + num.getTypeOrder()
|
| | | + num.getTypeScore() + num.getTypeSystem() + num.getTypeOther();
|
| | | JSONObject data = null;
|
| | | if ("android".equalsIgnoreCase(acceptData.getPlatform())) {
|
| | | data = JSONObject.fromObject(androidBuilder.excludeFieldsWithoutExposeAnnotation().create().toJson(num));
|
| | | } else {
|
| | | data = JSONObject.fromObject(JsonUtil.getApiCommonGson().toJson(num));
|
| | | }
|
| | | data.put("totalCount", totalCount);
|
| | |
|
| | | try {
|
| | | UserSettingsVO vo = userCustomSettingsService.getMySettings(uid);
|
| | |
| | | return builder;
|
| | | }
|
| | |
|
| | | private void addRecommendGoods(Long uid, String imei, String idfa) {
|
| | | private void addRecommendGoods(Long uid, String device, String imei, String idfa) {
|
| | | TaoBaoSearchResult result = TaoKeApiUtil.guessDeviceLike(1, 50, imei, idfa);
|
| | | if (result != null && result.getTaoBaoGoodsBriefs() != null) {
|
| | | for (int i = 0; i < result.getTaoBaoGoodsBriefs().size(); i++) {
|
| | |
| | | }
|
| | | }
|
| | | try {
|
| | | recommendUserGoodsService.addRecommend(uid, "", goodsList);
|
| | | recommendUserGoodsService.addRecommend(uid, device, "", goodsList);
|
| | | } catch (RecommendUserGoodsException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | private void addRecommendGoods(Long uid) {
|
| | | private void addRecommendGoods(Long uid, String device) {
|
| | | List<QualityFactory> qfList = qualityFactoryService.listByMinSalesCountOrderByCreateTimeDesc(10000, 1, 20);
|
| | | if (qfList != null && qfList != null) {
|
| | | for (int i = 0; i < qfList.size(); i++) {
|
| | |
| | | }
|
| | | }
|
| | | try {
|
| | | recommendUserGoodsService.addRecommend(uid, "", goodsList);
|
| | | recommendUserGoodsService.addRecommend(uid, device, "", goodsList);
|
| | | } catch (RecommendUserGoodsException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
| | | */
|
| | | @RequestMapping(value = "getHomeMsgList", method = RequestMethod.POST)
|
| | | public void getHomeMsgList(AcceptData acceptData, Long uid, int page, HttpSession session, PrintWriter out) {
|
| | | if (uid == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | if (uid != null && uid == 0)
|
| | | uid = null;
|
| | | String device = acceptData.getDevice();
|
| | | if (device == null || device.trim().length() == 0) {
|
| | | out.print(JsonUtil.loadFalseResult("设备号不能为空"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (page == 1) {
|
| | | if (uid != null)
|
| | | recommendUserGoodsService.syncDeviceAndUid(uid, acceptData.getDevice());
|
| | |
|
| | | boolean canAdd = false;
|
| | | int hour = Calendar.getInstance().get(Calendar.HOUR);
|
| | | RecommendUserGoods goods = recommendUserGoodsService.getLatestRecommendUserGoods(uid);
|
| | | RecommendUserGoods goods = recommendUserGoodsService.getLatestRecommendUserGoodsByDevice(device);
|
| | |
|
| | | if (goods == null) {
|
| | | canAdd = true;
|
| | | } else {
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | String key = "recommend-goods-user-" + uid;
|
| | | // String key = "recommend-goods-user-" + uid;
|
| | | String key = "recommend-goods-user-" + device;
|
| | | if (Constant.IS_OUTNET) {
|
| | | if (canAdd && StringUtil.isNullOrEmpty(redisManager.getCommonString(key))) {
|
| | | if (Constant.IS_OUTNET)
|
| | | redisManager.cacheCommonString(key, "1", 20);
|
| | | if (hour < 12)
|
| | | addRecommendGoods(uid);
|
| | | addRecommendGoods(uid, device);
|
| | | else
|
| | | addRecommendGoods(uid, acceptData.getImei(), acceptData.getIdfa());
|
| | | addRecommendGoods(uid, device, acceptData.getImei(), acceptData.getIdfa());
|
| | | session.removeAttribute("recommendgoods");
|
| | | }
|
| | | } else {
|
| | | if (canAdd) {
|
| | | if (hour < 12)
|
| | | addRecommendGoods(uid);
|
| | | addRecommendGoods(uid, device);
|
| | | else
|
| | | addRecommendGoods(uid, acceptData.getImei(), acceptData.getIdfa());
|
| | | addRecommendGoods(uid, device, acceptData.getImei(), acceptData.getIdfa());
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | List<UserHomeMsgVO> volist = new ArrayList<>();
|
| | | List<RecommendUserGoods> list = recommendUserGoodsService.listRecommend(uid, page, Constant.PAGE_SIZE);
|
| | | long count = recommendUserGoodsService.countRecommend(uid);//
|
| | |
|
| | | List<RecommendUserGoods> list = recommendUserGoodsService.listRecommendGoodsByDevice(device, page,
|
| | | Constant.PAGE_SIZE);
|
| | | long count = recommendUserGoodsService.countRecommendGoodsByDevice(device);
|
| | |
|
| | | Date now = new Date();
|
| | | for (RecommendUserGoods goods : list) {
|
| | |
| | | volist.add(vo);
|
| | | }
|
| | |
|
| | | Long time = userInfoService.selectByPKey(uid).getCreatetime();
|
| | | if (time > TimeUtil.convertToTimeTemp("2019-01-28", "yyyy-MM-dd"))
|
| | | count++;// 计算欢迎语的数量
|
| | | Long time = (uid == null ? System.currentTimeMillis() : userInfoService.selectByPKey(uid).getCreatetime());
|
| | |
|
| | | if (volist.size() > 0 && volist.size() < Constant.PAGE_SIZE) {
|
| | | // 添加欢迎语
|
| | | // 创建时间在28号后的才有新人欢迎
|
| | | if (time > TimeUtil.convertToTimeTemp("2019-01-28", "yyyy-MM-dd")) {
|
| | | if ((time > TimeUtil.convertToTimeTemp("2019-01-28", "yyyy-MM-dd") || uid == null)) {
|
| | | 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);
|
| | | count++;
|
| | | }
|
| | | }
|
| | |
|
| | | JSONObject root = new JSONObject();
|
| | | root.put("msgList", new Gson().toJson(volist));
|
| | | if (page == 1) {
|
| | | if (page == 1 && uid != null) {
|
| | | UserMsgUnReadNum num = userMsgReadStateService.getReadStateByUid(uid);
|
| | | UserSystemMsg usm = userSystemMsgService.getLatestUserSystemMsg(uid);
|
| | | if (usm != null)
|
| | |
| | | }
|
| | | root.put("count", count);
|
| | | out.print(JsonUtil.loadTrueResult(root));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取消息列表
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param page
|
| | | * @param type
|
| | | * @param out
|
| | | */
|
| | | @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<>();
|
| | |
|
| | | // 单条消息
|
| | | 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) {
|
| | |
|
| | | 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;
|
| | | 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);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | 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));
|
| | | 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("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>() {
|
| | | @Override
|
| | | public int compare(UserMsgVO o1, UserMsgVO o2) {
|
| | | if (o1.getTime().getTime() > o2.getTime().getTime()) {
|
| | | return -1;
|
| | | } else if (o1 == o2) {
|
| | | return 0;
|
| | | } else {
|
| | | return 1;
|
| | | }
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | 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.getTypeScore() + num.getTypeSystem() + num.getTypeOther();
|
| | | if (totalNum == 0) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "没有未读消息"));
|
| | | return;
|
| | |
| | | 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, "请上传type"));
|
| | | 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(""));
|
| | | }
|
| | |
|
| | | }
|