123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using EMIS.CommonLogic.Students;
- using Bowin.Common.Exceptions;
- using EMIS.ViewModel.ExaminationApply;
- using EMIS.CommonLogic.ExaminationApply;
- using EMIS.ViewModel.Students;
- using EMIS.ViewModel;
- using EMIS.Entities;
- using EMIS.Web.Controls;
- using EMIS.Utility;
- using System.IO;
- using EMIS.ViewModel.FeeManage;
- namespace EMIS.Web.Controllers.StudentSystem.Examine
- {
- [Authorization]
- public class ExamineApplyController : Controller
- {
- public IStudentsServices StudentsServices { get; set; }
- public IStudentRecordServices StudentRecordService { get; set; }
- public IExamineApplyServices ExamineApplyService { get; set; }
- public IExaminationSubjectServices ExaminationSubjectServices { get; set; }
- //
- // GET: /ExamineApply/
- [HttpGet]
- public ActionResult Apply()
- {
- var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
- var Student = StudentRecordService.GetStudentByStudentNo(user.UserID);
- return View(Student);
- }
- [HttpGet]
- public ActionResult RegisterList()
- {
- var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
- var Student = StudentRecordService.GetStudentByStudentNo(user.UserID);
- return View(Student);
- }
- /// <summary>
- /// 获取可报名列表
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult GetExaminationSubjectList()
- {
- var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
- return base.Json(ExamineApplyService.GetExaminationSubjectList(user.UserID));
- }
- /// <summary>
- /// 获取已报名列表
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public ActionResult GetExaminationRegisterList()
- {
- var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
- return base.Json(ExamineApplyService.GetExaminationRegisterList(user.UserID));
- }
- [HttpGet]
- public ActionResult Register(Guid? ExaminationBatchProjectID)
- {
- var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
- StudentListView registerView = new StudentListView();
- if (ExaminationBatchProjectID.HasValue)
- {
- registerView = ExamineApplyService.GetRegisterViewByExaminationBatchProjectID(ExaminationBatchProjectID, user.UserID);
- }
- return View(registerView);
- }
- [HttpPost]
- public ActionResult Register(StudentListView registerView)
- {
- try
- {
- var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
- var accepts = new List<string> { ".jpg" };
- var postedFile = Request.Files["RegistView.PhotoUrl"];
- if (postedFile != null && !string.IsNullOrEmpty(postedFile.FileName) && !accepts.Contains(Path.GetExtension(postedFile.FileName).ToLower()))
- {
- throw new Exception("只允许上传.jpg格式的文件。");
- }
- if (postedFile != null && !string.IsNullOrEmpty(postedFile.FileName) && (postedFile.ContentLength > (200 * 1024) || postedFile.ContentLength < (50 * 1024)))
- {
- throw new Exception("只允许上传50-200k大小的照片。");
- }
- string photoUrl = FileUploadHelper.UploadFile(postedFile);
- if (photoUrl != null)
- {
- registerView.RegistView.PhotoUrl = photoUrl;
- }
- var register = ExamineApplyService.StudentRegister(registerView, user.UserID);
- //return Json(new ReturnMessage()
- //{
- // IsSuccess = true,
- // Message = "报名成功",
- // Type = 1,
- //});
- if (register.IsOnlinePay)
- {
- return RedirectToAction("MsgShowAndOpenAddUrl", "Common", new
- {
- title = "在线缴费",
- WindowID = Request["WindowID"],
- msg = "报名成功,请进入”已报项目“在规定时间内完成缴费",
- url = Url.Content("~/Weixin/NativePay").AddMenuParameter() + "&examinationRegistrationID=" + register.ExaminationRegistrationID + "&fee=" + register.Fee + "&feeTypeName=" + register.FeeTypeName,
- });
- }
- else {
- return RedirectToAction("MsgShow", "Common", new
- {
- WindowID = Request["WindowID"],
- msg = "报名成功,请进入”已报项目“在规定时间内完成缴费",
- url = Url.Action("Apply").AddMenuParameter()
- });
- }
- }
- catch (Exception ex)
- {
- return RedirectToAction("MsgShow", "Common", new
- {
- WindowID = Request["WindowID"],
- msg = "报名失败,原因:" + ex.Message,
- url = Url.Action("Apply").AddMenuParameter()
- });
- //return Json(new ReturnMessage()
- //{
- // IsSuccess = false,
- // Message = "报名失败,原因:" + ex.Message
- //});
- }
- }
- public ActionResult Cancel(string ExaminationRegistrationIDs)
- {
- try
- {
- var examinationRegistrationIDList = ExaminationRegistrationIDs.Split(',').Where(x => x.IndexOf("-") >= 0).Select(x => new Guid(x)).ToList();
- var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
-
- var registrationList = ExamineApplyService.GetExaminationRegistrationPayViewByRegistrationID(examinationRegistrationIDList);
- if (registrationList.Where(x => x.RecordStatus != (int)EX_ExaminationRegistrationStatus.Paid && x.RecordStatus != (int)EX_ExaminationRegistrationStatus.ForPay).Count() > 0)
- {
- throw new Exception("只有待缴费或者已缴费状态的数据才能取消报名!");
- }
- var changeIDList = registrationList.Where(x => x.RecordStatus == (int)EX_ExaminationRegistrationStatus.Paid).Select(x => x.ExaminationRegistrationID).ToList();
- var deleteIDList = registrationList.Where(x => x.RecordStatus == (int)EX_ExaminationRegistrationStatus.ForPay).Select(x => x.ExaminationRegistrationID).ToList();
- //待缴费的需要按照原来的判断(已打包,报名时间)
- ExamineApplyService.CheckCanCancelOnline(deleteIDList);
- ExamineApplyService.ChangeAndDelete(new List<Guid>(), deleteIDList);
- //已缴费的撤销报名需要进行退费申请
- if (changeIDList.Count() > 0)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = ExaminationRegistrationIDs,
- Type = 99,
- });
- }
- //foreach (var registration in registrationList.Where(x => x.RecordStatus == (int)EX_ExaminationRegistrationStatus.Paid))
- //{
- // //是否线上缴费
- // var isOnlinePay = ExamineApplyService.CheckIsOnlinePay(registration.ExaminationRegistrationID);
- // if (isOnlinePay)
- // {
- // WechatHelper.Refund(registration.OrderID, registration.Fee ?? 0, (registration.Fee ?? 0) - (registration.RefundTotal ?? 0));
- // }
- //}
- //ExamineApplyService.ChangeAndDelete(changeIDList, deleteIDList);
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "撤销成功",
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "撤销失败,原因:" + ex.Message,
- });
- }
- }
- public ActionResult CheckIsOnlinePay(string ExaminationRegistrationIDs)
- {
- try
- {
- var examinationRegistrationIDList = ExaminationRegistrationIDs.Split(',').Where(x => x.IndexOf("-") >= 0).Select(x => new Guid(x)).ToList();
- var registrationList = ExamineApplyService.GetExaminationRegistrationPayViewByRegistrationID(examinationRegistrationIDList);
- List<bool> isOnlinePayList = new List<bool>();
- foreach (var registration in registrationList.Where(x => x.RecordStatus == (int)EX_ExaminationRegistrationStatus.Paid))
- {
- var isOnlinePay = ExamineApplyService.CheckIsOnlinePay(registration.ExaminationRegistrationID);
- isOnlinePayList.Add(isOnlinePay);
- }
- if (isOnlinePayList.Where(x => x == true).Count() > 0 && isOnlinePayList.Where(x => x == false).Count() > 0)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "批量撤销已缴费的报名,只能撤销同样是线上缴费或者同样是线下缴费的数据",
- });
- }
- else if (isOnlinePayList.Where(x => x == true).Count() == isOnlinePayList.Count())
- {
- Cancel(ExaminationRegistrationIDs);
- }
- else
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = ExaminationRegistrationIDs,
- Type = 99,
- });
- //return RedirectToAction("MsgShowAndOpenAddUrl", "Common", new
- //{
- // title = "退款信息确认",
- // WindowID = Request["WindowID"],
- // msg = "请对开户银行和银行卡号信息进行填写确认",
- // url = Url.Content("~/ExamineApply/Refund").AddMenuParameter() + "&examinationRegistrationIDs=" + ExaminationRegistrationIDs,
- //});
- }
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "撤销成功",
- });
- }
- catch (Exception ex)
- {
- string mge = ex.Message;
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "撤销失败,原因:" + mge,
- });
- }
- }
- [HttpPost]
- [AllowAnonymous]
- public ActionResult CanPay(Guid examinationRegistrationID)
- {
- try
- {
- this.ExamineApplyService.CheckCanPay(examinationRegistrationID);
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "可以缴费"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "缴费失败,原因:" + ex.Message
- });
- }
- }
- public ActionResult NativePay(Guid examinationRegistrationID, decimal fee, string feeTypeName)
- {
- var nativePayView = new NativePayView();
- nativePayView.ExaminationRegistrationID = examinationRegistrationID;
- nativePayView.Fee = fee;
- nativePayView.FeeTypeName = feeTypeName;
- return View(nativePayView);
- }
- [HttpGet]
- public ActionResult Refund(string examinationRegistrationIDs)
- {
- var refundView = new RefundView();
- var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
- refundView = ExamineApplyService.GetRefundViewByUserID(user.UserID);
- ViewBag.ExaminationRegistrationIDs = examinationRegistrationIDs;
- return View(refundView);
- }
- [HttpPost]
- public ActionResult Refund(RefundView refundView)
- {
- try
- {
- var examinationRegistrationIDs = Request.Form["SelectIDs"];
- var examinationRegistrationIDList = examinationRegistrationIDs.Split(',').Where(x => x.IndexOf("-") >= 0).Select(x => new Guid(x)).ToList();
- ExamineApplyService.RefundApply(refundView, examinationRegistrationIDList);
- return RedirectToAction("MsgShow", "Common", new
- {
- WindowID = Request["WindowID"],
- msg = "已提交退费申请,请在24小时内带齐办理资料(收费票据、银行卡复印件)到鉴定考试中心审核是否可以退费。",
- url = Url.Action("RegisterList").AddMenuParameter()
- });
- //return Json(new ReturnMessage()
- //{
- // IsSuccess = true,
- // Message = "退费申请提交成功,请等待老师审核!"
- //});
- }
- catch (Exception ex)
- {
- return RedirectToAction("MsgShow", "Common", new
- {
- WindowID = Request["WindowID"],
- msg = "退费申请提交失败,原因:" + ex.Message,
- url = Url.Action("RegisterList").AddMenuParameter()
- });
- //return Json(new ReturnMessage()
- //{
- // IsSuccess = false,
- // Message = "退费申请提交失败,原因:" + ex.Message
- //});
- }
- }
- //public ActionResult ApplySubmit(string ExaminationSubjectID)
- //{
- // try
- // {
- // Guid subjectID = Guid.Parse(Request.Params["ExaminationSubjectID"]);
- // int version = int.Parse(Request.Params["Version"]);
- // var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
- // ExamineApplyService.Value.ApplySubmit(subjectID, user.UserID);
- // return base.Json("报名成功");
- // }
- // catch (Exception ex)
- // {
- // GetExceptionDetailMessage(ex);
- // string mge = GetExceptionDetailMessage(ex).Message;
- // return base.Json("报名失败,原因:" + mge);
- // }
- //}
- //Exception GetExceptionDetailMessage(Exception ex)
- //{
- // if (ex.InnerException == null)
- // {
- // return ex;
- // }
- // else
- // return GetExceptionDetailMessage(ex.InnerException);
- //}
- }
- }
|