public PlatMyCard GetMyCardData(int cardid, int aid) { PlatMyCard model = base.GetModel(cardid); if (model == null) { return(new PlatMyCard()); } PlatPostUserMsgCountViewMolde msgmodel = PlatPostUserBLL.SingleModel.GetCountViewModel(model.Id); if (msgmodel != null) { model.MsgCount = msgmodel.PostMsgCount; } model.ContentCount = PlatMsgCommentBLL.SingleModel.GetUserContentCount(model.UserId); model.MsgDzCount = PlatUserFavoriteMsgBLL.SingleModel.GetMyMsgCount(model.UserId, (int)PointsActionType.点赞, (int)PointsDataType.帖子); PlatMsgviewFavoriteShare smodel = PlatMsgviewFavoriteShareBLL.SingleModel.GetModelByMsgId(aid, model.Id, (int)PointsDataType.片); if (smodel != null) { model.FollowCount = smodel.FollowCount; model.FavoriteCount = smodel.FavoriteCount; model.DzCount = smodel.DzCount; model.ViewCount = smodel.ViewCount; model.SiXinCount = smodel.SiXinCount; model.NewData = GetRedisCach(model.Id); } //行业 PlatIndustry industrymodel = PlatIndustryBLL.SingleModel.GetModel(model.IndustryId); model.IndustryName = industrymodel?.Name; //店铺 PlatStore store = PlatStoreBLL.SingleModel.GetModelBycardid(model.AId, model.Id); if (store != null) { smodel = PlatMsgviewFavoriteShareBLL.SingleModel.GetModelByMsgId(aid, store.Id, (int)PointsDataType.店铺); if (smodel != null) { model.StoreFavoriteCount = smodel.FavoriteCount; model.StoreViewCount = store.StorePV + store.StoreVirtualPV; model.StoreVistorCount = PlatUserFavoriteMsgBLL.SingleModel.GetUserMsgCount(model.AId, store.Id, (int)PointsActionType.过, (int)PointsDataType.店铺); } } return(model); }
/// <summary> /// 根据用户Id也就是myCardId 获取该用户发布的帖子列表 /// </summary> /// <param name="aid"></param> /// <param name="myCardId"></param> /// <param name="totalCount"></param> /// <param name="pageSize"></param> /// <param name="pageIndex"></param> /// <returns></returns> public List <PlatMsg> GetListByUserId(int aid, int myCardId, out int totalCount, int pageSize = 10, int pageIndex = 1) { string strWhere = $"aid={aid} and state<>-1 and PayState=1 and MyCardId={myCardId}"; List <PlatMsg> listPlatMsg = base.GetList(strWhere, pageSize, pageIndex, "*", " addTime desc"); int commentTotalCount = 0; if (listPlatMsg != null && listPlatMsg.Count > 0) { string cardIds = string.Join(",", listPlatMsg.Select(s => s.MyCardId).Distinct()); List <PlatMyCard> platMyCardList = PlatMyCardBLL.SingleModel.GetListByIds(cardIds); string msgTypeIds = string.Join(",", listPlatMsg.Select(s => s.MsgTypeId).Distinct()); List <PlatMsgType> platMsgTypeList = PlatMsgTypeBLL.SingleModel.GetListByIds(msgTypeIds); listPlatMsg.ForEach(x => { //获取用户头像 PlatMyCard platMyCard = platMyCardList?.FirstOrDefault(f => f.Id == x.MyCardId); if (platMyCard != null) { x.UserName = platMyCard.Name; x.UserHeaderImg = platMyCard.ImgUrl; } //获取帖子类别 PlatMsgType platMsgType = platMsgTypeList?.FirstOrDefault(f => f.Id == x.MsgTypeId); if (platMsgType != null) { x.MsgTypeName = platMsgType.Name; } //根据帖子ID获取其浏览量-收藏量-分享量数据 PlatMsgviewFavoriteShare _platMsgviewFavoriteShare = PlatMsgviewFavoriteShareBLL.SingleModel.GetModelByMsgId(x.Aid, x.Id, (int)PointsDataType.帖子); if (_platMsgviewFavoriteShare != null) { x.ViewCount = _platMsgviewFavoriteShare.ViewCount; x.FavoriteCount = _platMsgviewFavoriteShare.FavoriteCount; x.ShareCount = _platMsgviewFavoriteShare.ShareCount; x.DzCount = _platMsgviewFavoriteShare.DzCount; } x.Comments = PlatMsgCommentBLL.SingleModel.GetPlatMsgComment(x.Aid, out commentTotalCount, 0, string.Empty, 1000, 1, x.Id, 0); x.ShowTimeStr = CommondHelper.GetTimeSpan(DateTime.Now - x.AddTime); x.MsgDetail = HttpUtility.HtmlDecode(x.MsgDetail); }); } totalCount = base.GetCount(strWhere); return(listPlatMsg); }
/// <summary> /// 获取指定帖子详情 包含了 点赞数 分享数 收藏数 浏览量等... /// </summary> /// <param name="aid"></param> /// <param name="msgId"></param> /// <returns></returns> public PlatMsg GetMsg(int aid, int msgId) { PlatMsg x = base.GetModel($"aid={aid} and Id={msgId}"); if (x != null) { //获取用户头像 PlatMyCard platMyCard = PlatMyCardBLL.SingleModel.GetModel(x.MyCardId); if (platMyCard != null) { x.UserName = platMyCard.Name; x.UserHeaderImg = platMyCard.ImgUrl; x.UserId = platMyCard.UserId; } //获取帖子类别 PlatMsgType platMsgType = PlatMsgTypeBLL.SingleModel.GetModel(x.MsgTypeId); if (platMsgType != null) { x.MsgTypeName = platMsgType.Name; } //根据帖子ID获取其浏览量-收藏量-分享量数据 PlatMsgviewFavoriteShare _platMsgviewFavoriteShare = PlatMsgviewFavoriteShareBLL.SingleModel.GetModelByMsgId(x.Aid, x.Id, (int)PointsDataType.帖子); if (_platMsgviewFavoriteShare != null) { x.ViewCount = _platMsgviewFavoriteShare.ViewCount; x.FavoriteCount = _platMsgviewFavoriteShare.FavoriteCount; x.ShareCount = _platMsgviewFavoriteShare.ShareCount; x.DzCount = _platMsgviewFavoriteShare.DzCount; } x.MsgDetail = HttpUtility.HtmlDecode(x.MsgDetail); x.ShowTimeStr = CommondHelper.GetTimeSpan(DateTime.Now - x.AddTime); } return(x); }
/// <summary> /// 获取名片,并返回我是否点赞了该名片 /// </summary> /// <param name="userid"></param> /// <param name="myuserid"></param> /// <param name="aid"></param> /// <param name="datatype"></param> /// <returns></returns> public PlatMyCard GetMyCardData(long userid, int myuserid, int aid, int datatype) { PlatMyCard model = GetModelByUserId(userid, aid); if (model == null) { return(new PlatMyCard()); } PlatMsgviewFavoriteShare smodel = PlatMsgviewFavoriteShareBLL.SingleModel.GetModelByMsgId(aid, model.Id, datatype); if (smodel == null) { return(model); } List <PlatUserFavoriteMsg> userfavoritelist = PlatUserFavoriteMsgBLL.SingleModel.GetUserFavoriteMsgList(aid, model.Id.ToString(), myuserid, (int)PointsDataType.片); if (userfavoritelist != null && userfavoritelist.Count > 0) { PlatUserFavoriteMsg userfavorite = userfavoritelist.Where(w => w.ActionType == (int)PointsActionType.收藏).FirstOrDefault(); model.IsFavorite = userfavorite?.State >= 0; userfavorite = userfavoritelist.Where(w => w.ActionType == (int)PointsActionType.关注).FirstOrDefault(); model.IsFollow = userfavorite?.State >= 0; userfavorite = userfavoritelist.Where(w => w.ActionType == (int)PointsActionType.点赞).FirstOrDefault(); model.IsDz = userfavorite?.State >= 0; } model.FollowCount = smodel.FollowCount; model.FavoriteCount = smodel.FavoriteCount; model.DzCount = smodel.DzCount; model.ViewCount = smodel.ViewCount + model.FictitiousCount; model.SiXinCount = smodel.SiXinCount; model.NewData = GetRedisCach(model.Id); return(model); }
/// <summary> /// 数据雷达 /// </summary> /// <returns></returns> public ActionResult GetRadarData() { PlatRadarReportModel radar = new PlatRadarReportModel(); returnObj = new Return_Msg_APP(); int userId = Context.GetRequestInt("userid", 0); int aid = Context.GetRequestInt("aid", 0); int type = Context.GetRequestInt("type", 0);//-1:统计,0:本月,1:上个月 if (userId <= 0) { returnObj.Msg = "userid不能为0"; return(Json(returnObj)); } PlatMyCard myCard = PlatMyCardBLL.SingleModel.GetModelByUserId(userId); if (myCard == null) { returnObj.Msg = "名片已过期"; return(Json(returnObj)); } string startTime = ""; string endTime = ""; switch (type) { case -1: break; case 0: startTime = DateTime.Now.ToString("yyyy-MM") + "-1"; endTime = DateTime.Now.AddMonths(1).ToString("yyyy-MM") + "-1"; break; case 1: startTime = DateTime.Now.AddMonths(1).ToString("yyyy-MM") + "-1"; endTime = DateTime.Now.AddMonths(2).ToString("yyyy-MM") + "-1"; break; } #region 片数据分析 //浏览量 //点赞量 //关注量 //与多少人私信 //转发量 PlatMsgviewFavoriteShare reportData = PlatMsgviewFavoriteShareBLL.SingleModel.GetModelByMsgId(aid, myCard.Id, (int)PointsDataType.片); radar.MyCardViewCount = myCard.FictitiousCount; if (reportData != null) { radar.MyCardDzCount = reportData.DzCount; radar.MyCardViewCount += reportData.ViewCount; radar.MyCardFollowCount = reportData.FollowCount; radar.MyCardShareCount = reportData.ShareCount; } radar.MyCardSiXinCount = ImMessageBLL.SingleModel.GetCountByTuesrId(userId); //访客人数 int visitorCount = PlatUserFavoriteMsgBLL.SingleModel.GetVisitorCount(myCard.Id, myCard.AId, (int)PointsDataType.片, startTime, endTime); radar.MyCardVisitorCount = visitorCount; #endregion #region 人脉关系统计 //已关注人数 int myFavoriteCount = PlatUserFavoriteMsgBLL.SingleModel.GetUserMsgCount(aid, 0, (int)PointsActionType.关注, (int)PointsDataType.片, userId); radar.FollowCount = myFavoriteCount; //粉丝人数 int fanCount = PlatUserFavoriteMsgBLL.SingleModel.GetUserMsgCount(aid, myCard.Id, (int)PointsActionType.关注, (int)PointsDataType.片, 0); radar.FanCount = fanCount; //相互关注人数 radar.MutualFollowCount = PlatUserFavoriteMsgBLL.SingleModel.GetMutualFollowCount(aid, userId); #endregion #region 平台入驻店铺数据统计 PlatStore storeModel = PlatStoreBLL.SingleModel.GetPlatStore(myCard.Id, 1); if (storeModel != null) { //浏览量 radar.StoreViewCount = storeModel.StorePV + storeModel.StoreVirtualPV; //收藏数 List <PlatUserFavoriteMsg> storelist = PlatUserFavoriteMsgBLL.SingleModel.GetReportData(storeModel.Id, myCard.AId, (int)PointsDataType.店铺, startTime, endTime); if (storelist != null && storelist.Count > 0) { PlatUserFavoriteMsg tempmodel = storelist.Where(w => w.ActionType == (int)PointsActionType.收藏).FirstOrDefault(); radar.StoreFavoriteCount = tempmodel == null ? 0 : tempmodel.Count; } //访客人数 int storeVisitorCount = PlatUserFavoriteMsgBLL.SingleModel.GetVisitorCount(storeModel.Id, myCard.AId, (int)PointsDataType.店铺, startTime, endTime); radar.StoreVisitorCount = storeVisitorCount; } #endregion returnObj.isok = true; returnObj.dataObj = radar; return(Json(returnObj)); }
/// <summary> /// 获取帖子列表 排列顺序为 置顶未失效>时间降序 /// 然后再到前端进行排序 如果时间按照最近则不需要排序 /// 如果是按距离则再排一次先是置顶的然后 距离有限 再按时间降序 /// </summary> /// <param name="aid"></param> /// <param name="totalCount"></param> /// <param name="pageSize"></param> /// <param name="pageIndex"></param> /// <returns></returns> public List <PlatMsg> GetListMsg(int aid, out int totalCount, string keyMsg = "", int msgTypeId = 0, int pageSize = 10, int pageIndex = 1, int orderType = 0, double ws_lat = 0, double ws_lng = 0) { string strWhere = $" aid={aid} and state=1 and PayState=1 "; if (msgTypeId > 0) { strWhere += $" and MsgTypeId={msgTypeId} "; } List <MySqlParameter> parameters = new List <MySqlParameter>(); if (!string.IsNullOrEmpty(keyMsg)) { strWhere += $" and msgDetail like @keyMsg "; parameters.Add(new MySqlParameter("keyMsg", $"%{keyMsg}%")); } totalCount = base.GetCount(strWhere, parameters.ToArray()); string sql = $@"SELECT * FROM( SELECT * FROM (SELECT *,(DATE_ADD(ReviewTime,INTERVAL topDay DAY)-now()) as tspan from platmsg where (DATE_ADD(ReviewTime,INTERVAL topDay DAY)-now())>0 and { strWhere} ORDER BY addtime desc LIMIT 100000)t1 UNION SELECT* FROM( SELECT*, (DATE_ADD(ReviewTime, INTERVAL topDay DAY)-now()) as tspan from platmsg where (DATE_ADD(ReviewTime, INTERVAL topDay DAY) - now()) <= 0 and { strWhere} ORDER BY addtime desc LIMIT 100000) t2 ) t3 limit {(pageIndex - 1) * pageSize},{pageSize}"; if (orderType > 0) {//表示附近 sql = $@"SELECT * FROM( SELECT * FROM (SELECT *,(DATE_ADD(ReviewTime,INTERVAL topDay DAY)-now()) as tspan,ROUND(6378.138*2*ASIN(SQRT(POW(SIN(({ws_lat}*PI()/180-lat*PI()/180)/2),2)+COS({ws_lat}*PI()/180)*COS(lat*PI()/180)*POW(SIN(({ws_lng}*PI()/180-lng*PI()/180)/2),2)))*1000) AS distance from platmsg where (DATE_ADD(ReviewTime,INTERVAL topDay DAY)-now())>0 and { strWhere} ORDER BY distance asc,addtime desc LIMIT 100000)t1 UNION SELECT* FROM( SELECT*, (DATE_ADD(ReviewTime, INTERVAL topDay DAY)-now()) as tspan,ROUND(6378.138*2*ASIN(SQRT(POW(SIN(({ws_lat}*PI()/180-lat*PI()/180)/2),2)+COS({ws_lat}*PI()/180)*COS(lat*PI()/180)*POW(SIN(({ws_lng}*PI()/180-lng*PI()/180)/2),2)))*1000) AS distance from platmsg where (DATE_ADD(ReviewTime, INTERVAL topDay DAY) - now()) <= 0 and { strWhere} ORDER BY distance asc, addtime desc LIMIT 100000) t2 ) t3 limit {(pageIndex - 1) * pageSize},{pageSize}"; } // log4net.LogHelper.WriteInfo(this.GetType(),sql); List <PlatMsg> listPlatMsg = base.GetListBySql(sql, parameters.ToArray()); if (listPlatMsg != null && listPlatMsg.Count > 0) { string cardIds = string.Join(",", listPlatMsg.Select(s => s.MyCardId).Distinct()); List <PlatMyCard> platMyCardList = PlatMyCardBLL.SingleModel.GetListByIds(cardIds); string msgTypeIds = string.Join(",", listPlatMsg.Select(s => s.MsgTypeId).Distinct()); List <PlatMsgType> platMsgTypeList = PlatMsgTypeBLL.SingleModel.GetListByIds(msgTypeIds); listPlatMsg.ForEach(x => { //获取用户头像 PlatMyCard platMyCard = platMyCardList?.FirstOrDefault(f => f.Id == x.MyCardId); if (platMyCard != null) { x.UserName = platMyCard.Name; x.UserHeaderImg = platMyCard.ImgUrl; x.UserId = platMyCard.UserId; } //获取帖子类别 PlatMsgType platMsgType = platMsgTypeList?.FirstOrDefault(f => f.Id == x.MsgTypeId); if (platMsgType != null) { x.MsgTypeName = platMsgType.Name; } //根据帖子ID获取其浏览量-收藏量-分享量数据 PlatMsgviewFavoriteShare _platMsgviewFavoriteShare = PlatMsgviewFavoriteShareBLL.SingleModel.GetModelByMsgId(x.Aid, x.Id, (int)PointsDataType.帖子); if (_platMsgviewFavoriteShare != null) { x.ViewCount = _platMsgviewFavoriteShare.ViewCount; x.FavoriteCount = _platMsgviewFavoriteShare.FavoriteCount; x.ShareCount = _platMsgviewFavoriteShare.ShareCount; x.DzCount = _platMsgviewFavoriteShare.DzCount; } x.ShowTimeStr = CommondHelper.GetTimeSpan(DateTime.Now - x.AddTime); x.MsgDetail = HttpUtility.HtmlDecode(x.MsgDetail); }); } totalCount = base.GetCount(strWhere, parameters.ToArray()); return(listPlatMsg); }
/// <summary> /// 获取用户收藏帖子列表 /// </summary> /// <param name="aid"></param> /// <param name="userId"></param> /// <param name="totalCount"></param> /// <param name="pageSize"></param> /// <param name="pageIndex"></param> /// <returns></returns> public List <PlatMsg> GetListMyFavoriteMsg(int aid, int myCardId, out int totalCount, int pageSize = 10, int pageIndex = 1) { string strWhere = $"aid={aid} and userId={myCardId} and state=0 and actionType={(int)PointsActionType.收藏} and Datatype={(int)PointsDataType.帖子}"; totalCount = base.GetCount(strWhere); List <PlatMsg> listPlatMsg = new List <PlatMsg>(); List <PlatUserFavoriteMsg> listPlatUserFavoriteMsg = base.GetList(strWhere, pageSize, pageIndex, "*", "addTime desc"); if (listPlatUserFavoriteMsg != null && listPlatUserFavoriteMsg.Count > 0) { List <string> listMsgId = new List <string>(); foreach (var item in listPlatUserFavoriteMsg) { listMsgId.Add(item.MsgId.ToString());//获取到需要获取帖子的Id } if (listMsgId != null && listMsgId.Count > 0) { listPlatMsg = PlatMsgBLL.SingleModel.GetListByIds(aid, string.Join(",", listMsgId.ToArray())); if (listPlatMsg != null && listPlatMsg.Count > 0) { string cardIds = string.Join(",", listPlatMsg.Select(s => s.MyCardId).Distinct()); List <PlatMyCard> platMyCardList = PlatMyCardBLL.SingleModel.GetListByIds(cardIds); string msgTypeIds = string.Join(",", listPlatMsg.Select(s => s.MsgTypeId).Distinct()); List <PlatMsgType> platMsgTypeList = PlatMsgTypeBLL.SingleModel.GetListByIds(msgTypeIds); listPlatMsg.ForEach(x => { //获取用户头像 PlatMyCard platMyCard = platMyCardList?.FirstOrDefault(f => f.Id == x.MyCardId); if (platMyCard != null) { x.UserName = platMyCard.Name; x.UserHeaderImg = platMyCard.ImgUrl; } //获取帖子类别 PlatMsgType platMsgType = platMsgTypeList?.FirstOrDefault(f => f.Id == x.MsgTypeId); if (platMsgType != null) { x.MsgTypeName = platMsgType.Name; } //根据帖子ID获取其浏览量-收藏量-分享量数据 PlatMsgviewFavoriteShare _platMsgviewFavoriteShare = PlatMsgviewFavoriteShareBLL.SingleModel.GetModelByMsgId(x.Aid, x.Id, (int)PointsDataType.帖子); if (_platMsgviewFavoriteShare != null) { x.ViewCount = _platMsgviewFavoriteShare.ViewCount; x.FavoriteCount = _platMsgviewFavoriteShare.FavoriteCount; x.ShareCount = _platMsgviewFavoriteShare.ShareCount; x.DzCount = _platMsgviewFavoriteShare.DzCount; } x.ShowTimeStr = CommondHelper.GetTimeSpan(DateTime.Now - x.AddTime); x.FavoriteId = listPlatUserFavoriteMsg.FirstOrDefault(y => y.MsgId == x.Id).Id;//收藏记录ID }); } } } return(listPlatMsg); }
public string CommondFavoriteMsg(int aid, int othercardid, int userid, int actiontype, int datatype, ref int curState) { int count = 1; PlatUserFavoriteMsg platUserFavoriteMsgModel = GetUserFavoriteMsg(aid, othercardid, userid, actiontype, datatype); if (platUserFavoriteMsgModel == null) { platUserFavoriteMsgModel = new PlatUserFavoriteMsg(); platUserFavoriteMsgModel.ActionType = actiontype; platUserFavoriteMsgModel.AddTime = DateTime.Now; platUserFavoriteMsgModel.AId = aid; platUserFavoriteMsgModel.Datatype = datatype; platUserFavoriteMsgModel.MsgId = othercardid; platUserFavoriteMsgModel.State = 0; platUserFavoriteMsgModel.UserId = userid; } else if (platUserFavoriteMsgModel.State == -1) { platUserFavoriteMsgModel.State = 0; } else if (platUserFavoriteMsgModel.State == 0)//取消 { platUserFavoriteMsgModel.State = -1; count = -1; } curState = platUserFavoriteMsgModel.State; PlatMsgviewFavoriteShare platmsgviewModel = PlatMsgviewFavoriteShareBLL.SingleModel.GetModelByMsgId(aid, othercardid, datatype); if (platmsgviewModel == null) { platmsgviewModel = new PlatMsgviewFavoriteShare(); platmsgviewModel.AddTime = DateTime.Now; platmsgviewModel.AId = aid; platmsgviewModel.DataType = datatype; platmsgviewModel.DzCount = 0; platmsgviewModel.FavoriteCount = 0; platmsgviewModel.FollowCount = 0; platmsgviewModel.MsgId = othercardid; platmsgviewModel.ShareCount = 0; platmsgviewModel.SiXinCount = 0; platmsgviewModel.ViewCount = 0; platmsgviewModel.Id = Convert.ToInt32(PlatMsgviewFavoriteShareBLL.SingleModel.Add(platmsgviewModel)); } switch (actiontype) { case (int)PointsActionType.关注: platmsgviewModel.FollowCount += count; break; case (int)PointsActionType.收藏: platmsgviewModel.FavoriteCount += count; break; case (int)PointsActionType.点赞: platmsgviewModel.DzCount += count; break; case (int)PointsActionType.过: platmsgviewModel.ViewCount += 1; break; case (int)PointsActionType.私信: platmsgviewModel.SiXinCount += 1; break; case (int)PointsActionType.转发: platmsgviewModel.ShareCount += 1; break; } PlatMsgviewFavoriteShareBLL.SingleModel.Update(platmsgviewModel); if (platUserFavoriteMsgModel.Id > 0) { if (actiontype != (int)PointsActionType.转发 && actiontype != (int)PointsActionType.过 && actiontype != (int)PointsActionType.私信) { platUserFavoriteMsgModel.AddTime = DateTime.Now; base.Update(platUserFavoriteMsgModel, "State,AddTime"); } } else { platUserFavoriteMsgModel.Id = Convert.ToInt32(base.Add(platUserFavoriteMsgModel)); if (platUserFavoriteMsgModel.Id <= 0) { return("操作失效"); } } if (datatype == (int)PointsDataType.片 && platUserFavoriteMsgModel.State >= 0) { PlatMyCardBLL.SingleModel.RefleshCach(othercardid, actiontype, true); } if (datatype == (int)PointsDataType.片 || datatype == (int)PointsDataType.帖子) { //添加活动轨迹 PlatActivityTrajectoryBLL.SingleModel.AddData(aid, userid, othercardid, actiontype, datatype); } return(""); }