Browse Source

微信对接接口调整

zhengbingbing 5 years ago
parent
commit
9d1211269a

+ 2 - 0
CallCenterApi/CallCenterApi.BLL/CallCenterApi.BLL.csproj

60
     <Compile Include="T_Bus_VisitResultRecords.cs" />
60
     <Compile Include="T_Bus_VisitResultRecords.cs" />
61
     <Compile Include="T_Bus_WorkOrder.cs" />
61
     <Compile Include="T_Bus_WorkOrder.cs" />
62
     <Compile Include="T_Bus_WorkOrderReport.cs" />
62
     <Compile Include="T_Bus_WorkOrderReport.cs" />
63
+    <Compile Include="T_Bus_WorkOrder_WXDocking_logs.cs" />
64
+    <Compile Include="T_Bus_WorkOrder_WXDocking_Map.cs" />
63
     <Compile Include="T_Call_Blacklist.cs" />
65
     <Compile Include="T_Call_Blacklist.cs" />
64
     <Compile Include="T_Call_CallRecords.cs" />
66
     <Compile Include="T_Call_CallRecords.cs" />
65
     <Compile Include="T_Call_CallRecordsLD.cs" />
67
     <Compile Include="T_Call_CallRecordsLD.cs" />

+ 43 - 0
CallCenterApi/CallCenterApi.BLL/T_Bus_WorkOrder_WXDocking_Map.cs

1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Threading.Tasks;
6
+
7
+namespace CallCenterApi.BLL
8
+{
9
+    /// <summary>
10
+	/// T_Bus_WorkOrder_WXDocking_Map
11
+	/// </summary>
12
+	public partial class T_Bus_WorkOrder_WXDocking_Map
13
+    {
14
+        private readonly CallCenterApi.DAL.T_Bus_WorkOrder_WXDocking_Map dal = new CallCenterApi.DAL.T_Bus_WorkOrder_WXDocking_Map();
15
+        public T_Bus_WorkOrder_WXDocking_Map()
16
+        { }
17
+        #region  Method
18
+        /// <summary>
19
+        /// 是否存在该记录
20
+        /// </summary>
21
+        public bool Exists(int F_Id)
22
+        {
23
+            return dal.Exists(F_Id);
24
+        }
25
+        /// <summary>
26
+        /// 是否存在该记录
27
+        /// </summary>
28
+        public bool ExistsUUID(string uuid)
29
+        {
30
+            return dal.ExistsUUID(uuid);
31
+        }
32
+
33
+        /// <summary>
34
+        /// 增加一条数据
35
+        /// </summary>
36
+        public int Add(CallCenterApi.Model.T_Bus_WorkOrder_WXDocking_Map model)
37
+        {
38
+            return dal.Add(model);
39
+        }
40
+
41
+        #endregion  Method
42
+    }
43
+}

+ 28 - 0
CallCenterApi/CallCenterApi.BLL/T_Bus_WorkOrder_WXDocking_logs.cs

1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Threading.Tasks;
6
+
7
+namespace CallCenterApi.BLL
8
+{
9
+    /// <summary>
10
+	/// 反馈表
11
+	/// </summary>
12
+	public partial class T_Bus_WorkOrder_WXDocking_logs
13
+    {
14
+        private readonly CallCenterApi.DAL.T_Bus_WorkOrder_WXDocking_logs dal = new CallCenterApi.DAL.T_Bus_WorkOrder_WXDocking_logs();
15
+        public T_Bus_WorkOrder_WXDocking_logs()
16
+        { }
17
+        #region  Method
18
+        /// <summary>
19
+        /// 增加一条数据
20
+        /// </summary>
21
+        public int Add(CallCenterApi.Model.T_Bus_WorkOrder_WXDocking_logs model)
22
+        {
23
+            return dal.Add(model);
24
+        }
25
+
26
+        #endregion  Method
27
+    }
28
+}

+ 24 - 0
CallCenterApi/CallCenterApi.Common/CodeValidate.cs

22
             return pwd.Equals(ICode);
22
             return pwd.Equals(ICode);
23
             //return true;
23
             //return true;
24
         }
24
         }
25
+
26
+        /// <summary>
27
+        /// 安全参数
28
+        /// </summary>
29
+        /// <param name="obj">对象</param>
30
+        /// <returns></returns>
31
+        public static bool ICodeValidateGridding(string strParams, string ICode)
32
+        {
33
+            string SecurityCode = Configs.GetValue("WeChatCode"); //ConfigurationManager.AppSettings["SecurityCode"];
34
+            string pwd = CommonHelper.MD5(SecurityCode + strParams);
35
+            return pwd.Equals(ICode);
36
+            //return true;
37
+        }
38
+
39
+        /// <summary>
40
+        /// 安全参数
41
+        /// </summary>
42
+        /// <param name="obj">对象</param>
43
+        /// <returns></returns>
44
+        public static string ICodeValidateGriddingT(string strParams, string ICode)
45
+        {
46
+            string SecurityCode = Configs.GetValue("WeChatCode"); //ConfigurationManager.AppSettings["SecurityCode"];
47
+            return CommonHelper.MD5(SecurityCode + strParams);
48
+        }
25
     }
49
     }
26
 }
50
 }

+ 2 - 0
CallCenterApi/CallCenterApi.DAL/CallCenterApi.DAL.csproj

60
     <Compile Include="T_Bus_VisitResult.cs" />
60
     <Compile Include="T_Bus_VisitResult.cs" />
61
     <Compile Include="T_Bus_VisitResultRecords.cs" />
61
     <Compile Include="T_Bus_VisitResultRecords.cs" />
62
     <Compile Include="T_Bus_WorkOrder.cs" />
62
     <Compile Include="T_Bus_WorkOrder.cs" />
63
+    <Compile Include="T_Bus_WorkOrder_WXDocking_logs.cs" />
64
+    <Compile Include="T_Bus_WorkOrder_WXDocking_Map.cs" />
63
     <Compile Include="T_Call_Blacklist.cs" />
65
     <Compile Include="T_Call_Blacklist.cs" />
64
     <Compile Include="T_Call_CallRecords.cs" />
66
     <Compile Include="T_Call_CallRecords.cs" />
