123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619 |
- 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<ISchoolYearServices> 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<ExaminationApplyView> GetExaminationSubjectList(Guid UserID)
- {
- Expression<Func<EX_ExaminationBatch, bool>> batchExp = (x => true);
- Expression<Func<EX_ExaminationProject, bool>> projectExp = (x => true);
- Expression<Func<ER_ExaminationScore, bool>> scoreExp = (x => true);
- Expression<Func<CF_Facultymajor, bool>> facutyExp = (x => true);
- Expression<Func<CF_Grademajor, bool>> gradeExp = (x => true);
- Expression<Func<CF_Student, bool>> 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<Guid?, string> ProjectFeeIDAndFeeType = new Dictionary<Guid?, string>();
- 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<int?, int?> canResitCountDic = new Dictionary<int?, int?>();
- List<int?> cannotResitSubject = new List<int?>();
- List<Guid?> cannotResitProject = new List<Guid?>();
- 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<ExaminationApplyView>().ToGridResultSet();
- }
- public StudentListView GetRegisterViewByExaminationBatchProjectID(Guid? examinationBatchProjectID, Guid? userID)
- {
- Expression<Func<EX_ExaminationBatch, bool>> batchExp = (x => true);
- Expression<Func<EX_ExaminationProject, bool>> projectExp = (x => true);
- Expression<Func<ER_ExaminationScore, bool>> scoreExp = (x => true);
- Expression<Func<CF_Facultymajor, bool>> facutyExp = (x => true);
- Expression<Func<CF_Grademajor, bool>> gradeExp = (x => true);
- Expression<Func<CF_Student, bool>> 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<int?, int?> canResitCountDic = new Dictionary<int?, int?>();
- List<int?> cannotResitSubject = new List<int?>();
- 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<int?> feeTypeIDList = examinationProjectFeeTypeList.Select(x => x.FeeTypeID).Distinct().ToList();
- Dictionary<string, string> feeTypeDic = new Dictionary<string, string>();
- //如果缴费项目是补考,并且存在一个考试科目补考次数已经达到或者超过限制的次数,则不能报名补考的缴费项
- //如果没有对应的补考成绩,不能报名缴费项目是补考的
- 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<Func<EX_ExaminationBatch, bool>> batchExp = (x => true);
- Expression<Func<EX_ExaminationProject, bool>> projectExp = (x => true);
- Expression<Func<ER_ExaminationScore, bool>> scoreExp = (x => true);
- Expression<Func<CF_Facultymajor, bool>> facutyExp = (x => true);
- Expression<Func<CF_Grademajor, bool>> gradeExp = (x => true);
- Expression<Func<CF_Student, bool>> 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<EX_ExaminationRegistration> RegistrationList = new List<EX_ExaminationRegistration>();
- //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<int?> cannotResitSubject = new List<int?>();
- 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<Guid?, int?> dicControl = new Dictionary<Guid?, int?>();
- 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;
- }
- }
- /// <summary>
- /// 待缴费的数据取消报名需要进行判断
- /// </summary>
- /// <param name="examinationRegistrationIDList"></param>
- public void CheckCanCancelOnline(List<Guid> 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<CF_WechatPayList>(x => examinationRegistrationIDList.Contains(x.ExaminationRegistrationID.Value));
- //UnitOfWork.Delete<EX_ExaminationRegistration>(x => examinationRegistrationIDList.Contains(x.ExaminationRegistrationID));
- }
- catch (Exception)
- {
- throw;
- }
- }
- public void ChangeAndDelete(List<Guid> changeID, List<Guid> 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<CF_WechatPayList>(x => deleteID.Contains(x.ExaminationRegistrationID.Value));
- UnitOfWork.Delete<EX_ExaminationRegistration>(x => deleteID.Contains(x.ExaminationRegistrationID));
- }
- catch (Exception)
- {
- throw;
- }
- }
- public List<CF_WechatPayList> GetWechatPayListByExaminationRegistrationID(List<Guid> examinationRegistrationIDList)
- {
- return ExaminationSubjectDAL.wechatPayListRepository.Entities.Where(x => examinationRegistrationIDList.Contains(x.ExaminationRegistrationID.Value)).ToList();
- }
- public List<ExaminationRegistrationPayView> GetExaminationRegistrationPayViewByRegistrationID(List<Guid> 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<ExaminationRegisView> GetExaminationRegisterList(Guid UserID)
- {
-
- var result = ExamineApplyDAL.GetExaminationRegisterList(UserID).OrderBy(x => x.EndDate).ThenBy(x => x.StartDate).ThenBy(x => x.ExaminationDate).AsQueryable<ExaminationRegisView>().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("当前时间不在该次报名缴费时间范围,无法进行缴费。");
- }
- }
- }
- }
- }
- /// <summary>
- /// 获取考试类型下拉(根据学年学期)
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="schoolyearID"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<ExaminationTypeView> GetExaminationTypeViewForComboGrid(ConfiguretView configuretView, Guid? schoolyearID, Guid? examinationBatchID, int pageIndex, int pageSize)
- {
- Expression<Func<EX_ExaminationBatchProject, bool>> 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<ExaminationTypeView>(pageIndex, pageSize);
- }
- public IGridResultSet<ExaminationTypeView> GetCanRegisterExaminationTypeView(Guid? userID)
- {
- var subjectList = this.GetExaminationSubjectList(userID.Value);
- var examinationTypeIDList = subjectList.rows.Select(x => x.ExaminationTypeID).ToList();
- Expression<Func<EX_ExaminationType, bool>> exp = x => true;
- exp = exp.And(x => examinationTypeIDList.Contains(x.ExaminationTypeID));
- var examinationTypeList = ExaminationTypeDAL.GetExaminationTypeView(exp);
- return examinationTypeList.ToGridResultSet<ExaminationTypeView>();
- }
- 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<Guid> examinationRegistrationIDs)
- {
- try
- {
- List<EX_ExaminationRegistration> 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<EX_ExaminationRegistration>(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;
- }
- }
- }
|