zhoufan лет назад: 8
Родитель
Сommit
ced1d1f27a

+ 4 - 4
CallCenterApi/CallCenterApi.BLL/T_Sys_Users.cs

@@ -16,9 +16,9 @@ namespace CallCenterApi.BLL
16 16
         /// <summary>
17 17
         /// 是否存在该记录
18 18
         /// </summary>
19
-        public bool Exists(long F_Id)
19
+        public bool Exists(string usercode)
20 20
         {
21
-            return dal.Exists(F_Id);
21
+            return dal.Exists(usercode);
22 22
         }
23 23
 
24 24
         /// <summary>
@@ -64,9 +64,9 @@ namespace CallCenterApi.BLL
64 64
         /// <summary>
65 65
         /// 得到一个对象实体
66 66
         /// </summary>
67
-        public CallCenterApi.Model.T_Sys_Users GetModel(string F_OpenId)
67
+        public CallCenterApi.Model.T_Sys_Users GetModel(string openid)
68 68
         {
69
-            return dal.GetModel(F_OpenId);
69
+            return dal.GetModel(openid);
70 70
         }
71 71
 
72 72
         /// <summary>

+ 88 - 15
CallCenterApi/CallCenterApi.DAL/T_Sys_Users.cs

@@ -17,15 +17,15 @@ namespace CallCenterApi.DAL
17 17
         /// <summary>
18 18
         /// 是否存在该记录
19 19
         /// </summary>
20
-        public bool Exists(long F_Id)
20
+        public bool Exists(string usercode)
21 21
         {
22 22
             StringBuilder strSql = new StringBuilder();
23 23
             strSql.Append("select count(1) from T_Sys_Users");
24
-            strSql.Append(" where F_Id=@F_Id");
24
+            strSql.Append(" where F_OpenId=@F_OpenId");
25 25
             SqlParameter[] parameters = {
26
-                    new SqlParameter("@F_Id", SqlDbType.BigInt)
26
+                    new SqlParameter("@F_OpenId", SqlDbType.VarChar,100)
27 27
             };
28
-            parameters[0].Value = F_Id;
28
+            parameters[0].Value = usercode;
29 29
 
30 30
             return DbHelperSQL.Exists(strSql.ToString(), parameters);
31 31
         }
@@ -38,17 +38,33 @@ namespace CallCenterApi.DAL
38 38
         {
39 39
             StringBuilder strSql = new StringBuilder();
40 40
             strSql.Append("insert into T_Sys_Users(");
41
-            strSql.Append("F_OpenId,F_CreateTime,F_Type)");
41
+            strSql.Append("F_OpenId,F_CreateTime,F_Type,F_Password,F_Name,F_Telphone,F_Sex,F_Province,F_City,F_County,F_Address)");
42 42
             strSql.Append(" values (");
43
-            strSql.Append("@F_OpenId,@F_CreateTime,@F_Type)");
43
+            strSql.Append("@F_OpenId,@F_CreateTime,@F_Type,@F_Password,@F_Name,@F_Telphone,@F_Sex,@F_Province,@F_City,@F_County,@F_Address)");
44 44
             strSql.Append(";select @@IDENTITY");
45 45
             SqlParameter[] parameters = {
46 46
                     new SqlParameter("@F_OpenId", SqlDbType.VarChar,100),
47 47
                     new SqlParameter("@F_CreateTime", SqlDbType.DateTime),
48
-                    new SqlParameter("@F_Type", SqlDbType.Int,4)};
48
+                    new SqlParameter("@F_Type", SqlDbType.Int,4),
49
+                    new SqlParameter("@F_Password", SqlDbType.VarChar,50),
50
+                    new SqlParameter("@F_Name", SqlDbType.VarChar,50),
51
+                    new SqlParameter("@F_Telphone", SqlDbType.VarChar,50),
52
+                    new SqlParameter("@F_Sex", SqlDbType.Int,4),
53
+                    new SqlParameter("@F_Province", SqlDbType.VarChar,50),
54
+                    new SqlParameter("@F_City", SqlDbType.VarChar,50),
55
+                    new SqlParameter("@F_County", SqlDbType.VarChar,50),
56
+                    new SqlParameter("@F_Address", SqlDbType.VarChar,500)};
49 57
             parameters[0].Value = model.F_OpenId;
50 58
             parameters[1].Value = model.F_CreateTime;
51 59
             parameters[2].Value = model.F_Type;
60
+            parameters[3].Value = model.F_Password;
61
+            parameters[4].Value = model.F_Name;
62
+            parameters[5].Value = model.F_Telphone;
63
+            parameters[6].Value = model.F_Sex;
64
+            parameters[7].Value = model.F_Province;
65
+            parameters[8].Value = model.F_City;
66
+            parameters[9].Value = model.F_County;
67
+            parameters[10].Value = model.F_Address;
52 68
 
53 69
             object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
54 70
             if (obj == null)
@@ -69,17 +85,41 @@ namespace CallCenterApi.DAL
69 85
             strSql.Append("update T_Sys_Users set ");
70 86
             strSql.Append("F_OpenId=@F_OpenId,");
71 87
             strSql.Append("F_CreateTime=@F_CreateTime,");
