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); }
public List <PlatUserFavoriteMsg> GetMyCardUserFavoriteList(string appid, string lng, string lat, int myuserid, int type, int aid, int msgid, int actiontype, int datatype, int pageindex, int pagesize, ref int count) { PlatMyCardBLL.SingleModel.RefleshCach(msgid, actiontype, false); string sql = $"select f.*,m.imgurl,m.jobtype,m.Name cardname,m.Address cardaddress,m.Lat cardlat,m.Lng cardlng,m.Phone cardphone,m.CompanyName cardcompanyname,m.Job cardjob,m.Department carddepartment,m.IndustryId cardindustryid,m.HiddenPhone cardhiddenphone,f.userid carduserid,GetDistance({lng},{lat},m.lng,m.lat) distance from PlatUserFavoriteMsg f left join platmycard m on f.userid=m.userid "; string sqlcount = $"select Count(*) from PlatUserFavoriteMsg f left join platmycard m on f.userid=m.userid"; string sqlwhere = $" where f.aid={aid} and f.state=0 and f.datatype={datatype} and f.actiontype={actiontype} and m.appid='{appid}'"; string sqllimit = $" LIMIT {(pageindex - 1) * pagesize},{pagesize} "; string sqlorderby = " order by f.addtime desc "; if (type == 0) { sqlwhere += $" and f.msgid={msgid}"; } else { sqlwhere += $" and f.userid={myuserid}"; } List <PlatUserFavoriteMsg> list = new List <PlatUserFavoriteMsg>(); count = base.GetCountBySql(sqlcount + sqlwhere); if (count <= 0) { return(list); } using (MySqlDataReader dr = SqlMySql.ExecuteDataReaderMaster(connName, CommandType.Text, sql + sqlwhere + sqlorderby + sqllimit, null)) { while (dr.Read()) { PlatUserFavoriteMsg model = base.GetModel(dr); model.AddTimeStr = DateHelper.GetDateTimeFormat(model.AddTime); PlatMyCard mycard = new PlatMyCard(); if (type == 1) { if (dr["msgid"] != DBNull.Value) { mycard = PlatMyCardBLL.SingleModel.GetModel(Convert.ToInt32(dr["msgid"].ToString())); } if (mycard == null) { continue; } } else { mycard.UserId = model.UserId; } mycard = PlatMyCardBLL.SingleModel.GetMyCardData(mycard.UserId, myuserid, aid, datatype); if (DBNull.Value != dr["distance"]) { int tempdistance = Convert.ToInt32(dr["distance"]); mycard.Distance = DataHelper.GetDistanceFormat(tempdistance, 1); } else { mycard.Distance = "0m"; } model.MyCardModel = mycard; list.Add(model); } } if (list == null || list.Count <= 0) { return(list); } //行业 string industryids = string.Join(",", list.Select(s => s.MyCardModel.IndustryId).Distinct()); List <PlatIndustry> platIndustrylist = PlatIndustryBLL.SingleModel.GetListByIds(industryids); string cardids = string.Join(",", list.Select(s => s.MyCardModel.Id).Distinct()); List <PlatStore> platstorelist = PlatStoreBLL.SingleModel.GetListByCardId(cardids); foreach (PlatUserFavoriteMsg item in list) { PlatStore store = platstorelist?.FirstOrDefault(f => f.MyCardId == item.MyCardModel.Id); item.MyCardModel.StoreId = store != null ? store.Id : 0; PlatIndustry industryitem = platIndustrylist?.FirstOrDefault(f => f.Id == item.MyCardModel.IndustryId); if (industryitem != null) { item.MyCardModel.IndustryName = industryitem.Name; } } return(list); }