StudentChargeServices.cs 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885
  1. using System;
  2. using System.Web;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Linq.Expressions;
  6. using System.Text;
  7. using System.Text.RegularExpressions;
  8. using Bowin.Common.Linq;
  9. using Bowin.Common.Linq.Entity;
  10. using EMIS.ViewModel;
  11. using EMIS.ViewModel.WorkflowManage;
  12. using EMIS.ViewModel.ChargeManage.ChargeSituation;
  13. using EMIS.ViewModel.Students;
  14. using EMIS.Entities;
  15. using EMIS.DataLogic.ChargeManage.ChargeSituation;
  16. using EMIS.DataLogic.Repositories;
  17. using EMIS.CommonLogic.StudentManage.StudentStatistics;
  18. namespace EMIS.CommonLogic.ChargeManage.ChargeSituation
  19. {
  20. public class StudentChargeServices : BaseServices, IStudentChargeServices
  21. {
  22. public StudentChargeDAL StudentChargeDAL { get; set; }
  23. public ChargeProjectDAL ChargeProjectDAL { get; set; }
  24. public ChargeStandardDAL ChargeStandardDAL { get; set; }
  25. public StudentChargeRepository StudentChargeRepository { get; set; }
  26. public IInSchoolSettingServices InSchoolSettingServices { get; set; }
  27. public IChargeDelayServices IChargeDelayServices { get; set; }
  28. /// <summary>
  29. /// 查询应收名单信息View
  30. /// </summary>
  31. /// <param name="configuretView"></param>
  32. /// <param name="collegeID"></param>
  33. /// <param name="yearID"></param>
  34. /// <param name="standardID"></param>
  35. /// <param name="educationID"></param>
  36. /// <param name="learningformID"></param>
  37. /// <param name="learnSystem"></param>
  38. /// <param name="chargeYearID"></param>
  39. /// <param name="chargeProjectID"></param>
  40. /// <param name="chargeTagID"></param>
  41. /// <param name="inSchoolStatus"></param>
  42. /// <param name="isDream"></param>
  43. /// <param name="pageIndex"></param>
  44. /// <param name="pageSize"></param>
  45. /// <returns></returns>
  46. public IGridResultSet<StudentChargeView> GetStudentChargeViewGrid(ConfiguretView configuretView, Guid? collegeID, int? yearID,
  47. int? standardID, int? educationID, int? learningformID, string learnSystem, int? chargeYearID,
  48. Guid? chargeProjectID, int? chargeTagID, int? inSchoolStatus, int? isDream, int pageIndex, int pageSize)
  49. {
  50. //应收名单
  51. Expression<Func<EC_StudentCharge, bool>> expStudentCharge = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  52. if (chargeYearID.HasValue)
  53. {
  54. expStudentCharge = expStudentCharge.And(x => x.ChargeYear == chargeYearID);
  55. }
  56. if (chargeProjectID.HasValue)
  57. {
  58. expStudentCharge = expStudentCharge.And(x => x.ChargeProjectID == chargeProjectID);
  59. }
  60. if (chargeTagID.HasValue)
  61. {
  62. expStudentCharge = expStudentCharge.And(x => x.ChargeTag == chargeTagID);
  63. }
  64. Expression<Func<CF_Student, bool>> expStudent = (x => true);
  65. if (isDream.HasValue)
  66. {
  67. //expStudent = expStudent.And(x => x.IsDreamProject == (isDream == 1 ? true : false));
  68. if (isDream.Value == (int)CF_GeneralPurpose.IsYes)
  69. {
  70. expStudent = expStudent.And(x => x.CF_StudentProfile.IsDreamProject == true);
  71. }
  72. if (isDream.Value == (int)CF_GeneralPurpose.IsNo)
  73. {
  74. expStudent = expStudent.And(x => x.CF_StudentProfile.IsDreamProject != true);
  75. }
  76. }
  77. if (inSchoolStatus != null && inSchoolStatus > -1)
  78. {
  79. var inschoolStatusList = InSchoolSettingServices.GetInschoolStatusList(true);
  80. if (inSchoolStatus == 1)
  81. {
  82. //表示在校
  83. expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
  84. }
  85. if (inSchoolStatus == 0)
  86. {
  87. //不在校
  88. expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
  89. }
  90. }
  91. var query = StudentChargeDAL.GetStudentChargeViewQueryAble(expStudentCharge, expStudent);
  92. if (collegeID.HasValue)
  93. {
  94. query = query.Where(x => x.CollegeID == collegeID);
  95. }
  96. if (yearID.HasValue)
  97. {
  98. query = query.Where(x => x.GradeStr == yearID);
  99. }
  100. if (standardID.HasValue)
  101. {
  102. query = query.Where(x => x.StandardID == standardID);
  103. }
  104. if (educationID.HasValue)
  105. {
  106. query = query.Where(x => x.EducationID == educationID);
  107. }
  108. if (learningformID.HasValue)
  109. {
  110. query = query.Where(x => x.LearningformID == learningformID);
  111. }
  112. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  113. {
  114. var LearnSystems = Convert.ToDecimal(learnSystem);
  115. query = query.Where(x => x.LearnSystem == LearnSystems);
  116. }
  117. //查询条件
  118. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  119. {
  120. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  121. }
  122. return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.StudentNo.Length)
  123. .ThenBy(x => x.StudentNo).ThenBy(x => x.ChargeProjectStr)
  124. .ThenByDescending(x => x.ChargeYear)
  125. .ToGridResultSet<StudentChargeView>(pageIndex, pageSize);
  126. }
  127. /// <summary>
  128. /// 查询应收名单信息List
  129. /// </summary>
  130. /// <param name="configuretView"></param>
  131. /// <param name="collegeID"></param>
  132. /// <param name="yearID"></param>
  133. /// <param name="chargeYearID"></param>
  134. /// <param name="standardID"></param>
  135. /// <param name="educationID"></param>
  136. /// <param name="learningformID"></param>
  137. /// <param name="chargeProjectID"></param>
  138. /// <returns></returns>
  139. public List<StudentChargeView> GetStudentChargeViewGrid(ConfiguretView configuretView, Guid? collegeID, int? yearID,
  140. int? standardID, int? educationID, int? learningformID, string learnSystem, int? chargeYearID, Guid? chargeProjectID,
  141. int? chargeTagID, int? inSchoolStatus, int? isDream)
  142. {
  143. //应收名单
  144. Expression<Func<EC_StudentCharge, bool>> expStudentCharge = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  145. if (chargeYearID.HasValue)
  146. {
  147. expStudentCharge = expStudentCharge.And(x => x.ChargeYear == chargeYearID);
  148. }
  149. if (chargeProjectID.HasValue)
  150. {
  151. expStudentCharge = expStudentCharge.And(x => x.ChargeProjectID == chargeProjectID);
  152. }
  153. if (chargeTagID.HasValue)
  154. {
  155. expStudentCharge = expStudentCharge.And(x => x.ChargeTag == chargeTagID);
  156. }
  157. Expression<Func<CF_Student, bool>> expStudent = (x => true);
  158. if (isDream.HasValue)
  159. {
  160. //expStudent = expStudent.And(x => x.IsDreamProject == (isDream == 1 ? true : false));
  161. if (isDream.Value == (int)CF_GeneralPurpose.IsYes)
  162. {
  163. expStudent = expStudent.And(x => x.CF_StudentProfile.IsDreamProject == true);
  164. }
  165. if (isDream.Value == (int)CF_GeneralPurpose.IsNo)
  166. {
  167. expStudent = expStudent.And(x => x.CF_StudentProfile.IsDreamProject != true);
  168. }
  169. }
  170. if (inSchoolStatus != null && inSchoolStatus > -1)
  171. {
  172. var inschoolStatusList = InSchoolSettingServices.GetInschoolStatusList(true);
  173. if (inSchoolStatus == 1)
  174. {
  175. //表示在校
  176. expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
  177. }
  178. if (inSchoolStatus == 0)
  179. {
  180. //不在校
  181. expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
  182. }
  183. }
  184. var query = StudentChargeDAL.GetStudentChargeViewQueryAble(expStudentCharge, expStudent);
  185. if (collegeID.HasValue)
  186. {
  187. query = query.Where(x => x.CollegeID == collegeID);
  188. }
  189. if (yearID.HasValue)
  190. {
  191. query = query.Where(x => x.GradeStr == yearID);
  192. }
  193. if (standardID.HasValue)
  194. {
  195. query = query.Where(x => x.StandardID == standardID);
  196. }
  197. if (educationID.HasValue)
  198. {
  199. query = query.Where(x => x.EducationID == educationID);
  200. }
  201. if (learningformID.HasValue)
  202. {
  203. query = query.Where(x => x.LearningformID == learningformID);
  204. }
  205. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  206. {
  207. var LearnSystems = Convert.ToDecimal(learnSystem);
  208. query = query.Where(x => x.LearnSystem == LearnSystems);
  209. }
  210. //查询条件
  211. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  212. {
  213. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  214. }
  215. return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.StudentNo.Length)
  216. .ThenBy(x => x.StudentNo).ThenBy(x => x.ChargeProjectStr)
  217. .ThenByDescending(x => x.ChargeYear)
  218. .ToList();
  219. }
  220. /// <summary>
  221. /// 查询应收名单信息View
  222. /// </summary>
  223. /// <param name="studentChargeID"></param>
  224. /// <returns></returns>
  225. public StudentChargeView GetStudentChargeView(Guid? studentChargeID)
  226. {
  227. var query = StudentChargeDAL.GetStudentChargeViewQueryAble(x => x.StudentChargeID == studentChargeID, x => true)
  228. .SingleOrDefault();
  229. return query;
  230. }
  231. /// <summary>
  232. /// 查询应收名单实体
  233. /// </summary>
  234. /// <param name="studentChargeID"></param>
  235. /// <returns></returns>
  236. public EC_StudentCharge GetStudentCharge(Guid? studentChargeID)
  237. {
  238. //查询条件
  239. Expression<Func<EC_StudentCharge, bool>> expression = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  240. expression = (x => x.StudentChargeID == studentChargeID);
  241. return StudentChargeDAL.StudentChargeRepository.GetSingle(expression);
  242. }
  243. /// <summary>
  244. /// 获取学生信息视图
  245. /// </summary>
  246. /// <param name="UserID"></param>
  247. /// <returns></returns>
  248. public StudentsView GetStudentView(Guid? userID)
  249. {
  250. var query = StudentChargeDAL.GetStudentViewQueryAble(x => x.UserID == userID);
  251. return query.SingleOrDefault();
  252. }
  253. /// <summary>
  254. /// 查询收费项目信息
  255. /// </summary>
  256. /// <param name="chargeProjectID"></param>
  257. /// <returns></returns>
  258. public ChargeProjectView GetChargeProjectView(Guid? chargeProjectID)
  259. {
  260. Expression<Func<EC_ChargeProject, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  261. exp = exp.And(x => x.ChargeProjectID == chargeProjectID);
  262. var query = ChargeProjectDAL.GetChargeProjectViewQueryAble(exp);
  263. return query.SingleOrDefault();
  264. }
  265. /// <summary>
  266. /// 查询应收名单对应的收费标准
  267. /// </summary>
  268. /// <param name="userID"></param>
  269. /// <param name="chargeYearID"></param>
  270. /// <param name="chargeProjectID"></param>
  271. /// <returns></returns>
  272. public ChargeStandardView StudentChargeChargeStandard(Guid? userID, int? chargeYearID, Guid? chargeProjectID)
  273. {
  274. try
  275. {
  276. //查询用户ID对应的信息
  277. var studentView = StudentChargeDAL.GetStudentViewQueryAble(x => x.UserID == userID).SingleOrDefault();
  278. //收费标准
  279. Expression<Func<EC_ChargeStandard, bool>> expChargeStandard = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  280. if (userID.HasValue)
  281. {
  282. if (studentView != null)
  283. {
  284. expChargeStandard = expChargeStandard.And(x => x.GrademajorID == studentView.GradeMajorID);
  285. }
  286. }
  287. if (chargeYearID.HasValue)
  288. {
  289. expChargeStandard = expChargeStandard.And(x => x.ChargeYear == chargeYearID);
  290. }
  291. if (chargeProjectID.HasValue)
  292. {
  293. expChargeStandard = expChargeStandard.And(x => x.ChargeProjectID == chargeProjectID);
  294. }
  295. var chargeStandardView = StudentChargeDAL.GetStudentChargeChargeStandard(expChargeStandard)
  296. .SingleOrDefault();
  297. return chargeStandardView;
  298. }
  299. catch (Exception ex)
  300. {
  301. throw new Exception(ex.Message);
  302. }
  303. }
  304. /// <summary>
  305. /// 编辑(新增、修改)
  306. /// 存在对应的收费标准时,才可新增
  307. /// 业务主键不可修改(业务主键:用户ID、缴费学年、收费项目ID)
  308. /// </summary>
  309. /// <param name="studentChargeView"></param>
  310. public void StudentChaegeEdit(StudentChargeView studentChargeView)
  311. {
  312. try
  313. {
  314. //查询用户ID对应的信息
  315. var studentView = StudentChargeDAL.GetStudentViewQueryAble(x => x.UserID == studentChargeView.UserID)
  316. .SingleOrDefault();
  317. if (studentView != null)
  318. {
  319. //验证是否存在对应的收费标准
  320. var chargeStandardView = StudentChargeDAL.GetStudentChargeChargeStandard(x => x.GrademajorID == studentView.GradeMajorID
  321. && x.ChargeYear == studentChargeView.ChargeYear
  322. && x.ChargeProjectID == studentChargeView.ChargeProjectID)
  323. .SingleOrDefault();
  324. if (chargeStandardView == null)
  325. {
  326. throw new Exception("对应的收费标准不存在");
  327. }
  328. else
  329. {
  330. //查询数据库进行验证(需排除自己)
  331. var studentChargeVerification = StudentChargeDAL.StudentChargeRepository.GetList(x => x.StudentChargeID != studentChargeView.StudentChargeID
  332. && x.UserID == studentChargeView.UserID
  333. && x.ChargeYear == studentChargeView.ChargeYear
  334. && x.ChargeProjectID == studentChargeView.ChargeProjectID)
  335. .SingleOrDefault();
  336. if (studentChargeVerification == null)
  337. {
  338. //数据有误验证
  339. if (studentChargeView.StudentChargeID != Guid.Empty)
  340. {
  341. //表示修改
  342. var studentCharge = StudentChargeDAL.StudentChargeRepository
  343. .GetList(x => x.StudentChargeID == studentChargeView.StudentChargeID)
  344. .SingleOrDefault();
  345. if (studentCharge == null)
  346. {
  347. throw new Exception("数据有误,请核查");
  348. }
  349. else
  350. {
  351. //业务主键不可修改(业务主键:用户ID、缴费学年、收费项目ID)
  352. //验证是否存在对应的学生缴费信息
  353. studentCharge.Amount = chargeStandardView.Amount;
  354. studentCharge.ActualAmount = studentChargeView.ActualAmount;
  355. studentCharge.ChargeTag = studentChargeView.ChargeTag;
  356. studentCharge.Remark = studentChargeView.Remark;
  357. SetModifyStatus(studentCharge);
  358. }
  359. }
  360. else
  361. {
  362. //表示新增
  363. //应收名单
  364. EC_StudentCharge studentCharge = new EC_StudentCharge();
  365. studentCharge.StudentChargeID = Guid.NewGuid();
  366. studentCharge.UserID = studentChargeView.UserID;
  367. studentCharge.ChargeProjectID = studentChargeView.ChargeProjectID;
  368. studentCharge.ChargeYear = studentChargeView.ChargeYear;
  369. studentCharge.Amount = chargeStandardView.Amount;
  370. studentCharge.ActualAmount = studentChargeView.ActualAmount; //实收金额(减免后金额)
  371. studentCharge.ChargeTag = (int)EC_ChargeTag.Normal; //默认为正常收费
  372. studentCharge.Remark = studentChargeView.Remark;
  373. SetNewStatus(studentCharge, (int)SYS_STATUS.USABLE);
  374. UnitOfWork.Add(studentCharge);
  375. }
  376. }
  377. else
  378. {
  379. throw new Exception("已存在相同的应收名单,请核查");
  380. }
  381. }
  382. }
  383. else
  384. {
  385. throw new Exception("数据有误,请核查");
  386. }
  387. //事务提交
  388. UnitOfWork.Commit();
  389. }
  390. catch (Exception ex)
  391. {
  392. throw new Exception(ex.Message);
  393. }
  394. }
  395. /// <summary>
  396. /// 删除(当选择删除的信息中存在对应的缓交名单信息、学生缴费信息时,无法删除)
  397. /// </summary>
  398. /// <param name="studentChargeIDs"></param>
  399. /// <returns></returns>
  400. public bool StudentChargedDelete(List<Guid> studentChargeIDs)
  401. {
  402. try
  403. {
  404. //查询应收名单信息List
  405. var studentChargeList = StudentChargeDAL.StudentChargeRepository
  406. .GetList(x => studentChargeIDs.Contains(x.StudentChargeID)).ToList();
  407. //用户IDList
  408. var userIDList = studentChargeList.Where(x => !string.IsNullOrEmpty(x.UserID.ToString()))
  409. .Select(x => x.UserID).ToList();
  410. //缴费学年IDList
  411. var chargeYearIDList = studentChargeList.Where(x => !string.IsNullOrEmpty(x.ChargeYear.ToString()))
  412. .Select(x => x.ChargeYear).ToList();
  413. //收费项目IDList
  414. var chargeProjectIDList = studentChargeList.Where(x => !string.IsNullOrEmpty(x.ChargeProjectID.ToString()))
  415. .Select(x => x.ChargeProjectID).ToList();
  416. //应收名单
  417. Expression<Func<EC_StudentCharge, bool>> expStudentCharge = (x => true);
  418. if (studentChargeIDs != null && studentChargeIDs.Count() > 0)
  419. {
  420. //应收名单ID
  421. expStudentCharge = expStudentCharge.And(x => studentChargeIDs.Contains(x.StudentChargeID));
  422. }
  423. if (userIDList != null && userIDList.Count() > 0)
  424. {
  425. //用户ID
  426. expStudentCharge = expStudentCharge.And(x => userIDList.Contains(x.UserID));
  427. }
  428. if (chargeYearIDList != null && chargeYearIDList.Count() > 0)
  429. {
  430. //缴费学年
  431. expStudentCharge = expStudentCharge.And(x => chargeYearIDList.Contains(x.ChargeYear));
  432. }
  433. if (chargeProjectIDList != null && chargeProjectIDList.Count() > 0)
  434. {
  435. //收费项目
  436. expStudentCharge = expStudentCharge.And(x => chargeProjectIDList.Contains(x.ChargeProjectID));
  437. }
  438. //查询学生缴费信息(业务主键:用户ID、缴费学年、收费项目ID)
  439. var studentChargePaymentList = StudentChargeDAL.GetStudentChargePaymentView(expStudentCharge).ToList();
  440. //查询对应的缓交名单信息
  441. var chargeDelayList = StudentChargeDAL.GetStudentChargeChargeDelayView(expStudentCharge).ToList();
  442. //注:由于用户会选择多条信息进行删除
  443. //目前的删除逻辑暂时不处理更进一步的删除操作(如:同时存在可删除、不可删除的信息)
  444. if (chargeDelayList != null && chargeDelayList.Count() > 0)
  445. {
  446. //表示已存在缓交名单信息
  447. throw new Exception("选择删除的信息中存在相应的缓交名单信息,如需删除,请删除相关的缓交名单信息。");
  448. }
  449. else
  450. {
  451. if (studentChargePaymentList != null && studentChargePaymentList.Count() > 0)
  452. {
  453. //表示已存在学生缴费信息
  454. throw new Exception("选择删除的信息中存在相应的学生缴费信息,如需删除,请删除相关的学生缴费信息。");
  455. }
  456. else
  457. {
  458. UnitOfWork.Delete<EC_StudentCharge>(x => studentChargeIDs.Contains(x.StudentChargeID));
  459. }
  460. }
  461. return true;
  462. }
  463. catch (Exception ex)
  464. {
  465. throw new Exception(ex.Message);
  466. }
  467. }
  468. /// <summary>
  469. /// 费用调整(可批量调整)
  470. /// </summary>
  471. /// <param name="studentChargeView"></param>
  472. /// <param name="actualAmount"></param>
  473. /// <param name="chargeTag"></param>
  474. /// <param name="remark"></param>
  475. public void UpdateActualAmount(List<StudentChargeView> studentChargeViewList, decimal? actualAmount,
  476. int? chargeTag, string remark)
  477. {
  478. try
  479. {
  480. if (studentChargeViewList.Count() > 0)
  481. {
  482. //应收名单IDList
  483. var studentChargeIDList = studentChargeViewList.Where(x => !string.IsNullOrEmpty(x.StudentChargeID.ToString()))
  484. .Select(x => x.StudentChargeID).ToList();
  485. //查询对应的应收名单List
  486. var studentChargeList = StudentChargeDAL.StudentChargeRepository
  487. .GetList(x => studentChargeIDList.Contains(x.StudentChargeID)).ToList();
  488. List<EC_StudentCharge> studentChargeUpList = new List<EC_StudentCharge>();
  489. foreach (var studentCharge in studentChargeList)
  490. {
  491. studentCharge.ActualAmount = actualAmount;
  492. studentCharge.ChargeTag = chargeTag;
  493. studentCharge.Remark = remark;
  494. SetModifyStatus(studentCharge);
  495. studentChargeUpList.Add(studentCharge);
  496. }
  497. //批量提交
  498. if (studentChargeUpList != null && studentChargeUpList.Count() > 0)
  499. {
  500. UnitOfWork.Commit();
  501. }
  502. }
  503. else
  504. {
  505. throw new Exception("数据有误,请核查");
  506. }
  507. }
  508. catch (Exception ex)
  509. {
  510. throw new Exception(ex.Message);
  511. }
  512. }
  513. /// <summary>
  514. /// 查询应收名单中对应的缴交信息View(对应的缴交信息全部查询,左联-待缓交金额、已缓交金额)
  515. /// 同时对相应的缓交信息进行验证
  516. /// </summary>
  517. /// <param name="studentChargeID"></param>
  518. /// <returns></returns>
  519. public ChargeDelayView GetStudentChargeChargeDelayView(Guid? studentChargeID)
  520. {
  521. try
  522. {
  523. //应收名单
  524. Expression<Func<EC_StudentCharge, bool>> expStudentCharge = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  525. if (studentChargeID.HasValue)
  526. {
  527. expStudentCharge = expStudentCharge.And(x => x.StudentChargeID == studentChargeID);
  528. }
  529. //查询对应的全部流程环节信息(WorkflowStatusView)
  530. var chargeDelayWorkflowStatusView = IChargeDelayServices.GetStatusViewList();
  531. if (chargeDelayWorkflowStatusView == null || chargeDelayWorkflowStatusView.Count() <= 0)
  532. {
  533. throw new Exception("工作流平台中,费用缓交流程未配置,请核查");
  534. }
  535. //查询缓交申请工作流程开始环节状态
  536. var chargeDelayStartStatus = IChargeDelayServices.GetStartStatus();
  537. if (chargeDelayStartStatus == null)
  538. {
  539. throw new Exception("工作流平台中,费用缓交开始环节流程未配置,请核查");
  540. }
  541. //缓交申请流程中的ID(包含未提交、待审核)
  542. var applyStatusList = IChargeDelayServices.GetStartApproveStatusList();
  543. //缓交申请(流程中)
  544. Expression<Func<EC_ChargeDelay, bool>> expChargeDelayApply = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  545. if (studentChargeID.HasValue)
  546. {
  547. expChargeDelayApply = expChargeDelayApply.And(x => x.StudentChargeID == studentChargeID);
  548. expChargeDelayApply = expChargeDelayApply.And(x => applyStatusList.Contains(x.RecordStatus));
  549. }
  550. //查询缓交申请工作流程结束环节状态ID(通过)
  551. var chargeDelayEndtStatus = IChargeDelayServices.GetCorrectEndStatus();
  552. if (chargeDelayEndtStatus == null)
  553. {
  554. throw new Exception("工作流平台中,费用缓交结束环节流程未配置,请核查");
  555. }
  556. //缓交申请(审核通过)
  557. Expression<Func<EC_ChargeDelay, bool>> expChargeDelayPass = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  558. if (studentChargeID.HasValue)
  559. {
  560. expChargeDelayPass = expChargeDelayPass.And(x => x.StudentChargeID == studentChargeID);
  561. expChargeDelayPass = expChargeDelayPass.And(x => x.RecordStatus == chargeDelayEndtStatus);
  562. }
  563. //查询对应的缴交信息View(对应的缴交信息全部查询,左联-待缓交金额、已缓交金额)
  564. var chargeDelayView = StudentChargeDAL.GetStudentChargeChargeDelayView(expStudentCharge, expChargeDelayApply, expChargeDelayPass)
  565. .SingleOrDefault();
  566. return chargeDelayView;
  567. }
  568. catch (Exception ex)
  569. {
  570. throw new Exception(ex.Message);
  571. }
  572. }
  573. /// <summary>
  574. /// 缓交申请
  575. /// </summary>
  576. /// <param name="chargeDelayView"></param>
  577. public void ChargeDelay(ChargeDelayView chargeDelayView)
  578. {
  579. try
  580. {
  581. //注:可通过缓交申请表单来获取相关缓交信息(目前暂时不采用此种方式)
  582. var chargeDelay = this.GetStudentChargeChargeDelayView(chargeDelayView.StudentChargeID);
  583. if (chargeDelay == null)
  584. {
  585. throw new Exception("数据有误,请核查");
  586. }
  587. //缓交金额需在可缓交金额范围内
  588. if (chargeDelay.DelayAmount > chargeDelay.CanDelayAmount)
  589. {
  590. throw new Exception("缓交金额不能大于可缓交金额,请核查");
  591. }
  592. else
  593. {
  594. //查询缓交申请工作流程开始环节状态
  595. var chargeDelayStartStatus = IChargeDelayServices.GetStartStatus();
  596. if (chargeDelayStartStatus == null)
  597. {
  598. throw new Exception("工作流平台中,费用缓交开始环节流程未配置,请核查");
  599. }
  600. EC_ChargeDelay newChargeDelay = new EC_ChargeDelay();
  601. newChargeDelay.ChargeDelayID = Guid.NewGuid();
  602. newChargeDelay.StudentChargeID = chargeDelayView.StudentChargeID;
  603. newChargeDelay.DelayAmount = chargeDelayView.DelayAmount;
  604. newChargeDelay.DelayPercent = chargeDelayView.DelayPercent;
  605. newChargeDelay.Reason = chargeDelayView.Reason;
  606. SetNewStatus(newChargeDelay, chargeDelayStartStatus.Value);
  607. UnitOfWork.Add(newChargeDelay);
  608. }
  609. UnitOfWork.Commit();
  610. }
  611. catch (Exception ex)
  612. {
  613. throw new Exception(ex.Message);
  614. }
  615. }
  616. /// <summary>
  617. /// 应收名单验证(业务主键:用户ID、缴费学年、收费项目ID)
  618. /// 存在对应的收费标准时,才可新增
  619. /// 业务主键不可修改(业务主键:用户ID、缴费学年、收费项目ID)
  620. /// </summary>
  621. /// <param name="studentChargeID"></param>
  622. /// <param name="userID"></param>
  623. /// <param name="chargeYearID"></param>
  624. /// <param name="chargeProjectID"></param>
  625. /// <returns></returns>
  626. public string GetVerification(Guid? studentChargeID, Guid? userID, int? chargeYearID, Guid? chargeProjectID)
  627. {
  628. try
  629. {
  630. //查询数据库进行验证(需排除自己)
  631. var studentCharge = StudentChargeDAL.StudentChargeRepository.GetList(x => x.StudentChargeID != studentChargeID
  632. && x.UserID == userID
  633. && x.ChargeYear == chargeYearID
  634. && x.ChargeProjectID == chargeProjectID)
  635. .SingleOrDefault();
  636. if (studentCharge == null)
  637. {
  638. //数据有误验证
  639. if (studentChargeID.HasValue && studentChargeID != Guid.Empty)
  640. {
  641. studentCharge = StudentChargeDAL.StudentChargeRepository.GetList(x => x.StudentChargeID == studentChargeID)
  642. .SingleOrDefault();
  643. if (studentCharge == null)
  644. {
  645. return "数据有误,请核查";
  646. }
  647. else
  648. {
  649. return "成功";
  650. }
  651. }
  652. else
  653. {
  654. //查询用户ID对应的信息
  655. var studentView = StudentChargeDAL.GetStudentViewQueryAble(x => x.UserID == userID).SingleOrDefault();
  656. if (studentView != null)
  657. {
  658. //验证是否存在对应的收费标准
  659. var chargeStandardView = StudentChargeDAL.GetStudentChargeChargeStandard(x => x.GrademajorID == studentView.GradeMajorID
  660. && x.ChargeYear == chargeYearID
  661. && x.ChargeProjectID == chargeProjectID)
  662. .SingleOrDefault();
  663. if (chargeStandardView == null)
  664. {
  665. return "对应的收费标准不存在";
  666. }
  667. else
  668. {
  669. return "成功";
  670. }
  671. }
  672. else
  673. {
  674. return "数据有误,请核查";
  675. }
  676. }
  677. }
  678. else
  679. {
  680. return "已存在相同的应收名单";
  681. }
  682. }
  683. catch (Exception ex)
  684. {
  685. throw new Exception(ex.Message);
  686. }
  687. }
  688. /// <summary>
  689. /// 查询对应的缴费信息View(学生平台)
  690. /// </summary>
  691. /// <param name="configuretView"></param>
  692. /// <param name="userID"></param>
  693. /// <param name="chargeYearID"></param>
  694. /// <param name="chargeProjectID"></param>
  695. /// <param name="chargeTagID"></param>
  696. /// <param name="isArrear"></param>
  697. /// <param name="pageIndex"></param>
  698. /// <param name="pageSize"></param>
  699. /// <returns></returns>
  700. public IGridResultSet<StudentChargeView> GetPersonalPaymentViewGrid(ConfiguretView configuretView, Guid userID, int? chargeYearID,
  701. Guid? chargeProjectID, int? chargeTagID, int? isArrear, int pageIndex, int pageSize)
  702. {
  703. //应收名单
  704. Expression<Func<EC_StudentCharge, bool>> expStudentCharge = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  705. //用户ID
  706. expStudentCharge = expStudentCharge.And(x => x.UserID == userID);
  707. if (chargeYearID.HasValue)
  708. {
  709. //缴费学年
  710. expStudentCharge = expStudentCharge.And(x => x.ChargeYear == chargeYearID);
  711. }
  712. if (chargeProjectID.HasValue)
  713. {
  714. //收费项目
  715. expStudentCharge = expStudentCharge.And(x => x.ChargeProjectID == chargeProjectID);
  716. }
  717. if (chargeTagID.HasValue)
  718. {
  719. //缴费标记
  720. expStudentCharge = expStudentCharge.And(x => x.ChargeTag == chargeTagID);
  721. }
  722. //学生信息
  723. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  724. //学生信息ID
  725. expStudent = expStudent.And(x => x.UserID == userID);
  726. var query = StudentChargeDAL.GetStudentChargeViewQueryAble(expStudentCharge, expStudent);
  727. //欠费状态
  728. if (isArrear.HasValue)
  729. {
  730. if (isArrear.Value == (int)CF_GeneralPurpose.IsYes)
  731. {
  732. query = query.Where(x => x.IsArrear == (int)CF_GeneralPurpose.IsYes);
  733. }
  734. if (isArrear.Value == (int)CF_GeneralPurpose.IsNo)
  735. {
  736. query = query.Where(x => x.IsArrear == (int)CF_GeneralPurpose.IsNo);
  737. }
  738. }
  739. //查询条件
  740. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  741. {
  742. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  743. }
  744. return query.OrderBy(x => x.ChargeProjectStr).ThenByDescending(x => x.ChargeYear)
  745. .ToGridResultSet<StudentChargeView>(pageIndex, pageSize);
  746. }
  747. /// <summary>
  748. /// 查询对应的缴费信息List(学生平台)
  749. /// </summary>
  750. /// <param name="configuretView"></param>
  751. /// <param name="userID"></param>
  752. /// <param name="chargeYearID"></param>
  753. /// <param name="chargeProjectID"></param>
  754. /// <param name="chargeTagID"></param>
  755. /// <param name="isArrear"></param>
  756. /// <returns></returns>
  757. public List<StudentChargeView> GetPersonalPaymentViewList(ConfiguretView configuretView, Guid userID, int? chargeYearID,
  758. Guid? chargeProjectID, int? chargeTagID, int? isArrear)
  759. {
  760. //应收名单
  761. Expression<Func<EC_StudentCharge, bool>> expStudentCharge = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  762. //用户ID
  763. expStudentCharge = expStudentCharge.And(x => x.UserID == userID);
  764. if (chargeYearID.HasValue)
  765. {
  766. //缴费学年
  767. expStudentCharge = expStudentCharge.And(x => x.ChargeYear == chargeYearID);
  768. }
  769. if (chargeProjectID.HasValue)
  770. {
  771. //收费项目
  772. expStudentCharge = expStudentCharge.And(x => x.ChargeProjectID == chargeProjectID);
  773. }
  774. if (chargeTagID.HasValue)
  775. {
  776. //缴费标记
  777. expStudentCharge = expStudentCharge.And(x => x.ChargeTag == chargeTagID);
  778. }
  779. //学生信息
  780. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  781. //学生信息ID
  782. expStudent = expStudent.And(x => x.UserID == userID);
  783. var query = StudentChargeDAL.GetStudentChargeViewQueryAble(expStudentCharge, expStudent);
  784. //欠费状态
  785. if (isArrear.HasValue)
  786. {
  787. if (isArrear.Value == (int)CF_GeneralPurpose.IsYes)
  788. {
  789. query = query.Where(x => x.IsArrear == (int)CF_GeneralPurpose.IsYes);
  790. }
  791. if (isArrear.Value == (int)CF_GeneralPurpose.IsNo)
  792. {
  793. query = query.Where(x => x.IsArrear == (int)CF_GeneralPurpose.IsNo);
  794. }
  795. }
  796. //查询条件
  797. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  798. {
  799. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  800. }
  801. return query.OrderBy(x => x.ChargeProjectStr).ThenByDescending(x => x.ChargeYear)
  802. .ToList();
  803. }
  804. }
  805. }