72
-            strSql.Append("F_Type=@F_Type");
88
+            strSql.Append("F_Type=@F_Type,");
89
+            strSql.Append("F_Password=@F_Password,");
90
+            strSql.Append("F_Name=@F_Name,");
91
+            strSql.Append("F_Telphone=@F_Telphone,");
92
+            strSql.Append("F_Sex=@F_Sex,");
93
+            strSql.Append("F_Province=@F_Province,");
94
+            strSql.Append("F_City=@F_City,");
95
+            strSql.Append("F_County=@F_County,");
96
+            strSql.Append("F_Address=@F_Address");
73 97
             strSql.Append(" where F_Id=@F_Id");
74 98
             SqlParameter[] parameters = {
75 99
                     new SqlParameter("@F_OpenId", SqlDbType.VarChar,100),
76 100
                     new SqlParameter("@F_CreateTime", SqlDbType.DateTime),
77 101
                     new SqlParameter("@F_Type", SqlDbType.Int,4),
102
+                    new SqlParameter("@F_Password", SqlDbType.VarChar,50),
103
+                    new SqlParameter("@F_Name", SqlDbType.VarChar,50),
104
+                    new SqlParameter("@F_Telphone", SqlDbType.VarChar,50),
105
+                    new SqlParameter("@F_Sex", SqlDbType.Int,4),
106
+                    new SqlParameter("@F_Province", SqlDbType.VarChar,50),
107
+                    new SqlParameter("@F_City", SqlDbType.VarChar,50),
108
+                    new SqlParameter("@F_County", SqlDbType.VarChar,50),
109
+                    new SqlParameter("@F_Address", SqlDbType.VarChar,500),
78 110
                     new SqlParameter("@F_Id", SqlDbType.BigInt,8)};
79 111
             parameters[0].Value = model.F_OpenId;
80 112
             parameters[1].Value = model.F_CreateTime;
81 113
             parameters[2].Value = model.F_Type;
82
-            parameters[3].Value = model.F_Id;
114
+            parameters[3].Value = model.F_Password;
115
+            parameters[4].Value = model.F_Name;
116
+            parameters[5].Value = model.F_Telphone;
117
+            parameters[6].Value = model.F_Sex;
118
+            parameters[7].Value = model.F_Province;
119
+            parameters[8].Value = model.F_City;
120
+            parameters[9].Value = model.F_County;
121
+            parameters[10].Value = model.F_Address;
122
+            parameters[11].Value = model.F_Id;
83 123
 
84 124
             int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
85 125
             if (rows > 0)
@@ -143,7 +183,7 @@ namespace CallCenterApi.DAL
143 183
         {
144 184
 
145 185
             StringBuilder strSql = new StringBuilder();
146
-            strSql.Append("select  top 1 F_Id,F_OpenId,F_CreateTime,F_Type from T_Sys_Users ");
186
+            strSql.Append("select  top 1 F_Id,F_OpenId,F_CreateTime,F_Type,F_Password,F_Name,F_Telphone,F_Sex,F_Province,F_City,F_County,F_Address from T_Sys_Users ");
147 187
             strSql.Append(" where F_Id=@F_Id");
148 188
             SqlParameter[] parameters = {
149 189
                     new SqlParameter("@F_Id", SqlDbType.BigInt)
@@ -165,16 +205,16 @@ namespace CallCenterApi.DAL
165 205
         /// <summary>
166 206
         /// 得到一个对象实体
167 207
         /// </summary>
168
-        public CallCenterApi.Model.T_Sys_Users GetModel(string F_OpenId)
208
+        public CallCenterApi.Model.T_Sys_Users GetModel(string openid)
169 209
         {
170 210
 
171 211
             StringBuilder strSql = new StringBuilder();
172
-            strSql.Append("select  top 1 F_Id,F_OpenId,F_CreateTime,F_Type from T_Sys_Users ");
212
+            strSql.Append("select  top 1 F_Id,F_OpenId,F_CreateTime,F_Type,F_Password,F_Name,F_Telphone,F_Sex,F_Province,F_City,F_County,F_Address from T_Sys_Users ");
173 213
             strSql.Append(" where F_OpenId=@F_OpenId");
174 214
             SqlParameter[] parameters = {
175 215
                     new SqlParameter("@F_OpenId", SqlDbType.VarChar,100)
176 216
             };
177
-            parameters[0].Value = F_OpenId;
217
+            parameters[0].Value = openid;
178 218
 
179 219
             CallCenterApi.Model.T_Sys_Users model = new CallCenterApi.Model.T_Sys_Users();
180 220
             DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
@@ -188,6 +228,7 @@ namespace CallCenterApi.DAL
188 228
             }
189 229
         }
190 230
 
231
+
191 232
         /// <summary>
192 233
         /// 得到一个对象实体
193 234
         /// </summary>
@@ -212,6 +253,38 @@ namespace CallCenterApi.DAL
212 253
                 {
213 254
                     model.F_Type = int.Parse(row["F_Type"].ToString());
214 255
                 }
256
+                if (row["F_Password"] != null)
257
+                {
258
+                    model.F_Password = row["F_Password"].ToString();
259
+                }
260
+                if (row["F_Name"] != null)
261
+                {
262
+                    model.F_Name = row["F_Name"].ToString();
263
+                }
264
+                if (row["F_Telphone"] != null)
265
+                {
266
+                    model.F_Telphone = row["F_Telphone"].ToString();
267
+                }
268
+                if (row["F_Sex"] != null && row["F_Sex"].ToString() != "")
269
+                {
270
+                    model.F_Sex = int.Parse(row["F_Sex"].ToString());
271
+                }
272
+                if (row["F_Province"] != null)
273
+                {
274
+                    model.F_Province = row["F_Province"].ToString();
275
+                }
276
+                if (row["F_City"] != null)
277
+                {
278
+                    model.F_City = row["F_City"].ToString();
279
+                }
280
+                if (row["F_County"] != null)
281
+                {
282
+                    model.F_County = row["F_County"].ToString();
283
+                }
284
+                if (row["F_Address"] != null)
285
+                {
286
+                    model.F_Address = row["F_Address"].ToString();
287
+                }
215 288
             }
