|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Net;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Web.Script.Serialization;
|
|
|
|
|
|
|
|
|
|
namespace NetLibrary.Express
|
|
|
|
|
{
|
|
|
|
|
public class BelgiumApi
|
|
|
|
|
{
|
|
|
|
|
public string url { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 授权码
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string authenticate { get; set; }
|
|
|
|
|
|
|
|
|
|
JavaScriptSerializer JsonConvert = null;
|
|
|
|
|
|
|
|
|
|
public BelgiumApi()
|
|
|
|
|
{
|
|
|
|
|
JsonConvert = new JavaScriptSerializer();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 发货
|
|
|
|
|
public string SendGoods(Belgium_Order model, string authenticate, out string ErrorMessage)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(authenticate) == true)
|
|
|
|
|
{
|
|
|
|
|
ErrorMessage = "校验码不能为空";
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
List<string> ListHeader = new List<string>();
|
|
|
|
|
ListHeader.Add("Authorization:" + authenticate);
|
|
|
|
|
// ListHeader.Add("Content-Type:text/json;charset=utf-8");
|
|
|
|
|
|
|
|
|
|
string postmessage = JsonConvert.Serialize(model);
|
|
|
|
|
//UTF8Encoding encoding = new UTF8Encoding();
|
|
|
|
|
byte[] data = Encoding.UTF8.GetBytes(postmessage);
|
|
|
|
|
string XmlContent = CustomIO.HttpRequest2("http://114.55.90.117/api/LvsParcels", "POST", "text/json;charset=utf-8", ListHeader, HttpVersion.Version10, data, out ErrorMessage);
|
|
|
|
|
if (string.IsNullOrEmpty(ErrorMessage) == false) return "";
|
|
|
|
|
Belgium_Order_Result model2 = JsonConvert.Deserialize<Belgium_Order_Result>(XmlContent);
|
|
|
|
|
if (model2 == null || model2.ProductBarcode == null || model2.ProductBarcode == "")
|
|
|
|
|
ErrorMessage = XmlContent;
|
|
|
|
|
return model2.ProductBarcode;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
#region 运费估算
|
|
|
|
|
public Belgium_Fee GetFee(Belgium_Fee model, string authenticate, out string ErrorMessage)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(authenticate) == true)
|
|
|
|
|
{
|
|
|
|
|
ErrorMessage = "校验码不能为空";
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
List<string> ListHeader = new List<string>();
|
|
|
|
|
ListHeader.Add("Authorization:" + authenticate);
|
|
|
|
|
ListHeader.Add("charset=utf-8");
|
|
|
|
|
string postmessage = JsonConvert.Serialize(model);
|
|
|
|
|
UTF8Encoding encoding = new UTF8Encoding();
|
|
|
|
|
byte[] data = encoding.GetBytes(postmessage);
|
|
|
|
|
string XmlContent = CustomIO.HttpRequest2(url + "/api/ShippingPrice", "POST", "text/json", ListHeader, HttpVersion.Version10, data, out ErrorMessage);
|
|
|
|
|
model = JsonConvert.Deserialize<Belgium_Fee>(XmlContent);
|
|
|
|
|
string[] ss=model.ShippingPrice.Split(':');
|
|
|
|
|
model.currencyCode = ss[0];
|
|
|
|
|
model.fee = Convert.ToDecimal(ss[1]);
|
|
|
|
|
return model;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 订单
|
|
|
|
|
public class Belgium_Order
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 永远用1
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int ContractId { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 订单号
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string OrderNumber { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 追踪条形码(用户自定义,可为空)
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string ProductBarcode { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 接收人姓名
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string RecipientName { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 接收人所在街道
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string RecipientStreet { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 接收人所在房子号码N
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string RecipientHouseNumber { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 公交车号码N
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string RecipientBusnumber { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 接收人邮编
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string RecipientZipCode { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 接收人所在城市
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string RecipientCity { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 接收人所在省/州N
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string RecipientState { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// MiniPak EU写EU27, 接收人所在国家全名或者2位缩写
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string RecipientCountry { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 接收人电话N
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string PhoneNumber { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 接收人邮箱N
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Email { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 寄件人姓名N
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string SenderName { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 寄件人地址N
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string SenderAddress { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 会写在发票上N
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string SenderSequence { get; set; }
|
|
|
|
|
|
|
|
|
|
public bool IsSure { get; set; }
|
|
|
|
|
public List<Belgium_Goods> Customs { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Belgium_Order()
|
|
|
|
|
{
|
|
|
|
|
ContractId = 1;
|
|
|
|
|
IsSure = true;
|
|
|
|
|
Customs = new List<Belgium_Goods>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
#region 物品信息
|
|
|
|
|
public class Belgium_Goods
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 物品号码
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Sku { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 物品的中文描述
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string ChineseContentDescription { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 物品描述
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string ItemContent { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 包裹里不同物品的总数
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int ItemCount { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 客户为了物品付款数目 (excl 快递) : 如果礼物或样品-> 真实价值! 使用英文逗号不要用中文逗号! MiniPak EU 小于22欧元
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int Value { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 货币种类: LVS:EUR, GBP, USD
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Currency { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 净重(克) (1 kg = 1000 gr) – 米进制.最大值: 1999
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int Weight { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 在标签和发票上的SKU 信息N
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string SkuInInvoice { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
#region 运费估算
|
|
|
|
|
public class Belgium_Fee
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 重量信息,单位为克
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int Weight { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 物品价值
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int Value { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 货币种类 EUR ,GBP,USD.DDU : EUR, GBP, JPY, CNY, HKD, USD, MYR
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Currency { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 目的地国家
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Country { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 包裹种类 (MiniPack 或者 TrackPack).
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string ProductName { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 包裹运费
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string ShippingPrice { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 估算费用货币代码
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string currencyCode { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 估算费用
|
|
|
|
|
/// </summary>
|
|
|
|
|
public decimal fee { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 错误信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Error { get; set; }
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
#region 订单返回结果
|
|
|
|
|
public class Belgium_Order_Result
|
|
|
|
|
{
|
|
|
|
|
public string ProductBarcode { get; set; }
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
}
|