65
     <Compile Include="T_Call_CallRecordsLD.cs" />
67
     <Compile Include="T_Call_CallRecordsLD.cs" />

+ 92 - 0
CallCenterApi/CallCenterApi.DAL/T_Bus_WorkOrder_WXDocking_Map.cs

1
+using CallCenterApi.DB;
2
+using System;
3
+using System.Collections.Generic;
4
+using System.Data;
5
+using System.Data.SqlClient;
6
+using System.Linq;
7
+using System.Text;
8
+using System.Threading.Tasks;
9
+
10
+namespace CallCenterApi.DAL
11
+{
12
+    /// <summary>
13
+    /// 数据访问类:T_Bus_WorkOrder_WXDocking_Map
14
+    /// </summary>
15
+    public partial class T_Bus_WorkOrder_WXDocking_Map
16
+    {
17
+        public T_Bus_WorkOrder_WXDocking_Map()
18
+        { }
19
+        #region  Method
20
+        /// <summary>
21
+        /// 是否存在该记录
22
+        /// </summary>
23
+        public bool Exists(int F_Id)
24
+        {
25
+            StringBuilder strSql = new StringBuilder();
26
+            strSql.Append("select count(1) from T_Bus_WorkOrder_WXDocking_Map");
27
+            strSql.Append(" where F_Id=@F_Id");
28
+            SqlParameter[] parameters = {
29
+                    new SqlParameter("@F_Id", SqlDbType.Int,4)
30
+            };
31
+            parameters[0].Value = F_Id;
32
+
33
+            return DbHelperSQL.Exists(strSql.ToString(), parameters);
34
+        }
35
+
36
+        /// <summary>
37
+        /// 是否存在该记录
38
+        /// </summary>
39
+        public bool ExistsUUID(string uuid)
40
+        {
41
+            StringBuilder strSql = new StringBuilder();
42
+            strSql.Append("select count(1) from T_Bus_WorkOrder_WXDocking_Map");
43
+            strSql.Append(" where uuid=@F_uuid");
44
+            SqlParameter[] parameters = {
45
+                    new SqlParameter("@F_uuid", SqlDbType.NVarChar,50),
46
+            };
47
+            parameters[0].Value = uuid;
48
+
49
+            return DbHelperSQL.Exists(strSql.ToString(), parameters);
50
+        }
51
+
52
+
53
+        /// <summary>
54
+        /// 增加一条数据
55
+        /// </summary>
56
+        public int Add(CallCenterApi.Model.T_Bus_WorkOrder_WXDocking_Map model)
57
+        {
58
+            StringBuilder strSql = new StringBuilder();
59
+            strSql.Append("insert into T_Bus_WorkOrder_WXDocking_Map(");
60
+            strSql.Append("F_WorkOrderId,F_Direction,F_Action,F_AddTime,openid,uuid,port_password)");
61
+            strSql.Append(" values (");
62
+            strSql.Append("@F_WorkOrderId,@F_Direction,@F_Action,@F_AddTime,@openid,@uuid,@port_password)");
63
+            strSql.Append(";select @@IDENTITY");
64
+            SqlParameter[] parameters = {
65
+                    new SqlParameter("@F_WorkOrderId", SqlDbType.VarChar,50),
66
+                    new SqlParameter("@F_Direction", SqlDbType.NVarChar,50),
67
+                    new SqlParameter("@F_Action", SqlDbType.NVarChar,200),
68
+                    new SqlParameter("@F_AddTime", SqlDbType.DateTime),
69
+                    new SqlParameter("@openid", SqlDbType.NVarChar,50),
70
+                    new SqlParameter("@uuid", SqlDbType.NVarChar,50),
71
+                    new SqlParameter("@port_password", SqlDbType.NVarChar)};
72
+            parameters[0].Value = model.F_WorkOrderId;
73
+            parameters[1].Value = model.F_Direction;
74
+            parameters[2].Value = model.F_Action;
75
+            parameters[3].Value = model.F_AddTime;
76
+            parameters[4].Value = model.openid;
77
+            parameters[5].Value = model.uuid;
78
+            parameters[6].Value = model.port_password;
79
+
80
+            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
81
+            if (obj == null)
82
+            {
83
+                return 0;
84
+            }
85
+            else
86
+            {
87
+                return Convert.ToInt32(obj);
88
+            }
89
+        }
90
+        #endregion  Method
91
+    }
92
+}

+ 82 - 0
CallCenterApi/CallCenterApi.DAL/T_Bus_WorkOrder_WXDocking_logs.cs

