123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885 |
- using System;
- using System.Web;
- using System.Collections.Generic;
- using System.Linq;
- using System.Linq.Expressions;
- using System.Text;
- using System.Text.RegularExpressions;
- using Bowin.Common.Linq;
- using Bowin.Common.Linq.Entity;
- using EMIS.ViewModel;
- using EMIS.ViewModel.WorkflowManage;
- using EMIS.ViewModel.ChargeManage.ChargeSituation;
- using EMIS.ViewModel.Students;
- using EMIS.Entities;
- using EMIS.DataLogic.ChargeManage.ChargeSituation;
- using EMIS.DataLogic.Repositories;
- using EMIS.CommonLogic.StudentManage.StudentStatistics;
- namespace EMIS.CommonLogic.ChargeManage.ChargeSituation
- {
- public class StudentChargeServices : BaseServices, IStudentChargeServices
- {
- public StudentChargeDAL StudentChargeDAL { get; set; }
- public ChargeProjectDAL ChargeProjectDAL { get; set; }
- public ChargeStandardDAL ChargeStandardDAL { get; set; }
- public StudentChargeRepository StudentChargeRepository { get; set; }
- public IInSchoolSettingServices InSchoolSettingServices { get; set; }
- public IChargeDelayServices IChargeDelayServices { get; set; }
- /// <summary>
- /// 查询应收名单信息View
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="collegeID"></param>
- /// <param name="yearID"></param>
- /// <param name="standardID"></param>
- /// <param name="educationID"></param>
- /// <param name="learningformID"></param>
- /// <param name="learnSystem"></param>
- /// <param name="chargeYearID"></param>
- /// <param name="chargeProjectID"></param>
- /// <param name="chargeTagID"></param>
- /// <param name="inSchoolStatus"></param>
- /// <param name="isDream"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<StudentChargeView> GetStudentChargeViewGrid(ConfiguretView configuretView, Guid? collegeID, int? yearID,
- int? standardID, int? educationID, int? learningformID, string learnSystem, int? chargeYearID,
- Guid? chargeProjectID, int? chargeTagID, int? inSchoolStatus, int? isDream, int pageIndex, int pageSize)
- {
- //应收名单
- Expression<Func<EC_StudentCharge, bool>> expStudentCharge = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (chargeYearID.HasValue)
- {
- expStudentCharge = expStudentCharge.And(x => x.ChargeYear == chargeYearID);
- }
- if (chargeProjectID.HasValue)
- {
- expStudentCharge = expStudentCharge.And(x => x.ChargeProjectID == chargeProjectID);
- }
- if (chargeTagID.HasValue)
- {
- expStudentCharge = expStudentCharge.And(x => x.ChargeTag == chargeTagID);
- }
- Expression<Func<CF_Student, bool>> expStudent = (x => true);
- if (isDream.HasValue)
- {
- //expStudent = expStudent.And(x => x.IsDreamProject == (isDream == 1 ? true : false));
- if (isDream.Value == (int)CF_GeneralPurpose.IsYes)
- {
- expStudent = expStudent.And(x => x.CF_StudentProfile.IsDreamProject == true);
- }
- if (isDream.Value == (int)CF_GeneralPurpose.IsNo)
- {
- expStudent = expStudent.And(x => x.CF_StudentProfile.IsDreamProject != true);
- }
- }
- if (inSchoolStatus != null && inSchoolStatus > -1)
- {
- var inschoolStatusList = InSchoolSettingServices.GetInschoolStatusList(true);
- if (inSchoolStatus == 1)
- {
- //表示在校
- expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
- }
- if (inSchoolStatus == 0)
- {
- //不在校
- expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
- }
- }
- var query = StudentChargeDAL.GetStudentChargeViewQueryAble(expStudentCharge, expStudent);
- if (collegeID.HasValue)
- {
- query = query.Where(x => x.CollegeID == collegeID);
- }
- if (yearID.HasValue)
- {
- query = query.Where(x => x.GradeStr == yearID);
- }
- if (standardID.HasValue)
- {
- query = query.Where(x => x.StandardID == standardID);
- }
- if (educationID.HasValue)
- {
- query = query.Where(x => x.EducationID == educationID);
- }
- if (learningformID.HasValue)
- {
- query = query.Where(x => x.LearningformID == learningformID);
- }
- if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
- {
- var LearnSystems = Convert.ToDecimal(learnSystem);
- query = query.Where(x => x.LearnSystem == LearnSystems);
- }
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.StudentNo.Length)
- .ThenBy(x => x.StudentNo).ThenBy(x => x.ChargeProjectStr)
- .ThenByDescending(x => x.ChargeYear)
- .ToGridResultSet<StudentChargeView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询应收名单信息List
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="collegeID"></param>
- /// <param name="yearID"></param>
- /// <param name="chargeYearID"></param>
- /// <param name="standardID"></param>
- /// <param name="educationID"></param>
- /// <param name="learningformID"></param>
- /// <param name="chargeProjectID"></param>
- /// <returns></returns>
- public List<StudentChargeView> GetStudentChargeViewGrid(ConfiguretView configuretView, Guid? collegeID, int? yearID,
- int? standardID, int? educationID, int? learningformID, string learnSystem, int? chargeYearID, Guid? chargeProjectID,
- int? chargeTagID, int? inSchoolStatus, int? isDream)
- {
- //应收名单
- Expression<Func<EC_StudentCharge, bool>> expStudentCharge = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (chargeYearID.HasValue)
- {
- expStudentCharge = expStudentCharge.And(x => x.ChargeYear == chargeYearID);
- }
- if (chargeProjectID.HasValue)
- {
- expStudentCharge = expStudentCharge.And(x => x.ChargeProjectID == chargeProjectID);
- }
- if (chargeTagID.HasValue)
- {
- expStudentCharge = expStudentCharge.And(x => x.ChargeTag == chargeTagID);
- }
- Expression<Func<CF_Student, bool>> expStudent = (x => true);
- if (isDream.HasValue)
- {
- //expStudent = expStudent.And(x => x.IsDreamProject == (isDream == 1 ? true : false));
- if (isDream.Value == (int)CF_GeneralPurpose.IsYes)
- {
- expStudent = expStudent.And(x => x.CF_StudentProfile.IsDreamProject == true);
- }
- if (isDream.Value == (int)CF_GeneralPurpose.IsNo)
- {
- expStudent = expStudent.And(x => x.CF_StudentProfile.IsDreamProject != true);
- }
- }
- if (inSchoolStatus != null && inSchoolStatus > -1)
- {
- var inschoolStatusList = InSchoolSettingServices.GetInschoolStatusList(true);
- if (inSchoolStatus == 1)
- {
- //表示在校
- expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
- }
- if (inSchoolStatus == 0)
- {
- //不在校
- expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
- }
- }
- var query = StudentChargeDAL.GetStudentChargeViewQueryAble(expStudentCharge, expStudent);
- if (collegeID.HasValue)
- {
- query = query.Where(x => x.CollegeID == collegeID);
- }
- if (yearID.HasValue)
- {
- query = query.Where(x => x.GradeStr == yearID);
- }
- if (standardID.HasValue)
- {
- query = query.Where(x => x.StandardID == standardID);
- }
- if (educationID.HasValue)
- {
- query = query.Where(x => x.EducationID == educationID);
- }
- if (learningformID.HasValue)
- {
- query = query.Where(x => x.LearningformID == learningformID);
- }
- if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
- {
- var LearnSystems = Convert.ToDecimal(learnSystem);
- query = query.Where(x => x.LearnSystem == LearnSystems);
- }
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.StudentNo.Length)
- .ThenBy(x => x.StudentNo).ThenBy(x => x.ChargeProjectStr)
- .ThenByDescending(x => x.ChargeYear)
- .ToList();
- }
- /// <summary>
- /// 查询应收名单信息View
- /// </summary>
- /// <param name="studentChargeID"></param>
- /// <returns></returns>
- public StudentChargeView GetStudentChargeView(Guid? studentChargeID)
- {
- var query = StudentChargeDAL.GetStudentChargeViewQueryAble(x => x.StudentChargeID == studentChargeID, x => true)
- .SingleOrDefault();
- return query;
- }
- /// <summary>
- /// 查询应收名单实体
- /// </summary>
- /// <param name="studentChargeID"></param>
- /// <returns></returns>
- public EC_StudentCharge GetStudentCharge(Guid? studentChargeID)
- {
- //查询条件
- Expression<Func<EC_StudentCharge, bool>> expression = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- expression = (x => x.StudentChargeID == studentChargeID);
- return StudentChargeDAL.StudentChargeRepository.GetSingle(expression);
- }
- /// <summary>
- /// 获取学生信息视图
- /// </summary>
- /// <param name="UserID"></param>
- /// <returns></returns>
- public StudentsView GetStudentView(Guid? userID)
- {
- var query = StudentChargeDAL.GetStudentViewQueryAble(x => x.UserID == userID);
- return query.SingleOrDefault();
- }
- /// <summary>
- /// 查询收费项目信息
- /// </summary>
- /// <param name="chargeProjectID"></param>
- /// <returns></returns>
- public ChargeProjectView GetChargeProjectView(Guid? chargeProjectID)
- {
- Expression<Func<EC_ChargeProject, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- exp = exp.And(x => x.ChargeProjectID == chargeProjectID);
- var query = ChargeProjectDAL.GetChargeProjectViewQueryAble(exp);
- return query.SingleOrDefault();
- }
- /// <summary>
- /// 查询应收名单对应的收费标准
- /// </summary>
- /// <param name="userID"></param>
- /// <param name="chargeYearID"></param>
- /// <param name="chargeProjectID"></param>
- /// <returns></returns>
- public ChargeStandardView StudentChargeChargeStandard(Guid? userID, int? chargeYearID, Guid? chargeProjectID)
- {
- try
- {
- //查询用户ID对应的信息
- var studentView = StudentChargeDAL.GetStudentViewQueryAble(x => x.UserID == userID).SingleOrDefault();
- //收费标准
- Expression<Func<EC_ChargeStandard, bool>> expChargeStandard = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (userID.HasValue)
- {
- if (studentView != null)
- {
- expChargeStandard = expChargeStandard.And(x => x.GrademajorID == studentView.GradeMajorID);
- }
- }
- if (chargeYearID.HasValue)
- {
- expChargeStandard = expChargeStandard.And(x => x.ChargeYear == chargeYearID);
- }
- if (chargeProjectID.HasValue)
- {
- expChargeStandard = expChargeStandard.And(x => x.ChargeProjectID == chargeProjectID);
- }
- var chargeStandardView = StudentChargeDAL.GetStudentChargeChargeStandard(expChargeStandard)
- .SingleOrDefault();
- return chargeStandardView;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 编辑(新增、修改)
- /// 存在对应的收费标准时,才可新增
- /// 业务主键不可修改(业务主键:用户ID、缴费学年、收费项目ID)
- /// </summary>
- /// <param name="studentChargeView"></param>
- public void StudentChaegeEdit(StudentChargeView studentChargeView)
- {
- try
- {
- //查询用户ID对应的信息
- var studentView = StudentChargeDAL.GetStudentViewQueryAble(x => x.UserID == studentChargeView.UserID)
- .SingleOrDefault();
- if (studentView != null)
- {
- //验证是否存在对应的收费标准
- var chargeStandardView = StudentChargeDAL.GetStudentChargeChargeStandard(x => x.GrademajorID == studentView.GradeMajorID
- && x.ChargeYear == studentChargeView.ChargeYear
- && x.ChargeProjectID == studentChargeView.ChargeProjectID)
- .SingleOrDefault();
- if (chargeStandardView == null)
- {
- throw new Exception("对应的收费标准不存在");
- }
- else
- {
- //查询数据库进行验证(需排除自己)
- var studentChargeVerification = StudentChargeDAL.StudentChargeRepository.GetList(x => x.StudentChargeID != studentChargeView.StudentChargeID
- && x.UserID == studentChargeView.UserID
- && x.ChargeYear == studentChargeView.ChargeYear
- && x.ChargeProjectID == studentChargeView.ChargeProjectID)
- .SingleOrDefault();
- if (studentChargeVerification == null)
- {
- //数据有误验证
- if (studentChargeView.StudentChargeID != Guid.Empty)
- {
- //表示修改
- var studentCharge = StudentChargeDAL.StudentChargeRepository
- .GetList(x => x.StudentChargeID == studentChargeView.StudentChargeID)
- .SingleOrDefault();
- if (studentCharge == null)
- {
- throw new Exception("数据有误,请核查");
- }
- else
- {
- //业务主键不可修改(业务主键:用户ID、缴费学年、收费项目ID)
- //验证是否存在对应的学生缴费信息
- studentCharge.Amount = chargeStandardView.Amount;
- studentCharge.ActualAmount = studentChargeView.ActualAmount;
- studentCharge.ChargeTag = studentChargeView.ChargeTag;
- studentCharge.Remark = studentChargeView.Remark;
- SetModifyStatus(studentCharge);
- }
- }
- else
- {
- //表示新增
- //应收名单
- EC_StudentCharge studentCharge = new EC_StudentCharge();
- studentCharge.StudentChargeID = Guid.NewGuid();
- studentCharge.UserID = studentChargeView.UserID;
- studentCharge.ChargeProjectID = studentChargeView.ChargeProjectID;
- studentCharge.ChargeYear = studentChargeView.ChargeYear;
- studentCharge.Amount = chargeStandardView.Amount;
- studentCharge.ActualAmount = studentChargeView.ActualAmount; //实收金额(减免后金额)
- studentCharge.ChargeTag = (int)EC_ChargeTag.Normal; //默认为正常收费
- studentCharge.Remark = studentChargeView.Remark;
- SetNewStatus(studentCharge, (int)SYS_STATUS.USABLE);
- UnitOfWork.Add(studentCharge);
- }
- }
- else
- {
- throw new Exception("已存在相同的应收名单,请核查");
- }
- }
- }
- else
- {
- throw new Exception("数据有误,请核查");
- }
- //事务提交
- UnitOfWork.Commit();
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 删除(当选择删除的信息中存在对应的缓交名单信息、学生缴费信息时,无法删除)
- /// </summary>
- /// <param name="studentChargeIDs"></param>
- /// <returns></returns>
- public bool StudentChargedDelete(List<Guid> studentChargeIDs)
- {
- try
- {
- //查询应收名单信息List
- var studentChargeList = StudentChargeDAL.StudentChargeRepository
- .GetList(x => studentChargeIDs.Contains(x.StudentChargeID)).ToList();
- //用户IDList
- var userIDList = studentChargeList.Where(x => !string.IsNullOrEmpty(x.UserID.ToString()))
- .Select(x => x.UserID).ToList();
- //缴费学年IDList
- var chargeYearIDList = studentChargeList.Where(x => !string.IsNullOrEmpty(x.ChargeYear.ToString()))
- .Select(x => x.ChargeYear).ToList();
- //收费项目IDList
- var chargeProjectIDList = studentChargeList.Where(x => !string.IsNullOrEmpty(x.ChargeProjectID.ToString()))
- .Select(x => x.ChargeProjectID).ToList();
- //应收名单
- Expression<Func<EC_StudentCharge, bool>> expStudentCharge = (x => true);
- if (studentChargeIDs != null && studentChargeIDs.Count() > 0)
- {
- //应收名单ID
- expStudentCharge = expStudentCharge.And(x => studentChargeIDs.Contains(x.StudentChargeID));
- }
- if (userIDList != null && userIDList.Count() > 0)
- {
- //用户ID
- expStudentCharge = expStudentCharge.And(x => userIDList.Contains(x.UserID));
- }
- if (chargeYearIDList != null && chargeYearIDList.Count() > 0)
- {
- //缴费学年
- expStudentCharge = expStudentCharge.And(x => chargeYearIDList.Contains(x.ChargeYear));
- }
- if (chargeProjectIDList != null && chargeProjectIDList.Count() > 0)
- {
- //收费项目
- expStudentCharge = expStudentCharge.And(x => chargeProjectIDList.Contains(x.ChargeProjectID));
- }
- //查询学生缴费信息(业务主键:用户ID、缴费学年、收费项目ID)
- var studentChargePaymentList = StudentChargeDAL.GetStudentChargePaymentView(expStudentCharge).ToList();
- //查询对应的缓交名单信息
- var chargeDelayList = StudentChargeDAL.GetStudentChargeChargeDelayView(expStudentCharge).ToList();
- //注:由于用户会选择多条信息进行删除
- //目前的删除逻辑暂时不处理更进一步的删除操作(如:同时存在可删除、不可删除的信息)
- if (chargeDelayList != null && chargeDelayList.Count() > 0)
- {
- //表示已存在缓交名单信息
- throw new Exception("选择删除的信息中存在相应的缓交名单信息,如需删除,请删除相关的缓交名单信息。");
- }
- else
- {
- if (studentChargePaymentList != null && studentChargePaymentList.Count() > 0)
- {
- //表示已存在学生缴费信息
- throw new Exception("选择删除的信息中存在相应的学生缴费信息,如需删除,请删除相关的学生缴费信息。");
- }
- else
- {
- UnitOfWork.Delete<EC_StudentCharge>(x => studentChargeIDs.Contains(x.StudentChargeID));
- }
- }
- return true;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 费用调整(可批量调整)
- /// </summary>
- /// <param name="studentChargeView"></param>
- /// <param name="actualAmount"></param>
- /// <param name="chargeTag"></param>
- /// <param name="remark"></param>
- public void UpdateActualAmount(List<StudentChargeView> studentChargeViewList, decimal? actualAmount,
- int? chargeTag, string remark)
- {
- try
- {
- if (studentChargeViewList.Count() > 0)
- {
- //应收名单IDList
- var studentChargeIDList = studentChargeViewList.Where(x => !string.IsNullOrEmpty(x.StudentChargeID.ToString()))
- .Select(x => x.StudentChargeID).ToList();
- //查询对应的应收名单List
- var studentChargeList = StudentChargeDAL.StudentChargeRepository
- .GetList(x => studentChargeIDList.Contains(x.StudentChargeID)).ToList();
- List<EC_StudentCharge> studentChargeUpList = new List<EC_StudentCharge>();
- foreach (var studentCharge in studentChargeList)
- {
- studentCharge.ActualAmount = actualAmount;
- studentCharge.ChargeTag = chargeTag;
- studentCharge.Remark = remark;
- SetModifyStatus(studentCharge);
- studentChargeUpList.Add(studentCharge);
- }
- //批量提交
- if (studentChargeUpList != null && studentChargeUpList.Count() > 0)
- {
- UnitOfWork.Commit();
- }
- }
- else
- {
- throw new Exception("数据有误,请核查");
- }
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 查询应收名单中对应的缴交信息View(对应的缴交信息全部查询,左联-待缓交金额、已缓交金额)
- /// 同时对相应的缓交信息进行验证
- /// </summary>
- /// <param name="studentChargeID"></param>
- /// <returns></returns>
- public ChargeDelayView GetStudentChargeChargeDelayView(Guid? studentChargeID)
- {
- try
- {
- //应收名单
- Expression<Func<EC_StudentCharge, bool>> expStudentCharge = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (studentChargeID.HasValue)
- {
- expStudentCharge = expStudentCharge.And(x => x.StudentChargeID == studentChargeID);
- }
- //查询对应的全部流程环节信息(WorkflowStatusView)
- var chargeDelayWorkflowStatusView = IChargeDelayServices.GetStatusViewList();
- if (chargeDelayWorkflowStatusView == null || chargeDelayWorkflowStatusView.Count() <= 0)
- {
- throw new Exception("工作流平台中,费用缓交流程未配置,请核查");
- }
- //查询缓交申请工作流程开始环节状态
- var chargeDelayStartStatus = IChargeDelayServices.GetStartStatus();
- if (chargeDelayStartStatus == null)
- {
- throw new Exception("工作流平台中,费用缓交开始环节流程未配置,请核查");
- }
- //缓交申请流程中的ID(包含未提交、待审核)
- var applyStatusList = IChargeDelayServices.GetStartApproveStatusList();
- //缓交申请(流程中)
- Expression<Func<EC_ChargeDelay, bool>> expChargeDelayApply = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (studentChargeID.HasValue)
- {
- expChargeDelayApply = expChargeDelayApply.And(x => x.StudentChargeID == studentChargeID);
- expChargeDelayApply = expChargeDelayApply.And(x => applyStatusList.Contains(x.RecordStatus));
- }
- //查询缓交申请工作流程结束环节状态ID(通过)
- var chargeDelayEndtStatus = IChargeDelayServices.GetCorrectEndStatus();
- if (chargeDelayEndtStatus == null)
- {
- throw new Exception("工作流平台中,费用缓交结束环节流程未配置,请核查");
- }
- //缓交申请(审核通过)
- Expression<Func<EC_ChargeDelay, bool>> expChargeDelayPass = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (studentChargeID.HasValue)
- {
- expChargeDelayPass = expChargeDelayPass.And(x => x.StudentChargeID == studentChargeID);
- expChargeDelayPass = expChargeDelayPass.And(x => x.RecordStatus == chargeDelayEndtStatus);
- }
- //查询对应的缴交信息View(对应的缴交信息全部查询,左联-待缓交金额、已缓交金额)
- var chargeDelayView = StudentChargeDAL.GetStudentChargeChargeDelayView(expStudentCharge, expChargeDelayApply, expChargeDelayPass)
- .SingleOrDefault();
- return chargeDelayView;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 缓交申请
- /// </summary>
- /// <param name="chargeDelayView"></param>
- public void ChargeDelay(ChargeDelayView chargeDelayView)
- {
- try
- {
- //注:可通过缓交申请表单来获取相关缓交信息(目前暂时不采用此种方式)
- var chargeDelay = this.GetStudentChargeChargeDelayView(chargeDelayView.StudentChargeID);
- if (chargeDelay == null)
- {
- throw new Exception("数据有误,请核查");
- }
- //缓交金额需在可缓交金额范围内
- if (chargeDelay.DelayAmount > chargeDelay.CanDelayAmount)
- {
- throw new Exception("缓交金额不能大于可缓交金额,请核查");
- }
- else
- {
- //查询缓交申请工作流程开始环节状态
- var chargeDelayStartStatus = IChargeDelayServices.GetStartStatus();
- if (chargeDelayStartStatus == null)
- {
- throw new Exception("工作流平台中,费用缓交开始环节流程未配置,请核查");
- }
- EC_ChargeDelay newChargeDelay = new EC_ChargeDelay();
- newChargeDelay.ChargeDelayID = Guid.NewGuid();
- newChargeDelay.StudentChargeID = chargeDelayView.StudentChargeID;
- newChargeDelay.DelayAmount = chargeDelayView.DelayAmount;
- newChargeDelay.DelayPercent = chargeDelayView.DelayPercent;
- newChargeDelay.Reason = chargeDelayView.Reason;
- SetNewStatus(newChargeDelay, chargeDelayStartStatus.Value);
- UnitOfWork.Add(newChargeDelay);
- }
- UnitOfWork.Commit();
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 应收名单验证(业务主键:用户ID、缴费学年、收费项目ID)
- /// 存在对应的收费标准时,才可新增
- /// 业务主键不可修改(业务主键:用户ID、缴费学年、收费项目ID)
- /// </summary>
- /// <param name="studentChargeID"></param>
- /// <param name="userID"></param>
- /// <param name="chargeYearID"></param>
- /// <param name="chargeProjectID"></param>
- /// <returns></returns>
- public string GetVerification(Guid? studentChargeID, Guid? userID, int? chargeYearID, Guid? chargeProjectID)
- {
- try
- {
- //查询数据库进行验证(需排除自己)
- var studentCharge = StudentChargeDAL.StudentChargeRepository.GetList(x => x.StudentChargeID != studentChargeID
- && x.UserID == userID
- && x.ChargeYear == chargeYearID
- && x.ChargeProjectID == chargeProjectID)
- .SingleOrDefault();
- if (studentCharge == null)
- {
- //数据有误验证
- if (studentChargeID.HasValue && studentChargeID != Guid.Empty)
- {
- studentCharge = StudentChargeDAL.StudentChargeRepository.GetList(x => x.StudentChargeID == studentChargeID)
- .SingleOrDefault();
- if (studentCharge == null)
- {
- return "数据有误,请核查";
- }
- else
- {
- return "成功";
- }
- }
- else
- {
- //查询用户ID对应的信息
- var studentView = StudentChargeDAL.GetStudentViewQueryAble(x => x.UserID == userID).SingleOrDefault();
- if (studentView != null)
- {
- //验证是否存在对应的收费标准
- var chargeStandardView = StudentChargeDAL.GetStudentChargeChargeStandard(x => x.GrademajorID == studentView.GradeMajorID
- && x.ChargeYear == chargeYearID
- && x.ChargeProjectID == chargeProjectID)
- .SingleOrDefault();
- if (chargeStandardView == null)
- {
- return "对应的收费标准不存在";
- }
- else
- {
- return "成功";
- }
- }
- else
- {
- return "数据有误,请核查";
- }
- }
- }
- else
- {
- return "已存在相同的应收名单";
- }
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 查询对应的缴费信息View(学生平台)
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="userID"></param>
- /// <param name="chargeYearID"></param>
- /// <param name="chargeProjectID"></param>
- /// <param name="chargeTagID"></param>
- /// <param name="isArrear"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<StudentChargeView> GetPersonalPaymentViewGrid(ConfiguretView configuretView, Guid userID, int? chargeYearID,
- Guid? chargeProjectID, int? chargeTagID, int? isArrear, int pageIndex, int pageSize)
- {
- //应收名单
- Expression<Func<EC_StudentCharge, bool>> expStudentCharge = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- //用户ID
- expStudentCharge = expStudentCharge.And(x => x.UserID == userID);
- if (chargeYearID.HasValue)
- {
- //缴费学年
- expStudentCharge = expStudentCharge.And(x => x.ChargeYear == chargeYearID);
- }
- if (chargeProjectID.HasValue)
- {
- //收费项目
- expStudentCharge = expStudentCharge.And(x => x.ChargeProjectID == chargeProjectID);
- }
- if (chargeTagID.HasValue)
- {
- //缴费标记
- expStudentCharge = expStudentCharge.And(x => x.ChargeTag == chargeTagID);
- }
- //学生信息
- Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- //学生信息ID
- expStudent = expStudent.And(x => x.UserID == userID);
-
- var query = StudentChargeDAL.GetStudentChargeViewQueryAble(expStudentCharge, expStudent);
- //欠费状态
- if (isArrear.HasValue)
- {
- if (isArrear.Value == (int)CF_GeneralPurpose.IsYes)
- {
- query = query.Where(x => x.IsArrear == (int)CF_GeneralPurpose.IsYes);
- }
- if (isArrear.Value == (int)CF_GeneralPurpose.IsNo)
- {
- query = query.Where(x => x.IsArrear == (int)CF_GeneralPurpose.IsNo);
- }
- }
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderBy(x => x.ChargeProjectStr).ThenByDescending(x => x.ChargeYear)
- .ToGridResultSet<StudentChargeView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询对应的缴费信息List(学生平台)
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="userID"></param>
- /// <param name="chargeYearID"></param>
- /// <param name="chargeProjectID"></param>
- /// <param name="chargeTagID"></param>
- /// <param name="isArrear"></param>
- /// <returns></returns>
- public List<StudentChargeView> GetPersonalPaymentViewList(ConfiguretView configuretView, Guid userID, int? chargeYearID,
- Guid? chargeProjectID, int? chargeTagID, int? isArrear)
- {
- //应收名单
- Expression<Func<EC_StudentCharge, bool>> expStudentCharge = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- //用户ID
- expStudentCharge = expStudentCharge.And(x => x.UserID == userID);
- if (chargeYearID.HasValue)
- {
- //缴费学年
- expStudentCharge = expStudentCharge.And(x => x.ChargeYear == chargeYearID);
- }
- if (chargeProjectID.HasValue)
- {
- //收费项目
- expStudentCharge = expStudentCharge.And(x => x.ChargeProjectID == chargeProjectID);
- }
- if (chargeTagID.HasValue)
- {
- //缴费标记
- expStudentCharge = expStudentCharge.And(x => x.ChargeTag == chargeTagID);
- }
- //学生信息
- Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- //学生信息ID
- expStudent = expStudent.And(x => x.UserID == userID);
- var query = StudentChargeDAL.GetStudentChargeViewQueryAble(expStudentCharge, expStudent);
- //欠费状态
- if (isArrear.HasValue)
- {
- if (isArrear.Value == (int)CF_GeneralPurpose.IsYes)
- {
- query = query.Where(x => x.IsArrear == (int)CF_GeneralPurpose.IsYes);
- }
- if (isArrear.Value == (int)CF_GeneralPurpose.IsNo)
- {
- query = query.Where(x => x.IsArrear == (int)CF_GeneralPurpose.IsNo);
- }
- }
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderBy(x => x.ChargeProjectStr).ThenByDescending(x => x.ChargeYear)
- .ToList();
- }
- }
- }
|