Pārlūkot izejas kodu

微信管理员登陆管理客户

zhaozhiqiang 5 gadi atpakaļ
vecāks
revīzija
74a63faed0

+ 16 - 0
codegit/CallCenterApi/CallCenterApi.BLL/T_Cus_CustomerBaseNew.cs

@@ -81,6 +81,22 @@ namespace CallCenterApi.BLL
81 81
             return dal.GetModelcuscode(archivecuscode);
82 82
         }
83 83
         /// <summary>
84
+        /// 根据公司名称得到一个对象实体
85
+        /// </summary>
86
+        public CallCenterApi.Model.T_Cus_CustomerBaseNew GetModelcusName(string company)
87
+        {
88
+
89
+            return dal.GetModelcusName(company);
90
+        }
91
+        /// <summary>
92
+        /// 根据客户编号和微信登录密码得到一个对象实体
93
+        /// </summary>
94
+        public CallCenterApi.Model.T_Cus_CustomerBaseNew GetModelWx(string cuscode, string wxpower)
95
+        {
96
+
97
+            return dal.GetModelWx(cuscode,wxpower);
98
+        }
99
+        /// <summary>
84 100
         /// 获得数据列表
85 101
         /// </summary>
86 102
         public DataSet GetList(string strWhere)

+ 57 - 3
codegit/CallCenterApi/CallCenterApi.DAL/T_Cus_CustomerBaseNew.cs

@@ -349,7 +349,7 @@ namespace CallCenterApi.DAL
349 349
 
350 350
 
351 351
         /// <summary>
352
-        /// 得到一个对象实体
352
+        /// 根据客户id得到一个对象实体
353 353
         /// </summary>
354 354
         public CallCenterApi.Model.T_Cus_CustomerBaseNew GetModel(int F_CustomerId)
355 355
         {
@@ -374,7 +374,7 @@ namespace CallCenterApi.DAL
374 374
             }
375 375
         }
376 376
         /// <summary>
377
-        /// 得到一个对象实体
377
+        /// 根据openid得到一个对象实体
378 378
         /// </summary>
379 379
         public CallCenterApi.Model.T_Cus_CustomerBaseNew GetModels(string openid)
380 380
         {
@@ -399,7 +399,7 @@ namespace CallCenterApi.DAL
399 399
             }
400 400
         }
401 401
         /// <summary>
402
-        /// 得到一个对象实体
402
+        /// 根据编号得到一个对象实体
403 403
         /// </summary>
404 404
         public CallCenterApi.Model.T_Cus_CustomerBaseNew GetModelcuscode(string archiveCode)
405 405
         {
@@ -423,6 +423,60 @@ namespace CallCenterApi.DAL
423 423
                 return null;
424 424
             }
425 425
         }
426
+        
427
+        /// <summary>
428
+        /// 根据公司名称得到一个对象实体
429
+        /// </summary>
430
+        public CallCenterApi.Model.T_Cus_CustomerBaseNew GetModelcusName(string company)
431
+        {
432
+
433
+            StringBuilder strSql = new StringBuilder();
434
+            strSql.Append("select  top 1 * from T_Cus_CustomerBaseNew ");
435
+            strSql.Append(" where F_CompanyName=@company");
436
+            SqlParameter[] parameters = {
437
+                    new SqlParameter("@company", SqlDbType.NVarChar,500)
438
+            };
439
+            parameters[0].Value = company;
440
+
441
+            CallCenterApi.Model.T_Cus_CustomerBaseNew model = new CallCenterApi.Model.T_Cus_CustomerBaseNew();
442
+            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
443
+            if (ds.Tables[0].Rows.Count > 0)
444
+            {
445
+                return DataRowToModel(ds.Tables[0].Rows[0]);
446
+            }
447
+            else
448
+            {
449
+                return null;
450
+            }
451
+        }
452
+
453
+        /// <summary>
454
+        /// 根据客户编号和微信登录密码得到一个对象实体
455
+        /// </summary>
456
+        public CallCenterApi.Model.T_Cus_CustomerBaseNew GetModelWx(string cuscode,string wxpower)
457
+        {
458
+
459
+            StringBuilder strSql = new StringBuilder();
460
+            strSql.Append("select  top 1 * from T_Cus_CustomerBaseNew ");
461
+            strSql.Append(" where F_CustomerCode=@cuscode and F_WxPassword=@wxpower");
462
+            SqlParameter[] parameters = {
463
+                    new SqlParameter("@cuscode", SqlDbType.NVarChar,100),
464
+                    new SqlParameter("@wxpower", SqlDbType.NVarChar,100)
465
+            };
466
+            parameters[0].Value = cuscode;
467
+            parameters[1].Value = wxpower;
468
+
469
+            CallCenterApi.Model.T_Cus_CustomerBaseNew model = new CallCenterApi.Model.T_Cus_CustomerBaseNew();
470
+            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
471
+            if (ds.Tables[0].Rows.Count > 0)
472
+            {
473
+                return DataRowToModel(ds.Tables[0].Rows[0]);
474
+            }
475
+            else
476
+            {
477
+                return null;
478
+            }
479
+        }
426 480
         /// <summary>
