| | |
| | | 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.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.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;
|
| | |
| | |
|
| | | @Resource
|
| | | private PushGoodsService pushGoodsService;
|
| | |
|
| | | @Resource
|
| | | private DeviceActiveService deviceActiveService;
|
| | |
|
| | | @Resource
|
| | | private MsgConfigService msgConfigService;
|
| | |
|
| | | @Resource
|
| | | private MsgDeviceReadStateService msgDeviceReadStateService;
|
| | |
|
| | | // 消息的类型
|
| | | final static String MSG_TYPE_ORDER = "order";
|
| | |
| | | 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);
|
| | | commonMsgList.add(new UserCommonMsgVO("http://img.flqapp.com/resource/msg/icon_recommend.png", "推荐记录",
|
| | | new Date(), UserCommonMsgVO.TYPE_RECOMMEND, "防油防水防潮,污渍一抹即净,从胃到心的暖意", false,
|
| | | jumpDetailV2Service.getByTypeCache("recommend_list"), null));
|
| | |
|
| | | // 1、活动区域
|
| | | List<Special> listSpecial = specialService.listByPlaceKey("msg_activities");
|
| | |
| | | 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();
|
| | |
| | | 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(""));
|
| | | }
|
| | |
|
| | | }
|