Нет описания

CallInScreenController.cs 46KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018
  1. 
  2. using CallCenter.Utility;
  3. using CallCenterApi.Common;
  4. using CallCenterApi.DB;
  5. using CallCenterApi.Interface.Controllers.Base;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Data;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Web;
  12. using System.Web.Mvc;
  13. namespace CallCenterApi.Interface.Controllers.tel
  14. {
  15. public class CallInScreenController : BaseController
  16. {
  17. /// <summary>
  18. /// 添加黑名单
  19. /// </summary>
  20. /// <returns></returns>
  21. public ActionResult AddBlack()
  22. {
  23. if (Request.IsAuthenticated)
  24. {
  25. int userId = CurrentUser.UserData.F_UserId;
  26. if (userId != 0)
  27. {
  28. Model.T_Sys_UserAccount ua = new BLL.T_Sys_UserAccount().GetModel(userId);
  29. if (ua != null)
  30. {
  31. string tel = HttpUtility.UrlDecode(RequestString.GetFormString("tel"));
  32. string callid = HttpUtility.UrlDecode(RequestString.GetFormString("callid"));
  33. int n = RequestString.GetInt("num", 0);
  34. int type = RequestString.GetInt("type", 0);
  35. Model.T_Call_Blacklist dModel = new BLL.T_Call_Blacklist().GetModelList(" F_TelPhone='" + tel + "' ").FirstOrDefault();
  36. var date = DateTime.Now;
  37. var enddate = date;
  38. switch (type)
  39. {
  40. case 1: enddate = enddate.AddDays(n); break;
  41. case 2: enddate = enddate.AddHours(n); break;
  42. case 3: enddate = enddate.AddMinutes(n); break;
  43. case 4: enddate = DateTime.MaxValue; break;
  44. }
  45. if (dModel == null)
  46. {
  47. dModel = new Model.T_Call_Blacklist();
  48. dModel.F_CallId = callid;
  49. dModel.F_TelPhone = tel.Trim();
  50. dModel.F_SetTime = date;
  51. dModel.F_RemoveTime = enddate;
  52. dModel.F_InterceptNum = 1;
  53. dModel.F_UserId = ua.F_UserId;
  54. int b = new BLL.T_Call_Blacklist().Add(dModel);
  55. if (b > 0)
  56. {
  57. return Success("添加成功", enddate.ToString("yyyy-MM-dd HH:mm:ss"));
  58. }
  59. else
  60. {
  61. return Error("添加失败");
  62. }
  63. }
  64. else
  65. {
  66. dModel.F_RemoveTime = enddate;
  67. if (new BLL.T_Call_Blacklist().Update(dModel))
  68. {
  69. return Success("修改成功", enddate.ToString("yyyy-MM-dd HH:mm:ss"));
  70. }
  71. else
  72. {
  73. return Error("修改失败");
  74. }
  75. }
  76. }
  77. }
  78. }
  79. return NoToken("未知错误,请重新登录");
  80. }
  81. /// <summary>
  82. /// 取消黑名单
  83. /// </summary>
  84. /// <returns></returns>
  85. public ActionResult DelBlack()
  86. {
  87. //if (Request.IsAuthenticated)
  88. //{
  89. string tel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));
  90. Model.T_Call_Blacklist dModel = new BLL.T_Call_Blacklist().GetModelList(" F_TelPhone='" + tel + "' ").FirstOrDefault();
  91. if (dModel != null)
  92. {
  93. bool bl = new BLL.T_Call_Blacklist().Delete(dModel.F_BlackId);
  94. if (bl)
  95. {
  96. return Success("取消成功");
  97. }
  98. }
  99. return Success("找不到此记录");
  100. // }
  101. // return NoToken("未知错误,请重新登录");
  102. }
  103. /// <summary>
  104. /// 根据来电号码获取客户信息
  105. /// </summary>
  106. /// <returns></returns>
  107. public ActionResult GetCustomerByTel()
  108. {
  109. if (Request.IsAuthenticated)
  110. {
  111. //DataTable dt = new DataTable();
  112. string tel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));
  113. BLL.T_Cus_CustomerBase bll = new BLL.T_Cus_CustomerBase();
  114. //dt = bll.GetList(" F_Telephone like '%" + tel + "%' or F_Mobile like '%" + tel + "%' ").Tables[0];
  115. //20180509 来电弹屏一个号码弹两个客户信息 machenyang
  116. var cusmodel = bll.GetModelList(" F_Telephone like '%" + tel + "%' or F_Mobile like '%" + tel + "%' ").Count() == 0 ? null : bll.GetModelList(" F_Telephone like '%" + tel + "%' or F_Mobile like '%" + tel + "%' ").OrderByDescending(p => p.F_CustomerId).First();
  117. return Success("客户信息加载成功", cusmodel);
  118. }
  119. return NoToken("未知错误,请重新登录");
  120. }
  121. /// <summary>
  122. /// 根据来电号码获取最近的callid
  123. /// </summary>
  124. /// <returns></returns>
  125. public ActionResult GetCallIdByPhone()
  126. {
  127. if (Request.IsAuthenticated)
  128. {
  129. DataTable dt = new DataTable();
  130. string tel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));
  131. Model.T_Call_CallRecords model = new BLL.T_Call_CallRecords().GetModelByTelphone(tel);
  132. return Success("加载成功", model);
  133. }
  134. return NoToken("未知错误,请重新登录");
  135. }
  136. /// <summary>
  137. /// 根据callid获取最近的通话记录
  138. /// </summary>
  139. /// <returns></returns>
  140. public ActionResult GetTelRecordByCallid()
  141. {
  142. if (Request.IsAuthenticated)
  143. {
  144. DataTable dt = new DataTable();
  145. string callid = HttpUtility.UrlDecode(RequestString.GetQueryString("callid"));
  146. Model.T_Call_CallRecords model = new BLL.T_Call_CallRecords().GetModelByCallId(callid);
  147. return Success("通话记录加载成功", model);
  148. }
  149. return NoToken("未知错误,请重新登录");
  150. }
  151. /// <summary>
  152. /// 来电归属地查询
  153. /// </summary>
  154. /// <returns></returns>
  155. public ActionResult GetPhoneLocation()
  156. {
  157. if (Request.IsAuthenticated)
  158. {
  159. string location = "未知";
  160. string tel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));
  161. if (tel.Trim().Length == 12)
  162. {
  163. BLL.T_Sys_MobileData mobile_Bll = new BLL.T_Sys_MobileData();
  164. Model.T_Sys_MobileData mobileModel = mobile_Bll.GetModelList(" F_MobileNum='" + tel.Substring(1, 7) + "' ").FirstOrDefault();
  165. if (mobileModel != null)
  166. {
  167. location = mobileModel.F_CityDes + mobileModel.F_CardDes;
  168. }
  169. else
  170. {
  171. var PhoneNumber = MobiledataController.GetDetails(tel.Substring(1, 11));
  172. if (PhoneNumber != null&& PhoneNumber.Count >0)
  173. {
  174. Model.T_Sys_MobileData dModel = new Model.T_Sys_MobileData();
  175. dModel.F_MobileNum = tel.Substring(1, 7);
  176. var model = new BLL.T_Sys_MobileData().GetList(1, "F_CityDes='" + PhoneNumber["省份"] + "-" + PhoneNumber["市区"] + "' and F_IsDelete=0", "F_Id desc ");
  177. if (model != null)
  178. dModel.F_ZipCode = model.FirstOrDefault().F_ZipCode;
  179. dModel.F_CityDes = PhoneNumber["省份"] + "-" + PhoneNumber["市区"];
  180. dModel.F_CardDes = PhoneNumber["电信运营商"];
  181. dModel.F_IsDelete = 0;
  182. dModel.F_CreateUser = "8000";
  183. dModel.F_CreateTime = DateTime.Now;
  184. int t = new BLL.T_Sys_MobileData().Add(dModel);
  185. if (t > 0)
  186. {
  187. location = dModel.F_CityDes + dModel.F_CardDes;
  188. }
  189. }
  190. else
  191. {
  192. BLL.T_Sys_TelTitleData numbBll = new BLL.T_Sys_TelTitleData();
  193. List<Model.T_Sys_TelTitleData> mobileModel1 = numbBll.GetModelList(" F_KeyPhoneNum='" + tel.Substring(0, 4) + "'");
  194. if (mobileModel1 == null || mobileModel1.Count <= 0)
  195. {
  196. mobileModel1 = numbBll.GetModelList(" F_KeyPhoneNum='" + tel.Substring(0, 3) + "'");
  197. }
  198. if (mobileModel1.Count > 0)
  199. {
  200. location = mobileModel1[0].F_TitleName;
  201. }
  202. }
  203. }
  204. }
  205. else
  206. {
  207. if (tel.Trim().Length == 11 && tel.Substring(0, 1) != "0")
  208. {
  209. BLL.T_Sys_MobileData mobile_Bll = new BLL.T_Sys_MobileData();
  210. Model.T_Sys_MobileData mobileModel = mobile_Bll.GetModelList(" F_MobileNum='" + tel.Substring(0, 7) + "' ").FirstOrDefault();
  211. if (mobileModel != null)
  212. {
  213. location = mobileModel.F_CityDes + mobileModel.F_CardDes;
  214. }
  215. else
  216. {
  217. var PhoneNumber = MobiledataController .GetDetails (tel.Substring(0, 10));
  218. if (PhoneNumber != null && PhoneNumber.Count > 0)
  219. {
  220. Model.T_Sys_MobileData dModel = new Model.T_Sys_MobileData();
  221. dModel.F_MobileNum = tel.Substring(0, 7);
  222. var model = new BLL.T_Sys_MobileData().GetList(1, "F_CityDes='" + PhoneNumber["省份"] + "-" + PhoneNumber["市区"] + "' and F_IsDelete=0", "F_Id desc ");
  223. if (model != null)
  224. dModel.F_ZipCode = model.FirstOrDefault().F_ZipCode;
  225. dModel.F_CityDes = PhoneNumber["省份"] + "-" + PhoneNumber["市区"];
  226. dModel.F_CardDes = PhoneNumber["电信运营商"];
  227. dModel.F_IsDelete = 0;
  228. dModel.F_CreateUser = "8000";
  229. dModel.F_CreateTime = DateTime.Now;
  230. int t = new BLL.T_Sys_MobileData().Add(dModel);
  231. if (t > 0)
  232. {
  233. location = dModel.F_CityDes + dModel.F_CardDes;
  234. }
  235. }
  236. }
  237. }
  238. else
  239. {
  240. if (tel.Trim().Length > 3)
  241. {
  242. BLL.T_Sys_TelTitleData numbBll = new BLL.T_Sys_TelTitleData();
  243. List<Model.T_Sys_TelTitleData> mobileModel = numbBll.GetModelList(" F_KeyPhoneNum='" + tel.Substring(0, 4) + "'");
  244. if (mobileModel == null || mobileModel.Count <= 0)
  245. {
  246. mobileModel = numbBll.GetModelList(" F_KeyPhoneNum='" + tel.Substring(0, 3) + "'");
  247. }
  248. if (mobileModel.Count > 0)
  249. {
  250. location = mobileModel[0].F_TitleName;
  251. }
  252. }
  253. }
  254. }
  255. return Success("归属地加载成功", location);
  256. }
  257. return NoToken("未知错误,请重新登录");
  258. }
  259. /// <summary>
  260. /// 历史记录列表
  261. /// </summary>
  262. /// <returns></returns>
  263. public ActionResult GetOldList()
  264. {
  265. if (Request.IsAuthenticated)
  266. {
  267. int userId = CurrentUser.UserData.F_UserId;
  268. if (userId != 0)
  269. {
  270. Model.T_Sys_UserAccount ua = new BLL.T_Sys_UserAccount().GetModel(userId);
  271. if (ua != null)
  272. {
  273. string sql = "";
  274. string sqlcount = "";
  275. DataTable dt = new DataTable();
  276. //来电号码
  277. string strtel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));
  278. string strcalltype = HttpUtility.UrlDecode(RequestString.GetQueryString("calltype"));
  279. string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
  280. string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
  281. string strpageindex = RequestString.GetQueryString("page");
  282. int pageindex = 1;
  283. string strpagesize = RequestString.GetQueryString("pagesize");
  284. int pagesize = 10;
  285. //除管理员外,各坐席只能看到自己的
  286. //20180507 每个人都能看到该来电的所有历史记录 machenyang
  287. //if (ua.F_RoleId != 17)
  288. // sql += " and UserId = '" + userId + "'";
  289. ////20180514 坐席能看到同组的
  290. //var usergroup = ua.F_SeartGroup;
  291. //var usercodes = new BLL.T_Sys_UserAccount().GetModelList("F_SeartGroup='" + usergroup + "'") == null ? null : new BLL.T_Sys_UserAccount().GetModelList("F_SeartGroup='" + usergroup + "'").Select(p => p.F_UserCode);
  292. //var str = "";
  293. //if (usercodes != null)
  294. //{
  295. // foreach (var item in usercodes)
  296. // {
  297. // str += item.ToString() + ',';
  298. // }
  299. // str = str.TrimEnd(',');
  300. // sql += " and UserCode in ("+str+") ";
  301. //}
  302. //else
  303. // sql += " and UserCode='"+ua.F_UserCode+"' ";
  304. #region 2018-05-30 lihai 坐席能看到同组的通话记录
  305. int seartGroupId = ua.F_SeartGroupID ?? 0;
  306. if (seartGroupId != 0)
  307. {
  308. //groupcode判断是市场部或客服部的通话记录
  309. var modelSeartGroup = new BLL.T_Sys_SeatGroup().GetModel(seartGroupId);
  310. if (modelSeartGroup != null)
  311. {
  312. sql += " and groupcode = '" + modelSeartGroup.F_ZXZCode + "' ";
  313. //if (modelSeartGroup.F_ZXZCode == "SCZ")
  314. //{
  315. // sql += " and groupcode = 'SCZ' ";
  316. //}
  317. //else
  318. //{
  319. // sql += " and groupcode = 'KFZ' ";
  320. //}
  321. }
  322. //else
  323. // sql += " and UserCode='" + ua.F_UserCode + "' ";
  324. }
  325. else
  326. {
  327. //找不到对应坐席组
  328. sql += " and UserCode='" + ua.F_UserCode + "' ";
  329. }
  330. #endregion
  331. if (strcalltype.Trim() != "" && strcalltype != "undefined")
  332. {
  333. sql += " and CallType=" + strcalltype + " ";
  334. }
  335. if (strtel.Trim() != "" && strtel != "undefined")
  336. {
  337. sql += " and CallNumber= '" + strtel.Trim() + "' ";
  338. sqlcount += " and CallNumber= '" + strtel.Trim() + "' ";
  339. }
  340. //else
  341. //{
  342. // sql += " and 1=0 ";
  343. //}
  344. if (strstarttime.Trim() != "" && strstarttime != "undefined")
  345. {
  346. sql += " and datediff(day,BeginTime,'" + strstarttime + "')<=0 ";
  347. sqlcount += " and datediff(day,BeginTime,'" + strstarttime + "')<=0 ";
  348. }
  349. if (strendtime.Trim() != "" && strendtime != "undefined")
  350. {
  351. sql += " and datediff(day,BeginTime,'" + strendtime + "')>=0 ";
  352. sqlcount += " and datediff(day,BeginTime,'" + strendtime + "')>=0 ";
  353. }
  354. if (strpageindex.Trim() != "")
  355. {
  356. pageindex = Convert.ToInt32(strpageindex);
  357. }
  358. if (strpagesize.Trim() != "")
  359. {
  360. pagesize = Convert.ToInt32(strpagesize);
  361. }
  362. int recordCount = 0;
  363. dt = BLL.PagerBLL.GetListPager(
  364. "T_Call_CallRecords WITH(NOLOCK)",
  365. "CallRecordsId",
  366. "*",
  367. sql,
  368. "ORDER BY CallRecordsId desc",
  369. pagesize,
  370. pageindex,
  371. true,
  372. out recordCount);
  373. dt.Columns.Add("CusName");
  374. dt.Columns.Add("CusDepName");
  375. var config = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='PlayPath' ").FirstOrDefault();
  376. var listCustomer = new BLL.T_Cus_CustomerBase().GetModelList(" F_DeleteFlag=0 ");
  377. foreach (DataRow dr in dt.Rows)
  378. {
  379. string path = dr["FilePath"] != null ? dr["FilePath"].ToString() : "";
  380. if (path != "" && config != null && !string.IsNullOrEmpty(config.F_ParamValue))
  381. {
  382. var ym = config.F_ParamValue;
  383. if (ym.Substring(ym.Length - 1) == "/")
  384. {
  385. ym = ym.Substring(0, ym.Length - 1);
  386. }
  387. dr["FilePath"] = ym + path.Substring(path.IndexOf(':') + 1).Replace('\\', '/');
  388. }
  389. var modelCustomer = listCustomer.FirstOrDefault(x => x.F_Telephone == dr["CallNumber"].ToString());
  390. if (modelCustomer != null)
  391. {
  392. dr["CusName"] = modelCustomer.F_CustomerName; //客户姓名
  393. dr["CusDepName"] = modelCustomer.F_CustomerIndustry; //来电单位
  394. }
  395. }
  396. int hrcount = new BLL.T_Call_CallRecords().GetRecordCount(" calltype=0 " + sqlcount);
  397. int hccount = new BLL.T_Call_CallRecords().GetRecordCount(" calltype=1 " + sqlcount);
  398. var obj = new
  399. {
  400. state = "success",
  401. message = "成功",
  402. rows = dt,
  403. total = recordCount,
  404. hrcount = hrcount,
  405. hccount = hccount,
  406. };
  407. return Content(obj.ToJson());
  408. }
  409. }
  410. }
  411. return NoToken("未知错误,请重新登录");
  412. }
  413. /// <summary>
  414. /// 获取最新知识库
  415. /// </summary>
  416. /// <returns></returns>
  417. public ActionResult GetZSKList()
  418. {
  419. if (Request.IsAuthenticated)
  420. {
  421. DataTable dt = new DataTable();
  422. string pid = HttpUtility.UrlDecode(RequestString.GetQueryString("pid"));
  423. string keywords = HttpUtility.UrlDecode(RequestString.GetQueryString("keywords"));
  424. string sql = " F_DeleteFlag=0";
  425. if (pid.Trim() != "")
  426. {
  427. sql += " and F_CategoryId=" + pid.Trim();
  428. }
  429. if (keywords.Trim() != "")
  430. {
  431. sql += " and (F_Content like '%" + keywords.Trim() + "%' or F_Title like '%"
  432. + keywords.Trim() + "%' or F_KeyWords like '%" + keywords.Trim() + "%')";
  433. }
  434. dt = new BLL.T_RepositoryInformation().GetList(8, sql, " F_RepositoryId desc").Tables[0];
  435. return Success("加载成功", dt);
  436. }
  437. return NoToken("未知错误,请重新登录");
  438. }
  439. /// <summary>
  440. /// 振铃事件
  441. /// </summary>
  442. /// <returns></returns>
  443. public ActionResult UpdateZL()
  444. {
  445. if (Request.IsAuthenticated)
  446. {
  447. int userId = CurrentUser.UserData.F_UserId;
  448. if (userId != 0)
  449. {
  450. Model.T_Sys_UserAccount ua = new BLL.T_Sys_UserAccount().GetModel(userId);
  451. if (ua != null)
  452. {
  453. Model.T_Call_CallRecords model = new Model.T_Call_CallRecords();
  454. model.CallId = RequestString.GetFormString("callid");
  455. //model.UserId = ua.F_UserId;
  456. //model.UserCode = ua.F_UserCode;
  457. //model.UserName = ua.F_UserName;
  458. ////model.ExtNumber = ua.F_WorkNumber;
  459. //model.ExtNumber = CurrentUser.UserData.F_ExtensionNumber;
  460. model.DealType = 5;
  461. bool bl = new BLL.T_Call_CallRecords().UpdateCallInRingTelRecord(model);
  462. if (bl)
  463. {
  464. return Success("更新振铃状态成功");
  465. }
  466. else
  467. {
  468. // return Error("更新振铃状态失败");
  469. return Success("更新振铃状态失败");
  470. }
  471. }
  472. }
  473. }
  474. return NoToken("未知错误,请重新登录");
  475. }
  476. /// <summary>
  477. /// 摘机事件
  478. /// </summary>
  479. /// <returns></returns>
  480. public ActionResult UpdateZJ()
  481. {
  482. if (Request.IsAuthenticated)
  483. {
  484. Model.T_Call_CallRecords model = new Model.T_Call_CallRecords();
  485. model.CallId = RequestString.GetFormString("callid");
  486. model.CallState = 1;
  487. model.DealType = 6;
  488. bool bl = new BLL.T_Call_CallRecords().UpdateCallInAnswerTelRecord(model);
  489. if (bl)
  490. {
  491. Model.T_Call_CallRecords vmodel = new BLL.T_Call_CallRecords().GetModelByCallId(model.CallId);
  492. string type = vmodel.OperateType.ToString();
  493. if (type == "7")
  494. {
  495. new BLL.T_Call_TaskTelNum().UpdateYJ(Convert.ToInt32(vmodel.OperateObject.ToString()), 1);
  496. }
  497. return Success("更新摘机状态成功");
  498. }
  499. else
  500. {
  501. //return Error("更新摘机状态失败");
  502. return Success("更新摘机状态失败");
  503. }
  504. }
  505. return NoToken("未知错误,请重新登录");
  506. }
  507. /// <summary>
  508. /// 挂机事件
  509. /// </summary>
  510. /// <returns></returns>
  511. public ActionResult UpdateGJ()
  512. {
  513. if (Request.IsAuthenticated)
  514. {
  515. return Success("更新挂机状态成功");
  516. //string strid = RequestString.GetFormString("callid");
  517. //bool bl = new BLL.T_Call_CallRecords().UpdateCallInHookTelRecord(strid);
  518. //if (bl)
  519. //{
  520. // return Success("更新挂机状态成功");
  521. //}
  522. //else
  523. //{
  524. // return Success("更新挂机状态失败");
  525. //}
  526. }
  527. return NoToken("未知错误,请重新登录");
  528. }
  529. /// <summary>
  530. /// 录音事件
  531. /// </summary>
  532. /// <returns></returns>
  533. public ActionResult UpdateLY(string callid)
  534. {
  535. if (Request.IsAuthenticated)
  536. {
  537. Model.T_Call_CallRecords vmodel = new BLL.T_Call_CallRecords().GetModelByCallId(callid);
  538. if (vmodel!=null)
  539. {
  540. string type = vmodel.OperateType.ToString();
  541. if (type == "7")
  542. {
  543. new BLL.T_Call_TaskTelNum().UpdateYJ(Convert.ToInt32(vmodel.OperateObject.ToString()), 1);
  544. }
  545. }
  546. return Success("更新挂机状态成功");
  547. //Model.T_Call_CallRecords model = new Model.T_Call_CallRecords();
  548. //model.CallId = RequestString.GetFormString("callid");
  549. //model.CallState = 1;
  550. //model.DealType = 6;
  551. ////model.FilePath = RequestString.GetFormString("path");
  552. //bool bl = new BLL.T_Call_CallRecords().UpdateCallInPathTelRecord(model);
  553. //if (bl)
  554. //{
  555. // Model.T_Call_CallRecords vmodel = new BLL.T_Call_CallRecords().GetModelByCallId(model.CallId);
  556. // string type = vmodel.OperateType.ToString();
  557. // if (type == "7")
  558. // {
  559. // new BLL.T_Call_TaskTelNum().UpdateYJ(Convert.ToInt32(vmodel.OperateObject.ToString()), 1);
  560. // }
  561. // return Success("更新挂机状态成功");
  562. //}
  563. //else
  564. //{
  565. // return Success("更新挂机状态失败");
  566. //}
  567. }
  568. return NoToken("未知错误,请重新登录");
  569. }
  570. /// <summary>
  571. /// 创建工单
  572. /// </summary>
  573. /// <returns></returns>
  574. public ActionResult AddWorkOrder()
  575. {
  576. if (Request.IsAuthenticated)
  577. {
  578. int userId = CurrentUser.UserData.F_UserId;
  579. if (userId != 0)
  580. {
  581. Model.T_Sys_UserAccount ua = new BLL.T_Sys_UserAccount().GetModel(userId);
  582. if (ua != null)
  583. {
  584. //姓名
  585. string callCustomer = RequestString.GetFormString("callCustomer");
  586. //电话
  587. string tel = RequestString.GetFormString("tel");
  588. //来电所在省份
  589. string prov = RequestString.GetFormString("province");
  590. //来电单位
  591. string lddep = RequestString.GetFormString("lddep");
  592. //反馈单位
  593. string fkdep = RequestString.GetFormString("fkdep");
  594. //工单来源
  595. int gdly = RequestString.GetFormInt("gdly", 0);
  596. //工单类型
  597. int gdlx = RequestString.GetFormInt("gdlx", 0);
  598. //工单状态 471 默认未处理
  599. int gdzt = RequestString.GetFormInt("gdzt", 471);
  600. //反馈内容
  601. string fkcont = RequestString.GetFormString("fkcont");
  602. //快递信息
  603. string sendmsg = RequestString.GetFormString("sendmsg");
  604. //备注1
  605. string note1 = RequestString.GetFormString("note1");
  606. //备注2
  607. string note2 = RequestString.GetFormString("note2");
  608. //备注3
  609. string note3 = RequestString.GetFormString("note3");
  610. //callID
  611. string callid = HttpUtility.UrlDecode(RequestString.GetFormString("callid"));
  612. if(string.IsNullOrEmpty(callCustomer))
  613. return Error("姓名不能为空!");
  614. if (string.IsNullOrEmpty(tel))
  615. return Error("电话不能为空!");
  616. if (string.IsNullOrEmpty(lddep))
  617. return Error("来电单位不能为空!");
  618. Model.T_Wo_WorkOrder model = new Model.T_Wo_WorkOrder();
  619. model.WorkOrderID = DateTime.Now.ToString("yyyyMMddHHmmssms");//工单编号
  620. model.Customer = callCustomer;
  621. model.CustomerTel = tel;
  622. //将省份放入工单
  623. model.CreateUserID = prov;
  624. //工单来源
  625. model.Type = gdly;
  626. //工单类型
  627. model.TypeClass = gdlx;
  628. //反馈内容
  629. //var detailutf8 = System.Web.HttpUtility.UrlDecode(fkcont, System.Text.Encoding.UTF8);
  630. var detailutf8 = System.Web.HttpUtility.HtmlDecode(fkcont);
  631. model.Detail = detailutf8;
  632. //快递信息
  633. model.Files = sendmsg;
  634. //备注一
  635. model.County = note1;
  636. //备注二
  637. model.Province = note2;
  638. //备注三
  639. model.City = note3;
  640. //默认为未处理
  641. int gdstate = 0;
  642. string dep = DbHelperSQL.GetSingle("select F_ZXZName from [dbo].[T_Sys_SeatGroup],T_Sys_UserAccount where T_Sys_UserAccount.F_SeartGroupID =[dbo].[T_Sys_SeatGroup].F_ZXZID and F_UserCode ='" + ua.F_UserCode + "' ").ToString();
  643. if (dep.Contains("市场"))
  644. {
  645. if (string.IsNullOrEmpty(fkcont.Trim()))
  646. gdstate = 1;
  647. }
  648. else
  649. {
  650. if (gdzt != 471)
  651. gdstate = 1;
  652. }
  653. model.State = gdstate;
  654. if (gdstate == 1)//如果直接为已处理 需要将lastdealuser改为当前坐席
  655. model.LastDealUser = ua.F_UserCode;
  656. model.IsDel = 0;
  657. model.IsReturn = 0;
  658. model.IsReturnBak = 0;
  659. model.ResponDept = 0;
  660. model.Answer = "";
  661. model.IsTimeOut = 0;
  662. model.IsUserSend = 0;
  663. model.IsAdminSend = 0;
  664. ////原——将新增的工单插入待指派表中
  665. //Model.T_Wo_WorkOrderTimeOut to = new BLL.T_Wo_WorkOrderTimeOut().GetModel(gdlx);
  666. //if (to != null)
  667. //{
  668. // model.LimitTime = to.MainTime;
  669. //}
  670. //存入callid
  671. model.CallID = callid;
  672. //来电单位 反馈单位
  673. model.Address = lddep;
  674. model.Source = fkdep;
  675. model.CreateUser = ua.F_UserCode;
  676. model.CreateTime = DateTime.Now;
  677. //if (clbm != 0 || clid != 0)
  678. //{
  679. // Model.T_Wo_WorkOrderItem item = new Model.T_Wo_WorkOrderItem();
  680. // item.WorkOrderID = model.WorkOrderID;
  681. // item.ToDept = clbm;
  682. // item.Type = 1;
  683. // if (clid != 0)
  684. // {
  685. // Model.T_Sys_UserAccount clus = new BLL.T_Sys_UserAccount().GetModel(clid);
  686. // if (clus != null)
  687. // {
  688. // item.ToUser = clus.F_UserCode;
  689. // }
  690. // }
  691. // else
  692. // {
  693. // string users = string.Empty;
  694. // var list = new BLL.T_Sys_UserAccount().GetModelList(" F_DeptId='" + clbm + "'");
  695. // foreach (var l in list)
  696. // {
  697. // if (string.IsNullOrEmpty(users))
  698. // {
  699. // users = l.F_UserCode;
  700. // }
  701. // else
  702. // {
  703. // users = users + "," + l.F_UserCode;
  704. // }
  705. // }
  706. // item.ToUser = users;
  707. // }
  708. // if (to != null)
  709. // {
  710. // item.LimitTime = to.ItemTime;
  711. // }
  712. // item.Detail = answer;
  713. // item.IsLast = 0;
  714. // item.State = 0;
  715. // item.IsStart = 0;
  716. // item.IsTimeOut = 0;
  717. // item.IsDel = 0;
  718. // item.CreateUser = ua.F_UserCode;
  719. // item.CreateTime = DateTime.Now;
  720. // long itemid = new BLL.T_Wo_WorkOrderItem().Add(item);
  721. // if (itemid > 0)
  722. // {
  723. // model.State = 1;//已指派
  724. // model.AppointTime = DateTime.Now;
  725. // #region 消息表
  726. // foreach (string ur in item.ToUser.Split(','))
  727. // {
  728. // Model.T_Msg_List msg = new Model.T_Msg_List();
  729. // msg.Type = 1;
  730. // msg.ToUser = ur;
  731. // msg.ToID = Int32.Parse(itemid.ToString());
  732. // msg.Detail = ua.F_UserName + "给你指派了工单,单号:" + model.WorkOrderID;
  733. // msg.State = 0;
  734. // msg.IsDel = 0;
  735. // msg.CreateUser = ua.F_UserCode;
  736. // msg.CreateDate = DateTime.Now;
  737. // new BLL.T_Msg_List().Add(msg);
  738. // }
  739. // #endregion
  740. // }
  741. //}
  742. if (new BLL.T_Wo_WorkOrder().Add(model) > 0)
  743. {
  744. if (!string.IsNullOrEmpty(callid))
  745. {
  746. var rec = new BLL.T_Call_CallRecords().GetModelByCallId(callid);
  747. if (rec != null)
  748. {
  749. rec.IsExitWorkOrder = true;
  750. new BLL.T_Call_CallRecords().Update(rec);
  751. }
  752. }
  753. #region 将不存在的客户保存到客户基础信息中。
  754. //如果客户不存在,需要同时添加到客户基础信息表中,存在则修改
  755. Model.T_Cus_CustomerBase userModel = new BLL.T_Cus_CustomerBase().GetModel(tel);
  756. if (userModel == null)
  757. {
  758. int cusid = new BLL.T_Cus_CustomerBase().Add(new Model.T_Cus_CustomerBase()
  759. {
  760. F_CustomerName = callCustomer,
  761. F_Mobile = tel,
  762. F_Telephone = tel,
  763. F_CreateBy = userId,
  764. F_CreatedOn = DateTime.Now,
  765. F_DeleteFlag = 0,
  766. F_Province = prov,
  767. F_CustomerIndustry = lddep,
  768. F_RelationShipClass = fkdep
  769. });
  770. //if (cusid > 0)
  771. // return Success("新增成功!");
  772. }
  773. else
  774. {
  775. userModel.F_Province = prov;
  776. userModel.F_CustomerIndustry = lddep;
  777. userModel.F_RelationShipClass = fkdep;
  778. userModel.F_CustomerName = callCustomer;
  779. userModel.F_Mobile = tel;
  780. userModel.F_Telephone = tel;
  781. new BLL.T_Cus_CustomerBase().Update(userModel);
  782. }
  783. #endregion
  784. #region 新增工单后新的单位要保存到反馈单位和来电单位中
  785. List<string> lddep_cache = null;
  786. lddep_cache = CacheHelper.Get("LDDep") as List<string>;
  787. if (lddep_cache != null && lddep_cache.Count > 0)
  788. {
  789. if (!lddep_cache.Contains(lddep))
  790. lddep_cache.Add(lddep);
  791. if (!lddep_cache.Contains(fkdep))
  792. lddep_cache.Add(fkdep);
  793. CacheHelper.Insert("LDDep", lddep_cache);
  794. }
  795. else
  796. {
  797. lddep_cache = new BLL.T_Cus_CustomerBase().GetLDdep();
  798. var gdlddep = new BLL.T_Wo_WorkOrder().GetModelList("1=1").Select(p => p.Address).Distinct().ToList();//从工单来电单位中加载
  799. var gdfkdep = new BLL.T_Wo_WorkOrder().GetModelList("1=1").Select(p => p.Source).Distinct().ToList();//从工单反馈单位中加载
  800. foreach (var item in gdlddep)
  801. {
  802. if (!lddep.Contains(item))
  803. lddep_cache.Add(item);
  804. }
  805. foreach (var item in gdfkdep)
  806. {
  807. if (!lddep.Contains(item))
  808. lddep_cache.Add(item);
  809. }
  810. if (lddep_cache != null && lddep_cache.Count > 0)
  811. {
  812. if (!lddep_cache.Contains(lddep))
  813. lddep_cache.Add(lddep);
  814. if (!lddep_cache.Contains(fkdep))
  815. lddep_cache.Add(fkdep);
  816. CacheHelper.Insert("LDDep", lddep_cache);
  817. }
  818. else
  819. return Error("获取失败,没有对应数据");
  820. }
  821. #endregion
  822. return Success("新增成功!");
  823. }
  824. else
  825. {
  826. return Error("新增失败!");
  827. }
  828. #region no use
  829. //Model.T_Wo_WorkOrderBase model = new Model.T_Wo_WorkOrderBase();
  830. //model.F_CODE = DateTime.Now.ToString("yyyyMMddHHmmssms");//工单编号
  831. //model.F_WORKORDERTYPEID = type;
  832. //model.F_WORKORDERSTATEID = 0;
  833. //model.F_WORKORDERNAME = "";
  834. //model.F_WORKORDERFROM = "";
  835. //model.F_WORKORDERLEVELID = 0;
  836. //model.F_ADSLACCOUNT = callid;
  837. ////model.F_USERID = ua.F_UserId;
  838. ////model.F_USERNAME = ua.F_UserName;
  839. ////model.F_USERPHONE = ua.F_WorkNumber;
  840. //model.F_TypeName = "";
  841. //model.F_STARTTIME = DateTime.Now;
  842. //model.F_RETURNVISITFLAG = 0;
  843. //model.F_LINKMANTELEPHONE = tsdh;
  844. //model.F_LINKMAN = tskh;
  845. //model.F_DELETEFLAG = 0;
  846. //model.F_CUSTOMERTELEPHONE = tsdh;
  847. //model.F_CUSTOMERNAME = tskh;
  848. //model.F_CUSTOMERID = 0;//待实现
  849. //model.F_CREATEDATE = DateTime.Now;
  850. //model.F_CREATEBY = ua.F_UserId;
  851. //model.F_CONTENT = cont;
  852. //model.F_REPAIRMANNAME = tskh;
  853. //model.F_REPAIRMANPHONE = tsdh;
  854. //if (new BLL.T_Wo_WorkOrderBase().Add(model) > 0)
  855. //{
  856. // return Success("新增成功!");
  857. //}
  858. //else
  859. //{
  860. // return Error("新增失败!");
  861. //}
  862. #endregion
  863. }
  864. }
  865. }
  866. return NoToken("未知错误,请重新登录");
  867. }
  868. /// <summary>
  869. /// 获取当前坐席所在部门及坐席组
  870. /// </summary>
  871. /// <returns></returns>
  872. public ActionResult GetCurrUserDep()
  873. {
  874. if (Request.IsAuthenticated)
  875. {
  876. int? groid = CurrentUser.UserData.F_SeartGroupID;
  877. //string groname = CurrentUser.UserData.F_SeartGroup;
  878. string groname = "";
  879. string depname = "";
  880. int depid = CurrentUser.UserData.F_DeptId;
  881. if (depid != 0)
  882. {
  883. Model.T_Sys_Department depModel = new BLL.T_Sys_Department().GetModel(depid);
  884. if (depModel != null)
  885. {
  886. depname = depModel.F_DeptName;
  887. Model.T_Sys_SeatGroup groModel = new BLL.T_Sys_SeatGroup().GetModel(groid == null ? 0 : int.Parse(groid.ToString()));
  888. if (groModel != null)
  889. {
  890. groname = groModel.F_ZXZName;
  891. }
  892. }
  893. }
  894. var obj = new
  895. {
  896. depid = depid,
  897. depname = depname,
  898. groid = groid,
  899. groname = groname
  900. };
  901. return Success("获取坐席部门成功!", obj);
  902. }
  903. return NoToken("未知错误,请重新登录");
  904. }
  905. /// <summary>
  906. /// 获取所有坐席
  907. /// </summary>
  908. /// <returns></returns>
  909. public ActionResult GetUsers()
  910. {
  911. if (Request.IsAuthenticated)
  912. {
  913. int depid = CurrentUser.UserData.F_DeptId;
  914. List<Model.T_Sys_UserAccount> userModel = new BLL.T_Sys_UserAccount().GetModelList($"F_DeleteFlag=0 and F_DeptId = {depid} ");
  915. var list = userModel.Select(p => new { p.F_UserId, p.F_UserCode, p.F_UserName });
  916. var obj = new
  917. {
  918. user = list
  919. };
  920. return Success("获取坐席成功!", obj);
  921. }
  922. return NoToken("未知错误,请重新登录");
  923. }
  924. }
  925. }