1
+using CallCenterApi.DB;
2
+using System;
3
+using System.Collections.Generic;
4
+using System.Data;
5
+using System.Data.SqlClient;
6
+using System.Linq;
7
+using System.Text;
8
+using System.Threading.Tasks;
9
+
10
+namespace CallCenterApi.DAL
11
+{
12
+    /// <summary>
13
+	/// 数据访问类:T_Bus_WorkOrder_WXDocking_logs
14
+	/// </summary>
15
+	public partial class T_Bus_WorkOrder_WXDocking_logs
16
+    {
17
+        public T_Bus_WorkOrder_WXDocking_logs()
18
+        { }
19
+        #region  Method
20
+
21
+        /// <summary>
22
+        /// 增加一条数据
23
+        /// </summary>
24
+        public int Add(CallCenterApi.Model.T_Bus_WorkOrder_WXDocking_logs model)
25
+        {
26
+            StringBuilder strSql = new StringBuilder();
27
+            strSql.Append("insert into T_Bus_WorkOrder_WXDocking_logs(");
28
+            strSql.Append("F_CusName,F_CusPhone,F_ComTitle,F_ComContent,F_SourceArea,F_SourceAddress,F_Key,F_InfoType,F_IsProtect,F_File,F_openid,F_uuid,F_port_password,F_MapID,F_Direction,F_AddTime,F_Message,F_Action)");
29
+            strSql.Append(" values (");
30
+            strSql.Append("@F_CusName,@F_CusPhone,@F_ComTitle,@F_ComContent,@F_SourceArea,@F_SourceAddress,@F_Key,@F_InfoType,@F_IsProtect,@F_File,@F_openid,@F_uuid,@F_port_password,@F_MapID,@F_Direction,@F_AddTime,@F_Message,@F_Action)");
31
+            strSql.Append(";select @@IDENTITY");
32
+            SqlParameter[] parameters = {
33
+                    new SqlParameter("@F_CusName", SqlDbType.NVarChar,20),
34
+                    new SqlParameter("@F_CusPhone", SqlDbType.NVarChar,20),
35
+                    new SqlParameter("@F_ComTitle", SqlDbType.NVarChar,200),
36
+                    new SqlParameter("@F_ComContent", SqlDbType.NVarChar),
37
+                    new SqlParameter("@F_SourceArea", SqlDbType.Int,4),
38
+                    new SqlParameter("@F_SourceAddress", SqlDbType.NVarChar,200),
39
+                    new SqlParameter("@F_Key", SqlDbType.VarChar,500),
40
+                    new SqlParameter("@F_InfoType", SqlDbType.Int,4),
41
+                    new SqlParameter("@F_IsProtect", SqlDbType.Int,4),
42
+                    new SqlParameter("@F_File", SqlDbType.VarChar,500),
43
+                    new SqlParameter("@F_openid", SqlDbType.NVarChar,50),
44
+                    new SqlParameter("@F_uuid", SqlDbType.NVarChar,50),
45
+                    new SqlParameter("@F_port_password", SqlDbType.NVarChar,200),
46
+                    new SqlParameter("@F_MapID", SqlDbType.Int,4),
47
+                    new SqlParameter("@F_Direction", SqlDbType.NVarChar,20),
48
+                    new SqlParameter("@F_AddTime", SqlDbType.DateTime),
49
+                    new SqlParameter("@F_Message", SqlDbType.NVarChar),
50
+                    new SqlParameter("@F_Action", SqlDbType.NVarChar,200)};
51
+            parameters[0].Value = model.F_CusName;
52
+            parameters[1].Value = model.F_CusPhone;
53
+            parameters[2].Value = model.F_ComTitle;
54
+            parameters[3].Value = model.F_ComContent;
55
+            parameters[4].Value = model.F_SourceArea;
56
+            parameters[5].Value = model.F_SourceAddress;
57
+            parameters[6].Value = model.F_Key;
58
+            parameters[7].Value = model.F_InfoType;
59
+            parameters[8].Value = model.F_IsProtect;
60
+            parameters[9].Value = model.F_File;
61
+            parameters[10].Value = model.F_openid;
62
+            parameters[11].Value = model.F_uuid;
63
+            parameters[12].Value = model.F_port_password;
64
+            parameters[13].Value = model.F_MapID;
65
+            parameters[14].Value = model.F_Direction;
66
+            parameters[15].Value = model.F_AddTime;
67
+            parameters[16].Value = model.F_Message;
68
+            parameters[17].Value = model.F_Action;
69
+
70
+            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
71
+            if (obj == null)
72
+            {
73
+                return 0;
74
+            }
75
+            else
76
+            {
77
+                return Convert.ToInt32(obj);
78
+            }
79
+        }
80
+        #endregion  Method
81
+    }
82
+}

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

236
     <Compile Include="Controllers\weibo\WeiBoApi\ReceiveMsg.cs" />
236
     <Compile Include="Controllers\weibo\WeiBoApi\ReceiveMsg.cs" />
237
     <Compile Include="Controllers\weibo\WeiBoController.cs" />
237
     <Compile Include="Controllers\weibo\WeiBoController.cs" />
238
     <Compile Include="Controllers\weibo\WeiBoReceiveController.cs" />
238
     <Compile Include="Controllers\weibo\WeiBoReceiveController.cs" />
239
+    <Compile Include="Controllers\weixin\WechatDockingController.cs" />
239
     <Compile Include="Controllers\weixin\WxCustomController.cs" />
240
     <Compile Include="Controllers\weixin\WxCustomController.cs" />
240
     <Compile Include="Controllers\weixin\WxLoginController.cs" />
241
     <Compile Include="Controllers\weixin\WxLoginController.cs" />
241
     <Compile Include="Controllers\weixin\WxReceiveController.cs" />
242
     <Compile Include="Controllers\weixin\WxReceiveController.cs" />
289
     <Folder Include="App_Data\" />
290
     <Folder Include="App_Data\" />
290
     <Folder Include="Views\KnowledgeClassNew\" />
291
     <Folder Include="Views\KnowledgeClassNew\" />
291
     <Folder Include="Views\Volunteer\" />
292
     <Folder Include="Views\Volunteer\" />
293
+    <Folder Include="Views\WechatDocking\" />
292
   </ItemGroup>
294
   </ItemGroup>
293
   <ItemGroup>
295
   <ItemGroup>
294
     <WCFMetadata Include="Service References\" />
296
     <WCFMetadata Include="Service References\" />

+ 3 - 1
CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Configs/system.config

53
   <!--应用的access_token-->
53
   <!--应用的access_token-->
54
   <add key="WeiBoAccessToken" value="2.00VbCStC01bkzx7bc0709d60OZTfkC" />
54
   <add key="WeiBoAccessToken" value="2.00VbCStC01bkzx7bc0709d60OZTfkC" />
55
   <!-- ================== 5:Redis配置 ================== -->
55
   <!-- ================== 5:Redis配置 ================== -->
56
-  <add key="Redis_Server" value="192.168.8.13"/>
56
+  <add key="Redis_Server" value="192.168.8.20"/>
57
   <add key="Redis_Port" value="6379"/>
57
   <add key="Redis_Port" value="6379"/>
58
   <!-- ================== 7:性能监控 - 配置语音文件盘符 ================== -->
58
   <!-- ================== 7:性能监控 - 配置语音文件盘符 ================== -->
59
   <add key="VideoHardDisc" value="D" />
59
   <add key="VideoHardDisc" value="D" />
75
   <!--验证码code-->
75
   <!--验证码code-->
76
   <add key="APPSignCode" value="#XYX@12345$zwfww%" />
76
   <add key="APPSignCode" value="#XYX@12345$zwfww%" />
77
   <add key="ZWWCode" value="XYXZWW_" />
