浏览代码

Merge branch 'master' of http://192.168.1.222:3000/zhengbingbing/ZLJ_API_V6.0

duhongyu 5 年之前
父节点
当前提交
4fb08af424

+ 2 - 2
代码/System.Model/T_Bus_OrderDetail.cs

13
 		private string _f_id;
13
 		private string _f_id;
14
 		private int _f_sort = 1;
14
 		private int _f_sort = 1;
15
 		private string _f_orderid;
15
 		private string _f_orderid;
16
-		private int _f_productid;
16
+		private string _f_productid;
17
 		private string _f_productname = "";
17
 		private string _f_productname = "";
18
 		private decimal _f_price;
18
 		private decimal _f_price;
19
 		private decimal _f_dealprice;
19
 		private decimal _f_dealprice;
51
 		/// <summary>
51
 		/// <summary>
52
 		/// 产品编号
52
 		/// 产品编号
53
 		/// </summary>
53
 		/// </summary>
54
-		public int F_ProductId
54
+		public string F_ProductId
55
 		{
55
 		{
56
 			set { _f_productid = value; }
56
 			set { _f_productid = value; }
57
 			get { return _f_productid; }
57
 			get { return _f_productid; }

+ 2 - 2
代码/System.Model/T_Bus_Product.cs

10
 		public T_Bus_Product()
10
 		public T_Bus_Product()
11
 		{ }
11
 		{ }
12
 		#region Model
12
 		#region Model
13
-		private int _f_productid;
13
+		private string _f_productid;
14
 		private string _f_productnumber="";
14
 		private string _f_productnumber="";
15
 		private string _f_productname;
15
 		private string _f_productname;
16
 		private string _f_productshortname="";
16
 		private string _f_productshortname="";
50
 		/// <summary>
50
 		/// <summary>
51
 		/// 产品编号ID
51
 		/// 产品编号ID
52
 		/// </summary>
52
 		/// </summary>
53
-		public int F_ProductId
53
+		public string F_ProductId
54
 		{
54
 		{
55
 			set { _f_productid = value; }
55
 			set { _f_productid = value; }
56
 			get { return _f_productid; }
56
 			get { return _f_productid; }

+ 3 - 3
代码/System.Model/T_Bus_StockLog.cs

12
 		#region Model
12
 		#region Model
13
 		private string _f_id;
13
 		private string _f_id;
14
 		private string _f_orderid = "";
14
 		private string _f_orderid = "";
15
-		private int _f_productid = 0;
15
+		private string _f_productid = "";
16
 		private string _f_stock = "";
16
 		private string _f_stock = "";
17
 		private int _f_num = 0;
17
 		private int _f_num = 0;
18
 		private DateTime _f_addtime;
18
 		private DateTime _f_addtime;
44
 		/// <summary>
44
 		/// <summary>
45
 		/// 产品Id
45
 		/// 产品Id
46
 		/// </summary>
46
 		/// </summary>
47
-		public int F_ProductId
47
+		public string F_ProductId
48
 		{
48
 		{
49
 			set { _f_productid = value; }
49
 			set { _f_productid = value; }
50
 			get { return _f_productid; }
50
 			get { return _f_productid; }
90
 			get { return _f_username; }
90
 			get { return _f_username; }
91
 		}
91
 		}
92
 		/// <summary>
92
 		/// <summary>
93
-		/// 变动结果  1成功  0失败
93
+		/// 变动结果0未开始  1成功  2失败
94
 		/// </summary>
94
 		/// </summary>
95
 		public int F_State
95
 		public int F_State
96
 		{
96
 		{

+ 35 - 0
代码/System.Model/eBoss/GetStock.cs

1
+using System;
2
+using System.Collections.Generic;
3
+
4
+namespace System.Model
5
+{
6
+	/// <summary>
7
+	///  订单表
8
+	/// </summary>
9
+	[Serializable]
10
+	public partial class GetStock
11
+	{
12
+		public GetStock()
13
+		{ }
14
+		public bool success { get; set; }
15
+		public List<EBossStock> stocks { get; set; }
16
+		
17
+	}
18
+
19
+	/// <summary>
20
+	///  亿博士库存返回对象
21
+	/// </summary>
22
+	[Serializable]
23
+	public  class EBossStock
24
+	{
25
+		public EBossStock()
26
+		{ }
27
+		public string store { get; set; }
28
+		public string sku { get; set; }
29
+
30
+		public int qty { get; set; }
31
+		public int qtyout { get; set; }
32
+		public int qtyin { get; set; }
33
+	}
34
+}
35
+

+ 60 - 0
代码/System.Model/eBoss/SetStock.cs

1
+using System;
2
+using System.Collections.Generic;
3
+
4
+namespace System.Model
5
+{
6
+	/// <summary>
7
+	///  亿博士更新库存
8
+	/// </summary>
9
+	[Serializable]
10
+	public partial class SetStockModel
11
+	{
12
+		public SetStockModel()
13
+		{ }
14
+		public string appid { get; set; }
15
+		
16
+		public string appkey { get; set; }
17
+		public string method { get; set; } = "eboss.drp.adj.add";
18
+		public string adjtype { get; set; } = "正常调整";
19
+		/// <summary>
20
+		/// 不超过22位
21
+		/// </summary>
22
+		public string masterid { get; set; }
23
+		public string billdate { get; set; }
24
+		public string store { get; set; }
25
+		public string remark { get; set; }
26
+		public string createid { get; set; } = "000";
27
+
28
+		public List<StockChangeModel> dts { get; set; }
29
+		public List<StockChangeMSModel> ms { get; set; }
30
+
31
+	}
32
+
33
+	/// <summary>
34
+	///  亿博士库存返回对象
35
+	/// </summary>
36
+	[Serializable]
37
+	public  class StockChangeModel
38
+	{
39
+		public StockChangeModel()
40
+		{ }
41
+
42
+		public string sku { get; set; }
43
+
44
+		public int qty { get; set; }
45
+
46
+	}
47
+	[Serializable]
48
+	public class StockChangeMSModel
49
+	{
50
+		public StockChangeMSModel()
51
+		{ }
52
+
53
+		public string sku { get; set; }
54
+		public string mastercode { get; set; }
55
+		public string mastercode2 { get; set; }
56
+
57
+	}
58
+
59
+}
60
+

+ 146 - 0
代码/System.Utility/Http/HttpHelper.cs

1
+using System;
2
+using System.Collections.Generic;
3
+using System.Net.Http;
4
+using System.Text;
5
+using System.Threading.Tasks;
6
+
7
+namespace System.Utility.Http
8
+{
9
+    public class HttpHelper
10
+    {
11
+        /// <summary>
12
+        /// 同步GET请求
13
+        /// </summary>
14
+        /// <param name="url"></param>
15
+        /// <param name="headers"></param>
16
+        /// <param name="timeout">请求响应超时时间,单位/s(默认100秒)</param>
17
+        /// <returns></returns>
18
+        public static string HttpGet(string url, Dictionary<string, string> headers = null, int timeout = 0)
19
+        {
20
+            using (HttpClient client = new HttpClient())
21
+            {
22
+                if (headers != null)
23
+                {
24
+                    foreach (KeyValuePair<string, string> header in headers)
25
+                    {
26
+                        client.DefaultRequestHeaders.Add(header.Key, header.Value);
27
+                    }
28
+                }
29
+                if (timeout > 0)
30
+                {
31
+                    client.Timeout = new TimeSpan(0, 0, timeout);
32
+                }
33
+                Byte[] resultBytes = client.GetByteArrayAsync(url).Result;
34
+                return Encoding.UTF8.GetString(resultBytes);
35
+            }
36
+        }
37
+
38
+        /// <summary>
39
+        /// 异步GET请求
40
+        /// </summary>
41
+        /// <param name="url"></param>
42
+        /// <param name="headers"></param>
43
+        /// <param name="timeout">请求响应超时时间,单位/s(默认100秒)</param>
44
+        /// <returns></returns>
45
+        public static async Task<string> HttpGetAsync(string url, Dictionary<string, string> headers = null, int timeout = 0)
46
+        {
47
+            using (HttpClient client = new HttpClient())
48
+            {
49
+                if (headers != null)
50
+                {
51
+                    foreach (KeyValuePair<string, string> header in headers)
52
+                    {
53
+                        client.DefaultRequestHeaders.Add(header.Key, header.Value);
54
+                    }
55
+                }
56
+                if (timeout > 0)
57
+                {
58
+                    client.Timeout = new TimeSpan(0, 0, timeout);
59
+                }
60
+                Byte[] resultBytes = await client.GetByteArrayAsync(url);
61
+                return Encoding.Default.GetString(resultBytes);
62
+            }
63
+        }
64
+
65
+
66
+        /// <summary>
67
+        /// 同步POST请求
68
+        /// </summary>
69
+        /// <param name="url"></param>
70
+        /// <param name="postData"></param>
71
+        /// <param name="headers"></param>
72
+        /// <param name="contentType"></param>
73
+        /// <param name="timeout">请求响应超时时间,单位/s(默认100秒)</param>
74
+        /// <param name="encoding">默认UTF8</param>
75
+        /// <returns></returns>
76
+        public static string HttpPost(string url, string postData, Dictionary<string, string> headers = null, string contentType = null, int timeout = 0, Encoding encoding = null)
77
+        {
78
+            using (HttpClient client = new HttpClient())
79
+            {
80
+                if (headers != null)
81
+                {
82
+                    foreach (KeyValuePair<string, string> header in headers)
83
+                    {
84
+                        client.DefaultRequestHeaders.Add(header.Key, header.Value);
85
+                    }
86
+                }
87
+                if (timeout > 0)
88
+                {
89
+                    client.Timeout = new TimeSpan(0, 0, timeout);
90
+                }
91
+                using (HttpContent content = new StringContent(postData ?? "", encoding ?? Encoding.UTF8))
92
+                {
93
+                    if (contentType != null)
94
+                    {
95
+                        content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(contentType);
96
+                    }
97
+                    using (HttpResponseMessage responseMessage = client.PostAsync(url, content).Result)
98
+                    {
99
+                        Byte[] resultBytes = responseMessage.Content.ReadAsByteArrayAsync().Result;
100
+                        return Encoding.UTF8.GetString(resultBytes);
101
+                    }
102
+                }
103
+            }
104
+        }
105
+
106
+        /// <summary>
107
+        /// 异步POST请求
108
+        /// </summary>
109
+        /// <param name="url"></param>
110
+        /// <param name="postData"></param>
111
+        /// <param name="headers"></param>
112
+        /// <param name="contentType"></param>
113
+        /// <param name="timeout">请求响应超时时间,单位/s(默认100秒)</param>
114
+        /// <param name="encoding">默认UTF8</param>
115
+        /// <returns></returns>
116
+        public static async Task<string> HttpPostAsync(string url, string postData, Dictionary<string, string> headers = null, string contentType = null, int timeout = 0, Encoding encoding = null)
117
+        {
118
+            using (HttpClient client = new HttpClient())
119
+            {
120
+                if (headers != null)
121
+                {
122
+                    foreach (KeyValuePair<string, string> header in headers)
123
+                    {
124
+                        client.DefaultRequestHeaders.Add(header.Key, header.Value);
125
+                    }
126
+                }
127
+                if (timeout > 0)
128
+                {
129
+                    client.Timeout = new TimeSpan(0, 0, timeout);
130
+                }
131
+                using (HttpContent content = new StringContent(postData ?? "", encoding ?? Encoding.UTF8))
132
+                {
133
+                    if (contentType != null)
134
+                    {
135
+                        content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(contentType);
136
+                    }
137
+                    using (HttpResponseMessage responseMessage = await client.PostAsync(url, content))
138
+                    {
139
+                        Byte[] resultBytes = await responseMessage.Content.ReadAsByteArrayAsync();
140
+                        return Encoding.UTF8.GetString(resultBytes);
141
+                    }
142
+                }
143
+            }
144
+        }
145
+    }
146
+}

+ 532 - 0
代码/System.Utility/Http/HttpMethods.cs

1
+using System;
2
+using System.Collections;
3
+using System.Collections.Generic;
4
+using System.IO;
5
+using System.Net;
6
+using System.Net.Http;
7
+using System.Net.Security;
8
+using System.Security.Cryptography.X509Certificates;
9
+using System.Text;
10
+
11
+namespace System.Utility
12
+{
13
+    public class HttpMethods
14
+    {
15
+        #region POST
16
+        /// <summary>
17
+        /// HTTP POST方式请求数据
18
+        /// </summary>
19
+        /// <param name="url">URL.</param>
20
+        /// <param name="param">POST的数据</param>
21
+        /// <returns></returns>
22
+        public static string HttpPost(string url, string param = null)
23
+        {
24
+            HttpWebRequest request;
25
+
26
+            //如果是发送HTTPS请求  
27
+            if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
28
+            {
29
+                ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
30
+                request = WebRequest.Create(url) as HttpWebRequest;
31
+                request.ProtocolVersion = HttpVersion.Version10;
32
+            }
33
+            else
34
+            {
35
+                request = WebRequest.Create(url) as HttpWebRequest;
36
+            }
37
+
38
+            request.Method = "POST";
39
+            request.ContentType = "application/x-www-form-urlencoded";
40
+            request.Accept = "*/*";
41
+            request.Timeout = 15000;
42
+            request.AllowAutoRedirect = false;
43
+
44
+
45
+
46
+            StreamWriter requestStream = null;
47
+            WebResponse response = null;
48
+            string responseStr = null;
49
+
50
+            try
51
+            {
52
+                requestStream = new StreamWriter(request.GetRequestStream());
53
+                requestStream.Write(param);
54
+                requestStream.Close();
55
+
56
+                response = request.GetResponse();
57
+                if (response != null)
58
+                {
59
+                    StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
60
+                    responseStr = reader.ReadToEnd();
61
+                    reader.Close();
62
+                }
63
+            }
64
+            catch (Exception)
65
+            {
66
+                throw;
67
+            }
68
+            finally
69
+            {
70
+                request = null;
71
+                requestStream = null;
72
+                response = null;
73
+            }
74
+
75
+            return responseStr;
76
+        }
77
+
78
+
79
+        private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
80
+        {
81
+            return true; //总是接受  
82
+        }
83
+        public static string BuildRequest(string strUrl, Dictionary<string, string> dicPara, string fileName)
84
+        {
85
+            string contentType = "image/jpeg";
86
+            //待请求参数数组
87
+            FileStream Pic = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
88
+            byte[] PicByte = new byte[Pic.Length];
89
+            Pic.Read(PicByte, 0, PicByte.Length);
90
+            int lengthFile = PicByte.Length;
91
+
92
+            //构造请求地址
93
+
94
+            //设置HttpWebRequest基本信息
95
+            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(strUrl);
96
+            //设置请求方式:get、post
97
+            request.Method = "POST";
98
+            //设置boundaryValue
99
+            string boundaryValue = DateTime.Now.Ticks.ToString("x");
100
+            string boundary = "--" + boundaryValue;
101
+            request.ContentType = "\r\nmultipart/form-data; boundary=" + boundaryValue;
102
+            //设置KeepAlive
103
+            request.KeepAlive = true;
104
+            //设置请求数据,拼接成字符串
105
+            StringBuilder sbHtml = new StringBuilder();
106
+            foreach (KeyValuePair<string, string> key in dicPara)
107
+            {
108
+                sbHtml.Append(boundary + "\r\nContent-Disposition: form-data; name=\"" + key.Key + "\"\r\n\r\n" + key.Value + "\r\n");
109
+            }
110
+            sbHtml.Append(boundary + "\r\nContent-Disposition: form-data; name=\"pic\"; filename=\"");
111
+            sbHtml.Append(fileName);
112
+            sbHtml.Append("\"\r\nContent-Type: " + contentType + "\r\n\r\n");
113
+            string postHeader = sbHtml.ToString();
114
+            //将请求数据字符串类型根据编码格式转换成字节流
115
+            Encoding code = Encoding.GetEncoding("UTF-8");
116
+            byte[] postHeaderBytes = code.GetBytes(postHeader);
117
+            byte[] boundayBytes = Encoding.ASCII.GetBytes("\r\n" + boundary + "--\r\n");
118
+            //设置长度
119
+            long length = postHeaderBytes.Length + lengthFile + boundayBytes.Length;
120
+            request.ContentLength = length;
121
+
122
+            //请求远程HTTP
123
+            Stream requestStream = request.GetRequestStream();
124
+            Stream myStream = null;
125
+            try
126
+            {
127
+                //发送数据请求服务器
128
+                requestStream.Write(postHeaderBytes, 0, postHeaderBytes.Length);
129
+                requestStream.Write(PicByte, 0, lengthFile);
130
+                requestStream.Write(boundayBytes, 0, boundayBytes.Length);
131
+                HttpWebResponse HttpWResp = (HttpWebResponse)request.GetResponse();
132
+                myStream = HttpWResp.GetResponseStream();
133
+            }
134
+            catch (WebException e)
135
+            {
136
+                //LogResult(e.Message);
137
+                return "";
138
+            }
139
+            finally
140
+            {
141
+                if (requestStream != null)
142
+                {
143
+                    requestStream.Close();
144
+                }
145
+            }
146
+
147
+            //读取处理结果
148
+            StreamReader reader = new StreamReader(myStream, code);
149
+            StringBuilder responseData = new StringBuilder();
150
+
151
+            String line;
152
+            while ((line = reader.ReadLine()) != null)
153
+            {
154
+                responseData.Append(line);
155
+            }
156
+            myStream.Close();
157
+            Pic.Close();
158
+
159
+            return responseData.ToString();
160
+        }
161
+        #endregion
162
+
163
+        #region Put
164
+        /// <summary>
165
+        /// HTTP Put方式请求数据.
166
+        /// </summary>
167
+        /// <param name="url">URL.</param>
168
+        /// <returns></returns>
169
+        public static string HttpPut(string url, string param = null)
170
+        {
171
+            HttpWebRequest request;
172
+
173
+            //如果是发送HTTPS请求  
174
+            if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
175
+            {
176
+                ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
177
+                request = WebRequest.Create(url) as HttpWebRequest;
178
+                request.ProtocolVersion = HttpVersion.Version10;
179
+            }
180
+            else
181
+            {
182
+                request = WebRequest.Create(url) as HttpWebRequest;
183
+            }
184
+            request.Method = "PUT";
185
+            request.ContentType = "application/x-www-form-urlencoded";
186
+            request.Accept = "*/*";
187
+            request.Timeout = 15000;
188
+            request.AllowAutoRedirect = false;
189
+
190
+            StreamWriter requestStream = null;
191
+            WebResponse response = null;
192
+            string responseStr = null;
193
+
194
+            try
195
+            {
196
+                requestStream = new StreamWriter(request.GetRequestStream());
197
+                requestStream.Write(param);
198
+                requestStream.Close();
199
+
200
+                response = request.GetResponse();
201
+                if (response != null)
202
+                {
203
+                    StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
204
+                    responseStr = reader.ReadToEnd();
205
+                    reader.Close();
206
+                }
207
+            }
208
+            catch (Exception)
209
+            {
210
+                throw;
211
+            }
212
+            finally
213
+            {
214
+                request = null;
215
+                requestStream = null;
216
+                response = null;
217
+            }
218
+
219
+            return responseStr;
220
+        }
221
+        #endregion
222
+
223
+        #region Delete
224
+        /// <summary>
225
+        /// HTTP Delete方式请求数据.
226
+        /// </summary>
227
+        /// <param name="url">URL.</param>
228
+        /// <returns></returns>
229
+        public static string HttpDelete(string url, string param = null)
230
+        {
231
+            HttpWebRequest request;
232
+
233
+            //如果是发送HTTPS请求  
234
+            if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
235
+            {
236
+                ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
237
+                request = WebRequest.Create(url) as HttpWebRequest;
238
+                request.ProtocolVersion = HttpVersion.Version10;
239
+            }
240
+            else
241
+            {
242
+                request = WebRequest.Create(url) as HttpWebRequest;
243
+            }
244
+            request.Method = "Delete";
245
+            request.ContentType = "application/x-www-form-urlencoded";
246
+            request.Accept = "*/*";
247
+            request.Timeout = 15000;
248
+            request.AllowAutoRedirect = false;
249
+
250
+            StreamWriter requestStream = null;
251
+            WebResponse response = null;
252
+            string responseStr = null;
253
+
254
+            try
255
+            {
256
+                requestStream = new StreamWriter(request.GetRequestStream());
257
+                requestStream.Write(param);
258
+                requestStream.Close();
259
+
260
+                response = request.GetResponse();
261
+                if (response != null)
262
+                {
263
+                    StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
264
+                    responseStr = reader.ReadToEnd();
265
+                    reader.Close();
266
+                }
267
+            }
268
+            catch (Exception)
269
+            {
270
+                throw;
271
+            }
272
+            return responseStr;
273
+        }
274
+        #endregion
275
+
276
+        #region Get
277
+        /// <summary>
278
+        /// HTTP GET方式请求数据.
279
+        /// </summary>
280
+        /// <param name="url">URL.</param>
281
+        /// <returns></returns>
282
+        public static string HttpGet(string url, Hashtable headht = null)
283
+        {
284
+            HttpWebRequest request;
285
+
286
+            //如果是发送HTTPS请求  
287
+            if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
288
+            {
289
+                ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
290
+                request = WebRequest.Create(url) as HttpWebRequest;
291
+                request.ProtocolVersion = HttpVersion.Version10;
292
+            }
293
+            else
294
+            {
295
+                request = WebRequest.Create(url) as HttpWebRequest;
296
+            }
297
+            request.Method = "GET";
298
+            //request.ContentType = "application/x-www-form-urlencoded";
299
+            request.Accept = "*/*";
300
+            request.Timeout = 15000;
301
+            request.AllowAutoRedirect = false;
302
+            WebResponse response = null;
303
+            string responseStr = null;
304
+            if (headht != null)
305
+            {
306
+                foreach (DictionaryEntry item in headht)
307
+                {
308
+                    request.Headers.Add(item.Key.ToString(), item.Value.ToString());
309
+                }
310
+            }
311
+
312
+            try
313
+            {
314
+                response = request.GetResponse();
315
+
316
+                if (response != null)
317
+                {
318
+                    StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
319
+                    responseStr = reader.ReadToEnd();
320
+                    reader.Close();
321
+                }
322
+            }
323
+            catch (Exception)
324
+            {
325
+                throw;
326
+            }
327
+            return responseStr;
328
+        }
329
+        public static string HttpGet(string url, Encoding encodeing, Hashtable headht = null)
330
+        {
331
+            HttpWebRequest request;
332
+
333
+            //如果是发送HTTPS请求  
334
+            if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
335
+            {
336
+                ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
337
+                request = WebRequest.Create(url) as HttpWebRequest;
338
+                request.ProtocolVersion = HttpVersion.Version10;
339
+            }
340
+            else
341
+            {
342
+                request = WebRequest.Create(url) as HttpWebRequest;
343
+            }
344
+            request.Method = "GET";
345
+            //request.ContentType = "application/x-www-form-urlencoded";
346
+            request.Accept = "*/*";
347
+            request.Timeout = 15000;
348
+            request.AllowAutoRedirect = false;
349
+            WebResponse response = null;
350
+            string responseStr = null;
351
+            if (headht != null)
352
+            {
353
+                foreach (DictionaryEntry item in headht)
354
+                {
355
+                    request.Headers.Add(item.Key.ToString(), item.Value.ToString());
356
+                }
357
+            }
358
+
359
+            try
360
+            {
361
+                response = request.GetResponse();
362
+
363
+                if (response != null)
364
+                {
365
+                    StreamReader reader = new StreamReader(response.GetResponseStream(), encodeing);
366
+                    responseStr = reader.ReadToEnd();
367
+                    reader.Close();
368
+                }
369
+            }
370
+            catch (Exception)
371
+            {
372
+                throw;
373
+            }
374
+            return responseStr;
375
+        }
376
+        #endregion
377
+
378
+        #region Post With Pic
379
+        private string HttpPost(string url, IDictionary<object, object> param, string filePath)
380
+        {
381
+            string boundary = "---------------------------" + DateTime.Now.Ticks.ToString("x");
382
+            byte[] boundarybytes = System.Text.Encoding.ASCII.GetBytes("\r\n--" + boundary + "\r\n");
383
+
384
+            HttpWebRequest wr = (HttpWebRequest)WebRequest.Create(url);
385
+            wr.ContentType = "multipart/form-data; boundary=" + boundary;
386
+            wr.Method = "POST";
387
+            wr.KeepAlive = true;
388
+            wr.Credentials = System.Net.CredentialCache.DefaultCredentials;
389
+
390
+            Stream rs = wr.GetRequestStream();
391
+            string responseStr = null;
392
+
393
+            string formdataTemplate = "Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}";
394
+            foreach (string key in param.Keys)
395
+            {
396
+                rs.Write(boundarybytes, 0, boundarybytes.Length);
397
+                string formitem = string.Format(formdataTemplate, key, param[key]);
398
+                byte[] formitembytes = System.Text.Encoding.UTF8.GetBytes(formitem);
399
+                rs.Write(formitembytes, 0, formitembytes.Length);
400
+            }
401
+            rs.Write(boundarybytes, 0, boundarybytes.Length);
402
+
403
+            string headerTemplate = "Content-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"\r\nContent-Type: {2}\r\n\r\n";
404
+            string header = string.Format(headerTemplate, "pic", filePath, "text/plain");
405
+            byte[] headerbytes = System.Text.Encoding.UTF8.GetBytes(header);
406
+            rs.Write(headerbytes, 0, headerbytes.Length);
407
+
408
+            FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read);
409
+            byte[] buffer = new byte[4096];
410
+            int bytesRead = 0;
411
+            while ((bytesRead = fileStream.Read(buffer, 0, buffer.Length)) != 0)
412
+            {
413
+                rs.Write(buffer, 0, bytesRead);
414
+            }
415
+            fileStream.Close();
416
+
417
+            byte[] trailer = System.Text.Encoding.ASCII.GetBytes("\r\n--" + boundary + "--\r\n");
418
+            rs.Write(trailer, 0, trailer.Length);
419
+            rs.Close();
420
+
421
+            WebResponse wresp = null;
422
+            try
423
+            {
424
+                wresp = wr.GetResponse();
425
+                Stream stream2 = wresp.GetResponseStream();
426
+                StreamReader reader2 = new StreamReader(stream2);
427
+                responseStr = reader2.ReadToEnd();
428
+                //logger.Debug(string.Format("File uploaded, server response is: {0}", responseStr));
429
+            }
430
+            catch (Exception ex)
431
+            {
432
+                //logger.Error("Error uploading file", ex);
433
+                if (wresp != null)
434
+                {
435
+                    wresp.Close();
436
+                    wresp = null;
437
+                }
438
+                throw;
439
+            }
440
+            return responseStr;
441
+        }
442
+        #endregion
443
+
444
+        #region Post With Pic
445
+        /// <summary>
446
+        /// HTTP POST方式请求数据(带图片)
447
+        /// </summary>
448
+        /// <param name="url">URL</param>        
449
+        /// <param name="param">POST的数据</param>
450
+        /// <param name="fileByte">图片</param>
451
+        /// <returns></returns>
452
+        public static string HttpPost(string url, IDictionary<object, object> param, byte[] fileByte)
453
+        {
454
+            string boundary = "---------------------------" + DateTime.Now.Ticks.ToString("x");
455
+            byte[] boundarybytes = System.Text.Encoding.ASCII.GetBytes("\r\n--" + boundary + "\r\n");
456
+
457
+            HttpWebRequest wr = (HttpWebRequest)WebRequest.Create(url);
458
+            wr.ContentType = "multipart/form-data; boundary=" + boundary;
459
+            wr.Method = "POST";
460
+            wr.KeepAlive = true;
461
+            wr.Credentials = System.Net.CredentialCache.DefaultCredentials;
462
+
463
+            Stream rs = wr.GetRequestStream();
464
+            string responseStr = null;
465
+
466
+            string formdataTemplate = "Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}";
467
+            foreach (string key in param.Keys)
468
+            {
469
+                rs.Write(boundarybytes, 0, boundarybytes.Length);
470
+                string formitem = string.Format(formdataTemplate, key, param[key]);
471
+                byte[] formitembytes = System.Text.Encoding.UTF8.GetBytes(formitem);
472
+                rs.Write(formitembytes, 0, formitembytes.Length);
473
+            }
474
+            rs.Write(boundarybytes, 0, boundarybytes.Length);
475
+
476
+            string headerTemplate = "Content-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"\r\nContent-Type: {2}\r\n\r\n";
477
+            string header = string.Format(headerTemplate, "pic", fileByte, "text/plain");//image/jpeg
478
+            byte[] headerbytes = System.Text.Encoding.UTF8.GetBytes(header);
479
+            rs.Write(headerbytes, 0, headerbytes.Length);
480
+
481
+            rs.Write(fileByte, 0, fileByte.Length);
482
+
483
+            byte[] trailer = System.Text.Encoding.ASCII.GetBytes("\r\n--" + boundary + "--\r\n");
484
+            rs.Write(trailer, 0, trailer.Length);
485
+            rs.Close();
486
+
487
+            WebResponse wresp = null;
488
+            try
489
+            {
490
+                wresp = wr.GetResponse();
491
+                Stream stream2 = wresp.GetResponseStream();
492
+                StreamReader reader2 = new StreamReader(stream2);
493
+                responseStr = reader2.ReadToEnd();
494
+                // logger.Error(string.Format("File uploaded, server response is: {0}", responseStr));
495
+            }
496
+            catch (Exception ex)
497
+            {
498
+                //logger.Error("Error uploading file", ex);
499
+                if (wresp != null)
500
+                {
501
+                    wresp.Close();
502
+                    wresp = null;
503
+                }
504
+                throw;
505
+            }
506
+            return responseStr;
507
+        }
508
+        #endregion
509
+
510
+        #region HttpsClient
511
+        /// <summary>
512
+        /// 创建HttpClient
513
+        /// </summary>
514
+        /// <returns></returns>
515
+        public static HttpClient CreateHttpClient(string url)
516
+        {
517
+            HttpClient httpclient;
518
+            //如果是发送HTTPS请求  
519
+            if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
520
+            {
521
+                ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
522
+                httpclient = new HttpClient();
523
+            }
524
+            else
525
+            {
526
+                httpclient = new HttpClient();
527
+            }
528
+            return httpclient;
529
+        }
530
+        #endregion
531
+    }
532
+}

+ 1 - 1
代码/TVShoppingCallCenter_ZLJ/Controllers/Marketing/MarketingController.cs

266
                     if (split != null)
266
                     if (split != null)
267
                         foreach (var iv in split)
267
                         foreach (var iv in split)
268
                         {
268
                         {
269
-                            var data = await _productRepository.GetSingle(x => x.F_ProductId == int.Parse(iv));
269
+                            var data = await _productRepository.GetSingle(x => x.F_ProductId ==iv);
270
                             if (data != null)
270
                             if (data != null)
271
                             {
271
                             {
272
                                 if (marketing.F_GiftName == "")
272
                                 if (marketing.F_GiftName == "")

+ 2 - 2
代码/TVShoppingCallCenter_ZLJ/Controllers/MediaCente/MediaCenteController.cs

310
                     foreach (var ib in spritcom)
310
                     foreach (var ib in spritcom)
311
                     {
311
                     {
312
                         if (MediaCente.F_CommodityName == "")
312
                         if (MediaCente.F_CommodityName == "")
313
-                            MediaCente.F_CommodityName = _productRepository.GetSingle(x => x.F_ProductId == int.Parse(ib)).Result.F_ProductName;
313
+                            MediaCente.F_CommodityName = _productRepository.GetSingle(x => x.F_ProductId ==ib).Result.F_ProductName;
314
                         else
314
                         else
315
-                            MediaCente.F_CommodityName+=","+ _productRepository.GetSingle(x => x.F_ProductId == int.Parse(ib)).Result.F_ProductName;
315
+                            MediaCente.F_CommodityName+=","+ _productRepository.GetSingle(x => x.F_ProductId ==ib).Result.F_ProductName;
316
                     }
316
                     }
317
                 }
317
                 }
318
                 catch
318
                 catch

文件差异内容过多而无法显示
+ 185 - 63
代码/TVShoppingCallCenter_ZLJ/Controllers/Order/OrderController.cs


+ 9 - 9
代码/TVShoppingCallCenter_ZLJ/Controllers/Product/ProductController.cs

289
                 return Error("请输入正确会员价");
289
                 return Error("请输入正确会员价");
290
             if (input.SpecialPrice <= 0)
290
             if (input.SpecialPrice <= 0)
291
                 return Error("请输入正确特惠价");
291
                 return Error("请输入正确特惠价");
292
-            if (input.ProductId <= 0)
292
+            if (string.IsNullOrEmpty(input.ProductId))
293
                 return Error("请输入正确产品编码");
293
                 return Error("请输入正确产品编码");
294
             if (string.IsNullOrEmpty(input.PinyinShort))
294
             if (string.IsNullOrEmpty(input.PinyinShort))
295
                 return Error("请输入正确拼音简码");
295
                 return Error("请输入正确拼音简码");
403
                 return Error("请输入正确会员价");
403
                 return Error("请输入正确会员价");
404
             if (input.SpecialPrice <= 0)
404
             if (input.SpecialPrice <= 0)
405
                 return Error("请输入正确特惠价");
405
                 return Error("请输入正确特惠价");
406
-            if (input.ProductId <= 0)
407
-                return Error("产品ID必须大于0");
406
+            if (string.IsNullOrEmpty(input.ProductId))
407
+                return Error("产品ID不能为空");
408
             if (string.IsNullOrEmpty(input.PinyinShort))
408
             if (string.IsNullOrEmpty(input.PinyinShort))
409
                 return Error("请输入正确拼音简码");
409
                 return Error("请输入正确拼音简码");
410
             #endregion
410
             #endregion
660
 
660
 
661
             conModels.Add(new ConditionalModel() { FieldName = "F_IsDelete", ConditionalType = ConditionalType.Equal, FieldValue = ((int)EnumDelState.Enabled).ToString() });
661
             conModels.Add(new ConditionalModel() { FieldName = "F_IsDelete", ConditionalType = ConditionalType.Equal, FieldValue = ((int)EnumDelState.Enabled).ToString() });
662
 
662
 
663
-            if (input.ProductId > 0)
663
+            if (!string.IsNullOrEmpty(input.ProductId))
664
             {
664
             {
665
-                conModels.Add(new ConditionalModel() { FieldName = "F_ProductId", ConditionalType = ConditionalType.Equal, FieldValue = input.ProductId.ToString() });
665
+                conModels.Add(new ConditionalModel() { FieldName = "F_ProductId", ConditionalType = ConditionalType.Equal, FieldValue = input.ProductId });
666
             }
666
             }
667
             //指定分类
667
             //指定分类
668
             if (input.ClassId > 0)
668
             if (input.ClassId > 0)
775
 
775
 
776
             foreach (ProductInput m in input)
776
             foreach (ProductInput m in input)
777
             {
777
             {
778
-                if (m.ProductId <= 0)
778
+                if (string.IsNullOrEmpty(m.ProductId))
779
                     return Error("参数缺失产品id");
779
                     return Error("参数缺失产品id");
780
 
780
 
781
                 T_Bus_Product model = await _productRepository.GetSingle(a => a.F_ProductId == m.ProductId);
781
                 T_Bus_Product model = await _productRepository.GetSingle(a => a.F_ProductId == m.ProductId);
797
 
797
 
798
             #endregion
798
             #endregion
799
             //此字段更新单独字段
799
             //此字段更新单独字段
800
-            if (await _productRepository.UpdateListToColumns(listmodel, it => new { it.F_Stock, it.F_FreezeStock, it.F_Stock1, it.F_FreezeStock1, }))
800
+            //if (await _productRepository.UpdateListToColumns(listmodel, it => new { it.F_Stock, it.F_FreezeStock, it.F_Stock1, it.F_FreezeStock1, }))
801
                 return Success("更新库存成功");
801
                 return Success("更新库存成功");
802
-            else
803
-                return Success("更新库存失败");
802
+            //else
803
+            //    return Success("更新库存失败");
804
         }
804
         }
805
 
805
 
806
 
806
 

+ 2 - 2
代码/TVShoppingCallCenter_ZLJ/Models/Inputs/OrderDetailInput.cs

13
 		private string _f_id;
13
 		private string _f_id;
14
 		private int _f_sort = 1;
14
 		private int _f_sort = 1;
15
 		private string _f_orderid;
15
 		private string _f_orderid;
16
-		private int _f_productid;
16
+		private string _f_productid;
17
 		private string _f_productname = "";
17
 		private string _f_productname = "";
18
 		private decimal _f_price;
18
 		private decimal _f_price;
19
 		private decimal _f_dealprice;
19
 		private decimal _f_dealprice;
62
 		/// <summary>
62
 		/// <summary>
63
 		/// 产品编号
63
 		/// 产品编号
64
 		/// </summary>
64
 		/// </summary>
65
-		public int F_ProductId
65
+		public string F_ProductId
66
 		{
66
 		{
67
 			set { _f_productid = value; }
67
 			set { _f_productid = value; }
68
 			get { return _f_productid; }
68
 			get { return _f_productid; }

+ 2 - 2
代码/TVShoppingCallCenter_ZLJ/Models/Inputs/ProductInput.cs

9
     {
9
     {
10
 
10
 
11
         #region Model
11
         #region Model
12
-        private int _f_productid;
12
+        private string _f_productid;
13
         private string _f_productnumber;
13
         private string _f_productnumber;
14
         private string _f_productname;
14
         private string _f_productname;
15
         private string _f_productshortname;
15
         private string _f_productshortname;
49
         /// <summary>
49
         /// <summary>
50
         /// 产品编号ID
50
         /// 产品编号ID
51
         /// </summary>
51
         /// </summary>
52
-        public int ProductId
52
+        public string ProductId
53
         {
53
         {
54
             set { _f_productid = value; }
54
             set { _f_productid = value; }
55
             get { return _f_productid; }
55
             get { return _f_productid; }

+ 7 - 0
代码/TVShoppingCallCenter_ZLJ/appsettings.json

1
 {
1
 {
2
   "Cors": "",
2
   "Cors": "",
3
+  "eBoss": {
4
+    "url": "http://36.99.164.148/eboss_yun/ebossapi.ashx?",
5
+    "appid": "180702",
6
+    "appkey": "9E9672CE87224A8CB825ABAF8DD4B7B8",
7
+    "stock": "WLZZ0001",
8
+    "stock1": "WLZZ0001"
9
+  },
3
   "ConnectionStrings": {
10
   "ConnectionStrings": {
4
     "DefaultConnection": "Data Source=192.168.8.3;User ID=sa;pwd=800100;Initial Catalog=TVCallCenter_ZLJ;"
11
     "DefaultConnection": "Data Source=192.168.8.3;User ID=sa;pwd=800100;Initial Catalog=TVCallCenter_ZLJ;"
5
   },
12
   },