説明なし

UserAccountController.cs 28KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664
  1. using CallCenter.Utility;
  2. using CallCenterApi.Common;
  3. using CallCenterApi.DB;
  4. using CallCenterApi.Interface.Controllers.Base;
  5. using CallCenterApi.Interface.Controllers.Sms;
  6. using CallCenterApi.Interface.Models.Input;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Data;
  10. using System.Linq;
  11. using System.Text.RegularExpressions;
  12. using System.Web;
  13. using System.Web.Mvc;
  14. namespace CallCenterApi.Interface.Controllers
  15. {
  16. [Authority]
  17. public class UserAccountController : BaseController
  18. {
  19. private BLL.T_Sys_UserAccount sysUserAccountBll = new BLL.T_Sys_UserAccount();
  20. private BLL.T_Sys_Department departmentBLL = new BLL.T_Sys_Department();
  21. private BLL.T_Sys_DictionaryValue dicValueBLL = new BLL.T_Sys_DictionaryValue();
  22. //用户列表
  23. //[Authority]
  24. public ActionResult GetList(int isdc=0)
  25. {
  26. DataTable dt = new DataTable();
  27. string sql = " ";
  28. try
  29. {
  30. //用户管理中,加个筛选项根据角色筛选(筛选二级单位时,可以看到该二级单位下的所有人员)
  31. string roleId = RequestString.GetQueryString("roleId");
  32. string rolecode = RequestString.GetQueryString("rolecode");
  33. //用户管理中,加个筛选项根据角色筛选(筛选二级单位时,可以看到该二级单位下的所有人员)
  34. string Key = RequestString.GetQueryString("Key");
  35. int Id = RequestString.GetInt("Id", 0);
  36. string strpageindex = RequestString.GetQueryString("page");
  37. int pageindex = 1;
  38. string strpagesize = RequestString.GetQueryString("pagesize");
  39. int pagesize = 10;
  40. if (Id > 0)
  41. {
  42. sql += " and F_DeptId=" + Id;
  43. }
  44. if (User.F_RoleCode == "GLY" || User.F_RoleCode == "YSZY" || User.F_RoleCode == "ZXLD" || User.F_RoleCode == "ZXHWY"|| User.F_RoleCode == "MTDD" || User.F_RoleCode == "DMTSH")
  45. {
  46. }
  47. else
  48. {
  49. sql += "and F_DeptId in (select F_DeptId from T_Sys_Department where F_State=0 and ( F_DeptId='" + User.F_DeptId + "' or F_PartentId='" + User.F_DeptId + "'))";
  50. }
  51. if (!string.IsNullOrWhiteSpace(Key))
  52. {
  53. // sql = "";
  54. string str = string.Format(" and (F_UserCode like '%{0}%' or F_UserName like '%{1}%')", Key, Key);
  55. sql += str;
  56. }
  57. if (!string.IsNullOrWhiteSpace(roleId))
  58. {
  59. // sql = "";
  60. string str = string.Format(" and (F_RoleId = '{0}' )", roleId);
  61. sql += str;
  62. }
  63. if (!string.IsNullOrWhiteSpace(rolecode))
  64. {
  65. // sql = "";
  66. string str = string.Format(" and F_RoleId in ({0})", rolecode);
  67. sql += str;
  68. }
  69. if (strpageindex.Trim() != "")
  70. {
  71. pageindex = Convert.ToInt32(strpageindex);
  72. }
  73. if (strpagesize.Trim() != "")
  74. {
  75. pagesize = Convert.ToInt32(strpagesize);
  76. }
  77. if (isdc==1)
  78. {
  79. var dtdc = DbHelperSQL.Query(" select F_UserCode 工号, F_UserName 姓名,F_Company 单位,F_Department 科室,F_Post 职务, F_Mobile 手机号码,F_Telephone 办公电话 from T_Sys_UserAccount WITH(NOLOCK) where 1=1 " + sql).Tables[0];
  80. var msg = new NPOIHelper().ExportToExcel("单位信息列表", dtdc);
  81. if (msg == "")
  82. {
  83. return Success("导出成功");
  84. }
  85. else
  86. {
  87. return Error("导出失败");
  88. }
  89. }
  90. if (isdc ==2)
  91. {
  92. var dtdc = DbHelperSQL.Query("select F_UserCode 坐席工号, F_UserName 用户名称, F_Telephone 用户电话, F_Mobile 用户手机, (select F_RoleName from T_Sys_RoleInfo where F_RoleId = a.F_RoleId ) 用户角色,(select F_DeptName from T_Sys_Department where F_DeptId = a.F_DeptId ) 用户部门,(case F_DeleteFlag when 0 then '正常' else '禁用' end ) 用户状态 ,F_CreateOn 创建时间 from T_Sys_UserAccount a WITH(NOLOCK) where 1=1 " + sql).Tables[0];
  93. var msg = new NPOIHelper().ExportToExcel("用户列表", dtdc);
  94. if (msg == "")
  95. {
  96. return Success("导出成功");
  97. }
  98. else
  99. {
  100. return Error("导出失败");
  101. }
  102. }
  103. else
  104. {
  105. int recordCount = 0;
  106. dt = BLL.PagerBLL.GetListPager(
  107. "T_Sys_UserAccount",
  108. "F_UserId",
  109. "*",
  110. sql,
  111. "ORDER BY F_UserId desc",
  112. pagesize,
  113. pageindex,
  114. true,
  115. out recordCount);
  116. List<Model.UserAccount> modelList = new BLL.UserAccount().DataTableToList(dt);
  117. var obj = new
  118. {
  119. rows = modelList.Select(x => new
  120. {
  121. F_UserId = x.F_UserId,
  122. F_UserCode = x.F_UserCode,
  123. F_ExtensionNumber = x.F_ExtensionNumber,
  124. F_UserName = x.F_UserName,
  125. F_GroupName = x.F_GroupName,
  126. F_DeptId = x.F_DeptId,
  127. F_RoleId = x.F_RoleId,
  128. F_GroupId = x.F_GroupId,
  129. F_SeatFlag = x.F_SeatFlag,
  130. F_SeatRight = x.F_SeatRight,
  131. F_SeatLevel = x.F_SeatLevel,
  132. F_SexFlag = x.F_SexFlag,
  133. F_RemindFlag = x.F_RemindFlag,
  134. F_Remark = x.F_Remark,
  135. F_Telephone = x.F_Telephone,
  136. F_Mobile = x.F_Mobile,
  137. F_HomePhone = x.F_HomePhone,
  138. F_Birthday = x.F_Birthday,
  139. F_CreateOn = x.F_CreateOn,
  140. F_CancelOn = x.F_CancelOn,
  141. F_DeleteFlag = x.F_DeleteFlag,
  142. F_APPOnFlag = x.F_APPOnFlag,
  143. F_LastActiveTime = x.F_LastActiveTime,
  144. F_See = x.F_See,
  145. F_HJType = x.F_HJType,
  146. F_PId = x.F_PId,
  147. F_TmId = x.F_TmId,
  148. F_RoleName = x.F_RoleName,
  149. F_DeptName = x.F_DeptName,
  150. F_WorkNumber = x.F_WorkNumber,
  151. F_Company = x.F_Company,
  152. F_Department = x.F_Department,
  153. F_Post = x.F_Post,
  154. F_IsSms=x.F_IsSms,
  155. F_SeartGroupCode = x.F_SeartGroupCode
  156. }),
  157. total = recordCount
  158. };
  159. return Content(obj.ToJson());
  160. }
  161. }
  162. catch (Exception err)
  163. {
  164. return Error("错误:" + err.ToString());
  165. }
  166. finally
  167. {
  168. dt.Clear();
  169. dt.Dispose();
  170. }
  171. }
  172. //获取用户信息
  173. //[Authority]
  174. public ActionResult GetUser(int userId = 0, string userCode = "")
  175. {
  176. string sql = "";
  177. if (userId > 0)
  178. {
  179. sql += " and F_UserId=" + userId;
  180. }
  181. if (!string.IsNullOrWhiteSpace(userCode))
  182. {
  183. sql += " and F_UserCode='" + userCode+"'";
  184. }
  185. if (string.IsNullOrWhiteSpace(sql))
  186. return Error("获取失败");
  187. Model.T_Sys_UserAccount User = sysUserAccountBll.GetModelList(" 1=1 " + sql).FirstOrDefault();
  188. if (User == null) return Error("获取失败");
  189. var depModel = departmentBLL.GetModel(User.F_DeptId);
  190. var zxzModel = dicValueBLL.GetModel(User.F_GroupId ?? 0);
  191. return Success("获取成功", new
  192. {
  193. F_UserId = User.F_UserId,
  194. F_UserCode = User.F_UserCode,
  195. F_ExtensionNumber = User.F_ExtensionNumber,
  196. F_UserName = User.F_UserName,
  197. F_DeptId = User.F_DeptId,
  198. F_RoleId = User.F_RoleId,
  199. F_GroupId = User.F_GroupId,
  200. F_SeatFlag = User.F_SeatFlag,
  201. F_SeatRight = User.F_SeatRight,
  202. F_SeatLevel = User.F_SeatLevel,
  203. F_SexFlag = User.F_SexFlag,
  204. F_RemindFlag = User.F_RemindFlag,
  205. F_Remark = User.F_Remark,
  206. F_Telephone = User.F_Telephone,
  207. F_Mobile = User.F_Mobile,
  208. F_HomePhone = User.F_HomePhone,
  209. F_Birthday = (User.F_Birthday ?? DateTime.MinValue).ToString("yyyy-MM-dd"),
  210. F_CreateOn = User.F_CreateOn,
  211. F_CancelOn = User.F_CancelOn,
  212. F_DeleteFlag = User.F_DeleteFlag,
  213. F_APPOnFlag = User.F_APPOnFlag,
  214. F_LastActiveTime = User.F_LastActiveTime,
  215. F_See = User.F_See,
  216. F_HJType = User.F_HJType ?? 0,
  217. F_PId = User.F_PId,
  218. F_TmId = User.F_TmId,
  219. F_WorkNumber = User.F_WorkNumber,
  220. F_Name= User.F_Name ,
  221. F_Company = User.F_Company ,
  222. F_Department = User.F_Department ,
  223. F_Post = User.F_Post ,
  224. F_IsSms = User.F_IsSms,
  225. //zxzname = zxzModel?.F_Name ?? "",
  226. depname = depModel?.F_DeptName ?? "",
  227. F_SeartGroupCode = User.F_SeartGroupCode,
  228. F_SeartGroupID = User.F_SeartGroupID
  229. });
  230. }
  231. //[Authority]
  232. //添加用户信息
  233. public ActionResult AddUsers(UserAccountInput input)
  234. {
  235. Regex reg = new Regex(@"^[1-9]\d*$");
  236. if (!reg.IsMatch(input.Usercode.Trim()))
  237. {
  238. return Error("工号必须为正整数");
  239. }
  240. Model.T_Sys_UserAccount userAccountModel = new Model.T_Sys_UserAccount();
  241. userAccountModel.F_UserCode = input.Usercode.Trim();
  242. userAccountModel.F_UserName = input.Username.Trim();
  243. userAccountModel.F_Password = input.Password.Trim();
  244. //userAccountModel.F_ExtensionNumber = input.Extno.Trim();
  245. userAccountModel.F_WorkNumber = input.Usercode;
  246. userAccountModel.F_DeptId = input.DeptId;
  247. userAccountModel.F_RoleId = input.RoleId;
  248. userAccountModel.F_GroupId = input.GroupId;
  249. userAccountModel.F_SeatFlag = input.IsSeat;
  250. userAccountModel.F_SeatRight = input.SearRight;
  251. userAccountModel.F_SexFlag = input.Sex;
  252. userAccountModel.F_Remark = input.Remark;
  253. userAccountModel.F_Mobile = input.Mobile;
  254. userAccountModel.F_Telephone = input.Telphone;
  255. userAccountModel.F_Birthday = input.Birth;
  256. userAccountModel.F_CreateOn = DateTime.Now;
  257. userAccountModel.F_DeleteFlag = 0;
  258. userAccountModel.F_ModifytTime = DateTime.Now;
  259. userAccountModel.F_LastActiveTime = DateTime.Now;
  260. userAccountModel.F_IsSms = input.F_IsSms;
  261. //userAccountModel.F_HJType = input.HjType;
  262. var model = sysUserAccountBll.GetModel(input.Usercode);
  263. if (model != null)
  264. return Error("当前员工工号存在,请更换!");
  265. if (input.GroupId != 0)
  266. {
  267. userAccountModel.F_SeartGroupID = input.GroupId;
  268. Model.T_Sys_SeatGroup sm = new BLL.T_Sys_SeatGroup().GetModel(input.GroupId);
  269. if (sm != null)
  270. {
  271. userAccountModel.F_SeartGroupCode = sm.F_ZXZName;
  272. }
  273. }
  274. if (input.IsSeat)
  275. {
  276. // userAccountModel.F_WorkNumber = input.Usercode.Trim();
  277. if (input.ClassId.Value > 0)
  278. {
  279. var cls = new BLL.T_Sys_Class().GetModel(input.ClassId.Value);
  280. userAccountModel.F_ClassCode = (cls != null ? cls.F_Code : "");
  281. }
  282. SysConfigController sys = new SysConfigController();
  283. //话务人员限制权限判断
  284. if (sys.IsValidSeatPermission())
  285. {
  286. if (sysUserAccountBll.Add(userAccountModel) > 0)
  287. return Success("新增成功!");
  288. else
  289. return Error("新增失败!");
  290. }
  291. else
  292. {
  293. return Error("话务人员数量已超!");
  294. }
  295. }
  296. if (sysUserAccountBll.Add(userAccountModel) > 0)
  297. return Success("新增成功!");
  298. else
  299. return Error("新增失败!");
  300. }
  301. //[Authority]
  302. //修改用户信息
  303. public ActionResult EditUsers(UserAccountInput input)
  304. {
  305. Regex reg = new Regex(@"^[1-9]\d*$");
  306. if (!reg.IsMatch(input.Usercode.Trim()))
  307. {
  308. return Error("工号必须为正整数");
  309. }
  310. BLL.T_Sys_UserAccount sysUserAccountBll = new BLL.T_Sys_UserAccount();
  311. Model.T_Sys_UserAccount userAccountModel = sysUserAccountBll.GetModelList(" F_UserId = " + input.UserId).FirstOrDefault();
  312. if (userAccountModel == null)
  313. return Error("获取用户失败");
  314. userAccountModel.F_UserCode = input.Usercode.Trim();
  315. userAccountModel.F_UserName = input.Username.Trim();
  316. //userAccountModel.F_Password = input.Password.Trim();
  317. //userAccountModel.F_ExtensionNumber = input.Extno.Trim();
  318. userAccountModel.F_WorkNumber = input.Usercode;
  319. userAccountModel.F_DeptId = input.DeptId;
  320. userAccountModel.F_RoleId = input.RoleId;
  321. // userAccountModel.F_GroupId = input.GroupId;
  322. userAccountModel.F_SeatFlag = input.IsSeat;
  323. userAccountModel.F_SeatRight = input.SearRight;
  324. userAccountModel.F_SexFlag = input.Sex;
  325. userAccountModel.F_Remark = input.Remark;
  326. userAccountModel.F_Mobile = input.Mobile;
  327. userAccountModel.F_Telephone = input.Telphone;
  328. userAccountModel.F_Birthday = input.Birth;
  329. userAccountModel.F_IsSms = input.F_IsSms;
  330. userAccountModel.F_ModifytTime = DateTime.Now;
  331. //userAccountModel.F_DeleteFlag = 0;
  332. //userAccountModel.F_HJType = input.HjType;
  333. if (input.GroupId != 0)
  334. {
  335. userAccountModel.F_SeartGroupID = input.GroupId;
  336. Model.T_Sys_SeatGroup sm = new BLL.T_Sys_SeatGroup().GetModel(input.GroupId);
  337. if (sm != null)
  338. {
  339. userAccountModel.F_SeartGroupCode = sm.F_ZXZName;
  340. }
  341. }
  342. if (input.IsSeat)
  343. {
  344. //userAccountModel.F_WorkNumber = input.Usercode.Trim();
  345. if (input.ClassId.Value > 0)
  346. {
  347. var cls = new BLL.T_Sys_Class().GetModel(input.ClassId.Value);
  348. userAccountModel.F_ClassCode = (cls != null ? cls.F_Code : "");
  349. }
  350. SysConfigController sys = new SysConfigController();
  351. //话务人员限制权限判断
  352. if (sys.IsValidSeatPermission())
  353. {
  354. if (sysUserAccountBll.Update(userAccountModel))
  355. return Success("编辑成功!");
  356. else
  357. return Error("编辑失败!");
  358. }
  359. else
  360. {
  361. return Error("话务人员数量已超!");
  362. }
  363. }
  364. if (sysUserAccountBll.Update(userAccountModel))
  365. return Success("编辑成功!");
  366. else
  367. return Error("编辑失败!");
  368. }
  369. //[Authority]
  370. //删除/禁用/启用 用户
  371. public ActionResult DelUsers(string[] ids, int state = 0)
  372. {
  373. if (ids == null || ids.Length <= 0)
  374. return Error("请选择用户");
  375. var idStr = string.Join(",", ids);
  376. if (string.IsNullOrEmpty(idStr))
  377. return Error("请选择用户");
  378. SysConfigController sys = new SysConfigController();
  379. //话务人员限制权限判断
  380. if (state == 0) {
  381. if (sys.IsValidSeatPermission())
  382. {
  383. if (sysUserAccountBll.DeleteList(idStr, state))
  384. return Success("设置成功");
  385. else
  386. return Error("设置失败");
  387. }
  388. else
  389. {
  390. return Error("话务人员数量已超!");
  391. }
  392. }
  393. if (sysUserAccountBll.DeleteList(idStr, state))
  394. return Success("设置成功");
  395. else
  396. return Error("设置失败");
  397. }
  398. //[Authority]
  399. //删除用户
  400. public ActionResult WLDelUsers(string[] ids)
  401. {
  402. if (ids == null || ids.Length <= 0)
  403. return Error("请选择用户");
  404. var idStr = string.Join(",", ids);
  405. if (string.IsNullOrEmpty(idStr))
  406. return Error("请选择用户");
  407. if (sysUserAccountBll.DeleteList(idStr))
  408. return Success("删除成功");
  409. else
  410. return Error("删除失败");
  411. }
  412. //获取坐席列表
  413. public ActionResult GetSeatList()
  414. {
  415. //List<Model.T_Sys_UserAccount> userSeartList = sysUserAccountBll.GetModelList(" f_seatflag=1 ");
  416. var drs = sysUserAccountBll.GetList("").Tables[0].Select("f_seatflag=1");
  417. var userSeartList = from r in drs select new {
  418. F_UserId = r["F_UserId"].ToString(),
  419. F_UserName = r["F_UserName"].ToString(),
  420. F_UserCode = r["F_UserCode"].ToString()
  421. };
  422. var result = userSeartList.OrderBy(p => p.F_UserName.Substring(p.F_UserName.Length - 1)).ToList();
  423. return Success("列表加载成功", result);
  424. }
  425. //根据角色获取用户
  426. public ActionResult GetUsersList(string rolecode)
  427. {
  428. var sql = " 1=1 ";
  429. if (!string.IsNullOrWhiteSpace(rolecode.Trim()))
  430. {
  431. string F_RoleId = DbHelperSQL.GetSingle("select F_RoleId from T_Sys_RoleInfo with(nolock) where F_RoleCode='" + rolecode.Trim() + "'")?.ToString() ?? "0";
  432. sql += " and F_RoleId = " + F_RoleId;
  433. }
  434. //List<Model.T_Sys_UserAccount> userList = sysUserAccountBll.GetModelList(sql, " f_userid desc ");
  435. var userList = sysUserAccountBll.GetList(sql, " f_userid desc ").Tables[0];
  436. return Success("列表加载成功", userList);
  437. }
  438. //根据部门获取用户
  439. public ActionResult GetDeptUserList(int deptid = 0)
  440. {
  441. var DeptUserList = sysUserAccountBll.GetList("F_DeptId='" + deptid + "' ", " f_userid desc ");
  442. return Success("列表加载成功", DeptUserList);
  443. }
  444. //[Authority]
  445. //获取当前用户信息
  446. public ActionResult GetNowUser()
  447. {
  448. if (User == null)
  449. return Error("获取失败");
  450. Model.T_Sys_RoleInfo roleModel = new BLL.T_Sys_RoleInfo().GetModel(User.F_RoleId);
  451. var obj = new
  452. {
  453. user = User,
  454. role = roleModel
  455. };
  456. return Success("获取成功", obj);
  457. }
  458. //[Authority]
  459. /// <summary>
  460. /// 重置密码
  461. /// </summary>
  462. /// <param name="usercode"></param>
  463. /// <param name="pwd"></param>
  464. /// <returns></returns>
  465. public ActionResult ResetPwd(string usercode = "", string pwd = "")
  466. {
  467. if (string.IsNullOrWhiteSpace(pwd))
  468. return Error("请输入密码");
  469. var model = sysUserAccountBll.GetModel(usercode);
  470. if (model == null) return Error("此用户不存在");
  471. model.F_Password = pwd;
  472. if (sysUserAccountBll.Update(model))
  473. return Success("重置密码成功");
  474. else
  475. return Error("重置密码失败");
  476. }
  477. public class VerificationCode
  478. {
  479. public string mobile { set; get; }
  480. public string code { set; get; }
  481. public DateTime Time { set; get; }
  482. }
  483. public ActionResult SendCode(string mobile)
  484. {
  485. if (string .IsNullOrEmpty (mobile))
  486. {
  487. return Error("请输入将要发送的号码");
  488. }
  489. int codes = new Random().Next(1000, 9999);
  490. // string msg = codes.ToString ();
  491. // bool n = SMSController.AddSmS(0, msg, "你的验证码是"+ codes+".十分钟有效.", mobile, "168411", "");
  492. string mag = "[\"" + codes.ToString() + "\"]";
  493. string v = SmsNewController.AddSmS(0, "你的验证码是" + codes + ".十分钟有效.", mobile, "681240638956277760", mag,
  494. "");
  495. if (v=="")
  496. {
  497. return Success("发送成功");
  498. }
  499. else
  500. return Error ("发送失败");
  501. }
  502. public ActionResult GetUserModify( )
  503. {
  504. if (string.IsNullOrEmpty(User.F_Mobile))
  505. return Error("请填写手机号");
  506. if (string.IsNullOrEmpty(User.F_Company) || string.IsNullOrEmpty(User.F_Department) || string.IsNullOrEmpty(User.F_Post))
  507. return Error("用户信息不完整");
  508. if (User.F_ModifytTime!=null )
  509. {
  510. if (((DateTime )User.F_ModifytTime).Month != DateTime.Now.Month)
  511. {
  512. if (DateTime.Now.Day >= 5)
  513. {
  514. return Error("请及时修改密码");
  515. }
  516. }
  517. }
  518. return Success("成功");
  519. }
  520. public ActionResult UpdatePwd(string name , string company,string department,string post,
  521. string mobile,string phone, string code, string usercode = "", string pwd = "", string oldPwd = ""
  522. )
  523. {
  524. if (string.IsNullOrEmpty(code))
  525. return Error("请输入短信验证码");
  526. if (string.IsNullOrWhiteSpace(pwd))
  527. return Error("请输入密码");
  528. if (string.IsNullOrEmpty(company) || string.IsNullOrEmpty(department) || string.IsNullOrEmpty(post)|| string.IsNullOrEmpty(name))
  529. return Error("用户信息不完整");
  530. var model = sysUserAccountBll.GetModel(usercode);
  531. if (model == null) return Error("此用户不存在");
  532. if (pwd.Equals(oldPwd))
  533. return Error("新密码不能和原密码相同");
  534. if (!model.F_Password.Equals(oldPwd)) return Error("原密码不正确");
  535. if (string.IsNullOrEmpty(mobile))
  536. return Error("请输入手机号码");
  537. string msgcount = "你的验证码是" + code + ".十分钟有效.";
  538. var sms = new BLL.T_SMS_RecvSMS().GetModelList("Content='"+ msgcount+ "' and CallerNum='"+ mobile+ "'order by RecvTime desc");
  539. if (sms != null&& sms.Count >0)
  540. {
  541. var modelSms = sms.First();
  542. if ((DateTime.Now - modelSms.RecvTime ).Minutes > 10)
  543. {
  544. return Error("验证码已失效");
  545. }
  546. }
  547. else
  548. return Error("请获取验证码");
  549. model.F_Password = pwd;
  550. if (!string.IsNullOrEmpty(name))
  551. model.F_UserName = name;
  552. if (!string.IsNullOrEmpty(company))
  553. model.F_Company = company;
  554. if (!string.IsNullOrEmpty(department))
  555. model.F_Department = department;
  556. if (!string.IsNullOrEmpty(post))
  557. model.F_Post = post;
  558. if (!string.IsNullOrEmpty(mobile))
  559. model.F_Mobile = mobile;
  560. if (!string.IsNullOrEmpty(phone))
  561. model.F_Telephone = phone;
  562. model.F_ModifytTime = DateTime.Now;
  563. if (sysUserAccountBll.Update(model))
  564. return Success("修改成功");
  565. else
  566. return Error("修改失败");
  567. }
  568. #region App手机端 用户列表
  569. /// <summary>
  570. /// App手机端 用户列表
  571. /// </summary>
  572. /// <returns></returns>
  573. //[Authority]
  574. public ActionResult GetAppUserList()
  575. {
  576. DataTable dt = new DataTable();
  577. string sql = " 1=1 and F_RoleId=2 ";
  578. try
  579. {
  580. string Key = RequestString.GetQueryString("Key");
  581. if (!string.IsNullOrWhiteSpace(Key))
  582. {
  583. string str = string.Format(" and (F_DeptId IN (SELECT F_DeptId FROM dbo.T_Sys_Department WHERE F_DeptName like '%{0}%') or F_UserName like '%{1}%' or F_Mobile like '%{2}%' or F_Telephone like '%{3}%' or F_HomePhone like '%{3}%')", Key, Key, Key, Key, Key);
  584. sql += str;
  585. }
  586. dt = sysUserAccountBll.GetListNoCache(sql).Tables[0];
  587. List<Model.UserAccount> modelList = new BLL.UserAccount().DataTableToList(dt);
  588. return Success("获取成功",
  589. modelList.Select(x => new
  590. {
  591. F_UserId = x.F_UserId,
  592. F_UserCode = x.F_UserCode,
  593. F_UserName = x.F_UserName,
  594. F_DeptId = x.F_DeptId,
  595. F_SexFlag = x.F_SexFlag,
  596. F_Remark = x.F_Remark,
  597. F_Telephone = x.F_Telephone,
  598. F_Mobile = x.F_Mobile,
  599. F_HomePhone = x.F_HomePhone,
  600. F_Birthday = x.F_Birthday,
  601. F_CreateOn = x.F_CreateOn,
  602. F_APPOnFlag = x.F_APPOnFlag,
  603. F_LastActiveTime = x.F_LastActiveTime,
  604. F_RoleName = x.F_RoleName,
  605. F_DeptName = x.F_DeptName
  606. })
  607. );
  608. }
  609. catch (Exception err)
  610. {
  611. return Error("错误:" + err.ToString());
  612. }
  613. finally
  614. {
  615. dt.Clear();
  616. dt.Dispose();
  617. }
  618. }
  619. #endregion
  620. }
  621. }