Ejemplo n.º 1
0
        public string GetCultivateDetail(dynamic requestData)
        {
            CultivateVisit cuVisit = JsonConvert.DeserializeObject <CultivateVisit>(JsonConvert.SerializeObject(requestData));

            //先增加看过数量

            db.CultivateVisit.Add(cuVisit);

            var sql = string.Format(@"Update CultivateInterflow set VisitCount=VisitCount+1 where CuInterId={0}", cuVisit.CuInterId);

            dataContext.ExecuteNonQuery(CommandType.Text, sql);



            //查询活动基本信息

            var qtest = (from v in db.CultivatePraise
                         where v.OpenId == cuVisit.OpenId
                         select v);

            var q = (from v in db.CultivateInterflow
                     join p in qtest on v.CuInterId equals p.CuInterId into temp
                     from tt in temp.DefaultIfEmpty()
                     where v.CuInterId == cuVisit.CuInterId
                     select new
            {
                CuInterId = v.CuInterId,
                CurriculumType = v.CurriculumType,
                Url = v.Url,
                Introduce = v.Introduce,
                CurriculumName = v.CurriculumName,
                PraiseCount = v.PraiseCount,
                VisitCount = v.VisitCount,
                CreateTime = v.CreateTime,
                IsPraise = tt.Id == null ? "f" : "t"
            }).FirstOrDefault();


            //活动下面带的讲师
            var qLecturer = (from v in db.Lecturer
                             where v.CuInterId == cuVisit.CuInterId
                             select new {
                LecturerId = v.LecturerId,
                HeadPicUrl = v.HeadPicUrl,
                LecturerName = v.LecturerName,
                Post = v.Post,
                HotelName = v.HotelName
            });


            return("{\"Cultivate\":" + JsonConvert.SerializeObject(q, DateTimeConvent.DateTimedd()) + ",\"Lecturer\":" + JsonConvert.SerializeObject(qLecturer) + "}");
        }
Ejemplo n.º 2
0
        public string GetChefByMBIdCAId(int mbId, int caId)
        {
            var q = (from v in db.Chef
                     join p in db.MatchRegion on v.MatchRegionId equals p.MatchRegionId
                     where v.MemberId == mbId && v.ChefActivityId == caId
                     select new
            {
                ChefId = v.ChefId,
                MemberId = v.MemberId,
                ChefActivityId = v.ChefActivityId,
                MatchRegionId = v.MatchRegionId,
                AreaName = p.AreaName,
                ApplyType = v.ApplyType,
                ReferrerName = v.ReferrerName,
                Birthday = v.Birthday,
                ChefPicUrl = v.ChefPicUrl,
                //ChefHotelName = v.ChefHotelName,
                ChefHotelPicUrl = v.ChefHotelPicUrl
            });

            return(JsonConvert.SerializeObject(q, DateTimeConvent.DateTimedd()));
        }
