/// <summary> /// 课程中心-课程列表(加载课程列表) /// </summary> /// <param name="search">筛选条件、分页信息</param> /// <returns></returns> public JsonResult GetCourses(CourseSearch search) { CourseBll bll = new CourseBll(); DtoCourseSelectCondition condition = new DtoCourseSelectCondition(); condition.Grade = search.Grade; condition.CourseType = search.CourseType; condition.OrderBy = (DtoCourseSelectCondition.DtoCourseSelectOrderEnum)search.OrderBy; condition.StudentId = GetCurrentUser().StudentId; PagingObject paging = search.Pagination; //是否包含价格 bool includePrice = false; List <DtoSelectCenterResult> entities = bll.GetCourseForSelectCenter(condition, paging, out includePrice); IEnumerable <CourseViewModel> list = entities.Select(s => { var model = s.ConvertTo <CourseViewModel>(); if (string.IsNullOrEmpty(model.CourseImage)) { model.CourseImage = defaultCourseImg; } return(model); }); bool hasMore = paging.TotalCount > search.Pagination.PageIndex * search.Pagination.PageSize; return(Json(new JsonResponse <CourseSet> { State = true, ErrorCode = 0, ErrorMsg = "", Data = new CourseSet() { DataList = list, HasMore = hasMore, IncludePrice = includePrice } }, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 选课中心课程列表,不包含价格 /// </summary> public List <DtoSelectCenterCourseObject> GetCourseWithoutPrice(DtoCourseSelectCondition condition, PagingObject paging) { string field = $@"a.Ycs_Id as CourseId,a.Ycs_Name as CourseName,a.Ycs_CoverImage as CourseImage, a.Ycs_SellCount as SellCount,a.Ycs_Grade as Grade,a.Ycs_CourseType as CourseType,a.Ycs_LessonCount as LessonCount"; string where = $@"yw_course a where a.ycs_status = 3 {condition.GradeExpression} {condition.CourseTypeExpression}"; string orderBy = condition.OrderExpression; return(QueryPaging <DtoSelectCenterCourseObject>(field, where, orderBy, paging, new { SchoolLevelId = condition.SchoolLevel, Grade = condition.Grade, CourseType = condition.CourseType }).ToList()); }
/// <summary> /// 选课中心课程详情-预览功能 /// </summary> /// <param name="courseId">课程Id</param> /// <param name="studentId">学生Id</param> /// <returns></returns> public DtoSelectCenterCourseDetailResult GetCourseDetailForPreview(int courseId, int studentId) { DtoSelectCenterCourseDetailResult result = new DtoSelectCenterCourseDetailResult(); DtoCourseSelectCondition condition = new DtoCourseSelectCondition(); condition.StudentId = studentId; DtoSelectCenterCourseDetailObject course = null; Dictionary <string, decimal> voucherDic = null; Yw_StudentOrder order = null; DtoStudentApplySchool applyRecord = null; SchoolBll schBll = new SchoolBll(); Bas_School school = schBll.GetSchoolByStudent(condition.StudentId); if (school != null) { condition.SetSchoolLevel(school.Bsl_Level); condition.SetSchoolId(school.Bsl_Id); course = CourseRepository.GetCourseDetailWithPrice(courseId, condition.SchoolLevel, true); if (course != null && course.CourseId > 0) { DtoSimpleCourse simpleCourse = new DtoSimpleCourse() { CourseId = course.CourseId, Amount = course.CoursePrice, CourseType = course.CourseType, Grade = course.Grade }; voucherDic = GetVoucherDicForUserCourse(new List <DtoSimpleCourse>() { simpleCourse }, condition); //查询用户是否已购买此课程 StudentOrderBll studentOrderBll = new StudentOrderBll(); order = studentOrderBll.GetFinishOrder(condition.StudentId, course.CourseId); } } else { course = CourseRepository.GetCourseDetailWithoutPrice(courseId, true); StudentApplyBll studentApplyBll = new StudentApplyBll(); applyRecord = studentApplyBll.GetApplyByStudentId(condition.StudentId); } if (course != null) { Yw_CourseIntroduction introduction = CourseIntroductionRespository.GetCourseIntroduction(course.CourseId); result = CreateSelectCenterCourseDetailResultItem(course, introduction, school, applyRecord, voucherDic, order); } else { throw new AbhsException(ErrorCodeEnum.CourseNotExists, AbhsErrorMsg.ConstCourseNotExists); } return(result); }
/// <summary> /// 选课中心课程列表(不再使用) /// </summary> public List <DtoSelectCenterResult> GetCourseForSelectCenter(DtoCourseSelectCondition condition, PagingObject paging) { SchoolBll schBll = new SchoolBll(); Bas_School school = schBll.GetSchoolByStudent(condition.StudentId); if (school != null) { return(GetCourseWithPriceForSelectCenter(school, condition, paging)); } else { return(GetCourseWithoutPriceForSelectCenter(condition, paging)); } }
/// <summary> /// 选课中心课程列表不包含价格(学生没有绑定校区) /// </summary> /// <param name="condition"></param> /// <param name="paging"></param> /// <returns></returns> private List <DtoSelectCenterResult> GetCourseWithoutPriceForSelectCenter(DtoCourseSelectCondition condition, PagingObject paging) { List <DtoSelectCenterResult> results = new List <DtoSelectCenterResult>(); List <DtoSelectCenterCourseObject> courseList = CourseRepository.GetCourseWithoutPrice(condition, paging); if (courseList.Count > 0) { foreach (DtoSelectCenterCourseObject obj in courseList) { results.Add(CreateSelectCenterResultItem(obj)); } } return(results); }
public void GetCourseForSelectCenterTest() { CourseBll bll = new CourseBll(); DtoCourseSelectCondition condition = new DtoCourseSelectCondition(); condition.StudentId = 10003; condition.Grade = 0; condition.CourseType = 0; condition.OrderBy = DtoCourseSelectCondition.DtoCourseSelectOrderEnum.Lastest; PagingObject paging = new PagingObject() { PageIndex = 1, PageSize = 20 }; bool includePrice = false; List <DtoSelectCenterResult> result = bll.GetCourseForSelectCenter(condition, paging, out includePrice); }
private Dictionary <string, decimal> GetVoucherDicForUserCourse(List <DtoSimpleCourse> simpleCourses, DtoCourseSelectCondition condition) { CashVoucherBll voucherBll = new CashVoucherBll(); List <DtoVoucherForUserCourse> vouchers = voucherBll.GetBestVoucherForUserCourse(simpleCourses, condition.StudentId, condition.SchoolId); Dictionary <string, decimal> voucherDic = new Dictionary <string, decimal>(); foreach (DtoVoucherForUserCourse voucher in vouchers) { voucherDic[voucher.CourseId + "_" + voucher.VoucherType] = voucher.Amount; } return(voucherDic); }
/// <summary> /// 选课中心课程列表包含价格(学生已经绑定校区) /// </summary> private List <DtoSelectCenterResult> GetCourseWithPriceForSelectCenter(Bas_School school, DtoCourseSelectCondition condition, PagingObject paging) { List <DtoSelectCenterResult> results = new List <DtoSelectCenterResult>(); condition.SetSchoolLevel(school.Bsl_Level); condition.SetSchoolId(school.Bsl_Id); List <DtoSelectCenterCourseObject> courseList = CourseRepository.GetCourseWithPrice(condition, paging); if (courseList.Count > 0) { List <DtoSimpleCourse> simpleCourses = courseList.Select( x => new DtoSimpleCourse() { CourseId = x.CourseId, Amount = x.CoursePrice, CourseType = x.CourseType, Grade = x.Grade }) .ToList(); Dictionary <string, decimal> voucherDic = GetVoucherDicForUserCourse(simpleCourses, condition); foreach (DtoSelectCenterCourseObject obj in courseList) { results.Add(CreateSelectCenterResultItem(obj, voucherDic)); } } return(results); }