public Respbase <FriMessageCollection> GetMsg(ReqGetMsg req) { FriFacade facade = new FriFacade(); var result = facade.GetMsg(req); return(new Respbase <FriMessageCollection> { Message = facade.PromptInfo.Message, Result = facade.PromptInfo.Result, Data = result }); }
/// <summary> /// 获取信友圈-根据用户查询 /// </summary> /// <param name="req"></param> /// <returns></returns> public FriMessageCollection GetMsg(ReqGetMsg req) { FriMessageCollection result = new FriMessageCollection(); TnetReginfo regInfo = db.TnetReginfoSet.Find(req.Snodeid); if (regInfo == null) { Alert("用户不存在"); return(null); } //当前用户是否是查看用户好友 List <TchatFriend> friList = db.TchatFriendSet.Where(c => c.Friendstatus == 1 && (c.Mynodeid == req.Nodeid || c.Friendnodeid == req.Nodeid)).ToList(); //查看用户是达人时不是好友也可以查看他的朋友圈 var user = db.TnetReginfoSet.Where(c => c.Nodeid == req.Snodeid).FirstOrDefault(); if ((user?.Isenterprise != 3 && user?.Isenterprise != 4)) { if (!(friList.Select(a => a.Mynodeid).Contains(req.Snodeid) || friList.Select(a => a.Friendnodeid).Contains(req.Snodeid))) { Alert("请添加好友再查看该用户信友圈"); return(null); } } var query = from msg in db.TpxinMessageSet join tp in db.TpxinPayhisSet.Where(a => a.Nodeid == req.Nodeid) on msg.Infoid equals tp.Infoid into tp_join from tp in tp_join.DefaultIfEmpty() join tp2 in db.TpxinPraiseSet.Where(a => a.Fromnodeid == req.Nodeid) on msg.Infoid equals tp2.Infoid into tp2_join from tp2 in tp2_join.DefaultIfEmpty() where msg.Nodeid == req.Snodeid && msg.Status == 1 select new MessageDto { Commentnum = msg.Commentnum, Createtime = msg.Createtime, Down = msg.Down, Infoid = msg.Infoid, Up = msg.Up, Nodeid = msg.Nodeid, Localnodeid = req.Nodeid, Ispay = (msg.Nodeid == req.Nodeid || msg.Price == 0 || (tp != null && tp.Hisid > 0)) ? 1 : 0, IsUp = (tp2.Fromnodeid == req.Nodeid && tp2.Tonodeid == msg.Nodeid && tp2.Status == 1) ? 1 : 0, IsDown = (tp2.Fromnodeid == req.Nodeid && tp2.Tonodeid == msg.Nodeid && tp2.Status == -1) ? 1 : 0, Reward = tp2 == null ? 0 : tp2.Reward, Price = (msg.Nodeid == req.Nodeid || msg.Price == 0 || (tp != null && tp.Hisid > 0)) ? 0 : msg.Price, Content = (msg.Nodeid == req.Nodeid || msg.Price == 0 || (tp != null && tp.Hisid > 0)) ? msg.Content : (msg.Content.Substring(0, 5) + "..."), Video = (msg.Nodeid == req.Nodeid || msg.Price == 0 || (tp != null && tp.Hisid > 0)) ? msg.Video : "", Sound = (msg.Nodeid == req.Nodeid || msg.Price == 0 || (tp != null && tp.Hisid > 0)) ? msg.Sound : "", Picurl = (msg.Nodeid == req.Nodeid || msg.Price == 0 || (tp != null && tp.Hisid > 0)) ? msg.Picurl : "" }; result.Messages = query.OrderByDescending(a => a.Createtime).Skip(req.PageSize * (req.PageIndex - 1)).Take(req.PageSize).ToList();//进行分页 int[] infos = result.Messages.Select(a => a.Infoid).ToArray(); int[] mynodeids = friList.Select(a => a.Mynodeid).ToArray(); int[] Friendnodeids = friList.Select(a => a.Friendnodeid).ToArray(); var queryComment = from comment in db.TpxinCommentHisSet join msg in db.TpxinMessageSet on comment.Infoid equals msg.Infoid where infos.Contains(msg.Infoid) && (mynodeids.Contains(comment.Nodeid) || Friendnodeids.Contains(comment.Nodeid)) orderby comment.Createtime ascending select new CommentDto { Content = comment.Content, Createtime = comment.Createtime, Hisid = comment.Hisid, Infoid = comment.Infoid, Nodeid = comment.Nodeid, Phisid = comment.Phisid, Pnodeid = comment.Pnodeid }; result.Comments = queryComment.ToList(); return(result); }