123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Linq.Expressions;
- using System.Text;
- using System.Transactions;
- using Bowin.Common.Linq;
- using Bowin.Common.Linq.Entity;
- using EMIS.CommonLogic.SystemServices;
- using EMIS.DataLogic.FeeManage;
- using EMIS.Entities;
- using EMIS.ViewModel;
- using EMIS.ViewModel.FeeManage;
- using MRMS.Utility;
- using EMIS.Utility.FormValidate;
- using EMIS.DataLogic.Repositories;
- namespace EMIS.CommonLogic.FeeManage
- {
- public class FeeServices : BaseServices, IFeeServices
- {
- public FeeDAL FeeDAL { get; set; }
- public InvalidReceiptDAL InvalidReceiptDAL { get; set; }
- public Lazy<IParameterServices> ParameterServices { get; set; }
- public ReceiptRepository ReceiptRepository { get; set; }
- public ReceiptView GetReceiptView()
- {
- ReceiptView receiptView = new ReceiptView();
- var userID = CustomPrincipal.Current.UserID;
- var receipt = ReceiptRepository.GetSingle(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE
- && x.UserID == userID);
- if (receipt != null)
- {
- receiptView.StartNo = receipt.ReceiptStartNo;
- receiptView.EndNo = receipt.ReceiptEndNo;
- }
- return receiptView;
- }
- public IGridResultSet<StudentFeeView> GetStudentFeeViewGrid(ConfiguretView conditionView, Guid? schoolyearID, Guid? examinationBatchID, Guid? examinationTypeID,
- Guid? examinationProjectID, int? schoolAreaID, Guid? collegeID, int? yearID, Guid? classmajorID, int? recordStatus, bool? isConfirm, DateTime? startDate, DateTime? endDate, int? payWay,
- DateTime? refundStartDate, DateTime? refundEndDate, int? pageIndex, int? pageSize)
- {
- Expression<Func<EX_ExaminationBatch, bool>> batchExp = (x => true);
- Expression<Func<EX_ExaminationType, bool>> typeExp = (x => true);
- Expression<Func<EX_ExaminationProject, bool>> projectExp = (x => true);
- Expression<Func<EX_ExaminationRegistration, bool>> registExp = (x => true);
- Expression<Func<CF_College, bool>> collegeExp = (x => true);
- Expression<Func<CF_Facultymajor, bool>> facultExp = (x => true);
- Expression<Func<CF_Grademajor, bool>> grademajorExp = (x => true);
- Expression<Func<CF_Classmajor, bool>> classmajorExp = (x => true);
- if (schoolyearID.HasValue)
- {
- batchExp = batchExp.And(x => x.SchoolyearID == schoolyearID);
- }
- if (examinationBatchID.HasValue)
- {
- batchExp = batchExp.And(x => x.ExaminationBatchID == examinationBatchID);
- }
- if (examinationTypeID.HasValue)
- {
- typeExp = typeExp.And(x => x.ExaminationTypeID == examinationTypeID);
- }
- if (examinationProjectID.HasValue)
- {
- projectExp = projectExp.And(x => x.ExaminationProjectID == examinationProjectID);
- }
- if (schoolAreaID.HasValue)
- {
- grademajorExp = grademajorExp.And(x => x.SchoolAreaID == schoolAreaID);
- }
- if (collegeID.HasValue)
- {
- facultExp = facultExp.And(x => x.CollegeID == collegeID);
- }
- if (yearID.HasValue)
- {
- grademajorExp = grademajorExp.And(x => x.SchoolyearID == yearID);
- }
- if (classmajorID.HasValue)
- {
- classmajorExp = classmajorExp.And(x => x.ClassmajorID == classmajorID);
- }
- if (recordStatus.HasValue)
- {
- registExp = registExp.And(x => x.RecordStatus == recordStatus);
- }
- if (isConfirm.HasValue)
- {
- if (isConfirm.Value)
- {
- registExp = registExp.And(x => x.ExaminationRegistrationConfirmID != null);
- }
- else
- {
- registExp = registExp.And(x => x.ExaminationRegistrationConfirmID == null);
- }
- }
- if (startDate.HasValue)
- {
- registExp = registExp.And(x => x.PayTime >= startDate);
- }
- if (endDate.HasValue)
- {
- var correctEndDate = endDate.Value.Date.AddDays(1);
- registExp = registExp.And(x => x.PayTime < correctEndDate);
- }
- if (refundStartDate.HasValue)
- {
- registExp = registExp.And(x => x.RefundTime >= refundStartDate);
- }
- if (refundEndDate.HasValue)
- {
- var correctRefundEndDate = refundEndDate.Value.Date.AddDays(1);
- registExp = registExp.And(x => x.RefundTime < correctRefundEndDate);
- }
- var query = FeeDAL.GetStudentFeeViewQueryable(batchExp, typeExp, projectExp, registExp, collegeExp, facultExp, grademajorExp, classmajorExp);
- if(payWay.HasValue)
- {
- query = query.Where(x => x.PayWay == payWay);
- }
- if (!string.IsNullOrEmpty(conditionView.ConditionValue) && !string.IsNullOrEmpty(conditionView.Attribute))
- {
- query = query.DynamicWhere(conditionView.Attribute, conditionView.Condition, conditionView.ConditionValue);
- }
- var result = GetQueryByDataRangeByCollege(query);
- return result.OrderBy(x => x.ExaminationTypeName).ThenBy(x => x.ExaminationProjectName).ThenBy(x => x.FeeTypeID).ThenBy(x => x.UserName).ToGridResultSet<StudentFeeView>(pageIndex, pageSize);
- }
- public List<StudentFeeView> GetStudentFeeViewList(ConfiguretView conditionView, Guid? schoolyearID, Guid? examinationBatchID, Guid? examinationTypeID,
- Guid? examinationProjectID, int? schoolAreaID, Guid? collegeID, int? yearID, Guid? classmajorID, int? recordStatus, bool? isConfirm, DateTime? startDate, DateTime? endDate, int? payWay,
- DateTime? refundStartDate, DateTime? refundEndDate, IList<Guid> examinationRegistrationIDList)
- {
- Expression<Func<EX_ExaminationBatch, bool>> batchExp = (x => true);
- Expression<Func<EX_ExaminationType, bool>> typeExp = (x => true);
- Expression<Func<EX_ExaminationProject, bool>> projectExp = (x => true);
- Expression<Func<EX_ExaminationRegistration, bool>> registExp = (x => true);
- Expression<Func<CF_College, bool>> collegeExp = (x => true);
- Expression<Func<CF_Facultymajor, bool>> facultExp = (x => true);
- Expression<Func<CF_Grademajor, bool>> grademajorExp = (x => true);
- Expression<Func<CF_Classmajor, bool>> classmajorExp = (x => true);
- if (schoolyearID.HasValue)
- {
- batchExp = batchExp.And(x => x.SchoolyearID == schoolyearID);
- }
- if (examinationBatchID.HasValue)
- {
- batchExp = batchExp.And(x => x.ExaminationBatchID == examinationBatchID);
- }
- if (examinationTypeID.HasValue)
- {
- typeExp = typeExp.And(x => x.ExaminationTypeID == examinationTypeID);
- }
- if (examinationProjectID.HasValue)
- {
- projectExp = projectExp.And(x => x.ExaminationProjectID == examinationProjectID);
- }
- if (schoolAreaID.HasValue)
- {
- grademajorExp = grademajorExp.And(x => x.SchoolAreaID == schoolAreaID);
- }
- if (collegeID.HasValue)
- {
- facultExp = facultExp.And(x => x.CollegeID == collegeID);
- }
- if (yearID.HasValue)
- {
- grademajorExp = grademajorExp.And(x => x.SchoolyearID == yearID);
- }
- if (classmajorID.HasValue)
- {
- classmajorExp = classmajorExp.And(x => x.ClassmajorID == classmajorID);
- }
- if (recordStatus.HasValue)
- {
- registExp = registExp.And(x => x.RecordStatus == recordStatus);
- }
- if (isConfirm.HasValue)
- {
- if (isConfirm.Value)
- {
- registExp = registExp.And(x => x.ExaminationRegistrationConfirmID != null);
- }
- else
- {
- registExp = registExp.And(x => x.ExaminationRegistrationConfirmID == null);
- }
- }
- if (startDate.HasValue)
- {
- registExp = registExp.And(x => x.PayTime >= startDate);
- }
- if (endDate.HasValue)
- {
- var correctEndDate = endDate.Value.Date.AddDays(1);
- registExp = registExp.And(x => x.PayTime < correctEndDate);
- }
- if (refundStartDate.HasValue)
- {
- registExp = registExp.And(x => x.RefundTime >= refundStartDate);
- }
- if (refundEndDate.HasValue)
- {
- var correctRefundEndDate = refundEndDate.Value.Date.AddDays(1);
- registExp = registExp.And(x => x.RefundTime < correctRefundEndDate);
- }
- if (examinationRegistrationIDList.Count > 0)
- {
- registExp = registExp.And(x => examinationRegistrationIDList.Contains(x.ExaminationRegistrationID));
- }
- var query = FeeDAL.GetStudentFeeViewQueryable(batchExp, typeExp, projectExp, registExp, collegeExp, facultExp, grademajorExp, classmajorExp);
- if (payWay.HasValue)
- {
- query = query.Where(x => x.PayWay == payWay);
- }
- if (!string.IsNullOrEmpty(conditionView.ConditionValue) && !string.IsNullOrEmpty(conditionView.Attribute))
- {
- query = query.DynamicWhere(conditionView.Attribute, conditionView.Condition, conditionView.ConditionValue);
- }
- var result = GetQueryByDataRangeByCollege(query);
- return result.OrderByDescending(x => x.SchoolyearCode).ThenBy(x => x.ExaminationBatchName)
- .ThenBy(x => x.ExaminationProjectName).ThenBy(x => x.ClassmajorName).ThenBy(x => x.UserName)
- .ToList();
- }
- public decimal GetStudentFeeViewListSum(ConfiguretView conditionView, Guid? schoolyearID, Guid? examinationBatchID, Guid? examinationTypeID,
- Guid? examinationProjectID, int? schoolAreaID, Guid? collegeID, int? yearID, Guid? classmajorID, int? recordStatus, bool? isConfirm, DateTime? startDate, DateTime? endDate, int? payWay,
- DateTime? refundStartDate, DateTime? refundEndDate)
- {
- Expression<Func<EX_ExaminationBatch, bool>> batchExp = (x => true);
- Expression<Func<EX_ExaminationType, bool>> typeExp = (x => true);
- Expression<Func<EX_ExaminationProject, bool>> projectExp = (x => true);
- Expression<Func<EX_ExaminationRegistration, bool>> registExp = (x => true);
- Expression<Func<CF_College, bool>> collegeExp = (x => true);
- Expression<Func<CF_Facultymajor, bool>> facultExp = (x => true);
- Expression<Func<CF_Grademajor, bool>> grademajorExp = (x => true);
- Expression<Func<CF_Classmajor, bool>> classmajorExp = (x => true);
- if (schoolyearID.HasValue)
- {
- batchExp = batchExp.And(x => x.SchoolyearID == schoolyearID);
- }
- if (examinationBatchID.HasValue)
- {
- batchExp = batchExp.And(x => x.ExaminationBatchID == examinationBatchID);
- }
- if (examinationTypeID.HasValue)
- {
- typeExp = typeExp.And(x => x.ExaminationTypeID == examinationTypeID);
- }
- if (examinationProjectID.HasValue)
- {
- projectExp = projectExp.And(x => x.ExaminationProjectID == examinationProjectID);
- }
- if (schoolAreaID.HasValue)
- {
- grademajorExp = grademajorExp.And(x => x.SchoolAreaID == schoolAreaID);
- }
- if (collegeID.HasValue)
- {
- facultExp = facultExp.And(x => x.CollegeID == collegeID);
- }
- if (yearID.HasValue)
- {
- grademajorExp = grademajorExp.And(x => x.SchoolyearID == yearID);
- }
- if (classmajorID.HasValue)
- {
- classmajorExp = classmajorExp.And(x => x.ClassmajorID == classmajorID);
- }
- if (recordStatus.HasValue)
- {
- registExp = registExp.And(x => x.RecordStatus == recordStatus);
- }
- if (isConfirm.HasValue)
- {
- if (isConfirm.Value)
- {
- registExp = registExp.And(x => x.ExaminationRegistrationConfirmID != null);
- }
- else
- {
- registExp = registExp.And(x => x.ExaminationRegistrationConfirmID == null);
- }
- }
- if (startDate.HasValue)
- {
- registExp = registExp.And(x => x.PayTime >= startDate);
- }
- if (endDate.HasValue)
- {
- var correctEndDate = endDate.Value.Date.AddDays(1);
- registExp = registExp.And(x => x.PayTime < correctEndDate);
- }
- if (refundStartDate.HasValue)
- {
- registExp = registExp.And(x => x.RefundTime >= refundStartDate);
- }
- if (refundEndDate.HasValue)
- {
- var correctRefundEndDate = refundEndDate.Value.Date.AddDays(1);
- registExp = registExp.And(x => x.RefundTime < correctRefundEndDate);
- }
- var query = FeeDAL.GetStudentFeeViewQueryable(batchExp, typeExp, projectExp, registExp, collegeExp, facultExp, grademajorExp, classmajorExp);
- if (payWay.HasValue)
- {
- query = query.Where(x => x.PayWay == payWay);
- }
- if (!string.IsNullOrEmpty(conditionView.ConditionValue) && !string.IsNullOrEmpty(conditionView.Attribute))
- {
- query = query.DynamicWhere(conditionView.Attribute, conditionView.Condition, conditionView.ConditionValue);
- }
- var result = GetQueryByDataRangeByCollege(query);
- return result.Sum(x => x.Fee) ?? 0;
- }
- public void SaveInvalidReceipt(string invalidReceiptNo)
- {
- var dupReceipt = InvalidReceiptDAL.InvalidReceiptRepository.GetSingle(x => x.ReceiptNo == invalidReceiptNo);
- if (dupReceipt != null)
- {
- throw new Exception("该收据已经作废,无需重复作废。");
- }
- var invalidReceipt = new EX_InvalidReceipt();
- invalidReceipt.InvalidReceiptID = Guid.NewGuid();
- invalidReceipt.ReceiptNo = invalidReceiptNo;
- this.SetNewStatus(invalidReceipt);
- this.UnitOfWork.Add(invalidReceipt);
- this.UnitOfWork.Commit();
- }
- public void SaveReceiptView(ReceiptView receiptView)
- {
- if (receiptView.StartNo.Length != receiptView.EndNo.Length)
- {
- throw new Exception("开始号码和结束号码长度不一致,请检查。");
- }
- var userID = CustomPrincipal.Current.UserID;
- var allReceiptList = this.ReceiptRepository.Entities.ToList();
- foreach (var oldReceipt in allReceiptList)
- {
- if (OperateSerialNo.CheckRangeContentedValue(oldReceipt.ReceiptStartNo, oldReceipt.ReceiptEndNo, receiptView.StartNo)
- || OperateSerialNo.CheckRangeContentedValue(oldReceipt.ReceiptStartNo, oldReceipt.ReceiptEndNo, receiptView.EndNo))
- {
- throw new Exception("收据号码全部或部分已经被使用,请重新输入。");
- }
- }
- this.UnloadReceipt();
- EX_Receipt receipt = new EX_Receipt();
- receipt.ReceiptID = Guid.NewGuid();
- receipt.UserID = userID;
- receipt.ReceiptStartNo = receiptView.StartNo;
- receipt.ReceiptEndNo = receiptView.EndNo;
- receipt.CurrentReceipNo = receiptView.StartNo;
- this.SetNewStatus(receipt);
- this.UnitOfWork.Update<EX_Receipt>(x => new EX_Receipt { RecordStatus = (int)SYS_STATUS.UNUSABLE }, x => x.UserID == userID);
- this.UnitOfWork.Add(receipt);
- this.UnitOfWork.Commit();
- //ParameterServices.Value.SaveTo(CF_ParameterType.ReceiptStartNo, receiptView.StartNo);
- //ParameterServices.Value.SaveTo(CF_ParameterType.ReceiptEndNo, receiptView.EndNo);
- //ParameterServices.Value.SaveTo(CF_ParameterType.CurrentReceiptNo, receiptView.StartNo);
- //this.UnitOfWork.Delete<EX_InvalidReceipt>(x => true);
- }
- public IGridResultSet<StudentFeeDetailView> GetStudentFeeDetailViewGrid(ConfiguretView conditionView, string examinationRegistConfirmNo, int? pageIndex, int? pageSize)
- {
- Expression<Func<EX_ExaminationRegistrationConfirm, bool>> confirmExp = (x => true);
- if (!string.IsNullOrEmpty(examinationRegistConfirmNo))
- {
- confirmExp = confirmExp.And(x => x.No == examinationRegistConfirmNo);
- }
- var query = FeeDAL.GetStudentFeeDetailViewQueryable(confirmExp);
- if (!string.IsNullOrEmpty(conditionView.ConditionValue) && !string.IsNullOrEmpty(conditionView.Attribute))
- {
- query = query.DynamicWhere(conditionView.Attribute, conditionView.Condition, conditionView.ConditionValue);
- }
- return query.OrderBy(x => x.ExaminationTypeName).ThenBy(x => x.ExaminationProjectName).ThenBy(x => x.FeeTypeID).ThenBy(x => x.UserName).ToGridResultSet(pageIndex, pageSize);
- }
- public decimal GetStudentFeeDetailTotal(ConfiguretView conditionView, string examinationRegistConfirmNo)
- {
- Expression<Func<EX_ExaminationRegistrationConfirm, bool>> confirmExp = (x => true);
- if (!string.IsNullOrEmpty(examinationRegistConfirmNo))
- {
- confirmExp = confirmExp.And(x => x.No == examinationRegistConfirmNo);
- }
- var query = FeeDAL.GetStudentFeeDetailViewQueryable(confirmExp);
- if (!string.IsNullOrEmpty(conditionView.ConditionValue) && !string.IsNullOrEmpty(conditionView.Attribute))
- {
- query = query.DynamicWhere(conditionView.Attribute, conditionView.Condition, conditionView.ConditionValue);
- }
- return query.Sum(x => x.Fee) ?? 0;
- }
- private string GetCurrentReceiptNo()
- {
- List<string> invalidReceiptNoList = InvalidReceiptDAL.GetInvalidReceipt().ToList();
- var userID = CustomPrincipal.Current.UserID;
- var receipt = ReceiptRepository.GetSingle(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE
- && x.UserID == userID);
- if (receipt == null)
- {
- throw new Exception("未装载收据号,请先装载。");
- }
- string currentReceiptNo = receipt.CurrentReceipNo;
- string receiptStartNo = receipt.ReceiptStartNo;
- string receiptEndNo = receipt.ReceiptEndNo;
- while (invalidReceiptNoList.Contains(currentReceiptNo))
- {
- currentReceiptNo = OperateSerialNo.CardSerialNoAddNum(currentReceiptNo, 1);
- }
- string nextReceiptNo = OperateSerialNo.CardSerialNoAddNum(currentReceiptNo, 1);
- while (invalidReceiptNoList.Contains(nextReceiptNo))
- {
- nextReceiptNo = OperateSerialNo.CardSerialNoAddNum(nextReceiptNo, 1);
- }
- if (!OperateSerialNo.CheckRangeContentedValue(receiptStartNo, receiptEndNo, currentReceiptNo))
- {
- throw new Exception("收据号已经用完,请重新设置。");
- }
- receipt.CurrentReceipNo = nextReceiptNo;
- this.SetModifyStatus(receipt);
- this.UnitOfWork.Commit();
- return currentReceiptNo;
- }
- public string GetProductId()
- {
- DateTime today = DateTime.Today;
- string productId = ParameterServices.Value.GetParameterValue(CF_ParameterType.ReceiptNo);
- int seed = 1;
- if (productId != null)
- {
- if (productId.Substring(0, 8) == today.ToString("yyyyMMdd"))
- {
- seed = Convert.ToInt32(productId.Substring(8, productId.Length - 8)) + 1;
- }
- }
- productId = today.ToString("yyyyMMdd") + seed.ToString().PadLeft(3, '0');
- ParameterServices.Value.SaveTo(CF_ParameterType.ReceiptNo, productId);
- return productId;
- }
- public PrintView PrintSave(string examinationRegistConfirmNo)
- {
- var examinationRegistConfirm = this.FeeDAL.ExaminationRegistrationConfirmRepository.GetSingle(x => x.No == examinationRegistConfirmNo);
- if (examinationRegistConfirm == null)
- {
- throw new Exception("打印错误,无法找到该确认单号,请检查输入。");
- }
- string currentReceiptNo = this.GetCurrentReceiptNo();
- DateTime nowTime = DateTime.Now;
- examinationRegistConfirm.ReceiptNo = currentReceiptNo;
- this.SetModifyStatus(examinationRegistConfirm);
- examinationRegistConfirm.Receiver = examinationRegistConfirm.ModifyUserID;
- using (var scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = IsolationLevel.RepeatableRead }))
- {
- this.UnitOfWork.Commit();
- this.UnitOfWork.Update<EX_ExaminationRegistration>((x => new EX_ExaminationRegistration { PayTime = nowTime, RecordStatus = (int)EX_ExaminationRegistrationStatus.Paid }),
- (x => x.ExaminationRegistrationConfirmID == examinationRegistConfirm.ExaminationRegistrationConfirmID));
- scope.Complete();
- }
- var printView = FeeDAL.GetPrintViewQueryable(x => x.No == examinationRegistConfirmNo).FirstOrDefault();
- return printView;
- }
- public PrintGDCXView PrintSaveGDCX(string examinationRegistConfirmNo)
- {
- var userName = CustomPrincipal.Current.Name;
- var examinationRegistConfirm = this.FeeDAL.ExaminationRegistrationConfirmRepository.GetSingle(x => x.No == examinationRegistConfirmNo);
- if (examinationRegistConfirm == null)
- {
- throw new Exception("打印错误,无法找到该确认单号,请检查输入。");
- }
- string currentReceiptNo = this.GetProductId();
- DateTime nowTime = DateTime.Now;
- examinationRegistConfirm.ReceiptNo = currentReceiptNo;
- this.SetModifyStatus(examinationRegistConfirm);
- examinationRegistConfirm.Receiver = examinationRegistConfirm.ModifyUserID;
- using (var scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = IsolationLevel.RepeatableRead }))
- {
- this.UnitOfWork.Commit();
- this.UnitOfWork.Update<EX_ExaminationRegistration>((x => new EX_ExaminationRegistration { PayTime = nowTime, RecordStatus = (int)EX_ExaminationRegistrationStatus.Paid }),
- (x => x.ExaminationRegistrationConfirmID == examinationRegistConfirm.ExaminationRegistrationConfirmID));
- scope.Complete();
- }
- var printView = FeeDAL.GetPrintGDCXViewQueryable(x => x.No == examinationRegistConfirmNo).FirstOrDefault();
- var projectView = FeeDAL.GetPrintProjectViewQueryable(x => x.No == examinationRegistConfirmNo).ToList();
- printView.projectList = projectView;
- printView.Operator = userName;
- return printView;
- }
- public void RefundOffline(RefundView refundView)
- {
- var user = CustomPrincipal.Current;
- var regist = this.FeeDAL.ExaminationRegistrationRepository.GetSingle(x => x.ExaminationRegistrationID == refundView.ExaminationRegistrationID);
- regist.BankName = refundView.BankName;
- regist.CardNo = refundView.CardNo;
- regist.RefundReason = refundView.RefundReason;
- regist.RecordStatus = (int)EX_ExaminationRegistrationStatus.Refunding;
- regist.RefundUserID = user.UserID;
- regist.RefundTime = DateTime.Now;
- this.SetModifyStatus(regist);
- UnitOfWork.Commit();
- }
- public RefundView GetRefundView(Guid examinationRegistrationID)
- {
- var refundView = this.FeeDAL.GetRefundViewQueryable(x => x.ExaminationRegistrationID == examinationRegistrationID
- //&& x.RecordStatus == (int)EX_ExaminationRegistrationStatus.Paid
- ).FirstOrDefault();
- return refundView;
- }
- public void RefundConfirm(Guid examinationRegistrationID)
- {
- var regist = this.FeeDAL.ExaminationRegistrationRepository
- .GetSingle(x => x.ExaminationRegistrationID == examinationRegistrationID);
- regist.RefundConfirmUserID = CustomPrincipal.Current.UserID;
- regist.RefundConfirmTime = DateTime.Now;
- regist.RecordStatus = (int)EX_ExaminationRegistrationStatus.Refunded;
- this.SetModifyStatus(regist);
- UnitOfWork.Commit();
- }
- private IQueryable<StudentFeeClassStatisticView> GetStudentFeeClassStatisticViewQueryable(ConfiguretView conditionView, Guid? schoolyearID,
- Guid? examinationBatchID, Guid? examinationTypeID, Guid? examinationProjectID, Guid? collegeID, int? yearID, int? standardID,
- Guid? classmajorID)
- {
- Expression<Func<EX_ExaminationBatch, bool>> batchExp = (x => true);
- Expression<Func<EX_ExaminationProject, bool>> projectExp = (x => true);
- Expression<Func<CF_Facultymajor, bool>> facultExp = (x => true);
- Expression<Func<CF_Grademajor, bool>> grademajorExp = (x => true);
- Expression<Func<CF_Classmajor, bool>> classmajorExp = (x => true);
- if (schoolyearID.HasValue)
- {
- batchExp = batchExp.And(x => x.SchoolyearID == schoolyearID);
- }
- if (examinationBatchID.HasValue)
- {
- batchExp = batchExp.And(x => x.ExaminationBatchID == examinationBatchID);
- }
- if (examinationTypeID.HasValue)
- {
- projectExp = projectExp.And(x => x.ExaminationTypeID == examinationTypeID);
- }
- if (examinationProjectID.HasValue)
- {
- projectExp = projectExp.And(x => x.ExaminationProjectID == examinationProjectID);
- }
- if (collegeID.HasValue)
- {
- facultExp = facultExp.And(x => x.CollegeID == collegeID);
- }
- if (yearID.HasValue)
- {
- grademajorExp = grademajorExp.And(x => x.SchoolyearID == yearID);
- }
- if (standardID.HasValue)
- {
- facultExp = facultExp.And(x => x.StandardID == standardID);
- }
- if (classmajorID.HasValue)
- {
- classmajorExp = classmajorExp.And(x => x.ClassmajorID == classmajorID);
- }
- var query = FeeDAL.GetStudentFeeClassStatisticViewQueryable(batchExp, projectExp, facultExp, grademajorExp, classmajorExp);
- if (!string.IsNullOrEmpty(conditionView.ConditionValue) && !string.IsNullOrEmpty(conditionView.Attribute))
- {
- query = query.DynamicWhere(conditionView.Attribute, conditionView.Condition, conditionView.ConditionValue);
- }
- var result = query;
- //GetQueryByDataRangeByCollege(query);
- return result;
- }
- private IQueryable<StudentFeeProjectStatisticView> GetStudentFeeProjectStatisticViewQueryable(ConfiguretView conditionView, Guid? schoolyearID,
- Guid? examinationBatchID, Guid? examinationTypeID, Guid? examinationProjectID,int? schoolAreaID, Guid? collegeID, int? yearID, int? standardID,
- Guid? classmajorID,DateTime? startdate, DateTime? enddate)
- {
- Expression<Func<EX_ExaminationBatch, bool>> batchExp = (x => true);
- Expression<Func<EX_ExaminationProject, bool>> projectExp = (x => true);
- Expression<Func<CF_Facultymajor, bool>> facultExp = (x => true);
- Expression<Func<CF_Grademajor, bool>> grademajorExp = (x => true);
- Expression<Func<CF_Classmajor, bool>> classmajorExp = (x => true);
- Expression<Func<EX_ExaminationRegistration, bool>> registExp = (x => true);
- if (schoolyearID.HasValue)
- {
- batchExp = batchExp.And(x => x.SchoolyearID == schoolyearID);
- }
- if (examinationBatchID.HasValue)
- {
- batchExp = batchExp.And(x => x.ExaminationBatchID == examinationBatchID);
- }
- if (examinationTypeID.HasValue)
- {
- projectExp = projectExp.And(x => x.ExaminationTypeID == examinationTypeID);
- }
- if (examinationProjectID.HasValue)
- {
- projectExp = projectExp.And(x => x.ExaminationProjectID == examinationProjectID);
- }
- if (schoolAreaID.HasValue)
- {
- grademajorExp = grademajorExp.And(x => x.SchoolAreaID == schoolAreaID);
- }
- if (collegeID.HasValue)
- {
- facultExp = facultExp.And(x => x.CollegeID == collegeID);
- }
- if (yearID.HasValue)
- {
- grademajorExp = grademajorExp.And(x => x.SchoolyearID == yearID);
- }
- if (standardID.HasValue)
- {
- facultExp = facultExp.And(x => x.StandardID == standardID);
- }
- if (classmajorID.HasValue)
- {
- classmajorExp = classmajorExp.And(x => x.ClassmajorID == classmajorID);
- }
- if (startdate.HasValue)
- {
- registExp = registExp.And(x => x.PayTime > startdate);
- }
- if (enddate.HasValue)
- {
- var correctEndDate = enddate.Value.Date.AddDays(1);
- registExp = registExp.And(x => x.PayTime < correctEndDate);
- }
- var query = FeeDAL.GetStudentFeeProjectStatisticViewQueryable(batchExp, projectExp, facultExp, grademajorExp, classmajorExp, registExp);
- if (!string.IsNullOrEmpty(conditionView.ConditionValue) && !string.IsNullOrEmpty(conditionView.Attribute))
- {
- query = query.DynamicWhere(conditionView.Attribute, conditionView.Condition, conditionView.ConditionValue);
- }
- return query;
- }
- public IGridResultSet<StudentFeeClassStatisticView> GetStudentFeeClassStatisticViewGrid(ConfiguretView conditionView, Guid? schoolyearID,
- Guid? examinationBatchID, Guid? examinationTypeID, Guid? examinationProjectID, Guid? collegeID, int? yearID, int? standardID,
- Guid? classmajorID, int? pageIndex, int? pageSize)
- {
- var result = this.GetStudentFeeClassStatisticViewQueryable(conditionView, schoolyearID, examinationBatchID,
- examinationTypeID, examinationProjectID, collegeID, yearID, standardID, classmajorID);
- return result.OrderByDescending(x => x.CollegeName).ThenBy(x => x.ClassmajorName)
- .ThenBy(x => x.ExaminationTypeName).ThenBy(x => x.ExaminationProjectName).ThenBy(x => x.FeeTypeID)
- .ToGridResultSet(pageIndex, pageSize);
- }
- public List<StudentFeeClassStatisticView> GetStudentFeeClassStatisticViewList(ConfiguretView conditionView, Guid? schoolyearID,
- Guid? examinationBatchID, Guid? examinationTypeID, Guid? examinationProjectID, Guid? collegeID, int? yearID, int? standardID, Guid? classmajorID)
- {
- var result = this.GetStudentFeeClassStatisticViewQueryable(conditionView, schoolyearID, examinationBatchID,
- examinationTypeID, examinationProjectID, collegeID, yearID, standardID, classmajorID);
- return result.OrderByDescending(x => x.CollegeName).ThenBy(x => x.ClassmajorName)
- .ThenBy(x => x.ExaminationTypeName).ThenBy(x => x.ExaminationProjectName).ThenBy(x => x.FeeTypeID)
- .ToList();
- }
- public StudentFeeStatisticTotalView GetStudentFeeClassStatisticViewTotal(ConfiguretView conditionView, Guid? schoolyearID,
- Guid? examinationBatchID, Guid? examinationTypeID, Guid? examinationProjectID, Guid? collegeID, int? yearID, int? standardID, Guid? classmajorID)
- {
- var queryable = this.GetStudentFeeClassStatisticViewQueryable(conditionView, schoolyearID, examinationBatchID,
- examinationTypeID, examinationProjectID, collegeID, yearID, standardID, classmajorID);
- var resultQueryable = (from statistic in queryable
- select new StudentFeeStatisticTotalView
- {
- TotalRegistCount = queryable.Sum(x => x.TotalRegistCount),
- TotalRegistAmount = queryable.Sum(x => x.TotalRegistAmount),
- TotalPaidCount = queryable.Sum(x => x.TotalPaidCount),
- TotalPaidAmount = queryable.Sum(x => x.TotalPaidAmount),
- TotalRefundCount = queryable.Sum(x => x.TotalRefundCount),
- TotalRefundAmount = queryable.Sum(x => x.TotalRefundAmount),
- TotalRefundApplyCount = queryable.Sum(x => x.TotalRefundApplyCount),
- TotalRefundApplyAmount = queryable.Sum(x => x.TotalRefundApplyAmount),
- TotalRefundingCount = queryable.Sum(x => x.TotalRefundingCount),
- TotalRefundingAmount = queryable.Sum(x => x.TotalRefundingAmount)
- });
- return resultQueryable.First();
- }
- public IGridResultSet<StudentFeeProjectStatisticView> GetStudentFeeProjectStatisticViewGrid(ConfiguretView conditionView, Guid? schoolyearID,
- Guid? examinationBatchID, Guid? examinationTypeID, Guid? examinationProjectID, int? schoolAreaID, Guid? collegeID, int? yearID, int? standardID, Guid? classmajorID, DateTime? startdate, DateTime? enddate,
- int? pageIndex, int? pageSize)
- {
- var result = this.GetStudentFeeProjectStatisticViewQueryable(conditionView, schoolyearID, examinationBatchID,
- examinationTypeID, examinationProjectID, schoolAreaID, collegeID, yearID, standardID, classmajorID, startdate, enddate);
- return result.OrderByDescending(x => x.ExaminationBatchName)
- .ThenBy(x => x.ExaminationTypeName).ThenBy(x => x.ExaminationProjectName).ThenBy(x => x.FeeTypeID)
- .ToGridResultSet(pageIndex, pageSize);
- }
- public List<StudentFeeProjectStatisticView> GetStudentFeeProjectStatisticViewList(ConfiguretView conditionView, Guid? schoolyearID, Guid? examinationBatchID,
- Guid? examinationTypeID, Guid? examinationProjectID,int? schoolAreaID, Guid? collegeID, int? yearID, int? standardID, Guid? classmajorID, DateTime? startdate, DateTime? enddate)
- {
- var result = this.GetStudentFeeProjectStatisticViewQueryable(conditionView, schoolyearID, examinationBatchID,
- examinationTypeID, examinationProjectID, schoolAreaID, collegeID, yearID, standardID, classmajorID, startdate, enddate);
- return result.OrderByDescending(x => x.ExaminationBatchName)
- .ThenBy(x => x.ExaminationTypeName).ThenBy(x => x.ExaminationProjectName).ThenBy(x => x.FeeTypeID)
- .ToList();
- }
- public StudentFeeStatisticTotalView GetStudentFeeProjectStatisticViewTotal(ConfiguretView conditionView, Guid? schoolyearID, Guid? examinationBatchID,
- Guid? examinationTypeID, Guid? examinationProjectID, int? schoolAreaID, Guid? collegeID, int? yearID, int? standardID, Guid? classmajorID, DateTime? startdate, DateTime? enddate)
- {
- var queryable = this.GetStudentFeeProjectStatisticViewQueryable(conditionView, schoolyearID, examinationBatchID,
- examinationTypeID, examinationProjectID, schoolAreaID, collegeID, yearID, standardID, classmajorID, startdate, enddate);
- var resultQueryable = (from statistic in queryable
- select new StudentFeeStatisticTotalView
- {
- TotalRegistCount = queryable.Sum(x => x.TotalRegistCount),
- TotalRegistAmount = queryable.Sum(x => x.TotalRegistAmount),
- TotalPaidCount = queryable.Sum(x => x.TotalPaidCount),
- TotalPaidAmount = queryable.Sum(x => x.TotalPaidAmount),
- TotalRefundCount = queryable.Sum(x => x.TotalRefundCount),
- TotalRefundAmount = queryable.Sum(x => x.TotalRefundAmount),
- TotalRefundApplyCount = queryable.Sum(x => x.TotalRefundApplyCount),
- TotalRefundApplyAmount = queryable.Sum(x => x.TotalRefundApplyAmount),
- TotalRefundingCount = queryable.Sum(x => x.TotalRefundingCount),
- TotalRefundingAmount = queryable.Sum(x => x.TotalRefundingAmount)
- });
- return resultQueryable.First();
- }
- private IQueryable<FinanceReportView> GetFinanceReportViewQueryabled(ConfiguretView conditionView, Guid? schoolyearID, DateTime? payTimeStart, DateTime? payTimeEnd,
- Guid? examinationProjectID, Guid? receiverID)
- {
- Expression<Func<EX_ExaminationBatch, bool>> batchExp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- Expression<Func<EX_ExaminationProject, bool>> projectExp = (x => true);
- Expression<Func<EX_ExaminationRegistration, bool>> registExp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (schoolyearID.HasValue)
- {
- batchExp = batchExp.And(x => x.SchoolyearID == schoolyearID);
- }
- if (payTimeStart.HasValue)
- {
- registExp = registExp.And(x => x.PayTime >= payTimeStart);
- }
- if (payTimeEnd.HasValue)
- {
- var correctPayTimeEnd = payTimeEnd.Value.Date.AddDays(1);
- registExp = registExp.And(x => x.PayTime < correctPayTimeEnd);
- }
- if (examinationProjectID.HasValue)
- {
- projectExp = projectExp.And(x => x.ExaminationProjectID == examinationProjectID);
- }
- if (receiverID.HasValue)
- {
- registExp = registExp.And(x => x.EX_ExaminationRegistrationConfirm.Receiver == receiverID);
- }
- var query = FeeDAL.GetFinanceReportViewQueryable(batchExp, projectExp, registExp);
- if (!string.IsNullOrEmpty(conditionView.ConditionValue) && !string.IsNullOrEmpty(conditionView.Attribute))
- {
- query = query.DynamicWhere(conditionView.Attribute, conditionView.Condition, conditionView.ConditionValue);
- }
- return query.OrderBy(x => x.PayTimeOrder).ThenBy(x => x.ReceiptNo.Length).ThenBy(x => x.ReceiptNo);
- }
- public IGridResultSet<FinanceReportView> GetFinanceReportViewGrid(ConfiguretView conditionView, Guid? schoolyearID, DateTime? payTimeStart, DateTime? payTimeEnd,
- Guid? examinationProjectID, Guid? receiverID, int? pageIndex, int? pageSize)
- {
- var query = this.GetFinanceReportViewQueryabled(conditionView, schoolyearID, payTimeStart, payTimeEnd, examinationProjectID, receiverID);
- return query.ToGridResultSet(pageIndex, pageSize);
- }
- public List<FinanceReportView> GetFinanceReportViewList(ConfiguretView conditionView, Guid? schoolyearID, DateTime? payTimeStart, DateTime? payTimeEnd,
- Guid? examinationProjectID, Guid? receiverID)
- {
- var query = this.GetFinanceReportViewQueryabled(conditionView, schoolyearID, payTimeStart, payTimeEnd, examinationProjectID, receiverID);
- return query.ToList();
- }
- public FinanceReportTotalView GetFinanceReportViewTotal(ConfiguretView conditionView, Guid? schoolyearID, DateTime? payTimeStart, DateTime? payTimeEnd, Guid? examinationProjectID, Guid? receiverID)
- {
- var query = this.GetFinanceReportViewQueryabled(conditionView, schoolyearID, payTimeStart, payTimeEnd, examinationProjectID, receiverID);
- var resultQueryable = (from statistic in query
- select new FinanceReportTotalView
- {
- TotalCount = query.Sum(x => x.StudentCount),
- TotalAmount = query.Sum(x => x.Amount)
- });
- return resultQueryable.First();
- }
- public void UnloadReceipt()
- {
- var userID = CustomPrincipal.Current.UserID;
- var availableReceiptList = this.ReceiptRepository.GetList(x => x.RecordStatus == (int)SYS_STATUS.USABLE
- && x.UserID == userID).ToList();
- availableReceiptList.ForEach(x => {
- x.ReceiptEndNo = OperateSerialNo.CardSerialNoAddNum(x.CurrentReceipNo, -1);
- x.CurrentReceipNo = x.ReceiptEndNo;
- x.RecordStatus = (int)SYS_STATUS.UNUSABLE;
- this.SetModifyStatus(x);
- });
- this.UnitOfWork.Commit();
- }
- public void ApproveRefund(RefundApproveView refundApproveView)
- {
- var examinationRegistrationIDList = refundApproveView. ExaminationRegistrationIDs.Split(',').Where(x => x.IndexOf("-") >= 0).Select(x => new Guid(x)).ToList();
- var examinationRegistrationList = FeeDAL.ExaminationRegistrationRepository.Entities.Where(x => examinationRegistrationIDList.Contains(x.ExaminationRegistrationID)).ToList();
- try
- {
- if (refundApproveView.ApproveStatus == (int)CF_RefundFeeApproval.Agree)
- {
- examinationRegistrationList.ForEach(x =>
- {
- x.ModifyTime = DateTime.Now;
- x.ModifyUserID = CustomPrincipal.Current.UserID;
- x.RecordStatus = (int)EX_ExaminationRegistrationStatus.Refunding;
- });
- }
- else if (refundApproveView.ApproveStatus == (int)CF_RefundFeeApproval.Returnback)
- {
- examinationRegistrationList.ForEach(x =>
- {
- x.RecordStatus = (int)EX_ExaminationRegistrationStatus.Paid;
- x.ModifyTime = DateTime.Now;
- x.ModifyUserID = CustomPrincipal.Current.UserID;
- });
- }
- UnitOfWork.BatchUpdate<EX_ExaminationRegistration>(examinationRegistrationList);
- }
- catch (Exception)
- {
- throw;
- }
- }
- }
- }
|