地铁二期项目正式开始

CustomerController.cs 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  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 YTSoft.BaseCallCenter.Model;
  9. using YTSoft.BaseCallCenter.MVCWeb.Models;
  10. namespace YTSoft.BaseCallCenter.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. YTSoft.BaseCallCenter.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. int count = new BLL.T_Call_Blacklist().Add(orderModel);
  82. }
  83. catch
  84. { }
  85. #endregion
  86. }
  87. else
  88. {
  89. new BLL.T_Call_Blacklist().DeleteBlack(CustomerBaseModel.F_Telephone.Trim());
  90. }
  91. bl = cusBLL.UpdateCusInfoModel(CustomerBaseModel);
  92. if (bl)
  93. return Success("成功");
  94. else
  95. return Error("失败");
  96. }
  97. /// <summary>
  98. /// 客户状态修改
  99. /// </summary>
  100. /// <param name="model"></param>
  101. /// <returns></returns>
  102. public bool SaveReceivedData(string keyList, int status)
  103. {
  104. AddAction("t_cus_customerbase", keyList, "修改客户状态",status.ToMyString());
  105. AddAction("t_cus_customerbase", keyList, "修改客户状态", string.Format("修改{0}数据F_ScaleResume/F_CustomerClass状态为{1}" , keyList, status), "关键信息");
  106. return cusBLL.EditCustonStatus(keyList, status);
  107. }
  108. #region 加载客户列表
  109. /// <summary>
  110. /// 加载客户列表
  111. /// </summary>
  112. /// <param name="page">当前页码</param>
  113. /// <param name="limit">每页数据量</param>
  114. /// <param name="sqlWhere">查询条件</param>
  115. /// <returns></returns>
  116. [ActionName("LoadCustomerALLList")]
  117. [HttpGet]
  118. public string LoadCustomerALLList(DateTime? NowDateTime, string cusType, int page, int limit, string cusName, string cusNum)
  119. {
  120. //数据结果集
  121. ResponseData dataModel = new ResponseData();
  122. string sql = "";
  123. sql += " and F_DeleteFlag=0 ";
  124. //语音客户
  125. if (cusType == "1")
  126. {
  127. sql += " and F_Kind=1 ";
  128. }
  129. //微信客户
  130. if (cusType == "2")
  131. {
  132. sql += " and F_Kind=2 ";
  133. }
  134. //微博客户
  135. if (cusType == "3")
  136. {
  137. sql += " and F_Kind=3 ";
  138. }
  139. //特别客户
  140. if (cusType == "4")
  141. {
  142. sql += " and F_ScaleResume=2";
  143. }
  144. //黑名单客户
  145. if (cusType == "5")
  146. {
  147. sql += " and F_ScaleResume=3";
  148. }
  149. //白名单客户
  150. if (cusType == "6")
  151. {
  152. sql += " and F_ScaleResume=4";
  153. }
  154. if (!string.IsNullOrEmpty(cusName))
  155. {
  156. sql += " and F_CustomerName like '%" + cusName.Trim() + "%' ";
  157. }
  158. if (!string.IsNullOrEmpty(cusNum))
  159. {
  160. // sql += " and( F_Telephone like '%" + cusNum + "%' or F_Mobile like '%" + cusNum + "%' )";
  161. sql += " and F_Telephone like '%" + cusNum.Trim() + "%'";
  162. }
  163. DataTable dt = new DataTable();
  164. int recordCount = 0;
  165. Model.PageData<Model.T_Cus_CustomerBase> pageModel = new Model.PageData<Model.T_Cus_CustomerBase>();
  166. dt = BLL.PagerBLL.GetListPager(
  167. "T_Cus_CustomerBase",
  168. "F_CustomerId",
  169. "*,CONVERT(varchar,F_ModifiedOn, 120 ) as F_ModifiedOnNew "
  170. ,
  171. sql,
  172. "ORDER BY F_CustomerId desc",
  173. limit,
  174. page,
  175. true,
  176. out recordCount);
  177. dataModel.code = 0;
  178. dataModel.count = recordCount;
  179. dataModel.data = dt;
  180. return JsonConvert.SerializeObject(dataModel);
  181. }
  182. [ActionName("GetCustomerModel")]
  183. [HttpGet]
  184. public string GetCustomerModel(int id)
  185. {
  186. if (id == 0)
  187. {
  188. return Error("id不能为空");
  189. }
  190. BLL.T_Cus_CustomerBase busCus_CustomerBase = new BLL.T_Cus_CustomerBase();
  191. Model.T_Cus_CustomerBase model= busCus_CustomerBase.GetModel(id);
  192. int count = 0;
  193. if (model != null)
  194. count = 1;
  195. return Success("成功", model, count);
  196. }
  197. #endregion
  198. #region 客户工单信息
  199. /// <summary>
  200. /// 获取所有工单信息
  201. /// </summary>
  202. /// <returns></returns>
  203. public ActionResult CusOrderList(string callNumber)
  204. {
  205. ViewCusOrderModel cusModel = new ViewCusOrderModel();
  206. cusModel.F_Telephone = callNumber;
  207. cusModel.SeatFlag = F_SeatFlag;
  208. return View(cusModel);
  209. }
  210. /// <summary>
  211. /// 获取工单信息
  212. /// </summary>
  213. /// <param name="page">当前页码</param>
  214. /// <param name="limit">每页数据量</param>
  215. /// <param name="sqlWhere">查询条件</param>
  216. /// <returns></returns>
  217. [ActionName("CusOrderData")]
  218. [HttpGet]
  219. public string CusOrderData(int page, int limit, string cusNumber)
  220. {
  221. //数据结果集
  222. ResponseData dataModel = new ResponseData();
  223. string sql = "";
  224. //客户电话
  225. if (!string.IsNullOrEmpty(cusNumber))
  226. {
  227. sql += " and t.F_CUSTOMERTELEPHONE = '" + cusNumber.Trim() + "'";
  228. }
  229. else
  230. {
  231. sql += " and t.F_CUSTOMERTELEPHONE='-1'";
  232. }
  233. 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);
  234. DataTable dt = new DataTable();
  235. int recordCount = 0;
  236. Model.PageData<Model.T_Wo_WorkOrderBase> pageModel = new Model.PageData<Model.T_Wo_WorkOrderBase>();
  237. dt = BLL.PagerBLL.GetListPager(
  238. tableNew,
  239. "F_WORKORDERID",
  240. " t.*,CONVERT(varchar,t.F_CREATEDATE, 120 ) as F_CREATEDATENew"
  241. + " ,(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",
  242. sql,
  243. "ORDER BY t.F_CREATEDATE desc",
  244. limit,
  245. page,
  246. true,
  247. out recordCount);
  248. dataModel.code = 0;
  249. dataModel.count = recordCount;
  250. dataModel.data = dt;
  251. return JsonConvert.SerializeObject(dataModel);
  252. }
  253. [ActionName("GetCusDatabyNumber")]
  254. [HttpGet]
  255. public string GetCusDatabyNumber( string cusNumber)
  256. {
  257. //数据结果集
  258. ResponseData dataModel = new ResponseData();
  259. // cusBLL.GetCusInfoModel(cusNumber);
  260. return JsonConvert.SerializeObject(cusBLL.GetCusInfoModel(cusNumber));
  261. }
  262. //
  263. /// <summary>
  264. /// 保存编辑客户
  265. /// </summary>
  266. /// <param name="workOrderBaseModel"></param>
  267. /// <returns></returns>
  268. //[AcceptVerbs(HttpVerbs.Post)]
  269. //public bool SaveRepositoryCategoryContentData(T_RepositoryInformation categoryContentModel)
  270. //{
  271. // categoryContentModel.F_CreateBy = F_UserID;
  272. // if (categoryContentModel.F_RepositoryId > 0)
  273. // {
  274. // return reposCategoryContentBLL.Update(categoryContentModel);
  275. // }
  276. // else
  277. // {
  278. // return reposCategoryContentBLL.Add(categoryContentModel) > 0;
  279. // }
  280. //}
  281. #endregion
  282. }
  283. public class ViewCusOrderModel
  284. {
  285. public string F_Telephone
  286. {
  287. get;
  288. set;
  289. }
  290. public bool SeatFlag
  291. {
  292. get;
  293. set;
  294. }
  295. }
  296. }