427 481
 		/// 得到一个对象实体
428 482
 		/// </summary>

+ 11 - 4
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/archives/archivesController.cs

@@ -35,8 +35,6 @@ namespace CallCenterApi.Interface.Controllers.archives
35 35
         /// <returns></returns>
36 36
         public ActionResult GetList(int PageIndex, int PageSize,string A_archiveName,string openid)
37 37
         {
38
-          
39
-            
40 38
             #region 分页显示档案物资
41 39
             if (PageIndex == 0)
42 40
             {
@@ -1037,8 +1035,17 @@ namespace CallCenterApi.Interface.Controllers.archives
1037 1035
                     var model = new Model.archives();
1038 1036
                     //Model.T_RepositoryCategory pModel = new BLL.T_RepositoryCategory().GetModel(int.Parse(pid.Trim()));
1039 1037
                     var pmodel = list.FirstOrDefault();
1040
-
1041
-                    model.A_archiveCode = dataRow[0].ToString();
1038
+                    //根据公司名称获取客户编号
1039
+                    Model.T_Cus_CustomerBaseNew customs = cusbll.GetModelcusName(dataRow[0].ToString());
1040
+                    if (customs != null)
1041
+                    {
1042
+                        model.A_archiveCode = customs.F_CustomerCode;// dataRow[0].ToString();
1043
+                    }
1044
+                    else
1045
+                    {
1046
+                        model.A_archiveCode = "";
1047
+                    }
1048
+                  
1042 1049
                     model.A_archiveName = dataRow[1].ToString();
1043 1050
                     model.fileid = fid;
1044 1051
                     model.A_archiveState = 1;

+ 1 - 1
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/customer/CustomerNewController.cs

@@ -180,7 +180,7 @@ namespace CallCenterApi.Interface.Controllers.customer
180 180
             if (list.Count > 0)
181 181
                 return Success("根据客户编号获取公司信息", list);
182 182
             else
183
-                return Error("没有获取到相关公司,请重新搜索");
183
+                return Success("没有获取到相关公司,请重新搜索", list);
184 184
         }
185 185
         /// <summary>
186 186
         /// 获取客户信息

+ 94 - 31
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/weixin/WxLoginController.cs

@@ -24,6 +24,8 @@ namespace CallCenterApi.Interface.Controllers.weixin
24 24
         private readonly BLL.T_Cus_CustomerBaseNew customerBaseBLL = new BLL.T_Cus_CustomerBaseNew();
25 25
         private readonly BLL.T_Cus_CustomerFinance finbll = new BLL.T_Cus_CustomerFinance();
26 26
         private readonly BLL.T_Wo_WorkOrder woBLL = new BLL.T_Wo_WorkOrder();
27
+        private readonly BLL.ManagementUser muserbll = new BLL.ManagementUser();
28
+        private readonly BLL.T_Cus_CustomerBaseNew cusbll = new BLL.T_Cus_CustomerBaseNew();
27 29
         //private readonly BLL.T_Cus_RegionCategory bllCus = new T_Cus_RegionCategory();
28 30
 
29 31
         ///// <summary>
@@ -68,6 +70,8 @@ namespace CallCenterApi.Interface.Controllers.weixin
68 70
             #endregion
69 71
             if (login.UserType == 1)
70 72
             {
73
+                #region usertype=1
74
+
71 75
                 Dictionary<string, string> paras = new Dictionary<string, string>();
72 76
                 string sql = " select * from T_Sys_UserAccount (NOLOCK) where F_UserCode=@F_UserCode and F_PassWord=@F_PassWord and F_DeleteFlag = 0 ";
73 77
                 paras.Add("@F_UserCode", login.UserCode);
@@ -79,7 +83,7 @@ namespace CallCenterApi.Interface.Controllers.weixin
79 83
                     //var user = userAccountBLL.GetModel(login.UserCode);   //20180926 次方法查询有漏洞
80 84
                     var user = userAccountBLL.DataTableToList(dt).ToList().FirstOrDefault();
81 85
                     user.F_WxOpenId = login.OpenId;
82
-                    int UserType = 0;string rolecode = "";
86
+                    int UserType = 0; string rolecode = "";
83 87
 
84 88
                     //部门
85 89
                     Model.T_Sys_Department modelDep = new BLL.T_Sys_Department().GetModel(user.F_DeptId);
@@ -90,8 +94,8 @@ namespace CallCenterApi.Interface.Controllers.weixin
90 94
                     if (rolemodel != null)
91 95
                         rolecode = rolemodel.F_RoleCode;
92 96
                     #endregion
93
-                        #region 部门角色
94
-                        //部门角色(-1管理员,1接待部,2案场经理、项目负责人,3销售部总经理、物业部总经理、工程总经理、设计总经理,4区域客服,5业主(客户档案))
97
+                    #region 部门角色
98
+                    //部门角色(-1管理员,1接待部,2案场经理、项目负责人,3销售部总经理、物业部总经理、工程总经理、设计总经理,4区域客服,5业主(客户档案))
95 99
                     if (user.F_RoleId == 17 || user.F_RoleId == 57)
96 100
                     {
97 101
                         //-1管理员
@@ -134,7 +138,7 @@ namespace CallCenterApi.Interface.Controllers.weixin
134 138
                         openid = login.OpenId,
135 139
                         usercode = login.UserCode,
136 140
                         usertype = UserType,
137
-                        rolecode=rolecode,
141
+                        rolecode = rolecode,
138 142
                     };
139 143
 
140 144
                     if (userAccountBLL.Update(user))
@@ -143,43 +147,102 @@ namespace CallCenterApi.Interface.Controllers.weixin
143 147
                         return Error("绑定失败");
144 148
                 }
145 149
                 return Error("账号或密码错误,请重新登录");
150
+                #endregion
146 151
             }
