订单列表增加 同步订单
This commit is contained in:
1 parent
4f606c3561
commit
cef6300e8e
24 files changed
+2674
-1211
No files matched your search
@@ -0,0 +1,112 @@
|
||||
using AllBase;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WxOrder.Framework.Commons;
|
||||
|
||||
namespace Work.KJDServer.API
|
||||
{
|
||||
public class KJDServerHttp
|
||||
{
|
||||
public static async Task<string> PostAsync(string url, string data)
|
||||
{
|
||||
if (url.StartsWith("/"))
|
||||
url = url.Substring(1);
|
||||
url = BaseClass.LoginApiUrl + "/wxxd_" + url + "?obj=" + BaseClass.MainPath + "/wxxd_" + url;
|
||||
string sign = UserLogin.GetSignaturex();
|
||||
data = $"{sign}&{data}";
|
||||
return await _postAsync(url, data);
|
||||
}
|
||||
public static async Task<T> PostAsync<T>(string url, string data) where T : Result, new()
|
||||
{
|
||||
try
|
||||
{
|
||||
string result = await PostAsync(url, data);
|
||||
return JsonConvert.DeserializeObject<T>(result);
|
||||
}
|
||||
catch (JsonException)
|
||||
{
|
||||
return new T { Code = 0, Msg = "数据解析失败" };
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new T { Code = 0, Msg = ex.Message };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static async Task<string> _postAsync(string url, string postData, int timeOut = -1)
|
||||
{
|
||||
HttpWebResponse response = null;
|
||||
string result;
|
||||
try
|
||||
{
|
||||
HttpWebRequest request;
|
||||
request = (HttpWebRequest)WebRequest.Create(url);
|
||||
|
||||
request.KeepAlive = true;
|
||||
request.ContentType = "application/x-www-form-urlencoded; charset=utf-8";
|
||||
request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36";
|
||||
request.Headers.Set(HttpRequestHeader.AcceptEncoding, "gzip, deflate");
|
||||
request.Headers.Set(HttpRequestHeader.AcceptLanguage, "zh-CN,zh;q=0.9");
|
||||
|
||||
request.Method = "POST";
|
||||
request.ServicePoint.Expect100Continue = false;
|
||||
|
||||
string body = postData;
|
||||
byte[] postBytes = System.Text.Encoding.UTF8.GetBytes(body);
|
||||
request.ContentLength = postBytes.Length;
|
||||
Stream stream = request.GetRequestStream();
|
||||
stream.Write(postBytes, 0, postBytes.Length);
|
||||
stream.Close();
|
||||
|
||||
response = (HttpWebResponse)await request.GetResponseAsync();
|
||||
}
|
||||
catch (WebException ex)
|
||||
{
|
||||
if (ex.Status == WebExceptionStatus.ProtocolError)
|
||||
{
|
||||
response = (HttpWebResponse)ex.Response;
|
||||
result = ReadResponse(response);
|
||||
return result;
|
||||
}
|
||||
else return ex.Message;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (response != null) response.Close();
|
||||
return e.Message;
|
||||
}
|
||||
result = ReadResponse(response);
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
public static string ReadResponse(HttpWebResponse response, Encoding encoding = null)
|
||||
{
|
||||
using (Stream responseStream = response.GetResponseStream())
|
||||
{
|
||||
Stream streamToRead = responseStream;
|
||||
if (response.ContentEncoding.ToLower().Contains("gzip"))
|
||||
{
|
||||
streamToRead = new GZipStream(streamToRead, CompressionMode.Decompress);
|
||||
}
|
||||
else if (response.ContentEncoding.ToLower().Contains("deflate"))
|
||||
{
|
||||
streamToRead = new DeflateStream(streamToRead, CompressionMode.Decompress);
|
||||
}
|
||||
if (encoding == null) encoding = Encoding.UTF8;
|
||||
using (StreamReader streamReader = new StreamReader(streamToRead, encoding))
|
||||
{
|
||||
return streamReader.ReadToEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Work.KJDServer.API.Models
|
||||
{
|
||||
public class OrderTask
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public int TaskType { get; set; }
|
||||
|
||||
public string TaskDescribe { get; set; }
|
||||
|
||||
public string ShopId { get; set; }
|
||||
public string ShopName { get; set; }
|
||||
|
||||
public string ObjectIds { get; set; }
|
||||
|
||||
public int SubTaskNum { get; set; }
|
||||
|
||||
public int SuccessTaskNum { get; set; }
|
||||
|
||||
public int FailTaskNum { get; set; }
|
||||
|
||||
public int Status { get; set; }
|
||||
|
||||
public string CreateBy { get; set; }
|
||||
|
||||
public string UpdateBy { get; set; }
|
||||
|
||||
public string Remark { get; set; }
|
||||
|
||||
public string TaskFailReason { get; set; }
|
||||
|
||||
public DateTime CreateTime { get; set; }
|
||||
|
||||
public DateTime UpdateTime { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using AllBase;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Work.KJDServer.API.Models;
|
||||
using WxOrder.Framework.Commons;
|
||||
|
||||
namespace Work.KJDServer.API.WXOrder
|
||||
{
|
||||
public class WxOrderServiceApi
|
||||
{
|
||||
public WxOrderServiceApi()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public async Task<List<OrderTask>> GetWxTaskStatus()
|
||||
{
|
||||
var ret = await KJDServerHttp.PostAsync<Result<List<OrderTask>>>("order/wx_get_task_status_list", "");
|
||||
if (ret.Code == 200)
|
||||
{
|
||||
return ret.Data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user