Ver Código Fonte

财务对接相关接口

zhengbingbing 5 anos atrás
pai
commit
79775cc188

+ 14 - 0
codegit/CallCenterApi/CallCenterApi.Common/DESEncrypt.cs

@@ -98,5 +98,19 @@ namespace CallCenterApi.Common
98 98
         }
99 99
 
100 100
         #endregion
101
+
102
+        //加密算法HmacSHA256  
103
+        public static string HmacSHA256(string secret, string signKey)
104
+        {
105
+            string signRet = string.Empty;
106
+            using (HMACSHA256 mac = new HMACSHA256(Encoding.UTF8.GetBytes(secret)))
107
+            {
108
+                byte[] hash = mac.ComputeHash(Encoding.UTF8.GetBytes(signKey));
109
+                signRet = Convert.ToBase64String(hash);
110
+                //signRet = ToHexString(hash); ;
111
+            }
112
+            return signRet;
113
+        }
114
+
101 115
     }
102 116
 }

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

@@ -226,6 +226,7 @@
226 226
     <Compile Include="Controllers\RoleInfoController.cs" />
227 227
     <Compile Include="Controllers\Satisfaction\QuestionAnswerController.cs" />
228 228
     <Compile Include="Controllers\SeatGroupController.cs" />
229
+    <Compile Include="Controllers\SignController.cs" />
229 230
     <Compile Include="Controllers\SMSController.cs" />
230 231
     <Compile Include="Controllers\SMSZXZBController.cs" />
231 232
     <Compile Include="Controllers\SysConfigController.cs" />
@@ -267,6 +268,7 @@
267 268
     <Compile Include="Models\Dto\Ask_QuestionDto.cs" />
268 269
     <Compile Include="Models\Dto\CallPlan.cs" />
269 270
     <Compile Include="Models\Dto\CategoryDto.cs" />
271
+    <Compile Include="Models\Dto\DockingCustomerListDto.cs" />
270 272
     <Compile Include="Models\Dto\ModuleInfoDto.cs" />
271 273
     <Compile Include="Models\Dto\OrderDto.cs" />
272 274
     <Compile Include="Models\Dto\ProductDto.cs" />

+ 4 - 0
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Configs/system.config

@@ -33,4 +33,8 @@
33 33
   <!--<add key="MessageUrl" value="http://sycw.800100.net/index.html?menucode=GDXQ" />-->
34 34
   <!-- ================== 4:公司名称中需截取掉的字符串 ================== -->
35 35
   <add key="keystring" value="有限公司,公司,科技,网络,信息,河南,河南省,洛阳,洛阳市,郑州,郑州市,南阳,南阳市,新乡,新乡市,有限、商贸、市"/>
36
+  <!-- ================== 5:亿企财务公司对接 ================== -->
37
+  <add key="appKey" value="9b4a98b1bbce465381d323e0005c8588" />
38
+  <add key="appSecret" value="hgtRQ2iauHEOMYg3QlvamA==" />
39
+  <add key="version" value="1.0.0" />
36 40
 </appSettings>

+ 154 - 374
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/SignController.cs

@@ -1,5 +1,7 @@
1 1
 using CallCenter.Utility;
2
+using CallCenterApi.Common;
2 3
 using CallCenterApi.Interface.Controllers.Base;
4
+using CallCenterApi.Interface.Models.Dto;
3 5
 using Newtonsoft.Json;
4 6
 using Newtonsoft.Json.Linq;
5 7
 using System;