77
   <add key="ZWWCode" value="XYXZWW_" />
78
+  <!-- ================== 11:新城办事处网格化对接 ================== -->
79
+  <add key="WeChatCode" value="minquan12345%#@6" />
78
 </appSettings>
80
 </appSettings>

+ 410 - 0
CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/weixin/WechatDockingController.cs

1
+using CallCenter.Utility;
2
+using CallCenter.Utility.log;
3
+using CallCenterApi.Interface.Controllers.Base;
4
+using System;
5
+using System.Collections.Generic;
6
+using System.Linq;
7
+using System.Transactions;
8
+using System.Web;
9
+using System.Web.Mvc;
10
+
11
+namespace CallCenterApi.Interface.Controllers.weixin
12
+{
13
+    public class WechatDockingController : BaseController
14
+    {
15
+        private BLL.T_Sys_DictionaryValue divBLL = new BLL.T_Sys_DictionaryValue();
16
+        private BLL.T_Sys_Area areaBLL = new BLL.T_Sys_Area();
17
+        BLL.T_Bus_WorkOrder_WXDocking_Map womagpbll = new BLL.T_Bus_WorkOrder_WXDocking_Map();
18
+
19
+        private AjaxResult ajresult = new AjaxResult();
20
+        /// <summary>
21
+        /// 测试验证
22
+        /// </summary>
23
+        /// <returns></returns>
24
+        public ActionResult GetScor(string uuid, string port_password, string openid, string timesamp)
25
+        {
26
+            var pp = Common.CodeValidate.ICodeValidateGriddingT(openid + timesamp + uuid, port_password);
27
+            return Success("获取", pp);
28
+        }
29
+        /// <summary>
30
+        /// 绑定微信openid
31
+        /// </summary>
32
+        /// <returns></returns>
33
+        [HttpPost]
34
+        public ActionResult BindOpenID(string uuid, string port_password, string openid, string timesamp)
35
+        {
36
+            using (TransactionScope trans = new TransactionScope())
37
+            {
38
+                #region 参数验证
39
+                if (string.IsNullOrEmpty(uuid))
40
+                {
41
+                    ajresult.state = (int)CodeStatus.ID不存在;
42
+                    ajresult.message = "客户唯一标识不能为空";
43
+                    return Process();
44
+                }
45
+                else if (uuid.Length > 50)
46
+                {
47
+                    ajresult.state = (int)CodeStatus.字符串超出长度;
48
+                    ajresult.message = "客户唯一标识超出长度";
49
+                    return Process();
50
+                }
51
+                if (string.IsNullOrEmpty(openid))
52
+                {
53
+                    ajresult.state = (int)CodeStatus.ID不存在;
54
+                    ajresult.message = "openid不能为空";
55
+                    return Process();
56
+                }
57
+                if (string.IsNullOrEmpty(timesamp))
58
+                {
59
+                    ajresult.state = (int)CodeStatus.必填字段为空;
60
+                    ajresult.message = "时间戳不能为空";
61
+                    return Process();
62
+                }
63
+                if (!Common.CodeValidate.ICodeValidateGridding(openid + timesamp + uuid, port_password))
64
+                {
65
+                    ajresult.state = (int)CodeStatus.安全验证未通过;
66
+                    ajresult.message = "安全验证未通过";
67
+                    return Process();
68
+                }
69
+                if (womagpbll.ExistsUUID(uuid))  //uuid是否已存在,防止重复添加
70
+                {
71
+                    ajresult.state = (int)CodeStatus.数据库错误;
72
+                    ajresult.message = "操作失败,信息已存在";
73
+                    return Process();
74
+                }
75
+                #endregion
76
+                string res = "";
77
+                var model = new BLL.T_Sys_Users().GetModelList(" F_OpenId='" + openid + "'  and F_Type=5 order by F_CreateTime desc").FirstOrDefault();
78
+                if (model != null)
79
+                {
80
+                    ajresult.state = (int)CodeStatus.SUCCESS;
81
+                    ajresult.message = "获取成功";
82
+                    ajresult.data = openid;
83
+                    res = openid + "||" + model.F_Id;
84
+                }
85
+                else
86
+                {
87
+                    model = new Model.T_Sys_Users();
88
+                    model.F_OpenId = openid;
89
+                    model.F_Type = 5;//微信对接
90
+                    model.F_CreateTime = DateTime.Now;
91
+                    long sysid = new BLL.T_Sys_Users().Add(model);
92
+                    res = openid + "||" + model.F_Id + "||" + sysid;
93
+                    if (sysid > 0)
94
+                    {
95
+                        ajresult.state = (int)CodeStatus.SUCCESS;
96
+                        ajresult.message = "获取成功";
97
+                        ajresult.data = openid;
98
+                    }
99
+                    else
100
+                    {
101
+                        ajresult.state = (int)CodeStatus.执行失败;
102
+                        ajresult.message = "获取失败";
103
+                    }
104
+                }
105
+
106
+                int mapid = AddMap(uuid, port_password, "receive", "GetOpenID", openid, res);
107
+
108
+                AddDockingLogs("", "", "", "", "", "", uuid, port_password, "receive", ajresult.ToJson(), "GetOpenID", openid, 0, 0, 0, 0, mapid);
109
+
110
+                trans.Complete();
111
+            }
112
+            return Process();
113
+        }
114
+
115
+        /// <summary>
116
+        /// 获取关键词
117
+        /// </summary>
118
+        /// <returns></returns>
119
+        [HttpPost]
120
+        public ActionResult GetKeys(string uuid, string port_password, string openid, string timesamp)
121
+        {
122
+            using (TransactionScope trans = new TransactionScope())
123
+            {
124
+                #region 参数验证
125
+                if (string.IsNullOrEmpty(uuid))
126
+                {
127
+                    ajresult.state = (int)CodeStatus.ID不存在;
128
+                    ajresult.message = "客户唯一标识不能为空";
129
+                    return Process();
130
+                }
131
+                else if (uuid.Length > 50)
132
+                {
133
+                    ajresult.state = (int)CodeStatus.字符串超出长度;
134
+                    ajresult.message = "客户唯一标识超出长度";
135
+                    return Process();
136
+                }
137
+                if (string.IsNullOrEmpty(openid))
138
+                {
139
+                    ajresult.state = (int)CodeStatus.ID不存在;
140
+                    ajresult.message = "openid不能为空";
141
+                    return Process();
142
+                }
143
+                if (string.IsNullOrEmpty(timesamp))
144
+                {
145
+                    ajresult.state = (int)CodeStatus.必填字段为空;
146
+                    ajresult.message = "时间戳不能为空";
147
+                    return Process();
148
+                }
149
+                if (!Common.CodeValidate.ICodeValidateGridding(openid + timesamp + uuid, port_password))
150
+                {
151
+                    ajresult.state = (int)CodeStatus.安全验证未通过;
152
+                    ajresult.message = "安全验证未通过";
153
+                    return Process();
154
+                }
155
+                if (womagpbll.ExistsUUID(uuid))  //uuid是否已存在,防止重复添加
156
+                {
157
+                    ajresult.state = (int)CodeStatus.数据库错误;
158
+                    ajresult.message = "操作失败,信息已存在";
159
+                    return Process();
160
+                }
161
+                #endregion
162
+                var divlist = divBLL.GetModelList(" F_PrentId=38 and F_State=0  order by F_ValueId ");
163
+
164
+                var divnewList = divlist.Select(x=>{ return new { id = x.F_ValueId, value = x.F_Value }; });
165
+
166
+                ajresult.state = (int)CodeStatus.SUCCESS;
167
+                ajresult.message = "关键词获取成功";
168
+                ajresult.data = divnewList;
169
+
170
+                int mapid = AddMap(uuid, port_password, "receive", "GetKeys", openid, "");
171
+
172
+                AddDockingLogs("", "", "", "", "", "", uuid, port_password, "receive", ajresult.ToJson(), "GetKeys", openid, 0, 0, 0, 0, mapid);
173
+                trans.Complete();
174
+            }
175
+            return Process();
176
+        }
177
+        /// <summary>
178
+        /// 获取事件区域
179
+        /// </summary>
180
+        /// <returns></returns>
181
+        [HttpPost]
182
+        public ActionResult GetAreas(string uuid, string port_password, string openid, string timesamp)
183
+        {
184
+            using (TransactionScope trans = new TransactionScope())
185
+            {
186
+                #region 参数验证
187
+                if (string.IsNullOrEmpty(uuid))
188
+                {
189
+                    ajresult.state = (int)CodeStatus.ID不存在;
190
+                    ajresult.message = "客户唯一标识不能为空";
191
+                    return Process();
192
+                }
193
+                else if (uuid.Length > 50)
194
+                {
195
+                    ajresult.state = (int)CodeStatus.字符串超出长度;
196
+                    ajresult.message = "客户唯一标识超出长度";
197
+                    return Process();
198
+                }
199
+                if (string.IsNullOrEmpty(openid))
200
+                {
201
+                    ajresult.state = (int)CodeStatus.ID不存在;
202
+                    ajresult.message = "openid不能为空";
203
+                    return Process();
204
+                }
205
+                if (string.IsNullOrEmpty(timesamp))
206
+                {
207
+                    ajresult.state = (int)CodeStatus.必填字段为空;
208
+                    ajresult.message = "时间戳不能为空";
209
+                    return Process();
210
+                }
211
+                if (!Common.CodeValidate.ICodeValidateGridding(openid + timesamp + uuid, port_password))
212
+                {
213
+                    ajresult.state = (int)CodeStatus.安全验证未通过;
214
+                    ajresult.message = "安全验证未通过";
215
+                    return Process();
216
+                }
217
+                if (womagpbll.ExistsUUID(uuid))  //uuid是否已存在,防止重复添加
218
+                {
219
+                    ajresult.state = (int)CodeStatus.数据库错误;
220
+                    ajresult.message = "操作失败,信息已存在";
221
+                    return Process();
222
+                }
223
+                #endregion
224
+                var arealist = areaBLL.GetModelList(" isnull(F_PrentId,0)=0 and F_State=0 order by F_AreaId ");
225
+
226
+                var areanewList = arealist.Select(x => { return new { id = x.F_AreaId, value = x.F_AreaName }; });
227
+
228
+                ajresult.state = (int)CodeStatus.SUCCESS;
229
+                ajresult.message = "地区获取成功";
230
+                ajresult.data = areanewList;
231
+
232
+                int mapid = AddMap(uuid, port_password, "receive", "GetAreas", openid, "");
233
+
234
+                AddDockingLogs("", "", "", "", "", "", uuid, port_password, "receive", ajresult.ToJson(), "GetAreas", openid, 0, 0, 0, 0, mapid);
235
+
236
+                trans.Complete();
237
+            }
238
+            return Process();
239
+        }
240
+
241
+        /// <summary>
242
+        /// 添加工单
243
+        /// </summary>
244
+        /// <returns></returns>
245
+        [HttpPost]
246
+        public ActionResult AddWxOrders(string uuid, string port_password, string openid, string timesamp, string cusname, string cusphone, string title, string content, string sourceaddress, string files, int sourcearea = 0, int keys = 0, int type = 0, int isprotect = 0)
247
+        {
248
+            using (TransactionScope trans = new TransactionScope())
249
+            {
250
+                #region 参数验证
251
+                if (string.IsNullOrEmpty(uuid))
252
+                {
253
+                    ajresult.state = (int)CodeStatus.ID不存在;
254
+                    ajresult.message = "客户唯一标识不能为空";
255
+                    return Process();
256
+                }
257
+                else if (uuid.Length > 50)
258
+                {
259
+                    ajresult.state = (int)CodeStatus.字符串超出长度;
260
+                    ajresult.message = "客户唯一标识超出长度";
261
+                    return Process();
262
+                }
263
+                if (string.IsNullOrEmpty(openid))
264
+                {
265
+                    ajresult.state = (int)CodeStatus.ID不存在;
266
+                    ajresult.message = "openid不能为空";
267
+                    return Process();
268
+                }
269
+                if (string.IsNullOrEmpty(timesamp))
270
+                {
271
+                    ajresult.state = (int)CodeStatus.必填字段为空;
272
+                    ajresult.message = "时间戳不能为空";
273
+                    return Process();
274
+                }
275
+                if (!Common.CodeValidate.ICodeValidateGridding(openid + timesamp + uuid, port_password))
276
+                {
277
+                    ajresult.state = (int)CodeStatus.安全验证未通过;
278
+                    ajresult.message = "安全验证未通过";
279
+                    return Process();
280
+                }
281
+                if (womagpbll.ExistsUUID(uuid))  //uuid是否已存在,防止重复添加
282
+                {
283
+                    ajresult.state = (int)CodeStatus.数据库错误;
284
+                    ajresult.message = "操作失败,信息已存在";
285
+                    return Process();
286
+                }
287
+                #endregion
288
+
289
+                var wxuser = new BLL.T_Sys_Users().GetModelList(" F_OpenId='" + openid + "'  and F_Type=5 order by F_CreateTime desc").FirstOrDefault();
290
+                if(wxuser==null)
291
+                {
292
+                    ajresult.state = (int)CodeStatus.用户无效;
293
+                    ajresult.message = "用户无效";
294
+                    return Process();
295
+                }
296
+
297
+                workorder.WorkOrderController wo = new workorder.WorkOrderController();
298
+                string workorderid = wo.AddWorkOrderBySource(5, cusname, "", cusphone, "", "", "", "", cusphone, title,content, sourcearea, sourceaddress, keys.ToString(), "", type, 0, 0, isprotect, 0, files);
299
+
300
+                int mapid = AddMap(uuid, port_password, "receive", "AddWxOrders", openid, workorderid);
301
+
302
+                if (string.IsNullOrEmpty(workorderid))
303
+                {
304
+                    ajresult.state = (int)CodeStatus.执行失败;
305
+                    ajresult.message = "操作失败";
306
+                }
307
+                else
308
+                {
309
+                    Model.T_Bus_UserWorkOrder tbu = new Model.T_Bus_UserWorkOrder();
310
+                    tbu.F_UserId = wxuser.F_Id;
311
+                    tbu.F_WorkOrderId = workorderid;
312
+                    new BLL.T_Bus_UserWorkOrder().Add(tbu);
313
+
314
+                    ajresult.state = (int)CodeStatus.SUCCESS;
315
+                    ajresult.message = "操作成功";
316
+                    ajresult.data = workorderid;  //反馈ID
317
+
318
+                }
319
+
320
+                AddDockingLogs(cusname, cusphone, title, content, sourceaddress, files, uuid, port_password, "receive", ajresult.ToJson(), "AddWxOrders", openid, sourcearea, keys, type, isprotect, mapid);
321
+                trans.Complete();
322
+            }
323
+            return Process();
324
+        }
325
+
326
+        #region 私有方法
327
+        /// <summary>
328
+        /// 成功的消息格式化
329
+        /// </summary>
330
+        /// <param name="message"></param>
331
+        /// <returns></returns>
332
+        protected virtual ActionResult Process()
333
+        {
334
+            string methodName = new System.Diagnostics.StackTrace(true).GetFrame(1).GetMethod().Name;   //事件源
335
+            LogInterface.WriteLog(this.GetType().ToString() + " -- " + methodName + "\r\n" + ajresult.state + "|" + ajresult.data + ajresult.message); //日志
336
+            var jsonMsg = new AjaxResult { state = ajresult.state, message = ajresult.message, data = ajresult.data }.ToJson();
337
+            return Content(jsonMsg);
338
+        }
339
+
340
+        protected int AddMap(string uuid, string port_password, string direction, string action, string openid,string workorderid)
341
+        {
342
+            Model.T_Bus_WorkOrder_WXDocking_Map womagpmodel = new Model.T_Bus_WorkOrder_WXDocking_Map();
343
+            womagpmodel.F_WorkOrderId = workorderid;
344
+            womagpmodel.uuid = uuid;
345
+            womagpmodel.openid = openid;
346
+            womagpmodel.port_password = port_password;
347
+            womagpmodel.F_Direction = "receive";
348
+            womagpmodel.F_AddTime = DateTime.Now;
349
+            womagpmodel.F_Action = action;
350
+            int mapid = womagpbll.Add(womagpmodel);
351
+            return mapid;
352
+        }
353
+
354
+        /// <summary>
355
+        /// 添加日志
356
+        /// </summary>
357
+        protected void AddDockingLogs(string cusname, string cusphone, string title, string content, string sourceaddress, string files,
358
+            string uuid, string port_password, string direction, string msg,string action,string openid, int sourcearea=0, int keys = 0, int type = 0, int isprotect = 0, int mapid = 0)
359
+        {
360
+            Model.T_Bus_WorkOrder_WXDocking_logs logs = new Model.T_Bus_WorkOrder_WXDocking_logs();
361
+
362
+            logs.F_CusName = cusname;
363
+            logs.F_CusPhone = cusphone;
364
+            logs.F_ComTitle = title;
365
+            logs.F_ComContent = content;
366
+            logs.F_SourceArea = sourcearea;
367
+            logs.F_SourceAddress = sourceaddress;
368
+            logs.F_InfoType = type;
369
+            logs.F_IsProtect = isprotect;
370
+            logs.F_Key = keys.ToString();
371
+            logs.F_File = files;
372
+
373
+            logs.F_uuid = uuid;
374
+            logs.F_port_password = port_password;
375
+            logs.F_MapID = mapid;
376
+            logs.F_Direction = direction;
377
+            logs.F_AddTime = DateTime.Now;
378
+            logs.F_Message = msg;
379
+            logs.F_Action = action;
380
+            logs.F_openid = openid;
381
+
382
+            new BLL.T_Bus_WorkOrder_WXDocking_logs().Add(logs);
383
+        }
384
+        #endregion
385
+    }
386
+
387
+    /// <summary>
388
+    /// 状态枚举
389
+    /// </summary>
390
+    public enum CodeStatus
391
+    {
392
+        SUCCESS = 200,
393
+        安全验证未通过 = 400,
394
+        无法预测的程序错误 = 501,
395
+        参数格式错误 = 100,
396
+        必填字段为空 = 101,
397
+        字符串超出长度 = 102,
398
+        数据库错误 = 103,
399
+        执行超时 = 104,
400
+        参数逻辑错误 = 105,
401
+        ID不存在 = 106,
402
+        无可上传文件 = 107,
403
+        执行失败 = 108,
404
+        用户已禁用 = 120,
405
+        用户无效=121,
406
+
407
+        异常结果类型 = 500
408
+
409
+    }
410
+}

