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.

182 lines
4.8 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 System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Script.Serialization;
namespace NetLibrary.Express
{
public class MiaoXinApi
{
public string url { get; set; }
/// <summary>
/// 授权码
/// </summary>
public string authenticate { get; set; }
JavaScriptSerializer JsonConvert = null;
public MiaoXinApi()
{
JsonConvert = new JavaScriptSerializer();
}
#region 发货
public string SendGoods(MiaoXin_Order model, out string ErrorMessage)
{
string postmessage = JsonConvert.Serialize(model);
//UTF8Encoding encoding = new UTF8Encoding();
string XmlContent = CustomIO.HttpRequest("http://222.73.27.186:8082/createOrderApi.htm?param=" + postmessage, "POST", out ErrorMessage);
if (string.IsNullOrEmpty(ErrorMessage) == false) return "";
MiaoXin_Result model2 = JsonConvert.Deserialize<MiaoXin_Result>(XmlContent);
if (model2.ack.ToLower() == "true")
return model2.tracking_number;
else
{
ErrorMessage = model2.message;
return "";
}
}
#endregion
}
#region 订单
public class MiaoXin_Order
{
public string buyerid { get; set; }
/// <summary>
/// 收件地址街道,必填
/// </summary>
public string consignee_address { get; set; }
/// <summary>
/// 城市
/// </summary>
public string consignee_city { get; set; }
/// <summary>
/// 接收人手机
/// </summary>
public string consignee_mobile { get; set; }
/// <summary>
/// 收件人,必填
/// </summary>
public string consignee_name { get; set; }
/// <summary>
/// 接前找淼信索取该代码淼信用于判断数据来源Trade_type可选值请对号入座
//SUMAI 速脉ERP
//QQZS 全球助手
//WDJL 网店精灵
//IEBAY365 IEBAY365
//ZYXT 客户自用系统/其他不在列表中的均使用该代码
//STOMS 赛兔OMS
//TTERP 通途ERP
//MGDZ 芒果店长
//LRERP 懒人erp
/// </summary>
public string trade_type { get; set; }
/// <summary>
/// 邮编,有邮编的国家必填
/// </summary>
public string consignee_postcode { get; set; }
/// <summary>
/// 州/省
/// </summary>
public string consignee_state { get; set; }
/// <summary>
/// 收件电话,必填
/// </summary>
public string consignee_telephone { get; set; }
/// <summary>
/// 收件国家二字代码,必填
/// </summary>
public string country { get; set; }
/// <summary>
/// 客户ID必填 {'customer_id':'16201','customer_userid':'15361','ack':'true'}
/// </summary>
public string customer_id { get; set; }
/// <summary>
/// 登录人ID必填
/// </summary>
public string customer_userid { get; set; }
/// <summary>
/// 原单号,必填
/// </summary>
public string order_customerinvoicecode { get; set; }
/// <summary>
/// 运输方式ID必填 3861
/// </summary>
public string product_id { get; set; }
public string weight { get; set; }
public List<MiaoXin_Goods> orderInvoiceParam { get; set; }
}
#endregion
#region 物品信息
public class MiaoXin_Goods
{
/// <summary>
/// 申报价值,必填
/// </summary>
public string invoice_amount { get; set; }
/// <summary>
///件数,必填
/// </summary>
public string invoice_pcs { get; set; }
/// <summary>
/// 品名,必填
/// </summary>
public string invoice_title { get; set; }
/// <summary>
/// 单件重
/// </summary>
public string invoice_weight { get; set; }
/// <summary>
///
/// </summary>
public string item_id { get; set; }
/// <summary>
///
/// </summary>
public string item_transactionid { get; set; }
/// <summary>
/// sku,如果是e邮宝e特快e包裹则传中文品名
/// </summary>
public string sku { get; set; }
}
#endregion
#region 返回信息
public class MiaoXin_Result
{
public string ack { get; set; }
public string message { get; set; }
public string reference_number { get; set; }
public string tracking_number { get; set; }
/// <summary>
///
/// </summary>
public string order_id { get; set; }
}
#endregion
}