using NetLibrary.Data; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Web; using System.Web.Services; using TradeData; using NetLibrary; using TradeModel; using NetLibrary.Express; using System.Web.Script.Serialization; using NetLibrary.ReportPrint; using NetLibrary.OnlineTrade; using System.Text; using Newtonsoft.Json.Linq; using Newtonsoft.Json; using NetLibrary.Log; using System.Text.RegularExpressions; using System.Xml.Linq; namespace TradeManage.DingDan { /// /// DD_OrderServiceForTM 的摘要说明 /// [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.ComponentModel.ToolboxItem(false)] // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消注释以下行。 [System.Web.Script.Services.ScriptService] public class DD_OrderServiceForTM : System.Web.Services.WebService { [WebMethod] public string HelloWorld() { return "Hello World"; } #region 未付款订单催款 [WebMethod(EnableSession = true)] public string DeptOrder(string content, int pagenum, string Timetemp, List ListModel) { string ErrorMess = ""; string errorlist = ""; string success = ""; for (int l = 0; l < ListModel.Count(); l++) { try { string errorm = ""; AlibabaApi obj = new AlibabaApi(); var model = JC_ShopService.GetModel(ListModel[l]); if (model != null) { obj.Appkey = model.Appkey; obj.DeveKey = model.DeveKey; obj.RefreshToken = model.RefreshToken; obj.AccessToken = model.AccessToken; obj.GroupName = model.ShopName; obj.RefreshTokenSaveTime = model.RefreshTokenSaveTime; obj.AccessTokenUpdateTime = model.AccessTokenUpdateTime; for (int pn = 1; pn <= pagenum; pn++) { string npostr = obj.NoPayOrderList(pn.ToString(), out errorm); if (!errorm.Contains("失败")) { JObject jo = (JObject)JsonConvert.DeserializeObject(npostr); string totalItem = jo["totalItem"].ToString(); string orderList = jo["orderList"].ToString(); JArray ja = (JArray)JsonConvert.DeserializeObject(orderList); for (int i = 0; i < ja.Count(); i++) { if (ja[i]["orderId"] == null) { errorlist += "订单号不存在\r\n"; break; } string orderId = ja[i]["orderId"].ToString();//订单号 //备注 string memo = ""; JArray jaItem = (JArray)JsonConvert.DeserializeObject(ja[i]["productList"].ToString()); for (int j = 0; j < jaItem.Count(); j++) { if (jaItem[j]["memo"] != null) { if (jaItem[j]["memo"].ToString() != "") memo += jaItem[j]["memo"].ToString() + ";"; } } if (memo != "") { errorlist += orderId + " 存在备注\r\n"; continue; } //订单创建时间 string gmtCreate = ""; if (ja[i]["gmtCreate"] != null) { gmtCreate = ja[i]["gmtCreate"].ToString(); gmtCreate = gmtCreate.Substring(0, 4) + "-" + gmtCreate.Substring(4, 2) + "-" + gmtCreate.Substring(6, 2) + " " + gmtCreate.Substring(8, 2) + ":" + gmtCreate.Substring(10, 2); } else { errorlist += orderId + " 时间为空\r\n"; continue; } if (DateTime.Now > Convert.ToDateTime(gmtCreate).AddHours(15).AddMinutes(Convert.ToInt32(Timetemp) + 2)) { //得到留言数据 string messagestr = obj.GetMsgstr(orderId, "order_msg", out errorm); ; if (!errorm.Contains("失败")) { errorlist += orderId + " 失败\r\n"; continue; } if (messagestr.Length < 60) { string detail = obj.GetOrderstr(orderId, out errorm); JObject sigle = (JObject)JsonConvert.DeserializeObject(detail); if (!errorm.Contains("失败")) { errorlist += orderId + " 失败\r\n"; continue; } string country = sigle["receiptAddress"]["country"].ToString(); string buyid = sigle["buyerloginid"].ToString(); if (country != "Brazil") { obj.BackLeaveWord(orderId, buyid, content, "", out errorm); if (!errorm.Contains("失败")) { success += orderId + " 成功\r\n"; } else { errorlist += orderId + " 失败\r\n"; } } else { errorlist += orderId + " 巴西国家不催款\r\n"; } } else { errorlist += orderId + " 存在留言\r\n"; } } else { errorlist += orderId + " 时间不满足\r\n"; } } } else { errorlist += errorm + "\r\n"; } } } else { errorlist += "不存在该店铺\r\n"; } } catch { ErrorMess = "异常\r\n"; } } ErrorMess = errorlist; return ErrorMess; } #endregion #region 延长订单收货时间 [WebMethod(EnableSession = true)] public string ExtentTime(int begin, int end, string day, List ListModel) { string ErrorMess = ""; string sucess = ""; string errorlist = ""; for (int l = 0; l < ListModel.Count(); l++) { try { string errorstr = ""; AlibabaApi obj = new AlibabaApi(); var model = JC_ShopService.GetModel(ListModel[l]); if (model != null) { for (int i = begin; i < end + 1; i++) { obj.Appkey = model.Appkey; obj.DeveKey = model.DeveKey; obj.RefreshToken = model.RefreshToken; obj.AccessToken = model.AccessToken; obj.GroupName = model.ShopName; obj.RefreshTokenSaveTime = model.RefreshTokenSaveTime; obj.AccessTokenUpdateTime = model.AccessTokenUpdateTime; string orderstr = obj.OrderList(i.ToString(), "WAIT_BUYER_ACCEPT_GOODS", out errorstr); if (errorstr.Contains("失败")) { errorlist += errorstr + "\r\n"; } JObject jo = (JObject)JsonConvert.DeserializeObject(orderstr); string orderList = jo["orderList"].ToString(); JArray ja = (JArray)JsonConvert.DeserializeObject(orderList); for (int j = 0; j < ja.Count(); j++) { if (ja[j]["orderId"] == null) { break; } string orderId = ja[j]["orderId"].ToString();//订单号 string result = obj.Extentday(orderId, day, out errorstr); if (errorstr.Contains("失败")) { errorlist += orderId + " " + errorstr + "\r\n"; } if (result.Contains("true")) { sucess += orderId + " 成功\r\n"; } else { errorlist += orderId + " 失败\r\n"; } } } } else { errorlist += "速卖通店铺不存在"; } } catch { errorlist += "异常"; } } ErrorMess = errorlist; return ErrorMess; } #endregion #region 声明发货(备注+网址) [WebMethod(EnableSession = true)] public string Alibaba_TrackBack(List list, string trackingWebsite, string description) { Pages.Login(this.Session); int CompanyId = Convert.ToInt32(Session["CompanyId"]); int UserId = Convert.ToInt32(Session["UserId"]); AlibabaApi obj = new AlibabaApi(); BaseService obj1 = new BaseService(); DD_OrderData obj2 = new DD_OrderData(); string error = ""; if (list != null) { int shopid = 0; JC_Shop shopmodel = null; foreach (var md in list) { if (shopid != md.ShopId.Value) shopmodel = JC_ShopService.GetModel(md.ShopId.Value); shopid = md.ShopId.Value; if (shopmodel == null) continue; obj.Appkey = shopmodel.Appkey; obj.DeveKey = shopmodel.DeveKey; obj.RefreshToken = shopmodel.RefreshToken; obj.AccessToken = shopmodel.AccessToken; obj.GroupName = shopmodel.ShopName; obj.RefreshTokenSaveTime = shopmodel.RefreshTokenSaveTime; obj.AccessTokenUpdateTime = shopmodel.AccessTokenUpdateTime; string serviceName = "CMAP"; if (md.Post == null || md.Post == 0)//线上发货的除外 continue; if (md.Post == 9) { serviceName = obj1.GetOnlineServiceName(md.OrderId.Value); } else { var emd = obj1.GetExpressModel(md.Post.Value, CompanyId); if (emd != null && emd.Remark != null) serviceName = emd.Remark; } if (md.TrackCode == null || md.TrackCode == "") continue; if (md.IsJoin == 1)//合并订单 { var hblist = obj2.GetHBOrderList(md.OrderId.Value); if (hblist != null) { for (int i = 0; i < hblist.Count; i++) { bool tstate = true; if (description == "" && trackingWebsite == "") tstate = obj.SubmitTrack(md.PlatOrderCode, md.TrackCode, serviceName, "", out error); if (description != "" && trackingWebsite == "") { tstate = obj.SubmitTrackD(md.PlatOrderCode, md.TrackCode, serviceName, "", description, out error); } if (description == "" && trackingWebsite != "") { tstate = obj.SubmitTrackW(md.PlatOrderCode, md.TrackCode, serviceName, "", trackingWebsite, out error); } if (description != "" && trackingWebsite != "") { tstate = obj.SubmitTrackDW(md.PlatOrderCode, md.TrackCode, serviceName, "", description, trackingWebsite, out error); } obj2.UpdateOrderTrack(md.OrderId.Value); Pages.SaveLog(UserId, "速卖通声明发货", "订单号:" + md.PlatOrderCode + "跟踪码:" + md.TrackCode + "serviceName:" + serviceName + ";" + tstate.ToString(), md.OrderId.Value); } } } else { bool tstate = true;// obj.SubmitTrack(md.PlatOrderCode, md.TrackCode, serviceName, "", out error); if (description == "" && trackingWebsite == "") tstate = obj.SubmitTrack(md.PlatOrderCode, md.TrackCode, serviceName, "", out error); if (description != "" && trackingWebsite == "") { tstate = obj.SubmitTrackD(md.PlatOrderCode, md.TrackCode, serviceName, "", description, out error); } if (description == "" && trackingWebsite != "") { tstate = obj.SubmitTrackW(md.PlatOrderCode, md.TrackCode, serviceName, "", trackingWebsite, out error); } if (description != "" && trackingWebsite != "") { tstate = obj.SubmitTrackDW(md.PlatOrderCode, md.TrackCode, serviceName, "", description, trackingWebsite, out error); } obj2.UpdateOrderTrack(md.OrderId.Value); Pages.SaveLog(UserId, "速卖通声明发货", "订单号:" + md.PlatOrderCode + "跟踪码:" + md.TrackCode + "serviceName:" + serviceName + ";" + tstate.ToString(), md.OrderId.Value); } } } return error; } #endregion #region Wish上传跟踪码 [WebMethod(EnableSession = true)] public string WishUpTrack(List list) { int UserId = Convert.ToInt32(Session["UserId"]); string str = ""; string wstr = ""; string xtr = ""; int total = 0; WishApi wa = new WishApi(); if (list != null) { int shopid = 0; JC_Shop shopmodel = null; foreach (var md in list) { if (shopid != md.ShopId.Value) shopmodel = JC_ShopService.GetModel(md.ShopId.Value); if (shopmodel == null) continue; if (md.TrackCode == null || md.TrackCode == "") { str = str + md.PlatOrderCode + ";"; continue; } string back = wa.GetOneOrder(shopmodel.AccessToken, md.PlatOrderCode); string backstr = "未填"; try { JObject jo = (JObject)JsonConvert.DeserializeObject(back); if (jo["data"]["Order"]["tracking_number"] != null) { backstr = jo["data"]["Order"]["tracking_number"].ToString(); } } catch { } if (backstr == "未填") { if (wa.UpTrackTOWish(shopmodel.AccessToken, md.PlatOrderCode, md.serviceName, md.TrackCode, md.Message)) { Pages.SaveLog(UserId, "Wish声明发货", "订单号:" + md.PlatOrderCode + "跟踪码:" + md.TrackCode + "serviceName:" + md.serviceName + ";", md.OrderId.Value); total++; wstr = wstr + md.PlatOrderCode + ";"; } else { str = str + md.PlatOrderCode + ";"; } } else { if (backstr != md.TrackCode) { if (wa.ModifyTrackTOWish(shopmodel.AccessToken, md.PlatOrderCode, md.serviceName, md.TrackCode, md.Message)) { Pages.SaveLog(UserId, "Wish修改平台跟踪码", "订单号:" + md.PlatOrderCode + "跟踪码:" + md.TrackCode + "serviceName:" + md.serviceName + ";", md.OrderId.Value); total++; xtr = xtr + md.PlatOrderCode + ";"; } else { str = str + md.PlatOrderCode + ";"; } } else { total++; } } } } if (str == "" && wstr == "" && xtr == "") return "成功" + total + "笔!"; else return "成功" + total + "笔!失败:" + str + " 修改订单:" + xtr; } #endregion #region CD上传跟踪码 [WebMethod(EnableSession = true)] public string CDUpTrack(List list) { Pages.Login(this.Session); int CompanyId = Convert.ToInt32(Session["CompanyId"]); int UserId = Convert.ToInt32(Session["UserId"]); WishApi obj = new WishApi(); BaseService obj1 = new BaseService(); DD_OrderData obj2 = new DD_OrderData(); string error = ""; string tempOrderID = ""; string Appkey = ""; string DeveKey = ""; string ValidateOrder = ""; StringBuilder sbdetail = new StringBuilder(); if (list != null) { int shopid = 0; int PostId = 0; JC_Shop shopmodel = null; JC_Express emd = null; foreach (var md in list) { if (shopid != md.ShopId.Value) shopmodel = JC_ShopService.GetModel(md.ShopId.Value); shopid = md.ShopId.Value; if (shopmodel == null) continue; Appkey = shopmodel.Appkey; DeveKey = shopmodel.DeveKey; string AccessToken = shopmodel.AccessToken; string serviceName = "China Post";//"ChinaAirPost"; string url = "http://www.17track.net/fr"; if (md.Post == null || md.Post == 0 || md.Post.Value == 9)//线上发货的除外 continue; if (PostId != md.Post.Value) emd = obj1.GetExpressModelForTM(md.Post.Value, CompanyId); PostId = md.Post.Value; if (emd != null) { serviceName = emd.ExpressInfo; } if (md.TrackCode == null || md.TrackCode == "") continue; string TrackCode = ""; if (md.TrackCode.Trim(',').Contains(',')) { TrackCode = md.TrackCode.Trim(',').Split(',')[0]; } else TrackCode = md.TrackCode.Trim(','); if (md.IsJoin == 1)//合并订单 { var hblist = obj2.GetHBOrderListForTM(md.OrderId.Value); if (hblist != null) { for (int i = 0; i < hblist.Count; i++) { bool tstate = obj.ModifyTrackTOWish(AccessToken, hblist[i].PlatOrderCode, serviceName, TrackCode, md.Message); tempOrderID += md.OrderId.Value + ","; var gooddetail = obj2.GetOrderGoodsDetailCD(hblist[i].PlatOrderCode); if (gooddetail != null) { sbdetail.Append(""); sbdetail.Append("" + serviceName + ""); sbdetail.Append(""); foreach (var q in gooddetail) { sbdetail.Append(""); sbdetail.Append("ShippedBySeller"); sbdetail.Append("New"); sbdetail.Append("" + q.GoodsSKU + ""); sbdetail.Append(""); } sbdetail.Append(""); sbdetail.Append("" + hblist[i].PlatOrderCode + ""); sbdetail.Append("Shipped"); sbdetail.Append("" + TrackCode + ""); sbdetail.Append("" + url + ""); sbdetail.Append(""); } } } } else { var gooddetail = obj2.GetOrderGoodsDetailCD(md.PlatOrderCode); if (gooddetail != null) { sbdetail.Append(""); sbdetail.Append("" + serviceName + ""); sbdetail.Append(""); foreach (var q in gooddetail) { sbdetail.Append(""); sbdetail.Append("ShippedBySeller"); sbdetail.Append("New"); sbdetail.Append("" + q.GoodsSKU + ""); sbdetail.Append(""); } sbdetail.Append(""); sbdetail.Append("" + md.PlatOrderCode + ""); sbdetail.Append("Shipped"); sbdetail.Append("" + TrackCode + ""); sbdetail.Append("http://www.17track.net/fr"); sbdetail.Append(""); tempOrderID += md.OrderId.Value + ","; } } } } ValidateOrder = sbdetail.ToString(); StringBuilder sb = new StringBuilder(); sb.Append(""); sb.Append(""); sb.Append(""); sb.Append(""); sb.Append(""); sb.Append(""); sb.Append("1"); sb.Append("1"); sb.Append("100"); sb.Append(""); sb.Append(""); sb.Append("Fr"); sb.Append("Eur"); sb.Append("2"); sb.Append("Fr"); sb.Append(""); sb.Append(""); sb.Append(""); sb.Append(""); sb.Append(""); sb.Append(""); sb.Append("@Token@"); sb.Append(""); sb.Append(""); sb.Append("1.0"); sb.Append(""); sb.Append(""); sb.Append(""); sb.Append(ValidateOrder); sb.Append(""); sb.Append(""); sb.Append(""); sb.Append(""); sb.Append(""); string str = sb.ToString(); CDiscountAPI cda = new CDiscountAPI(); try { if (Appkey != "" && DeveKey != "" && ValidateOrder != "") { string XmlContent = cda.SendTrack(Appkey, DeveKey, str); XmlContent = XmlContent.Replace(" ListModel) { string ErrorMess = ""; string errorlist = ""; string success = ""; for (int l = 0; l < ListModel.Count(); l++) { int countnum = 0; try { string errorm = ""; AlibabaApi obj = new AlibabaApi(); var model = JC_ShopService.GetModel(ListModel[l]); if (model != null) { obj.Appkey = model.Appkey; obj.DeveKey = model.DeveKey; obj.RefreshToken = model.RefreshToken; obj.AccessToken = model.AccessToken; obj.GroupName = model.ShopName; obj.RefreshTokenSaveTime = model.RefreshTokenSaveTime; obj.AccessTokenUpdateTime = model.AccessTokenUpdateTime; string orderstr = obj.FeedBackList("1", out errorm); //success = orderstr; //ErrorMess = "test"; //return success; if (!orderstr.Contains("失败")) { JObject jo = (JObject)JsonConvert.DeserializeObject(orderstr); string totalItem = jo["totalItem"].ToString(); if (totalItem == "0") errorlist += "没有留言订单\r\n"; int totalpage = (int)((Convert.ToInt32(totalItem) + 9) / 10); for (int i = totalpage; i >= 1; i--) { orderstr = obj.FeedBackList(i.ToString(), out errorm); if (!orderstr.Contains("失败")) { totalItem = jo["totalItem"].ToString(); if (totalItem == "0") break; string orderList = jo["listResult"].ToString(); JArray ja = (JArray)JsonConvert.DeserializeObject(orderList); for (int j = 0; j < ja.Count(); j++) { if (ja[j]["orderId"] == null) { errorlist += "订单号采集不到!\r\n"; break; } string orderId = ja[j]["orderId"].ToString();//订单号 string Fstr = obj.FeedBackWord(orderId, content, out errorm); try { JObject jf = (JObject)JsonConvert.DeserializeObject(Fstr); string result = jf["success"].ToString(); //判断是否提交成功 if (Fstr != "Error") { if (result == "True") { success += (orderId + " 成功!\r\n"); } else { errorlist += (orderId + " 失败!\r\n"); } } else { errorlist += (orderId + " 失败!\r\n"); } countnum++; } catch { errorlist += (orderId + " 失败!\r\n"); } } } else { errorlist += errorm; } } } else { errorlist += errorm; } } else { errorlist += "不存在该店铺\r\n"; } } catch { ErrorMess = "异常\r\n"; } } ErrorMess = errorlist; return ErrorMess; } #endregion #region 获取订单物流跟踪码 [WebMethod(EnableSession = true)] public string GetOrderTrackCode(List list, int TrackType) { Pages.Login(this.Session); int CompanyId = Convert.ToInt32(Session["CompanyId"]); string error = ""; var obj1 = new JC_ExpressService(); List temporder = new List(); if (list != null) { var obj = new DD_OrderData(); foreach (var md in list) { if (md.JoinOrderCode != null) { if (md.JoinOrderCode != "") { var check = temporder.Where(o => o.JoinOrderCode == md.JoinOrderCode); if (check.Count() == 0) { temporder.Add(md); } else { continue; } } } var md1 = obj1.GetExpressModel(CompanyId, md.Post.Value); string TrackCode = ""; string error1 = GetOrderPostCode(md1, md.PlatOrderCode, md.OrderId.Value, md.Post.Value, CompanyId, md.IsSpare, md.JoinOrderCode, TrackType, out TrackCode); if (error1 != "") error += error1 + ";"; } } return error; } #endregion #region 获取订单物流跟踪码 [WebMethod(EnableSession = true)] public string GetOrderTrackCode2(List list) { Pages.Login(this.Session); int CompanyId = Convert.ToInt32(Session["CompanyId"]); string error = ""; var obj1 = new JC_ExpressService(); List temporder = new List(); if (list != null) { var obj = new DD_OrderData(); foreach (var md in list) { if (md.IsGet == 0) { List plist = new List(); plist = list.FindAll(n => n.Post == md.Post && md.IsGet == 0); if (plist != null && plist.Count > 0) { string OrderIds = ""; foreach (var pmd in plist) { pmd.IsGet = 1; if (pmd.JoinOrderCode != null && pmd.JoinOrderCode != "") { var check = temporder.Where(o => o.JoinOrderCode == pmd.JoinOrderCode); if (check.Count() == 0) { temporder.Add(md); } else { continue; } } OrderIds += pmd.OrderId + ","; } if (OrderIds != "") { error += GetOrderPostCode3(md.LogisticsId.Value, md.Post.Value, OrderIds); } } } } } return error; } #endregion #region 修改订单物流并获取跟踪码 [WebMethod(EnableSession = true)] public string SaveOrderPostAndGetTrackCode(List list, int LogisticsId, int PostId) { Pages.Login(this.Session); int CompanyId = Convert.ToInt32(Session["CompanyId"]); string error = ""; var obj1 = new JC_ExpressService(); var md1 = obj1.GetExpressModel(CompanyId, PostId); if (md1 == null || md1.DefaultAddr == null || md1.DefaultAddr == 0) { return "该物流渠道没有设置过发货地址,请先到系统管理下面的物流快递处设置发货地址"; } List temporder = new List(); if (list != null) { var obj = new DD_OrderData(); foreach (var md in list) { if (md.Post == PostId) continue; //obj.UpdateOrderExpress(md.OrderId.Value, PostId); string TrackCode = ""; string error1 = UpdateOrderPostForTM(md1, md.OrderId.Value, LogisticsId, PostId, CompanyId, md.PlatOrderCode, md.JoinOrderCode, md.CountryCode, out TrackCode); if (error1 != "") { error += error1 + ";"; continue; } if (md.JoinOrderCode != null) { if (md.JoinOrderCode != "") { var check = temporder.Where(o => o.JoinOrderCode == md.JoinOrderCode); if (check.Count() == 0) { temporder.Add(md); } else { continue; } } } string error2 = GetOrderPostCode(md1, md.PlatOrderCode, md.OrderId.Value, PostId, CompanyId, md.IsSpare, md.JoinOrderCode, 1, out TrackCode); if (error2 != "") error += error2 + ";"; } } return error; } #endregion #region 修改物流 public string UpdateOrderPostForTM(JC_ExpressPost md, int OrderId, int LogisticsId, int PostId, int CompanyId, string PlatOrderCode, string JoinOrderCode, string CountryCode, out string TrackCode) { var obj = new DD_OrderData(); var companymd = new JC_PostAddress(); var obj1 = new JC_ExpressService(); var obj11 = new BaseService(); //var ordermd = obj.GetOrderModel(OrderId); TrackCode = ""; //var goodslist = obj.GetOrderGoodsDetailList(OrderId); //var md = obj1.GetExpressModel(CompanyId, PostId); //if (md != null && PostId == 9) //线上发货 //{ // //obj.UpdateTrackPost(PostId, OrderId); // return ""; //} string ErrorInfo = ""; var obj2 = new BaseService(); if (CountryCode == null || CountryCode == "") { ErrorInfo = PlatOrderCode + "的订单国家代码没对应;"; return ErrorInfo; } if (obj2.IsExpress2(CompanyId, PostId, CountryCode) <= 0) { ErrorInfo = PlatOrderCode + "的订单国家不支持该物流发送;"; return ErrorInfo; } if (ErrorInfo == "") obj.UpdateTrackPostForTM2(PostId, LogisticsId, OrderId); return ErrorInfo; } #endregion #region 获取订单物流跟踪码 [WebMethod(EnableSession = true)] public DT_TrackCode GetOrderTrackCodeModel(DT_Order model, int TrackType) { Pages.Login(this.Session); int CompanyId = Convert.ToInt32(Session["CompanyId"]); string error = ""; var obj1 = new JC_ExpressService(); var md = new DT_TrackCode(); string TrackCode = ""; if (model != null) { var obj = new DD_OrderData(); var md1 = obj1.GetExpressModel(CompanyId, model.Post.Value); error = GetOrderPostCode(md1, model.PlatOrderCode, model.OrderId.Value, model.Post.Value, CompanyId, model.IsSpare, model.JoinOrderCode, TrackType, out TrackCode); } md.Error = error; md.TrackCode = TrackCode.Trim(','); return md; } #endregion #region 核对物流跟踪码 [WebMethod(EnableSession = true)] public int CheckWuliu(int LogisticsId, string TrackCode) { if (LogisticsId == 1) { Regex re = new Regex(@"^LK\d{9}CN$|LN\d{9}CN$|LT\d{9}CN$|AG\d{9}CN$|LM\d{9}CN$|EV\d{9}CN$|LX\d{9}CN$|LQ\d{9}CN$|LS\d{9}CN$"); if (!re.IsMatch(TrackCode)) { return 1; } } if (LogisticsId == 2) { Regex re = new Regex(@"^R[A-Z]{1}\d{9}[A-Z]{2}$"); if (!re.IsMatch(TrackCode)) { return 1; } } if (LogisticsId == 3) { Regex re = new Regex(@"^\d{9}$|\d{10}$|\d{11}$|\d{12}$|\d{13}$|\d{14}$"); if (!re.IsMatch(TrackCode)) { return 1; } } //if (LogisticsId == 8) //{ // Regex re = new Regex(@"^LVS\d{18}$|\d{19}$|\BLVS\d{16}$"); // if (!re.IsMatch(TrackCode)) // { // return 1; // } //} if (LogisticsId == 14) { Regex re = new Regex(@"^E[A-Z]{1}\d{9}CN$"); if (!re.IsMatch(TrackCode)) { return 1; } } return 0; } #endregion #region 获取物流单号 public string GetOrderPostCode(JC_ExpressPost md, string PlatCode, int OrderId, int PostId, int CompanyId, int? IsSpare, string JoinOrderCode, int? TrackType, out string TrackCode) { var obj = new DD_OrderData(); var companymd = new JC_PostAddress(); var obj1 = new JC_ExpressService(); var obj11 = new BaseService(); companymd = obj11.GetAddressModel2(PostId); //var md = obj1.GetExpressModel(CompanyId, PostId); TrackCode = ""; //if (md != null && md.PostType == 4) //线上发货 //{ // return ""; //} string orderidlist = ""; string ErrorInfo = ""; string ordercode = ""; string PostCode = ""; var obj2 = new BaseService(); if (md == null) return ""; if (md.CheckCode == null || md.CheckCode == "") { PostCode = obj1.GetInnerExpressCode(CompanyId, PostId); } else { try { var ordermd = obj.GetOrderModel(OrderId); List goodslist = null; if (ordermd.JoinOrderCode != null && ordermd.JoinOrderCode != "")//合并订单 { goodslist = obj.GetOrderGoodsDetailListForJoin(ordermd.JoinOrderCode); } else { goodslist = obj.GetOrderGoodsDetailList(OrderId); } ordercode = ordermd.PlatOrderCode; if (md != null && ordermd != null) { if (md.PostType == 1) //EUB { if (md.CheckCode != null && md.CheckCode != "" && goodslist != null && goodslist.Count > 0) { if (companymd == null) { ErrorInfo = "发货地址没选择;"; return ErrorInfo; } if (md.Name == "EUB" && ordermd.CountryCode != "US") { return "国家不支持"; } if (md.Name.Contains("美国") == true && ordermd.CountryCode != "US") { return "国家不支持"; } if (md.Name == "EUB上海" && ordermd.CountryCode != "US") { return "国家不支持"; } if (md.Name == "EUB慈溪" && ordermd.CountryCode != "US") { return "国家不支持"; } if (md.Name == "俄EUB" && ordermd.CountryCode != "RU") { return "国家不支持"; } if (md.Name.Contains("俄罗斯") == true && ordermd.CountryCode != "RU") { return "国家不支持"; } if (md.Name == "加拿大EUB" && ordermd.CountryCode != "CA") { return "国家不支持"; } if (md.Name.Contains("加拿大") == true && ordermd.CountryCode != "CA") { return "国家不支持"; } if (md.Name == "英国EUB" && (ordermd.CountryCode != "UK" && ordermd.CountryCode != "GB")) { return "国家不支持"; } if (md.Name.Contains("英国") == true && (ordermd.CountryCode != "UK" && ordermd.CountryCode != "GB")) { return "国家不支持"; } if (md.Name == "线上EUB" && ordermd.CountryCode != "US") { return "国家不支持"; } if (md.Name == "线上俄EUB" && ordermd.CountryCode != "RU") { return "国家不支持"; } if (md.Name == "澳大利亚EUB" && ordermd.CountryCode != "AU") { return "国家不支持"; } if (md.Name.Contains("澳大利亚") == true && ordermd.CountryCode != "AU") { return "国家不支持"; } if (md.Name == "乌克兰EUB" && ordermd.CountryCode != "UA") { return "国家不支持"; } if (md.Name.Contains("澳大利亚") == true && ordermd.CountryCode != "AU") { return "国家不支持"; } if (md.Name == "法国EUB" && ordermd.CountryCode != "FR") { return "国家不支持"; } if (md.Name.Contains("澳大利亚") == true && ordermd.CountryCode != "AU") { return "国家不支持"; } if (md.Name == "以色列EUB" && ordermd.CountryCode != "IL") { return "国家不支持"; } if (md.Name.Contains("以色列") == true && ordermd.CountryCode != "IL") { return "国家不支持"; } if (md.Name == "沙特EUB" && ordermd.CountryCode != "SA") { return "国家不支持"; } if (md.Name.Contains("沙特") == true && ordermd.CountryCode != "SA") { return "国家不支持"; } EubApi eub = new EubApi(); Eub_Order model = new Eub_Order(); model.Orderid = ordermd.PlatOrderCode; if (md.operationtype != null) model.operationtype = md.operationtype.Value; else model.operationtype = 0; model.producttype = 0; model.customercode = md.customercode; model.vipcode = md.vipcode; if (md.clcttype != null) model.clcttype = md.clcttype.Value; else model.clcttype = 1; model.pod = false; model.untread = "Returned"; if (goodslist != null && goodslist.Count > 0 && goodslist[0].Solid != null) model.volweight = Convert.ToInt32(goodslist[0].Solid / 6000); else model.volweight = 0; model.startdate = DateTime.Now; model.enddate = DateTime.Now.AddDays(15); model.sku1 = goodslist[0].GoodsSKU.Replace("&", " "); model.printcode = "03"; model.barcode = ordermd.PlatOrderCode; Eub_Person sendmd = new Eub_Person(); sendmd.company = companymd.CompanyEnglishName; sendmd.email = companymd.Email; sendmd.name = companymd.SendEnglishName; sendmd.phone = companymd.Phone; sendmd.province = companymd.province; sendmd.city = companymd.city; sendmd.country = "CN"; sendmd.county = companymd.county; sendmd.street = companymd.EnglishAddress; //"Guangyuan Road 69 (Asia Tiger Park Building 4),Jiangbei District,Ningbo,China"; sendmd.postcode = companymd.PostCode; model.sender = sendmd; Eub_Person revmodel = new Eub_Person(); revmodel.name = ordermd.RevName; revmodel.phone = ordermd.RevPhone; if (ordermd.RevProvince != null && ordermd.RevProvince != "") revmodel.province = ordermd.RevProvince; else { if (md.Name != "EUB" && md.Name != "EUB上海" && md.Name != "EUB慈溪") { //ErrorInfo += ordercode + "收件省不能为空;"; if (ordermd.RevCity != null && ordermd.RevCity != "") { revmodel.province = ordermd.RevCity; } else { revmodel.province = " "; } } //return ErrorInfo; } string postcode = ordermd.RevPostCode; if (ordermd.RevCountry == "United States" && postcode.Length > 5) { // postcode = Convert.ToInt32(ordermd.RevPostCode.Substring(0, 5).Trim()).ToString(); postcode = ordermd.RevPostCode.Substring(0, 5).Trim(); } else if (ordermd.RevCountry == "Russian Federation" && postcode.Length > 6) { // postcode = Convert.ToInt32(ordermd.RevPostCode.Substring(0, 6).Trim()).ToString(); postcode = ordermd.RevPostCode.Substring(0, 6).Trim(); } revmodel.county = ordermd.RevArea; revmodel.city = ordermd.RevCity; if (ordermd.CountryCode == "UK") ordermd.CountryCode = "GB"; revmodel.country = ordermd.CountryCode; revmodel.street = ordermd.RevAddr.Replace("+", " ").Replace("&", " ").Replace("#", " ").Replace("/", " "); ; revmodel.postcode = postcode; model.receiver = revmodel; Eub_Person collmodel = new Eub_Person(); collmodel.company = companymd.CompanyName; collmodel.email = companymd.Email; collmodel.name = companymd.SendName; collmodel.phone = companymd.Phone; collmodel.province = companymd.province; collmodel.country = "CN"; collmodel.city = companymd.city; collmodel.county = companymd.county; collmodel.street = companymd.Address; collmodel.postcode = companymd.PostCode; model.collect = collmodel; List ListGoods = new List(); if (goodslist != null) { decimal dw = Convert.ToDecimal(0.20); if (goodslist.Count > 10) dw = Convert.ToDecimal(0.10); foreach (var goodsmodel in goodslist) { var ListGoodsmd = new Eub_Goods(); ListGoodsmd.cnname = goodsmodel.GoodsName.Replace("+", " ").Replace("&", " ").Replace("#", " ").Replace("/", " "); if (goodsmodel.GoodsEnglisgName == null || goodsmodel.GoodsEnglisgName == "") ListGoodsmd.enname = goodsmodel.GoodsName; else ListGoodsmd.enname = goodsmodel.GoodsEnglisgName; ListGoodsmd.count = goodsmodel.GoodsNum.Value; ListGoodsmd.unit = "件"; // if (goodsmodel.GoodsPrice != null && goodsmodel.GoodsNum != null) ListGoodsmd.delcarevalue = 10; //if (goodsmodel.Weight != null) // ListGoodsmd.weight = goodsmodel.Weight.Value / 1000; //else ListGoodsmd.weight = dw; ListGoodsmd.origin = "CN"; ListGoodsmd.description = ""; ListGoods.Add(ListGoodsmd); } } model.ListGoods = ListGoods; PostCode = eub.SendGoods(model, md.CheckCode, out ErrorInfo); } //if (PostCode == null || PostCode == "") //{ // PostCode = obj1.GetInnerExpressCode(CompanyId, PostId); //} } else if (md.Name == "E邮宝") //E邮宝 { if (md.CheckCode != null && md.CheckCode != "" && goodslist != null && goodslist.Count > 0) { EubApi eub = new EubApi(); Eub_Order model = new Eub_Order(); model.Orderid = ordermd.PlatOrderCode; if (md.operationtype != null) model.operationtype = md.operationtype.Value; else model.operationtype = 0; model.producttype = 0; model.customercode = md.customercode; model.vipcode = md.vipcode; if (md.clcttype != null) model.clcttype = md.clcttype.Value; else model.clcttype = 1; model.pod = false; model.untread = "Returned"; if (goodslist != null && goodslist.Count > 0 && goodslist[0].Solid != null) model.volweight = Convert.ToInt32(goodslist[0].Solid / 6000); else model.volweight = 0; model.startdate = DateTime.Now; model.enddate = DateTime.Now.AddDays(15); model.sku1 = goodslist[0].GoodsSKU.Replace("&", " "); model.printcode = "03"; model.barcode = ordermd.PlatOrderCode; Eub_Person sendmd = new Eub_Person(); sendmd.company = companymd.CompanyEnglishName; sendmd.email = companymd.Email; sendmd.name = companymd.SendEnglishName; sendmd.phone = companymd.Phone; sendmd.province = companymd.province; sendmd.city = companymd.city; sendmd.country = "CN"; sendmd.county = companymd.county; sendmd.street = companymd.EnglishAddress; //"Guangyuan Road 69 (Asia Tiger Park Building 4),Jiangbei District,Ningbo,China"; sendmd.postcode = companymd.PostCode; model.sender = sendmd; Eub_Person revmodel = new Eub_Person(); revmodel.name = ordermd.RevName; revmodel.phone = ordermd.RevPhone; if (ordermd.RevMoblie != null && ordermd.RevMoblie != "") revmodel.mobile = ordermd.RevMoblie.Replace("+", "").Replace("-", "").Replace("/", ""); if (ordermd.RevProvince != null && ordermd.RevProvince != "") revmodel.province = ordermd.RevProvince; if (revmodel.province == null && revmodel.province != "") { revmodel.province = ordermd.RevCity; } string postcode = ordermd.RevPostCode; if (ordermd.RevCountry == "United States" && postcode.Length > 5) { // postcode = Convert.ToInt32(ordermd.RevPostCode.Substring(0, 5).Trim()).ToString(); postcode = ordermd.RevPostCode.Substring(0, 5).Trim(); } else if (ordermd.RevCountry == "Russian Federation" && postcode.Length > 6) { // postcode = Convert.ToInt32(ordermd.RevPostCode.Substring(0, 6).Trim()).ToString(); postcode = ordermd.RevPostCode.Substring(0, 6).Trim(); } revmodel.county = ordermd.RevArea; revmodel.city = ordermd.RevCity; if (ordermd.CountryCode == "UK") ordermd.CountryCode = "GB"; revmodel.country = ordermd.CountryCode; revmodel.street = ordermd.RevAddr.Replace("+", " ").Replace("&", " ").Replace("#", " ").Replace("/", " "); revmodel.postcode = postcode; model.receiver = revmodel; Eub_Person collmodel = new Eub_Person(); collmodel.company = companymd.CompanyName; collmodel.email = companymd.Email; collmodel.name = companymd.SendName; collmodel.phone = companymd.Phone; collmodel.province = companymd.province; collmodel.country = "CN"; collmodel.city = companymd.city; collmodel.county = companymd.county; collmodel.street = companymd.Address; collmodel.postcode = companymd.PostCode; model.collect = collmodel; List ListGoods = new List(); if (goodslist != null) { decimal dw = Convert.ToDecimal(0.20); if (goodslist.Count > 10) dw = Convert.ToDecimal(0.10); foreach (var goodsmodel in goodslist) { if (goodsmodel.GoodsName != null && goodsmodel.GoodsName.Length > 30) goodsmodel.GoodsName = goodsmodel.GoodsName.Substring(0, 30); var ListGoodsmd = new Eub_Goods(); ListGoodsmd.cnname = goodsmodel.GoodsName.Replace("+", " ").Replace("&", " ").Replace("#", " ").Replace("/", " "); // if (goodsmodel.GoodsEnglisgName == null || goodsmodel.GoodsEnglisgName == "") ListGoodsmd.enname = goodsmodel.GoodsCode + "-" + goodsmodel.TypeCode + goodsmodel.TypeDesc; // else // ListGoodsmd.enname = goodsmodel.GoodsEnglisgName; ListGoodsmd.count = goodsmodel.GoodsNum.Value; ListGoodsmd.unit = "件"; // if (goodsmodel.GoodsPrice != null && goodsmodel.GoodsNum != null) ListGoodsmd.delcarevalue = 10; //if (goodsmodel.Weight != null) // ListGoodsmd.weight = goodsmodel.Weight.Value / 1000; //else ListGoodsmd.weight = dw; ListGoodsmd.origin = "CN"; ListGoodsmd.description = ""; ListGoods.Add(ListGoodsmd); } } model.ListGoods = ListGoods; PostCode = eub.SendGoods(model, md.CheckCode, out ErrorInfo); } } else if (md.Name == "BPost") //比利时邮政 { if (md.CheckCode != null && md.CheckCode != "" && goodslist != null && goodslist.Count > 0) { if (companymd == null) { ErrorInfo = "发货地址没选择;"; return ErrorInfo; } if (PostCode == null || PostCode == "") { PostCode = obj1.GetGZExpressCodeBP(CompanyId, PostId); } BelgiumApi baobj = new BelgiumApi(); baobj.authenticate = "basic " + Convert.ToBase64String(Encoding.UTF8.GetBytes(string.Format("{0}:{1}", md.UserCode, md.CheckCode))); Belgium_Order bamodel = new Belgium_Order(); bamodel.ContractId = 1; bamodel.OrderNumber = ordermd.PlatOrderCode; bamodel.ProductBarcode = PostCode; bamodel.RecipientName = ordermd.RevName; bamodel.RecipientStreet = ordermd.RevAddr; bamodel.RecipientHouseNumber = ""; bamodel.RecipientBusnumber = ""; bamodel.RecipientZipCode = ordermd.RevPostCode; bamodel.RecipientCity = ordermd.RevCity; bamodel.RecipientState = ordermd.RevProvince; bamodel.RecipientCountry = ordermd.CountryCode; bamodel.PhoneNumber = ordermd.RevPhone; bamodel.Email = ordermd.RevMail; bamodel.SenderName = companymd.SendEnglishName; bamodel.SenderAddress = companymd.Address; bamodel.SenderSequence = "1"; bamodel.IsSure = true; List bglist = new List(); if (goodslist != null) { foreach (var goodsmodel in goodslist) { Belgium_Goods bgmd = new Belgium_Goods(); bgmd.Sku = goodsmodel.GoodsSKU; bgmd.ChineseContentDescription = goodsmodel.GoodsName; bgmd.ItemContent = goodsmodel.GoodsEnglisgName; if (goodsmodel.GoodsPrice != null && goodsmodel.GoodsPrice.Value > 10) bgmd.Value = 9; else bgmd.Value = 7; bgmd.ItemCount = goodsmodel.GoodsNum.Value; bgmd.Currency = "USD"; bgmd.Weight = 200; bgmd.SkuInInvoice = ""; bglist.Add(bgmd); } } bamodel.Customs = bglist; PostCode = baobj.SendGoods(bamodel, baobj.authenticate, out ErrorInfo); if (ErrorInfo != "") PostCode = ""; } } else if (md.LogisticsName == "SF Express") //顺丰 { if (md.CheckCode != null && md.CheckCode != "" && goodslist != null && goodslist.Count > 0) { if (companymd == null) { ErrorInfo = "发货地址没选择;"; return ErrorInfo; } sfApi sfobj = new sfApi(); sf_Order model = new sf_Order(); if (md.Name == "顺丰E宝挂号" || md.Name == "顺丰E宝平邮") { if (md.operationtype != null) model.express_type = md.operationtype.Value.ToString(); else model.express_type = "9"; } else if (md.Name == "顺丰美国") { model.express_type = "A9"; } else if (md.Name == "顺丰欧洲") { model.express_type = "A2"; } model.d_tel = ordermd.RevPhone; model.d_company = ordermd.RevName; model.d_contact = ordermd.RevName; model.d_address = ordermd.RevAddr; model.orderid = ordermd.PlatOrderCode; model.d_county = ordermd.RevArea; model.d_city = ordermd.RevCity; model.d_post_code = ordermd.RevPostCode; model.d_deliverycode = ordermd.CountryCode; model.d_province = ordermd.RevProvince; model.d_country = ordermd.RevCountry; model.cargo_total_weight = Convert.ToDecimal(ordermd.TotalWeight) / 1000; model.j_tel = companymd.Phone; model.j_company = companymd.CompanyEnglishName; model.j_province = companymd.province;// "zhejiang province"; model.j_city = companymd.city; //"Ningbo"; model.j_county = companymd.county; model.j_contact = companymd.SendEnglishName; model.j_address = companymd.EnglishAddress; model.j_post_code = companymd.PostCode; model.declared_value = ordermd.TotalPrice; model.declared_value_currency = ordermd.MoneyCode; model.parcel_quantity = 1; model.pay_method = 1; model.custid = md.customercode;//"7551878519"; model.cargo_length = 60; model.cargo_width = 60; model.cargo_height = 60; List ListGoods = new List(); if (goodslist != null) { foreach (var goodsmodel in goodslist) { var ListGoodsmd = new sf_Goods(); if (goodsmodel.GoodsEnglisgName != null && goodsmodel.GoodsEnglisgName != "") { ListGoodsmd.ename = goodsmodel.GoodsEnglisgName; } else { ListGoodsmd.ename = "dress"; } ListGoodsmd.name = goodsmodel.GoodsName; ListGoodsmd.count = goodsmodel.GoodsNum.Value; ListGoodsmd.unit = "piece"; if (goodsmodel.Weight != null) ListGoodsmd.weight = goodsmodel.Weight.Value; else ListGoodsmd.weight = 100; //if (goodsmodel.GoodsPrice != null) ListGoodsmd.amount = goodsmodel.GoodsPrice.GetValueOrDefault(10); ListGoodsmd.currency = "USD"; ListGoodsmd.source_area = "China"; ListGoods.Add(ListGoodsmd); } } model.ListGoods = ListGoods; sfobj.UserCode = md.UserCode; sfobj.CheckCode = md.CheckCode; if (md.Name == "顺丰E宝挂号" || md.Name == "顺丰E宝平邮") { PostCode = sfobj.SendGoods(model, out ErrorInfo); } if (md.Name == "顺丰美国" || md.Name == "顺丰欧洲") { PostCode = sfobj.SendOU(model, out ErrorInfo); } } } else if (md.Name == "顺丰国际挂号(美国)" || md.Name == "顺丰国际挂号(澳大利亚)" || md.Name == "顺丰国际挂号(其它)") //顺丰 { if (md.CheckCode != null && md.CheckCode != "" && goodslist != null && goodslist.Count > 0) { sfApi sfobj = new sfApi(); sf_Order2 model = new sf_Order2(); model.express_type = "E2"; model.d_tel = ordermd.RevPhone; model.d_company = ordermd.RevName; model.d_contact = ordermd.RevName; model.d_address = ordermd.RevAddr; model.orderid = ordermd.PlatOrderCode; model.d_city = ordermd.RevCity; model.d_post_code = ordermd.RevPostCode; model.d_province = ordermd.RevProvince; model.d_country = ordermd.RevCountry; model.cargo_total_weight = 1; //Convert.ToDecimal(ordermd.TotalWeight) / 1000; model.j_tel = companymd.Phone; model.j_company = companymd.CompanyEnglishName; model.j_province = "zhejiang";// "zhejiang province"; model.j_city = "ningbo"; //"Ningbo"; model.j_contact = companymd.SendEnglishName; model.j_address = companymd.EnglishAddress; model.j_post_code = companymd.PostCode; model.parcel_quantity = 1; List ListGoods = new List(); if (goodslist != null) { foreach (var goodsmodel in goodslist) { var ListGoodsmd = new sf_Goods2(); if (goodsmodel.GoodsEnglisgName != null && goodsmodel.GoodsEnglisgName != "") { ListGoodsmd.ename = goodsmodel.GoodsEnglisgName; } else { ListGoodsmd.ename = "dress"; } if (ListGoodsmd.ename.Length > 25) ListGoodsmd.ename = ListGoodsmd.ename.Substring(0, 24); ListGoodsmd.name = goodsmodel.GoodsName; if (ListGoodsmd.name.Length > 25) ListGoodsmd.name = ListGoodsmd.name.Substring(0, 24); ListGoodsmd.count = goodsmodel.GoodsNum.Value; //ListGoodsmd.unit = "piece"; //if (goodsmodel.Weight != null) // ListGoodsmd.weight = goodsmodel.Weight.Value; //else // ListGoodsmd.weight = 100; //if (goodsmodel.GoodsPrice != null) //if (goodsmodel.GoodsPrice != null && goodsmodel.GoodsPrice < 10) // ListGoodsmd.amount = goodsmodel.GoodsPrice.Value; //else ListGoodsmd.amount = 10; //ListGoodsmd.currency = "USD"; // ListGoodsmd.source_area = "China"; ListGoods.Add(ListGoodsmd); } } model.ListGoods = ListGoods; sfobj.UserCode = md.UserCode; sfobj.CheckCode = md.CheckCode; PostCode = sfobj.SendGoods2(model, out ErrorInfo); if (ErrorInfo != "") PostCode = ""; } } else if (md.Name == "德邮小包" || md.Name == "DHL中英专线") { PostCode = obj1.GetGZExpressCodeDY(CompanyId, PostId); } else if (md.Name.Contains("DHL")) { if (md.client_id != null && md.client_id != "" && goodslist != null && goodslist.Count > 0) { DHLApi dhlobj = new DHLApi(); DHLOrder dhlmodel = new DHLOrder(); dhlobj.clientId = md.client_id; //"LTExMTgwNTI4MTY="; dhlobj.GetTime = md.GetTime; dhlobj.password = md.client_secret; //"APITest1"; dhlobj.AccessToken = md.UserCode; dhlobj.token_type = md.CheckCode; labelRequest labelRequest = new labelRequest(); hdr hdr = new hdr(); hdr.messageType = "LABEL"; hdr.messageDateTime = DateTime.Now.ToString("s"); hdr.accessToken = ""; hdr.messageVersion = "1.4"; hdr.messageLanguage = "en"; labelRequest.hdr = hdr; DHL_Order bd = new DHL_Order(); bd.customerAccountId = null; bd.pickupAccountId = md.refresh_token; //"5999999201"; bd.soldToAccountId = md.Code; //"5999999201"; bd.pickupDateTime = DateTime.Now.ToString("s"); pickupAddress pickupAddress = new pickupAddress(); pickupAddress.companyName = "DHL"; pickupAddress.name = "DHL"; pickupAddress.address1 = "china"; pickupAddress.address2 = null; pickupAddress.address3 = null; pickupAddress.city = "china"; pickupAddress.state = "china"; pickupAddress.district = "china"; pickupAddress.country = "CN"; pickupAddress.postCode = "6278"; pickupAddress.phone = "9999"; pickupAddress.email = "test@dhl.com"; bd.pickupAddress = pickupAddress; List shipmentItemslist = new List(); shipmentItems shipmentItems = new shipmentItems(); consigneeAddress consigneeAddress = new consigneeAddress(); string Name = ordermd.RevName; if (Name.Length > 30) Name = Name.Substring(0, 30); consigneeAddress.companyName = Name; consigneeAddress.name = Name; consigneeAddress.address2 = null; consigneeAddress.address3 = null; if (ordermd.RevAddr.Length <= 50) consigneeAddress.address1 = ordermd.RevAddr; else consigneeAddress.address1 = ordermd.RevAddr.Substring(0, 50); if (ordermd.RevAddr.Length > 50 && ordermd.RevAddr.Length <= 100) consigneeAddress.address2 = ordermd.RevAddr.Substring(49, ordermd.RevAddr.Length - 50); else if (ordermd.RevAddr.Length > 100 && ordermd.RevAddr.Length <= 150) consigneeAddress.address3 = ordermd.RevAddr.Substring(99, ordermd.RevAddr.Length - 100); consigneeAddress.city = ordermd.RevCity; consigneeAddress.state = ordermd.RevProvince; consigneeAddress.district = null; consigneeAddress.country = ordermd.CountryCode; consigneeAddress.postCode = ordermd.RevPostCode; consigneeAddress.phone = ordermd.RevPhone; consigneeAddress.email = null; consigneeAddress.idNumber = "9999"; consigneeAddress.idType = "1"; shipmentItems.consigneeAddress = consigneeAddress; returnAddress returnAddress = new returnAddress(); returnAddress.companyName = "MHSG"; returnAddress.name = companymd.SendEnglishName; if (companymd.Address != null && companymd.Address.Length < 50) returnAddress.address1 = companymd.Address; else if (companymd.Address != null) returnAddress.address1 = companymd.Address.Substring(0, 49); returnAddress.address2 = null; returnAddress.address3 = null; returnAddress.city = "ningbo"; returnAddress.state = "zhejiang"; returnAddress.district = "zhenhai"; returnAddress.country = "CN"; returnAddress.postCode = "315000"; returnAddress.phone = companymd.Phone; shipmentItems.returnAddress = returnAddress; shipmentItems.shipmentID = "CNAEV543" + ordermd.OrderId.ToString(); shipmentItems.deliveryConfirmationNo = null; shipmentItems.packageDesc = "Desc"; shipmentItems.totalWeightUOM = "G"; shipmentItems.dimensionUOM = "cm"; shipmentItems.height = Convert.ToDecimal(0.1); shipmentItems.length = Convert.ToDecimal(0.1); shipmentItems.width = Convert.ToDecimal(0.1); shipmentItems.customerReference1 = null; shipmentItems.customerReference2 = null; shipmentItems.productCode = "PPS"; shipmentItems.incoterm = "DDU"; shipmentItems.contentIndicator = "01"; shipmentItems.codValue = null; shipmentItems.insuranceValue = null; shipmentItems.freightCharge = Convert.ToDecimal(0.1); shipmentItems.currency = "USD"; List shipmentContentsList = new List(); int TNum = 0; foreach (var gmd in goodslist) { TNum += gmd.GoodsNum.Value; } decimal tj = Convert.ToDecimal(5.5); decimal dj = Convert.ToDecimal(5.5); if (TNum > 1 && TNum <= 5) { tj = Convert.ToDecimal(2.1 * TNum); dj = Convert.ToDecimal(2.1); } else if (TNum > 5) { tj = Convert.ToDecimal(1.1 * TNum); dj = Convert.ToDecimal(1.1); } foreach (var gmd in goodslist) { shipmentContents shipmentContents = new shipmentContents(); shipmentContents.skuNumber = gmd.GoodsSKU; if (gmd.GoodsSKU == null && gmd.GoodsSKU.Length > 50) shipmentContents.skuNumber = "DEC001"; if (gmd.GoodsEnglisgName != null && gmd.GoodsEnglisgName != "" && gmd.GoodsEnglisgName.Length < 50) { shipmentContents.description = gmd.GoodsEnglisgName; shipmentContents.descriptionImport = gmd.GoodsEnglisgName; } else { shipmentContents.description = "cloth"; shipmentContents.descriptionImport = "cloth"; } if (gmd.GoodsName.Length < 50) shipmentContents.descriptionExport = gmd.GoodsName; else shipmentContents.descriptionExport = gmd.GoodsName.Substring(0, 49); shipmentContents.itemValue = dj; shipmentContents.itemQuantity = gmd.GoodsNum.Value; shipmentContents.grossWeight = 100; shipmentContents.netWeight = 100; shipmentContents.weightUOM = "g"; shipmentContents.contentIndicator = "01"; shipmentContents.countryOfOrigin = "CN"; shipmentContents.hsCode = null; shipmentContentsList.Add(shipmentContents); shipmentItems.shipmentContents = shipmentContentsList; shipmentItemslist.Add(shipmentItems); } shipmentItems.totalValue = tj; shipmentItems.totalWeight = Convert.ToDecimal(100 * 1.00 * TNum); bd.shipmentItems = shipmentItemslist; label label = new label(); label.pageSize = "400x600"; label.format = "PDF"; label.layout = "4x1"; bd.label = label; labelRequest.bd = bd; dhlmodel.labelRequest = labelRequest; PostCode = dhlobj.SendGoods(dhlmodel, out ErrorInfo); } } else if (md.Name.StartsWith("CNE")) { string postmessage = "{\"RequestName\":\"TimeStamp\"}"; string error = ""; CNE cneobj = new CNE(); string timeinfo = cneobj.SendGoods(postmessage, out error); JavaScriptSerializer JsonConvert = new JavaScriptSerializer(); CNE_Result model = JsonConvert.Deserialize(timeinfo); string code = NetLibrary.Safety.CryptoPublic.Md5For32(md.UserCode + model.ReturnValue + md.CheckCode); var cnemd = new CNE_Order(); cnemd.RequestName = "PreInputSet"; cnemd.icID = md.UserCode; cnemd.TimeStamp = model.ReturnValue; cnemd.MD5 = code; List RecList = new List(); var recmd = new CNE_Reve(); recmd.iID = "0"; recmd.nItemType = 1; recmd.cRNo = ordermd.PlatOrderCode; recmd.cDes = ordermd.CountryName; recmd.cEmsKind = md.customercode; recmd.fWeight = 0; recmd.cReceiver = ordermd.RevName; recmd.cREMail = ""; recmd.cRAddr = ordermd.RevAddr; recmd.cRCity = ordermd.RevCity; recmd.cRProvince = ordermd.RevProvince; recmd.cRCountry = ordermd.RevCountry; recmd.cRPhone = ordermd.RevPhone; recmd.cRPostcode = ordermd.RevPostCode; var glist = new List(); if (goodslist != null) { foreach (var goodsmodel in goodslist) { var gmd = new CNE_Goods(); gmd.cxGoods = goodsmodel.GoodsName; if (goodsmodel.GoodsEnglisgName != null && goodsmodel.GoodsEnglisgName != "") gmd.cxGoodsA = goodsmodel.GoodsEnglisgName; else gmd.cxGoodsA = "cloth"; if (gmd.cxGoodsA.Length > 20) gmd.cxGoodsA = gmd.cxGoodsA.Substring(0, 20); gmd.fxPrice = 10; gmd.ixQuantity = goodsmodel.GoodsNum.Value; gmd.cxGCodeA = goodsmodel.GoodsSKU; glist.Add(gmd); recmd.GoodsList = glist; RecList.Add(recmd); } } cnemd.RecList = RecList; PostCode = cneobj.SendGoods2(cnemd, out ErrorInfo); } else if (md.Name.Contains("Wish")) { if (md.CheckCode != null && md.CheckCode != "" && goodslist != null && goodslist.Count > 0) { //WishYouApi wya = new WishYouApi(); //wya.api_key = md.UserCode; //wya.bid = 0; //wya.zx_type = 6; //wya.guid = ordermd.OrderId.ToString(); //if (md.Name == "Wish挂号") // wya.otype = "1"; //if (md.Name == "Wish平邮") // wya.otype = "0"; //if (md.Name == "DLP平邮") // wya.otype = "9-0"; //if (md.Name == "DLP挂号") // wya.otype = "9-1"; //if (md.Name == "Wish-E邮宝") // wya.otype = "11-0"; //companymd = obj1.GetSendAddress(CompanyId); //wya.from = companymd.SendName; //wya.sender_addres = companymd.SendEnglishName; //wya.sender_city = companymd.city; //wya.sender_province = companymd.province; //wya.sender_phone = companymd.Phone; //wya.CustomName = ordermd.RevName; //wya.to_local = ordermd.RevName; //wya.recipient_addres = ordermd.RevAddr.Replace("+", " ").Replace("&", " ").Replace("#", " ").Replace("/", " "); ; //wya.recipient_addres_local = ordermd.RevAddr.Replace("+", " ").Replace("&", " ").Replace("#", " ").Replace("/", " "); ; //wya.recipient_country_short = ordermd.CountryCode; //wya.recipient_country_local = ordermd.RevCountry; //wya.recipient_province = ordermd.RevProvince; //wya.recipient_province_local = ordermd.RevProvince; //wya.recipient_city = ordermd.RevCity; //wya.recipient_city_local = ordermd.RevCity; //wya.recipient_postcode = ordermd.RevPostCode; //string phone = ""; //if (ordermd.RevMoblie != null) //{ // if (ordermd.RevMoblie.Length > 5) // { // phone = ordermd.RevMoblie; // } //} //if (phone == "") phone = ordermd.RevPhone; //wya.recipient_phone = phone; //string content = ""; //int totalnum = 0; //decimal totalweight =0;// ordermd.TotalWeight.Value; //var totalprice = ordermd.TotalPrice.Value; //if (goodslist != null) //{ // foreach (var goodsmodel in goodslist) // { // totalweight +=Convert.ToDecimal( goodsmodel.Weight.GetValueOrDefault(100) / 1000); // if (goodsmodel.GoodsEnglisgName != "") // { // content += goodsmodel.GoodsEnglisgName + ";"; // } // else // { // content += "dress;"; // } // totalnum += goodsmodel.GoodsNum.Value; // } //} //wya.content = content; //wya.type_no = 1; //wya.weight = totalweight.ToString(); //wya.num = totalnum; //wya.price = totalprice.ToString(); //wya.from_country = "China"; //wya.user_desc = ordermd.PlatOrderCode; //wya.trande_no = ordermd.PlatOrderCode; //wya.trade_amount = totalprice.ToString(); WishYouApi2 wya = new WishYouApi2(); wya.ExpressId = md.ExpressID; wya.client_id = md.client_id; wya.client_secret = md.client_secret; wya.redirect_uri = md.redirect_uri; wya.refresh_token = md.refresh_token; wya.code = md.Code; wya.GetTime = md.GetTime; wya.access_token = md.UserCode; wya.bid = 0; wya.mark = ""; wya.guid = ordermd.OrderId.ToString(); if (md.Name == "Wish挂号") wya.otype = "1"; if (md.Name == "Wish平邮") wya.otype = "0"; if (md.Name == "DLP平邮") wya.otype = "9-0"; if (md.Name == "DLP挂号") wya.otype = "9-1"; if (md.Name == "Wish-E邮宝") wya.otype = "11-0"; if (md.customercode != null && md.customercode != "") wya.otype = md.customercode; // companymd = obj1.GetSendAddress(CompanyId); wya.from = companymd.SendName; //"Stella Xu"; wya.sender_addres = companymd.SendEnglishName;// "ChangxingRoad689"; wya.sender_city = companymd.citycode; //"Ningbo"; wya.sender_province = companymd.provincecode;// "Zhejiang"; wya.sender_phone = companymd.Phone;// "13456152202"; wya.to = ordermd.RevName; wya.to_local = ordermd.RevName; wya.recipient_country = ordermd.RevCountry; wya.recipient_addres = ordermd.RevAddr.Replace("+", " ").Replace("&", " ").Replace("#", " ").Replace("/", " "); ; wya.recipient_addres_local = ordermd.RevAddr.Replace("+", " ").Replace("&", " ").Replace("#", " ").Replace("/", " "); ; wya.recipient_country_short = ordermd.CountryCode; wya.recipient_country_local = ordermd.RevCountry; if (ordermd.RevProvince == null || ordermd.RevProvince == "") { wya.recipient_province = ordermd.RevCity; wya.recipient_province_local = ordermd.RevCity; } else { wya.recipient_province = ordermd.RevProvince; wya.recipient_province_local = ordermd.RevProvince; } wya.recipient_city = ordermd.RevCity; wya.recipient_city_local = ordermd.RevCity; wya.recipient_postcode = ordermd.RevPostCode; string phone = ""; if (ordermd.RevMoblie != null) { if (ordermd.RevMoblie.Length > 5) { phone = ordermd.RevMoblie; } } if (phone == "") phone = ordermd.RevPhone; wya.recipient_phone = phone; string content = ""; int totalnum = 0; decimal totalweight = 0;// ordermd.TotalWeight.Value; var totalprice = ordermd.TotalPrice.Value; string contentdesc = ""; string contentname = "货物"; if (goodslist != null) { foreach (var goodsmodel in goodslist) { if (goodsmodel.GoodsName != null && goodsmodel.GoodsName != "") contentname = goodsmodel.GoodsName; totalweight += Convert.ToDecimal(goodsmodel.Weight.GetValueOrDefault(100) / 1000); if (goodsmodel.GoodsEnglisgName != "") { content += goodsmodel.GoodsEnglisgName + ";"; } else { content += "dress;"; } totalnum += goodsmodel.GoodsNum.Value; contentdesc += goodsmodel.GoodsCode + "-" + goodsmodel.TypeCode + goodsmodel.TypeDesc + "[" + goodsmodel.GoodsNum.ToString() + "];"; } } if (contentname.Length > 49) contentname = contentname.Substring(0, 40); wya.content_chinese = contentname; wya.content = content; wya.type_no = 1; wya.weight = totalweight.ToString(); wya.num = totalnum; wya.single_price = totalprice.ToString(); wya.warehouse_code = md.operationtype.ToString();//仓库 "13"; wya.doorpickup = ""; if (md.vipcode == "1") //上门揽货 wya.doorpickup = "1"; wya.has_battery = ""; if (md.clcttype == 1) wya.has_battery = "1";//含电池 wya.from_country = "China"; wya.user_desc = contentdesc;// ordermd.PlatOrderCode; wya.receive_from = companymd.ChargeName;// "ChangxingRoad689"; wya.receive_city = companymd.Shen; //"Ningbo"; wya.receive_province = companymd.Shi;// "Zhejiang"; wya.receive_phone = companymd.Phone;// "13456152202"; wya.receive_addres = companymd.Address;// "13456152202"; wya.trande_no = ordermd.PlatOrderCode; wya.trade_amount = totalprice.ToString(); PostCode = wya.SendGood(wya); } } //else if (md.Name.Contains("递四方")) //{ // if (md.CheckCode != null && md.CheckCode != "" && goodslist != null && goodslist.Count > 0) // { // try // { // pxserver.OrderOnlineServiceClient opx = new pxserver.OrderOnlineServiceClient(); // opx.Open(); // pxserver.createAndPreAlertOrderRequest[] rq = new pxserver.createAndPreAlertOrderRequest[1]; // pxserver.createAndPreAlertOrderRequest rq1 = new pxserver.createAndPreAlertOrderRequest(); // rq1.consigneeName = ordermd.RevName;// "jack"; // rq1.consigneePostCode = ordermd.RevPostCode;// "72601"; // rq1.consigneeTelephone = ordermd.RevPhone;// "0805522713"; // if (ordermd.RevPhone == null || ordermd.RevPhone == "") // rq1.consigneeTelephone = ordermd.RevMoblie; // rq1.city = ordermd.RevCity;// "Harrison"; // if (ordermd.RevCity == null || ordermd.RevCity == "") // rq1.city = ordermd.RevProvince; // rq1.stateOrProvince = ordermd.RevProvince;// "AR"; // if (ordermd.RevProvince == null || ordermd.RevProvince == "") // rq1.stateOrProvince = ordermd.RevCity; // rq1.street = ordermd.RevAddr;//"1202 Chalet Ln1"; // rq1.orderNo = ordermd.PlatOrderCode;// "5958d6a19ca1e531230ec8c5"; // if (rq1.orderNo.Length > 20) // rq1.orderNo = rq1.orderNo.Substring(0, 20); // rq1.shipperAddress = companymd.EnglishAddress;// "haishu"; // rq1.shipperCity = companymd.city;// "ningbo"; // rq1.shipperCompanyName = companymd.SendName;// "chu"; // rq1.shipperName = companymd.SendName;// "chu"; // rq1.shipperPostCode = "315000"; // rq1.initialCountryCode = "CN"; // rq1.destinationCountryCode = ordermd.CountryCode;// "US"; // rq1.productCode = md.customercode;//渠道 "B1"; // if(md.Name.Contains("电")) // rq1.hasBattery = "Y"; // else // rq1.hasBattery = "N"; // rq1.returnSign = "Y"; // pxserver.declareInvoice[] gmd = new pxserver.declareInvoice[goodslist.Count]; // int idx = 0; // int gmx = 0; // foreach (var ggmd in goodslist) // { // pxserver.declareInvoice md1 = new pxserver.declareInvoice(); // md1.cName = ggmd.GoodsName; // md1.declareNote = ggmd.GoodsCode + "-" + ggmd.TypeCode + ggmd.TypeDesc; // md1.declarePieces = ggmd.GoodsNum.Value.ToString(); // md1.unitPrice = "5"; // md1.name = "衣服"; // md1.eName = "cloth"; // gmd[idx] = md1; // gmx += ggmd.GoodsNum.Value; // idx++; // } // rq1.declareInvoice = gmd; // rq1.pieces = gmx.ToString(); // rq[0] = rq1; // pxserver.createAndPreAlertOrderResponse[] rp = new pxserver.createAndPreAlertOrderResponse[1]; // rp = opx.createAndPreAlertOrderService(md.CheckCode, rq); // if (rp[0].ack == "Success") // { // PostCode = rp[0].trackingNumber; // } // else // { // ErrorInfo ="失败"+ rp[0].errors[0].cnMessage + rp[0].errors[0].cnAction + rp[0].errors[0].defineMessage; // } // opx.Close(); // } // catch (Exception ex) // { // ErrorInfo = "失败" + ex.Message; // } // } //} else if (md.LogisticsId == 67) { PostCode = OnewordCreate(md, ordermd, goodslist); } else if (md.Name.Contains("燕文") || md.Name == "燕邮宝平邮") { if (md.CheckCode != null && md.CheckCode != "" && goodslist != null && goodslist.Count > 0) { YanWenApi ywa = new YanWenApi(); ywa.CheckCode = md.CheckCode; ywa.UserCode = md.UserCode; YW_Order model = new YW_Order(); model.Channel = md.customercode; if (md.Name == "燕文上海平邮" || md.Name == "燕文宁波平邮") { model.Channel = "中邮上海平邮小包"; } if (md.Name == "燕文北京平邮") { model.Channel = "中邮北京平邮小包"; } if (md.Name == "燕文上海小包" || md.Name == "燕文宁波小包") { model.Channel = "中邮上海挂号小包"; } if (md.Name.Contains("燕文德邮")) { model.Channel = "德国邮政挂号小包(上海)"; } if (md.Name.Contains("燕文荷兰挂号(电)")) { model.Channel = "荷兰邮政挂号小包(含电)"; } if (md.Name.Contains("燕文上海E邮宝")) { model.Channel = "中邮上海E邮宝(线下)"; } if (md.Name.Contains("燕文马来西亚邮政平邮小包")) { model.Channel = "马来西亚邮政平邮小包(新)"; } model.orderid = ordermd.PlatOrderCode; model.d_address = ordermd.RevAddr.Replace("+", " ").Replace("&", " ").Replace("#", " ").Replace("/", " "); ; model.d_City = ordermd.RevCity; model.d_contact = ordermd.RevName; model.d_country = ordermd.CountryName; model.d_email = ordermd.RevMail; model.d_mobile = ordermd.RevMoblie; model.d_postcode = ordermd.RevPostCode; model.d_State = ordermd.RevProvince; model.d_tel = ordermd.RevPhone; //string desc = ""; //foreach (var ggmd in goodslist) //{ // desc +=ggmd.GoodsCode+"-"+ ggmd.TypeCode + ggmd.TypeDesc + "[" + ggmd.GoodsNum.ToString() + "];"; //} string contentdesc = ""; string contentdesc2 = ""; int GoodsNum = 0; int IsMore = 0; if (goodslist != null) { foreach (var goodsmodel in goodslist) { IsMore++; GoodsNum += goodsmodel.GoodsNum.Value; contentdesc2 += goodsmodel.GoodsCode + "-" + goodsmodel.TypeCode + "" + goodsmodel.TypeDesc.Replace("+", " ").Replace("&", " ").Replace("#", " ").Replace("/", " ") + "[" + goodsmodel.GoodsNum.ToString() + "];"; contentdesc += goodsmodel.GoodsCode + "-" + goodsmodel.TypeCode + goodsmodel.TypeDesc + "[" + goodsmodel.GoodsNum.ToString() + "];"; } } model.GoodsNum = GoodsNum; model.delcarevalue = 5; if (IsMore > 1) contentdesc2 = "[MORE]" + contentdesc2; if (contentdesc2.Length > 195) contentdesc2 = contentdesc2.Substring(0, 195); if (IsMore > 1) model.cnname = goodslist.First().GoodsName.Replace("+", " ").Replace("&", " ").Replace("#", " ").Replace("/", " ") + " 多个"; else model.cnname = goodslist.First().GoodsName.Replace("+", " ").Replace("&", " ").Replace("#", " ").Replace("/", " "); model.enname = contentdesc2; // model.Memo = contentdesc; // if (contentdesc.Length > 50) // model.Memo = contentdesc2; model.MoreGoodsName = contentdesc; model.weight = 100; PostCode = ywa.GetTrackCode(model); // ywa.getchannel(); } } else if (md.Name.Contains("淼信")) { if (md.Name == "淼信俄罗斯") { MiaoXinApi mxobj = new MiaoXinApi(); MiaoXin_Order model = new MiaoXin_Order(); model.buyerid = ""; model.consignee_address = ordermd.RevAddr; model.consignee_city = ordermd.RevCity; model.consignee_mobile = ""; model.consignee_name = ordermd.RevName; model.consignee_postcode = ordermd.RevPostCode; model.consignee_state = "Other"; model.consignee_telephone = ordermd.RevPhone; model.country = "RU"; model.customer_id = md.UserCode; model.customer_userid = md.CheckCode; model.order_customerinvoicecode = ordermd.PlatOrderCode; model.product_id = "3861"; model.trade_type = "ZYXT"; model.weight = ""; List GoodsList = new List(); if (goodslist != null) { foreach (var goodsmodel in goodslist) { MiaoXin_Goods model2 = new MiaoXin_Goods(); model2.invoice_amount = "5"; model2.invoice_pcs = goodsmodel.GoodsNum.ToString(); model2.invoice_title = goodsmodel.GoodsEnglisgName; model2.invoice_weight = "100"; model2.item_id = ""; model2.item_transactionid = ""; model2.sku = goodsmodel.GoodsName; GoodsList.Add(model2); } } model.orderInvoiceParam = GoodsList; PostCode = mxobj.SendGoods(model, out ErrorInfo); } } else if (md.Name.Contains("Fedex") && md.customercode == "SMART_POST") { FedexSmartPost fedexobj = new FedexSmartPost(); FedexSmartPost.Key = md.UserCode; FedexSmartPost.Password = md.CheckCode; FedexSmartPost.AccountNumber = md.client_id; FedexSmartPost.MeterNumber = md.client_secret; FedexSmartPost.PayAccountNumber = md.refresh_token; FedexSmartPost.HubId = md.Code; FedexOrder fdorder = new FedexOrder(); Shiper shiper = new Shiper { City = companymd.city, CompanyName = companymd.SendEnglishName, PersonName = companymd.SendEnglishName, PhoneNumber = companymd.Phone, PostalCode = companymd.PostCode, StateOrProvinceCode = companymd.provincecode, StreetLines = companymd.EnglishAddress, CountryCode = companymd.countycode }; fdorder.Shiper = shiper; fdorder.CustomerTransactionId = ordermd.PlatOrderCode; fdorder.PostId = new int?(PostId); Rever rever = new Rever { City = ordermd.RevCity, CompanyName = ordermd.RevName, PersonName = ordermd.RevName, PhoneNumber = ordermd.RevPhone, PostalCode = ordermd.RevPostCode }; if ((ordermd.RevProvince == null) || (ordermd.RevProvince == "")) { rever.StateOrProvinceCode = ordermd.RevCity; } else { rever.StateOrProvinceCode = ordermd.RevProvince; } rever.StreetLines = ordermd.RevAddr; rever.CountryCode = ordermd.CountryCode; fdorder.Rever = rever; List fedlist = new List(); string gsku = ""; int gnum = 0; foreach (DT_OrderGoods gmd in goodslist) { gsku += gmd.GoodsCode + gmd.GoodsDesc; gnum += gmd.GoodsNum.Value; } FedexGoods fgmd = new FedexGoods { Amount = 10.000M, SKU = gsku, Description = gsku, NumberOfPieces = gnum.ToString(), Weight = 1M, Quantity = 1M }; fedlist.Add(fgmd); fdorder.GoodsList = fedlist; PostCode = fedexobj.GetFedex(fdorder, out ErrorInfo); } } } catch (Exception ex) { ErrorInfo += ex.Message; } } try { if (PostCode != null && PostCode != "" && !PostCode.Contains("失败")) { DT_TrackCodeApply Model = new DT_TrackCodeApply(); string[] tracklist = PostCode.Split(','); //if (md.LogisticsId != null) //{ // if (md.LogisticsId > 0) // { // if (CheckWuliu(md.LogisticsId.GetValueOrDefault(0), tracklist[0].ToString()) == 1) // { // return ""; // } // } //} if (tracklist.Length > 1) { Model.TrackCode = tracklist[0].ToString(); Model.TrackCode2 = tracklist[1].ToString(); } else { Model.TrackCode = tracklist[0].ToString(); } Model.GetDate = DateTime.Now; Model.InName = Session["Name"].ToString(); if (JoinOrderCode != "") Model.OrderCode = JoinOrderCode; else Model.OrderCode = ordercode; Model.OrderId = OrderId; Model.PostId = PostId; Model.State = 1; Model.TrackType = TrackType; Model.UpdateTime = DateTime.Now; Model.IsSpare = IsSpare; Model.JoinOrderCode = JoinOrderCode; //obj.UpdateTrackCode(PostCode, PostId,OrderId, ErrorInfo); obj.SaveTrackCodeApply2(Model); } else //if (md.PostType != 4) //线上发货的除外 { ErrorFollow.TraceWrite("GetOrderPostCode", "物流id:" + PostId.ToString() + ";订单号:" + PlatCode + "获取跟踪码错误", ErrorInfo); //ErrorInfo += "未获取到跟踪码"; obj.UpdateTrackCodeError2(OrderId, PostId, "获取到跟踪码失败"); } if (PostCode != null && PostCode != "" && !PostCode.Contains("失败")) { TrackCode = PostCode; return ""; } else return PlatCode + "的订单" + ErrorInfo + " " + PostCode; } catch (Exception ex) { return ErrorInfo + ex.Message; } } #endregion #region 获取物流单号2 [WebMethod(EnableSession = true)] public string GetOrderPostCode2(int LogisticsId, int PostId, string OrderIds) { Pages.Login(this.Session); var obj = new DD_OrderData(); if (OrderIds == "") return "没有选择订单"; int CompanyId = Convert.ToInt32(Session["CompanyId"]); var companymd = new JC_PostAddress(); var obj1 = new JC_ExpressService(); var obj11 = new BaseService(); string ErrorInfo = ""; companymd = obj11.GetAddressModel(CompanyId); if (companymd == null) { ErrorInfo = "发货地址没选择;"; return ErrorInfo; } var md = obj1.GetExpressModel(CompanyId, PostId); var plist = new List(); //var elist = new List(); var orderlist = obj.GetOrderModelList(OrderIds.Trim(',')); var orderGoodslist = obj.GetOrderGoodsList2(OrderIds.Trim(',')); if (orderlist == null || orderlist.Count == 0) return "没有选择订单"; var obj2 = new BaseService(); if (md == null) return ""; foreach (var ordermd in orderlist) { if (ordermd.JoinOrderCode != null) { if (plist.Where(o => o.JoinOrderCode == ordermd.JoinOrderCode).Count() > 0) { continue; } } //if (LogisticsId != 80) //{ // if (obj2.IsExpress2(CompanyId, PostId, ordermd.CountryCode) <= 0) // { // ErrorInfo += ordermd.PlatOrderCode + "的订单国家不支持该物流发送;"; // continue; // } //} string PostCode = ""; if (md.CheckCode == null || md.CheckCode == "") { PostCode = obj1.GetInnerExpressCode(CompanyId, PostId); } else { try { List goodslist = new List(); //var ordermd = obj.GetOrderModel(OrderId); if (ordermd.JoinOrderCode != null && ordermd.JoinOrderCode != "")//合并订单 { goodslist = obj.GetOrderGoodsDetailListForJoin(ordermd.JoinOrderCode); } else { if (orderGoodslist != null && orderGoodslist.Count > 0) { goodslist = orderGoodslist.FindAll(n => n.OrderId == ordermd.OrderId); } } string ordercode = ordermd.PlatOrderCode; if (md != null && ordermd != null) { if (md.PostType == 1) //EUB { if (md.CheckCode != null && md.CheckCode != "" && goodslist != null && goodslist.Count > 0) { if (md.Name == "EUB" && ordermd.CountryCode != "US") { return "国家不支持"; } if (md.Name.Contains("美国") == true && ordermd.CountryCode != "US") { return "国家不支持"; } if (md.Name == "EUB上海" && ordermd.CountryCode != "US") { return "国家不支持"; } if (md.Name == "EUB慈溪" && ordermd.CountryCode != "US") { return "国家不支持"; } if (md.Name == "俄EUB" && ordermd.CountryCode != "RU") { return "国家不支持"; } if (md.Name.Contains("俄罗斯") == true && ordermd.CountryCode != "RU") { return "国家不支持"; } if (md.Name == "加拿大EUB" && ordermd.CountryCode != "CA") { return "国家不支持"; } if (md.Name.Contains("加拿大") == true && ordermd.CountryCode != "CA") { return "国家不支持"; } if (md.Name == "英国EUB" && (ordermd.CountryCode != "UK" && ordermd.CountryCode != "GB")) { return "国家不支持"; } if (md.Name.Contains("英国") == true && (ordermd.CountryCode != "UK" && ordermd.CountryCode != "GB")) { return "国家不支持"; } if (md.Name == "线上EUB" && ordermd.CountryCode != "US") { return "国家不支持"; } if (md.Name == "线上俄EUB" && ordermd.CountryCode != "RU") { return "国家不支持"; } if (md.Name == "澳大利亚EUB" && ordermd.CountryCode != "AU") { return "国家不支持"; } if (md.Name.Contains("澳大利亚") == true && ordermd.CountryCode != "AU") { return "国家不支持"; } if (md.Name == "乌克兰EUB" && ordermd.CountryCode != "UA") { return "国家不支持"; } if (md.Name.Contains("澳大利亚") == true && ordermd.CountryCode != "AU") { return "国家不支持"; } if (md.Name == "法国EUB" && ordermd.CountryCode != "FR") { return "国家不支持"; } if (md.Name.Contains("澳大利亚") == true && ordermd.CountryCode != "AU") { return "国家不支持"; } if (md.Name == "以色列EUB" && ordermd.CountryCode != "IL") { return "国家不支持"; } if (md.Name.Contains("以色列") == true && ordermd.CountryCode != "IL") { return "国家不支持"; } if (md.Name == "沙特EUB" && ordermd.CountryCode != "SA") { return "国家不支持"; } if (md.Name.Contains("沙特") == true && ordermd.CountryCode != "SA") { return "国家不支持"; } EubApi eub = new EubApi(); Eub_Order model = new Eub_Order(); model.Orderid = ordermd.PlatOrderCode; model.OrderCode = ordermd.OrderCode; model.BuyID = ordermd.CustomID; if (md.operationtype != null) model.operationtype = md.operationtype.Value; else model.operationtype = 0; //model.operationtype = 0; model.customercode = md.customercode; model.vipcode = md.vipcode; if (md.clcttype != null) model.clcttype = md.clcttype.Value; else model.clcttype = 1; model.pod = false; model.untread = "Returned"; if (goodslist != null && goodslist.Count > 0 && goodslist[0].Solid != null) model.volweight = Convert.ToInt32(goodslist[0].Solid / 6000); else model.volweight = 0; model.startdate = DateTime.Now; model.enddate = DateTime.Now.AddDays(15); model.sku1 = goodslist[0].GoodsSKU.Replace("&", " "); model.printcode = "03"; model.barcode = ordermd.PlatOrderCode; Eub_Person sendmd = new Eub_Person(); sendmd.company = companymd.CompanyEnglishName; sendmd.email = companymd.Email; sendmd.name = companymd.SendEnglishName; sendmd.phone = companymd.Phone; sendmd.province = companymd.province; sendmd.city = companymd.city; sendmd.country = "CN"; sendmd.county = companymd.county; sendmd.street = companymd.EnglishAddress; //"Guangyuan Road 69 (Asia Tiger Park Building 4),Jiangbei District,Ningbo,China"; sendmd.postcode = companymd.PostCode; model.sender = sendmd; Eub_Person revmodel = new Eub_Person(); revmodel.name = ordermd.RevName; revmodel.phone = ordermd.RevPhone; if (ordermd.RevProvince != null && ordermd.RevProvince != "") revmodel.province = ordermd.RevProvince; else { if (md.Name != "EUB" && md.Name != "EUB上海" && md.Name != "EUB慈溪") { //ErrorInfo += ordercode + "收件省不能为空;"; if (ordermd.RevCity != null && ordermd.RevCity != "") { revmodel.province = ordermd.RevCity; } else { revmodel.province = " "; } } } string postcode = ordermd.RevPostCode; if (ordermd.RevCountry == "United States" && postcode.Length > 5) { // postcode = Convert.ToInt32(ordermd.RevPostCode.Substring(0, 5).Trim()).ToString(); postcode = ordermd.RevPostCode.Substring(0, 5).Trim(); } else if (ordermd.RevCountry == "Russian Federation" && postcode.Length > 6) { // postcode = Convert.ToInt32(ordermd.RevPostCode.Substring(0, 6).Trim()).ToString(); postcode = ordermd.RevPostCode.Substring(0, 6).Trim(); } revmodel.county = ordermd.RevArea; revmodel.city = ordermd.RevCity; if (ordermd.CountryCode == "UK") ordermd.CountryCode = "GB"; revmodel.country = ordermd.CountryCode; revmodel.street = ordermd.RevAddr.Replace("+", " ").Replace("&", " ").Replace("#", " ").Replace("/", " "); ; revmodel.postcode = postcode; model.receiver = revmodel; Eub_Person collmodel = new Eub_Person(); collmodel.company = companymd.CompanyName; collmodel.email = companymd.Email; collmodel.name = companymd.SendName; collmodel.phone = companymd.Phone; collmodel.province = companymd.province; collmodel.country = "CN"; collmodel.city = companymd.city; collmodel.county = companymd.county; collmodel.street = companymd.Address; collmodel.postcode = companymd.PostCode; model.collect = collmodel; List ListGoods = new List(); if (goodslist != null) { foreach (var goodsmodel in goodslist) { var ListGoodsmd = new Eub_Goods(); ListGoodsmd.cnname = goodsmodel.GoodsName.Replace("+", " ").Replace("&", " ").Replace("#", " ").Replace("/", " "); if (goodsmodel.GoodsEnglisgName == null || goodsmodel.GoodsEnglisgName == "") ListGoodsmd.enname = goodsmodel.GoodsName; else ListGoodsmd.enname = goodsmodel.GoodsEnglisgName; ListGoodsmd.count = goodsmodel.GoodsNum.Value; ListGoodsmd.unit = "件"; // if (goodsmodel.GoodsPrice != null && goodsmodel.GoodsNum != null) ListGoodsmd.delcarevalue = 10; //if (goodsmodel.Weight != null) // ListGoodsmd.weight = goodsmodel.Weight.Value / 1000; //else ListGoodsmd.weight = Convert.ToDecimal(0.20); ListGoodsmd.origin = "CN"; ListGoodsmd.description = ""; ListGoods.Add(ListGoodsmd); } } model.ListGoods = ListGoods; if (md.Name == "线上EUB") { EbayApi ea = new EbayApi(); JC_PostAddress2 add = new JC_PostAddress2(); add.SendName = companymd.SendName; add.CompanyName = companymd.CompanyName; add.Email = companymd.Email; add.Address = companymd.Address; add.EnglishAddress = companymd.EnglishAddress; add.CompanyEnglishName = companymd.CompanyEnglishName; add.city = companymd.city; add.citycode = companymd.citycode; add.county = companymd.county; add.countycode = companymd.countycode; add.province = companymd.province; add.provincecode = companymd.provincecode; add.Phone = companymd.Phone; add.PostCode = companymd.PostCode; PostCode = ea.senderorder(model, add, md.CheckCode, "ebayshop2"); } else PostCode = eub.SendGoods(model, md.CheckCode, out ErrorInfo); } //if (PostCode == null || PostCode == "") //{ // PostCode = obj1.GetInnerExpressCode(CompanyId, PostId); //} } else if (md.Name == "E邮宝") //E邮宝 { if (md.CheckCode != null && md.CheckCode != "" && goodslist != null && goodslist.Count > 0) { EubApi eub = new EubApi(); Eub_Order model = new Eub_Order(); model.Orderid = ordermd.PlatOrderCode; if (md.operationtype != null) model.operationtype = md.operationtype.Value; else model.operationtype = 0; model.producttype = 0; model.customercode = md.customercode; model.vipcode = md.vipcode; if (md.clcttype != null) model.clcttype = md.clcttype.Value; else model.clcttype = 1; model.pod = false; model.untread = "Returned"; if (goodslist != null && goodslist.Count > 0 && goodslist[0].Solid != null) model.volweight = Convert.ToInt32(goodslist[0].Solid / 6000); else model.volweight = 0; model.startdate = DateTime.Now; model.enddate = DateTime.Now.AddDays(15); model.sku1 = goodslist[0].GoodsSKU.Replace("&", " "); model.printcode = "03"; model.barcode = ordermd.PlatOrderCode; Eub_Person sendmd = new Eub_Person(); sendmd.company = companymd.CompanyEnglishName; sendmd.email = companymd.Email; sendmd.name = companymd.SendEnglishName; sendmd.phone = companymd.Phone; sendmd.province = companymd.province; sendmd.city = companymd.city; sendmd.country = "CN"; sendmd.county = companymd.county; sendmd.street = companymd.EnglishAddress; //"Guangyuan Road 69 (Asia Tiger Park Building 4),Jiangbei District,Ningbo,China"; sendmd.postcode = companymd.PostCode; model.sender = sendmd; Eub_Person revmodel = new Eub_Person(); revmodel.name = ordermd.RevName; revmodel.phone = ordermd.RevPhone; if (ordermd.RevMoblie != null && ordermd.RevMoblie != "") revmodel.mobile = ordermd.RevMoblie.Replace("+", "").Replace("-", "").Replace("/", ""); if (ordermd.RevProvince != null && ordermd.RevProvince != "") revmodel.province = ordermd.RevProvince; if (revmodel.province == null && revmodel.province != "") { revmodel.province = ordermd.RevCity; } string postcode = ordermd.RevPostCode; if (ordermd.RevCountry == "United States" && postcode.Length > 5) { // postcode = Convert.ToInt32(ordermd.RevPostCode.Substring(0, 5).Trim()).ToString(); postcode = ordermd.RevPostCode.Substring(0, 5).Trim(); } else if (ordermd.RevCountry == "Russian Federation" && postcode.Length > 6) { // postcode = Convert.ToInt32(ordermd.RevPostCode.Substring(0, 6).Trim()).ToString(); postcode = ordermd.RevPostCode.Substring(0, 6).Trim(); } revmodel.county = ordermd.RevArea; revmodel.city = ordermd.RevCity; if (ordermd.CountryCode == "UK") ordermd.CountryCode = "GB"; revmodel.country = ordermd.CountryCode; revmodel.street = ordermd.RevAddr.Replace("+", " ").Replace("&", " ").Replace("#", " ").Replace("/", " "); ; revmodel.postcode = postcode; model.receiver = revmodel; Eub_Person collmodel = new Eub_Person(); collmodel.company = companymd.CompanyName; collmodel.email = companymd.Email; collmodel.name = companymd.SendName; collmodel.phone = companymd.Phone; collmodel.province = companymd.province; collmodel.country = "CN"; collmodel.city = companymd.city; collmodel.county = companymd.county; collmodel.street = companymd.Address; collmodel.postcode = companymd.PostCode; model.collect = collmodel; List ListGoods = new List(); if (goodslist != null) { decimal dw = Convert.ToDecimal(0.20); if (goodslist.Count > 10) dw = Convert.ToDecimal(0.10); foreach (var goodsmodel in goodslist) { if (goodsmodel.GoodsName != null && goodsmodel.GoodsName.Length > 30) goodsmodel.GoodsName = goodsmodel.GoodsName.Substring(0, 30); var ListGoodsmd = new Eub_Goods(); ListGoodsmd.cnname = goodsmodel.GoodsName.Replace("+", " ").Replace("&", " ").Replace("#", " ").Replace("/", " "); // if (goodsmodel.GoodsEnglisgName == null || goodsmodel.GoodsEnglisgName == "") ListGoodsmd.enname = goodsmodel.GoodsCode + "-" + goodsmodel.TypeCode + goodsmodel.TypeDesc; // else // ListGoodsmd.enname = goodsmodel.GoodsEnglisgName; ListGoodsmd.count = goodsmodel.GoodsNum.Value; ListGoodsmd.unit = "件"; // if (goodsmodel.GoodsPrice != null && goodsmodel.GoodsNum != null) ListGoodsmd.delcarevalue = 10; //if (goodsmodel.Weight != null) // ListGoodsmd.weight = goodsmodel.Weight.Value / 1000; //else ListGoodsmd.weight = dw; ListGoodsmd.origin = "CN"; ListGoodsmd.description = ""; ListGoods.Add(ListGoodsmd); } } model.ListGoods = ListGoods; PostCode = eub.SendGoods(model, md.CheckCode, out ErrorInfo); } } else if (md.Name == "BPost") //比利时邮政 { if (md.CheckCode != null && md.CheckCode != "" && goodslist != null && goodslist.Count > 0) { //if (companymd == null) //{ // ErrorInfo = "发货地址没选择;"; // return ErrorInfo; //} if (PostCode == null || PostCode == "") { PostCode = obj1.GetGZExpressCodeBP(CompanyId, PostId); } BelgiumApi baobj = new BelgiumApi(); baobj.authenticate = "basic " + Convert.ToBase64String(Encoding.UTF8.GetBytes(string.Format("{0}:{1}", md.UserCode, md.CheckCode))); Belgium_Order bamodel = new Belgium_Order(); bamodel.ContractId = 1; bamodel.OrderNumber = ordermd.PlatOrderCode; bamodel.ProductBarcode = PostCode; bamodel.RecipientName = ordermd.RevName; bamodel.RecipientStreet = ordermd.RevAddr; bamodel.RecipientHouseNumber = ""; bamodel.RecipientBusnumber = ""; bamodel.RecipientZipCode = ordermd.RevPostCode; bamodel.RecipientCity = ordermd.RevCity; bamodel.RecipientState = ordermd.RevProvince; bamodel.RecipientCountry = ordermd.CountryCode; bamodel.PhoneNumber = ordermd.RevPhone; bamodel.Email = ordermd.RevMail; bamodel.SenderName = companymd.SendEnglishName; bamodel.SenderAddress = companymd.Address; bamodel.SenderSequence = "1"; bamodel.IsSure = true; List bglist = new List(); if (goodslist != null) { foreach (var goodsmodel in goodslist) { Belgium_Goods bgmd = new Belgium_Goods(); bgmd.Sku = goodsmodel.GoodsSKU; bgmd.ChineseContentDescription = goodsmodel.GoodsName; bgmd.ItemContent = goodsmodel.GoodsEnglisgName; if (goodsmodel.GoodsPrice != null && goodsmodel.GoodsPrice.Value > 10) bgmd.Value = 9; else bgmd.Value = 7; bgmd.ItemCount = goodsmodel.GoodsNum.Value; bgmd.Currency = "USD"; bgmd.Weight = 200; bgmd.SkuInInvoice = ""; bglist.Add(bgmd); } } bamodel.Customs = bglist; PostCode = baobj.SendGoods(bamodel, baobj.authenticate, out ErrorInfo); if (ErrorInfo != "") PostCode = ""; } } else if (md.LogisticsName == "SF Express") //顺丰 { if (md.CheckCode != null && md.CheckCode != "" && goodslist != null && goodslist.Count > 0) { sfApi sfobj = new sfApi(); sf_Order model = new sf_Order(); if (md.Name == "顺丰E宝挂号" || md.Name == "顺丰E宝平邮") { if (md.operationtype != null) model.express_type = md.operationtype.Value.ToString(); else model.express_type = "9"; } else if (md.Name == "顺丰美国") { model.express_type = "A9"; } else if (md.Name == "顺丰欧洲") { model.express_type = "A2"; } model.d_tel = ordermd.RevPhone; model.d_company = ordermd.RevName; model.d_contact = ordermd.RevName; model.d_address = ordermd.RevAddr; model.orderid = ordermd.PlatOrderCode; model.d_county = ordermd.RevArea; model.d_city = ordermd.RevCity; model.d_post_code = ordermd.RevPostCode; model.d_deliverycode = ordermd.CountryCode; model.d_province = ordermd.RevProvince; model.d_country = ordermd.RevCountry; model.cargo_total_weight = 1; //Convert.ToDecimal(ordermd.TotalWeight) / 1000; model.j_tel = companymd.Phone; model.j_company = companymd.CompanyEnglishName; model.j_province = companymd.province;// "zhejiang province"; model.j_city = companymd.city; //"Ningbo"; model.j_county = companymd.county; model.j_contact = companymd.SendEnglishName; model.j_address = companymd.EnglishAddress; model.j_post_code = companymd.PostCode; model.declared_value = ordermd.TotalPrice; model.declared_value_currency = ordermd.MoneyCode; model.parcel_quantity = 1; model.pay_method = 1; model.custid = md.customercode;//"7551878519"; model.cargo_length = 60; model.cargo_width = 60; model.cargo_height = 60; List ListGoods = new List(); if (goodslist != null) { foreach (var goodsmodel in goodslist) { var ListGoodsmd = new sf_Goods(); if (goodsmodel.GoodsEnglisgName != null && goodsmodel.GoodsEnglisgName != "") { ListGoodsmd.ename = goodsmodel.GoodsEnglisgName; } else { ListGoodsmd.ename = "dress"; } ListGoodsmd.name = goodsmodel.GoodsName; ListGoodsmd.count = goodsmodel.GoodsNum.Value; ListGoodsmd.unit = "piece"; if (goodsmodel.Weight != null) ListGoodsmd.weight = goodsmodel.Weight.Value; else ListGoodsmd.weight = 100; //if (goodsmodel.GoodsPrice != null) ListGoodsmd.amount = goodsmodel.GoodsPrice.GetValueOrDefault(10); ListGoodsmd.currency = "USD"; ListGoodsmd.source_area = "China"; ListGoods.Add(ListGoodsmd); } } model.ListGoods = ListGoods; sfobj.UserCode = md.UserCode; sfobj.CheckCode = md.CheckCode; if (md.Name == "顺丰E宝挂号" || md.Name == "顺丰E宝平邮") { PostCode = sfobj.SendGoods(model, out ErrorInfo); } if (md.Name == "顺丰美国" || md.Name == "顺丰欧洲") { PostCode = sfobj.SendOU(model, out ErrorInfo); } } } else if (md.Name == "顺丰国际挂号(美国)" || md.Name == "顺丰国际挂号(澳大利亚)" || md.Name == "顺丰国际挂号(其它)") //顺丰 { if (md.CheckCode != null && md.CheckCode != "" && goodslist != null && goodslist.Count > 0) { sfApi sfobj = new sfApi(); sf_Order2 model = new sf_Order2(); model.express_type = "E2"; model.d_tel = ordermd.RevPhone; model.d_company = ordermd.RevName; model.d_contact = ordermd.RevName; model.d_address = ordermd.RevAddr; model.orderid = ordermd.PlatOrderCode; model.d_city = ordermd.RevCity; model.d_post_code = ordermd.RevPostCode; model.d_province = ordermd.RevProvince; model.d_country = ordermd.RevCountry; model.cargo_total_weight = 1; //Convert.ToDecimal(ordermd.TotalWeight) / 1000; model.j_tel = companymd.Phone; model.j_company = companymd.CompanyEnglishName; model.j_province = "zhejiang";// "zhejiang province"; model.j_city = "ningbo"; //"Ningbo"; model.j_contact = companymd.SendEnglishName; model.j_address = companymd.EnglishAddress; model.j_post_code = companymd.PostCode; model.parcel_quantity = 1; List ListGoods = new List(); if (goodslist != null) { foreach (var goodsmodel in goodslist) { var ListGoodsmd = new sf_Goods2(); if (goodsmodel.GoodsEnglisgName != null && goodsmodel.GoodsEnglisgName != "") { ListGoodsmd.ename = goodsmodel.GoodsEnglisgName; } else { ListGoodsmd.ename = "dress"; } if (ListGoodsmd.ename.Length > 25) ListGoodsmd.ename = ListGoodsmd.ename.Substring(0, 24); ListGoodsmd.name = goodsmodel.GoodsName; if (ListGoodsmd.name.Length > 25) ListGoodsmd.name = ListGoodsmd.name.Substring(0, 24); ListGoodsmd.count = goodsmodel.GoodsNum.Value; //ListGoodsmd.unit = "piece"; //if (goodsmodel.Weight != null) // ListGoodsmd.weight = goodsmodel.Weight.Value; //else // ListGoodsmd.weight = 100; //if (goodsmodel.GoodsPrice != null) //if (goodsmodel.GoodsPrice != null && goodsmodel.GoodsPrice < 10) // ListGoodsmd.amount = goodsmodel.GoodsPrice.Value; //else ListGoodsmd.amount = 10; //ListGoodsmd.currency = "USD"; // ListGoodsmd.source_area = "China"; ListGoods.Add(ListGoodsmd); } } model.ListGoods = ListGoods; sfobj.UserCode = md.UserCode; sfobj.CheckCode = md.CheckCode; PostCode = sfobj.SendGoods2(model, out ErrorInfo); if (ErrorInfo != "") PostCode = ""; } } else if (md.Name == "德邮小包" || md.Name == "DHL中英专线") { PostCode = obj1.GetGZExpressCodeDY(CompanyId, PostId); } else if (md.Name.Contains("DHL")) { if (md.client_id != null && md.client_id != "" && goodslist != null && goodslist.Count > 0) { DHLApi dhlobj = new DHLApi(); DHLOrder dhlmodel = new DHLOrder(); dhlobj.clientId = md.client_id; //"LTExMTgwNTI4MTY="; dhlobj.GetTime = md.GetTime; dhlobj.password = md.client_secret; //"APITest1"; dhlobj.AccessToken = md.UserCode; dhlobj.token_type = md.CheckCode; labelRequest labelRequest = new labelRequest(); hdr hdr = new hdr(); hdr.messageType = "LABEL"; hdr.messageDateTime = DateTime.Now.ToString("s"); hdr.accessToken = ""; hdr.messageVersion = "1.4"; hdr.messageLanguage = "en"; labelRequest.hdr = hdr; DHL_Order bd = new DHL_Order(); bd.customerAccountId = null; bd.pickupAccountId = md.refresh_token; //"5999999201"; bd.soldToAccountId = md.Code; //"5999999201"; bd.pickupDateTime = DateTime.Now.ToString("s"); pickupAddress pickupAddress = new pickupAddress(); pickupAddress.companyName = "DHL"; pickupAddress.name = "DHL"; pickupAddress.address1 = "china"; pickupAddress.address2 = null; pickupAddress.address3 = null; pickupAddress.city = "china"; pickupAddress.state = "china"; pickupAddress.district = "china"; pickupAddress.country = "CN"; pickupAddress.postCode = "6278"; pickupAddress.phone = "9999"; pickupAddress.email = "test@dhl.com"; bd.pickupAddress = pickupAddress; List shipmentItemslist = new List(); shipmentItems shipmentItems = new shipmentItems(); consigneeAddress consigneeAddress = new consigneeAddress(); string Name = ordermd.RevName; if (Name.Length > 30) Name = Name.Substring(0, 30); consigneeAddress.companyName = Name; consigneeAddress.name = Name; consigneeAddress.address2 = null; consigneeAddress.address3 = null; if (ordermd.RevAddr.Length <= 50) consigneeAddress.address1 = ordermd.RevAddr; else consigneeAddress.address1 = ordermd.RevAddr.Substring(0, 50); if (ordermd.RevAddr.Length > 50 && ordermd.RevAddr.Length <= 100) consigneeAddress.address2 = ordermd.RevAddr.Substring(49, ordermd.RevAddr.Length - 50); else if (ordermd.RevAddr.Length > 100 && ordermd.RevAddr.Length <= 150) consigneeAddress.address3 = ordermd.RevAddr.Substring(99, ordermd.RevAddr.Length - 100); consigneeAddress.city = ordermd.RevCity; consigneeAddress.state = ordermd.RevProvince; consigneeAddress.district = null; consigneeAddress.country = ordermd.CountryCode; consigneeAddress.postCode = ordermd.RevPostCode; consigneeAddress.phone = ordermd.RevPhone; consigneeAddress.email = null; consigneeAddress.idNumber = "9999"; consigneeAddress.idType = "1"; shipmentItems.consigneeAddress = consigneeAddress; returnAddress returnAddress = new returnAddress(); returnAddress.companyName = "MHSG"; returnAddress.name = companymd.SendEnglishName; if (companymd.Address != null && companymd.Address.Length < 50) returnAddress.address1 = companymd.Address; else if (companymd.Address != null) returnAddress.address1 = companymd.Address.Substring(0, 49); returnAddress.address2 = null; returnAddress.address3 = null; returnAddress.city = "ningbo"; returnAddress.state = "zhejiang"; returnAddress.district = "zhenhai"; returnAddress.country = "CN"; returnAddress.postCode = "315000"; returnAddress.phone = companymd.Phone; shipmentItems.returnAddress = returnAddress; shipmentItems.shipmentID = "CNAEV543" + ordermd.OrderId.ToString(); shipmentItems.deliveryConfirmationNo = null; shipmentItems.packageDesc = "Desc"; shipmentItems.totalWeightUOM = "G"; shipmentItems.dimensionUOM = "cm"; shipmentItems.height = Convert.ToDecimal(0.1); shipmentItems.length = Convert.ToDecimal(0.1); shipmentItems.width = Convert.ToDecimal(0.1); shipmentItems.customerReference1 = null; shipmentItems.customerReference2 = null; shipmentItems.productCode = "PPS"; shipmentItems.incoterm = "DDU"; shipmentItems.contentIndicator = "01"; shipmentItems.codValue = null; shipmentItems.insuranceValue = null; shipmentItems.freightCharge = Convert.ToDecimal(0.1); shipmentItems.currency = "USD"; List shipmentContentsList = new List(); int TNum = 0; foreach (var gmd in goodslist) { TNum += gmd.GoodsNum.Value; } decimal tj = Convert.ToDecimal(5.5); decimal dj = Convert.ToDecimal(5.5); if (TNum > 1 && TNum <= 5) { tj = Convert.ToDecimal(2.1 * TNum); dj = Convert.ToDecimal(2.1); } else if (TNum > 5) { tj = Convert.ToDecimal(1.1 * TNum); dj = Convert.ToDecimal(1.1); } foreach (var gmd in goodslist) { shipmentContents shipmentContents = new shipmentContents(); shipmentContents.skuNumber = gmd.GoodsSKU; if (gmd.GoodsSKU == null && gmd.GoodsSKU.Length > 50) shipmentContents.skuNumber = "DEC001"; if (gmd.GoodsEnglisgName != null && gmd.GoodsEnglisgName != "" && gmd.GoodsEnglisgName.Length < 50) { shipmentContents.description = gmd.GoodsEnglisgName; shipmentContents.descriptionImport = gmd.GoodsEnglisgName; } else { shipmentContents.description = "cloth"; shipmentContents.descriptionImport = "cloth"; } if (gmd.GoodsName.Length < 50) shipmentContents.descriptionExport = gmd.GoodsName; else shipmentContents.descriptionExport = gmd.GoodsName.Substring(0, 49); shipmentContents.itemValue = dj; shipmentContents.itemQuantity = gmd.GoodsNum.Value; shipmentContents.grossWeight = 100; shipmentContents.netWeight = 100; shipmentContents.weightUOM = "g"; shipmentContents.contentIndicator = "01"; shipmentContents.countryOfOrigin = "CN"; shipmentContents.hsCode = null; shipmentContentsList.Add(shipmentContents); shipmentItems.shipmentContents = shipmentContentsList; shipmentItemslist.Add(shipmentItems); } shipmentItems.totalValue = tj; shipmentItems.totalWeight = Convert.ToDecimal(100 * 1.00 * TNum); bd.shipmentItems = shipmentItemslist; label label = new label(); label.pageSize = "400x600"; label.format = "PDF"; label.layout = "4x1"; bd.label = label; labelRequest.bd = bd; dhlmodel.labelRequest = labelRequest; PostCode = dhlobj.SendGoods(dhlmodel, out ErrorInfo); } } else if (md.Name.Contains("Fedex")) { if (md.UserCode != null && md.UserCode != "" && goodslist != null && goodslist.Count > 0) { Fedex fedexobj = new Fedex(); Fedex.Key = md.UserCode;// "ENsVAGUr9UIGx7Uj"; Fedex.Password = md.CheckCode; //"o7j1X19OxhxWqwb9gMTDEGYfE"; Fedex.AccountNumber = md.client_id;// "510087160"; Fedex.MeterNumber = md.client_secret;//"118810402"; Fedex.PayAccountNumber = md.refresh_token;//"510087160"; FedexOrder fedexmd = new FedexOrder(); Shiper shipmd = new Shiper(); shipmd.City = companymd.city;// "Harrison"; shipmd.CompanyName = companymd.SendEnglishName;//"chu"; shipmd.PersonName = companymd.SendEnglishName;//"chu"; shipmd.PhoneNumber = companymd.Phone;//"0805522713"; shipmd.PostalCode = companymd.PostCode;// "72601"; shipmd.StateOrProvinceCode = companymd.provincecode;// "AR"; shipmd.StreetLines = companymd.EnglishAddress;// "1202 Chalet Ln"; shipmd.CountryCode = companymd.countycode;// "US"; fedexmd.Shiper = shipmd; fedexmd.CustomerTransactionId = ordermd.PlatOrderCode; Rever Revmd = new Rever(); Revmd.City = ordermd.RevCity;// "Harrison"; Revmd.CompanyName = ordermd.RevName; //"Jack"; Revmd.PersonName = ordermd.RevName;// "Jack"; Revmd.PhoneNumber = ordermd.RevPhone;// "9012637906"; Revmd.PostalCode = ordermd.RevPostCode;// "72601"; if (ordermd.RevProvince == null || ordermd.RevProvince == "") Revmd.StateOrProvinceCode = ordermd.RevCity;// "AR"; else Revmd.StateOrProvinceCode = ordermd.RevProvince;// "AR"; Revmd.StreetLines = ordermd.RevAddr; //"1806 Chalet Ln"; Revmd.CountryCode = ordermd.CountryCode; //"US"; fedexmd.Rever = Revmd; List fedlist = new List(); foreach (var gmd in goodslist) { FedexGoods fedGd = new FedexGoods(); fedGd.Amount = 10.000M; fedGd.Description = "ABC001-002 white shirt [NB2][1]"; fedGd.NumberOfPieces = "1"; fedGd.Weight = 0.2M; fedGd.Quantity = 1; fedlist.Add(fedGd); } fedexmd.GoodsList = fedlist; Fedex.ormd = fedexmd; PostCode = fedexobj.GetFedex(out ErrorInfo); } } else if (md.Name.StartsWith("CNE")) { string postmessage = "{\"RequestName\":\"TimeStamp\"}"; string error = ""; CNE cneobj = new CNE(); string timeinfo = cneobj.SendGoods(postmessage, out error); JavaScriptSerializer JsonConvert = new JavaScriptSerializer(); CNE_Result model = JsonConvert.Deserialize(timeinfo); string code = NetLibrary.Safety.CryptoPublic.Md5For32(md.UserCode + model.ReturnValue + md.CheckCode); var cnemd = new CNE_Order(); cnemd.RequestName = "PreInputSet"; cnemd.icID = md.UserCode; cnemd.TimeStamp = model.ReturnValue; cnemd.MD5 = code; List RecList = new List(); var recmd = new CNE_Reve(); recmd.iID = "0"; recmd.nItemType = 1; recmd.cRNo = ordermd.PlatOrderCode; recmd.cDes = ordermd.CountryName; recmd.cEmsKind = md.customercode; recmd.fWeight = 0; recmd.cReceiver = ordermd.RevName; recmd.cREMail = ""; recmd.cRAddr = ordermd.RevAddr; recmd.cRCity = ordermd.RevCity; recmd.cRProvince = ordermd.RevProvince; recmd.cRCountry = ordermd.RevCountry; recmd.cRPhone = ordermd.RevPhone; recmd.cRPostcode = ordermd.RevPostCode; var glist = new List(); if (goodslist != null) { foreach (var goodsmodel in goodslist) { if (goodsmodel.GoodsName != null && goodsmodel.GoodsName.Length > 30) goodsmodel.GoodsName = goodsmodel.GoodsName.Substring(0, 30); var gmd = new CNE_Goods(); gmd.cxGoods = goodsmodel.GoodsName; if (goodsmodel.GoodsEnglisgName != null && goodsmodel.GoodsEnglisgName != "") gmd.cxGoodsA = goodsmodel.GoodsEnglisgName; else gmd.cxGoodsA = "cloth"; if (gmd.cxGoodsA.Length > 20) gmd.cxGoodsA = gmd.cxGoodsA.Substring(0, 20); gmd.fxPrice = 10; gmd.ixQuantity = goodsmodel.GoodsNum.Value; gmd.cxGCodeA = goodsmodel.GoodsSKU; glist.Add(gmd); recmd.GoodsList = glist; RecList.Add(recmd); } } cnemd.RecList = RecList; PostCode = cneobj.SendGoods2(cnemd, out ErrorInfo); } else if (md.Name.Contains("Wish")) { if (md.CheckCode != null && md.CheckCode != "" && goodslist != null && goodslist.Count > 0) { //WishYouApi wya = new WishYouApi(); //wya.api_key = md.UserCode; //wya.bid = 0; //wya.zx_type = 6; //wya.guid = ordermd.OrderId.ToString(); //if (md.Name == "Wish挂号") // wya.otype = "1"; //if (md.Name == "Wish平邮") // wya.otype = "0"; //if (md.Name == "DLP平邮") // wya.otype = "9-0"; //if (md.Name == "DLP挂号") // wya.otype = "9-1"; //if (md.Name == "Wish-E邮宝") // wya.otype = "11-0"; //companymd = obj1.GetSendAddress(CompanyId); //wya.from = companymd.SendName; //wya.sender_addres = companymd.SendEnglishName; //wya.sender_city = companymd.city; //wya.sender_province = companymd.province; //wya.sender_phone = companymd.Phone; //wya.CustomName = ordermd.RevName; //wya.to_local = ordermd.RevName; //wya.recipient_addres = ordermd.RevAddr.Replace("+", " ").Replace("&", " ").Replace("#", " ").Replace("/", " "); ; //wya.recipient_addres_local = ordermd.RevAddr.Replace("+", " ").Replace("&", " ").Replace("#", " ").Replace("/", " "); ; //wya.recipient_country_short = ordermd.CountryCode; //wya.recipient_country_local = ordermd.RevCountry; //wya.recipient_province = ordermd.RevProvince; //wya.recipient_province_local = ordermd.RevProvince; //wya.recipient_city = ordermd.RevCity; //wya.recipient_city_local = ordermd.RevCity; //wya.recipient_postcode = ordermd.RevPostCode; //string phone = ""; //if (ordermd.RevMoblie != null) //{ // if (ordermd.RevMoblie.Length > 5) // { // phone = ordermd.RevMoblie; // } //} //if (phone == "") phone = ordermd.RevPhone; //wya.recipient_phone = phone; //string content = ""; //int totalnum = 0; //decimal totalweight = 0;// ordermd.TotalWeight.Value; //var totalprice = ordermd.TotalPrice.Value; //if (goodslist != null) //{ // foreach (var goodsmodel in goodslist) // { // totalweight += Convert.ToDecimal(goodsmodel.Weight.GetValueOrDefault(100) / 1000); // if (goodsmodel.GoodsEnglisgName != "") // { // content += goodsmodel.GoodsEnglisgName + ";"; // } // else // { // content += "dress;"; // } // totalnum += goodsmodel.GoodsNum.Value; // } //} //wya.content = content; //wya.type_no = 1; //wya.weight = totalweight.ToString(); //wya.num = totalnum; //wya.price = totalprice.ToString(); //wya.from_country = "China"; //wya.user_desc = ordermd.PlatOrderCode; //wya.trande_no = ordermd.PlatOrderCode; //wya.trade_amount = totalprice.ToString(); //PostCode = wya.SendGood(wya); WishYouApi2 wya = new WishYouApi2(); wya.ExpressId = md.ExpressID; wya.client_id = md.client_id; wya.client_secret = md.client_secret; wya.redirect_uri = md.redirect_uri; wya.refresh_token = md.refresh_token; wya.code = md.Code; wya.GetTime = md.GetTime; wya.access_token = md.UserCode; wya.bid = 0; wya.mark = ""; wya.guid = ordermd.OrderId.ToString(); if (md.Name == "Wish挂号") wya.otype = "1"; if (md.Name == "Wish平邮") wya.otype = "0"; if (md.Name == "DLP平邮") wya.otype = "9-0"; if (md.Name == "DLP挂号") wya.otype = "9-1"; if (md.Name == "Wish-E邮宝") wya.otype = "11-0"; if (md.customercode != null && md.customercode != "") wya.otype = md.customercode; // companymd = obj1.GetSendAddress(CompanyId); wya.from = companymd.SendName; //"Stella Xu"; wya.sender_addres = companymd.SendEnglishName;// "ChangxingRoad689"; wya.sender_city = companymd.citycode; //"Ningbo"; wya.sender_province = companymd.provincecode;// "Zhejiang"; wya.sender_phone = companymd.Phone;// "13456152202"; wya.to = ordermd.RevName; wya.to_local = ordermd.RevName; wya.recipient_country = ordermd.RevCountry; wya.recipient_addres = ordermd.RevAddr.Replace("+", " ").Replace("&", " ").Replace("#", " ").Replace("/", " "); ; wya.recipient_addres_local = ordermd.RevAddr.Replace("+", " ").Replace("&", " ").Replace("#", " ").Replace("/", " "); ; wya.recipient_country_short = ordermd.CountryCode; wya.recipient_country_local = ordermd.RevCountry; if (ordermd.RevProvince == null || ordermd.RevProvince == "") { wya.recipient_province = ordermd.RevCity; wya.recipient_province_local = ordermd.RevCity; } else { wya.recipient_province = ordermd.RevProvince; wya.recipient_province_local = ordermd.RevProvince; } wya.recipient_city = ordermd.RevCity; wya.recipient_city_local = ordermd.RevCity; wya.recipient_postcode = ordermd.RevPostCode; string phone = ""; if (ordermd.RevMoblie != null) { if (ordermd.RevMoblie.Length > 5) { phone = ordermd.RevMoblie; } } if (phone == "") phone = ordermd.RevPhone; wya.recipient_phone = phone; string content = ""; int totalnum = 0; decimal totalweight = 0;// ordermd.TotalWeight.Value; var totalprice = ordermd.TotalPrice.Value; string contentdesc = ""; string contentname = "货物"; if (goodslist != null) { foreach (var goodsmodel in goodslist) { if (goodsmodel.GoodsName != null && goodsmodel.GoodsName != "") contentname = goodsmodel.GoodsName; totalweight += Convert.ToDecimal(goodsmodel.Weight.GetValueOrDefault(100) / 1000); if (goodsmodel.GoodsEnglisgName != "") { content += goodsmodel.GoodsEnglisgName + ";"; } else { content += "dress;"; } totalnum += goodsmodel.GoodsNum.Value; contentdesc += goodsmodel.GoodsCode + "-" + goodsmodel.TypeCode + goodsmodel.TypeDesc + "[" + goodsmodel.GoodsNum.ToString() + "];"; } } if (contentname.Length > 49) contentname = contentname.Substring(0, 40); wya.content_chinese = contentname; wya.content = contentdesc; wya.type_no = 1; wya.weight = totalweight.ToString(); wya.num = totalnum; wya.single_price = totalprice.ToString(); wya.warehouse_code = md.operationtype.ToString();//仓库 "13"; wya.doorpickup = ""; if (md.vipcode == "1") //上门揽货 wya.doorpickup = "1"; wya.has_battery = ""; if (md.clcttype == 1) wya.has_battery = "1";//含电池 wya.from_country = "China"; wya.user_desc = contentdesc;// ordermd.PlatOrderCode; wya.receive_from = companymd.ChargeName;// "ChangxingRoad689"; wya.receive_city = companymd.Shen; //"Ningbo"; wya.receive_province = companymd.Shi;// "Zhejiang"; wya.receive_phone = companymd.Phone;// "13456152202"; wya.receive_addres = companymd.Address;// "13456152202"; wya.trande_no = ordermd.PlatOrderCode; wya.trade_amount = totalprice.ToString(); PostCode = wya.SendGood(wya); } } //else if (md.Name.Contains("递四方")) //{ // if (md.CheckCode != null && md.CheckCode != "" && goodslist != null && goodslist.Count > 0) // { // try // { // pxserver.OrderOnlineServiceClient opx = new pxserver.OrderOnlineServiceClient(); // opx.Open(); // pxserver.createAndPreAlertOrderRequest[] rq = new pxserver.createAndPreAlertOrderRequest[1]; // pxserver.createAndPreAlertOrderRequest rq1 = new pxserver.createAndPreAlertOrderRequest(); // rq1.consigneeName = ordermd.RevName;// "jack"; // rq1.consigneePostCode = ordermd.RevPostCode;// "72601"; // rq1.consigneeTelephone = ordermd.RevPhone;// "0805522713"; // if (ordermd.RevPhone == null || ordermd.RevPhone == "") // rq1.consigneeTelephone = ordermd.RevMoblie; // rq1.city = ordermd.RevCity;// "Harrison"; // if (ordermd.RevCity == null || ordermd.RevCity == "") // rq1.city = ordermd.RevProvince; // rq1.stateOrProvince = ordermd.RevProvince;// "AR"; // if (ordermd.RevProvince == null || ordermd.RevProvince == "") // rq1.stateOrProvince = ordermd.RevCity; // rq1.street = ordermd.RevAddr;//"1202 Chalet Ln1"; // rq1.orderNo = ordermd.PlatOrderCode;// "5958d6a19ca1e531230ec8c5"; // if (rq1.orderNo.Length > 20) // rq1.orderNo = rq1.orderNo.Substring(0, 20); // rq1.shipperAddress = companymd.EnglishAddress;// "haishu"; // rq1.shipperCity = companymd.city;// "ningbo"; // rq1.shipperCompanyName = companymd.SendName;// "chu"; // rq1.shipperName = companymd.SendName;// "chu"; // rq1.shipperPostCode = "315000"; // rq1.initialCountryCode = "CN"; // rq1.destinationCountryCode = ordermd.CountryCode;// "US"; // rq1.productCode = md.customercode;//渠道 "B1"; // if (md.Name.Contains("电")) // rq1.hasBattery = "Y"; // else // rq1.hasBattery = "N"; // rq1.returnSign = "Y"; // pxserver.declareInvoice[] gmd = new pxserver.declareInvoice[goodslist.Count]; // int idx = 0; // int gmx = 0; // foreach (var ggmd in goodslist) // { // pxserver.declareInvoice md1 = new pxserver.declareInvoice(); // md1.cName = ggmd.GoodsName; // md1.declareNote = ggmd.GoodsCode + "-" + ggmd.TypeCode + ggmd.TypeDesc; // md1.declarePieces = ggmd.GoodsNum.Value.ToString(); // md1.unitPrice = "5"; // md1.name = "衣服"; // md1.eName = "cloth"; // gmd[idx] = md1; // gmx += ggmd.GoodsNum.Value; // idx++; // } // rq1.declareInvoice = gmd; // rq1.pieces = gmx.ToString(); // rq[0] = rq1; // pxserver.createAndPreAlertOrderResponse[] rp = new pxserver.createAndPreAlertOrderResponse[1]; // rp = opx.createAndPreAlertOrderService(md.CheckCode, rq); // if (rp[0].ack == "Success") // { // PostCode = rp[0].trackingNumber; // } // else // { // ErrorInfo = "失败" + rp[0].errors[0].cnMessage + rp[0].errors[0].cnAction + rp[0].errors[0].defineMessage; // } // opx.Close(); // } // catch (Exception ex) // { // ErrorInfo = "失败" + ex.Message; // } // } //} else if (md.Name.StartsWith("CNE")) { string postmessage = "{\"RequestName\":\"TimeStamp\"}"; string error = ""; CNE cneobj = new CNE(); string timeinfo = cneobj.SendGoods(postmessage, out error); JavaScriptSerializer JsonConvert = new JavaScriptSerializer(); CNE_Result model = JsonConvert.Deserialize(timeinfo); string code = NetLibrary.Safety.CryptoPublic.Md5For32(md.UserCode + model.ReturnValue + md.CheckCode); var cnemd = new CNE_Order(); cnemd.RequestName = "PreInputSet"; cnemd.icID = md.UserCode; cnemd.TimeStamp = model.ReturnValue; cnemd.MD5 = code; List RecList = new List(); var recmd = new CNE_Reve(); recmd.iID = "0"; recmd.nItemType = 1; recmd.cRNo = ordermd.PlatOrderCode; recmd.cDes = ordermd.CountryName; recmd.cEmsKind = md.customercode; recmd.fWeight = 0; recmd.cReceiver = ordermd.RevName; recmd.cREMail = ""; recmd.cRAddr = ordermd.RevAddr; recmd.cRCity = ordermd.RevCity; recmd.cRProvince = ordermd.RevProvince; recmd.cRCountry = ordermd.RevCountry; recmd.cRPhone = ordermd.RevPhone; recmd.cRPostcode = ordermd.RevPostCode; var glist = new List(); if (goodslist != null) { foreach (var goodsmodel in goodslist) { if (goodsmodel.GoodsName != null && goodsmodel.GoodsName.Length > 30) goodsmodel.GoodsName = goodsmodel.GoodsName.Substring(0, 30); var gmd = new CNE_Goods(); gmd.cxGoods = goodsmodel.GoodsName; if (goodsmodel.GoodsEnglisgName != null && goodsmodel.GoodsEnglisgName != "") gmd.cxGoodsA = goodsmodel.GoodsEnglisgName; else gmd.cxGoodsA = "cloth"; if (gmd.cxGoodsA.Length > 20) gmd.cxGoodsA = gmd.cxGoodsA.Substring(0, 20); gmd.fxPrice = 10; gmd.ixQuantity = goodsmodel.GoodsNum.Value; gmd.cxGCodeA = goodsmodel.GoodsSKU; glist.Add(gmd); recmd.GoodsList = glist; RecList.Add(recmd); } } cnemd.RecList = RecList; PostCode = cneobj.SendGoods2(cnemd, out ErrorInfo); } else if (md.LogisticsId == 67) { PostCode = OnewordCreate2(md, ordermd, goodslist); } else if (md.Name.Contains("燕文") || md.Name == "燕邮宝平邮") { if (md.CheckCode != null && md.CheckCode != "" && goodslist != null && goodslist.Count > 0) { YanWenApi ywa = new YanWenApi(); ywa.CheckCode = md.CheckCode; ywa.UserCode = md.UserCode; YW_Order model = new YW_Order(); model.Channel = md.customercode; if (md.Name == "燕文上海平邮" || md.Name == "燕文宁波平邮") { model.Channel = "中邮上海平邮小包"; } if (md.Name == "燕文北京平邮") { model.Channel = "中邮北京平邮小包"; } if (md.Name == "燕文上海小包" || md.Name == "燕文宁波小包") { model.Channel = "中邮上海挂号小包"; } if (md.Name.Contains("燕文德邮")) { model.Channel = "德国邮政挂号小包(上海)"; } if (md.Name.Contains("燕文荷兰挂号(电)")) { model.Channel = "荷兰邮政挂号小包(含电)"; } if (md.Name.Contains("燕文上海E邮宝")) { model.Channel = "中邮上海E邮宝(线下)"; } if (md.Name.Contains("燕文马来西亚邮政平邮小包")) { model.Channel = "马来西亚邮政平邮小包(新)"; } model.orderid = ordermd.PlatOrderCode; model.d_address = ordermd.RevAddr.Replace("+", " ").Replace("&", " ").Replace("#", " ").Replace("/", " "); model.d_City = ordermd.RevCity; model.d_contact = ordermd.RevName; model.d_country = ordermd.CountryName; model.d_email = ordermd.RevMail; model.d_mobile = ordermd.RevMoblie; model.d_postcode = ordermd.RevPostCode; model.d_State = ordermd.RevProvince; model.d_tel = ordermd.RevPhone; model.delcarevalue = 5; string contentdesc = ""; string contentdesc2 = ""; int GoodsNum = 0; int IsMore = 0; if (goodslist != null) { foreach (var goodsmodel in goodslist) { IsMore++; GoodsNum += goodsmodel.GoodsNum.Value; contentdesc2 += goodsmodel.GoodsCode + "-" + goodsmodel.TypeCode + "" + goodsmodel.TypeDesc.Replace("+", " ").Replace("&", " ").Replace("#", " ").Replace("/", " ") + "[" + goodsmodel.GoodsNum.ToString() + "];"; contentdesc += goodsmodel.GoodsCode + "-" + goodsmodel.TypeCode + goodsmodel.TypeDesc + "[" + goodsmodel.GoodsNum.ToString() + "];"; } } model.GoodsNum = GoodsNum; model.delcarevalue = 5; if (IsMore > 1) contentdesc2 = "[MORE]" + contentdesc2; if (contentdesc2.Length > 195) contentdesc2 = contentdesc2.Substring(0, 195); if (IsMore > 1) model.cnname = goodslist.First().GoodsName.Replace("+", " ").Replace("&", " ").Replace("#", " ").Replace("/", " ") + " 多个"; else model.cnname = goodslist.First().GoodsName.Replace("+", " ").Replace("&", " ").Replace("#", " ").Replace("/", " "); model.enname = contentdesc2; // model.Memo = contentdesc; // if (contentdesc.Length > 50) // model.Memo = contentdesc2; model.MoreGoodsName = contentdesc; model.weight = 100; PostCode = ywa.GetTrackCode(model); } } else if (md.Name.Contains("淼信")) { if (md.Name == "淼信俄罗斯") { MiaoXinApi mxobj = new MiaoXinApi(); MiaoXin_Order model = new MiaoXin_Order(); model.buyerid = ""; model.consignee_address = ordermd.RevAddr; model.consignee_city = ordermd.RevCity; model.consignee_mobile = ""; model.consignee_name = ordermd.RevName; model.consignee_postcode = ordermd.RevPostCode; model.consignee_state = "Other"; model.consignee_telephone = ordermd.RevPhone; model.country = "RU"; model.customer_id = md.UserCode; model.customer_userid = md.CheckCode; model.order_customerinvoicecode = ordermd.PlatOrderCode; model.product_id = "3861"; model.trade_type = "ZYXT"; model.weight = ""; List GoodsList = new List(); if (goodslist != null) { foreach (var goodsmodel in goodslist) { MiaoXin_Goods model2 = new MiaoXin_Goods(); model2.invoice_amount = "5"; model2.invoice_pcs = goodsmodel.GoodsNum.ToString(); model2.invoice_title = goodsmodel.GoodsEnglisgName; model2.invoice_weight = "100"; model2.item_id = ""; model2.item_transactionid = ""; model2.sku = goodsmodel.GoodsName; GoodsList.Add(model2); } } model.orderInvoiceParam = GoodsList; PostCode = mxobj.SendGoods(model, out ErrorInfo); } } } } catch (Exception ex) { ErrorInfo += ex.Message; } } if (PostCode != null && PostCode != "" && !PostCode.Contains("失败")) { DT_TrackCodeApply Model = new DT_TrackCodeApply(); if (PostCode.Contains(',')) { string[] tracklist = PostCode.Split(','); if (tracklist.Length > 1) { Model.TrackCode = tracklist[0].ToString(); Model.TrackCode2 = tracklist[1].ToString(); } } else { Model.TrackCode = PostCode; } //if (md.LogisticsId != null) //{ // if (md.LogisticsId > 0) // { // if (CheckWuliu(md.LogisticsId.GetValueOrDefault(0), Model.TrackCode) == 1) // { // return ""; // } // } //} Model.GetDate = DateTime.Now; Model.InName = Session["Name"].ToString(); if (ordermd.JoinOrderCode != null && ordermd.JoinOrderCode != "") Model.OrderCode = ordermd.JoinOrderCode; else Model.OrderCode = ordermd.PlatOrderCode; Model.OrderId = ordermd.OrderId; Model.PostId = PostId; Model.State = 1; Model.TrackType = 1; Model.UpdateTime = DateTime.Now; Model.IsSpare = 0; Model.JoinOrderCode = ordermd.JoinOrderCode; plist.Add(Model); //obj.UpdateTrackCode(PostCode, PostId,OrderId, ErrorInfo); //obj.SaveTrackCodeApply2(Model); } else //if (md.PostType != 4) //线上发货的除外 { // ErrorFollow.TraceWrite("GetOrderPostCode", "物流id:" + PostId.ToString() + ";订单号:" + PlatCode + "获取跟踪码错误", ErrorInfo); //ErrorInfo += "未获取到跟踪码"; var emd = new DT_TrackCodeApply(); emd.OrderId = ordermd.OrderId; emd.PostError = "未获取到跟踪码"; plist.Add(emd); ErrorInfo += ordermd.PlatOrderCode + "未获取到跟踪码"; // obj.UpdateTrackCodeError2(OrderId, PostId, "获取到跟踪码失败"); } //if (PostCode != null && PostCode != "" && !PostCode.Contains("失败")) //{ // TrackCode = PostCode; // return ""; //} //else // return PlatCode + "的订单" + ErrorInfo + " " + PostCode; } if (plist != null && plist.Count > 0) { foreach (var pmd in plist) { try { if (pmd.TrackCode != null) { if (pmd.TrackCode != "") obj.SaveTrackCodeApply3(LogisticsId, PostId, pmd); } } catch { System.Threading.Thread.Sleep(1000); } } } if (ErrorInfo == "") return "获取成功"; else return ErrorInfo; } #endregion #region 获取物流单号3 public string GetOrderPostCode3(int LogisticsId, int PostId, string OrderIds) { string ErrorInfo = ""; try { var obj = new DD_OrderData(); Pages.Login(this.Session); if (OrderIds == "") return "没有选择订单"; int CompanyId = Convert.ToInt32(Session["CompanyId"]); var companymd = new JC_PostAddress(); var obj1 = new JC_ExpressService(); var obj11 = new BaseService(); companymd = obj11.GetAddressModel(CompanyId); if (companymd == null) { ErrorInfo = "发货地址没选择;"; return ErrorInfo; } var md = obj1.GetExpressModel(CompanyId, PostId); var plist = new List(); //var elist = new List(); var orderlist = obj.GetOrderModelList(OrderIds.Trim(',')); var orderGoodslist = obj.GetOrderGoodsList2(OrderIds.Trim(',')); if (orderlist == null || orderlist.Count == 0) return "没有选择订单"; //string PostCode = ""; var obj2 = new BaseService(); if (md == null) return ""; foreach (var ordermd in orderlist) { if (ordermd.JoinOrderCode != null) { if (plist.Where(o => o.JoinOrderCode == ordermd.JoinOrderCode).Count() > 0) { continue; } } string PostCode = ""; if (md.CheckCode == null || md.CheckCode == "") { PostCode = obj1.GetInnerExpressCode(CompanyId, PostId); } else { try { List goodslist = new List(); //var ordermd = obj.GetOrderModel(OrderId); if (ordermd.JoinOrderCode != null && ordermd.JoinOrderCode != "")//合并订单 { goodslist = obj.GetOrderGoodsDetailListForJoin(ordermd.JoinOrderCode); } else { if (orderGoodslist != null && orderGoodslist.Count > 0) { goodslist = orderGoodslist.FindAll(n => n.OrderId == ordermd.OrderId); } } string ordercode = ordermd.PlatOrderCode; if (md != null && ordermd != null) { if (md.PostType == 1) //EUB { if (md.CheckCode != null && md.CheckCode != "" && goodslist != null && goodslist.Count > 0) { if (md.Name == "EUB" && ordermd.CountryCode != "US") { return "国家不支持"; } if (md.Name.Contains("美国") == true && ordermd.CountryCode != "US") { return "国家不支持"; } if (md.Name == "EUB上海" && ordermd.CountryCode != "US") { return "国家不支持"; } if (md.Name == "EUB慈溪" && ordermd.CountryCode != "US") { return "国家不支持"; } if (md.Name == "俄EUB" && ordermd.CountryCode != "RU") { return "国家不支持"; } if (md.Name.Contains("俄罗斯") == true && ordermd.CountryCode != "RU") { return "国家不支持"; } if (md.Name == "加拿大EUB" && ordermd.CountryCode != "CA") { return "国家不支持"; } if (md.Name.Contains("加拿大") == true && ordermd.CountryCode != "CA") { return "国家不支持"; } if (md.Name == "英国EUB" && (ordermd.CountryCode != "UK" && ordermd.CountryCode != "GB")) { return "国家不支持"; } if (md.Name.Contains("英国") == true && (ordermd.CountryCode != "UK" && ordermd.CountryCode != "GB")) { return "国家不支持"; } if (md.Name == "线上EUB" && ordermd.CountryCode != "US") { return "国家不支持"; } if (md.Name == "线上俄EUB" && ordermd.CountryCode != "RU") { return "国家不支持"; } if (md.Name == "澳大利亚EUB" && ordermd.CountryCode != "AU") { return "国家不支持"; } if (md.Name.Contains("澳大利亚") == true && ordermd.CountryCode != "AU") { return "国家不支持"; } if (md.Name == "乌克兰EUB" && ordermd.CountryCode != "UA") { return "国家不支持"; } if (md.Name.Contains("澳大利亚") == true && ordermd.CountryCode != "AU") { return "国家不支持"; } if (md.Name == "法国EUB" && ordermd.CountryCode != "FR") { return "国家不支持"; } if (md.Name.Contains("澳大利亚") == true && ordermd.CountryCode != "AU") { return "国家不支持"; } if (md.Name == "以色列EUB" && ordermd.CountryCode != "IL") { return "国家不支持"; } if (md.Name.Contains("以色列") == true && ordermd.CountryCode != "IL") { return "国家不支持"; } if (md.Name == "沙特EUB" && ordermd.CountryCode != "SA") { return "国家不支持"; } if (md.Name.Contains("沙特") == true && ordermd.CountryCode != "SA") { return "国家不支持"; } EubApi eub = new EubApi(); Eub_Order model = new Eub_Order(); model.Orderid = ordermd.PlatOrderCode; model.OrderCode = ordermd.OrderCode; model.BuyID = ordermd.CustomID; if (md.operationtype != null) model.operationtype = md.operationtype.Value; else model.operationtype = 0; //model.operationtype = 0; model.customercode = md.customercode; model.vipcode = md.vipcode; if (md.clcttype != null) model.clcttype = md.clcttype.Value; else model.clcttype = 1; model.pod = false; model.untread = "Returned"; if (goodslist != null && goodslist.Count > 0 && goodslist[0].Solid != null) model.volweight = Convert.ToInt32(goodslist[0].Solid / 6000); else model.volweight = 0; model.startdate = DateTime.Now; model.enddate = DateTime.Now.AddDays(15); model.sku1 = goodslist[0].GoodsSKU.Replace("&", " "); model.printcode = "03"; model.barcode = ordermd.PlatOrderCode; Eub_Person sendmd = new Eub_Person(); sendmd.company = companymd.CompanyEnglishName; sendmd.email = companymd.Email; sendmd.name = companymd.SendEnglishName; sendmd.phone = companymd.Phone; sendmd.province = companymd.province; sendmd.city = companymd.city; sendmd.country = "CN"; sendmd.county = companymd.county; sendmd.street = companymd.EnglishAddress; //"Guangyuan Road 69 (Asia Tiger Park Building 4),Jiangbei District,Ningbo,China"; sendmd.postcode = companymd.PostCode; model.sender = sendmd; Eub_Person revmodel = new Eub_Person(); revmodel.name = ordermd.RevName; revmodel.phone = ordermd.RevPhone; if (ordermd.RevProvince != null && ordermd.RevProvince != "") revmodel.province = ordermd.RevProvince; else { if (md.Name != "EUB" && md.Name != "EUB上海" && md.Name != "EUB慈溪") { //ErrorInfo += ordercode + "收件省不能为空;"; if (ordermd.RevCity != null && ordermd.RevCity != "") { revmodel.province = ordermd.RevCity; } else { revmodel.province = " "; } } //return ErrorInfo; } string postcode = ordermd.RevPostCode; if (ordermd.RevCountry == "United States" && postcode.Length > 5) { // postcode = Convert.ToInt32(ordermd.RevPostCode.Substring(0, 5).Trim()).ToString(); postcode = ordermd.RevPostCode.Substring(0, 5).Trim(); } else if (ordermd.RevCountry == "Russian Federation" && postcode.Length > 6) { // postcode = Convert.ToInt32(ordermd.RevPostCode.Substring(0, 6).Trim()).ToString(); postcode = ordermd.RevPostCode.Substring(0, 6).Trim(); } revmodel.county = ordermd.RevArea; revmodel.city = ordermd.RevCity; if (ordermd.CountryCode == "UK") ordermd.CountryCode = "GB"; revmodel.country = ordermd.CountryCode; revmodel.street = ordermd.RevAddr.Replace("+", " ").Replace("&", " ").Replace("#", " ").Replace("/", " "); ; revmodel.postcode = postcode; model.receiver = revmodel; Eub_Person collmodel = new Eub_Person(); collmodel.company = companymd.CompanyName; collmodel.email = companymd.Email; collmodel.name = companymd.SendName; collmodel.phone = companymd.Phone; collmodel.province = companymd.province; collmodel.country = "CN"; collmodel.city = companymd.city; collmodel.county = companymd.county; collmodel.street = companymd.Address; collmodel.postcode = companymd.PostCode; model.collect = collmodel; List ListGoods = new List(); if (goodslist != null) { decimal dw = Convert.ToDecimal(0.20); if (goodslist.Count > 10) dw = Convert.ToDecimal(0.10); foreach (var goodsmodel in goodslist) { var ListGoodsmd = new Eub_Goods(); ListGoodsmd.cnname = goodsmodel.GoodsName.Replace("+", " ").Replace("&", " ").Replace("#", " ").Replace("/", " "); if (goodsmodel.GoodsEnglisgName == null || goodsmodel.GoodsEnglisgName == "") ListGoodsmd.enname = goodsmodel.GoodsName; else ListGoodsmd.enname = goodsmodel.GoodsEnglisgName; ListGoodsmd.count = goodsmodel.GoodsNum.Value; ListGoodsmd.unit = "件"; // if (goodsmodel.GoodsPrice != null && goodsmodel.GoodsNum != null) ListGoodsmd.delcarevalue = 10; //if (goodsmodel.Weight != null) // ListGoodsmd.weight = goodsmodel.Weight.Value / 1000; //else ListGoodsmd.weight = dw; ListGoodsmd.origin = "CN"; ListGoodsmd.description = ""; ListGoods.Add(ListGoodsmd); } } model.ListGoods = ListGoods; if (md.Name == "线上EUB") { EbayApi ea = new EbayApi(); JC_PostAddress2 add = new JC_PostAddress2(); add.SendName = companymd.SendName; add.CompanyName = companymd.CompanyName; add.Email = companymd.Email; add.Address = companymd.Address; add.EnglishAddress = companymd.EnglishAddress; add.CompanyEnglishName = companymd.CompanyEnglishName; add.city = companymd.city; add.citycode = companymd.citycode; add.county = companymd.county; add.countycode = companymd.countycode; add.province = companymd.province; add.provincecode = companymd.provincecode; add.Phone = companymd.Phone; add.PostCode = companymd.PostCode; PostCode = ea.senderorder(model, add, md.CheckCode, "ebayshop2"); } else PostCode = eub.SendGoods(model, md.CheckCode, out ErrorInfo); } //if (PostCode == null || PostCode == "") //{ // PostCode = obj1.GetInnerExpressCode(CompanyId, PostId); //} } else if (md.Name == "E邮宝") //E邮宝 { if (md.CheckCode != null && md.CheckCode != "" && goodslist != null && goodslist.Count > 0) { EubApi eub = new EubApi(); Eub_Order model = new Eub_Order(); model.Orderid = ordermd.PlatOrderCode; if (md.operationtype != null) model.operationtype = md.operationtype.Value; else model.operationtype = 0; model.producttype = 0; model.customercode = md.customercode; model.vipcode = md.vipcode; if (md.clcttype != null) model.clcttype = md.clcttype.Value; else model.clcttype = 1; model.pod = false; model.untread = "Returned"; if (goodslist != null && goodslist.Count > 0 && goodslist[0].Solid != null) model.volweight = Convert.ToInt32(goodslist[0].Solid / 6000); else model.volweight = 0; model.startdate = DateTime.Now; model.enddate = DateTime.Now.AddDays(15); model.sku1 = goodslist[0].GoodsSKU.Replace("&", " "); model.printcode = "03"; model.barcode = ordermd.PlatOrderCode; Eub_Person sendmd = new Eub_Person(); sendmd.company = companymd.CompanyEnglishName; sendmd.email = companymd.Email; sendmd.name = companymd.SendEnglishName; sendmd.phone = companymd.Phone; sendmd.province = companymd.province; sendmd.city = companymd.city; sendmd.country = "CN"; sendmd.county = companymd.county; sendmd.street = companymd.EnglishAddress; //"Guangyuan Road 69 (Asia Tiger Park Building 4),Jiangbei District,Ningbo,China"; sendmd.postcode = companymd.PostCode; model.sender = sendmd; Eub_Person revmodel = new Eub_Person(); revmodel.name = ordermd.RevName; revmodel.phone = ordermd.RevPhone; if (ordermd.RevMoblie != null && ordermd.RevMoblie != "") revmodel.mobile = ordermd.RevMoblie.Replace("+", "").Replace("-", "").Replace("/", ""); if (ordermd.RevProvince != null && ordermd.RevProvince != "") revmodel.province = ordermd.RevProvince; if (revmodel.province == null && revmodel.province != "") { revmodel.province = ordermd.RevCity; } string postcode = ordermd.RevPostCode; if (ordermd.RevCountry == "United States" && postcode.Length > 5) { // postcode = Convert.ToInt32(ordermd.RevPostCode.Substring(0, 5).Trim()).ToString(); postcode = ordermd.RevPostCode.Substring(0, 5).Trim(); } else if (ordermd.RevCountry == "Russian Federation" && postcode.Length > 6) { // postcode = Convert.ToInt32(ordermd.RevPostCode.Substring(0, 6).Trim()).ToString(); postcode = ordermd.RevPostCode.Substring(0, 6).Trim(); } revmodel.county = ordermd.RevArea; revmodel.city = ordermd.RevCity; if (ordermd.CountryCode == "UK") ordermd.CountryCode = "GB"; revmodel.country = ordermd.CountryCode; revmodel.street = ordermd.RevAddr.Replace("+", " ").Replace("&", " ").Replace("#", " ").Replace("/", " "); ; revmodel.postcode = postcode; model.receiver = revmodel; Eub_Person collmodel = new Eub_Person(); collmodel.company = companymd.CompanyName; collmodel.email = companymd.Email; collmodel.name = companymd.SendName; collmodel.phone = companymd.Phone; collmodel.province = companymd.province; collmodel.country = "CN"; collmodel.city = companymd.city; collmodel.county = companymd.county; collmodel.street = companymd.Address; collmodel.postcode = companymd.PostCode; model.collect = collmodel; List ListGoods = new List(); if (goodslist != null) { decimal dw = Convert.ToDecimal(0.20); if (goodslist.Count > 10) dw = Convert.ToDecimal(0.10); foreach (var goodsmodel in goodslist) { if (goodsmodel.GoodsName != null && goodsmodel.GoodsName.Length > 30) goodsmodel.GoodsName = goodsmodel.GoodsName.Substring(0, 30); var ListGoodsmd = new Eub_Goods(); ListGoodsmd.cnname = goodsmodel.GoodsName.Replace("+", " ").Replace("&", " ").Replace("#", " ").Replace("/", " "); // if (goodsmodel.GoodsEnglisgName == null || goodsmodel.GoodsEnglisgName == "") ListGoodsmd.enname = goodsmodel.GoodsCode + "-" + goodsmodel.TypeCode + goodsmodel.TypeDesc; // else // ListGoodsmd.enname = goodsmodel.GoodsEnglisgName; ListGoodsmd.count = goodsmodel.GoodsNum.Value; ListGoodsmd.unit = "件"; // if (goodsmodel.GoodsPrice != null && goodsmodel.GoodsNum != null) ListGoodsmd.delcarevalue = 10; //if (goodsmodel.Weight != null) // ListGoodsmd.weight = goodsmodel.Weight.Value / 1000; //else ListGoodsmd.weight = dw; ListGoodsmd.origin = "CN"; ListGoodsmd.description = ""; ListGoods.Add(ListGoodsmd); } } model.ListGoods = ListGoods; PostCode = eub.SendGoods(model, md.CheckCode, out ErrorInfo); } } else if (md.Name == "BPost") //比利时邮政 { if (md.CheckCode != null && md.CheckCode != "" && goodslist != null && goodslist.Count > 0) { //if (companymd == null) //{ // ErrorInfo = "发货地址没选择;"; // return ErrorInfo; //} if (PostCode == null || PostCode == "") { PostCode = obj1.GetGZExpressCodeBP(CompanyId, PostId); } } } else if (md.LogisticsName == "SF Express") //顺丰 { if (md.CheckCode != null && md.CheckCode != "" && goodslist != null && goodslist.Count > 0) { sfApi sfobj = new sfApi(); sf_Order model = new sf_Order(); if (md.Name == "顺丰E宝挂号" || md.Name == "顺丰E宝平邮") { if (md.operationtype != null) model.express_type = md.operationtype.Value.ToString(); else model.express_type = "9"; } else if (md.Name == "顺丰美国") { model.express_type = "A9"; } else if (md.Name == "顺丰欧洲") { model.express_type = "A2"; } model.d_tel = ordermd.RevPhone; model.d_company = ordermd.RevName; model.d_contact = ordermd.RevName; model.d_address = ordermd.RevAddr; model.orderid = ordermd.PlatOrderCode; model.d_county = ordermd.RevArea; model.d_city = ordermd.RevCity; model.d_post_code = ordermd.RevPostCode; model.d_deliverycode = ordermd.CountryCode; model.d_province = ordermd.RevProvince; model.d_country = ordermd.RevCountry; model.cargo_total_weight = 1; //Convert.ToDecimal(ordermd.TotalWeight) / 1000; model.j_tel = companymd.Phone; model.j_company = companymd.CompanyEnglishName; model.j_province = companymd.province;// "zhejiang province"; model.j_city = companymd.city; //"Ningbo"; model.j_county = companymd.county; model.j_contact = companymd.SendEnglishName; model.j_address = companymd.EnglishAddress; model.j_post_code = companymd.PostCode; model.declared_value = ordermd.TotalPrice; model.declared_value_currency = ordermd.MoneyCode; model.parcel_quantity = 1; model.pay_method = 1; model.custid = md.customercode;//"7551878519"; model.cargo_length = 60; model.cargo_width = 60; model.cargo_height = 60; List ListGoods = new List(); if (goodslist != null) { foreach (var goodsmodel in goodslist) { var ListGoodsmd = new sf_Goods(); if (goodsmodel.GoodsEnglisgName != null && goodsmodel.GoodsEnglisgName != "") { ListGoodsmd.ename = goodsmodel.GoodsEnglisgName; } else { ListGoodsmd.ename = "dress"; } ListGoodsmd.name = goodsmodel.GoodsName; ListGoodsmd.count = goodsmodel.GoodsNum.Value; ListGoodsmd.unit = "piece"; if (goodsmodel.Weight != null) ListGoodsmd.weight = goodsmodel.Weight.Value; else ListGoodsmd.weight = 100; //if (goodsmodel.GoodsPrice != null) ListGoodsmd.amount = goodsmodel.GoodsPrice.GetValueOrDefault(10); ListGoodsmd.currency = "USD"; ListGoodsmd.source_area = "China"; ListGoods.Add(ListGoodsmd); } } model.ListGoods = ListGoods; sfobj.UserCode = md.UserCode; sfobj.CheckCode = md.CheckCode; if (md.Name == "顺丰E宝挂号" || md.Name == "顺丰E宝平邮") { PostCode = sfobj.SendGoods(model, out ErrorInfo); } if (md.Name == "顺丰美国" || md.Name == "顺丰欧洲") { PostCode = sfobj.SendOU(model, out ErrorInfo); } } } else if (md.Name == "顺丰国际挂号(美国)" || md.Name == "顺丰国际挂号(澳大利亚)" || md.Name == "顺丰国际挂号(其它)") //顺丰 { if (md.CheckCode != null && md.CheckCode != "" && goodslist != null && goodslist.Count > 0) { sfApi sfobj = new sfApi(); sf_Order2 model = new sf_Order2(); model.express_type = "E2"; model.d_tel = ordermd.RevPhone; model.d_company = ordermd.RevName; model.d_contact = ordermd.RevName; model.d_address = ordermd.RevAddr; model.orderid = ordermd.PlatOrderCode; model.d_city = ordermd.RevCity; model.d_post_code = ordermd.RevPostCode; model.d_province = ordermd.RevProvince; model.d_country = ordermd.RevCountry; model.cargo_total_weight = 1; //Convert.ToDecimal(ordermd.TotalWeight) / 1000; model.j_tel = companymd.Phone; model.j_company = companymd.CompanyEnglishName; model.j_province = "zhejiang";// "zhejiang province"; model.j_city = "ningbo"; //"Ningbo"; model.j_contact = companymd.SendEnglishName; model.j_address = "ningbo"; model.j_post_code = companymd.PostCode; model.parcel_quantity = 1; List ListGoods = new List(); if (goodslist != null) { foreach (var goodsmodel in goodslist) { var ListGoodsmd = new sf_Goods2(); if (goodsmodel.GoodsEnglisgName != null && goodsmodel.GoodsEnglisgName != "") { ListGoodsmd.ename = goodsmodel.GoodsEnglisgName; } else { ListGoodsmd.ename = "dress"; } ListGoodsmd.name = goodsmodel.GoodsName; ListGoodsmd.count = goodsmodel.GoodsNum.Value; //ListGoodsmd.unit = "piece"; //if (goodsmodel.Weight != null) // ListGoodsmd.weight = goodsmodel.Weight.Value; //else // ListGoodsmd.weight = 100; //if (goodsmodel.GoodsPrice != null) //if (goodsmodel.GoodsPrice != null && goodsmodel.GoodsPrice < 10) // ListGoodsmd.amount = goodsmodel.GoodsPrice.Value; //else ListGoodsmd.amount = 10; //ListGoodsmd.currency = "USD"; // ListGoodsmd.source_area = "China"; ListGoods.Add(ListGoodsmd); } } model.ListGoods = ListGoods; sfobj.UserCode = md.UserCode; sfobj.CheckCode = md.CheckCode; PostCode = sfobj.SendGoods2(model, out ErrorInfo); if (ErrorInfo != "") PostCode = ""; } } else if (md.Name == "德邮小包" || md.Name == "DHL中英专线") { PostCode = obj1.GetGZExpressCodeDY(CompanyId, PostId); } else if (md.Name.Contains("DHL")) { if (md.client_id != null && md.client_id != "" && goodslist != null && goodslist.Count > 0) { DHLApi dhlobj = new DHLApi(); DHLOrder dhlmodel = new DHLOrder(); dhlobj.clientId = md.client_id; //"LTExMTgwNTI4MTY="; dhlobj.GetTime = md.GetTime; dhlobj.password = md.client_secret; //"APITest1"; dhlobj.AccessToken = md.UserCode; dhlobj.token_type = md.CheckCode; labelRequest labelRequest = new labelRequest(); hdr hdr = new hdr(); hdr.messageType = "LABEL"; hdr.messageDateTime = DateTime.Now.ToString("s"); hdr.accessToken = ""; hdr.messageVersion = "1.4"; hdr.messageLanguage = "en"; labelRequest.hdr = hdr; DHL_Order bd = new DHL_Order(); bd.customerAccountId = null; bd.pickupAccountId = md.refresh_token; //"5999999201"; bd.soldToAccountId = md.Code; //"5999999201"; bd.pickupDateTime = DateTime.Now.ToString("s"); pickupAddress pickupAddress = new pickupAddress(); pickupAddress.companyName = "DHL"; pickupAddress.name = "DHL"; pickupAddress.address1 = "china"; pickupAddress.address2 = null; pickupAddress.address3 = null; pickupAddress.city = "china"; pickupAddress.state = "china"; pickupAddress.district = "china"; pickupAddress.country = "CN"; pickupAddress.postCode = "6278"; pickupAddress.phone = "9999"; pickupAddress.email = "test@dhl.com"; bd.pickupAddress = pickupAddress; List shipmentItemslist = new List(); shipmentItems shipmentItems = new shipmentItems(); consigneeAddress consigneeAddress = new consigneeAddress(); string Name = ordermd.RevName; if (Name.Length > 30) Name = Name.Substring(0, 30); consigneeAddress.companyName = Name; consigneeAddress.name = Name; consigneeAddress.address2 = null; consigneeAddress.address3 = null; if (ordermd.RevAddr.Length <= 50) consigneeAddress.address1 = ordermd.RevAddr; else consigneeAddress.address1 = ordermd.RevAddr.Substring(0, 50); if (ordermd.RevAddr.Length > 50 && ordermd.RevAddr.Length <= 100) consigneeAddress.address2 = ordermd.RevAddr.Substring(49, ordermd.RevAddr.Length - 50); else if (ordermd.RevAddr.Length > 100 && ordermd.RevAddr.Length <= 150) consigneeAddress.address3 = ordermd.RevAddr.Substring(99, ordermd.RevAddr.Length - 100); consigneeAddress.city = ordermd.RevCity; consigneeAddress.state = ordermd.RevProvince; consigneeAddress.district = null; consigneeAddress.country = ordermd.CountryCode; consigneeAddress.postCode = ordermd.RevPostCode; consigneeAddress.phone = ordermd.RevPhone; consigneeAddress.email = null; consigneeAddress.idNumber = "9999"; consigneeAddress.idType = "1"; shipmentItems.consigneeAddress = consigneeAddress; returnAddress returnAddress = new returnAddress(); returnAddress.companyName = "MHSG"; returnAddress.name = companymd.SendEnglishName; if (companymd.Address != null && companymd.Address.Length < 50) returnAddress.address1 = companymd.Address; else if (companymd.Address != null) returnAddress.address1 = companymd.Address.Substring(0, 49); returnAddress.address2 = null; returnAddress.address3 = null; returnAddress.city = "ningbo"; returnAddress.state = "zhejiang"; returnAddress.district = "zhenhai"; returnAddress.country = "CN"; returnAddress.postCode = "315000"; returnAddress.phone = companymd.Phone; shipmentItems.returnAddress = returnAddress; shipmentItems.shipmentID = "CNAEV543" + ordermd.OrderId.ToString(); shipmentItems.deliveryConfirmationNo = null; shipmentItems.packageDesc = "Desc"; shipmentItems.totalWeightUOM = "G"; shipmentItems.dimensionUOM = "cm"; shipmentItems.height = Convert.ToDecimal(0.1); shipmentItems.length = Convert.ToDecimal(0.1); shipmentItems.width = Convert.ToDecimal(0.1); shipmentItems.customerReference1 = null; shipmentItems.customerReference2 = null; shipmentItems.productCode = "PPS"; shipmentItems.incoterm = "DDU"; shipmentItems.contentIndicator = "01"; shipmentItems.codValue = null; shipmentItems.insuranceValue = null; shipmentItems.freightCharge = Convert.ToDecimal(0.1); shipmentItems.currency = "USD"; List shipmentContentsList = new List(); int TNum = 0; foreach (var gmd in goodslist) { TNum += gmd.GoodsNum.Value; } decimal tj = Convert.ToDecimal(5.5); decimal dj = Convert.ToDecimal(5.5); if (TNum > 1 && TNum <= 5) { tj = Convert.ToDecimal(2.1 * TNum); dj = Convert.ToDecimal(2.1); } else if (TNum > 5) { tj = Convert.ToDecimal(1.1 * TNum); dj = Convert.ToDecimal(1.1); } foreach (var gmd in goodslist) { shipmentContents shipmentContents = new shipmentContents(); shipmentContents.skuNumber = gmd.GoodsSKU; if (gmd.GoodsSKU == null && gmd.GoodsSKU.Length > 50) shipmentContents.skuNumber = "DEC001"; if (gmd.GoodsEnglisgName != null && gmd.GoodsEnglisgName != "" && gmd.GoodsEnglisgName.Length < 50) { shipmentContents.description = gmd.GoodsEnglisgName; shipmentContents.descriptionImport = gmd.GoodsEnglisgName; } else { shipmentContents.description = "cloth"; shipmentContents.descriptionImport = "cloth"; } if (gmd.GoodsName.Length < 50) shipmentContents.descriptionExport = gmd.GoodsName; else shipmentContents.descriptionExport = gmd.GoodsName.Substring(0, 49); shipmentContents.itemValue = dj; shipmentContents.itemQuantity = gmd.GoodsNum.Value; shipmentContents.grossWeight = 100; shipmentContents.netWeight = 100; shipmentContents.weightUOM = "g"; shipmentContents.contentIndicator = "01"; shipmentContents.countryOfOrigin = "CN"; shipmentContents.hsCode = null; shipmentContentsList.Add(shipmentContents); shipmentItems.shipmentContents = shipmentContentsList; shipmentItemslist.Add(shipmentItems); } shipmentItems.totalValue = tj; shipmentItems.totalWeight = Convert.ToDecimal(100 * 1.00 * TNum); bd.shipmentItems = shipmentItemslist; label label = new label(); label.pageSize = "400x600"; label.format = "PDF"; label.layout = "4x1"; bd.label = label; labelRequest.bd = bd; dhlmodel.labelRequest = labelRequest; PostCode = dhlobj.SendGoods(dhlmodel, out ErrorInfo); } } else if (md.Name.StartsWith("CNE")) { string postmessage = "{\"RequestName\":\"TimeStamp\"}"; string error = ""; CNE cneobj = new CNE(); string timeinfo = cneobj.SendGoods(postmessage, out error); JavaScriptSerializer JsonConvert = new JavaScriptSerializer(); CNE_Result model = JsonConvert.Deserialize(timeinfo); string code = NetLibrary.Safety.CryptoPublic.Md5For32(md.UserCode + model.ReturnValue + md.CheckCode); var cnemd = new CNE_Order(); cnemd.RequestName = "PreInputSet"; cnemd.icID = md.UserCode; cnemd.TimeStamp = model.ReturnValue; cnemd.MD5 = code; List RecList = new List(); var recmd = new CNE_Reve(); recmd.iID = "0"; recmd.nItemType = 1; recmd.cRNo = ordermd.PlatOrderCode; recmd.cDes = ordermd.CountryName; recmd.cEmsKind = md.customercode; recmd.fWeight = 0; recmd.cReceiver = ordermd.RevName; recmd.cREMail = ""; recmd.cRAddr = ordermd.RevAddr; recmd.cRCity = ordermd.RevCity; recmd.cRProvince = ordermd.RevProvince; recmd.cRCountry = ordermd.RevCountry; recmd.cRPhone = ordermd.RevPhone; recmd.cRPostcode = ordermd.RevPostCode; var glist = new List(); if (goodslist != null) { foreach (var goodsmodel in goodslist) { if (goodsmodel.GoodsName != null && goodsmodel.GoodsName.Length > 30) goodsmodel.GoodsName = goodsmodel.GoodsName.Substring(0, 30); var gmd = new CNE_Goods(); gmd.cxGoods = goodsmodel.GoodsName; if (goodsmodel.GoodsEnglisgName != null && goodsmodel.GoodsEnglisgName != "") gmd.cxGoodsA = goodsmodel.GoodsEnglisgName; else gmd.cxGoodsA = "cloth"; if (gmd.cxGoodsA.Length > 20) gmd.cxGoodsA = gmd.cxGoodsA.Substring(0, 20); gmd.fxPrice = 10; gmd.ixQuantity = goodsmodel.GoodsNum.Value; gmd.cxGCodeA = goodsmodel.GoodsSKU; glist.Add(gmd); recmd.GoodsList = glist; RecList.Add(recmd); } } cnemd.RecList = RecList; PostCode = cneobj.SendGoods2(cnemd, out ErrorInfo); } else if (md.Name.Contains("Wish")) { if (md.CheckCode != null && md.CheckCode != "" && goodslist != null && goodslist.Count > 0) { //WishYouApi wya = new WishYouApi(); //wya.api_key = md.UserCode; //wya.bid = 0; //wya.zx_type = 6; //wya.guid = ordermd.OrderId.ToString(); //if (md.Name == "Wish挂号") // wya.otype = "1"; //if (md.Name == "Wish平邮") // wya.otype = "0"; //if (md.Name == "DLP平邮") // wya.otype = "9-0"; //if (md.Name == "DLP挂号") // wya.otype = "9-1"; //if (md.Name == "Wish-E邮宝") // wya.otype = "11-0"; //companymd = obj1.GetSendAddress(CompanyId); //wya.from = companymd.SendName; //wya.sender_addres = companymd.SendEnglishName; //wya.sender_city = companymd.city; //wya.sender_province = companymd.province; //wya.sender_phone = companymd.Phone; //wya.CustomName = ordermd.RevName; //wya.to_local = ordermd.RevName; //wya.recipient_addres = ordermd.RevAddr.Replace("+", " ").Replace("&", " ").Replace("#", " ").Replace("/", " "); ; //wya.recipient_addres_local = ordermd.RevAddr.Replace("+", " ").Replace("&", " ").Replace("#", " ").Replace("/", " "); ; //wya.recipient_country_short = ordermd.CountryCode; //wya.recipient_country_local = ordermd.RevCountry; //wya.recipient_province = ordermd.RevProvince; //wya.recipient_province_local = ordermd.RevProvince; //wya.recipient_city = ordermd.RevCity; //wya.recipient_city_local = ordermd.RevCity; //wya.recipient_postcode = ordermd.RevPostCode; //string phone = ""; //if (ordermd.RevMoblie != null) //{ // if (ordermd.RevMoblie.Length > 5) // { // phone = ordermd.RevMoblie; // } //} //if (phone == "") phone = ordermd.RevPhone; //wya.recipient_phone = phone; //string content = ""; //int totalnum = 0; //decimal totalweight = 0;// ordermd.TotalWeight.Value; //var totalprice = ordermd.TotalPrice.Value; //if (goodslist != null) //{ // foreach (var goodsmodel in goodslist) // { // totalweight += Convert.ToDecimal(goodsmodel.Weight.GetValueOrDefault(100) / 1000); // if (goodsmodel.GoodsEnglisgName != "") // { // content += goodsmodel.GoodsEnglisgName + ";"; // } // else // { // content += "dress;"; // } // totalnum += goodsmodel.GoodsNum.Value; // } //} //wya.content = content; //wya.type_no = 1; //wya.weight = totalweight.ToString(); //wya.num = totalnum; //wya.price = totalprice.ToString(); //wya.from_country = "China"; //wya.user_desc = ordermd.PlatOrderCode; //wya.trande_no = ordermd.PlatOrderCode; //wya.trade_amount = totalprice.ToString(); //PostCode = wya.SendGood(wya); WishYouApi2 wya = new WishYouApi2(); wya.ExpressId = md.ExpressID; wya.client_id = md.client_id; wya.client_secret = md.client_secret; wya.redirect_uri = md.redirect_uri; wya.refresh_token = md.refresh_token; wya.code = md.Code; wya.GetTime = md.GetTime; wya.access_token = md.UserCode; wya.bid = 0; wya.mark = ""; wya.guid = ordermd.OrderId.ToString(); if (md.Name == "Wish挂号") wya.otype = "1"; if (md.Name == "Wish平邮") wya.otype = "0"; if (md.Name == "DLP平邮") wya.otype = "9-0"; if (md.Name == "DLP挂号") wya.otype = "9-1"; if (md.Name == "Wish-E邮宝") wya.otype = "11-0"; if (md.customercode != null && md.customercode != "") wya.otype = md.customercode; // companymd = obj1.GetSendAddress(CompanyId); wya.from = companymd.SendName; //"Stella Xu"; wya.sender_addres = companymd.SendEnglishName;// "ChangxingRoad689"; wya.sender_city = companymd.citycode; //"Ningbo"; wya.sender_province = companymd.provincecode;// "Zhejiang"; wya.sender_phone = companymd.Phone;// "13456152202"; wya.to = ordermd.RevName; wya.to_local = ordermd.RevName; wya.recipient_country = ordermd.RevCountry; wya.recipient_addres = ordermd.RevAddr.Replace("+", " ").Replace("&", " ").Replace("#", " ").Replace("/", " "); ; wya.recipient_addres_local = ordermd.RevAddr.Replace("+", " ").Replace("&", " ").Replace("#", " ").Replace("/", " "); ; wya.recipient_country_short = ordermd.CountryCode; wya.recipient_country_local = ordermd.RevCountry; if (ordermd.RevProvince == null || ordermd.RevProvince == "") { wya.recipient_province = ordermd.RevCity; wya.recipient_province_local = ordermd.RevCity; } else { wya.recipient_province = ordermd.RevProvince; wya.recipient_province_local = ordermd.RevProvince; } wya.recipient_city = ordermd.RevCity; wya.recipient_city_local = ordermd.RevCity; wya.recipient_postcode = ordermd.RevPostCode; string phone = ""; if (ordermd.RevMoblie != null) { if (ordermd.RevMoblie.Length > 5) { phone = ordermd.RevMoblie; } } if (phone == "") phone = ordermd.RevPhone; wya.recipient_phone = phone; string content = ""; int totalnum = 0; decimal totalweight = 0;// ordermd.TotalWeight.Value; var totalprice = ordermd.TotalPrice.Value; string contentdesc = ""; string contentname = "货物"; if (goodslist != null) { foreach (var goodsmodel in goodslist) { if (goodsmodel.GoodsName != null && goodsmodel.GoodsName != "") contentname = goodsmodel.GoodsName; totalweight += Convert.ToDecimal(goodsmodel.Weight.GetValueOrDefault(100) / 1000); if (goodsmodel.GoodsEnglisgName != "") { content += goodsmodel.GoodsEnglisgName + ";"; } else { content += "dress;"; } totalnum += goodsmodel.GoodsNum.Value; contentdesc += goodsmodel.GoodsCode + "-" + goodsmodel.TypeCode + goodsmodel.TypeDesc + "[" + goodsmodel.GoodsNum.ToString() + "];"; } } if (contentname.Length > 49) contentname = contentname.Substring(0, 40); wya.content_chinese = contentname; wya.content = content; wya.type_no = 1; wya.weight = totalweight.ToString(); wya.num = totalnum; wya.single_price = totalprice.ToString(); wya.warehouse_code = md.operationtype.ToString();//仓库 "13"; wya.doorpickup = ""; if (md.vipcode == "1") //上门揽货 wya.doorpickup = "1"; wya.has_battery = ""; if (md.clcttype == 1) wya.has_battery = "1";//含电池 wya.from_country = "China"; wya.user_desc = contentdesc;// ordermd.PlatOrderCode; wya.receive_from = companymd.ChargeName;// "ChangxingRoad689"; wya.receive_city = companymd.Shen; //"Ningbo"; wya.receive_province = companymd.Shi;// "Zhejiang"; wya.receive_phone = companymd.Phone;// "13456152202"; wya.receive_addres = companymd.Address;// "13456152202"; wya.trande_no = ordermd.PlatOrderCode; wya.trade_amount = totalprice.ToString(); PostCode = wya.SendGood(wya); } } //else if (md.Name.Contains("递四方")) //{ // if (md.CheckCode != null && md.CheckCode != "" && goodslist != null && goodslist.Count > 0) // { // try // { // pxserver.OrderOnlineServiceClient opx = new pxserver.OrderOnlineServiceClient(); // opx.Open(); // pxserver.createAndPreAlertOrderRequest[] rq = new pxserver.createAndPreAlertOrderRequest[1]; // pxserver.createAndPreAlertOrderRequest rq1 = new pxserver.createAndPreAlertOrderRequest(); // rq1.consigneeName = ordermd.RevName;// "jack"; // rq1.consigneePostCode = ordermd.RevPostCode;// "72601"; // rq1.consigneeTelephone = ordermd.RevPhone;// "0805522713"; // if (ordermd.RevPhone == null || ordermd.RevPhone == "") // rq1.consigneeTelephone = ordermd.RevMoblie; // rq1.city = ordermd.RevCity;// "Harrison"; // if (ordermd.RevCity == null || ordermd.RevCity == "") // rq1.city = ordermd.RevProvince; // rq1.stateOrProvince = ordermd.RevProvince;// "AR"; // if (ordermd.RevProvince == null || ordermd.RevProvince == "") // rq1.stateOrProvince = ordermd.RevCity; // rq1.street = ordermd.RevAddr;//"1202 Chalet Ln1"; // rq1.orderNo = ordermd.PlatOrderCode;// "5958d6a19ca1e531230ec8c5"; // if (rq1.orderNo.Length > 20) // rq1.orderNo = rq1.orderNo.Substring(0, 20); // rq1.shipperAddress = companymd.EnglishAddress;// "haishu"; // rq1.shipperCity = companymd.city;// "ningbo"; // rq1.shipperCompanyName = companymd.SendName;// "chu"; // rq1.shipperName = companymd.SendName;// "chu"; // rq1.shipperPostCode = "315000"; // rq1.initialCountryCode = "CN"; // rq1.destinationCountryCode = ordermd.CountryCode;// "US"; // rq1.productCode = md.customercode;//渠道 "B1"; // if (md.Name.Contains("电")) // rq1.hasBattery = "Y"; // else // rq1.hasBattery = "N"; // rq1.returnSign = "Y"; // pxserver.declareInvoice[] gmd = new pxserver.declareInvoice[goodslist.Count]; // int idx = 0; // int gmx = 0; // foreach (var ggmd in goodslist) // { // pxserver.declareInvoice md1 = new pxserver.declareInvoice(); // md1.cName = ggmd.GoodsName; // md1.declareNote = ggmd.GoodsCode + "-" + ggmd.TypeCode + ggmd.TypeDesc; // md1.declarePieces = ggmd.GoodsNum.Value.ToString(); // md1.unitPrice = "5"; // md1.name = "衣服"; // md1.eName = "cloth"; // gmd[idx] = md1; // gmx += ggmd.GoodsNum.Value; // idx++; // } // rq1.declareInvoice = gmd; // rq1.pieces = gmx.ToString(); // rq[0] = rq1; // pxserver.createAndPreAlertOrderResponse[] rp = new pxserver.createAndPreAlertOrderResponse[1]; // rp = opx.createAndPreAlertOrderService(md.CheckCode, rq); // if (rp[0].ack == "Success") // { // PostCode = rp[0].trackingNumber; // } // else // { // ErrorInfo = "失败" + rp[0].errors[0].cnMessage + rp[0].errors[0].cnAction + rp[0].errors[0].defineMessage; // } // opx.Close(); // } // catch (Exception ex) // { // ErrorInfo = "失败" + ex.Message; // } // } //} else if (md.Name.StartsWith("CNE")) { string postmessage = "{\"RequestName\":\"TimeStamp\"}"; string error = ""; CNE cneobj = new CNE(); string timeinfo = cneobj.SendGoods(postmessage, out error); JavaScriptSerializer JsonConvert = new JavaScriptSerializer(); CNE_Result model = JsonConvert.Deserialize(timeinfo); string code = NetLibrary.Safety.CryptoPublic.Md5For32(md.UserCode + model.ReturnValue + md.CheckCode); var cnemd = new CNE_Order(); cnemd.RequestName = "PreInputSet"; cnemd.icID = md.UserCode; cnemd.TimeStamp = model.ReturnValue; cnemd.MD5 = code; List RecList = new List(); var recmd = new CNE_Reve(); recmd.iID = "0"; recmd.nItemType = 1; recmd.cRNo = ordermd.PlatOrderCode; recmd.cDes = ordermd.CountryName; recmd.cEmsKind = md.customercode; recmd.fWeight = 0; recmd.cReceiver = ordermd.RevName; recmd.cREMail = ""; recmd.cRAddr = ordermd.RevAddr; recmd.cRCity = ordermd.RevCity; recmd.cRProvince = ordermd.RevProvince; recmd.cRCountry = ordermd.RevCountry; recmd.cRPhone = ordermd.RevPhone; recmd.cRPostcode = ordermd.RevPostCode; var glist = new List(); if (goodslist != null) { foreach (var goodsmodel in goodslist) { var gmd = new CNE_Goods(); gmd.cxGoods = goodsmodel.GoodsName; gmd.fxPrice = 10; gmd.ixQuantity = goodsmodel.GoodsNum.Value; gmd.cxGCodeA = goodsmodel.GoodsSKU; glist.Add(gmd); recmd.GoodsList = glist; RecList.Add(recmd); } } cnemd.RecList = RecList; PostCode = cneobj.SendGoods2(cnemd, out ErrorInfo); } else if (md.LogisticsId == 67) { PostCode = OnewordCreate2(md, ordermd, goodslist); } else if (md.Name.Contains("燕文") || md.Name == "燕邮宝平邮") { if (md.CheckCode != null && md.CheckCode != "" && goodslist != null && goodslist.Count > 0) { YanWenApi ywa = new YanWenApi(); ywa.CheckCode = md.CheckCode; ywa.UserCode = md.UserCode; YW_Order model = new YW_Order(); model.Channel = md.customercode; if (md.Name == "燕文上海平邮" || md.Name == "燕文宁波平邮") { model.Channel = "中邮上海平邮小包"; } if (md.Name == "燕文北京平邮") { model.Channel = "中邮北京平邮小包"; } if (md.Name == "燕文上海小包" || md.Name == "燕文宁波小包") { model.Channel = "中邮上海挂号小包"; } if (md.Name.Contains("燕文德邮")) { model.Channel = "德国邮政挂号小包(上海)"; } if (md.Name.Contains("燕文荷兰挂号(电)")) { model.Channel = "荷兰邮政挂号小包(含电)"; } if (md.Name.Contains("燕文上海E邮宝")) { model.Channel = "中邮上海E邮宝(线下)"; } if (md.Name.Contains("燕文马来西亚邮政平邮小包")) { model.Channel = "马来西亚邮政平邮小包(新)"; } model.orderid = ordermd.PlatOrderCode; model.d_address = ordermd.RevAddr.Replace("+", " ").Replace("&", " ").Replace("#", " ").Replace("/", " "); ; model.d_City = ordermd.RevCity; model.d_contact = ordermd.RevName; model.d_country = ordermd.CountryName; model.d_email = ordermd.RevMail; model.d_mobile = ordermd.RevMoblie; model.d_postcode = ordermd.RevPostCode; model.d_State = ordermd.RevProvince; model.d_tel = ordermd.RevPhone; model.delcarevalue = 5; // model.enname = goodslist.First().GoodsEnglisgName; string contentdesc = ""; string contentdesc2 = ""; int GoodsNum = 0; int IsMore = 0; if (goodslist != null) { foreach (var goodsmodel in goodslist) { IsMore++; GoodsNum += goodsmodel.GoodsNum.Value; contentdesc2 += goodsmodel.GoodsCode + "-" + goodsmodel.TypeCode + "" + goodsmodel.TypeDesc.Replace("+", " ").Replace("&", " ").Replace("#", " ").Replace("/", " ") + "[" + goodsmodel.GoodsNum.ToString() + "];"; contentdesc += goodsmodel.GoodsCode + "-" + goodsmodel.TypeCode + goodsmodel.TypeDesc + "[" + goodsmodel.GoodsNum.ToString() + "];"; } } model.GoodsNum = GoodsNum; model.delcarevalue = 5; if (IsMore > 1) contentdesc2 = "[MORE]" + contentdesc2; if (contentdesc2.Length > 195) contentdesc2 = contentdesc2.Substring(0, 195); if (IsMore > 1) model.cnname = goodslist.First().GoodsName.Replace("+", " ").Replace("&", " ").Replace("#", " ").Replace("/", " ") + " 多个"; else model.cnname = goodslist.First().GoodsName.Replace("+", " ").Replace("&", " ").Replace("#", " ").Replace("/", " "); model.enname = contentdesc2; // model.Memo = contentdesc; // if (contentdesc.Length > 50) // model.Memo = contentdesc2; model.MoreGoodsName = contentdesc; model.weight = 100; PostCode = ywa.GetTrackCode(model); } } else if (md.Name.Contains("淼信")) { if (md.Name == "淼信俄罗斯") { MiaoXinApi mxobj = new MiaoXinApi(); MiaoXin_Order model = new MiaoXin_Order(); model.buyerid = ""; model.consignee_address = ordermd.RevAddr; model.consignee_city = ordermd.RevCity; model.consignee_mobile = ""; model.consignee_name = ordermd.RevName; model.consignee_postcode = ordermd.RevPostCode; model.consignee_state = "Other"; model.consignee_telephone = ordermd.RevPhone; model.country = "RU"; model.customer_id = md.UserCode; model.customer_userid = md.CheckCode; model.order_customerinvoicecode = ordermd.PlatOrderCode; model.product_id = "3861"; model.trade_type = "ZYXT"; model.weight = ""; List GoodsList = new List(); if (goodslist != null) { foreach (var goodsmodel in goodslist) { MiaoXin_Goods model2 = new MiaoXin_Goods(); model2.invoice_amount = "5"; model2.invoice_pcs = goodsmodel.GoodsNum.ToString(); model2.invoice_title = goodsmodel.GoodsEnglisgName; model2.invoice_weight = "100"; model2.item_id = ""; model2.item_transactionid = ""; model2.sku = goodsmodel.GoodsName; GoodsList.Add(model2); } } model.orderInvoiceParam = GoodsList; PostCode = mxobj.SendGoods(model, out ErrorInfo); } } } } catch (Exception ex) { ErrorInfo += ex.Message; } } if (PostCode != null && PostCode != "" && !PostCode.Contains("失败")) { DT_TrackCodeApply Model = new DT_TrackCodeApply(); if (PostCode.Contains(',')) { string[] tracklist = PostCode.Split(','); if (tracklist.Length > 1) { Model.TrackCode = tracklist[0].ToString(); Model.TrackCode2 = tracklist[1].ToString(); } } else { Model.TrackCode = PostCode; } //if (md.LogisticsId != null) //{ // if (md.LogisticsId > 0) // { // if (CheckWuliu(md.LogisticsId.GetValueOrDefault(0), Model.TrackCode) == 1) // { // return ""; // } // } //} Model.GetDate = DateTime.Now; Model.InName = Session["Name"].ToString(); if (ordermd.JoinOrderCode != null && ordermd.JoinOrderCode != "") Model.OrderCode = ordermd.JoinOrderCode; else Model.OrderCode = ordermd.PlatOrderCode; Model.OrderId = ordermd.OrderId; Model.PostId = PostId; Model.State = 1; Model.TrackType = 1; Model.UpdateTime = DateTime.Now; Model.IsSpare = 0; Model.JoinOrderCode = ordermd.JoinOrderCode; plist.Add(Model); //obj.UpdateTrackCode(PostCode, PostId,OrderId, ErrorInfo); //obj.SaveTrackCodeApply2(Model); } else //if (md.PostType != 4) //线上发货的除外 { // ErrorFollow.TraceWrite("GetOrderPostCode", "物流id:" + PostId.ToString() + ";订单号:" + PlatCode + "获取跟踪码错误", ErrorInfo); //ErrorInfo += "未获取到跟踪码"; var emd = new DT_TrackCodeApply(); emd.OrderId = ordermd.OrderId; emd.PostError = "未获取到跟踪码"; emd.PostId = PostId; plist.Add(emd); ErrorInfo += ordermd.PlatOrderCode + "未获取到跟踪码"; // obj.UpdateTrackCodeError2(OrderId, PostId, "获取到跟踪码失败"); } //if (PostCode != null && PostCode != "" && !PostCode.Contains("失败")) //{ // TrackCode = PostCode; // return ""; //} //else // return PlatCode + "的订单" + ErrorInfo + " " + PostCode; } if (plist != null && plist.Count > 0) { foreach (var pmd in plist) { if (pmd.TrackCode != null) { if (pmd.TrackCode != "") obj.SaveTrackCodeApply4(pmd); } } } if (ErrorInfo == "") return ""; else return ErrorInfo; } catch (Exception ex) { return ErrorInfo + ex.Message; } } #endregion #region Oneword验证授权 [WebMethod(EnableSession = true)] public string OnewordSQ(string Code, string Pwd) { Pages.Login(this.Session); string URL = "http://api.oneworldexpress.cn/api/whoami"; string error = ""; string Content = CustomIO.OneWordHttpRequest(URL, "Get", Code, Pwd, null, out error); if (string.IsNullOrEmpty(error) == false) return "验证失败"; JavaScriptSerializer JsonConvert = new JavaScriptSerializer(); OneWordResultInfo Model = JsonConvert.Deserialize(Content); if (Model != null && Model.Succeeded == true) return "成功"; else if (Model != null && Model.Error != null) return "验证失败;" + Model.Error.Message; else return "验证失败;"; } #endregion #region Oneword创建订单 [WebMethod(EnableSession = true)] public string OnewordCreate(JC_ExpressPost md, DT_OrderModel ordermodel, List goodlist) { try { OneWorldAPI owa = new OneWorldAPI(); string ShippingMethod = md.customercode; string CountryCode = ordermodel.CountryCode; if (CountryCode == "DE" && md.Name == "OneWorld") { ShippingMethod = "19EURDPDDE"; } if (CountryCode == "ES" && md.Name == "OneWorld") { ShippingMethod = "CORREOS"; } if (CountryCode == "UK" && md.Name == "OneWorld") { ShippingMethod = "3HPA"; } if (CountryCode == "CZ" || CountryCode == "IL") { if (md.Name == "东欧小包") ShippingMethod = "REGPOSTHUNINT"; if (md.Name == "东欧平邮") ShippingMethod = "REGHUNUTRINT"; } string DutyPaymentMethod = md.vipcode; if (ShippingMethod == "" || CountryCode == "") { return "失败:国家不正确"; } string[] AddressList = ordermodel.RevAddr.Split(','); string Street1 = " "; string Street2 = " "; string Street3 = " "; string City = " "; string Province = " "; string Postcode = ""; Postcode = ordermodel.RevPostCode; Province = ordermodel.RevProvince; City = ordermodel.RevCity; Street1 = AddressList[0]; if (AddressList.Length > 2) Street2 = AddressList[1]; if (AddressList.Length > 3) { for (int i = 2; i < AddressList.Length; i++) { Street3 += AddressList[i] + " "; } } string str = ""; ONEBody ob = new ONEBody(); ob.ReferenceId = ordermodel.PlatOrderCode; ob.WeightInKg = 0.6; ob.WithBatteryType = "NOBattery"; ob.Notes = ""; ob.BatchNo = ""; ob.WarehouseCode = "SH";//"SH"; ob.ShippingMethod = ShippingMethod; ob.ItemType = "SPX"; ob.DutyPaymentMethod = DutyPaymentMethod; ob.TrackingNumber = ""; ob.IsMPS = true; ob.CheckRepeat = false; ob.AutoConfirm = true; ShippingAddressClass ShippingAddress = new ShippingAddressClass(); ShippingAddress.Company = ordermodel.RevName; ShippingAddress.Street1 = Street1; ShippingAddress.Street2 = Street2; ShippingAddress.Street3 = Street3; ShippingAddress.City = City; ShippingAddress.Province = Province; ShippingAddress.Country = ordermodel.RevCountry; ShippingAddress.CountryCode = CountryCode; ShippingAddress.Postcode = Postcode; ShippingAddress.Contacter = ordermodel.RevName; ShippingAddress.Tel = ordermodel.RevMoblie == null ? ordermodel.RevPhone : (ordermodel.RevMoblie == "" ? ordermodel.RevPhone : ordermodel.RevMoblie); ShippingAddress.Email = ordermodel.RevMail; ob.ShippingAddress = ShippingAddress; double weight = 0; foreach (var q in goodlist) { ItemDetailsClass idc = new ItemDetailsClass(); idc.GoodsId = q.GoodsCode; idc.GoodsTitle = q.GoodsName; idc.DeclaredNameEn = q.GoodsEnglisgName; idc.DeclaredNameCn = q.GoodsName; idc.WeightInKg = Math.Round((q.Weight == 0 ? 0.9 : ((float)q.Weight.Value) + 0.01) * (float)q.GoodsNum.Value / 1000, 3); weight += idc.WeightInKg; idc.Quantity = q.GoodsNum.Value; idc.HSCode = ""; idc.CaseCode = "Box001"; DeclaredValueClass dvc = new DeclaredValueClass(); dvc.Code = "USD"; dvc.Value = Math.Round(((float)ordermodel.TotalPrice / (float)ordermodel.GoodsNum) * (float)q.GoodsNum.Value, 2); idc.DeclaredValue = dvc; ob.ItemDetails.Add(idc); } TotalValueClass tvc = new TotalValueClass(); tvc.Code = "USD"; tvc.Value = Convert.ToDouble(ordermodel.TotalPrice.Value); ob.TotalValue = tvc; TotalVolumeClass tmc = new TotalVolumeClass(); tmc.Height = 1; tmc.Length = 1; tmc.Width = 1; tmc.Unit = "m"; ob.TotalVolume = tmc; CasesClass cc = new CasesClass(); cc.Code = "Box001"; cc.WeightInKg = weight; VolumeClass vc = new VolumeClass(); vc.Height = 1; vc.Length = 1; vc.Width = 1; vc.Unit = "m"; cc.Volume = vc; ob.Cases.Add(cc); string output = JsonConvert.SerializeObject(ob); string result = owa.sendData(output, "http://api.oneworldexpress.cn/api/parcels"); JObject jo = (JObject)JsonConvert.DeserializeObject(result); string sresult = jo["Succeeded"].ToString(); string ProcessCode = ""; string TrackingNumber = ""; if (sresult == "False") { if (result.Contains("己经存在")) { string mess = jo["Error"]["Message"].ToString(); string[] ssslist = mess.Split(','); ProcessCode = ssslist[1].Replace("对应处理号为", "").Trim(); } else { return jo["Error"]["Message"].ToString() + " 失败"; } } if (!result.Contains("己经存在")) { ProcessCode = jo["Data"]["ProcessCode"].ToString(); TrackingNumber = jo["Data"]["TrackingNumber"].ToString(); } string resultstr = ""; if (TrackingNumber == "" && ProcessCode != "") { System.Threading.Thread.Sleep(1000); result = owa.sendpost("http://api.oneworldexpress.cn/api/parcels/" + ProcessCode); jo = (JObject)JsonConvert.DeserializeObject(result); sresult = jo["Succeeded"].ToString(); if (sresult == "False") { resultstr = jo["Error"]["Message"].ToString(); } if (ProcessCode == "") ProcessCode = jo["Data"]["ProcessCode"].ToString(); TrackingNumber = jo["Data"]["TrackingNumber"].ToString(); if (TrackingNumber == "") { TrackingNumber = ProcessCode; } } if (TrackingNumber != "") { return TrackingNumber + "," + ProcessCode; } //return "成功" + resultstr; } catch { return "申请失败!"; } //OnewordGetTrackCode2(list, expressmd, PostId); return ""; } #endregion #region Oneword创建订单 [WebMethod(EnableSession = true)] public string OnewordCreate2(JC_ExpressPost md, DT_OrderExpressModel ordermodel, List goodlist) { try { OneWorldAPI owa = new OneWorldAPI(); string ShippingMethod = md.customercode; string CountryCode = ordermodel.CountryCode; if (CountryCode == "DE" && md.Name == "OneWorld") { ShippingMethod = "19EURDPDDE"; } if (CountryCode == "ES" && md.Name == "OneWorld") { ShippingMethod = "CORREOS"; } if (CountryCode == "UK" && md.Name == "OneWorld") { ShippingMethod = "3HPA"; } if (CountryCode == "CZ" || CountryCode == "IL") { if (md.Name == "东欧小包") ShippingMethod = "REGPOSTHUNINT"; if (md.Name == "东欧平邮") ShippingMethod = "REGHUNUTRINT"; } string DutyPaymentMethod = md.vipcode; if (ShippingMethod == "" || CountryCode == "") { return "失败:国家不正确"; } string[] AddressList = ordermodel.RevAddr.Split(','); string Street1 = " "; string Street2 = " "; string Street3 = " "; string City = " "; string Province = " "; string Postcode = ""; Postcode = ordermodel.RevPostCode; Province = ordermodel.RevProvince; City = ordermodel.RevCity; Street1 = AddressList[0]; if (AddressList.Length > 2) Street2 = AddressList[1]; if (AddressList.Length > 3) { for (int i = 2; i < AddressList.Length; i++) { Street3 += AddressList[i] + " "; } } string str = ""; ONEBody ob = new ONEBody(); ob.ReferenceId = ordermodel.PlatOrderCode; ob.WeightInKg = 0.6; ob.WithBatteryType = "NOBattery"; ob.Notes = ""; ob.BatchNo = ""; ob.WarehouseCode = "SH";//"SH"; ob.ShippingMethod = ShippingMethod; ob.ItemType = "SPX"; ob.DutyPaymentMethod = DutyPaymentMethod; ob.TrackingNumber = ""; ob.IsMPS = true; ob.CheckRepeat = false; ob.AutoConfirm = true; ShippingAddressClass ShippingAddress = new ShippingAddressClass(); ShippingAddress.Company = ordermodel.RevName; ShippingAddress.Street1 = Street1; ShippingAddress.Street2 = Street2; ShippingAddress.Street3 = Street3; ShippingAddress.City = City; ShippingAddress.Province = Province; ShippingAddress.Country = ordermodel.RevCountry; ShippingAddress.CountryCode = CountryCode; ShippingAddress.Postcode = Postcode; ShippingAddress.Contacter = ordermodel.RevName; ShippingAddress.Tel = ordermodel.RevMoblie == null ? ordermodel.RevPhone : (ordermodel.RevMoblie == "" ? ordermodel.RevPhone : ordermodel.RevMoblie); ShippingAddress.Email = ordermodel.RevMail; ob.ShippingAddress = ShippingAddress; double weight = 0; foreach (var q in goodlist) { ItemDetailsClass idc = new ItemDetailsClass(); idc.GoodsId = q.GoodsCode; idc.GoodsTitle = q.GoodsName; idc.DeclaredNameEn = q.GoodsEnglisgName; idc.DeclaredNameCn = q.GoodsName; idc.WeightInKg = Math.Round((q.Weight == 0 ? 0.9 : ((float)q.Weight.Value) + 0.01) * (float)q.GoodsNum.Value / 1000, 3); weight += idc.WeightInKg; idc.Quantity = q.GoodsNum.Value; idc.HSCode = ""; idc.CaseCode = "Box001"; DeclaredValueClass dvc = new DeclaredValueClass(); dvc.Code = "USD"; dvc.Value = Math.Round(((float)ordermodel.TotalPrice / (float)ordermodel.GoodsNum) * (float)q.GoodsNum.Value, 2); idc.DeclaredValue = dvc; ob.ItemDetails.Add(idc); } TotalValueClass tvc = new TotalValueClass(); tvc.Code = "USD"; tvc.Value = Convert.ToDouble(ordermodel.TotalPrice.Value); ob.TotalValue = tvc; TotalVolumeClass tmc = new TotalVolumeClass(); tmc.Height = 1; tmc.Length = 1; tmc.Width = 1; tmc.Unit = "m"; ob.TotalVolume = tmc; CasesClass cc = new CasesClass(); cc.Code = "Box001"; cc.WeightInKg = weight; VolumeClass vc = new VolumeClass(); vc.Height = 1; vc.Length = 1; vc.Width = 1; vc.Unit = "m"; cc.Volume = vc; ob.Cases.Add(cc); string output = JsonConvert.SerializeObject(ob); string result = owa.sendData(output, "http://api.oneworldexpress.cn/api/parcels"); JObject jo = (JObject)JsonConvert.DeserializeObject(result); string sresult = jo["Succeeded"].ToString(); string ProcessCode = ""; string TrackingNumber = ""; if (sresult == "False") { if (result.Contains("己经存在")) { string mess = jo["Error"]["Message"].ToString(); string[] ssslist = mess.Split(','); ProcessCode = ssslist[1].Replace("对应处理号为", "").Trim(); } else { return jo["Error"]["Message"].ToString() + " 失败"; } } if (!result.Contains("己经存在")) { ProcessCode = jo["Data"]["ProcessCode"].ToString(); TrackingNumber = jo["Data"]["TrackingNumber"].ToString(); } string resultstr = ""; if (TrackingNumber == "" && ProcessCode != "") { System.Threading.Thread.Sleep(1000); result = owa.sendpost("http://api.oneworldexpress.cn/api/parcels/" + ProcessCode); jo = (JObject)JsonConvert.DeserializeObject(result); sresult = jo["Succeeded"].ToString(); if (sresult == "False") { resultstr = jo["Error"]["Message"].ToString(); } if (ProcessCode == "") ProcessCode = jo["Data"]["ProcessCode"].ToString(); TrackingNumber = jo["Data"]["TrackingNumber"].ToString(); if (TrackingNumber == "") { TrackingNumber = ProcessCode; } } if (TrackingNumber != "") { return TrackingNumber + "," + ProcessCode; } //return "成功" + resultstr; } catch { return "申请失败!"; } //OnewordGetTrackCode2(list, expressmd, PostId); return ""; } #endregion #region Oneword获取跟踪码 public string OnewordGetTrackCode2(string ProcessCode) { OneWorldAPI owa = new OneWorldAPI(); string result = owa.sendpost("http://api.oneworldexpress.cn/api/parcels/" + ProcessCode); JObject jo = (JObject)JsonConvert.DeserializeObject(result); string TrackingNumber = ""; string resultstr = ""; string sresult = jo["Succeeded"].ToString(); if (sresult == "False") { resultstr = jo["Error"]["Message"].ToString(); } if (ProcessCode == "") ProcessCode = jo["Data"]["ProcessCode"].ToString(); TrackingNumber = jo["Data"]["TrackingNumber"].ToString(); if (TrackingNumber == "") { TrackingNumber = ProcessCode; } if (TrackingNumber != "") { return TrackingNumber; } else return resultstr; } #endregion #region Oneword获取面单 [WebMethod(EnableSession = true)] public string OnewordGetPdf(List list, int PostId) { Pages.Login(this.Session); if (list == null) return ""; DD_OrderData obj1 = new DD_OrderData(); string URL = "http://api-sbx.oneworldexpress.cn/api/parcels/labels?processCodes="; foreach (var omd in list) { var ordermodel = obj1.GetOrderModel(omd.OrderId.Value); if (ordermodel.PostOneCode != null) URL += ordermodel.PostOneCode + "|"; } URL = URL.Trim('|'); JC_ExpressService obj = new JC_ExpressService(); int CompanyId = Convert.ToInt32(Session["CompanyId"]); var expressmd = obj.GetExpressModel(CompanyId, PostId); if (expressmd == null) return ""; if (expressmd.UserCode == null || expressmd.UserCode == "" || expressmd.CheckCode == null || expressmd.CheckCode == "") return "该物流需要api的账号和令牌"; string ErrorMessage = ""; string url = CustomIO.OneWordPdfHttpRequest(URL, "Get", expressmd.UserCode, expressmd.CheckCode, null, out ErrorMessage); return url; } #endregion #region Oneword修改重量 [WebMethod(EnableSession = true)] public string OnewordUpdateWeight(string ProcessCode, double weight) { OneWorldAPI owa = new OneWorldAPI(); ChangeClass cc = new ChangeClass(); cc.ProcessCode = ProcessCode; cc.WeightInKg = Math.Round(weight / 1000, 3).ToString(); string Outstr = JsonConvert.SerializeObject(cc);// "{\"ProcessCode\":\"" + checkP.mailno + "\",\"WeightInKg\":\"" + Math.Round(checkM.First().PackageWeight.GetValueOrDefault(100), 3).ToString() + "\"}"; string result = owa.PutData(Outstr, "http://api.oneworldexpress.cn/api/parcels/" + ProcessCode + "/customerWeight"); return result; } #endregion #region 查询oneworld渠道 [WebMethod(EnableSession = true)] public List GetShippingMethods() { Pages.Login(this.Session); var obj = new JC_ExpressService(); int CompanyId = Convert.ToInt32(Session["CompanyId"]); var list = obj.GetShippingMethods(); return list; } #endregion #region CNE获取面单 [WebMethod(EnableSession = true)] public string CNEGetPdf(List list, int PostId) { Pages.Login(this.Session); if (list == null) return ""; DD_OrderData obj1 = new DD_OrderData(); string TrackCodes = ""; string URL = "http://api-sbx.oneworldexpress.cn/api/parcels/labels?processCodes="; foreach (var omd in list) { TrackCodes += omd.TrackCode.Trim().Replace("
", ",") + ","; } TrackCodes = TrackCodes.Trim(','); JC_ExpressService obj = new JC_ExpressService(); int CompanyId = Convert.ToInt32(Session["CompanyId"]); var expressmd = obj.GetExpressModel(CompanyId, PostId); if (expressmd == null) return ""; if (expressmd.UserCode == null || expressmd.UserCode == "" || expressmd.CheckCode == null || expressmd.CheckCode == "") return "0"; string ErrorMessage = ""; string sign = NetLibrary.Safety.CryptoPublic.Md5For32(expressmd.UserCode + TrackCodes + expressmd.CheckCode); CNE cobj = new CNE(); string url = cobj.GetLabel(expressmd.UserCode, TrackCodes, sign, out ErrorMessage); return url; } #endregion #region 燕文获取面单 [WebMethod(EnableSession = true)] public string YANWENGetPdf(List list, int PostId) { Pages.Login(this.Session); if (list == null) return ""; DD_OrderData obj1 = new DD_OrderData(); string TrackCodes = ""; foreach (var omd in list) { TrackCodes += omd.TrackCode.Trim().Replace("
", ",") + ","; } //TrackCodes = TrackCodes.Trim(','); TrackCodes = "" + TrackCodes.Trim(',') + ""; //TrackCodes += ","; JC_ExpressService obj = new JC_ExpressService(); int CompanyId = Convert.ToInt32(Session["CompanyId"]); var expressmd = obj.GetExpressModel(CompanyId, PostId); if (expressmd == null) return ""; if (expressmd.UserCode == null || expressmd.UserCode == "" || expressmd.CheckCode == null || expressmd.CheckCode == "") return "0"; string ErrorMessage = ""; YanWenApi yobj = new YanWenApi(); yobj.UserCode = expressmd.UserCode; yobj.CheckCode = expressmd.CheckCode; string url = yobj.GetLabels(expressmd.UserCode, TrackCodes, out ErrorMessage); return url; } #endregion #region 燕文获取面单 [WebMethod(EnableSession = true)] public string YANWENGetPdf2(List list, int PostId, int BGD) { Pages.Login(this.Session); if (list == null) return ""; DD_OrderData obj1 = new DD_OrderData(); string TrackCodes = ""; foreach (var omd in list) { TrackCodes += omd.TrackCode.Trim().Replace("
", ",") + ","; } //TrackCodes = TrackCodes.Trim(','); TrackCodes = "" + TrackCodes.Trim(',') + ""; //TrackCodes += ","; JC_ExpressService obj = new JC_ExpressService(); int CompanyId = Convert.ToInt32(Session["CompanyId"]); var expressmd = obj.GetExpressModel(CompanyId, PostId); if (expressmd == null) return ""; if (expressmd.UserCode == null || expressmd.UserCode == "" || expressmd.CheckCode == null || expressmd.CheckCode == "") return "0"; string ErrorMessage = ""; YanWenApi yobj = new YanWenApi(); yobj.UserCode = expressmd.UserCode; yobj.CheckCode = expressmd.CheckCode; string url = yobj.GetLabels2(expressmd.UserCode, TrackCodes, BGD, out ErrorMessage); return url; } #endregion //#region 递四方获取面单 //[WebMethod(EnableSession = true)] //public string PXGetPdf(List list, int PostId) //{ // Pages.Login(this.Session); // if (list == null) // return ""; // DD_OrderData obj1 = new DD_OrderData(); // List tlist = new List(); // foreach (var omd in list) // { // string tcodes = omd.TrackCode.Trim().Replace("
", ","); // string[] tcode = tcodes.Split(','); // for (int i = 0; i < tcode.Length; i++) // { // if (tcode[i].Trim() != "") // { // PX_Order tmd = new PX_Order(); // tmd.TrackingNumber = tcode[i].Trim(); // tlist.Add(tmd); // } // } // } // JC_ExpressService obj = new JC_ExpressService(); // int CompanyId = Convert.ToInt32(Session["CompanyId"]); // var expressmd = obj.GetExpressModel(CompanyId, PostId); // if (expressmd == null) // return ""; // if (expressmd.CheckCode == null || expressmd.CheckCode == "") // return "0"; // _4PXApi obj2 = new _4PXApi(); // string error = ""; // string url = obj2.GetLabel(expressmd.CheckCode, tlist, out error); // if (error!="") // return "失败"+error; // return url; //} //#endregion #region wish邮获取面单 [WebMethod(EnableSession = true)] public string WishGetPdf(List list, int PostId) { Pages.Login(this.Session); if (list == null) return ""; DD_OrderData obj1 = new DD_OrderData(); List tlist = new List(); foreach (var omd in list) { string tcodes = omd.TrackCode.Trim().Replace("
", ","); string[] tcode = tcodes.Split(','); for (int i = 0; i < tcode.Length; i++) { if (tcode[i].Trim() != "") { WishPostTrack tmd = new WishPostTrack(); tmd.barcode = tcode[i].Trim(); tlist.Add(tmd); } } } JC_ExpressService obj = new JC_ExpressService(); int CompanyId = Convert.ToInt32(Session["CompanyId"]); var expressmd = obj.GetExpressModel(CompanyId, PostId); if (expressmd == null) return ""; if (expressmd.UserCode == null || expressmd.UserCode == "" || expressmd.CheckCode == null || expressmd.CheckCode == "") return "0"; WishYouApi2 obj2 = new WishYouApi2(); obj2.client_id = expressmd.client_id; obj2.ExpressId = expressmd.ExpressID; obj2.client_id = expressmd.client_id; obj2.client_secret = expressmd.client_secret; obj2.redirect_uri = expressmd.redirect_uri; obj2.refresh_token = expressmd.refresh_token; obj2.code = expressmd.Code; obj2.GetTime = expressmd.GetTime; obj2.access_token = expressmd.UserCode; string url = obj2.GetLabel(tlist); if (url.Contains("失败") == true) return ""; return url; } #endregion #region eub邮获取面单 [WebMethod(EnableSession = true)] public string EubGetPdf(List list, int PostId) { Pages.Login(this.Session); if (list == null) return ""; DD_OrderData obj1 = new DD_OrderData(); StringBuilder sb = new StringBuilder(); sb.Append(""); sb.Append(""); sb.Append("01"); sb.Append("1"); foreach (var omd in list) { string tcodes = omd.TrackCode.Trim().Replace("
", ","); string[] tcode = tcodes.Split(','); for (int i = 0; i < tcode.Length; i++) { if (tcode[i].Trim() != "") { sb.Append(""); sb.Append("" + tcode[i].Trim() + ""); sb.Append(""); } } } sb.Append("
"); JC_ExpressService obj = new JC_ExpressService(); int CompanyId = Convert.ToInt32(Session["CompanyId"]); var expressmd = obj.GetExpressModel(CompanyId, PostId); if (expressmd == null) return ""; EubApi obj2 = new EubApi(); string error = ""; string url = obj2.GetLabel(sb.ToString(), expressmd.CheckCode, out error); if (error != "") return ""; return url; } #endregion } }