+ 2 - 2
CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Web.config

18
   </appSettings>
18
   </appSettings>
19
   <connectionStrings>
19
   <connectionStrings>
20
     <!--<add name="ConnectionString" connectionString="Data Source=192.168.8.3;User ID=sa;pwd=800100;Initial Catalog=12345_YuCheng;"/>-->
20
     <!--<add name="ConnectionString" connectionString="Data Source=192.168.8.3;User ID=sa;pwd=800100;Initial Catalog=12345_YuCheng;"/>-->
21
-    <!--<add name="ConnectionString" connectionString="Data Source=192.168.8.3;User ID=sa;pwd=800100;Initial Catalog=12345_MinQuan;"/>-->
22
-    <add name="ConnectionString" connectionString="Data Source=192.168.8.3;User ID=sa;pwd=800100;Initial Catalog=12345_SuiXian;"/>
21
+    <add name="ConnectionString" connectionString="Data Source=192.168.8.3;User ID=sa;pwd=800100;Initial Catalog=12345_MinQuan;"/>
22
+    <!--<add name="ConnectionString" connectionString="Data Source=192.168.8.3;User ID=sa;pwd=800100;Initial Catalog=12345_SuiXian;"/>-->
23
     <!--<add name="ConnectionString" connectionString="Data Source=192.168.8.3;User ID=sa;pwd=800100;Initial Catalog=12345_YongCheng;"/>-->