Ejemplo n.º 3
0
        public string GetMyTrack(dynamic requestData)
        {
            string openId    = JsonConvert.DeserializeObject <string>(JsonConvert.SerializeObject(requestData.OpenId));
            int    memeberId = JsonConvert.DeserializeObject <int>(JsonConvert.SerializeObject(requestData.MemberId));
            int    pageIndex = JsonConvert.DeserializeObject <int>(JsonConvert.SerializeObject(requestData.pageIndex));

            string keyword = JsonConvert.DeserializeObject <string>(JsonConvert.SerializeObject(requestData.KeyWord));



            string sql = string.Format(@"select * from 
 (
 select '知味报名' as module,c.CreateTime as CreateTime,CA.ChefActivityName  as Name from Chef as c join ChefActivity as CA on c.ChefActivityId=CA.ChefActivityId  where MemberId={0}

 union all
 select '菜品投票' as   module ,DSL.CreateTime as CreateTime , CA.ChefActivityName as Name from  DishSelectedLog as DSL join ChefActivity as CA on DSL.ChefActivityId=CA.ChefActivityId where OpenId='{1}'

 ) as a where  1=1 ", memeberId, openId);

            if (!string.IsNullOrEmpty(keyword))
            {
                sql += "and a.module like '%" + keyword + "%' or a.Name like '%" + keyword + "%' ";
            }


            var q     = dataContext.ExecuteDataTable(CommandType.Text, sql);
            var count = q.Rows.Count;

            if (pageIndex <= 0 || string.IsNullOrEmpty(keyword))
            {
                pageIndex = 1;
            }

            var lastq = imgHandle.GetPagedTable(q, pageIndex, 10);

            return("{ \"Count\":\"" + count + "\",\"data\":" + JsonConvert.SerializeObject(lastq, DateTimeConvent.DateTimedd()) + "}");
        }
        public string GetSignin(dynamic requestData)
        {
            #region 最近7天签到情况
            int MemberId = JsonConvert.DeserializeObject <int>(JsonConvert.SerializeObject(requestData.MemberId));
            var datatime = DateTime.Today;
            List <SigninCreditLog> listSCLog = new List <SigninCreditLog>();
            for (int i = 0; i < 7; i++)
            {
                var list = (from v in db.SigninCreditLog
                            where v.MemberId == MemberId && v.SigninData == datatime
                            select v).FirstOrDefault();
                if (list == null)
                {
                    SigninCreditLog sclog = new SigninCreditLog();
                    sclog.Id         = 0;
                    sclog.IsDraw     = 2;
                    sclog.SigninData = datatime;
                    sclog.MemberId   = MemberId;
                    listSCLog.Add(sclog);
                }
                else
                {
                    listSCLog.Add(list);
                }
                datatime = datatime.AddDays(-1);
            }
            var d = (from v in listSCLog
                     select new
            {
                MemberId = v.MemberId,
                SigninData = v.SigninData,
                IsDraw = v.IsDraw
            });
            #endregion


            #region 计算连续签到天数

            int continuousDay = 0;

            for (int i = 0; i < 7; i++)
            {
                if (i == 0 && listSCLog[i].SigninData == DateTime.Today && listSCLog[i].IsDraw == 2)
                {
                    continue;
                }
                if (listSCLog[i].IsDraw == 0)
                {
                    continuousDay = continuousDay + 1;
                }
                else
                {
                    break;
                }
            }



            #endregion



            #region 当天是否签到

            datatime = DateTime.Today;
            var isSigninData = "f";
            var scl          = (from v in db.SigninCreditLog
                                where v.MemberId == MemberId && v.SigninData == datatime
                                select v).FirstOrDefault();
            if (scl == null)
            {
                isSigninData = "f";
            }
            else
            {
                isSigninData = "t";
            }
            #endregion
            //return JsonConvert.SerializeObject(d, DateTimeConvent.DateTimedd());
            return("{\"SigninCredit\":" + JsonConvert.SerializeObject(d, DateTimeConvent.DateTimedd()) + ",\"IsSiginCredit\":\"" + isSigninData + "\",\"ContinuousDay\":" + continuousDay + "}");
        }
Ejemplo n.º 5
0
        public string GetCultivateInterflowList(dynamic requestData)
        {
            try
            {
                // var orderBy = requestData.OrderBy;

                string orderBy = JsonConvert.DeserializeObject <string>(JsonConvert.SerializeObject(requestData.OrderBy));

                if (orderBy != "time" && orderBy != "count")
                {
                    orderBy = "time";
                }

                string isDesc = JsonConvert.DeserializeObject <string>(JsonConvert.SerializeObject(requestData.IsDesc));

                if (isDesc != "f" && isDesc != "t")
                {
                    isDesc = "f";
                }

                string openId = JsonConvert.DeserializeObject <string>(JsonConvert.SerializeObject(requestData.OpenId));

                int pageIndex = JsonConvert.DeserializeObject <int>(JsonConvert.SerializeObject(requestData.PageIndex));
                if (pageIndex <= 0)
                {
                    pageIndex = 1;
                }
                //            var sql = string.Format(@"select C.CuInterId,C.CurriculumType,C.Url,C.CurriculumName,C.VisitCount,C.PraiseCount,C.CreateTime,case when CP.Id is null then 'f' else 't' end  as isPraise from  CultivateInterflow  C left join( select * from  CultivatePraise where OpenId={0}) as  CP  on C.CuInterId=CP.CuInterId
                //where C.IsDisplay=1
                //order By C.Priority ",openId);


                var qtest = (from v in db.CultivatePraise
                             where v.OpenId == openId
                             select v);


                var q = (from v in db.CultivateInterflow
                         join p in qtest on v.CuInterId equals p.CuInterId into temp
                         from tt in temp.DefaultIfEmpty()
                         where v.IsDisplay == 1
                         select new
                {
                    CuInterId = v.CuInterId,
                    CurriculumType = v.CurriculumType,
                    Url = v.Url,
                    CurriculumName = v.CurriculumName,
                    PraiseCount = v.PraiseCount,
                    VisitCount = v.VisitCount,
                    CreateTime = v.CreateTime,
                    IsPraise = tt.Id == null ? "f" : "t"
                });

                var count = q.Count();



                //if (isDesc == "f")
                //{
                //    var lastq = q.OrderBy(v => orderBy).Skip((pageIndex - 1) * 4).Take(4);
                //    return "{ \"Count\":\"" + count + "\",\"data\":" + JsonConvert.SerializeObject(lastq) + "}";
                //}
                //else
                //{
                //    var lastq = q.OrderByDescending(v => orderBy).Skip((pageIndex - 1) * 4).Take(4);
                //    return "{ \"Count\":\"" + count + "\",\"data\":" + JsonConvert.SerializeObject(lastq) + "}";
                //}

                if (orderBy == "time")
                {
                    if (isDesc == "t")
                    {
                        q = q.OrderByDescending(v => v.CreateTime);
                    }
                    if (isDesc == "f")
                    {
                        q = q.OrderBy(v => v.CreateTime);
                    }
                }
                if (orderBy == "count")
                {
                    if (isDesc == "t")
                    {
                        q = q.OrderByDescending(v => v.VisitCount);
                    }
                    if (isDesc == "f")
                    {
                        q = q.OrderBy(v => v.VisitCount);
                    }
                }

                q = q.Skip((pageIndex - 1) * 4).Take(4);


                return("{ \"Count\":\"" + count + "\",\"data\":" + JsonConvert.SerializeObject(q, DateTimeConvent.DateTimedd()) + "}");
            }
            catch (Exception)
            {
                return("No");
            }
        }
Ejemplo n.º 6
0
        public string GetCultivateList(dynamic requestData)
        {
            try
            {
                string sql = "select * from (select c.CuInterId,c.CurriculumName,c.CreateTime, STUFF((SELECT ' '+LecturerName FROM  Lecturer where CuInterId=c.CuInterId  FOR XML PATH('')), 1, 1, '') lecturer,c.CurriculumType,c.IsDisplay,c.Priority  from CultivateInterflow c  ) as d where 1=1";

                var StarTime = JsonConvert.DeserializeObject <string>(JsonConvert.SerializeObject(requestData.StarTime));


                var EndTime = JsonConvert.DeserializeObject <string>(JsonConvert.SerializeObject(requestData.EndTime));

                var Name = JsonConvert.DeserializeObject <string>(JsonConvert.SerializeObject(requestData.Name));



                var pageIndex = JsonConvert.DeserializeObject <int>(JsonConvert.SerializeObject(requestData.PageIndex));


                if (!string.IsNullOrEmpty(StarTime))
                {
                    sql += " and d.CreateTime>'" + StarTime + "'";
                }
                if (!string.IsNullOrEmpty(EndTime))
                {
                    sql += " and d.CreateTime<'" + EndTime + "'";
                }
                if (!string.IsNullOrEmpty(Name))
                {
                    sql += " and (d.CurriculumName like '%" + Name + "%' or  d.lecturer like '%" + Name + "%')";
                }
                sql = sql + "  Order by d.Priority";
                var q     = dataContext.ExecuteDataTable(CommandType.Text, sql);
                var count = q.Rows.Count;

                if (pageIndex <= 0)
                {
                    pageIndex = 1;
                }
                var lastq = imgHandel.GetPagedTable(q, pageIndex, 10);

                return("{ \"Count\":\"" + count + "\",\"data\":" + JsonConvert.SerializeObject(lastq, DateTimeConvent.DateTimedd()) + "}");
            }
            catch (Exception)
            {
                return("No");
            }
        }