You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1283 lines
48 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using NetLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Script.Serialization;
using System.Net.Security;
using System.Security.Authentication;
using System.Security.Cryptography.X509Certificates;
using System.Net;
using System.IO;
using NetLibrary.Data;
using System.Data.Common;
using System.Data;
using Lazop.Api;
using NetLibrary.Log;
using NetLibrary.OnlineTrade;
using System.Security.Cryptography;
using Newtonsoft.Json;
namespace TradeManageNew
{
public class LXOpenApi
{
/// <summary>
/// 时间戳转为C#格式时间
/// </summary>
/// <param name="timeStamp">Unix时间戳格式</param>
/// <returns>C#格式时间</returns>
public static DateTime GetStampTimeToDate(string timeStamp)
{
DateTime dtStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
long lTime = long.Parse(timeStamp + "0000000");
TimeSpan toNow = new TimeSpan(lTime);
return dtStart.Add(toNow);
}
#region 读取订单
/// <summary>
/// 本时区日期时间转时间戳
/// </summary>
/// <param name="datetime"></param>
/// <returns>long=Int64</returns>
public static long DateTimeToTimestamp(DateTime datetime)
{
// DateTime dd = new DateTime(1970, 1, 1, 0, 0, 0, 0);
System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)); // 当地时区
long timeStamp = (long)(datetime - startTime).TotalSeconds; // 相差毫秒数
return timeStamp;//精确到毫秒
}
static string MD5Setting(string str)
{
StringBuilder sb = new StringBuilder();
using (MD5 md5 = MD5.Create())
{
byte[] bytes = System.Text.Encoding.UTF8.GetBytes(str);
byte[] md5Bytes = md5.ComputeHash(bytes);
for (int i = 0; i < md5Bytes.Length; i++)
{
sb.Append(md5Bytes[i].ToString("X2"));
}
}
return sb.ToString();
}
/// <summary>
/// 加密 参数string
/// </summary>
/// <param name="strCon">加密内容</param>
/// <param name="key">密钥</param>
/// <returns>string密文</returns>
public static string Encrypt(string strCon, string key)
{
try
{
if (string.IsNullOrWhiteSpace(strCon))
{
return null;
}
byte[] byCon = Encoding.UTF8.GetBytes(strCon);
var rm = new RijndaelManaged
{
IV = Encoding.UTF8.GetBytes(key),
Key = Encoding.UTF8.GetBytes(key),
Mode = CipherMode.ECB,
Padding = PaddingMode.PKCS7
};
ICryptoTransform cTransform = rm.CreateEncryptor();
byte[] resultArray = cTransform.TransformFinalBlock(byCon, 0, byCon.Length);
return Convert.ToBase64String(resultArray, 0, resultArray.Length);
}
catch
{
return "";
}
}
public string GetAccToken()
{
//if (LXaccess_token != "" && LXGetTime != null && LXGetTime.Value.AddMinutes(5) > DateTime.Now)
//{
// return LXaccess_token;
//}
string ErrorMessage = "";
string a = "ak_tbUU8T9h3aqgb";// Uri.EscapeDataString("#{ak_tbUU8T9h3aqgb}");// System.Web.HttpUtility.UrlEncode("#{ak_tbUU8T9h3aqgb}", System.Text.Encoding.GetEncoding("UTF-8"));
string b = "EjgjgmerpADaCZpCw8Y/NA==";
string XmlContent = CustomIO.HttpRequest("https://openapi.lingxing.com/api/auth-server/oauth/access-token?appId=" + a + "&appSecret=" + b, "POST", out ErrorMessage);
string token = "";
if (ErrorMessage == "")
{
lxresult md = JsonConvert.DeserializeObject<lxresult>(XmlContent);
if (md != null && md.code == "200")
{
token = md.data.access_token;
LXaccess_token = token;
LXGetTime = DateTime.Now;
}
}
return token;
}
//第二种
/// <summary>
/// 判断输入是否为数字
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public static bool IsNumeral(string input)//shuz数字 numeral
{
foreach (char ch in input)
{
if (ch < '0' || ch > '9')
{
return false;
}
}
return true;
}
public List<OrderModel> GetOrders(string storeid,out string ErrorMessage)
{
try
{
string access_token = GetAccToken();// "a4a36e31-cb88-4802-ba3a-1a8e9cec3619";
string app_key = "ak_tbUU8T9h3aqgb";
string st = DateTimeToTimestamp(DateTime.Now).ToString();
Dictionary<string, string> tempDict3 = new Dictionary<string, string>();
Dictionary<string, string> tempDict = new Dictionary<string, string>();
List<OrderModel> ListModel = new List<OrderModel>();
tempDict.Add("access_token", access_token);
tempDict.Add("app_key", app_key);
tempDict.Add("timestamp", st);
long stime = DateTimeToTimestamp(DateTime.Today.AddDays(-10));
long etime = DateTimeToTimestamp(DateTime.Now);
tempDict.Add("date_type", "global_purchase_time");
tempDict.Add("end_time", etime.ToString());
tempDict.Add("length", "200");
tempDict.Add("offset", "0");
// tempDict.Add("platform_code", "[]");
tempDict.Add("start_time", stime.ToString());
tempDict.Add("store_id", "[\"" + storeid + "\"]");
var tempDict2 = tempDict.OrderBy(p => p.Key).ToDictionary(p => p.Key, o => o.Value);
string cs = "";
foreach (var dc in tempDict2)
{
cs += dc.Key + "=" + dc.Value + "&";
}
cs = cs.TrimEnd('&');
// string ss = "access_token=96bba267-db6e-4cd6-8cf1-b8688ffb3705&app_key=ak_JaDhGPFYRGGSB&timestamp=" + st;
string mds = MD5Setting(cs);
LXOrderModel omd = new LXOrderModel();
omd.date_type = "global_purchase_time";
omd.end_time = etime;
omd.length = 200;
omd.offset = 0;
omd.start_time = stime;
List<string> slist = new List<string>();
slist.Add(storeid);
//slist.Add("110198019658899456");
// slist.Add("110202917567819776");
omd.store_id = slist;
string js = JsonConvert.SerializeObject(omd);
byte[] data = System.Text.Encoding.UTF8.GetBytes(js);
string sss = System.Net.WebUtility.UrlEncode(Encrypt(mds, app_key));
tempDict3.Add("access_token", access_token);
tempDict3.Add("app_key", app_key);
tempDict3.Add("timestamp", st);
tempDict3.Add("sign", sss);
string cs2 = "";
foreach (var dc in tempDict3)
{
cs2 += dc.Key + "=" + dc.Value + "&";
}
cs2 = cs2.TrimEnd('&');
string url = "https://openapi.lingxing.com/pb/mp/order/list?" + cs2;
string XmlContent = HttpRequest(url, "Post", "application/json", null, null, data, out ErrorMessage);
ErrorFollow.TraceWrite("GetLXGetOrders", XmlContent, ErrorMessage);
if (string.IsNullOrEmpty(ErrorMessage) == false)
{
return null;
}
var smd = JsonConvert.DeserializeObject<LX_Root>(XmlContent);
if (smd != null)
{
if (smd.code == "1"&&smd.data.total>0 && smd.data != null)
{
foreach (var ordermd in smd.data.list)
{
// ErrorFollow.TraceWrite("GetFedexFee", ordermd.item_info[0].platform_order_no, ordermd.status);
if (ordermd.status != "4" && ordermd.status != "5" && ordermd.status != "6")
continue;
var str=JsonConvert.SerializeObject(ordermd);
OrderModel model = new OrderModel();
if (ordermd.item_info == null)
continue;
model.OrderCode = ordermd.item_info[0].platform_order_no;
if(model.OrderCode== "108912838956786")
{
}
if (ordermd.transaction_info != null && ordermd.transaction_info[0].order_total_amount != null)
{
string order_total_amount = ordermd.transaction_info[0].order_total_amount.Replace("?","").Replace("-","").Replace("", "").Replace("$", "");
order_total_amount = order_total_amount.ToLower().Replace("?", "");
//if (model.OrderCode == "CS466144423")
//{
// ErrorFollow.TraceWrite("CS466144423", order_total_amount.ToString(), "");
//}
//if (model.OrderCode == "220902PXTN9WG5")
//{
// ErrorFollow.TraceWrite("220902PXTN9WG5", order_total_amount.ToString(), "");
// if (order_total_amount.ToLower().Substring(0, 1) == "?"|| order_total_amount.ToLower().Substring(0, 1) == "")
// {
// ErrorFollow.TraceWrite("220902PXTN9WG5??", order_total_amount.ToString(), "");
// }
//}
if (IsNumeral(order_total_amount.Substring(0,1))==true)
model.TotalPrice = Convert.ToDecimal(order_total_amount);
else if (order_total_amount.Length>=2&&IsNumeral(order_total_amount.Substring(1, 1)) == true)
model.TotalPrice = Convert.ToDecimal(order_total_amount.Substring(1));
else
model.TotalPrice = Convert.ToDecimal(order_total_amount.Substring(2));
}
//客户交的税费,不算在总金额当中,需要减去
if(ordermd.transaction_info != null && ordermd.transaction_info[0].customer_tax_amount_show != null)
{
string customer_tax_amount = ordermd.transaction_info[0].customer_tax_amount_show.Replace("?", "").Replace("-", "").Replace("", "").Replace("$", "");
customer_tax_amount = customer_tax_amount.ToLower().Replace("?", "");
if (IsNumeral(customer_tax_amount.Substring(0, 1)) == true)
model.TotalPrice = model.TotalPrice - Convert.ToDecimal(customer_tax_amount);
else if (customer_tax_amount.Length >= 2 && IsNumeral(customer_tax_amount.Substring(1, 1)) == true)
model.TotalPrice = model.TotalPrice - Convert.ToDecimal(customer_tax_amount.Substring(1));
else
model.TotalPrice = model.TotalPrice - Convert.ToDecimal(customer_tax_amount.Substring(2));
}
//if (model.OrderCode == "CS432813230")
//{
// ErrorFollow.TraceWrite("CS432813230", model.TotalPrice.ToString(), "");
//}
//if (model.OrderCode == "220902PXTN9WG5")
//{
// ErrorFollow.TraceWrite("220902PXTN9WG5", model.TotalPrice.ToString(), "");
//}
model.MoneyCode = ordermd.amount_currency;
model.OrderDate = GetStampTimeToDate(ordermd.global_payment_time.ToString());
if (model.OrderDate.Value.Year < 2000)
{
model.OrderDate = DateTime.Now;
}
model.BuyerID = "";
// model.OrderState = 2;
if (ordermd.address_info != null)
model.BuyerName = ordermd.address_info.receiver_name;
if (ordermd.address_info.receiver_country_code != null)
model.BuyerCountry = ordermd.address_info.receiver_country_code;
if (ordermd.address_info.address_line1 != null)
model.BuyerAddr = ordermd.address_info.address_line1;
if (ordermd.address_info.address_line2 != null)
model.BuyerAddr += " " + ordermd.address_info.address_line2;
if (ordermd.address_info.address_line3 != null)
model.BuyerAddr += " " + ordermd.address_info.address_line3;
model.BuyerPhone = ordermd.address_info.receiver_tel;
model.BuyerMobile = ordermd.address_info.receiver_mobile;
model.BuyerMail = "";
//model.logisticsAmount =ordermd.buyerInfo.logisticsAmount;
//if (ordermd.escrow_tax != null)
//{
// model.escrowFee = Convert.ToDecimal(ordermd.escrow_tax);
// // model.TotalPrice = Convert.ToDecimal(ordermd.escrow_amount);
//}
//if (ordermd.escrow_amount != null && ordermd.escrow_amount != "")
// model.TotalPrice = Convert.ToDecimal(ordermd.escrow_amount);
model.BuyerFax = "";
if (ordermd.address_info != null)
model.BuyerZip = ordermd.address_info.postal_code;
if (ordermd.address_info != null)
model.BuyerProvince = ordermd.address_info.state_or_region;
if (ordermd.address_info != null)
model.BuyerCity = ordermd.address_info.city;
if (ordermd.address_info != null)
model.BuyerArea = ordermd.address_info.district;
model.OrderRemark = ""; //memo
model.LeaveWord = "";
model.PayDate = model.OrderDate;
model.OutOrderDate = GetStampTimeToDate(ordermd.global_latest_ship_time.ToString());
if (ordermd.logistics_info != null)
model.PostInfo = ordermd.logistics_info.logistics_type_name;
model.ListModel = new List<OrderDetailModel>();
// {"item_name":"Adjustable Kids Safety Harness Wrist Leash Anti-lost Link","item_sku":"\tZHI049","variation_discounted_price":"7.74","variation_id":320874188,"variation_name":"Blue, 250CM","item_id":418147192,
// "variation_quantity_purchased":1,"variation_sku":"\tZHI049","variation_original_price":"8.60"
if (ordermd.item_info != null)
{
foreach (var item2 in ordermd.item_info)
{
OrderDetailModel model2 = new OrderDetailModel();
model2.TypeDesc = item2.variant_attr;
model2.productImgUrl = "";
model2.GoodsNum = Convert.ToInt32(item2.quantity);
if (item2.unit_price_amount != null)
model2.GoodsPrice = Convert.ToDecimal(item2.unit_price_amount);
model2.MoneyCode = "";
model2.GoodsName = item2.local_product_name;
model2.GoodsSKU = item2.msku;
model2.PostInfo = "";
model.ListModel.Add(model2);
}
}
// ErrorFollow.TraceWrite("GetFedexFee", ListModel.Count.ToString(), "");
ListModel.Add(model);
}
bool flag = true;
int offset = 0;
while (flag)
{
offset = offset + 200;
int count = 0;
var list = GetOrdersNext(storeid, offset, stime, etime, out ErrorMessage,out count);
if (count==0)
{
flag = false;
}
else if (list != null)
{
foreach (var oomd in list)
{
ListModel.Add(oomd);
}
}
}
}
}
return ListModel;
}
catch (Exception ex)
{
ErrorFollow.TraceWrite("GetLXOrder", ex.Message.ToString(), "");
ErrorMessage = ex.Message;
return null;
}
// ErrorFollow.TraceWrite("GetFedexFee", ListModel.Count.ToString(),"");
}
public static string LXaccess_token = "";
public static DateTime? LXGetTime = null;
public List<OrderModel> GetOrdersNext(string storeid,int offset,long stime, long etime, out string ErrorMessage,out int count)
{
count = 0;
try
{
string access_token = GetAccToken();// "a4a36e31-cb88-4802-ba3a-1a8e9cec3619";
string app_key = "ak_tbUU8T9h3aqgb";
string st = DateTimeToTimestamp(DateTime.Now).ToString();
Dictionary<string, string> tempDict3 = new Dictionary<string, string>();
Dictionary<string, string> tempDict = new Dictionary<string, string>();
List<OrderModel> ListModel = new List<OrderModel>();
tempDict.Add("access_token", access_token);
tempDict.Add("app_key", app_key);
tempDict.Add("timestamp", st);
tempDict.Add("date_type", "global_purchase_time");
tempDict.Add("end_time", etime.ToString());
tempDict.Add("length", "200");
tempDict.Add("offset", offset.ToString());
// tempDict.Add("platform_code", "[]");
tempDict.Add("start_time", stime.ToString());
tempDict.Add("store_id", "[\"" + storeid + "\"]");
var tempDict2 = tempDict.OrderBy(p => p.Key).ToDictionary(p => p.Key, o => o.Value);
string cs = "";
foreach (var dc in tempDict2)
{
cs += dc.Key + "=" + dc.Value + "&";
}
cs = cs.TrimEnd('&');
// string ss = "access_token=96bba267-db6e-4cd6-8cf1-b8688ffb3705&app_key=ak_JaDhGPFYRGGSB&timestamp=" + st;
string mds = MD5Setting(cs);
LXOrderModel omd = new LXOrderModel();
omd.date_type = "global_purchase_time";
omd.end_time = etime;
omd.length = 200;
omd.offset = offset;
omd.start_time = stime;
List<string> slist = new List<string>();
slist.Add(storeid);
//slist.Add("110198019658899456");
// slist.Add("110202917567819776");
omd.store_id = slist;
string js = JsonConvert.SerializeObject(omd);
byte[] data = System.Text.Encoding.UTF8.GetBytes(js);
string sss = System.Net.WebUtility.UrlEncode(Encrypt(mds, app_key));
tempDict3.Add("access_token", access_token);
tempDict3.Add("app_key", app_key);
tempDict3.Add("timestamp", st);
tempDict3.Add("sign", sss);
string cs2 = "";
foreach (var dc in tempDict3)
{
cs2 += dc.Key + "=" + dc.Value + "&";
}
cs2 = cs2.TrimEnd('&');
string url = "https://openapi.lingxing.com/pb/mp/order/list?" + cs2;
string XmlContent = HttpRequest(url, "Post", "application/json", null, null, data, out ErrorMessage);
ErrorFollow.TraceWrite("GetLXGetOrders", XmlContent, ErrorMessage);
if (string.IsNullOrEmpty(ErrorMessage) == false)
{
return null;
}
var smd = JsonConvert.DeserializeObject<LX_Root>(XmlContent);
if (smd != null)
{
if (smd.code == "1" && smd.data.total > 0 && smd.data != null)
{
count = smd.data.total.Value;
foreach (var ordermd in smd.data.list)
{
// ErrorFollow.TraceWrite("GetFedexFee", ordermd.item_info[0].platform_order_no, ordermd.status);
if (ordermd.status != "4" && ordermd.status != "5" && ordermd.status != "6")
continue;
OrderModel model = new OrderModel();
if (ordermd.item_info == null)
continue;
model.OrderCode = ordermd.item_info[0].platform_order_no;
if (model.OrderCode == "108906731002378")
{
}
if (ordermd.transaction_info != null && ordermd.transaction_info[0].order_total_amount != null)
{
string order_total_amount = ordermd.transaction_info[0].order_total_amount.Replace("?", "").Replace("-", "").Replace("", "").Replace("$", "");
order_total_amount = order_total_amount.ToLower().Replace("?", "");
if (IsNumeral(order_total_amount.Substring(0, 1)) == true)
model.TotalPrice = Convert.ToDecimal(order_total_amount);
else if (order_total_amount.Length >= 2 && IsNumeral(order_total_amount.Substring(1, 1)) == true)
model.TotalPrice = Convert.ToDecimal(order_total_amount.Substring(1));
else
model.TotalPrice = Convert.ToDecimal(order_total_amount.Substring(2));
}
//客户交的税费,不算在总金额当中,需要减去
if (ordermd.transaction_info != null && ordermd.transaction_info[0].customer_tax_amount_show != null)
{
string customer_tax_amount = ordermd.transaction_info[0].customer_tax_amount_show.Replace("?", "").Replace("-", "").Replace("", "").Replace("$", "");
customer_tax_amount = customer_tax_amount.ToLower().Replace("?", "");
if (IsNumeral(customer_tax_amount.Substring(0, 1)) == true)
model.TotalPrice = model.TotalPrice - Convert.ToDecimal(customer_tax_amount);
else if (customer_tax_amount.Length >= 2 && IsNumeral(customer_tax_amount.Substring(1, 1)) == true)
model.TotalPrice = model.TotalPrice - Convert.ToDecimal(customer_tax_amount.Substring(1));
else
model.TotalPrice = model.TotalPrice - Convert.ToDecimal(customer_tax_amount.Substring(2));
}
model.MoneyCode = ordermd.amount_currency;
model.OrderDate = GetStampTimeToDate(ordermd.global_payment_time.ToString());
if (model.OrderDate.Value.Year < 2000)
{
model.OrderDate = DateTime.Now;
}
model.BuyerID = "";
// model.OrderState = 2;
if (ordermd.address_info != null)
model.BuyerName = ordermd.address_info.receiver_name;
if (ordermd.address_info.receiver_country_code != null)
model.BuyerCountry = ordermd.address_info.receiver_country_code;
if (ordermd.address_info.address_line1 != null)
model.BuyerAddr = ordermd.address_info.address_line1;
if (ordermd.address_info.address_line2 != null)
model.BuyerAddr += " " + ordermd.address_info.address_line2;
if (ordermd.address_info.address_line3 != null)
model.BuyerAddr += " " + ordermd.address_info.address_line3;
model.BuyerPhone = ordermd.address_info.receiver_tel;
model.BuyerMobile = ordermd.address_info.receiver_mobile;
model.BuyerMail = "";
//model.logisticsAmount =ordermd.buyerInfo.logisticsAmount;
//if (ordermd.escrow_tax != null)
//{
// model.escrowFee = Convert.ToDecimal(ordermd.escrow_tax);
// // model.TotalPrice = Convert.ToDecimal(ordermd.escrow_amount);
//}
//if (ordermd.escrow_amount != null && ordermd.escrow_amount != "")
// model.TotalPrice = Convert.ToDecimal(ordermd.escrow_amount);
model.BuyerFax = "";
if (ordermd.address_info != null)
model.BuyerZip = ordermd.address_info.postal_code;
if (ordermd.address_info != null)
model.BuyerProvince = ordermd.address_info.state_or_region;
if (ordermd.address_info != null)
model.BuyerCity = ordermd.address_info.city;
if (ordermd.address_info != null)
model.BuyerArea = ordermd.address_info.district;
model.OrderRemark = ""; //memo
model.LeaveWord = "";
model.PayDate = model.OrderDate;
model.OutOrderDate = GetStampTimeToDate(ordermd.global_latest_ship_time.ToString());
if (ordermd.logistics_info != null)
model.PostInfo = ordermd.logistics_info.logistics_type_name;
model.ListModel = new List<OrderDetailModel>();
// {"item_name":"Adjustable Kids Safety Harness Wrist Leash Anti-lost Link","item_sku":"\tZHI049","variation_discounted_price":"7.74","variation_id":320874188,"variation_name":"Blue, 250CM","item_id":418147192,
// "variation_quantity_purchased":1,"variation_sku":"\tZHI049","variation_original_price":"8.60"
if (ordermd.item_info != null)
{
foreach (var item2 in ordermd.item_info)
{
OrderDetailModel model2 = new OrderDetailModel();
model2.TypeDesc = item2.variant_attr;
model2.productImgUrl = "";
model2.GoodsNum = Convert.ToInt32(item2.quantity);
if (item2.unit_price_amount != null)
model2.GoodsPrice = Convert.ToDecimal(item2.unit_price_amount);
model2.MoneyCode = "";
model2.GoodsName = item2.local_product_name;
model2.GoodsSKU = item2.msku;
model2.PostInfo = "";
model.ListModel.Add(model2);
}
}
// ErrorFollow.TraceWrite("GetFedexFee", ListModel.Count.ToString(), "");
ListModel.Add(model);
}
}
}
// ErrorFollow.TraceWrite("GetFedexFee", ListModel.Count.ToString(),"");
return ListModel;
}
catch (Exception ex)
{
ErrorFollow.TraceWrite("GetLXNextOrder", ex.Message.ToString(), "");
ErrorMessage = ex.Message;
return null;
}
}
#region Http请求
public static string HttpRequest(string url, string Method, string ContentType, List<string> ListHeader, Version ver, byte[] bytes, out string ErrorMessage)
{
try
{
ErrorMessage = "";
//System.Net.ServicePointManager.DefaultConnectionLimit =200;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3
| SecurityProtocolType.Tls
| SecurityProtocolType.Tls11
| SecurityProtocolType.Tls12;
if (string.IsNullOrEmpty(ContentType) == true) ContentType = "application/x-www-form-urlencoded";
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(url);
myRequest.Method = Method; //GET,POST
myRequest.ContentType = ContentType;
myRequest.KeepAlive = true;
//myRequest.Accept = "text/html";
//myRequest.UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; qihu theworld)";
myRequest.Headers.Add("Accept-Language: zh-CN");
myRequest.Headers["Pragma"] = "no-cache"; //禁用缓存
myRequest.Headers["Cache-Control"] = "no-cache"; //禁用缓存
//myRequest.Timeout = 3 * 60 * 1000;
myRequest.Timeout = 15000;
myRequest.ReadWriteTimeout = 3 * 60 * 1000;
if (ver != null)
myRequest.ProtocolVersion = ver;
if (ListHeader != null)
{
foreach (var item in ListHeader)
{
myRequest.Headers.Add(item);
}
}
if (Method.ToUpper() == "POST" && (bytes == null || bytes.Length == 0))
{
bytes = new byte[1];
}
if (bytes != null && bytes.Length > 0)
{
//myRequest.GetRequestStream().Write(bytes, 0, bytes.Length);
Stream stream = myRequest.GetRequestStream();
stream.Write(bytes, 0, bytes.Length);
stream.Close();
}
//获得接口返回值
HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
Stream myResponseStream = myResponse.GetResponseStream();
StreamReader reader = new StreamReader(myResponseStream, Encoding.UTF8);
string content = reader.ReadToEnd();
reader.Close();
myResponseStream.Close();
myRequest.Abort();
myResponse.Close();
reader = null;
myResponseStream = null;
myRequest = null;
myResponse = null;
return content;
}
catch (WebException e)
{
if (e.Response == null)
{
ErrorMessage = e.Message;
}
else
{
Stream myResponseStream = e.Response.GetResponseStream();
StreamReader reader = new StreamReader(myResponseStream, Encoding.UTF8);
ErrorMessage = reader.ReadToEnd();
if (ErrorMessage == "") ErrorMessage = e.Message;
}
}
return "";
}
#endregion
private int GetTimeStamp(DateTime dt)
{
DateTime dateStart = new DateTime(1970, 1, 1, 8, 0, 0);
int timeStamp = Convert.ToInt32((dt - dateStart).TotalSeconds);
return timeStamp;
}
#endregion
}
public class Address_info
{
/// <summary>
///
/// </summary>
public string address_line1 { get; set; }
/// <summary>
///
/// </summary>
public string address_line2 { get; set; }
/// <summary>
///
/// </summary>
public string address_line3 { get; set; }
/// <summary>
///
/// </summary>
public string city { get; set; }
/// <summary>
///
/// </summary>
public string district { get; set; }
/// <summary>
///
/// </summary>
public string doorplate_no { get; set; }
/// <summary>
///
/// </summary>
public string postal_code { get; set; }
/// <summary>
///
/// </summary>
public string receiver_country_code { get; set; }
/// <summary>
///
/// </summary>
public string receiver_mobile { get; set; }
/// <summary>
///
/// </summary>
public string receiver_name { get; set; }
/// <summary>
///
/// </summary>
public string receiver_tel { get; set; }
/// <summary>
///
/// </summary>
public string state_or_region { get; set; }
}
public class Buyers_info
{
/// <summary>
///
/// </summary>
public string buyer_email { get; set; }
/// <summary>
///
/// </summary>
public string buyer_name { get; set; }
/// <summary>
///
/// </summary>
public string buyer_no { get; set; }
/// <summary>
///
/// </summary>
public string buyer_note { get; set; }
}
public class Item_info
{
/// <summary>
///
/// </summary>
public string item_from_name { get; set; }
/// <summary>
///
/// </summary>
public string local_product_name { get; set; }
/// <summary>
///
/// </summary>
public string local_sku { get; set; }
/// <summary>
///
/// </summary>
public string msku { get; set; }
/// <summary>
///
/// </summary>
public string order_item_no { get; set; }
/// <summary>
///
/// </summary>
public string platform_order_no { get; set; }
/// <summary>
///
/// </summary>
public string platform_status { get; set; }
/// <summary>
///
/// </summary>
public string quantity { get; set; }
/// <summary>
///
/// </summary>
public string remark { get; set; }
/// <summary>
///
/// </summary>
public string type { get; set; }
/// <summary>
///
/// </summary>
public string unit_price_amount { get; set; }
/// <summary>
///
/// </summary>
public string variant_attr { get; set; }
}
public class Logistics_info
{
/// <summary>
///
/// </summary>
public string actual_carrier { get; set; }
/// <summary>
///
/// </summary>
public string cost_amount { get; set; }
/// <summary>
///
/// </summary>
public string cost_currency_code { get; set; }
/// <summary>
///
/// </summary>
//public Int32? logistics_provider_id { get; set; }
/// <summary>
///
/// </summary>
public string logistics_provider_id { get; set; }
/// <summary>
///
/// </summary>
public string logistics_provider_name { get; set; }
/// <summary>
///
/// </summary>
public Int32? logistics_time { get; set; }
/// <summary>
///
/// </summary>
//public int logistics_type_id { get; set; }
/// <summary>
///
/// </summary>
public string logistics_type_id { get; set; }
/// <summary>
///
/// </summary>
public string logistics_type_name { get; set; }
/// <summary>
///
/// </summary>
public string pkg_fee_weight { get; set; }
/// <summary>
///
/// </summary>
public string pkg_fee_weight_unit { get; set; }
/// <summary>
///
/// </summary>
public string pkg_height { get; set; }
/// <summary>
///
/// </summary>
public string pkg_length { get; set; }
/// <summary>
///
/// </summary>
public string pkg_size_unit { get; set; }
/// <summary>
///
/// </summary>
public string pkg_width { get; set; }
/// <summary>
///
/// </summary>
public string pre_cost_amount { get; set; }
/// <summary>
///
/// </summary>
public string pre_fee_weight { get; set; }
/// <summary>
///
/// </summary>
public string pre_fee_weight_unit { get; set; }
/// <summary>
///
/// </summary>
public string pre_pkg_height { get; set; }
/// <summary>
///
/// </summary>
public string pre_pkg_length { get; set; }
/// <summary>
///
/// </summary>
public string pre_pkg_width { get; set; }
/// <summary>
///
/// </summary>
public string pre_weight { get; set; }
/// <summary>
///
/// </summary>
public string status { get; set; }
/// <summary>
///
/// </summary>
public string waybill_no { get; set; }
/// <summary>
///
/// </summary>
public string weight { get; set; }
/// <summary>
///
/// </summary>
public string weight_unit { get; set; }
}
public class Order_tag
{
/// <summary>
///
/// </summary>
public string tag_no { get; set; }
/// <summary>
///
/// </summary>
public string tag_type { get; set; }
}
public class Platform_info
{
/// <summary>
///
/// </summary>
public Int32? cancel_time { get; set; }
/// <summary>
///
/// </summary>
public Int32? delivery_time { get; set; }
/// <summary>
///
/// </summary>
public Int32? latest_ship_time { get; set; }
/// <summary>
///
/// </summary>
public string order_from { get; set; }
/// <summary>
///
/// </summary>
public string payment_status { get; set; }
/// <summary>
///
/// </summary>
public Int32? payment_time { get; set; }
/// <summary>
///
/// </summary>
public string platform_code { get; set; }
/// <summary>
///
/// </summary>
public string platform_order_name { get; set; }
/// <summary>
///
/// </summary>
public string platform_order_no { get; set; }
/// <summary>
///
/// </summary>
public Int32? purchase_time { get; set; }
/// <summary>
///
/// </summary>
public string shipping_status { get; set; }
/// <summary>
///
/// </summary>
public string status { get; set; }
/// <summary>
///
/// </summary>
public string store_Country_code { get; set; }
}
public class Transaction_info
{
/// <summary>
///
/// </summary>
public string amountInit { get; set; }
/// <summary>
///
/// </summary>
public string customer_shipping_amount { get; set; }
/// <summary>
///
/// </summary>
public string customer_tax_amount_show { get; set; }
/// <summary>
///
/// </summary>
public string customer_tip_amount { get; set; }
/// <summary>
///
/// </summary>
public string discount_amount { get; set; }
/// <summary>
///
/// </summary>
public string order_item_amount { get; set; }
/// <summary>
///
/// </summary>
public string order_total_amount { get; set; }
/// <summary>
///
/// </summary>
public string outbound_cost_amount { get; set; }
/// <summary>
///
/// </summary>
public string pre_cost_amount { get; set; }
/// <summary>
///
/// </summary>
public string profit_amount { get; set; }
/// <summary>
///
/// </summary>
public string transaction_fee_amount { get; set; }
}
public class LX_List
{
public string amount_currency { get; set; }
/// <summary>
///
/// </summary>
public Address_info address_info { get; set; }
/// <summary>
///
/// </summary>
public Buyers_info buyers_info { get; set; }
/// <summary>
///
/// </summary>
public string delivery_type { get; set; }
/// <summary>
///
/// </summary>
public Int32? global_cancel_time { get; set; }
/// <summary>
///
/// </summary>
public Int32? global_delivery_time { get; set; }
/// <summary>
///
/// </summary>
public Int32? global_distribution_time { get; set; }
/// <summary>
///
/// </summary>
public Int32? global_latest_ship_time { get; set; }
/// <summary>
///
/// </summary>
public string global_order_no { get; set; }
/// <summary>
///
/// </summary>
public Int32? global_payment_time { get; set; }
/// <summary>
///
/// </summary>
public Int32? global_print_time { get; set; }
/// <summary>
///
/// </summary>
public Int32? global_purchase_time { get; set; }
/// <summary>
///
/// </summary>
public Int32? global_review_time { get; set; }
/// <summary>
///
/// </summary>
public List<Item_info> item_info { get; set; }
/// <summary>
///
/// </summary>
public Logistics_info logistics_info { get; set; }
/// <summary>
///
/// </summary>
public string order_from_name { get; set; }
/// <summary>
///
/// </summary>
public string status { get; set; }
/// <summary>
///
/// </summary>
public List<Order_tag> order_tag { get; set; }
/// <summary>
///
/// </summary>
public List<Platform_info> platform_info { get; set; }
/// <summary>
///
/// </summary>
public string platform_order_name { get; set; }
/// <summary>
///
/// </summary>
public string platform_order_no { get; set; }
/// <summary>
///
/// </summary>
public string remark { get; set; }
/// <summary>
///
/// </summary>
public string split_type { get; set; }
/// <summary>
///
/// </summary>
public string store_id { get; set; }
/// <summary>
///
/// </summary>
public List<Transaction_info> transaction_info { get; set; }
/// <summary>
///
/// </summary>
public int update_time { get; set; }
/// <summary>
///
/// </summary>
public string wid { get; set; }
}
public class LX_Data
{
/// <summary>
///
/// </summary>
public int current { get; set; }
/// <summary>
///
/// </summary>
public List<LX_List> list { get; set; }
/// <summary>
///
/// </summary>
public Int32? pages { get; set; }
/// <summary>
///
/// </summary>
public Int32? size { get; set; }
/// <summary>
///
/// </summary>
public Int32? total { get; set; }
}
public class LX_Root
{
/// <summary>
///
/// </summary>
public string code { get; set; }
/// <summary>
///
/// </summary>
public LX_Data data { get; set; }
/// <summary>
///
/// </summary>
public string msg { get; set; }
/// <summary>
///
/// </summary>
public Boolean? success { get; set; }
/// <summary>
///
/// </summary>
public string traceId { get; set; }
}
public class lxresult
{
public string code { get; set; }
public string msg { get; set; }
public lxtoken data { get; set; }
}
public class lxtoken
{
public string access_token { get; set; }
public string refresh_token { get; set; }
}
public class LXOrderModel
{
public string date_type { get; set; }
public long? end_time { get; set; }
public Int32? length { get; set; }
public Int32? offset { get; set; }
public long? start_time { get; set; }
// public List<string> platform_code { get; set; }
public List<string> store_id { get; set; }
}
}