147 152
             else if (login.UserType == 5)
148 153
             {
149
-                //客户档案登录 - 用戶信息不存在时,登录客户档案业主账号
150
-                Dictionary<string, string> paras_Customer = new Dictionary<string, string>();
151
-                // F_RelationShipClassID IN (1,2) 用户类型:0来电用户; 1准业主; 2不是准业主或是亲戚朋友
152
-                //首次密码默认为身份证后6位信息
153
-                //F_CustomerClassID >= 0 为业主或租户,且F_RelationShipClassID = 0为会员账号 2、登录最早的信息
154
-                string sql_Customer = " select * from dbo.T_Cus_CustomerBaseNew (NOLOCK) where F_CustomerCode=@F_UserCode and F_WxPassword=@F_PassWord and F_DeleteFlag = 0 ORDER BY F_CreatedOn ASC ";
155
-                paras_Customer.Add("@F_UserCode", login.UserCode);
156
-                paras_Customer.Add("@F_PassWord", login.Password);
157
-                var dt_Customer = DbHelperSQL.Query(sql_Customer, paras_Customer).Tables[0];
154
+                //判断登录的用户是客户表的还是管理员表的
155
+                Model.T_Cus_CustomerBaseNew cusmodelwx = cusbll.GetModelWx(login.UserCode, login.Password);
156
+                Model.ManagementUser manuserwx = muserbll.GetManageCustomerModelwx(login.UserCode, login.Password);
158 157
 
159
-                if (dt_Customer != null && dt_Customer.Rows.Count > 0)
158
+                if (cusmodelwx != null)
160 159
                 {
161
-                    //var customer = customerBaseBLL.GetModel(login.UserCode);  //20180926 次方法查询有漏洞
162
-                    var customer = customerBaseBLL.DataTableToList(dt_Customer).ToList().FirstOrDefault();
163
-                    customer.F_WxOpenId = login.OpenId;
160
+                    #region usertype=5
161
+                    //客户档案登录 - 用戶信息不存在时,登录客户档案业主账号
162
+                    Dictionary<string, string> paras_Customer = new Dictionary<string, string>();
163
+                    // F_RelationShipClassID IN (1,2) 用户类型:0来电用户; 1准业主; 2不是准业主或是亲戚朋友
164
+                    //首次密码默认为身份证后6位信息
165
+                    //F_CustomerClassID >= 0 为业主或租户,且F_RelationShipClassID = 0为会员账号 2、登录最早的信息
166
+                    string sql_Customer = " select * from dbo.T_Cus_CustomerBaseNew (NOLOCK) where F_CustomerCode=@F_UserCode and F_WxPassword=@F_PassWord and F_DeleteFlag = 0 ORDER BY F_CreatedOn ASC ";
167
+                    paras_Customer.Add("@F_UserCode", login.UserCode);
168
+                    paras_Customer.Add("@F_PassWord", login.Password);
169
+                    var dt_Customer = DbHelperSQL.Query(sql_Customer, paras_Customer).Tables[0];
170
+
171
+                    if (dt_Customer != null && dt_Customer.Rows.Count > 0)
172
+                    {
173
+                        //var customer = customerBaseBLL.GetModel(login.UserCode);  //20180926 次方法查询有漏洞
174
+                        var customer = customerBaseBLL.DataTableToList(dt_Customer).ToList().FirstOrDefault();
175
+                        customer.F_WxOpenId = login.OpenId;
176
+
177
+                        #region 新加 - 登录后同时获取用户账号,openid,和角色
178
+                        //5--业主(客户档案会员) 
179
+                        //int UserType = 5;
180
+                        var obj = new
181
+                        {
182
+                            openid = login.OpenId,
183
+                            usercode = login.UserCode,
184
+                            companyname = customer.F_CompanyName,
185
+                            companyaddress = customer.F_CompanyAddress,
186
+                        };
187
+                        #endregion
188
+                        if (customerBaseBLL.Update(customer))
189
+                            return Success("绑定成功!", obj);
190
+                        else
191
+                            return Error("绑定失败!");
192
+                    }
193
+                    return Error("账号或密码错误或者没有注册,请重新登录");
194
+                    #endregion
164 195
 
165
-                    #region 新加 - 登录后同时获取用户账号,openid,和角色
166
-                    //5--业主(客户档案会员) 
167
-                    //int UserType = 5;
168
-                    var obj = new
196
+                }
197
+                else if (manuserwx != null)
198
+                {
199
+                    if (manuserwx.ifdeler == 1)
169 200
                     {
170
-                        openid = login.OpenId,
171
-                        usercode = login.UserCode,
172
-                        companyname = customer.F_CompanyName,
173
-                        companyaddress=customer.F_CompanyAddress,
174
-                    };
201
+                        return Error("该用户已被禁用");
202
+                    }
203
+                    #region UserType == 2
204
+                    int UserType = 2;
205
+                    Dictionary<string, string> paras_Customer = new Dictionary<string, string>();
206
+                    string sql_Customer = " select * from ManagementUser (NOLOCK) where username=@username and userpower=@userpower and ifdeler = 0  ";
207
+                    paras_Customer.Add("@username", login.UserCode);
208
+                    paras_Customer.Add("@userpower", login.Password);
209
+                    var dt_Customer = DbHelperSQL.Query(sql_Customer, paras_Customer).Tables[0];
210
+
211
+                    if (dt_Customer != null && dt_Customer.Rows.Count > 0)
212
+                    {
213
+                        //var customer = customerBaseBLL.GetModel(login.UserCode);  //20180926 次方法查询有漏洞
214
+                        var customer = muserbll.DataTableToList(dt_Customer).ToList().FirstOrDefault();
215
+
216
+                        customer.openid = login.OpenId;
217
+                        if (customer.ifdeler == 0)
218
+                        {
219
+                            #region 新加 - 登录后同时获取用户账号,openid,和角色
220
+
221
+                            var obj = new
222
+                            {
223
+                                openid = login.OpenId,
224
+                                username = login.UserCode,
225
+                                userpower = login.Password,
226
+                                usertype = UserType
227
+                            };
228
+                            #endregion
229
+                            if (muserbll.Update(customer))
230
+                                return Success("绑定成功!", obj);
231
+                            else
232
+                                return Error("绑定失败!");
233
+                        }
234
+                        else
235
+                        {
236
+                            return Error("该账户被禁用!");
237
+                        }
238
+                    }
175 239
                     #endregion
176
-                    if (customerBaseBLL.Update(customer))
177
-                        return Success("绑定成功!", obj);
178
-                    else
179
-                        return Error("绑定失败!");
180 240
                 }
181
-                return Error("账号或密码错误或者没有注册,请重新登录");
241
+                else {
242
+                    return Error("用户名或密码错误!");
243
+                }
182 244
             }
245
+           
183 246
             return Error("绑定失败");
184 247
         }
185 248
 

+ 19 - 0
设置管理员账号/管理员账号表.sql

@@ -0,0 +1,19 @@
1
+--创建管理员账号表
2
+create table ManagementUser
3
+(
4
+	id int identity primary key , --id
5
+	username nvarchar(100),        --账号名称
6
+	userpower nvarchar(200),      --密码
7
+	handleper nvarchar(100),      --操作人
8
+	handdate datetime,            --操作时间
9
+	ifdeler  int,                 --是否删除0 未删 1 已删
10
+	openid   nvarchar(300)         --微信登录的openid
11
+)
12
+--创建管理员客户关联表
13
+create table ManageCustomer
14
+(
15
+	id int identity primary key , --id
16
+	mangid int,                   --管理员账号id
17
+	cusmid int                    --客户id
18
+)
19
+select b.username,c.F_CompanyName from ManageCustomer a left join ManagementUser b on a.mangid=b.id left join T_Cus_CustomerBaseNew c on a.cusmid=c.F_CustomerId