using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Web.Script.Serialization;
namespace TradeManageNew
{
public partial class test : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Unnamed1_Click(object sender, EventArgs e)
{
YCService.Ec obj = new YCService.Ec();
StringBuilder sb = new StringBuilder();
var list = DataNew.GetYCOrders("0");
//sb.Append("");
//sb.Append("");
//sb.Append("");
//sb.Append("");
//sb.Append("");
//sb.Append("{");
//sb.Append("{\"country_code\":\"OTHER\",\"shipping_method\":\"F4\",\"consignee_name\":\"张三\",\"consignee_company\":\"易仓科技\",\"consignee_province\":\"province\",\"consignee_city\":\"city\",\"consignee_street\":\"address1\",\"consignee_street1\":\"address2\",\"consignee_street2\":\"address3\",\"consignee_postcode\":\"142970\",\"consignee_areacode\":\"doorplate\",\"consignee_phone\":\"company\",\"consignee_fax\":\"name\",\"consignee_email\":\"136@163.com\",\"consignee_doorplate\":\"email\"}");
//sb.Append("\"allocated_auto\":\"0\",");
//sb.Append("\"warehouse_code\":\"HRBW\",");
//sb.Append("\"shipping_method\":\"F4\",");
//sb.Append("\"reference_no\":\"ref_1399867101_123\"");
//sb.Append("}");
//sb.Append("");
//sb.Append("appToken");
//sb.Append("appKey");
//sb.Append("createOrder");
//sb.Append("");
//sb.Append("");
//sb.Append("");
//{
// "platform":"OTHER",
// "allocated_auto":"0",
// "warehouse_code":"HRBW",
// "shipping_method":"F4",
// "reference_no":"ref_1399867101",
// "aliexpress_order_no":"8000777788889999",
// "order_desc":"\u8ba2\u5355\u63cf\u8ff0",
// "remark":"我是备注",
// "order_business_type":"b2c",
// "lp_order_number":"lp_123456",
// "country_code":"RU",
// "province":"province",
// "city":"city",
// "district":"收件人区",
// "address1":"address1",
// "address2":"address2",
// "address3":"address3",
// "zipcode":"142970",
// "license":"420904",
// "doorplate":"doorplate",
// "company":"company",
// "name":"name",
// "phone":"phone",
// "cell_phone":"cell_phone",
// "email":"email",
// "platform_shop":"shop",
// "is_order_cod":1,
// "order_cod_price":99,
// "order_cod_currency":"RMB",
// "order_age_limit":2,
// "is_signature":0,
// "is_insurance":0,
// "insurance_value":0,
// "channel_code":"demo",
// "packageCenterCode":"center_code",
// "packageCenterName":"集包地中心名称",
// "QrCode":"123ABC",
// "shortAddress":"100-200-30-400",
// "seller_id":"ebay-test001",
// "buyer_id":"ebay-test002",
// "only_logistics":0,
// "assign_date":"2021-01-01",
// "assign_time":"02",
// "items":[
// {
// "product_sku":"EA140509201610",
// "reference_no":"149H6286",
// "product_name_en":"Product Name",
// "product_name":"Product Name",
// "product_declared_value":5.000,
// "quantity":1,
// "ref_tnx":"1495099983020",
// "ref_item_id":"302588235574",
// "ref_buyer_id":"esramo_a62szxok"
// }
// ],
// "report":[
// {
// "product_title":"键盘",
// "product_title_en":"keyboard",
// "product_quantity":1,
// "product_declared_value":5,
// "product_weight":3
// }
// ],
// "tracking_no":"123",
// "label":{
// "file_type":"png",
// "file_data":"hVJPjUP4+yHjvKErt5PuFfvRhd...",
// "file_size":"100x100"
// },
// "is_pack_box":0,
// "is_release_cargo":0,
// "is_vip":0,
// "order_kind":"BC",
// "order_payer_name":"小明",
// "order_id_number":"1325323112323",
// "order_payer_phone":"13120775656",
// "order_country_code_origin":"美国",
// "order_sale_amount":"0",
// "order_sale_currency":"RMB",
// "is_platform_ebay":"0",
// "ebay_item_id":"130056",
// "ebay_transaction_id":"202009041652-0001",
// "tax_payment_method":"CFR_OR_CPT",
// "customs_company_name":"我是清关公司",
// "customs_address":"我是清关地址",
// "customs_contact_name":"我是清关联系人",
// "customs_email":"15026521351@gmail.com",
// "customs_tax_code":"156156156",
// "customs_phone":"15625231521",
// "customs_city":"武汉市",
// "customs_state":"湖北省",
// "customs_country_code":"CN",
// "customs_postcode":"434400",
// "customs_doorplate":"601",
// "consignee_tax_number":"682515426999999",
// "order_battery_type":"UN3481",
// "vat_tax_code":"16515612231",
// "distribution_information":"distribution information",
// "consignee_tax_type":1,
// "api_source":"mabangerp",
// "verify":1,
// "forceVerify":0,
// "lp_code":"AEOWH0000345968"
// }
JavaScriptSerializer JsonConvert = new JavaScriptSerializer();
foreach (var md in list)
{
YC_createOrder omd = new YC_createOrder();
omd.reference_no = md.PlatOrderCode;
omd.aliexpress_order_no = md.PlatOrderCode;
//omd.lp_code = md.PlatOrderCode;
if(md.PlatId==2)
omd.platform = "AMAZON";//平台, ALIEXPRESS,AMAZON,B2C,EBAY,OTHER 默认OTHER
else if (md.PlatId == 3)
omd.platform = "EBAY";
else if (md.PlatId == 1)
omd.platform = "ALIEXPRESS";
else if (md.PlatId == 2)
omd.platform = "OTHER";
omd.country_code = md.CountryCode;
omd.shipping_method = "UPSGROUND";
omd.warehouse_code = "CAMR";
omd.province =md.RevProvince;
omd.city = md.RevCity;
omd.district = md.RevArea;
omd.address1 = md.RevAddr;
omd.address2 = "";
omd.address3 = "";
omd.license = "";
omd.doorplate = "";
omd.company = "";
omd.verify = 1;
omd.forceVerify = 1;
if(md.RevPhone.Contains("ext"))
{
var len=md.RevPhone.IndexOf("ext");
omd.phone = md.RevPhone.Substring(0,len-1);
}
omd.name = md.RevName;
if (md.RevMoblie.Contains("ext"))
{
var len = md.RevMoblie.IndexOf("ext");
omd.cell_phone = md.RevMoblie.Substring(0, len - 1);
}
omd.email = md.RevMail;
omd.zipcode = md.RevPostCode;
omd.platform_shop = md.ShopName;
List itemlist = new List();
List relist = new List();
foreach (var gmd in md.GoodsList)
{
YC_Items imd = new YC_Items();
imd.product_sku = gmd.TypeCode;
imd.reference_no = "";
imd.product_declared_value = 5;
imd.product_name_en =gmd.GoodsEnglisgName;
imd.product_name = gmd.GoodsName;
imd.quantity = gmd.GoodsNum;
imd.ref_tnx = "";
imd.ref_item_id = "";
imd.ref_buyer_id = "";
itemlist.Add(imd);
YC_Report ymd = new YC_Report();
ymd.product_title = gmd.GoodsEnglisgName;
ymd.product_title_en = gmd.GoodsName;
ymd.product_quantity = gmd.GoodsNum;
ymd.product_declared_value = 5;
if (gmd.Weight != null)
ymd.product_weight = Convert.ToInt32(gmd.Weight.Value);
else
ymd.product_weight = 100;
relist.Add(ymd);
}
omd.items = itemlist;
omd.report = relist;
// string ojson = JsonConvert.Serialize(omd);
//string re = obj.callService(ojson, "d45efccfc1a9e3a3199c3abcc37d9ce6", "b28a8987bea38085e14194a8970c8947", "createOrder");
string ojson = "{\"reference_no\":\"22-07040-59321\"}";
string re = obj.callService(ojson, "d45efccfc1a9e3a3199c3abcc37d9ce6", "b28a8987bea38085e14194a8970c8947", "getOrderByRefCode");
YC_Result ReModel = JsonConvert.Deserialize(re);
//{"ask":"Success","message":"","data":{"company_code":"KF","order_business_type":"b2c","order_code":"KF-210616-0020","reference_no":"22-07040-59321","platform":"AMAZON","order_status":"C","shipping_method":"UPSGROUND","tracking_no":"","carrier_name":"","warehouse_code":"CAMR","order_weight":"6.0000","order_desc":"","date_create":"2021-06-16 17:10:48","date_release":"","date_shipping":"","date_modify":"2021-06-16 17:11:03","consignee_country_code":"US","consignee_country_name":"US","consignee_state":"KS","consignee_city":"Bel Aire","consignee_district":"","consignee_address1":"4459 N Eagle Lake Dr","consignee_address2":"","consignee_address3":"","consigne_zipcode":"67220-1729","consignee_doorplate":"","consignee_company":"","consignee_name":"Albert C. Ma","consignee_phone":"0000000000","consignee_email":"logon123cox@gmail.com","platform_shop":"","abnormal_reason":"","create_type":"ERP订单","order_cod_price":"0.000","order_cod_currency":"","is_order_cod":"0","transfer_order_no":"","fee_details":null,"currency":"USD","items":[{"product_sku":"KM6684","quantity":"1"}],"inventory_batch_out":[],"return_tracking_number_sign":1}}
//{"ask":"Success","message":"Success","order_code":"KF-210616-0020","error_code":500,"tracking_no":"","order_status":"C"}
//{"ask":"Failure","message":"oms:数据验证失败SKU:KM2528-2-W未审核","order_code":"KF-210616-0018","error_code":500,"tracking_no":"","Error":{"errMessage":"数据验证失败SKU:KM2528-2-W未审核","errCode":500129}}
}
}
}
}