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.
 
 
 
 
 
 

1356 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. photo = "/" + photo.Substring(photo.IndexOf("Resource"));
  263. }
  264. result.Add(new
  265. {
  266. schoolID = company.F_CompanyId,
  267. school = company.F_FullName,
  268. address = company.F_Address,
  269. schoolPic = photo
  270. });
  271. }
  272. return Success(result);
  273. }
  274. private Response GetMajorByCompany(dynamic _)
  275. {
  276. var companyId = this.GetReqData();
  277. var result = new List<object>();
  278. if (!string.IsNullOrEmpty(companyId))
  279. {
  280. var majorList = majorIbll.GetAllList().Where(a => a.F_SchoolId == companyId);
  281. if (majorList.Count() > 0)
  282. {
  283. foreach (var major in majorList)
  284. {
  285. result.Add(new
  286. {
  287. departID = major.MajorNo,
  288. depart = major.MajorName,
  289. type = major.RecruitObject
  290. });
  291. }
  292. return Success(result);
  293. }
  294. else
  295. {
  296. return Fail("无专业");
  297. }
  298. }
  299. else
  300. {
  301. return Fail("未知错误");
  302. }
  303. }
  304. private Response GetMajorDetail(dynamic _)
  305. {
  306. var majorNo = this.GetReqData();
  307. var entity = majorIbll.GetCdMajorEntityByMajorNo(majorNo);
  308. var itemList = dataItemIBLL.GetDetailList("RecruitObject").ToList();
  309. var school = companyIBLL.GetEntity(entity.F_SchoolId);
  310. var photo = "";
  311. if (!string.IsNullOrEmpty(entity.Photo))
  312. {
  313. photo = annexesFileIBLL.GetEntityByFolderId(entity.Photo)?.F_FilePath;
  314. if (!string.IsNullOrEmpty(photo))
  315. {
  316. photo = "/" + photo.Substring(photo.IndexOf("Resource"));
  317. }
  318. }
  319. var result = new
  320. {
  321. pimage = photo,
  322. name = entity.MajorName,
  323. schoolName = school?.F_FullName,
  324. pObjectName = itemList.FirstOrDefault(a => a.F_ItemValue == entity.RecruitObject).F_ItemName, //招生对象
  325. developLevel = entity.DevelopLevel, //培养对象
  326. pCertificate = entity.Certificate,
  327. developTarget = entity.DevelopTarget,
  328. introduce = entity.Introduce,
  329. };
  330. return Success(result);
  331. }
  332. private Response StuRegister(dynamic _)
  333. {
  334. var stuModel = this.GetReqData<StuModel>();
  335. AP_OnlineStudentInfoEntity infoEntity = new AP_OnlineStudentInfoEntity();
  336. AP_OnlineUserInfoEntity userEntity = new AP_OnlineUserInfoEntity();
  337. userEntity.RealName = stuModel.username;
  338. userEntity.SexId = stuModel.sex;
  339. userEntity.Mobile = stuModel.phone;
  340. userEntity.Password = "123456";
  341. userEntity.DetailedAddress = stuModel.address;
  342. userEntity.CertNum = stuModel.ids;
  343. userEntity.Province = stuModel.province;
  344. userEntity.City = stuModel.city;
  345. userEntity.Country = stuModel.county;
  346. aP_OnlineUserInfoIBLL.SaveEntity("", userEntity);
  347. infoEntity.UserId = userEntity.Id;
  348. infoEntity.CultureId = stuModel.culture;
  349. infoEntity.SchoolId = stuModel.school;
  350. infoEntity.MajorId = stuModel.depart;
  351. infoEntity.PaymentQuota = Convert.ToDecimal(stuModel.paymentQuota);
  352. infoEntity.UserTeacherId = stuModel.rTeacher;
  353. infoEntity.Remarks = stuModel.renarks;
  354. aP_OnlineStudentInfoIBLL.SaveEntity("", infoEntity);
  355. return Success("修改成功");
  356. }
  357. private Response GetCultureInfo(dynamic _)
  358. {
  359. var list = bCdCultureDegreeIBLL.GetAllList().ToList();
  360. List<object> result = new List<object>();
  361. foreach (var item in list)
  362. {
  363. result.Add(new
  364. {
  365. dicentryid = item.CultureDegreeNo,
  366. name = item.CultureDegree
  367. });
  368. }
  369. return Success(result);
  370. }
  371. private Response DelStu(dynamic _)
  372. {
  373. var id = this.GetReqData();
  374. var stuEntity = aP_OnlineStudentInfoIBLL.GetEntity(id);
  375. if (stuEntity != null)
  376. {
  377. aP_OnlineStudentInfoIBLL.DeleteEntity(id);
  378. aP_OnlineUserInfoIBLL.DeleteEntity(stuEntity.UserId);
  379. return Success("删除成功");
  380. }
  381. else
  382. {
  383. return Fail("删除失败");
  384. }
  385. }
  386. private Response UpdateStuByStuTerminal(dynamic _)
  387. {
  388. var stuModel = this.GetReqData<StuModel>();
  389. AP_OnlineUserInfoEntity userEntity = aP_OnlineUserInfoIBLL.GetEntity(stuModel.id);
  390. if (userEntity == null)
  391. {
  392. return Fail("未找到学生信息");
  393. }
  394. if (!string.IsNullOrEmpty(stuModel.username))
  395. {
  396. userEntity.RealName = stuModel.username;
  397. }
  398. if (!string.IsNullOrEmpty(stuModel.birthday))
  399. {
  400. userEntity.BirthDate = Convert.ToDateTime(stuModel.birthday);
  401. }
  402. if (!string.IsNullOrEmpty(stuModel.sex))
  403. {
  404. userEntity.SexId = stuModel.sex;
  405. }
  406. if (!string.IsNullOrEmpty(stuModel.phone))
  407. {
  408. userEntity.Mobile = stuModel.phone;
  409. }
  410. if (!string.IsNullOrEmpty(stuModel.address))
  411. {
  412. userEntity.DetailedAddress = stuModel.address;
  413. }
  414. if (!string.IsNullOrEmpty(stuModel.ids))
  415. {
  416. userEntity.CertNum = stuModel.ids;
  417. }
  418. if (!string.IsNullOrEmpty(stuModel.province))
  419. {
  420. userEntity.Province = stuModel.province;
  421. }
  422. if (!string.IsNullOrEmpty(stuModel.city))
  423. {
  424. userEntity.City = stuModel.city;
  425. }
  426. if (!string.IsNullOrEmpty(stuModel.county))
  427. {
  428. userEntity.Country = stuModel.county;
  429. }
  430. aP_OnlineUserInfoIBLL.SaveEntity(stuModel.id, userEntity);
  431. AP_OnlineStudentInfoEntity infoEntity = aP_OnlineStudentInfoIBLL.GetEntityByUserId(userEntity.Id);
  432. if (infoEntity == null)
  433. {
  434. return Fail("找不到用户数据");
  435. }
  436. if (!string.IsNullOrEmpty(stuModel.culture))
  437. {
  438. infoEntity.CultureId = stuModel.culture;
  439. }
  440. if (!string.IsNullOrEmpty(stuModel.school))
  441. {
  442. infoEntity.SchoolId = stuModel.school;
  443. }
  444. if (!string.IsNullOrEmpty(stuModel.depart))
  445. {
  446. infoEntity.MajorId = stuModel.depart;
  447. }
  448. if (!string.IsNullOrEmpty(stuModel.paymentQuota))
  449. {
  450. infoEntity.PaymentQuota = Convert.ToDecimal(stuModel.paymentQuota);
  451. }
  452. if (!string.IsNullOrEmpty(stuModel.rTeacher))
  453. {
  454. infoEntity.UserTeacherId = stuModel.rTeacher;
  455. }
  456. if (!string.IsNullOrEmpty(stuModel.renarks))
  457. {
  458. infoEntity.Remarks = stuModel.renarks;
  459. }
  460. aP_OnlineStudentInfoIBLL.SaveEntity(infoEntity.Id, infoEntity);
  461. return Success("修改成功");
  462. }
  463. private Response UpdateStuInfoById(dynamic _)
  464. {
  465. var stuModel = this.GetReqData<StuModel>();
  466. AP_OnlineStudentInfoEntity infoEntity = aP_OnlineStudentInfoIBLL.GetEntity(stuModel.id);
  467. if (infoEntity == null)
  468. {
  469. return Fail("找不到用户数据");
  470. }
  471. if (!string.IsNullOrEmpty(stuModel.culture))
  472. {
  473. infoEntity.CultureId = stuModel.culture;
  474. }
  475. if (!string.IsNullOrEmpty(stuModel.school))
  476. {
  477. infoEntity.SchoolId = stuModel.school;
  478. }
  479. if (!string.IsNullOrEmpty(stuModel.depart))
  480. {
  481. infoEntity.MajorId = stuModel.depart;
  482. }
  483. if (!string.IsNullOrEmpty(stuModel.paymentQuota))
  484. {
  485. infoEntity.PaymentQuota = Convert.ToDecimal(stuModel.paymentQuota);
  486. }
  487. if (!string.IsNullOrEmpty(stuModel.rTeacher))
  488. {
  489. infoEntity.UserTeacherId = stuModel.rTeacher;
  490. }
  491. if (!string.IsNullOrEmpty(stuModel.renarks))
  492. {
  493. infoEntity.Remarks = stuModel.renarks;
  494. }
  495. aP_OnlineStudentInfoIBLL.SaveEntity(stuModel.id, infoEntity);
  496. AP_OnlineUserInfoEntity userEntity = aP_OnlineUserInfoIBLL.GetEntity(infoEntity.UserId);
  497. if (!string.IsNullOrEmpty(stuModel.username))
  498. {
  499. userEntity.RealName = stuModel.username;
  500. }
  501. if (!string.IsNullOrEmpty(stuModel.sex))
  502. {
  503. userEntity.SexId = stuModel.sex;
  504. }
  505. if (!string.IsNullOrEmpty(stuModel.phone))
  506. {
  507. userEntity.Mobile = stuModel.phone;
  508. }
  509. if (!string.IsNullOrEmpty(stuModel.address))
  510. {
  511. userEntity.DetailedAddress = stuModel.address;
  512. }
  513. if (!string.IsNullOrEmpty(stuModel.ids))
  514. {
  515. userEntity.CertNum = stuModel.ids;
  516. }
  517. if (!string.IsNullOrEmpty(stuModel.province))
  518. {
  519. userEntity.Province = stuModel.province;
  520. }
  521. if (!string.IsNullOrEmpty(stuModel.city))
  522. {
  523. userEntity.City = stuModel.city;
  524. }
  525. if (!string.IsNullOrEmpty(stuModel.county))
  526. {
  527. userEntity.Country = stuModel.county;
  528. }
  529. aP_OnlineUserInfoIBLL.SaveEntity(infoEntity.UserId, userEntity);
  530. return Success("修改成功");
  531. }
  532. private Response GetStuInfo(dynamic _)
  533. {
  534. var queryParam = this.GetReqData<stuQueryParam>();
  535. var stuInfolist = aP_OnlineStudentInfoIBLL.GetList("").Where(a => a.UserTeacherId == queryParam.empid).ToList();
  536. var userInfo = aP_OnlineUserInfoIBLL.GetList("");
  537. List<AP_OnlineStudentInfoEntity> reList = new List<AP_OnlineStudentInfoEntity>();
  538. switch (queryParam.num)
  539. {
  540. case "1":
  541. reList = stuInfolist;
  542. break;
  543. case "2":
  544. reList = stuInfolist.Where(a => a.IsPaymentId == "1")
  545. .Where(a => a.IsDropOut == null || a.IsDropOut == "0").ToList();
  546. break;
  547. case "3":
  548. reList = stuInfolist.Where(a => a.IsDropOut == "1").ToList();
  549. break;
  550. case "4":
  551. reList = stuInfolist.Where(a => a.PaymentQuota == 0 || a.PaymentQuota == null).ToList();
  552. break;
  553. default:
  554. reList = stuInfolist;
  555. break;
  556. }
  557. List<object> result = new List<object>();
  558. foreach (var item in reList)
  559. {
  560. var companyEntity = companyIBLL.GetEntity(item.SchoolId);
  561. var majorEntity = majorIbll.GetCdMajorEntityByMajorNo(item.MajorId);
  562. var entity = userInfo.FirstOrDefault(a => a.Id == item.UserId);
  563. var photo = entity.PhotoUrl;
  564. result.Add(new
  565. {
  566. userPhoto = photo,
  567. strdentName = entity.RealName,
  568. strMobile = entity.Mobile,
  569. moneyQuota = item.PaymentQuota == null ? 0 : item.PaymentQuota,
  570. schoolName = companyEntity?.F_FullName,
  571. professionName = majorEntity?.MajorName,
  572. professionMoney = "",
  573. ID = item.Id,
  574. UserID = item.UserId
  575. });
  576. }
  577. return Success(result);
  578. }
  579. private Response GetStuById(dynamic _)
  580. {
  581. var userId = this.GetReqData();
  582. var stuentity = aP_OnlineStudentInfoIBLL.GetEntity(userId);
  583. var userentity = aP_OnlineUserInfoIBLL.GetEntity(stuentity.UserId);
  584. var result = new
  585. {
  586. username = userentity.RealName,
  587. sexid = userentity.SexId,
  588. sex = userentity.SexId == "1" ? "男" : "女",
  589. phone = userentity.Mobile,
  590. address = userentity.DetailedAddress,
  591. ids = userentity.CertNum,
  592. cultureid = stuentity.CultureId,
  593. culture = bCdCultureDegreeIBLL.GetEntity(stuentity.CultureId)?.CultureDegree,
  594. schoolid = stuentity.SchoolId,
  595. school = companyIBLL.GetEntity(stuentity.SchoolId)?.F_FullName,
  596. departid = stuentity.MajorId,
  597. depart = majorIbll.GetCdMajorEntityByMajorNo(stuentity.MajorId)?.MajorName,
  598. paymentQuota = stuentity.PaymentQuota,
  599. renarks = stuentity.Remarks,
  600. province = userentity.Province,
  601. city = userentity.City,
  602. county = userentity.Country
  603. };
  604. return Success(result);
  605. }
  606. private Response GetStuInfoByUserId(dynamic _)
  607. {
  608. var userId = this.GetReqData();
  609. var userentity = aP_OnlineUserInfoIBLL.GetEntity(userId);
  610. var stuentity = aP_OnlineStudentInfoIBLL.GetEntityByUserId(userentity.Id);
  611. var company = companyIBLL.GetEntity(stuentity.SchoolId);
  612. var major = majorIbll.GetCdMajorEntityByMajorNo(stuentity.MajorId);
  613. var teacher = userIBLL.GetEntityByUserId(stuentity.UserTeacherId);
  614. var cultrue = bCdCultureDegreeIBLL.GetEntity(stuentity.CultureId);
  615. var photourl = annexesFileIBLL.GetEntityByFolderId(userentity.PhotoUrl)?.F_FilePath;
  616. if (photourl != null && photourl.IndexOf("Resource") > 0)
  617. {
  618. photourl = "/" + photourl.Substring(photourl.IndexOf("Resource"));
  619. }
  620. var result = new
  621. {
  622. ID = userentity.Id,
  623. username = userentity.RealName,
  624. sex = userentity.SexId,
  625. sexname = userentity.SexId == "1" ? "男" : "女",
  626. photo = photourl,
  627. phone = userentity.Mobile,
  628. status = 1,
  629. birth = userentity.BirthDate,
  630. depart = stuentity.MajorId,
  631. departname = major?.MajorName,
  632. school = stuentity.SchoolId,
  633. schoolname = company?.F_FullName,
  634. culture = stuentity.CultureId,
  635. culturename = cultrue?.CultureDegree,
  636. pTotalMoney = "",
  637. teaID = stuentity.UserTeacherId,
  638. teaName = teacher?.F_RealName,
  639. teaPhone = teacher?.F_Mobile,
  640. ids = userentity.CertNum,
  641. gexin = ""
  642. };
  643. return Success(result);
  644. }
  645. private Response Upload(dynamic _)
  646. {
  647. var userid = this.GetReqData();
  648. HttpFileCollection files = System.Web.HttpContext.Current.Request.Files;
  649. //没有文件上传,直接返回
  650. if (files[0].ContentLength == 0 || string.IsNullOrEmpty(files[0].FileName))
  651. {
  652. return Fail("");
  653. }
  654. string FileEextension = Path.GetExtension(files[0].FileName);
  655. string filePath = Config.GetValue("AnnexesFile");
  656. string uploadDate = DateTime.Now.ToString("yyyyMMdd");
  657. string fileGuid = Guid.NewGuid().ToString();
  658. string fileHeadImg = Config.GetValue("AnnexesFile");
  659. //string fullFileName = string.Format("{0}/{1}{2}", fileHeadImg, userInfo.userId, FileEextension);
  660. string fullFileName = $"{fileHeadImg}/{userid}/{uploadDate}/{fileGuid}{FileEextension}";
  661. var saveFileName = "/Resource/" + fullFileName.Substring(fullFileName.IndexOf(userid), fullFileName.Length - fullFileName.IndexOf(userid));
  662. //创建文件夹,保存文件
  663. string path = Path.GetDirectoryName(fullFileName);
  664. Directory.CreateDirectory(path);
  665. files[0].SaveAs(fullFileName);
  666. UserEntity userEntity = new UserEntity();
  667. userEntity.F_UserId = userid;
  668. userEntity.F_HeadIcon = saveFileName;
  669. userIBLL.SaveEntity(userEntity.F_UserId, userEntity);
  670. return Success(saveFileName);
  671. }
  672. private Response UploadStudent(dynamic _)
  673. {
  674. var userid = this.GetReqData();
  675. HttpFileCollection files = System.Web.HttpContext.Current.Request.Files;
  676. //没有文件上传,直接返回
  677. if (files[0].ContentLength == 0 || string.IsNullOrEmpty(files[0].FileName))
  678. {
  679. return Fail("");
  680. }
  681. string FileEextension = Path.GetExtension(files[0].FileName);
  682. string filePath = Config.GetValue("AnnexesFile");
  683. string uploadDate = DateTime.Now.ToString("yyyyMMdd");
  684. string fileGuid = Guid.NewGuid().ToString();
  685. string fileHeadImg = Config.GetValue("AnnexesFile");
  686. //string fullFileName = string.Format("{0}/{1}{2}", fileHeadImg, userInfo.userId, FileEextension);
  687. string fullFileName = $"{fileHeadImg}/{userid}/{uploadDate}/{fileGuid}{FileEextension}";
  688. var saveFileName = "/Resource/" + fullFileName.Substring(fullFileName.IndexOf(userid), fullFileName.Length - fullFileName.IndexOf(userid));
  689. //创建文件夹,保存文件
  690. string path = Path.GetDirectoryName(fullFileName);
  691. Directory.CreateDirectory(path);
  692. files[0].SaveAs(fullFileName);
  693. var stuInfoEntity = aP_OnlineUserInfoIBLL.GetEntity(userid);
  694. if (stuInfoEntity != null)
  695. {
  696. if (!string.IsNullOrEmpty(stuInfoEntity.PhotoUrl))
  697. {
  698. var annexEntity = annexesFileIBLL.GetEntityByFolderId(stuInfoEntity.PhotoUrl);
  699. annexEntity.F_FilePath = fullFileName;
  700. annexEntity.F_Id = Guid.NewGuid().ToString();
  701. annexesFileIBLL.SaveEntity(stuInfoEntity.PhotoUrl, annexEntity);
  702. }
  703. else
  704. {
  705. stuInfoEntity.PhotoUrl = Guid.NewGuid().ToString();
  706. aP_OnlineUserInfoIBLL.SaveEntity(stuInfoEntity.Id, stuInfoEntity);
  707. var annexEntity = new AnnexesFileEntity();
  708. annexEntity.F_FilePath = fullFileName;
  709. annexEntity.F_FolderId = stuInfoEntity.PhotoUrl;
  710. annexEntity.F_Id = Guid.NewGuid().ToString();
  711. annexesFileIBLL.SaveEntity(stuInfoEntity.PhotoUrl, annexEntity);
  712. }
  713. }
  714. return Success(saveFileName);
  715. }
  716. private Response UpdataTeacherInfo(dynamic _)
  717. {
  718. var strEntity = this.GetReqData<teaInfo>();
  719. var teaEntity = userIBLL.GetEntityByUserId(strEntity.id);
  720. if (teaEntity != null)
  721. {
  722. teaEntity.F_RealName = strEntity.realName;
  723. teaEntity.F_Gender = Convert.ToInt32(strEntity.sexID);
  724. teaEntity.F_Birthday = strEntity.birthDate.ToDate();
  725. teaEntity.PerSignature = strEntity.remark;
  726. teaEntity.F_Mobile = strEntity.photo;
  727. userIBLL.SaveEntity(teaEntity.F_UserId, teaEntity);
  728. }
  729. return Success("修改成功");
  730. }
  731. private Response UpdatePassword(dynamic _)
  732. {
  733. var strEntity = this.GetReqData<pwdModel>();
  734. strEntity.oldpwd = Md5Helper.Encrypt(strEntity.oldpwd, 32);
  735. strEntity.newpwd = Md5Helper.Encrypt(strEntity.newpwd, 32);
  736. var entity = userIBLL.GetEntityByUserId(strEntity.userid);
  737. if (entity != null)
  738. {
  739. string oldPasswordByEncrypt = Md5Helper.Encrypt(DESEncrypt.Encrypt(strEntity.oldpwd, entity.F_Secretkey).ToLower(), 32).ToLower();
  740. if (oldPasswordByEncrypt == entity.F_Password)
  741. {
  742. userIBLL.setPassword(entity.F_UserId, strEntity.newpwd);
  743. }
  744. else
  745. {
  746. return Fail("旧密码不正确");
  747. }
  748. return Success("修改成功");
  749. }
  750. else
  751. {
  752. return Fail("修改失败");
  753. }
  754. }
  755. private Response UpdatePasswordStu(dynamic _)
  756. {
  757. var strEntity = this.GetReqData<pwdModel>();
  758. var entity = aP_OnlineUserInfoIBLL.GetEntity(strEntity.userid);
  759. if (entity != null)
  760. {
  761. if (strEntity.oldpwd == entity.Password)
  762. {
  763. entity.Password = strEntity.newpwd;
  764. aP_OnlineUserInfoIBLL.SaveEntity(entity.Id, entity);
  765. }
  766. else
  767. {
  768. return Fail("旧密码不正确");
  769. }
  770. return Success("修改成功");
  771. }
  772. else
  773. {
  774. return Fail("修改失败");
  775. }
  776. }
  777. private Response BankInfo(dynamic _)
  778. {
  779. var userId = this.GetReqData();
  780. var list = aP_TeacherBankCardIBLL.GetListByID(userId).ToList();
  781. List<object> result = new List<object>();
  782. foreach (var item in list)
  783. {
  784. result.Add(new
  785. {
  786. bankName = item.Bank,
  787. bankNumber = item.BankCardNo
  788. });
  789. }
  790. return Success(result);
  791. }
  792. private Response IntegralDetails(dynamic _)
  793. {
  794. var userId = this.GetReqData();
  795. var list = aP_IntegralDetailsIBLL.GetListByID(userId).ToList();
  796. List<object> result = new List<object>();
  797. foreach (var item in list)
  798. {
  799. result.Add(new
  800. {
  801. year = item.CreateTime.ToDate().Year,
  802. bankNumber = item.BankCardNo,
  803. scoresNum = item.IntegralNum,
  804. createDate = item.CreateTime,
  805. scorename = item.IntegralName
  806. });
  807. }
  808. return Success(result);
  809. }
  810. private Response DetailInfo(dynamic _)
  811. {
  812. var userId = this.GetReqData();
  813. var list = aP_IntegralDetailsIBLL.GetListByID(userId).ToList();
  814. var result = new
  815. {
  816. getcount = list.Count(a => a.IsReceived == "1"),
  817. allcount = list.Count()
  818. };
  819. return Success(result);
  820. }
  821. private Response AboutSchool(dynamic _)
  822. {
  823. var list = newsIBLL.GetAboutSchool().FirstOrDefault();
  824. return Success(new { content = list.F_NewsContent });
  825. }
  826. private Response GetNews(dynamic _)
  827. {
  828. var list = newsIBLL.GetNews();
  829. List<object> result = new List<object>();
  830. foreach (var item in list)
  831. {
  832. result.Add(new
  833. {
  834. articleID = item.F_NewsId,
  835. title = item.F_FullHead,
  836. common = item.F_NewsContent,
  837. date = item.F_CreateDate
  838. });
  839. }
  840. return Success(result);
  841. }
  842. private Response GetNewsDetail(dynamic _)
  843. {
  844. var id = this.GetReqData();
  845. var list = newsIBLL.GetEntity(id);
  846. var result = new
  847. {
  848. title = list.F_FullHead,
  849. date = list.F_CreateDate,
  850. content = list.F_NewsContent
  851. };
  852. return Success(result);
  853. }
  854. private Response GetCompanyNews(dynamic _)
  855. {
  856. var param = this.GetReqData<newsParamModel>();
  857. var list = companyNewsIBLL.GetListByCompanyID(param.companyid).ToList();
  858. if (param.type == "1")
  859. {
  860. list = list.Where(a => a.NewType == "1").ToList();
  861. }
  862. else
  863. {
  864. list = list.Where(a => a.NewType == "0").ToList();
  865. }
  866. List<object> res = new List<object>();
  867. foreach (var item in list)
  868. {
  869. res.Add(new
  870. {
  871. articleID = item.ID,
  872. title = item.Title,
  873. date = item.F_CreateDate,
  874. content = item.Content
  875. }); ;
  876. }
  877. return Success(res);
  878. }
  879. private Response GetCompanyNewsDetail(dynamic _)
  880. {
  881. var id = this.GetReqData();
  882. var entity = companyNewsIBLL.GetCompanyNewsEntity(id);
  883. var res = new
  884. {
  885. title = entity.Title,
  886. date = entity.F_CreateDate,
  887. content = entity.Content
  888. };
  889. return Success(res);
  890. }
  891. private Response GetCompanyInfo(dynamic _)
  892. {
  893. var companyID = this.GetReqData();
  894. var res = companyIBLL.GetEntity(companyID);
  895. return Success(res);
  896. }
  897. /// <summary>
  898. /// 修改密码
  899. /// </summary>
  900. /// <param name="_"></param>
  901. /// <returns></returns>
  902. private Response ModifyPassword(dynamic _)
  903. {
  904. ModifyModel modifyModel = this.GetReqData<ModifyModel>();
  905. if (userInfo.isSystem)
  906. {
  907. return Fail("当前账户不能修改密码");
  908. }
  909. else
  910. {
  911. bool res = userIBLL.RevisePassword(modifyModel.newpassword, modifyModel.oldpassword);
  912. if (!res)
  913. {
  914. return Fail("原密码错误,请重新输入");
  915. }
  916. else
  917. {
  918. return Success("密码修改成功");
  919. }
  920. }
  921. }
  922. private Response ForgetPwd(dynamic _)
  923. {
  924. forgetPwdParamModel param = this.GetReqData<forgetPwdParamModel>();
  925. var entity = aP_OnlineUserInfoIBLL.GetEntityByMobile(param.mobile);
  926. if (entity != null)
  927. {
  928. if (entity.CertNum == param.ids)
  929. {
  930. return Success(entity.Password);
  931. }
  932. else
  933. {
  934. return Fail("输入的手机号或者身份证不正确");
  935. }
  936. }
  937. else
  938. {
  939. return Fail("输入的手机号或者身份证不正确");
  940. }
  941. }
  942. private Response GetEditonInfo(dynamic _)
  943. {
  944. var type = this.GetReqData();
  945. var entity = editonManagementIbll.GetEditonManagementEntityByEType(type);
  946. var apkurl = "";
  947. if (entity.Url != null)
  948. {
  949. apkurl = annexesFileIBLL.GetEntityByFolderId(entity.Url).F_FilePath;
  950. apkurl = "/" + apkurl.Substring(apkurl.IndexOf("Resource"));
  951. }
  952. entity.Url = apkurl;
  953. return Success(entity);
  954. }
  955. /// <summary>
  956. /// 解绑微信
  957. /// </summary>
  958. /// <param name="_"></param>
  959. /// <returns></returns>
  960. private Response DoUnbundWeiXin(dynamic _)
  961. {
  962. userIBLL.DoUnbundWeiXin(userInfo.userId);
  963. return Success("解绑成功");
  964. }
  965. /// <summary>
  966. /// 获取所有员工账号列表
  967. /// </summary>
  968. /// <param name="_"></param>
  969. /// <returns></returns>
  970. private Response GetList(dynamic _)
  971. {
  972. var data = userInfo;
  973. data.password = null;
  974. data.secretkey = null;
  975. var jsonData = new
  976. {
  977. baseinfo = data,
  978. post = postIBLL.GetListByPostIds(data.postIds),
  979. role = roleIBLL.GetListByRoleIds(data.roleIds)
  980. };
  981. return Success(jsonData);
  982. }
  983. /// <summary>
  984. /// 获取用户映射表
  985. /// </summary>
  986. /// <param name="_"></param>
  987. /// <returns></returns>
  988. public Response GetMap(dynamic _)
  989. {
  990. string ver = this.GetReqData();// 获取模板请求数据
  991. var data = userIBLL.GetModelMap();
  992. string md5 = Md5Helper.Encrypt(data.ToJson(), 32);
  993. if (md5 == ver)
  994. {
  995. return Success("no update");
  996. }
  997. else
  998. {
  999. var jsondata = new
  1000. {
  1001. data = data,
  1002. ver = md5
  1003. };
  1004. return Success(jsondata);
  1005. }
  1006. }
  1007. public Response GetSaveClassMap(dynamic _)
  1008. {
  1009. string account = this.GetReqData<UserAccount>().account;
  1010. var data = userIBLL.GetSaveClassMap();
  1011. var students = stuInfoBasicIBLL.GetSaveClassStudents(account);
  1012. data = data.Where(a => students.Contains(a.F_Account) && a.F_Account != account).ToList();
  1013. var dic = new Dictionary<string, UserModel>();
  1014. foreach (var item in data)
  1015. {
  1016. UserModel model = new UserModel()
  1017. {
  1018. companyId = item.F_CompanyId,
  1019. departmentId = item.F_DepartmentId,
  1020. name = item.F_RealName,
  1021. id = item.F_UserId,
  1022. };
  1023. string img = "";
  1024. if (!string.IsNullOrEmpty(item.F_HeadIcon))
  1025. {
  1026. string fileHeadImg = Config.GetValue("fileHeadImg");
  1027. string fileImg = string.Format("{0}/{1}{2}", fileHeadImg, item.F_UserId, item.F_HeadIcon);
  1028. if (DirFileHelper.IsExistFile(fileImg))
  1029. {
  1030. img = item.F_HeadIcon;
  1031. }
  1032. }
  1033. if (string.IsNullOrEmpty(img))
  1034. {
  1035. if (item.F_Gender == 0)
  1036. {
  1037. img = "0";
  1038. }
  1039. else
  1040. {
  1041. img = "1";
  1042. }
  1043. }
  1044. model.img = img;
  1045. dic.Add(item.F_UserId, model);
  1046. }
  1047. string md5 = Md5Helper.Encrypt(dic.ToJson(), 32);
  1048. var jsondata = new
  1049. {
  1050. data = dic,
  1051. var = md5
  1052. };
  1053. return Success(jsondata);
  1054. }
  1055. /// <summary>
  1056. /// 获取人员头像图标
  1057. /// </summary>
  1058. /// <param name="_"></param>
  1059. /// <returns></returns>
  1060. public Response GetImg(dynamic _)
  1061. {
  1062. string userId = this.GetReqData();// 获取模板请求数据
  1063. userIBLL.GetImg(userId);
  1064. return Success("获取成功");
  1065. }
  1066. /// <summary>
  1067. /// 获取IP
  1068. /// </summary>
  1069. /// <returns></returns>
  1070. private string GetIP()
  1071. {
  1072. //string ip = string.Empty;
  1073. //if (!string.IsNullOrEmpty(System.Web.HttpContext.Current.Request.ServerVariables["HTTP_VIA"]))
  1074. // ip = Convert.ToString(System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]);
  1075. //if (string.IsNullOrEmpty(ip))
  1076. // ip = Convert.ToString(System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]);
  1077. //return ip;
  1078. string userIP = "未获取用户IP";
  1079. try
  1080. {
  1081. if (System.Web.HttpContext.Current == null
  1082. || System.Web.HttpContext.Current.Request == null
  1083. || System.Web.HttpContext.Current.Request.ServerVariables == null)
  1084. {
  1085. return "";
  1086. }
  1087. string CustomerIP = "";
  1088. //CDN加速后取到的IP simone 090805
  1089. CustomerIP = System.Web.HttpContext.Current.Request.Headers["Cdn-Src-Ip"];
  1090. if (!string.IsNullOrEmpty(CustomerIP))
  1091. {
  1092. return CustomerIP;
  1093. }
  1094. CustomerIP = System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
  1095. if (!string.IsNullOrEmpty(CustomerIP))
  1096. {
  1097. return CustomerIP;
  1098. }
  1099. if (System.Web.HttpContext.Current.Request.ServerVariables["HTTP_VIA"] != null)
  1100. {
  1101. CustomerIP = System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
  1102. if (CustomerIP == null)
  1103. {
  1104. CustomerIP = System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
  1105. }
  1106. }
  1107. else
  1108. {
  1109. CustomerIP = System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
  1110. }
  1111. if (string.Compare(CustomerIP, "unknown", true) == 0 || string.IsNullOrEmpty(CustomerIP))
  1112. {
  1113. return System.Web.HttpContext.Current.Request.UserHostAddress;
  1114. }
  1115. return CustomerIP;
  1116. }
  1117. catch { }
  1118. return userIP;
  1119. }
  1120. }
  1121. /// <summary>
  1122. /// 登录信息
  1123. /// </summary>
  1124. public class TLoginModel
  1125. {
  1126. /// <summary>
  1127. /// 账号
  1128. /// </summary>
  1129. public string username { get; set; }
  1130. /// <summary>
  1131. /// 密码
  1132. /// </summary>
  1133. public string password { get; set; }
  1134. /// <summary>
  1135. /// 设备号
  1136. /// </summary>
  1137. public string deviceid { get; set; }
  1138. public string openid { get; set; }
  1139. }
  1140. public class StuModel
  1141. {
  1142. public string id { get; set; }
  1143. public string username { get; set; }
  1144. public string sex { get; set; }
  1145. public string phone { get; set; }
  1146. public string address { get; set; }
  1147. public string culture { get; set; }
  1148. public string school { get; set; }
  1149. public string depart { get; set; }
  1150. public string paymentQuota { get; set; }
  1151. public string rTeacher { get; set; }
  1152. public string ids { get; set; }
  1153. public string renarks { get; set; }
  1154. public string province { get; set; }
  1155. public string city { get; set; }
  1156. public string county { get; set; }
  1157. public string birthday { get; set; }
  1158. }
  1159. public class stuQueryParam
  1160. {
  1161. public string empid { get; set; }
  1162. public string num { get; set; }
  1163. }
  1164. public class teaInfo
  1165. {
  1166. public string id { get; set; }
  1167. public string photo { get; set; }
  1168. public string realName { get; set; }
  1169. public string sexID { get; set; }
  1170. public string remark { get; set; }
  1171. public string birthDate { get; set; }
  1172. }
  1173. public class pwdModel
  1174. {
  1175. public string userid { get; set; }
  1176. public string oldpwd { get; set; }
  1177. public string newpwd { get; set; }
  1178. }
  1179. public class stuInfo
  1180. {
  1181. public string id { get; set; }
  1182. public string sex { get; set; }
  1183. public string birthday { get; set; }
  1184. public string idcard { get; set; }
  1185. }
  1186. public class newsParamModel
  1187. {
  1188. public string companyid { get; set; }
  1189. public string type { get; set; }
  1190. }
  1191. public class forgetPwdParamModel
  1192. {
  1193. public string mobile { get; set; }
  1194. public string ids { get; set; }
  1195. }
  1196. public class RegisterModel
  1197. {
  1198. public string name { get; set; }
  1199. public string logpwd { get; set; }
  1200. public string ids { get; set; }
  1201. public string mobile { get; set; }
  1202. }
  1203. }