216 289
             return model;
217 290
         }
@@ -222,7 +295,7 @@ namespace CallCenterApi.DAL
222 295
         public DataSet GetList(string strWhere)
223 296
         {
224 297
             StringBuilder strSql = new StringBuilder();
225
-            strSql.Append("select F_Id,F_OpenId,F_CreateTime,F_Type ");
298
+            strSql.Append("select F_Id,F_OpenId,F_CreateTime,F_Type,F_Password,F_Name,F_Telphone,F_Sex,F_Province,F_City,F_County,F_Address ");
226 299
             strSql.Append(" FROM T_Sys_Users ");
227 300
             if (strWhere.Trim() != "")
228 301
             {
@@ -242,7 +315,7 @@ namespace CallCenterApi.DAL
242 315
             {
243 316
                 strSql.Append(" top " + Top.ToString());
244 317
             }
245
-            strSql.Append(" F_Id,F_OpenId,F_CreateTime,F_Type ");
318
+            strSql.Append(" F_Id,F_OpenId,F_CreateTime,F_Type,F_Password,F_Name,F_Telphone,F_Sex,F_Province,F_City,F_County,F_Address ");
246 319
             strSql.Append(" FROM T_Sys_Users ");
247 320
             if (strWhere.Trim() != "")
248 321
             {

+ 25 - 0
CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/App_Start/APPActionFilter.cs

@@ -0,0 +1,25 @@
1
+using CallCenter.Utility;
2
+using System;
3
+using System.Collections.Generic;
4
+using System.Linq;
5
+using System.Web;
6
+using System.Web.Mvc;
7
+
8
+namespace CallCenterApi.Interface.App_Start
9
+{
10
+    public class APPActionFilter : ActionFilterAttribute
11
+    {
12
+        private readonly BLL.T_Sys_Users userBLL = new BLL.T_Sys_Users();
13
+        public override void OnActionExecuting(ActionExecutingContext filterContext)
14
+        {
15
+            var usercode = filterContext.HttpContext.Request["usercode"];
16
+            var model = userBLL.GetModel(usercode);
17
+            if (model == null)
18
+            {
19
+                filterContext.Result = new ContentResult() { Content = new AjaxResult { state = ResultTypes.notoken.ToString(), message = "登录超时,请重新登录" }.ToJson() };
20
+                return;
21
+            }
22
+            base.OnActionExecuting(filterContext);
23
+        }
24
+    }
25
+}

+ 3 - 0
CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/CallCenterApi.Interface.csproj

@@ -156,11 +156,13 @@
156 156
     </Content>
157 157
   </ItemGroup>
158 158
   <ItemGroup>
159
+    <Compile Include="App_Start\APPActionFilter.cs" />
159 160
     <Compile Include="App_Start\AuthorizeAttribute.cs" />
160 161
     <Compile Include="App_Start\FilterConfig.cs" />
161 162
     <Compile Include="App_Start\ErrorAttribute.cs" />
162 163
     <Compile Include="App_Start\RouteConfig.cs" />
163 164
     <Compile Include="App_Start\WechatActionFilter.cs" />
165
+    <Compile Include="Controllers\APPController.cs" />
164 166
     <Compile Include="Controllers\AreaController.cs" />
165 167
     <Compile Include="Controllers\Base\BaseController.cs" />
166 168
     <Compile Include="Controllers\CallOutOptController.cs" />
@@ -288,6 +290,7 @@
288 290
     <Folder Include="App_Data\" />
289 291
     <Folder Include="Views\AddressBook\" />
290 292
     <Folder Include="Views\ApplicationsRefresh\" />
293
+    <Folder Include="Views\APP\" />
291 294
     <Folder Include="Views\Area\" />
292 295
     <Folder Include="Views\Article\" />
293 296
     <Folder Include="Views\Base\" />

+ 588 - 0
CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/APPController.cs

@@ -0,0 +1,588 @@
1
+using CallCenter.Utility;
2
+using CallCenterApi.DB;
3
+using CallCenterApi.Interface.App_Start;
4
+using CallCenterApi.Interface.Controllers.Base;
5
+using CallCenterApi.Interface.Controllers.workorder;
6
+using System;
7
+using System.Collections.Generic;
8
+using System.Data;
9
+using System.Linq;
10
+using System.Transactions;
11
+using System.Web;
12
+using System.Web.Mvc;
13
+
14
+namespace CallCenterApi.Interface.Controllers
15
+{
16
+    public class APPController : BaseController
17
+    {
18
+        // GET: APP
19
+
20
+        /// <summary>
21
+        /// 登录
22
+        /// </summary>
23
+        /// <returns></returns>
24
+        public ActionResult Login(string usercode,string password)
25
+        {
26
+            DateTime ExpiredTime = DateTime.Now.AddDays(1);
27
+            bool appResult = DateTime.Now> ExpiredTime;// Convert.ToDateTime(ReadFile(HttpRuntime.AppDomainAppPath + "tools\\hykj.hy"));
28
+            if (appResult)
29
+            {
30
+                DataTable dt = new DataTable();
31
+                try
32
+                {
33
+                    Dictionary<string, string> paras = new Dictionary<string, string>();
34
+                    string sql = " select * from T_Sys_Users where F_OpenId=@F_OpenId and F_Password=@F_Password";
35
+                    paras.Add("@F_OpenId", usercode);
36
+                    paras.Add("@F_Password", password);
37
+
38
+                    dt = DbHelperSQL.Query(sql, paras).Tables[0];
39
+                    if (dt != null)
40
+                    {
41
+                        //写入登录日志
42
+                        new CallCenterApi.BLL.T_Sys_LoginLogs().Add(new Model.T_Sys_LoginLogs()
43
+                        {
44
+                            F_LoginName = dt.Rows[0]["F_OpenId"].ToString(),
45
+                            F_LoginId = Convert.ToInt32(dt.Rows[0]["F_Id"].ToString()),
46
+                            F_Result = "APP市民登录成功",
47
+                            F_LoginIP = Common.DTRequest.GetIP(),
48
+                            F_Hostname = Common.DTRequest.GetIP(),
49
+                            F_LoginDate = DateTime.Now,
50
+                            F_Remark = "",
51
+                            F_State = 0
52
+                        });
53
+
54
+                        return Success("登录成功",new {
55
+                            usercode= dt.Rows[0]["F_OpenId"].ToString(),
56
+                            userid= dt.Rows[0]["F_Id"].ToString()
57
+                        });
58
+                    }
59
+                    else
60
+                    {
61
+                        //写入登录日志
62
+                        DataTable dt1 = new CallCenterApi.BLL.T_Sys_Users().GetList("F_OpenId='" + usercode + "'").Tables[0];
63
+                        if (dt1.Rows.Count > 0)
64
+                        {
65
+                            int rr = new CallCenterApi.BLL.T_Sys_LoginLogs().Add(new Model.T_Sys_LoginLogs()
66
+                            {
67
+                                F_LoginName = dt1.Rows[0]["F_OpenId"].ToString(),
68
+                                F_LoginId = Convert.ToInt32(dt1.Rows[0]["F_Id"].ToString()),
69
+                                F_Result = "APP市民登录失败:帐号-" + usercode,
70
+                                F_LoginIP = Common.DTRequest.GetIP(),
71
+                                F_Hostname = Common.DTRequest.GetIP(),
72
+                                F_LoginDate = DateTime.Now,
73
+                                F_Remark = "",
74
+                                F_State = 0
75
+                            });
76
+                        }
77
+                        else
78
+                        {
79
+                            int rr = new BLL.T_Sys_LoginLogs().Add(new Model.T_Sys_LoginLogs()
80
+                            {
81
+                                F_LoginName = usercode,
82
+                                F_LoginId = -1,
83
+                                F_Result = "APP市民登录失败:帐号-" + usercode ,
84
+                                F_LoginIP = Common.DTRequest.GetIP(),
85
+                                F_Hostname = Common.DTRequest.GetIP(),
86
+                                F_LoginDate = DateTime.Now,
87
+                                F_Remark = "",
88
+                                F_State = 0
89
+                            });
90
+                        }
91
+
92
+                        return Error("账号或密码错误,请重新登录");
93
+                    }
94
+                }
95
+                catch
96
+                {
97
+                    return Error("账号或密码错误,请重新登录");
98
+                }
99
+            }
100
+            else
101
+            {
102
+                return Error("授权过期,请联系系统厂家。");
103
+            }
104
+        }
105
+
106
+        /// <summary>
107
+        /// 注册用户
108
+        /// </summary>
109
+        /// <param name="input"></param>
110
+        /// <returns></returns>
111
+        [HttpPost]
112
+        public ActionResult AddUser()
113
+        {
114
+            string usercode = RequestString.GetFormString("usercode");
115
+            string password = RequestString.GetFormString("password");
116
+            string name = RequestString.GetFormString("name");
117
+            string phone = RequestString.GetFormString("phone");
118
+            int sex = RequestString.GetInt("sex", 0);
119
+            string province = RequestString.GetFormString("province");
120
+            string city = RequestString.GetFormString("city");
121
+            string county = RequestString.GetFormString("county");
122
+            string address = RequestString.GetFormString("address");
123
+
124
+            Model.T_Sys_Users dModel = new Model.T_Sys_Users();
125
+
126
+            var list = new BLL.T_Sys_Users().GetModelList(" F_OpenId='" + usercode + "' ");
127
+            if (list.Count > 0)
128
+            {
129
+                return Error("已经存在此账号");
130
+            }
131
+            else
132
+            {
133
+                dModel.F_OpenId = usercode;
134
+                dModel.F_Password = password;
135
+                dModel.F_Name = name;
136
+                dModel.F_Telphone = phone;
137
+                dModel.F_Sex = sex;
138
+                dModel.F_Type = 4;
139
+                dModel.F_Province = province;
140
+                dModel.F_City = city;
141
+                dModel.F_County = county;
142
+                dModel.F_Address = address;
143
+
144
+
145
+                dModel.F_CreateTime = DateTime.Now;
146
+
147
+                long n = new BLL.T_Sys_Users().Add(dModel);
148
+                if (n > 0)
149
+                    return Success("添加成功", n);
150
+                else
151
+                    return Error("添加失败");
152
+            }
153
+        }
154
+
155
+        /// <summary>
156
+        /// 编辑用户
157
+        /// </summary>
158
+        /// <param name="input"></param>
159
+        /// <returns></returns>
160
+        [APPActionFilter]
161
+        [HttpPost]
162
+        public ActionResult UpdateUser()
163
+        {
164
+            int id = RequestString.GetInt("id", 0);
165
+            string usercode = RequestString.GetFormString("usercode");
166
+            string password = RequestString.GetFormString("password");
167
+            string name = RequestString.GetFormString("name");
168
+            string phone = RequestString.GetFormString("phone");
169
+            int sex = RequestString.GetInt("sex", 0);
170
+            string province = RequestString.GetFormString("province");
171
+            string city = RequestString.GetFormString("city");
172
+            string county = RequestString.GetFormString("county");
173
+            string address = RequestString.GetFormString("address");
174
+
175
+            Model.T_Sys_Users dModel = new Model.T_Sys_Users();
176
+            if (id == 0)
177
+            {
178
+                dModel = new BLL.T_Sys_Users().GetModel(id);
179
+                if (dModel != null)
180
+                {
181
+                    var list = new BLL.T_Sys_Users().GetModelList(" F_OpenId='" + usercode + "' and F_Id!='" + id + "' ");
182
+                    if (list.Count > 0)
183
+                    {
184
+                        return Error("已经存在此账号");
185
+                    }
186
+                    else
187
+                    {
188
+                        dModel.F_OpenId = usercode;
189
+                        dModel.F_Name = name;
190
+                        dModel.F_Telphone = phone;
191
+                        dModel.F_Sex = sex;
192
+                        dModel.F_Province = province;
193
+                        dModel.F_City = city;
194
+                        dModel.F_County = county;
195
+                        dModel.F_Address = address;
196
+
197
+                        if (new BLL.T_Sys_Users().Update(dModel))
198
+                            return Success("修改成功");
199
+                        else
200
+                            return Error("修改失败");
201
+                    }
202
+                }
203
+                else
204
+                {
205
+                    return Error("修改失败");
206
+                }
207
+            }
208
+            else
209
+            {
210
+                return Error("修改失败");
211
+            }
212
+        }
213
+
214
+        /// <summary>
215
+        /// 修改密码
216
+        /// </summary>
217
+        /// <returns></returns>
218
+        [APPActionFilter]
219
+        [HttpPost]
220
+        public ActionResult UpdatePassword()
221
+        {
222
+            string usercode = RequestString.GetFormString("usercode");
223
+            string old = RequestString.GetFormString("old");
224
+            string new1 = RequestString.GetFormString("new1");
225
+            string new2 = RequestString.GetFormString("new2");
226
+            if (string.IsNullOrEmpty(old) || string.IsNullOrEmpty(new1) || string.IsNullOrEmpty(new2))
227
+            {
228
+                return Error("请输入新旧密码");
229
+            }
230
+            if (new1 != new2)
231
+            {
232
+                return Error("两次输入的不一致");
233
+            }
234
+
235
+            var userinfo = new BLL.T_Sys_Users().GetModel(usercode);
236
+            if (old == userinfo.F_Password)
237
+            {
238
+                userinfo.F_Password = new1;
239
+                new BLL.T_Sys_Users().Update(userinfo);
240
+
241
+                return Success("修改成功");
242
+            }
243
+            else
244
+            {
245
+                return Error("原密码错误");
246
+            }
247
+        }
248
+
249
+        /// <summary>
250
+        /// 获取工单列表
251
+        /// </summary>
252
+        /// <returns></returns>
253
+        [APPActionFilter]
254
+        public ActionResult GetUserWorkOrderList(int isdc = 0)
255
+        {
256
+            string sql = " and F_IsDelete=0 ";
257
+
258
+            string strusercode = HttpUtility.UrlDecode(RequestString.GetQueryString("usercode"));
259
+
260
+            var ouid = DbHelperSQL.GetSingle(" select F_ID from T_Sys_Users where F_OpenId ='" + strusercode + "'");
261
+
262
+            string sqlwhere = "select F_WorkOrderID FROM T_Bus_UserWorkOrder where F_UserId = '" + ouid.ToString() + "' ";
263
+            sql += " and F_WorkOrderID in (" + sqlwhere + ")";
264
+
265
+
266
+            DataTable dt = new DataTable();
267
+
268
+            string strstate = HttpUtility.UrlDecode(RequestString.GetQueryString("state"));
269
+            string strname = HttpUtility.UrlDecode(RequestString.GetQueryString("name"));
270
+            string strtel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));
271
+            string strkey = HttpUtility.UrlDecode(RequestString.GetQueryString("key"));
272
+            string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
273
+            string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
274
+            string strworkid = HttpUtility.UrlDecode(RequestString.GetQueryString("workid"));
275
+
276
+            int source = RequestString.GetInt("source", 0);
277
+            int keyid = RequestString.GetInt("keyid", 0);
278
+            int type = RequestString.GetInt("type", 0);
279
+            int bigtype = RequestString.GetInt("bigtype", 0);
280
+            int smalltype = RequestString.GetInt("smalltype", 0);
281
+            int sourcearea = RequestString.GetInt("sourcearea", 0);
282
+
283
+            int deptid = RequestString.GetInt("deptid", 0);
284
+            int dealtype = RequestString.GetInt("dealtype", -1);
285
+            int issend = RequestString.GetInt("issend", -1);
286
+
287
+            string strpageindex = RequestString.GetQueryString("page");
288
+            int pageindex = 1;
289
+            string strpagesize = RequestString.GetQueryString("pagesize");
290
+            int pagesize = 10;
291
+
292
+            #region sql 语句相关处理
293
+            if (strstate.Trim() != "" && strstate != "undefined")
294
+            {
295
+                sql += " and F_WorkState = '" + strstate.Trim() + "' ";
296
+            }
297
+            if (strworkid.Trim() != "" && strworkid != "undefined")
298
+            {
299
+                sql += " and F_WorkOrderId like '%" + strworkid + "%' ";
300
+            }
301
+            if (strname.Trim() != "" && strname != "undefined")
302
+            {
303
+                sql += " and F_CusName like '%" + strname + "%' ";
304
+            }
305
+            if (strtel.Trim() != "" && strtel != "undefined")
306
+            {
307
+                sql += " and (F_CusPhone like '%" + strtel + "%' or F_ConPhone like '%" + strtel + "%') ";
308
+            }
309
+            if (strkey.Trim() != "" && strkey != "undefined")
310
+            {
311
+                sql += " and (F_ComTitle like '%" + strkey + "%' or F_ComContent like '%" + strkey + "%') ";
312
+            }
313
+
314
+            if (source != 0)
315
+            {
316
+                sql += " and F_InfoSource = '" + source + "' ";
317
+            }
318
+            if (keyid != 0)
319
+            {
320
+                sql += " and ','+F_Key+',' like '%," + keyid + ",%' ";
321
+            }
322
+            if (type != 0)
323
+            {
324
+                sql += " and F_InfoType = '" + type + "' ";
325
+            }
326
+            if (bigtype != 0)
327
+            {
328
+                sql += " and F_InfoConBigType = '" + bigtype + "' ";
329
+            }
330
+            if (smalltype != 0)
331
+            {
332
+                sql += " and F_InfoConSmallType = '" + smalltype + "' ";
333
+            }
334
+
335
+            if (sourcearea != 0)
336
+            {
337
+                sql += " and F_SourceArea = '" + sourcearea + "' ";
338
+            }
339
+
340
+            if (deptid != 0)
341
+            {
342
+                string sqlwhere1 = "select F_WorkOrderID from T_Bus_AssignedInfo where F_MainDeptId = '" + deptid + "' and F_IsSure in (0,1) and F_State=1 and F_IsDelete=0 ";
343
+                sql += " and F_WorkOrderID in(" + sqlwhere1 + ")";
344
+            }
345
+            if (dealtype != -1)
346
+            {
347
+                sql += " and isnull(F_IsResult,0) = '" + dealtype + "' ";
348
+            }
349
+            if (issend != -1)
350
+            {
351
+                sql += " and isnull(F_IsRelease,0) = '" + issend + "' ";
352
+            }
353
+
354
+            if (strstarttime.Trim() != "" && strstarttime != "undefined")
355
+            {
356
+                sql += " and datediff(day,F_CreateTime,'" + strstarttime + "')<=0 ";
357
+            }
358
+            if (strendtime.Trim() != "" && strendtime != "undefined")
359
+            {
360
+                sql += " and datediff(day,F_CreateTime,'" + strendtime + "')>=0   ";
361
+            }
362
+            #endregion
363
+
364
+            if (strpageindex.Trim() != "")
365
+            {
366
+                pageindex = Convert.ToInt32(strpageindex);
367
+            }
368
+
369
+            if (strpagesize.Trim() != "")
370
+            {
371
+                pagesize = Convert.ToInt32(strpagesize);
372
+            }
373
+
374
+            string cols = "*,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName,dbo.GetDictionaryName(F_InfoSource) as SourceName";
375
+
376
+            if (isdc > 0)
377
+            {
378
+                var dtdc = DbHelperSQL.Query(" select " + cols + " from T_Bus_WorkOrder where 1=1 " + sql).Tables[0];
379
+                var msg = new NPOIHelper().ExportToExcel("工单列表", dtdc);
380
+                if (msg == "")
381
+                {
382
+                    return Success("导出成功");
383
+                }
384
+                else
385
+                {
386
+                    return Error("导出失败");
387
+                }
388
+            }
389
+
390
+            int recordCount = 0;
391
+            dt = BLL.PagerBLL.GetListPager(
392
+                "T_Bus_WorkOrder",
393
+                "F_WorkOrderId",
394
+                cols,
395
+                sql,
396
+                "ORDER BY F_CreateTime DESC",
397
+                pagesize,
398
+                pageindex,
399
+                true,
400
+                out recordCount);
401
+
402
+            var obj = new
403
+            {
404
+                state = "success",
405
+                message = "成功",
406
+                rows = dt,
407
+                total = recordCount
408
+            };
409
+            return Content(obj.ToJson());
410
+
411
+        }
412
+
413
+        /// <summary>
414
+        /// APP上传图片
415
+        /// </summary>
416
+        /// <returns></returns>
417
+        [APPActionFilter]
418
+        public ActionResult Upload64()
419
+        {
420
+            //string dataurl = HttpUtility.UrlDecode(RequestString.GetFormString("dataurl"));
421
+            string dataurl = RequestString.GetFormString("dataurl");
422
+            if (!string.IsNullOrEmpty(dataurl))
423
+            {
424
+                string path = "/Upload/APP/" + DateTime.Now.ToString("yyyy") + "/" + DateTime.Now.ToString("MM") + "/" + DateTime.Now.ToString("dd") + "/";
425
+
426
+                ImageUpload iu = new ImageUpload();
427
+                iu.SavePath = path;
428
+                iu.DataUrl = dataurl;
429
+                iu.SaveType = 0;
430
+                iu.Upload64();
431
+
432
+                int n = iu.Error;
433
+                if (n == 0)
434
+                {
435
+                    path = path + iu.OutFileName;
436
+
437
+                    Model.T_Sys_Accessories model_T_Sys_Accessories = new Model.T_Sys_Accessories();
438
+                    model_T_Sys_Accessories.F_AddTime = DateTime.Now;//上传时间
439
+                    model_T_Sys_Accessories.F_FileName = iu.OutFileName;//附件名称
440
+                    model_T_Sys_Accessories.F_FileType = ".jpg";//附件类型
441
+                    model_T_Sys_Accessories.F_FileUrl = path;//附件地址
442
+                    model_T_Sys_Accessories.F_Size = iu.FileSize;
443
+                    //model_T_Sys_Accessories.F_UserCode = userModel.F_UserCode;//上传人  
444
+                    int id = new BLL.T_Sys_Accessories().Add(model_T_Sys_Accessories);
445
+                    model_T_Sys_Accessories.F_FileId = id;
446
+
447
+                    return Success("成功", model_T_Sys_Accessories);
448
+                }
449
+                else
450
+                {
451
+                    string msg = string.Empty;
452
+                    switch (n)
453
+                    {
454
+                        case 1: msg = "请选择要上传的文件"; break;
455
+                        case 2: msg = "上传的文件类型不支持"; break;
456
+                        case 3: msg = "上传的文件过大"; break;
457
+                        case 4: msg = "未知错误"; break;
458
+                    }
459
+                    return Error(msg);
460
+                }
461
+            }
462
+            else
463
+            {
464
+                return Error("请选择要上传的文件");
465
+            }
466
+        }
467
+
468
+        /// <summary>
469
+        /// 添加工单信息
470
+        /// </summary>
471
+        /// <returns></returns>
472
+        [APPActionFilter]
473
+        public ActionResult AddWorkOrder()
474
+        {
475
+
476
+            string usercode = RequestString.GetFormString("usercode");
477
+
478
+            var userinfo = new BLL.T_Sys_Users().GetModel(usercode);
479
+
480
+            int source = RequestString.GetInt("source", 6);
481
+
482
+            string cusname = RequestString.GetFormString("cusname");
483
+            string cussex = RequestString.GetFormString("cussex");
484
+            string cusphone = RequestString.GetFormString("cusphone");
485
+            string cusaddress = RequestString.GetFormString("cusaddress");
486
+            string email = RequestString.GetFormString("email");
487
+            string zipcode = RequestString.GetFormString("zipcode");
488
+            string conname = RequestString.GetFormString("conname");
489
+            string conphone = RequestString.GetFormString("conphone");
490
+
491
+            string title = RequestString.GetFormString("title");
492
+            string content = RequestString.GetFormString("content");
493
+            string files = RequestString.GetFormString("files");
494
+            int sourcearea = RequestString.GetInt("sourcearea", 0);
495
+            string sourceaddress = RequestString.GetFormString("sourceaddress");
496
+
497
+            int isresult = RequestString.GetInt("isresult", 0);
498
+            string result = RequestString.GetFormString("result");
499
+
500
+            string keys = RequestString.GetFormString("keys");
501
+            string splituser = RequestString.GetFormString("splituser");
502
+
503
+            int type = RequestString.GetInt("type", 0);
504
+            int bigtype = RequestString.GetInt("bigtype", 0);
505
+            int smalltype = RequestString.GetInt("smalltype", 0);
506
+
507
+            int isprotect = RequestString.GetInt("isprotect", 0);
508
+            int level = RequestString.GetInt("level", 0);
509
+
510
+            WorkOrderController woc = new WorkOrderController();
511
+            string workorderid = woc.AddWorkOrderBySource(6, cusname, cussex, cusphone, cusaddress, email, zipcode, conname,
512
+                    conphone, title, content, sourcearea, sourceaddress, keys, splituser, type, bigtype, smalltype, isprotect, level);
513
+            if (!string.IsNullOrEmpty(workorderid))
514
+            {
515
+                using (TransactionScope trans = new TransactionScope())
516
+                {
517
+                    #region 保存用户工单信息
518
+                    Model.T_Bus_UserWorkOrder tbu = new Model.T_Bus_UserWorkOrder();
519
+                    tbu.F_UserId = userinfo.F_Id;
520
+                    tbu.F_WorkOrderId = workorderid;
521
+                    new BLL.T_Bus_UserWorkOrder().Add(tbu);
522
+                    #endregion
523
+
524
+                    trans.Complete();
525
+                }
526
+                return Success("操作成功");
527
+            }
528
+            else
529
+            {
530
+                return Error("操作失败");
531
+            }
532
+        }
533
+
534
+        /// <summary>
535
+        /// 市民催单
536
+        /// </summary>
537
+        /// <returns></returns>
538
+        [APPActionFilter]
539
+        public ActionResult AdditionalWorkOrder()
540
+        {
541
+            string usercode = RequestString.GetFormString("usercode");
542
+            var userinfo = new BLL.T_Sys_Users().GetModel(usercode);
543
+
544
+            string workorderid = RequestString.GetFormString("workorderid");
545
+            string title = RequestString.GetFormString("title");
546
+            string content = RequestString.GetFormString("content");
547
+            Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = new BLL.T_Bus_WorkOrder().GetModel(workorderid);
548
+            if (modelT_Bus_WorkOrder != null)
549
+            {
550
+                using (TransactionScope trans = new TransactionScope())
551
+                {
552
+
553
+                    #region 插入附加记录
554
+                    //批示记录
555
+                    Model.T_Bus_Additional model_T_Bus_Additional = new Model.T_Bus_Additional();
556
+                    model_T_Bus_Additional.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;//工单流水号
557
+                    model_T_Bus_Additional.F_Title = title;
558
+                    model_T_Bus_Additional.F_Content = content;
559
+                    model_T_Bus_Additional.F_CreateTime = DateTime.Now;
560
+                    model_T_Bus_Additional.F_IsDelete = 0;
561
+                    model_T_Bus_Additional.F_State = 1;
562
+                    new BLL.T_Bus_Additional().Add(model_T_Bus_Additional);
563
+                    #endregion
564
+
565
+                    #region 插入操作记录
566
+                    Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
567
+                    oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
568
+                    oper.F_State = modelT_Bus_WorkOrder.F_WorkState;
569
+
570
+                    oper.F_Message = "市民("+ userinfo.F_OpenId + ")催单,内容:" + content;
571
+                    //oper.F_CreateUser = userModel.F_UserCode;
572
+                    oper.F_CreateTime = DateTime.Now;
573
+                    oper.F_IsDelete = 0;
574
+
575
+                    new BLL.T_Bus_Operation().Add(oper);
576
+                    #endregion
577
+
578
+                    trans.Complete();
579
+                }
580
+                return Success("操作成功");
581
+            }
582
+            else
583
+            {
584
+                return Error("操作失败");
585
+            }
586
+        }
587
+    }
588
+}

+ 76 - 4
CallCenterApi/CallCenterApi.Model/T_Sys_Users.cs

@@ -14,8 +14,16 @@ namespace CallCenterApi.Model
14 14
         private string _f_openid;
15 15
         private DateTime _f_createtime = DateTime.Now;
16 16
         private int? _f_type;
17
+        private string _f_password;
18
+        private string _f_name;
19
+        private string _f_telphone;
20
+        private int? _f_sex;
21
+        private string _f_province;
22
+        private string _f_city;
23
+        private string _f_county;
24
+        private string _f_address;
17 25
         /// <summary>
18
-        /// 自增id
26
+        /// 
19 27
         /// </summary>
20 28
         public long F_Id
21 29
         {
@@ -23,7 +31,7 @@ namespace CallCenterApi.Model
23 31
             get { return _f_id; }
24 32
         }
25 33
         /// <summary>
26
-        /// 微信openid,微博号
34
+        /// 
27 35
         /// </summary>
28 36
         public string F_OpenId
29 37
         {
@@ -31,7 +39,7 @@ namespace CallCenterApi.Model
31 39
             get { return _f_openid; }
32 40
         }
33 41
         /// <summary>
34
-        /// 创建时间
42
+        /// 
35 43
         /// </summary>
36 44
         public DateTime F_CreateTime
37 45
         {
@@ -39,13 +47,77 @@ namespace CallCenterApi.Model
39 47
             get { return _f_createtime; }
40 48
         }
41 49
         /// <summary>
42
-        /// 1微信2微博
50
+        /// 
43 51
         /// </summary>
44 52
         public int? F_Type
45 53
         {
46 54
             set { _f_type = value; }
47 55
             get { return _f_type; }
48 56
         }
57
+        /// <summary>
58
+        /// 
59
+        /// </summary>
60
+        public string F_Password
61
+        {
62
+            set { _f_password = value; }
63
+            get { return _f_password; }
64
+        }
65
+        /// <summary>
66
+        /// 
67
+        /// </summary>
68
+        public string F_Name
69
+        {
70
+            set { _f_name = value; }
71
+            get { return _f_name; }
72
+        }
73
+        /// <summary>
74
+        /// 
75
+        /// </summary>
76
+        public string F_Telphone
77
+        {
78
+            set { _f_telphone = value; }
79
+            get { return _f_telphone; }
80
+        }
81
+        /// <summary>
82
+        /// 
83
+        /// </summary>
84
+        public int? F_Sex
85
+        {
86
+            set { _f_sex = value; }
87
+            get { return _f_sex; }
88
+        }
89
+        /// <summary>
90
+        /// 
91
+        /// </summary>
92
+        public string F_Province
93
+        {
94
+            set { _f_province = value; }
95
+            get { return _f_province; }
96
+        }
97
+        /// <summary>
98
+        /// 
99
+        /// </summary>
100
+        public string F_City
101
+        {
102
+            set { _f_city = value; }
103
+            get { return _f_city; }
104
+        }
105
+        /// <summary>
106
+        /// 
107
+        /// </summary>
108
+        public string F_County
109
+        {
110
+            set { _f_county = value; }
111
+            get { return _f_county; }
112
+        }
113
+        /// <summary>
114
+        /// 
115
+        /// </summary>
116
+        public string F_Address
117
+        {
118
+            set { _f_address = value; }
119
+            get { return _f_address; }
120
+        }
49 121
         #endregion Model
50 122
 
51 123
     }