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
{
///
/// 时间戳转为C#格式时间
///
/// Unix时间戳格式
/// C#格式时间
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 读取订单
///
/// 本时区日期时间转时间戳
///
///
/// long=Int64
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();
}
///
/// 加密 参数:string
///
/// 加密内容
/// 密钥
/// string:密文
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(XmlContent);
if (md != null && md.code == "200")
{
token = md.data.access_token;
LXaccess_token = token;
LXGetTime = DateTime.Now;
}
}
return token;
}
//第二种
///
/// 判断输入是否为数字
///
///
///
public static bool IsNumeral(string input)//shuz数字 numeral
{
foreach (char ch in input)
{
if (ch < '0' || ch > '9')
{
return false;
}
}
return true;
}
public List 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 tempDict3 = new Dictionary();
Dictionary tempDict = new Dictionary();
List ListModel = new List();
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×tamp=" + 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 slist = new List();
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(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();
// {"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 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 tempDict3 = new Dictionary();
Dictionary tempDict = new Dictionary();
List ListModel = new List();
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×tamp=" + 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 slist = new List();
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(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();
// {"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 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
{
///
///
///
public string address_line1 { get; set; }
///
///
///
public string address_line2 { get; set; }
///
///
///
public string address_line3 { get; set; }
///
///
///
public string city { get; set; }
///
///
///
public string district { get; set; }
///
///
///
public string doorplate_no { get; set; }
///
///
///
public string postal_code { get; set; }
///
///
///
public string receiver_country_code { get; set; }
///
///
///
public string receiver_mobile { get; set; }
///
///
///
public string receiver_name { get; set; }
///
///
///
public string receiver_tel { get; set; }
///
///
///
public string state_or_region { get; set; }
}
public class Buyers_info
{
///
///
///
public string buyer_email { get; set; }
///
///
///
public string buyer_name { get; set; }
///
///
///
public string buyer_no { get; set; }
///
///
///
public string buyer_note { get; set; }
}
public class Item_info
{
///
///
///
public string item_from_name { get; set; }
///
///
///
public string local_product_name { get; set; }
///
///
///
public string local_sku { get; set; }
///
///
///
public string msku { get; set; }
///
///
///
public string order_item_no { get; set; }
///
///
///
public string platform_order_no { get; set; }
///
///
///
public string platform_status { get; set; }
///
///
///
public string quantity { get; set; }
///
///
///
public string remark { get; set; }
///
///
///
public string type { get; set; }
///
///
///
public string unit_price_amount { get; set; }
///
///
///
public string variant_attr { get; set; }
}
public class Logistics_info
{
///
///
///
public string actual_carrier { get; set; }
///
///
///
public string cost_amount { get; set; }
///
///
///
public string cost_currency_code { get; set; }
///
///
///
//public Int32? logistics_provider_id { get; set; }
///
///
///
public string logistics_provider_id { get; set; }
///
///
///
public string logistics_provider_name { get; set; }
///
///
///
public Int32? logistics_time { get; set; }
///
///
///
//public int logistics_type_id { get; set; }
///
///
///
public string logistics_type_id { get; set; }
///
///
///
public string logistics_type_name { get; set; }
///
///
///
public string pkg_fee_weight { get; set; }
///
///
///
public string pkg_fee_weight_unit { get; set; }
///
///
///
public string pkg_height { get; set; }
///
///
///
public string pkg_length { get; set; }
///
///
///
public string pkg_size_unit { get; set; }
///
///
///
public string pkg_width { get; set; }
///
///
///
public string pre_cost_amount { get; set; }
///
///
///
public string pre_fee_weight { get; set; }
///
///
///
public string pre_fee_weight_unit { get; set; }
///
///
///
public string pre_pkg_height { get; set; }
///
///
///
public string pre_pkg_length { get; set; }
///
///
///
public string pre_pkg_width { get; set; }
///
///
///
public string pre_weight { get; set; }
///
///
///
public string status { get; set; }
///
///
///
public string waybill_no { get; set; }
///
///
///
public string weight { get; set; }
///
///
///
public string weight_unit { get; set; }
}
public class Order_tag
{
///
///
///
public string tag_no { get; set; }
///
///
///
public string tag_type { get; set; }
}
public class Platform_info
{
///
///
///
public Int32? cancel_time { get; set; }
///
///
///
public Int32? delivery_time { get; set; }
///
///
///
public Int32? latest_ship_time { get; set; }
///
///
///
public string order_from { get; set; }
///
///
///
public string payment_status { get; set; }
///
///
///
public Int32? payment_time { get; set; }
///
///
///
public string platform_code { get; set; }
///
///
///
public string platform_order_name { get; set; }
///
///
///
public string platform_order_no { get; set; }
///
///
///
public Int32? purchase_time { get; set; }
///
///
///
public string shipping_status { get; set; }
///
///
///
public string status { get; set; }
///
///
///
public string store_Country_code { get; set; }
}
public class Transaction_info
{
///
///
///
public string amountInit { get; set; }
///
///
///
public string customer_shipping_amount { get; set; }
///
///
///
public string customer_tax_amount_show { get; set; }
///
///
///
public string customer_tip_amount { get; set; }
///
///
///
public string discount_amount { get; set; }
///
///
///
public string order_item_amount { get; set; }
///
///
///
public string order_total_amount { get; set; }
///
///
///
public string outbound_cost_amount { get; set; }
///
///
///
public string pre_cost_amount { get; set; }
///
///
///
public string profit_amount { get; set; }
///
///
///
public string transaction_fee_amount { get; set; }
}
public class LX_List
{
public string amount_currency { get; set; }
///
///
///
public Address_info address_info { get; set; }
///
///
///
public Buyers_info buyers_info { get; set; }
///
///
///
public string delivery_type { get; set; }
///
///
///
public Int32? global_cancel_time { get; set; }
///
///
///
public Int32? global_delivery_time { get; set; }
///
///
///
public Int32? global_distribution_time { get; set; }
///
///
///
public Int32? global_latest_ship_time { get; set; }
///
///
///
public string global_order_no { get; set; }
///
///
///
public Int32? global_payment_time { get; set; }
///
///
///
public Int32? global_print_time { get; set; }
///
///
///
public Int32? global_purchase_time { get; set; }
///
///
///
public Int32? global_review_time { get; set; }
///
///
///
public List item_info { get; set; }
///
///
///
public Logistics_info logistics_info { get; set; }
///
///
///
public string order_from_name { get; set; }
///
///
///
public string status { get; set; }
///
///
///
public List order_tag { get; set; }
///
///
///
public List platform_info { get; set; }
///
///
///
public string platform_order_name { get; set; }
///
///
///
public string platform_order_no { get; set; }
///
///
///
public string remark { get; set; }
///
///
///
public string split_type { get; set; }
///
///
///
public string store_id { get; set; }
///
///
///
public List transaction_info { get; set; }
///
///
///
public int update_time { get; set; }
///
///
///
public string wid { get; set; }
}
public class LX_Data
{
///
///
///
public int current { get; set; }
///
///
///
public List list { get; set; }
///
///
///
public Int32? pages { get; set; }
///
///
///
public Int32? size { get; set; }
///
///
///
public Int32? total { get; set; }
}
public class LX_Root
{
///
///
///
public string code { get; set; }
///
///
///
public LX_Data data { get; set; }
///
///
///
public string msg { get; set; }
///
///
///
public Boolean? success { get; set; }
///
///
///
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 platform_code { get; set; }
public List store_id { get; set; }
}
}