| | |
| | | import java.util.Set;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | | import javax.servlet.http.HttpSession;
|
| | |
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | |
| | | 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.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.factory.CommonGoodsFactory;
|
| | |
| | |
|
| | | @Resource
|
| | | private UserCustomSettingsService userCustomSettingsService;
|
| | |
|
| | | @Resource
|
| | | private RedisManager redisManager;
|
| | |
|
| | | // 消息的类型
|
| | | final static String MSG_TYPE_ORDER = "order";
|
| | |
| | | List<MsgInviteDetail> detailList3 = msgInviteDetailService.listMsgInviteDetail(uid, page);
|
| | | count = msgInviteDetailService.countMsgInviteDetail(uid);
|
| | | if (detailList3 != null)
|
| | | for (MsgInviteDetail detail : detailList3)
|
| | | list.add(UserMsgVOFactory.create(detail));
|
| | | for (MsgInviteDetail detail : detailList3) {
|
| | | UserMsgVO vo = UserMsgVOFactory.create(detail);
|
| | | if (vo != null)
|
| | | list.add(vo);
|
| | | else
|
| | | count--;
|
| | | }
|
| | | break;
|
| | | }
|
| | |
|
| | |
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getHomeMsgList", method = RequestMethod.POST)
|
| | | public void getHomeMsgList(AcceptData acceptData, Long uid, int page, PrintWriter out) {
|
| | | public void getHomeMsgList(AcceptData acceptData, Long uid, int page, HttpSession session, PrintWriter out) {
|
| | | if (uid == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | |
| | | canAdd = true;
|
| | | } else {
|
| | | // 是否和上次间隔时间足够
|
| | | if (System.currentTimeMillis() - goods.getCreateTime().getTime() >= 1000 * 60 * 60 * 8L) {
|
| | | if (System.currentTimeMillis() - goods.getCreateTime().getTime() >= 1000 * 60 * 60 * 4L) {
|
| | | canAdd = true;
|
| | | }
|
| | | }
|
| | |
|
| | | if (canAdd) {
|
| | | String key = "recommend-goods-user-" + uid;
|
| | | if (canAdd && StringUtil.isNullOrEmpty(redisManager.getCommonString(key))) {
|
| | | redisManager.cacheCommonString(key, "1", 20);
|
| | | if (hour < 12)
|
| | | addRecommendGoods(uid);
|
| | | else
|
| | | addRecommendGoods(uid, acceptData.getImei(), acceptData.getIdfa());
|
| | | session.removeAttribute("recommendgoods");
|
| | | }
|
| | | }
|
| | |
|
| | | List<UserHomeMsgVO> volist = new ArrayList<>();
|
| | | List<RecommendUserGoods> list = recommendUserGoodsService.listRecommend(uid, page, Constant.PAGE_SIZE);
|
| | | long count = recommendUserGoodsService.countRecommend(uid) + 1;// 计算欢迎语的数量
|
| | | long count = recommendUserGoodsService.countRecommend(uid);//
|
| | |
|
| | | Date now = new Date();
|
| | | for (RecommendUserGoods goods : list) {
|
| | |
| | | List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
|
| | | for (CommonGoods cg : goods.getGoodsList()) {
|
| | | if (goods.getGoodsList().size() == 1)
|
| | | cg.setPicture(TbImgUtil.getTBSizeImg(cg.getPicture(), 400));
|
| | | cg.setPicture(TbImgUtil.getTBSizeImg(
|
| | | StringUtil.isNullOrEmpty(cg.getPictureWhite()) ? cg.getPicture() : cg.getPictureWhite(),
|
| | | 400));
|
| | | else if (goods.getGoodsList().size() == 2)
|
| | | cg.setPicture(TbImgUtil.getTBSizeImg(cg.getPicture(), 320));
|
| | | cg.setPicture(TbImgUtil.getTBSizeImg(
|
| | | StringUtil.isNullOrEmpty(cg.getPictureWhite()) ? cg.getPicture() : cg.getPictureWhite(),
|
| | | 320));
|
| | | else if (goods.getGoodsList().size() == 3)
|
| | | cg.setPicture(TbImgUtil.getTBSizeImg(cg.getPicture(), 220));
|
| | | cg.setPicture(TbImgUtil.getTBSizeImg(
|
| | | StringUtil.isNullOrEmpty(cg.getPictureWhite()) ? cg.getPicture() : cg.getPictureWhite(),
|
| | | 220));
|
| | | TaoBaoGoodsBrief tbGoods = new TaoBaoGoodsBrief();
|
| | | if (cg.getCouponAmount() == null)
|
| | | tbGoods.setCouponAmount(new BigDecimal(0));
|
| | |
| | | volist.add(vo);
|
| | | }
|
| | |
|
| | | Long time = userInfoService.selectByPKey(uid).getCreatetime();
|
| | | if (time > TimeUtil.convertToTimeTemp("2019-01-28", "yyyy-MM-dd"))
|
| | | count++;// 计算欢迎语的数量
|
| | |
|
| | | if (volist.size() > 0 && volist.size() < Constant.PAGE_SIZE) {
|
| | | // 添加欢迎语
|
| | | UserHomeMsgVO vo = new UserHomeMsgVO();
|
| | | vo.setContent("恭喜你,成为返利券的用户\n独家优惠券帮你省钱;\n参与奖金活动帮你赚钱;\n让返利券成为你的省钱助手吧!");
|
| | | vo.setTitle("新人欢迎");
|
| | | vo.setCreateTime(getTimeDesc(now, new Date(userInfoService.getUserById(uid).getCreatetime())));
|
| | | vo.setType(UserHomeMsgVO.TYPE_WELCOME);
|
| | | volist.add(vo);
|
| | | // 创建时间在28号后的才有新人欢迎
|
| | | if (time > TimeUtil.convertToTimeTemp("2019-01-28", "yyyy-MM-dd")) {
|
| | | 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);
|
| | | }
|
| | | }
|
| | |
|
| | | JSONObject root = new JSONObject();
|
| | |
| | | out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | | userMsgReadStateService.setAllMsgRead(uid);
|
| | |
|
| | | UserMsgUnReadNum num = userMsgReadStateService.getReadStateByUid(uid);
|
| | | int totalNum = num.getTypeAccount() + num.getTypeInvite() + num.getTypeMoney() + num.getTypeOrder()
|
| | | + num.getTypeScore() + num.getTypeSystem();
|
| | | if (totalNum == 0) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "没有未读消息"));
|
| | | return;
|
| | | } else
|
| | | userMsgReadStateService.setAllMsgRead(uid);
|
| | | out.print(JsonUtil.loadTrueResult(""));
|
| | | }
|
| | |
|