Procházet zdrojové kódy

自定义字段客户管理
来电弹屏自定义字段

yuqian %!s(int64=8) %!d(string=před) roky
rodič
revize
879d784bbf

+ 7 - 7
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/customer/CustomerController.cs

@@ -169,7 +169,9 @@ namespace CallCenterApi.Interface.Controllers.customer
169 169
             if (userModel == null)
170 170
                 return Error("获取失败,该客户信息不存在");
171 171
             //系统列+自定义列 实体
172
-            var columnList = customerFieldBLL.GetList().Where(x => x.F_IsShowOnList > 0).OrderBy(x => x.F_FieldType).ThenBy(x => x.F_Sort).ToList();
172
+            var columnList = customerFieldBLL.GetList()
173
+                .Where(x => (x.F_FieldType == 0 && x.F_IsNecessary > 0) || (x.F_FieldType == 1 && x.F_IsShowOnScrean > 0))
174
+                .OrderBy(x => x.F_FieldType).ThenBy(x => x.F_Sort).ToList();
173 175
             //系统列+自定义列 字符串
174 176
             var headList = columnList.Select(x => x.F_Name).ToList();
175 177
             //系统列+自定义列 字段名
@@ -180,7 +182,7 @@ namespace CallCenterApi.Interface.Controllers.customer
180 182
             var expand = DbHelperSQL.Query("select  top 1 * from T_Cus_CustomerExpand where F_CustomerId=@F_CustomerId", new SqlParameter("@F_CustomerId", userModel.F_Id)).Tables[0].Rows[0];
181 183
             List<string> strList1 = new List<string>()
182 184
             {
183
-                 userModel.F_Name, userModel.F_PhoneNum1, userModel.F_PhoneNum2, userModel.F_Address, userModel.F_AddAgentName, userModel.F_AddTime.ToString("yyyy-MM-dd HH:mm:ss"), userModel.F_Remark
185
+                 userModel.F_Name, userModel.F_PhoneNum1, userModel.F_PhoneNum2, userModel.F_Address, userModel.F_Remark
184 186
             };
185 187
             List<string> strList2 = new List<string>();
186 188
             foreach (var item in customerColumnArr)
@@ -362,14 +364,12 @@ namespace CallCenterApi.Interface.Controllers.customer
362 364
             return Error("获取参数失败");
363 365
         }
364 366
 
365
-        /// <summary>
366
-        /// 获取自定义字段的字段名和字符串
367
-        /// </summary>
368
-        /// <returns></returns>
369 367
         public ActionResult GetCustomerField()