@@ -19,414 +21,192 @@ namespace CallCenterApi.Interface.Controllers
19 21
 {
20 22
     public class SignController : BaseController
21 23
     {
22
-        // GET: Sign
23
-        public ActionResult Index()
24
+        //获取客户信息
25
+        public ActionResult GetCustomers(string cusname)
24 26
         {
25
-            return View();
26
-        }
27
-
28
-        public ActionResult GetSign(List<string> keyvalue)
29
-        {
30
-            //model.timestamp = DateTimeConvert.ToTimespan(DateTime.Now);//保存导入时间时间戳
31
-            var input = keyvalue;
32
-
33
-            var keys = new List<string>();
34
-            var values = new List<string>();
35
-
36
-            for (int index = 0; index < input.Count; index++)
37
-            {
38
-                if (index % 2 == 0) keys.Add(input[index]);
39
-                else values.Add(input[index]);
40
-            }
41
-            //添加时间戳
42
-            keys.Add("timestamp");
43
-            values.Add(DateTimeToInt(DateTime.Now).ToString());
44
-            var result = keys.Zip(values, (key, value) =>
45
-                                    new KeyValuePair<string, string>(key, value)).ToList();
46
-            var sign = GenerateSign(result, "");
47
-
48
-            return Success( sign);
49
-        }
50
-
51
-        public static int DateTimeToInt(DateTime dt)
52
-        {
53
-            int date = 0;
54
-            TimeSpan ts2 = new TimeSpan(dt.Ticks);
55
-            TimeSpan ts3 = new TimeSpan(DateTime.Parse("1970-01-01").Ticks);
56
-            TimeSpan ts_1 = ts2.Subtract(ts3).Duration();
57
-            Int32 NowMinu = (Int32)ts_1.TotalSeconds;
58
-            date = NowMinu;
59
-            return date;
60
-        }
61
-        /// <summary>  
62
-        /// 将c# DateTime时间格式转换为Unix时间戳格式  
63
-        /// </summary>  
64
-        /// <param name="time">时间</param>  
65
-        /// <returns>long</returns>  
66
-        public static long ConvertDateTimeToInt(System.DateTime time)
67
-        {
68
-            System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1, 0, 0, 0, 0));
69
-            long t = (time.Ticks - startTime.Ticks) / 10000;   //除10000调整为13位      
70
-            return t;
71
-        }
72
-
73
-        #region 计算签名
74
-        /// <summary>
75
-        /// 生成签名
76
-        /// </summary>
77
-        /// <param name="paramlst">参数列表</param>
78
-        /// <param name="IsToUpper">是否转大写</param>
79
-        /// <param name="IsDirect">是否直接加上签名Key</param>
80
-        /// <returns></returns>
81
-        public static string GenerateSign(List<KeyValuePair<string, string>> lst, string privateKey)
82
-        {
83
-            Comparison<KeyValuePair<string, string>> Comparer = new Comparison<KeyValuePair<string, string>>(CompareKeyValuepair);
84
-            lst.Sort(Comparer);
85
-            var paramlst = lst.Where(p => !string.IsNullOrEmpty(p.Value)).ToList();
86
-            string signstr = string.Join("&", paramlst.Select(p => p.Key + "=" + p.Value)) + privateKey;
87
-            return Sign(signstr, "UTF-8");
88
-        }
89
-
90
-        /// <summary>
91
-        /// 根据Key比较排序位置
92
-        /// </summary>
93
-        private static int CompareKeyValuepair(KeyValuePair<string, string> p1, KeyValuePair<string, string> p2)
94
-        {
95
-            return string.Compare(p1.Key, p2.Key);
96
-        }
97
-
98
-        /// <summary>
99
-        /// 签名字符串
100
-        /// </summary>
101
-        /// <param name="prestr">需要签名的字符串</param>
102
-        /// <param name="key">密钥</param>
103
-        /// <param name="inputCharset">编码格式</param>
104
-        /// <returns>签名结果</returns>
105
-        public static string Sign(string prestr, string inputCharset)
106
-        {
107
-            StringBuilder sb = new StringBuilder();
108
-            MD5 md5 = new MD5CryptoServiceProvider();
109
-            byte[] t = md5.ComputeHash(Encoding.GetEncoding(inputCharset).GetBytes(prestr));
110
-            foreach (byte t1 in t)
111
-            {
112
-                sb.Append(t1.ToString("x2"));
113
-            }
114
-            return sb.ToString();
115
-        }
116
-        #endregion
117
-
118
-        public ActionResult getsignature()
119
-        {
120
-            String appKey = "9b4a98b1bbce465381d323e0005c8588";
121
-            String appSecret = "hgtRQ2iauHEOMYg3QlvamA==";
122
-            String version = "1.0.0";
123
-            long timestamp = ConvertDateTimeToInt(DateTime.Now);
124
-            String nonce = System.Guid.NewGuid().ToString("N");
125
-            string mergeStr = nonce + appKey + appSecret + timestamp + version;
126
-            string encodedStr = System.Web.HttpUtility.UrlEncode(mergeStr);
127
-            string signStr = HmacSHA256(appSecret,encodedStr);
128
-            //return signStr;
129
-
130
-            string strURL = "https://openapi.17win.com";
27
+            string strURL = "https://openapi.17win.com/gateway/openyqdz/manage/customer/queryCustomers";
131 28
             var m = new
132 29
             {
133
-                timestamp,
134
-                version,
135
-                appKey,
136
-                signStr,
137
-                nonce
30
+                customerLikeCriteria = new { fullName= cusname },
31
+                pageNo = 1,
32
+                pageSize = 20
138 33
             };
34
+
139 35
             //实体序列化和反序列化
140 36
             string json1 = JsonConvert.SerializeObject(m);
141
-            string strHTML = HttpPost(strURL, json1);
142
-            JObject jo1 = (JObject)JsonConvert.DeserializeObject(strHTML);
143
-            if (jo1 != null && jo1["state"].ToString() == "success")
37
+            string strHTML = GetP(strURL, json1);
38
+            DockingCusResultDto jo1 = JsonConvert.DeserializeObject<DockingCusResultDto>(strHTML);
39
+            if (jo1 != null)
144 40
             {
145
-                return Success("成功");
41
+                return Success("成功", jo1);
146 42
             }
147 43
             return Error("失败");
148 44
         }
