public Bas_School ToSchoolDbModel(Bas_School model) { //Bas_School model //Bas_School model = new Bas_School(); //model.Bsl_Address = this.Bsl_Address; //model.Bsl_City = this.Bsl_City; //model.Bsl_ContractDate = this.Bsl_ContractDate; //model.Bsl_County = this.Bsl_County; //model.Bsl_Creator = this.Bsl_Creator; //model.Bsl_Editor = this.Bsl_Editor; //model.Bsl_ExpiredDate = this.Bsl_ExpiredDate; //model.Bsl_Id = this.Bsl_Id; //model.Bsl_IsValid = this.Bsl_IsValid; //model.Bsl_Level = this.Bsl_Level; //model.Bsl_MasterName = this.Bsl_MasterName; //model.Bsl_MasterPhone = this.Bsl_MasterPhone; //model.Bsl_Province = this.Bsl_Province; //model.Bsl_Remark = this.Bsl_Remark; //model.Bsl_SchoolMasterId = this.Bsl_SchoolMasterId; //model.Bsl_SchoolName = this.Bsl_SchoolName; //model.Bsl_Status = this.Bsl_Status; model = this.ConvertTo <Bas_School>(model); model.Bsl_IsValid = this.IsValidStr == "on"; return(model); }
public SchoolInputModel FromDbModel(Bas_School school, Yw_SchoolTeacher schoolTeacher) { SchoolInputModel res = new SchoolInputModel(); if (school != null) { res = school.ConvertTo <SchoolInputModel>(); res.IsValidStr = school.Bsl_IsValid ? "on" : ""; //this.Bsl_Address = school.Bsl_Address; //this.Bsl_City = school.Bsl_City; //this.Bsl_ContractDate = school.Bsl_ContractDate; //this.Bsl_County = school.Bsl_County; //this.Bsl_Creator = school.Bsl_Creator; //this.Bsl_Editor = school.Bsl_Editor; //this.Bsl_ExpiredDate = school.Bsl_ExpiredDate; //this.Bsl_Id = school.Bsl_Id; //this.Bsl_IsValid = school.Bsl_IsValid; //this.Bsl_Level = school.Bsl_Level; //this.Bsl_MasterName = school.Bsl_MasterName; //this.Bsl_MasterPhone = school.Bsl_MasterPhone; //this.Bsl_Province = school.Bsl_Province; //this.Bsl_Remark = school.Bsl_Remark; //this.Bsl_SchoolMasterId = school.Bsl_SchoolMasterId; //this.Bsl_SchoolName = school.Bsl_SchoolName; //this.Bsl_Status = school.Bsl_Status; } if (schoolTeacher != null) { res.LoginPhone = schoolTeacher.Yoh_Phone; } return(res); }
/// <summary> /// 学员下订单 /// </summary> public int MakeOrder(int studentId, int courseId) { CourseBll courseBll = new CourseBll(); SchoolBll schoolBll = new SchoolBll(); Yw_Course course = courseBll.GetCourse(courseId); if (course == null || course.Ycs_Status != (int)CourseStatusEnum.已上架) { throw new AbhsException(ErrorCodeEnum.CourseCanNotBuy, AbhsErrorMsg.ConstCourseCanNotBuy); } Bas_School school = schoolBll.GetSchoolByStudent(studentId); if (school == null) { throw new AbhsException(ErrorCodeEnum.StudentNotBindSchool, AbhsErrorMsg.ConstStudentNotBindSchool); } Yw_CoursePrice price = courseBll.GetCoursePrice(courseId, school.Bsl_Level); Yw_StudentOrder order = new Yw_StudentOrder(); order.Yod_CourseId = courseId; order.Yod_OrderNo = GenerateOrderNo(courseId, studentId); order.Yod_OrderTime = DateTime.Now; order.Yod_OrderType = (int)OrderTypeEnum.订单; order.Yod_PayBatchId = 0; order.Yod_ReferOrderId = 0; order.Yod_PayTime = new DateTime(1900, 1, 1); order.Yod_Status = (int)StudentOrderStatus.待支付; order.Yod_StudentId = studentId; order.Yod_UpdateTime = DateTime.Now; order.Yod_Amount = price.Yce_Price; OrderService.Add(order); return order.Yod_Id; }
/// <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); }
/// <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)); } }
public ActionResult SaveSchool(SchoolInputModel viewModel) { Bas_School oldSchool = new Bas_School(); Yw_SchoolTeacher oldTeacher = new Yw_SchoolTeacher(); if (viewModel.Bsl_Id > 0) { oldSchool = schoolBll.GetSchool(viewModel.Bsl_Id); if (oldSchool == null) { throw new AbhsException(ErrorCodeEnum.ParameterInvalid, AbhsErrorMsg.ConstParameterInvalid); } } var school = viewModel.ToSchoolDbModel(oldSchool); var teacher = viewModel.ToSchoolTeacherDbModel(); if (school.Bsl_Id == 0) { school.Bsl_CreateTime = DateTime.Now; school.Bsl_Creator = CurrentUserID; } school.Bsl_Editor = CurrentUserID; school.Bsl_UpdateTime = DateTime.Now; if (teacher.Yoh_Id == 0) { teacher.Yoh_CreateTime = DateTime.Now; teacher.Yoh_Creator = CurrentUserID; } teacher.Yoh_UpdateTime = DateTime.Now; teacher.Yoh_Editor = CurrentUserID; if (teacher.Yoh_Password.HasValue()) { teacher.Yoh_Password = Encrypt.GetMD5Pwd(teacher.Yoh_Password); } bool success = schoolBll.SaveSchool(school, teacher); var msg = success ? "保存成功" : "保存失败"; return(Json(new JsonSimpleResponse() { State = success, ErrorMsg = msg })); }
private DtoSelectCenterCourseDetailResult CreateSelectCenterCourseDetailResultItem(DtoSelectCenterCourseDetailObject obj, Yw_CourseIntroduction introduction, Bas_School school, DtoStudentApplySchool applySchoolRecord = null, Dictionary <string, decimal> voucherDic = null, Yw_StudentOrder order = null) { DtoSelectCenterCourseDetailResult result = new DtoSelectCenterCourseDetailResult(); result.IsBindSchool = (school != null && school.Bsl_Id > 0) ? true : false; result.CourseId = obj.CourseId; result.CourseImage = obj.CourseImage.ToOssPath(); result.CourseName = obj.CourseName; result.CourseType = obj.CourseType; result.Grade = obj.Grade; result.LessonCount = obj.LessonCount; result.Description = obj.Description; result.Introduction = introduction?.Yci_Introduction; result.Arrange = introduction?.Yci_Arrange; if (result.IsBindSchool) { result.SellCount = obj.SellCount; result.CoursePrice = obj.CoursePrice; result.BaseVoucherPrice = voucherDic.ContainsKey(obj.CourseId + "_" + 1) ? voucherDic[obj.CourseId + "_" + 1] : 0; result.SchoolVoucherPrice = voucherDic.ContainsKey(obj.CourseId + "_" + 2) ? voucherDic[obj.CourseId + "_" + 2] : 0; } if (applySchoolRecord != null && applySchoolRecord.Yay_Id > 0) { result.StudentApplySchoolStatus = applySchoolRecord.Yay_Status; result.StudentApplySchoolName = applySchoolRecord.SchoolName; } if (order != null && order.Yod_Id > 0) { result.IsHaveThisCourse = true; } return(result); }
/// <summary> /// 保存学校 /// </summary> /// <param name="school"></param> /// <param name="schoolTeacher"></param> /// <returns></returns> public bool SaveSchool(Bas_School school, Yw_SchoolTeacher schoolTeacher) { bool result = false; #region 参数逻辑校验 bool checkParam = true; if (school.Bsl_Id == 0 && schoolTeacher.Yoh_Id != 0)//学校不存在 校长已经存在 { checkParam = false; } if (school.Bsl_Id != 0 && schoolTeacher.Yoh_Id == 0)//学校存在 校长不存在 { checkParam = false; } int count = SchoolTeacherBll.GetSchoolTeacherCountByPhone(schoolTeacher.Yoh_Phone); if (schoolTeacher.Yoh_Id == 0 && count > 0)//校长不存在,登录手机已经存在 { checkParam = false; } if (!checkParam) { //throw new AbhsException(ErrorCodeEnum.ParameterInvalid, AbhsErrorMsg.ConstParameterInvalid); return(false); } #endregion using (TransactionScope scope = new TransactionScope()) { try { if (school.Bsl_Id == 0) { int schoolId = SchoolRepository.Insert(school); int schoolTeacherId = 0; if (schoolId > 0) { schoolTeacher.Yoh_SchoolId = schoolId; schoolTeacherId = SchoolTeacherBll.InsertEntity(schoolTeacher); if (schoolTeacherId > 0) { result = SchoolRepository.UpdateMasterId(schoolId, schoolTeacherId); } } } else { #region teacher bool updateTeacher = true; bool updateSchool = true; var oldTeacher = SchoolTeacherBll.GetEntity(schoolTeacher.Yoh_Id); int schoolTeacherId = schoolTeacher.Yoh_Id; #region 更新校长 if (oldTeacher.Yoh_Phone != schoolTeacher.Yoh_Phone) { if (SchoolTeacherBll.GetSchoolTeacherCountByPhone(schoolTeacher.Yoh_Phone) == 0 && schoolTeacher.Yoh_Password.HasValue()) { SchoolTeacherBll.UpdateStatus(schoolTeacher.Yoh_Id, (int)StatusEnum.除, school.Bsl_Editor); schoolTeacher.Yoh_Id = 0; schoolTeacher.Yoh_SchoolId = school.Bsl_Id; schoolTeacher.Yoh_CreateTime = DateTime.Now; schoolTeacher.Yoh_UpdateTime = DateTime.Now; schoolTeacherId = SchoolTeacherBll.InsertEntity(schoolTeacher); updateTeacher = schoolTeacherId > 0; } else { updateTeacher = false; } } #endregion #region 更新密码 else { if (schoolTeacher.Yoh_Password.HasValue()) { updateTeacher = SchoolTeacherBll.UpdatePwd(schoolTeacher.Yoh_Id, schoolTeacher.Yoh_Password, school.Bsl_Editor); } } #endregion #endregion #region 更新学校 school.Bsl_SchoolMasterId = schoolTeacherId; updateSchool = SchoolRepository.Update(school); #endregion result = updateTeacher && updateSchool; } if (result) { scope.Complete(); } else { RollbackTran(); } } catch (Exception ex) { RollbackTran(); throw ex; } } return(result); }