23
     <!--<add name="ConnectionString" connectionString="Data Source=192.168.8.3;User ID=sa;pwd=800100;Initial Catalog=12345_YongCheng;"/>-->
24
     <!--<add name="ConnectionString" connectionString="Data Source=192.168.8.3;User ID=sa;pwd=800100;Initial Catalog=12345_ZheCheng;"/>-->
24
     <!--<add name="ConnectionString" connectionString="Data Source=192.168.8.3;User ID=sa;pwd=800100;Initial Catalog=12345_ZheCheng;"/>-->
25
     <!--<add name="ConnectionString" connectionString="Data Source=192.168.8.3;User ID=sa;pwd=800100;Initial Catalog=12345_XiaYi;"/>-->
25
     <!--<add name="ConnectionString" connectionString="Data Source=192.168.8.3;User ID=sa;pwd=800100;Initial Catalog=12345_XiaYi;"/>-->

+ 2 - 0
CallCenterApi/CallCenterApi.Model/CallCenterApi.Model.csproj

53
     <Compile Include="T_Bus_VisitResultRecords.cs" />
53
     <Compile Include="T_Bus_VisitResultRecords.cs" />
54
     <Compile Include="T_Bus_WorkOrderReport.cs" />
54
     <Compile Include="T_Bus_WorkOrderReport.cs" />