149 45
 
150
-
151
-
152
-        //加密算法HmacSHA256  
153
-        public string HmacSHA256(string secret, string signKey)
46
+        //获取科目余额
47
+        public ActionResult GetAccountBalance(string customerId,string beginPeriod,string endPeriod)
154 48
         {
155
-            string signRet = string.Empty;
156
-            using (HMACSHA256 mac = new HMACSHA256(Encoding.UTF8.GetBytes(signKey)))
49
+            string strURL = "https://openapi.17win.com/gateway/openyqdz/finance/sheetController/queryAccountBalanceSheet";
50
+            var m = new
157 51
             {
158
-                byte[] hash = mac.ComputeHash(Encoding.UTF8.GetBytes(secret));
159
-                signRet = Convert.ToBase64String(hash);
160
-                //signRet = ToHexString(hash); ;
161
-            }
162
-            return signRet;
163
-        }
52
+                customerId,
53
+                beginPeriod,
54
+                endPeriod,
55
+                pageNo = 0,
56
+                pageSize = 20
57
+            };
164 58
 
165
-        //byte[]转16进制格式string
166
-        public static string ToHexString(byte[] bytes)
167
-        {
168
-            string hexString = string.Empty;
169
-            if (bytes != null)
59
+            //实体序列化和反序列化
60
+            string json1 = JsonConvert.SerializeObject(m);
61
+            string strHTML = GetP(strURL, json1);
62
+            DockingBalanceResultDto jo1 = JsonConvert.DeserializeObject<DockingBalanceResultDto>(strHTML);
63
+            if (jo1 != null)
170 64
             {
171
-                StringBuilder strB = new StringBuilder();
172
-                foreach (byte b in bytes)
173
-                {
174
-                    strB.AppendFormat("{0:x2}", b);
175
-                }
176
-                hexString = strB.ToString();
65
+                return Success("成功", jo1);
177 66
             }
178
-            return hexString;
67
+            return Error("失败");
179 68
         }
180 69
 
181
-
182
-        #region POST
70
+        #region 私有方法
183 71
         /// <summary>
184
-        /// HTTP POST方式请求数据
72
+        /// 发送请求
185 73
         /// </summary>
186
-        /// <param name="url">URL.</param>
187
-        /// <param name="param">POST的数据</param>
74
+        /// <param name="url"></param>
75
+        /// <param name="param"></param>
188 76
         /// <returns></returns>
189
-        public static string HttpPost(string url, string param = null)
77
+        private string GetP(string url,string param)
190 78
         {
191
-            HttpWebRequest request;
192
-
193
-            //如果是发送HTTPS请求  
194
-            if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
195
-            {
196
-                ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
197
-                request = WebRequest.Create(url) as HttpWebRequest;
198
-                request.ProtocolVersion = HttpVersion.Version10;
199
-            }
200
-            else
201
-            {
202
-                request = WebRequest.Create(url) as HttpWebRequest;
203
-            }
204
-
205
-            request.Method = "POST";
206
-            request.ContentType = "application/x-www-form-urlencoded";
207
-            request.Accept = "*/*";
208
-            request.Timeout = 15000;
209
-            request.AllowAutoRedirect = false;
210
-
79
+            String appKey = Configs.GetValue("appKey");
80
+            String appSecret = Configs.GetValue("appSecret");
81
+            String version = Configs.GetValue("version");
82
+            long timestamp = DateTimeConvert.ConvertDateTimeToInt(DateTime.Now);
83
+            String nonce = System.Guid.NewGuid().ToString("N");
211 84
 
85
+            Dictionary<string, string> dic = new Dictionary<string, string>();
86
+            dic.Add("appKey", appKey);
87
+            dic.Add("appSecret", appSecret);
88
+            dic.Add("version", version);
89
+            dic.Add("timestamp", timestamp.ToString());
90
+            dic.Add("xReqNonce", nonce);
212 91
 
213
-            StreamWriter requestStream = null;
214
-            WebResponse response = null;
215
-            string responseStr = null;
92
+            var dicnew = dic.OrderBy(d => d.Key).ToList();
216 93
 
217
-            try
94
+            var mergeStr = new StringBuilder();
95
+            foreach (var item in dicnew)
218 96
             {
219
-                requestStream = new StreamWriter(request.GetRequestStream());
220
-                requestStream.Write(param);
221
-                requestStream.Close();
222
-
223
-                response = request.GetResponse();
224
-                if (response != null)
225
-                {
226
-                    StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
227
-                    responseStr = reader.ReadToEnd();
228
-                    reader.Close();
229
-                }
230
-            }
231
-            catch (Exception)
232
-            {
233
-                throw;
234
-            }
235
-            finally
236
-            {
237
-                request = null;
238
-                requestStream = null;
239
-                response = null;
97
+                mergeStr.Append(item.Value.ToString());
240 98
             }
99
+            var msergestring = mergeStr.ToString();
100
+            var enen = WebUtility.UrlEncode(msergestring);
101
+            string signStr = DESEncrypt.HmacSHA256(appSecret, enen);
241 102
 
242
-            return responseStr;
243
-        }
244
-
103
+            WebHeaderCollection header = new WebHeaderCollection();
104
+            header.Add("timestamp", timestamp.ToString());
105
+            header.Add("version", version);
106
+            header.Add("appKey", appKey);
107
+            header.Add("signature", signStr);
108
+            header.Add("xReqNonce", nonce);
245 109
 
