using System; using System.Collections.Generic; using System.Linq; using System.Text; using EMIS.ViewModel.Students; using Bowin.Common.Linq.Entity; using EMIS.DataLogic.StudentSystem.ExamineApply; using EMIS.ViewModel.ExaminationApply; using EMIS.CommonLogic.SystemServices; using EMIS.Entities; using EMIS.DataLogic.Repositories; using EMIS.DataLogic.StudentSystem.StudentMaterial; using EMIS.DataLogic.ExaminationApply; using EMIS.CommonLogic.CalendarManage; using EMIS.ViewModel; using System.Transactions; using EMIS.DataLogic.Common.Students; using EMIS.ViewModel.Cache; using System.Linq.Expressions; using Bowin.Common.Linq; using EMIS.DataLogic.ScoreManage; using EMIS.ViewModel.FeeManage; using EMIS.Utility.FormValidate; namespace EMIS.CommonLogic.Students { public class ExamineApplyServices : BaseServices, IExamineApplyServices { public Lazy SchoolYearServices { get; set; } public IUserServices userServices { get; set; } public ExamineApplyDAL ExamineApplyDAL { get; set; } public ExaminationTypeDAL ExaminationTypeDAL { get; set; } public StudentRecordDAL studentRecordDAL { get; set; } public ExaminationRegistrationRepository RegistrationRepository { get; set; } //public SubjectCountLimitDAL SubjectCountLimitDAL { get; set; } //public OpenControlDAL OpenControlDAL { get; set; } public GrademajorRepository gradeRepository { get; set; } public StudentsDAL StudentsDAL { get; set; } public ExaminationSubjectDAL ExaminationSubjectDAL { get; set; } public ResitDAL ResitDAL { get; set; } //public LevelScoreDAL levelScoreDAL { get; set; } //public LevelSettingDAL levelSettingDAL { get; set; } //public ExaminationSubjectCollegeControlDAL examinationSubjectCollegeControlDAL { get; set; } public IGridResultSet GetExaminationSubjectList(Guid UserID) { Expression> batchExp = (x => true); Expression> projectExp = (x => true); Expression> scoreExp = (x => true); Expression> facutyExp = (x => true); Expression> gradeExp = (x => true); Expression> studentExp = (x => true); scoreExp = scoreExp.And(x => x.UserID == UserID); var resitquery = ResitDAL.GetResitViewQueryable(batchExp, projectExp, scoreExp, facutyExp, gradeExp, studentExp).ToList(); var examinationScoreList = ResitDAL.ExaminationScoreRepository.GetList(x => x.UserID == UserID, (x => x.EX_ExaminationBatchProject)); Dictionary ProjectFeeIDAndFeeType = new Dictionary(); var query = ExamineApplyDAL.GetExaminationSubjectList(UserID).ToList(); var ExaminationProjectFeeIDList = query.Select(x => x.ExaminationProjectFeeID).ToList(); var projectIDList = query.Select(x => x.ExaminationProjectID).ToList(); var examinationProjectSubjectList = ExaminationSubjectDAL.examinationProjectSubjectRepository.Entities.Where(x => projectIDList.Contains(x.ExaminationProjectID)).ToList(); //Dictionary canResitCountDic = new Dictionary(); List cannotResitSubject = new List(); List cannotResitProject = new List(); examinationProjectSubjectList.ForEach(x => { if (resitquery.Where(y => y.ExaminationProjectID == x.ExaminationProjectID && y.ExaminationSubjectID == x.ExaminationSubjectID).Count() > x.ResitCount) { cannotResitSubject.Add(x.ExaminationSubjectID); cannotResitProject.Add(x.ExaminationProjectID); } }); //examinationProjectSubjectList.GroupBy(x => new { x.ExaminationSubjectID, x.ExaminationProjectID }).ToList().ForEach(x => //{ // if (resitquery.Where(y => y.ExaminationSubjectID == x.Key.ExaminationSubjectID && y.ExaminationProjectID == x.Key.ExaminationProjectID).Count() >= x.Count()) // { // cannotResitProject.Add(x.Key.ExaminationProjectID); // } //}); var FeeTypeByProjectFeeViewList = ExamineApplyDAL.GetFeeTypeByProjectFeeView(x => ExaminationProjectFeeIDList.Contains(x.ExaminationProjectFeeID)).ToList(); var FeeType = from a in FeeTypeByProjectFeeViewList.Where(x => x.IsResit == false || (!cannotResitProject.Contains(x.ExaminationProjectID) && x.IsResit == true && resitquery.Where(y => y.ExaminationProjectID == x.ExaminationProjectID).Count() > 0 && examinationScoreList.Where(z => z.EX_ExaminationBatchProject.ExaminationProjectID == x.ExaminationProjectID).Count() > 0 && examinationScoreList.Where(z => z.EX_ExaminationBatchProject.ExaminationProjectID == x.ExaminationProjectID).Max(z => z.Expire) > DateTime.Now)) group a by a.ExaminationProjectFeeID into ga select new { ExaminationProjectFeeID = ga.Key, FeeTypeStr = String.Join(";\r\n", ga.Select(x => x.FeeTypeName).ToArray()), }; foreach (var a in FeeType.ToList()) { ProjectFeeIDAndFeeType.Add(a.ExaminationProjectFeeID, a.FeeTypeStr); } query.ForEach(x => { foreach (var a in ProjectFeeIDAndFeeType) { if (x.ExaminationProjectFeeID == a.Key) { x.FeeTypeListStr = a.Value; } } }); //var examinationProjectFeeTypeList = ExaminationSubjectDAL.examinationProjectFeeTypeRepository.GetList(x => ExaminationProjectFeeIDList.Contains(x.ExaminationProjectFeeID) && x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList(); return query.Where(x => x.EndDate.Value.AddDays(1) >= DateTime.Now && x.StartDate <= DateTime.Now).OrderBy(x => x.EndDate).ThenBy(x => x.StartDate).ThenBy(x => x.ExaminationDate).AsQueryable().ToGridResultSet(); } public StudentListView GetRegisterViewByExaminationBatchProjectID(Guid? examinationBatchProjectID, Guid? userID) { Expression> batchExp = (x => true); Expression> projectExp = (x => true); Expression> scoreExp = (x => true); Expression> facutyExp = (x => true); Expression> gradeExp = (x => true); Expression> studentExp = (x => true); var registView = StudentsDAL.GetRegustViewQueryable(x => x.UserID == userID).FirstOrDefault(); var query = ExamineApplyDAL.GetRegisterViewByExaminationBatchProjectID(examinationBatchProjectID, userID); scoreExp = scoreExp.And(x => x.UserID == userID); scoreExp = scoreExp.And(x => x.EX_ExaminationBatchProject.ExaminationProjectID == query.ExaminationProjectID); //获取要报名的项目是否有补考记录 var resitquery = ResitDAL.GetResitViewQueryable(batchExp, projectExp, scoreExp, facutyExp, gradeExp, studentExp).ToList(); var examinationProjectSubjectList = ExaminationSubjectDAL.examinationProjectSubjectRepository.Entities.Where(x => x.ExaminationProjectID == query.ExaminationProjectID).ToList(); var examinationScore = ResitDAL.ExaminationScoreRepository.Entities.Where(x => x.EX_ExaminationBatchProject.ExaminationProjectID == query.ExaminationProjectID).OrderByDescending(x => x.Expire).FirstOrDefault(); //Dictionary canResitCountDic = new Dictionary(); List cannotResitSubject = new List(); examinationProjectSubjectList.ForEach(x => { if (x.ResitCount != null && resitquery.Where(y => y.ExaminationSubjectID == x.ExaminationSubjectID).Count() > x.ResitCount) { cannotResitSubject.Add(x.ExaminationSubjectID); } }); //examinationProjectSubjectList.GroupBy(x => x.ExaminationSubjectID).ToList().ForEach(x => //{ // if (resitquery.Where(y => y.ExaminationSubjectID == x.Key).Count() >= x.Count()) // { // cannotResitSubject.Add(x.Key); // } //}); var examinationProjectFeeID = query.ExaminationProjectFeeID; var examinationProjectFeeTypeList = ExaminationSubjectDAL.examinationProjectFeeTypeRepository.GetList(x => x.ExaminationProjectFeeID == examinationProjectFeeID && x.RecordStatus > (int)SYS_STATUS.UNUSABLE) //.Where(x => x.IsResit == false || (resitquery.Where(y => y.Expire >= DateTime.Now).Count() > 0 && x.IsResit == true)) .ToList(); //List feeTypeIDList = examinationProjectFeeTypeList.Select(x => x.FeeTypeID).Distinct().ToList(); Dictionary feeTypeDic = new Dictionary(); //如果缴费项目是补考,并且存在一个考试科目补考次数已经达到或者超过限制的次数,则不能报名补考的缴费项 //如果没有对应的补考成绩,不能报名缴费项目是补考的 foreach (var feeType in examinationProjectFeeTypeList.Where(x => x.IsResit == false || (x.IsResit == true && cannotResitSubject.Count() == 0 && resitquery.Count() > 0 && examinationScore != null && examinationScore.Expire > DateTime.Now)).OrderBy(x => x.FeeTypeID)) { string feeTypeName = IdNameExt.GetDictionaryItem(DictionaryItem.EX_ExaminationProjectFeeType.ToString()) .Where(x => x.Value == feeType.FeeTypeID) .Select(x => x.Name).FirstOrDefault(); string feeTypeValue = feeTypeName + "(" + feeType.Fee.ToString() + ")"; feeTypeDic.Add(feeType.FeeTypeID.ToString(), feeTypeValue); } query.FeeTypeList = feeTypeDic; query.RegistView = registView; query.CertificatesType = registView.CertificatesType; return query; } public StudentListView StudentRegister(StudentListView studentListView, Guid? userID) { try { Expression> batchExp = (x => true); Expression> projectExp = (x => true); Expression> scoreExp = (x => true); Expression> facutyExp = (x => true); Expression> gradeExp = (x => true); Expression> studentExp = (x => true); var student = StudentsDAL.GetStudentQueryable(x => x.UserID == userID).FirstOrDefault(); var currentSchoolyear = ExamineApplyDAL.schoolyearRepository.Entities.Where(x => x.IsCurrent == true).FirstOrDefault(); var studentGra = StudentsDAL.GrademajorRepository.Entities.Where(x => x.GrademajorID == student.GradeMajorID).FirstOrDefault(); var graSchoolYear = ExamineApplyDAL.schoolyearRepository.Entities.Where(x => x.SchoolcodeID == studentGra.SchoolcodeID && x.Years == studentGra.SchoolyearID).FirstOrDefault(); int? studentSchoolyearNumID = null;//如果是社会人员,无法判断是第几学年 if (graSchoolYear != null) { studentSchoolyearNumID = ((currentSchoolyear.Value - graSchoolYear.Value - (currentSchoolyear.SchoolcodeID == studentGra.SchoolcodeID ? 0 : 1)) / 2 + 1); } //是否有收费标准对应收费项的配置 var ExaminationProjectFeeType = ExaminationSubjectDAL.examinationProjectFeeTypeRepository.GetSingle(x => x.ExaminationProjectFeeID == studentListView.ExaminationProjectFeeID && x.FeeTypeID == studentListView.FeeTypeID); if (ExaminationProjectFeeType == null) { throw new Exception("找不到收费标准对应的收费项,请先设置。"); } var examinationBatchProject = ExamineApplyDAL.examinationBatchProjectRepository.Entities.Where(x => x.ExaminationBatchID == studentListView.ExaminationBatchID && x.ExaminationProjectID == studentListView.ExaminationProjectID).FirstOrDefault(); var examinationProjectCountLimitControlList = ExamineApplyDAL.examinationProjectCountLimitRepository.Entities.ToList(); //获取所有已报名的名单(不包含已退费) var dbstudentListView = ExaminationSubjectDAL.GetStudentListView(x => x.RecordStatus != (int)EX_ExaminationRegistrationStatus.Refunded, x => true, x => true, x => true); var registerCount = dbstudentListView.Where(y => y.ExaminationBatchProjectID == examinationBatchProject.ExaminationBatchProjectID).Count(); //&& y.ExaminationProjectFeeTypeID == ExaminationProjectFeeType.ExaminationProjectFeeTypeID //项目报名人数限制 if (examinationBatchProject != null && registerCount >= examinationBatchProject.MaxRegistCount) { throw new Exception("该项目报名人数已达上限。"); } //考试类型控制(年级专业对应的考试类型报名门数限制) var myRegisterCount = dbstudentListView.Where(x => x.UserID == userID && x.ExaminationTypeID == studentListView.ExaminationTypeID).Count(); EX_ExaminationProjectCountLimit examinationProjectCountLimitControl = null; if(studentSchoolyearNumID != null)//如果不是校内学生,没有学年则无需判断 { examinationProjectCountLimitControl = examinationProjectCountLimitControlList.Where(x => x.ExaminationTypeID == studentListView.ExaminationTypeID && (x.StandardID == student.StandardID || x.StandardID == null) && (x.SchoolyearNumID == studentSchoolyearNumID || x.SchoolyearNumID == null)).FirstOrDefault(); } if (examinationProjectCountLimitControl != null && myRegisterCount >= examinationProjectCountLimitControl.SubjectCountLimit) { throw new Exception("该考试类型报考门数已达上限。"); } //List RegistrationList = new List(); //var ExaminationBatchProject = ExaminationSubjectDAL.examinationBatchProjectRepository.GetList(x => x.ExaminationProjectID == studentListView.ExaminationProjectID && x.ExaminationBatchID == studentListView.ExaminationBatchID).FirstOrDefault(); //是否已报名 var dbstudentRegistration = ExaminationSubjectDAL.examinationRegistrationRepository.GetList(x => x.ExaminationProjectFeeTypeID == ExaminationProjectFeeType.ExaminationProjectFeeTypeID && x.ExaminationBatchProjectID == examinationBatchProject.ExaminationBatchProjectID && x.UserID == userID && x.RecordStatus != (int)EX_ExaminationRegistrationStatus.Refunded).FirstOrDefault(); if (dbstudentRegistration != null) { throw new Exception("该项目已报名。"); } //报考限定通过项目 var ExaminationProject = ExamineApplyDAL.examinationProjectRepository.GetSingle(x => x.ExaminationProjectID == studentListView.ExaminationProjectID); if (ExaminationProject.PreposeProjectID != null) { var PreposeProject = ExamineApplyDAL.examinationProjectRepository.GetSingle(x => x.ExaminationProjectID == ExaminationProject.PreposeProjectID); var IsPassedList = ExamineApplyDAL.GetPreposeProjectIsPass(ExaminationProject.PreposeProjectID, userID); if (!IsPassedList.Contains(true) || IsPassedList.Count == 0 || IsPassedList == null) { throw new Exception("该项目报名需要先通过" + PreposeProject.Name + "。"); } } //如果报名的收费项是补考的收费项,那么判断报名的项目对应的科目是否有设置补考次数,有则做限制,是否已有补考的成绩,有才能进行报名 if (ExaminationProjectFeeType.IsResit.Value) { scoreExp = scoreExp.And(x => x.UserID == userID); scoreExp = scoreExp.And(x => x.EX_ExaminationBatchProject.ExaminationProjectID == studentListView.ExaminationProjectID); var resitquery = ResitDAL.GetResitViewQueryable(batchExp, projectExp, scoreExp, facutyExp, gradeExp, studentExp).ToList(); var examinationProjectSubjectList = ExaminationSubjectDAL.examinationProjectSubjectRepository.Entities.Where(x => x.ExaminationProjectID == studentListView.ExaminationProjectID).ToList(); List cannotResitSubject = new List(); examinationProjectSubjectList.ForEach(x => { if (x.ResitCount != null && resitquery.Where(y => y.ExaminationSubjectID == x.ExaminationSubjectID).Count() > x.ResitCount) { cannotResitSubject.Add(x.ExaminationSubjectID); } }); if (resitquery.Count() == 0 || cannotResitSubject.Count() > 0) { throw new Exception("没有补考成绩或者超过补考次数,无法报名补考收费项"); } //ExaminationProjectFeeType. } EX_ExaminationRegistration examinationRegistration = new EX_ExaminationRegistration(); //确认个人信息 using (TransactionScope ts = new TransactionScope()) { if (studentListView.RegistView != null) { studentListView.RegistView.UserID = userID; studentListView.RegistView.CertificatesType = studentListView.CertificatesType; userServices.StudentRegist(studentListView.RegistView); } examinationRegistration.ExaminationBatchProjectID = examinationBatchProject.ExaminationBatchProjectID; examinationRegistration.ExaminationProjectFeeTypeID = ExaminationProjectFeeType.ExaminationProjectFeeTypeID; examinationRegistration.ExaminationRegistrationConfirmID = studentListView.ExaminationRegistrationConfirmID; //examinationRegistration.SchoolyearID = studentListView.SchoolyearID; examinationRegistration.Fee = ExaminationProjectFeeType.Fee; //examinationRegistration.Remark = studentListView.Remark; examinationRegistration.ExaminationRegistrationID = Guid.NewGuid(); examinationRegistration.UserID = userID; examinationRegistration.RecordStatus = (int)SYS_STATUS.USABLE; examinationRegistration.CreateUserID = userID; examinationRegistration.CreateTime = DateTime.Now; examinationRegistration.ModifyUserID = userID; examinationRegistration.ModifyTime = DateTime.Now; //this.SetNewStatus(examinationRegistration); //RegistrationList.Add(examinationRegistration); UnitOfWork.Add(examinationRegistration); UnitOfWork.Commit(); ts.Complete(); } var register = ExaminationSubjectDAL.GetStudentListView(x => x.ExaminationRegistrationID == examinationRegistration.ExaminationRegistrationID, x => true, x => true, x => true).FirstOrDefault(); var isOnlinePayControl = false; var examinationBatchProjectPersonControl = ExaminationSubjectDAL.examinationBatchProjectPersonControlRepository.Entities.Where(x => x.UserID == userID && x.ExaminationBatchProjectID == register.ExaminationBatchProjectID).FirstOrDefault(); var examinationBatchProjectControlList = ExaminationSubjectDAL.examinationBatchProjectControlRepository.Entities.Where(x => x.ExaminationBatchProjectID == register.ExaminationBatchProjectID && x.ExaminationProjectFeeID == register.ExaminationProjectFeeID && (x.SchoolyearID == student.Years || x.SchoolyearID == null) && (x.StandardID == student.StandardID || x.StandardID == null) && (x.CollegeID == student.CollegeID || x.CollegeID == null)).ToList(); Dictionary dicControl = new Dictionary(); if (examinationBatchProjectPersonControl != null) { isOnlinePayControl = examinationBatchProjectPersonControl.IsOnlinePay == null ? false : examinationBatchProjectPersonControl.IsOnlinePay.Value; } else if (examinationBatchProjectControlList != null) { if (examinationBatchProjectControlList.Count() > 1) { foreach(var projectControl in examinationBatchProjectControlList) { int? count = 0; if (projectControl.CollegeID != null) { count++; } if (projectControl.SchoolyearID != null) { count++; } if (projectControl.StandardID != null) { count++; } dicControl.Add(projectControl.ExaminationBatchProjectControlID, count); } var control = examinationBatchProjectControlList.Where(x => x.ExaminationBatchProjectControlID == dicControl.OrderByDescending(y => y.Value).FirstOrDefault().Key).FirstOrDefault(); isOnlinePayControl = control.IsOnlinePay == null ? false : control.IsOnlinePay.Value; } else { isOnlinePayControl = examinationBatchProjectControlList.FirstOrDefault().IsOnlinePay == null ? false : examinationBatchProjectControlList.FirstOrDefault().IsOnlinePay.Value; } } register.IsOnlinePay = isOnlinePayControl; return register; } catch (Exception) { throw; } } /// /// 待缴费的数据取消报名需要进行判断 /// /// public void CheckCanCancelOnline(List examinationRegistrationIDList) { try { //var examinationProjectCountLimitControlList = ExamineApplyDAL.examinationProjectCountLimitRepository.Entities.ToList(); //var studentListView = ExaminationSubjectDAL.GetStudentListView(x => true, x => true, x => true, x => true); var personalControlList = ExamineApplyDAL.examinationBatchProjectPersonControlRepository.Entities.ToList(); var dbExaminationRegistrationList = ExaminationSubjectDAL.GetStudentListView(x => examinationRegistrationIDList.Contains(x.ExaminationRegistrationID), x => true, x => true, x => true).ToList(); dbExaminationRegistrationList.ForEach(x => { var personalControl = personalControlList.Where(y => y.UserID == x.UserID && y.ExaminationBatchProjectID == x.ExaminationBatchProjectID && y.ExaminationProjectFeeID == x.ExaminationProjectFeeID).FirstOrDefault(); //var registerCount = studentListView.Where(y => y.ExaminationBatchProjectID == x.ExaminationBatchProjectID && y.ExaminationProjectFeeTypeID == x.ExaminationProjectFeeTypeID).Count(); //var examinationProjectCountLimitControl = examinationProjectCountLimitControlList.Where(y => y.ExaminationTypeID == x.ExaminationTypeID && y.StandardID == x.StandardID && y.SchoolyearNumID == x.SchoolyearNumID).FirstOrDefault(); //if(examinationProjectCountLimitControl.SubjectCountLimit) //if (x.RecordStatus != (int)EX_ExaminationRegistrationStatus.ForPay && x.RecordStatus != (int)EX_ExaminationRegistrationStatus.Paid) //{ // throw new Exception("只有待缴费或者已缴费的报名项目才能取消报名。"); //} if (x.ExaminationRegistrationConfirmID != null) { throw new Exception("待缴费的数据,只有未打包确认才能取消报名。"); } if (personalControl != null) { if (personalControl.EndDate.Value.AddDays(1) < DateTime.Now) { throw new Exception("待缴费的数据,只有在报名时间范围内才能取消报名。"); } } else if (x.EndDate.Value.AddDays(1) < DateTime.Now) { throw new Exception("待缴费的数据,只有在报名时间范围内才能取消报名。"); } }); //var wechatPayList = ExaminationSubjectDAL.wechatPayListRepository.Entities.Where(x => examinationRegistrationIDList.Contains(x.ExaminationRegistrationID.Value)).ToList(); //foreach (var wechatpay in wechatPayList) //{ // var examinationRegistration = dbExaminationRegistrationList.FirstOrDefault(x => x.ExaminationRegistrationID == wechatpay.ExaminationRegistrationID); // WechatHelper //} //UnitOfWork.Delete(x => examinationRegistrationIDList.Contains(x.ExaminationRegistrationID.Value)); //UnitOfWork.Delete(x => examinationRegistrationIDList.Contains(x.ExaminationRegistrationID)); } catch (Exception) { throw; } } public void ChangeAndDelete(List changeID, List deleteID) { try { var changeList = ExaminationSubjectDAL.examinationRegistrationRepository.Entities.Where(x => changeID.Contains(x.ExaminationRegistrationID)).ToList(); changeList.ForEach(x => { x.RecordStatus = (int)EX_ExaminationRegistrationStatus.OnRefund; }); this.UnitOfWork.Commit(); UnitOfWork.Delete(x => deleteID.Contains(x.ExaminationRegistrationID.Value)); UnitOfWork.Delete(x => deleteID.Contains(x.ExaminationRegistrationID)); } catch (Exception) { throw; } } public List GetWechatPayListByExaminationRegistrationID(List examinationRegistrationIDList) { return ExaminationSubjectDAL.wechatPayListRepository.Entities.Where(x => examinationRegistrationIDList.Contains(x.ExaminationRegistrationID.Value)).ToList(); } public List GetExaminationRegistrationPayViewByRegistrationID(List examinationRegistrationIDList) { return ExaminationSubjectDAL.GetExaminationRegistrationPayViewQueryable(x => examinationRegistrationIDList.Contains(x.ExaminationRegistrationID)).ToList(); } public ExaminationRegistrationPayView GetExaminationRegistrationPayViewByRegistrationID(Guid examinationRegistrationID) { return ExaminationSubjectDAL.GetExaminationRegistrationPayViewQueryable(x => x.ExaminationRegistrationID == examinationRegistrationID).FirstOrDefault(); } public IGridResultSet GetExaminationRegisterList(Guid UserID) { var result = ExamineApplyDAL.GetExaminationRegisterList(UserID).OrderBy(x => x.EndDate).ThenBy(x => x.StartDate).ThenBy(x => x.ExaminationDate).AsQueryable().ToGridResultSet(); return result; } public void CheckCanPay(Guid examinationRegistrationID) { var registration = ExamineApplyDAL.examinationRegistrationRepository.GetSingle(x => x.ExaminationRegistrationID == examinationRegistrationID, (x => x.EX_ExaminationProjectFeeType), (x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor)); if (registration.RecordStatus != (int)EX_ExaminationRegistrationStatus.ForPay && registration.RecordStatus != (int)EX_ExaminationRegistrationStatus.Paying) { throw new Exception("当前报名的考试并非待支付状态,不能支付。"); } if (registration.ExaminationRegistrationConfirmID.HasValue) { throw new Exception("当前报名的考试已产生确认单,不能在线支付,请线下进行支付。"); } if (registration.EX_ExaminationProjectFeeType == null) { throw new Exception("数据错误,请联系系统管理员。"); } var personalControl = ExamineApplyDAL.examinationBatchProjectPersonControlRepository.GetSingle(x => x.ExaminationBatchProjectID == registration.ExaminationBatchProjectID && x.UserID == registration.UserID && x.ExaminationProjectFeeID == registration.EX_ExaminationProjectFeeType.ExaminationProjectFeeID); var batchControl = ExamineApplyDAL.examinationBatchProjectControlRepository.GetSingle(x => x.ExaminationBatchProjectID == registration.ExaminationBatchProjectID && x.ExaminationProjectFeeID == registration.EX_ExaminationProjectFeeType.ExaminationProjectFeeID && x.SchoolyearID == registration.CF_Student.CF_Classmajor.CF_Grademajor.SchoolyearID && x.StandardID == registration.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.StandardID && x.CollegeID == registration.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID); var allControl = ExamineApplyDAL.examinationBatchProjectControlRepository.GetSingle(x => x.ExaminationBatchProjectID == registration.ExaminationBatchProjectID && x.ExaminationProjectFeeID == registration.EX_ExaminationProjectFeeType.ExaminationProjectFeeID && x.SchoolyearID == null && x.StandardID == null && x.CollegeID == null); var batchProject = ExamineApplyDAL.examinationBatchProjectRepository.GetSingle(x => x.ExaminationBatchProjectID == registration.ExaminationBatchProjectID); if (personalControl != null) { if (personalControl.IsOnlinePay != true) { throw new Exception("该次报名不支持线上缴费,请线下进行支付。"); } if (personalControl.StartDate > DateTime.Now || personalControl.EndDate.Value.AddDays(1) <= DateTime.Now) { throw new Exception("当前时间不在该次报名缴费时间范围,无法进行缴费。"); } } else { if (batchControl != null) { if (batchControl.IsOnlinePay != true) { throw new Exception("该次报名不支持线上缴费,请线下进行支付。"); } if (batchProject.StartDate > DateTime.Now || batchProject.EndDate.Value.AddDays(1) <= DateTime.Now) { throw new Exception("当前时间不在该次报名缴费时间范围,无法进行缴费。"); } } else { if (allControl != null) { if (allControl.IsOnlinePay != true) { throw new Exception("该次报名不支持线上缴费,请线下进行支付。"); } if (batchProject.StartDate > DateTime.Now || batchProject.EndDate.Value.AddDays(1) <= DateTime.Now) { throw new Exception("当前时间不在该次报名缴费时间范围,无法进行缴费。"); } } } } } /// /// 获取考试类型下拉(根据学年学期) /// /// /// /// /// /// public IGridResultSet GetExaminationTypeViewForComboGrid(ConfiguretView configuretView, Guid? schoolyearID, Guid? examinationBatchID, int pageIndex, int pageSize) { Expression> ebpexp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (schoolyearID.HasValue) { ebpexp = ebpexp.And(x => x.EX_ExaminationBatch.SchoolyearID == schoolyearID); } if (examinationBatchID.HasValue) { ebpexp = ebpexp.And(x => x.ExaminationBatchID == examinationBatchID); } var query = ExaminationTypeDAL.GetExaminationTypeViewBySchoolyearID(ebpexp); if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } return query.Distinct().OrderBy(x => x.Name).ToGridResultSet(pageIndex, pageSize); } public IGridResultSet GetCanRegisterExaminationTypeView(Guid? userID) { var subjectList = this.GetExaminationSubjectList(userID.Value); var examinationTypeIDList = subjectList.rows.Select(x => x.ExaminationTypeID).ToList(); Expression> exp = x => true; exp = exp.And(x => examinationTypeIDList.Contains(x.ExaminationTypeID)); var examinationTypeList = ExaminationTypeDAL.GetExaminationTypeView(exp); return examinationTypeList.ToGridResultSet(); } public bool CheckIsOnlinePay(Guid? examinationRegistrationID) { var isOnline = false; var examinationRegistration = ExamineApplyDAL.examinationRegistrationRepository.Entities.Where(x => x.ExaminationRegistrationID == examinationRegistrationID).FirstOrDefault(); var projectControl = GetProjectControlByRegistration(examinationRegistrationID); var personControl = ExamineApplyDAL.examinationBatchProjectPersonControlRepository.Entities.Where(x => x.ExaminationBatchProjectID == examinationRegistration.ExaminationBatchProjectID && x.UserID == examinationRegistration.UserID).FirstOrDefault(); if (projectControl.IsOnlinePay.Value || (personControl != null && personControl.IsOnlinePay.Value)) { isOnline = true; } else { isOnline = false; } return isOnline; } public EX_ExaminationBatchProjectControl GetProjectControlByRegistration(Guid? examinationRegistrationID) { //var isOnlinePay = false; var examinationRegistration = ExamineApplyDAL.examinationRegistrationRepository.Entities.Where(x => x.ExaminationRegistrationID == examinationRegistrationID).FirstOrDefault(); var student = StudentsDAL.GetStudentQueryable(x => x.UserID == examinationRegistration.UserID, x => true, x => true).FirstOrDefault(); var projectControl = ExamineApplyDAL.examinationBatchProjectControlRepository.Entities .Where(x => x.ExaminationBatchProjectID == examinationRegistration.ExaminationBatchProjectID && x.ExaminationProjectFeeID == examinationRegistration.ExaminationProjectFeeTypeID && (x.CollegeID == null || x.CollegeID == student.CollegeID) && (x.StandardID == null || x.StandardID == student.StandardID) &&( x.SchoolyearID == null || x.SchoolyearID == student.Years)) .FirstOrDefault(); return projectControl; } public void RefundApply(RefundView refundView, List examinationRegistrationIDs) { try { List examinationRegistrationList = ExamineApplyDAL.examinationRegistrationRepository.Entities.Where(x => examinationRegistrationIDs.Contains(x.ExaminationRegistrationID)).ToList(); examinationRegistrationList.ForEach(x => { x.RefundUserID = CustomPrincipal.Current == null ? x.UserID: CustomPrincipal.Current.UserID; x.RefundTime = DateTime.Now; x.BankName = refundView.BankName; x.CardNo = refundView.CardNo; x.RefundReason = refundView.RefundReason; x.RecordStatus = (int)EX_ExaminationRegistrationStatus.RefundApply; }); UnitOfWork.BatchUpdate(examinationRegistrationList); } catch (Exception) { throw; } } public RefundView GetRefundViewByUserID(Guid? userID) { RefundView refundView = new RefundView(); var stu = ExamineApplyDAL.StudentAccountRepository.Entities.Where(x => x.UserID == userID).FirstOrDefault(); refundView.BankName = stu.BankName; refundView.CardNo = stu.CardNo; return refundView; } } }