55
     <Compile Include="T_Bus_UserWorkOrder.cs" />
55
     <Compile Include="T_Bus_UserWorkOrder.cs" />
56
+    <Compile Include="T_Bus_WorkOrder_WXDocking_logs.cs" />
57
+    <Compile Include="T_Bus_WorkOrder_WXDocking_Map.cs" />
56
     <Compile Include="T_Call_RecordSet.cs" />
58
     <Compile Include="T_Call_RecordSet.cs" />
57
     <Compile Include="T_Bus_WorkOrder_GovernmentServiceWO_Map.cs" />
59
     <Compile Include="T_Bus_WorkOrder_GovernmentServiceWO_Map.cs" />
58
     <Compile Include="T_Chat_InOut.cs" />
60
     <Compile Include="T_Chat_InOut.cs" />

+ 92 - 0
CallCenterApi/CallCenterApi.Model/T_Bus_WorkOrder_WXDocking_Map.cs

1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Threading.Tasks;
6
+
7
+namespace CallCenterApi.Model
8
+{
9
+    /// <summary>
10
+	/// T_Bus_WorkOrder_WXDocking_Map:实体类(属性说明自动提取数据库字段的描述信息)
11
+	/// </summary>
12
+	[Serializable]
13
+    public partial class T_Bus_WorkOrder_WXDocking_Map
14
+    {
15
+        public T_Bus_WorkOrder_WXDocking_Map()
16
+        { }
17
+        #region Model
18
+        private int _f_id;
19
+        private string _f_workorderid;
20
+        private string _f_direction;
21
+        private string _f_action;
22
+        private DateTime? _f_addtime;
23
+        private string _openid;
24
+        private string _uuid;
25
+        private string _port_password;
26
+        /// <summary>
27
+        /// id,自增
28
+        /// </summary>
29
+        public int F_Id
30
+        {
31
+            set { _f_id = value; }
32
+            get { return _f_id; }
33
+        }
34
+        /// <summary>
35
+        /// 工单流水号
36
+        /// </summary>
37
+        public string F_WorkOrderId
38
+        {
39
+            set { _f_workorderid = value; }
40
+            get { return _f_workorderid; }
41
+        }
42
+        /// <summary>
43
+        /// 方向:send,receive
44
+        /// </summary>
45
+        public string F_Direction
46
+        {
47
+            set { _f_direction = value; }
48
+            get { return _f_direction; }
49
+        }
50
+        /// <summary>
51
+        /// 对应方法
52
+        /// </summary>
53
+        public string F_Action
54
+        {
55
+            set { _f_action = value; }
56
+            get { return _f_action; }
57
+        }
58
+        /// <summary>
59
+        /// 添加时间
60
+        /// </summary>
61
+        public DateTime? F_AddTime
62
+        {
63
+            set { _f_addtime = value; }
64
+            get { return _f_addtime; }
65
+        }
66
+        /// <summary>
67
+        /// 
68
+        /// </summary>
69
+        public string openid
70
+        {
71
+            set { _openid = value; }
72
+            get { return _openid; }
73
+        }
74
+        /// <summary>
75
+        /// 
76
+        /// </summary>
77
+        public string uuid
78
+        {
79
+            set { _uuid = value; }
80
+            get { return _uuid; }
81
+        }
82
+        /// <summary>
83
+        /// 
84
+        /// </summary>
85
+        public string port_password
86
+        {
87
+            set { _port_password = value; }
88
+            get { return _port_password; }
89
+        }
90
+        #endregion Model
91
+    }
92
+}

