|
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Web;
- using Learun.Application.Base.SystemModule;
- using Learun.Application.TwoDevelopment.EducationalAdministration;
- using Learun.Application.TwoDevelopment.LogisticsManagement;
- using Learun.Application.TwoDevelopment.ReceiveSendFeeManagement;
- using Learun.Util;
- using Nancy;
-
- namespace Learun.Application.WebApi.Modules
- {
- public class StuInfoFreshApi : BaseApi
- {
- public StuInfoFreshApi()
- : base("/StuInfoFresh")
- {
- Get["/stuInfoFreshEntity"] = GetStuInfoFreshEntity;
- Get["/stuInfoFresh"] = GetStuInfoFresh;
- Get["/saveStuInfoFresh"] = GetSaveStuInfoFresh;
- Get["/saveLoan"] = GetSaveLoan;
- Post["/savePhoto"] = GetSavePhoto;
- Get["/payFeeDetail"] = GetPayFeeDetail;
- Get["/pageList"] = GetPageList;
- Get["/form"] = GetForm;
- Post["/save"] = SaveForm;
-
- }
-
- private StuInfoFreshIBLL stuInfoFreshIBLL = new StuInfoFreshBLL();
- private CdMajorIBLL cdMajorIBLL = new CdMajorBLL();
- private CdDeptIBLL cdDeptIBLL = new CdDeptBLL();
- private ClassInfoIBLL classInfoIBLL = new ClassInfoBLL();
- private AnnexesFileIBLL annexesFileIBLL = new AnnexesFileBLL();
- private EmpInfoIBLL empInfoIBLL = new EmpInfoBLL();
- private AccommodationIBLL accdormitoryIBLL = new AccommodationBLL();
- private FinaChargesStandardIBLL finaChargesStandardIBLL = new FinaChargesStandardBLL();
- private ClassroomInfoIBLL classroomInfoIBLL = new ClassroomInfoBLL();
-
- /// <summary>
- /// 获取个人信息
- /// </summary>
- /// <param name="_"></param>
- /// <returns></returns>
- private Response GetStuInfoFreshEntity(dynamic _)
- {
- var url = Config.GetValue("defaultheadimg");
- var StuInfoFreshFamilyList = new List<StuInfoFreshFamilyEntity>();
- var StuInfoFreshEmergePeopleList = new List<StuInfoFreshEmergePeopleEntity>();
-
- var StuInfoFreshEntity = stuInfoFreshIBLL.GetStuInfoFreshEntityByStuNo(GetReqData());
- if (StuInfoFreshEntity != null)
- {
- //处理数据源
- StuInfoFreshEntity.MajorNo = cdMajorIBLL.GetCdMajorEntityByMajorNo(StuInfoFreshEntity.MajorNo)?.MajorName;
- StuInfoFreshEntity.DeptNo = cdDeptIBLL.GetCdDeptEntityByNo(StuInfoFreshEntity.DeptNo)?.DeptName;
-
- var classInfoEntity = classInfoIBLL.GetClassInfoEntityByClassNo(StuInfoFreshEntity.ClassNo);
- if (classInfoEntity != null)
- {
- StuInfoFreshEntity.ClassNo = classInfoEntity.ClassName;
- if (classInfoEntity.ClassTutorNo != null)
- {
- StuInfoFreshEntity.ClassTutorNo = classInfoEntity.ClassTutorNo;
- var empInfoEntity = empInfoIBLL.GetEmpInfoEntityByEmpNo(classInfoEntity.ClassTutorNo);
- if (empInfoEntity != null)
- {
- StuInfoFreshEntity.ClassTutorName = empInfoEntity.EmpName;
- StuInfoFreshEntity.ClassTutorMobile = empInfoEntity.mobile;
- }
- }
- if (classInfoEntity.ClassDiredctorNo != null)
- {
- StuInfoFreshEntity.ClassDiredctorNo = classInfoEntity.ClassDiredctorNo;
- var empInfoEntity2 = empInfoIBLL.GetEmpInfoEntityByEmpNo(classInfoEntity.ClassDiredctorNo);
- if (empInfoEntity2 != null)
- {
- StuInfoFreshEntity.ClassDiredctorName = empInfoEntity2.EmpName;
- StuInfoFreshEntity.ClassDiredctorMobile = empInfoEntity2.mobile;
- }
- }
- if (classInfoEntity.SerialNum != null)
- {
- StuInfoFreshEntity.DefaultClassRoomNo = classInfoEntity.SerialNum;
- var classroomEntity = classroomInfoIBLL.GetClassroomInfoEntityByNo(classInfoEntity.SerialNum);
- if (classroomEntity != null)
- {
- StuInfoFreshEntity.DefaultClassRoomName = classroomEntity.ClassroomName;
- }
- }
- }
-
- //获取头像地址
- if (StuInfoFreshEntity.IsPhoto == true && !string.IsNullOrEmpty(StuInfoFreshEntity.Photo))
- {
- var annexesFileEntity = annexesFileIBLL.GetEntity(StuInfoFreshEntity.Photo);
- if (annexesFileEntity != null)
- {
- url = annexesFileEntity.F_FilePath.Substring(annexesFileEntity.F_FilePath.IndexOf("Resource"));
- }
- }
- StuInfoFreshEntity.DormitoryName = accdormitoryIBLL.GetDormitoryInfoByPlanStuNo(StuInfoFreshEntity.ID);
- if (StuInfoFreshEntity.IsPoor != "1")
- {
- StuInfoFreshEntity.IsPoor = "0";
- }
- if (StuInfoFreshEntity.GetKeyStatus != "1")
- {
- StuInfoFreshEntity.GetKeyStatus = "0";
- }
- if (StuInfoFreshEntity.GetCardStatus != "1")
- {
- StuInfoFreshEntity.GetCardStatus = "0";
- }
- if (StuInfoFreshEntity.OtherPayFeeStatus != "1")
- {
- StuInfoFreshEntity.OtherPayFeeStatus = "0";
- }
- if (StuInfoFreshEntity.CollectFileStatus != "1")
- {
- StuInfoFreshEntity.CollectFileStatus = "0";
- }
-
-
- //是否完善信息
- StuInfoFreshFamilyList = stuInfoFreshIBLL.GetStuInfoFreshFamilyList(StuInfoFreshEntity.ID).ToList();
- StuInfoFreshEmergePeopleList = stuInfoFreshIBLL.GetStuInfoFreshEmergePeopleList(StuInfoFreshEntity.ID).ToList();
- StuInfoFreshEntity.IsCompleteInfo = StuInfoFreshFamilyList.Any() ? "已完善" : "未完善";
- }
-
- var result = new
- {
- StuInfoFreshEntity = StuInfoFreshEntity,
- StuInfoFreshFamilyList = StuInfoFreshFamilyList,
- StuInfoFreshEmergePeopleList = StuInfoFreshEmergePeopleList,
- Url = url
- };
-
- return Success(result);
- }
-
- /// <summary>
- /// 获取个人信息
- /// </summary>
- /// <param name="_"></param>
- /// <returns></returns>
- private Response GetStuInfoFresh(dynamic _)
- {
- var StuInfoFreshEntity = stuInfoFreshIBLL.GetStuInfoFreshEntityByStuNo(userInfo.account);
-
- var result = new
- {
- StuInfoFreshEntity = StuInfoFreshEntity
- };
-
- return Success(result);
- }
-
- /// <summary>
- /// 保存完善个人信息
- /// </summary>
- /// <param name="_"></param>
- /// <returns></returns>
- private Response GetSaveStuInfoFresh(dynamic _)
- {
- var model = this.GetReqData<StuInfoFreshModel>();
-
- var entity = stuInfoFreshIBLL.GetStuInfoFreshEntity(model.ID);
- entity.RegionNo = model.RegionNo;
- entity.FamilyAddress = model.FamilyAddress;
- entity.telephone = model.telephone;
- entity.BankCard = model.BankCard;
- entity.BankLocation = model.BankLocation;
- entity.DepositBank = model.DepositBank;
-
- if (!string.IsNullOrEmpty(model.Photo))
- {
- entity.IsPhoto = true;
- entity.Photo = model.Photo;
- }
- else
- {
- entity.IsPhoto = false;
- entity.Photo = "";
- }
-
- stuInfoFreshIBLL.SaveEntity(entity.ID, entity, model.StuInfoFreshEmergePeopleEntities, model.StuInfoFreshFamilyEntities);
-
- return Success("保存成功");
- }
- /// <summary>
- /// 保存贷款回执码
- /// </summary>
- /// <param name="_"></param>
- /// <returns></returns>
- private Response GetSaveLoan(dynamic _)
- {
- var model = this.GetReqData<StuInfoFreshModel>();
-
- var entity = stuInfoFreshIBLL.GetStuInfoFreshEntity(model.ID);
- entity.StudentLoan = model.StudentLoan;
- entity.StudentLoanStatus = model.StudentLoanStatus;
- entity.StudentLoanBLStatus = model.StudentLoanBLStatus;
- stuInfoFreshIBLL.SaveEntity(entity.ID, entity);
-
- return Success("保存成功");
- }
- /// <summary>
- /// 头像
- /// </summary>
- /// <param name="_"></param>
- /// <returns></returns>
- private Response GetSavePhoto(dynamic _)
- {
- var model = this.GetReqData<PhotoModel>();
-
- var folderId = Guid.NewGuid().ToString();
- string filePath = Config.GetValue("AnnexesFile");
- string uploadDate = DateTime.Now.ToString("yyyyMMdd");
- string FileEextension = ".png";
- string fileGuid = Guid.NewGuid().ToString();
- string virtualPath = string.Format("{0}/{1}/{2}/{3}{4}", filePath, userInfo.account, uploadDate, fileGuid, FileEextension);
-
- //创建文件夹
- string path = Path.GetDirectoryName(virtualPath);
- Directory.CreateDirectory(path);
- AnnexesFileEntity fileAnnexesEntity = new AnnexesFileEntity();
- if (!System.IO.File.Exists(virtualPath))
- {
- //byte[] bytes = Convert.FromBase64String(model.Base64Url.Replace("data:image/jpeg;base64,", ""));
- byte[] bytes = Convert.FromBase64String(model.Base64Url.Substring(model.Base64Url.IndexOf("base64,") + 7));
- FileInfo file = new FileInfo(virtualPath);
- FileStream fs = file.Create();
- fs.Write(bytes, 0, bytes.Length);
- fs.Close();
-
- //文件信息写入数据库
- fileAnnexesEntity.F_Id = fileGuid;
- fileAnnexesEntity.F_FileName = "userphoto.png";
- fileAnnexesEntity.F_FilePath = virtualPath;
- fileAnnexesEntity.F_FileSize = bytes.Length.ToString();
- fileAnnexesEntity.F_FileExtensions = FileEextension;
- fileAnnexesEntity.F_FileType = FileEextension.Replace(".", "");
- fileAnnexesEntity.F_CreateUserId = userInfo.userId;
- fileAnnexesEntity.F_CreateUserName = userInfo.realName;
- annexesFileIBLL.SaveEntity(folderId, fileAnnexesEntity);
- }
-
- var data = new
- {
- Url = virtualPath.Substring(virtualPath.IndexOf("Resource")),
- AnnexesFileId = fileGuid
- };
-
- return Success(data);
- }
-
- /// <summary>
- /// 学费查询
- /// </summary>
- /// <param name="_"></param>
- /// <returns></returns>
- private Response GetPayFeeDetail(dynamic _)
- {
- var academicAndYear = Common.GetSemesterAndYear();
- var FinaChargesStandardList = new List<FinaChargesStandardEntity>();
- var StuInfoFreshData = stuInfoFreshIBLL.GetStuInfoFreshEntityByStuNo(userInfo.account);
- if (StuInfoFreshData != null)
- {
- if (!string.IsNullOrEmpty(StuInfoFreshData.ClassNo) && !string.IsNullOrEmpty(StuInfoFreshData.MajorNo))
- {
- var ClassInfoEntity = classInfoIBLL.GetClassInfoEntityByClassNo(StuInfoFreshData.ClassNo);
- if (ClassInfoEntity != null)
- {
- FinaChargesStandardList = finaChargesStandardIBLL.GetFinaChargesStandardListByMajorNoOfNotAll(StuInfoFreshData.MajorNo, academicAndYear.AcademicYearShort, academicAndYear.Semester, ClassInfoEntity.Grade).ToList();
- }
- }
- }
- var PayFeeTotal = FinaChargesStandardList.Select(x => x.Standard).Sum();
-
- var result = new
- {
- FinaChargesStandardList = FinaChargesStandardList,
- PayFeeTotal = PayFeeTotal,
- AcademicYearNo = academicAndYear.AcademicYearShort,
- Semester = academicAndYear.Semester,
- };
-
- return Success(result);
- }
-
- /// <summary>
- /// 根据班级查询新生列表
- /// <summary>
- /// <param name="_"></param>
- /// <returns></returns>
- public Response GetPageList(dynamic _)
- {
- ReqPageParam parameter = this.GetReqData<ReqPageParam>();
- var data = stuInfoFreshIBLL.GetPageList(parameter.pagination, parameter.queryJson);
- var jsonData = new
- {
- rows = data,
- total = parameter.pagination.total,
- page = parameter.pagination.page,
- records = parameter.pagination.records
- };
- return Success(jsonData);
- }
-
- /// <summary>
- /// 获取表单数据
- /// <summary>
- /// <param name="_"></param>
- /// <returns></returns>
- public Response GetForm(dynamic _)
- {
- string keyValue = this.GetReqData();
- var StuInfoFreshData = stuInfoFreshIBLL.GetStuInfoFreshEntity(keyValue);
- var jsonData = new
- {
- StuInfoFresh = StuInfoFreshData,
- };
- return Success(jsonData);
- }
- /// <summary>
- /// 保存实体数据(新增、修改)
- /// <param name="_"></param>
- /// <summary>
- /// <returns></returns>
- public Response SaveForm(dynamic _)
- {
- ReqFormEntity parameter = this.GetReqData<ReqFormEntity>();
- StuInfoFreshEntity entity = parameter.strEntity.ToObject<StuInfoFreshEntity>();
- stuInfoFreshIBLL.SaveEntity(parameter.keyValue, entity);
- return Success("保存成功!");
- }
-
- #region 私有类
-
- /// <summary>
- /// 表单实体类
- /// <summary>
- private class ReqFormEntity
- {
- public string keyValue { get; set; }
- public string strEntity { get; set; }
- }
- #endregion
-
- /// <summary>
- /// 个人信息
- /// </summary>
- public class StuInfoFreshModel
- {
- /// <summary>
- /// 主键
- /// </summary>
- public string ID { get; set; }
- /// <summary>
- /// 籍贯
- /// </summary>
- public string RegionNo { get; set; }
- /// <summary>
- /// 家庭住址
- /// </summary>
- public string FamilyAddress { get; set; }
- /// <summary>
- /// 联系电话
- /// </summary>
- public string telephone { get; set; }
- /// <summary>
- /// 头像地址
- /// </summary>
- public string Photo { get; set; }
- /// <summary>
- /// 贷款回执码
- /// </summary>
- public string StudentLoan { get; set; }
- /// <summary>
- /// 贷款回执码状态
- /// </summary>
- public string StudentLoanStatus { get; set; }
- /// <summary>
- /// 办理贷款状态
- /// </summary>
- public string StudentLoanBLStatus { get; set; }
- /// <summary>
- /// 家庭成员
- /// </summary>
- public List<StuInfoFreshFamilyEntity> StuInfoFreshFamilyEntities { get; set; }
- /// <summary>
- /// 紧急联系人
- /// </summary>
- public List<StuInfoFreshEmergePeopleEntity> StuInfoFreshEmergePeopleEntities { get; set; }
- /// <summary>
- /// 开户行
- /// </summary>
- public string DepositBank { get; set; }
- /// <summary>
- /// 银行卡号
- /// </summary>
- public string BankCard { get; set; }
- /// <summary>
- /// 开户行位置
- /// </summary>
- public string BankLocation { get; set; }
-
- }
-
- public class PhotoModel
- {
- public string Base64Url { get; set; }
- public string account { get; set; }
- }
-
- }
- }
|