Example #1
0
        /// <summary>
        /// 批量更新排序
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>

        public ActionResult SaveMsgTypeSort(List <PlatMsgType> list)
        {
            result = new PlatReturnMsg();

            if (list == null || list.Count <= 0)
            {
                result.Msg = "数据不能为空";
                return(Json(result));
            }
            PlatMsgType        model           = new PlatMsgType();
            TransactionModel   tranModel       = new TransactionModel();
            string             sql             = string.Empty;
            string             msgTypeIds      = string.Join(",", list.Select(s => s.Id));
            List <PlatMsgType> platMsgTypeList = PlatMsgTypeBLL.SingleModel.GetListByIds(msgTypeIds);

            foreach (PlatMsgType item in list)
            {
                model = platMsgTypeList?.FirstOrDefault(f => f.Id == item.Id);
                if (model == null)
                {
                    result.Msg = $"Id={item.Id}不存在数据库里";
                    return(Json(result));
                }

                if (model.Aid != item.Aid)
                {
                    result.Msg = $"Id={item.Id}权限不足";
                    return(Json(result));
                }


                model.SortNumber = item.SortNumber;
                model.UpdateTime = DateTime.Now;
                sql = PlatMsgTypeBLL.SingleModel.BuildUpdateSql(model, "SortNumber,UpdateTime");
                tranModel.Add(sql);
            }

            if (tranModel.sqlArray != null && tranModel.sqlArray.Length > 0)
            {
                if (PlatMsgTypeBLL.SingleModel.ExecuteTransactionDataCorect(tranModel.sqlArray))
                {
                    result.isok = true;
                    result.Msg  = "操作成功";
                    return(Json(result));
                }
                else
                {
                    result.Msg = "操作失败";
                    return(Json(result));
                }
            }
            else
            {
                result.Msg = "没有需要更新的数据";
                return(Json(result));
            }
        }
Example #2
0
        /// <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);
        }
Example #3
0
        /// <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);
        }
Example #4
0
        /// <summary>
        /// 类别名称是否存在
        /// </summary>
        /// <returns></returns>

        public ActionResult CheckMsgTypeName()
        {
            result = new PlatReturnMsg();
            int    appId       = Utility.IO.Context.GetRequestInt("appId", 0);
            int    Id          = Utility.IO.Context.GetRequestInt("Id", 0);
            string msgTypeName = Utility.IO.Context.GetRequest("msgTypeName", string.Empty);

            if (appId <= 0 || string.IsNullOrEmpty(msgTypeName))
            {
                result.Msg = "参数错误";
                return(Json(result));
            }

            PlatMsgType model = PlatMsgTypeBLL.SingleModel.msgTypeNameIsExist(appId, msgTypeName);

            if (model != null && model.Id != Id)
            {
                result.Msg = "类别名称已存在";
                return(Json(result));
            }
            result.isok = true;
            result.Msg  = "ok";
            return(Json(result));
        }