+ 191 - 0
CallCenterApi/CallCenterApi.Model/T_Bus_WorkOrder_WXDocking_logs.cs

1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Threading.Tasks;
6
+
7
+namespace CallCenterApi.Model
8
+{
9
+    /// <summary>
10
+	/// 反馈表
11
+	/// </summary>
12
+	[Serializable]
13
+    public partial class T_Bus_WorkOrder_WXDocking_logs
14
+    {
15
+        public T_Bus_WorkOrder_WXDocking_logs()
16
+        { }
17
+        #region Model
18
+        private int _f_id;
19
+        private string _f_cusname;
20
+        private string _f_cusphone;
21
+        private string _f_comtitle;
22
+        private string _f_comcontent;
23
+        private int? _f_sourcearea;
24
+        private string _f_sourceaddress;
25
+        private string _f_key;
26
+        private int? _f_infotype;
27
+        private int? _f_isprotect;
28
+        private string _f_file;
29
+        private string _f_openid;
30
+        private string _f_uuid;
31
+        private string _f_port_password;
32
+        private int? _f_mapid;
33
+        private string _f_direction;
34
+        private DateTime? _f_addtime;
35
+        private string _f_message;
36
+        private string _f_action;
37
+        /// <summary>
38
+        /// 
39
+        /// </summary>
40
+        public int F_Id
41
+        {
42
+            set { _f_id = value; }
43
+            get { return _f_id; }
44
+        }
45
+        /// <summary>
46
+        /// 联系人姓名
47
+        /// </summary>
48
+        public string F_CusName
49
+        {
50
+            set { _f_cusname = value; }
51
+            get { return _f_cusname; }
52
+        }
53
+        /// <summary>
54
+        /// 联系人电话
55
+        /// </summary>
56
+        public string F_CusPhone
57
+        {
58
+            set { _f_cusphone = value; }
59
+            get { return _f_cusphone; }
60
+        }
61
+        /// <summary>
62
+        /// 诉求主题
63
+        /// </summary>
64
+        public string F_ComTitle
65
+        {
66
+            set { _f_comtitle = value; }
67
+            get { return _f_comtitle; }
68
+        }
69
+        /// <summary>
70
+        /// 诉求内容
71
+        /// </summary>
72
+        public string F_ComContent
73
+        {
74
+            set { _f_comcontent = value; }
75
+            get { return _f_comcontent; }
76
+        }
77
+        /// <summary>
78
+        /// 事发区域
79
+        /// </summary>
80
+        public int? F_SourceArea
81
+        {
82
+            set { _f_sourcearea = value; }
83
+            get { return _f_sourcearea; }
84
+        }
85
+        /// <summary>
86
+        /// 详细地址
87
+        /// </summary>
88
+        public string F_SourceAddress
89
+        {
90
+            set { _f_sourceaddress = value; }
91
+            get { return _f_sourceaddress; }
92
+        }
93
+        /// <summary>
94
+        /// 关键词id
95
+        /// </summary>
96
+        public string F_Key
97
+        {
98
+            set { _f_key = value; }
99
+            get { return _f_key; }
100
+        }
101
+        /// <summary>
102
+        /// 诉求类型:9咨询,10求助,11投诉,12建议,13表扬
103
+        /// </summary>
104
+        public int? F_InfoType
105
+        {
106
+            set { _f_infotype = value; }
107
+            get { return _f_infotype; }
108
+        }
109
+        /// <summary>
110
+        /// 是否保密(0:否1:是)
111
+        /// </summary>
112
+        public int? F_IsProtect
113
+        {
114
+            set { _f_isprotect = value; }
115
+            get { return _f_isprotect; }
116
+        }
117
+        /// <summary>
118
+        /// 附件id
119
+        /// </summary>
120
+        public string F_File
121
+        {
122
+            set { _f_file = value; }
123
+            get { return _f_file; }
124
+        }
125
+        /// <summary>
126
+        /// 微信openid
127
+        /// </summary>
128
+        public string F_openid
129
+        {
130
+            set { _f_openid = value; }
131
+            get { return _f_openid; }
132
+        }
133
+        /// <summary>
134
+        /// 
135
+        /// </summary>
136
+        public string F_uuid
137
+        {
138
+            set { _f_uuid = value; }
139
+            get { return _f_uuid; }
140
+        }
141
+        /// <summary>
142
+        /// port_password
143
+        /// </summary>
144
+        public string F_port_password
145
+        {
146
+            set { _f_port_password = value; }
147
+            get { return _f_port_password; }
148
+        }
149
+        /// <summary>
150
+        /// MapID
151
+        /// </summary>
152
+        public int? F_MapID
153
+        {
154
+            set { _f_mapid = value; }
155
+            get { return _f_mapid; }
156
+        }
157
+        /// <summary>
158
+        /// 方向:receive send
159
+        /// </summary>
160
+        public string F_Direction
161
+        {
162
+            set { _f_direction = value; }
163
+            get { return _f_direction; }
164
+        }
165
+        /// <summary>
166
+        /// 添加时间
167
+        /// </summary>
168
+        public DateTime? F_AddTime
169
+        {
170
+            set { _f_addtime = value; }
171
+            get { return _f_addtime; }
172
+        }
173
+        /// <summary>
174
+        /// 消息内容
175
+        /// </summary>
176
+        public string F_Message
177
+        {
178
+            set { _f_message = value; }
179
+            get { return _f_message; }
180
+        }
181
+        /// <summary>
182
+        /// 方法
183
+        /// </summary>
184
+        public string F_Action
185
+        {
186
+            set { _f_action = value; }
187
+            get { return _f_action; }
188
+        }
189
+        #endregion Model
190
+    }
191
+}