246
-        private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
247
-        {
248
-            return true; //总是接受  
110
+            string strHTML = HttpMethods.HttpPost(url, header, param);
111
+            return strHTML;
249 112
         }
250
-        public static string BuildRequest(string strUrl, Dictionary<string, string> dicPara, string fileName)
251
-        {
252
-            string contentType = "image/jpeg";
253
-            //待请求参数数组
254
-            FileStream Pic = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
255
-            byte[] PicByte = new byte[Pic.Length];
256
-            Pic.Read(PicByte, 0, PicByte.Length);
257
-            int lengthFile = PicByte.Length;
258 113
 
259
-            //构造请求地址
260
-
261
-            //设置HttpWebRequest基本信息
262
-            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(strUrl);
263
-            //设置请求方式:get、post
264
-            request.Method = "POST";
265
-            //设置boundaryValue
266
-            string boundaryValue = DateTime.Now.Ticks.ToString("x");
267
-            string boundary = "--" + boundaryValue;
268
-            request.ContentType = "\r\nmultipart/form-data; boundary=" + boundaryValue;
269
-            //设置KeepAlive
270
-            request.KeepAlive = true;
271
-            //设置请求数据,拼接成字符串
272
-            StringBuilder sbHtml = new StringBuilder();
273
-            foreach (KeyValuePair<string, string> key in dicPara)
274
-            {
275
-                sbHtml.Append(boundary + "\r\nContent-Disposition: form-data; name=\"" + key.Key + "\"\r\n\r\n" + key.Value + "\r\n");
276
-            }
277
-            sbHtml.Append(boundary + "\r\nContent-Disposition: form-data; name=\"pic\"; filename=\"");
278
-            sbHtml.Append(fileName);
279
-            sbHtml.Append("\"\r\nContent-Type: " + contentType + "\r\n\r\n");
280
-            string postHeader = sbHtml.ToString();
281
-            //将请求数据字符串类型根据编码格式转换成字节流
282
-            Encoding code = Encoding.GetEncoding("UTF-8");
283
-            byte[] postHeaderBytes = code.GetBytes(postHeader);
284
-            byte[] boundayBytes = Encoding.ASCII.GetBytes("\r\n" + boundary + "--\r\n");
285
-            //设置长度
286
-            long length = postHeaderBytes.Length + lengthFile + boundayBytes.Length;
287
-            request.ContentLength = length;
288
-
289
-            //请求远程HTTP
290
-            Stream requestStream = request.GetRequestStream();
291
-            Stream myStream = null;
292
-            try
293
-            {
294
-                //发送数据请求服务器
295
-                requestStream.Write(postHeaderBytes, 0, postHeaderBytes.Length);
296
-                requestStream.Write(PicByte, 0, lengthFile);
297
-                requestStream.Write(boundayBytes, 0, boundayBytes.Length);
298
-                HttpWebResponse HttpWResp = (HttpWebResponse)request.GetResponse();
299
-                myStream = HttpWResp.GetResponseStream();
300
-            }
301
-            catch (WebException e)
302
-            {
303
-                //LogResult(e.Message);
304
-                return "";
305
-            }
306
-            finally
307
-            {
308
-                if (requestStream != null)
309
-                {
310
-                    requestStream.Close();
311
-                }
312
-            }
313
-
314
-            //读取处理结果
315
-            StreamReader reader = new StreamReader(myStream, code);
316
-            StringBuilder responseData = new StringBuilder();
317
-
318
-            String line;
319
-            while ((line = reader.ReadLine()) != null)
320
-            {
321
-                responseData.Append(line);
322
-            }
323
-            myStream.Close();
324
-            Pic.Close();
325
-
326
-            return responseData.ToString();
327
-        }
114
+        #endregion
115
+        #region 测试
116
+        //public ActionResult getsignature1()
117
+        //{
118
+        //    String appKey = "9b4a98b1bbce465381d323e0005c8588";
119
+        //    String appSecret = "hgtRQ2iauHEOMYg3QlvamA==";
120
+        //    String version = "1.0.0";
121
+        //    long timestamp = DateTimeConvert.ConvertDateTimeToInt(DateTime.Now);
122
+        //    String nonce = System.Guid.NewGuid().ToString("N");
123
+
124
+        //    Dictionary<string, string> dic = new Dictionary<string, string>();
125
+        //    dic.Add("appKey", appKey);
126
+        //    dic.Add("appSecret", appSecret);
127
+        //    dic.Add("version", version);
128
+        //    dic.Add("timestamp", timestamp.ToString());
129
+        //    dic.Add("xReqNonce", nonce);
130
+
131
+        //    var dicnew = dic.OrderBy(d => d.Key).ToList();
132
+
133
+        //    var mergeStr = new StringBuilder();
134
+        //    foreach (var item in dicnew)
135
+        //    {
136
+        //        mergeStr.Append(item.Value.ToString());
137
+        //    }
138
+        //    var msergestring = mergeStr.ToString();
139
+        //    //var encodedStr= System.Web.HttpUtility.UrlEncode(msergestring);
140
+        //    var enen=WebUtility.UrlEncode(msergestring);
141
+        //    string signStr = DESEncrypt.HmacSHA256(appSecret, enen);
142
+
143
+        //    string strURL = "https://openapi.17win.com/gateway/openyqdz/manage/customer/queryCustomers";
144
+        //    var m = new
145
+        //    {
146
+        //        pageNo = 1,
147
+        //        pageSize = 20
148
+        //    };
149
+
150
+        //    WebHeaderCollection header = new WebHeaderCollection();
151
+        //    header.Add("timestamp", timestamp.ToString());
152
+        //    header.Add("version", version);
153
+        //    header.Add("appKey", appKey);
154
+        //    header.Add("signature", signStr);
155
+        //    header.Add("xReqNonce", nonce);
156
+
157
+        //    //实体序列化和反序列化
158
+        //    string json1 = JsonConvert.SerializeObject(m);
159
+        //    string strHTML = HttpMethods.HttpPost(strURL, header, json1);
160
+        //    JObject jo1 = (JObject)JsonConvert.DeserializeObject(strHTML);
161
+        //    if (jo1 != null )
162
+        //    {
163
+        //        var status = jo1["head"]["status"].ToString();
164
+        //        return Success("成功", jo1);
165
+        //    }
166
+        //    return Error("失败");
167
+        //}
168
+
169
+        //public ActionResult getsignature()
170
+        //{
171
+        //    String appKey = "9b4a98b1bbce465381d323e0005c8588";
172
+        //    String appSecret = "hgtRQ2iauHEOMYg3QlvamA==";
173
+        //    String version = "1.0.0";
174
+        //    long timestamp = DateTimeConvert.ConvertDateTimeToInt(DateTime.Now);
175
+        //    String nonce = System.Guid.NewGuid().ToString("N");
176
+        //    string mergeStr = appKey + appSecret + timestamp + version + nonce;
177
+        //    //string encodedStr = System.Web.HttpUtility.UrlEncode(mergeStr);
178
+        //    string encodedStr = WebUtility.UrlEncode(mergeStr);
179
+        //    string signStr = DESEncrypt.HmacSHA256(appSecret,encodedStr);
180
+        //    //return signStr;
181
+
182
+        //    string strURL = "https://openapi.17win.com/gateway/openyqdz/manage/customer/queryCustomers";
183
+        //    var m = new
184
+        //    {
185
+        //        pageNo=1,
186
+        //        pageSize=20
187
+        //    };
188
+
189
+        //    WebHeaderCollection header = new WebHeaderCollection();
190
+        //    header.Add("timestamp", timestamp.ToString());
191
+        //    header.Add("version", version);
192
+        //    header.Add("appKey", appKey);
193
+        //    header.Add("signature", signStr);
194
+        //    header.Add("xReqNonce", nonce);
195
+
196
+        //    //实体序列化和反序列化
197
+        //    string json1 = JsonConvert.SerializeObject(m);
198
+        //    string strHTML = HttpMethods.HttpPost(strURL, header, json1);
199
+        //    DockingResultDto jo1 = JsonConvert.DeserializeObject< DockingResultDto>(strHTML);
200
+        //    if (jo1 != null)
201
+        //    {
202
+        //        return Success("成功", jo1);
203
+        //    }
204
+        //    return Error("失败");
205
+        //}
328 206
         #endregion
