郑州颐和随访系统

MobiledataController.cs 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  1. using CallCenter.Utility;
  2. using CallCenterApi.Common;
  3. using CallCenterApi.DB;
  4. using CallCenterApi.Interface.Controllers.Base;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Data;
  8. using System.Linq;
  9. using System.Web;
  10. using System.Web.Mvc;
  11. namespace CallCenterApi.Interface.Controllers.tel
  12. {
  13. public class MobiledataController : BaseController
  14. {
  15. //获取号码归属地列表
  16. public ActionResult GetList(string strtelnum)
  17. {
  18. ActionResult res = NoToken("未知错误,请重新登录");
  19. if (Request.IsAuthenticated)
  20. {
  21. string sql = " and F_IsDelete=0";
  22. DataTable dt = new DataTable();
  23. string strpageindex = RequestString.GetQueryString("page");
  24. int pageindex = 1;
  25. string strpagesize = RequestString.GetQueryString("pagesize");
  26. int pagesize = 10;
  27. if (strtelnum != null && strtelnum.Trim() != "")
  28. {
  29. sql += " and (F_MobileNum like '%" + strtelnum.Trim() + "%' or F_ZipCode like '%" + strtelnum.Trim()
  30. + "%' or F_CityDes like '%" + strtelnum.Trim() + "%'or F_CardDes like '%" + strtelnum.Trim() + "%')";
  31. }
  32. if (strpageindex.Trim() != "")
  33. {
  34. pageindex = Convert.ToInt32(strpageindex);
  35. }
  36. if (strpagesize.Trim() != "")
  37. {
  38. pagesize = Convert.ToInt32(strpagesize);
  39. }
  40. int recordCount = 0;
  41. dt = BLL.PagerBLL.GetListPager(
  42. "T_Sys_MobileData",
  43. "F_Id",
  44. "*",
  45. sql,
  46. "ORDER BY F_Id desc",
  47. pagesize,
  48. pageindex,
  49. true,
  50. out recordCount);
  51. var obj = new
  52. {
  53. state = "success",
  54. message = "成功",
  55. rows = dt,
  56. total = recordCount
  57. };
  58. res = Content(obj.ToJson());
  59. }
  60. return res;
  61. }
  62. public ActionResult GetMobiledata(int id)
  63. {
  64. ActionResult res = NoToken("未知错误,请重新登录");
  65. if (Request.IsAuthenticated)
  66. {
  67. BLL.T_Sys_MobileData dBLL = new BLL.T_Sys_MobileData();
  68. Model.T_Sys_MobileData dModel = dBLL.GetModel(id);
  69. res = Success("获取号码归属地成功", dModel);
  70. }
  71. return res;
  72. }
  73. //获取号码归属地
  74. public ActionResult GetMobiledataByNum(string mobileNum)
  75. {
  76. ActionResult res = NoToken("未知错误,请重新登录");
  77. if (Request.IsAuthenticated)
  78. {
  79. if (mobileNum != null && mobileNum.Trim() != "")
  80. {
  81. BLL.T_Sys_MobileData dBLL = new BLL.T_Sys_MobileData();
  82. Model.T_Sys_MobileData dModel = dBLL.GetModelList(" F_MobileNum='" + mobileNum.Trim() + "' ").FirstOrDefault();
  83. if (dModel != null)
  84. {
  85. res = Success("获取号码归属地成功", dModel);
  86. }
  87. else
  88. {
  89. res = Error("获取号码归属地失败");
  90. }
  91. }
  92. else
  93. {
  94. res = Error("获取参数失败");
  95. }
  96. }
  97. return res;
  98. }
  99. //添加/编辑号码归属地
  100. public ActionResult AddMobiledata(string mobileNum, string zipCode, string cityDes, string cardDes, int id = 0)
  101. {
  102. ActionResult res = NoToken("未知错误,请重新登录");
  103. if (Request.IsAuthenticated)
  104. {
  105. int userId = CurrentUser.UserData.F_UserId;
  106. Model.T_Sys_UserAccount ua = new BLL.T_Sys_UserAccount().GetModel(userId);
  107. BLL.T_Sys_MobileData dBLL = new BLL.T_Sys_MobileData();
  108. Model.T_Sys_MobileData dModel = new Model.T_Sys_MobileData();
  109. if (id != 0)
  110. {
  111. dModel = dBLL.GetModel(id);
  112. if (dModel != null)
  113. {
  114. if (!string.IsNullOrWhiteSpace(mobileNum.Trim()))
  115. {
  116. dModel.F_MobileNum = mobileNum.Trim();
  117. }
  118. if (!string.IsNullOrWhiteSpace(zipCode.Trim()))
  119. {
  120. dModel.F_ZipCode = zipCode.Trim();
  121. }
  122. if (!string.IsNullOrWhiteSpace(cityDes.Trim()))
  123. {
  124. dModel.F_CityDes = cityDes.Trim();
  125. }
  126. if (!string.IsNullOrWhiteSpace(cardDes.Trim()))
  127. {
  128. dModel.F_CardDes = cardDes.Trim();
  129. }
  130. bool b = dBLL.Update(dModel);
  131. if (b)
  132. {
  133. res = Success("编辑成功");
  134. }
  135. else
  136. {
  137. res = Error("编辑失败");
  138. }
  139. }
  140. else
  141. {
  142. res = Error("编辑失败");
  143. }
  144. }
  145. else
  146. {
  147. dModel = new Model.T_Sys_MobileData();
  148. if (!string.IsNullOrWhiteSpace(mobileNum.Trim()))
  149. {
  150. dModel.F_MobileNum = mobileNum.Trim();
  151. }
  152. if (!string.IsNullOrWhiteSpace(zipCode.Trim()))
  153. {
  154. dModel.F_ZipCode = zipCode.Trim();
  155. }
  156. if (!string.IsNullOrWhiteSpace(cityDes.Trim()))
  157. {
  158. dModel.F_CityDes = cityDes.Trim();
  159. }
  160. if (!string.IsNullOrWhiteSpace(cardDes.Trim()))
  161. {
  162. dModel.F_CardDes = cardDes.Trim();
  163. }
  164. dModel.F_IsDelete = 0;
  165. dModel.F_CreateUser = ua.F_UserCode;
  166. dModel.F_CreateTime = DateTime.Now;
  167. int n = new BLL.T_Sys_MobileData().Add(dModel);
  168. if (n > 0)
  169. {
  170. res = Success("添加成功", n);
  171. }
  172. else
  173. {
  174. res = Error("添加失败");
  175. }
  176. }
  177. }
  178. return res;
  179. }
  180. //删除号码归属地记录
  181. public ActionResult DelMobiledata(string[] nums)
  182. {
  183. ActionResult res = NoToken("未知错误,请重新登录");
  184. if (Request.IsAuthenticated)
  185. {
  186. int userId = CurrentUser.UserData.F_UserId;
  187. Model.T_Sys_UserAccount ua = new BLL.T_Sys_UserAccount().GetModel(userId);
  188. if (nums != null && nums.Length > 0)
  189. {
  190. string idd = " ";
  191. foreach (string str in nums)
  192. {
  193. idd += "'" + str + "',";
  194. }
  195. if (new BLL.T_Sys_MobileData().DeleteList(idd.TrimEnd(','), ua.F_UserCode))
  196. {
  197. res = Success("删除成功");
  198. }
  199. else
  200. res = Error("删除失败");
  201. }
  202. else
  203. {
  204. res = Error("请选择要删除的记录");
  205. }
  206. }
  207. return res;
  208. }
  209. //IVR获取号码归属地
  210. public ActionResult IVRGetList(string strtelnum)
  211. {
  212. ActionResult res = NoToken("未知错误,请重新登录");
  213. if (Request.IsAuthenticated)
  214. {
  215. string sql = " and isDelete=0";
  216. DataTable dt = new DataTable();
  217. string strpageindex = RequestString.GetQueryString("page");
  218. int pageindex = 1;
  219. string strpagesize = RequestString.GetQueryString("pagesize");
  220. int pagesize = 10;
  221. if (strtelnum != null && strtelnum.Trim() != "")
  222. {
  223. sql += " and tel like '%" + strtelnum.Trim() + "%'";
  224. }
  225. if (strpageindex.Trim() != "")
  226. {
  227. pageindex = Convert.ToInt32(strpageindex);
  228. }
  229. if (strpagesize.Trim() != "")
  230. {
  231. pagesize = Convert.ToInt32(strpagesize);
  232. }
  233. int recordCount = 0;
  234. dt = BLL.PagerBLL.GetListPager(
  235. "tel_location",
  236. "tel_location.id",
  237. "*",
  238. sql,
  239. "ORDER BY tel_location.id asc",
  240. pagesize,
  241. pageindex,
  242. true,
  243. out recordCount);
  244. var obj = new
  245. {
  246. state = "success",
  247. message = "成功",
  248. rows = dt,
  249. total = recordCount
  250. };
  251. res = Content(obj.ToJson());
  252. }
  253. return res;
  254. }
  255. public ActionResult GetMobileUsersData(int id)
  256. {
  257. ActionResult res = NoToken("未知错误,请重新登录");
  258. if (Request.IsAuthenticated)
  259. {
  260. BLL.telloc_users dBLL = new BLL.telloc_users();
  261. Model.telloc_users dModel = dBLL.GetModel(id);
  262. res = Success("获取号码归属地成功", dModel);
  263. }
  264. return res;
  265. }
  266. //获取IVR号码归属地坐席关联
  267. public ActionResult GetMobileUsersList()
  268. {
  269. ActionResult res = NoToken("未知错误,请重新登录");
  270. if (Request.IsAuthenticated)
  271. {
  272. string sql = " and isDelete=0";
  273. DataTable dt = new DataTable();
  274. int userid = 0;
  275. userid = RequestString.GetQueryString("userid").ToString() == "" ? 0 : int.Parse(RequestString.GetQueryString("userid").ToString());
  276. string locstr = RequestString.GetQueryString("location");
  277. string strpageindex = RequestString.GetQueryString("page");
  278. int pageindex = 1;
  279. string strpagesize = RequestString.GetQueryString("pagesize");
  280. int pagesize = 10;
  281. List<int> telloclist = new List<int>();
  282. if (userid != 0)
  283. {
  284. //sql += " and userid="+userid;
  285. DataTable dttelusers = DbHelperSQL.Query(" select tellocid from telloc_users where isdelete=0 and userid=" + userid).Tables[0];
  286. if (dttelusers.Rows.Count > 0)
  287. {
  288. foreach (DataRow dr in dttelusers.Rows)
  289. {
  290. telloclist.Add(int.Parse(dr[0].ToString()));
  291. }
  292. }
  293. }
  294. if (locstr.Trim() != "")
  295. {
  296. sql += " and (province like '%" + locstr + "%' or city like '%" + locstr + "%')";
  297. }
  298. if (strpageindex.Trim() != "")
  299. {
  300. pageindex = Convert.ToInt32(strpageindex);
  301. }
  302. if (strpagesize.Trim() != "")
  303. {
  304. pagesize = Convert.ToInt32(strpagesize);
  305. }
  306. int recordCount = 0;
  307. dt = BLL.PagerBLL.GetListPager(
  308. "tel_location",
  309. "tel_location.id",
  310. "*",
  311. sql,
  312. "ORDER BY tel_location.id asc",
  313. pagesize,
  314. pageindex,
  315. true,
  316. out recordCount);
  317. dt.Columns.Add("res");
  318. dt.Columns.Add("uid");
  319. if (userid == 0)
  320. {
  321. foreach (DataRow dr in dt.Rows)
  322. {
  323. dr["res"] = 0;
  324. dr["uid"] = 0;
  325. }
  326. }
  327. else
  328. {
  329. foreach (DataRow dr in dt.Rows)
  330. {
  331. int tid = int.Parse(dr["id"].ToString());
  332. if (telloclist.Contains(tid))
  333. {
  334. dr["res"] = 1;
  335. dr["uid"] = userid;
  336. }
  337. else
  338. {
  339. dr["res"] = 0;
  340. dr["uid"] = 0;
  341. }
  342. }
  343. }
  344. var obj = new
  345. {
  346. state = "success",
  347. message = "成功",
  348. rows = dt,
  349. total = recordCount
  350. };
  351. res = Content(obj.ToJson());
  352. }
  353. return res;
  354. }
  355. //添加/修改IVR号码归属地坐席关联
  356. public ActionResult AddMobileUsers(int tellocid, int userid, int type)
  357. {
  358. ActionResult res = NoToken("未知错误,请重新登录");
  359. if (Request.IsAuthenticated)
  360. {
  361. int userId = CurrentUser.UserData.F_UserId;
  362. Model.T_Sys_UserAccount ua = new BLL.T_Sys_UserAccount().GetModel(userId);
  363. BLL.telloc_users dBLL = new BLL.telloc_users();
  364. Model.telloc_users dModel = new Model.telloc_users();
  365. //if (type == 1)//0为添加,1是解除
  366. //{
  367. // dModel = dBLL.GetModel(userid,tellocid);
  368. // if (dModel != null)
  369. // {
  370. // dModel.isdelete = 1;
  371. // bool b = dBLL.Update(dModel);
  372. // if (b)
  373. // {
  374. // res = Success("解除成功");
  375. // }
  376. // else
  377. // {
  378. // res = Error("解除失败");
  379. // }
  380. // }
  381. // else
  382. // {
  383. // res = Error("解除失败");
  384. // }
  385. //}
  386. //else
  387. //{
  388. // dModel = new Model.telloc_users();
  389. // if (!string.IsNullOrWhiteSpace(tellocid.ToString()))
  390. // {
  391. // dModel.tellocid = tellocid;
  392. // }
  393. // if (!string.IsNullOrWhiteSpace(userid.ToString()))
  394. // {
  395. // dModel.userid = userid;
  396. // }
  397. // dModel.isdelete = 0;
  398. // int n = new BLL.telloc_users().Add(dModel);
  399. // if (n > 0)
  400. // {
  401. // res = Success("添加成功", n);
  402. // }
  403. // else
  404. // {
  405. // res = Error("添加失败");
  406. // }
  407. //}
  408. dModel = new Model.telloc_users();
  409. if (!string.IsNullOrWhiteSpace(tellocid.ToString()))
  410. {
  411. dModel.tellocid = tellocid;
  412. }
  413. if (!string.IsNullOrWhiteSpace(userid.ToString()))
  414. {
  415. dModel.userid = userid;
  416. }
  417. dModel = dBLL.GetModel(userid, tellocid);
  418. if (dModel != null)
  419. {
  420. dModel.isdelete = type;
  421. bool b = dBLL.Update(dModel);
  422. var str = type == 1 ? "解除" : "添加";
  423. if (b)
  424. {
  425. res = Success(str + "成功");
  426. }
  427. else
  428. {
  429. res = Error(str + "失败");
  430. }
  431. }
  432. else
  433. {
  434. dModel.isdelete = 0;
  435. int n = new BLL.telloc_users().Add(dModel);
  436. if (n > 0)
  437. {
  438. res = Success("添加成功", n);
  439. }
  440. else
  441. {
  442. res = Error("添加失败");
  443. }
  444. }
  445. }
  446. return res;
  447. }
  448. //删除IVR号码归属地坐席关联
  449. public ActionResult DeleteMobileUsers(int id)
  450. {
  451. ActionResult res = NoToken("未知错误,请重新登录");
  452. if (Request.IsAuthenticated)
  453. {
  454. BLL.telloc_users dBLL = new BLL.telloc_users();
  455. Model.telloc_users dModel = new Model.telloc_users();
  456. if (id != 0)//修改
  457. {
  458. dModel = dBLL.GetModel(id);
  459. if (dModel != null)
  460. {
  461. dModel.isdelete = 1;
  462. bool b = dBLL.Update(dModel);
  463. if (b)
  464. {
  465. res = Success("删除成功");
  466. }
  467. else
  468. {
  469. res = Error("删除失败");
  470. }
  471. }
  472. else
  473. {
  474. res = Error("删除失败");
  475. }
  476. }
  477. else
  478. {
  479. res = Error("传入参数错误");
  480. }
  481. }
  482. return res;
  483. }
  484. public ActionResult GetSeatGroup()
  485. {
  486. ActionResult res = NoToken("未知错误,请重新登录");
  487. if (Request.IsAuthenticated)
  488. {
  489. BLL.T_Sys_SeatGroup dBLL = new BLL.T_Sys_SeatGroup();
  490. var seatgroups = dBLL.GetModelList("1=1").Select(n => new { n.F_ZXZID, n.F_ZXZName });
  491. res = Success("获取坐席组成功", seatgroups);
  492. }
  493. return res;
  494. }
  495. }
  496. }