Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 
 

1359 righe
48 KiB

  1. using System;
  2. using Learun.Application.Base.SystemModule;
  3. using Learun.Application.Organization;
  4. using Learun.Application.TwoDevelopment.EducationalAdministration;
  5. using Learun.Util;
  6. using Learun.Util.Operat;
  7. using Nancy;
  8. using System.Collections.Generic;
  9. using System.IO;
  10. using System.Linq;
  11. using System.Web;
  12. using Learun.Application.Mapping;
  13. using Learun.Application.OA;
  14. using Learun.Application.TwoDevelopment.AdmissionsPlatform;
  15. using Learun.Application.TwoDevelopment.LogisticsManagement;
  16. using Newtonsoft.Json;
  17. namespace Learun.Application.WebApi
  18. {
  19. /// <summary>
  20. /// 版 本 Learun-ADMS V7.0.0 数字化智慧校园
  21. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  22. /// 创建人:数字化智慧校园-框架开发组
  23. /// 日 期:2017.05.12
  24. /// 描 述:用户信息
  25. /// </summary>
  26. public class TUserApi : BaseNoLoginApi
  27. {
  28. /// <summary>
  29. /// 注册接口
  30. /// </summary>
  31. public TUserApi()
  32. : base("/user")
  33. {
  34. Post["/login"] = Login;//登录
  35. Post["/studentLogin"] = StudentLogin;//学生登录
  36. Post["/studentRegister"] = StudentRegister;//学生注册
  37. Post["/getstunum"] = GetStuNum;//获得各种状态的学生数量
  38. Post["/getdataitem"] = GetDataItem;//根据code获取字典值
  39. Get["/getcompany"] = GetCompany;//获取校区
  40. Post["/getmajor"] = GetMajorByCompany;//根据校区获取专业
  41. Post["/majorDetail"] = GetMajorDetail;//专业详细
  42. Post["/register"] = StuRegister;//学生注册
  43. Post["/getCultureInfo"] = GetCultureInfo;//获取学生文化程度列表
  44. Post["/delstu"] = DelStu;//删除学生信息
  45. Post["/updatestu"] = UpdateStuInfoById;//修改学生信息
  46. Post["/updateStuByStuTerminal"] = UpdateStuByStuTerminal;//学生端修改个人信息
  47. Post["/getstuinfo"] = GetStuInfo;//获取学生列表
  48. Post["/getstubyid"] = GetStuById;//根据id获取学生信息
  49. Post["/getStuByUserId"] = GetStuInfoByUserId;//根据id获取学生信息
  50. Post["/upload"] = Upload;//修改头像
  51. Post["/uploadStudent"] = UploadStudent;//修改头像
  52. Post["/updatetea"] = UpdataTeacherInfo;
  53. Post["/updatepwd"] = UpdatePassword;//教师修改密码
  54. Post["/updatePwdStu"] = UpdatePasswordStu;//学生修改密码
  55. Post["/bankinfo"] = BankInfo;
  56. Post["/integradetail"] = IntegralDetails;
  57. Post["/detailInfo"] = DetailInfo;
  58. Post["/aboutSchool"] = AboutSchool;
  59. Post["/getnews"] = GetNews;
  60. Post["/getnewsdetail"] = GetNewsDetail;
  61. Post["/getCompanyNews"] = GetCompanyNews;//获取校区新闻和招生信息
  62. Post["/getCompanyNewsDetail"] = GetCompanyNewsDetail;//获取校区新闻
  63. Post["/getCompanyInfo"] = GetCompanyInfo;//获取校区信息
  64. Post["/forgetPwd"] = ForgetPwd; //忘记密码
  65. Post["/getEditionInfo"] = GetEditonInfo;//获取版本信息
  66. }
  67. private UserIBLL userIBLL = new UserBLL();
  68. private AnnexesFileIBLL annexesFileIBLL = new AnnexesFileBLL();
  69. private PostIBLL postIBLL = new PostBLL();
  70. private RoleIBLL roleIBLL = new RoleBLL();
  71. private DataItemIBLL dataItemIBLL = new DataItemBLL();
  72. private StuInfoBasicIBLL stuInfoBasicIBLL = new StuInfoBasicBLL();
  73. private DepartmentIBLL departmentIBLL = new DepartmentBLL();
  74. private AP_OnlineStudentInfoIBLL aP_OnlineStudentInfoIBLL = new AP_OnlineStudentInfoBLL();
  75. private AP_OnlineUserInfoIBLL aP_OnlineUserInfoIBLL = new AP_OnlineUserInfoBLL();
  76. private CompanyIBLL companyIBLL = new CompanyBLL();
  77. private AP_TeacherBankCardIBLL aP_TeacherBankCardIBLL = new AP_TeacherBankCardBLL();
  78. private AP_IntegralDetailsIBLL aP_IntegralDetailsIBLL = new AP_IntegralDetailsBLL();
  79. private CdMajorIBLL majorIbll = new CdMajorBLL();
  80. private NewsIBLL newsIBLL = new NewsBLL();
  81. private BCdCultureDegreeIBLL bCdCultureDegreeIBLL = new BCdCultureDegreeBLL();
  82. private CompanyNewsIBLL companyNewsIBLL = new CompanyNewsBLL();
  83. private EditonManagementIBLL editonManagementIbll = new EditonManagementBLL();
  84. /// <summary>
  85. /// 登录接口
  86. /// </summary>
  87. /// <param name="_"></param>
  88. /// <returns></returns>
  89. private Response Login(dynamic _)
  90. {
  91. var loginModel = this.GetReqData<TLoginModel>();
  92. #region 内部账户验证
  93. UserEntity userEntity = userIBLL.CheckLogin(loginModel.username, Md5Helper.Encrypt(loginModel.password, 32));
  94. if (!userEntity.LoginOk)//登录失败
  95. {
  96. return Fail(userEntity.LoginMsg);
  97. }
  98. else
  99. {
  100. var userInfo = userIBLL.GetEntityByUserId(userEntity.F_UserId);
  101. var companyEntity = companyIBLL.GetEntity(userInfo?.F_CompanyId);
  102. var departmentEntity = departmentIBLL.GetEntity(userInfo?.F_CompanyId, userInfo?.F_DepartmentId);
  103. var result = new
  104. {
  105. ID = userInfo?.F_UserId,
  106. username = userInfo?.F_RealName,
  107. sex = userInfo?.F_Gender,
  108. sexname = userInfo?.F_Gender == 1 ? "男" : "女",
  109. photo = userInfo?.F_HeadIcon,
  110. phone = userInfo?.F_Mobile,
  111. status = 1,
  112. birth = userInfo?.F_Birthday,
  113. depart = "",
  114. departname = "",
  115. school = userInfo?.F_CompanyId,
  116. schoolname = companyEntity?.F_FullName,
  117. culture = "",
  118. culturename = "",
  119. pTotalMoney = "",
  120. teaID = "",
  121. teaName = "",
  122. teaPhone = "",
  123. ids = userInfo?.F_IdentityCardNo,
  124. gexin = userInfo?.PerSignature
  125. };
  126. return Success(result);
  127. }
  128. #endregion
  129. }
  130. private Response StudentLogin(dynamic _)
  131. {
  132. var loginModel = this.GetReqData<TLoginModel>();
  133. #region 内部账户验证
  134. var stuEntity = aP_OnlineUserInfoIBLL.GetEntityByPhone(loginModel.username);
  135. var stuInfoEntity = aP_OnlineStudentInfoIBLL.GetEntityByUserId(stuEntity.Id);
  136. var company = companyIBLL.GetEntity(stuInfoEntity.SchoolId);
  137. var major = majorIbll.GetCdMajorEntityByMajorNo(stuInfoEntity.MajorId);
  138. var teacher = userIBLL.GetEntityByUserId(stuInfoEntity.UserTeacherId);
  139. var cultrue = bCdCultureDegreeIBLL.GetEntity(stuInfoEntity.CultureId);
  140. if (stuEntity != null)
  141. {
  142. if (stuEntity.Password.Trim() == loginModel.password.Trim())
  143. {
  144. var photourl = annexesFileIBLL.GetEntityByFolderId(stuEntity.PhotoUrl)?.F_FilePath;
  145. if (photourl != null && photourl.IndexOf("Resource") > 0)
  146. {
  147. photourl = "/" + photourl.Substring(photourl.IndexOf("Resource"));
  148. }
  149. var entity = new
  150. {
  151. ID = stuEntity.Id,
  152. username = stuEntity.RealName,
  153. sex = stuEntity.SexId,
  154. sexname = stuEntity.SexId == "1" ? "男" : "女",
  155. photo = photourl,
  156. phone = stuEntity.Mobile,
  157. status = 1,
  158. birth = stuEntity.BirthDate,
  159. depart = stuInfoEntity.MajorId,
  160. departname = major?.MajorName,
  161. school = stuInfoEntity.SchoolId,
  162. schoolname = company?.F_FullName,
  163. culture = stuInfoEntity.CultureId,
  164. culturename = cultrue?.CultureDegree,
  165. pTotalMoney = "",
  166. teaID = stuInfoEntity.UserTeacherId,
  167. teaName = teacher?.F_RealName,
  168. teaPhone = teacher?.F_Mobile,
  169. ids = stuEntity.CertNum,
  170. gexin = ""
  171. };
  172. return Success(entity);
  173. }
  174. else
  175. {
  176. return Fail("账号密码不正确");
  177. }
  178. }
  179. else
  180. {
  181. return Fail("账号密码不正确");
  182. }
  183. #endregion
  184. }
  185. private Response StudentRegister(dynamic _)
  186. {
  187. var regModel = this.GetReqData<RegisterModel>();
  188. var entity = aP_OnlineUserInfoIBLL.GetEntityByMobile(regModel.mobile);
  189. if (entity != null)
  190. {
  191. return Fail("此手机号已经被注册");
  192. }
  193. else
  194. {
  195. var newEntity = new AP_OnlineUserInfoEntity();
  196. var newStuEntity = new AP_OnlineStudentInfoEntity();
  197. newEntity.RealName = regModel.name;
  198. newEntity.Mobile = regModel.mobile;
  199. newEntity.CertNum = regModel.ids;
  200. newEntity.Password = regModel.logpwd;
  201. aP_OnlineUserInfoIBLL.SaveEntity("", newEntity);
  202. newStuEntity.UserId = newEntity.Id;
  203. aP_OnlineStudentInfoIBLL.SaveEntity("", newStuEntity);
  204. return Success("注册成功");
  205. }
  206. }
  207. /// <summary>
  208. /// 获取用户信息
  209. /// </summary>
  210. /// <param name="_"></param>
  211. /// <returns></returns>
  212. private Response GetStuNum(dynamic _)
  213. {
  214. var teacherId = this.GetReqData();
  215. var users = aP_OnlineStudentInfoIBLL.GetAllList().Where(a => a.UserTeacherId == teacherId).ToList();
  216. var count = users.Count();
  217. var isPayNum = users.Count(a => a.IsPaymentId == "1");
  218. var isDropoutNum = users.Count(a => a.IsDropOut == "1");
  219. var result = new
  220. {
  221. count,
  222. isPayNum,
  223. isDropoutNum
  224. };
  225. return Success(result);
  226. }
  227. /// <summary>
  228. /// 获取字典
  229. /// </summary>
  230. /// <param name="_"></param>
  231. /// <returns></returns>
  232. private Response GetDataItem(dynamic _)
  233. {
  234. var code = this.GetReqData();
  235. var itemList = dataItemIBLL.GetDetailList(code);
  236. var result = new List<object>();
  237. foreach (var item in itemList)
  238. {
  239. result.Add(new
  240. {
  241. dicentryid = item.F_ItemValue,
  242. name = item.F_ItemName
  243. });
  244. }
  245. return Success(result);
  246. }
  247. /// <summary>
  248. /// 获取校区
  249. /// </summary>
  250. /// <param name="_"></param>
  251. /// <returns></returns>
  252. private Response GetCompany(dynamic _)
  253. {
  254. var compList = companyIBLL.GetList().ToList();
  255. var result = new List<object>();
  256. foreach (var company in compList)
  257. {
  258. var photo = "";
  259. if (company.F_Photo != null)
  260. {
  261. photo = annexesFileIBLL.GetEntityByFolderId(company.F_Photo)?.F_FilePath;
  262. if (!string.IsNullOrEmpty(photo))
  263. {
  264. photo = "/" + photo.Substring(photo.IndexOf("Resource"));
  265. }
  266. }
  267. result.Add(new
  268. {
  269. schoolID = company.F_CompanyId,
  270. school = company.F_FullName,
  271. address = company.F_Address,
  272. schoolPic = photo
  273. });
  274. }
  275. return Success(result);
  276. }
  277. private Response GetMajorByCompany(dynamic _)
  278. {
  279. var companyId = this.GetReqData();
  280. var result = new List<object>();
  281. if (!string.IsNullOrEmpty(companyId))
  282. {
  283. var majorList = majorIbll.GetAllList().Where(a => a.F_SchoolId == companyId);
  284. if (majorList.Count() > 0)
  285. {
  286. foreach (var major in majorList)
  287. {
  288. result.Add(new
  289. {
  290. departID = major.MajorNo,
  291. depart = major.MajorName,
  292. type = major.RecruitObject
  293. });
  294. }
  295. return Success(result);
  296. }
  297. else
  298. {
  299. return Fail("无专业");
  300. }
  301. }
  302. else
  303. {
  304. return Fail("未知错误");
  305. }
  306. }
  307. private Response GetMajorDetail(dynamic _)
  308. {
  309. var majorNo = this.GetReqData();
  310. var entity = majorIbll.GetCdMajorEntityByMajorNo(majorNo);
  311. var itemList = dataItemIBLL.GetDetailList("RecruitObject").ToList();
  312. var school = companyIBLL.GetEntity(entity.F_SchoolId);
  313. var photo = "";
  314. if (!string.IsNullOrEmpty(entity.Photo))
  315. {
  316. photo = annexesFileIBLL.GetEntityByFolderId(entity.Photo)?.F_FilePath;
  317. if (!string.IsNullOrEmpty(photo))
  318. {
  319. photo = "/" + photo.Substring(photo.IndexOf("Resource"));
  320. }
  321. }
  322. var result = new
  323. {
  324. pimage = photo,
  325. name = entity.MajorName,
  326. schoolName = school?.F_FullName,
  327. pObjectName = itemList.FirstOrDefault(a => a.F_ItemValue == entity.RecruitObject)?.F_ItemName, //招生对象
  328. developLevel = entity.DevelopLevel, //培养对象
  329. pCertificate = entity.Certificate,
  330. developTarget = entity.DevelopTarget,
  331. introduce = entity.Introduce,
  332. };
  333. return Success(result);
  334. }
  335. private Response StuRegister(dynamic _)
  336. {
  337. var stuModel = this.GetReqData<StuModel>();
  338. AP_OnlineStudentInfoEntity infoEntity = new AP_OnlineStudentInfoEntity();
  339. AP_OnlineUserInfoEntity userEntity = new AP_OnlineUserInfoEntity();
  340. userEntity.RealName = stuModel.username;
  341. userEntity.SexId = stuModel.sex;
  342. userEntity.Mobile = stuModel.phone;
  343. userEntity.Password = "123456";
  344. userEntity.DetailedAddress = stuModel.address;
  345. userEntity.CertNum = stuModel.ids;
  346. userEntity.Province = stuModel.province;
  347. userEntity.City = stuModel.city;
  348. userEntity.Country = stuModel.county;
  349. aP_OnlineUserInfoIBLL.SaveEntity("", userEntity);
  350. infoEntity.UserId = userEntity.Id;
  351. infoEntity.CultureId = stuModel.culture;
  352. infoEntity.SchoolId = stuModel.school;
  353. infoEntity.MajorId = stuModel.depart;
  354. infoEntity.PaymentQuota = Convert.ToDecimal(stuModel.paymentQuota);
  355. infoEntity.UserTeacherId = stuModel.rTeacher;
  356. infoEntity.Remarks = stuModel.renarks;
  357. aP_OnlineStudentInfoIBLL.SaveEntity("", infoEntity);
  358. return Success("修改成功");
  359. }
  360. private Response GetCultureInfo(dynamic _)
  361. {
  362. var list = bCdCultureDegreeIBLL.GetAllList().ToList();
  363. List<object> result = new List<object>();
  364. foreach (var item in list)
  365. {
  366. result.Add(new
  367. {
  368. dicentryid = item.CultureDegreeNo,
  369. name = item.CultureDegree
  370. });
  371. }
  372. return Success(result);
  373. }
  374. private Response DelStu(dynamic _)
  375. {
  376. var id = this.GetReqData();
  377. var stuEntity = aP_OnlineStudentInfoIBLL.GetEntity(id);
  378. if (stuEntity != null)
  379. {
  380. aP_OnlineStudentInfoIBLL.DeleteEntity(id);
  381. aP_OnlineUserInfoIBLL.DeleteEntity(stuEntity.UserId);
  382. return Success("删除成功");
  383. }
  384. else
  385. {
  386. return Fail("删除失败");
  387. }
  388. }
  389. private Response UpdateStuByStuTerminal(dynamic _)
  390. {
  391. var stuModel = this.GetReqData<StuModel>();
  392. AP_OnlineUserInfoEntity userEntity = aP_OnlineUserInfoIBLL.GetEntity(stuModel.id);
  393. if (userEntity == null)
  394. {
  395. return Fail("未找到学生信息");
  396. }
  397. if (!string.IsNullOrEmpty(stuModel.username))
  398. {
  399. userEntity.RealName = stuModel.username;
  400. }
  401. if (!string.IsNullOrEmpty(stuModel.birthday))
  402. {
  403. userEntity.BirthDate = Convert.ToDateTime(stuModel.birthday);
  404. }
  405. if (!string.IsNullOrEmpty(stuModel.sex))
  406. {
  407. userEntity.SexId = stuModel.sex;
  408. }
  409. if (!string.IsNullOrEmpty(stuModel.phone))
  410. {
  411. userEntity.Mobile = stuModel.phone;
  412. }
  413. if (!string.IsNullOrEmpty(stuModel.address))
  414. {
  415. userEntity.DetailedAddress = stuModel.address;
  416. }
  417. if (!string.IsNullOrEmpty(stuModel.ids))
  418. {
  419. userEntity.CertNum = stuModel.ids;
  420. }
  421. if (!string.IsNullOrEmpty(stuModel.province))
  422. {
  423. userEntity.Province = stuModel.province;
  424. }
  425. if (!string.IsNullOrEmpty(stuModel.city))
  426. {
  427. userEntity.City = stuModel.city;
  428. }
  429. if (!string.IsNullOrEmpty(stuModel.county))
  430. {
  431. userEntity.Country = stuModel.county;
  432. }
  433. aP_OnlineUserInfoIBLL.SaveEntity(stuModel.id, userEntity);
  434. AP_OnlineStudentInfoEntity infoEntity = aP_OnlineStudentInfoIBLL.GetEntityByUserId(userEntity.Id);
  435. if (infoEntity == null)
  436. {
  437. return Fail("找不到用户数据");
  438. }
  439. if (!string.IsNullOrEmpty(stuModel.culture))
  440. {
  441. infoEntity.CultureId = stuModel.culture;
  442. }
  443. if (!string.IsNullOrEmpty(stuModel.school))
  444. {
  445. infoEntity.SchoolId = stuModel.school;
  446. }
  447. if (!string.IsNullOrEmpty(stuModel.depart))
  448. {
  449. infoEntity.MajorId = stuModel.depart;
  450. }
  451. if (!string.IsNullOrEmpty(stuModel.paymentQuota))
  452. {
  453. infoEntity.PaymentQuota = Convert.ToDecimal(stuModel.paymentQuota);
  454. }
  455. if (!string.IsNullOrEmpty(stuModel.rTeacher))
  456. {
  457. infoEntity.UserTeacherId = stuModel.rTeacher;
  458. }
  459. if (!string.IsNullOrEmpty(stuModel.renarks))
  460. {
  461. infoEntity.Remarks = stuModel.renarks;
  462. }
  463. aP_OnlineStudentInfoIBLL.SaveEntity(infoEntity.Id, infoEntity);
  464. return Success("修改成功");
  465. }
  466. private Response UpdateStuInfoById(dynamic _)
  467. {
  468. var stuModel = this.GetReqData<StuModel>();
  469. AP_OnlineStudentInfoEntity infoEntity = aP_OnlineStudentInfoIBLL.GetEntity(stuModel.id);
  470. if (infoEntity == null)
  471. {
  472. return Fail("找不到用户数据");
  473. }
  474. if (!string.IsNullOrEmpty(stuModel.culture))
  475. {
  476. infoEntity.CultureId = stuModel.culture;
  477. }
  478. if (!string.IsNullOrEmpty(stuModel.school))
  479. {
  480. infoEntity.SchoolId = stuModel.school;
  481. }
  482. if (!string.IsNullOrEmpty(stuModel.depart))
  483. {
  484. infoEntity.MajorId = stuModel.depart;
  485. }
  486. if (!string.IsNullOrEmpty(stuModel.paymentQuota))
  487. {
  488. infoEntity.PaymentQuota = Convert.ToDecimal(stuModel.paymentQuota);
  489. }
  490. if (!string.IsNullOrEmpty(stuModel.rTeacher))
  491. {
  492. infoEntity.UserTeacherId = stuModel.rTeacher;
  493. }
  494. if (!string.IsNullOrEmpty(stuModel.renarks))
  495. {
  496. infoEntity.Remarks = stuModel.renarks;
  497. }
  498. aP_OnlineStudentInfoIBLL.SaveEntity(stuModel.id, infoEntity);
  499. AP_OnlineUserInfoEntity userEntity = aP_OnlineUserInfoIBLL.GetEntity(infoEntity.UserId);
  500. if (!string.IsNullOrEmpty(stuModel.username))
  501. {
  502. userEntity.RealName = stuModel.username;
  503. }
  504. if (!string.IsNullOrEmpty(stuModel.sex))
  505. {
  506. userEntity.SexId = stuModel.sex;
  507. }
  508. if (!string.IsNullOrEmpty(stuModel.phone))
  509. {
  510. userEntity.Mobile = stuModel.phone;
  511. }
  512. if (!string.IsNullOrEmpty(stuModel.address))
  513. {
  514. userEntity.DetailedAddress = stuModel.address;
  515. }
  516. if (!string.IsNullOrEmpty(stuModel.ids))
  517. {
  518. userEntity.CertNum = stuModel.ids;
  519. }
  520. if (!string.IsNullOrEmpty(stuModel.province))
  521. {
  522. userEntity.Province = stuModel.province;
  523. }
  524. if (!string.IsNullOrEmpty(stuModel.city))
  525. {
  526. userEntity.City = stuModel.city;
  527. }
  528. if (!string.IsNullOrEmpty(stuModel.county))
  529. {
  530. userEntity.Country = stuModel.county;
  531. }
  532. aP_OnlineUserInfoIBLL.SaveEntity(infoEntity.UserId, userEntity);
  533. return Success("修改成功");
  534. }
  535. private Response GetStuInfo(dynamic _)
  536. {
  537. var queryParam = this.GetReqData<stuQueryParam>();
  538. var stuInfolist = aP_OnlineStudentInfoIBLL.GetList("").Where(a => a.UserTeacherId == queryParam.empid).ToList();
  539. var userInfo = aP_OnlineUserInfoIBLL.GetList("");
  540. List<AP_OnlineStudentInfoEntity> reList = new List<AP_OnlineStudentInfoEntity>();
  541. switch (queryParam.num)
  542. {
  543. case "1":
  544. reList = stuInfolist;
  545. break;
  546. case "2":
  547. reList = stuInfolist.Where(a => a.IsPaymentId == "1")
  548. .Where(a => a.IsDropOut == null || a.IsDropOut == "0").ToList();
  549. break;
  550. case "3":
  551. reList = stuInfolist.Where(a => a.IsDropOut == "1").ToList();
  552. break;
  553. case "4":
  554. reList = stuInfolist.Where(a => a.PaymentQuota == 0 || a.PaymentQuota == null).ToList();
  555. break;
  556. default:
  557. reList = stuInfolist;
  558. break;
  559. }
  560. List<object> result = new List<object>();
  561. foreach (var item in reList)
  562. {
  563. var companyEntity = companyIBLL.GetEntity(item.SchoolId);
  564. var majorEntity = majorIbll.GetCdMajorEntityByMajorNo(item.MajorId);
  565. var entity = userInfo.FirstOrDefault(a => a.Id == item.UserId);
  566. var photo = entity.PhotoUrl;
  567. result.Add(new
  568. {
  569. userPhoto = photo,
  570. strdentName = entity.RealName,
  571. strMobile = entity.Mobile,
  572. moneyQuota = item.PaymentQuota == null ? 0 : item.PaymentQuota,
  573. schoolName = companyEntity?.F_FullName,
  574. professionName = majorEntity?.MajorName,
  575. professionMoney = "",
  576. ID = item.Id,
  577. UserID = item.UserId
  578. });
  579. }
  580. return Success(result);
  581. }
  582. private Response GetStuById(dynamic _)
  583. {
  584. var userId = this.GetReqData();
  585. var stuentity = aP_OnlineStudentInfoIBLL.GetEntity(userId);
  586. var userentity = aP_OnlineUserInfoIBLL.GetEntity(stuentity.UserId);
  587. var result = new
  588. {
  589. username = userentity.RealName,
  590. sexid = userentity.SexId,
  591. sex = userentity.SexId == "1" ? "男" : "女",
  592. phone = userentity.Mobile,
  593. address = userentity.DetailedAddress,
  594. ids = userentity.CertNum,
  595. cultureid = stuentity.CultureId,
  596. culture = bCdCultureDegreeIBLL.GetEntity(stuentity.CultureId)?.CultureDegree,
  597. schoolid = stuentity.SchoolId,
  598. school = companyIBLL.GetEntity(stuentity.SchoolId)?.F_FullName,
  599. departid = stuentity.MajorId,
  600. depart = majorIbll.GetCdMajorEntityByMajorNo(stuentity.MajorId)?.MajorName,
  601. paymentQuota = stuentity.PaymentQuota,
  602. renarks = stuentity.Remarks,
  603. province = userentity.Province,
  604. city = userentity.City,
  605. county = userentity.Country
  606. };
  607. return Success(result);
  608. }
  609. private Response GetStuInfoByUserId(dynamic _)
  610. {
  611. var userId = this.GetReqData();
  612. var userentity = aP_OnlineUserInfoIBLL.GetEntity(userId);
  613. var stuentity = aP_OnlineStudentInfoIBLL.GetEntityByUserId(userentity.Id);
  614. var company = companyIBLL.GetEntity(stuentity.SchoolId);
  615. var major = majorIbll.GetCdMajorEntityByMajorNo(stuentity.MajorId);
  616. var teacher = userIBLL.GetEntityByUserId(stuentity.UserTeacherId);
  617. var cultrue = bCdCultureDegreeIBLL.GetEntity(stuentity.CultureId);
  618. var photourl = annexesFileIBLL.GetEntityByFolderId(userentity.PhotoUrl)?.F_FilePath;
  619. if (photourl != null && photourl.IndexOf("Resource") > 0)
  620. {
  621. photourl = "/" + photourl.Substring(photourl.IndexOf("Resource"));
  622. }
  623. var result = new
  624. {
  625. ID = userentity.Id,
  626. username = userentity.RealName,
  627. sex = userentity.SexId,
  628. sexname = userentity.SexId == "1" ? "男" : "女",
  629. photo = photourl,
  630. phone = userentity.Mobile,
  631. status = 1,
  632. birth = userentity.BirthDate,
  633. depart = stuentity.MajorId,
  634. departname = major?.MajorName,
  635. school = stuentity.SchoolId,
  636. schoolname = company?.F_FullName,
  637. culture = stuentity.CultureId,
  638. culturename = cultrue?.CultureDegree,
  639. pTotalMoney = "",
  640. teaID = stuentity.UserTeacherId,
  641. teaName = teacher?.F_RealName,
  642. teaPhone = teacher?.F_Mobile,
  643. ids = userentity.CertNum,
  644. gexin = ""
  645. };
  646. return Success(result);
  647. }
  648. private Response Upload(dynamic _)
  649. {
  650. var userid = this.GetReqData();
  651. HttpFileCollection files = System.Web.HttpContext.Current.Request.Files;
  652. //没有文件上传,直接返回
  653. if (files[0].ContentLength == 0 || string.IsNullOrEmpty(files[0].FileName))
  654. {
  655. return Fail("");
  656. }
  657. string FileEextension = Path.GetExtension(files[0].FileName);
  658. string filePath = Config.GetValue("AnnexesFile");
  659. string uploadDate = DateTime.Now.ToString("yyyyMMdd");
  660. string fileGuid = Guid.NewGuid().ToString();
  661. string fileHeadImg = Config.GetValue("AnnexesFile");
  662. //string fullFileName = string.Format("{0}/{1}{2}", fileHeadImg, userInfo.userId, FileEextension);
  663. string fullFileName = $"{fileHeadImg}/{userid}/{uploadDate}/{fileGuid}{FileEextension}";
  664. var saveFileName = "/Resource/" + fullFileName.Substring(fullFileName.IndexOf(userid), fullFileName.Length - fullFileName.IndexOf(userid));
  665. //创建文件夹,保存文件
  666. string path = Path.GetDirectoryName(fullFileName);
  667. Directory.CreateDirectory(path);
  668. files[0].SaveAs(fullFileName);
  669. UserEntity userEntity = new UserEntity();
  670. userEntity.F_UserId = userid;
  671. userEntity.F_HeadIcon = saveFileName;
  672. userIBLL.SaveEntity(userEntity.F_UserId, userEntity);
  673. return Success(saveFileName);
  674. }
  675. private Response UploadStudent(dynamic _)
  676. {
  677. var userid = this.GetReqData();
  678. HttpFileCollection files = System.Web.HttpContext.Current.Request.Files;
  679. //没有文件上传,直接返回
  680. if (files[0].ContentLength == 0 || string.IsNullOrEmpty(files[0].FileName))
  681. {
  682. return Fail("");
  683. }
  684. string FileEextension = Path.GetExtension(files[0].FileName);
  685. string filePath = Config.GetValue("AnnexesFile");
  686. string uploadDate = DateTime.Now.ToString("yyyyMMdd");
  687. string fileGuid = Guid.NewGuid().ToString();
  688. string fileHeadImg = Config.GetValue("AnnexesFile");
  689. //string fullFileName = string.Format("{0}/{1}{2}", fileHeadImg, userInfo.userId, FileEextension);
  690. string fullFileName = $"{fileHeadImg}/{userid}/{uploadDate}/{fileGuid}{FileEextension}";
  691. var saveFileName = "/Resource/" + fullFileName.Substring(fullFileName.IndexOf(userid), fullFileName.Length - fullFileName.IndexOf(userid));
  692. //创建文件夹,保存文件
  693. string path = Path.GetDirectoryName(fullFileName);
  694. Directory.CreateDirectory(path);
  695. files[0].SaveAs(fullFileName);
  696. var stuInfoEntity = aP_OnlineUserInfoIBLL.GetEntity(userid);
  697. if (stuInfoEntity != null)
  698. {
  699. if (!string.IsNullOrEmpty(stuInfoEntity.PhotoUrl))
  700. {
  701. var annexEntity = annexesFileIBLL.GetEntityByFolderId(stuInfoEntity.PhotoUrl);
  702. annexEntity.F_FilePath = fullFileName;
  703. annexEntity.F_Id = Guid.NewGuid().ToString();
  704. annexesFileIBLL.SaveEntity(stuInfoEntity.PhotoUrl, annexEntity);
  705. }
  706. else
  707. {
  708. stuInfoEntity.PhotoUrl = Guid.NewGuid().ToString();
  709. aP_OnlineUserInfoIBLL.SaveEntity(stuInfoEntity.Id, stuInfoEntity);
  710. var annexEntity = new AnnexesFileEntity();
  711. annexEntity.F_FilePath = fullFileName;
  712. annexEntity.F_FolderId = stuInfoEntity.PhotoUrl;
  713. annexEntity.F_Id = Guid.NewGuid().ToString();
  714. annexesFileIBLL.SaveEntity(stuInfoEntity.PhotoUrl, annexEntity);
  715. }
  716. }
  717. return Success(saveFileName);
  718. }
  719. private Response UpdataTeacherInfo(dynamic _)
  720. {
  721. var strEntity = this.GetReqData<teaInfo>();
  722. var teaEntity = userIBLL.GetEntityByUserId(strEntity.id);
  723. if (teaEntity != null)
  724. {
  725. teaEntity.F_RealName = strEntity.realName;
  726. teaEntity.F_Gender = Convert.ToInt32(strEntity.sexID);
  727. teaEntity.F_Birthday = strEntity.birthDate.ToDate();
  728. teaEntity.PerSignature = strEntity.remark;
  729. teaEntity.F_Mobile = strEntity.photo;
  730. userIBLL.SaveEntity(teaEntity.F_UserId, teaEntity);
  731. }
  732. return Success("修改成功");
  733. }
  734. private Response UpdatePassword(dynamic _)
  735. {
  736. var strEntity = this.GetReqData<pwdModel>();
  737. strEntity.oldpwd = Md5Helper.Encrypt(strEntity.oldpwd, 32);
  738. strEntity.newpwd = Md5Helper.Encrypt(strEntity.newpwd, 32);
  739. var entity = userIBLL.GetEntityByUserId(strEntity.userid);
  740. if (entity != null)
  741. {
  742. string oldPasswordByEncrypt = Md5Helper.Encrypt(DESEncrypt.Encrypt(strEntity.oldpwd, entity.F_Secretkey).ToLower(), 32).ToLower();
  743. if (oldPasswordByEncrypt == entity.F_Password)
  744. {
  745. userIBLL.setPassword(entity.F_UserId, strEntity.newpwd);
  746. }
  747. else
  748. {
  749. return Fail("旧密码不正确");
  750. }
  751. return Success("修改成功");
  752. }
  753. else
  754. {
  755. return Fail("修改失败");
  756. }
  757. }
  758. private Response UpdatePasswordStu(dynamic _)
  759. {
  760. var strEntity = this.GetReqData<pwdModel>();
  761. var entity = aP_OnlineUserInfoIBLL.GetEntity(strEntity.userid);
  762. if (entity != null)
  763. {
  764. if (strEntity.oldpwd == entity.Password)
  765. {
  766. entity.Password = strEntity.newpwd;
  767. aP_OnlineUserInfoIBLL.SaveEntity(entity.Id, entity);
  768. }
  769. else
  770. {
  771. return Fail("旧密码不正确");
  772. }
  773. return Success("修改成功");
  774. }
  775. else
  776. {
  777. return Fail("修改失败");
  778. }
  779. }
  780. private Response BankInfo(dynamic _)
  781. {
  782. var userId = this.GetReqData();
  783. var list = aP_TeacherBankCardIBLL.GetListByID(userId).ToList();
  784. List<object> result = new List<object>();
  785. foreach (var item in list)
  786. {
  787. result.Add(new
  788. {
  789. bankName = item.Bank,
  790. bankNumber = item.BankCardNo
  791. });
  792. }
  793. return Success(result);
  794. }
  795. private Response IntegralDetails(dynamic _)
  796. {
  797. var userId = this.GetReqData();
  798. var list = aP_IntegralDetailsIBLL.GetListByID(userId).ToList();
  799. List<object> result = new List<object>();
  800. foreach (var item in list)
  801. {
  802. result.Add(new
  803. {
  804. year = item.CreateTime.ToDate().Year,
  805. bankNumber = item.BankCardNo,
  806. scoresNum = item.IntegralNum,
  807. createDate = item.CreateTime,
  808. scorename = item.IntegralName
  809. });
  810. }
  811. return Success(result);
  812. }
  813. private Response DetailInfo(dynamic _)
  814. {
  815. var userId = this.GetReqData();
  816. var list = aP_IntegralDetailsIBLL.GetListByID(userId).ToList();
  817. var result = new
  818. {
  819. getcount = list.Count(a => a.IsReceived == "1"),
  820. allcount = list.Count()
  821. };
  822. return Success(result);
  823. }
  824. private Response AboutSchool(dynamic _)
  825. {
  826. var list = newsIBLL.GetAboutSchool().FirstOrDefault();
  827. return Success(new { content = list.F_NewsContent });
  828. }
  829. private Response GetNews(dynamic _)
  830. {
  831. var list = newsIBLL.GetNews();
  832. List<object> result = new List<object>();
  833. foreach (var item in list)
  834. {
  835. result.Add(new
  836. {
  837. articleID = item.F_NewsId,
  838. title = item.F_FullHead,
  839. common = item.F_NewsContent,
  840. date = item.F_CreateDate
  841. });
  842. }
  843. return Success(result);
  844. }
  845. private Response GetNewsDetail(dynamic _)
  846. {
  847. var id = this.GetReqData();
  848. var list = newsIBLL.GetEntity(id);
  849. var result = new
  850. {
  851. title = list.F_FullHead,
  852. date = list.F_CreateDate,
  853. content = list.F_NewsContent
  854. };
  855. return Success(result);
  856. }
  857. private Response GetCompanyNews(dynamic _)
  858. {
  859. var param = this.GetReqData<newsParamModel>();
  860. var list = companyNewsIBLL.GetListByCompanyID(param.companyid).ToList();
  861. if (param.type == "1")
  862. {
  863. list = list.Where(a => a.NewType == "1").ToList();
  864. }
  865. else
  866. {
  867. list = list.Where(a => a.NewType == "0").ToList();
  868. }
  869. List<object> res = new List<object>();
  870. foreach (var item in list)
  871. {
  872. res.Add(new
  873. {
  874. articleID = item.ID,
  875. title = item.Title,
  876. date = item.F_CreateDate,
  877. content = item.Content
  878. }); ;
  879. }
  880. return Success(res);
  881. }
  882. private Response GetCompanyNewsDetail(dynamic _)
  883. {
  884. var id = this.GetReqData();
  885. var entity = companyNewsIBLL.GetCompanyNewsEntity(id);
  886. var res = new
  887. {
  888. title = entity.Title,
  889. date = entity.F_CreateDate,
  890. content = entity.Content
  891. };
  892. return Success(res);
  893. }
  894. private Response GetCompanyInfo(dynamic _)
  895. {
  896. var companyID = this.GetReqData();
  897. var res = companyIBLL.GetEntity(companyID);
  898. return Success(res);
  899. }
  900. /// <summary>
  901. /// 修改密码
  902. /// </summary>
  903. /// <param name="_"></param>
  904. /// <returns></returns>
  905. private Response ModifyPassword(dynamic _)
  906. {
  907. ModifyModel modifyModel = this.GetReqData<ModifyModel>();
  908. if (userInfo.isSystem)
  909. {
  910. return Fail("当前账户不能修改密码");
  911. }
  912. else
  913. {
  914. bool res = userIBLL.RevisePassword(modifyModel.newpassword, modifyModel.oldpassword);
  915. if (!res)
  916. {
  917. return Fail("原密码错误,请重新输入");
  918. }
  919. else
  920. {
  921. return Success("密码修改成功");
  922. }
  923. }
  924. }
  925. private Response ForgetPwd(dynamic _)
  926. {
  927. forgetPwdParamModel param = this.GetReqData<forgetPwdParamModel>();
  928. var entity = aP_OnlineUserInfoIBLL.GetEntityByMobile(param.mobile);
  929. if (entity != null)
  930. {
  931. if (entity.CertNum == param.ids)
  932. {
  933. return Success(entity.Password);
  934. }
  935. else
  936. {
  937. return Fail("输入的手机号或者身份证不正确");
  938. }
  939. }
  940. else
  941. {
  942. return Fail("输入的手机号或者身份证不正确");
  943. }
  944. }
  945. private Response GetEditonInfo(dynamic _)
  946. {
  947. var type = this.GetReqData();
  948. var entity = editonManagementIbll.GetEditonManagementEntityByEType(type);
  949. var apkurl = "";
  950. if (entity.Url != null)
  951. {
  952. apkurl = annexesFileIBLL.GetEntityByFolderId(entity.Url).F_FilePath;
  953. apkurl = "/" + apkurl.Substring(apkurl.IndexOf("Resource"));
  954. }
  955. entity.Url = apkurl;
  956. return Success(entity);
  957. }
  958. /// <summary>
  959. /// 解绑微信
  960. /// </summary>
  961. /// <param name="_"></param>
  962. /// <returns></returns>
  963. private Response DoUnbundWeiXin(dynamic _)
  964. {
  965. userIBLL.DoUnbundWeiXin(userInfo.userId);
  966. return Success("解绑成功");
  967. }
  968. /// <summary>
  969. /// 获取所有员工账号列表
  970. /// </summary>
  971. /// <param name="_"></param>
  972. /// <returns></returns>
  973. private Response GetList(dynamic _)
  974. {
  975. var data = userInfo;
  976. data.password = null;
  977. data.secretkey = null;
  978. var jsonData = new
  979. {
  980. baseinfo = data,
  981. post = postIBLL.GetListByPostIds(data.postIds),
  982. role = roleIBLL.GetListByRoleIds(data.roleIds)
  983. };
  984. return Success(jsonData);
  985. }
  986. /// <summary>
  987. /// 获取用户映射表
  988. /// </summary>
  989. /// <param name="_"></param>
  990. /// <returns></returns>
  991. public Response GetMap(dynamic _)
  992. {
  993. string ver = this.GetReqData();// 获取模板请求数据
  994. var data = userIBLL.GetModelMap();
  995. string md5 = Md5Helper.Encrypt(data.ToJson(), 32);
  996. if (md5 == ver)
  997. {
  998. return Success("no update");
  999. }
  1000. else
  1001. {
  1002. var jsondata = new
  1003. {
  1004. data = data,
  1005. ver = md5
  1006. };
  1007. return Success(jsondata);
  1008. }
  1009. }
  1010. public Response GetSaveClassMap(dynamic _)
  1011. {
  1012. string account = this.GetReqData<UserAccount>().account;
  1013. var data = userIBLL.GetSaveClassMap();
  1014. var students = stuInfoBasicIBLL.GetSaveClassStudents(account);
  1015. data = data.Where(a => students.Contains(a.F_Account) && a.F_Account != account).ToList();
  1016. var dic = new Dictionary<string, UserModel>();
  1017. foreach (var item in data)
  1018. {
  1019. UserModel model = new UserModel()
  1020. {
  1021. companyId = item.F_CompanyId,
  1022. departmentId = item.F_DepartmentId,
  1023. name = item.F_RealName,
  1024. id = item.F_UserId,
  1025. };
  1026. string img = "";
  1027. if (!string.IsNullOrEmpty(item.F_HeadIcon))
  1028. {
  1029. string fileHeadImg = Config.GetValue("fileHeadImg");
  1030. string fileImg = string.Format("{0}/{1}{2}", fileHeadImg, item.F_UserId, item.F_HeadIcon);
  1031. if (DirFileHelper.IsExistFile(fileImg))
  1032. {
  1033. img = item.F_HeadIcon;
  1034. }
  1035. }
  1036. if (string.IsNullOrEmpty(img))
  1037. {
  1038. if (item.F_Gender == 0)
  1039. {
  1040. img = "0";
  1041. }
  1042. else
  1043. {
  1044. img = "1";
  1045. }
  1046. }
  1047. model.img = img;
  1048. dic.Add(item.F_UserId, model);
  1049. }
  1050. string md5 = Md5Helper.Encrypt(dic.ToJson(), 32);
  1051. var jsondata = new
  1052. {
  1053. data = dic,
  1054. var = md5
  1055. };
  1056. return Success(jsondata);
  1057. }
  1058. /// <summary>
  1059. /// 获取人员头像图标
  1060. /// </summary>
  1061. /// <param name="_"></param>
  1062. /// <returns></returns>
  1063. public Response GetImg(dynamic _)
  1064. {
  1065. string userId = this.GetReqData();// 获取模板请求数据
  1066. userIBLL.GetImg(userId);
  1067. return Success("获取成功");
  1068. }
  1069. /// <summary>
  1070. /// 获取IP
  1071. /// </summary>
  1072. /// <returns></returns>
  1073. private string GetIP()
  1074. {
  1075. //string ip = string.Empty;
  1076. //if (!string.IsNullOrEmpty(System.Web.HttpContext.Current.Request.ServerVariables["HTTP_VIA"]))
  1077. // ip = Convert.ToString(System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]);
  1078. //if (string.IsNullOrEmpty(ip))
  1079. // ip = Convert.ToString(System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]);
  1080. //return ip;
  1081. string userIP = "未获取用户IP";
  1082. try
  1083. {
  1084. if (System.Web.HttpContext.Current == null
  1085. || System.Web.HttpContext.Current.Request == null
  1086. || System.Web.HttpContext.Current.Request.ServerVariables == null)
  1087. {
  1088. return "";
  1089. }
  1090. string CustomerIP = "";
  1091. //CDN加速后取到的IP simone 090805
  1092. CustomerIP = System.Web.HttpContext.Current.Request.Headers["Cdn-Src-Ip"];
  1093. if (!string.IsNullOrEmpty(CustomerIP))
  1094. {
  1095. return CustomerIP;
  1096. }
  1097. CustomerIP = System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
  1098. if (!string.IsNullOrEmpty(CustomerIP))
  1099. {
  1100. return CustomerIP;
  1101. }
  1102. if (System.Web.HttpContext.Current.Request.ServerVariables["HTTP_VIA"] != null)
  1103. {
  1104. CustomerIP = System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
  1105. if (CustomerIP == null)
  1106. {
  1107. CustomerIP = System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
  1108. }
  1109. }
  1110. else
  1111. {
  1112. CustomerIP = System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
  1113. }
  1114. if (string.Compare(CustomerIP, "unknown", true) == 0 || string.IsNullOrEmpty(CustomerIP))
  1115. {
  1116. return System.Web.HttpContext.Current.Request.UserHostAddress;
  1117. }
  1118. return CustomerIP;
  1119. }
  1120. catch { }
  1121. return userIP;
  1122. }
  1123. }
  1124. /// <summary>
  1125. /// 登录信息
  1126. /// </summary>
  1127. public class TLoginModel
  1128. {
  1129. /// <summary>
  1130. /// 账号
  1131. /// </summary>
  1132. public string username { get; set; }
  1133. /// <summary>
  1134. /// 密码
  1135. /// </summary>
  1136. public string password { get; set; }
  1137. /// <summary>
  1138. /// 设备号
  1139. /// </summary>
  1140. public string deviceid { get; set; }
  1141. public string openid { get; set; }
  1142. }
  1143. public class StuModel
  1144. {
  1145. public string id { get; set; }
  1146. public string username { get; set; }
  1147. public string sex { get; set; }
  1148. public string phone { get; set; }
  1149. public string address { get; set; }
  1150. public string culture { get; set; }
  1151. public string school { get; set; }
  1152. public string depart { get; set; }
  1153. public string paymentQuota { get; set; }
  1154. public string rTeacher { get; set; }
  1155. public string ids { get; set; }
  1156. public string renarks { get; set; }
  1157. public string province { get; set; }
  1158. public string city { get; set; }
  1159. public string county { get; set; }
  1160. public string birthday { get; set; }
  1161. }
  1162. public class stuQueryParam
  1163. {
  1164. public string empid { get; set; }
  1165. public string num { get; set; }
  1166. }
  1167. public class teaInfo
  1168. {
  1169. public string id { get; set; }
  1170. public string photo { get; set; }
  1171. public string realName { get; set; }
  1172. public string sexID { get; set; }
  1173. public string remark { get; set; }
  1174. public string birthDate { get; set; }
  1175. }
  1176. public class pwdModel
  1177. {
  1178. public string userid { get; set; }
  1179. public string oldpwd { get; set; }
  1180. public string newpwd { get; set; }
  1181. }
  1182. public class stuInfo
  1183. {
  1184. public string id { get; set; }
  1185. public string sex { get; set; }
  1186. public string birthday { get; set; }
  1187. public string idcard { get; set; }
  1188. }
  1189. public class newsParamModel
  1190. {
  1191. public string companyid { get; set; }
  1192. public string type { get; set; }
  1193. }
  1194. public class forgetPwdParamModel
  1195. {
  1196. public string mobile { get; set; }
  1197. public string ids { get; set; }
  1198. }
  1199. public class RegisterModel
  1200. {
  1201. public string name { get; set; }
  1202. public string logpwd { get; set; }
  1203. public string ids { get; set; }
  1204. public string mobile { get; set; }
  1205. }
  1206. }