public static List <SeckillListModel> SelectSeckillList(DateTime dt)
        {
            var data1 = DalSeckill.SelectQiangGouAndProducts(dt);     //已审核产品数据
            var data2 = DalSeckill.SelectQiangGouTempAndProducts(dt); //待审核产品数据

            var data2aids = data2.Select(r => r.ActivityID).ToList();
            //var data3 = data2.Except(data1);
            var dbResult = data1.Where(r => !data2aids.Contains(r.ActivityID)).Union(data2).ToList();



            var scheduleDetails = dbResult.GroupBy(r => new
            {
                r.ActivityID,
                r.StartDateTime,
                r.EndDateTime,
                r.IsShow
            })
                                  .Select(
                d =>
                new ScheduleDetail(DalSeckill.SelectActivityStatusByActivityId(d.Key.ActivityID.ToString()),
                                   d.Key.StartDateTime, d.Key.EndDateTime)
            {
                ActivityId  = d.Key.ActivityID.ToString(),
                Count       = dbResult.Where(a => a.ActivityID == d.Key.ActivityID).Count(),
                IsShowCount = dbResult.Where(a => a.IsShow == true && a.ActivityID == d.Key.ActivityID).Count()
            });



            var scheduleModels = scheduleDetails.GroupBy(r => new
            {
                r.ShortDate,
                r.Week
            }).Select(d => new ScheduleModel()
            {
                Week      = d.Key.Week,
                ShortDate = d.Key.ShortDate,
                Schedule  = d.Select(s => new ScheduleDetail()
                {
                    ActivityId  = s.ActivityId,
                    Count       = s.Count,
                    Schedule    = s.Schedule,
                    Status      = s.Status,
                    ShortDate   = s.ShortDate,
                    StrStatus   = s.StrStatus,
                    IsShowCount = s.IsShowCount
                }).ToList()
            }).ToList();

            return(new List <SeckillListModel>
            {
                new SeckillListModel(dt, "0点场", scheduleModels),
                new SeckillListModel(dt, "10点场", scheduleModels),
                new SeckillListModel(dt, "13点场", scheduleModels),
                new SeckillListModel(dt, "16点场", scheduleModels),
                new SeckillListModel(dt, "20点场", scheduleModels),
            });
        }
Exemple #2
0
        public ScheduleDetail DefaultGenerateDefaultActivity(string schedule, string shortDate)
        {
            var models = DalSeckill.SelectDefultActivityBySchedule(schedule)?.ToList() ?? new List <QiangGouProductModel>();;
            var first  = models.FirstOrDefault();

            if (first == null || first.ActivityID == new Guid())
            {
                models = DalSeckill.SelectDefultActivityTempBySchedule(schedule)?.ToList() ?? new List <QiangGouProductModel>();
                first  = models.FirstOrDefault();
                if (first == null || first.ActivityID == new Guid())
                {
                    return(new ScheduleDetail
                    {
                        Status = 1,
                        StrStatus = "新建",
                        ShortDate = shortDate,
                        Schedule = schedule,
                        IsDefault = true,
                    });
                }
            }
            var status    = DalSeckill.SelectActivityStatusByActivityId(first.ActivityID.ToString());
            var strStatus = "已发布";
            var count     = models.Count;

            if (status != 0)
            {
                status    = status == 1 ? 2 : 4;
                count     = DalSeckill.SelectActivityProductsByActivityId(first.ActivityID.ToString());
                strStatus = status == 2
                    ? "待审核"
                    : "已驳回";
            }
            else
            {
                status = 3;
            }
            return(new ScheduleDetail
            {
                Status = status,
                StrStatus = strStatus,
                ActivityId = models.Select(r => r.ActivityID).FirstOrDefault().ToString(),
                Count = count,
                Schedule = schedule,
                IsDefault = true,
                ShortDate = shortDate
            });
        }