370 368
         {
371 369
             //系统列+自定义列 实体
372
-            var columnList = customerFieldBLL.GetList().Where(x => x.F_IsShowOnList > 0).OrderBy(x => x.F_FieldType).ThenBy(x => x.F_Sort).ToList();
370
+            var columnList = customerFieldBLL.GetList()
371
+                .Where(x => (x.F_FieldType == 0 && x.F_IsNecessary > 0) || (x.F_FieldType == 1 && x.F_IsShowOnScrean > 0))
372
+                .OrderBy(x => x.F_FieldType).ThenBy(x => x.F_Sort).ToList();
373 373
             //系统列+自定义列 字符串
374 374
             var headList = columnList.Select(x => x.F_Name).ToList();
375 375
             //系统列+自定义列 字段名

+ 137 - 84
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/tel/CallInScreenController.cs

@@ -1,9 +1,11 @@
1 1
 using CallCenter.Utility;
2 2
 using CallCenterApi.Common;
3
+using CallCenterApi.DB;
3 4
 using CallCenterApi.Interface.Controllers.Base;
4 5
 using System;
5 6
 using System.Collections.Generic;
6 7
 using System.Data;
8
+using System.Data.SqlClient;
7 9
 using System.Linq;
8 10
 using System.Web;
9 11
 using System.Web.Mvc;
@@ -12,6 +14,12 @@ namespace CallCenterApi.Interface.Controllers.tel
12 14
 {
13 15
     public class CallInScreenController : BaseController
14 16
     {
17
+
18
+        private readonly BLL.T_Cus_CustomerBase customerBaseBLL = new BLL.T_Cus_CustomerBase();
19
+        private readonly BLL.T_Cus_CustomerField customerFieldBLL = new BLL.T_Cus_CustomerField();
20
+        private readonly BLL.T_Cus_CustomerExpand customerExpandBLL = new BLL.T_Cus_CustomerExpand();
21
+        private readonly BLL.T_RepositoryInformation knowledgeBLL = new BLL.T_RepositoryInformation();
22
+        private readonly BLL.T_Sys_Department deptBLL = new BLL.T_Sys_Department();
15 23
         /// <summary>
16 24
         /// 添加黑名单
17 25
         /// </summary>
@@ -21,63 +29,63 @@ namespace CallCenterApi.Interface.Controllers.tel
21 29
             ActionResult res = NoToken("未知错误,请重新登录");
22 30
             if (Request.IsAuthenticated)
23 31
             {
24
-                
25
-                    int userId = CurrentUser.UserData.F_UserId;
26
-                    if (userId != 0)
32
+
33
+                int userId = CurrentUser.UserData.F_UserId;
34
+                if (userId != 0)
35
+                {
36
+                    Model.T_Sys_UserAccount ua = new BLL.T_Sys_UserAccount().GetModel(userId);
37
+                    if (ua != null)
27 38
                     {
28
-                        Model.T_Sys_UserAccount ua = new BLL.T_Sys_UserAccount().GetModel(userId);
29
-                        if (ua != null)
39
+                        string tel = HttpUtility.UrlDecode(RequestString.GetFormString("tel"));
40
+                        string callid = HttpUtility.UrlDecode(RequestString.GetFormString("callid"));
41
+                        int n = RequestString.GetInt("num", 0);
42
+                        int type = RequestString.GetInt("type", 0);
43
+                        Model.T_Call_Blacklist dModel = new BLL.T_Call_Blacklist().GetModelList(" F_TelPhone='" + tel + "' ").FirstOrDefault();
44
+
45
+                        var date = DateTime.Now;
46
+                        var enddate = date;
47
+                        switch (type)
48
+                        {
49
+                            case 1: enddate = enddate.AddDays(n); break;
50
+                            case 2: enddate = enddate.AddHours(n); break;
51
+                            case 3: enddate = enddate.AddMinutes(n); break;
52
+                            case 4: enddate = DateTime.MaxValue; break;
53
+                        }
54
+                        if (dModel == null)
30 55
                         {
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
-
37
-                            var date = DateTime.Now;
38
-                            var enddate = date;
39
-                            switch (type)
56
+                            dModel = new Model.T_Call_Blacklist();
57
+                            dModel.F_CallId = callid;
58
+                            dModel.F_TelPhone = tel.Trim();
59
+                            dModel.F_SetTime = date;
60
+                            dModel.F_RemoveTime = enddate;
61
+                            dModel.F_InterceptNum = 1;
62
+                            dModel.F_UserId = ua.F_UserId;
63
+                            int b = new BLL.T_Call_Blacklist().Add(dModel);
64
+                            if (b > 0)
40 65
                             {
41
-                                case 1: enddate = enddate.AddDays(n); break;
42
-                                case 2: enddate = enddate.AddHours(n); break;
43
-                                case 3: enddate = enddate.AddMinutes(n); break;
44
-                                case 4: enddate = DateTime.MaxValue; break;
66
+                                res = Success("添加成功", enddate.ToString("yyyy-MM-dd HH:mm:ss"));
45 67
                             }
46
-                            if (dModel == null)
68
+                            else
47 69
                             {
48
-                                dModel = new Model.T_Call_Blacklist();
49
-                                dModel.F_CallId = callid;
50
-                                dModel.F_TelPhone = tel.Trim();
51
-                                dModel.F_SetTime = date;
52
-                                dModel.F_RemoveTime = enddate;
53
-                                dModel.F_InterceptNum = 1;
54
-                                dModel.F_UserId = ua.F_UserId;
55
-                                int b = new BLL.T_Call_Blacklist().Add(dModel);
56
-                                if (b > 0)
57
-                                {
58
-                                    res = Success("添加成功", enddate.ToString("yyyy-MM-dd HH:mm:ss"));
59
-                                }
60
-                                else
61
-                                {
62
-                                    res = Error("添加失败");
63
-                                }
70
+                                res = Error("添加失败");
71
+                            }
72
+                        }
73
+                        else
74
+                        {
75
+
76
+                            dModel.F_RemoveTime = enddate;
77
+                            if (new BLL.T_Call_Blacklist().Update(dModel))
78
+                            {
79
+                                res = Success("修改成功", enddate.ToString("yyyy-MM-dd HH:mm:ss"));
64 80
                             }
65 81
                             else
66 82
                             {
67
-
68
-                                dModel.F_RemoveTime = enddate;
69
-                                if (new BLL.T_Call_Blacklist().Update(dModel))
70
-                                {
71
-                                    res = Success("修改成功", enddate.ToString("yyyy-MM-dd HH:mm:ss"));
72
-                                }
73
-                                else
74
-                                {
75
-                                    res = Error("修改失败");
76
-                                }
83
+                                res = Error("修改失败");
77 84
                             }
78 85
                         }
79 86
                     }
80
-              
87
+                }
88
+
81 89
             }
82 90
             return res;
83 91
         }
@@ -112,21 +120,66 @@ namespace CallCenterApi.Interface.Controllers.tel
112 120
         /// 根据来电号码获取客户信息
113 121
         /// </summary>
114 122
         /// <returns></returns>
115
-        public ActionResult GetCustomerByTel()
123
+        public ActionResult GetCustomerByTel(string tel)
116 124
         {
117
-            ActionResult res = NoToken("未知错误,请重新登录");
118
-            if (Request.IsAuthenticated)
119
-            {
120
-                DataTable dt = new DataTable();
125
+            //ActionResult res = NoToken("未知错误,请重新登录");
126
+            //if (Request.IsAuthenticated)
127
+            //{
128
+            //    DataTable dt = new DataTable();
121 129
 
122
-                string tel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));
123
-                BLL.T_Cus_CustomerBase bll = new BLL.T_Cus_CustomerBase();
124
-                dt = bll.GetList(" F_Telephone like '%" + tel + "%' or F_Mobile like '%" + tel + "%' ").Tables[0];
130
+            //    string tel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));
131
+            //    BLL.T_Cus_CustomerBase bll = new BLL.T_Cus_CustomerBase();
132
+            //    dt = bll.GetList(" F_Telephone like '%" + tel + "%' or F_Mobile like '%" + tel + "%' ").Tables[0];
133
+
134
+            //    res = Success("客户信息加载成功", dt);
135
+
136
+            //}
137
+            //return res;
125 138
 
126
-                res = Success("客户信息加载成功", dt);
127 139
 
140
+
141
+            if (string.IsNullOrWhiteSpace(tel))
142
+                return Error("来电号码为空");
143
+
144
+            //系统列+自定义列 实体
145
+            var columnList = customerFieldBLL.GetList()
146
+                .Where(x => (x.F_FieldType == 0 && x.F_IsNecessary > 0) || (x.F_FieldType == 1 && x.F_IsShowOnScrean > 0))
147
+                .OrderBy(x => x.F_FieldType).ThenBy(x => x.F_Sort).ToList();
148
+            //系统列+自定义列 字符串
149
+            var headList = columnList.Select(x => x.F_Name).ToList();
150
+            //系统列+自定义列 字段名
151
+            var nameList = columnList.Select(x => x.F_DBFieldName).ToList();
152
+
153
+            var userModel = customerBaseBLL.GetModelByTel(tel);
154
+            if (userModel == null)
155
+                return Success("获取成功", new
156
+                {
157
+                    namelist = nameList,
158
+                    headlist = headList
159
+                });
160
+
161
+            //自定义列字段名
162
+            var customerColumnArr = columnList.Where(x => x.F_FieldType == 1).Select(x => x.F_DBFieldName).ToList();
163
+            //自定义列值
164
+            var expand = DbHelperSQL.Query("select  top 1 * from T_Cus_CustomerExpand where F_CustomerId=@F_CustomerId", new SqlParameter("@F_CustomerId", userModel.F_Id)).Tables[0].Rows[0];
165
+            List<string> strList1 = new List<string>()
166
+            {
167
+                 userModel.F_Name, userModel.F_PhoneNum1, userModel.F_PhoneNum2, userModel.F_Address, userModel.F_Remark
168
+            };
169
+            List<string> strList2 = new List<string>();
170
+            foreach (var item in customerColumnArr)
171
+            {
172
+                strList2.Add(expand[item].ToString());
128 173
             }
129
-            return res;
174
+            strList1.AddRange(strList2);
175
+
176
+            return Success("获取成功", new
177
+            {
178
+                id = userModel.F_Id,
179
+                namelist = nameList,
180
+                headlist = headList,
181
+                datalist = strList1
182
+            });
130 183
         }
131 184
 
132 185
         /// <summary>
@@ -184,7 +237,7 @@ namespace CallCenterApi.Interface.Controllers.tel
184 237
                 if (tel.Trim().Length == 11 && tel.Substring(0, 1) != "0")
185 238
                 {
186 239
                     BLL.T_Sys_MobileData mobile_Bll = new BLL.T_Sys_MobileData();
187
-                    Model.T_Sys_MobileData mobileModel = mobile_Bll.GetModelList(" F_MobileNum='" + tel.Substring(0, 7) + "' ").FirstOrDefault(); 
240
+                    Model.T_Sys_MobileData mobileModel = mobile_Bll.GetModelList(" F_MobileNum='" + tel.Substring(0, 7) + "' ").FirstOrDefault();
188 241
 
189 242
                     if (mobileModel != null)
190 243
                     {
@@ -293,17 +346,17 @@ namespace CallCenterApi.Interface.Controllers.tel
293 346
                     }
294 347
                 }
295 348
 
296
-                int hrcount = new BLL.T_Call_CallRecords().GetRecordCount(" calltype=0 "+ sqlcount);
297
-                int hccount = new BLL.T_Call_CallRecords().GetRecordCount(" calltype=1 "+ sqlcount);
298
-                
349
+                int hrcount = new BLL.T_Call_CallRecords().GetRecordCount(" calltype=0 " + sqlcount);
350
+                int hccount = new BLL.T_Call_CallRecords().GetRecordCount(" calltype=1 " + sqlcount);
351
+
299 352
                 var obj = new
300 353
                 {
301 354
                     state = "success",
302 355
                     message = "成功",
303 356
                     rows = dt,
304 357
                     total = recordCount,
305
-                    hrcount=hrcount,
306
-                    hccount=hccount,
358
+                    hrcount = hrcount,
359
+                    hccount = hccount,
307 360
                 };
308 361
 
309 362
                 res = Content(obj.ToJson());
@@ -354,34 +407,34 @@ namespace CallCenterApi.Interface.Controllers.tel
354 407
             ActionResult res = NoToken("未知错误,请重新登录");
355 408
             if (Request.IsAuthenticated)
356 409
             {
357
-               
358
-                    int userId = CurrentUser.UserData.F_UserId;
359
-                    if (userId != 0)
410
+
411
+                int userId = CurrentUser.UserData.F_UserId;
412
+                if (userId != 0)
413
+                {
414
+                    Model.T_Sys_UserAccount ua = new BLL.T_Sys_UserAccount().GetModel(userId);
415
+                    if (ua != null)
360 416
                     {
361
-                        Model.T_Sys_UserAccount ua = new BLL.T_Sys_UserAccount().GetModel(userId);
362
-                        if (ua != null)
363
-                        {
364
-                            Model.T_Call_CallRecords model = new Model.T_Call_CallRecords();
365
-                            model.CallId = RequestString.GetFormString("callid");
366
-                            model.UserId = ua.F_UserId;
367
-                            model.UserCode = ua.F_UserCode;
368
-                            model.UserName = ua.F_UserName;
417
+                        Model.T_Call_CallRecords model = new Model.T_Call_CallRecords();
418
+                        model.CallId = RequestString.GetFormString("callid");
419
+                        model.UserId = ua.F_UserId;
420
+                        model.UserCode = ua.F_UserCode;
421
+                        model.UserName = ua.F_UserName;
369 422
                         //model.ExtNumber = ua.F_WorkNumber;
370 423
                         model.ExtNumber = CurrentUser.UserData.F_ExtensionNumber;
371 424
 
372
-                            model.DealType = 5;
373
-                            bool bl = new BLL.T_Call_CallRecords().UpdateCallInRingTelRecord(model);
374
-                            if (bl)
375
-                            {
376
-                                res = Success("更新振铃状态成功");
377
-                            }
378
-                            else
379
-                            {
380
-                                res = Error("更新振铃状态失败");
381
-                            }
425
+                        model.DealType = 5;
426
+                        bool bl = new BLL.T_Call_CallRecords().UpdateCallInRingTelRecord(model);
427
+                        if (bl)
428
+                        {
429
+                            res = Success("更新振铃状态成功");
430
+                        }
431
+                        else
432
+                        {
433
+                            res = Error("更新振铃状态失败");
382 434
                         }
383 435
                     }
384
-            
436
+                }
437
+
385 438
             }
386 439
             return res;
387 440
         }