public ApplyWinterSummerModel(CourseSrv courseSrv, BusinessSrv businessSrv)
 {
     _CourseSrv   = courseSrv;
     _BusinessSrv = businessSrv;
     WSRange      = StaticDataSrv.CourseDateRange.Where(a => a.Year == DateTime.Now.Year &&
                                                        a.CourseScheduleType == StaticDataSrv.CurrentScheduleType).FirstOrDefault();
     // _UserSrv = userSrv;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// /获取订单行,更新课时
        /// </summary>
        /// <param name="userOpenId"></param>
        /// <param name="line"></param>
        private EUserAccount UpdateUserAccountByOrderLine(string userOpenId, EOrderLine line)
        {
            EUserAccount userAccount = _dbContext.DBUserAccount.Where(a => a.UserOpenId == userOpenId).FirstOrDefault();

            if (userAccount == null)
            {
                UserSrv userSrv = new UserSrv(_dbContext);
                userAccount = userSrv.CreateNewUserAccount(userOpenId);
            }

            CourseScheduleType courseScheduleType = (CourseScheduleType)line.Ext1;
            ECourseDateRange   dr = null;

            switch (courseScheduleType)
            {
            case CourseScheduleType.Standard:
            case CourseScheduleType.VIP:
                userAccount.RemainCourseTime += line.Qty;
                if (userAccount.BuyDate == DateTime.MinValue)
                {
                    userAccount.BuyDate = DateTime.Now;
                }
                if (userAccount.DeadLine == DateTime.MinValue)
                {
                    userAccount.DeadLine = DateTime.Now;
                }
                userAccount.DeadLine = userAccount.DeadLine.AddYears(1);

                break;

            case CourseScheduleType.Summer:
                userAccount.RemainSummerTime += line.Qty;
                dr = StaticDataSrv.CourseDateRange.Where(a => a.CourseScheduleType == CourseScheduleType.Summer && a.Year == DateTime.Now.Year).FirstOrDefault();

                userAccount.SummerDeadLine = dr.EndDate;

                if (userAccount.SummerBuyDate == DateTime.MinValue)
                {
                    userAccount.SummerBuyDate = DateTime.Now;
                }

                break;

            case CourseScheduleType.Winter:
                userAccount.RemainWinterTime += line.Qty;
                dr = StaticDataSrv.CourseDateRange.Where(a => a.CourseScheduleType == CourseScheduleType.Winter && a.Year == DateTime.Now.Year).FirstOrDefault();
                userAccount.WinterDeadLine = dr.EndDate;
                if (userAccount.WinterBuyDate == DateTime.MinValue)
                {
                    userAccount.WinterBuyDate = DateTime.Now;
                }
                break;
            }
            return(userAccount);
        }
Ejemplo n.º 3
0
        public static CourseScheduleType GetSysCurrentCourseScheduleType(DateTime date)
        {
            ECourseDateRange dr = CourseDateRange.Where(a => a.StartDate <= date &&
                                                        a.EndDate >= date).FirstOrDefault();

            if (dr != null)
            {
                return(dr.CourseScheduleType);
            }
            else
            {
                return(CourseScheduleType.Standard);
            }
        }
Ejemplo n.º 4
0
        public IActionResult OnPostGet(int year, CourseScheduleType scheduleType)
        {
            ResultObject <PPlan> result = new ResultObject <PPlan>();

            try
            {
                ECourseDateRange dr = StaticDataSrv.CourseDateRange.Where(a => a.CourseScheduleType == scheduleType && a.Year == year).FirstOrDefault();
                result.Entity.PlanInfo = "";
                if (dr != null)
                {
                    result.Entity.PlanInfo = $"{dr.Year} {dr.CourseDateRangeName}: {dr.StartDate.ToString("MM月dd日")} 到 {dr.EndDate.ToString("MM月dd日")}";
                }

                result.Entity.CourseScheduleList = _CourseSrv.GetCourseScheduleByYearType(year, scheduleType);
            }
            catch (Exception ex)
            {
                result.ErrorMsg = ex.Message;
            }

            return(new JsonResult(result));
        }