329 207
 
330
-        #region Get
331
-        /// <summary>
332
-        /// HTTP GET方式请求数据.
333
-        /// </summary>
334
-        /// <param name="url">URL.</param>
335
-        /// <returns></returns>
336
-        public static string HttpGet(string url, Hashtable headht = null)
337
-        {
338
-            HttpWebRequest request;
339
-
340
-            //如果是发送HTTPS请求  
341
-            if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
342
-            {
343
-                ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
344
-                request = WebRequest.Create(url) as HttpWebRequest;
345
-                request.ProtocolVersion = HttpVersion.Version10;
346
-            }
347
-            else
348
-            {
349
-                request = WebRequest.Create(url) as HttpWebRequest;
350
-            }
351
-            request.Method = "GET";
352
-            //request.ContentType = "application/x-www-form-urlencoded";
353
-            request.Accept = "*/*";
354
-            request.Timeout = 15000;
355
-            request.AllowAutoRedirect = false;
356
-            WebResponse response = null;
357
-            string responseStr = null;
358
-            if (headht != null)
359
-            {
360
-                foreach (DictionaryEntry item in headht)
361
-                {
362
-                    request.Headers.Add(item.Key.ToString(), item.Value.ToString());
363
-                }
364
-            }
365
-
366
-            try
367
-            {
368
-                response = request.GetResponse();
369
-
370
-                if (response != null)
371
-                {
372
-                    StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
373
-                    responseStr = reader.ReadToEnd();
374
-                    reader.Close();
375
-                }
376
-            }
377
-            catch (Exception)
378
-            {
379
-                throw;
380
-            }
381
-            return responseStr;
382
-        }
383
-        public static string HttpGet(string url, Encoding encodeing, Hashtable headht = null)
384
-        {
385
-            HttpWebRequest request;
386
-
387
-            //如果是发送HTTPS请求  
388
-            if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
389
-            {
390
-                ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
391
-                request = WebRequest.Create(url) as HttpWebRequest;
392
-                request.ProtocolVersion = HttpVersion.Version10;
393
-            }
394
-            else
395
-            {
396
-                request = WebRequest.Create(url) as HttpWebRequest;
397
-            }
398
-            request.Method = "GET";
399
-            //request.ContentType = "application/x-www-form-urlencoded";
400
-            request.Accept = "*/*";
401
-            request.Timeout = 15000;
402
-            request.AllowAutoRedirect = false;
403
-            WebResponse response = null;
404
-            string responseStr = null;
405
-            if (headht != null)
406
-            {
407
-                foreach (DictionaryEntry item in headht)
408
-                {
409
-                    request.Headers.Add(item.Key.ToString(), item.Value.ToString());
410
-                }
411
-            }
412 208
 
413
-            try
414
-            {
415
-                response = request.GetResponse();
209
+        
416 210
 
417
-                if (response != null)
418
-                {
419
-                    StreamReader reader = new StreamReader(response.GetResponseStream(), encodeing);
420
-                    responseStr = reader.ReadToEnd();
421
-                    reader.Close();
422
-                }
423
-            }
424
-            catch (Exception)
425
-            {
426
-                throw;
427
-            }
428
-            return responseStr;
429
-        }
430
-        #endregion
431 211
     }