Example #5
0
        /// <summary>
        /// 获取帖子列表 后台数据用
        /// </summary>
        /// <param name="aid"></param>
        /// <param name="totalCount"></param>
        /// <param name="isTop"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <param name="msgTypeName"></param>
        /// <param name="userName"></param>
        /// <param name="userPhone"></param>
        /// <param name="orderWhere"></param>
        /// <param name="Review">-2表示全部</param>
        /// <returns></returns>
        public List <PlatMsg> GetListByaid(int aid, out int totalCount, int isTop = 0, int pageSize = 10, int pageIndex = 1, string msgTypeName = "", string userName = "", string userPhone = "", string orderWhere = "addTime desc", int Review = -2, int isFromStore = -1)
        {
            string strWhere = $"aid={aid} and state<>-1 and PayState=1";

            if (isTop == 0)
            {
                //表示普通信息 非置顶信息
                strWhere += " and topDay=0 and isTop=0";
            }
            if (isTop == 1)
            {
                strWhere += $" and (topDay>0 or isTop=1) ";//置顶信息
            }


            if (Review != -2)
            {
                strWhere += $" and Review={Review} ";
            }



            #region 根据类别名称查询类别
            List <PlatMsgType> listMsgType = new List <PlatMsgType>();

            if (!string.IsNullOrEmpty(msgTypeName))
            {
                //类别
                int        count   = 0;
                string     typeIds = string.Empty;
                List <int> listIds = new List <int>();
                listMsgType = PlatMsgTypeBLL.SingleModel.getListByaid(aid, out count, 1000, 1, msgTypeName);
                if (listMsgType != null && listMsgType.Count > 0)
                {
                    listIds.AddRange(listMsgType.Select(x => x.Id));
                }
                else
                {
                    listIds.Add(0);
                }
                typeIds = string.Join(",", listIds);
                if (!string.IsNullOrEmpty(typeIds))
                {
                    strWhere += $" and msgTypeId in ({typeIds})";
                }
            }
            #endregion

            #region 根据用户昵称模糊匹配用户列表
            List <PlatMyCard> listPlatMyCard = new List <PlatMyCard>();
            if (!string.IsNullOrEmpty(userName))
            {
                string     platMyCardIds   = string.Empty;
                List <int> listIds         = new List <int>();
                int        platMyCardCount = 0;
                listPlatMyCard = PlatMyCardBLL.SingleModel.GetDataList(aid, ref platMyCardCount, userName);
                if (listPlatMyCard != null && listPlatMyCard.Count > 0)
                {
                    //  log4net.LogHelper.WriteInfo(this.GetType(), $"listUserInfo={listUserInfo.Count}");
                    listIds.AddRange(listPlatMyCard.Select(x => x.Id));
                }
                else
                {
                    listIds.Add(0);
                }

                platMyCardIds = string.Join(",", listIds);
                if (!string.IsNullOrEmpty(platMyCardIds))
                {
                    strWhere += $" and mycardid in ({platMyCardIds})";
                }
            }
            #endregion

            List <MySqlParameter> parameters = new List <MySqlParameter>();

            if (!string.IsNullOrEmpty(userPhone))
            {
                parameters.Add(new MySqlParameter("@userPhone", $"%{userPhone}%"));
                strWhere += " and phone like @userPhone";
            }

            totalCount = base.GetCount(strWhere, parameters.ToArray());
            // log4net.LogHelper.WriteInfo(this.GetType(), strWhere);
            List <PlatMsg> listPlatMsg = base.GetListByParam(strWhere, parameters.ToArray(), pageSize, pageIndex, "*", orderWhere);
            if (listPlatMsg != null && listPlatMsg.Count > 0)
            {
                listPlatMsg.ForEach(x =>
                {
                    if (listPlatMyCard != null && listPlatMyCard.Count > 0)
                    {
                        x.UserName      = listPlatMyCard.FirstOrDefault(u => u.Id == x.MyCardId).Name;
                        x.UserHeaderImg = listPlatMyCard.FirstOrDefault(u => u.Id == x.MyCardId).ImgUrl;
                    }
                    else
                    {
                        PlatMyCard platMyCard = PlatMyCardBLL.SingleModel.GetModel(x.MyCardId);
                        if (platMyCard != null)
                        {
                            x.UserName      = platMyCard.Name;
                            x.UserHeaderImg = platMyCard.ImgUrl;
                        }
                    }

                    if (listMsgType != null && listMsgType.Count > 0)
                    {
                        x.MsgTypeName = listMsgType.FirstOrDefault(t => t.Id == x.MsgTypeId).Name;
                    }
                    else
                    {
                        PlatMsgType platMsgType = PlatMsgTypeBLL.SingleModel.GetModel(x.MsgTypeId);
                        if (platMsgType != null)
                        {
                            x.MsgTypeName = platMsgType.Name;
                        }
                    }
                    x.MsgDetail = HttpUtility.HtmlDecode(x.MsgDetail);

                    if (isFromStore != -1)
                    {
                        x.MsgDetail = x.MsgDetail.Length > 10 ? x.MsgDetail.Substring(0, 10) + "..." : x.MsgDetail;
                    }
                });
            }

            return(listPlatMsg);
        }
Example #6
0
        /// <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);
        }
Example #7
0
        /// <summary>
        /// 编辑或者新增 信息分类
        /// </summary>
        /// <param name="city_Storemsgrules"></param>
        /// <returns></returns>

        public ActionResult SaveMsgType(PlatMsgType platMsgType)
        {
            result = new PlatReturnMsg();
            if (platMsgType == null)
            {
                result.Msg = "数据不能为空";
                return(Json(result));
            }

            if (platMsgType.Aid <= 0)
            {
                result.Msg = "appId非法";
                return(Json(result));
            }



            int Id = platMsgType.Id;

            if (Id == 0)
            {
                //表示新增
                Id = Convert.ToInt32(PlatMsgTypeBLL.SingleModel.Add(new PlatMsgType()
                {
                    MaterialPath = platMsgType.MaterialPath,
                    Name         = platMsgType.Name,
                    AddTime      = DateTime.Now,
                    UpdateTime   = DateTime.Now,
                    Aid          = platMsgType.Aid,
                    State        = 0,
                    SortNumber   = platMsgType.SortNumber
                }));
                if (Id > 0)
                {
                    result.isok = true;
                    result.Msg  = "新增成功";
                    return(Json(result));
                }
                else
                {
                    result.Msg = "新增失败";
                    return(Json(result));
                }
            }
            else
            {
                //表示更新
                PlatMsgType model = PlatMsgTypeBLL.SingleModel.GetModel(Id);
                if (model == null)
                {
                    result.Msg = "不存在数据库里";
                    return(Json(result));
                }

                if (model.Aid != platMsgType.Aid)
                {
                    result.Msg = "权限不足";
                    return(Json(result));
                }
                model.UpdateTime   = DateTime.Now;
                model.MaterialPath = platMsgType.MaterialPath;
                model.Name         = platMsgType.Name;
                model.SortNumber   = platMsgType.SortNumber;
                if (PlatMsgTypeBLL.SingleModel.Update(model, "updateTime,materialPath,name,sortNumber"))
                {
                    result.isok = true;
                    result.Msg  = "更新成功";
                    return(Json(result));
                }
                else
                {
                    result.Msg = "更新失败";
                    return(Json(result));
                }
            }
        }
Example #8
0
        /// <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);
        }