郑许地铁

CustomerController.cs 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. using Newtonsoft.Json;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Web;
  7. using System.Web.Mvc;
  8. using ZXDT.CallCenter.Model;
  9. using ZXDT.CallCenter.MVCWeb.Models;
  10. namespace ZXDT.CallCenter.MVCWeb.Controllers
  11. {
  12. public class CustomerController : BaseController
  13. {
  14. //
  15. // GET: /Customer/
  16. BLL.T_Cus_CustomerBase cusBLL = new BLL.T_Cus_CustomerBase();
  17. public ActionResult CustomerAllList(int cusType)
  18. {
  19. CusPageModel model = new CusPageModel();
  20. model.cusType = cusType;
  21. return View(model);
  22. }
  23. /// <summary>
  24. /// 添加修改 视图
  25. /// </summary>
  26. /// <returns></returns>
  27. public ActionResult Add()
  28. {
  29. return View();
  30. }
  31. /// <summary>
  32. /// 保存用户信息
  33. /// </summary>
  34. /// <param name="workOrderBaseModel"></param>
  35. /// <returns></returns>
  36. [AcceptVerbs(HttpVerbs.Post)]
  37. public string AddData(T_Cus_CustomerBase CustomerBaseModel)
  38. {
  39. //客户属性
  40. bool bl = false;
  41. if (string.IsNullOrWhiteSpace(CustomerBaseModel.F_Telephone))
  42. {
  43. return Error("手机号不能为空");
  44. }
  45. if (string.IsNullOrEmpty(CustomerBaseModel.F_Kind))
  46. {
  47. CustomerBaseModel.F_Kind = "2";
  48. }
  49. if (string.IsNullOrEmpty(CustomerBaseModel.F_CustomerNature))
  50. {
  51. CustomerBaseModel.F_CustomerNature = "微信";
  52. }
  53. if (CustomerBaseModel.F_CustomerId > 0)
  54. {
  55. AddAction("t_cus_customerbase", CustomerBaseModel.F_CustomerId.ToMyString(), "更新客户信息", CustomerBaseModel.F_CustomerName.ToMyString());
  56. AddAction("t_cus_customerbase", CustomerBaseModel.F_CustomerId.ToMyString(), "更新客户信息", "数据:" + JsonConvert.SerializeObject(CustomerBaseModel), "关键信息");
  57. }
  58. else
  59. {
  60. ZXDT.CallCenter.Model.T_Cus_CustomerBase modelcus = cusBLL.GetCusInfoModel(CustomerBaseModel.F_Telephone);
  61. if (modelcus.F_CustomerId > 0)
  62. {
  63. return Error("此手机号已存在,请进行查询修改");
  64. }
  65. AddAction("t_cus_customerbase", CustomerBaseModel.F_Telephone, "添加客户信息", CustomerBaseModel.F_CustomerName.ToMyString());
  66. AddAction("t_cus_customerbase", CustomerBaseModel.F_Telephone, "添加客户信息", "数据:" + JsonConvert.SerializeObject(CustomerBaseModel), "关键信息");
  67. }
  68. if (CustomerBaseModel.F_ScaleResume == "3")
  69. {
  70. #region 添加到黑名单表
  71. try
  72. {
  73. string phone = CustomerBaseModel.F_Telephone;
  74. Model.T_Call_Blacklist orderModel = new Model.T_Call_Blacklist();
  75. orderModel.F_TelPhone = phone;
  76. orderModel.F_CallId = CustomerBaseModel.F_CustomerId.ToMyString();
  77. orderModel.F_SetTime = DateTime.Now;
  78. orderModel.F_RemoveTime = DateTime.Now.AddYears(10);
  79. orderModel.F_Describe = "客户id:" + CustomerBaseModel.F_CustomerId.ToMyString();
  80. orderModel.F_InterceptNum = 0;
  81. orderModel.F_UserId = F_UserID;
  82. int count = new BLL.T_Call_Blacklist().Add(orderModel);
  83. }
  84. catch
  85. { }
  86. #endregion
  87. }
  88. else
  89. {
  90. new BLL.T_Call_Blacklist().DeleteBlack(CustomerBaseModel.F_Telephone.Trim());
  91. }
  92. if (CustomerBaseModel.F_CustomerId > 0)
  93. { }
  94. else
  95. {
  96. CustomerBaseModel.F_CreateBy = F_UserID;
  97. }
  98. bl = cusBLL.UpdateCusInfoModel(CustomerBaseModel);
  99. if (bl)
  100. return Success("成功");
  101. else
  102. return Error("失败");
  103. }
  104. /// <summary>
  105. /// 客户状态修改
  106. /// </summary>
  107. /// <param name="model"></param>
  108. /// <returns></returns>
  109. public bool SaveReceivedData(string keyList, int status)
  110. {
  111. AddAction("t_cus_customerbase", keyList, "修改客户状态",status.ToMyString());
  112. AddAction("t_cus_customerbase", keyList, "修改客户状态", string.Format("修改{0}数据F_ScaleResume/F_CustomerClass状态为{1}" , keyList, status), "关键信息");
  113. return cusBLL.EditCustonStatus(keyList, status,F_UserID);
  114. }
  115. #region 加载客户列表
  116. /// <summary>
  117. /// 加载客户列表
  118. /// </summary>
  119. /// <param name="page">当前页码</param>
  120. /// <param name="limit">每页数据量</param>
  121. /// <param name="sqlWhere">查询条件</param>
  122. /// <returns></returns>
  123. [ActionName("LoadCustomerALLList")]
  124. [HttpGet]
  125. public string LoadCustomerALLList(DateTime? NowDateTime, string cusType, int page, int limit, string cusName, string cusNum)
  126. {
  127. //数据结果集
  128. ResponseData dataModel = new ResponseData();
  129. string sql = "";
  130. sql += " and F_DeleteFlag=0 ";
  131. //语音客户
  132. if (cusType == "1")
  133. {
  134. sql += " and F_Kind=1 ";
  135. }
  136. //微信客户
  137. if (cusType == "2")
  138. {
  139. sql += " and F_Kind=2 ";
  140. }
  141. //微博客户
  142. if (cusType == "3")
  143. {
  144. sql += " and F_Kind=3 ";
  145. }
  146. //特别客户
  147. if (cusType == "4")
  148. {
  149. sql += " and F_ScaleResume=2";
  150. }
  151. //白名单客户
  152. if (cusType == "6")
  153. {
  154. sql += " and F_ScaleResume=4";
  155. }
  156. if (!string.IsNullOrEmpty(cusName))
  157. {
  158. sql += " and F_CustomerName like '%" + cusName.Trim() + "%' ";
  159. }
  160. if (!string.IsNullOrEmpty(cusNum))
  161. {
  162. // sql += " and( F_Telephone like '%" + cusNum + "%' or F_Mobile like '%" + cusNum + "%' )";
  163. sql += " and F_Telephone like '%" + cusNum.Trim() + "%'";
  164. }
  165. //黑名单客户
  166. if (cusType == "5")
  167. {
  168. // sql += " and F_ScaleResume=3";
  169. int recordCountblack = 0;
  170. DataTable dtblack = new DataTable();
  171. //Model.PageData<Model.T_Cus_CustomerBase> pageModelblack = new Model.PageData<Model.T_Cus_CustomerBase>();
  172. string table = " (select t1.*,t2.F_UserId from T_Cus_CustomerBase t1 left join T_Call_Blacklist t2 on t1.F_CustomerId = t2.F_CallId where t1.F_DeleteFlag = 0 and t2.F_IsDelete = 0) t";
  173. dtblack = BLL.PagerBLL.GetListPager(
  174. table,
  175. "F_CustomerId",
  176. "*,CONVERT(varchar,F_ModifiedOn, 120 ) as F_ModifiedOnNew ,[dbo].[GetUserNameByUserID](F_UserId) F_CreateUserName",
  177. sql,
  178. "ORDER BY F_CustomerId desc",
  179. limit,
  180. page,
  181. true,
  182. out recordCountblack);
  183. dataModel.code = 0;
  184. dataModel.count = recordCountblack;
  185. dataModel.data = dtblack;
  186. return JsonConvert.SerializeObject(dataModel);
  187. }
  188. DataTable dt = new DataTable();
  189. int recordCount = 0;
  190. Model.PageData<Model.T_Cus_CustomerBase> pageModel = new Model.PageData<Model.T_Cus_CustomerBase>();
  191. dt = BLL.PagerBLL.GetListPager(
  192. "T_Cus_CustomerBase",
  193. "F_CustomerId",
  194. "*,CONVERT(varchar,F_ModifiedOn, 120 ) as F_ModifiedOnNew ,[dbo].[GetUserNameByUserID](F_CreateBy) F_CreateUserName" ,
  195. sql,
  196. "ORDER BY F_CustomerId desc",
  197. limit,
  198. page,
  199. true,
  200. out recordCount);
  201. dataModel.code = 0;
  202. dataModel.count = recordCount;
  203. dataModel.data = dt;
  204. return JsonConvert.SerializeObject(dataModel);
  205. }
  206. [ActionName("GetCustomerModel")]
  207. [HttpGet]
  208. public string GetCustomerModel(int id)
  209. {
  210. if (id == 0)
  211. {
  212. return Error("id不能为空");
  213. }
  214. BLL.T_Cus_CustomerBase busCus_CustomerBase = new BLL.T_Cus_CustomerBase();
  215. Model.T_Cus_CustomerBase model= busCus_CustomerBase.GetModel(id);
  216. int count = 0;
  217. if (model != null)
  218. count = 1;
  219. return Success("成功", model, count);
  220. }
  221. #endregion
  222. #region 客户工单信息
  223. /// <summary>
  224. /// 获取所有工单信息
  225. /// </summary>
  226. /// <returns></returns>
  227. public ActionResult CusOrderList(string callNumber)
  228. {
  229. ViewCusOrderModel cusModel = new ViewCusOrderModel();
  230. cusModel.F_Telephone = callNumber;
  231. cusModel.SeatFlag = F_SeatFlag;
  232. return View(cusModel);
  233. }
  234. /// <summary>
  235. /// 获取工单信息
  236. /// </summary>
  237. /// <param name="page">当前页码</param>
  238. /// <param name="limit">每页数据量</param>
  239. /// <param name="sqlWhere">查询条件</param>
  240. /// <returns></returns>
  241. [ActionName("CusOrderData")]
  242. [HttpGet]
  243. public string CusOrderData(int page, int limit, string cusNumber)
  244. {
  245. //数据结果集
  246. ResponseData dataModel = new ResponseData();
  247. string sql = "";
  248. //客户电话
  249. if (!string.IsNullOrEmpty(cusNumber))
  250. {
  251. sql += " and t.F_CUSTOMERTELEPHONE = '" + cusNumber.Trim() + "'";
  252. }
  253. else
  254. {
  255. sql += " and t.F_CUSTOMERTELEPHONE='-1'";
  256. }
  257. string tableNew = string.Format("(select DISTINCT t.* from T_Wo_WorkOrderBase t LEFT JOIN T_Wo_WorkOrderHistory h ON t.F_WORKORDERID=h.F_INSTANCEID LEFT JOIN T_Sys_UserAccount u ON t.F_USERID= u.F_UserId where (u.F_DeptId={0} OR h.F_OPTBTNID={0})) as t", F_DeptId);
  258. DataTable dt = new DataTable();
  259. int recordCount = 0;
  260. Model.PageData<Model.T_Wo_WorkOrderBase> pageModel = new Model.PageData<Model.T_Wo_WorkOrderBase>();
  261. dt = BLL.PagerBLL.GetListPager(
  262. tableNew,
  263. "F_WORKORDERID",
  264. " t.*,CONVERT(varchar,t.F_CREATEDATE, 120 ) as F_CREATEDATENew"
  265. + " ,(CASE F_WORKORDERFROM WHEN '留言工单' THEN (SELECT F_RecFileUrl FROM dbo.T_Call_LeaveRecord WHERE F_CallId=t.F_KSHADDRESSCODE) WHEN '语音工单' THEN (SELECT FilePath FROM dbo.T_Call_CallRecords WHERE CallId=t.F_KSHADDRESSCODE) ELSE NULL END ) as FilePath",
  266. sql,
  267. "ORDER BY t.F_CREATEDATE desc",
  268. limit,
  269. page,
  270. true,
  271. out recordCount);
  272. dataModel.code = 0;
  273. dataModel.count = recordCount;
  274. dataModel.data = dt;
  275. return JsonConvert.SerializeObject(dataModel);
  276. }
  277. [ActionName("GetCusDatabyNumber")]
  278. [HttpGet]
  279. public string GetCusDatabyNumber( string cusNumber)
  280. {
  281. //数据结果集
  282. ResponseData dataModel = new ResponseData();
  283. // cusBLL.GetCusInfoModel(cusNumber);
  284. return JsonConvert.SerializeObject(cusBLL.GetCusInfoModel(cusNumber));
  285. }
  286. //
  287. /// <summary>
  288. /// 保存编辑客户
  289. /// </summary>
  290. /// <param name="workOrderBaseModel"></param>
  291. /// <returns></returns>
  292. //[AcceptVerbs(HttpVerbs.Post)]
  293. //public bool SaveRepositoryCategoryContentData(T_RepositoryInformation categoryContentModel)
  294. //{
  295. // categoryContentModel.F_CreateBy = F_UserID;
  296. // if (categoryContentModel.F_RepositoryId > 0)
  297. // {
  298. // return reposCategoryContentBLL.Update(categoryContentModel);
  299. // }
  300. // else
  301. // {
  302. // return reposCategoryContentBLL.Add(categoryContentModel) > 0;
  303. // }
  304. //}
  305. #endregion
  306. }
  307. public class ViewCusOrderModel
  308. {
  309. public string F_Telephone
  310. {
  311. get;
  312. set;
  313. }
  314. public bool SeatFlag
  315. {
  316. get;
  317. set;
  318. }
  319. }
  320. }