432 212
 }

+ 293 - 0
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Models/Dto/DockingCustomerListDto.cs

@@ -0,0 +1,293 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Web;
5
+
6
+namespace CallCenterApi.Interface.Models.Dto
7
+{
8
+    #region 客户信息类
9
+
10
+    public class DockingCustomerListDto
11
+    {
12
+        /// <summary>
13
+        /// 企业ID
14
+        /// </summary>
15
+        public string customerId { get; set; }
16
+        /// <summary>
17
+        /// 客户简称
18
+        /// </summary>
19
+        public string name { get; set; }
20
+        /// <summary>
21
+        /// 客户全称
22
+        /// </summary>
23
+        public string fullName { get; set; }
24
+        /// <summary>
25
+        /// 客户编号
26
+        /// </summary>
27
+        public string customerNo { get; set; }
28
+        /// <summary>
29
+        /// 代账客户, 非代账客户
30
+        /// </summary>
31
+        public string customerType { get; set; }
32
+        /// <summary>
33
+        /// 税号
34
+        /// </summary>
35
+        public string taxNo { get; set; }
36
+        /// <summary>
37
+        /// 行业门类
38
+        /// </summary>
39
+        public string industryCategory { get; set; }
40
+        /// <summary>
41
+        /// 行业中小类
42
+        /// </summary>
43
+        public string industryType { get; set; }
44
+        /// <summary>
45
+        /// 地区码
46
+        /// </summary>
47
+        public string locationCode { get; set; }
48
+        /// <summary>
49
+        /// 地址
50
+        /// </summary>
51
+        public string address { get; set; }
52
+        /// <summary>
53
+        /// 增值税类型
54
+        /// </summary>
55
+        public string taxType { get; set; }
56
+        public string createDate { get; set; }
57
+        /// <summary>
58
+        /// 客户状态 1:正常, 2.暂停 3.流失
59
+        /// </summary>
60
+        public string status { get; set; }
61
+        /// <summary>
62
+        /// 客户等级
63
+        /// </summary>
64
+        public string level { get; set; }
65
+        /// <summary>
66
+        /// 部门id
67
+        /// </summary>
68
+        public int departmentId { get; set; }
69
+        public List<DockingAccountlistDto> accountlist { get; set; }
70
+    }
71
+
72
+    public class DockingAccountlistDto
73
+    {
74
+        /// <summary>
75
+        /// 人员id
76
+        /// </summary>
77
+        public string accountId { get; set; }
78
+        /// <summary>
79
+        /// 类型, 1: 服务顾问, 2:其他服务人员, 3:税务会计,4:财务会计, 5:审核会计,6:收款负责人
80
+        /// </summary>
81
+        public int relationshipType { get; set; }
82
+        /// <summary>
83
+        /// 员工登录手机号
84
+        /// </summary>
85
+        public string loginName { get; set; }
86
+    }
87
+    //result
88
+    public class DockingCusResultDto
89
+    {
90
+        public DockingHeadDto head { get; set; }
91
+        public DockingBodyCusDto body { get; set; }
92
+    }
93
+    //body
94
+    public class DockingBodyCusDto
95
+    {
96
+        public int total { get; set; }
97
+        public DockingPagerDto pager { get; set; }
98
+        public List<DockingCustomerListDto> customerlist { get; set; }
99
+    }
100
+    #endregion
101
+    #region 科目余额信息
102
+    public class DockingAccountBalanceDto
103
+    {
104
+        /**
105
+     * 科目ID
106
+     */
107
+        public int? titleId { get; set; }
108
+
109
+        public bool titleIsLast { get; set; }
110
+        /**
111
+         * 辅助类型
112
+         */
113
+        public String assistantType { get; set; }
114
+        /**
115
+         * 辅助ID
116
+         */
117
+        public int? assistantId { get; set; }
118
+        /**
119
+         * 科目编码
120
+         */
121
+        public String titleCode { get; set; }
122
+        /**
123
+         * 科目名称
124
+         */
125
+        public String titleName { get; set; }
126
+        /**
127
+         * 科目全称
128
+         */
129
+        public String titleFullName { get; set; }
130
+        /**
131
+         * 父级科目编码
132
+         */
133
+        public String pTitleCode { get; set; }
134
+        /**
135
+         * 科目级别
136
+         */
137
+        public int? level { get; set; }
138
+        /**
139
+         * 行的类型
140
+         */
141
+        public String type { get; set; }
142
+        /**
143
+         * 计量单位
144
+         */
145
+        public String unit { get; set; }
146
+        /**
147
+         * 币种
148
+         */
149
+        public String fcurCode { get; set; }
150
+        /**
151
+         * 规格型号
152
+         */
153
+        public String specification { get; set; }
154
+        /**
155
+         * 辅助名称
156
+         */
157
+        public String assistantName { get; set; }
158
+        /**
159
+         * 期初余额方向
160
+         */
161
+        public int beginDirection { get; set; }
162
+        /**
163
+         * 期初余额
164
+         */
165
+        public decimal beginAmount { get; set; } = 0;
166
+        /**
167
+         * 期初数量
168
+         */
169
+        public decimal beginQuantity { get; set; } = 0;
170
+        /**
171
+         * 期初单价
172
+         */
173
+        public decimal beginUnitPrice { get; set; } = 0;
174
+        /**
175
+         * 期初余额借
176
+         */
177
+        public decimal beginDebit { get; set; } = 0;
178
+        /**
179
+         * 期初余额贷
180
+         */
181
+        public decimal beginCredit { get; set; } = 0;
182
+        /**
183
+         * 期初余额借方外币
184
+         */
185
+        public decimal beginDebitFcur { get; set; } = 0;
186
+        /**
187
+         * 期初余额贷方外币
188
+         */
189
+        public decimal beginCreditFcur { get; set; } = 0;
190
+        /**
191
+         * 本期发生额借
192
+         */
193
+        public decimal occurredDebit { get; set; } = 0;
194
+        /**
195
+         * 本期发生额借方数量
196
+         */
197
+        public decimal occurredDebitQuantity { get; set; } = 0;
198
+        /**
199
+         * 本期发生额借方外币
200
+         */
201
+        public decimal occurredDebitFcur { get; set; } = 0;
202
+        /**
203
+         * 本期发生额贷
204
+         */
205
+        public decimal occurredCredit { get; set; } = 0;
206
+        /**
207
+         * 本期发生额贷方数量
208
+         */
209
+        public decimal occurredCreditQuantity { get; set; } = 0;
210
+        /**
211
+         * 本期发生额贷方外币
212
+         */
213
+        public decimal occurredCreditFcur { get; set; } = 0;
214
+        /**
215
+         * 本年累计借
216
+         */
217
+        public decimal yearAccumulatedDebit { get; set; } = 0;
218
+        /**
219
+         * 本年累计贷
220
+         */
221
+        public decimal yearAccumulatedCredit { get; set; } = 0;
222
+        /**
223
+         * 期末余额借
224
+         */
225
+        public decimal endDebit { get; set; } = 0;
226
+        /**
227
+         * 期末余额贷
228
+         */
229
+        public decimal endCredit { get; set; } = 0;
230
+        /**
231
+         * 期末余额借
232
+         */
233
+        public decimal endDebitFcur { get; set; } = 0;
234
+        /**
235
+         * 期末余额贷
236
+         */
237
+        public decimal endCreditFcur { get; set; } = 0;
238
+        /**
239
+         * 期末余额方向
240
+         */
241
+        public int endDirection { get; set; }
242
+        /**
243
+         * 期末余额
244
+         */
245
+        public decimal endAmount { get; set; } = 0;
246
+        /**
247
+         * 期末余额
248
+         */
249
+        public decimal endQuantity { get; set; } = 0;
250
+        /**
251
+         * 期末单价
252
+         */
253
+        public decimal endUnitPrice { get; set; } = 0;
254
+        /**
255
+         * 本期发生额借方单价
256
+         */
257
+        public decimal occurredDebitUnitPrice { get; set; } = 0;
258
+        /**
259
+         * 本期发生额贷方单价
260
+         */
261
+        public decimal occurredCreditUnitPrice { get; set; } = 0;
262
+    }
263
+    //body
264
+    public class DockingBodyAccountBalanceDto
265
+    {
266
+        public int total { get; set; }
267
+        public List<DockingAccountBalanceDto> list { get; set; }
268
+    }
269
+    //result
270
+    public class DockingBalanceResultDto
271
+    {
272
+        public DockingHeadDto head { get; set; }
273
+        public DockingBodyAccountBalanceDto body { get; set; }
274
+    }
275
+    #endregion
276
+
277
+    public class DockingHeadDto
278
+    {
279
+        public string code { get; set; }
280
+        public string description { get; set; }
281
+        public string msg { get; set; }
282
+        public string time { get; set; }
283
+        public string status { get; set; }
284
+    }
285
+
286
+    public class DockingPagerDto
287
+    {
288
+        public int currentPage { get; set; }
289
+        public int pageSize { get; set; }
290
+    }
291
+
292
+    
293
+}

