| | |
| | | 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.bus.user.UserInfoExtra;
|
| | | 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.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.money.msg.MsgMoneyDetailService;
|
| | | 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.order.msg.MsgOrderDetailService;
|
| | | 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.UserInfoExtraService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.invite.MsgInviteDetailService;
|
| | | import com.yeshi.fanli.service.inter.user.msg.MsgAccountDetailService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.RedisKeyEnum;
|
| | | 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.account.UserUtil;
|
| | | import com.yeshi.fanli.util.annotation.RequestSerializableByKey;
|
| | | import com.yeshi.fanli.util.factory.CommonGoodsFactory;
|
| | | import com.yeshi.fanli.util.factory.msg.UserMsgVOFactory;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | |
| | | @Resource
|
| | | private MsgDeviceReadStateService msgDeviceReadStateService;
|
| | |
|
| | | @Resource
|
| | | private UserInfoExtraService userInfoExtraService;
|
| | |
|
| | | // 消息的类型
|
| | | final static String MSG_TYPE_ORDER = "order";
|
| | | final static String MSG_TYPE_MONEY = "money";
|
| | |
| | | */
|
| | | @RequestMapping(value = "getMsgList", method = RequestMethod.POST)
|
| | | public void getMsgList(AcceptData acceptData, Long uid, int page, String type, PrintWriter out) {
|
| | |
|
| | | if (uid == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | |
| | | for (MsgOrderDetail detail : detailList) {
|
| | | JSONObject params = new JSONObject();
|
| | | params.put("orderNo", detail.getOrderId());
|
| | | if (detail.getType() == MsgTypeOrderTypeEnum.share
|
| | | || detail.getType() == MsgTypeOrderTypeEnum.invite)
|
| | | if (detail.getType() == MsgTypeOrderTypeEnum.invite || detail.getType() == MsgTypeOrderTypeEnum.orderInvite)
|
| | | params.put("orderHideNo", UserUtil.filterOrderId(detail.getOrderId()));
|
| | | list.add(UserMsgVOFactory.create(detail, jumpDetailV2Service.getByTypeCache("order_search"),
|
| | | params));
|
| | | |
| | | UserMsgVO msgVO = UserMsgVOFactory.create(detail, jumpDetailV2Service.getByTypeCache("order_search"), params);
|
| | | msgVO.setType(MSG_TYPE_ORDER);
|
| | | list.add(msgVO);
|
| | | }
|
| | | break;
|
| | | case MSG_TYPE_MONEY:
|
| | |
| | | List<MsgMoneyDetail> detailList1 = msgMoneyDetailService.listMsgMoneyDetail(uid, page);
|
| | | count = msgMoneyDetailService.countMsgMoneyDetail(uid);
|
| | | if (detailList1 != null)
|
| | | for (MsgMoneyDetail detail : detailList1)
|
| | | list.add(UserMsgVOFactory.create(detail));
|
| | | for (MsgMoneyDetail detail : detailList1) {
|
| | | UserMsgVO msgVO = UserMsgVOFactory.create(detail);
|
| | | msgVO.setType(MSG_TYPE_MONEY);
|
| | | list.add(msgVO);
|
| | | }
|
| | | break;
|
| | | case MSG_TYPE_ACCOUNT:
|
| | | userMsgReadStateService.readAccountMsg(uid);
|
| | | List<MsgAccountDetail> detailList2 = msgAccountDetailService.listMsgAccountDetail(uid, page);
|
| | | count = msgAccountDetailService.countMsgAccountDetail(uid);
|
| | | if (detailList2 != null)
|
| | | for (MsgAccountDetail detail : detailList2)
|
| | | list.add(UserMsgVOFactory.create(detail));
|
| | | for (MsgAccountDetail detail : detailList2) {
|
| | | UserMsgVO msgVO = UserMsgVOFactory.create(detail);
|
| | | msgVO.setType(MSG_TYPE_ACCOUNT);
|
| | | list.add(msgVO);
|
| | | }
|
| | | break;
|
| | | case MSG_TYPE_INVITE:
|
| | | userMsgReadStateService.readInviteMsg(uid);
|
| | |
| | | if (detailList3 != null)
|
| | | for (MsgInviteDetail detail : detailList3) {
|
| | | UserMsgVO vo = UserMsgVOFactory.create(detail);
|
| | | if (vo != null)
|
| | | if (vo != null) {
|
| | | vo.setType(MSG_TYPE_INVITE);
|
| | | list.add(vo);
|
| | | else
|
| | | } else {
|
| | | count--;
|
| | | }
|
| | | }
|
| | | break;
|
| | | case MSG_TYPE_OTHER:
|
| | |
| | | if (detailList4 != null)
|
| | | for (MsgOtherDetail detail : detailList4) {
|
| | | UserMsgVO vo = UserMsgVOFactory.create(detail);
|
| | | if (vo != null)
|
| | | if (vo != null) {
|
| | | vo.setType(MSG_TYPE_OTHER);
|
| | | list.add(vo);
|
| | | else
|
| | | } else {
|
| | | count--;
|
| | | }
|
| | | }
|
| | | break;
|
| | | }
|
| | |
| | | * @param uid
|
| | | * @param out
|
| | | */
|
| | | @RequestSerializableByKey(key = "#acceptData.device")
|
| | | @RequestMapping(value = "getUnReadMsgCount", method = RequestMethod.POST)
|
| | | public void getUnReadMsgCount(AcceptData acceptData, Long uid, PrintWriter out) {
|
| | | GsonBuilder androidBuilder = new GsonBuilder().registerTypeAdapter(Integer.class,
|
| | |
| | | "android".equalsIgnoreCase(acceptData.getPlatform()) ? 1 : 2, MsgDeviceReadState.TYPE_KEFU);
|
| | | data.put("totalCount", totalCount);
|
| | | }
|
| | |
|
| | | data.put("mineCount", 0);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | return;
|
| | | }
|
| | |
| | | data = JSONObject.fromObject(JsonUtil.getApiCommonGson().toJson(num));
|
| | | }
|
| | | data.put("totalCount", totalCount);
|
| | | // "我的"选项角标
|
| | | int welfareCenterNews = 0;
|
| | | if (uid != null) {
|
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
|
| | | if (userInfoExtra != null) {
|
| | | if (userInfoExtra.getCouponNews() != null) {
|
| | | welfareCenterNews = userInfoExtra.getCouponNews();
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | data.put("mineCount", welfareCenterNews);
|
| | |
|
| | | try {
|
| | | UserSettingsVO vo = userCustomSettingsService.getMySettings(uid);
|
| | |
| | | }
|
| | |
|
| | | private void addRecommendGoods(Long uid, String device, String imei, String idfa) {
|
| | | TaoBaoSearchResult result = TaoKeApiUtil.guessDeviceLike(1, 50, imei, idfa);
|
| | | TaoBaoSearchResult result = TaoKeApiUtil.guessDeviceLike(1, 50, imei, idfa,"");
|
| | | if (result != null && result.getTaoBaoGoodsBriefs() != null) {
|
| | | for (int i = 0; i < result.getTaoBaoGoodsBriefs().size(); i++) {
|
| | | if (result.getTaoBaoGoodsBriefs().get(i).getCouponAmount() == null
|
| | |
| | | public void getHomeMsgList(AcceptData acceptData, Long uid, int page, HttpSession session, PrintWriter out) {
|
| | | if (uid != null && uid == 0)
|
| | | uid = null;
|
| | | if (uid != null)
|
| | | userSystemMsgService.syncSystemZNX(uid);
|
| | |
|
| | | String device = acceptData.getDevice();
|
| | | if (device == null || device.trim().length() == 0) {
|
| | | out.print(JsonUtil.loadFalseResult("设备号不能为空"));
|
| | |
| | | }
|
| | |
|
| | | // String key = "recommend-goods-user-" + uid;
|
| | | String key = "recommend-goods-user-" + device;
|
| | | String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.recommendGoodsUser, device);
|
| | | if (Constant.IS_OUTNET) {
|
| | | if (canAdd && StringUtil.isNullOrEmpty(redisManager.getCommonString(key))) {
|
| | | if (Constant.IS_OUTNET)
|
| | |
| | | // 创建时间在28号后的才有新人欢迎
|
| | | if ((time > TimeUtil.convertToTimeTemp("2019-01-28", "yyyy-MM-dd") || uid == null)) {
|
| | | UserHomeMsgVO vo = new UserHomeMsgVO();
|
| | | vo.setContent("恭喜你,成为返利券的用户\n独家优惠券帮你省钱;\n参与奖金活动帮你赚钱;\n让返利券成为你的省钱助手吧!");
|
| | | vo.setContent(String.format("恭喜你,成为%s的用户\n独家优惠券帮你省钱;\n参与奖金活动帮你赚钱;\n让%s成为你的省钱助手吧!",
|
| | | Constant.getAppName(acceptData.getPlatform(), acceptData.getVersion()),
|
| | | Constant.getAppName(acceptData.getPlatform(), acceptData.getVersion())));
|
| | | vo.setTitle("新人欢迎");
|
| | | vo.setCreateTime(getTimeDesc(now, new Date(time)));
|
| | | vo.setType(UserHomeMsgVO.TYPE_WELCOME);
|
| | |
| | | * @param type
|
| | | * @param out
|
| | | */
|
| | | @RequestSerializableByKey(key = "#acceptData.device")
|
| | | @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) {
|
| | | userSystemMsgService.syncSystemZNX(uid);
|
| | | }
|
| | |
|
| | | List<UserMsgCenter> listCenter = new ArrayList<>();
|
| | |
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | // 返利券小助手
|
| | | // 板栗快省小助手
|
| | | MsgCommonDTO zhuShouMsg = msgConfigService.getZhuShouMsg();
|
| | | if (zhuShouMsg != null && zhuShouMsg.getShow() == true) {
|
| | | boolean read = false;
|
| | |
| | | // list = pushGoodsService.listHistoryByPushTime(0, 1, uid, createTime);
|
| | |
|
| | | // 1、活动区域
|
| | | List<Special> listSpecial = specialService.listByPlaceKey("msg_activities");
|
| | | int platformCode = Constant.getPlatformCode(acceptData.getPlatform());
|
| | |
|
| | | List<Special> listSpecial = specialService.listByPlaceKey("msg_activities", platformCode,
|
| | | Integer.parseInt(acceptData.getVersion()));
|
| | | if (listSpecial != null && listSpecial.size() > 0) {
|
| | | for (Special special : listSpecial) {
|
| | |
|
| | |
| | | for (MsgOrderDetail detail : detailList) {
|
| | | JSONObject params = new JSONObject();
|
| | | params.put("orderNo", detail.getOrderId());
|
| | | if (detail.getType() == MsgTypeOrderTypeEnum.share
|
| | | || detail.getType() == MsgTypeOrderTypeEnum.invite)
|
| | | if (detail.getType() == MsgTypeOrderTypeEnum.invite || detail.getType() == MsgTypeOrderTypeEnum.orderInvite)
|
| | | params.put("orderHideNo", UserUtil.filterOrderId(detail.getOrderId()));
|
| | | UserMsgVO userMsgVO = UserMsgVOFactory.create(detail,
|
| | | jumpDetailV2Service.getByTypeCache("order_search"), params);
|
| | |
| | | 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("content",
|
| | | String.format("恭喜你,成为%s的用户\n独家优惠券帮你省钱;\n参与奖金活动帮你赚钱;\n让%s成为你的省钱助手吧!",
|
| | | Constant.getAppName(acceptData.getPlatform(), acceptData.getVersion()),
|
| | | Constant.getAppName(acceptData.getPlatform(), acceptData.getVersion())));
|
| | | map.put("createTime", new Date(time));
|
| | | UserMsgCenter msgCenternre = new UserMsgCenter();
|
| | | msgCenternre.setWelcomeMsg(map);
|
| | |
| | | /**
|
| | | * 提醒大图
|
| | | */
|
| | | MsgCommonDTO notify = msgConfigService.getNotifyMsg();
|
| | | if (!"douyin".equalsIgnoreCase(acceptData.getChannel())) {
|
| | | MsgCommonDTO notify = msgConfigService.getNotifyMsg();
|
| | |
|
| | | if (notify != null && notify.getShow() == true) {
|
| | | boolean read = false;
|
| | | MsgDeviceReadState state = msgDeviceReadStateService.getByDeviceAndPlatformAndType(
|
| | | UserCommonMsgVO.TYPE_NOTIFY, acceptData.getDevice(),
|
| | | acceptData.getPlatform().equalsIgnoreCase("android") ? 1 : 2);
|
| | | if (state != null && state.getReadTime() != null
|
| | | && zhuShouMsg.getUpdateTime().getTime() < state.getReadTime().getTime())
|
| | | read = true;
|
| | | if (notify.getJumpDetail() == null)
|
| | | read = true;
|
| | | // 查询是否已读
|
| | | UserCommonMsgVO vo = new UserCommonMsgVO(notify.getIcon(), notify.getTitle(), notify.getUpdateTime(),
|
| | | UserCommonMsgVO.TYPE_NOTIFY, notify.getContent(), read, notify.getJumpDetail(), notify.getParams(),
|
| | | 0);
|
| | | vo.setPicture(notify.getPicture());
|
| | | root.put("notifyMsg", builder.create().toJson(vo));
|
| | | if (notify != null && notify.getShow() == true) {
|
| | | boolean read = false;
|
| | | MsgDeviceReadState state = msgDeviceReadStateService.getByDeviceAndPlatformAndType(
|
| | | UserCommonMsgVO.TYPE_NOTIFY, acceptData.getDevice(),
|
| | | acceptData.getPlatform().equalsIgnoreCase("android") ? 1 : 2);
|
| | | if (state != null && state.getReadTime() != null
|
| | | && zhuShouMsg.getUpdateTime().getTime() < state.getReadTime().getTime())
|
| | | read = true;
|
| | | if (notify.getJumpDetail() == null)
|
| | | read = true;
|
| | | // 查询是否已读
|
| | | UserCommonMsgVO vo = new UserCommonMsgVO(notify.getIcon(), notify.getTitle(), notify.getUpdateTime(),
|
| | | UserCommonMsgVO.TYPE_NOTIFY, notify.getContent(), read, notify.getJumpDetail(),
|
| | | notify.getParams(), 0);
|
| | | vo.setPicture(notify.getPicture());
|
| | | root.put("notifyMsg", builder.create().toJson(vo));
|
| | | }
|
| | | }
|
| | |
|
| | | root.put("list", builder.create().toJson(listCenter));
|
| | | root.put("commonList", builder.create().toJson(commonMsgList));
|
| | | root.put("count", listCenter.size());
|
| | |
| | | out.print(JsonUtil.loadTrueResult(""));
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 删除消息
|
| | | * @param acceptData
|
| | | * @param type
|
| | | * @param id
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "deleteMsg", method = RequestMethod.POST)
|
| | | public void deleteMsg(AcceptData acceptData, String type, Long id, Long uid, PrintWriter out) {
|
| | | if (StringUtil.isNullOrEmpty(type) || id == null || uid == null) {
|
| | | out.print(JsonUtil.loadFalseResult("参数不完整"));
|
| | | return;
|
| | | }
|
| | | |
| | | switch (type) {
|
| | | case MSG_TYPE_ORDER:
|
| | | MsgOrderDetail msgOrderDetail = msgOrderDetailService.selectByPrimaryKey(id);
|
| | | if (msgOrderDetail != null && msgOrderDetail.getUser().getId().longValue() == uid.longValue()) {
|
| | | msgOrderDetailService.deleteByPrimaryKey(id);
|
| | | }
|
| | | break;
|
| | | case MSG_TYPE_MONEY:
|
| | | MsgMoneyDetail moneyDetail = msgMoneyDetailService.selectByPrimaryKey(id);
|
| | | if (moneyDetail != null && moneyDetail.getUser().getId().longValue() == uid.longValue()) {
|
| | | msgMoneyDetailService.deleteByPrimaryKey(id);
|
| | | }
|
| | | break;
|
| | | case MSG_TYPE_ACCOUNT:
|
| | | MsgAccountDetail accountDetail = msgAccountDetailService.selectByPrimaryKey(id);
|
| | | if (accountDetail != null && accountDetail.getUser().getId().longValue() == uid.longValue()) {
|
| | | msgAccountDetailService.deleteByPrimaryKey(id);
|
| | | }
|
| | | break;
|
| | | case MSG_TYPE_INVITE:
|
| | | MsgInviteDetail inviteDetail = msgInviteDetailService.selectByPrimaryKey(id);
|
| | | if (inviteDetail != null && inviteDetail.getUser().getId().longValue() == uid.longValue()) {
|
| | | msgInviteDetailService.deleteByPrimaryKey(id);
|
| | | }
|
| | | break;
|
| | | case MSG_TYPE_OTHER:
|
| | | MsgOtherDetail otherDetail = msgOtherDetailService.selectByPrimaryKey(id);
|
| | | if (otherDetail != null && otherDetail.getUser().getId().longValue() == uid.longValue()) {
|
| | | msgOtherDetailService.deleteByPrimaryKey(id);
|
| | | }
|
| | | break;
|
| | | }
|
| | | out.print(JsonUtil.loadTrueResult(""));
|
| | | }
|
| | | |
| | | }
|