/// <summary>
        /// 根据文章ID查询文章信息,用于从首页点击进入阅读文章页面,根据返回数据前端判断是否可以直接阅读或者需要遮罩付费
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public Ptcp <M_QueryArticleByIdRes> QueryArticleById(M_QueryArticleByIdReq req)
        {
            var ptcp = new Ptcp <M_QueryArticleByIdRes>();

            if (req.IsNull())
            {
                ptcp.DoResult = "非法请求";
                return(ptcp);
            }

            if (req.ArticleSysNo <= 0)
            {
                ptcp.DoResult = "文章ID错误";
                return(ptcp);
            }

            //获取当前文章信息
            var artciclInfo = DbSession.MLT.T_SelfMediaArticleRepository.QueryBy(new T_SelfMediaArticle()
            {
                SysNo    = req.ArticleSysNo,
                IsEnable = true
            }).FirstOrDefault();

            if (artciclInfo.IsNull() || artciclInfo.SysNo <= 0)
            {
                ptcp.DoResult = "未能获取到信息";
                return(ptcp);
            }

            //获取当前作者信息
            var authorInfo = DbSession.MLT.T_SelfMediaAuthorRepository.QueryBy(new T_SelfMediaAuthor()
            {
                SysNo    = artciclInfo.AuthorSysNo,
                IsEnable = true
            }).FirstOrDefault();

            if (authorInfo.IsNull() || authorInfo.SysNo <= 0)
            {
                ptcp.DoResult = "未能获取到作者信息";
                return(ptcp);
            }

            int payCount = 0;

            if (req.UserId > 0)
            {
                var payDbCount = DbSession.MLT.T_SelfMediaPayRecordRepository.QueryCountBy(new T_SelfMediaPayRecord()
                {
                    UserId       = req.UserId,
                    ArticleSysNo = artciclInfo.SysNo,
                    AuthorSysNo  = authorInfo.SysNo,
                    IsEnable     = true
                });

                payCount = Converter.ParseInt(payDbCount, 0);
            }

            var artciclCount = DbSession.MLT.T_SelfMediaArticleRepository.QueryCountBy(new T_SelfMediaArticle()
            {
                AuthorSysNo = authorInfo.SysNo,
                IsHot       = true,
                IsEnable    = true
            });

            M_ArticleEntity articleEntity = new M_ArticleEntity();

            if (payCount > 0)
            {
                articleEntity.IsRead = true;
            }

            articleEntity.ReadScore = artciclInfo.ReadScore.GetValueOrDefault();
            articleEntity.SysNo     = artciclInfo.SysNo.GetValueOrDefault();
            articleEntity.Title     = artciclInfo.Title;
            articleEntity.HeadPic   = artciclInfo.HeadPic;
            articleEntity.Subtitle  = artciclInfo.Subtitle;
            articleEntity.Content   = artciclInfo.Content;
            //articleEntity.StartDateTime = artciclInfo.StartDateTime.GetValueOrDefault();
            //articleEntity.EndDateTime = artciclInfo.EndDateTime.GetValueOrDefault();
            articleEntity.SortId          = artciclInfo.SortId.GetValueOrDefault();
            articleEntity.RowCeateDate    = artciclInfo.RowCeateDate.GetValueOrDefault();
            articleEntity.StrRowCeateDate = articleEntity.RowCeateDate.ToString("yyyy-MM-dd");

            M_AuthorEntity author = new M_AuthorEntity();

            author.AuthorSysNo     = authorInfo.SysNo.GetValueOrDefault();
            author.AuthorName      = authorInfo.AuthorName;
            author.Portrait        = authorInfo.Portrait;
            author.Describe        = authorInfo.Describe;
            author.HotArticleCount = Converter.ParseInt(artciclCount, 0);

            ptcp.ReturnValue = new M_QueryArticleByIdRes();
            ptcp.ReturnValue.ArticleEntity = articleEntity;
            ptcp.ReturnValue.AuthorEntity  = author;
            ptcp.DoFlag = PtcpState.Success;

            return(ptcp);
        }
        /// <summary>
        /// 我的关注列表
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public Ptcp <M_QueryMyFollowRes> QueryMyFollow(M_QueryMyFollowReq req)
        {
            var ptcp = new Ptcp <M_QueryMyFollowRes>();

            if (req.IsNull())
            {
                ptcp.DoResult = "非法请求";
                return(ptcp);
            }

            if (req.UserId <= 0)
            {
                ptcp.DoResult = "会员ID错误";
                return(ptcp);
            }

            //取出我的关注
            var myFollows = DbSession.MLT.T_SelfMediaFollowRecordRepository.QueryBy(new T_SelfMediaFollowRecord()
            {
                UserId   = req.UserId,
                IsFollow = true,
                IsEnable = true
            }, " ORDER BY SysNo DESC").ToList();

            if (myFollows.IsNull() || !myFollows.IsHasRow())
            {
                ptcp.DoResult = "没有关注信息";
                return(ptcp);
            }

            //取出作者
            List <int> authIdList = myFollows.Select(c => c.AuthorSysNo.GetValueOrDefault()).ToList();
            string     strAuthor  = string.Join(",", authIdList);

            string sqlArt    = string.Format(@"SELECT * FROM T_SelfMediaArticle WHERE AuthorSysNo IN ({0}) AND IsEnable = 1", strAuthor);
            string sqlPay    = string.Format(@"SELECT * FROM T_SelfMediaPayRecord WHERE UserId = {0} AND IsEnable = 1 ", req.UserId);
            string sqlAuthor = string.Format(@"SELECT * FROM T_SelfMediaAuthor WHERE SysNo IN ({0}) AND IsEnable = 1", strAuthor);

            var artList    = DbSession.MLT.ExecuteSql <T_SelfMediaArticle>(sqlArt).ToList();
            var authorList = DbSession.MLT.ExecuteSql <T_SelfMediaAuthor>(sqlAuthor).ToList();

            if (artList.IsNull() || !artList.IsHasRow() || authorList.IsNull() || !authorList.IsHasRow())
            {
                ptcp.DoResult = "没有关注信息";
                return(ptcp);
            }

            var payList = DbSession.MLT.ExecuteSql <T_SelfMediaPayRecord>(sqlPay).ToList();

            List <M_AuthorEntity> authorEntities = new List <M_AuthorEntity>();

            foreach (var myf in myFollows)
            {
                M_AuthorEntity author = new M_AuthorEntity();
                author.IsFollow = true;

                var authorInfo = authorList.Where(c => c.SysNo == myf.AuthorSysNo).FirstOrDefault();
                if (authorInfo.IsNotNull() && authorInfo.SysNo > 0)
                {
                    #region

                    author.AuthorSysNo = authorInfo.SysNo.GetValueOrDefault();
                    author.AuthorName  = authorInfo.AuthorName;
                    author.Portrait    = authorInfo.Portrait;
                    author.Describe    = authorInfo.Describe;

                    //取出当前作者的文章
                    var nowAuthorArts = artList.Where(c => c.AuthorSysNo == author.AuthorSysNo).ToList();
                    //取出当前会员已读取当前作者的文章
                    if (payList.IsNotNull() && payList.IsHasRow())
                    {
                        #region

                        var payActs = payList.Where(c => c.UserId == req.UserId && c.AuthorSysNo == author.AuthorSysNo).ToList();
                        if (payActs.IsNotNull() && payActs.IsHasRow())
                        {
                            int allCount  = nowAuthorArts.Count;
                            int readCount = payActs.Count;
                            int notCount  = allCount - readCount;
                            if (notCount <= 0)
                            {
                                author.NotReadCount    = 0;
                                author.StrNotReadCount = "0";
                            }
                            else
                            {
                                author.NotReadCount = notCount;
                                if (notCount > 9)
                                {
                                    author.StrNotReadCount = "9+";
                                }
                                else
                                {
                                    author.StrNotReadCount = notCount.ToString();
                                }
                            }
                        }
                        else
                        {
                            author.NotReadCount    = 0;
                            author.StrNotReadCount = "0";
                        }

                        #endregion
                    }
                    else
                    {
                        if (nowAuthorArts.IsNotNull() && nowAuthorArts.IsHasRow())
                        {
                            author.NotReadCount = nowAuthorArts.Count;
                            if (nowAuthorArts.Count > 9)
                            {
                                author.StrNotReadCount = "9+";
                            }
                            else
                            {
                                author.StrNotReadCount = nowAuthorArts.Count.ToString();
                            }
                        }
                        else
                        {
                            author.NotReadCount    = 0;
                            author.StrNotReadCount = "0";
                        }
                    }

                    //取出最新一个的文章标题
                    if (nowAuthorArts.IsNotNull() && nowAuthorArts.IsHasRow())
                    {
                        author.Title = nowAuthorArts.OrderByDescending(c => c.SysNo).FirstOrDefault().Title;
                    }

                    authorEntities.Add(author);

                    #endregion
                }
            }

            ptcp.ReturnValue = new M_QueryMyFollowRes();
            ptcp.ReturnValue.AuthorEntities = authorEntities;
            ptcp.DoFlag = PtcpState.Success;

            return(ptcp);
        }
        /// <summary>
        /// 查询作者下面所有的文章信息
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public Ptcp <M_QueryAuthorArticleRes> QueryAuthorArticle(M_QueryAuthorArticleReq req)
        {
            var ptcp = new Ptcp <M_QueryAuthorArticleRes>();

            if (req.IsNull())
            {
                ptcp.DoResult = "非法请求";
                return(ptcp);
            }

            if (req.AuthorSysNo <= 0)
            {
                ptcp.DoResult = "作者ID错误";
                return(ptcp);
            }

            if (req.PageIndex <= 0 || req.PageIndex > 10000)
            {
                req.PageIndex = 1;
            }

            if (req.PageSize <= 0 || req.PageSize > 100)
            {
                req.PageSize = 10;
            }

            //获取当前作者信息
            var authorInfo = DbSession.MLT.T_SelfMediaAuthorRepository.QueryBy(new T_SelfMediaAuthor()
            {
                SysNo    = req.AuthorSysNo,
                IsEnable = true
            }).FirstOrDefault();

            if (authorInfo.IsNull() || authorInfo.SysNo <= 0)
            {
                ptcp.DoResult = "未能获取到作者信息";
                return(ptcp);
            }

            //获取作者文章信息
            var artciclListCount = DbSession.MLT.T_SelfMediaArticleRepository.QueryCountBy(new T_SelfMediaArticle()
            {
                AuthorSysNo = req.AuthorSysNo,
                IsEnable    = true
            });
            var artciclList = DbSession.MLT.T_SelfMediaArticleRepository.QueryPageBy(req.PageIndex, req.PageSize, new T_SelfMediaArticle()
            {
                AuthorSysNo = req.AuthorSysNo,
                IsEnable    = true
            }, " ORDER BY SysNo DESC").ToList();

            int follow = 0;

            if (req.UserId > 0)
            {
                //是否关注
                var followDb = DbSession.MLT.T_SelfMediaFollowRecordRepository.QueryCountBy(new T_SelfMediaFollowRecord()
                {
                    UserId      = req.UserId,
                    AuthorSysNo = req.AuthorSysNo,
                    IsFollow    = true,
                    IsEnable    = true
                });

                follow = Converter.ParseInt(followDb, 0);
            }

            M_AuthorEntity author = new M_AuthorEntity();

            author.AuthorSysNo = authorInfo.SysNo.GetValueOrDefault();
            author.AuthorName  = authorInfo.AuthorName;
            author.Portrait    = authorInfo.Portrait;
            author.Describe    = authorInfo.Describe;

            if (follow > 0)
            {
                author.IsFollow = true;
            }

            List <M_ArticleEntity> articleEntities = new List <M_ArticleEntity>();

            if (artciclList.IsNotNull() && artciclList.IsHasRow())
            {
                foreach (var art in artciclList)
                {
                    M_ArticleEntity articleEntity = new M_ArticleEntity();

                    articleEntity.ReadScore       = art.ReadScore.GetValueOrDefault();
                    articleEntity.SysNo           = art.SysNo.GetValueOrDefault();
                    articleEntity.HeadPic         = art.HeadPic;
                    articleEntity.Title           = art.Title;
                    articleEntity.Subtitle        = art.Subtitle;
                    articleEntity.Content         = art.Content;
                    articleEntity.SortId          = art.SortId.GetValueOrDefault();
                    articleEntity.RowCeateDate    = art.RowCeateDate.GetValueOrDefault();
                    articleEntity.StrRowCeateDate = articleEntity.RowCeateDate.ToString("yyyy-MM-dd");

                    articleEntities.Add(articleEntity);
                }
            }

            ptcp.ReturnValue = new M_QueryAuthorArticleRes();
            ptcp.ReturnValue.ArticleEntities = articleEntities;
            ptcp.ReturnValue.AuthorEntity    = author;
            ptcp.ReturnValue.Total           = Converter.ParseInt(artciclListCount, 0);
            ptcp.DoFlag = PtcpState.Success;

            return(ptcp);
        }