+ 61 - 0
codegit/CallCenterCommon/CallCenter.Utility/Http/HttpMethods.cs

@@ -74,7 +74,68 @@ namespace CallCenter.Utility
74 74
 
75 75
             return responseStr;
76 76
         }
77
+        /// <summary>
78
+        /// HTTP POST方式带头部请求数据
79
+        /// </summary>
80
+        /// <param name="url"></param>
81
+        /// <param name="whc">头部</param>
82
+        /// <param name="param"></param>
83
+        /// <returns></returns>
84
+        public static string HttpPost(string url, WebHeaderCollection whc, string param = null)
85
+        {
86
+            HttpWebRequest request;
87
+
88
+            //如果是发送HTTPS请求  
89
+            if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
90
+            {
91
+                ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
92
+                request = WebRequest.Create(url) as HttpWebRequest;
93
+                request.ProtocolVersion = HttpVersion.Version10;
94
+            }
95
+            else
96
+            {
97
+                request = WebRequest.Create(url) as HttpWebRequest;
98
+            }
99
+
100
+            request.Method = "POST";
101
+            //request.ContentType = "application/x-www-form-urlencoded";
102
+            request.ContentType = "application/json";
103
+            request.Accept = "*/*";
104
+            request.Timeout = 15000;
105
+            request.AllowAutoRedirect = false;
106
+            request.Headers.Add(whc);
107
+
108
+            StreamWriter requestStream = null;
109
+            WebResponse response = null;
110
+            string responseStr = null;
77 111
 
112
+            try
113
+            {
114
+                requestStream = new StreamWriter(request.GetRequestStream());
115
+                requestStream.Write(param);
116
+                requestStream.Close();
117
+
118
+                response = request.GetResponse();
119
+                if (response != null)
120
+                {
121
+                    StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
122
+                    responseStr = reader.ReadToEnd();
123
+                    reader.Close();
124
+                }
125
+            }
126
+            catch (Exception)
127
+            {
128
+                throw;
129
+            }
130
+            finally
131
+            {
132
+                request = null;
133
+                requestStream = null;
134
+                response = null;
135
+            }
136
+
137
+            return responseStr;
138
+        }
78 139
 
79 140
         private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
80 141
         {

+ 12 - 0
codegit/CallCenterCommon/CallCenter.Utility/Time/DateTimeConvert.cs

@@ -301,5 +301,17 @@ namespace CallCenter.Utility
301 301
             DateTime t1 = t.AddDays(iDay - RInt);
302 302
             return t1;
303 303
         }
304
+
305
+        /// <summary>  
306
+        /// 将c# DateTime时间格式转换为Unix时间戳格式  
307
+        /// </summary>  
308
+        /// <param name="time">时间</param>  
309
+        /// <returns>long</returns>  
310
+        public static long ConvertDateTimeToInt(System.DateTime time)
311
+        {
312
+            System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1, 0, 0, 0, 0));
313
+            long t = (time.Ticks - startTime.Ticks) / 10000;   //除10000调整为13位      
314
+            return t;
315
+        }
304 316
     }
305 317
 }