using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Services; using TradeData; using NetLibrary.Data; using System.Data; using TradeModel; using NetLibrary.ReportPrint; using NetLibrary; using NetLibrary.Express; using System.Text.RegularExpressions; using NetLibrary.OnlineTrade; using System.Web.Script.Serialization; using System.Text; using NetLibrary.Log; using System.Threading; using ApiNew; using Aspose.Pdf; using System.Net; using System.Runtime.ConstrainedExecution; using System.IO; using System.Net.Http; using Newtonsoft.Json; using Org.BouncyCastle.Asn1.Pkcs; using TradeManage; using System.Security.Cryptography; using NetLibrary.WebReference; using FastJSON; using System.Runtime.CompilerServices; using Newtonsoft.Json.Serialization; using NPOI.HSSF.Record.Formula.Functions; using static NPOI.HSSF.Util.HSSFColor; using System.Linq.Expressions; using APIClients.ShopifyAPI; using LinqToDB; using Match = System.Text.RegularExpressions.Match; using TradeManageNew.APIClients.FedexApi.Tests; using TradeManageNew.APIClients.FedexAPI.Models.RatesAndTransitTimes; using TradeManageNew.Models.ShopifyUsedSale; namespace TradeManageNew { /// /// DD_OrderServiceNew 的摘要说明 /// [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_OrderServiceNew : System.Web.Services.WebService { [WebMethod] public string HelloWorld() { return "Hello World"; } #region 导出订单 [WebMethod(EnableSession = true)] public string GetListOrderPrintForExcel2(int PlatType, int IsWeight, int ShopId, int DateType, DateTime? SDate, DateTime? EDate, int OutDays, int TjType, string Name, int PrintState, int State, int IsSku, int IsError, int IsDetail, int HBOrder, int PostId, int IsAddr, int IsFP, string KWCode, string GoodsInfo, int TrackState, int FHState, int GM, int SNum, int ENum, int PageIndex, int PageSize, String Sort,string PostionCode, string PostionCode2,int StoreId) { PagesNew.Login(this.Session); var obj = new DD_OrderData(); int CompanyId = Convert.ToInt32(Session["CompanyId"]); RefParameterCollection Param = new RefParameterCollection(); if (IsFP > -1) Param.Add("isnull(a.BillPrint,0)", "=", IsFP, DbType.Int32); Param.Add("a.CompanyId", "=", CompanyId, DbType.Int32); Param.Add("a.MateState", "=", 2, DbType.Int32); if (StoreId > 0) Param.Add("b.StoreId", "=", StoreId, DbType.Int32); if (PlatType > 0) Param.Add("a.PlatId", "=", PlatType, DbType.Int32); if (ShopId > 0) Param.Add("a.ShopId", "=", ShopId, DbType.Int32); if (TrackState == 1) { Param.Add("b.TrackState", ">", 0, DbType.Int32); if (PostId == 0) Param.Add("b.Post", ">", 0, DbType.Int32); } else if (TrackState == 0) { Param.Add("b.TrackState", "=", 0, DbType.Int32); } if (DateType == 1) { if (SDate != null) Param.Add("a.OrderDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.OrderDate", "<=", EDate, DbType.DateTime); } else if (DateType == 2) { if (SDate != null) Param.Add("a.InDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.InDate", "<=", EDate, DbType.DateTime); } else if (DateType == 3) { if (SDate != null) Param.Add("a.PrintDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.PrintDate", "<=", EDate, DbType.DateTime); } else if (DateType == 4) { if (SDate != null) Param.Add("a.PostDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.PostDate", "<=", EDate, DbType.DateTime); } else if (DateType == 5) { if (SDate != null) Param.Add("a.OrderOutDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.OrderOutDate", "<=", EDate, DbType.DateTime); } if (OutDays > 0) { Param.Add("a.OrderOutDate", "<=", DateTime.Today.AddDays(OutDays), DbType.DateTime); } if (PrintState == -1 && FHState > -1) { Param.Add("a.poststate", "=", FHState, DbType.Int32); if (IsError == 1) { Param.Add("isnull(b.ErrorInfo,'')", "<>", "", DbType.String); } } else { if (IsError == 1) { Param.Add("(a.PostState", "=", 2, DbType.Int32); Param.Add("isnull(b.ErrorInfo,'')", "<>", "", "or", ")", DbType.String); } else Param.Add("a.PostState", "<", 2, DbType.Int32); } if (PrintState > -1) Param.Add("a.PrintState", "=", PrintState, DbType.Int32); if (PrintState > -1) Param.Add("a.State", "=", 1, DbType.Int32); else { Param.Add("a.State", ">", 0, DbType.Int32); Param.Add("a.State", "<", 3, DbType.Int32); //Param.Add("b.RevPhone", "is", null, "or",")",DbType.String); } if (PostId > 0) Param.Add("b.Post", "=", PostId, DbType.Int32); if (HBOrder == 1) Param.Add("a.IsJoin", "=", 1, DbType.Int32); //if (IsError == 1) //{ // Param.Add("(b.SendAddr", ">", 0, DbType.Int32); // Param.Add("b.IsLeaveWord", "=", 1, "or", ")", DbType.Int32); //} if (IsAddr > -1) { Param.Add("b.SendAddr", "=", IsAddr, DbType.Int32); } string TCode = ""; if (Name != "") { Name = Name.Trim(); if (TjType == 1) { Param.Add("(a.PlatOrderCode", "=", Name, DbType.String); Param.Add("a.JoinOrderCode", "=", Name, "or", ")", DbType.String); } else if (TjType == 2) { Param.Add("b.RevName", "like", Name, DbType.String); } else if (TjType == 3) { Param.Add("b.RevPhone", "like", Name, DbType.String); } else if (TjType == 4) { Param.Add("(b.RevCountry", "=", Name, DbType.String); Param.Add("b.CountryName", "=", Name, "or", DbType.String); Param.Add("b.CountryCode", "=", Name, "or", ")", DbType.String); } else if (TjType == 5) { Param.Add("b.RevPostCode", "=", Name, DbType.String); } else if (TjType == 6) { Param.Add("(b.RevAddr", "like", Name, DbType.String); Param.Add("b.RevProvince", "like", Name, "or", DbType.String); Param.Add("b.RevCity", "like", Name, "or", DbType.String); Param.Add("b.RevArea", "like", Name, "or", ")", DbType.String); } else if (TjType == 9) { Param.Add("(b.ErrorInfo", "like", Name, DbType.String); Param.Add("b.PostError", "like", Name, "or", ")", DbType.String); } else if (TjType == 10) { // Param.Add("b.TrackCode", "like", Name, DbType.String); TCode = Name; } } //if (IsError == 2) //{ // Param.Add("(a.SendAddr", ">", 0, DbType.Int32); // Param.Add("a.IsLeaveWord", "=", 1, "or", ")", DbType.Int32); //} if (IsWeight == 2) { Param.Add("isnull(a.IsSpare,0)", "=", 1, DbType.Int32); } else if (IsWeight == 1) { Param.Add("isnull(a.IsSpare,0)", "=", 0, DbType.Int32); } //if (IsSku == 0) // Param.Add("a.FPDate", "is", null, DbType.String); //else if (IsSku == 1) // Param.Add("a.FPDate", "is not", null, DbType.String); //Param.Add("a.OrderDate", ">=", 0, DbType.Int32); JsonModel> resultModel = new JsonModel>(); int RowCount = 0; //string Sort = "orderid desc"; //if (PrintState == 0) // Sort = "orderid"; string GoodsName = ""; string Code = ""; if (GoodsInfo != "") { GoodsName = GoodsInfo.Trim(); if (GoodsInfo.Trim().Contains(' ')) { GoodsName = GoodsInfo.Trim().Split(' ')[0].Trim(); Code = GoodsInfo.Trim().Split(' ')[1].Trim(); } } //else // if (TjType == 8 && Name != "") // { // SKU = Name; // } List orderlist = new List(); List ordertemp = new List(); if (PrintState > -1) orderlist = DataNew.GetListDT_PrintOrderInfoForTM2(CompanyId, TCode, GoodsName, 0, Code, KWCode, IsSku, GM, PrintState, Param, PageIndex, PageSize, Sort, out RowCount); else orderlist = DataNew.GetListDT_PrintOrderInfoForTM(CompanyId, TCode, GoodsName, 0, Code, KWCode, IsSku, Param, PageIndex, PageSize, Sort, out RowCount); string Ids = ""; if (orderlist != null) { foreach (var md in orderlist) { Ids += md.OrderId.ToString() + ","; ordertemp.Add(md); } } orderlist = new List(); if (Ids != "") { JC_ExpressService obj3 = new JC_ExpressService(); // var elist = obj3.GetExpressTypeList(); var plist = obj3.GetExpressList(); // var errorlist = obj.GetErrorList(Ids.Trim(',')); if (plist != null) { foreach (var md in ordertemp) { // if (errorlist != null && errorlist.Count > 0) // { // var emd = errorlist.Find(n => n.OrderId == md.OrderId); // if (emd != null) // { // md.ErrorInfo = emd.ErrorInfo; // } // } if (md.Post > 0 && plist != null && plist.Count > 0) { var emd = plist.Find(n => n.ExpressID == md.Post); if (emd != null) { md.PostInfo = emd.Name; } } } } } if (IsDetail == 0 && ordertemp != null) { if (Ids != "") { var listTrack = obj.GetTrackCodeApplyList2(Ids.Trim(',')); if (listTrack != null) { foreach (var md in ordertemp) { var list3 = new List(); if (md.JoinOrderCode != null && md.JoinOrderCode != "") list3 = listTrack.FindAll(n => n.OrderCode == md.JoinOrderCode); else list3 = listTrack.FindAll(n => n.OrderId == md.OrderId); if (list3 != null && list3.Count > 0) { string trackinfo = ""; int tcount = 0; foreach (var md1 in list3) { if (md1.TrackType < 3) { trackinfo += md1.TrackCode + ","; tcount++; } } if (IsWeight == 1 && tcount > 1 && IsError == 2) { ordertemp.Remove(md); } if (IsError == 5 && IsWeight == 1 && tcount > 1) { orderlist.Add(md); } md.TrackCode = trackinfo; } } } } } else if (IsDetail == 1 && ordertemp != null) { if (Ids != "") { var listTrack = obj.GetTrackCodeApplyList2(Ids.Trim(',')); var list1 = DataNew.GetOrderGoodsPostionList(Ids.Trim(',')); if (list1 != null) { foreach (var md in ordertemp) { var list2 = list1.FindAll(n => n.OrderId == md.OrderId); md.OrderLevel = 0; md.OrderName = ""; md.GoodsCode = ""; md.IsBlank = 0; if (list2 != null) { md.GoodsList = list2; if (PostionCode != "") { var pmd = list2.Find(n => n.PostionCode.Contains(PostionCode) == true); if (pmd != null) md.IsBlank = 1; } if (list2.Count > 0) { md.OrderLevel = list2[0].LockNum; md.OrderName = list2[0].PostionCode; md.GoodsCode = list2[0].GoodsCode; } if (SNum > 0 && ENum == 0) { if (list2.Sum(o => o.GoodsNum).GetValueOrDefault(0) >= SNum) { orderlist.Add(md); } } if (SNum > 0 && ENum > 0) { if (list2.Sum(o => o.GoodsNum).GetValueOrDefault(0) >= SNum && list2.Sum(o => o.GoodsNum).GetValueOrDefault(0) <= ENum) { orderlist.Add(md); } } if (SNum == 0 && ENum > 0) { if (list2.Sum(o => o.GoodsNum).GetValueOrDefault(0) <= ENum) { orderlist.Add(md); } } } var list3 = new List(); if (listTrack != null) { if (md.JoinOrderCode != null && md.JoinOrderCode != "") list3 = listTrack.FindAll(n => n.OrderCode == md.JoinOrderCode); else list3 = listTrack.FindAll(n => n.OrderId == md.OrderId); } if (list3 != null && list3.Count > 0) { string trackinfo = ""; int tcount = 0; foreach (var md1 in list3) { if (md1.TrackType < 3) { trackinfo += md1.TrackCode + ","; tcount++; } } if (IsWeight == 1 && tcount > 1 && IsError == 2) { ordertemp.Remove(md); } if (IsError == 5 && IsWeight == 1 && tcount > 1) { orderlist.Add(md); } md.TrackCode = trackinfo; } } } } } if (IsError == 5) ordertemp = orderlist; if (orderlist != null) { if (orderlist.Count() > 0) ordertemp = orderlist; } if (PostionCode2 != "") { ordertemp = ordertemp.FindAll(n => n.IsBlank == 0); } else if (PostionCode != "") { ordertemp = ordertemp.FindAll(n => n.IsBlank == 1); } List orderList2 = new List(); // if (PostionCode == "" || PostionCode2!="") //orderList2 = ordertemp.OrderBy(s => s.OrderLevel).ThenBy(s => s.OrderName).ThenBy(s => s.GoodsCode).ToList(); // else //orderList2 = ordertemp.OrderBy(s => s.GoodsCode).ThenBy(s => s.OrderLevel).ThenBy(s => s.OrderName).ToList(); orderList2 = ordertemp.OrderBy(s => s.OrderLevel).OrderBy(s => s.OrderName).ThenBy(s => s.GoodsCode).ThenByDescending(s => s.GoodsNum).ToList(); resultModel.DataSource = orderList2.Take(PageSize).Skip(PageSize * (PageIndex - 1)).ToList(); DataTable tb = new DataTable(); tb.Columns.Add("ordercode", Type.GetType("System.String")); //tb.Columns.Add("hbordercode", Type.GetType("System.String")); tb.Columns.Add("goodscode", Type.GetType("System.String")); tb.Columns.Add("goodscode2", Type.GetType("System.String")); tb.Columns.Add("num", Type.GetType("System.String")); tb.Columns.Add("kwcode", Type.GetType("System.String")); tb.Columns.Add("sortno", Type.GetType("System.String")); tb.Columns.Add("trackcode", Type.GetType("System.String")); string ids2 = ""; if (resultModel.DataSource != null) { foreach (var md in resultModel.DataSource) { ids2 += md.OrderId + ","; DataRow row = tb.NewRow(); if (md.JoinOrderCode != null && md.JoinOrderCode != "") row["ordercode"] = md.PlatOrderCode + " [合" + md.JoinOrderCode + "]"; else row["ordercode"] = md.PlatOrderCode; // row["hbordercode"] = md.JoinOrderCode; row["trackcode"] = md.TrackCode.TrimEnd(','); //tb.Rows.Add(row); if (md.GoodsList != null) { int i = 0; foreach (var gmd in md.GoodsList) { i++; if (i == 1) { if (gmd.OldTypeDesc != null && gmd.OldTypeDesc != "") row["goodscode"] = gmd.OldTypeDesc; else row["goodscode"] = gmd.GoodsCode; if(gmd.GoodsOldCode!=null) row["goodscode2"] = gmd.GoodsOldCode; row["num"] = gmd.GoodsNum.ToString(); row["kwcode"] = gmd.PostionCode.ToString(); row["sortno"] = gmd.LockNum.ToString(); tb.Rows.Add(row); } else { DataRow row1 = tb.NewRow(); row1["ordercode"] = ""; if (gmd.OldTypeDesc != null && gmd.OldTypeDesc != "") row1["goodscode"] = gmd.OldTypeDesc; else row1["goodscode"] = gmd.GoodsCode; if (gmd.GoodsOldCode != null) row1["goodscode2"] = gmd.GoodsOldCode; row1["num"] = gmd.GoodsNum.ToString(); row1["kwcode"] = gmd.PostionCode.ToString(); row1["sortno"] = gmd.LockNum.ToString(); tb.Rows.Add(row1); } } } } DataTable dtCopy = tb.Copy(); DataView dv = tb.DefaultView; dv.Sort = "sortno,kwcode"; dtCopy = dv.ToTable(); if (ids2 != null) { DataRow row2 = dtCopy.NewRow(); row2["ordercode"] = ""; row2["goodscode"] = ""; row2["goodscode2"] = ""; row2["num"] = ""; row2["kwcode"] = ""; dtCopy.Rows.Add(row2); row2 = dtCopy.NewRow(); row2["ordercode"] = ""; row2["goodscode"] = ""; row2["goodscode2"] = ""; row2["num"] = ""; row2["kwcode"] = ""; dtCopy.Rows.Add(row2); row2 = dtCopy.NewRow(); row2["ordercode"] = "Total:"; row2["goodscode"] = ""; row2["goodscode2"] = ""; row2["num"] = ""; row2["kwcode"] = ""; dtCopy.Rows.Add(row2); List list8 = DataNew.GetOrderGoodsPostionList22(ids2.Trim(',')); if (list8 != null) { foreach (DT_OrderGoods goods2 in list8) { row2 = dtCopy.NewRow(); row2["ordercode"] = ""; if (goods2.OldTypeDesc != null && goods2.OldTypeDesc != "") row2["goodscode"] = goods2.OldTypeDesc; else row2["goodscode"] = goods2.GoodsCode; row2["goodscode2"] = goods2.GoodsOldCode; row2["num"] = goods2.GoodsNum; row2["kwcode"] = goods2.PostionCode; dtCopy.Rows.Add(row2); } } } string cn = "QTY" + DateTime.Today.ToString("MMdd"); TableColumnCollection listColumns = new TableColumnCollection(); listColumns.Add("ordercode", "OrderCode", DbType.String, ""); listColumns.Add("goodscode", "SKU", DbType.String, ""); listColumns.Add("goodscode2", "GoodsCode2", DbType.String, ""); listColumns.Add("num", cn, DbType.String, ""); listColumns.Add("kwcode", "LOCATION", DbType.String, ""); listColumns.Add("trackcode", "Trackcode", DbType.String, ""); MicrosoftExcel obj2 = new MicrosoftExcel(); return obj2.Export(dtCopy, listColumns); } return ""; } #endregion #region 判断是否是数字 [WebMethod(EnableSession = true)] public int CheckNum(string str) { try { string count = str.Trim(); str = count.PadLeft(5, '0'); str = str.Substring(0, 5); int temp = Convert.ToInt32(str); return 1; } catch { return 0; } } #endregion #region 获取订单物流跟踪码 [WebMethod(EnableSession = true)] public DT_TrackCode GetOrderTrackCodeModel(DT_Order model, int TrackType) { PagesNew.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.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")) { FedexSmartPostNew fedexobj = new FedexSmartPostNew(); FedexSmartPostNew.Key = md.UserCode; FedexSmartPostNew.Password = md.CheckCode; FedexSmartPostNew.AccountNumber = md.client_id; FedexSmartPostNew.MeterNumber = md.client_secret; FedexSmartPostNew.PayAccountNumber = md.refresh_token; FedexSmartPostNew.HubId = md.Code; FedexSmartPostNew.PostName = md.customercode; FedexOrder fdorder = new FedexOrder(); Shiper shiper = new Shiper { City = companymd.city, CompanyName = companymd.SendName, 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, Height="", Width="", Lenght="", 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) { PagesNew.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.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(); PagesNew.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.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 导入新平台订单 [WebMethod(EnableSession = true)] public string ImportNewOrderHWC(string FileName, int CompanyId, int ShopId, int StoreId) { PagesNew.Login(this.Session); if (string.IsNullOrEmpty(FileName) == true) return "要导入的文件路径不能为空"; string ServerFileName = AppDomain.CurrentDomain.BaseDirectory + FileName; if (System.IO.File.Exists(ServerFileName) == false) return "要导入的文件路径不存在"; //int CompanyId = Convert.ToInt32(Session["CompanyId"]); try { MicrosoftExcel excel = new MicrosoftExcel(); DataTable tb = excel.ImportExcel(ServerFileName); string error = ""; if (tb.Columns.Contains("订单日期") == false) { error = error + "导入模板的 订单日期 列不存在"; } if (tb.Columns.Contains("订单号") == false) { error = error + "导入模板的 订单号 列不存在"; } if (tb.Columns.Contains("收件人") == false) { error = error + "导入模板的 收件人 列不存在"; } if (tb.Columns.Contains("地址1") == false) { error = error + "导入模板的 地址1 列不存在"; } if (tb.Columns.Contains("sku") == false) { error = error + "导入模板的 sku 列不存在"; } if (tb.Columns.Contains("订单金额$") == false) { error = error + "导入模板的 订单金额$ 列不存在"; } if (string.IsNullOrEmpty(error) == false) return error + ";请导入格式不正确"; DD_OrderData obj = new DD_OrderData(); int UserId = Convert.ToInt32(Session["UserId"]); List OrderList = new List(); int Num = 0; int PlatId = 0; var smd = JC_ShopService.GetModel(ShopId); PlatId = smd.PlatType.Value; for (int i = 0; i < tb.Rows.Count; i++) { DT_ExcelOrderInfo md = new DT_ExcelOrderInfo(); string PlatOrderCode = tb.Rows[i]["订单号"].ToString().Trim(); if (PlatOrderCode == "") { // error += "第" + (i + 2).ToString() + " 行的order number没填
"; continue; } md.PlatOrderCode = PlatOrderCode; md.OrderCode = PlatOrderCode; md.PlatId = PlatId; md.ShopId = ShopId; if (tb.Rows[i]["订单金额$"].ToString().Trim() == "") { md.TotalPrice = 0; } else { try { md.TotalPrice = Convert.ToDecimal(tb.Rows[i]["订单金额$"].ToString().Trim()); } catch (Exception ex) { error += "第" + (i + 2).ToString() + " 行的价格必须是数字
"; continue; } } int PayState = 1; int OrderState = 1; md.OrderDate = DateTime.Now; md.PayDate = DateTime.Now; md.PayState = PayState; md.OrderState = OrderState; md.RevName = tb.Rows[i]["收件人"].ToString().Trim(); if (md.RevName == "") { error += "第" + (i + 2).ToString() + " 行的收件人没填
"; continue; } //md.OrderName = tb.Rows[i]["sales_order"].ToString().Trim(); md.RevAddr = tb.Rows[i]["地址1"].ToString().Trim() + " " + tb.Rows[i]["地址2"].ToString().Trim(); if (md.RevAddr == "") { error += "第" + (i + 2).ToString() + " 行的地址1没填
"; continue; } try { if (tb.Rows[i]["订单日期"].ToString().Trim() != "") md.OrderDate = Convert.ToDateTime(tb.Rows[i]["订单日期"].ToString().Trim()); else md.OrderDate = DateTime.Today; } catch (Exception ex) { md.OrderDate = DateTime.Today; } md.PayDate = DateTime.Today; md.RevPostCode = tb.Rows[i]["邮编"].ToString().Trim().Replace("'", ""); if (md.RevPostCode == "") md.RevPostCode = "12345"; md.RevProvince = tb.Rows[i]["省州"].ToString().Trim(); md.RevCity = tb.Rows[i]["城市"].ToString().Trim(); if (md.RevProvince == null || md.RevProvince == "") md.RevProvince = md.RevCity; md.RevPhone = tb.Rows[i]["电话"].ToString().Trim().Replace("'", "").Replace("+", "").Replace("+", "").Replace("(", "").Replace(")", "").Replace(" ", ""); md.CustomID = ""; md.RevMoblie = tb.Rows[i]["电话"].ToString().Trim().Replace("'", "").Replace("+", "").Replace("+", "").Replace("(", "").Replace(")", "").Replace(" ", ""); md.LeaveWord = ""; md.TrackCode = ""; md.RevCountry = "US"; md.MoneyCode = "USD"; md.CompanyId = CompanyId; md.InUserId = UserId; List Glist = new List(); var GoodsModel = new DT_OrderExcelGoods(); if (tb.Rows[i]["数量"].ToString().Trim() == "") { // error += "第" + (i + 2).ToString() + " 行的quantity没填
"; // continue; GoodsModel.GoodsNum = 1; } else { try { GoodsModel.GoodsNum = Convert.ToInt32(tb.Rows[i]["数量"].ToString().Trim()); } catch (Exception ex) { error += "第" + (i + 2).ToString() + " 行的数量必须是数字
"; continue; } } GoodsModel.SKU = tb.Rows[i]["sku"].ToString().Trim(); if (GoodsModel.SKU == "") { error += "第" + (i + 2).ToString() + " 行的sku 信息没填
"; continue; } md.GoodsNum = GoodsModel.GoodsNum; GoodsModel.GoodsName = GoodsModel.SKU; GoodsModel.GoodsPrice = md.TotalPrice; if (OrderList != null) { var omd = OrderList.Find(n => n.PlatOrderCode == PlatOrderCode); if (omd != null)//相同订单号 sku合并 { omd.GoodsList.Add(GoodsModel); continue; } } GoodsModel.CompanyId = CompanyId; Glist.Add(GoodsModel); md.OrderName = ""; md.PostFee = 0; md.RevMail = ""; md.RevFax = ""; md.RevArea = ""; md.PostInfo = ""; md.GoodsList = Glist; OrderList.Add(md); } if (error != "") { return error; } else if (OrderList.Count > 0) { string OrderIds = ""; foreach (var md in OrderList) { md.StoreId = StoreId; int OrderId = obj.ExcelOrderAdd4(md); OrderIds += OrderId.ToString() + ","; } obj.UpdateOrderGoodsNum(); if (OrderIds != "") PartOrderGoodsLockForHWC(CompanyId, 0, 6, OrderIds.TrimEnd(','), ""); error = "数据导入成功【" + OrderList.Count.ToString() + "条】;" + error; return error; } } catch (Exception e) { return "文件导入失败!请确定模板格式是否正确,或者重新下载模板,填写数据,重新导入!!!" + e.Message; } return "导入成功"; } #endregion #region 全部订单锁定匹配货物海外仓 [WebMethod(EnableSession = true)] public string AllOrderGoodsLockForHWC(int CompanyId, int IsError, int StoreId) { PagesNew.Login(this.Session); var obj = new DD_OrderData(); int Num = 0; if (CompanyId == 1) return ""; int UserId = Convert.ToInt32(Session["UserId"]); try { string Sort = "a.OrderLevel desc,a.OrderDate"; obj.SetStore();//仓库调整 var orderlist = DataNew.GetLockOrderListForHWC(CompanyId, IsError, StoreId, Sort); var list = DataNew.GetLockOrderGoodsForHWC(CompanyId, StoreId, IsError); var KClist = DataNew.GetNowKCGoodsHWC(CompanyId, IsError, StoreId); var nfplist = obj.GetNoFPOrderList(); List mlist = new List(); if (orderlist != null && list != null && KClist != null && orderlist.Count > 0 && list.Count > 0 && KClist.Count > 0) { var hwlist2 = new List(); var OrderMatelist = new List(); List JoinOrderList = new List(); foreach (var ordermd in orderlist) { //if (ordermd.OrderId == 5329133) //{ // string a = ""; //} string JoinOrderCode = ""; if (ordermd.JoinOrderCode != null && ordermd.JoinOrderCode != "") JoinOrderCode = ordermd.JoinOrderCode; if (JoinOrderCode != "") { if (JoinOrderList != null && JoinOrderList.Count > 0) { var jmd = JoinOrderList.Find(n => n.JoinOrderCode == JoinOrderCode); DT_OrderMateKCOrder nmd = null; if (nfplist != null && nfplist.Count > 0) nmd = nfplist.Find(n => n.JoinOrderCode == JoinOrderCode); if (jmd != null || nmd != null) continue; else { var jmd1 = new DT_OrderMateKCGoods(); jmd1.JoinOrderCode = JoinOrderCode; JoinOrderList.Add(jmd1); } } else { var jmd1 = new DT_OrderMateKCGoods(); jmd1.JoinOrderCode = JoinOrderCode; JoinOrderList.Add(jmd1); } } List listGoods = new List(); List OutList = new List(); var Goodslist = new List(); if (JoinOrderCode == "") Goodslist = list.FindAll(n => n.OrderId == ordermd.OrderId); else //合并订单 Goodslist = list.FindAll(n => n.JoinOrderCode == JoinOrderCode); if (Goodslist != null && Goodslist.Count > 0) { var hwlist1 = new List(); bool qbFlag = true;//全部货物满足 bool Flag = false;//全部货物满足 foreach (var goodsmd in Goodslist) { int DDNum = goodsmd.GoodsNum.Value; int LeftNum = DDNum; var kcmdlist = KClist.FindAll(n => n.DetailId == goodsmd.DetailId && n.KCNum - n.LockNum > 0); if (kcmdlist == null || kcmdlist.Count == 0) { qbFlag = false; Flag = false; continue; } foreach (var kcmd in kcmdlist) { if (kcmd.KCNum - kcmd.LockNum >= LeftNum) { kcmd.LockNum += LeftNum; var ckmd = new DT_OrderNowKCGoods(); ckmd.OrderNum = LeftNum; ckmd.InId = kcmd.InId; ckmd.OrderId = ordermd.OrderId; ckmd.OrderGoodsId = goodsmd.Id; ckmd.StoreId = kcmd.StoreId; ckmd.PostionId = kcmd.PostionId; ckmd.DetailId = kcmd.DetailId; hwlist1.Add(ckmd); LeftNum = 0; break; } else { var ckmd = new DT_OrderNowKCGoods(); ckmd.OrderNum = kcmd.KCNum.Value - kcmd.LockNum.Value; ckmd.InId = kcmd.InId; ckmd.OrderId = ordermd.OrderId; ckmd.OrderGoodsId = goodsmd.Id; ckmd.StoreId = kcmd.StoreId; ckmd.PostionId = kcmd.PostionId; ckmd.DetailId = kcmd.DetailId; hwlist1.Add(ckmd); LeftNum = LeftNum - kcmd.KCNum.Value + kcmd.LockNum.Value; kcmd.LockNum = kcmd.KCNum; } } if (LeftNum <= 0) { Flag = true; goodsmd.IsMate = 1; } else { qbFlag = false; Flag = false; goodsmd.IsMate = 0; } } if (qbFlag == true && Flag == true) { mlist.Add(ordermd); ordermd.IsMate = 1; if (hwlist1 != null) { foreach (var hmd in hwlist1) { hwlist2.Add(hmd); } } } else { foreach (var hmd in hwlist1) { var opmd = new HW_OrderMate(); opmd.InId = hmd.InId; opmd.Num = hmd.OrderNum; opmd.DetailId = hmd.DetailId; opmd.GoodsOrderId = hmd.OrderGoodsId; opmd.StoreId = hmd.StoreId; opmd.PostionId = hmd.PostionId; OrderMatelist.Add(opmd); } hwlist1.Clear(); } } } // var olist=orderlist.FindAll(n=>n.IsMate==1); if (mlist != null) { Num = mlist.Count; //string OrderIds = ""; // string JoinOrderCodes = ""; foreach (var omd in mlist) { int OrderId = 0; string JoinOrderCode = ""; if (omd.JoinOrderCode != null && omd.JoinOrderCode != "") JoinOrderCode = omd.JoinOrderCode; else OrderId = omd.OrderId.Value; var cklist = hwlist2.FindAll(n => n.OrderId == omd.OrderId); if (cklist != null && cklist.Count > 0) DataNew.UpdateOrderGoodsLockForHWC(OrderId, JoinOrderCode, cklist); } //if (OrderIds != "" || JoinOrderCodes != "") // obj.UpdateOrderGoodsLockForTM31(OrderIds.Trim(','), JoinOrderCodes.Trim(',')); } //obj.DeleteOrderMate(); //if (OrderMatelist != null) //{ // foreach (var mmd in OrderMatelist) // { // obj.SaveOrderMate(mmd); // } //} } } catch (Exception ex) { return ex.Message; } return "匹配" + Num.ToString() + "条"; } #endregion #region 海外仓订单匹配货物 [WebMethod(EnableSession = true)] public string PartOrderGoodsLockForHWC(int CompanyId, int IsError, int StoreId, string OrderIds, string JoinOrderCodes) { PagesNew.Login(this.Session); var obj = new DD_OrderData(); int Num = 0; if (CompanyId == 1) return ""; int UserId = Convert.ToInt32(Session["UserId"]); try { string Sort = "a.OrderLevel desc,a.OrderDate"; var orderlist = DataNew.GetLockPartOrderListForHWC(CompanyId, OrderIds.Trim(','), JoinOrderCodes.Trim(','), IsError, StoreId, Sort); var list = DataNew.GetLockPartOrderGoodsForHWC(CompanyId, OrderIds.Trim(','), JoinOrderCodes.Trim(','), StoreId, IsError); var nfplist = DataNew.GetNoFPOrderList2(CompanyId); if (orderlist != null && list != null) { var hwlist = new List(); //货物占用 var hwlist2 = new List(); var hwnolist = new List(); //不够的货物 List JoinOrderList = new List(); foreach (var ordermd in orderlist) { string JoinOrderCode = ""; if (ordermd.JoinOrderCode != null && ordermd.JoinOrderCode != "") JoinOrderCode = ordermd.JoinOrderCode; List listGoods = new List(); List OutList = new List(); var Goodslist = new List(); if (JoinOrderCode == "") Goodslist = list.FindAll(n => n.OrderId == ordermd.OrderId); else //合并订单 Goodslist = list.FindAll(n => n.JoinOrderCode == JoinOrderCode); if (JoinOrderCode != "") { if (JoinOrderList != null && JoinOrderList.Count > 0) { var jmd = JoinOrderList.Find(n => n.JoinOrderCode == JoinOrderCode); DT_OrderMateKCOrder nmd = null; if (nfplist != null && nfplist.Count > 0) nmd = nfplist.Find(n => n.JoinOrderCode == JoinOrderCode); if (jmd != null || nmd != null) continue; else { var jmd1 = new DT_OrderGoods(); jmd1.JoinOrderCode = JoinOrderCode; JoinOrderList.Add(jmd1); } } else { var jmd1 = new DT_OrderGoods(); jmd1.JoinOrderCode = JoinOrderCode; JoinOrderList.Add(jmd1); } } if (Goodslist != null) { bool Flag = false; //匹配标记 bool qbFlag = true;//全部货物满足 foreach (var goodsmd in Goodslist) { int ZYNum = 0;//占用数量 int DDNum = goodsmd.GoodsNum.Value;//订单数量 if (hwnolist != null) { var hwnodetail = hwnolist.Find(n => n.DetailId == goodsmd.DetailId); if (hwnodetail != null)//已经在没有库存记录里 { Flag = false; qbFlag = false; continue; } } if (hwlist != null) { var hwdetail = hwlist.Find(n => n.DetailId == goodsmd.DetailId); if (hwdetail != null)//已经在没有满足库存记录里 { ZYNum = hwdetail.KCNum.Value; } } var inlist = DataNew.GetMateOrderGoodsInForHWC(goodsmd.DetailId.Value, StoreId); if (inlist == null || inlist.Count == 0)//没有库存 { Flag = false; qbFlag = false; HW_GoodsOutDetail hwnomd = new HW_GoodsOutDetail(); hwnomd.DetailId = goodsmd.DetailId; hwnolist.Add(hwnomd); continue; } int LeftNum = DDNum; foreach (var kcmd in inlist) { if (kcmd.KCNum.Value >= LeftNum + ZYNum) { HW_GoodsInDetail hwinmd = new HW_GoodsInDetail(); hwinmd.DetailId = goodsmd.DetailId; hwinmd.InId = kcmd.InId; hwinmd.Price = kcmd.Price; hwinmd.PostPrice = kcmd.PostPrice; hwinmd.OrderGoodsId = goodsmd.Id; hwinmd.KCNum = LeftNum; hwlist2.Add(hwinmd); LeftNum = 0; break; } else if (kcmd.KCNum.Value < LeftNum + ZYNum) { HW_GoodsInDetail hwinmd = new HW_GoodsInDetail(); hwinmd.DetailId = goodsmd.DetailId; hwinmd.InId = kcmd.InId; hwinmd.Price = kcmd.Price; hwinmd.PostPrice = kcmd.PostPrice; hwinmd.OrderGoodsId = goodsmd.Id; hwinmd.KCNum = kcmd.KCNum.Value; hwlist2.Add(hwinmd); LeftNum = LeftNum - kcmd.KCNum.Value; } } if (LeftNum == 0) //够分配 { Flag = true; } else //不够分配 { Flag = false; qbFlag = false; var bgmd = hwlist.Find(n => n.DetailId == goodsmd.DetailId); if (bgmd != null) { bgmd.KCNum += DDNum; } else { var bgmd1 = new HW_GoodsInDetail(); bgmd1.KCNum = DDNum; hwlist.Add(bgmd1); } } } if (Flag == true && qbFlag == true)//已经分配 { decimal GoodsFee = 0; //货物采购均价 decimal PostFee = 0;//货物快递成本 if (hwlist2 != null) { Num++; //int Num = hwlist2.Count; foreach (var md in hwlist2) { if (md.Price != null) GoodsFee += md.Price.Value * md.KCNum.Value; if (md.PostPrice != null) PostFee += md.PostPrice.Value * md.KCNum.Value; } //if (Num > 0) //{ // GoodsFee = GoodsFee / Num; // PostFee = PostFee / Num; //} } DataNew.UpdateOrderGoodsLockForHWC(ordermd.OrderId.Value, 2, GoodsFee, PostFee, JoinOrderCode, hwlist2); hwlist2.Clear(); } else //未分配 { if (hwlist2 != null) { foreach (var md in hwlist2) { var bgmd = hwlist.Find(n => n.DetailId == md.DetailId); if (bgmd != null) { bgmd.KCNum += md.KCNum.Value; } else { var bgmd1 = new HW_GoodsInDetail(); bgmd1.KCNum = md.KCNum.Value; hwlist.Add(bgmd1); } } hwlist2.Clear(); } } } } } } catch (Exception ex) { return ex.Message; } return "匹配" + Num.ToString() + "条"; } #endregion #region 查询订单 [WebMethod(EnableSession = true)] public JsonModel> GetListOrderForHWC(int CompanyId,int StoreId, int PlatType, int ShopId, int DateType, DateTime? SDate, DateTime? EDate, int TjType, string Name, int PrintState, int MateState, int State, int PageIndex, int PageSize, string Sort) { PagesNew.Login(this.Session); var obj = new DD_OrderData(); // int CompanyId = Convert.ToInt32(Session["CompanyId"]); RefParameterCollection Param = new RefParameterCollection(); Param.Add("a.CompanyId", "=", CompanyId, DbType.Int32); if (StoreId > 0) { Param.Add("a.StoreId", "=", StoreId, DbType.Int32); } if (PlatType > 0) Param.Add("a.PlatId", "=", PlatType, DbType.Int32); if (ShopId > 0) Param.Add("a.ShopId", "=", ShopId, DbType.Int32); if (DateType == 1) { if (SDate != null) Param.Add("a.OrderDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.OrderDate", "<", EDate.Value.AddDays(1), DbType.DateTime); } else if (DateType == 2) { if (SDate != null) Param.Add("a.InDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.InDate", "<", EDate.Value.AddDays(1), DbType.DateTime); } else if (DateType == 3) { if (SDate != null) Param.Add("a.PrintDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.PrintDate", "<", EDate.Value.AddDays(1), DbType.DateTime); } else if (DateType == 4) { if (SDate != null) Param.Add("a.PostDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.PostDate", "<", EDate.Value.AddDays(1), DbType.DateTime); } else if (DateType == 5) { if (SDate != null) Param.Add("a.OrderOutDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.OrderOutDate", "<", EDate.Value.AddDays(1), DbType.DateTime); } if (MateState > -1) Param.Add("a.MateState", "=", MateState, DbType.Int32); if (PrintState > -1) Param.Add("a.PrintState", "=", PrintState, DbType.Int32); if (State == 3) Param.Add("a.State", "=", 2, DbType.Int32); else if (State == 4) Param.Add("a.State", "=", 3, DbType.Int32); else if (State == 5) { Param.Add("a.State", "=", 1, DbType.Int32); Param.Add("a.MoneyState", "=", 1, DbType.Int32); } else if (State == 1) { //Param.Add("a.State", "=", 2, DbType.Int32); Param.Add("a.PostState", "=", 1, DbType.Int32); } else if (State == 2) { Param.Add("a.State", "<", 3, DbType.Int32); Param.Add("a.PostState", "=", 2, DbType.Int32); } else if (State == 0) { //Param.Add("a.State", "=", 2, DbType.Int32); Param.Add("a.State", "=", 1, DbType.Int32); } else Param.Add("a.State", ">", 0, DbType.Int32); string TCode = ""; if (Name != "") { Name = Name.Trim(); if (TjType == 1) { Param.Add("(a.PlatOrderCode", "like", Name, DbType.String); Param.Add("OrderCode", "like", Name, "or", DbType.String); Param.Add("a.JoinOrderCode", "like", Name, "or", ")", DbType.String); } else if (TjType == 2) { Param.Add("a.RevName", "like", Name, DbType.String); } else if (TjType == 3) { Param.Add("a.RevPhone", "like", Name, DbType.String); } else if (TjType == 4) { Param.Add("(a.RevCountry", "=", Name, DbType.String); Param.Add("a.CountryName", "=", Name, "or", DbType.String); Param.Add("a.CountryCode", "=", Name, "or", ")", DbType.String); } else if (TjType == 5) { Param.Add("a.RevPostCode", "=", Name, DbType.String); } else if (TjType == 6) { Param.Add("(a.RevAddr", "like", Name, DbType.String); Param.Add("a.RevProvince", "like", Name, "or", DbType.String); Param.Add("a.RevCity", "like", Name, "or", DbType.String); Param.Add("a.RevArea", "like", Name, "or", ")", DbType.String); } else if (TjType == 9) { Param.Add("(a.ErrorInfo", "like", Name, DbType.String); Param.Add("a.PostError", "like", Name, "or", ")", DbType.String); } else if (TjType == 10) { //Param.Add("dbo.getOrderTrackCode(a.OrderId,0)", "like", Name, DbType.String); TCode = Name; } else if (TjType == 11) { Param.Add("a.CustomID", "=", Name, DbType.String); } else if (TjType == 12) { Param.Add("a.RevMail", "=", Name, DbType.String); } } JsonModel> resultModel = new JsonModel>(); int RowCount = 0; //string Sort = "orderid desc"; string GoodsName = ""; string SKU = ""; if (TjType == 7 && Name != "") { GoodsName = Name; } else if (TjType == 8 && Name != "") { SKU = Name; } // if (State == 0 || State == 2) resultModel.DataSource = DataNew.GetListDT_OrderInfoForHWC(CompanyId, GoodsName.Trim(), SKU.Trim(), TCode, -1, 0, Param, PageIndex, PageSize, Sort, out RowCount); // else // resultModel.DataSource = obj.GetListDT_OrderInfoForTM(CompanyId, GoodsName.Trim(), SKU.Trim(), TCode, -1, 0, Param, PageIndex, PageSize, Sort, out RowCount); resultModel.RowCount = RowCount; string Ids = ""; if (resultModel.DataSource != null) { foreach (var md in resultModel.DataSource) { Ids += md.OrderId.ToString() + ","; } } if (Ids != "") { var errorlist = obj.GetErrorList(Ids.Trim(',')); if (errorlist != null && errorlist.Count > 0) { foreach (var md in resultModel.DataSource) { var emd = errorlist.Find(n => n.OrderId == md.OrderId); if (emd != null) { md.ErrorInfo = emd.ErrorInfo; } } } } if (resultModel.DataSource != null) { if (Ids != "") { var list1 = DataNew.GetOrderGoodsListHWC(Ids.Trim(',')); var listTrack = obj.GetTrackCodeApplyList(Ids.Trim(',')); if (list1 != null) { foreach (var md in resultModel.DataSource) { var list2 = list1.FindAll(n => n.OrderId == md.OrderId); if (list2 != null) { md.GoodsList = list2; } } } if (listTrack != null) { foreach (var md in resultModel.DataSource) { var list3 = new List(); if (md.JoinOrderCode != null && md.JoinOrderCode != "") list3 = listTrack.FindAll(n => n.OrderCode == md.JoinOrderCode); else list3 = listTrack.FindAll(n => n.OrderId == md.OrderId); if (list3 != null && list3.Count > 0) { string trackinfo = ""; string TrackCode = ""; foreach (var md1 in list3) { string blank = ""; if (md1.TrackType == 3) blank = "[空包裹]"; if (md1.Weight != null) { string dd = ""; if (md1.ScanDate != null) dd = "发货时间:" + md1.ScanDate.Value.ToString("yyyy-MM-dd HH:mm"); trackinfo += md1.TrackCode + blank + "重量" + md1.Weight.ToString() + "g" + dd + "
"; } else trackinfo += md1.TrackCode + blank + "
"; if (TrackCode == "") TrackCode = md1.TrackCode; } md.TrackInfo = trackinfo; md.TrackCode = TrackCode; } } } } } return resultModel; } #endregion #region 查询物流订单 [WebMethod(EnableSession = true)] public JsonModel> GetListOrderExpressHWC(int CompanyId, int Num, int PlatType, int TrackState, int MateState, int ShopId, int DateType, DateTime? SDate, DateTime? EDate, int OutDays, int TjType, string Name, int ExpressState, int IsSku, int IsError, int IsDetail, int HBOrder, int PostId, int LogisticsId, int Addr, int PageIndex, int PageSize, string Sort) { PagesNew.Login(this.Session); var obj = new DD_OrderData(); RefParameterCollection Param = new RefParameterCollection(); if (Num == 1) Param.Add("a.GoodsNum", "=", 1, DbType.Int32); else if (Num == 2) Param.Add("a.GoodsNum", ">", 1, DbType.Int32); Param.Add("a.CompanyId", "=", CompanyId, DbType.Int32); if (MateState > -1) Param.Add("a.MateState", "=", MateState, DbType.Int32); int IsTrack = TrackState; //if (ExpressState>-1) Param.Add("isnull(a.PrintState,0)", "=", 0, DbType.Int32); if (PlatType > 0) Param.Add("a.PlatId", "=", PlatType, DbType.Int32); if (ShopId > 0) Param.Add("a.ShopId", "=", ShopId, DbType.Int32); if (DateType == 1) { if (SDate != null) Param.Add("a.OrderDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.OrderDate", "<", EDate.Value.AddDays(1), DbType.DateTime); } else if (DateType == 2) { if (SDate != null) Param.Add("a.InDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.InDate", "<", EDate.Value.AddDays(1), DbType.DateTime); } else if (DateType == 3) { if (SDate != null) Param.Add("a.PrintDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.PrintDate", "<", EDate.Value.AddDays(1), DbType.DateTime); } else if (DateType == 4) { if (SDate != null) Param.Add("a.PostDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.PostDate", "<", EDate.Value.AddDays(1), DbType.DateTime); } else if (DateType == 5) { if (SDate != null) Param.Add("a.OrderOutDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.OrderOutDate", "<", EDate.Value.AddDays(1), DbType.DateTime); } if (OutDays > 0) { Param.Add("a.OrderOutDate", "<=", DateTime.Now.AddHours(OutDays), DbType.DateTime); Param.Add("a.OrderOutDate", ">=", DateTime.Now, DbType.DateTime); } if (LogisticsId > 0) Param.Add("b.LogisticsId", "=", LogisticsId, DbType.String); if (ExpressState == 0) { Param.Add("isnull(b.Post,0)", "=", 0, DbType.Int32); } else if (ExpressState == 2) { Param.Add("b.Post", ">", 0, DbType.Int32); Param.Add("isnull(b.TrackState,0)", "=", 0, DbType.Int32); } else if (ExpressState == 1) { Param.Add("b.Post", ">", 0, DbType.Int32); Param.Add("b.TrackState", ">", 0, DbType.Int32); } if (PostId > 0) Param.Add("b.Post", "=", PostId, DbType.Int32); Param.Add("a.State", "=", 1, DbType.Int32); if (HBOrder == 1) Param.Add("a.IsJoin", "=", 1, DbType.Int32); if (IsError == 1) { Param.Add("(b.SendAddr", ">", 0, DbType.Int32); Param.Add("b.IsLeaveWord", "=", 1, "or", ")", DbType.Int32); } string TCode = ""; if (Name != "") { if (TjType == 1) { Param.Add("(a.PlatOrderCode", "=", Name, DbType.String); Param.Add("a.JoinOrderCode", "=", Name, "or", ")", DbType.String); } else if (TjType == 2) { Param.Add("b.RevName", "like", Name, DbType.String); } else if (TjType == 3) { Param.Add("b.RevPhone", "like", Name, DbType.String); } else if (TjType == 4) { Param.Add("(b.RevCountry", "=", Name, DbType.String); Param.Add("b.CountryName", "=", Name, "or", DbType.String); Param.Add("b.CountryCode", "=", Name, "or", ")", DbType.String); } else if (TjType == 5) { Param.Add("b.RevPostCode", "=", Name, DbType.String); } else if (TjType == 6) { Param.Add("(b.RevAddr", "like", Name, DbType.String); Param.Add("b.RevProvince", "like", Name, "or", DbType.String); Param.Add("b.RevCity", "like", Name, "or", DbType.String); Param.Add("b.RevArea", "like", Name, "or", ")", DbType.String); } else if (TjType == 9) { Param.Add("(b.ErrorInfo", "like", Name, DbType.String); Param.Add("b.PostError", "like", Name, "or", ")", DbType.String); } else if (TjType == 10) { // Param.Add("dbo.getOrderTrackCode(a.OrderId,1)", "like", Name, DbType.String); TCode = Name; } } if (IsSku == 0) Param.Add("a.FPDate", "is", null, DbType.String); else if (IsSku == 1) Param.Add("a.FPDate", "is not", null, DbType.String); //if (Addr > -1) //{ // Param.Add("b.SendAddr", "=", Addr, DbType.Int32); //} // Param.Add("a.OrderDate", ">=", 0, DbType.Int32); JsonModel> resultModel = new JsonModel>(); int RowCount = 0; //var pxlist = obj.GetLevelConfig(CompanyId, 0); // string Sort = "JoinOrderCode,PlatOrderCode"; //if (pxlist != null) //{ // Sort = ""; // foreach (var md in pxlist) // { // if (md.SortType == 1) // Sort += "a.OrderLevel desc,"; // else if (md.SortType == 2) // Sort += "a.OrderDate,"; // else if (md.SortType == 3) // Sort += "c.LevelGrade desc,"; // else if (md.SortType == 4) // Sort += "a.RMBPrice desc,"; // } //} //Sort = Sort.Trim(','); string GoodsName = ""; string SKU = ""; if (TjType == 7 && Name != "") { GoodsName = Name; } else if (TjType == 8 && Name != "") { SKU = Name; } resultModel.DataSource = DataNew.GetListDT_OrderInfoExpressHWC(IsTrack, TCode, GoodsName, SKU, IsSku, Param, PageIndex, PageSize, Sort, out RowCount); resultModel.RowCount = RowCount; string Ids = ""; if (resultModel.DataSource != null) { foreach (var md in resultModel.DataSource) { Ids += md.OrderId.ToString() + ","; } } if (Ids != "") { JC_ExpressService obj3 = new JC_ExpressService(); var elist = obj3.GetExpressTypeList(); var plist = obj3.GetExpressList(); var errorlist = obj.GetErrorList(Ids.Trim(',')); if (errorlist != null || elist != null || plist != null) { foreach (var md in resultModel.DataSource) { if (errorlist != null && errorlist.Count > 0) { var emd = errorlist.Find(n => n.OrderId == md.OrderId); if (emd != null) { md.ErrorInfo = emd.ErrorInfo; } } //if (md.LogisticsId>0&&elist != null && elist.Count > 0) //{ // var emd = elist.Find(n => n.LogisticsId == md.LogisticsId); // if (emd != null) // { // md.PostInfo = emd.LogisticsName; // } //} if (md.Post > 0 && plist != null && plist.Count > 0) { var emd = plist.Find(n => n.ExpressID == md.Post); if (emd != null) { md.LocalPost = emd.Name; } } } } } if (resultModel.DataSource != null) { if (Ids != "") { if (IsDetail == 1) { var list1 = obj.GetOrderGoodsList(Ids.Trim(',')); if (list1 != null) { foreach (var md in resultModel.DataSource) { var list2 = list1.FindAll(n => n.OrderId == md.OrderId); if (list2 != null) { md.GoodsList = list2; } } } } var listTrack = obj.GetTrackCodeApplyList(Ids.Trim(',')); if (listTrack != null) { foreach (var md in resultModel.DataSource) { List list3 = new List(); if (md.JoinOrderCode != null && md.JoinOrderCode != "") { list3 = listTrack.FindAll(n => n.OrderCode == md.JoinOrderCode); } else list3 = listTrack.FindAll(n => n.OrderId == md.OrderId); if (list3 != null && list3.Count > 0) { string trackinfo = ""; string blank = ""; string trackinfo1 = ""; foreach (var md1 in list3) { if (md1.TrackType == 3) blank = "[空包裹]"; if (md1.Weight != null) trackinfo += md1.TrackCode + blank + "重量" + md1.Weight.ToString() + "g;
"; else trackinfo += md1.TrackCode + blank + "
"; trackinfo1 = md1.TrackCode + blank + "
"; } md.TrackInfo = trackinfo; md.TrackCode = trackinfo1; } } } } } return resultModel; } #endregion #region 获取物流单号 [WebMethod(EnableSession = true)] public string GetOrderPostCodeList(string OrderIds, int PostId, int CompanyId) { PagesNew.Login(this.Session); var obj = new DD_OrderData(); if (CompanyId == 0) CompanyId = Convert.ToInt32(Session["CompanyId"]); var companymd = new JC_PostAddress(); var obj1 = new JC_ExpressService(); var obj11 = new BaseService(); companymd = obj11.GetAddressModel2(PostId); string ErrorInfo = ""; string PostCode = ""; var obj2 = new BaseService(); var md = DataNew.GetExpressModel(CompanyId, PostId); var orderlist = obj.GetOrderModelList(OrderIds.Trim(',')); var orderGoodslist = DataNew.GetOrderGoodsList2(OrderIds.Trim(',')); if (orderlist == null || orderGoodslist == null || md == null) return ""; foreach (var ordermd in orderlist) { if ((ordermd.RevPhone == null || ordermd.RevPhone == "") && (ordermd.RevPhone == null || ordermd.RevPhone == "")) ErrorInfo += ordermd.PlatOrderCode + "收件人电话没填"; if (ordermd.RevPostCode == null || ordermd.RevPostCode == "") ErrorInfo += ordermd.PlatOrderCode + "收件人邮编没填"; if (ordermd.RevProvince == null || ordermd.RevProvince == "") ErrorInfo += ordermd.PlatOrderCode + "州没填"; var goodslist = orderGoodslist.FindAll(n => n.OrderId == ordermd.OrderId); if (goodslist == null) ErrorInfo += ordermd.PlatOrderCode + "货物没有分配"; else { foreach (var gmd in goodslist) { if (gmd.Weight == null && gmd.Weight2 == null) { ErrorInfo += ordermd.PlatOrderCode + " " + gmd.GoodsSKU + "货物重量没填"; } if (gmd.Long == null && gmd.Long2 == null) { ErrorInfo += ordermd.PlatOrderCode + " " + gmd.GoodsSKU + "货物尺寸没填"; } else if (gmd.Width == null && gmd.Width2 == null) { ErrorInfo += ordermd.PlatOrderCode + " " + gmd.GoodsSKU + "货物尺寸没填"; } else if (gmd.Height == null && gmd.Height2 == null) { ErrorInfo += ordermd.PlatOrderCode + " " + gmd.GoodsSKU + "货物尺寸没填"; } } } } if (ErrorInfo != "") { return ErrorInfo; } var plist = new List(); foreach (var ordermd in orderlist) { var goodslist = orderGoodslist.FindAll(n => n.OrderId == ordermd.OrderId); if (md.Name.Contains("Fedex") && md.customercode != null && md.customercode != "") { FedexSmartPostNew fedexobj = new FedexSmartPostNew(); FedexSmartPostNew.Key = md.UserCode; FedexSmartPostNew.Password = md.CheckCode; FedexSmartPostNew.AccountNumber = md.client_id; FedexSmartPostNew.MeterNumber = md.client_secret; FedexSmartPostNew.PayAccountNumber = md.refresh_token; FedexSmartPostNew.HubId = md.Code; FedexSmartPostNew.PostName = md.customercode; FedexSmartPostNew.IsQM = 0; FedexOrder fdorder = new FedexOrder(); string SendName = companymd.SendName; string PersonName = companymd.SendEnglishName; if (goodslist != null && goodslist[0].SendName != null && goodslist[0].SendName != "") { SendName = goodslist[0].SendName; PersonName = goodslist[0].SendName; } Shiper shiper = new Shiper { City = companymd.city, CompanyName = SendName, PersonName = PersonName, 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); string Phone = ordermd.RevMoblie; if (ordermd.RevPhone != null && ordermd.RevPhone != "") Phone = ordermd.RevPhone; Rever rever = new Rever { City = ordermd.RevCity, CompanyName = ordermd.RevName, PersonName = ordermd.RevName, PhoneNumber = Phone, 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; decimal ww = 0; decimal c = 0; decimal k = 0; decimal g = 0; foreach (var gmd in goodslist) { if (gmd.GoodsSKU != null && gmd.GoodsSKU != "") gsku += gmd.GoodsNum.Value + "x" + gmd.GoodsSKU; gnum += gmd.GoodsNum.Value; if (gmd.Weight2 != null) ww += gmd.GoodsNum.Value * gmd.Weight2.Value * Convert.ToDecimal(0.0625); else if (gmd.Weight != null) ww += gmd.GoodsNum.Value * gmd.Weight.Value * Convert.ToDecimal(0.0022046); if (gmd.Long2 != null) c += gmd.Long2.Value; else if (gmd.Long != null) c += gmd.Long.Value * Convert.ToDecimal(0.3937008); if (gmd.Width2 != null) k += gmd.Width2.Value; else if (gmd.Width != null) k += gmd.Width.Value * Convert.ToDecimal(0.3937008); if (gmd.Height2 != null) g += gmd.Height2.Value; else if (gmd.Height != null) g += gmd.Height.Value * Convert.ToDecimal(0.3937008); } FedexGoods fgmd = new FedexGoods { Amount = 10.000M, SKU = gsku, Description = gsku, NumberOfPieces = gnum.ToString(), Weight = ww, Height = Math.Ceiling(g).ToString(), Lenght = Math.Ceiling(c).ToString(), Width = Math.Ceiling(k).ToString(), Quantity = gnum }; fedlist.Add(fgmd); fdorder.GoodsList = fedlist; string error = ""; PostCode = fedexobj.GetFedex(fdorder, out error); if (error != "") ErrorInfo += error; else if (PostCode != null && PostCode != "" && !PostCode.Contains("失败")) { DT_TrackCodeApplyNew Model = new DT_TrackCodeApplyNew(); 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; } 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.OrderCode2 = fdorder.CustomerTransactionId; Model.SKU = gsku; Model.Weight2 = ww.ToString("0.00"); Model.Long = Math.Ceiling(c).ToString(); Model.Height = Math.Ceiling(g).ToString(); Model.Width = Math.Ceiling(k).ToString(); Model.OrderId = ordermd.OrderId; Model.PostId = PostId; Model.State = 1; Model.TrackType = 1; Model.UpdateTime = DateTime.Now; Model.IsSpare = 0; Model.LabelUrl = PostCode + ".png"; Model.JoinOrderCode = ordermd.JoinOrderCode; plist.Add(Model); } } } if (plist != null && plist.Count > 0) { foreach (var pmd in plist) { if (pmd.TrackCode != null) { if (pmd.TrackCode != "") DataNew.SaveTrackCodeApply(pmd); } } } if (ErrorInfo == "") return ""; else return ErrorInfo + ";其他订单获取成功"; } #endregion #region 获取物流单号 [WebMethod(EnableSession = true)] public string GetOrderPostCodeOne(string OrderIds, int PostId, int CompanyId, string SKU, int Num, int IsSpare, decimal? weight, decimal? cd, decimal? kd, decimal? gd, int IsQS) { PagesNew.Login(this.Session); var obj = new DD_OrderData(); if (CompanyId == 0) CompanyId = Convert.ToInt32(Session["CompanyId"]); var companymd = new JC_PostAddress(); var obj1 = new JC_ExpressService(); var obj11 = new BaseService(); companymd = obj11.GetAddressModel2(PostId); string ErrorInfo = ""; string PostCode = ""; var obj2 = new BaseService(); var md = DataNew.GetExpressModel(CompanyId, PostId); //var orderlist = obj.GetOrderModelList(OrderIds.Trim(',')); var orderlist = DataNew.GetOrderModelList(OrderIds.Trim(',')); var orderGoodslist = DataNew.GetOrderGoodsList2(OrderIds.Trim(',')); if (orderlist == null || orderGoodslist == null || md == null) return ""; foreach (var ordermd in orderlist) { if ((ordermd.RevPhone == null || ordermd.RevPhone == "") && (ordermd.RevPhone == null || ordermd.RevPhone == "")) ErrorInfo += ordermd.PlatOrderCode + "收件人电话没填"; if (ordermd.RevPostCode == null || ordermd.RevPostCode == "") ErrorInfo += ordermd.PlatOrderCode + "收件人邮编没填"; if (ordermd.RevProvince == null || ordermd.RevProvince == "") ErrorInfo += ordermd.PlatOrderCode + "州没填"; } if (ErrorInfo != "") { return ErrorInfo; } var plist = new List(); foreach (var ordermd in orderlist) { var goodslist = orderGoodslist.FindAll(n => n.OrderId == ordermd.OrderId); if (md.Name.Contains("Fedex") && md.customercode != null && md.customercode != "") { FedexSmartPostNew2 fedexobj = new FedexSmartPostNew2(); FedexSmartPostNew2.Key = md.UserCode; FedexSmartPostNew2.Password = md.CheckCode; FedexSmartPostNew2.AccountNumber = md.client_id; FedexSmartPostNew2.MeterNumber = md.client_secret; FedexSmartPostNew2.PayAccountNumber = md.refresh_token; FedexSmartPostNew2.HubId = md.Code; FedexSmartPostNew2.PostName = md.customercode; if (IsQS == 1) FedexSmartPostNew2.IsQM = 1; else FedexSmartPostNew2.IsQM = 0; FedexOrder fdorder = new FedexOrder(); string SendName = companymd.SendName; string PersonName = companymd.SendEnglishName; if (goodslist != null && goodslist[0].SendName != null && goodslist[0].SendName != "") { SendName = goodslist[0].SendName; PersonName = goodslist[0].SendName; } Shiper shiper = new Shiper { City = companymd.city, CompanyName = SendName, PersonName = PersonName, PhoneNumber = companymd.Phone, PostalCode = companymd.PostCode, StateOrProvinceCode = companymd.provincecode, StreetLines = companymd.EnglishAddress, CountryCode = companymd.countycode }; fdorder.Shiper = shiper; Random rd = new Random(); if (IsSpare == 1) fdorder.CustomerTransactionId = ordermd.PlatOrderCode + rd.Next(100, 999); else fdorder.CustomerTransactionId = ordermd.PlatOrderCode; fdorder.PostId = new int?(PostId); string Phone = ordermd.RevMoblie; if (ordermd.RevPhone != null && ordermd.RevPhone != "") Phone = ordermd.RevPhone; Rever rever = new Rever { City = ordermd.RevCity, CompanyName = ordermd.RevName, PersonName = ordermd.RevName, PhoneNumber = Phone, CountryCode = ordermd.CountryCode, PostalCode = ordermd.RevPostCode }; if ((ordermd.RevProvince == null) || (ordermd.RevProvince == "")) { rever.StateOrProvinceCode = ordermd.RevCity; } else { rever.StateOrProvinceCode = ordermd.RevProvince; } if (ordermd.PlatId == 22) //TikTok的申请快递面单的详细地址过长,需要减去国家,省,市等,否则面单显示不下 { rever.StreetLines = string.IsNullOrEmpty(ordermd.RevAddr) ? "" : (ordermd.RevAddr.Split(',').Last()); } else rever.StreetLines = ordermd.RevAddr; rever.CountryCode = ordermd.CountryCode; fdorder.Rever = rever; List fedlist = new List(); string gsku = ""; int gnum = 0; decimal ww = 0; decimal c = 0; decimal k = 0; decimal g = 0; if (SKU != "") { gsku += SKU + " "; ww = weight.Value * Convert.ToDecimal(0.0625); c = cd.Value; k = kd.Value; g = gd.Value; gnum = Num; } else { foreach (var gmd in goodslist) { if (gmd.GoodsSKU != null && gmd.GoodsSKU != "") gsku += gmd.GoodsNum.Value + "x" + gmd.GoodsSKU + " "; gnum += gmd.GoodsNum.Value; if (gmd.Weight2 != null) ww += gmd.GoodsNum.Value * gmd.Weight2.Value * Convert.ToDecimal(0.0625); else if (gmd.Weight != null) ww += gmd.GoodsNum.Value * gmd.Weight.Value * Convert.ToDecimal(0.0022046); if (gmd.Long2 != null) c += gmd.Long2.Value; else if (gmd.Long != null) c += gmd.Long.Value * Convert.ToDecimal(0.3937008); if (gmd.Width2 != null) k += gmd.Width2.Value; else if (gmd.Width != null) k += gmd.Width.Value * Convert.ToDecimal(0.3937008); if (gmd.Height2 != null) g += gmd.Height2.Value; else if (gmd.Height != null) g += gmd.Height.Value * Convert.ToDecimal(0.3937008); } } FedexGoods fgmd = new FedexGoods { Amount = 10.000M, SKU = gsku, Description = gsku, NumberOfPieces = gnum.ToString(), Weight = ww, Height = Math.Ceiling(g).ToString(), Lenght = Math.Ceiling(c).ToString(), Width = Math.Ceiling(k).ToString(), Quantity = gnum }; fedlist.Add(fgmd); fdorder.GoodsList = fedlist; string error = ""; var fmd = fedexobj.GetFedex(fdorder, out error); if (fmd != null && fmd.CustomerTransactionId != null&&fdorder.CustomerTransactionId==fmd.CustomerTransactionId) PostCode = fmd.PostCode; else if (fmd != null && fmd.CustomerTransactionId != null) { PostCode = ""; error = "获取失败,重新获取"; } if (error != "") ErrorInfo += ordermd.PlatOrderCode + ":" + error; else if (PostCode != null && PostCode != "" && !PostCode.Contains("失败")) { DT_TrackCodeApplyNew Model = new DT_TrackCodeApplyNew(); 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; } 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.OrderCode2 = fdorder.CustomerTransactionId; Model.SKU = gsku; Model.Weight2 = ww.ToString("0.00"); Model.Long = Math.Ceiling(c).ToString(); Model.Height = Math.Ceiling(g).ToString(); Model.Width = Math.Ceiling(k).ToString(); Model.OrderId = ordermd.OrderId; Model.PostId = PostId; Model.State = 1; Model.TrackType = 1; Model.UpdateTime = DateTime.Now; Model.IsSpare = 0; Model.LabelUrl = PostCode + ".png"; Model.JoinOrderCode = ordermd.JoinOrderCode; plist.Add(Model); } } else if (md.Name.Contains("UPS")) { UpsShip fedexobj = new UpsShip(); UpsShip.AccessLicenseNumber = md.client_id; UpsShip.Username = md.UserCode; UpsShip.Password = md.CheckCode; UpsShip.ShipperNumber = md.Code; UPSOrder fdorder = new UPSOrder(); fdorder.shipservicecode = md.customercode; fdorder.packType = "02"; Shiper shiper = new Shiper { City = companymd.city, CompanyName = companymd.SendName, PersonName = companymd.SendEnglishName, PhoneNumber = companymd.Phone, PostalCode = companymd.PostCode, StateOrProvinceCode = companymd.provincecode, StreetLines = companymd.EnglishAddress, CountryCode = companymd.countycode }; fdorder.Shiper = shiper; Random rd = new Random(); if (IsSpare == 1) fdorder.CustomerTransactionId = ordermd.PlatOrderCode + rd.Next(100, 999); else fdorder.CustomerTransactionId = ordermd.PlatOrderCode; fdorder.PostId = new int?(PostId); string Phone = ordermd.RevMoblie; if (ordermd.RevPhone != null && ordermd.RevPhone != "") Phone = ordermd.RevPhone; Rever rever = new Rever { City = ordermd.RevCity, CompanyName = ordermd.RevName, PersonName = ordermd.RevName, PhoneNumber = Phone, 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 upslist = new List(); string gsku = ""; int gnum = 0; decimal ww = 0; decimal c = 0; decimal k = 0; decimal g = 0; if (SKU != "") { gsku += SKU + " "; ww = weight.Value * Convert.ToDecimal(0.0625); c = cd.Value; k = kd.Value; g = gd.Value; gnum = Num; } else { foreach (var gmd in goodslist) { if (gmd.GoodsSKU != null && gmd.GoodsSKU != "") gsku += gmd.GoodsNum.Value + "x" + gmd.GoodsSKU + " "; gnum += gmd.GoodsNum.Value; if (gmd.Weight2 != null) ww += gmd.GoodsNum.Value * gmd.Weight2.Value * Convert.ToDecimal(0.0625); else if (gmd.Weight != null) ww += gmd.GoodsNum.Value * gmd.Weight.Value * Convert.ToDecimal(0.0022046); if (gmd.Long2 != null) c += gmd.Long2.Value; else if (gmd.Long != null) c += gmd.Long.Value * Convert.ToDecimal(0.3937008); if (gmd.Width2 != null) k += gmd.Width2.Value; else if (gmd.Width != null) k += gmd.Width.Value * Convert.ToDecimal(0.3937008); if (gmd.Height2 != null) g += gmd.Height2.Value; else if (gmd.Height != null) g += gmd.Height.Value * Convert.ToDecimal(0.3937008); } } UpsGoods fgmd = new UpsGoods { Amount = 10.000M, SKU = gsku, Description = gsku, NumberOfPieces = gnum.ToString(), Weight = ww, Height = Math.Ceiling(g).ToString(), Lenght = Math.Ceiling(c).ToString(), Width = Math.Ceiling(k).ToString(), Quantity = gnum }; upslist.Add(fgmd); fdorder.GoodsList = upslist; string error = ""; UpsShip upsobj = new UpsShip(); string LabelUrl = ""; string tcode = upsobj.GetTrackCodeNew(fdorder, out error); if (error != "") { ErrorInfo += ordermd.PlatOrderCode + ":" + error; } else if (tcode == "") { PostCode = ""; error = "获取失败,重新获取"; } else { PostCode = tcode; UpsLabel objlb = new UpsLabel(); UpsLabel.AccessLicenseNumber = md.client_id; UpsLabel.Username = md.UserCode; UpsLabel.Password = md.CheckCode; UpsLabel.ShipperNumber = md.Code; //string lberror = ""; //objlb.GetLabel(PostCode, out lberror); //if (lberror == "") //{ // LabelUrl = PostCode + ".png"; //} LabelUrl = PostCode + ".png"; } if (PostCode != null && PostCode != "" && !PostCode.Contains("失败")) { DT_TrackCodeApplyNew Model = new DT_TrackCodeApplyNew(); 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; } 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.OrderCode2 = fdorder.CustomerTransactionId; Model.SKU = gsku; Model.Weight2 = ww.ToString("0.00"); Model.Long = Math.Ceiling(c).ToString(); Model.Height = Math.Ceiling(g).ToString(); Model.Width = Math.Ceiling(k).ToString(); Model.OrderId = ordermd.OrderId; Model.PostId = PostId; Model.State = 1; Model.TrackType = 1; Model.UpdateTime = DateTime.Now; Model.IsSpare = 0; Model.LabelUrl = LabelUrl;// PostCode + ".png"; Model.JoinOrderCode = ordermd.JoinOrderCode; plist.Add(Model); } } } if (plist != null && plist.Count > 0) { foreach (var pmd in plist) { if (pmd.TrackCode != null) { if (pmd.TrackCode != "") DataNew.SaveTrackCodeApply(pmd); } } } if (ErrorInfo == "") return ""; else return ErrorInfo + ";"; } #endregion #region 返回订单Model [WebMethod(EnableSession = true)] public DT_OrderModel GetOrderModelNew(int OrderId) { PagesNew.Login(this.Session); var obj = new DD_OrderData(); int CompanyId = Convert.ToInt32(Session["CompanyId"]); var md = obj.GetOrderModel(OrderId); if (md == null) return null; if (md.IsSpare == 1) { string TrackCodes = ""; var splist = obj.GetOrderSpareList(OrderId); if (splist != null) { for (int i = 0; i < splist.Count; i++) { TrackCodes += splist[i].TrackCode.ToString() + ","; } } md.TrackCode = TrackCodes.Trim(','); } return md; } #endregion #region 获取物流sku [WebMethod(EnableSession = true)] public DT_TrackCodeApplyNew GetOrderFedexSKU(string OrderIds) { PagesNew.Login(this.Session); var obj = new DD_OrderData(); var orderGoodslist = DataNew.GetOrderGoodsList2(OrderIds.Trim(',')); if (orderGoodslist == null) return null; string gsku = ""; int gnum = 0; decimal ww = 0; decimal c = 0; decimal k = 0; decimal g = 0; foreach (var gmd in orderGoodslist) { if (gmd.GoodsSKU != null && gmd.GoodsSKU != "") gsku += gmd.GoodsNum.Value + "x" + gmd.GoodsSKU + " "; gnum += gmd.GoodsNum.Value; if (gmd.Weight2 != null) ww += gmd.GoodsNum.Value * gmd.Weight2.Value; else if (gmd.Weight != null) ww += gmd.GoodsNum.Value * gmd.Weight.Value * Convert.ToDecimal(0.035274); decimal c2 = 0; decimal k2 = 0; decimal g2 = 0; if (gmd.Long2 != null) c2 = gmd.Long2.Value; // else if (gmd.Long != null) // c2 = gmd.Long.Value * Convert.ToDecimal(0.3937008); if (gmd.Width2 != null) k2 = gmd.Width2.Value; // else if (gmd.Width != null) // k2 = gmd.Width.Value * Convert.ToDecimal(0.3937008); if (gmd.Height2 != null) g2 = gmd.Height2.Value; // else if (gmd.Height != null) // g2 = gmd.Height.Value * Convert.ToDecimal(0.3937008); if (c2 > c) c = c2; if (k2 > k) k = k2; if (g2 > g) g = g2; } DT_TrackCodeApplyNew Model = new DT_TrackCodeApplyNew(); Model.SKU = gsku; if (ww > 0) Model.Weight2 = ww.ToString("0.00"); if (c > 0) Model.Long = Math.Ceiling(c).ToString(); if (g > 0) Model.Height = Math.Ceiling(g).ToString(); if (k > 0) Model.Width = Math.Ceiling(k).ToString(); return Model; } #endregion #region 获取物流sku [WebMethod(EnableSession = true)] public List GetOrderFedexSKU2(int OrderId) { PagesNew.Login(this.Session); var obj = new DD_OrderData(); var olist = DataNew.GetListSpareFee(OrderId); if (olist != null && olist.Count > 0) return olist; var orderGoodslist = DataNew.GetOrderGoodsList3(OrderId); if (orderGoodslist == null) return null; List list = new List(); foreach (var gmd in orderGoodslist) { if (gmd.GoodsNum > 0) { for (int i = 0; i < gmd.GoodsNum; i++) { DT_SpareFee Model = new DT_SpareFee(); Model.Sku = gmd.GoodsSKU; decimal ww = 0; decimal c = 0; decimal k = 0; decimal g = 0; if (gmd.Weight2 != null) ww = gmd.Weight2.Value; else if (gmd.Weight != null) ww = gmd.Weight.Value * Convert.ToDecimal(0.035274); Model.Weight = ww.ToString("0.00"); if (gmd.Long2 != null) c = gmd.Long2.Value; // else if (gmd.Long != null) // c = gmd.Long.Value * Convert.ToDecimal(0.3937008); if (gmd.Width2 != null) k = gmd.Width2.Value; // else if (gmd.Width != null) // k = gmd.Width.Value * Convert.ToDecimal(0.3937008); if (gmd.Height2 != null) g = gmd.Height2.Value; // else if (gmd.Height != null) // g = gmd.Height.Value * Convert.ToDecimal(0.3937008); if (c > 0) Model.Long = Math.Ceiling(c).ToString(); if (g > 0) Model.Height = Math.Ceiling(g).ToString(); if (k > 0) Model.Width = Math.Ceiling(k).ToString(); list.Add(Model); } } } return list; } #endregion #region 获取物流sku [WebMethod(EnableSession = true)] public List GetOrderFedexSKU3(int OrderId) { PagesNew.Login(this.Session); var obj = new DD_OrderData(); var olist = DataNew.GetListSpareFee(OrderId); return olist; } #endregion #region 查询订单跟踪码 [WebMethod(EnableSession = true)] public List GetOrderTrackCodeList(int OrderId, string JoinOrderCode) { PagesNew.Login(this.Session); var obj = new DD_OrderData(); int CompanyId = Convert.ToInt32(Session["CompanyId"]); var list = DataNew.GetOrderTrackCodeNew(OrderId, JoinOrderCode); if (list != null) { foreach (var md in list) { md.SKUstr = md.SKU; string sku = ""; sku += md.SKU; if (md.Weight2 != null) sku += md.Weight2 + "磅"; if (md.Long != null) sku += "长:" + md.Long + "in"; if (md.Width != null) sku += "宽:" + md.Width + "in"; if (md.Height != null) sku += "高:" + md.Height + "in"; md.SKU = sku; } } return list; } #endregion #region 查询物流订单 [WebMethod(EnableSession = true)] public JsonModel> GetListOrderExpressForTM(int SortId, int DeptId, int PlatType, int TrackState, int MateState, int ShopId, int DateType, DateTime? SDate, DateTime? EDate, int OutDays, int TjType, string Name, int ExpressState, int IsSku, int IsError, int IsDetail, int HBOrder, int PostId, int LogisticsId, int Addr, int PageIndex, int PageSize, string Sort, int GoodsNum) { PagesNew.Login(this.Session); var obj = new DD_OrderData(); int CompanyId = Convert.ToInt32(Session["CompanyId"]); RefParameterCollection Param = new RefParameterCollection(); if (DeptId > 0) Param.Add("c.DeptId", "=", DeptId, DbType.Int32); Param.Add("a.CompanyId", "=", CompanyId, DbType.Int32); if (MateState > -1) Param.Add("a.MateState", "=", MateState, DbType.Int32); if (GoodsNum == 1) Param.Add("a.GoodsNum", "=", 1, DbType.Int32); int IsTrack = TrackState; //if (ExpressState>-1) Param.Add("isnull(a.PrintState,0)", "=", 0, DbType.Int32); if (PlatType > 0) Param.Add("a.PlatId", "=", PlatType, DbType.Int32); if (ShopId > 0) Param.Add("a.ShopId", "=", ShopId, DbType.Int32); if (DateType == 1) { if (SDate != null) Param.Add("a.OrderDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.OrderDate", "<", EDate.Value.AddDays(1), DbType.DateTime); } else if (DateType == 2) { if (SDate != null) Param.Add("a.InDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.InDate", "<", EDate.Value.AddDays(1), DbType.DateTime); } else if (DateType == 3) { if (SDate != null) Param.Add("a.PrintDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.PrintDate", "<", EDate.Value.AddDays(1), DbType.DateTime); } else if (DateType == 4) { if (SDate != null) Param.Add("a.PostDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.PostDate", "<", EDate.Value.AddDays(1), DbType.DateTime); } else if (DateType == 5) { if (SDate != null) Param.Add("a.OrderOutDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.OrderOutDate", "<", EDate.Value.AddDays(1), DbType.DateTime); } if (OutDays > 0) { Param.Add("a.OrderOutDate", "<=", DateTime.Now.AddHours(OutDays), DbType.DateTime); Param.Add("a.OrderOutDate", ">=", DateTime.Now, DbType.DateTime); } if (LogisticsId > 0) Param.Add("b.LogisticsId", "=", LogisticsId, DbType.String); if (ExpressState == 0) { Param.Add("isnull(b.Post,0)", "=", 0, DbType.Int32); } else if (ExpressState == 2) { Param.Add("b.Post", ">", 0, DbType.Int32); Param.Add("isnull(b.TrackState,0)", "=", 0, DbType.Int32); } else if (ExpressState == 1) { Param.Add("b.Post", ">", 0, DbType.Int32); Param.Add("b.TrackState", ">", 0, DbType.Int32); } if (PostId > 0) Param.Add("b.Post", "=", PostId, DbType.Int32); Param.Add("a.State", "=", 1, DbType.Int32); if (HBOrder == 1) Param.Add("a.IsJoin", "=", 1, DbType.Int32); if (IsError == 1) { Param.Add("(b.SendAddr", ">", 0, DbType.Int32); Param.Add("b.IsLeaveWord", "=", 1, "or", ")", DbType.Int32); } string TCode = ""; if (Name != "") { if (TjType == 1) { Param.Add("(a.PlatOrderCode", "=", Name, DbType.String); Param.Add("a.JoinOrderCode", "=", Name, "or", ")", DbType.String); } else if (TjType == 2) { Param.Add("b.RevName", "like", Name, DbType.String); } else if (TjType == 3) { Param.Add("b.RevPhone", "like", Name, DbType.String); } else if (TjType == 4) { Param.Add("(b.RevCountry", "=", Name, DbType.String); Param.Add("b.CountryName", "=", Name, "or", DbType.String); Param.Add("b.CountryCode", "=", Name, "or", ")", DbType.String); } else if (TjType == 5) { Param.Add("b.RevPostCode", "=", Name, DbType.String); } else if (TjType == 6) { Param.Add("(b.RevAddr", "like", Name, DbType.String); Param.Add("b.RevProvince", "like", Name, "or", DbType.String); Param.Add("b.RevCity", "like", Name, "or", DbType.String); Param.Add("b.RevArea", "like", Name, "or", ")", DbType.String); } else if (TjType == 9) { Param.Add("(b.ErrorInfo", "like", Name, DbType.String); Param.Add("b.PostError", "like", Name, "or", ")", DbType.String); } else if (TjType == 10) { // Param.Add("dbo.getOrderTrackCode(a.OrderId,1)", "like", Name, DbType.String); TCode = Name; } } if (IsSku == 0) Param.Add("a.FPDate", "is", null, DbType.String); else if (IsSku == 1) Param.Add("a.FPDate", "is not", null, DbType.String); //if (Addr > -1) //{ // Param.Add("b.SendAddr", "=", Addr, DbType.Int32); //} // Param.Add("a.OrderDate", ">=", 0, DbType.Int32); JsonModel> resultModel = new JsonModel>(); int RowCount = 0; //var pxlist = obj.GetLevelConfig(CompanyId, 0); // string Sort = "JoinOrderCode,PlatOrderCode"; //if (pxlist != null) //{ // Sort = ""; // foreach (var md in pxlist) // { // if (md.SortType == 1) // Sort += "a.OrderLevel desc,"; // else if (md.SortType == 2) // Sort += "a.OrderDate,"; // else if (md.SortType == 3) // Sort += "c.LevelGrade desc,"; // else if (md.SortType == 4) // Sort += "a.RMBPrice desc,"; // } //} //Sort = Sort.Trim(','); string GoodsName = ""; string SKU = ""; if (TjType == 7 && Name != "") { GoodsName = Name; } else if (TjType == 8 && Name != "") { SKU = Name; } if (ExpressState == -1) resultModel.DataSource = obj.GetListDT_OrderInfoExpressForTM(SortId, IsTrack, TCode, GoodsName, SKU, IsSku, Param, PageIndex, PageSize, Sort, out RowCount); else resultModel.DataSource = obj.GetListDT_OrderInfoExpressForTM2(SortId, IsTrack, TCode, GoodsName, SKU, IsSku, Param, PageIndex, PageSize, Sort, out RowCount); resultModel.RowCount = RowCount; string Ids = ""; if (resultModel.DataSource != null) { foreach (var md in resultModel.DataSource) { Ids += md.OrderId.ToString() + ","; } } if (Ids != "") { JC_ExpressService obj3 = new JC_ExpressService(); var elist = obj3.GetExpressTypeList(); var plist = obj3.GetExpressList(); var errorlist = obj.GetErrorList(Ids.Trim(',')); if (errorlist != null || elist != null || plist != null) { foreach (var md in resultModel.DataSource) { if (errorlist != null && errorlist.Count > 0) { var emd = errorlist.Find(n => n.OrderId == md.OrderId); if (emd != null) { md.ErrorInfo = emd.ErrorInfo; } } //if (md.LogisticsId>0&&elist != null && elist.Count > 0) //{ // var emd = elist.Find(n => n.LogisticsId == md.LogisticsId); // if (emd != null) // { // md.PostInfo = emd.LogisticsName; // } //} if (md.Post > 0 && plist != null && plist.Count > 0) { var emd = plist.Find(n => n.ExpressID == md.Post); if (emd != null) { md.LocalPost = emd.Name; } } } } } if (resultModel.DataSource != null) { if (Ids != "") { if (IsDetail == 1) { var list1 = obj.GetOrderGoodsList(Ids.Trim(',')); if (list1 != null) { foreach (var md in resultModel.DataSource) { var list2 = list1.FindAll(n => n.OrderId == md.OrderId); if (list2 != null) { md.GoodsList = list2; } } } } var listTrack = obj.GetTrackCodeApplyList(Ids.Trim(',')); if (listTrack != null) { foreach (var md in resultModel.DataSource) { List list3 = new List(); if (md.JoinOrderCode != null && md.JoinOrderCode != "") { list3 = listTrack.FindAll(n => n.OrderCode == md.JoinOrderCode); } else list3 = listTrack.FindAll(n => n.OrderId == md.OrderId); if (list3 != null && list3.Count > 0) { string trackinfo = ""; string blank = ""; string trackinfo1 = ""; foreach (var md1 in list3) { if (md1.TrackType == 3) blank = "[空包裹]"; if (md1.Weight != null) trackinfo += md1.TrackCode + blank + "重量" + md1.Weight.ToString() + "g;
"; else trackinfo += md1.TrackCode + blank + "
"; trackinfo1 = md1.TrackCode + blank + "
"; } md.TrackInfo = trackinfo; md.TrackCode = trackinfo1; } } } } } return resultModel; } #endregion [WebMethod(EnableSession = true)] public string GetFedexLabelNew2(string OrderIds, int PostId, int CompanyId) { PagesNew.Login(base.Session); OrderPrintData data = new OrderPrintData(); List source = null; var obj = new DD_OrderData(); if (source == null) { source = DataNew.GetOrderPrintListForFedex(OrderIds.TrimEnd(','), 0); } if (source == null || source.Count == 0) { return ""; } BaseService obj2 = new BaseService(); var expressmd = DataNew.GetExpressModel2(PostId, CompanyId); JC_ExpressService service = new JC_ExpressService(); DataTable table = new DataTable(); table.Columns.Add("SKU"); table.Columns.Add("OrderCode"); table.Columns.Add("SKU3"); table.Columns.Add("Photo3"); table.Columns.Add("SKU2"); table.Columns.Add("Photo2"); table.Columns.Add("SKU4"); table.Columns.Add("Photo4"); table.Columns.Add("SKU5"); table.Columns.Add("Photo5"); table.Columns.Add("Photo0"); string str2 = ""; string wordTemplatePath = ""; foreach (var order2 in source) { wordTemplatePath = expressmd.PrintTemplateName; DataRow row = table.NewRow(); row["Photo0"] = AppDomain.CurrentDomain.BaseDirectory + "attached/fedex/" + order2.TrackCode.ToString() + ".png"; row["OrderCode"] = order2.OrderCode; row["SKU"] = ""; if (order2.GoodsList != null && order2.GoodsList.Count > 0 && order2.GoodsList[0].GoodsUrl != null && order2.GoodsList[0].GoodsUrl != "") { row["Photo2"] = AppDomain.CurrentDomain.BaseDirectory + order2.GoodsList[0].GoodsUrl.Replace("../", ""); } //if ((order2.GoodsList != null && order2.GoodsList.Count > 0)) //{ // row["SKU2"] = order2.GoodsList[0].SKU1 + " " + order2.GoodsList[0].GoodsName + order2.GoodsList[0].GoodsCode + " " + order2.GoodsList[0].TypeDesc + "[Number]:" + order2.GoodsList[0].GoodsNum + " [Storage Location]:" + order2.GoodsList[0].PostionDesc; //} string SKU2 = ""; if (order2.GoodsList != null) { foreach (var ggmd in order2.GoodsList) { SKU2 = ggmd.GoodsNum.ToString() + "x" + ggmd.SKU1 + " "; } } row["SKU2"] = SKU2; if (order2.GoodsList != null && order2.GoodsList.Count > 1 && order2.GoodsList[1].GoodsUrl != null && order2.GoodsList[1].GoodsUrl != "") { row["Photo3"] = AppDomain.CurrentDomain.BaseDirectory + order2.GoodsList[1].GoodsUrl.Replace("../", ""); } if (order2.GoodsList != null && order2.GoodsList.Count > 1) { row["SKU3"] = order2.GoodsList[1].SKU1 + " " + order2.GoodsList[1].GoodsName + order2.GoodsList[1].GoodsCode + " " + order2.GoodsList[1].TypeDesc + "[Number]:" + order2.GoodsList[1].GoodsNum + " [Storage Location]:" + order2.GoodsList[1].PostionDesc; } if (order2.GoodsList != null && order2.GoodsList.Count > 2 && order2.GoodsList[2].GoodsUrl != null && order2.GoodsList[2].GoodsUrl != "") { row["Photo4"] = AppDomain.CurrentDomain.BaseDirectory + order2.GoodsList[2].GoodsUrl.Replace("../", ""); } if ((order2.GoodsList != null && order2.GoodsList.Count > 2)) { row["SKU4"] = order2.GoodsList[2].SKU1 + " " + order2.GoodsList[2].GoodsName + order2.GoodsList[2].GoodsCode + " " + order2.GoodsList[2].TypeDesc + "[Number]:" + order2.GoodsList[2].GoodsNum + " [Storage Location]:" + order2.GoodsList[2].PostionDesc; } if (order2.GoodsList != null && order2.GoodsList.Count > 3 && order2.GoodsList[3].GoodsUrl != null && order2.GoodsList[3].GoodsUrl != "") { row["Photo4"] = AppDomain.CurrentDomain.BaseDirectory + order2.GoodsList[3].GoodsUrl.Replace("../", ""); } if ((order2.GoodsList != null && order2.GoodsList.Count > 3)) { row["SKU4"] = order2.GoodsList[3].SKU1 + " " + order2.GoodsList[3].GoodsName + order2.GoodsList[3].GoodsCode + " " + order2.GoodsList[3].TypeDesc + "[Number]:" + order2.GoodsList[3].GoodsNum + " [Storage Location]:" + order2.GoodsList[3].PostionDesc; } if (order2.GoodsList.Count > 4) { for (int i = 4; i < order2.GoodsList.Count; i++) { row["SKU"] += order2.GoodsList[i].SKU1 + "[Number]:" + order2.GoodsList[i].GoodsNum + " [Storage Location]:" + order2.GoodsList[i].PostionDesc + ";"; } } table.Rows.Add(row); } TableColumnCollection listColumns = new TableColumnCollection(); listColumns.Add("SKU", "SKU", DbType.String, ""); listColumns.Add("OrderCode", "OrderCode", DbType.String, ""); listColumns.Add("Photo2", "Photo2", DbType.Object, "40*40"); listColumns.Add("SKU3", "SKU3", DbType.String, ""); listColumns.Add("Photo3", "Photo3", DbType.Object, "40*40"); listColumns.Add("SKU4", "SKU4", DbType.String, ""); listColumns.Add("Photo4", "Photo4", DbType.Object, "40*40"); listColumns.Add("SKU5", "SKU5", DbType.String, ""); listColumns.Add("Photo5", "Photo5", DbType.Object, "40*40"); listColumns.Add("Photo0", "Photo0", DbType.Object, "265*390"); listColumns.Add("SKU2", "SKU2", DbType.String, ""); MicrosoftWord word = new MicrosoftWord(); if (wordTemplatePath != null) { str2 = word.Export(wordTemplatePath, table, listColumns, ".pdf"); } return str2; } [WebMethod(EnableSession = true)] public string GetFedexLabelNew(string OrderIds, int PostId) { PagesNew.Login(base.Session); int CompanyId = Convert.ToInt32(Session["CompanyId"]); OrderPrintData data = new OrderPrintData(); List source = null; var obj = new DD_OrderData(); if (source == null) { source = DataNew.GetOrderPrintListForFedex(OrderIds.TrimEnd(','), 0); } if (source == null || source.Count == 0) { return ""; } string[] oids = OrderIds.TrimEnd(',').Split(','); List source2 = new List(); for (int i = 0; i < oids.Length; i++) { var omdlist = source.FindAll(n => n.OrderId == Convert.ToInt32(oids[i])); if (omdlist != null) { foreach (var omd in omdlist) { source2.Add(omd); } } } BaseService obj2 = new BaseService(); var expressmd = DataNew.GetExpressModel2(PostId, CompanyId); JC_ExpressService service = new JC_ExpressService(); DataTable table = new DataTable(); table.Columns.Add("SKU"); table.Columns.Add("OrderCode"); table.Columns.Add("SKU3"); table.Columns.Add("Photo3"); table.Columns.Add("SKU2"); table.Columns.Add("Photo2"); table.Columns.Add("SKU4"); table.Columns.Add("Photo4"); table.Columns.Add("SKU5"); table.Columns.Add("Photo5"); table.Columns.Add("Photo0"); string str2 = ""; string wordTemplatePath = ""; foreach (var order2 in source2) { wordTemplatePath = expressmd.PrintTemplateName; DataRow row = table.NewRow(); row["Photo0"] = AppDomain.CurrentDomain.BaseDirectory + "attached/fedex/" + order2.TrackCode.ToString() + ".png"; row["OrderCode"] = order2.OrderCode; row["SKU"] = ""; if (order2.GoodsList != null && order2.GoodsList.Count > 0 && order2.GoodsList[0].GoodsUrl != null && order2.GoodsList[0].GoodsUrl != "") { row["Photo2"] = AppDomain.CurrentDomain.BaseDirectory + order2.GoodsList[0].GoodsUrl.Replace("../", ""); } //if ((order2.GoodsList != null && order2.GoodsList.Count > 0)) //{ // row["SKU2"] = order2.GoodsList[0].SKU1 + " " + order2.GoodsList[0].GoodsName + order2.GoodsList[0].GoodsCode + " " + order2.GoodsList[0].TypeDesc + "[Number]:" + order2.GoodsList[0].GoodsNum + " [Storage Location]:" + order2.GoodsList[0].PostionDesc; //} string SKU2 = ""; if (order2.GoodsList != null) { foreach (var ggmd in order2.GoodsList) { SKU2 = ggmd.GoodsNum.ToString() + "x" + ggmd.SKU1 + " "; } } row["SKU2"] = SKU2; if (order2.GoodsList != null && order2.GoodsList.Count > 1 && order2.GoodsList[1].GoodsUrl != null && order2.GoodsList[1].GoodsUrl != "") { row["Photo3"] = AppDomain.CurrentDomain.BaseDirectory + order2.GoodsList[1].GoodsUrl.Replace("../", ""); } if (order2.GoodsList != null && order2.GoodsList.Count > 1) { row["SKU3"] = order2.GoodsList[1].SKU1 + " " + order2.GoodsList[1].GoodsName + order2.GoodsList[1].GoodsCode + " " + order2.GoodsList[1].TypeDesc + "[Number]:" + order2.GoodsList[1].GoodsNum + " [Storage Location]:" + order2.GoodsList[1].PostionDesc; } if (order2.GoodsList != null && order2.GoodsList.Count > 2 && order2.GoodsList[2].GoodsUrl != null && order2.GoodsList[2].GoodsUrl != "") { row["Photo4"] = AppDomain.CurrentDomain.BaseDirectory + order2.GoodsList[2].GoodsUrl.Replace("../", ""); } if ((order2.GoodsList != null && order2.GoodsList.Count > 2)) { row["SKU4"] = order2.GoodsList[2].SKU1 + " " + order2.GoodsList[2].GoodsName + order2.GoodsList[2].GoodsCode + " " + order2.GoodsList[2].TypeDesc + "[Number]:" + order2.GoodsList[2].GoodsNum + " [Storage Location]:" + order2.GoodsList[2].PostionDesc; } if (order2.GoodsList != null && order2.GoodsList.Count > 3 && order2.GoodsList[3].GoodsUrl != null && order2.GoodsList[3].GoodsUrl != "") { row["Photo4"] = AppDomain.CurrentDomain.BaseDirectory + order2.GoodsList[3].GoodsUrl.Replace("../", ""); } if ((order2.GoodsList != null && order2.GoodsList.Count > 3)) { row["SKU4"] = order2.GoodsList[3].SKU1 + " " + order2.GoodsList[3].GoodsName + order2.GoodsList[3].GoodsCode + " " + order2.GoodsList[3].TypeDesc + "[Number]:" + order2.GoodsList[3].GoodsNum + " [Storage Location]:" + order2.GoodsList[3].PostionDesc; } if (order2.GoodsList.Count > 4) { for (int i = 4; i < order2.GoodsList.Count; i++) { row["SKU"] += order2.GoodsList[i].SKU1 + "[Number]:" + order2.GoodsList[i].GoodsNum + " [Storage Location]:" + order2.GoodsList[i].PostionDesc + ";"; } } table.Rows.Add(row); } TableColumnCollection listColumns = new TableColumnCollection(); listColumns.Add("SKU", "SKU", DbType.String, ""); listColumns.Add("OrderCode", "OrderCode", DbType.String, ""); listColumns.Add("Photo2", "Photo2", DbType.Object, "40*40"); listColumns.Add("SKU3", "SKU3", DbType.String, ""); listColumns.Add("Photo3", "Photo3", DbType.Object, "40*40"); listColumns.Add("SKU4", "SKU4", DbType.String, ""); listColumns.Add("Photo4", "Photo4", DbType.Object, "40*40"); listColumns.Add("SKU5", "SKU5", DbType.String, ""); listColumns.Add("Photo5", "Photo5", DbType.Object, "40*40"); listColumns.Add("Photo0", "Photo0", DbType.Object, "265*390"); listColumns.Add("SKU2", "SKU2", DbType.String, ""); MicrosoftWord word = new MicrosoftWord(); if (wordTemplatePath != null) { str2 = word.Export(wordTemplatePath, table, listColumns, ".pdf"); } return str2; } [WebMethod(EnableSession = true)] public string GetFedexLabelNewUPS(string OrderIds, int PostId) { PagesNew.Login(base.Session); int CompanyId = Convert.ToInt32(Session["CompanyId"]); OrderPrintData data = new OrderPrintData(); List source = null; var obj = new DD_OrderData(); if (source == null) { source = DataNew.GetOrderPrintListForFedex(OrderIds.TrimEnd(','), 0); } if (source == null || source.Count == 0) { return ""; } string[] oids = OrderIds.TrimEnd(',').Split(','); List source2 = new List(); for (int i = 0; i < oids.Length; i++) { var omdlist = source.FindAll(n => n.OrderId == Convert.ToInt32(oids[i])); if (omdlist != null) { foreach (var omd in omdlist) { source2.Add(omd); } } } BaseService obj2 = new BaseService(); var expressmd = DataNew.GetExpressModel2(PostId, CompanyId); JC_ExpressService service = new JC_ExpressService(); DataTable table = new DataTable(); table.Columns.Add("SKU"); table.Columns.Add("OrderCode"); table.Columns.Add("SKU3"); table.Columns.Add("Photo3"); table.Columns.Add("SKU2"); table.Columns.Add("Photo2"); table.Columns.Add("SKU4"); table.Columns.Add("Photo4"); table.Columns.Add("SKU5"); table.Columns.Add("Photo5"); table.Columns.Add("Photo0"); string str2 = ""; string wordTemplatePath = ""; foreach (var order2 in source2) { wordTemplatePath = expressmd.PrintTemplateName; DataRow row = table.NewRow(); row["Photo0"] = AppDomain.CurrentDomain.BaseDirectory + "attached/ups/" + order2.TrackCode.ToString() + ".png"; row["OrderCode"] = order2.OrderCode; // if (order2.GoodsList != null && order2.GoodsList.Count > 0) row["SKU2"] = order2.SKU; //if (order2.GoodsList != null && order2.GoodsList.Count > 0 && order2.GoodsList[0].GoodsUrl != null && order2.GoodsList[0].GoodsUrl != "") //{ // row["Photo2"] = AppDomain.CurrentDomain.BaseDirectory + order2.GoodsList[0].GoodsUrl.Replace("../", ""); //} //if ((order2.GoodsList != null && order2.GoodsList.Count > 0)) //{ // row["SKU2"] = order2.GoodsList[0].SKU1 + " " + order2.GoodsList[0].GoodsName + order2.GoodsList[0].GoodsCode + " " + order2.GoodsList[0].TypeDesc + "[Number]:" + order2.GoodsList[0].GoodsNum + " [Storage Location]:" + order2.GoodsList[0].PostionDesc; //} //if (order2.GoodsList != null && order2.GoodsList.Count > 1 && order2.GoodsList[1].GoodsUrl != null && order2.GoodsList[1].GoodsUrl != "") //{ // row["Photo3"] = AppDomain.CurrentDomain.BaseDirectory + order2.GoodsList[1].GoodsUrl.Replace("../", ""); //} //if (order2.GoodsList != null && order2.GoodsList.Count > 1) //{ // row["SKU3"] = order2.GoodsList[1].SKU1 + " " + order2.GoodsList[1].GoodsName + order2.GoodsList[1].GoodsCode + " " + order2.GoodsList[1].TypeDesc + "[Number]:" + order2.GoodsList[1].GoodsNum + " [Storage Location]:" + order2.GoodsList[1].PostionDesc; //} //if (order2.GoodsList != null && order2.GoodsList.Count > 2 && order2.GoodsList[2].GoodsUrl != null && order2.GoodsList[2].GoodsUrl != "") //{ // row["Photo4"] = AppDomain.CurrentDomain.BaseDirectory + order2.GoodsList[2].GoodsUrl.Replace("../", ""); //} //if ((order2.GoodsList != null && order2.GoodsList.Count > 2)) //{ // row["SKU4"] = order2.GoodsList[2].SKU1 + " " + order2.GoodsList[2].GoodsName + order2.GoodsList[2].GoodsCode + " " + order2.GoodsList[2].TypeDesc + "[Number]:" + order2.GoodsList[2].GoodsNum + " [Storage Location]:" + order2.GoodsList[2].PostionDesc; //} //if (order2.GoodsList != null && order2.GoodsList.Count > 3 && order2.GoodsList[3].GoodsUrl != null && order2.GoodsList[3].GoodsUrl != "") //{ // row["Photo4"] = AppDomain.CurrentDomain.BaseDirectory + order2.GoodsList[3].GoodsUrl.Replace("../", ""); //} //if ((order2.GoodsList != null && order2.GoodsList.Count > 3)) //{ // row["SKU4"] = order2.GoodsList[3].SKU1 + " " + order2.GoodsList[3].GoodsName + order2.GoodsList[3].GoodsCode + " " + order2.GoodsList[3].TypeDesc + "[Number]:" + order2.GoodsList[3].GoodsNum + " [Storage Location]:" + order2.GoodsList[3].PostionDesc; //} //if (order2.GoodsList.Count > 4) //{ // for (int i = 4; i < order2.GoodsList.Count; i++) // { // row["SKU"] += order2.GoodsList[i].SKU1 + "[Number]:" + order2.GoodsList[i].GoodsNum + " [Storage Location]:" + order2.GoodsList[i].PostionDesc + ";"; // } //} table.Rows.Add(row); } TableColumnCollection listColumns = new TableColumnCollection(); listColumns.Add("SKU", "SKU", DbType.String, ""); listColumns.Add("OrderCode", "OrderCode", DbType.String, ""); listColumns.Add("SKU2", "SKU2", DbType.String, ""); listColumns.Add("Photo2", "Photo2", DbType.Object, "40*40"); listColumns.Add("SKU3", "SKU3", DbType.String, ""); listColumns.Add("Photo3", "Photo3", DbType.Object, "40*40"); listColumns.Add("SKU4", "SKU4", DbType.String, ""); listColumns.Add("Photo4", "Photo4", DbType.Object, "40*40"); listColumns.Add("SKU5", "SKU5", DbType.String, ""); listColumns.Add("Photo5", "Photo5", DbType.Object, "40*40"); listColumns.Add("Photo0", "Photo0", DbType.Object, "265*390"); MicrosoftWord word = new MicrosoftWord(); if (wordTemplatePath != null) { str2 = word.Export(wordTemplatePath, table, listColumns, ".pdf"); } return str2; } [WebMethod(EnableSession = true)] public string GetFedexFee22(DT_OrderFedexModel omd, decimal weight, decimal width, decimal slong, decimal height, int Uint, int PostId, string PostType) { PagesNew.Login(base.Session); // int companyId = Convert.ToInt32(base.Session["CompanyId"]); JC_ExpressService service = new JC_ExpressService(); JC_PostAddress address = new BaseService().GetAddressModel2(PostId); JC_ExpressPost expressModel = service.GetExpressModel(1, PostId); FedexRate rate = new FedexRate(); FedexRate.Key = expressModel.UserCode; FedexRate.Password = expressModel.CheckCode; FedexRate.AccountNumber = expressModel.client_id; FedexRate.MeterNumber = expressModel.client_secret; FedexRate.PayAccountNumber = expressModel.refresh_token; FedexRate.HubId = expressModel.Code; FedexFeeMd md = new FedexFeeMd { RevName = omd.RevName, RevPhone = omd.RevPhone }; if ((omd.RevPhone == null) || (omd.RevPhone == "")) { md.RevPhone = omd.RevMoblie; } md.OrderId = -1; md.PostType = PostType; md.SendAddr = address.EnglishAddress; md.SendCountry = address.countycode; md.SendCity = address.city; md.SendProv = address.provincecode; md.SendPostCode = address.PostCode; if ((omd.RevAddr != null) && (omd.RevAddr != "")) { md.RevAddr = omd.RevAddr; } else { md.RevAddr = "street No 18"; } md.RevCity = omd.RevCity; if ((omd.RevCity == null) || (omd.RevCity == "")) { md.RevCity = omd.RevProvince; } if ((omd.RevProvinceCode != null) && (omd.RevProvinceCode != "")) { md.RevProv = omd.RevProvinceCode; } else if (((omd.RevProvince != null) && (omd.RevProvince != "")) && (omd.RevProvince.Length > 2)) { md.RevProv = omd.RevProvince.Substring(omd.RevProvince.Length - 2, 2); } else { md.RevProv = omd.RevProvince; } md.RevPostCode = omd.RevPostCode; md.RevCountry = omd.CountryCode; md.Width = Math.Ceiling(width).ToString(); md.Height = Math.Ceiling(height).ToString(); md.Lenght = Math.Ceiling(slong).ToString(); md.Weight = new decimal?(weight); if (Uint == 2) { md.Weight = new decimal?(weight * Convert.ToDecimal((double)2.2046226)); } else if (Uint == 3) { md.Weight = new decimal?(weight * Convert.ToDecimal((double)0.0625)); } string outError = ""; string fee = rate.GetFee(md, out outError); if (outError != "") { return outError; } return fee; } [WebMethod(EnableSession = true)] public string GetFedexFee22New(DT_OrderFedexModel omd, decimal weight, decimal width, decimal slong, decimal height, int Uint, int PostId, string PostType) { PagesNew.Login(base.Session); // int companyId = Convert.ToInt32(base.Session["CompanyId"]); JC_ExpressService service = new JC_ExpressService(); JC_PostAddress address = new BaseService().GetAddressModel2(PostId); JC_ExpressPost expressModel = service.GetExpressModel(1, PostId); FedexRate rate = new FedexRate(); FedexRate.Key = expressModel.UserCode; FedexRate.Password = expressModel.CheckCode; FedexRate.AccountNumber = expressModel.client_id; FedexRate.MeterNumber = expressModel.client_secret; FedexRate.PayAccountNumber = expressModel.refresh_token; FedexRate.HubId = expressModel.Code; FedexFeeMd md = new FedexFeeMd { RevName = omd.RevName, RevPhone = omd.RevPhone }; if ((omd.RevPhone == null) || (omd.RevPhone == "")) { md.RevPhone = omd.RevMoblie; } md.OrderId = -1; md.PostType = PostType; md.SendAddr = address.EnglishAddress; md.SendCountry = address.countycode; md.SendCity = address.city; md.SendProv = address.provincecode; md.SendPostCode = address.PostCode; if ((omd.RevAddr != null) && (omd.RevAddr != "")) { md.RevAddr = omd.RevAddr; } else { md.RevAddr = "street No 18"; } md.RevCity = omd.RevCity; if ((omd.RevCity == null) || (omd.RevCity == "")) { md.RevCity = omd.RevProvince; } if ((omd.RevProvinceCode != null) && (omd.RevProvinceCode != "")) { md.RevProv = omd.RevProvinceCode; } else if (((omd.RevProvince != null) && (omd.RevProvince != "")) && (omd.RevProvince.Length > 2)) { md.RevProv = omd.RevProvince.Substring(omd.RevProvince.Length - 2, 2); } else { md.RevProv = omd.RevProvince; } md.RevPostCode = omd.RevPostCode; md.RevCountry = omd.CountryCode; md.Width = Math.Ceiling(width).ToString(); md.Height = Math.Ceiling(height).ToString(); md.Lenght = Math.Ceiling(slong).ToString(); md.Weight = new decimal?(weight); if (Uint == 2) { md.Weight = new decimal?(weight * Convert.ToDecimal((double)2.2046226)); } else if (Uint == 3) { md.Weight = new decimal?(weight * Convert.ToDecimal((double)0.0625)); } string outError = ""; string fee = rate.GetFee(md, out outError); if (outError != "") { return outError; } return fee; } [WebMethod(EnableSession = true)] public string GetFedexFeeHWC(DT_OrderFedexModel omd, decimal weight, decimal width, decimal slong, decimal height, int Uint, int Uint2, int PostId, string PostType) { PagesNew.Login(base.Session); // int companyId = Convert.ToInt32(base.Session["CompanyId"]); if (Session["CompanyId"].ToString()=="25") { string a = GetFedexFeeHWC2(omd, weight, width, slong, height, Uint, Uint2, PostId, PostType); return a; } else { JC_ExpressService service = new JC_ExpressService(); JC_PostAddress address = new BaseService().GetAddressModel2(PostId); JC_ExpressPost expressModel = service.GetExpressModel(0, PostId); FedexRateNewHWC rate = new FedexRateNewHWC(); FedexRateNewHWC.Key = expressModel.UserCode; FedexRateNewHWC.Password = expressModel.CheckCode; FedexRateNewHWC.AccountNumber = expressModel.client_id; FedexRateNewHWC.MeterNumber = expressModel.client_secret; FedexRateNewHWC.PayAccountNumber = expressModel.refresh_token; FedexRateNewHWC.HubId = expressModel.Code; FedexRateNewHWC.AddFeeRate = 0.05M; FedexFeeMdNew md = new FedexFeeMdNew { RevName = omd.RevName, RevPhone = omd.RevPhone }; if ((omd.RevPhone == null) || (omd.RevPhone == "")) { md.RevPhone = omd.RevMoblie; } md.OrderId = -1; md.PostType = PostType; md.SendAddr = address.EnglishAddress; md.SendCountry = address.countycode; md.SendCity = address.city; md.SendProv = address.provincecode; md.SendPostCode = address.PostCode; if ((omd.RevAddr != null) && (omd.RevAddr != "")) { md.RevAddr = omd.RevAddr; } else { md.RevAddr = "street No 18"; } md.RevCity = omd.RevCity; if ((omd.RevCity == null) || (omd.RevCity == "")) { md.RevCity = omd.RevProvince; } if ((omd.RevProvinceCode != null) && (omd.RevProvinceCode != "")) { md.RevProv = omd.RevProvinceCode; } else if (((omd.RevProvince != null) && (omd.RevProvince != "")) && (omd.RevProvince.Length > 2)) { md.RevProv = omd.RevProvince.Substring(omd.RevProvince.Length - 2, 2); } else { md.RevProv = omd.RevProvince; } md.RevPostCode = omd.RevPostCode; md.RevCountry = omd.CountryCode; md.Width = Math.Ceiling(width).ToString(); md.Height = Math.Ceiling(height).ToString(); md.Lenght = Math.Ceiling(slong).ToString(); if (Uint2 == 2) { md.Width = Math.Ceiling(width * 0.3937M).ToString(); md.Height = Math.Ceiling(height * 0.3937M).ToString(); md.Lenght = Math.Ceiling(slong * 0.3937M).ToString(); } md.Weight = new decimal?(weight); if (Uint == 2) { md.Weight = new decimal?(weight * Convert.ToDecimal((double)2.2046226)); } else if (Uint == 3) { md.Weight = new decimal?(weight * Convert.ToDecimal((double)0.0625)); } string outError = ""; string fee = rate.GetFee(md, out outError); if (outError != "") { return outError; } return fee; } } public string GetFedexFeeHWC2(DT_OrderFedexModel omd, decimal weight, decimal width, decimal slong, decimal height, int Uint, int Uint2, int PostId, string PostType) { JC_ExpressService service = new JC_ExpressService(); JC_PostAddress address = new BaseService().GetAddressModel2(PostId); JC_ExpressPost expressModel = service.GetExpressModel(0, PostId); FedexRateNewHWC2 rate = new FedexRateNewHWC2(); FedexRateNewHWC2.Key = expressModel.UserCode; FedexRateNewHWC2.Password = expressModel.CheckCode; FedexRateNewHWC2.AccountNumber = expressModel.client_id; FedexRateNewHWC2.MeterNumber = expressModel.client_secret; FedexRateNewHWC2.PayAccountNumber = expressModel.refresh_token; FedexRateNewHWC2.HubId = expressModel.Code; FedexRateNewHWC2.AddFeeRate = 0.05M; FedexFeeMdNew md = new FedexFeeMdNew { RevName = omd.RevName, RevPhone = omd.RevPhone }; if ((omd.RevPhone == null) || (omd.RevPhone == "")) { md.RevPhone = omd.RevMoblie; } md.OrderId = -1; md.PostType = PostType; md.SendAddr = address.EnglishAddress; md.SendCountry = address.countycode; md.SendCity = address.city; md.SendProv = address.provincecode; md.SendPostCode = address.PostCode; if ((omd.RevAddr != null) && (omd.RevAddr != "")) { md.RevAddr = omd.RevAddr; } else { md.RevAddr = "street No 18"; } md.RevCity = omd.RevCity; if ((omd.RevCity == null) || (omd.RevCity == "")) { md.RevCity = omd.RevProvince; } if ((omd.RevProvinceCode != null) && (omd.RevProvinceCode != "")) { md.RevProv = omd.RevProvinceCode; } else if (((omd.RevProvince != null) && (omd.RevProvince != "")) && (omd.RevProvince.Length > 2)) { md.RevProv = omd.RevProvince.Substring(omd.RevProvince.Length - 2, 2); } else { md.RevProv = omd.RevProvince; } md.RevPostCode = omd.RevPostCode; md.RevCountry = omd.CountryCode; md.Width = Math.Ceiling(width).ToString(); md.Height = Math.Ceiling(height).ToString(); md.Lenght = Math.Ceiling(slong).ToString(); if (Uint2 == 2) { md.Width = Math.Ceiling(width * 0.3937M).ToString(); md.Height = Math.Ceiling(height * 0.3937M).ToString(); md.Lenght = Math.Ceiling(slong * 0.3937M).ToString(); } md.Weight = new decimal?(weight); if (Uint == 2) { md.Weight = new decimal?(weight * Convert.ToDecimal((double)2.2046226)); } else if (Uint == 3) { md.Weight = new decimal?(weight * Convert.ToDecimal((double)0.0625)); } string outError = ""; string fee = rate.GetFee(md, out outError); if (outError != "") { return outError; } return fee; } [WebMethod(EnableSession = true)] public List GetFedexFeeHWCNew(DT_OrderFedexModel omd, decimal weight, decimal width, decimal slong, decimal height, int Uint, int Uint2) { PagesNew.Login(base.Session); var rmodel = new List(); var postTypes = new List() { "SMART_POST", "FEDEX_2_DAY", "FEDEX_GROUND", "GROUND_HOME_DELIVERY" }; var postIds = new List() { 228, 237 };//W仓,E仓 var hycj = 0m;//获取立方,用来计算东西仓库海运差价 if (Uint2 == 1)//单位IN英寸 { hycj = (slong * 0.0254m * width * 0.0254m * height * 0.0254m) * 30; } else if (Uint2 == 2) //单位cm { hycj = (slong * 0.01m * width * 0.01m * height * 0.01m) * 30; } foreach (var postid in postIds) { JC_ExpressService service = new JC_ExpressService(); JC_PostAddress address = new BaseService().GetAddressModel2(postid); JC_ExpressPost expressModel = service.GetExpressModel(1, postid); TradeManageNew.FedexRateNew3 rate = new TradeManageNew.FedexRateNew3(); TradeManageNew.FedexRateNew3.Key = expressModel.UserCode; TradeManageNew.FedexRateNew3.Password = expressModel.CheckCode; TradeManageNew.FedexRateNew3.AccountNumber = expressModel.client_id; TradeManageNew.FedexRateNew3.MeterNumber = expressModel.client_secret; TradeManageNew.FedexRateNew3.PayAccountNumber = expressModel.refresh_token; TradeManageNew.FedexRateNew3.HubId = expressModel.Code; TradeManageNew.FedexRateNew3.PostId = postid; TradeManageNew.FedexFeeMdNew md = new TradeManageNew.FedexFeeMdNew { RevName = omd.RevName, RevPhone = omd.RevPhone }; if ((omd.RevPhone == null) || (omd.RevPhone == "")) { md.RevPhone = omd.RevMoblie; } md.OrderId = -1; md.SendAddr = address.EnglishAddress; md.SendCountry = address.countycode; md.SendCity = address.city; md.SendProv = address.provincecode; md.SendPostCode = address.PostCode; if ((omd.RevAddr != null) && (omd.RevAddr != "")) { md.RevAddr = omd.RevAddr; } md.RevCity = omd.RevCity; if ((omd.RevProvinceCode != null) && (omd.RevProvinceCode != "")) { md.RevProv = omd.RevProvinceCode; } md.RevPostCode = omd.RevPostCode; md.RevCountry = omd.CountryCode; md.Width = Math.Ceiling(width).ToString(); md.Height = Math.Ceiling(height).ToString(); md.Lenght = Math.Ceiling(slong).ToString(); if (Uint2 == 2) { md.Width = Math.Ceiling(width * 0.3937M).ToString(); md.Height = Math.Ceiling(height * 0.3937M).ToString(); md.Lenght = Math.Ceiling(slong * 0.3937M).ToString(); } md.Weight = new decimal?(weight); if (Uint == 2) { md.Weight = new decimal?(weight * Convert.ToDecimal((double)2.2046226)); } else if (Uint == 3) { md.Weight = new decimal?(weight * Convert.ToDecimal((double)0.0625)); } foreach (var postType in postTypes) { md.PostType = postType; var feeObj = rate.GetFee(md); var saveObj = new OrderPostFeeEstimate(); if (feeObj != null) { saveObj.OrderId = md.OrderId.Value; //东部仓库比西部仓库海运运费更高,所以只有东部仓库需要加上海运差价 if (postid == 228) { saveObj.Warehouse = "W仓"; saveObj.HYCJ = 0; } else if (postid == 237) { saveObj.Warehouse = "E仓"; saveObj.HYCJ = hycj; } saveObj.ServiceType = postType; saveObj.FenQu = feeObj.FenQu; saveObj.TotalFee = string.IsNullOrEmpty(feeObj.TotalFee) ? 0 : Convert.ToDecimal(feeObj.TotalFee); saveObj.BaseFee = string.IsNullOrEmpty(feeObj.BaseFee) ? 0 : Convert.ToDecimal(feeObj.BaseFee); saveObj.AHS = string.IsNullOrEmpty(feeObj.AHS) ? 0 : Convert.ToDecimal(feeObj.AHS); saveObj.OverSize = string.IsNullOrEmpty(feeObj.OverSize) ? 0 : Convert.ToDecimal(feeObj.OverSize); saveObj.PYAreaFee = string.IsNullOrEmpty(feeObj.PYAreaFee) ? 0 : Convert.ToDecimal(feeObj.PYAreaFee); saveObj.CPYAreaFee = string.IsNullOrEmpty(feeObj.CPYAreaFee) ? 0 : Convert.ToDecimal(feeObj.CPYAreaFee); saveObj.CJPYAreaFee = string.IsNullOrEmpty(feeObj.CJPYAreaFee) ? 0 : Convert.ToDecimal(feeObj.CJPYAreaFee); saveObj.FJDFee = string.IsNullOrEmpty(feeObj.FJDFee) ? 0 : Convert.ToDecimal(feeObj.FJDFee); saveObj.WangJiFee = string.IsNullOrEmpty(feeObj.WangJiFee) ? 0 : Convert.ToDecimal(feeObj.WangJiFee); saveObj.RanYouFee = string.IsNullOrEmpty(feeObj.RanYouFee) ? 0 : Convert.ToDecimal(feeObj.RanYouFee); saveObj.QianShouFee = string.IsNullOrEmpty(feeObj.QianShouFee) ? 0 : Convert.ToDecimal(feeObj.QianShouFee); saveObj.ZZFDZFee = string.IsNullOrEmpty(feeObj.ZZFDZFee) ? 0 : Convert.ToDecimal(feeObj.ZZFDZFee); saveObj.ChaoBiaoFee = string.IsNullOrEmpty(feeObj.ChaoBiaoFee) ? 0 : Convert.ToDecimal(feeObj.ChaoBiaoFee); if (!string.IsNullOrEmpty(feeObj.YuJiSongDa)) { saveObj.YuJiSongDa = Convert.ToDateTime(feeObj.YuJiSongDa).Date; } else saveObj.YuJiSongDa = null; saveObj.TotalDiscountFee = string.IsNullOrEmpty(feeObj.TotalDiscountFee) ? 0 : Convert.ToDecimal(feeObj.TotalDiscountFee); saveObj.TotalBillWeight = string.IsNullOrEmpty(feeObj.TotalBillWeight) ? "" : feeObj.TotalBillWeight; saveObj.IsBest = 0; //DataNew.SaveOrderPostFeeEstimate(saveObj); } else { saveObj.OrderId = md.OrderId.Value; if (postid == 228) { saveObj.Warehouse = "W仓"; } else if (postid == 237) { saveObj.Warehouse = "E仓"; } saveObj.ServiceType = postType; saveObj.FenQu = ""; saveObj.TotalFee = null; saveObj.BaseFee = null; saveObj.AHS = null; saveObj.OverSize = null; saveObj.PYAreaFee = null; saveObj.CPYAreaFee = null; saveObj.CJPYAreaFee = null; saveObj.FJDFee = null; saveObj.WangJiFee = null; saveObj.RanYouFee = null; saveObj.QianShouFee = null; saveObj.ZZFDZFee = null; saveObj.ChaoBiaoFee = null; saveObj.YuJiSongDa = null; saveObj.TotalDiscountFee = null; saveObj.TotalBillWeight = null; saveObj.IsBest = 0; } rmodel.Add(saveObj); Thread.Sleep(500); } } var rmodelNew = new List(); var rmodel1 = rmodel.Where(r => r.TotalFee != null && r.TotalFee.Value > 0).OrderBy(r => r.TotalFee + r.HYCJ); if(rmodel1!=null && rmodel1.Count()>0) rmodelNew.AddRange(rmodel1); var rmodel2 = rmodel.Where(r => r.TotalFee == null || r.TotalFee.Value <= 0); if(rmodel2!=null && rmodel2.Count()>0) rmodelNew.AddRange(rmodel2); return rmodelNew; } [WebMethod(EnableSession = true)] public RateAndTransitTimesResp GetFedexFeeTest() { var ratesAndTransitTimesTests = new RatesAndTransitTimesTests(); return ratesAndTransitTimesTests.Should_RateAsync_IsReturn(); } #region 修改允许发货 [WebMethod(EnableSession = true)] public void UpdatePostState2(List list) { PagesNew.Login(this.Session); if (list != null) { var obj = new DD_OrderData(); foreach (var md in list) { DataNew.UpdatePostState2(md.OrderId.Value); } } } #endregion [WebMethod(EnableSession = true)] public List GetOrderGoodsListForTM(int OrderId) { PagesNew.Login(base.Session); DD_OrderData data = new DD_OrderData(); List orderGoodsListNew = DataNew.GetOrderGoodsListNew(OrderId); DT_FeesTC TCModel = DataNew.GetModel_FeesTC(); decimal? tcfee = 0; if (TCModel != null&&TCModel.tc_fee!=null) tcfee = TCModel.tc_fee.Value; decimal goodssolid = 0M; if (orderGoodsListNew != null) { JC_Money money; List.Enumerator enumerator; decimal? hWCFee; decimal num4; decimal? nullable3; decimal num = Convert.ToDecimal((double)6.5); List list2 = new BaseService().GetMoneyList2(); List orderGoodsPostionCode = DataNew.GetOrderGoodsPostionCode(OrderId); decimal num2 = 0M; decimal num3 = 0M; decimal hwsfee = 0M; if ((orderGoodsPostionCode != null) && (orderGoodsPostionCode.Count > 0)) { using (enumerator = orderGoodsListNew.GetEnumerator()) { Predicate match = null; Predicate predicate2 = null; DT_OrderMateGoods md; while (enumerator.MoveNext()) { md = enumerator.Current; md.RMBMoney = 0; if (match == null) { match = delegate(JC_Money n) { int? nullable; int? nullable2; return (n.MCode == "USD") && (((nullable = n.PlatId).GetValueOrDefault() == (nullable2 = md.PlatId).GetValueOrDefault()) && (nullable.HasValue == nullable2.HasValue)); }; } money = list2.Find(match); if (money != null) { num = money.MRate.Value; } if (predicate2 == null) { predicate2 = n => n.Id == md.Id; } DT_OrderMateGoods goods = orderGoodsPostionCode.Find(predicate2); if (goods != null) { md.PostionCode = goods.PostionCode; md.Price = 0; if (goods.Price > 0 && md.GoodsPrice > 0) { md.RMBMoney = (goods.Price.Value * goods.GoodsPrice.Value * md.GoodsNum.Value * Convert.ToDecimal(0.01)) / num; } if (goods.Price.HasValue && md.GoodsNum.HasValue) { num4 = (goods.Price.Value * md.GoodsNum.Value) / num; md.Price = new decimal?(Convert.ToDecimal(num4.ToString("0.00"))); } md.PostPrice = 0; if (goods.PostPrice.HasValue && md.GoodsNum.HasValue) { num4 = (goods.PostPrice.Value * md.GoodsNum.Value) / num; md.PostPrice = new decimal?(Convert.ToDecimal(num4.ToString("0.00"))); } hWCFee = goods.HWCFee; num4 = md.GoodsNum.Value; md.HWCFee = hWCFee.HasValue ? new decimal?(hWCFee.GetValueOrDefault() * num4) : ((decimal?)(nullable3 = null)); num2 += ((goods.Price.Value * md.GoodsNum.Value) + (goods.PostPrice.Value * md.GoodsNum.Value)) / num; num3 += md.HWCFee.Value; hwsfee += md.RMBMoney.Value; } } } if (orderGoodsListNew.Count > 0) { orderGoodsListNew[0].GoodsCB = new decimal?(Convert.ToDecimal(num2.ToString("0.00"))); orderGoodsListNew[0].GoodsCB2 = new decimal?(Convert.ToDecimal(num3.ToString("0.00"))); orderGoodsListNew[0].RMBMoney = new decimal?(Convert.ToDecimal(hwsfee.ToString("0.00"))); } // return orderGoodsListNew; } num2 = 0M; num3 = 0M; hwsfee = 0M; decimal Ratefee = 0M; using (enumerator = orderGoodsListNew.GetEnumerator()) { Predicate predicate3 = null; DT_OrderMateGoods md; while (enumerator.MoveNext()) { md = enumerator.Current; if (md.Solid != null) goodssolid += md.Solid.Value * md.GoodsNum.Value; if (predicate3 == null) { predicate3 = delegate(JC_Money n) { int? nullable; int? nullable2; return (n.MCode == "USD") && (((nullable = n.PlatId).GetValueOrDefault() == (nullable2 = md.PlatId).GetValueOrDefault()) && (nullable.HasValue == nullable2.HasValue)); }; } money = list2.Find(predicate3); if (money != null) { num = money.MRate.Value; } num4 = (md.InPrice.Value * md.GoodsNum.Value) / num; md.Price = new decimal?(Convert.ToDecimal(num4.ToString("0.00"))); md.PostPrice = 0; md.HWCFee = 0; if (md.Solid != null) { hWCFee = md.Solid * 170M * md.GoodsNum.Value;//预估头程 // num4 = md.GoodsNum.Value; md.HWCFee = hWCFee; } if (md.GoodsPrice != null) Ratefee += md.Price.Value * md.GoodsPrice.Value * 0.01M;//预估税费 num2 += md.Price.Value; num3 += md.HWCFee.Value; } } if (orderGoodsListNew.Count > 0) { orderGoodsListNew[0].OldTypeDesc = num2.ToString("0.00");//预估成本 orderGoodsListNew[0].OldTypeCode = Ratefee.ToString("0.00");//预估税费 orderGoodsListNew[0].MoneyCode = num3.ToString("0.00");//预估头程 if (orderGoodsListNew[0].GoodsCB == null || orderGoodsListNew[0].GoodsCB == 0) orderGoodsListNew[0].GoodsCB = new decimal?(Convert.ToDecimal(num2.ToString("0.00"))); if (orderGoodsListNew[0].GoodsCB2 == null || orderGoodsListNew[0].GoodsCB2 == 0) orderGoodsListNew[0].GoodsCB2 = new decimal?(Convert.ToDecimal(num3.ToString("0.00"))); // if (orderGoodsListNew[0].RMBMoney == null || orderGoodsListNew[0].RMBMoney == 0) // orderGoodsListNew[0].RMBMoney = new decimal?(Convert.ToDecimal(Ratefee.ToString("0.00"))); // orderGoodsListNew[0].Length2 = goodssolid;//货物立方 } } return orderGoodsListNew; } [WebMethod(EnableSession = true)] public List GetOrderGoodsListForTM4(int OrderId) { PagesNew.Login(base.Session); DD_OrderData data = new DD_OrderData(); List orderGoodsListNew = DataNew.GetOrderGoodsListNew(OrderId); if (orderGoodsListNew != null) { JC_Money money; List.Enumerator enumerator; decimal? hWCFee; decimal num4; decimal? nullable3; decimal num = Convert.ToDecimal((double)6.5); List list2 = new BaseService().GetMoneyList2(); List orderGoodsPostionCode = DataNew.GetOrderGoodsPostionCode(OrderId); decimal num2 = 0M; decimal num3 = 0M; decimal hwsfee = 0M; if ((orderGoodsPostionCode != null) && (orderGoodsPostionCode.Count > 0)) { using (enumerator = orderGoodsListNew.GetEnumerator()) { Predicate match = null; Predicate predicate2 = null; DT_OrderMateGoods md; while (enumerator.MoveNext()) { md = enumerator.Current; md.RMBMoney = 0; if (match == null) { match = delegate(JC_Money n) { int? nullable; int? nullable2; return (n.MCode == "USD") && (((nullable = n.PlatId).GetValueOrDefault() == (nullable2 = md.PlatId).GetValueOrDefault()) && (nullable.HasValue == nullable2.HasValue)); }; } money = list2.Find(match); if (money != null) { num = money.MRate.Value; } num = 1;//按人民币算 if (predicate2 == null) { predicate2 = n => n.Id == md.Id; } DT_OrderMateGoods goods = orderGoodsPostionCode.Find(predicate2); if (goods != null) { md.PostionCode = goods.PostionCode; md.Price = 0; if (goods.Price > 0 && md.GoodsPrice > 0) { md.RMBMoney = (goods.Price.Value * goods.GoodsPrice.Value * md.GoodsNum.Value * Convert.ToDecimal(0.01)) / num; } if (goods.Price.HasValue && md.GoodsNum.HasValue) { num4 = (goods.Price.Value * md.GoodsNum.Value) / num; md.Price = new decimal?(Convert.ToDecimal(num4.ToString("0.00"))); } md.PostPrice = 0; if (goods.PostPrice.HasValue && md.GoodsNum.HasValue) { num4 = (goods.PostPrice.Value * md.GoodsNum.Value) / num; md.PostPrice = new decimal?(Convert.ToDecimal(num4.ToString("0.00"))); } hWCFee = goods.HWCFee; num4 = md.GoodsNum.Value; md.HWCFee = hWCFee.HasValue ? new decimal?(hWCFee.GetValueOrDefault() * num4) : ((decimal?)(nullable3 = null)); num2 += ((goods.Price.Value * md.GoodsNum.Value) + (goods.PostPrice.Value * md.GoodsNum.Value)) / num; num3 += md.HWCFee.Value; hwsfee += md.RMBMoney.Value; } } } if (orderGoodsListNew.Count > 0) { orderGoodsListNew[0].GoodsCB = new decimal?(Convert.ToDecimal(num2.ToString("0.00"))); orderGoodsListNew[0].GoodsCB2 = new decimal?(Convert.ToDecimal(num3.ToString("0.00"))); orderGoodsListNew[0].RMBMoney = new decimal?(Convert.ToDecimal(hwsfee.ToString("0.00"))); } // return orderGoodsListNew; } num2 = 0M; num3 = 0M; hwsfee = 0M; decimal Ratefee = 0M; using (enumerator = orderGoodsListNew.GetEnumerator()) { Predicate predicate3 = null; DT_OrderMateGoods md; while (enumerator.MoveNext()) { md = enumerator.Current; if (predicate3 == null) { predicate3 = delegate(JC_Money n) { int? nullable; int? nullable2; return (n.MCode == "USD") && (((nullable = n.PlatId).GetValueOrDefault() == (nullable2 = md.PlatId).GetValueOrDefault()) && (nullable.HasValue == nullable2.HasValue)); }; } money = list2.Find(predicate3); if (money != null) { num = money.MRate.Value; } num = 1;//按人民币算 num4 = (md.InPrice.Value * md.GoodsNum.Value) / num; md.Price = new decimal?(Convert.ToDecimal(num4.ToString("0.00"))); md.PostPrice = 0; md.HWCFee = 0; if (md.Solid != null) { hWCFee = md.Solid * 170M * md.GoodsNum.Value;//预估头程 // num4 = md.GoodsNum.Value; md.HWCFee = hWCFee; } if (md.GoodsPrice != null) Ratefee += md.Price.Value * md.GoodsPrice.Value * 0.01M;//预估税费 num2 += md.Price.Value; num3 += md.HWCFee.Value; } } if (orderGoodsListNew.Count > 0) { orderGoodsListNew[0].OldTypeDesc = num2.ToString("0.00");//预估成本 orderGoodsListNew[0].OldTypeCode = Ratefee.ToString("0.00");//预估税费 orderGoodsListNew[0].MoneyCode = num3.ToString("0.00");//预估头程 if (orderGoodsListNew[0].GoodsCB == null || orderGoodsListNew[0].GoodsCB == 0) orderGoodsListNew[0].GoodsCB = new decimal?(Convert.ToDecimal(num2.ToString("0.00"))); if (orderGoodsListNew[0].GoodsCB2 == null || orderGoodsListNew[0].GoodsCB2 == 0) orderGoodsListNew[0].GoodsCB2 = new decimal?(Convert.ToDecimal(num3.ToString("0.00"))); // if (orderGoodsListNew[0].RMBMoney == null || orderGoodsListNew[0].RMBMoney == 0) // orderGoodsListNew[0].RMBMoney = new decimal?(Convert.ToDecimal(Ratefee.ToString("0.00"))); } } return orderGoodsListNew; } [WebMethod(EnableSession = true)] public void GetGoodsFee() { PagesNew.Login(base.Session); DataNew.GetGoodsFee(); DataNew.GetGoodsBack(); } #region 扫描订单发货 [WebMethod(EnableSession = true)] public DT_OrderModel ScanOrderPost2(int OrderId, int Post, string CountryCode, int PostState, int Weight, int BagUserId, string TrackCode, string OrderCode, string JoinOrderCode, int OrderState, int TrackId, int IsBlank, int IsCSM) { PagesNew.Login(this.Session); var obj = new DD_OrderData(); int CompanyId = Convert.ToInt32(Session["CompanyId"]); int UserId = Convert.ToInt32(Session["UserId"]); string Name = Convert.ToString(Session["Name"]); DT_OrderModel md = new DT_OrderModel(); //if (Weight > 2000) //{ // int isweight = JC_ExpressService.GetExpressWeight(Post); // if (isweight >= 2000) // { // md.PostError = "超出重量限制"; // return md; // } //} //int weightrate md.WeightRate.Value; //if (Weight > GoodsWeight * (1 + Convert.ToDecimal(weightrate * 1.00) / 100)) //{ // md.PostError = "根据订单计算重量为" + GoodsWeight + "g,称重重量超过订单重量的" + weightrate.ToString() + "%;请确定货物是否正确再发货"; //} //else // if (Weight < GoodsWeight * (1 - Convert.ToDecimal(weightrate * 1.00) / 100)) // { // md.PostError = "根据订单计算重量为" + GoodsWeight + "g,重量验证低于实际重量的" + weightrate.ToString() + "%;请确定货物是否正确再发货"; // } //if (IsJe == 1 && GoodsPrice > 0 && postfee > GoodsPrice * Convert.ToDecimal(1.2)) //{ // md.PostError = "运费"; //} //else //{ DT_TrackCodeScan Model = new DT_TrackCodeScan(); Model.PostId = Post; Model.OrderId = OrderId; Model.InName = Name; Model.InDate = DateTime.Now; Model.IsSure = 0; Model.PostFee = 0; Model.OldPostFee = 0; Model.Weight = Weight; Model.BagUserId = BagUserId; Model.TrackCode = TrackCode; if (JoinOrderCode != null && JoinOrderCode != "") Model.OrderCode = JoinOrderCode; else Model.OrderCode = OrderCode; Model.TrackId = TrackId; Model.Count = 1; Model.JoinOrderCode = JoinOrderCode; Model.IsCSM = IsCSM; DataNew.SaveTrackCodeScan3(Model); md.PostState = 1; string log = Model.OrderCode; if (IsBlank == 1) log += "空包裹"; PagesNew.SaveLog(UserId, "订单发货", log + "发货扫描", OrderId); //if (OrderState == 2) //空包裹 //{ // obj.UpdateBlankBagForTM(OrderId, Weight, postfee); //} //else // obj.UpdateOrderGoodsForTM(OrderId, Weight, postfee, JoinOrderCode); // } md.PostFee = 0; return md; } #endregion [WebMethod(EnableSession = true)] public JsonModel> GetListOrderForTM22(int IsYJ, string MName, string groupName, int StoreId, int DeptId, int PlatType, int ShopId, int DateType, DateTime? SDate, DateTime? EDate, int TjType, string Name, int PrintState, int MateState, int MoneyState, int OutDays, int State, int IsSku, int IsError, int IsE, int IsDetail, int HBOrder, int IsSD, int SaleState, int IsBuy, int WLId, int PostId, int IsDH, int SFLY, int yfcy, int storeyc, int PageIndex, int PageSize, string Sort) { PagesNew.Login(base.Session); DD_OrderData data = new DD_OrderData(); int num = Convert.ToInt32(base.Session["CompanyId"]); RefParameterCollection where = new RefParameterCollection(); if (storeyc == 1)//仓库异常 { var olist = DataNew.GetListStoreYC(DateTime.Today); string sids = "0,"; if (olist != null) { foreach (var smd in olist) { sids += smd.OrderId.ToString() + ","; } } where.Add("a.OrderId", "in", sids.TrimEnd(','), DbType.String); } if (IsYJ == 1) { where.Add("a.PlatId", "=", 2, DbType.Int32); where.Add("isnull(a.Fee6,0)", "=", 0, DbType.Int32); where.Add("isnull(a.Fee7,0)", "=", 0, DbType.Int32); where.Add("isnull(a.Fee8,0)", "=", 0, DbType.Int32); } if (StoreId > 0) { where.Add("a.StoreId", "=", StoreId, DbType.Int32); } if (IsBuy == 1) { where.Add("a.BuyDate", "is not", null, DbType.String); } else if (IsBuy == 0) { where.Add("a.BuyDate", "is", null, DbType.String); } where.Add("a.CompanyId", "=", num, DbType.Int32); // where.Add("isnull(a.IsSDan,0)", "=", IsSD, DbType.Int32); if (yfcy == 1) where.Add("a.WLSS", "=", 1, DbType.Int32); if (SaleState > 0) { where.Add("a.SaleState", "=", SaleState, DbType.Int32); } if (WLId > 0) { where.Add("a.LogisticsId", "=", WLId, DbType.Int32); } if (PostId > 0) { where.Add("a.Post", "=", PostId, DbType.Int32); } if (DeptId > 0) { where.Add("c.DeptId", "=", DeptId, DbType.Int32); } if (PlatType > 0) { where.Add("a.PlatId", "=", PlatType, DbType.Int32); } if (ShopId > 0) { where.Add("a.ShopId", "=", ShopId, DbType.Int32); } if (DateType == 1) { if (SDate.HasValue) { where.Add("a.OrderDate", ">=", SDate, DbType.DateTime); } if (EDate.HasValue) { where.Add("a.OrderDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime); } } else if (DateType == 2) { if (SDate.HasValue) { where.Add("a.InDate", ">=", SDate, DbType.DateTime); } if (EDate.HasValue) { where.Add("a.InDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime); } } else if (DateType == 3) { if (SDate.HasValue) { where.Add("a.PrintDate", ">=", SDate, DbType.DateTime); } if (EDate.HasValue) { where.Add("a.PrintDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime); } } else if (DateType == 4) { if (SDate.HasValue) { where.Add("a.PostDate", ">=", SDate, DbType.DateTime); } if (EDate.HasValue) { where.Add("a.PostDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime); } } else if (DateType == 5) { if (SDate.HasValue) { where.Add("a.OrderOutDate", ">=", SDate, DbType.DateTime); } if (EDate.HasValue) { where.Add("a.OrderOutDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime); } } if (OutDays > 0) { where.Add("a.OrderOutDate", "<=", DateTime.Now.AddDays((double)OutDays), DbType.DateTime); where.Add("a.OrderOutDate", ">=", DateTime.Now, DbType.DateTime); } if (MateState > -1) { where.Add("a.MateState", "=", MateState, DbType.Int32); } if (MoneyState > -1) { where.Add("a.MoneyState", "=", MoneyState, DbType.Int32); } if (PrintState > -1) { where.Add("a.PrintState", "=", PrintState, DbType.Int32); } if (State == 3) { where.Add("a.State", "=", 2, DbType.Int32); } else if (State == 4) { where.Add("a.State", "=", 3, DbType.Int32); } else if (State == 5) { where.Add("a.State", "=", 1, DbType.Int32); where.Add("a.MoneyState", "=", 1, DbType.Int32); } else if (State == 7) { where.Add("a.OrderState2", "=", 1, DbType.Int32); } else if (State == 1) { where.Add("a.PostState", "=", 1, DbType.Int32); } else if (State == 2) { where.Add("a.State", "<", 3, DbType.Int32); where.Add("a.PostState", "=", 2, DbType.Int32); } else if (State == 0) { where.Add("a.State", "=", 1, DbType.Int32); } else if (State == 8) { where.Add("a.State", "<", 3, DbType.Int32); where.Add("a.PostState", "=", 3, DbType.Int32); } else { where.Add("a.State", ">", 0, DbType.Int32); } if (HBOrder == 1) { where.Add("a.IsJoin", "=", 1, DbType.Int32); } if (IsError == 1) { where.Add("(a.SendAddr", ">", 0, DbType.Int32); where.Add("a.IsLeaveWord", "=", 1, "or", ")", DbType.Int32); } if (IsE == 1) { where.Add("a.PostState", "=", 2, DbType.Int32); } if (IsE == 0) { where.Add("a.PostState", "<", 2, DbType.Int32); } string trackCode = ""; if (Name != "") { Name = Name.Trim(); if (TjType == 1) { where.Add("(a.PlatOrderCode", "like", Name, DbType.String); where.Add("OrderCode", "like", Name, "or", DbType.String); where.Add("a.JoinOrderCode", "like", Name, "or", ")", DbType.String); } else if (TjType == 2) { where.Add("a.RevName", "like", Name, DbType.String); } else if (TjType == 3) { where.Add("a.RevPhone", "like", Name, DbType.String); } else if (TjType == 4) { where.Add("(a.RevCountry", "=", Name, DbType.String); where.Add("a.CountryName", "=", Name, "or", DbType.String); where.Add("a.CountryCode", "=", Name, "or", ")", DbType.String); } else if (TjType == 5) { where.Add("a.RevPostCode", "=", Name, DbType.String); } else if (TjType == 6) { where.Add("(a.RevAddr", "like", Name, DbType.String); where.Add("a.RevProvince", "like", Name, "or", DbType.String); where.Add("a.RevCity", "like", Name, "or", DbType.String); where.Add("a.RevArea", "like", Name, "or", ")", DbType.String); } else if (TjType == 9) { where.Add("(a.ErrorInfo", "like", Name, DbType.String); where.Add("a.PostError", "like", Name, "or", ")", DbType.String); } else if (TjType == 10) { trackCode = Name; } else if (TjType == 11) { where.Add("a.CustomID", "=", Name, DbType.String); } else if (TjType == 12) { where.Add("a.RevMail", "=", Name, DbType.String); } } if (IsSku == 0) { where.Add("a.FPDate", "is", null, DbType.String); } else if (IsSku == 1) { where.Add("a.FPDate", "is not", null, DbType.String); } JsonModel> model = new JsonModel>(); int rowCount = 0; string str2 = ""; string str3 = ""; if ((TjType == 7) && (Name != "")) { str2 = Name; } else if ((TjType == 8) && (Name != "")) { str3 = Name; } if (TjType == 13 && Name != "")//根据人员查询 { model.DataSource = DataNew.GetListDT_OrderInfoForUser_New(num, SDate, str2.Trim(), Name, trackCode, -1, IsDH, where, PageIndex, PageSize, Sort, out rowCount); } else { //if (SFLY > 0) //{ // if (SFLY == 1) // { // model.DataSource = data.GetListDT_OrderInfoForTM6(num, str2.Trim(), str3.Trim(), trackCode, -1, IsDH, where, PageIndex, PageSize, Sort, out rowCount); // } // if (SFLY == 2) // { // model.DataSource = data.GetListDT_OrderInfoForTM7(num, str2.Trim(), str3.Trim(), trackCode, -1, IsDH, where, PageIndex, PageSize, Sort, out rowCount); // } //} //else //{ model.DataSource = DataNew.GetListDT_OrderInfoForTM2_New(num, MName, str2.Trim(), str3.Trim(), trackCode, -1, IsDH, where, PageIndex, PageSize, Sort, out rowCount,groupName); // } } model.RowCount = rowCount; string ids = ""; List shopids = new List(); DateTime? maxDate = null, minDate = null; JC_ExpressService wlobj = new JC_ExpressService(); var wlist = wlobj.GetExpressList(); List maplist = null; if (model.DataSource != null) { foreach (DT_OrderListNew md in model.DataSource) { ids += md.OrderId.ToString() + ","; if (md.Post != null && md.Post > 0) { var wlmd = wlist.Find(n => n.ExpressID == md.Post); if (wlmd != null) { md.TrackInfo = wlmd.Name; } } if (md.StoreId == 11) md.RevFax = "E"; else md.RevFax = "W"; if (md.ShopId.HasValue) shopids.Add(md.ShopId.Value); //if (maplist != null && md.RevProvince != null && md.RevProvince != "") //{ // var mmd = maplist.Find(n => n.code == md.RevProvince.ToUpper() || n.ename == md.RevProvince); // if (mmd != null) // { // if (mmd.IsEast == 1) // { // md.RevFax = "E"; // } // else // md.RevFax = "W"; // } //} } maxDate = model.DataSource.OrderByDescending(r => r.OrderDate.Value).First().OrderDate.Value; minDate = model.DataSource.OrderBy(r => r.OrderDate.Value).First().OrderDate.Value; } var linklist = new List(); if (ids != "") { maplist = DataNew.GetListUSMap4(ids.Trim(',')); List errorList = data.GetErrorList(ids.Trim(',')); linklist = DataNew.GetListMBLinkOrder(ids.Trim(',')); if ((errorList != null) && (errorList.Count > 0)) { foreach (var md in model.DataSource) { DT_OrderError error = errorList.Find(n => n.OrderId == md.OrderId); if (error != null) { md.ErrorInfo = error.ErrorInfo; } } } } if (shopids != null && shopids.Count > 0) shopids = shopids.Distinct().ToList(); List saleBackModelList = null; List flist = null; if ((IsDetail == 1) && (model.DataSource != null)) { int? trackType; if (ids != "") { List orderGoodsList = DataNew.GetOrderGoodsListNew2_New(ids.Trim(',')); List trackCodeApplyList = data.GetTrackCodeApplyList(ids.Trim(',')); //saleBackModelList = data.GetSaleBackModelList(ids.Trim(',')); flist = DataNew.GetOrderFees(ids.Trim(',')); //var pmlist = DataNew.GetOrderGoodsCodeData(); var pmlist = DataNew.GetGoodsRankModelList(string.Join(",", shopids), maxDate, minDate); List JZLinklist = DataNew.GetListJZLinkOrder(ids.Trim(',')); List adSpendList = DataNew.GetAllGoodWeekAdSpend(); //List orderGoodsAdList = DataNew.GetOrderListGoodsAdFeeByOrderID(ids.Trim(',')); var last2DayadFees = DataNew.GetGoodsLast2DayAdFeeListByOrders(ids.TrimEnd(','));//商品前天的广告花费 if (orderGoodsList != null) { foreach (var md in model.DataSource) { bool kcW = true; bool kcE = true;//W仓,E仓库存是否足够发货,足够发货才能和UPS比较运费 List list5 = orderGoodsList.FindAll(n => n.OrderId == md.OrderId); var totalAdfee = 0m;//订单广告总花费 var hyfcj = 0m;//海运费差价 if (list5 != null) { md.GoodsList = list5; foreach (var mdg in md.GoodsList) { if (mdg.WestNum < mdg.GoodsNum) kcW = false; if (mdg.EastNum < mdg.GoodsNum) kcE = false; if (mdg.GoodsId.HasValue && md.ShopId.HasValue) { if (adSpendList != null) { var adspend = adSpendList.Where(r => r.shopid == md.ShopId.Value && r.goodsid == mdg.GoodsId.Value).FirstOrDefault(); mdg.goodWeekAdFee = adspend == null ? 0 : (adspend.spend.HasValue ? adspend.spend.Value : 0); } if (last2DayadFees != null) { var last2DayFee = last2DayadFees.Where(r => r.shopid == md.ShopId.Value && r.goodsid == mdg.GoodsId.Value).FirstOrDefault(); mdg.last2DayAdFee = last2DayFee == null ? 0 : (last2DayFee.spend.HasValue ? last2DayFee.spend.Value : 0); } //if (orderGoodsAdList != null) //{ // var adFee = orderGoodsAdList.Where(r => r.OrderDate == md.OrderDate.Value.ToString("yyyy-MM-dd") && r.ShopId == md.ShopId && r.GoodsId == mdg.GoodsId.Value).FirstOrDefault(); // mdg.goodWeekAdFee = adFee == null ? 0 : (adFee.AvgAdfee.HasValue ? adFee.AvgAdfee.Value : 0); //} } else { mdg.goodWeekAdFee = 0; mdg.last2DayAdFee = 0; } totalAdfee = totalAdfee + (mdg.adfee.HasValue ? mdg.adfee.Value : 0); hyfcj += (mdg.GoodsNum.HasValue && mdg.Solid2.HasValue) ? (mdg.GoodsNum.Value * mdg.Solid2.Value) : 0; } if (pmlist != null) { foreach (var mmd in list5) { var pmmd = pmlist.Find(n => n.asin == mmd.productImgUrl2 && n.ShopId == md.ShopId && n.OrderDate.Date == md.OrderDate.Value.Date); if (pmmd != null) { string imgurl = ""; if (pmmd.Int10 != null && pmmd.Int10 == 1) { imgurl = ""; } if (pmmd.Int10 != null && pmmd.Int10 == 2) { imgurl = ""; } if (pmmd.Int10 != null && pmmd.Int10 == 3) { imgurl = ""; } if (pmmd.Int3 < 100) mmd.OldTypeDesc = "排名:" + pmmd.Int3.ToString(); else mmd.OldTypeDesc = "排名:" + pmmd.Int3.ToString(); if (pmmd.Int2 != null) mmd.OldTypeDesc += "/" + pmmd.Int2.ToString(); mmd.OldTypeDesc += "" + imgurl; } else mmd.OldTypeDesc = ""; } } } md.TotalAdFee = totalAdfee; //ups和fedex比较运费,再东西部都有库存的情况下,UPS需要和Fedex的W仓和E仓两个二比较, //如果收货地址是Residential住宅区,则UPS和Fedex的Smart_Post、GROUND_HOME_DELIVERY比较; //如果收货地址是Commercial或者Office,ups就和Fedex的Smart_Post、Fedex_Ground比较;Fedex的E仓比较时需要加上海运费差价 if (md.UpsFeeR.HasValue) { if (md.AddressType == "Commercial" || md.AddressType == "Office") { if (kcW) { md.UPSFee = (md.UpsFeeR < md.Fee6 && md.UpsFeeR < md.Fee7) ? md.UpsFeeR : 0; } if (kcE) { if (!kcW || (md.UPSFee.HasValue && md.UPSFee.Value > 0)) //如果西部没有库存 或者 此时md.UPSFee有值并且大于0,说明UPS快递费小于Fedex的西部费用,接下来和Fedex的东部费用比较 { md.UPSFee = (md.UpsFeeR < (md.Fee11 + hyfcj * 30) && md.UpsFeeR < (md.Fee12 + hyfcj * 30)) ? md.UpsFeeR : 0; } else md.UPSFee = 0; } } else { if (kcW) { md.UPSFee = (md.UpsFeeR < md.Fee6 && md.UpsFeeR < md.Fee8) ? md.UpsFeeR : 0; } if (kcE) { if (!kcW || (md.UPSFee.HasValue && md.UPSFee.Value > 0)) //如果西部没有库存 或者 此时md.UPSFee有值并且大于0,说明UPS快递费小于Fedex的西部费用,接下来和Fedex的东部费用比较 { md.UPSFee = (md.UpsFeeR < (md.Fee11 + hyfcj * 30) && md.UpsFeeR < (md.Fee13 + hyfcj * 30)) ? md.UpsFeeR : 0; } else md.UPSFee = 0; } } } else md.UPSFee = 0; //if (md.UpsFeeR.HasValue && md.UpsFeeE.HasValue) //{ // md.UPSFee = md.UpsFeeR > md.UpsFeeE ? md.UpsFeeE : md.UpsFeeR; //} //else if (!md.UpsFeeR.HasValue && !md.UpsFeeE.HasValue) //{ // md.UPSFee = 0; //} //else //{ // md.UPSFee = md.UpsFeeR.HasValue ? md.UpsFeeR.Value : md.UpsFeeE.Value; //} //if (md.UPSFee > md.Fee8 || md.UPSFee > (md.Fee13 + hyfcj * 30)) //{ // md.UPSFee = 0; //} } } if (trackCodeApplyList != null) { foreach (var md in model.DataSource) { List list6 = new List(); if ((md.JoinOrderCode != null) && (md.JoinOrderCode != "")) { list6 = trackCodeApplyList.FindAll(n => n.OrderCode == md.JoinOrderCode); } else { list6 = trackCodeApplyList.FindAll(n => n.OrderId == md.OrderId); } if ((list6 != null) && (list6.Count > 0)) { string str5 = ""; string str6 = ""; foreach (DT_TrackCodeApply apply in list6) { string str7 = ""; trackType = apply.TrackType; if (trackType != null && trackType == 3) { str7 = "[空包裹]"; } if (apply.Weight.HasValue) { string str8 = ""; if (apply.ScanDate.HasValue) { str8 = "扫描时间:" + apply.ScanDate.Value.ToString("yyyy-MM-dd HH:mm") + "
"; } string str9 = str5; str5 = str9 + apply.TrackCode + str7 + "
重量" + apply.Weight.ToString() + "g" + str8 + "
"; } else { str5 = str5 + apply.TrackCode + str7 + "
"; } if (str6 == "") { str6 = apply.TrackCode; } } md.TrackInfo += str5; md.TrackCode = str6; } } } decimal moneyrate = Convert.ToDecimal((double)6.5); List list7 = new BaseService().GetMoneyList2(); //decimal ckfee = 0; //decimal mdfee = 0; //decimal adfee = 0; //decimal DR_BackFee = 0; //decimal DR_SSFee = 0; //decimal DR_PostFee = 0; foreach (var md in model.DataSource) { var fmd = flist.Find(n => n.orderid == md.OrderId); if (fmd == null) fmd = new DT_Fees(); md.OrderName = (fmd != null && fmd.SubsidyFee.HasValue && fmd.SubsidyFee.Value > 0) ? fmd.SubsidyFee.Value.ToString("0.00") : ""; #region 注释竞品信息改为显示补贴金额2024-05-17 //string jplink = ""; //if (linklist != null) //{ // var lmdlist = linklist.FindAll(n => n.OrderId == md.OrderId && n.ShopId == md.ShopId); // if (lmdlist != null) // { // foreach (var lmd in lmdlist) // { // int pm2 = 0; // var pmmd = pmlist != null ? pmlist.Find(n => n.GoodsId == lmd.GoodsId && n.ShopId == md.ShopId) : null; // if (pmmd != null && pmmd.Int3 != null) // { // pm2 = pmmd.Int3.Value; // } // if (lmdlist.Count > 1) // jplink += "" + lmd.SKU1 + ":【S】" + lmd.GoodsHJNum2 + ""; // else // jplink += "【S】" + lmd.GoodsHJNum2 + ""; // if (lmd.Num != null) // { // if (lmd.GoodsHJNum2 >= lmd.Num) // jplink += "【TS】" + lmd.Num + ""; // else // jplink += "【TS】" + lmd.Num + ""; // } // jplink += "
"; // if (pm2 > 0) // jplink += "【R】" + pm2 + ""; // else // jplink += "【R】无"; // if (lmd.PM != null) // { // if (pm2 > 0 && lmd.PM >= pm2) // jplink += "【TR】" + lmd.PM + ""; // else // jplink += "【TR】" + lmd.PM + ""; // } // jplink += "
"; // } // } // md.OrderName = jplink; //} //if (JZLinklist != null) //{ // var jzmd = JZLinklist.FindAll(n => n.OrderId == md.OrderId && n.ShopId == md.ShopId); // if (jzmd != null) // { // int i = 1; // foreach (var jzmmd in jzmd) // { // if (jzmmd.Price != null) // jplink += "竟品" + i.ToString() + "价格:" + jzmmd.Price.Value + "$
"; // else // jplink += "竟品" + i.ToString() + "
"; // i++; // } // } // md.OrderName = jplink; //} #endregion if (fmd.moneyrate != null) moneyrate = fmd.moneyrate.Value; else { JC_Money money = list7.Find(n => n.MCode == "USD" && n.PlatId == md.PlatId); if (money != null) { moneyrate = money.MRate.Value; } else { money = list7.Find(n => n.MCode == "USD"); moneyrate = money.MRate.Value; } } decimal TotalPrice = 0M; if (md.TotalPrice != null) { TotalPrice = md.TotalPrice.Value; } decimal YJPrice = 0M; decimal sjyf = 0; if (fmd.sjyf != null) sjyf = fmd.sjyf.Value; decimal ygyf = 0; if (fmd.yf != null) ygyf = fmd.yf.Value; md.PostFee = sjyf; md.BoxFee = ygyf; if (fmd.yj != null) YJPrice = fmd.yj.Value; decimal GoodsFee = 0; if (fmd.sjcb != null) GoodsFee = fmd.sjcb.Value; if (fmd.sjhwsf != null) GoodsFee += fmd.sjhwsf.Value; if (moneyrate == 0) moneyrate = 6.5M; GoodsFee = GoodsFee / moneyrate; decimal YJGoodsFee = 0; if (fmd.cb != null) YJGoodsFee = fmd.cb.Value; if (fmd.hwsf != null) YJGoodsFee += fmd.hwsf.Value; md.Fee8 = 0; md.Fee8 = fmd.ck; decimal sjtc = 0; if (fmd.sjtc == null || fmd.sjtc == 0) sjtc = fmd.tc.Value; else sjtc = fmd.sjtc.Value; YJGoodsFee = YJGoodsFee / moneyrate; if (md.PlatId != 2) md.TotalAdFee = fmd.Ad_Fee; decimal LR = TotalPrice - YJPrice - fmd.escrowFee.Value - GoodsFee - sjyf - sjtc - fmd.DR_BackFee.Value - fmd.DR_PostFee.Value - fmd.Other_Fee.Value + fmd.DR_SSFee.Value - fmd.md.Value + fmd.SubsidyFee.Value - (md.TotalAdFee.HasValue ? md.TotalAdFee.Value : 0); decimal YGLR = TotalPrice - YJPrice - fmd.escrowFee.Value - YJGoodsFee - ygyf - fmd.tc.Value - fmd.DR_PostFee.Value - fmd.Other_Fee.Value + fmd.DR_SSFee.Value - fmd.md.Value + fmd.SubsidyFee.Value - (md.TotalAdFee.HasValue ? md.TotalAdFee.Value : 0); md.LR = new decimal?(Convert.ToDecimal(LR.ToString("0.00"))); md.YGLR = new decimal?(Convert.ToDecimal(YGLR.ToString("0.00"))); } } } return model; } #region 为新系统单个人订单查询 [WebMethod(EnableSession = true)] public JsonModel> GetListOrderForTM22ForPerson(int IsYJ, string MName, string groupName, int StoreId, int DeptId, int PlatType, int ShopId, int DateType, DateTime? SDate, DateTime? EDate, int TjType, string Name, int PrintState, int MateState, int MoneyState, int OutDays, int State, int IsSku, int IsError, int IsE, int IsDetail, int HBOrder, int IsSD, int SaleState, int IsBuy, int WLId, int PostId, int IsDH, int SFLY, int yfcy, int storeyc, int PageIndex, int PageSize, string Sort) { PagesNew.Login(base.Session); DD_OrderData data = new DD_OrderData(); int num = Convert.ToInt32(base.Session["CompanyId"]); RefParameterCollection where = new RefParameterCollection(); if (storeyc == 1)//仓库异常 { var olist = DataNew.GetListStoreYC(DateTime.Today); string sids = "0,"; if (olist != null) { foreach (var smd in olist) { sids += smd.OrderId.ToString() + ","; } } where.Add("a.OrderId", "in", sids.TrimEnd(','), DbType.String); } if (IsYJ == 1) { where.Add("a.PlatId", "=", 2, DbType.Int32); where.Add("isnull(a.Fee6,0)", "=", 0, DbType.Int32); where.Add("isnull(a.Fee7,0)", "=", 0, DbType.Int32); where.Add("isnull(a.Fee8,0)", "=", 0, DbType.Int32); } if (StoreId > 0) { where.Add("a.StoreId", "=", StoreId, DbType.Int32); } if (IsBuy == 1) { where.Add("a.BuyDate", "is not", null, DbType.String); } else if (IsBuy == 0) { where.Add("a.BuyDate", "is", null, DbType.String); } where.Add("a.CompanyId", "=", num, DbType.Int32); // where.Add("isnull(a.IsSDan,0)", "=", IsSD, DbType.Int32); if (yfcy == 1) where.Add("a.WLSS", "=", 1, DbType.Int32); if (SaleState > 0) { where.Add("a.SaleState", "=", SaleState, DbType.Int32); } if (WLId > 0) { where.Add("a.LogisticsId", "=", WLId, DbType.Int32); } if (PostId > 0) { where.Add("a.Post", "=", PostId, DbType.Int32); } if (DeptId > 0) { where.Add("c.DeptId", "=", DeptId, DbType.Int32); } if (PlatType > 0) { where.Add("a.PlatId", "=", PlatType, DbType.Int32); } if (ShopId > 0) { where.Add("a.ShopId", "=", ShopId, DbType.Int32); } if (DateType == 1) { if (SDate.HasValue) { where.Add("a.OrderDate", ">=", SDate, DbType.DateTime); } if (EDate.HasValue) { where.Add("a.OrderDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime); } } else if (DateType == 2) { if (SDate.HasValue) { where.Add("a.InDate", ">=", SDate, DbType.DateTime); } if (EDate.HasValue) { where.Add("a.InDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime); } } else if (DateType == 3) { if (SDate.HasValue) { where.Add("a.PrintDate", ">=", SDate, DbType.DateTime); } if (EDate.HasValue) { where.Add("a.PrintDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime); } } else if (DateType == 4) { if (SDate.HasValue) { where.Add("a.PostDate", ">=", SDate, DbType.DateTime); } if (EDate.HasValue) { where.Add("a.PostDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime); } } else if (DateType == 5) { if (SDate.HasValue) { where.Add("a.OrderOutDate", ">=", SDate, DbType.DateTime); } if (EDate.HasValue) { where.Add("a.OrderOutDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime); } } if (OutDays > 0) { where.Add("a.OrderOutDate", "<=", DateTime.Now.AddDays((double)OutDays), DbType.DateTime); where.Add("a.OrderOutDate", ">=", DateTime.Now, DbType.DateTime); } if (MateState > -1) { where.Add("a.MateState", "=", MateState, DbType.Int32); } if (MoneyState > -1) { where.Add("a.MoneyState", "=", MoneyState, DbType.Int32); } if (PrintState > -1) { where.Add("a.PrintState", "=", PrintState, DbType.Int32); } if (State == 3) { where.Add("a.State", "=", 2, DbType.Int32); } else if (State == 4) { where.Add("a.State", "=", 3, DbType.Int32); } else if (State == 5) { where.Add("a.State", "=", 1, DbType.Int32); where.Add("a.MoneyState", "=", 1, DbType.Int32); } else if (State == 7) { where.Add("a.OrderState2", "=", 1, DbType.Int32); } else if (State == 1) { where.Add("a.PostState", "=", 1, DbType.Int32); } else if (State == 2) { where.Add("a.State", "<", 3, DbType.Int32); where.Add("a.PostState", "=", 2, DbType.Int32); } else if (State == 0) { where.Add("a.State", "=", 1, DbType.Int32); } else if (State == 8) { where.Add("a.State", "<", 3, DbType.Int32); where.Add("a.PostState", "=", 3, DbType.Int32); } else { where.Add("a.State", ">", 0, DbType.Int32); } if (HBOrder == 1) { where.Add("a.IsJoin", "=", 1, DbType.Int32); } if (IsError == 1) { where.Add("(a.SendAddr", ">", 0, DbType.Int32); where.Add("a.IsLeaveWord", "=", 1, "or", ")", DbType.Int32); } if (IsE == 1) { where.Add("a.PostState", "=", 2, DbType.Int32); } if (IsE == 0) { where.Add("a.PostState", "<", 2, DbType.Int32); } string trackCode = ""; if (Name != "") { Name = Name.Trim(); if (TjType == 1) { where.Add("(a.PlatOrderCode", "like", Name, DbType.String); where.Add("OrderCode", "like", Name, "or", DbType.String); where.Add("a.JoinOrderCode", "like", Name, "or", ")", DbType.String); } else if (TjType == 2) { where.Add("a.RevName", "like", Name, DbType.String); } else if (TjType == 3) { where.Add("a.RevPhone", "like", Name, DbType.String); } else if (TjType == 4) { where.Add("(a.RevCountry", "=", Name, DbType.String); where.Add("a.CountryName", "=", Name, "or", DbType.String); where.Add("a.CountryCode", "=", Name, "or", ")", DbType.String); } else if (TjType == 5) { where.Add("a.RevPostCode", "=", Name, DbType.String); } else if (TjType == 6) { where.Add("(a.RevAddr", "like", Name, DbType.String); where.Add("a.RevProvince", "like", Name, "or", DbType.String); where.Add("a.RevCity", "like", Name, "or", DbType.String); where.Add("a.RevArea", "like", Name, "or", ")", DbType.String); } else if (TjType == 9) { where.Add("(a.ErrorInfo", "like", Name, DbType.String); where.Add("a.PostError", "like", Name, "or", ")", DbType.String); } else if (TjType == 10) { trackCode = Name; } else if (TjType == 11) { where.Add("a.CustomID", "=", Name, DbType.String); } else if (TjType == 12) { where.Add("a.RevMail", "=", Name, DbType.String); } } if (IsSku == 0) { where.Add("a.FPDate", "is", null, DbType.String); } else if (IsSku == 1) { where.Add("a.FPDate", "is not", null, DbType.String); } JsonModel> model = new JsonModel>(); int rowCount = 0; string str2 = ""; string str3 = ""; if ((TjType == 7) && (Name != "")) { str2 = Name; } else if ((TjType == 8) && (Name != "")) { str3 = Name; } if (TjType == 13 && Name != "")//根据人员查询 { model.DataSource = DataNew.GetListDT_OrderInfoForUser_New(num, SDate, str2.Trim(), Name, trackCode, -1, IsDH, where, PageIndex, PageSize, Sort, out rowCount); } else { //if (SFLY > 0) //{ // if (SFLY == 1) // { // model.DataSource = data.GetListDT_OrderInfoForTM6(num, str2.Trim(), str3.Trim(), trackCode, -1, IsDH, where, PageIndex, PageSize, Sort, out rowCount); // } // if (SFLY == 2) // { // model.DataSource = data.GetListDT_OrderInfoForTM7(num, str2.Trim(), str3.Trim(), trackCode, -1, IsDH, where, PageIndex, PageSize, Sort, out rowCount); // } //} //else //{ model.DataSource = DataNew.GetListDT_OrderInfoForTM2_New(num, MName, str2.Trim(), str3.Trim(), trackCode, -1, IsDH, where, PageIndex, PageSize, Sort, out rowCount, groupName); // } } model.RowCount = rowCount; string ids = ""; List shopids = new List(); DateTime? maxDate = null, minDate = null; JC_ExpressService wlobj = new JC_ExpressService(); var wlist = wlobj.GetExpressList(); List maplist = null; if (model.DataSource != null) { foreach (DT_OrderListNew md in model.DataSource) { ids += md.OrderId.ToString() + ","; if (md.Post != null && md.Post > 0) { var wlmd = wlist.Find(n => n.ExpressID == md.Post); if (wlmd != null) { md.TrackInfo = wlmd.Name; } } if (md.StoreId == 11) md.RevFax = "E"; else md.RevFax = "W"; if (md.ShopId.HasValue) shopids.Add(md.ShopId.Value); //if (maplist != null && md.RevProvince != null && md.RevProvince != "") //{ // var mmd = maplist.Find(n => n.code == md.RevProvince.ToUpper() || n.ename == md.RevProvince); // if (mmd != null) // { // if (mmd.IsEast == 1) // { // md.RevFax = "E"; // } // else // md.RevFax = "W"; // } //} } maxDate = model.DataSource.OrderByDescending(r => r.OrderDate.Value).First().OrderDate.Value; minDate = model.DataSource.OrderBy(r => r.OrderDate.Value).First().OrderDate.Value; } var linklist = new List(); if (ids != "") { maplist = DataNew.GetListUSMap4(ids.Trim(',')); List errorList = data.GetErrorList(ids.Trim(',')); linklist = DataNew.GetListMBLinkOrder(ids.Trim(',')); if ((errorList != null) && (errorList.Count > 0)) { foreach (var md in model.DataSource) { DT_OrderError error = errorList.Find(n => n.OrderId == md.OrderId); if (error != null) { md.ErrorInfo = error.ErrorInfo; } } } } if (shopids != null && shopids.Count > 0) shopids = shopids.Distinct().ToList(); List saleBackModelList = null; List flist = null; if ((IsDetail == 1) && (model.DataSource != null)) { int? trackType; if (ids != "") { List orderGoodsList = DataNew.GetOrderGoodsListNew2_New(ids.Trim(',')); List trackCodeApplyList = data.GetTrackCodeApplyList(ids.Trim(',')); //saleBackModelList = data.GetSaleBackModelList(ids.Trim(',')); flist = DataNew.GetOrderFees(ids.Trim(',')); //var pmlist = DataNew.GetOrderGoodsCodeData(); var pmlist = DataNew.GetGoodsRankModelList(string.Join(",", shopids), maxDate, minDate); List JZLinklist = DataNew.GetListJZLinkOrder(ids.Trim(',')); List adSpendList = DataNew.GetAllGoodWeekAdSpend(); //List orderGoodsAdList = DataNew.GetOrderListGoodsAdFeeByOrderID(ids.Trim(',')); var last2DayadFees = DataNew.GetGoodsLast2DayAdFeeListByOrders(ids.TrimEnd(','));//商品前天的广告花费 if (orderGoodsList != null) { foreach (var md in model.DataSource) { bool kcW = true; bool kcE = true;//W仓,E仓库存是否足够发货,足够发货才能和UPS比较运费 List list5 = orderGoodsList.FindAll(n => n.OrderId == md.OrderId); var totalAdfee = 0m;//订单广告总花费 var hyfcj = 0m;//海运费差价 if (list5 != null) { md.GoodsList = list5; foreach (var mdg in md.GoodsList) { if (mdg.WestNum < mdg.GoodsNum) kcW = false; if (mdg.EastNum < mdg.GoodsNum) kcE = false; if (mdg.GoodsId.HasValue && md.ShopId.HasValue) { if (adSpendList != null) { var adspend = adSpendList.Where(r => r.shopid == md.ShopId.Value && r.goodsid == mdg.GoodsId.Value).FirstOrDefault(); mdg.goodWeekAdFee = adspend == null ? 0 : (adspend.spend.HasValue ? adspend.spend.Value : 0); } if (last2DayadFees != null) { var last2DayFee = last2DayadFees.Where(r => r.shopid == md.ShopId.Value && r.goodsid == mdg.GoodsId.Value).FirstOrDefault(); mdg.last2DayAdFee = last2DayFee == null ? 0 : (last2DayFee.spend.HasValue ? last2DayFee.spend.Value : 0); } //if (orderGoodsAdList != null) //{ // var adFee = orderGoodsAdList.Where(r => r.OrderDate == md.OrderDate.Value.ToString("yyyy-MM-dd") && r.ShopId == md.ShopId && r.GoodsId == mdg.GoodsId.Value).FirstOrDefault(); // mdg.goodWeekAdFee = adFee == null ? 0 : (adFee.AvgAdfee.HasValue ? adFee.AvgAdfee.Value : 0); //} } else { mdg.goodWeekAdFee = 0; mdg.last2DayAdFee = 0; } totalAdfee = totalAdfee + (mdg.adfee.HasValue ? mdg.adfee.Value : 0); hyfcj += (mdg.GoodsNum.HasValue && mdg.Solid2.HasValue) ? (mdg.GoodsNum.Value * mdg.Solid2.Value) : 0; } if (pmlist != null) { foreach (var mmd in list5) { var pmmd = pmlist.Find(n => n.asin == mmd.productImgUrl2 && n.ShopId == md.ShopId && n.OrderDate.Date == md.OrderDate.Value.Date); if (pmmd != null) { string imgurl = ""; if (pmmd.Int10 != null && pmmd.Int10 == 1) { imgurl = ""; } if (pmmd.Int10 != null && pmmd.Int10 == 2) { imgurl = ""; } if (pmmd.Int10 != null && pmmd.Int10 == 3) { imgurl = ""; } if (pmmd.Int3 < 100) mmd.OldTypeDesc = "排名:" + pmmd.Int3.ToString(); else mmd.OldTypeDesc = "排名:" + pmmd.Int3.ToString(); if (pmmd.Int2 != null) mmd.OldTypeDesc += "/" + pmmd.Int2.ToString(); mmd.OldTypeDesc += "" + imgurl; } else mmd.OldTypeDesc = ""; } } } md.TotalAdFee = totalAdfee; //ups和fedex比较运费,再东西部都有库存的情况下,UPS需要和Fedex的W仓和E仓两个二比较, //如果收货地址是Residential住宅区,则UPS和Fedex的Smart_Post、GROUND_HOME_DELIVERY比较; //如果收货地址是Commercial或者Office,ups就和Fedex的Smart_Post、Fedex_Ground比较;Fedex的E仓比较时需要加上海运费差价 if (md.UpsFeeR.HasValue) { if (md.AddressType == "Commercial" || md.AddressType == "Office") { if (kcW) { md.UPSFee = (md.UpsFeeR < md.Fee6 && md.UpsFeeR < md.Fee7) ? md.UpsFeeR : 0; } if (kcE) { if (!kcW || (md.UPSFee.HasValue && md.UPSFee.Value > 0)) //如果西部没有库存 或者 此时md.UPSFee有值并且大于0,说明UPS快递费小于Fedex的西部费用,接下来和Fedex的东部费用比较 { md.UPSFee = (md.UpsFeeR < (md.Fee11 + hyfcj * 30) && md.UpsFeeR < (md.Fee12 + hyfcj * 30)) ? md.UpsFeeR : 0; } else md.UPSFee = 0; } } else { if (kcW) { md.UPSFee = (md.UpsFeeR < md.Fee6 && md.UpsFeeR < md.Fee8) ? md.UpsFeeR : 0; } if (kcE) { if (!kcW || (md.UPSFee.HasValue && md.UPSFee.Value > 0)) //如果西部没有库存 或者 此时md.UPSFee有值并且大于0,说明UPS快递费小于Fedex的西部费用,接下来和Fedex的东部费用比较 { md.UPSFee = (md.UpsFeeR < (md.Fee11 + hyfcj * 30) && md.UpsFeeR < (md.Fee13 + hyfcj * 30)) ? md.UpsFeeR : 0; } else md.UPSFee = 0; } } } else md.UPSFee = 0; //if (md.UpsFeeR.HasValue && md.UpsFeeE.HasValue) //{ // md.UPSFee = md.UpsFeeR > md.UpsFeeE ? md.UpsFeeE : md.UpsFeeR; //} //else if (!md.UpsFeeR.HasValue && !md.UpsFeeE.HasValue) //{ // md.UPSFee = 0; //} //else //{ // md.UPSFee = md.UpsFeeR.HasValue ? md.UpsFeeR.Value : md.UpsFeeE.Value; //} //if (md.UPSFee > md.Fee8 || md.UPSFee > (md.Fee13 + hyfcj * 30)) //{ // md.UPSFee = 0; //} } } if (trackCodeApplyList != null) { foreach (var md in model.DataSource) { List list6 = new List(); if ((md.JoinOrderCode != null) && (md.JoinOrderCode != "")) { list6 = trackCodeApplyList.FindAll(n => n.OrderCode == md.JoinOrderCode); } else { list6 = trackCodeApplyList.FindAll(n => n.OrderId == md.OrderId); } if ((list6 != null) && (list6.Count > 0)) { string str5 = ""; string str6 = ""; foreach (DT_TrackCodeApply apply in list6) { string str7 = ""; trackType = apply.TrackType; if (trackType != null && trackType == 3) { str7 = "[空包裹]"; } if (apply.Weight.HasValue) { string str8 = ""; if (apply.ScanDate.HasValue) { str8 = "扫描时间:" + apply.ScanDate.Value.ToString("yyyy-MM-dd HH:mm") + "
"; } string str9 = str5; str5 = str9 + apply.TrackCode + str7 + "
重量" + apply.Weight.ToString() + "g" + str8 + "
"; } else { str5 = str5 + apply.TrackCode + str7 + "
"; } if (str6 == "") { str6 = apply.TrackCode; } } md.TrackInfo += str5; md.TrackCode = str6; } } } decimal moneyrate = Convert.ToDecimal((double)6.5); List list7 = new BaseService().GetMoneyList2(); //decimal ckfee = 0; //decimal mdfee = 0; //decimal adfee = 0; //decimal DR_BackFee = 0; //decimal DR_SSFee = 0; //decimal DR_PostFee = 0; foreach (var md in model.DataSource) { var fmd = flist.Find(n => n.orderid == md.OrderId); if (fmd == null) fmd = new DT_Fees(); md.OrderName = (fmd != null && fmd.SubsidyFee.HasValue && fmd.SubsidyFee.Value > 0) ? fmd.SubsidyFee.Value.ToString("0.00") : ""; #region 注释竞品信息改为显示补贴金额2024-05-17 //string jplink = ""; //if (linklist != null) //{ // var lmdlist = linklist.FindAll(n => n.OrderId == md.OrderId && n.ShopId == md.ShopId); // if (lmdlist != null) // { // foreach (var lmd in lmdlist) // { // int pm2 = 0; // var pmmd = pmlist != null ? pmlist.Find(n => n.GoodsId == lmd.GoodsId && n.ShopId == md.ShopId) : null; // if (pmmd != null && pmmd.Int3 != null) // { // pm2 = pmmd.Int3.Value; // } // if (lmdlist.Count > 1) // jplink += "" + lmd.SKU1 + ":【S】" + lmd.GoodsHJNum2 + ""; // else // jplink += "【S】" + lmd.GoodsHJNum2 + ""; // if (lmd.Num != null) // { // if (lmd.GoodsHJNum2 >= lmd.Num) // jplink += "【TS】" + lmd.Num + ""; // else // jplink += "【TS】" + lmd.Num + ""; // } // jplink += "
"; // if (pm2 > 0) // jplink += "【R】" + pm2 + ""; // else // jplink += "【R】无"; // if (lmd.PM != null) // { // if (pm2 > 0 && lmd.PM >= pm2) // jplink += "【TR】" + lmd.PM + ""; // else // jplink += "【TR】" + lmd.PM + ""; // } // jplink += "
"; // } // } // md.OrderName = jplink; //} //if (JZLinklist != null) //{ // var jzmd = JZLinklist.FindAll(n => n.OrderId == md.OrderId && n.ShopId == md.ShopId); // if (jzmd != null) // { // int i = 1; // foreach (var jzmmd in jzmd) // { // if (jzmmd.Price != null) // jplink += "竟品" + i.ToString() + "价格:" + jzmmd.Price.Value + "$
"; // else // jplink += "竟品" + i.ToString() + "
"; // i++; // } // } // md.OrderName = jplink; //} #endregion if (fmd.moneyrate != null) moneyrate = fmd.moneyrate.Value; else { JC_Money money = list7.Find(n => n.MCode == "USD" && n.PlatId == md.PlatId); if (money != null) { moneyrate = money.MRate.Value; } else { money = list7.Find(n => n.MCode == "USD"); moneyrate = money.MRate.Value; } } decimal TotalPrice = 0M; if (md.TotalPrice != null) { TotalPrice = md.TotalPrice.Value; } decimal YJPrice = 0M; decimal sjyf = 0; if (fmd.sjyf != null) sjyf = fmd.sjyf.Value; decimal ygyf = 0; if (fmd.yf != null) ygyf = fmd.yf.Value; md.PostFee = sjyf; md.BoxFee = ygyf; if (fmd.yj != null) YJPrice = fmd.yj.Value; decimal GoodsFee = 0; if (fmd.sjcb != null) GoodsFee = fmd.sjcb.Value; if (fmd.sjhwsf != null) GoodsFee += fmd.sjhwsf.Value; if (moneyrate == 0) moneyrate = 6.5M; GoodsFee = GoodsFee / moneyrate; decimal YJGoodsFee = 0; if (fmd.cb != null) YJGoodsFee = fmd.cb.Value; if (fmd.hwsf != null) YJGoodsFee += fmd.hwsf.Value; md.Fee8 = 0; md.Fee8 = fmd.ck; decimal sjtc = 0; if (fmd.sjtc == null || fmd.sjtc == 0) sjtc = fmd.tc.Value; else sjtc = fmd.sjtc.Value; YJGoodsFee = YJGoodsFee / moneyrate; if (md.PlatId != 2) md.TotalAdFee = fmd.Ad_Fee; decimal LR = TotalPrice - YJPrice - fmd.escrowFee.Value - GoodsFee - sjyf - sjtc - fmd.DR_BackFee.Value - fmd.DR_PostFee.Value - fmd.Other_Fee.Value + fmd.DR_SSFee.Value - fmd.md.Value + fmd.SubsidyFee.Value - (md.TotalAdFee.HasValue ? md.TotalAdFee.Value : 0); decimal YGLR = TotalPrice - YJPrice - fmd.escrowFee.Value - YJGoodsFee - ygyf - fmd.tc.Value - fmd.DR_PostFee.Value - fmd.Other_Fee.Value + fmd.DR_SSFee.Value - fmd.md.Value + fmd.SubsidyFee.Value - (md.TotalAdFee.HasValue ? md.TotalAdFee.Value : 0); md.LR = new decimal?(Convert.ToDecimal(LR.ToString("0.00"))); md.YGLR = new decimal?(Convert.ToDecimal(YGLR.ToString("0.00"))); } } } return model; } #endregion [WebMethod(EnableSession = true)] public JsonModel> GetListOrderForTM22_old(int IsYJ,string MName, int StoreId, int DeptId, int PlatType, int ShopId, int DateType, DateTime? SDate, DateTime? EDate, int TjType, string Name, int PrintState, int MateState, int MoneyState, int OutDays, int State, int IsSku, int IsError, int IsE, int IsDetail, int HBOrder, int IsSD, int SaleState, int IsBuy, int WLId, int IsDH, int SFLY, int yfcy,int storeyc, int PageIndex, int PageSize, string Sort) { PagesNew.Login(base.Session); DD_OrderData data = new DD_OrderData(); int num = Convert.ToInt32(base.Session["CompanyId"]); RefParameterCollection where = new RefParameterCollection(); if (storeyc == 1)//仓库异常 { var olist = DataNew.GetListStoreYC(DateTime.Today); string sids = "0,"; if (olist !=null) { foreach (var smd in olist) { sids += smd.OrderId.ToString() + ","; } } where.Add("a.OrderId", "in", sids.TrimEnd(','), DbType.String); } if (IsYJ == 1) { where.Add("a.PlatId", "=", 2, DbType.Int32); where.Add("isnull(a.Fee6,0)", "=", 0, DbType.Int32); where.Add("isnull(a.Fee7,0)", "=", 0, DbType.Int32); where.Add("isnull(a.Fee8,0)", "=", 0, DbType.Int32); } if (StoreId > 0) { where.Add("a.StoreId", "=", StoreId, DbType.Int32); } if (IsBuy == 1) { where.Add("a.BuyDate", "is not", null, DbType.String); } else if (IsBuy == 0) { where.Add("a.BuyDate", "is", null, DbType.String); } where.Add("a.CompanyId", "=", num, DbType.Int32); // where.Add("isnull(a.IsSDan,0)", "=", IsSD, DbType.Int32); if (yfcy == 1) where.Add("a.WLSS", "=", 1, DbType.Int32); if (SaleState > 0) { where.Add("a.SaleState", "=", SaleState, DbType.Int32); } if (WLId > 0) { where.Add("a.LogisticsId", "=", WLId, DbType.Int32); } if (DeptId > 0) { where.Add("c.DeptId", "=", DeptId, DbType.Int32); } if (PlatType > 0) { where.Add("a.PlatId", "=", PlatType, DbType.Int32); } if (ShopId > 0) { where.Add("a.ShopId", "=", ShopId, DbType.Int32); } if (DateType == 1) { if (SDate.HasValue) { where.Add("a.OrderDate", ">=", SDate, DbType.DateTime); } if (EDate.HasValue) { where.Add("a.OrderDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime); } } else if (DateType == 2) { if (SDate.HasValue) { where.Add("a.InDate", ">=", SDate, DbType.DateTime); } if (EDate.HasValue) { where.Add("a.InDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime); } } else if (DateType == 3) { if (SDate.HasValue) { where.Add("a.PrintDate", ">=", SDate, DbType.DateTime); } if (EDate.HasValue) { where.Add("a.PrintDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime); } } else if (DateType == 4) { if (SDate.HasValue) { where.Add("a.PostDate", ">=", SDate, DbType.DateTime); } if (EDate.HasValue) { where.Add("a.PostDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime); } } else if (DateType == 5) { if (SDate.HasValue) { where.Add("a.OrderOutDate", ">=", SDate, DbType.DateTime); } if (EDate.HasValue) { where.Add("a.OrderOutDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime); } } if (OutDays > 0) { where.Add("a.OrderOutDate", "<=", DateTime.Now.AddDays((double)OutDays), DbType.DateTime); where.Add("a.OrderOutDate", ">=", DateTime.Now, DbType.DateTime); } if (MateState > -1) { where.Add("a.MateState", "=", MateState, DbType.Int32); } if (MoneyState > -1) { where.Add("a.MoneyState", "=", MoneyState, DbType.Int32); } if (PrintState > -1) { where.Add("a.PrintState", "=", PrintState, DbType.Int32); } if (State == 3) { where.Add("a.State", "=", 2, DbType.Int32); } else if (State == 4) { where.Add("a.State", "=", 3, DbType.Int32); } else if (State == 5) { where.Add("a.State", "=", 1, DbType.Int32); where.Add("a.MoneyState", "=", 1, DbType.Int32); } else if (State == 7) { where.Add("a.OrderState2", "=", 1, DbType.Int32); } else if (State == 1) { where.Add("a.PostState", "=", 1, DbType.Int32); } else if (State == 2) { where.Add("a.State", "<", 3, DbType.Int32); where.Add("a.PostState", "=", 2, DbType.Int32); } else if (State == 0) { where.Add("a.State", "=", 1, DbType.Int32); } else { where.Add("a.State", ">", 0, DbType.Int32); } if (HBOrder == 1) { where.Add("a.IsJoin", "=", 1, DbType.Int32); } if (IsError == 1) { where.Add("(a.SendAddr", ">", 0, DbType.Int32); where.Add("a.IsLeaveWord", "=", 1, "or", ")", DbType.Int32); } if (IsE == 1) { where.Add("a.PostState", "=", 2, DbType.Int32); } if (IsE == 0) { where.Add("a.PostState", "<", 2, DbType.Int32); } string trackCode = ""; if (Name != "") { Name = Name.Trim(); if (TjType == 1) { where.Add("(a.PlatOrderCode", "like", Name, DbType.String); where.Add("OrderCode", "like", Name, "or", DbType.String); where.Add("a.JoinOrderCode", "like", Name, "or", ")", DbType.String); } else if (TjType == 2) { where.Add("a.RevName", "like", Name, DbType.String); } else if (TjType == 3) { where.Add("a.RevPhone", "like", Name, DbType.String); } else if (TjType == 4) { where.Add("(a.RevCountry", "=", Name, DbType.String); where.Add("a.CountryName", "=", Name, "or", DbType.String); where.Add("a.CountryCode", "=", Name, "or", ")", DbType.String); } else if (TjType == 5) { where.Add("a.RevPostCode", "=", Name, DbType.String); } else if (TjType == 6) { where.Add("(a.RevAddr", "like", Name, DbType.String); where.Add("a.RevProvince", "like", Name, "or", DbType.String); where.Add("a.RevCity", "like", Name, "or", DbType.String); where.Add("a.RevArea", "like", Name, "or", ")", DbType.String); } else if (TjType == 9) { where.Add("(a.ErrorInfo", "like", Name, DbType.String); where.Add("a.PostError", "like", Name, "or", ")", DbType.String); } else if (TjType == 10) { trackCode = Name; } else if (TjType == 11) { where.Add("a.CustomID", "=", Name, DbType.String); } else if (TjType == 12) { where.Add("a.RevMail", "=", Name, DbType.String); } } if (IsSku == 0) { where.Add("a.FPDate", "is", null, DbType.String); } else if (IsSku == 1) { where.Add("a.FPDate", "is not", null, DbType.String); } JsonModel> model = new JsonModel>(); int rowCount = 0; string str2 = ""; string str3 = ""; if ((TjType == 7) && (Name != "")) { str2 = Name; } else if ((TjType == 8) && (Name != "")) { str3 = Name; } if (TjType == 13 && Name != "")//根据人员查询 { model.DataSource = DataNew.GetListDT_OrderInfoForUser(num, SDate, str2.Trim(), Name, trackCode, -1, IsDH, where, PageIndex, PageSize, Sort, out rowCount); } else { //if (SFLY > 0) //{ // if (SFLY == 1) // { // model.DataSource = data.GetListDT_OrderInfoForTM6(num, str2.Trim(), str3.Trim(), trackCode, -1, IsDH, where, PageIndex, PageSize, Sort, out rowCount); // } // if (SFLY == 2) // { // model.DataSource = data.GetListDT_OrderInfoForTM7(num, str2.Trim(), str3.Trim(), trackCode, -1, IsDH, where, PageIndex, PageSize, Sort, out rowCount); // } //} //else //{ model.DataSource = DataNew.GetListDT_OrderInfoForTM2(num, MName,str2.Trim(), str3.Trim(), trackCode, -1, IsDH, where, PageIndex, PageSize, Sort, out rowCount); // } } model.RowCount = rowCount; string ids = ""; JC_ExpressService wlobj = new JC_ExpressService(); var wlist = wlobj.GetExpressList(); List maplist = null; if (model.DataSource != null) { foreach (DT_Order md in model.DataSource) { ids += md.OrderId.ToString() + ","; if (md.Post != null && md.Post > 0) { var wlmd = wlist.Find(n => n.ExpressID == md.Post); if (wlmd != null) { md.TrackInfo = wlmd.Name; } } if(md.StoreId==11) md.RevFax = "E"; else md.RevFax = "W"; //if (maplist != null && md.RevProvince != null && md.RevProvince != "") //{ // var mmd = maplist.Find(n => n.code == md.RevProvince.ToUpper() || n.ename == md.RevProvince); // if (mmd != null) // { // if (mmd.IsEast == 1) // { // md.RevFax = "E"; // } // else // md.RevFax = "W"; // } //} } } var linklist = new List(); if (ids != "") { maplist = DataNew.GetListUSMap4(ids.Trim(',')); List errorList = data.GetErrorList(ids.Trim(',')); linklist = DataNew.GetListMBLinkOrder(ids.Trim(',')); if ((errorList != null) && (errorList.Count > 0)) { foreach (var md in model.DataSource) { DT_OrderError error = errorList.Find(n => n.OrderId == md.OrderId); if (error != null) { md.ErrorInfo = error.ErrorInfo; } } } } List saleBackModelList = null; List flist = null; if ((IsDetail == 1) && (model.DataSource != null)) { int? trackType; if (ids != "") { List orderGoodsList = DataNew.GetOrderGoodsListNew2(ids.Trim(',')); List trackCodeApplyList = data.GetTrackCodeApplyList(ids.Trim(',')); //saleBackModelList = data.GetSaleBackModelList(ids.Trim(',')); flist = DataNew.GetOrderFees(ids.Trim(',')); var pmlist = DataNew.GetOrderGoodsCodeData(); List JZLinklist = DataNew.GetListJZLinkOrder(ids.Trim(',')); if (orderGoodsList != null) { foreach (var md in model.DataSource) { List list5 = orderGoodsList.FindAll(n => n.OrderId == md.OrderId); if (list5 != null) { md.GoodsList = list5; if (pmlist != null) { foreach (var mmd in list5) { var pmmd = pmlist.Find(n => n.asin == mmd.productImgUrl2 && n.ShopId == md.ShopId); if (pmmd != null) { string imgurl = ""; if (pmmd.Int10 != null && pmmd.Int10 == 1) { imgurl = ""; } if (pmmd.Int10 != null && pmmd.Int10 == 2) { imgurl = ""; } if (pmmd.Int10 != null && pmmd.Int10 == 3) { imgurl = ""; } if (pmmd.Int3 < 100) mmd.OldTypeDesc = "排名:" + pmmd.Int3.ToString(); else mmd.OldTypeDesc = "排名:" + pmmd.Int3.ToString(); if (pmmd.Int2 != null) mmd.OldTypeDesc += "/" + pmmd.Int2.ToString(); mmd.OldTypeDesc += "" + imgurl; } else mmd.OldTypeDesc = ""; } } } } } if (trackCodeApplyList != null) { foreach (var md in model.DataSource) { List list6 = new List(); if ((md.JoinOrderCode != null) && (md.JoinOrderCode != "")) { list6 = trackCodeApplyList.FindAll(n => n.OrderCode == md.JoinOrderCode); } else { list6 = trackCodeApplyList.FindAll(n => n.OrderId == md.OrderId); } if ((list6 != null) && (list6.Count > 0)) { string str5 = ""; string str6 = ""; foreach (DT_TrackCodeApply apply in list6) { string str7 = ""; trackType = apply.TrackType; if (trackType != null && trackType == 3) { str7 = "[空包裹]"; } if (apply.Weight.HasValue) { string str8 = ""; if (apply.ScanDate.HasValue) { str8 = "扫描时间:" + apply.ScanDate.Value.ToString("yyyy-MM-dd HH:mm") + "
"; } string str9 = str5; str5 = str9 + apply.TrackCode + str7 + "
重量" + apply.Weight.ToString() + "g" + str8 + "
"; } else { str5 = str5 + apply.TrackCode + str7 + "
"; } if (str6 == "") { str6 = apply.TrackCode; } } md.TrackInfo += str5; md.TrackCode = str6; } } } decimal moneyrate = Convert.ToDecimal((double)6.5); List list7 = new BaseService().GetMoneyList2(); //decimal ckfee = 0; //decimal mdfee = 0; //decimal adfee = 0; //decimal DR_BackFee = 0; //decimal DR_SSFee = 0; //decimal DR_PostFee = 0; foreach (var md in model.DataSource) { var fmd = flist.Find(n => n.orderid == md.OrderId); if (fmd == null) fmd = new DT_Fees(); md.OrderName = ""; string jplink = ""; if (linklist != null) { var lmdlist = linklist.FindAll(n => n.OrderId == md.OrderId && n.ShopId == md.ShopId); if (lmdlist != null) { foreach (var lmd in lmdlist) { int pm2 = 0; var pmmd = pmlist.Find(n => n.GoodsId == lmd.GoodsId && n.ShopId == md.ShopId); if (pmmd != null&&pmmd.Int3!=null) { pm2 = pmmd.Int3.Value; } if (lmdlist.Count > 1) jplink += "" + lmd.SKU1 + ":【S】" + lmd.GoodsHJNum2 + ""; else jplink += "【S】" + lmd.GoodsHJNum2 + ""; if (lmd.Num != null) { if(lmd.GoodsHJNum2>=lmd.Num) jplink += "【TS】" + lmd.Num + ""; else jplink += "【TS】" + lmd.Num + ""; } jplink += "
"; if(pm2>0) jplink += "【R】" + pm2 + ""; else jplink += "【R】无"; if (lmd.PM != null) { if(pm2>0&& lmd.PM>=pm2) jplink += "【TR】" + lmd.PM + ""; else jplink += "【TR】" + lmd.PM + ""; } jplink += "
"; } } md.OrderName = jplink; } if (JZLinklist != null) { var jzmd = JZLinklist.FindAll(n => n.OrderId == md.OrderId && n.ShopId == md.ShopId); if (jzmd != null) { int i = 1; foreach (var jzmmd in jzmd) { if (jzmmd.Price != null) jplink += "竟品" + i.ToString() + "价格:" + jzmmd.Price.Value + "$
"; else jplink += "竟品" + i.ToString() + "
"; i++; } } md.OrderName = jplink; } if (fmd.moneyrate != null) moneyrate = fmd.moneyrate.Value; else { JC_Money money = list7.Find(n => n.MCode == "USD" && n.PlatId == md.PlatId); if (money != null) { moneyrate = money.MRate.Value; } else { money = list7.Find(n => n.MCode == "USD"); moneyrate = money.MRate.Value; } } decimal TotalPrice = 0M; if (md.TotalPrice != null) { TotalPrice = md.TotalPrice.Value; } decimal YJPrice = 0M; decimal sjyf = 0; if (fmd.sjyf != null) sjyf = fmd.sjyf.Value; decimal ygyf = 0; if (fmd.yf != null) ygyf = fmd.yf.Value; md.PostFee = sjyf; md.BoxFee = ygyf; if (fmd.yj != null) YJPrice = fmd.yj.Value; decimal GoodsFee = 0; if (fmd.sjcb != null) GoodsFee = fmd.sjcb.Value; if (fmd.sjhwsf != null) GoodsFee += fmd.sjhwsf.Value; if (moneyrate == 0) moneyrate = 6.5M; GoodsFee = GoodsFee / moneyrate; decimal YJGoodsFee = 0; if (fmd.cb != null) YJGoodsFee = fmd.cb.Value; if (fmd.hwsf != null) YJGoodsFee += fmd.hwsf.Value; md.Fee8 = 0; md.Fee8 = fmd.ck; decimal sjtc = 0; if (fmd.sjtc == null || fmd.sjtc == 0) sjtc = fmd.tc.Value; else sjtc = fmd.sjtc.Value; YJGoodsFee = YJGoodsFee / moneyrate; decimal LR = TotalPrice - YJPrice - fmd.escrowFee.Value - GoodsFee - sjyf - sjtc - fmd.DR_BackFee.Value - fmd.DR_PostFee.Value - fmd.Other_Fee.Value - fmd.Ad_Fee.Value + fmd.DR_SSFee.Value - fmd.md.Value; decimal YGLR = TotalPrice - YJPrice - fmd.escrowFee.Value - YJGoodsFee - ygyf - fmd.tc.Value - fmd.DR_PostFee.Value - fmd.Other_Fee.Value - fmd.Ad_Fee.Value + fmd.DR_SSFee.Value - fmd.md.Value; md.LR = new decimal?(Convert.ToDecimal(LR.ToString("0.00"))); md.YGLR = new decimal?(Convert.ToDecimal(YGLR.ToString("0.00"))); } } } return model; } [WebMethod(EnableSession = true)] public JsonModel> GetListOrderForTM22222222(int IsYJ, int StoreId, int DeptId, int PlatType, int ShopId, int DateType, DateTime? SDate, DateTime? EDate, int TjType, string Name, int PrintState, int MateState, int MoneyState, int OutDays, int State, int IsSku, int IsError, int IsE, int IsDetail, int HBOrder, int IsSD, int SaleState, int IsBuy, int WLId, int IsDH, int SFLY,int yfcy, int PageIndex, int PageSize, string Sort) { PagesNew.Login(base.Session); DD_OrderData data = new DD_OrderData(); int num = Convert.ToInt32(base.Session["CompanyId"]); RefParameterCollection where = new RefParameterCollection(); if (IsYJ == 1) { where.Add("a.PlatId", "=", 2, DbType.Int32); where.Add("isnull(a.Fee6,0)", "=", 0, DbType.Int32); where.Add("isnull(a.Fee7,0)", "=", 0, DbType.Int32); where.Add("isnull(a.Fee8,0)", "=", 0, DbType.Int32); } if (StoreId > 0) { where.Add("a.StoreId", "=", StoreId, DbType.Int32); } if (IsBuy == 1) { where.Add("a.BuyDate", "is not", null, DbType.String); } else if (IsBuy == 0) { where.Add("a.BuyDate", "is", null, DbType.String); } where.Add("a.CompanyId", "=", num, DbType.Int32); // where.Add("isnull(a.IsSDan,0)", "=", IsSD, DbType.Int32); if(yfcy==1) where.Add("a.WLSS", "=", 1, DbType.Int32); if (SaleState > 0) { where.Add("a.SaleState", "=", SaleState, DbType.Int32); } if (WLId > 0) { where.Add("a.LogisticsId", "=", WLId, DbType.Int32); } if (DeptId > 0) { where.Add("c.DeptId", "=", DeptId, DbType.Int32); } if (PlatType > 0) { where.Add("a.PlatId", "=", PlatType, DbType.Int32); } if (ShopId > 0) { where.Add("a.ShopId", "=", ShopId, DbType.Int32); } if (DateType == 1) { if (SDate.HasValue) { where.Add("a.OrderDate", ">=", SDate, DbType.DateTime); } if (EDate.HasValue) { where.Add("a.OrderDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime); } } else if (DateType == 2) { if (SDate.HasValue) { where.Add("a.InDate", ">=", SDate, DbType.DateTime); } if (EDate.HasValue) { where.Add("a.InDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime); } } else if (DateType == 3) { if (SDate.HasValue) { where.Add("a.PrintDate", ">=", SDate, DbType.DateTime); } if (EDate.HasValue) { where.Add("a.PrintDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime); } } else if (DateType == 4) { if (SDate.HasValue) { where.Add("a.PostDate", ">=", SDate, DbType.DateTime); } if (EDate.HasValue) { where.Add("a.PostDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime); } } else if (DateType == 5) { if (SDate.HasValue) { where.Add("a.OrderOutDate", ">=", SDate, DbType.DateTime); } if (EDate.HasValue) { where.Add("a.OrderOutDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime); } } if (OutDays > 0) { where.Add("a.OrderOutDate", "<=", DateTime.Now.AddDays((double)OutDays), DbType.DateTime); where.Add("a.OrderOutDate", ">=", DateTime.Now, DbType.DateTime); } if (MateState > -1) { where.Add("a.MateState", "=", MateState, DbType.Int32); } if (MoneyState > -1) { where.Add("a.MoneyState", "=", MoneyState, DbType.Int32); } if (PrintState > -1) { where.Add("a.PrintState", "=", PrintState, DbType.Int32); } if (State == 3) { where.Add("a.State", "=", 2, DbType.Int32); } else if (State == 4) { where.Add("a.State", "=", 3, DbType.Int32); } else if (State == 5) { where.Add("a.State", "=", 1, DbType.Int32); where.Add("a.MoneyState", "=", 1, DbType.Int32); } else if (State == 7) { where.Add("a.OrderState2", "=", 1, DbType.Int32); } else if (State == 1) { where.Add("a.PostState", "=", 1, DbType.Int32); } else if (State == 2) { where.Add("a.State", "<", 3, DbType.Int32); where.Add("a.PostState", "=", 2, DbType.Int32); } else if (State == 0) { where.Add("a.State", "=", 1, DbType.Int32); } else { where.Add("a.State", ">", 0, DbType.Int32); } if (HBOrder == 1) { where.Add("a.IsJoin", "=", 1, DbType.Int32); } if (IsError == 1) { where.Add("(a.SendAddr", ">", 0, DbType.Int32); where.Add("a.IsLeaveWord", "=", 1, "or", ")", DbType.Int32); } if (IsE == 1) { where.Add("a.PostState", "=", 2, DbType.Int32); } if (IsE == 0) { where.Add("a.PostState", "<", 2, DbType.Int32); } string trackCode = ""; if (Name != "") { Name = Name.Trim(); if (TjType == 1) { where.Add("(a.PlatOrderCode", "like", Name, DbType.String); where.Add("OrderCode", "like", Name, "or", DbType.String); where.Add("a.JoinOrderCode", "like", Name, "or", ")", DbType.String); } else if (TjType == 2) { where.Add("a.RevName", "like", Name, DbType.String); } else if (TjType == 3) { where.Add("a.RevPhone", "like", Name, DbType.String); } else if (TjType == 4) { where.Add("(a.RevCountry", "=", Name, DbType.String); where.Add("a.CountryName", "=", Name, "or", DbType.String); where.Add("a.CountryCode", "=", Name, "or", ")", DbType.String); } else if (TjType == 5) { where.Add("a.RevPostCode", "=", Name, DbType.String); } else if (TjType == 6) { where.Add("(a.RevAddr", "like", Name, DbType.String); where.Add("a.RevProvince", "like", Name, "or", DbType.String); where.Add("a.RevCity", "like", Name, "or", DbType.String); where.Add("a.RevArea", "like", Name, "or", ")", DbType.String); } else if (TjType == 9) { where.Add("(a.ErrorInfo", "like", Name, DbType.String); where.Add("a.PostError", "like", Name, "or", ")", DbType.String); } else if (TjType == 10) { trackCode = Name; } else if (TjType == 11) { where.Add("a.CustomID", "=", Name, DbType.String); } else if (TjType == 12) { where.Add("a.RevMail", "=", Name, DbType.String); } } if (IsSku == 0) { where.Add("a.FPDate", "is", null, DbType.String); } else if (IsSku == 1) { where.Add("a.FPDate", "is not", null, DbType.String); } JsonModel> model = new JsonModel>(); int rowCount = 0; string str2 = ""; string str3 = ""; if ((TjType == 7) && (Name != "")) { str2 = Name; } else if ((TjType == 8) && (Name != "")) { str3 = Name; } if (TjType == 13 && Name != "")//根据人员查询 { model.DataSource = DataNew.GetListDT_OrderInfoForUser(num, SDate, str2.Trim(), Name, trackCode, -1, IsDH, where, PageIndex, PageSize, Sort, out rowCount); } else { if (SFLY > 0) { if (SFLY == 1) { model.DataSource = data.GetListDT_OrderInfoForTM6(num, str2.Trim(), str3.Trim(), trackCode, -1, IsDH, where, PageIndex, PageSize, Sort, out rowCount); } if (SFLY == 2) { model.DataSource = data.GetListDT_OrderInfoForTM7(num, str2.Trim(), str3.Trim(), trackCode, -1, IsDH, where, PageIndex, PageSize, Sort, out rowCount); } } else { model.DataSource = DataNew.GetListDT_OrderInfoForTM2(num, "",str2.Trim(), str3.Trim(), trackCode, -1, IsDH, where, PageIndex, PageSize, Sort, out rowCount); } } model.RowCount = rowCount; string ids = ""; JC_ExpressService wlobj = new JC_ExpressService(); var wlist = wlobj.GetExpressList(); List maplist = null; if (model.DataSource != null) { foreach (DT_Order md in model.DataSource) { ids += md.OrderId.ToString() + ","; if (md.Post != null && md.Post > 0) { var wlmd = wlist.Find(n => n.ExpressID == md.Post); if (wlmd != null) { md.TrackInfo = wlmd.Name; } } md.RevFax = ""; //if (maplist != null && md.RevProvince != null && md.RevProvince != "") //{ // var mmd = maplist.Find(n => n.code == md.RevProvince.ToUpper() || n.ename == md.RevProvince); // if (mmd != null) // { // if (mmd.IsEast == 1) // { // md.RevFax = "E"; // } // else // md.RevFax = "W"; // } //} } } if (ids != "") { maplist = DataNew.GetListUSMap4(ids.Trim(',')); List errorList = data.GetErrorList(ids.Trim(',')); if ((errorList != null) && (errorList.Count > 0)) { foreach (var md in model.DataSource) { DT_OrderError error = errorList.Find(n => n.OrderId == md.OrderId); if (error != null) { md.ErrorInfo = error.ErrorInfo; } } } } List saleBackModelList = null; if ((IsDetail == 1) && (model.DataSource != null)) { int? trackType; if (ids != "") { List orderGoodsList = DataNew.GetOrderGoodsListNew2(ids.Trim(',')); List trackCodeApplyList = data.GetTrackCodeApplyList(ids.Trim(',')); saleBackModelList = data.GetSaleBackModelList(ids.Trim(',')); var pmlist = DataNew.GetOrderGoodsCodeData(); List JZLinklist = DataNew.GetListJZLinkOrder(ids.Trim(',')); if (orderGoodsList != null) { foreach (var md in model.DataSource) { List list5 = orderGoodsList.FindAll(n => n.OrderId == md.OrderId); if (list5 != null) { md.GoodsList = list5; if (pmlist != null) { foreach (var mmd in list5) { var pmmd = pmlist.Find(n => n.GoodsId == mmd.GoodsId && n.ShopId == md.ShopId); if (pmmd != null) { string imgurl = ""; if (pmmd.Int10!=null&&pmmd.Int10 == 1) { imgurl = ""; } if (pmmd.Int10 != null && pmmd.Int10 == 2) { imgurl = ""; } if (pmmd.Int10 != null && pmmd.Int10 == 3) { imgurl = ""; } if (pmmd.Int3 < 100) mmd.OldTypeDesc = "排名:" + pmmd.Int3.ToString(); else mmd.OldTypeDesc = "排名:" + pmmd.Int3.ToString(); if (pmmd.Int2 != null) mmd.OldTypeDesc += "/" + pmmd.Int2.ToString(); mmd.OldTypeDesc += "" + imgurl; } else mmd.OldTypeDesc = ""; } } } } } if (trackCodeApplyList != null) { foreach (var md in model.DataSource) { List list6 = new List(); if ((md.JoinOrderCode != null) && (md.JoinOrderCode != "")) { list6 = trackCodeApplyList.FindAll(n => n.OrderCode == md.JoinOrderCode); } else { list6 = trackCodeApplyList.FindAll(n => n.OrderId == md.OrderId); } if ((list6 != null) && (list6.Count > 0)) { string str5 = ""; string str6 = ""; foreach (DT_TrackCodeApply apply in list6) { string str7 = ""; trackType = apply.TrackType; if (trackType != null && trackType == 3) { str7 = "[空包裹]"; } if (apply.Weight.HasValue) { string str8 = ""; if (apply.ScanDate.HasValue) { str8 = "扫描时间:" + apply.ScanDate.Value.ToString("yyyy-MM-dd HH:mm") + "
"; } string str9 = str5; str5 = str9 + apply.TrackCode + str7 + "
重量" + apply.Weight.ToString() + "g" + str8 + "
"; } else { str5 = str5 + apply.TrackCode + str7 + "
"; } if (str6 == "") { str6 = apply.TrackCode; } } md.TrackInfo += str5; md.TrackCode = str6; } } } decimal moneyrate = Convert.ToDecimal((double)6.5); List list7 = new BaseService().GetMoneyList2(); decimal ckfee = 0; decimal mdfee = 0; decimal adfee = 0; decimal DR_BackFee=0; decimal DR_SSFee=0; decimal DR_PostFee=0; foreach (var md in model.DataSource) { md.OrderName = ""; string jplink = ""; if (JZLinklist != null) { var jzmd = JZLinklist.FindAll(n => n.OrderId == md.OrderId && n.ShopId == md.ShopId); if (jzmd != null) { int i = 1; foreach (var jzmmd in jzmd) { if (jzmmd.Price != null) jplink += "竟品" + i.ToString() + "价格:" + jzmmd.Price.Value + "$
"; else jplink += "竟品" + i.ToString() + "
"; i++; } } md.OrderName = jplink; } JC_Money money = list7.Find(n => n.MCode == "USD" && n.PlatId == md.PlatId); if (money != null) { moneyrate = money.MRate.Value; } else { money = list7.Find(n => n.MCode == "USD"); moneyrate = money.MRate.Value; } decimal TotalPrice = 0M; if (md.TotalPrice != null) { TotalPrice = md.TotalPrice.Value; } decimal YJPrice = 0M; YJPrice = TotalPrice * Convert.ToDecimal((double)0.15); int PlatId = md.PlatId.Value; if (PlatId == 1) { YJPrice = TotalPrice * Convert.ToDecimal((double)0.05); } else if (PlatId == 4) { YJPrice = 0; } else if (PlatId == 5) { YJPrice = TotalPrice * Convert.ToDecimal((double)0.1); } else if (PlatId == 15) { YJPrice = TotalPrice * Convert.ToDecimal((double)0.029)+0.3M; } else if (PlatId == 18) { YJPrice = TotalPrice * Convert.ToDecimal((double)0.06); } //var admd = DataNew.GetModel_OrderFee(md.OrderId.Value);///仓储 面单 广告费 //if (admd != null) //{ // ckfee = admd.ckfee.Value; // mdfee = admd.mdfee.Value; // adfee = admd.adfee.Value; // DR_BackFee = admd.DR_BackFee.Value; // DR_PostFee = admd.DR_PostFee.Value; // DR_SSFee = admd.DR_SSFee.Value; //} decimal GoodsFee = 0M; decimal YJGoodsFee = 0M; decimal TCFee = 0M; decimal YJTCFee = 0M; decimal TSolid = 0M; decimal YGFeeRate = 0M; string AddrType = ""; decimal twight = 0; if (md.GoodsList != null && md.GoodsList.Count > 0) { AddrType = md.GoodsList[0].JoinOrderCode; if (md.GoodsList[0].Weight != null) twight = md.GoodsList[0].Weight.Value; foreach (DT_OrderGoods goods in md.GoodsList) { if (goods.GoodsFee.HasValue && (goods.GoodsFee.Value > 0M)) { GoodsFee += goods.GoodsFee.Value; } if (goods.GoodsPrice.HasValue) { if (GoodsFee == 0) GoodsFee += goods.GoodsPrice.Value * goods.GoodsNum.Value; YJGoodsFee += goods.GoodsPrice.Value * goods.GoodsNum.Value; if (goods.BGPrice != null) YGFeeRate += goods.GoodsPrice.Value * goods.GoodsNum.Value * goods.BGPrice.Value * Convert.ToDecimal(0.01); } if (goods.TCFee != null && goods.TCFee > 0) { TCFee += goods.TCFee.Value; } if (goods.Solid2.HasValue) { TSolid += goods.Solid2.Value * goods.GoodsNum.Value; } } } if (GoodsFee > 0M) { GoodsFee = GoodsFee / moneyrate; YJGoodsFee = YJGoodsFee / moneyrate;//预估货物成本 YGFeeRate = YGFeeRate / moneyrate;//预估税费 } decimal escrowFee = 0M; if ((TCFee == 0M) && (TSolid > 0M)) { TCFee = Convert.ToDecimal(170) * TSolid; } if (TSolid > 0M) { YJTCFee = Convert.ToDecimal(170) * TSolid;//预估头程 } if (md.escrowFee.HasValue) { escrowFee = md.escrowFee.Value;//页面上手填的税费 } decimal PostFee = 0M; if (md.PostFee.HasValue) { PostFee = md.PostFee.Value; } decimal BackFactPrice = 0M; decimal BackPostFee = 0M; int BackState = -1; if (md.OrderState2 != null) BackState = md.OrderState2.Value; if (BackState == 1 && (saleBackModelList != null)) { DT_OrderBackMoneyApply backmd = saleBackModelList.Find(n => n.OrderId == md.OrderId); if (backmd != null) { if (backmd.OrderState == 0) { YJPrice = TotalPrice * Convert.ToDecimal((double)0.2); TotalPrice = 0M; } if (backmd.OrderState == 1 || backmd.OrderState == 2) { GoodsFee = 0M; YJGoodsFee = 0M; } if (backmd.FactPrice.HasValue) { BackFactPrice = backmd.FactPrice.Value; } if (backmd.PostFee.HasValue) { BackPostFee = backmd.PostFee.Value; } } } decimal PostFeeYJ = 0M; //if (md.Post == 222 || md.Post == 226 || md.Post == 227) //{ // PostFeeYJ = PostFee * Convert.ToDecimal((double)0.1); //} decimal ygyf = 0M; decimal ygyf2 = 0M; int storeid = 6; md.RevFax = "W"; if (maplist != null) { var mmd = maplist.Find(n => n.OrderId == md.OrderId); if (mmd != null && mmd.StoreId != null) { if (mmd.StoreId == 11) { storeid = 11; md.RevFax = "E"; } if (mmd.Fee11 != null && mmd.Fee11 > 0) { ygyf = mmd.Fee11.Value; } if (ygyf == 0 && mmd.Fee12 != null && mmd.Fee12 > 0) ygyf = mmd.Fee12.Value; if (mmd.Fee12 != null && mmd.Fee12 > 0 && mmd.Fee12 < ygyf) { ygyf = mmd.Fee12.Value; } if (ygyf == 0 && mmd.Fee13 != null && mmd.Fee13 > 0) ygyf = mmd.Fee13.Value; if (mmd.Fee13 != null && mmd.Fee13 > 0 && mmd.Fee13 < ygyf) { ygyf = mmd.Fee13.Value; } if (ygyf == 0 && mmd.Fee14 != null && mmd.Fee14 > 0) ygyf = mmd.Fee14.Value; if (mmd.Fee14 != null && mmd.Fee14 > 0 && mmd.Fee14 < ygyf) { ygyf = mmd.Fee14.Value; } if (AddrType == "Residential" || AddrType == "RESIDENTIAL") { if (mmd.Fee11 > 0 && mmd.Fee11 < mmd.Fee13) { ygyf = mmd.Fee11.Value; } else if (mmd.Fee11 > 0 && mmd.Fee11 > mmd.Fee13) { ygyf = mmd.Fee13.Value; } } if (AddrType == "Commercial" || AddrType == "OFFICE") { if (mmd.Fee11 > 0 && mmd.Fee11 < mmd.Fee12) { ygyf = mmd.Fee11.Value; } else if (mmd.Fee12 > 0 && mmd.Fee11 > mmd.Fee12) { ygyf = mmd.Fee12.Value; } } if (twight >= 1120 && mmd.Fee12 > 0) ygyf = mmd.Fee12.Value; // if (ygyf > 0) // ygyf = ygyf * 1.1M; } } if (md.Fee6 != null && md.Fee6 > 0) { ygyf2 = md.Fee6.Value; } if (ygyf2 == 0 && md.Fee7 != null && md.Fee7 > 0) ygyf2 = md.Fee7.Value; if (md.Fee7 != null && md.Fee7 > 0 && md.Fee7 < ygyf2) { ygyf2 = md.Fee7.Value; } if (ygyf2 == 0 && md.Fee8 != null && md.Fee8 > 0) ygyf2 = md.Fee8.Value; if (md.Fee8 != null && md.Fee8 > 0 && md.Fee8 < ygyf2) { ygyf2 = md.Fee8.Value; } if (AddrType == "Residential" || AddrType == "RESIDENTIAL") { if (md.Fee6 > 0 && md.Fee6 < md.Fee8) { ygyf2 = md.Fee6.Value; } else if (md.Fee8 > 0 && md.Fee6 > md.Fee8) { ygyf2 = md.Fee8.Value; } } if (AddrType == "Commercial" || AddrType == "OFFICE") { if (md.Fee6 > 0 && md.Fee6 < md.Fee7) { ygyf2 = md.Fee6.Value; } else if (md.Fee7 > 0 && md.Fee6 > md.Fee7) { ygyf2 = md.Fee7.Value; } } if (twight >= 1120 && md.Fee7 > 0) ygyf2 = md.Fee7.Value; md.PostFee = new decimal?(PostFee); decimal ygyf0 = ygyf; if (ygyf == 0) ygyf0 = ygyf2; if (ygyf > 0 && ygyf <= ygyf2) ygyf0 = ygyf; else if (ygyf2 > 0 && ygyf2 < ygyf) ygyf0 = ygyf2; if (PlatId == 18) { ygyf0 = 0; PostFee = 0; } md.BoxFee = new decimal?(ygyf0); decimal LR = 0M; decimal YGLR = 0M; LR = TotalPrice - YJPrice - escrowFee - GoodsFee - PostFee - PostFeeYJ - TCFee - BackFactPrice - BackPostFee - ckfee - mdfee - adfee - DR_BackFee - DR_PostFee + DR_SSFee; YGLR = TotalPrice - YJPrice - escrowFee - YJGoodsFee - YGFeeRate - ygyf0 - YJTCFee - BackFactPrice - BackPostFee - ckfee - mdfee - adfee - DR_BackFee - DR_PostFee + DR_SSFee; ; md.LR = new decimal?(Convert.ToDecimal(LR.ToString("0.00"))); md.YGLR = new decimal?(Convert.ToDecimal(YGLR.ToString("0.00"))); } } } return model; } [WebMethod(EnableSession = true)] public JsonModel> GetListOrderForTM44(int IsYJ, int StoreId, int DeptId, int PlatType, int ShopId, int DateType, DateTime? SDate, DateTime? EDate, int TjType, string Name, int PrintState, int MateState, int MoneyState, int OutDays, int State, int IsSku, int IsError, int IsE, int IsDetail, int HBOrder, int IsSD, int SaleState, int IsBuy, int WLId, int IsDH, int SFLY, int yfcy, int PageIndex, int PageSize, string Sort) { PagesNew.Login(base.Session); DD_OrderData data = new DD_OrderData(); int num = Convert.ToInt32(base.Session["CompanyId"]); RefParameterCollection where = new RefParameterCollection(); if (IsYJ == 1) { where.Add("a.PlatId", "=", 2, DbType.Int32); where.Add("isnull(a.Fee6,0)", "=", 0, DbType.Int32); where.Add("isnull(a.Fee7,0)", "=", 0, DbType.Int32); where.Add("isnull(a.Fee8,0)", "=", 0, DbType.Int32); } if (StoreId > 0) { where.Add("a.StoreId", "=", StoreId, DbType.Int32); } if (IsBuy == 1) { where.Add("a.BuyDate", "is not", null, DbType.String); } else if (IsBuy == 0) { where.Add("a.BuyDate", "is", null, DbType.String); } where.Add("a.CompanyId", "=", num, DbType.Int32); // where.Add("isnull(a.IsSDan,0)", "=", IsSD, DbType.Int32); if (yfcy == 1) where.Add("a.WLSS", "=", 1, DbType.Int32); if (SaleState > 0) { where.Add("a.SaleState", "=", SaleState, DbType.Int32); } if (WLId > 0) { where.Add("a.LogisticsId", "=", WLId, DbType.Int32); } if (DeptId > 0) { where.Add("c.DeptId", "=", DeptId, DbType.Int32); } if (PlatType > 0) { where.Add("a.PlatId", "=", PlatType, DbType.Int32); } if (ShopId > 0) { where.Add("a.ShopId", "=", ShopId, DbType.Int32); } if (DateType == 1) { if (SDate.HasValue) { where.Add("a.OrderDate", ">=", SDate, DbType.DateTime); } if (EDate.HasValue) { where.Add("a.OrderDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime); } } else if (DateType == 2) { if (SDate.HasValue) { where.Add("a.InDate", ">=", SDate, DbType.DateTime); } if (EDate.HasValue) { where.Add("a.InDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime); } } else if (DateType == 3) { if (SDate.HasValue) { where.Add("a.PrintDate", ">=", SDate, DbType.DateTime); } if (EDate.HasValue) { where.Add("a.PrintDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime); } } else if (DateType == 4) { if (SDate.HasValue) { where.Add("a.PostDate", ">=", SDate, DbType.DateTime); } if (EDate.HasValue) { where.Add("a.PostDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime); } } else if (DateType == 5) { if (SDate.HasValue) { where.Add("a.OrderOutDate", ">=", SDate, DbType.DateTime); } if (EDate.HasValue) { where.Add("a.OrderOutDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime); } } if (OutDays > 0) { where.Add("a.OrderOutDate", "<=", DateTime.Now.AddDays((double)OutDays), DbType.DateTime); where.Add("a.OrderOutDate", ">=", DateTime.Now, DbType.DateTime); } if (MateState > -1) { where.Add("a.MateState", "=", MateState, DbType.Int32); } if (MoneyState > -1) { where.Add("a.MoneyState", "=", MoneyState, DbType.Int32); } if (PrintState > -1) { where.Add("a.PrintState", "=", PrintState, DbType.Int32); } if (State == 3) { where.Add("a.State", "=", 2, DbType.Int32); } else if (State == 4) { where.Add("a.State", "=", 3, DbType.Int32); } else if (State == 5) { where.Add("a.State", "=", 1, DbType.Int32); where.Add("a.MoneyState", "=", 1, DbType.Int32); } else if (State == 7) { where.Add("a.OrderState2", "=", 1, DbType.Int32); } else if (State == 1) { where.Add("a.PostState", "=", 1, DbType.Int32); } else if (State == 2) { where.Add("a.State", "<", 3, DbType.Int32); where.Add("a.PostState", "=", 2, DbType.Int32); } else if (State == 0) { where.Add("a.State", "=", 1, DbType.Int32); } else { where.Add("a.State", ">", 0, DbType.Int32); } if (HBOrder == 1) { where.Add("a.IsJoin", "=", 1, DbType.Int32); } if (IsError == 1) { where.Add("(a.SendAddr", ">", 0, DbType.Int32); where.Add("a.IsLeaveWord", "=", 1, "or", ")", DbType.Int32); } if (IsE == 1) { where.Add("a.PostState", "=", 2, DbType.Int32); } if (IsE == 0) { where.Add("a.PostState", "<", 2, DbType.Int32); } string trackCode = ""; if (Name != "") { Name = Name.Trim(); if (TjType == 1) { where.Add("(a.PlatOrderCode", "like", Name, DbType.String); where.Add("OrderCode", "like", Name, "or", DbType.String); where.Add("a.JoinOrderCode", "like", Name, "or", ")", DbType.String); } else if (TjType == 2) { where.Add("a.RevName", "like", Name, DbType.String); } else if (TjType == 3) { where.Add("a.RevPhone", "like", Name, DbType.String); } else if (TjType == 4) { where.Add("(a.RevCountry", "=", Name, DbType.String); where.Add("a.CountryName", "=", Name, "or", DbType.String); where.Add("a.CountryCode", "=", Name, "or", ")", DbType.String); } else if (TjType == 5) { where.Add("a.RevPostCode", "=", Name, DbType.String); } else if (TjType == 6) { where.Add("(a.RevAddr", "like", Name, DbType.String); where.Add("a.RevProvince", "like", Name, "or", DbType.String); where.Add("a.RevCity", "like", Name, "or", DbType.String); where.Add("a.RevArea", "like", Name, "or", ")", DbType.String); } else if (TjType == 9) { where.Add("(a.ErrorInfo", "like", Name, DbType.String); where.Add("a.PostError", "like", Name, "or", ")", DbType.String); } else if (TjType == 10) { trackCode = Name; } else if (TjType == 11) { where.Add("a.CustomID", "=", Name, DbType.String); } else if (TjType == 12) { where.Add("a.RevMail", "=", Name, DbType.String); } } if (IsSku == 0) { where.Add("a.FPDate", "is", null, DbType.String); } else if (IsSku == 1) { where.Add("a.FPDate", "is not", null, DbType.String); } JsonModel> model = new JsonModel>(); int rowCount = 0; string str2 = ""; string str3 = ""; if ((TjType == 7) && (Name != "")) { str2 = Name; } else if ((TjType == 8) && (Name != "")) { str3 = Name; } if (TjType == 13 && Name != "")//根据人员查询 { model.DataSource = DataNew.GetListDT_OrderInfoForUser(num, SDate, str2.Trim(), Name, trackCode, -1, IsDH, where, PageIndex, PageSize, Sort, out rowCount); } else { if (SFLY > 0) { if (SFLY == 1) { model.DataSource = data.GetListDT_OrderInfoForTM6(num, str2.Trim(), str3.Trim(), trackCode, -1, IsDH, where, PageIndex, PageSize, Sort, out rowCount); } if (SFLY == 2) { model.DataSource = data.GetListDT_OrderInfoForTM7(num, str2.Trim(), str3.Trim(), trackCode, -1, IsDH, where, PageIndex, PageSize, Sort, out rowCount); } } else { model.DataSource = DataNew.GetListDT_OrderInfoForTM2(num, "",str2.Trim(), str3.Trim(), trackCode, -1, IsDH, where, PageIndex, PageSize, Sort, out rowCount); } } model.RowCount = rowCount; string ids = ""; JC_ExpressService wlobj = new JC_ExpressService(); var wlist = wlobj.GetExpressList(); List maplist = null; if (model.DataSource != null) { foreach (DT_Order md in model.DataSource) { ids += md.OrderId.ToString() + ","; if (md.Post != null && md.Post > 0) { var wlmd = wlist.Find(n => n.ExpressID == md.Post); if (wlmd != null) { md.TrackInfo = wlmd.Name; } } md.RevFax = ""; //if (maplist != null && md.RevProvince != null && md.RevProvince != "") //{ // var mmd = maplist.Find(n => n.code == md.RevProvince.ToUpper() || n.ename == md.RevProvince); // if (mmd != null) // { // if (mmd.IsEast == 1) // { // md.RevFax = "E"; // } // else // md.RevFax = "W"; // } //} } } if (ids != "") { maplist = DataNew.GetListUSMap4(ids.Trim(',')); List errorList = data.GetErrorList(ids.Trim(',')); if ((errorList != null) && (errorList.Count > 0)) { foreach (var md in model.DataSource) { DT_OrderError error = errorList.Find(n => n.OrderId == md.OrderId); if (error != null) { md.ErrorInfo = error.ErrorInfo; } } } } decimal zje = 0; decimal zyf = 0; decimal zcb = 0; decimal zyj = 0; decimal zlr = 0; if ((IsDetail == 1) && (model.DataSource != null)) { int? trackType; if (ids != "") { List orderGoodsList = DataNew.GetOrderGoodsListNew2(ids.Trim(',')); List trackCodeApplyList = data.GetTrackCodeApplyList(ids.Trim(',')); // saleBackModelList = data.GetSaleBackModelList(ids.Trim(',')); // var pmlist = DataNew.GetOrderGoodsCodeData(); // List JZLinklist = DataNew.GetListJZLinkOrder(ids.Trim(',')); if (orderGoodsList != null) { foreach (var md in model.DataSource) { List list5 = orderGoodsList.FindAll(n => n.OrderId == md.OrderId); if (list5 != null) { md.GoodsList = list5; } } } if (trackCodeApplyList != null) { foreach (var md in model.DataSource) { List list6 = new List(); if ((md.JoinOrderCode != null) && (md.JoinOrderCode != "")) { list6 = trackCodeApplyList.FindAll(n => n.OrderCode == md.JoinOrderCode); } else { list6 = trackCodeApplyList.FindAll(n => n.OrderId == md.OrderId); } if ((list6 != null) && (list6.Count > 0)) { string str5 = ""; string str6 = ""; foreach (DT_TrackCodeApply apply in list6) { string str7 = ""; trackType = apply.TrackType; if (trackType != null && trackType == 3) { str7 = "[空包裹]"; } if (apply.Weight.HasValue) { string str8 = ""; if (apply.ScanDate.HasValue) { str8 = "扫描时间:" + apply.ScanDate.Value.ToString("yyyy-MM-dd HH:mm") + "
"; } string str9 = str5; str5 = str9 + apply.TrackCode + str7 + "
重量" + apply.Weight.ToString() + "g" + str8 + "
"; } else { str5 = str5 + apply.TrackCode + str7 + "
"; } if (str6 == "") { str6 = apply.TrackCode; } } md.TrackInfo += str5; md.TrackCode = str6; } } } decimal moneyrate = 1; decimal moneyrate2 = 1; List list7 = new BaseService().GetMoneyList2(); decimal ckfee = 0; decimal mdfee = 0; decimal adfee = 0; decimal DR_BackFee = 0; decimal DR_SSFee = 0; decimal DR_PostFee = 0; foreach (var md in model.DataSource) { md.OrderName = ""; JC_Money money = list7.Find(n => n.MCode == md.MoneyCode && n.PlatId == md.PlatId); if (money != null) { moneyrate = money.MRate.Value; } else { money = list7.Find(n => n.MCode == md.MoneyCode); if (money != null) moneyrate = money.MRate.Value; } JC_Money money2 = list7.Find(n => n.MCode == "USD" && n.PlatId == md.PlatId); if (money2 != null) { moneyrate2 = money2.MRate.Value; } else { money2 = list7.Find(n => n.MCode == "USD"); if (money2 != null) moneyrate2 = money2.MRate.Value; } decimal TotalPrice = 0M; if (md.TotalPrice != null) { TotalPrice = md.TotalPrice.Value; } decimal YJPrice = 0M; if (md.escrowFee != null) YJPrice = md.escrowFee.Value;//佣金 int PlatId = md.PlatId.Value; if (PlatId == 1) { YJPrice = TotalPrice * Convert.ToDecimal((double)0.05); } else if (PlatId == 4) { YJPrice = 0; } else if (PlatId == 5) { YJPrice = TotalPrice * Convert.ToDecimal((double)0.04); decimal payfee = 0; //lazada paymentfee if (md.CountryCode == "VN") { payfee = TotalPrice * 0.0384M; } else if (md.CountryCode == "TH") { payfee = TotalPrice * 0.028M; } else if (md.CountryCode == "ID") { payfee = TotalPrice * 0.0182M; } else { payfee = TotalPrice * 0.02M; } YJPrice = YJPrice + payfee; } else if (PlatId == 15) { YJPrice = TotalPrice * Convert.ToDecimal((double)0.029) + 0.3M; } else if (PlatId == 16) { YJPrice = TotalPrice * 0.15M; } if (TotalPrice > 0) TotalPrice = TotalPrice * moneyrate / moneyrate2; //总金额 转美金 if (YJPrice > 0) YJPrice = YJPrice * moneyrate / moneyrate2; //总金额 转美金 decimal GoodsFee = 0M; decimal YJGoodsFee = 0M; decimal TCFee = 0M; decimal YJTCFee = 0M; decimal TSolid = 0M; decimal YGFeeRate = 0M; string AddrType = ""; decimal twight = 0; if (md.GoodsList != null && md.GoodsList.Count > 0) { AddrType = md.GoodsList[0].JoinOrderCode; if (md.GoodsList[0].Weight != null) twight = md.GoodsList[0].Weight.Value; foreach (DT_OrderGoods goods in md.GoodsList) { if (goods.GoodsFee.HasValue && (goods.GoodsFee.Value > 0M)) { GoodsFee += goods.GoodsFee.Value; } if (goods.GoodsPrice.HasValue) { YJGoodsFee += goods.GoodsPrice.Value * goods.GoodsNum.Value; if (goods.BGPrice != null) YGFeeRate += goods.GoodsPrice.Value * goods.GoodsNum.Value * goods.BGPrice.Value * Convert.ToDecimal(0.01);//预估成本 } } } if (GoodsFee == 0) GoodsFee = YJGoodsFee; GoodsFee = GoodsFee / moneyrate2;//转美金 YGFeeRate = YGFeeRate / moneyrate2;//转美金 decimal PostFee = 0M; if (md.PostFee.HasValue) { PostFee = md.PostFee.Value; } decimal BackFactPrice = 0M; decimal BackPostFee = 0M; int BackState = -1; if (md.OrderState2 != null) BackState = md.OrderState2.Value; decimal PostFeeYJ = 0M; if (md.Fee7 != null) PostFeeYJ = md.Fee7.Value; // if (PostFeeYJ > 0) // PostFeeYJ = PostFeeYJ * moneyrate; md.BoxFee = PostFeeYJ; decimal LR = 0M; decimal YGLR = 0M; if (GoodsFee > 0) YJGoodsFee = GoodsFee; LR = TotalPrice - YJPrice - GoodsFee - PostFee - TCFee - BackFactPrice - BackPostFee - ckfee - mdfee - adfee - DR_BackFee - DR_PostFee + DR_SSFee; YGLR = TotalPrice - YJPrice - YJGoodsFee - YGFeeRate - PostFeeYJ - BackFactPrice - BackPostFee - ckfee - mdfee - adfee - DR_BackFee - DR_PostFee + DR_SSFee; if (PostFeeYJ > 0) { zje += TotalPrice; zyf += PostFeeYJ; zcb += YJGoodsFee; zyj += YJPrice; zlr += YGLR; } md.LR = new decimal?(Convert.ToDecimal(LR.ToString("0.00"))); md.YGLR = new decimal?(Convert.ToDecimal(YGLR.ToString("0.00"))); md.Fee8 = TotalPrice; } } } return model; } [WebMethod(EnableSession = true)] public JsonModel> GetListOrderForReturn(int ShopId,int changestate,string InType, string ScanState, DateTime? SDate, DateTime? EDate, DateTime? SDate2, DateTime? EDate2,string trackcode, string OrderCode,string SKU,int trackcz, int PageIndex, int PageSize, string Sort,int warehouse) { PagesNew.Login(base.Session); RefParameterCollection where = new RefParameterCollection(); if(changestate==0) where.Add(new RefParameter("a.orderid", "=", 0, DbType.Int32)); if (ShopId != 0) where.Add(new RefParameter("c.ShopId", "=", ShopId, DbType.Int32)); if (SDate != null) where.Add(new RefParameter("order_date", ">=", SDate, System.Data.DbType.DateTime)); if (EDate != null) where.Add(new RefParameter("convert(varchar(10), order_date, 120)", "<=", EDate, System.Data.DbType.DateTime)); if (SDate2 != null) where.Add(new RefParameter("ScanDate", ">=", SDate2, System.Data.DbType.DateTime)); if (EDate2 != null) where.Add(new RefParameter("convert(varchar(10), ScanDate, 120)", "<=", EDate2, System.Data.DbType.DateTime)); if (InType!="0") where.Add(new RefParameter("a.InType", "=", InType, DbType.String)); if (ScanState != "-1") where.Add(new RefParameter("isnull(a.ScanState,0)", "=", ScanState, DbType.String)); if (string.IsNullOrEmpty(trackcode) == false) { where.Add(new RefParameter("(a.tracking_id", "=", trackcode, DbType.String)); where.Add(new RefParameter("a.BarCode", "=", trackcode, "or", ")", DbType.String)); } if (string.IsNullOrEmpty(OrderCode) == false) where.Add(new RefParameter("a.ordercode", "like", OrderCode, DbType.String)); if (string.IsNullOrEmpty(SKU) == false) where.Add(new RefParameter("a.merchant_sku", "like", SKU, DbType.String)); if(trackcz==0) where.Add(new RefParameter("a.tracking_id", "=", "", DbType.String)); if (trackcz == 1) where.Add(new RefParameter("a.tracking_id", "<>", "", DbType.String)); if (warehouse == 0) where.Add(new RefParameter("d.WorkDesc", "=", "西仓", DbType.String)); if (warehouse == 1) where.Add(new RefParameter("d.WorkDesc", "=", "东仓", DbType.String)); JsonModel> resultModel = new JsonModel>(); int RowCount = 0; resultModel.DataSource =DataNew.GetListOrderReturn(where, PageIndex, PageSize, Sort, out RowCount); resultModel.RowCount = RowCount; return resultModel; } [WebMethod(EnableSession = true)] public JsonModel> GetListOrderForTM2222(int IsYJ, int StoreId, int DeptId, int PlatType, int ShopId, int DateType, DateTime? SDate, DateTime? EDate, int TjType, string Name, int PrintState, int MateState, int MoneyState, int OutDays, int State, int IsSku, int IsError, int IsE, int IsDetail, int HBOrder, int IsSD, int SaleState, int IsBuy, int WLId, int IsDH, int SFLY, int yfcy, int PageIndex, int PageSize, string Sort) { PagesNew.Login(base.Session); DD_OrderData data = new DD_OrderData(); int num = Convert.ToInt32(base.Session["CompanyId"]); // Session["KTSKU"] = "DC"; string ktsku = Session["KTSKU"].ToString(); RefParameterCollection where = new RefParameterCollection(); if (IsYJ == 1) { where.Add("a.PlatId", "=", 2, DbType.Int32); where.Add("isnull(a.Fee6,0)", "=", 0, DbType.Int32); where.Add("isnull(a.Fee7,0)", "=", 0, DbType.Int32); where.Add("isnull(a.Fee8,0)", "=", 0, DbType.Int32); } if (StoreId > 0) { where.Add("a.StoreId", "=", StoreId, DbType.Int32); } if (IsBuy == 1) { where.Add("a.BuyDate", "is not", null, DbType.String); } else if (IsBuy == 0) { where.Add("a.BuyDate", "is", null, DbType.String); } where.Add("a.CompanyId", "=", num, DbType.Int32); // where.Add("isnull(a.IsSDan,0)", "=", IsSD, DbType.Int32); if (yfcy == 1) where.Add("a.WLSS", "=", 1, DbType.Int32); if (SaleState > 0) { where.Add("a.SaleState", "=", SaleState, DbType.Int32); } if (WLId > 0) { where.Add("a.LogisticsId", "=", WLId, DbType.Int32); } if (DeptId > 0) { where.Add("c.DeptId", "=", DeptId, DbType.Int32); } if (PlatType > 0) { where.Add("a.PlatId", "=", PlatType, DbType.Int32); } if (ShopId > 0) { where.Add("a.ShopId", "=", ShopId, DbType.Int32); } if (DateType == 1) { if (SDate.HasValue) { where.Add("a.OrderDate", ">=", SDate, DbType.DateTime); } if (EDate.HasValue) { where.Add("a.OrderDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime); } } else if (DateType == 2) { if (SDate.HasValue) { where.Add("a.InDate", ">=", SDate, DbType.DateTime); } if (EDate.HasValue) { where.Add("a.InDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime); } } else if (DateType == 3) { if (SDate.HasValue) { where.Add("a.PrintDate", ">=", SDate, DbType.DateTime); } if (EDate.HasValue) { where.Add("a.PrintDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime); } } else if (DateType == 4) { if (SDate.HasValue) { where.Add("a.PostDate", ">=", SDate, DbType.DateTime); } if (EDate.HasValue) { where.Add("a.PostDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime); } } else if (DateType == 5) { if (SDate.HasValue) { where.Add("a.OrderOutDate", ">=", SDate, DbType.DateTime); } if (EDate.HasValue) { where.Add("a.OrderOutDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime); } } if (OutDays > 0) { where.Add("a.OrderOutDate", "<=", DateTime.Now.AddDays((double)OutDays), DbType.DateTime); where.Add("a.OrderOutDate", ">=", DateTime.Now, DbType.DateTime); } if (MateState > -1) { where.Add("a.MateState", "=", MateState, DbType.Int32); } if (MoneyState > -1) { where.Add("a.MoneyState", "=", MoneyState, DbType.Int32); } if (PrintState > -1) { where.Add("a.PrintState", "=", PrintState, DbType.Int32); } if (State == 3) { where.Add("a.State", "=", 2, DbType.Int32); } else if (State == 4) { where.Add("a.State", "=", 3, DbType.Int32); } else if (State == 5) { where.Add("a.State", "=", 1, DbType.Int32); where.Add("a.MoneyState", "=", 1, DbType.Int32); } else if (State == 7) { where.Add("a.OrderState2", "=", 1, DbType.Int32); } else if (State == 1) { where.Add("a.PostState", "=", 1, DbType.Int32); } else if (State == 2) { where.Add("a.State", "<", 3, DbType.Int32); where.Add("a.PostState", "=", 2, DbType.Int32); } else if (State == 0) { where.Add("a.State", "=", 1, DbType.Int32); } else { where.Add("a.State", ">", 0, DbType.Int32); } if (HBOrder == 1) { where.Add("a.IsJoin", "=", 1, DbType.Int32); } if (IsError == 1) { where.Add("(a.SendAddr", ">", 0, DbType.Int32); where.Add("a.IsLeaveWord", "=", 1, "or", ")", DbType.Int32); } if (IsE == 1) { where.Add("a.PostState", "=", 2, DbType.Int32); } if (IsE == 0) { where.Add("a.PostState", "<", 2, DbType.Int32); } string trackCode = ""; if (Name != "") { Name = Name.Trim(); if (TjType == 1) { where.Add("(a.PlatOrderCode", "like", Name, DbType.String); where.Add("OrderCode", "like", Name, "or", DbType.String); where.Add("a.JoinOrderCode", "like", Name, "or", ")", DbType.String); } else if (TjType == 2) { where.Add("a.RevName", "like", Name, DbType.String); } else if (TjType == 3) { where.Add("a.RevPhone", "like", Name, DbType.String); } else if (TjType == 4) { where.Add("(a.RevCountry", "=", Name, DbType.String); where.Add("a.CountryName", "=", Name, "or", DbType.String); where.Add("a.CountryCode", "=", Name, "or", ")", DbType.String); } else if (TjType == 5) { where.Add("a.RevPostCode", "=", Name, DbType.String); } else if (TjType == 6) { where.Add("(a.RevAddr", "like", Name, DbType.String); where.Add("a.RevProvince", "like", Name, "or", DbType.String); where.Add("a.RevCity", "like", Name, "or", DbType.String); where.Add("a.RevArea", "like", Name, "or", ")", DbType.String); } else if (TjType == 9) { where.Add("(a.ErrorInfo", "like", Name, DbType.String); where.Add("a.PostError", "like", Name, "or", ")", DbType.String); } else if (TjType == 10) { trackCode = Name; } else if (TjType == 11) { where.Add("a.CustomID", "=", Name, DbType.String); } else if (TjType == 12) { where.Add("a.RevMail", "=", Name, DbType.String); } } if (IsSku == 0) { where.Add("a.FPDate", "is", null, DbType.String); } else if (IsSku == 1) { where.Add("a.FPDate", "is not", null, DbType.String); } JsonModel> model = new JsonModel>(); int rowCount = 0; string str2 = ""; string str3 = ""; if ((TjType == 7) && (Name != "")) { str2 = Name; } else if ((TjType == 8) && (Name != "")) { str3 = Name; } model.DataSource = DataNew.GetListDT_OrderInfoForTM222(num, str2.Trim(), ktsku, str3.Trim(), trackCode, -1, IsDH, where, PageIndex, PageSize, Sort, out rowCount); model.RowCount = rowCount; string ids = ""; JC_ExpressService wlobj = new JC_ExpressService(); var wlist = wlobj.GetExpressList(); List maplist = null; if (model.DataSource != null) { foreach (DT_Order md in model.DataSource) { ids += md.OrderId.ToString() + ","; if (md.Post != null && md.Post > 0) { var wlmd = wlist.Find(n => n.ExpressID == md.Post); if (wlmd != null) { md.TrackInfo = wlmd.Name; } } md.RevFax = ""; //if (maplist != null && md.RevProvince != null && md.RevProvince != "") //{ // var mmd = maplist.Find(n => n.code == md.RevProvince.ToUpper() || n.ename == md.RevProvince); // if (mmd != null) // { // if (mmd.IsEast == 1) // { // md.RevFax = "E"; // } // else // md.RevFax = "W"; // } //} } } if (ids != "") { maplist = DataNew.GetListUSMap4(ids.Trim(',')); List errorList = data.GetErrorList(ids.Trim(',')); if ((errorList != null) && (errorList.Count > 0)) { foreach (var md in model.DataSource) { DT_OrderError error = errorList.Find(n => n.OrderId == md.OrderId); if (error != null) { md.ErrorInfo = error.ErrorInfo; } } } } List saleBackModelList = null; if ((IsDetail == 1) && (model.DataSource != null)) { int? trackType; if (ids != "") { List orderGoodsList = DataNew.GetOrderGoodsListNew2(ids.Trim(',')); List trackCodeApplyList = data.GetTrackCodeApplyList(ids.Trim(',')); saleBackModelList = data.GetSaleBackModelList(ids.Trim(',')); var pmlist = DataNew.GetOrderGoodsCodeData(); List JZLinklist = DataNew.GetListJZLinkOrder(ids.Trim(',')); if (orderGoodsList != null) { foreach (var md in model.DataSource) { List list5 = orderGoodsList.FindAll(n => n.OrderId == md.OrderId); if (list5 != null) { md.GoodsList = list5; if (pmlist != null) { foreach (var mmd in list5) { var pmmd = pmlist.Find(n => n.GoodsId == mmd.GoodsId && n.ShopId == md.ShopId); if (pmmd != null) { string imgurl = ""; if (pmmd.Int10 != null && pmmd.Int10 == 1) { imgurl = ""; } if (pmmd.Int10 != null && pmmd.Int10 == 2) { imgurl = ""; } if (pmmd.Int10 != null && pmmd.Int10 == 3) { imgurl = ""; } if (pmmd.Int3 < 100) mmd.OldTypeDesc = "排名:" + pmmd.Int3.ToString(); else mmd.OldTypeDesc = "排名:" + pmmd.Int3.ToString(); if (pmmd.Int2 != null) mmd.OldTypeDesc += "/" + pmmd.Int2.ToString(); mmd.OldTypeDesc += "" + imgurl; } else mmd.OldTypeDesc = ""; } } } } } if (trackCodeApplyList != null) { foreach (var md in model.DataSource) { List list6 = new List(); if ((md.JoinOrderCode != null) && (md.JoinOrderCode != "")) { list6 = trackCodeApplyList.FindAll(n => n.OrderCode == md.JoinOrderCode); } else { list6 = trackCodeApplyList.FindAll(n => n.OrderId == md.OrderId); } if ((list6 != null) && (list6.Count > 0)) { string str5 = ""; string str6 = ""; foreach (DT_TrackCodeApply apply in list6) { string str7 = ""; trackType = apply.TrackType; if (trackType != null && trackType == 3) { str7 = "[空包裹]"; } if (apply.Weight.HasValue) { string str8 = ""; if (apply.ScanDate.HasValue) { str8 = "扫描时间:" + apply.ScanDate.Value.ToString("yyyy-MM-dd HH:mm") + "
"; } string str9 = str5; str5 = str9 + apply.TrackCode + str7 + "
重量" + apply.Weight.ToString() + "g" + str8 + "
"; } else { str5 = str5 + apply.TrackCode + str7 + "
"; } if (str6 == "") { str6 = apply.TrackCode; } } md.TrackInfo += str5; md.TrackCode = str6; } } } decimal moneyrate = Convert.ToDecimal((double)6.5); List list7 = new BaseService().GetMoneyList2(); foreach (var md in model.DataSource) { md.OrderName = ""; string jplink = ""; if (JZLinklist != null) { var jzmd = JZLinklist.FindAll(n => n.OrderId == md.OrderId && n.ShopId == md.ShopId); if (jzmd != null) { int i = 1; foreach (var jzmmd in jzmd) { if (jzmmd.Price != null) jplink += "竟品" + i.ToString() + "价格:" + jzmmd.Price.Value + "$
"; else jplink += "竟品" + i.ToString() + "
"; i++; } } md.OrderName = jplink; } JC_Money money = list7.Find(n => n.MCode == "USD" && n.PlatId == md.PlatId); if (money != null) { moneyrate = money.MRate.Value; } else { money = list7.Find(n => n.MCode == "USD"); moneyrate = money.MRate.Value; } decimal TotalPrice = 0M; if (md.TotalPrice != null) { TotalPrice = md.TotalPrice.Value; } decimal YJPrice = 0M; YJPrice = TotalPrice * Convert.ToDecimal((double)0.15); int PlatId = md.PlatId.Value; if (PlatId == 1) { YJPrice = TotalPrice * Convert.ToDecimal((double)0.05); } else if (PlatId == 4) { YJPrice = 0; } else if (PlatId == 5) { YJPrice = TotalPrice * Convert.ToDecimal((double)0.1); } decimal GoodsFee = 0M; decimal YJGoodsFee = 0M; decimal TCFee = 0M; decimal YJTCFee = 0M; decimal TSolid = 0M; decimal YGFeeRate = 0M; string AddrType = ""; decimal twight = 0; if (md.GoodsList != null && md.GoodsList.Count > 0) { AddrType = md.GoodsList[0].JoinOrderCode; if (md.GoodsList[0].Weight != null) twight = md.GoodsList[0].Weight.Value; foreach (DT_OrderGoods goods in md.GoodsList) { if (goods.GoodsFee.HasValue && (goods.GoodsFee.Value > 0M)) { GoodsFee += goods.GoodsFee.Value; } if (goods.GoodsPrice.HasValue) { if (GoodsFee == 0) GoodsFee += goods.GoodsPrice.Value * goods.GoodsNum.Value; YJGoodsFee += goods.GoodsPrice.Value * goods.GoodsNum.Value; if (goods.BGPrice != null) YGFeeRate += goods.GoodsPrice.Value * goods.GoodsNum.Value * goods.BGPrice.Value * Convert.ToDecimal(0.01); } if (goods.TCFee != null && goods.TCFee > 0) { TCFee += goods.TCFee.Value; } if (goods.Solid2.HasValue) { TSolid += goods.Solid2.Value * goods.GoodsNum.Value; } } } if (GoodsFee > 0M) { GoodsFee = GoodsFee / moneyrate; YJGoodsFee = YJGoodsFee / moneyrate;//预估货物成本 YGFeeRate = YGFeeRate / moneyrate;//预估税费 } decimal escrowFee = 0M; if ((TCFee == 0M) && (TSolid > 0M)) { TCFee = Convert.ToDecimal(170) * TSolid; } if (TSolid > 0M) { YJTCFee = Convert.ToDecimal(170) * TSolid;//预估头程 } if (md.escrowFee.HasValue) { escrowFee = md.escrowFee.Value;//页面上手填的税费 } decimal PostFee = 0M; if (md.PostFee.HasValue) { PostFee = md.PostFee.Value; } decimal BackFactPrice = 0M; decimal BackPostFee = 0M; int BackState = -1; if (md.OrderState2 != null) BackState = md.OrderState2.Value; if (BackState == 1 && (saleBackModelList != null)) { DT_OrderBackMoneyApply backmd = saleBackModelList.Find(n => n.OrderId == md.OrderId); if (backmd != null) { if (backmd.OrderState == 0) { YJPrice = TotalPrice * Convert.ToDecimal((double)0.2); TotalPrice = 0M; } if (backmd.OrderState == 1 || backmd.OrderState == 2) { GoodsFee = 0M; YJGoodsFee = 0M; } if (backmd.FactPrice.HasValue) { BackFactPrice = backmd.FactPrice.Value; } if (backmd.PostFee.HasValue) { BackPostFee = backmd.PostFee.Value; } } } decimal PostFeeYJ = 0M; //if (md.Post == 222 || md.Post == 226 || md.Post == 227) //{ // PostFeeYJ = PostFee * Convert.ToDecimal((double)0.1); //} decimal ygyf = 0M; decimal ygyf2 = 0M; int storeid = 6; md.RevFax = "W"; if (maplist != null) { var mmd = maplist.Find(n => n.OrderId == md.OrderId); if (mmd != null && mmd.StoreId != null) { if (mmd.StoreId == 11) { storeid = 11; md.RevFax = "E"; } if (mmd.Fee11 != null && mmd.Fee11 > 0) { ygyf = mmd.Fee11.Value; } if (ygyf == 0 && mmd.Fee12 != null && mmd.Fee12 > 0) ygyf = mmd.Fee12.Value; if (mmd.Fee12 != null && mmd.Fee12 > 0 && mmd.Fee12 < ygyf) { ygyf = mmd.Fee12.Value; } if (ygyf == 0 && mmd.Fee13 != null && mmd.Fee13 > 0) ygyf = mmd.Fee13.Value; if (mmd.Fee13 != null && mmd.Fee13 > 0 && mmd.Fee13 < ygyf) { ygyf = mmd.Fee13.Value; } if (ygyf == 0 && mmd.Fee14 != null && mmd.Fee14 > 0) ygyf = mmd.Fee14.Value; if (mmd.Fee14 != null && mmd.Fee14 > 0 && mmd.Fee14 < ygyf) { ygyf = mmd.Fee14.Value; } if (AddrType == "Residential" || AddrType == "RESIDENTIAL") { if (mmd.Fee11 > 0 && mmd.Fee11 < mmd.Fee13) { ygyf = mmd.Fee11.Value; } else if (mmd.Fee11 > 0 && mmd.Fee11 > mmd.Fee13) { ygyf = mmd.Fee13.Value; } } if (AddrType == "Commercial" || AddrType == "OFFICE") { if (mmd.Fee11 > 0 && mmd.Fee11 < mmd.Fee12) { ygyf = mmd.Fee11.Value; } else if (mmd.Fee12 > 0 && mmd.Fee11 > mmd.Fee12) { ygyf = mmd.Fee12.Value; } } if (twight >= 1120 && mmd.Fee12 > 0) ygyf = mmd.Fee12.Value; // if (ygyf > 0) // ygyf = ygyf * 1.1M; } } if (md.Fee6 != null && md.Fee6 > 0) { ygyf2 = md.Fee6.Value; } if (ygyf2 == 0 && md.Fee7 != null && md.Fee7 > 0) ygyf2 = md.Fee7.Value; if (md.Fee7 != null && md.Fee7 > 0 && md.Fee7 < ygyf2) { ygyf2 = md.Fee7.Value; } if (ygyf2 == 0 && md.Fee8 != null && md.Fee8 > 0) ygyf2 = md.Fee8.Value; if (md.Fee8 != null && md.Fee8 > 0 && md.Fee8 < ygyf2) { ygyf2 = md.Fee8.Value; } if (AddrType == "Residential" || AddrType == "RESIDENTIAL") { if (md.Fee6 > 0 && md.Fee6 < md.Fee8) { ygyf2 = md.Fee6.Value; } else if (md.Fee8 > 0 && md.Fee6 > md.Fee8) { ygyf2 = md.Fee8.Value; } } if (AddrType == "Commercial" || AddrType == "OFFICE") { if (md.Fee6 > 0 && md.Fee6 < md.Fee7) { ygyf2 = md.Fee6.Value; } else if (md.Fee7 > 0 && md.Fee6 > md.Fee7) { ygyf2 = md.Fee7.Value; } } if (twight >= 1120 && md.Fee7 > 0) ygyf2 = md.Fee7.Value; md.PostFee = new decimal?(PostFee); decimal ygyf0 = ygyf; if (ygyf == 0) ygyf0 = ygyf2; if (ygyf > 0 && ygyf <= ygyf2) ygyf0 = ygyf; else if (ygyf2 > 0 && ygyf2 < ygyf) ygyf0 = ygyf2; md.BoxFee = new decimal?(ygyf0); decimal LR = 0M; decimal YGLR = 0M; LR = TotalPrice - YJPrice - escrowFee - GoodsFee - PostFee - PostFeeYJ - TCFee - BackFactPrice - BackPostFee; YGLR = TotalPrice - YJPrice - escrowFee - YJGoodsFee - YGFeeRate - ygyf0 - YJTCFee - BackFactPrice - BackPostFee; md.LR = new decimal?(Convert.ToDecimal(LR.ToString("0.00"))); md.YGLR = new decimal?(Convert.ToDecimal(YGLR.ToString("0.00"))); } } } return model; } [WebMethod(EnableSession = true)] public string GetFedexFeeNo(List list) { PagesNew.Login(base.Session); GetFedexFeeNo2(list, 228); Thread.Sleep(3000); GetFedexFeeNo2(list, 237); return "重新计算成功"; } public string GetFedexFeeNo2(List list, int PostId) { PagesNew.Login(base.Session); // int companyId = Convert.ToInt32(base.Session["CompanyId"]); string ids = ""; if (list != null) { foreach (var md in list) { ids += md.OrderId + ","; } } var GoodsList = DataNew.GetFedexOrderGoodsList(ids.TrimEnd(',')); var OrderList = DataNew.GetFedexOrderList2(ids.TrimEnd(',')); if (OrderList == null || GoodsList == null) return "重新计算成功0单"; JC_ExpressService service = new JC_ExpressService(); JC_PostAddress address = new BaseService().GetAddressModel2(PostId); JC_ExpressPost expressModel = service.GetExpressModel(1, PostId); TradeManageNew.FedexRateNew rate = new FedexRateNew(); TradeManageNew.FedexRateNew.Key = expressModel.UserCode; TradeManageNew.FedexRateNew.Password = expressModel.CheckCode; TradeManageNew.FedexRateNew.AccountNumber = expressModel.client_id; TradeManageNew.FedexRateNew.MeterNumber = expressModel.client_secret; TradeManageNew.FedexRateNew.PayAccountNumber = expressModel.refresh_token; TradeManageNew.FedexRateNew.HubId = expressModel.Code; TradeManageNew.FedexRateNew.PostId = PostId; int Num = 0; foreach (var omd in OrderList) { var glist = GoodsList.FindAll(n => n.OrderId == omd.OrderId); if (glist == null) continue; decimal weight = 0M; decimal width = 0; decimal slong = 0; decimal height = 0; foreach (var goods in glist) { if (goods.Weight != null && goods.Weight > 0 && goods.GoodsNum != null) { weight += goods.Weight.Value * goods.GoodsNum.Value; } if (goods.Width2 == null || goods.Length2 == null || goods.Height2 == null || goods.Length2 <= 0 || goods.Width2 <= 0 || goods.Height2 <= 0) { weight = 0; } if (goods.Width2 > width) width = goods.Width2.Value; if (goods.Length2 > slong) slong = goods.Length2.Value; if (goods.Height2 > height) height = goods.Height2.Value; } if (weight == 0) continue; FedexFeeMdNew md = new FedexFeeMdNew { RevName = omd.RevName, RevPhone = omd.RevPhone }; if ((omd.RevPhone == null) || (omd.RevPhone == "")) { md.RevPhone = omd.RevMoblie; } md.OrderId = omd.OrderId; md.SendAddr = address.EnglishAddress; md.SendCountry = address.countycode; md.SendCity = address.city; md.SendProv = address.provincecode; md.SendPostCode = address.PostCode; if ((omd.RevAddr != null) && (omd.RevAddr != "")) { md.RevAddr = omd.RevAddr; } else { md.RevAddr = "street No 18"; } md.RevCity = omd.RevCity; if (omd.RevCity == null || omd.RevCity == "") { md.RevCity = omd.RevProvince; } if (omd.RevProvinceCode != null && omd.RevProvinceCode != "") { md.RevProv = omd.RevProvinceCode; } else if (omd.RevProvince != null && omd.RevProvince != "" && omd.RevProvince.Length > 2) { md.RevProv = omd.RevProvince.Substring(omd.RevProvince.Length - 2, 2); } else { md.RevProv = omd.RevProvince; } md.RevPostCode = omd.RevPostCode; md.RevCountry = omd.CountryCode; if (md.RevCountry == null || md.RevCountry == "") md.RevCountry = "US"; md.Width = Math.Ceiling(width).ToString(); md.Height = Math.Ceiling(height).ToString(); md.Lenght = Math.Ceiling(slong).ToString(); md.Weight = weight; // Thread.Sleep(1000); md.PostType = "SMART_POST"; string outError = ""; rate.GetFee(md, out outError); // Thread.Sleep(1000); md.PostType = "FEDEX_GROUND"; string outError2 = ""; rate.GetFee(md, out outError2); // Thread.Sleep(1000); md.PostType = "GROUND_HOME_DELIVERY"; string outError3 = ""; rate.GetFee(md, out outError3); if (outError == "" || outError2 == "" || outError3 == "") { Num++; } } return "重新计算成功" + Num + "单"; } #region 查询订单匹配货物 [WebMethod(EnableSession = true)] public List GetOrderGoodsListForHWC(int OrderId) { PagesNew.Login(this.Session); var obj = new DD_OrderData(); //int CompanyId = Convert.ToInt32(Session["CompanyId"]); var list = obj.GetOrderGoodsListNew(OrderId); if (list != null) { decimal USDRate = Convert.ToDecimal(6.5); var obj2 = new BaseService(); var mlist = obj2.GetMoneyList2(); var plist = DataNew.GetOrderGoodsPostionCodeHWC(OrderId); decimal GoodsFee = 0; if (plist != null && plist.Count > 0) { foreach (var md in list) { var opmd = mlist.Find(n => n.MCode == "USD" && n.PlatId == md.PlatId); if (opmd != null) USDRate = opmd.MRate.Value; var pmd = plist.Find(n => n.Id == md.Id); if (pmd != null) { md.PostionCode = pmd.PostionCode; md.Price = pmd.Price * md.GoodsNum.Value / USDRate; md.PostPrice = pmd.PostPrice * md.GoodsNum.Value / USDRate; md.HWCFee = pmd.HWCFee * md.GoodsNum.Value; GoodsFee += (pmd.Price.Value * md.GoodsNum.Value + pmd.PostPrice.Value * md.GoodsNum.Value) / USDRate + md.HWCFee.Value; } } if (list.Count > 0) list[0].GoodsCB = Convert.ToDecimal(GoodsFee.ToString("0.00")); } } return list; } #endregion #region 读取物流渠道 [WebMethod(EnableSession = true)] public List GetExpressPostList(int LogisticsId, int CompanyId) { PagesNew.Login(this.Session); BaseService obj = new BaseService(); var list = DataNew.GetExpressPostList(CompanyId, LogisticsId); return list; } #endregion #region 修改订单物流 [WebMethod(EnableSession = true)] public string ChangeOrderPostForHWC(int OrderId, int PostId, int CompanyId) { PagesNew.Login(this.Session); var md = new DT_TrackCode(); // int CompanyId = Convert.ToInt32(Session["CompanyId"]); var obj1 = new JC_ExpressService(); var md1 = DataNew.GetExpressModel(PostId); //if (md1 == null || md1.DefaultAddr == null || md1.DefaultAddr == 0) //{ // string Error = "该物流渠道没有设置过发货地址,请先到系统管理下面的物流快递处设置发货地址"; // return Error; //} string TrackCode = ""; var obj = new DD_OrderData(); var ordermd = obj.GetOrderModel(OrderId); string error = UpdateOrderPostForTM(md1, OrderId, md1.LogisticsId.Value, PostId, CompanyId, ordermd.PlatOrderCode, ordermd.JoinOrderCode, ordermd.CountryCode, out TrackCode); 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 (LogisticsId != 80) //{ // if (obj2.IsExpress2(CompanyId, PostId, CountryCode) <= 0) // { // ErrorInfo = PlatOrderCode + "的订单国家不支持该物流发送;"; // return ErrorInfo; // } //} if (ErrorInfo == "") obj.UpdateTrackPostForTM2(PostId, LogisticsId, OrderId); return ErrorInfo; } #endregion #region 读取sku货物 [WebMethod(EnableSession = true)] public List GetGoodsModelFromGoodsCodeHWC(int CompanyId, int TJ, string SKU) { PagesNew.Login(this.Session); var obj = new DD_OrderData(); //int CompanyId = Convert.ToInt32(Session["CompanyId"]); string GoodsCode = SKU.Trim(); string TypeCode = ""; if (TJ == 1 && GoodsCode.Contains("-") == true) { GoodsCode = SKU.Trim().Split('-')[0].Trim(); TypeCode = SKU.Trim().Split('-')[1].Trim(); } else if (TJ == 1 && GoodsCode.Contains(" ") == true) { GoodsCode = SKU.Trim().Split(' ')[0].Trim(); TypeCode = SKU.Trim().Split(' ')[1].Trim(); } var list = obj.GetGoodsModelFromGoodsCode(TJ, CompanyId, GoodsCode, TypeCode); //string jsonString = new JavaScriptSerializer().Serialize(list); return list;// jsonString; } #endregion #region 打印确定 [WebMethod(EnableSession = true)] public void GetOrderDonePrintForHWC2(int CompanyId, int state, List list, DateTime? InDate) { PagesNew.Login(this.Session); // int CompanyId = Convert.ToInt32(Session["CompanyId"]); int UserId = Convert.ToInt32(Session["UserId"]); //var CompanyModel = JC_CompanyService.GetModel(CompanyId); var obj = new DD_OrderData(); var obj1 = new HuoWuData(); string JoinOrderCodes = ""; string OrderIds = ""; foreach (var pmd in list) { if (pmd.JoinOrderCode != null && pmd.JoinOrderCode != "") { JoinOrderCodes += "'" + pmd.JoinOrderCode + "',"; } else { OrderIds += pmd.OrderId + ","; } } var printlist = new List(); if (JoinOrderCodes != "" || OrderIds != "") { if (state > -1) printlist = obj.GetPrintOrderList2(OrderIds.Trim(','), JoinOrderCodes.Trim(',')); else printlist = obj.GetPrintOrderList3(OrderIds.Trim(','), JoinOrderCodes.Trim(',')); } if (printlist != null) { foreach (var md in printlist) { if (md.PrintState == 0) { // var GoodsList = obj.GetOrderGoodsList(md.OrderId.Value); HW_GoodsOutRecord model = new HW_GoodsOutRecord(); model.OutCode = GetOutCode(); model.OutReason = "订单发货"; model.CompanyId = CompanyId; model.InDate = DateTime.Now; model.InUserId = UserId; model.IsDelete = 0; model.OrderId = md.OrderId; // int Num = 0; model.OutNum = md.GoodsNum; var OutId = DataNew.UpdateOrderPrintHWC(model); //生成出库记录 } } } foreach (var md in list) { DataNew.SaveTrackCodeScanHWC(md.OrderId.Value, InDate.Value, UserId); } } #endregion #region 打印确定 [WebMethod(EnableSession = true)] public void GetOrderDonePrintForHWC(int CompanyId, int state, List list) { PagesNew.Login(this.Session); // int CompanyId = Convert.ToInt32(Session["CompanyId"]); int UserId = Convert.ToInt32(Session["UserId"]); //var CompanyModel = JC_CompanyService.GetModel(CompanyId); var obj = new DD_OrderData(); var obj1 = new HuoWuData(); string JoinOrderCodes = ""; string OrderIds = ""; foreach (var pmd in list) { if (pmd.JoinOrderCode != null && pmd.JoinOrderCode != "") { JoinOrderCodes += "'" + pmd.JoinOrderCode + "',"; } else { OrderIds += pmd.OrderId + ","; } } var printlist = new List(); if (JoinOrderCodes != "" || OrderIds != "") { if (state > -1) printlist = obj.GetPrintOrderList2(OrderIds.Trim(','), JoinOrderCodes.Trim(',')); else printlist = obj.GetPrintOrderList3(OrderIds.Trim(','), JoinOrderCodes.Trim(',')); } if (printlist != null) { foreach (var md in printlist) { if (md.PrintState == 0) { // var GoodsList = obj.GetOrderGoodsList(md.OrderId.Value); HW_GoodsOutRecord model = new HW_GoodsOutRecord(); model.OutCode = GetOutCode(); model.OutReason = "订单发货"; model.CompanyId = CompanyId; model.InDate = DateTime.Now; model.InUserId = UserId; model.IsDelete = 0; model.OrderId = md.OrderId; // int Num = 0; model.OutNum = md.GoodsNum; var OutId = DataNew.UpdateOrderPrintHWC(model); //生成出库记录 //if (GoodsList != null) //{ // foreach (var gmd in GoodsList) // { // HW_GoodsOutCK ckmd = new HW_GoodsOutCK(); // ckmd.OutId = OutId; // ckmd.OutNum = gmd.GoodsNum; // ckmd.DetailId = gmd.DetailId; // int CKId = obj1.SaveGoodsOutDetailNew(ckmd); // obj1.UpdateGoodsOutId(gmd.Id.Value, CKId); // } //} //obj.UpdateOrderPrint(md.OrderId.Value);//修改打印状态 //obj.UpdateOrderGoodsForPrint(md.OrderId.Value);//修改库存 //else // obj.UpdateOrderPrint(md.OrderId.Value);//修改打印状态 // PagesNew.SaveLog(UserId, "订单打印", "标记打印", md.OrderId.Value); } } } } #endregion public string GetOutCode() { PagesNew.Login(this.Session); var obj = new CG_ChaseData(); int CompanyId = Convert.ToInt32(Session["CompanyId"]); Random r = new Random(); string a = r.Next(10000, 99999).ToString(); string Code = DateTime.Now.ToString("yyyyMMddhhmmss") + a; return Code; } #region 查询订单 [WebMethod(EnableSession = true)] public JsonModel> GetListOrderForTM2(int StoreId, int DeptId, int PlatType, int ShopId, int DateType, DateTime? SDate, DateTime? EDate, int TjType, string Name, int PrintState, int MateState, int MoneyState, int OutDays, int State, int IsSku, int IsError, int IsE, int IsDetail, int HBOrder, int IsSD, int SaleState, int IsBuy, int WLId, int PostId, int IsDH, int SFLY, int PageIndex, int PageSize, string Sort) { PagesNew.Login(this.Session); var obj = new DD_OrderData(); int CompanyId = Convert.ToInt32(Session["CompanyId"]); RefParameterCollection Param = new RefParameterCollection(); if (StoreId > 0) Param.Add("a.StoreId", "=", StoreId, DbType.Int32); if (IsBuy == 1) Param.Add("a.BuyDate", "is not", null, DbType.String); else if (IsBuy == 0) Param.Add("a.BuyDate", "is", null, DbType.String); Param.Add("a.CompanyId", "=", CompanyId, DbType.Int32); if (IsSD == 2) Param.Add("isnull(a.IsSDan,0)", ">", 1, DbType.Int32); else if (IsSD > -1) Param.Add("isnull(a.TrackState,0)", "=", IsSD, DbType.Int32); if (SaleState > 0) Param.Add("a.SaleState", "=", SaleState, DbType.Int32); if (WLId > 0) Param.Add("a.LogisticsId", "=", WLId, DbType.Int32); if (PostId > 0) Param.Add("a.Post", "=", PostId, DbType.Int32); if (DeptId > 0) Param.Add("c.DeptId", "=", DeptId, DbType.Int32); if (PlatType > 0) Param.Add("a.PlatId", "=", PlatType, DbType.Int32); if (ShopId > 0) Param.Add("a.ShopId", "=", ShopId, DbType.Int32); if (DateType == 1) { if (SDate != null) Param.Add("a.OrderDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.OrderDate", "<", EDate.Value.AddDays(1), DbType.DateTime); } else if (DateType == 2) { if (SDate != null) Param.Add("a.InDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.InDate", "<", EDate.Value.AddDays(1), DbType.DateTime); } else if (DateType == 3) { if (SDate != null) Param.Add("a.PrintDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.PrintDate", "<", EDate.Value.AddDays(1), DbType.DateTime); } else if (DateType == 4) { if (SDate != null) Param.Add("a.PostDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.PostDate", "<", EDate.Value.AddDays(1), DbType.DateTime); } else if (DateType == 5) { if (SDate != null) Param.Add("a.OrderOutDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.OrderOutDate", "<", EDate.Value.AddDays(1), DbType.DateTime); } if (OutDays > 0) { Param.Add("a.OrderOutDate", "<=", DateTime.Now.AddDays(OutDays), DbType.DateTime); Param.Add("a.OrderOutDate", ">=", DateTime.Now, DbType.DateTime); } if (MateState > -1) Param.Add("a.MateState", "=", MateState, DbType.Int32); if (MoneyState > -1) Param.Add("a.MoneyState", "=", MoneyState, DbType.Int32); if (PrintState > -1) Param.Add("a.PrintState", "=", PrintState, DbType.Int32); if (State == 3) Param.Add("a.State", "=", 2, DbType.Int32); else if (State == 4) Param.Add("a.State", "=", 3, DbType.Int32); else if (State == 5) { Param.Add("a.State", "=", 1, DbType.Int32); Param.Add("a.MoneyState", "=", 1, DbType.Int32); } else if (State == 1) { //Param.Add("a.State", "=", 2, DbType.Int32); Param.Add("a.PostState", "=", 1, DbType.Int32); } else if (State == 2) { Param.Add("a.State", "<", 3, DbType.Int32); Param.Add("a.PostState", "=", 2, DbType.Int32); } else if (State == 0) { //Param.Add("a.State", "=", 2, DbType.Int32); Param.Add("a.State", "=", 1, DbType.Int32); } else if (State == 8) { //Param.Add("a.State", "=", 2, DbType.Int32); Param.Add("a.State", "<", 3, DbType.Int32); Param.Add("a.PostState", "=", 3, DbType.Int32); } else Param.Add("a.State", ">", 0, DbType.Int32); if (HBOrder == 1) Param.Add("a.IsJoin", "=", 1, DbType.Int32); if (IsError == 1) { Param.Add("(a.SendAddr", ">", 0, DbType.Int32); Param.Add("a.IsLeaveWord", "=", 1, "or", ")", DbType.Int32); } if (IsE == 1) { Param.Add("a.PostState", "=", 2, DbType.Int32); } if (IsE == 0) { Param.Add("a.PostState", "<", 2, DbType.Int32); } string TCode = ""; if (Name != "") { Name = Name.Trim(); if (TjType == 1) { Param.Add("(a.PlatOrderCode", "like", Name, DbType.String); Param.Add("OrderCode", "like", Name, "or", DbType.String); Param.Add("a.JoinOrderCode", "like", Name, "or", ")", DbType.String); } else if (TjType == 2) { Param.Add("a.RevName", "like", Name, DbType.String); } else if (TjType == 3) { Param.Add("a.RevPhone", "like", Name, DbType.String); } else if (TjType == 4) { Param.Add("(a.RevCountry", "=", Name, DbType.String); Param.Add("a.CountryName", "=", Name, "or", DbType.String); Param.Add("a.CountryCode", "=", Name, "or", ")", DbType.String); } else if (TjType == 5) { Param.Add("a.RevPostCode", "=", Name, DbType.String); } else if (TjType == 6) { Param.Add("(a.RevAddr", "like", Name, DbType.String); Param.Add("a.RevProvince", "like", Name, "or", DbType.String); Param.Add("a.RevCity", "like", Name, "or", DbType.String); Param.Add("a.RevArea", "like", Name, "or", ")", DbType.String); } else if (TjType == 16) { Param.Add("a.RevProvince", "=", Name, DbType.String); } else if (TjType == 9) { Param.Add("(a.ErrorInfo", "like", Name, DbType.String); Param.Add("a.PostError", "like", Name, "or", ")", DbType.String); } else if (TjType == 10) { //Param.Add("dbo.getOrderTrackCode(a.OrderId,0)", "like", Name, DbType.String); TCode = Name; } else if (TjType == 11) { Param.Add("a.CustomID", "=", Name, DbType.String); } else if (TjType == 12) { Param.Add("a.RevMail", "=", Name, DbType.String); } } if (IsSku == 0) Param.Add("a.FPDate", "is", null, DbType.String); else if (IsSku == 1) Param.Add("a.FPDate", "is not", null, DbType.String); JsonModel> resultModel = new JsonModel>(); int RowCount = 0; //string Sort = "orderid desc"; string GoodsName = ""; string SKU = ""; if (TjType == 7 && Name != "") { GoodsName = Name; } else if (TjType == 8 && Name != "") { SKU = Name; } if (SFLY > 0) { if (SFLY == 1) { resultModel.DataSource = obj.GetListDT_OrderInfoForTM6(CompanyId, GoodsName.Trim(), SKU.Trim(), TCode, -1, IsDH, Param, PageIndex, PageSize, Sort, out RowCount); } if (SFLY == 2) { resultModel.DataSource = obj.GetListDT_OrderInfoForTM7(CompanyId, GoodsName.Trim(), SKU.Trim(), TCode, -1, IsDH, Param, PageIndex, PageSize, Sort, out RowCount); } } else { if (State == 0 || State == 2) resultModel.DataSource = obj.GetListDT_OrderInfoForTM1(CompanyId, GoodsName.Trim(), SKU.Trim(), TCode, -1, IsDH, Param, PageIndex, PageSize, Sort, out RowCount); else resultModel.DataSource = obj.GetListDT_OrderInfoForTM(CompanyId, GoodsName.Trim(), SKU.Trim(), TCode, -1, IsDH, Param, PageIndex, PageSize, Sort, out RowCount); } resultModel.RowCount = RowCount; string Ids = ""; if (resultModel.DataSource != null) { foreach (var md in resultModel.DataSource) { Ids += md.OrderId.ToString() + ","; } } if (Ids != "") { var errorlist = obj.GetErrorList(Ids.Trim(',')); if (errorlist != null && errorlist.Count > 0) { foreach (var md in resultModel.DataSource) { var emd = errorlist.Find(n => n.OrderId == md.OrderId); if (emd != null) { md.ErrorInfo = emd.ErrorInfo; } } } } if (IsDetail == 1 && resultModel.DataSource != null) { if (Ids != "") { var list1 = obj.GetOrderGoodsList(Ids.Trim(',')); var listTrack = obj.GetTrackCodeApplyList(Ids.Trim(',')); if (list1 != null) { foreach (var md in resultModel.DataSource) { var list2 = list1.FindAll(n => n.OrderId == md.OrderId); if (list2 != null) { md.GoodsList = list2; } } } if (listTrack != null) { foreach (var md in resultModel.DataSource) { var list3 = new List(); if (md.JoinOrderCode != null && md.JoinOrderCode != "") list3 = listTrack.FindAll(n => n.OrderCode == md.JoinOrderCode); else list3 = listTrack.FindAll(n => n.OrderId == md.OrderId); if (list3 != null && list3.Count > 0) { string trackinfo = ""; string TrackCode = ""; foreach (var md1 in list3) { string blank = ""; if (md1.TrackType == 3) blank = "[空包裹]"; if (md1.Weight != null) { string dd = ""; if (md1.ScanDate != null) dd = "扫描时间:" + md1.ScanDate.Value.ToString("yyyy-MM-dd HH:mm"); trackinfo += md1.TrackCode + blank + "重量" + md1.Weight.ToString() + "g" + dd + "
"; } else trackinfo += md1.TrackCode + blank + "
"; if (TrackCode == "") TrackCode = md1.TrackCode; } md.TrackInfo = trackinfo; md.TrackCode = TrackCode; } } } } } return resultModel; } #endregion #region 查询订单加零星 [WebMethod(EnableSession = true)] public JsonModel> GetListOrderForTM_LX(int lxstate, int StoreId, int DeptId, int PlatType, int ShopId, int DateType, DateTime? SDate, DateTime? EDate, int TjType, string Name, int PrintState, int MateState, int MoneyState, int OutDays, int State, int IsSku, int IsError, int IsE, int IsDetail, int HBOrder, int IsSD, int SaleState, int IsBuy, int WLId, int PostId, int IsDH, int SFLY, int PageIndex, int PageSize, string Sort) { PagesNew.Login(this.Session); var obj = new DD_OrderData(); int CompanyId = Convert.ToInt32(Session["CompanyId"]); RefParameterCollection Param = new RefParameterCollection(); if(lxstate>=0) Param.Add("isnull(a.IsLX,0)", "=", lxstate, DbType.Int32); if (StoreId > 0) Param.Add("a.StoreId", "=", StoreId, DbType.Int32); if (IsBuy == 1) Param.Add("a.BuyDate", "is not", null, DbType.String); else if (IsBuy == 0) Param.Add("a.BuyDate", "is", null, DbType.String); Param.Add("a.CompanyId", "=", CompanyId, DbType.Int32); if (IsSD == 2) Param.Add("isnull(a.IsSDan,0)", ">", 1, DbType.Int32); else if (IsSD > -1) Param.Add("isnull(a.TrackState,0)", "=", IsSD, DbType.Int32); if (SaleState > 0) Param.Add("a.SaleState", "=", SaleState, DbType.Int32); if (WLId > 0) Param.Add("a.LogisticsId", "=", WLId, DbType.Int32); if (PostId > 0) Param.Add("a.Post", "=", PostId, DbType.Int32); if (DeptId > 0) Param.Add("c.DeptId", "=", DeptId, DbType.Int32); if (PlatType > 0) Param.Add("a.PlatId", "=", PlatType, DbType.Int32); if (ShopId > 0) Param.Add("a.ShopId", "=", ShopId, DbType.Int32); if (DateType == 1) { if (SDate != null) Param.Add("a.OrderDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.OrderDate", "<", EDate.Value.AddDays(1), DbType.DateTime); } else if (DateType == 2) { if (SDate != null) Param.Add("a.InDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.InDate", "<", EDate.Value.AddDays(1), DbType.DateTime); } else if (DateType == 3) { if (SDate != null) Param.Add("a.PrintDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.PrintDate", "<", EDate.Value.AddDays(1), DbType.DateTime); } else if (DateType == 4) { if (SDate != null) Param.Add("a.PostDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.PostDate", "<", EDate.Value.AddDays(1), DbType.DateTime); } else if (DateType == 5) { if (SDate != null) Param.Add("a.OrderOutDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.OrderOutDate", "<", EDate.Value.AddDays(1), DbType.DateTime); } if (OutDays > 0) { Param.Add("a.OrderOutDate", "<=", DateTime.Now.AddDays(OutDays), DbType.DateTime); Param.Add("a.OrderOutDate", ">=", DateTime.Now, DbType.DateTime); } if (MateState > -1) Param.Add("a.MateState", "=", MateState, DbType.Int32); if (MoneyState > -1) Param.Add("a.MoneyState", "=", MoneyState, DbType.Int32); if (PrintState > -1) Param.Add("a.PrintState", "=", PrintState, DbType.Int32); if (State == 3) Param.Add("a.State", "=", 2, DbType.Int32); else if (State == 4) Param.Add("a.State", "=", 3, DbType.Int32); else if (State == 5) { Param.Add("a.State", "=", 1, DbType.Int32); Param.Add("a.MoneyState", "=", 1, DbType.Int32); } else if (State == 1) { //Param.Add("a.State", "=", 2, DbType.Int32); Param.Add("a.PostState", "=", 1, DbType.Int32); } else if (State == 2) { Param.Add("a.State", "<", 3, DbType.Int32); Param.Add("a.PostState", "=", 2, DbType.Int32); } else if (State == 0) { //Param.Add("a.State", "=", 2, DbType.Int32); Param.Add("a.State", "=", 1, DbType.Int32); } else if (State == 8) { //Param.Add("a.State", "=", 2, DbType.Int32); Param.Add("a.State", "<", 3, DbType.Int32); Param.Add("a.PostState", "=", 3, DbType.Int32); } else Param.Add("a.State", ">", 0, DbType.Int32); if (HBOrder == 1) Param.Add("a.IsJoin", "=", 1, DbType.Int32); if (IsError == 1) { Param.Add("(a.SendAddr", ">", 0, DbType.Int32); Param.Add("a.IsLeaveWord", "=", 1, "or", ")", DbType.Int32); } if (IsE == 1) { Param.Add("a.PostState", "=", 2, DbType.Int32); } if (IsE == 0) { Param.Add("a.PostState", "<", 2, DbType.Int32); } string TCode = ""; if (Name != "") { Name = Name.Trim(); if (TjType == 1) { Param.Add("(a.PlatOrderCode", "like", Name, DbType.String); Param.Add("OrderCode", "like", Name, "or", DbType.String); Param.Add("a.JoinOrderCode", "like", Name, "or", ")", DbType.String); } else if (TjType == 2) { Param.Add("a.RevName", "like", Name, DbType.String); } else if (TjType == 3) { Param.Add("a.RevPhone", "like", Name, DbType.String); } else if (TjType == 4) { Param.Add("(a.RevCountry", "=", Name, DbType.String); Param.Add("a.CountryName", "=", Name, "or", DbType.String); Param.Add("a.CountryCode", "=", Name, "or", ")", DbType.String); } else if (TjType == 5) { Param.Add("a.RevPostCode", "=", Name, DbType.String); } else if (TjType == 6) { Param.Add("(a.RevAddr", "like", Name, DbType.String); Param.Add("a.RevProvince", "like", Name, "or", DbType.String); Param.Add("a.RevCity", "like", Name, "or", DbType.String); Param.Add("a.RevArea", "like", Name, "or", ")", DbType.String); } else if (TjType == 16) { Param.Add("a.RevProvince", "=", Name, DbType.String); } else if (TjType == 9) { Param.Add("(a.ErrorInfo", "like", Name, DbType.String); Param.Add("a.PostError", "like", Name, "or", ")", DbType.String); } else if (TjType == 10) { //Param.Add("dbo.getOrderTrackCode(a.OrderId,0)", "like", Name, DbType.String); TCode = Name; } else if (TjType == 11) { Param.Add("a.CustomID", "=", Name, DbType.String); } else if (TjType == 12) { Param.Add("a.RevMail", "=", Name, DbType.String); } } if (IsSku == 0) Param.Add("a.FPDate", "is", null, DbType.String); else if (IsSku == 1) Param.Add("a.FPDate", "is not", null, DbType.String); JsonModel> resultModel = new JsonModel>(); int RowCount = 0; //string Sort = "orderid desc"; string GoodsName = ""; string SKU = ""; if (TjType == 7 && Name != "") { GoodsName = Name; } else if (TjType == 8 && Name != "") { SKU = Name; } if (SFLY > 0) { if (SFLY == 1) { resultModel.DataSource = obj.GetListDT_OrderInfoForTM6(CompanyId, GoodsName.Trim(), SKU.Trim(), TCode, -1, IsDH, Param, PageIndex, PageSize, Sort, out RowCount); } if (SFLY == 2) { resultModel.DataSource = obj.GetListDT_OrderInfoForTM7(CompanyId, GoodsName.Trim(), SKU.Trim(), TCode, -1, IsDH, Param, PageIndex, PageSize, Sort, out RowCount); } } else { if (State == 0 || State == 2) resultModel.DataSource = DataNew.GetListDT_OrderInfoForTM_LX1(CompanyId, GoodsName.Trim(), SKU.Trim(), TCode, -1, IsDH, Param, PageIndex, PageSize, Sort, out RowCount); else resultModel.DataSource = DataNew.GetListDT_OrderInfoForTM_LX(CompanyId, GoodsName.Trim(), SKU.Trim(), TCode, -1, IsDH, Param, PageIndex, PageSize, Sort, out RowCount); } resultModel.RowCount = RowCount; string Ids = ""; if (resultModel.DataSource != null) { foreach (var md in resultModel.DataSource) { Ids += md.OrderId.ToString() + ","; } } if (Ids != "") { var errorlist = obj.GetErrorList(Ids.Trim(',')); if (errorlist != null && errorlist.Count > 0) { foreach (var md in resultModel.DataSource) { var emd = errorlist.Find(n => n.OrderId == md.OrderId); if (emd != null) { md.ErrorInfo = emd.ErrorInfo; } } } } if (IsDetail == 1 && resultModel.DataSource != null) { if (Ids != "") { var list1 = obj.GetOrderGoodsList(Ids.Trim(',')); var listTrack = obj.GetTrackCodeApplyList(Ids.Trim(',')); if (list1 != null) { foreach (var md in resultModel.DataSource) { var list2 = list1.FindAll(n => n.OrderId == md.OrderId); if (list2 != null) { md.GoodsList = list2; } } } if (listTrack != null) { foreach (var md in resultModel.DataSource) { var list3 = new List(); if (md.JoinOrderCode != null && md.JoinOrderCode != "") list3 = listTrack.FindAll(n => n.OrderCode == md.JoinOrderCode); else list3 = listTrack.FindAll(n => n.OrderId == md.OrderId); if (list3 != null && list3.Count > 0) { string trackinfo = ""; string TrackCode = ""; foreach (var md1 in list3) { string blank = ""; if (md1.TrackType == 3) blank = "[空包裹]"; if (md1.Weight != null) { string dd = ""; if (md1.ScanDate != null) dd = "扫描时间:" + md1.ScanDate.Value.ToString("yyyy-MM-dd HH:mm"); trackinfo += md1.TrackCode + blank + "重量" + md1.Weight.ToString() + "g" + dd + "
"; } else trackinfo += md1.TrackCode + blank + "
"; if (TrackCode == "") TrackCode = md1.TrackCode; } md.TrackInfo = trackinfo; md.TrackCode = TrackCode; } } } } } return resultModel; } #endregion #region 导出订单 [WebMethod(EnableSession = true)] public string GetListOrderPrintForExcel3(int PlatType, int IsWeight, int ShopId, int DateType, DateTime? SDate, DateTime? EDate, int OutDays, int TjType, string Name, int PrintState, int State, int IsSku, int IsError, int IsDetail, int HBOrder, int PostId, int IsAddr, int IsFP, string KWCode, string GoodsInfo, int TrackState, int FHState, int GM, int SNum, int ENum, int PageIndex, int PageSize,int StoreId, String Sort) { PagesNew.Login(this.Session); var obj = new DD_OrderData(); int CompanyId = Convert.ToInt32(Session["CompanyId"]); RefParameterCollection Param = new RefParameterCollection(); if (IsFP > -1) Param.Add("isnull(a.BillPrint,0)", "=", IsFP, DbType.Int32); Param.Add("a.CompanyId", "=", CompanyId, DbType.Int32); Param.Add("a.MateState", "=", 2, DbType.Int32); if (StoreId > 0) Param.Add("b.StoreId", "=", StoreId, DbType.Int32); if (PlatType > 0) Param.Add("a.PlatId", "=", PlatType, DbType.Int32); if (ShopId > 0) Param.Add("a.ShopId", "=", ShopId, DbType.Int32); if (TrackState == 1) { Param.Add("b.TrackState", ">", 0, DbType.Int32); if (PostId == 0) Param.Add("b.Post", ">", 0, DbType.Int32); } else if (TrackState == 0) { Param.Add("b.TrackState", "=", 0, DbType.Int32); } if (DateType == 1) { if (SDate != null) Param.Add("a.OrderDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.OrderDate", "<=", EDate, DbType.DateTime); } else if (DateType == 2) { if (SDate != null) Param.Add("a.InDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.InDate", "<=", EDate, DbType.DateTime); } else if (DateType == 3) { if (SDate != null) Param.Add("a.PrintDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.PrintDate", "<=", EDate, DbType.DateTime); } else if (DateType == 4) { if (SDate != null) Param.Add("a.PostDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.PostDate", "<=", EDate, DbType.DateTime); } else if (DateType == 5) { if (SDate != null) Param.Add("a.OrderOutDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.OrderOutDate", "<=", EDate, DbType.DateTime); } if (OutDays > 0) { Param.Add("a.OrderOutDate", "<=", DateTime.Today.AddDays(OutDays), DbType.DateTime); } if (PrintState == -1 && FHState > -1) { Param.Add("a.poststate", "=", FHState, DbType.Int32); if (IsError == 1) { Param.Add("isnull(b.ErrorInfo,'')", "<>", "", DbType.String); } } else { if (IsError == 1) { Param.Add("(a.PostState", "=", 2, DbType.Int32); Param.Add("isnull(b.ErrorInfo,'')", "<>", "", "or", ")", DbType.String); } else Param.Add("a.PostState", "<", 2, DbType.Int32); } if (PrintState > -1) Param.Add("a.PrintState", "=", PrintState, DbType.Int32); if (PrintState > -1) Param.Add("a.State", "=", 1, DbType.Int32); else { Param.Add("a.State", ">", 0, DbType.Int32); Param.Add("a.State", "<", 3, DbType.Int32); //Param.Add("b.RevPhone", "is", null, "or",")",DbType.String); } if (PostId > 0) Param.Add("b.Post", "=", PostId, DbType.Int32); if (HBOrder == 1) Param.Add("a.IsJoin", "=", 1, DbType.Int32); //if (IsError == 1) //{ // Param.Add("(b.SendAddr", ">", 0, DbType.Int32); // Param.Add("b.IsLeaveWord", "=", 1, "or", ")", DbType.Int32); //} if (IsAddr > -1) { Param.Add("b.SendAddr", "=", IsAddr, DbType.Int32); } string TCode = ""; if (Name != "") { Name = Name.Trim(); if (TjType == 1) { Param.Add("(a.PlatOrderCode", "=", Name, DbType.String); Param.Add("a.JoinOrderCode", "=", Name, "or", ")", DbType.String); } else if (TjType == 2) { Param.Add("b.RevName", "like", Name, DbType.String); } else if (TjType == 3) { Param.Add("b.RevPhone", "like", Name, DbType.String); } else if (TjType == 4) { Param.Add("(b.RevCountry", "=", Name, DbType.String); Param.Add("b.CountryName", "=", Name, "or", DbType.String); Param.Add("b.CountryCode", "=", Name, "or", ")", DbType.String); } else if (TjType == 5) { Param.Add("b.RevPostCode", "=", Name, DbType.String); } else if (TjType == 6) { Param.Add("(b.RevAddr", "like", Name, DbType.String); Param.Add("b.RevProvince", "like", Name, "or", DbType.String); Param.Add("b.RevCity", "like", Name, "or", DbType.String); Param.Add("b.RevArea", "like", Name, "or", ")", DbType.String); } else if (TjType == 9) { Param.Add("(b.ErrorInfo", "like", Name, DbType.String); Param.Add("b.PostError", "like", Name, "or", ")", DbType.String); } else if (TjType == 10) { // Param.Add("b.TrackCode", "like", Name, DbType.String); TCode = Name; } } //if (IsError == 2) //{ // Param.Add("(a.SendAddr", ">", 0, DbType.Int32); // Param.Add("a.IsLeaveWord", "=", 1, "or", ")", DbType.Int32); //} if (IsWeight == 2) { Param.Add("isnull(a.IsSpare,0)", "=", 1, DbType.Int32); } else if (IsWeight == 1) { Param.Add("isnull(a.IsSpare,0)", "=", 0, DbType.Int32); } //if (IsSku == 0) // Param.Add("a.FPDate", "is", null, DbType.String); //else if (IsSku == 1) // Param.Add("a.FPDate", "is not", null, DbType.String); //Param.Add("a.OrderDate", ">=", 0, DbType.Int32); JsonModel> resultModel = new JsonModel>(); int RowCount = 0; //string Sort = "orderid desc"; //if (PrintState == 0) // Sort = "orderid"; string GoodsName = ""; string Code = ""; if (GoodsInfo != "") { GoodsName = GoodsInfo.Trim(); if (GoodsInfo.Trim().Contains(' ')) { GoodsName = GoodsInfo.Trim().Split(' ')[0].Trim(); Code = GoodsInfo.Trim().Split(' ')[1].Trim(); } } //else // if (TjType == 8 && Name != "") // { // SKU = Name; // } List orderlist = new List(); List ordertemp = new List(); if (PrintState > -1) ordertemp = DataNew.GetListDT_PrintOrderInfoForTM2(CompanyId, TCode, GoodsName, 0, Code, KWCode, IsSku, GM, PrintState, Param, PageIndex, PageSize, Sort, out RowCount); else ordertemp = obj.GetListDT_PrintOrderInfoForTM(CompanyId, TCode, GoodsName, 0, Code, KWCode, IsSku, Param, PageIndex, PageSize, Sort, out RowCount); string Ids = ""; if (orderlist != null) { foreach (var md in orderlist) { Ids += md.OrderId.ToString() + ","; } } if (ordertemp != null) { if (Ids != "") { var list1 = DataNew.GetOrderGoodsPostionList(Ids.Trim(',')); if (list1 != null) { foreach (var md in ordertemp) { md.OrderLevel = 0; md.OrderName = ""; md.GoodsCode = ""; var list2 = list1.FindAll(n => n.OrderId == md.OrderId); if (list2 != null) { md.GoodsList = list2; md.IsBlank = 0; if (list2.Count > 0) { md.OrderLevel = list2[0].LockNum; md.OrderName = list2[0].PostionCode; md.GoodsCode = list2[0].GoodsCode; } } } } } } List orderList2 = new List(); // if (PostionCode == "" || PostionCode2 != "") // orderList2 = ordertemp.OrderBy(s => s.OrderLevel).ThenBy(s => s.OrderName).ThenBy(s => s.GoodsCode).ToList(); // else orderList2 = ordertemp.OrderBy(s => s.OrderLevel).OrderBy(s => s.OrderName).ThenBy(s => s.GoodsCode).ThenByDescending(s => s.GoodsNum).ToList(); string Ids2 = ""; if (orderList2 != null) { foreach (var md in orderList2) { Ids2 += md.OrderId.ToString() + ","; } } if (Ids2 == "") return ""; var GoodsList = DataNew.GetOrderGoodsInfos(Ids2.TrimEnd(',')); //order # country Name Address 1 City State Zip TEL SKU QTY Weight(oz) W(inch) L D Service Type Dept Note DataTable tb = new DataTable(); tb.Columns.Add("ordercode", Type.GetType("System.String")); tb.Columns.Add("country", Type.GetType("System.String")); tb.Columns.Add("Name", Type.GetType("System.String")); tb.Columns.Add("Address", Type.GetType("System.String")); tb.Columns.Add("City", Type.GetType("System.String")); tb.Columns.Add("State", Type.GetType("System.String")); tb.Columns.Add("Zip", Type.GetType("System.String")); tb.Columns.Add("TEL", Type.GetType("System.String")); tb.Columns.Add("SKU", Type.GetType("System.String")); tb.Columns.Add("GoodsCode2", Type.GetType("System.String")); tb.Columns.Add("QTY", Type.GetType("System.String")); tb.Columns.Add("Weight", Type.GetType("System.String")); tb.Columns.Add("W", Type.GetType("System.String")); tb.Columns.Add("L", Type.GetType("System.String")); tb.Columns.Add("D", Type.GetType("System.String")); tb.Columns.Add("Service", Type.GetType("System.String")); tb.Columns.Add("Note", Type.GetType("System.String")); if (orderList2 != null) { foreach (var md in orderList2) { DataRow row = tb.NewRow(); row["ordercode"] = md.PlatOrderCode; row["country"] = md.RevCountry; row["Name"] = md.RevName; row["Address"] = md.RevAddr; row["City"] = md.RevCity; row["State"] = md.RevProvince; row["Zip"] = md.RevPostCode; if (md.RevPhone != null && md.RevPhone != "") row["TEL"] = md.RevPhone; else if (md.RevMoblie != null && md.RevMoblie != "") row["TEL"] = md.RevMoblie; string ginfo = ""; decimal weight = 0; decimal Long = 0; decimal Width = 0; decimal Height = 0; string ginfo2 = ""; int Num = 0; if (GoodsList != null) { var dlist = GoodsList.FindAll(n => n.OrderId == md.OrderId); if (dlist != null) { foreach (var gmd in dlist) { Num += gmd.GoodsNum.Value; ginfo += gmd.GoodsNum + "x" + gmd.OldTypeDesc + ","; if(gmd.GoodsOldCode!=null&&gmd.GoodsOldCode!="") ginfo2 += gmd.GoodsNum + "x" + gmd.GoodsOldCode + ","; else ginfo2 += gmd.GoodsNum + "x" + gmd.OldTypeDesc + ","; if (gmd.Weight != null) weight += gmd.Weight.Value * gmd.GoodsNum.Value; if (gmd.Long2 != null) { if (gmd.Long2 > Long) Long = gmd.Long2.Value; } else if (gmd.Long != null) { if (gmd.Long.Value * Convert.ToDecimal(0.3937008) > Long) Long = gmd.Long.Value * Convert.ToDecimal(0.3937008); } if (gmd.Width2 != null) { if (gmd.Width2 > Width) Width = gmd.Width2.Value; } else if (gmd.Width != null) { if (gmd.Width.Value * Convert.ToDecimal(0.3937008) > Width) Width = gmd.Width.Value * Convert.ToDecimal(0.3937008); } if (gmd.Height2 != null) { if (gmd.Height2 > Height) Height = gmd.Height2.Value; } else if (gmd.Height != null) { if (gmd.Height.Value * Convert.ToDecimal(0.3937008) > Height) Height = gmd.Height.Value * Convert.ToDecimal(0.3937008); } } row["SKU"] = ginfo.TrimEnd(','); row["GoodsCode2"] = ginfo2.TrimEnd(','); } } row["QTY"] = Num.ToString(); row["Weight"] = weight.ToString("0.00"); row["W"] = Width.ToString("0.00"); row["L"] = Long.ToString("0.00"); row["D"] = Height.ToString("0.00"); tb.Rows.Add(row); } } // country Name Address 1 City State Zip TEL SKU QTY Weight(oz) W(inch) L D Service Type Dept Note TableColumnCollection listColumns = new TableColumnCollection(); listColumns.Add("ordercode", "order #", DbType.String, ""); listColumns.Add("country", "country", DbType.String, ""); listColumns.Add("Name", "Name", DbType.String, ""); listColumns.Add("Address", "Address 1", DbType.String, ""); listColumns.Add("City", "City", DbType.String, ""); listColumns.Add("State", "State", DbType.String, ""); listColumns.Add("Zip", "Zip", DbType.String, ""); listColumns.Add("TEL", "TEL", DbType.String, ""); listColumns.Add("SKU", "SKU", DbType.String, ""); listColumns.Add("GoodsCode2", "GoodsCode2", DbType.String, ""); listColumns.Add("QTY", "QTY", DbType.String, ""); listColumns.Add("Weight", "Weight(oz)", DbType.String, ""); listColumns.Add("W", "W(inch)", DbType.String, ""); listColumns.Add("L", "L", DbType.String, ""); listColumns.Add("D", "D", DbType.String, ""); listColumns.Add("Service", "Service Type", DbType.String, ""); listColumns.Add("Note", "Dept Note", DbType.String, ""); MicrosoftExcel obj2 = new MicrosoftExcel(); return obj2.Export(tb, listColumns); } #endregion #region 导出订单 [WebMethod(EnableSession = true)] public string GetListOrderPrintForExcelXZ(string oids,int PageIndex, int PageSize, String Sort) { PagesNew.Login(this.Session); var obj = new DD_OrderData(); int CompanyId = Convert.ToInt32(Session["CompanyId"]); RefParameterCollection Param = new RefParameterCollection(); Param.Add("a.orderid", "in", oids.TrimEnd(','), DbType.String); JsonModel> resultModel = new JsonModel>(); int RowCount = 0; //string Sort = "orderid desc"; //if (PrintState == 0) // Sort = "orderid"; string GoodsName = ""; string Code = ""; List orderlist = new List(); List ordertemp = new List(); ordertemp = obj.GetListDT_PrintOrderInfoForTM(CompanyId, "", GoodsName, 0, Code, "", 0, Param, PageIndex, PageSize, Sort, out RowCount); string Ids = ""; if (orderlist != null) { foreach (var md in orderlist) { Ids += md.OrderId.ToString() + ","; } } if (ordertemp != null) { if (Ids != "") { var list1 = DataNew.GetOrderGoodsPostionList(Ids.Trim(',')); if (list1 != null) { foreach (var md in ordertemp) { md.OrderLevel = 0; md.OrderName = ""; md.GoodsCode = ""; var list2 = list1.FindAll(n => n.OrderId == md.OrderId); if (list2 != null) { md.GoodsList = list2; md.IsBlank = 0; if (list2.Count > 0) { md.OrderLevel = list2[0].LockNum; md.OrderName = list2[0].PostionCode; md.GoodsCode = list2[0].GoodsCode; } } } } } } List orderList2 = new List(); // if (PostionCode == "" || PostionCode2 != "") // orderList2 = ordertemp.OrderBy(s => s.OrderLevel).ThenBy(s => s.OrderName).ThenBy(s => s.GoodsCode).ToList(); // else orderList2 = ordertemp.OrderBy(s => s.OrderLevel).OrderBy(s => s.OrderName).ThenBy(s => s.GoodsCode).ThenByDescending(s => s.GoodsNum).ToList(); string Ids2 = ""; if (orderList2 != null) { foreach (var md in orderList2) { Ids2 += md.OrderId.ToString() + ","; } } if (Ids2 == "") return ""; var GoodsList = DataNew.GetOrderGoodsInfos(Ids2.TrimEnd(',')); //order # country Name Address 1 City State Zip TEL SKU QTY Weight(oz) W(inch) L D Service Type Dept Note DataTable tb = new DataTable(); tb.Columns.Add("ordercode", Type.GetType("System.String")); tb.Columns.Add("country", Type.GetType("System.String")); tb.Columns.Add("Name", Type.GetType("System.String")); tb.Columns.Add("Address", Type.GetType("System.String")); tb.Columns.Add("City", Type.GetType("System.String")); tb.Columns.Add("State", Type.GetType("System.String")); tb.Columns.Add("Zip", Type.GetType("System.String")); tb.Columns.Add("TEL", Type.GetType("System.String")); tb.Columns.Add("SKU", Type.GetType("System.String")); tb.Columns.Add("GoodsCode2", Type.GetType("System.String")); tb.Columns.Add("QTY", Type.GetType("System.String")); tb.Columns.Add("Weight", Type.GetType("System.String")); tb.Columns.Add("W", Type.GetType("System.String")); tb.Columns.Add("L", Type.GetType("System.String")); tb.Columns.Add("D", Type.GetType("System.String")); tb.Columns.Add("Service", Type.GetType("System.String")); tb.Columns.Add("Note", Type.GetType("System.String")); if (orderList2 != null) { foreach (var md in orderList2) { DataRow row = tb.NewRow(); row["ordercode"] = md.PlatOrderCode; row["country"] = md.RevCountry; row["Name"] = md.RevName; row["Address"] = md.RevAddr; row["City"] = md.RevCity; row["State"] = md.RevProvince; row["Zip"] = md.RevPostCode; if (md.RevPhone != null && md.RevPhone != "") row["TEL"] = md.RevPhone; else if (md.RevMoblie != null && md.RevMoblie != "") row["TEL"] = md.RevMoblie; string ginfo = ""; decimal weight = 0; decimal Long = 0; decimal Width = 0; decimal Height = 0; string ginfo2 = ""; int Num = 0; if (GoodsList != null) { var dlist = GoodsList.FindAll(n => n.OrderId == md.OrderId); if (dlist != null) { foreach (var gmd in dlist) { Num += gmd.GoodsNum.Value; ginfo += gmd.GoodsNum + "x" + gmd.OldTypeDesc + ","; if (gmd.GoodsOldCode != null && gmd.GoodsOldCode != "") ginfo2 += gmd.GoodsNum + "x" + gmd.GoodsOldCode + ","; else ginfo2 += gmd.GoodsNum + "x" + gmd.OldTypeDesc + ","; if (gmd.Weight != null) weight += gmd.Weight.Value * gmd.GoodsNum.Value; if (gmd.Long2 != null) { if (gmd.Long2 > Long) Long = gmd.Long2.Value; } else if (gmd.Long != null) { if (gmd.Long.Value * Convert.ToDecimal(0.3937008) > Long) Long = gmd.Long.Value * Convert.ToDecimal(0.3937008); } if (gmd.Width2 != null) { if (gmd.Width2 > Width) Width = gmd.Width2.Value; } else if (gmd.Width != null) { if (gmd.Width.Value * Convert.ToDecimal(0.3937008) > Width) Width = gmd.Width.Value * Convert.ToDecimal(0.3937008); } if (gmd.Height2 != null) { if (gmd.Height2 > Height) Height = gmd.Height2.Value; } else if (gmd.Height != null) { if (gmd.Height.Value * Convert.ToDecimal(0.3937008) > Height) Height = gmd.Height.Value * Convert.ToDecimal(0.3937008); } } row["SKU"] = ginfo.TrimEnd(','); row["GoodsCode2"] = ginfo2.TrimEnd(','); } } row["QTY"] = Num.ToString(); row["Weight"] = weight.ToString("0.00"); row["W"] = Width.ToString("0.00"); row["L"] = Long.ToString("0.00"); row["D"] = Height.ToString("0.00"); tb.Rows.Add(row); } } // country Name Address 1 City State Zip TEL SKU QTY Weight(oz) W(inch) L D Service Type Dept Note TableColumnCollection listColumns = new TableColumnCollection(); listColumns.Add("ordercode", "order #", DbType.String, ""); listColumns.Add("country", "country", DbType.String, ""); listColumns.Add("Name", "Name", DbType.String, ""); listColumns.Add("Address", "Address 1", DbType.String, ""); listColumns.Add("City", "City", DbType.String, ""); listColumns.Add("State", "State", DbType.String, ""); listColumns.Add("Zip", "Zip", DbType.String, ""); listColumns.Add("TEL", "TEL", DbType.String, ""); listColumns.Add("SKU", "SKU", DbType.String, ""); listColumns.Add("GoodsCode2", "GoodsCode2", DbType.String, ""); listColumns.Add("QTY", "QTY", DbType.String, ""); listColumns.Add("Weight", "Weight(oz)", DbType.String, ""); listColumns.Add("W", "W(inch)", DbType.String, ""); listColumns.Add("L", "L", DbType.String, ""); listColumns.Add("D", "D", DbType.String, ""); listColumns.Add("Service", "Service Type", DbType.String, ""); listColumns.Add("Note", "Dept Note", DbType.String, ""); MicrosoftExcel obj2 = new MicrosoftExcel(); return obj2.Export(tb, listColumns); } #endregion #region 全部订单锁定匹配货物 [WebMethod(EnableSession = true)] public string AllOrderGoodsLockForTM6(int IsError, int StoreId, int StoreId2) { PagesNew.Login(this.Session); var obj = new DD_OrderData(); int Num = 0; int CompanyId = Convert.ToInt32(Session["CompanyId"]); int UserId = Convert.ToInt32(Session["UserId"]); bool bk = BaseService.SyncLock(CompanyId, 2, UserId, DateTime.Now); if (bk == false) return "当前有其他人正在操作库存匹配,为保证库存数据准确您暂时无法尝试此操作"; try { string Sort = "a.OrderLevel desc,a.OrderDate"; obj.SetStore();//仓库调整 var orderlist = obj.GetLockOrderListForTM4(CompanyId, IsError, StoreId, Sort); var list = obj.GetLockOrderGoodsForTM4(CompanyId, StoreId, IsError); var KClist = DataNew.GetNowKCGoods5(IsError, StoreId, StoreId2); var nfplist = obj.GetNoFPOrderList(); List mlist = new List(); if (orderlist != null && list != null && KClist != null && orderlist.Count > 0 && list.Count > 0 && KClist.Count > 0) { var hwlist2 = new List(); var OrderMatelist = new List(); List JoinOrderList = new List(); foreach (var ordermd in orderlist) { //if (ordermd.OrderId == 5329133) //{ // string a = ""; //} string JoinOrderCode = ""; if (ordermd.JoinOrderCode != null && ordermd.JoinOrderCode != "") JoinOrderCode = ordermd.JoinOrderCode; if (JoinOrderCode != "") { if (JoinOrderList != null && JoinOrderList.Count > 0) { var jmd = JoinOrderList.Find(n => n.JoinOrderCode == JoinOrderCode); DT_OrderMateKCOrder nmd = null; if (nfplist != null && nfplist.Count > 0) nmd = nfplist.Find(n => n.JoinOrderCode == JoinOrderCode); if (jmd != null || nmd != null) continue; else { var jmd1 = new DT_OrderMateKCGoods(); jmd1.JoinOrderCode = JoinOrderCode; JoinOrderList.Add(jmd1); } } else { var jmd1 = new DT_OrderMateKCGoods(); jmd1.JoinOrderCode = JoinOrderCode; JoinOrderList.Add(jmd1); } } List listGoods = new List(); List OutList = new List(); var Goodslist = new List(); if (JoinOrderCode == "") Goodslist = list.FindAll(n => n.OrderId == ordermd.OrderId); else //合并订单 Goodslist = list.FindAll(n => n.JoinOrderCode == JoinOrderCode); if (Goodslist != null && Goodslist.Count > 0) { var hwlist1 = new List(); bool qbFlag = true;//全部货物满足 bool Flag = false;//全部货物满足 foreach (var goodsmd in Goodslist) { int DDNum = goodsmd.GoodsNum.Value; int LeftNum = DDNum; List kcmdlist = new List(); if (StoreId == 5) { kcmdlist = KClist.FindAll(n => n.PostionCode == ordermd.ShopName && n.DetailId == goodsmd.DetailId && n.KCNum - n.LockNum > 0); } else { kcmdlist = KClist.FindAll(n => n.DetailId == goodsmd.DetailId && n.KCNum - n.LockNum > 0); kcmdlist = kcmdlist.OrderBy(s => s.SortNo).ThenBy(s => s.PostionId).ToList(); } if (kcmdlist == null || kcmdlist.Count == 0) { qbFlag = false; Flag = false; continue; } foreach (var kcmd in kcmdlist) { if (kcmd.KCNum - kcmd.LockNum >= LeftNum) { kcmd.LockNum += LeftNum; var ckmd = new DT_OrderNowKCGoods(); ckmd.OrderNum = LeftNum; ckmd.InId = kcmd.InId; ckmd.OrderId = ordermd.OrderId; ckmd.OrderGoodsId = goodsmd.Id; ckmd.StoreId = kcmd.StoreId; ckmd.PostionId = kcmd.PostionId; ckmd.DetailId = kcmd.DetailId; hwlist1.Add(ckmd); LeftNum = 0; break; } else { var ckmd = new DT_OrderNowKCGoods(); ckmd.OrderNum = kcmd.KCNum.Value - kcmd.LockNum.Value; ckmd.InId = kcmd.InId; ckmd.OrderId = ordermd.OrderId; ckmd.OrderGoodsId = goodsmd.Id; ckmd.StoreId = kcmd.StoreId; ckmd.PostionId = kcmd.PostionId; ckmd.DetailId = kcmd.DetailId; hwlist1.Add(ckmd); LeftNum = LeftNum - kcmd.KCNum.Value + kcmd.LockNum.Value; kcmd.LockNum = kcmd.KCNum; } } if (LeftNum <= 0) { Flag = true; goodsmd.IsMate = 1; } else { qbFlag = false; Flag = false; goodsmd.IsMate = 0; } } if (qbFlag == true && Flag == true) { mlist.Add(ordermd); ordermd.IsMate = 1; if (hwlist1 != null) { foreach (var hmd in hwlist1) { hwlist2.Add(hmd); } } } else { foreach (var hmd in hwlist1) { var opmd = new HW_OrderMate(); opmd.InId = hmd.InId; opmd.Num = hmd.OrderNum; opmd.DetailId = hmd.DetailId; opmd.GoodsOrderId = hmd.OrderGoodsId; opmd.StoreId = hmd.StoreId; opmd.PostionId = hmd.PostionId; OrderMatelist.Add(opmd); } hwlist1.Clear(); } } } // var olist=orderlist.FindAll(n=>n.IsMate==1); if (mlist != null) { Num = mlist.Count; //string OrderIds = ""; // string JoinOrderCodes = ""; foreach (var omd in mlist) { int OrderId = 0; string JoinOrderCode = ""; if (omd.JoinOrderCode != null && omd.JoinOrderCode != "") JoinOrderCode = omd.JoinOrderCode; else OrderId = omd.OrderId.Value; var cklist = hwlist2.FindAll(n => n.OrderId == omd.OrderId); if (cklist != null && cklist.Count > 0) DataNew.UpdateOrderGoodsLockForTM3(OrderId, JoinOrderCode, cklist); } //if (OrderIds != "" || JoinOrderCodes != "") // obj.UpdateOrderGoodsLockForTM31(OrderIds.Trim(','), JoinOrderCodes.Trim(',')); } obj.DeleteOrderMate(); if (OrderMatelist != null) { foreach (var mmd in OrderMatelist) { obj.SaveOrderMate(mmd); } } } } catch (Exception ex) { BaseService.UnSyncLock(CompanyId, 2, DateTime.Now); return ex.Message; } BaseService.UnSyncLock(CompanyId, 2, DateTime.Now); return "匹配" + Num.ToString() + "条"; } #endregion #region 选择订单锁定匹配货物(加认购) [WebMethod(EnableSession = true)] public string PartOrderGoodsLockForTM5(int IsError, int StoreId, int StoreId2, string OrderIds, string JoinOrderCodes) { PagesNew.Login(this.Session); var obj = new DD_OrderData(); int Num = 0; int CompanyId = Convert.ToInt32(Session["CompanyId"]); int UserId = Convert.ToInt32(Session["UserId"]); bool bk = BaseService.SyncLock(CompanyId, 2, UserId, DateTime.Now); if (bk == false) return "当前有其他人正在操作库存分配,为保证库存数据准确您暂时无法尝试此操作"; try { string Sort = "a.OrderLevel desc,a.OrderDate"; var orderlist = obj.GetLockPartOrderListForTM2(CompanyId, OrderIds.Trim(','), JoinOrderCodes.Trim(','), IsError, StoreId, Sort); var list = obj.GetLockPartOrderGoodsForTM2(CompanyId, OrderIds.Trim(','), JoinOrderCodes.Trim(','), StoreId, IsError); var nfplist = obj.GetNoFPOrderList(); //var buylist = DataNew.GetKCShopGoodsNumPart(CompanyId, OrderIds.Trim(','), JoinOrderCodes.Trim(','), StoreId2); //if (buylist == null) //{ // buylist = new List(); // BaseService.UnSyncLock(CompanyId, 2, DateTime.Now); // return "认购库存不满足"; //} if (orderlist != null && list != null) { var hwlist = new List(); //货物占用 var hwlist2 = new List(); var hwnolist = new List(); //不够的货物 List JoinOrderList = new List(); foreach (var ordermd in orderlist) { string JoinOrderCode = ""; if (ordermd.JoinOrderCode != null && ordermd.JoinOrderCode != "") JoinOrderCode = ordermd.JoinOrderCode; List listGoods = new List(); List OutList = new List(); var Goodslist = new List(); if (JoinOrderCode == "") Goodslist = list.FindAll(n => n.OrderId == ordermd.OrderId); else //合并订单 Goodslist = list.FindAll(n => n.JoinOrderCode == JoinOrderCode); if (JoinOrderCode != "") { if (JoinOrderList != null && JoinOrderList.Count > 0) { var jmd = JoinOrderList.Find(n => n.JoinOrderCode == JoinOrderCode); DT_OrderMateKCOrder nmd = null; if (nfplist != null && nfplist.Count > 0) nmd = nfplist.Find(n => n.JoinOrderCode == JoinOrderCode); if (jmd != null || nmd != null) continue; else { var jmd1 = new DT_OrderGoods(); jmd1.JoinOrderCode = JoinOrderCode; JoinOrderList.Add(jmd1); } } else { var jmd1 = new DT_OrderGoods(); jmd1.JoinOrderCode = JoinOrderCode; JoinOrderList.Add(jmd1); } } if (Goodslist != null) { //if (StoreId != 5)//认购库存验证 //{ // if (Goodslist != null && Goodslist.Count > 0) // { // bool buyFlag = true;//认购货物满足 // foreach (var goodsmd in Goodslist) // { // var buymdlist = buylist.Find(n => n.DetailId == goodsmd.DetailId && n.ShopId == ordermd.ShopId && n.NowNum - n.MateNum-goodsmd.GoodsNum >= 0);//认购数 // if (buymdlist == null) // { // buyFlag = false; // break; // } // } // if (buyFlag == false)//认购不满足 // continue; // } //} bool Flag = false; //匹配标记 bool qbFlag = true;//全部货物满足 foreach (var goodsmd in Goodslist) { int ZYNum = 0;//占用数量 int DDNum = goodsmd.GoodsNum.Value;//订单数量 if (hwnolist != null) { var hwnodetail = hwnolist.Find(n => n.DetailId == goodsmd.DetailId); if (hwnodetail != null)//已经在没有库存记录里 { Flag = false; qbFlag = false; continue; } } if (hwlist != null) { var hwdetail = hwlist.Find(n => n.DetailId == goodsmd.DetailId); if (hwdetail != null)//已经在没有满足库存记录里 { ZYNum = hwdetail.KCNum.Value; } } List inlist = null; if (StoreId == 5) { inlist = DataNew.GetMateOrderGoodsInForTM35(goodsmd.DetailId.Value, StoreId, ordermd.ShopName); } else { inlist = DataNew.GetMateOrderGoodsInForTM34(goodsmd.DetailId.Value, StoreId2); } if (inlist == null || inlist.Count == 0)//没有库存 { Flag = false; qbFlag = false; HW_GoodsOutDetail hwnomd = new HW_GoodsOutDetail(); hwnomd.DetailId = goodsmd.DetailId; hwnolist.Add(hwnomd); continue; } int LeftNum = DDNum; foreach (var kcmd in inlist) { if (kcmd.KCNum.Value >= LeftNum + ZYNum) { HW_GoodsInDetail hwinmd = new HW_GoodsInDetail(); hwinmd.DetailId = goodsmd.DetailId; hwinmd.InId = kcmd.InId; hwinmd.Price = kcmd.Price; hwinmd.PostPrice = kcmd.PostPrice; hwinmd.OrderGoodsId = goodsmd.Id; hwinmd.KCNum = LeftNum; hwlist2.Add(hwinmd); LeftNum = 0; break; } else if (kcmd.KCNum.Value < LeftNum + ZYNum) { HW_GoodsInDetail hwinmd = new HW_GoodsInDetail(); hwinmd.DetailId = goodsmd.DetailId; hwinmd.InId = kcmd.InId; hwinmd.Price = kcmd.Price; hwinmd.PostPrice = kcmd.PostPrice; hwinmd.OrderGoodsId = goodsmd.Id; hwinmd.KCNum = kcmd.KCNum.Value; hwlist2.Add(hwinmd); LeftNum = LeftNum - kcmd.KCNum.Value; } } if (LeftNum == 0) //够分配 { Flag = true; } else //不够分配 { Flag = false; qbFlag = false; var bgmd = hwlist.Find(n => n.DetailId == goodsmd.DetailId); if (bgmd != null) { bgmd.KCNum += DDNum; } else { var bgmd1 = new HW_GoodsInDetail(); bgmd1.KCNum = DDNum; hwlist.Add(bgmd1); } } } if (Flag == true && qbFlag == true)//已经分配 { //if (StoreId != 5)//认购库存验证 //{ // foreach (var goodsmd in Goodslist) // { // var buymdlist = buylist.Find(n => n.DetailId == goodsmd.DetailId && n.ShopId == ordermd.ShopId && n.NowNum - n.MateNum >= 0);//认购数 // if (buymdlist != null) // { // buymdlist.MateNum = buymdlist.MateNum + goodsmd.GoodsNum; // } // } //} decimal GoodsFee = 0; //货物采购均价 decimal PostFee = 0;//货物快递成本 if (hwlist2 != null) { Num++; //int Num = hwlist2.Count; foreach (var md in hwlist2) { if (md.Price != null) GoodsFee += md.Price.Value * md.KCNum.Value; if (md.PostPrice != null) PostFee += md.PostPrice.Value * md.KCNum.Value; } //if (Num > 0) //{ // GoodsFee = GoodsFee / Num; // PostFee = PostFee / Num; //} } DataNew.UpdateOrderGoodsLockForTM2(ordermd.OrderId.Value, 2, GoodsFee, PostFee, JoinOrderCode, hwlist2); hwlist2.Clear(); } else //未分配 { if (hwlist2 != null) { foreach (var md in hwlist2) { var bgmd = hwlist.Find(n => n.DetailId == md.DetailId); if (bgmd != null) { bgmd.KCNum += md.KCNum.Value; } else { var bgmd1 = new HW_GoodsInDetail(); bgmd1.KCNum = md.KCNum.Value; hwlist.Add(bgmd1); } } hwlist2.Clear(); } } } } } //if (buylist != null) //{ // SaveShopKC(buylist, StoreId2); //} } catch (Exception ex) { BaseService.UnSyncLock(CompanyId, 2, DateTime.Now); return ex.Message; } BaseService.UnSyncLock(CompanyId, 2, DateTime.Now); return "匹配" + Num.ToString() + "条"; } #endregion /// /// 修改认购匹配数 /// /// /// public void SaveShopKC(List mlist, int StoreId) { var klist = DataNew.GetShopGoodsNumNoMate(StoreId); if (mlist != null && klist != null) { foreach (var mmd in mlist) { if (mmd.MateNum <= 0) continue; int mnum = mmd.MateNum.Value; int shopid = mmd.ShopId.Value; var kmd = klist.FindAll(n => n.ShopId == shopid && n.DetailId == mmd.DetailId); if (kmd != null) { foreach (var ppmd in kmd) { if (ppmd.NowNum >= mnum) { ppmd.AddNum = mnum; mnum = 0; break; } else { ppmd.AddNum = ppmd.NowNum; mnum = mnum - ppmd.NowNum.Value; } } } } foreach (var md in klist) { if (md.AddNum > 0) { DataNew.UpdateUserBuyNumMate(md.Id.Value, md.AddNum.Value); } } } } #region 选择订单锁定匹配货物 [WebMethod(EnableSession = true)] public string PartOrderGoodsLockForTM4(int IsError, int StoreId, int StoreId2, string OrderIds, string JoinOrderCodes) { PagesNew.Login(this.Session); var obj = new DD_OrderData(); int Num = 0; int CompanyId = Convert.ToInt32(Session["CompanyId"]); int UserId = Convert.ToInt32(Session["UserId"]); bool bk = BaseService.SyncLock(CompanyId, 2, UserId, DateTime.Now); if (bk == false) return "当前有其他人正在操作库存分配,为保证库存数据准确您暂时无法尝试此操作"; try { string Sort = "a.OrderLevel desc,a.OrderDate"; var orderlist = obj.GetLockPartOrderListForTM2(CompanyId, OrderIds.Trim(','), JoinOrderCodes.Trim(','), IsError, StoreId, Sort); var list = obj.GetLockPartOrderGoodsForTM2(CompanyId, OrderIds.Trim(','), JoinOrderCodes.Trim(','), StoreId, IsError); var nfplist = obj.GetNoFPOrderList(); if (orderlist != null && list != null) { var hwlist = new List(); //货物占用 var hwlist2 = new List(); var hwnolist = new List(); //不够的货物 List JoinOrderList = new List(); foreach (var ordermd in orderlist) { string JoinOrderCode = ""; if (ordermd.JoinOrderCode != null && ordermd.JoinOrderCode != "") JoinOrderCode = ordermd.JoinOrderCode; List listGoods = new List(); List OutList = new List(); var Goodslist = new List(); if (JoinOrderCode == "") Goodslist = list.FindAll(n => n.OrderId == ordermd.OrderId); else //合并订单 Goodslist = list.FindAll(n => n.JoinOrderCode == JoinOrderCode); if (JoinOrderCode != "") { if (JoinOrderList != null && JoinOrderList.Count > 0) { var jmd = JoinOrderList.Find(n => n.JoinOrderCode == JoinOrderCode); DT_OrderMateKCOrder nmd = null; if (nfplist != null && nfplist.Count > 0) nmd = nfplist.Find(n => n.JoinOrderCode == JoinOrderCode); if (jmd != null || nmd != null) continue; else { var jmd1 = new DT_OrderGoods(); jmd1.JoinOrderCode = JoinOrderCode; JoinOrderList.Add(jmd1); } } else { var jmd1 = new DT_OrderGoods(); jmd1.JoinOrderCode = JoinOrderCode; JoinOrderList.Add(jmd1); } } if (Goodslist != null) { bool Flag = false; //匹配标记 bool qbFlag = true;//全部货物满足 foreach (var goodsmd in Goodslist) { int ZYNum = 0;//占用数量 int DDNum = goodsmd.GoodsNum.Value;//订单数量 if (hwnolist != null) { var hwnodetail = hwnolist.Find(n => n.DetailId == goodsmd.DetailId); if (hwnodetail != null)//已经在没有库存记录里 { Flag = false; qbFlag = false; continue; } } if (hwlist != null) { var hwdetail = hwlist.Find(n => n.DetailId == goodsmd.DetailId); if (hwdetail != null)//已经在没有满足库存记录里 { ZYNum = hwdetail.KCNum.Value; } } List inlist = null; if (StoreId == 5) { inlist = DataNew.GetMateOrderGoodsInForTM35(goodsmd.DetailId.Value, StoreId, ordermd.ShopName); } else { inlist = DataNew.GetMateOrderGoodsInForTM34(goodsmd.DetailId.Value, StoreId2); } if (inlist == null || inlist.Count == 0)//没有库存 { Flag = false; qbFlag = false; HW_GoodsOutDetail hwnomd = new HW_GoodsOutDetail(); hwnomd.DetailId = goodsmd.DetailId; hwnolist.Add(hwnomd); continue; } int LeftNum = DDNum; foreach (var kcmd in inlist) { if (kcmd.KCNum.Value >= LeftNum + ZYNum) { HW_GoodsInDetail hwinmd = new HW_GoodsInDetail(); hwinmd.DetailId = goodsmd.DetailId; hwinmd.InId = kcmd.InId; hwinmd.Price = kcmd.Price; hwinmd.PostPrice = kcmd.PostPrice; hwinmd.OrderGoodsId = goodsmd.Id; hwinmd.KCNum = LeftNum; hwlist2.Add(hwinmd); LeftNum = 0; break; } else if (kcmd.KCNum.Value < LeftNum + ZYNum) { HW_GoodsInDetail hwinmd = new HW_GoodsInDetail(); hwinmd.DetailId = goodsmd.DetailId; hwinmd.InId = kcmd.InId; hwinmd.Price = kcmd.Price; hwinmd.PostPrice = kcmd.PostPrice; hwinmd.OrderGoodsId = goodsmd.Id; hwinmd.KCNum = kcmd.KCNum.Value; hwlist2.Add(hwinmd); LeftNum = LeftNum - kcmd.KCNum.Value; } } if (LeftNum == 0) //够分配 { Flag = true; } else //不够分配 { Flag = false; qbFlag = false; var bgmd = hwlist.Find(n => n.DetailId == goodsmd.DetailId); if (bgmd != null) { bgmd.KCNum += DDNum; } else { var bgmd1 = new HW_GoodsInDetail(); bgmd1.KCNum = DDNum; hwlist.Add(bgmd1); } } } if (Flag == true && qbFlag == true)//已经分配 { decimal GoodsFee = 0; //货物采购均价 decimal PostFee = 0;//货物快递成本 if (hwlist2 != null) { Num++; //int Num = hwlist2.Count; foreach (var md in hwlist2) { if (md.Price != null) GoodsFee += md.Price.Value * md.KCNum.Value; if (md.PostPrice != null) PostFee += md.PostPrice.Value * md.KCNum.Value; } //if (Num > 0) //{ // GoodsFee = GoodsFee / Num; // PostFee = PostFee / Num; //} } DataNew.UpdateOrderGoodsLockForTM2(ordermd.OrderId.Value, 2, GoodsFee, PostFee, JoinOrderCode, hwlist2); hwlist2.Clear(); } else //未分配 { if (hwlist2 != null) { foreach (var md in hwlist2) { var bgmd = hwlist.Find(n => n.DetailId == md.DetailId); if (bgmd != null) { bgmd.KCNum += md.KCNum.Value; } else { var bgmd1 = new HW_GoodsInDetail(); bgmd1.KCNum = md.KCNum.Value; hwlist.Add(bgmd1); } } hwlist2.Clear(); } } } } } } catch (Exception ex) { BaseService.UnSyncLock(CompanyId, 2, DateTime.Now); return ex.Message; } BaseService.UnSyncLock(CompanyId, 2, DateTime.Now); return "匹配" + Num.ToString() + "条"; } #endregion #region 全部订单锁定匹配货物(判断认购) [WebMethod(EnableSession = true)] public string AllOrderGoodsLockForTM7(int IsError, int StoreId, int StoreId2) { PagesNew.Login(this.Session); var obj = new DD_OrderData(); int Num = 0; int CompanyId = Convert.ToInt32(Session["CompanyId"]); int UserId = Convert.ToInt32(Session["UserId"]); bool bk = BaseService.SyncLock(CompanyId, 2, UserId, DateTime.Now); if (bk == false) return "当前有其他人正在操作库存匹配,为保证库存数据准确您暂时无法尝试此操作"; try { string Sort = "a.OrderLevel desc,a.OrderDate"; obj.SetStore();//仓库调整 var orderlist = obj.GetLockOrderListForTM4(CompanyId, IsError, StoreId, Sort); var list = obj.GetLockOrderGoodsForTM4(CompanyId, StoreId, IsError); var KClist = DataNew.GetNowKCGoods5(IsError, StoreId, StoreId2); var nfplist = obj.GetNoFPOrderList(); //var buylist = DataNew.GetKCShopGoodsNum(StoreId, StoreId2); //if (buylist == null) //{ // buylist = new List(); // BaseService.UnSyncLock(CompanyId, 2, DateTime.Now); // return "认购库存不满足"; //} List mlist = new List(); if (orderlist != null && list != null && KClist != null&& orderlist.Count > 0 && list.Count > 0 && KClist.Count > 0) { var hwlist2 = new List(); var OrderMatelist = new List(); List JoinOrderList = new List(); foreach (var ordermd in orderlist) { //if (ordermd.OrderId == 5329133) //{ // string a = ""; //} string JoinOrderCode = ""; if (ordermd.JoinOrderCode != null && ordermd.JoinOrderCode != "") JoinOrderCode = ordermd.JoinOrderCode; if (JoinOrderCode != "") { if (JoinOrderList != null && JoinOrderList.Count > 0) { var jmd = JoinOrderList.Find(n => n.JoinOrderCode == JoinOrderCode); DT_OrderMateKCOrder nmd = null; if (nfplist != null && nfplist.Count > 0) nmd = nfplist.Find(n => n.JoinOrderCode == JoinOrderCode); if (jmd != null || nmd != null) continue; else { var jmd1 = new DT_OrderMateKCGoods(); jmd1.JoinOrderCode = JoinOrderCode; JoinOrderList.Add(jmd1); } } else { var jmd1 = new DT_OrderMateKCGoods(); jmd1.JoinOrderCode = JoinOrderCode; JoinOrderList.Add(jmd1); } } List listGoods = new List(); List OutList = new List(); var Goodslist = new List(); if (JoinOrderCode == "") Goodslist = list.FindAll(n => n.OrderId == ordermd.OrderId); else //合并订单 Goodslist = list.FindAll(n => n.JoinOrderCode == JoinOrderCode); //if (StoreId != 5)//认购库存验证 //{ // if (Goodslist != null && Goodslist.Count > 0) // { // bool buyFlag = true;//认购货物满足 // foreach (var goodsmd in Goodslist) // { // var buymdlist = buylist.Find(n => n.DetailId == goodsmd.DetailId && n.ShopId == ordermd.ShopId && n.NowNum - n.MateNum >= 0);//认购数 // if (buymdlist == null) // { // buyFlag = false; // break; // } // } // if (buyFlag == false)//认购不满足 // continue; // } //} if (Goodslist != null && Goodslist.Count > 0) { var hwlist1 = new List(); bool qbFlag = true;//全部货物满足 bool Flag = false;//货物满足 foreach (var goodsmd in Goodslist) { int DDNum = goodsmd.GoodsNum.Value; int LeftNum = DDNum; List kcmdlist = new List(); if (StoreId == 5) { kcmdlist = KClist.FindAll(n => n.PostionCode == ordermd.ShopName && n.DetailId == goodsmd.DetailId && n.KCNum - n.LockNum > 0); } else { kcmdlist = KClist.FindAll(n => n.DetailId == goodsmd.DetailId && n.KCNum - n.LockNum > 0); kcmdlist = kcmdlist.OrderBy(s => s.SortNo).ThenBy(s => s.PostionId).ToList(); } if (kcmdlist == null || kcmdlist.Count == 0) { qbFlag = false; Flag = false; continue; } foreach (var kcmd in kcmdlist) { if (kcmd.KCNum - kcmd.LockNum >= LeftNum) { kcmd.LockNum += LeftNum; var ckmd = new DT_OrderNowKCGoods(); ckmd.OrderNum = LeftNum; ckmd.InId = kcmd.InId; ckmd.OrderId = ordermd.OrderId; ckmd.OrderGoodsId = goodsmd.Id; ckmd.StoreId = kcmd.StoreId; ckmd.PostionId = kcmd.PostionId; ckmd.DetailId = kcmd.DetailId; hwlist1.Add(ckmd); LeftNum = 0; break; } else { var ckmd = new DT_OrderNowKCGoods(); ckmd.OrderNum = kcmd.KCNum.Value - kcmd.LockNum.Value; ckmd.InId = kcmd.InId; ckmd.OrderId = ordermd.OrderId; ckmd.OrderGoodsId = goodsmd.Id; ckmd.StoreId = kcmd.StoreId; ckmd.PostionId = kcmd.PostionId; ckmd.DetailId = kcmd.DetailId; hwlist1.Add(ckmd); LeftNum = LeftNum - kcmd.KCNum.Value + kcmd.LockNum.Value; kcmd.LockNum = kcmd.KCNum; } } if (LeftNum <= 0) { Flag = true; goodsmd.IsMate = 1; } else { qbFlag = false; Flag = false; goodsmd.IsMate = 0; } } if (qbFlag == true && Flag == true) { //if (StoreId != 5)//认购库存验证 //{ // foreach (var goodsmd in Goodslist) // { // var buymdlist = buylist.Find(n => n.DetailId == goodsmd.DetailId && n.ShopId == ordermd.ShopId && n.NowNum - n.MateNum >= 0);//认购数 // if (buymdlist != null) // { // buymdlist.MateNum = buymdlist.MateNum + goodsmd.GoodsNum; // } // } //} mlist.Add(ordermd); ordermd.IsMate = 1; if (hwlist1 != null) { foreach (var hmd in hwlist1) { hwlist2.Add(hmd); } } } else { foreach (var hmd in hwlist1) { var opmd = new HW_OrderMate(); opmd.InId = hmd.InId; opmd.Num = hmd.OrderNum; opmd.DetailId = hmd.DetailId; opmd.GoodsOrderId = hmd.OrderGoodsId; opmd.StoreId = hmd.StoreId; opmd.PostionId = hmd.PostionId; OrderMatelist.Add(opmd); } hwlist1.Clear(); } } } // var olist=orderlist.FindAll(n=>n.IsMate==1); if (mlist != null) { Num = mlist.Count; //string OrderIds = ""; // string JoinOrderCodes = ""; foreach (var omd in mlist) { int OrderId = 0; string JoinOrderCode = ""; if (omd.JoinOrderCode != null && omd.JoinOrderCode != "") JoinOrderCode = omd.JoinOrderCode; else OrderId = omd.OrderId.Value; var cklist = hwlist2.FindAll(n => n.OrderId == omd.OrderId); if (cklist != null && cklist.Count > 0) DataNew.UpdateOrderGoodsLockForTM3(OrderId, JoinOrderCode, cklist); } //if (OrderIds != "" || JoinOrderCodes != "") // obj.UpdateOrderGoodsLockForTM31(OrderIds.Trim(','), JoinOrderCodes.Trim(',')); } //if (buylist != null) //{ // SaveShopKC(buylist, StoreId2); //} //obj.DeleteOrderMate(); //if (OrderMatelist != null) //{ // foreach (var mmd in OrderMatelist) // { // obj.SaveOrderMate(mmd); // } //} } } catch (Exception ex) { BaseService.UnSyncLock(CompanyId, 2, DateTime.Now); return ex.Message; } BaseService.UnSyncLock(CompanyId, 2, DateTime.Now); return "匹配" + Num.ToString() + "条"; } #endregion #region 查询订单 [WebMethod(EnableSession = true)] public JsonModel> GetListOrderPrintForTM(int PlatType, int IsWeight, int ShopId, int DateType, DateTime? SDate, DateTime? EDate, int OutDays, int TjType, string Name, int PrintState, int State, int IsSku, int IsError, int IsDetail, int HBOrder, int LogicId, int PostId, int IsAddr, int IsFP, string KWCode, string GoodsInfo, int TrackState, int FHState, int GM, int SNum, int ENum, int PageIndex, int PageSize, String Sort, string PostionCode, string PostionCode2,int StoreId) { PagesNew.Login(this.Session); var obj = new DD_OrderData(); DataNew.UpdateOrderTrackState(); int CompanyId = Convert.ToInt32(Session["CompanyId"]); RefParameterCollection Param = new RefParameterCollection(); if (IsFP > -1) Param.Add("isnull(a.BillPrint,0)", "=", IsFP, DbType.Int32); Param.Add("a.CompanyId", "=", CompanyId, DbType.Int32); Param.Add("a.MateState", "=", 2, DbType.Int32); if (PlatType > 0) Param.Add("a.PlatId", "=", PlatType, DbType.Int32); if (ShopId > 0) Param.Add("a.ShopId", "=", ShopId, DbType.Int32); if (TrackState == 1) { Param.Add("b.TrackState", ">", 0, DbType.Int32); if (PostId == 0) Param.Add("b.Post", ">", 0, DbType.Int32); } else if (TrackState == 0) { Param.Add("b.TrackState", "=", 0, DbType.Int32); } if (DateType == 1) { if (SDate != null) Param.Add("a.OrderDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.OrderDate", "<=", EDate, DbType.DateTime); } else if (DateType == 2) { if (SDate != null) Param.Add("a.InDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.InDate", "<=", EDate, DbType.DateTime); } else if (DateType == 3) { if (SDate != null) Param.Add("a.PrintDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.PrintDate", "<=", EDate, DbType.DateTime); } else if (DateType == 4) { if (SDate != null) Param.Add("a.PostDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.PostDate", "<=", EDate, DbType.DateTime); } else if (DateType == 5) { if (SDate != null) Param.Add("a.OrderOutDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.OrderOutDate", "<=", EDate, DbType.DateTime); } if (OutDays > 0) { Param.Add("a.OrderOutDate", "<=", DateTime.Today.AddDays(OutDays), DbType.DateTime); } if (PrintState == -1 && FHState > -1) { Param.Add("a.poststate", "=", FHState, DbType.Int32); if (IsError == 1) { Param.Add("isnull(b.ErrorInfo,'')", "<>", "", DbType.String); } } else { if (IsError == 1) { Param.Add("(a.PostState", "=", 2, DbType.Int32); Param.Add("isnull(b.ErrorInfo,'')", "<>", "", "or", ")", DbType.String); } else Param.Add("a.PostState", "<", 2, DbType.Int32); } if (PrintState > -1) Param.Add("a.PrintState", "=", PrintState, DbType.Int32); if (PrintState > -1) Param.Add("a.State", "=", 1, DbType.Int32); else { Param.Add("a.State", ">", 0, DbType.Int32); Param.Add("a.State", "<", 3, DbType.Int32); //Param.Add("b.RevPhone", "is", null, "or",")",DbType.String); } if (LogicId==-2) Param.Add("b.LogisticsId", "in", "10,13", DbType.String); else if (LogicId > 0) Param.Add("b.LogisticsId", "=", LogicId, DbType.Int32); if (PostId > 0) Param.Add("b.Post", "=", PostId, DbType.Int32); if (HBOrder == 1) Param.Add("a.IsJoin", "=", 1, DbType.Int32); //if (IsError == 1) //{ // Param.Add("(b.SendAddr", ">", 0, DbType.Int32); // Param.Add("b.IsLeaveWord", "=", 1, "or", ")", DbType.Int32); //} if (IsAddr > -1) { Param.Add("b.SendAddr", "=", IsAddr, DbType.Int32); } string TCode = ""; if (Name != "") { Name = Name.Trim(); if (TjType == 1) { Param.Add("(a.PlatOrderCode", "=", Name, DbType.String); Param.Add("a.JoinOrderCode", "=", Name, "or", ")", DbType.String); } else if (TjType == 2) { Param.Add("b.RevName", "like", Name, DbType.String); } else if (TjType == 3) { Param.Add("b.RevPhone", "like", Name, DbType.String); } else if (TjType == 4) { Param.Add("(b.RevCountry", "=", Name, DbType.String); Param.Add("b.CountryName", "=", Name, "or", DbType.String); Param.Add("b.CountryCode", "=", Name, "or", ")", DbType.String); } else if (TjType == 5) { Param.Add("b.RevPostCode", "=", Name, DbType.String); } else if (TjType == 6) { Param.Add("(b.RevAddr", "like", Name, DbType.String); Param.Add("b.RevProvince", "like", Name, "or", DbType.String); Param.Add("b.RevCity", "like", Name, "or", DbType.String); Param.Add("b.RevArea", "like", Name, "or", ")", DbType.String); } else if (TjType == 9) { Param.Add("(b.ErrorInfo", "like", Name, DbType.String); Param.Add("b.PostError", "like", Name, "or", ")", DbType.String); } else if (TjType == 10) { // Param.Add("b.TrackCode", "like", Name, DbType.String); TCode = Name; } } if (StoreId > 0) { if (StoreId == 6) { Param.Add("b.StoreId", "in", "6,9,18", DbType.String); } else Param.Add("b.StoreId", "=", StoreId, DbType.Int32); } //if (IsError == 2) //{ // Param.Add("(a.SendAddr", ">", 0, DbType.Int32); // Param.Add("a.IsLeaveWord", "=", 1, "or", ")", DbType.Int32); //} if (IsWeight == 2) { Param.Add("isnull(a.IsSpare,0)", "=", 1, DbType.Int32); } else if (IsWeight == 1) { Param.Add("isnull(a.IsSpare,0)", "=", 0, DbType.Int32); } //if (IsSku == 0) // Param.Add("a.FPDate", "is", null, DbType.String); //else if (IsSku == 1) // Param.Add("a.FPDate", "is not", null, DbType.String); //Param.Add("a.OrderDate", ">=", 0, DbType.Int32); JsonModel> resultModel = new JsonModel>(); int RowCount = 0; //string Sort = "orderid desc"; //if (PrintState == 0) // Sort = "orderid"; string GoodsName = ""; string Code = ""; if (GoodsInfo != "") { GoodsName = GoodsInfo.Trim(); if (GoodsInfo.Trim().Contains(' ')) { GoodsName = GoodsInfo.Trim().Split(' ')[0].Trim(); Code = GoodsInfo.Trim().Split(' ')[1].Trim(); } } //else // if (TjType == 8 && Name != "") // { // SKU = Name; // } List orderlist = new List(); List ordertemp = new List(); if (PrintState > -1) orderlist = DataNew.GetListDT_PrintOrderInfoForTM2(CompanyId, TCode, GoodsName, 0, Code, KWCode, IsSku, GM, PrintState, Param, PageIndex, PageSize, Sort, out RowCount); else orderlist = DataNew.GetListDT_PrintOrderInfoForTM(CompanyId, TCode, GoodsName, 0, Code, KWCode, IsSku, Param, PageIndex, PageSize, Sort, out RowCount); string Ids = ""; if (orderlist != null) { foreach (var md in orderlist) { Ids += md.OrderId.ToString() + ","; //if (IsError > 0) //{ // if (IsError == 3) // { // int check = CheckNum(md.RevPostCode); // if (check == 0) // { // ordertemp.Add(md); // } // } // else if (IsError == 2) // { // int check = CheckNum(md.RevPostCode); // if (check == 1 && md.ErrorInfo == "") // { // ordertemp.Add(md); // } // } // else // { // ordertemp.Add(md); // } //} //else //{ ordertemp.Add(md); //} } } orderlist = new List(); if (Ids != "") { JC_ExpressService obj3 = new JC_ExpressService(); // var elist = obj3.GetExpressTypeList(); var plist = obj3.GetExpressList(); var errorlist = obj.GetErrorList(Ids.Trim(',')); if (errorlist != null || plist != null) { foreach (var md in ordertemp) { if (errorlist != null && errorlist.Count > 0) { var emd = errorlist.Find(n => n.OrderId == md.OrderId); if (emd != null) { md.ErrorInfo = emd.ErrorInfo; } } if (md.Post > 0 && plist != null && plist.Count > 0) { var emd = plist.Find(n => n.ExpressID == md.Post); if (emd != null) { md.PostInfo = emd.Name; } } } } } if (IsDetail == 0 && ordertemp != null) { if (Ids != "") { var listTrack = obj.GetTrackCodeApplyList2(Ids.Trim(',')); if (listTrack != null) { foreach (var md in ordertemp) { var list3 = new List(); if (md.JoinOrderCode != null && md.JoinOrderCode != "") list3 = listTrack.FindAll(n => n.OrderCode == md.JoinOrderCode); else list3 = listTrack.FindAll(n => n.OrderId == md.OrderId); if (list3 != null && list3.Count > 0) { string trackinfo = ""; int tcount = 0; foreach (var md1 in list3) { if (md1.TrackType < 3) { trackinfo += md1.TrackCode + "
"; tcount++; } } if (IsWeight == 1 && tcount > 1 && IsError == 2) { ordertemp.Remove(md); } if (IsError == 5 && IsWeight == 1 && tcount > 1) { orderlist.Add(md); } md.TrackCode = trackinfo; } } } } } else if (IsDetail == 1 && ordertemp != null) { if (Ids != "") { var listTrack = obj.GetTrackCodeApplyList2(Ids.Trim(',')); // ErrorFollow.TraceWrite("GetOrderGoodsPostionList", Ids, DateTime.Now.ToString("HH:mm:ss fff")); var list1 = DataNew.GetOrderGoodsPostionList(Ids.Trim(',')); // ErrorFollow.TraceWrite("GetOrderGoodsPostionList", "2", DateTime.Now.ToString("HH:mm:ss fff")); if (list1 != null) { foreach (var md in ordertemp) { md.OrderLevel = 0; md.OrderName = ""; md.GoodsCode = ""; var list2 = list1.FindAll(n => n.OrderId == md.OrderId); if (list2 != null) { md.GoodsList = list2; md.IsBlank = 0; if (PostionCode == "多库位") { string kw = ""; int kws = 0; foreach (var kwmd in list2) { if (kw != kwmd.PostionCode) { kws++; } kw = kwmd.PostionCode; } if(kws>1) md.IsBlank = 3; } else if (PostionCode != "") { var pmd = list2.Find(n => n.PostionCode.Contains(PostionCode) == true); if(pmd!=null) md.IsBlank = 1; } if (list2.Count > 0) { md.OrderLevel = list2[0].LockNum; md.OrderName = list2[0].PostionCode; md.GoodsCode = list2[0].GoodsCode; } if (SNum > 0 && ENum == 0) { if (list2.Sum(o => o.GoodsNum).GetValueOrDefault(0) >= SNum) { orderlist.Add(md); } } if (SNum > 0 && ENum > 0) { if (list2.Sum(o => o.GoodsNum).GetValueOrDefault(0) >= SNum && list2.Sum(o => o.GoodsNum).GetValueOrDefault(0) <= ENum) { orderlist.Add(md); } } if (SNum == 0 && ENum > 0) { if (list2.Sum(o => o.GoodsNum).GetValueOrDefault(0) <= ENum) { orderlist.Add(md); } } } var list3 = new List(); if (listTrack != null) { if (md.JoinOrderCode != null && md.JoinOrderCode != "") list3 = listTrack.FindAll(n => n.OrderCode == md.JoinOrderCode); else list3 = listTrack.FindAll(n => n.OrderId == md.OrderId); } if (list3 != null && list3.Count > 0) { string trackinfo = ""; int tcount = 0; foreach (var md1 in list3) { if (md1.TrackType < 3) { trackinfo += md1.TrackCode + "
"; tcount++; } } if (IsWeight == 1 && tcount > 1 && IsError == 2) { ordertemp.Remove(md); } if (IsError == 5 && IsWeight == 1 && tcount > 1) { orderlist.Add(md); } md.TrackCode = trackinfo; } } } } } // ErrorFollow.TraceWrite("GetOrderGoodsPostionList", "3", DateTime.Now.ToString("HH:mm:ss fff")); if (IsError == 5) ordertemp = orderlist; if (orderlist != null) { if (orderlist.Count() > 0) ordertemp = orderlist; } if (PostionCode2 != "") { ordertemp = ordertemp.FindAll(n => n.IsBlank == 0); } else if (PostionCode == "多库位") { ordertemp = ordertemp.FindAll(n => n.IsBlank == 3); } else if (PostionCode != "") { ordertemp = ordertemp.FindAll(n => n.IsBlank == 1); } // ErrorFollow.TraceWrite("GetOrderGoodsPostionList", "4", DateTime.Now.ToString("HH:mm:ss fff")); List orderList2 = new List(); // if(PostionCode==""||PostionCode2!="") //orderList2= ordertemp.OrderBy(s => s.OrderLevel).ThenBy(s => s.OrderName).ThenBy(s => s.GoodsCode).ToList(); // else // orderList2 = ordertemp.OrderBy(s => s.GoodsCode).ThenBy(s => s.OrderLevel).ThenBy(s => s.OrderName).ToList(); //orderList2 = ordertemp.OrderBy(s => s.OrderLevel).OrderBy(s => s.OrderName).ThenBy(s => s.GoodsCode).ThenByDescending(s => s.GoodsNum).ToList(); // ErrorFollow.TraceWrite("GetOrderGoodsPostionList", "5", DateTime.Now.ToString("HH:mm:ss fff")); var query = from s in ordertemp orderby s.OrderLevel, s.OrderName, s.GoodsCode, s.GoodsNum descending  //排序 select s; orderList2 = query.ToList(); resultModel.DataSource = orderList2.Take(PageSize).Skip(PageSize * (PageIndex - 1)).ToList(); int count = 0; if (orderList2 != null) count = orderList2.Count(); resultModel.RowCount = count; return resultModel; } #endregion #region 查询订单 [WebMethod(EnableSession = true)] public string GetListOrderPrintForTMExcel(int PlatType, int IsWeight, int ShopId, int DateType, DateTime? SDate, DateTime? EDate, int OutDays, int TjType, string Name, int PrintState, int State, int IsSku, int IsError, int IsDetail, int HBOrder, int LogicId, int PostId, int IsAddr, int IsFP, string KWCode, string GoodsInfo, int TrackState, int FHState, int GM, int SNum, int ENum, int PageIndex, int PageSize, String Sort, string PostionCode, string PostionCode2, int StoreId) { PagesNew.Login(this.Session); var obj = new DD_OrderData(); DataNew.UpdateOrderTrackState(); int CompanyId = Convert.ToInt32(Session["CompanyId"]); RefParameterCollection Param = new RefParameterCollection(); if (IsFP > -1) Param.Add("isnull(a.BillPrint,0)", "=", IsFP, DbType.Int32); Param.Add("a.CompanyId", "=", CompanyId, DbType.Int32); Param.Add("a.MateState", "=", 2, DbType.Int32); if (PlatType > 0) Param.Add("a.PlatId", "=", PlatType, DbType.Int32); if (ShopId > 0) Param.Add("a.ShopId", "=", ShopId, DbType.Int32); if (TrackState == 1) { Param.Add("b.TrackState", ">", 0, DbType.Int32); if (PostId == 0) Param.Add("b.Post", ">", 0, DbType.Int32); } else if (TrackState == 0) { Param.Add("b.TrackState", "=", 0, DbType.Int32); } if (DateType == 1) { if (SDate != null) Param.Add("a.OrderDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.OrderDate", "<=", EDate, DbType.DateTime); } else if (DateType == 2) { if (SDate != null) Param.Add("a.InDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.InDate", "<=", EDate, DbType.DateTime); } else if (DateType == 3) { if (SDate != null) Param.Add("a.PrintDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.PrintDate", "<=", EDate, DbType.DateTime); } else if (DateType == 4) { if (SDate != null) Param.Add("a.PostDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.PostDate", "<=", EDate, DbType.DateTime); } else if (DateType == 5) { if (SDate != null) Param.Add("a.OrderOutDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.OrderOutDate", "<=", EDate, DbType.DateTime); } if (OutDays > 0) { Param.Add("a.OrderOutDate", "<=", DateTime.Today.AddDays(OutDays), DbType.DateTime); } if (PrintState == -1 && FHState > -1) { Param.Add("a.poststate", "=", FHState, DbType.Int32); if (IsError == 1) { Param.Add("isnull(b.ErrorInfo,'')", "<>", "", DbType.String); } } else { if (IsError == 1) { Param.Add("(a.PostState", "=", 2, DbType.Int32); Param.Add("isnull(b.ErrorInfo,'')", "<>", "", "or", ")", DbType.String); } else Param.Add("a.PostState", "<", 2, DbType.Int32); } if (PrintState > -1) Param.Add("a.PrintState", "=", PrintState, DbType.Int32); if (PrintState > -1) Param.Add("a.State", "=", 1, DbType.Int32); else { Param.Add("a.State", ">", 0, DbType.Int32); Param.Add("a.State", "<", 3, DbType.Int32); //Param.Add("b.RevPhone", "is", null, "or",")",DbType.String); } if (LogicId == -2) Param.Add("b.LogisticsId", "in", "10,13", DbType.String); else if (LogicId > 0) Param.Add("b.LogisticsId", "=", LogicId, DbType.Int32); if (PostId > 0) Param.Add("b.Post", "=", PostId, DbType.Int32); if (HBOrder == 1) Param.Add("a.IsJoin", "=", 1, DbType.Int32); //if (IsError == 1) //{ // Param.Add("(b.SendAddr", ">", 0, DbType.Int32); // Param.Add("b.IsLeaveWord", "=", 1, "or", ")", DbType.Int32); //} if (IsAddr > -1) { Param.Add("b.SendAddr", "=", IsAddr, DbType.Int32); } string TCode = ""; if (Name != "") { Name = Name.Trim(); if (TjType == 1) { Param.Add("(a.PlatOrderCode", "=", Name, DbType.String); Param.Add("a.JoinOrderCode", "=", Name, "or", ")", DbType.String); } else if (TjType == 2) { Param.Add("b.RevName", "like", Name, DbType.String); } else if (TjType == 3) { Param.Add("b.RevPhone", "like", Name, DbType.String); } else if (TjType == 4) { Param.Add("(b.RevCountry", "=", Name, DbType.String); Param.Add("b.CountryName", "=", Name, "or", DbType.String); Param.Add("b.CountryCode", "=", Name, "or", ")", DbType.String); } else if (TjType == 5) { Param.Add("b.RevPostCode", "=", Name, DbType.String); } else if (TjType == 6) { Param.Add("(b.RevAddr", "like", Name, DbType.String); Param.Add("b.RevProvince", "like", Name, "or", DbType.String); Param.Add("b.RevCity", "like", Name, "or", DbType.String); Param.Add("b.RevArea", "like", Name, "or", ")", DbType.String); } else if (TjType == 9) { Param.Add("(b.ErrorInfo", "like", Name, DbType.String); Param.Add("b.PostError", "like", Name, "or", ")", DbType.String); } else if (TjType == 10) { // Param.Add("b.TrackCode", "like", Name, DbType.String); TCode = Name; } } if (StoreId > 0) { if (StoreId == 6) { Param.Add("b.StoreId", "in", "6,9", DbType.String); } else Param.Add("b.StoreId", "=", StoreId, DbType.Int32); } //if (IsError == 2) //{ // Param.Add("(a.SendAddr", ">", 0, DbType.Int32); // Param.Add("a.IsLeaveWord", "=", 1, "or", ")", DbType.Int32); //} if (IsWeight == 2) { Param.Add("isnull(a.IsSpare,0)", "=", 1, DbType.Int32); } else if (IsWeight == 1) { Param.Add("isnull(a.IsSpare,0)", "=", 0, DbType.Int32); } //if (IsSku == 0) // Param.Add("a.FPDate", "is", null, DbType.String); //else if (IsSku == 1) // Param.Add("a.FPDate", "is not", null, DbType.String); //Param.Add("a.OrderDate", ">=", 0, DbType.Int32); JsonModel> resultModel = new JsonModel>(); int RowCount = 0; //string Sort = "orderid desc"; //if (PrintState == 0) // Sort = "orderid"; string GoodsName = ""; string Code = ""; if (GoodsInfo != "") { GoodsName = GoodsInfo.Trim(); if (GoodsInfo.Trim().Contains(' ')) { GoodsName = GoodsInfo.Trim().Split(' ')[0].Trim(); Code = GoodsInfo.Trim().Split(' ')[1].Trim(); } } //else // if (TjType == 8 && Name != "") // { // SKU = Name; // } List orderlist = new List(); List ordertemp = new List(); if (PrintState > -1) orderlist = DataNew.GetListDT_PrintOrderInfoForTM2(CompanyId, TCode, GoodsName, 0, Code, KWCode, IsSku, GM, PrintState, Param, PageIndex, PageSize, Sort, out RowCount); else orderlist = DataNew.GetListDT_PrintOrderInfoForTM(CompanyId, TCode, GoodsName, 0, Code, KWCode, IsSku, Param, PageIndex, PageSize, Sort, out RowCount); string Ids = ""; if (orderlist != null) { foreach (var md in orderlist) { Ids += md.OrderId.ToString() + ","; if (IsError > 0) { if (IsError == 3) { int check = CheckNum(md.RevPostCode); if (check == 0) { ordertemp.Add(md); } } else if (IsError == 2) { int check = CheckNum(md.RevPostCode); if (check == 1 && md.ErrorInfo == "") { ordertemp.Add(md); } } else { ordertemp.Add(md); } } else { ordertemp.Add(md); } } } orderlist = new List(); if (Ids != "") { JC_ExpressService obj3 = new JC_ExpressService(); // var elist = obj3.GetExpressTypeList(); var plist = obj3.GetExpressList(); var errorlist = obj.GetErrorList(Ids.Trim(',')); if (errorlist != null || plist != null) { foreach (var md in ordertemp) { if (errorlist != null && errorlist.Count > 0) { var emd = errorlist.Find(n => n.OrderId == md.OrderId); if (emd != null) { md.ErrorInfo = emd.ErrorInfo; } } if (md.Post > 0 && plist != null && plist.Count > 0) { var emd = plist.Find(n => n.ExpressID == md.Post); if (emd != null) { md.PostInfo = emd.Name; } } } } } if (IsDetail == 0 && ordertemp != null) { if (Ids != "") { var listTrack = obj.GetTrackCodeApplyList2(Ids.Trim(',')); if (listTrack != null) { foreach (var md in ordertemp) { var list3 = new List(); if (md.JoinOrderCode != null && md.JoinOrderCode != "") list3 = listTrack.FindAll(n => n.OrderCode == md.JoinOrderCode); else list3 = listTrack.FindAll(n => n.OrderId == md.OrderId); if (list3 != null && list3.Count > 0) { string trackinfo = ""; int tcount = 0; foreach (var md1 in list3) { if (md1.TrackType < 3) { trackinfo += md1.TrackCode + ","; tcount++; } } if (IsWeight == 1 && tcount > 1 && IsError == 2) { ordertemp.Remove(md); } if (IsError == 5 && IsWeight == 1 && tcount > 1) { orderlist.Add(md); } md.TrackCode = trackinfo; } } } } } else if (IsDetail == 1 && ordertemp != null) { if (Ids != "") { var listTrack = obj.GetTrackCodeApplyList2(Ids.Trim(',')); // ErrorFollow.TraceWrite("GetOrderGoodsPostionList", Ids, DateTime.Now.ToString("HH:mm:ss fff")); var list1 = DataNew.GetOrderGoodsPostionList(Ids.Trim(',')); // ErrorFollow.TraceWrite("GetOrderGoodsPostionList", "2", DateTime.Now.ToString("HH:mm:ss fff")); if (list1 != null) { foreach (var md in ordertemp) { md.OrderLevel = 0; md.OrderName = ""; md.GoodsCode = ""; var list2 = list1.FindAll(n => n.OrderId == md.OrderId); if (list2 != null) { md.GoodsList = list2; md.IsBlank = 0; if (PostionCode != "") { var pmd = list2.Find(n => n.PostionCode.Contains(PostionCode) == true); if (pmd != null) md.IsBlank = 1; } if (list2.Count > 0) { md.OrderLevel = list2[0].LockNum; md.OrderName = list2[0].PostionCode; md.GoodsCode = list2[0].GoodsCode; } if (SNum > 0 && ENum == 0) { if (list2.Sum(o => o.GoodsNum).GetValueOrDefault(0) >= SNum) { orderlist.Add(md); } } if (SNum > 0 && ENum > 0) { if (list2.Sum(o => o.GoodsNum).GetValueOrDefault(0) >= SNum && list2.Sum(o => o.GoodsNum).GetValueOrDefault(0) <= ENum) { orderlist.Add(md); } } if (SNum == 0 && ENum > 0) { if (list2.Sum(o => o.GoodsNum).GetValueOrDefault(0) <= ENum) { orderlist.Add(md); } } } var list3 = new List(); if (listTrack != null) { if (md.JoinOrderCode != null && md.JoinOrderCode != "") list3 = listTrack.FindAll(n => n.OrderCode == md.JoinOrderCode); else list3 = listTrack.FindAll(n => n.OrderId == md.OrderId); } if (list3 != null && list3.Count > 0) { string trackinfo = ""; int tcount = 0; foreach (var md1 in list3) { if (md1.TrackType < 3) { trackinfo += md1.TrackCode + ","; tcount++; } } if (IsWeight == 1 && tcount > 1 && IsError == 2) { ordertemp.Remove(md); } if (IsError == 5 && IsWeight == 1 && tcount > 1) { orderlist.Add(md); } md.TrackCode = trackinfo; } } } } } // ErrorFollow.TraceWrite("GetOrderGoodsPostionList", "3", DateTime.Now.ToString("HH:mm:ss fff")); if (IsError == 5) ordertemp = orderlist; if (orderlist != null) { if (orderlist.Count() > 0) ordertemp = orderlist; } if (PostionCode2 != "") { ordertemp = ordertemp.FindAll(n => n.IsBlank == 0); } else if (PostionCode != "") { ordertemp = ordertemp.FindAll(n => n.IsBlank == 1); } // ErrorFollow.TraceWrite("GetOrderGoodsPostionList", "4", DateTime.Now.ToString("HH:mm:ss fff")); List orderList2 = new List(); // if(PostionCode==""||PostionCode2!="") //orderList2= ordertemp.OrderBy(s => s.OrderLevel).ThenBy(s => s.OrderName).ThenBy(s => s.GoodsCode).ToList(); // else // orderList2 = ordertemp.OrderBy(s => s.GoodsCode).ThenBy(s => s.OrderLevel).ThenBy(s => s.OrderName).ToList(); // orderList2 = ordertemp.OrderBy(s => s.OrderLevel).OrderBy(s => s.OrderName).ThenBy(s => s.GoodsCode).ThenByDescending(s => s.GoodsNum).ToList(); // ErrorFollow.TraceWrite("GetOrderGoodsPostionList", "5", DateTime.Now.ToString("HH:mm:ss fff")); var query = from s in ordertemp orderby s.OrderLevel, s.OrderName, s.GoodsCode, s.GoodsNum descending  //排序 select s; orderList2 = query.ToList(); resultModel.DataSource = orderList2.Take(PageSize).Skip(PageSize * (PageIndex - 1)).ToList(); DataTable tb = new DataTable(); tb.Columns.Add("ordercode", Type.GetType("System.String")); //tb.Columns.Add("hbordercode", Type.GetType("System.String")); tb.Columns.Add("goodscode", Type.GetType("System.String")); tb.Columns.Add("goodscode2", Type.GetType("System.String")); tb.Columns.Add("num", Type.GetType("System.String")); tb.Columns.Add("kwcode", Type.GetType("System.String")); tb.Columns.Add("sortno", Type.GetType("System.String")); tb.Columns.Add("trackcode", Type.GetType("System.String")); string ids2 = ""; if (resultModel.DataSource != null) { foreach (var md in resultModel.DataSource) { ids2 += md.OrderId + ","; DataRow row = tb.NewRow(); if (md.JoinOrderCode != null && md.JoinOrderCode != "") row["ordercode"] = md.PlatOrderCode + " [合" + md.JoinOrderCode + "]"; else row["ordercode"] = md.PlatOrderCode; // row["hbordercode"] = md.JoinOrderCode; row["trackcode"] = md.TrackCode.TrimEnd(','); //tb.Rows.Add(row); if (md.GoodsList != null) { int i = 0; foreach (var gmd in md.GoodsList) { i++; if (i == 1) { if (gmd.OldTypeDesc != null && gmd.OldTypeDesc != "") row["goodscode"] = gmd.OldTypeDesc; else row["goodscode"] = gmd.GoodsCode; if (gmd.GoodsOldCode != null) row["goodscode2"] = gmd.GoodsOldCode; row["num"] = gmd.GoodsNum.ToString(); row["kwcode"] = gmd.PostionCode.ToString(); row["sortno"] = gmd.LockNum.ToString(); tb.Rows.Add(row); } else { DataRow row1 = tb.NewRow(); row1["ordercode"] = ""; if (gmd.OldTypeDesc != null && gmd.OldTypeDesc != "") row1["goodscode"] = gmd.OldTypeDesc; else row1["goodscode"] = gmd.GoodsCode; if (gmd.GoodsOldCode != null) row1["goodscode2"] = gmd.GoodsOldCode; row1["num"] = gmd.GoodsNum.ToString(); row1["kwcode"] = gmd.PostionCode.ToString(); row1["sortno"] = gmd.LockNum.ToString(); tb.Rows.Add(row1); } } } } DataTable dtCopy = tb.Copy(); DataView dv = tb.DefaultView; // dv.Sort = "sortno,kwcode"; dtCopy = dv.ToTable(); if (ids2 != null) { DataRow row2 = dtCopy.NewRow(); row2["ordercode"] = ""; row2["goodscode"] = ""; row2["goodscode2"] = ""; row2["num"] = ""; row2["kwcode"] = ""; dtCopy.Rows.Add(row2); row2 = dtCopy.NewRow(); row2["ordercode"] = ""; row2["goodscode"] = ""; row2["goodscode2"] = ""; row2["num"] = ""; row2["kwcode"] = ""; dtCopy.Rows.Add(row2); row2 = dtCopy.NewRow(); row2["ordercode"] = "Total:"; row2["goodscode"] = ""; row2["goodscode2"] = ""; row2["num"] = ""; row2["kwcode"] = ""; dtCopy.Rows.Add(row2); List list8 = DataNew.GetOrderGoodsPostionList22(ids2.Trim(',')); if (list8 != null) { foreach (DT_OrderGoods goods2 in list8) { row2 = dtCopy.NewRow(); row2["ordercode"] = ""; if (goods2.OldTypeDesc != null && goods2.OldTypeDesc != "") row2["goodscode"] = goods2.OldTypeDesc; else row2["goodscode"] = goods2.GoodsCode; row2["goodscode2"] = goods2.GoodsOldCode; row2["num"] = goods2.GoodsNum; row2["kwcode"] = goods2.PostionCode; dtCopy.Rows.Add(row2); } } } string cn = "QTY" + DateTime.Today.ToString("MMdd"); TableColumnCollection listColumns = new TableColumnCollection(); listColumns.Add("ordercode", "OrderCode", DbType.String, ""); listColumns.Add("goodscode", "SKU", DbType.String, ""); listColumns.Add("goodscode2", "GoodsCode2", DbType.String, ""); listColumns.Add("num", cn, DbType.String, ""); listColumns.Add("kwcode", "LOCATION", DbType.String, ""); listColumns.Add("trackcode", "Trackcode", DbType.String, ""); MicrosoftExcel obj2 = new MicrosoftExcel(); return obj2.Export(dtCopy, listColumns); } return ""; } #endregion #region 修改货物 [WebMethod(EnableSession = true)] public void UpdateOrderGoodsListForTM(int GoodsNum, int OrderId) { PagesNew.Login(this.Session); var obj = new DD_OrderData(); DataNew.UpdateOrderBuyDateForTM2(OrderId, GoodsNum); } #endregion [WebMethod(EnableSession = true)] public string GetFedexFee2(DT_OrderModelNew omd, List glist, int PostId, string PostType) { PagesNew.Login(base.Session); int companyId = Convert.ToInt32(base.Session["CompanyId"]); JC_ExpressService service = new JC_ExpressService(); JC_PostAddress address = new BaseService().GetAddressModel2(PostId); JC_ExpressPost expressModel = service.GetExpressModel(companyId, PostId); decimal num2 = 0M; if (glist != null) { foreach (DT_OrderMateGoods goods in glist) { decimal? nullable; if (!(goods.Weight.HasValue && !(((nullable = goods.Weight).GetValueOrDefault() <= 0M) && nullable.HasValue))) { return (goods.GoodsName + "重量没填,无法计算"); } if (goods.Width2.HasValue) { nullable = goods.Width2; if (!((nullable.GetValueOrDefault() <= 0M) && nullable.HasValue) && goods.Length2.HasValue) { nullable = goods.Length2; } } if ((((nullable.GetValueOrDefault() <= 0M) && nullable.HasValue) || !goods.Height2.HasValue) || (((nullable = goods.Height2).GetValueOrDefault() <= 0M) && nullable.HasValue)) { return (goods.GoodsName + "长宽高没填,无法计算"); } num2 += goods.Weight.Value * goods.GoodsNum.Value; } } TradeManageNew.FedexRateNew rate = new TradeManageNew.FedexRateNew(); TradeManageNew.FedexRateNew.Key = expressModel.UserCode; TradeManageNew.FedexRateNew.Password = expressModel.CheckCode; TradeManageNew.FedexRateNew.AccountNumber = expressModel.client_id; TradeManageNew.FedexRateNew.MeterNumber = expressModel.client_secret; TradeManageNew.FedexRateNew.PayAccountNumber = expressModel.refresh_token; TradeManageNew.FedexRateNew.HubId = expressModel.Code; TradeManageNew.FedexRateNew.PostId = PostId; TradeManageNew.FedexFeeMdNew md = new TradeManageNew.FedexFeeMdNew { RevName = omd.RevName, RevPhone = omd.RevPhone }; if ((omd.RevPhone == null) || (omd.RevPhone == "")) { md.RevPhone = omd.RevMoblie; } md.OrderId = omd.OrderId; md.PostType = PostType; md.SendAddr = address.EnglishAddress; md.SendCountry = address.countycode; md.SendCity = address.city; md.SendProv = address.provincecode; md.SendPostCode = address.PostCode; md.RevAddr = omd.RevAddr; md.RevCity = omd.RevCity; if ((omd.RevCity == null) || (omd.RevCity == "")) { md.RevCity = omd.RevProvince; } if ((omd.RevProvinceCode != null) && (omd.RevProvinceCode != "")) { md.RevProv = omd.RevProvinceCode; } else if (((omd.RevProvince != null) && (omd.RevProvince != "")) && (omd.RevProvince.Length > 2)) { md.RevProv = omd.RevProvince.Substring(omd.RevProvince.Length - 2, 2); } else { md.RevProv = omd.RevProvince; } md.RevPostCode = omd.RevPostCode; md.RevCountry = omd.CountryCode; md.Width = Math.Ceiling(glist[0].Width2.Value).ToString(); md.Height = Math.Ceiling(glist[0].Height2.Value).ToString(); md.Lenght = Math.Ceiling(glist[0].Length2.Value).ToString(); md.Weight = new decimal?(num2); string outError = ""; string fee = rate.GetFee(md, out outError); if (outError != "") { return outError; } return fee; } #region 获取Fedex多种运输方式的运费 [WebMethod(EnableSession = true)] public List GetFedexFeeDetail(DT_OrderModelNew omd, List glist) { Pages.Login(base.Session); var rmodel = new List(); var postTypes = new List() { "SMART_POST", "FEDEX_2_DAY", "FEDEX_GROUND", "GROUND_HOME_DELIVERY" }; var postIds = new List() { 228, 237 };//W仓,E仓 foreach (var postId in postIds) { int companyId = Convert.ToInt32(base.Session["CompanyId"]); JC_ExpressService service = new JC_ExpressService(); JC_PostAddress address = new BaseService().GetAddressModel2(postId); JC_ExpressPost expressModel = service.GetExpressModel(companyId, postId); decimal num2 = 0M; string Width = ""; string Height = ""; string Lenght = ""; if (glist != null) { Width = Math.Ceiling(glist[0].Width2.Value).ToString(); Height = Math.Ceiling(glist[0].Height2.Value).ToString(); Lenght = Math.Ceiling(glist[0].Length2.Value).ToString(); foreach (DT_OrderMateGoods goods in glist) { decimal? nullable; if (!(goods.Weight.HasValue && !(((nullable = goods.Weight).GetValueOrDefault() <= 0M) && nullable.HasValue))) { return rmodel; } if (goods.Width2.HasValue) { nullable = goods.Width2; if (!((nullable.GetValueOrDefault() <= 0M) && nullable.HasValue) && goods.Length2.HasValue) { nullable = goods.Length2; } } if ((((nullable.GetValueOrDefault() <= 0M) && nullable.HasValue) || !goods.Height2.HasValue) || (((nullable = goods.Height2).GetValueOrDefault() <= 0M) && nullable.HasValue)) { return rmodel; } num2 += goods.Weight.Value * goods.GoodsNum.Value; } } TradeManageNew.FedexRateNew3 rate = new TradeManageNew.FedexRateNew3(); TradeManageNew.FedexRateNew3.Key = expressModel.UserCode; TradeManageNew.FedexRateNew3.Password = expressModel.CheckCode; TradeManageNew.FedexRateNew3.AccountNumber = expressModel.client_id; TradeManageNew.FedexRateNew3.MeterNumber = expressModel.client_secret; TradeManageNew.FedexRateNew3.PayAccountNumber = expressModel.refresh_token; TradeManageNew.FedexRateNew3.HubId = expressModel.Code; TradeManageNew.FedexRateNew3.PostId = postId; TradeManageNew.FedexFeeMdNew md = new TradeManageNew.FedexFeeMdNew { RevName = omd.RevName, RevPhone = omd.RevPhone }; if ((omd.RevPhone == null) || (omd.RevPhone == "")) { md.RevPhone = omd.RevMoblie; } md.OrderId = omd.OrderId; //md.PostType = PostType; md.SendAddr = address.EnglishAddress; md.SendCountry = address.countycode; md.SendCity = address.city; md.SendProv = address.provincecode; md.SendPostCode = address.PostCode; md.RevAddr = omd.RevAddr; md.RevCity = omd.RevCity; if ((omd.RevCity == null) || (omd.RevCity == "")) { md.RevCity = omd.RevProvince; } if ((omd.RevProvinceCode != null) && (omd.RevProvinceCode != "")) { md.RevProv = omd.RevProvinceCode; } else if (((omd.RevProvince != null) && (omd.RevProvince != "")) && (omd.RevProvince.Length > 2)) { md.RevProv = omd.RevProvince.Substring(omd.RevProvince.Length - 2, 2); } else { md.RevProv = omd.RevProvince; } md.RevPostCode = omd.RevPostCode; md.RevCountry = omd.CountryCode; md.Width = Math.Ceiling(glist[0].Width2.Value).ToString(); md.Height = Math.Ceiling(glist[0].Height2.Value).ToString(); md.Lenght = Math.Ceiling(glist[0].Length2.Value).ToString(); md.Weight = new decimal?(num2); foreach (var postType in postTypes) { md.PostType = postType; var feeObj = rate.GetFee(md); if (feeObj != null) { rmodel.Add(feeObj); } Thread.Sleep(1000); } } return rmodel; } [WebMethod(EnableSession = true)] public List GetFedexFeeDetail2(DT_OrderModelNew omd, List glist, string postType) { Pages.Login(base.Session); var rmodel = new List(); var postIds = new List() { 228, 237 };//W仓,E仓 foreach (var postId in postIds) { int companyId = Convert.ToInt32(base.Session["CompanyId"]); JC_ExpressService service = new JC_ExpressService(); JC_PostAddress address = new BaseService().GetAddressModel2(postId); JC_ExpressPost expressModel = service.GetExpressModel(companyId, postId); decimal num2 = 0M; string Width = ""; string Height = ""; string Lenght = ""; if (glist != null) { Width = Math.Ceiling(glist[0].Width2.Value).ToString(); Height = Math.Ceiling(glist[0].Height2.Value).ToString(); Lenght = Math.Ceiling(glist[0].Length2.Value).ToString(); foreach (DT_OrderMateGoods goods in glist) { decimal? nullable; if (!(goods.Weight.HasValue && !(((nullable = goods.Weight).GetValueOrDefault() <= 0M) && nullable.HasValue))) { return rmodel; } if (goods.Width2.HasValue) { nullable = goods.Width2; if (!((nullable.GetValueOrDefault() <= 0M) && nullable.HasValue) && goods.Length2.HasValue) { nullable = goods.Length2; } } if ((((nullable.GetValueOrDefault() <= 0M) && nullable.HasValue) || !goods.Height2.HasValue) || (((nullable = goods.Height2).GetValueOrDefault() <= 0M) && nullable.HasValue)) { return rmodel; } num2 += goods.Weight.Value * goods.GoodsNum.Value; } } TradeManageNew.FedexRateNew3 rate = new TradeManageNew.FedexRateNew3(); TradeManageNew.FedexRateNew3.Key = expressModel.UserCode; TradeManageNew.FedexRateNew3.Password = expressModel.CheckCode; TradeManageNew.FedexRateNew3.AccountNumber = expressModel.client_id; TradeManageNew.FedexRateNew3.MeterNumber = expressModel.client_secret; TradeManageNew.FedexRateNew3.PayAccountNumber = expressModel.refresh_token; TradeManageNew.FedexRateNew3.HubId = expressModel.Code; TradeManageNew.FedexRateNew3.PostId = postId; TradeManageNew.FedexFeeMdNew md = new TradeManageNew.FedexFeeMdNew { RevName = omd.RevName, RevPhone = omd.RevPhone }; if ((omd.RevPhone == null) || (omd.RevPhone == "")) { md.RevPhone = omd.RevMoblie; } md.OrderId = omd.OrderId; md.PostType = postType; md.SendAddr = address.EnglishAddress; md.SendCountry = address.countycode; md.SendCity = address.city; md.SendProv = address.provincecode; md.SendPostCode = address.PostCode; md.RevAddr = omd.RevAddr; md.RevCity = omd.RevCity; if ((omd.RevCity == null) || (omd.RevCity == "")) { md.RevCity = omd.RevProvince; } if ((omd.RevProvinceCode != null) && (omd.RevProvinceCode != "")) { md.RevProv = omd.RevProvinceCode; } else if (((omd.RevProvince != null) && (omd.RevProvince != "")) && (omd.RevProvince.Length > 2)) { md.RevProv = omd.RevProvince.Substring(omd.RevProvince.Length - 2, 2); } else { md.RevProv = omd.RevProvince; } md.RevPostCode = omd.RevPostCode; md.RevCountry = omd.CountryCode; md.Width = Math.Ceiling(glist[0].Width2.Value).ToString(); md.Height = Math.Ceiling(glist[0].Height2.Value).ToString(); md.Lenght = Math.Ceiling(glist[0].Length2.Value).ToString(); md.Weight = new decimal?(num2); var feeObj = rate.GetFee(md); if (feeObj != null) { rmodel.Add(feeObj); } } return rmodel; } #endregion [WebMethod(EnableSession = true)] public string GetFedexFee22(DT_OrderModel omd, DT_OrderMateGoods gmd, int PostId, string PostType) { PagesNew.Login(base.Session); int companyId = Convert.ToInt32(base.Session["CompanyId"]); JC_ExpressService service = new JC_ExpressService(); JC_PostAddress address = new BaseService().GetAddressModel2(PostId); JC_ExpressPost expressModel = service.GetExpressModel(companyId, PostId); decimal num2 = 0M; var goods = gmd; decimal? nullable; if (!(goods.Weight.HasValue && !(((nullable = goods.Weight).GetValueOrDefault() <= 0M) && nullable.HasValue))) { return (goods.GoodsName + "重量没填,无法计算"); } if (goods.Width2.HasValue) { nullable = goods.Width2; if (!((nullable.GetValueOrDefault() <= 0M) && nullable.HasValue) && goods.Length2.HasValue) { nullable = goods.Length2; } } if ((((nullable.GetValueOrDefault() <= 0M) && nullable.HasValue) || !goods.Height2.HasValue) || (((nullable = goods.Height2).GetValueOrDefault() <= 0M) && nullable.HasValue)) { return (goods.GoodsName + "长宽高没填,无法计算"); } num2 += goods.Weight.Value * goods.GoodsNum.Value; TradeManageNew.FedexRateNew rate = new TradeManageNew.FedexRateNew(); TradeManageNew.FedexRateNew.Key = expressModel.UserCode; TradeManageNew.FedexRateNew.Password = expressModel.CheckCode; TradeManageNew.FedexRateNew.AccountNumber = expressModel.client_id; TradeManageNew.FedexRateNew.MeterNumber = expressModel.client_secret; TradeManageNew.FedexRateNew.PayAccountNumber = expressModel.refresh_token; TradeManageNew.FedexRateNew.HubId = expressModel.Code; TradeManageNew.FedexFeeMdNew md = new TradeManageNew.FedexFeeMdNew { RevName = omd.RevName, RevPhone = omd.RevPhone }; if ((omd.RevPhone == null) || (omd.RevPhone == "")) { md.RevPhone = omd.RevMoblie; } md.OrderId = -1; md.OrderGoodsId = gmd.Id; md.PostType = PostType; md.SendAddr = address.EnglishAddress; md.SendCountry = address.countycode; md.SendCity = address.city; md.SendProv = address.provincecode; md.SendPostCode = address.PostCode; md.RevAddr = omd.RevAddr; md.RevCity = omd.RevCity; if ((omd.RevCity == null) || (omd.RevCity == "")) { md.RevCity = omd.RevProvince; } if ((omd.RevProvinceCode != null) && (omd.RevProvinceCode != "")) { md.RevProv = omd.RevProvinceCode; } else if (((omd.RevProvince != null) && (omd.RevProvince != "")) && (omd.RevProvince.Length > 2)) { md.RevProv = omd.RevProvince.Substring(omd.RevProvince.Length - 2, 2); } else { md.RevProv = omd.RevProvince; } md.RevPostCode = omd.RevPostCode; md.RevCountry = omd.CountryCode; md.Width = Math.Ceiling(gmd.Width2.Value).ToString(); md.Height = Math.Ceiling(gmd.Height2.Value).ToString(); md.Lenght = Math.Ceiling(gmd.Length2.Value).ToString(); md.Weight = new decimal?(num2); string outError = ""; string fee = rate.GetFee(md, out outError); if (outError != "") { return outError; } return fee; } [WebMethod(EnableSession = true)] public string GetFedexFee33(DT_OrderModelNew omd, List list, int PostId, string PostType) { PagesNew.Login(base.Session); if (list == null) return ""; int UserId = Convert.ToInt32(Session["UserId"]); JC_ExpressService service = new JC_ExpressService(); JC_PostAddress address = new BaseService().GetAddressModel2(PostId); JC_ExpressPost expressModel = service.GetExpressModel(1, PostId); TradeManageNew.FedexRateNew rate = new TradeManageNew.FedexRateNew(); TradeManageNew.FedexRateNew.Key = expressModel.UserCode; TradeManageNew.FedexRateNew.Password = expressModel.CheckCode; TradeManageNew.FedexRateNew.AccountNumber = expressModel.client_id; TradeManageNew.FedexRateNew.MeterNumber = expressModel.client_secret; TradeManageNew.FedexRateNew.PayAccountNumber = expressModel.refresh_token; TradeManageNew.FedexRateNew.HubId = expressModel.Code; TradeManageNew.FedexRateNew.PostId = PostId; TradeManageNew.FedexFeeMdNew md = new TradeManageNew.FedexFeeMdNew { RevName = omd.RevName, RevPhone = omd.RevPhone }; if ((omd.RevPhone == null) || (omd.RevPhone == "")) { md.RevPhone = omd.RevMoblie; } md.OrderId = omd.OrderId; md.OrderGoodsId = 1; md.PostType = PostType; md.SendAddr = address.EnglishAddress; md.SendCountry = address.countycode; md.SendCity = address.city; md.SendProv = address.provincecode; md.SendPostCode = address.PostCode; md.RevAddr = omd.RevAddr; md.RevCity = omd.RevCity; if ((omd.RevCity == null) || (omd.RevCity == "")) { md.RevCity = omd.RevProvince; } if ((omd.RevProvinceCode != null) && (omd.RevProvinceCode != "")) { md.RevProv = omd.RevProvinceCode; } else if (((omd.RevProvince != null) && (omd.RevProvince != "")) && (omd.RevProvince.Length > 2)) { md.RevProv = omd.RevProvince.Substring(omd.RevProvince.Length - 2, 2); } else { md.RevProv = omd.RevProvince; } md.RevPostCode = omd.RevPostCode; md.RevCountry = omd.CountryCode; //DataNew.Delete_SpareFee(omd.OrderId.Value); string error = ""; string fee = ""; foreach (var gmd in list) { gmd.OrderId = omd.OrderId; gmd.InDate = DateTime.Now; gmd.InUserId = UserId; // int Id = DataNew.Save_SpareFee(gmd); md.OrderGoodsId = gmd.Id.Value; md.Width = Math.Ceiling(Convert.ToDecimal(gmd.Width)).ToString(); md.Height = Math.Ceiling(Convert.ToDecimal(gmd.Height)).ToString(); md.Lenght = Math.Ceiling(Convert.ToDecimal(gmd.Long)).ToString(); md.Weight = Math.Ceiling(Convert.ToDecimal(gmd.Weight)); string outError = ""; fee += rate.GetFee(md, out outError); System.Threading.Thread.Sleep(1000); if (outError != "") { error += outError; } } //DataNew.Delete_SpareFee2(omd.OrderId.Value); DataNew.Sum_SpareFee(PostId,omd.OrderId.Value, PostType); if (error != "") return error; else return fee; } [WebMethod(EnableSession = true)] public string GetUPSFee(DT_OrderModelNew omd, List glist, int PostId, string PostType) { PagesNew.Login(base.Session); int companyId = Convert.ToInt32(base.Session["CompanyId"]); JC_ExpressService service = new JC_ExpressService(); JC_PostAddress address = new BaseService().GetAddressModel2(PostId); JC_ExpressPost expressModel = service.GetExpressModel(companyId, PostId); decimal num2 = 0M; int totalNum = 0; if (glist != null) { foreach (DT_OrderMateGoods goods in glist) { decimal? nullable; if (!(goods.Weight.HasValue && !(((nullable = goods.Weight).GetValueOrDefault() <= 0M) && nullable.HasValue))) { return (goods.GoodsName + "重量没填,无法计算"); } //if (goods.Width2.HasValue) //{ // nullable = goods.Width2; // if (!((nullable.GetValueOrDefault() <= 0M) && nullable.HasValue) && goods.Length2.HasValue) // { // nullable = goods.Length2; // } //} //if ((((nullable.GetValueOrDefault() <= 0M) && nullable.HasValue) || !goods.Height2.HasValue) || (((nullable = goods.Height2).GetValueOrDefault() <= 0M) && nullable.HasValue)) //{ // return (goods.GoodsName + "长宽高没填,无法计算"); //} num2 += goods.Weight.Value * goods.GoodsNum.Value; totalNum += goods.GoodsNum.Value; } } TradeManageNew.UPSRate rate = new TradeManageNew.UPSRate(); TradeManageNew.UPSRate.AccessLicenseNumber = expressModel.client_id; TradeManageNew.UPSRate.Username = expressModel.UserCode; TradeManageNew.UPSRate.Password = expressModel.CheckCode; TradeManageNew.UPSRate.ShipperNumber = expressModel.Code; TradeManageNew.FedexFeeMdNew md = new TradeManageNew.FedexFeeMdNew { RevName = omd.RevName, RevPhone = omd.RevPhone }; if ((omd.RevPhone == null) || (omd.RevPhone == "")) { md.RevPhone = omd.RevMoblie; } md.OrderId = omd.OrderId; md.PostType = PostType; md.packType = "02"; md.SendAddr = address.EnglishAddress; md.SendCountry = address.countycode; md.SendCity = address.city; md.SendProv = address.provincecode; md.SendPostCode = address.PostCode; md.RevAddr = omd.RevAddr; md.RevCity = omd.RevCity; if ((omd.RevCity == null) || (omd.RevCity == "")) { md.RevCity = omd.RevProvince; } if ((omd.RevProvinceCode != null) && (omd.RevProvinceCode != "")) { md.RevProv = omd.RevProvinceCode; } else if (((omd.RevProvince != null) && (omd.RevProvince != "")) && (omd.RevProvince.Length > 2)) { md.RevProv = omd.RevProvince.Substring(omd.RevProvince.Length - 2, 2); } else { md.RevProv = omd.RevProvince; } md.RevPostCode = omd.RevPostCode; md.RevCountry = omd.CountryCode; md.Width = Math.Ceiling(glist[0].Width2.Value).ToString(); md.Height = Math.Ceiling(glist[0].Height2.Value).ToString(); md.Lenght = Math.Ceiling(glist[0].Length2.Value).ToString(); md.Weight = num2 * 0.0625M; md.TotalNum = totalNum.ToString(); string outError = ""; string fee = rate.GetFeeNew(md); //获取到的ups运费更新到订单中 if (!fee.Contains("ErrorMessage:")) { var infos = fee.Split('&'); DataNew.UpdateOrderUPSPostFee(omd.OrderId.Value, string.IsNullOrEmpty(infos[0]) ? 0 : Convert.ToDecimal(infos[0]), PostId, infos[1]); } else { DataNew.UpdateOrderUPSLog(omd.OrderId.Value, fee); } return fee; } [WebMethod(EnableSession = true)] public DT_OrderModelNew GetUPSFeeNew(DT_OrderModelNew omd, List glist) { PagesNew.Login(base.Session); DT_OrderModelNew mdfee = new DT_OrderModelNew(); mdfee.ErrorInfo = ""; int companyId = Convert.ToInt32(base.Session["CompanyId"]); decimal num2 = 0M; int totalNum = 0; if (glist != null) { foreach (DT_OrderMateGoods goods in glist) { decimal? nullable; if (!(goods.Weight.HasValue && !(((nullable = goods.Weight).GetValueOrDefault() <= 0M) && nullable.HasValue))) { mdfee.ErrorInfo = goods.GoodsName + "重量没填,无法计算"; return mdfee; } num2 += goods.Weight.Value * goods.GoodsNum.Value; totalNum += goods.GoodsNum.Value; } } int PostId = 244;//e仓 string PostType = "03";//ups ground string fee = GetUPSAPIFee(omd, glist, num2, totalNum, companyId, PostId, PostType); PostId = 243;//e仓 PostType = "93";//UPS SurePost? 1 lb or Greater string fee2 = GetUPSAPIFee(omd, glist, num2, totalNum, companyId, PostId, PostType); PostId = 242;//w仓 PostType = "03";//ups ground string fee3 = GetUPSAPIFee(omd, glist, num2, totalNum, companyId, PostId, PostType); PostId = 241;//w仓 PostType = "93";//UPS SurePost? 1 lb or Greater string fee4 = GetUPSAPIFee(omd, glist, num2, totalNum, companyId, PostId, PostType); //获取到的ups运费更新到订单中 if (!fee.Contains("ErrorMessage:")) { var infos = fee.Split('&'); DataNew.UpdateOrderUpsFee(omd.OrderId.Value, string.IsNullOrEmpty(infos[0]) ? 0 : Convert.ToDecimal(infos[0]), 0, 0, 0); mdfee.UpsFeeE1 = string.IsNullOrEmpty(infos[0]) ? 0 : Convert.ToDecimal(infos[0]); } else { mdfee.ErrorInfo = fee; } if (!fee2.Contains("ErrorMessage:")) { var infos = fee2.Split('&'); DataNew.UpdateOrderUpsFee(omd.OrderId.Value, 0,string.IsNullOrEmpty(infos[0]) ? 0 : Convert.ToDecimal(infos[0]), 0, 0); mdfee.UpsFeeE2 = string.IsNullOrEmpty(infos[0]) ? 0 : Convert.ToDecimal(infos[0]); } else { mdfee.ErrorInfo = fee2; } if (!fee3.Contains("ErrorMessage:")) { var infos = fee3.Split('&'); DataNew.UpdateOrderUpsFee(omd.OrderId.Value, 0,0,string.IsNullOrEmpty(infos[0]) ? 0 : Convert.ToDecimal(infos[0]), 0); mdfee.UpsFeeW1 = string.IsNullOrEmpty(infos[0]) ? 0 : Convert.ToDecimal(infos[0]); } else { mdfee.ErrorInfo = fee3; } if (!fee4.Contains("ErrorMessage:")) { var infos = fee4.Split('&'); DataNew.UpdateOrderUpsFee(omd.OrderId.Value, 0, 0,0,string.IsNullOrEmpty(infos[0]) ? 0 : Convert.ToDecimal(infos[0])); mdfee.UpsFeeW2 = string.IsNullOrEmpty(infos[0]) ? 0 : Convert.ToDecimal(infos[0]); } else { mdfee.ErrorInfo = fee4; } return mdfee; } public string GetUPSAPIFee(DT_OrderModelNew omd, List glist, decimal num2,int totalNum,int companyId,int PostId,string PostType) { JC_ExpressService service = new JC_ExpressService(); JC_PostAddress address = new BaseService().GetAddressModel2(PostId); JC_ExpressPost expressModel = service.GetExpressModel(companyId, PostId); TradeManageNew.UPSRate rate = new TradeManageNew.UPSRate(); TradeManageNew.UPSRate.AccessLicenseNumber = expressModel.client_id; TradeManageNew.UPSRate.Username = expressModel.UserCode; TradeManageNew.UPSRate.Password = expressModel.CheckCode; TradeManageNew.UPSRate.ShipperNumber = expressModel.Code; TradeManageNew.FedexFeeMdNew md = new TradeManageNew.FedexFeeMdNew { RevName = omd.RevName, RevPhone = omd.RevPhone }; if ((omd.RevPhone == null) || (omd.RevPhone == "")) { md.RevPhone = omd.RevMoblie; } md.OrderId = omd.OrderId; md.PostType = PostType; md.packType = "02"; md.SendAddr = address.EnglishAddress; md.SendCountry = address.countycode; md.SendCity = address.city; md.SendProv = address.provincecode; md.SendPostCode = address.PostCode; md.RevAddr = omd.RevAddr; md.RevCity = omd.RevCity; if ((omd.RevCity == null) || (omd.RevCity == "")) { md.RevCity = omd.RevProvince; } if ((omd.RevProvinceCode != null) && (omd.RevProvinceCode != "")) { md.RevProv = omd.RevProvinceCode; } else if (((omd.RevProvince != null) && (omd.RevProvince != "")) && (omd.RevProvince.Length > 2)) { md.RevProv = omd.RevProvince.Substring(omd.RevProvince.Length - 2, 2); } else { md.RevProv = omd.RevProvince; } md.RevPostCode = omd.RevPostCode; md.RevCountry = omd.CountryCode; md.Width = Math.Ceiling(glist[0].Width2.Value).ToString(); md.Height = Math.Ceiling(glist[0].Height2.Value).ToString(); md.Lenght = Math.Ceiling(glist[0].Length2.Value).ToString(); md.Weight = num2 * 0.0625M; md.TotalNum = totalNum.ToString(); string fee = rate.GetFeeNew(md); return fee; } [WebMethod(EnableSession = true)] public string SaveOrderSpare(int OrderId, List list) { PagesNew.Login(base.Session); if (list == null) return ""; int UserId = Convert.ToInt32(Session["UserId"]); foreach (var gmd in list) { gmd.OrderId = OrderId; gmd.InDate = DateTime.Now; gmd.InUserId = UserId; int Id = DataNew.Save_SpareFee(gmd); } return ""; } #region 亚马逊上传跟踪码 [WebMethod(EnableSession = true)] public string AmazonTrack(List list) { PagesNew.Login(this.Session); int CompanyId = Convert.ToInt32(Session["CompanyId"]); int UserId = Convert.ToInt32(Session["UserId"]); string str = ""; BaseService obj1 = new BaseService(); ApiNew.Amazonapinew obj = new ApiNew.Amazonapinew(); AmazonNewApi obj3 = new AmazonNewApi(); DD_OrderData obj2 = new DD_OrderData(); Amazon_SPApi obj4 = new Amazon_SPApi(); string ordecodes = ""; foreach (var md in list) { ordecodes += "'" + md.PlatOrderCode + "',"; } var glist = DataNew.GetAmGoodsList(ordecodes.TrimEnd(',')); try { string error = ""; if (list != null) { int PostId = 0; JC_Shop shopmodel = JC_ShopService.GetModel(list[0].ShopId.Value); JC_Express emd = null; if (shopmodel == null) return "店铺未授权"; if (shopmodel.Code == "new2") { // obj3.SellerId = shopmodel.Appkey; // obj3.MWSAuthToken = shopmodel.AccessToken;// ShopModel.AccessToken; obj4.SellerId = shopmodel.Appkey; //obj2.MWSAuthToken = "amzn.mws.94ba1459-809f-6157-a36f-967c9209c99b";// ShopModel.AccessToken; obj4.SumoolToKen = shopmodel.AccessToken;//obj2.marketplaceId = "ATVPDKIKX0DER";// ShopModel.DeveKey; // obj3.SumoolToKen = shopmodel.RefreshToken;//obj2.marketplaceId = "ATVPDKIKX0DER";// ShopModel.DeveKey; obj4.country = shopmodel.Country; obj4.MarketplaceId = shopmodel.DeveKey; foreach (var md in list) { if (md.TrackCode == null || md.TrackCode == "") { str = str + md.PlatOrderCode + ";"; continue; } if (md.TrackCode != "" && md.TrackCode.Contains(",")) md.TrackCode = md.TrackCode.Split(',')[0]; if (PostId != md.Post.Value) emd = obj1.GetExpressModel(md.Post.Value, CompanyId); PostId = md.Post.Value; string carrname = md.PostInfo2; if (emd.Remark != null && emd.Remark != "") carrname = emd.Remark; md.serviceName = carrname; if (glist != null) { var gmd = glist.FindAll(n => n.OrderCode == md.PlatOrderCode); md.BackGoodsList = gmd; } } //obj.GetFeedSubmissionResult("54888017651"); bool a = obj4.createFeedDocument(list, out error); } else if (shopmodel.Code == "new") { obj3.SellerId = shopmodel.Appkey; obj3.MWSAuthToken = shopmodel.AccessToken;// ShopModel.AccessToken; obj3.SumoolToKen = shopmodel.RefreshToken;//obj2.marketplaceId = "ATVPDKIKX0DER";// ShopModel.DeveKey; obj3.country = shopmodel.Country; foreach (var md in list) { if (md.TrackCode == null || md.TrackCode == "") { str = str + md.PlatOrderCode + ";"; continue; } if (md.TrackCode != "" && md.TrackCode.Contains(",")) md.TrackCode = md.TrackCode.Split(',')[0]; if (PostId != md.Post.Value) emd = obj1.GetExpressModel(md.Post.Value, CompanyId); PostId = md.Post.Value; string carrname = md.PostInfo2; if (emd.Remark != null && emd.Remark != "") carrname = emd.Remark; md.serviceName = carrname; if (glist != null) { var gmd = glist.FindAll(n => n.OrderCode == md.PlatOrderCode); md.BackGoodsList = gmd; } //if (md.BackGoodsList == null || md.BackGoodsList.Count <= 0) //{ // //str += md.PlatOrderCode + "货物明细没有,"; // return md.PlatOrderCode + "货物明细没有,"; //} //obj.UploadAMOrder(md.PlatOrderCode, md.serviceName, md.TrackCode,md.BackGoodsList[0].GoodsDesc, 1); // List list2 = new List(); // list2.Add(md); // string error = ""; // a = obj.UploadAMOrder2(list2,out error); // if(error!="") // str += md.PlatOrderCode+error+";"; } //obj.GetFeedSubmissionResult("54888017651"); bool a = obj3.UploadAMOrder2(list, out error); } else { obj.accessKeyId = shopmodel.RefreshToken; obj.secretAccessKey = shopmodel.AccessToken; obj.merchantId = shopmodel.Appkey; obj.marketplaceId = shopmodel.DeveKey; obj.country = shopmodel.Country; obj.MWSAuthToken = shopmodel.Code; foreach (var md in list) { if (md.TrackCode == null || md.TrackCode == "") { str = str + md.PlatOrderCode + ";"; continue; } if (md.TrackCode != "" && md.TrackCode.Contains(",")) md.TrackCode = md.TrackCode.Split(',')[0]; if (PostId != md.Post.Value) emd = obj1.GetExpressModel(md.Post.Value, CompanyId); PostId = md.Post.Value; string carrname = md.PostInfo2; if (emd.Remark != null && emd.Remark != "") carrname = emd.Remark; md.serviceName = carrname; if (glist != null) { var gmd = glist.FindAll(n => n.OrderCode == md.PlatOrderCode); md.BackGoodsList = gmd; } //if (md.BackGoodsList == null || md.BackGoodsList.Count <= 0) //{ // //str += md.PlatOrderCode + "货物明细没有,"; // return md.PlatOrderCode + "货物明细没有,"; //} //obj.UploadAMOrder(md.PlatOrderCode, md.serviceName, md.TrackCode,md.BackGoodsList[0].GoodsDesc, 1); // List list2 = new List(); // list2.Add(md); // string error = ""; // a = obj.UploadAMOrder2(list2,out error); // if(error!="") // str += md.PlatOrderCode+error+";"; } //obj.GetFeedSubmissionResult("54888017651"); bool a = obj.UploadAMOrder2(list, out error); } } if (error != "") str += error + ";"; if (str == "") { foreach (var md in list) { obj2.UpdateOrderTrackForTM(md.OrderId.Value); PagesNew.SaveLog(UserId, "亚马逊声明发货", "订单号:" + md.PlatOrderCode + "跟踪码:" + md.TrackCode + "serviceName:" + md.PostInfo, md.OrderId.Value); } } else { if (str != "") return str + "填单失败"; else return ""; } return ""; } catch (Exception ex) { ErrorFollow.TraceWrite(ex.TargetSite.Name, ex.StackTrace, ex.Message); return ex.Message; } } #endregion #region 声明速卖通发货(新版) [WebMethod(EnableSession = true)] public string Alibaba_TrackBackForTMNew(List list) { PagesNew.Login(this.Session); int CompanyId = Convert.ToInt32(Session["CompanyId"]); int UserId = Convert.ToInt32(Session["UserId"]); AlibabaApiQM obj = new AlibabaApiQM(); BaseService obj1 = new BaseService(); DD_OrderData obj2 = new DD_OrderData(); string errorinfo = ""; 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; obj.sessionKey = shopmodel.Code; string serviceName = "Fedex"; if (md.Post == null || md.Post == 0)//线上发货的除外 continue; if (PostId != md.Post.Value) emd = obj1.GetExpressModel(md.Post.Value, CompanyId); PostId = md.Post.Value; if (emd != null && emd.Remark != null) serviceName = emd.Remark; if (md.TrackCode == null || md.TrackCode == "") continue; string TrackCode = ""; string OtherTrackCode = ""; if (md.TrackCode.Trim(',').Contains(',')) { TrackCode = md.TrackCode.Trim(',').Split(',')[0]; OtherTrackCode = "The other trackno is " + md.TrackCode.Trim(',').Substring(TrackCode.Length + 1); } else TrackCode = md.TrackCode.Trim(','); string error = ""; 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.SubmitTrack(hblist[i].PlatOrderCode, TrackCode, serviceName, OtherTrackCode, emd.trackingWebsite, out error); if (tstate == false) errorinfo += hblist[i].PlatOrderCode + "失败" + error + ";"; //if (tstate == true) //{ obj2.UpdateOrderTrackForTM(md.OrderId.Value); // Pages.SaveLog(UserId, "速卖通声明发货", "订单号:" + md.PlatOrderCode + "跟踪码:" + md.TrackCode + "serviceName:" + serviceName + ";" + tstate.ToString(), md.OrderId.Value); //} } } } else { bool tstate = obj.SubmitTrack(md.PlatOrderCode, TrackCode, serviceName, OtherTrackCode, emd.trackingWebsite, out error); //if (tstate == true) //{ obj2.UpdateOrderTrackForTM(md.OrderId.Value); if (tstate == false) errorinfo += md.PlatOrderCode + "失败" + error + ";"; //Pages.SaveLog(UserId, "速卖通声明发货", "订单号:" + md.PlatOrderCode + "跟踪码:" + md.TrackCode + "serviceName:" + serviceName + ";" + tstate.ToString(), md.OrderId.Value); //} } } } return errorinfo; } #endregion #region 声明ebay发货 [WebMethod(EnableSession = true)] public string ebay_TrackBackForTM(List list) { PagesNew.Login(this.Session); int CompanyId = Convert.ToInt32(Session["CompanyId"]); int UserId = Convert.ToInt32(Session["UserId"]); EbayApi obj = new EbayApi(); 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.CertKey = shopmodel.RefreshToken; string Token = shopmodel.AccessToken; string serviceName = "Fedex"; if (md.Post == null || md.Post == 0 || md.Post.Value == 9)//线上发货的除外 continue; string TrackCode = ""; //if (ysfs == "China Post Air Mail") // ysfs = "ChinaAirPost"; if (md.TrackCode.Trim(',').Contains(',')) { TrackCode = md.TrackCode.Trim(',').Split(',')[0]; //OtherTrackCode = "The other trackno is " + md.TrackCode.Trim(',').Substring(TrackCode.Length + 1); } else TrackCode = md.TrackCode.Trim(','); var emd = obj1.GetExpressModel(md.Post.Value, CompanyId); if (emd != null && emd.Remark != null) { if (emd.Remark == "CPAM") serviceName = "China Post"; else if (emd.Remark == "BPost") serviceName = "BPost"; else serviceName = emd.Remark; } if (TrackCode == null || TrackCode == "") continue; if (md.IsJoin == 1)//合并订单 { var hblist = obj2.GetHBOrderListForTM(md.OrderId.Value); if (hblist != null) { for (int i = 0; i < hblist.Count; i++) { string tstate = obj.CompleteSale(Token, hblist[i].OrderCode, serviceName, TrackCode, DateTime.Now.AddHours(-15)); if (tstate == "失败") error += hblist[i].PlatOrderCode + "失败;"; else { obj2.UpdateOrderTrackForTM(md.OrderId.Value); } //if (tstate == true) //{ //obj2.UpdateOrderTrackForTM(md.OrderId.Value); // Pages.SaveLog(UserId, "eaby声明发货", "订单号:" + md.PlatOrderCode + "跟踪码:" + md.TrackCode + "serviceName:" + serviceName + ";" + tstate, md.OrderId.Value); //} } } } else { string tstate = obj.CompleteSale(Token, md.OrderCode, serviceName, TrackCode, DateTime.Now.AddHours(-15)); //if (tstate == true) //{ if (tstate == "失败") error += md.PlatOrderCode + "失败;"; else obj2.UpdateOrderTrackForTM(md.OrderId.Value); // Pages.SaveLog(UserId, "eaby声明发货", "订单号:" + md.PlatOrderCode + "跟踪码:" + md.TrackCode + "serviceName:" + serviceName + ";" + tstate.ToString(), md.OrderId.Value); //} } } } return error; } #endregion #region 沃尔玛填单 [WebMethod(EnableSession = true)] public string WalmartPostBack(List list) { PagesNew.Login(this.Session); WalmartApi obj = new WalmartApi(); DD_OrderData obj2 = new DD_OrderData(); string messerror = ""; int shopid = 0; JC_Shop shopmodel = null; string e = ""; string token = obj.GetToken(out e); if (token == "") { messerror += "授权码获取失败"; return messerror; } foreach (var md in list) { FHorderShipment model = new FHorderShipment(); List flist = new List(); if (shopid != md.ShopId.Value) shopmodel = JC_ShopService.GetModel(md.ShopId.Value); shopid = md.ShopId.Value; if (shopmodel == null) continue; WalmartApi.PrivateKey = shopmodel.AccessToken; WalmartApi.ConsumerId = shopmodel.Appkey; WalmartApi.ChannelType = shopmodel.DeveKey; WalmartApi.ACCESS_TOKEN = token; string error = ""; string TrackCode = ""; //if (ysfs == "China Post Air Mail") // ysfs = "ChinaAirPost"; if (md.TrackCode.Trim(',').Contains(',')) { TrackCode = md.TrackCode.Trim(',').Split(',')[0]; //OtherTrackCode = "The other trackno is " + md.TrackCode.Trim(',').Substring(TrackCode.Length + 1); } else TrackCode = md.TrackCode.Trim(','); //fhcarrierName cmd = new fhcarrierName(); //cmd.carrier = "Fedex"; //cmd.otherCarrier = ""; //trackingInfo tmd = new trackingInfo(); //tmd.carrierName = cmd; //tmd.shipDateTime = WalmartApi.GetCurrentTimestamp(); //tmd.methodCode = "Express"; //tmd.trackingNumber = "61290983045522005561";// TrackCode; //tmd.trackingURL = "www.fedex.com"; //FHstatusQuantity sqmd = new FHstatusQuantity(); //sqmd.amount = "1"; //sqmd.unitOfMeasurement = "EACH"; //List smlist = new List(); //FHorderLineStatus smd = new FHorderLineStatus(); //smd.trackingInfo = tmd; //smd.statusQuantity = sqmd; //smd.status = "Shipped"; //smlist.Add(smd); //FHorderLineStatus2 fmlist = new FHorderLineStatus2(); //fmlist.orderLineStatus = smlist; //List fllists = new List(); //FHorderLine flmd = new FHorderLine(); //flmd.lineNumber = "1"; //flmd.orderLineStatuses = fmlist; //fllists.Add(flmd); //FHorderLines2 flmlist = new FHorderLines2(); //flmlist.orderLine = fllists; //FHorderLines flmds = new FHorderLines(); //flmds.orderLines = flmlist; //flist.Add(flmds); //model.orderShipment = flmds; string ss = "{"; ss += "\"orderShipment\": {"; ss += "\"orderLines\": {"; ss += "\"orderLine\": ["; ss += "{"; ss += "\"lineNumber\": \"1\","; ss += "\"orderLineStatuses\": {"; ss += "\"orderLineStatus\": ["; ss += "{"; ss += " \"status\": \"Shipped\","; ss += "\"statusQuantity\": {"; ss += "\"unitOfMeasurement\": \"EACH\","; ss += " \"amount\":1"; ss += " },"; ss += " \"trackingInfo\": {"; ss += "\"shipDateTime\": " + WalmartApi.GetCurrentTimestamp() + ","; ss += "\"carrierName\": {"; ss += " \"otherCarrier\": null,"; ss += "\"carrier\": \"FedEx\""; ss += " },"; ss += "\"methodCode\": \"Express\","; ss += "\"trackingNumber\": \"" + TrackCode + "\","; ss += "\"trackingURL\": \"www.fedex.com\""; ss += "}"; ss += "}"; ss += "]"; ss += "}"; ss += "}"; ss += "]"; ss += "}"; ss += "}"; ss += "}"; obj.WalmartOrderPost(md.PlatOrderCode, ss, out error); if (string.IsNullOrEmpty(error) == false) { messerror += md.PlatOrderCode + "失败" + error; } else obj2.UpdateOrderTrackForTM(md.OrderId.Value); } if (messerror == "") return "发货成功"; return messerror; } #endregion #region 声明wish发货 [WebMethod(EnableSession = true)] public string wish_TrackBackForTM3(List list) { PagesNew.Login(this.Session); int CompanyId = Convert.ToInt32(Session["CompanyId"]); int UserId = Convert.ToInt32(Session["UserId"]); WishYouNew obj = new WishYouNew(); BaseService obj1 = new BaseService(); DD_OrderData obj2 = new DD_OrderData(); string error = ""; 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; string AccessToken = shopmodel.AccessToken; string serviceName = "ChinaAirPost"; 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.EName; } if (md.TrackCode == null || md.TrackCode == "") continue; string TrackCode = ""; // string OtherTrackCode = ""; if (md.TrackCode.Trim(',').Contains(',')) { TrackCode = md.TrackCode.Trim(',').Split(',')[0]; //OtherTrackCode = "The other trackno is " + md.TrackCode.Trim(',').Substring(TrackCode.Length + 1); } 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++) { string re = obj.ModifyTrackTOWish2(AccessToken, hblist[i].PlatOrderCode, serviceName, TrackCode, md.Message); if (re != "OK") error += hblist[i].PlatOrderCode + "失败" + re; else { obj2.UpdateOrderTrackForTM(md.OrderId.Value); } } } } else { string re = obj.ModifyTrackTOWish2(AccessToken, md.PlatOrderCode, serviceName, TrackCode, md.Message); if (re == "OK") { obj2.UpdateOrderTrackForTM(md.OrderId.Value); } else error += md.PlatOrderCode + "失败" + re; } } } return error; } #endregion #region 标记填单状态 [WebMethod(EnableSession = true)] public string SaveBackOrderCodeState(List list) { PagesNew.Login(this.Session); DD_OrderData obj2 = new DD_OrderData(); string errorinfo = ""; if (list != null) { foreach (var md in list) { DataNew.SaveBackOrderCodeState(md.OrderId.Value); } } return ""; } #endregion #region 查询返回跟踪码订单 [WebMethod(EnableSession = true)] public JsonModel> GetListOrderBackCodeForTM(int BackState, int PostState, int PlatType, int ShopId, int DateType, DateTime? SDate, DateTime? EDate, DateTime? SDate1, DateTime? EDate1, int OutDays, int TjType, string Name, int PostId, int PageIndex, int PageSize) { PagesNew.Login(this.Session); var obj = new DD_OrderData(); int CompanyId = Convert.ToInt32(Session["CompanyId"]); RefParameterCollection Param = new RefParameterCollection(); Param.Add("a.CompanyId", "=", CompanyId, DbType.Int32); if (PlatType > 0) Param.Add("a.PlatId", "=", PlatType, DbType.Int32); if (ShopId > 0) Param.Add("a.ShopId", "=", ShopId, DbType.Int32); if (BackState == 1) Param.Add("b.TrackDate", "is not", null, DbType.String); else if (BackState == 0) { Param.Add("b.TrackDate", "is", null, DbType.String); } Param.Add("b.TrackState", ">", 0, DbType.Int32); if (DateType == 1) { if (SDate != null) Param.Add("a.OrderDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.OrderDate", "<=", EDate, DbType.DateTime); } else if (DateType == 2) { if (SDate != null) Param.Add("a.InDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.InDate", "<=", EDate, DbType.DateTime); } else if (DateType == 3) { if (SDate != null) Param.Add("a.PrintDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.PrintDate", "<=", EDate, DbType.DateTime); } else if (DateType == 4) { if (SDate != null) Param.Add("a.PostDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.PostDate", "<=", EDate, DbType.DateTime); } if (SDate1 != null) Param.Add("a.OrderOutDate", ">=", SDate1, DbType.DateTime); if (EDate1 != null) Param.Add("a.OrderOutDate", "<=", EDate1, DbType.DateTime); if (SDate1 == null && EDate1 == null) { if (OutDays > 0) { Param.Add("a.OrderOutDate", "<=", DateTime.Now.AddHours(OutDays), DbType.DateTime); Param.Add("a.OrderOutDate", ">=", DateTime.Now, DbType.DateTime); } } if (PostState > -1) Param.Add("a.PostState", "=", PostState, DbType.Int32); Param.Add("a.State", ">", 0, DbType.Int32); Param.Add("a.State", "<", 3, DbType.Int32); Param.Add("b.Post", ">", 0, DbType.Int32); if (PostId > 0) Param.Add("b.Post", "=", PostId, DbType.Int32); if (Name != "") { Name = Name.Trim(); if (TjType == 1) { Param.Add("(a.PlatOrderCode", "=", Name, DbType.String); Param.Add("a.JoinOrderCode", "=", Name, "or", ")", DbType.String); } else if (TjType == 2) { Param.Add("b.RevName", "like", Name, DbType.String); } else if (TjType == 3) { Param.Add("b.RevPhone", "like", Name, DbType.String); } else if (TjType == 4) { Param.Add("(b.RevCountry", "=", Name, DbType.String); Param.Add("b.CountryName", "=", Name, "or", DbType.String); Param.Add("b.CountryCode", "=", Name, "or", ")", DbType.String); } else if (TjType == 5) { Param.Add("b.RevPostCode", "=", Name, DbType.String); } else if (TjType == 6) { Param.Add("(b.RevAddr", "like", Name, DbType.String); Param.Add("b.RevProvince", "like", Name, "or", DbType.String); Param.Add("b.RevCity", "like", Name, "or", DbType.String); Param.Add("b.RevArea", "like", Name, "or", ")", DbType.String); } else if (TjType == 9) { Param.Add("(b.ErrorInfo", "like", Name, DbType.String); Param.Add("b.PostError", "like", Name, "or", ")", DbType.String); } else if (TjType == 10) { Param.Add("b.TrackCode", "like", Name, DbType.String); } } //Param.Add("a.OrderDate", ">=", 0, DbType.Int32); JsonModel> resultModel = new JsonModel>(); int RowCount = 0; string Sort = "orderid desc"; string GoodsName = ""; string SKU = ""; if (TjType == 7 && Name != "") { GoodsName = Name; } else if (TjType == 8 && Name != "") { SKU = Name; } if (PostState == 0) resultModel.DataSource = obj.GetListDT_OrderTrackInfoForTM2(CompanyId, GoodsName, SKU, 0, Param, PageIndex, PageSize, Sort, out RowCount); else resultModel.DataSource = obj.GetListDT_OrderTrackInfoForTM(CompanyId, GoodsName, SKU, 0, Param, PageIndex, PageSize, Sort, out RowCount); resultModel.RowCount = RowCount; if (resultModel.DataSource != null) { string OrderIds = ""; string hborders = ""; foreach (var md in resultModel.DataSource) { if (md.JoinOrderCode != null && md.JoinOrderCode != "") hborders += "'" + md.JoinOrderCode + "',"; OrderIds += md.OrderId.ToString() + ","; } if (OrderIds != "") { var tlist = obj.Get_OrderTrackList2(OrderIds.Trim(',')); var glist = DataNew.GetBackGoodsList(OrderIds.Trim(',')); var tlist2 = new List(); if (hborders != "") tlist2 = obj.Get_OrderTrackList3(hborders.Trim(',')); if (tlist != null || tlist2 != null || glist != null) { foreach (var md in resultModel.DataSource) { var plist = new List(); if (glist != null) { var gmdlist = glist.FindAll(n => n.OrderId == md.OrderId); md.GoodsList = gmdlist; } if (tlist != null) { if (md.JoinOrderCode != null && md.JoinOrderCode != "") plist = tlist.FindAll(n => n.OrderCode == md.JoinOrderCode && n.OrderCode != null); else plist = tlist.FindAll(n => n.OrderId == md.OrderId); } if (tlist2 != null) { if (plist == null || plist.Count == 0) { if (md.JoinOrderCode != null && md.JoinOrderCode != "") plist = tlist2.FindAll(n => n.OrderCode == md.JoinOrderCode && n.OrderCode != null); } } string trackcode = ""; if (plist != null) { foreach (var pmd in plist) { trackcode += pmd.TrackCode + ","; } } md.TrackCode = trackcode; } } } } return resultModel; } #endregion [WebMethod(EnableSession = true)] public DT_OrderScanModel ScanGetOrder3(string OrderCode, int IsBlank) { PagesNew.Login(base.Session); DD_OrderData data = new DD_OrderData(); int num = Convert.ToInt32(base.Session["CompanyId"]); DT_OrderScanModel model = new DT_OrderScanModel(); model = DataNew.GetScanOrderModelForTM3(OrderCode.Trim().Replace(" ", "")); decimal num2 = 0M; decimal num3 = 0M; if ((model != null) && (model.GoodsList != null)) { foreach (DT_OrderScanGoods goods in model.GoodsList) { if (goods.Weight.HasValue) { num2 += goods.Weight.Value; } if (goods.GoodsPrice.HasValue) { num3 += goods.GoodsPrice.Value; } } } if (model != null) { model.GoodsWeight = new decimal?(num2); model.GoodsPrice = new decimal?(num3); } return model; } #region 查询订单 [WebMethod(EnableSession = true)] public string GetListOrderForExcel2222(int StoreId, int DeptId, int PlatType, int ShopId, int DateType, DateTime? SDate, DateTime? EDate, int TjType, string Name, int PrintState, int MateState, int MoneyState, int OutDays, int State, int IsSku, int IsError, int IsE, int IsDetail, int HBOrder, int IsSD, int SaleState, int IsBuy, int WLId, int IsDH, int SFLY, int PageIndex, int PageSize, string Sort) { PagesNew.Login(this.Session); var obj = new DD_OrderData(); int CompanyId = Convert.ToInt32(Session["CompanyId"]); RefParameterCollection Param = new RefParameterCollection(); if (StoreId > 0) Param.Add("a.StoreId", "=", StoreId, DbType.Int32); if (IsBuy == 1) Param.Add("a.BuyDate", "is not", null, DbType.String); else if (IsBuy == 0) Param.Add("a.BuyDate", "is", null, DbType.String); Param.Add("a.CompanyId", "=", CompanyId, DbType.Int32); if (IsSD > -1) Param.Add("isnull(b.TrackState,0)", "=", IsSD, DbType.Int32); if (SaleState > 0) Param.Add("a.SaleState", "=", SaleState, DbType.Int32); if (WLId > 0) Param.Add("a.LogisticsId", "=", WLId, DbType.Int32); if (DeptId > 0) Param.Add("c.DeptId", "=", DeptId, DbType.Int32); if (PlatType > 0) Param.Add("a.PlatId", "=", PlatType, DbType.Int32); if (ShopId > 0) Param.Add("a.ShopId", "=", ShopId, DbType.Int32); if (DateType == 1) { if (SDate != null) Param.Add("a.OrderDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.OrderDate", "<", EDate.Value.AddDays(1), DbType.DateTime); } else if (DateType == 2) { if (SDate != null) Param.Add("a.InDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.InDate", "<", EDate.Value.AddDays(1), DbType.DateTime); } else if (DateType == 3) { if (SDate != null) Param.Add("a.PrintDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.PrintDate", "<", EDate.Value.AddDays(1), DbType.DateTime); } else if (DateType == 4) { if (SDate != null) Param.Add("a.PostDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.PostDate", "<", EDate.Value.AddDays(1), DbType.DateTime); } else if (DateType == 5) { if (SDate != null) Param.Add("a.OrderOutDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.OrderOutDate", "<", EDate.Value.AddDays(1), DbType.DateTime); } if (OutDays > 0) { Param.Add("a.OrderOutDate", "<=", DateTime.Now.AddDays(OutDays), DbType.DateTime); Param.Add("a.OrderOutDate", ">=", DateTime.Now, DbType.DateTime); } if (MateState > -1) Param.Add("a.MateState", "=", MateState, DbType.Int32); if (MoneyState > -1) Param.Add("a.MoneyState", "=", MoneyState, DbType.Int32); if (PrintState > -1) Param.Add("a.PrintState", "=", PrintState, DbType.Int32); if (State == 3) Param.Add("a.State", "=", 2, DbType.Int32); else if (State == 4) Param.Add("a.State", "=", 3, DbType.Int32); else if (State == 5) { Param.Add("a.State", "=", 1, DbType.Int32); Param.Add("a.MoneyState", "=", 1, DbType.Int32); } else if (State == 1) { //Param.Add("a.State", "=", 2, DbType.Int32); Param.Add("a.PostState", "=", 1, DbType.Int32); } else if (State == 2) { Param.Add("a.State", "<", 3, DbType.Int32); Param.Add("a.PostState", "=", 2, DbType.Int32); } else if (State == 0) { //Param.Add("a.State", "=", 2, DbType.Int32); Param.Add("a.State", "=", 1, DbType.Int32); } else Param.Add("a.State", ">", 0, DbType.Int32); if (HBOrder == 1) Param.Add("a.IsJoin", "=", 1, DbType.Int32); if (IsError == 1) { Param.Add("(a.SendAddr", ">", 0, DbType.Int32); Param.Add("a.IsLeaveWord", "=", 1, "or", ")", DbType.Int32); } if (IsE == 1) { Param.Add("a.PostState", "=", 2, DbType.Int32); } if (IsE == 0) { Param.Add("a.PostState", "<", 2, DbType.Int32); } string TCode = ""; if (Name != "") { Name = Name.Trim(); if (TjType == 1) { Param.Add("(a.PlatOrderCode", "like", Name, DbType.String); Param.Add("OrderCode", "like", Name, "or", DbType.String); Param.Add("a.JoinOrderCode", "like", Name, "or", ")", DbType.String); } else if (TjType == 2) { Param.Add("a.RevName", "like", Name, DbType.String); } else if (TjType == 3) { Param.Add("a.RevPhone", "like", Name, DbType.String); } else if (TjType == 4) { Param.Add("(a.RevCountry", "=", Name, DbType.String); Param.Add("a.CountryName", "=", Name, "or", DbType.String); Param.Add("a.CountryCode", "=", Name, "or", ")", DbType.String); } else if (TjType == 5) { Param.Add("a.RevPostCode", "=", Name, DbType.String); } else if (TjType == 6) { Param.Add("(a.RevAddr", "like", Name, DbType.String); Param.Add("a.RevProvince", "like", Name, "or", DbType.String); Param.Add("a.RevCity", "like", Name, "or", DbType.String); Param.Add("a.RevArea", "like", Name, "or", ")", DbType.String); } else if (TjType == 9) { Param.Add("(a.ErrorInfo", "like", Name, DbType.String); Param.Add("a.PostError", "like", Name, "or", ")", DbType.String); } else if (TjType == 10) { //Param.Add("dbo.getOrderTrackCode(a.OrderId,0)", "like", Name, DbType.String); TCode = Name; } else if (TjType == 11) { Param.Add("a.CustomID", "=", Name, DbType.String); } else if (TjType == 12) { Param.Add("a.RevMail", "=", Name, DbType.String); } } if (IsSku == 0) Param.Add("a.FPDate", "is", null, DbType.String); else if (IsSku == 1) Param.Add("a.FPDate", "is not", null, DbType.String); JsonModel> resultModel = new JsonModel>(); int RowCount = 0; //string Sort = "orderid desc"; string GoodsName = ""; string SKU = ""; if (TjType == 7 && Name != "") { GoodsName = Name; } else if (TjType == 8 && Name != "") { SKU = Name; } if (SFLY > 0) { if (SFLY == 1) { resultModel.DataSource = obj.GetListDT_OrderInfoForTM6(CompanyId, GoodsName.Trim(), SKU.Trim(), TCode, -1, IsDH, Param, PageIndex, PageSize, Sort, out RowCount); } if (SFLY == 2) { resultModel.DataSource = obj.GetListDT_OrderInfoForTM7(CompanyId, GoodsName.Trim(), SKU.Trim(), TCode, -1, IsDH, Param, PageIndex, PageSize, Sort, out RowCount); } } else { if (State == 0 || State == 2) resultModel.DataSource = obj.GetListDT_OrderInfoForTM1(CompanyId, GoodsName.Trim(), SKU.Trim(), TCode, -1, IsDH, Param, PageIndex, PageSize, Sort, out RowCount); else resultModel.DataSource = obj.GetListDT_OrderInfoForTM(CompanyId, GoodsName.Trim(), SKU.Trim(), TCode, -1, IsDH, Param, PageIndex, PageSize, Sort, out RowCount); } resultModel.RowCount = RowCount; string Ids = ""; if (resultModel.DataSource != null) { foreach (var md in resultModel.DataSource) { Ids += md.OrderId.ToString() + ","; } } //if (Ids != "") //{ // var errorlist = obj.GetErrorList(Ids.Trim(',')); // if (errorlist != null && errorlist.Count > 0) // { // foreach (var md in resultModel.DataSource) // { // var emd = errorlist.Find(n => n.OrderId == md.OrderId); // if (emd != null) // { // md.ErrorInfo = emd.ErrorInfo; // } // } // } //} if (IsDetail == 1 && resultModel.DataSource != null) { if (Ids != "") { var list1 = obj.GetOrderGoodsList22(Ids.Trim(',')); var listTrack = obj.GetTrackCodeApplyList(Ids.Trim(',')); if (list1 != null) { foreach (var md in resultModel.DataSource) { var list2 = list1.FindAll(n => n.OrderId == md.OrderId); if (list2 != null && list2.Count > 0) { md.SKU = list2[0].GoodsCode; if (list2[0].Weight != null) md.GWeight = list2[0].Weight.Value.ToString("0"); if (list2[0].Height2 != null) md.GHeight = list2[0].Height2.Value.ToString("0.0"); if (list2[0].Width2 != null) md.GWidth = list2[0].Width2.Value.ToString("0.0"); if (list2[0].Long2 != null) md.GLong = list2[0].Long2.Value.ToString("0.0"); } } } if (listTrack != null) { foreach (var md in resultModel.DataSource) { var list3 = new List(); if (md.JoinOrderCode != null && md.JoinOrderCode != "") list3 = listTrack.FindAll(n => n.OrderCode == md.JoinOrderCode); else list3 = listTrack.FindAll(n => n.OrderId == md.OrderId); if (list3 != null && list3.Count > 0) { string trackinfo = ""; string TrackCode = ""; foreach (var md1 in list3) { trackinfo += md1.TrackCode + ","; if (TrackCode == "") TrackCode = md1.TrackCode; } md.TrackCode = TrackCode; } } } } } // 订单号 收货人国家 收货人姓名 地址1+地址2 收货人城市 收货人州/省 邮编 收货人手机 收货人电话 SKU 产品数量 报关重量(oz) 长(inch) 宽(inch) TableColumnCollection listColumns = new TableColumnCollection(); listColumns.Add("PlatOrderCode", "订单号", DbType.String, ""); listColumns.Add("RevCountry", "收货人国家", DbType.String, ""); listColumns.Add("RevName", "收货人姓名", DbType.String, ""); listColumns.Add("RevAddr", "地址1+地址2", DbType.String, "yyyy-MM-dd HH:mm"); listColumns.Add("RevCity", "收货人城市", DbType.String, ""); listColumns.Add("RevProvince", "收货人州/省", DbType.String, ""); listColumns.Add("RevPostCode", "邮编", DbType.String, ""); listColumns.Add("RevMoblie", "收货人手机", DbType.String, ""); listColumns.Add("RevPhone", "收货人电话", DbType.String, ""); listColumns.Add("SKU", "SKU", DbType.String, "yyyy-MM-dd HH:mm"); listColumns.Add("GoodsNum", "产品数量", DbType.String, ""); listColumns.Add("GWeight", "报关重量(oz)", DbType.String, ""); listColumns.Add("GLong", "长(inch)", DbType.String, ""); listColumns.Add("GWidth", "宽(inch)", DbType.String, ""); listColumns.Add("GHeight", "高(inch)", DbType.String, ""); listColumns.Add("TrackCode", "跟踪码", DbType.String, ""); MicrosoftExcel obj2 = new MicrosoftExcel(); return obj2.Export(resultModel.DataSource, listColumns); } #endregion #region 查询订单 [WebMethod(EnableSession = true)] public string GetListOrderForExcel2(int StoreId, int DeptId, int PlatType, int ShopId, int DateType, DateTime? SDate, DateTime? EDate, int TjType, string Name, int PrintState, int MateState, int MoneyState, int OutDays, int State, int IsSku, int IsError, int IsE, int IsDetail, int HBOrder, int IsSD, int SaleState, int IsBuy, int WLId, int IsDH, int SFLY, int PageIndex, int PageSize, string Sort) { PagesNew.Login(this.Session); var obj = new DD_OrderData(); int CompanyId = Convert.ToInt32(Session["CompanyId"]); RefParameterCollection Param = new RefParameterCollection(); if (StoreId > 0) Param.Add("a.StoreId", "=", StoreId, DbType.Int32); if (IsBuy == 1) Param.Add("a.BuyDate", "is not", null, DbType.String); else if (IsBuy == 0) Param.Add("a.BuyDate", "is", null, DbType.String); Param.Add("a.CompanyId", "=", CompanyId, DbType.Int32); if (IsSD == 2) Param.Add("isnull(a.IsSDan,0)", ">", 1, DbType.Int32); else if (IsSD > -1) Param.Add("isnull(a.TrackState,0)", "=", IsSD, DbType.Int32); if (SaleState > 0) Param.Add("a.SaleState", "=", SaleState, DbType.Int32); if (WLId > 0) Param.Add("a.LogisticsId", "=", WLId, DbType.Int32); if (DeptId > 0) Param.Add("c.DeptId", "=", DeptId, DbType.Int32); if (PlatType > 0) Param.Add("a.PlatId", "=", PlatType, DbType.Int32); if (ShopId > 0) Param.Add("a.ShopId", "=", ShopId, DbType.Int32); if (DateType == 1) { if (SDate != null) Param.Add("a.OrderDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.OrderDate", "<", EDate.Value.AddDays(1), DbType.DateTime); } else if (DateType == 2) { if (SDate != null) Param.Add("a.InDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.InDate", "<", EDate.Value.AddDays(1), DbType.DateTime); } else if (DateType == 3) { if (SDate != null) Param.Add("a.PrintDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.PrintDate", "<", EDate.Value.AddDays(1), DbType.DateTime); } else if (DateType == 4) { if (SDate != null) Param.Add("a.PostDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.PostDate", "<", EDate.Value.AddDays(1), DbType.DateTime); } else if (DateType == 5) { if (SDate != null) Param.Add("a.OrderOutDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.OrderOutDate", "<", EDate.Value.AddDays(1), DbType.DateTime); } if (OutDays > 0) { Param.Add("a.OrderOutDate", "<=", DateTime.Now.AddDays(OutDays), DbType.DateTime); Param.Add("a.OrderOutDate", ">=", DateTime.Now, DbType.DateTime); } if (MateState > -1) Param.Add("a.MateState", "=", MateState, DbType.Int32); if (MoneyState > -1) Param.Add("a.MoneyState", "=", MoneyState, DbType.Int32); if (PrintState > -1) Param.Add("a.PrintState", "=", PrintState, DbType.Int32); if (State == 3) Param.Add("a.State", "=", 2, DbType.Int32); else if (State == 4) Param.Add("a.State", "=", 3, DbType.Int32); else if (State == 5) { Param.Add("a.State", "=", 1, DbType.Int32); Param.Add("a.MoneyState", "=", 1, DbType.Int32); } else if (State == 1) { //Param.Add("a.State", "=", 2, DbType.Int32); Param.Add("a.PostState", "=", 1, DbType.Int32); } else if (State == 2) { Param.Add("a.State", "<", 3, DbType.Int32); Param.Add("a.PostState", "=", 2, DbType.Int32); } else if (State == 0) { //Param.Add("a.State", "=", 2, DbType.Int32); Param.Add("a.State", "=", 1, DbType.Int32); } else Param.Add("a.State", ">", 0, DbType.Int32); if (HBOrder == 1) Param.Add("a.IsJoin", "=", 1, DbType.Int32); if (IsError == 1) { Param.Add("(a.SendAddr", ">", 0, DbType.Int32); Param.Add("a.IsLeaveWord", "=", 1, "or", ")", DbType.Int32); } if (IsE == 1) { Param.Add("a.PostState", "=", 2, DbType.Int32); } if (IsE == 0) { Param.Add("a.PostState", "<", 2, DbType.Int32); } string TCode = ""; if (Name != "") { Name = Name.Trim(); if (TjType == 1) { Param.Add("(a.PlatOrderCode", "like", Name, DbType.String); Param.Add("OrderCode", "like", Name, "or", DbType.String); Param.Add("a.JoinOrderCode", "like", Name, "or", ")", DbType.String); } else if (TjType == 2) { Param.Add("a.RevName", "like", Name, DbType.String); } else if (TjType == 3) { Param.Add("a.RevPhone", "like", Name, DbType.String); } else if (TjType == 4) { Param.Add("(a.RevCountry", "=", Name, DbType.String); Param.Add("a.CountryName", "=", Name, "or", DbType.String); Param.Add("a.CountryCode", "=", Name, "or", ")", DbType.String); } else if (TjType == 5) { Param.Add("a.RevPostCode", "=", Name, DbType.String); } else if (TjType == 6) { Param.Add("(a.RevAddr", "like", Name, DbType.String); Param.Add("a.RevProvince", "like", Name, "or", DbType.String); Param.Add("a.RevCity", "like", Name, "or", DbType.String); Param.Add("a.RevArea", "like", Name, "or", ")", DbType.String); } else if (TjType == 16) { Param.Add("a.RevProvince", "=", Name, DbType.String); } else if (TjType == 9) { Param.Add("(a.ErrorInfo", "like", Name, DbType.String); Param.Add("a.PostError", "like", Name, "or", ")", DbType.String); } else if (TjType == 10) { //Param.Add("dbo.getOrderTrackCode(a.OrderId,0)", "like", Name, DbType.String); TCode = Name; } else if (TjType == 11) { Param.Add("a.CustomID", "=", Name, DbType.String); } else if (TjType == 12) { Param.Add("a.RevMail", "=", Name, DbType.String); } } if (IsSku == 0) Param.Add("a.FPDate", "is", null, DbType.String); else if (IsSku == 1) Param.Add("a.FPDate", "is not", null, DbType.String); JsonModel> resultModel = new JsonModel>(); int RowCount = 0; //string Sort = "orderid desc"; string GoodsName = ""; string SKU = ""; if (TjType == 7 && Name != "") { GoodsName = Name; } else if (TjType == 8 && Name != "") { SKU = Name; } if (SFLY > 0) { if (SFLY == 1) { resultModel.DataSource = obj.GetListDT_OrderInfoForTM6(CompanyId, GoodsName.Trim(), SKU.Trim(), TCode, -1, IsDH, Param, PageIndex, PageSize, Sort, out RowCount); } if (SFLY == 2) { resultModel.DataSource = obj.GetListDT_OrderInfoForTM7(CompanyId, GoodsName.Trim(), SKU.Trim(), TCode, -1, IsDH, Param, PageIndex, PageSize, Sort, out RowCount); } } else { if (State == 0 || State == 2) resultModel.DataSource = DataNew.GetListDT_OrderInfoForTM2(CompanyId,"", GoodsName.Trim(), SKU.Trim(), TCode, -1, IsDH, Param, PageIndex, PageSize, Sort, out RowCount); else resultModel.DataSource = DataNew.GetListDT_OrderInfoForTM2(CompanyId, "",GoodsName.Trim(), SKU.Trim(), TCode, -1, IsDH, Param, PageIndex, PageSize, Sort, out RowCount); } resultModel.RowCount = RowCount; string Ids = ""; if (resultModel.DataSource != null) { foreach (var md in resultModel.DataSource) { Ids += md.OrderId.ToString() + ","; } } if (Ids != "") { var errorlist = obj.GetErrorList(Ids.Trim(',')); if (errorlist != null && errorlist.Count > 0) { foreach (var md in resultModel.DataSource) { var emd = errorlist.Find(n => n.OrderId == md.OrderId); if (emd != null) { md.ErrorInfo = emd.ErrorInfo; } } } } if (IsDetail == 1 && resultModel.DataSource != null) { if (Ids != "") { var list1 = DataNew.GetOrderSKU(Ids.Trim(',')); var listTrack = obj.GetTrackCodeApplyList(Ids.Trim(',')); if (list1 != null) { foreach (var md in resultModel.DataSource) { var list2 = list1.FindAll(n => n.OrderId == md.OrderId); if (list2 != null) { string sku = ""; int gnum = 0; foreach (var ssmd in list2) { sku += ssmd.GoodsSKU+"["+ ssmd .GoodsNum+ "];"; gnum += ssmd.GoodsNum.Value; } md.SKU = sku; md.GoodsNum = gnum; md.GoodsList = list2; } } } if (listTrack != null) { foreach (var md in resultModel.DataSource) { var list3 = new List(); if (md.JoinOrderCode != null && md.JoinOrderCode != "") list3 = listTrack.FindAll(n => n.OrderCode == md.JoinOrderCode); else list3 = listTrack.FindAll(n => n.OrderId == md.OrderId); if (list3 != null && list3.Count > 0) { string trackinfo = ""; string TrackCode = ""; foreach (var md1 in list3) { string blank = ""; if (md1.TrackType == 3) blank = "[空包裹]"; if (md1.Weight != null) { string dd = ""; if (md1.ScanDate != null) dd = "扫描时间:" + md1.ScanDate.Value.ToString("yyyy-MM-dd HH:mm"); trackinfo += md1.TrackCode + blank + "重量" + md1.Weight.ToString() + "g" + dd + "
"; } else trackinfo += md1.TrackCode + blank + "
"; if (TrackCode == "") TrackCode = md1.TrackCode; } md.TrackInfo = trackinfo; md.TrackCode = TrackCode; } } } } } TableColumnCollection listColumns = new TableColumnCollection(); listColumns.Add("ShopName", "店铺", DbType.String, ""); listColumns.Add("PlatOrderCode", "订单号", DbType.String, ""); listColumns.Add("OrderDate", "订单日期", DbType.String, "yyyy-MM-dd HH:mm"); listColumns.Add("RevCountry", "收货人国家", DbType.String, ""); listColumns.Add("RevName", "收货人姓名", DbType.String, ""); listColumns.Add("RevAddr", "地址1+地址2", DbType.String, ""); listColumns.Add("RevCity", "收货人城市", DbType.String, ""); listColumns.Add("RevProvince", "收货人州/省", DbType.String, ""); listColumns.Add("RevPostCode", "邮编", DbType.String, ""); listColumns.Add("RevMoblie", "收货人手机", DbType.String, ""); listColumns.Add("RevPhone", "收货人电话", DbType.String, ""); listColumns.Add("SKU", "SKU", DbType.String, ""); listColumns.Add("GoodsNum", "产品数量", DbType.String, ""); listColumns.Add("GWeight", "报关重量(oz)", DbType.String, ""); listColumns.Add("GLong", "长(inch)", DbType.String, ""); listColumns.Add("GWidth", "宽(inch)", DbType.String, ""); listColumns.Add("GHeight", "高(inch)", DbType.String, ""); listColumns.Add("TrackCode", "跟踪码", DbType.String, ""); listColumns.Add("TotalPrice", "总金额", DbType.Decimal, ""); MicrosoftExcel obj2 = new MicrosoftExcel(); return obj2.Export(resultModel.DataSource, listColumns); } #endregion #region 自动获取物流单号 public static string GetOrderPostCodeAuto(DT_OrderExpressModelNew ordermd, JC_ExpressPost md,JC_PostAddress companymd,int PostId) { try { var obj = new DD_OrderData(); //var companymd = new JC_PostAddress(); var obj1 = new JC_ExpressService(); var obj11 = new BaseService(); //companymd = obj11.GetAddressModel2(PostId); string ErrorInfo = ""; string PostCode = ""; var obj2 = new BaseService(); // var md = DataNew.GetExpressModel(CompanyId, PostId); if (ordermd == null) return ""; if ((ordermd.RevPhone == null || ordermd.RevPhone == "") && (ordermd.RevMoblie == null || ordermd.RevMoblie == "")) ErrorInfo += ordermd.PlatOrderCode + "收件人电话没填"; if (ordermd.RevPostCode == null || ordermd.RevPostCode == "") ErrorInfo += ordermd.PlatOrderCode + "收件人邮编没填"; if (ordermd.RevProvince == null || ordermd.RevProvince == "") ErrorInfo += ordermd.PlatOrderCode + "州没填"; if (ErrorInfo != "") { ErrorFollow.TraceWrite("GetOrderPostCodeAuto", "", ErrorInfo); DataNew.UpdateAutoTrack(ordermd.OrderId.Value, ErrorInfo); return ErrorInfo; } var plist = new List(); if (md.Name.Contains("Fedex") && md.customercode != null && md.customercode != "") { // ErrorFollow.TraceWrite("Fedex", "", md.customercode); FedexSmartPostNew fedexobj = new FedexSmartPostNew(); FedexSmartPostNew.Key = md.UserCode; FedexSmartPostNew.Password = md.CheckCode; FedexSmartPostNew.AccountNumber = md.client_id; FedexSmartPostNew.MeterNumber = md.client_secret; FedexSmartPostNew.PayAccountNumber = md.refresh_token; FedexSmartPostNew.HubId = md.Code; FedexSmartPostNew.PostName = md.customercode; FedexSmartPostNew.LBPath = "E:/erp/attached/fedex/"; FedexSmartPostNew.IsQM = 0;//默认不签名 FedexOrder fdorder = new FedexOrder(); string sendname= companymd.SendName; string PersonName= companymd.SendEnglishName; if(ordermd.sendname!=null&&ordermd.sendname!="") { sendname= ordermd.sendname; PersonName= ordermd.sendname; } Shiper shiper = new Shiper { City = companymd.city, CompanyName = sendname, PersonName = PersonName, PhoneNumber = companymd.Phone, PostalCode = companymd.PostCode, StateOrProvinceCode = companymd.provincecode, StreetLines = companymd.EnglishAddress, CountryCode = companymd.countycode }; fdorder.Shiper = shiper; Random rd = new Random(); fdorder.CustomerTransactionId = ordermd.PlatOrderCode; fdorder.PostId = new int?(PostId); string Phone = ordermd.RevMoblie; if (ordermd.RevPhone != null && ordermd.RevPhone != "") Phone = ordermd.RevPhone; Rever rever = new Rever { City = ordermd.RevCity, CompanyName = ordermd.RevName, PersonName = ordermd.RevName, PhoneNumber = Phone, PostalCode = ordermd.RevPostCode, CountryCode = "US" }; if ((ordermd.RevProvince == null) || (ordermd.RevProvince == "")) { rever.StateOrProvinceCode = ordermd.RevCity; } else { rever.StateOrProvinceCode = ordermd.RevProvince; } if (ordermd.PlatId == 22) //TikTok的申请快递面单的详细地址过长,需要减去国家,省,市等,否则面单显示不下 { rever.StreetLines = string.IsNullOrEmpty(ordermd.RevAddr) ? "" : (ordermd.RevAddr.Split(',').Last()); } else rever.StreetLines = ordermd.RevAddr; //rever.StreetLines = ordermd.RevAddr; rever.CountryCode = ordermd.CountryCode; fdorder.Rever = rever; List fedlist = new List(); string gsku = ""; int gnum = 0; decimal ww = 0; decimal c = 0; decimal k = 0; decimal g = 0; if (ordermd.SKU != null && ordermd.SKU != "") gsku += ordermd.GoodsNum.Value + "x" + ordermd.SKU + " "; gnum += ordermd.GoodsNum.Value; if (ordermd.Weight != null) ww += ordermd.GoodsNum.Value * ordermd.Weight.Value * Convert.ToDecimal(0.0625); // else if (ordermd.Width2 != null) // ww += ordermd.GoodsNum.Value * ordermd.Width2.Value * Convert.ToDecimal(0.0022046); if (ordermd.Long2 != null) c += ordermd.Long2.Value; // else if (ordermd.Long != null) // c += ordermd.Long.Value * Convert.ToDecimal(0.3937008); if (ordermd.Width2 != null) k += ordermd.Width2.Value; // else if (ordermd.Width != null) // k += ordermd.Width.Value * Convert.ToDecimal(0.3937008); if (ordermd.Height2 != null) g += ordermd.Height2.Value; //else if (ordermd.Height != null) // g += ordermd.Height.Value * Convert.ToDecimal(0.3937008); FedexGoods fgmd = new FedexGoods { Amount = 10.000M, SKU = gsku, Description = gsku, NumberOfPieces = gnum.ToString(), Weight = ww, Height = Math.Ceiling(g).ToString(), Lenght = Math.Ceiling(c).ToString(), Width = Math.Ceiling(k).ToString(), Quantity = gnum }; fedlist.Add(fgmd); fdorder.GoodsList = fedlist; string error = ""; PostCode = fedexobj.GetFedex(fdorder, out error); if (error != "" || PostCode == "") { ErrorInfo += ordermd.PlatOrderCode + ":" + error; // ErrorFollow.TraceWrite("GetOrderPostCodeAuto", "", ErrorInfo); DataNew.UpdateAutoTrack(ordermd.OrderId.Value, error); } else if (PostCode != null && PostCode != "" && !PostCode.Contains("失败")) { DT_TrackCodeApplyNew Model = new DT_TrackCodeApplyNew(); 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; } Model.GetDate = DateTime.Now; Model.InName = "系统自动生成"; if (ordermd.JoinOrderCode != null && ordermd.JoinOrderCode != "") Model.OrderCode = ordermd.JoinOrderCode; else Model.OrderCode = ordermd.PlatOrderCode; Model.OrderCode2 = fdorder.CustomerTransactionId; Model.SKU = gsku; Model.Weight2 = ww.ToString("0.00"); Model.Long = Math.Ceiling(c).ToString(); Model.Height = Math.Ceiling(g).ToString(); Model.Width = Math.Ceiling(k).ToString(); Model.OrderId = ordermd.OrderId; Model.PostId = PostId; Model.State = 1; Model.TrackType = 1; Model.UpdateTime = DateTime.Now; Model.IsSpare = 0; Model.LabelUrl = PostCode + ".png"; Model.JoinOrderCode = ordermd.JoinOrderCode; DataNew.SaveTrackCodeApply2(Model); } } if (ErrorInfo == "") return ""; else return ErrorInfo + ";"; } catch(Exception ex) { ErrorFollow.TraceWrite("GetOrderPostCodeAuto", "", ex.Message); DataNew.UpdateAutoTrack(ordermd.OrderId.Value, ex.Message); return ex.Message; } } #endregion #region 删除订单锁定 [WebMethod(EnableSession = true)] public void UpdateMateGoodsForTM(int OrderId) { PagesNew.Login(this.Session); var obj = new DD_OrderData(); int InUserId = Convert.ToInt32(Session["UserId"]); var mlist = new List(); mlist = DataNew.GetListUserMate(OrderId.ToString(), "'0'");//查询店铺匹配的数据 var hwlist = DataNew.GetCancelGoodsKC(OrderId.ToString()); BackShopKC(hwlist); obj.UpdateMateGoodsForTM(OrderId); PagesNew.SaveLog(InUserId, "删除订单锁定", OrderId + "删除订单锁定", 0); DataNew.UpdateUserMate(OrderId.ToString(),"'0'"); } #endregion #region 删除订单锁定 [WebMethod(EnableSession = true)] public void UpdateMateGoodsListForTM(List list) { PagesNew.Login(this.Session); int InUserId = Convert.ToInt32(Session["UserId"]); try { var obj = new DD_OrderData(); string orderids = ""; string joinordercodes = ""; if (list != null) { foreach (var md in list) { if (md.JoinOrderCode != null && md.JoinOrderCode != "") { joinordercodes += "'" + md.JoinOrderCode + "',"; } else orderids += md.OrderId + ","; } } var mlist = new List(); if (orderids != "" || joinordercodes != "") { if (orderids == "") orderids = "0"; if (joinordercodes == "") joinordercodes = "'0'"; mlist = DataNew.GetListUserMate(orderids.TrimEnd(','), joinordercodes.TrimEnd(','));//查询店铺匹配的数据 } string gids = ""; if (list != null) { foreach (var md in list) { if (mlist != null)//对应店铺匹配的数据 { var omd = mlist.Find(n => n.OrderId == md.OrderId); if (omd != null) { gids += omd.OrderId + ","; } } } if (gids != "") { var hwlist = DataNew.GetCancelGoodsKC(gids.TrimEnd(',')); BackShopKC(hwlist); } foreach (var md in list) { //if (md.PrintState == 1) obj.UpdatePrintMateStateForTM(md.OrderId.Value); PagesNew.SaveLog(InUserId, "删除订单锁定", md.OrderId.Value + "删除订单锁定", 0); } } if (orderids != "" || joinordercodes != "") { DataNew.UpdateUserMate(orderids.TrimEnd(','), joinordercodes.TrimEnd(',')); } } catch (Exception ex) { ErrorFollow.TraceWrite(ex.TargetSite.Name, ex.StackTrace, ex.Message); } } #endregion /// /// 回退认购匹配数 /// /// /// public void BackShopKC(List mlist) { if (mlist == null && mlist.Count == 0) return; string ids = "0,"; foreach (var mmd in mlist) { ids += mmd.DetailId + ","; } var klist = DataNew.GetShopGoodsNumNoMate4(ids.TrimEnd(',')); if (mlist != null && klist != null) { foreach (var mmd in mlist) { if (mmd.MateNum <= 0) continue; int mnum = mmd.MateNum.Value; int shopid = mmd.ShopId.Value; var kmd = klist.FindAll(n => n.ShopId == shopid && n.DetailId == mmd.DetailId && n.StoreId == mmd.StoreId); if (kmd != null) { foreach (var ppmd in kmd) { if (ppmd.NowNum >= mnum) { ppmd.AddNum = mnum; mnum = 0; break; } else { ppmd.AddNum = ppmd.NowNum; mnum = mnum - ppmd.NowNum.Value; } } } } foreach (var md in klist) { if (md.AddNum > 0) { DataNew.UpdateUserBuyNumMate3(md.Id.Value, md.AddNum.Value); } } } } [WebMethod(EnableSession = true)] public void DeketeOrderSpare(int Id) { PagesNew.Login(base.Session); DataNew.Delete_SpareFee3(Id); } #region 返回订单Model [WebMethod(EnableSession = true)] public DT_OrderModelNew GetOrderModelNew2(int OrderId) { PagesNew.Login(this.Session); var obj = new DD_OrderData(); int CompanyId = Convert.ToInt32(Session["CompanyId"]); var md = DataNew.GetOrderModel2(OrderId); if (md.CompanyId != CompanyId) return null; if (md.IsSpare == 1) { string TrackCodes = ""; var splist = obj.GetOrderSpareList(OrderId); if (splist != null) { for (int i = 0; i < splist.Count; i++) { TrackCodes += splist[i].TrackCode.ToString() + ","; } } md.TrackCode = TrackCodes.Trim(','); } return md; } #endregion #region 返回订单Model [WebMethod(EnableSession = true)] public DT_OrderModelNew GetOrderModelNew4(int OrderId) { PagesNew.Login(this.Session); var obj = new DD_OrderData(); int CompanyId = Convert.ToInt32(Session["CompanyId"]); var md = DataNew.GetOrderModel2(OrderId); if (md.CompanyId != CompanyId) return null; if (md.MoneyCode != null) { decimal feerate = 0; decimal feerate2 = 1; List mlist = new BaseService().GetMoneyList2(); JC_Money money = mlist.Find(n => n.MCode == md.MoneyCode && n.PlatId == md.PlatId); if (money != null) { feerate = money.MRate.Value; } else { money = mlist.Find(n => n.MCode == md.MoneyCode); feerate = money.MRate.Value; } md.FeeRate = feerate; JC_Money money2 = mlist.Find(n => n.MCode == "USD" && n.PlatId == md.PlatId); if (money2 != null) { feerate2 = money2.MRate.Value; } else { money2 = mlist.Find(n => n.MCode == "USD"); feerate2 = money2.MRate.Value; } md.FeeRate2 = feerate2; } if (md.IsSpare == 1) { string TrackCodes = ""; var splist = obj.GetOrderSpareList(OrderId); if (splist != null) { for (int i = 0; i < splist.Count; i++) { TrackCodes += splist[i].TrackCode.ToString() + ","; } } md.TrackCode = TrackCodes.Trim(','); } return md; } #endregion #region 返回订单Model [WebMethod(EnableSession = true)] public int Save_ErrorJH(int OrderId,int JHError,string JHRemark) { PagesNew.Login(this.Session); var obj = new DD_OrderData(); string name = Convert.ToString(Session["Name"]); if(JHError==0) JHRemark += " 取消人:" + name + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); else JHRemark += " 设置人:" + name + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); var md = DataNew.Save_ErrorJH(JHError, JHRemark, OrderId); return md; } #endregion #region 设置发货 [WebMethod(EnableSession = true)] public string SetSendStore(List list, int StoreId) { PagesNew.Login(this.Session); string mess = ""; foreach (var smd in list) { int a=DataNew.UpdateSendStore(smd.OrderId.Value, StoreId); if (a == 1) mess+=smd.PlatOrderCode+","; } if (mess != "") { return mess + "已经申请跟踪码请先删除原跟踪码再申请,其他订单修改成功"; } return "成功"; } #endregion #region DD_Goods页 #region 保存 [WebMethod(EnableSession = true)] public int Save_Goods(DD_Goods Model) { PagesNew.Login(this.Session); Model.InDate = DateTime.Now; Model.InName = Session["Name"].ToString(); return DataNew.Save_Goods(Model); } #endregion #region 删除 [WebMethod(EnableSession = true)] public bool Delete_Goods(int Id) { PagesNew.Login(this.Session); DataNew.Delete_Goods(Id); return true; } #endregion #region 返回Model [WebMethod(EnableSession = true)] public DD_Goods GetModel_Goods(int Id) { PagesNew.Login(this.Session); var Model=DataNew.GetModel_Goods(Id); return Model; } #endregion #region 是否重复判断 [WebMethod(EnableSession = true)] public bool CheckName_Goods(int Id,string Name) { PagesNew.Login(this.Session); return DataNew.CheckName_Goods(Id,Name); } #endregion #region 普通查询列表 [WebMethod(EnableSession = true)] public List GetListGoods3(int ShopId) { PagesNew.Login(this.Session); var ListModel = DataNew.GetListGoods(ShopId); return ListModel; } #endregion #region 分页查询 [WebMethod(EnableSession = true)] public JsonModel> GetListGoods(string cs,int PageIndex, int PageSize) { PagesNew.Login(this.Session); string where = CustomIO.Base64StringToString(cs); if (where!="")where = "where " + where.Substring(4); var resultModel = new JsonModel>(); int RowCount = 0; resultModel.DataSource=DataNew.GetListGoods(where,PageIndex,PageSize, "", out RowCount); resultModel.RowCount = RowCount; return resultModel; } #endregion #endregion #region DD_GoodsCodeData页 #region 保存 [WebMethod(EnableSession = true)] public int Save_GoodsCodeDataList(List list,DateTime SDate) { PagesNew.Login(this.Session); if (list == null) return 0; foreach (var md in list) { md.OrderDate = SDate; md.InDate = DateTime.Now; md.Int5 = Convert.ToInt32(Session["UserId"]); DataNew.Save_GoodsCodeData(md); } return 1; } #endregion #region 保存 [WebMethod(EnableSession = true)] public int Save_GoodsCodeData(DD_GoodsCodeData Model) { PagesNew.Login(this.Session); Model.InDate = DateTime.Now; Model.Int5 = Convert.ToInt32(Session["UserId"]); return DataNew.Save_GoodsCodeData(Model); } #endregion #region 删除 [WebMethod(EnableSession = true)] public bool Delete_GoodsCodeData(int Id) { PagesNew.Login(this.Session); DataNew.Delete_GoodsCodeData(Id); return true; } #endregion #region 返回Model [WebMethod(EnableSession = true)] public DD_GoodsCodeData GetModel_GoodsCodeData(int Id) { PagesNew.Login(this.Session); var Model=DataNew.GetModel_GoodsCodeData(Id); return Model; } #endregion #region 是否重复判断 [WebMethod(EnableSession = true)] public bool CheckName_GoodsCodeData(int Id,string Name) { PagesNew.Login(this.Session); return DataNew.CheckName_GoodsCodeData(Id,Name); } #endregion #region 普通查询列表 [WebMethod(EnableSession = true)] public List GetListGoodsCodeData3(DateTime SDate,int ShopId,string GoodsCode,string name) { PagesNew.Login(this.Session); int UserId =Convert.ToInt32(Session["UserId"]); var ListModel = DataNew.GetListGoodsCodeData3(ShopId, GoodsCode, SDate, UserId); return ListModel; } #endregion #region 返回Model [WebMethod(EnableSession = true)] public string GetGoodsCodeDataUrl(int ShopId,string GoodsCode) { PagesNew.Login(this.Session); var Model = DataNew.GetModel_GoodsCodeDataUrl(ShopId, GoodsCode); if (Model != null) return Model.Url; else return ""; } #endregion #region 分页查询 [WebMethod(EnableSession = true)] public JsonModel> GetListGoodsCodeData(string cs,int PageIndex, int PageSize) { PagesNew.Login(this.Session); string where = CustomIO.Base64StringToString(cs); if (where!="")where = "where " + where.Substring(4); var resultModel = new JsonModel>(); int RowCount = 0; resultModel.DataSource=DataNew.GetListGoodsCodeData(where,PageIndex,PageSize, "", out RowCount); resultModel.RowCount = RowCount; return resultModel; } #endregion #endregion #region 设置不允许发货 [WebMethod(EnableSession = true)] public void SetNoPost(List list,int PostState) { PagesNew.Login(this.Session); if (list != null) { foreach (var md in list) { DataNew.SetNoPost(md.OrderId.Value, PostState); } } } #endregion #region [WebMethod(EnableSession = true)] public string GetShopify(int ShopId) { PagesNew.Login(this.Session); Shopify sp = new Shopify(); JC_Shop model = JC_ShopService.GetModel(ShopId); // sp.ShopName = "bosonshop"; // sp.AccessToken = "66a64aa103767c7e9af2ffce3f15144f"; sp.ShopName = model.ShopNo; sp.AccessToken = model.AccessToken; sp.AppKey = model.Appkey; sp.AppSecret = model.DeveKey; string error = ""; var ListOrderModel = sp.GetOrdersNew(out error); if (error != "") return error; API_OrderInfoService.SaveOrderModel(1, ShopId, sp.ShopName, 15, 0, ListOrderModel); return "成功"; } #endregion #region 查询订单打印 [WebMethod(EnableSession = true)] public JsonModel> GetListOrderPrintHWC(int CompanyId,int StoreId, int PlatType, int ShopId, int DateType, DateTime? SDate, DateTime? EDate, int OutDays, int TjType, string Name, int PrintState, int State, int IsSku, int IsError, int IsDetail, int PostId, string KWCode, string GoodsInfo, int TrackState, int FHState, int PageIndex, int PageSize, String Sort) { PagesNew.Login(this.Session); var obj = new DD_OrderData(); RefParameterCollection Param = new RefParameterCollection(); Param.Add("a.CompanyId", "=", CompanyId, DbType.Int32); Param.Add("a.MateState", "=", 2, DbType.Int32); if (StoreId > 0) Param.Add("b.StoreId", "=", StoreId, DbType.Int32); if (PlatType > 0) Param.Add("a.PlatId", "=", PlatType, DbType.Int32); if (ShopId > 0) Param.Add("a.ShopId", "=", ShopId, DbType.Int32); if (TrackState == 1) { Param.Add("b.TrackState", ">", 0, DbType.Int32); if (PostId == 0) Param.Add("b.Post", ">", 0, DbType.Int32); } else if (TrackState == 0) { Param.Add("b.TrackState", "=", 0, DbType.Int32); } if (DateType == 1) { if (SDate != null) Param.Add("a.OrderDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.OrderDate", "<=", EDate, DbType.DateTime); } else if (DateType == 2) { if (SDate != null) Param.Add("a.InDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.InDate", "<=", EDate, DbType.DateTime); } else if (DateType == 3) { if (SDate != null) Param.Add("a.PrintDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.PrintDate", "<=", EDate, DbType.DateTime); } else if (DateType == 4) { if (SDate != null) Param.Add("a.PostDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.PostDate", "<=", EDate, DbType.DateTime); } else if (DateType == 5) { if (SDate != null) Param.Add("a.OrderOutDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.OrderOutDate", "<=", EDate, DbType.DateTime); } if (OutDays > 0) { Param.Add("a.OrderOutDate", "<=", DateTime.Today.AddDays(OutDays), DbType.DateTime); } if (PrintState == -1 && FHState > -1) { Param.Add("a.poststate", "=", FHState, DbType.Int32); if (IsError == 1) { Param.Add("isnull(b.ErrorInfo,'')", "<>", "", DbType.String); } } else { if (IsError == 1) { Param.Add("(a.PostState", "=", 2, DbType.Int32); Param.Add("isnull(b.ErrorInfo,'')", "<>", "", "or", ")", DbType.String); } else Param.Add("a.PostState", "<", 2, DbType.Int32); } if (PrintState > -1) Param.Add("a.PrintState", "=", PrintState, DbType.Int32); if (PrintState > -1) Param.Add("a.State", "=", 1, DbType.Int32); else { Param.Add("a.State", ">", 0, DbType.Int32); Param.Add("a.State", "<", 3, DbType.Int32); //Param.Add("b.RevPhone", "is", null, "or",")",DbType.String); } if (PostId > 0) Param.Add("b.Post", "=", PostId, DbType.Int32); string TCode = ""; if (Name != "") { Name = Name.Trim(); if (TjType == 1) { Param.Add("(a.PlatOrderCode", "=", Name, DbType.String); Param.Add("a.JoinOrderCode", "=", Name, "or", ")", DbType.String); } else if (TjType == 2) { Param.Add("b.RevName", "like", Name, DbType.String); } else if (TjType == 3) { Param.Add("b.RevPhone", "like", Name, DbType.String); } else if (TjType == 4) { Param.Add("(b.RevCountry", "=", Name, DbType.String); Param.Add("b.CountryName", "=", Name, "or", DbType.String); Param.Add("b.CountryCode", "=", Name, "or", ")", DbType.String); } else if (TjType == 5) { Param.Add("b.RevPostCode", "=", Name, DbType.String); } else if (TjType == 6) { Param.Add("(b.RevAddr", "like", Name, DbType.String); Param.Add("b.RevProvince", "like", Name, "or", DbType.String); Param.Add("b.RevCity", "like", Name, "or", DbType.String); Param.Add("b.RevArea", "like", Name, "or", ")", DbType.String); } else if (TjType == 9) { Param.Add("(b.ErrorInfo", "like", Name, DbType.String); Param.Add("b.PostError", "like", Name, "or", ")", DbType.String); } else if (TjType == 10) { TCode = Name; } } JsonModel> resultModel = new JsonModel>(); int RowCount = 0; string GoodsName = ""; string Code = ""; if (GoodsInfo != "") { GoodsName = GoodsInfo.Trim(); if (GoodsInfo.Trim().Contains(' ')) { GoodsName = GoodsInfo.Trim().Split(' ')[0].Trim(); Code = GoodsInfo.Trim().Split(' ')[1].Trim(); } } resultModel.DataSource = obj.GetListDT_PrintOrderInfoForTM(CompanyId, TCode, GoodsName, 0, Code, KWCode, IsSku, Param, PageIndex, PageSize, Sort, out RowCount); resultModel.RowCount = RowCount; string Ids = ""; if (resultModel.DataSource != null) { foreach (var md in resultModel.DataSource) { Ids += md.OrderId.ToString() + ","; } } if (Ids != "") { JC_ExpressService obj3 = new JC_ExpressService(); // var elist = obj3.GetExpressTypeList(); var plist = obj3.GetExpressList(); var errorlist = obj.GetErrorList(Ids.Trim(',')); if (errorlist != null || plist != null) { foreach (var md in resultModel.DataSource) { if (errorlist != null && errorlist.Count > 0) { var emd = errorlist.Find(n => n.OrderId == md.OrderId); if (emd != null) { md.ErrorInfo = emd.ErrorInfo; } } if (md.Post > 0 && plist != null && plist.Count > 0) { var emd = plist.Find(n => n.ExpressID == md.Post); if (emd != null) { md.PostInfo = emd.Name; } } } } } if (IsDetail == 0) { if (Ids != "") { var listTrack = obj.GetTrackCodeApplyList2(Ids.Trim(',')); if (listTrack != null) { foreach (var md in resultModel.DataSource) { var list3 = new List(); if (md.JoinOrderCode != null && md.JoinOrderCode != "") list3 = listTrack.FindAll(n => n.OrderCode == md.JoinOrderCode); else list3 = listTrack.FindAll(n => n.OrderId == md.OrderId); if (list3 != null && list3.Count > 0) { string trackinfo = ""; int tcount = 0; foreach (var md1 in list3) { if (md1.TrackType < 3) { trackinfo += md1.TrackCode + "
"; tcount++; } } md.TrackCode = trackinfo; } } } } } else if (IsDetail == 1) { if (Ids != "") { var listTrack = obj.GetTrackCodeApplyList2(Ids.Trim(',')); var list1 = DataNew.GetOrderGoodsPostionHWC(Ids.Trim(',')); if (list1 != null) { foreach (var md in resultModel.DataSource) { var list2 = list1.FindAll(n => n.OrderId == md.OrderId); if (list2 != null) { md.GoodsList = list2; } var list3 = new List(); if (listTrack != null) { if (md.JoinOrderCode != null && md.JoinOrderCode != "") list3 = listTrack.FindAll(n => n.OrderCode == md.JoinOrderCode); else list3 = listTrack.FindAll(n => n.OrderId == md.OrderId); } if (list3 != null && list3.Count > 0) { string trackinfo = ""; int tcount = 0; foreach (var md1 in list3) { if (md1.TrackType < 3) { trackinfo += md1.TrackCode + "
"; tcount++; } } md.TrackCode = trackinfo; } } } } } return resultModel; } #endregion #region 查询订单打印导出 [WebMethod(EnableSession = true)] public string GetListOrderPrintHWCExcel(int CompanyId,int StoreId, int PlatType, int ShopId, int DateType, DateTime? SDate, DateTime? EDate, int OutDays, int TjType, string Name, int PrintState, int State, int IsSku, int IsError, int IsDetail, int PostId, string KWCode, string GoodsInfo, int TrackState, int FHState, int PageIndex, int PageSize, String Sort) { PagesNew.Login(this.Session); var obj = new DD_OrderData(); RefParameterCollection Param = new RefParameterCollection(); Param.Add("a.CompanyId", "=", CompanyId, DbType.Int32); Param.Add("a.MateState", "=", 2, DbType.Int32); if(StoreId>0) Param.Add("b.StoreId", "=", StoreId, DbType.Int32); if (PlatType > 0) Param.Add("a.PlatId", "=", PlatType, DbType.Int32); if (ShopId > 0) Param.Add("a.ShopId", "=", ShopId, DbType.Int32); if (TrackState == 1) { Param.Add("b.TrackState", ">", 0, DbType.Int32); if (PostId == 0) Param.Add("b.Post", ">", 0, DbType.Int32); } else if (TrackState == 0) { Param.Add("b.TrackState", "=", 0, DbType.Int32); } if (DateType == 1) { if (SDate != null) Param.Add("a.OrderDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.OrderDate", "<=", EDate, DbType.DateTime); } else if (DateType == 2) { if (SDate != null) Param.Add("a.InDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.InDate", "<=", EDate, DbType.DateTime); } else if (DateType == 3) { if (SDate != null) Param.Add("a.PrintDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.PrintDate", "<=", EDate, DbType.DateTime); } else if (DateType == 4) { if (SDate != null) Param.Add("a.PostDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.PostDate", "<=", EDate, DbType.DateTime); } else if (DateType == 5) { if (SDate != null) Param.Add("a.OrderOutDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.OrderOutDate", "<=", EDate, DbType.DateTime); } if (OutDays > 0) { Param.Add("a.OrderOutDate", "<=", DateTime.Today.AddDays(OutDays), DbType.DateTime); } if (PrintState == -1 && FHState > -1) { Param.Add("a.poststate", "=", FHState, DbType.Int32); if (IsError == 1) { Param.Add("isnull(b.ErrorInfo,'')", "<>", "", DbType.String); } } else { if (IsError == 1) { Param.Add("(a.PostState", "=", 2, DbType.Int32); Param.Add("isnull(b.ErrorInfo,'')", "<>", "", "or", ")", DbType.String); } else Param.Add("a.PostState", "<", 2, DbType.Int32); } if (PrintState > -1) Param.Add("a.PrintState", "=", PrintState, DbType.Int32); if (PrintState > -1) Param.Add("a.State", "=", 1, DbType.Int32); else { Param.Add("a.State", ">", 0, DbType.Int32); Param.Add("a.State", "<", 3, DbType.Int32); //Param.Add("b.RevPhone", "is", null, "or",")",DbType.String); } if (PostId > 0) Param.Add("b.Post", "=", PostId, DbType.Int32); string TCode = ""; if (Name != "") { Name = Name.Trim(); if (TjType == 1) { Param.Add("(a.PlatOrderCode", "=", Name, DbType.String); Param.Add("a.JoinOrderCode", "=", Name, "or", ")", DbType.String); } else if (TjType == 2) { Param.Add("b.RevName", "like", Name, DbType.String); } else if (TjType == 3) { Param.Add("b.RevPhone", "like", Name, DbType.String); } else if (TjType == 4) { Param.Add("(b.RevCountry", "=", Name, DbType.String); Param.Add("b.CountryName", "=", Name, "or", DbType.String); Param.Add("b.CountryCode", "=", Name, "or", ")", DbType.String); } else if (TjType == 5) { Param.Add("b.RevPostCode", "=", Name, DbType.String); } else if (TjType == 6) { Param.Add("(b.RevAddr", "like", Name, DbType.String); Param.Add("b.RevProvince", "like", Name, "or", DbType.String); Param.Add("b.RevCity", "like", Name, "or", DbType.String); Param.Add("b.RevArea", "like", Name, "or", ")", DbType.String); } else if (TjType == 9) { Param.Add("(b.ErrorInfo", "like", Name, DbType.String); Param.Add("b.PostError", "like", Name, "or", ")", DbType.String); } else if (TjType == 10) { TCode = Name; } } JsonModel> resultModel = new JsonModel>(); int RowCount = 0; string GoodsName = ""; string Code = ""; if (GoodsInfo != "") { GoodsName = GoodsInfo.Trim(); if (GoodsInfo.Trim().Contains(' ')) { GoodsName = GoodsInfo.Trim().Split(' ')[0].Trim(); Code = GoodsInfo.Trim().Split(' ')[1].Trim(); } } resultModel.DataSource = obj.GetListDT_PrintOrderInfoForTM(CompanyId, TCode, GoodsName, 0, Code, KWCode, IsSku, Param, PageIndex, PageSize, Sort, out RowCount); resultModel.RowCount = RowCount; string Ids = ""; if (resultModel.DataSource != null) { foreach (var md in resultModel.DataSource) { Ids += md.OrderId.ToString() + ","; } } if (Ids != "") { JC_ExpressService obj3 = new JC_ExpressService(); // var elist = obj3.GetExpressTypeList(); var plist = obj3.GetExpressList(); var errorlist = obj.GetErrorList(Ids.Trim(',')); if (errorlist != null || plist != null) { foreach (var md in resultModel.DataSource) { if (errorlist != null && errorlist.Count > 0) { var emd = errorlist.Find(n => n.OrderId == md.OrderId); if (emd != null) { md.ErrorInfo = emd.ErrorInfo; } } if (md.Post > 0 && plist != null && plist.Count > 0) { var emd = plist.Find(n => n.ExpressID == md.Post); if (emd != null) { md.PostInfo = emd.Name; } } } } } if (IsDetail == 0) { if (Ids != "") { var listTrack = obj.GetTrackCodeApplyList2(Ids.Trim(',')); if (listTrack != null) { foreach (var md in resultModel.DataSource) { var list3 = new List(); if (md.JoinOrderCode != null && md.JoinOrderCode != "") list3 = listTrack.FindAll(n => n.OrderCode == md.JoinOrderCode); else list3 = listTrack.FindAll(n => n.OrderId == md.OrderId); if (list3 != null && list3.Count > 0) { string trackinfo = ""; int tcount = 0; foreach (var md1 in list3) { if (md1.TrackType < 3) { trackinfo += md1.TrackCode + "
"; tcount++; } } md.TrackCode = trackinfo; } } } } } else if (IsDetail == 1) { if (Ids != "") { var listTrack = obj.GetTrackCodeApplyList2(Ids.Trim(',')); var list1 = DataNew.GetOrderGoodsPostionHWC2(Ids.Trim(',')); if (list1 != null) { foreach (var md in resultModel.DataSource) { var list2 = list1.FindAll(n => n.OrderId == md.OrderId); if (list2 != null) { md.GoodsList = list2; } var list3 = new List(); if (listTrack != null) { if (md.JoinOrderCode != null && md.JoinOrderCode != "") list3 = listTrack.FindAll(n => n.OrderCode == md.JoinOrderCode); else list3 = listTrack.FindAll(n => n.OrderId == md.OrderId); } if (list3 != null && list3.Count > 0) { string trackinfo = ""; int tcount = 0; foreach (var md1 in list3) { if (md1.TrackType < 3) { trackinfo += md1.TrackCode + "
"; tcount++; } } md.TrackCode = trackinfo; } } } } } DataTable tb = new DataTable(); tb.Columns.Add("ordercode", Type.GetType("System.String")); //tb.Columns.Add("hbordercode", Type.GetType("System.String")); tb.Columns.Add("goodscode", Type.GetType("System.String")); tb.Columns.Add("goodscode2", Type.GetType("System.String")); tb.Columns.Add("num", Type.GetType("System.String")); tb.Columns.Add("kwcode", Type.GetType("System.String")); tb.Columns.Add("sortno", Type.GetType("System.String")); tb.Columns.Add("trackcode", Type.GetType("System.String")); string ids2 = ""; if (resultModel.DataSource != null) { foreach (var md in resultModel.DataSource) { ids2 += md.OrderId + ","; DataRow row = tb.NewRow(); if (md.JoinOrderCode != null && md.JoinOrderCode != "") row["ordercode"] = md.PlatOrderCode + " [合" + md.JoinOrderCode + "]"; else row["ordercode"] = md.PlatOrderCode; // row["hbordercode"] = md.JoinOrderCode; row["trackcode"] = md.TrackCode.TrimEnd(','); //tb.Rows.Add(row); if (md.GoodsList != null) { int i = 0; foreach (var gmd in md.GoodsList) { i++; if (i == 1) { if (gmd.OldTypeDesc != null && gmd.OldTypeDesc != "") row["goodscode"] = gmd.OldTypeDesc; else row["goodscode"] = gmd.GoodsCode; if (gmd.GoodsOldCode != null) row["goodscode2"] = gmd.GoodsOldCode; row["num"] = gmd.GoodsNum.ToString(); row["kwcode"] = gmd.PostionCode.ToString(); row["sortno"] = gmd.LockNum.ToString(); tb.Rows.Add(row); } else { DataRow row1 = tb.NewRow(); row1["ordercode"] = ""; if (gmd.OldTypeDesc != null && gmd.OldTypeDesc != "") row1["goodscode"] = gmd.OldTypeDesc; else row1["goodscode"] = gmd.GoodsCode; if (gmd.GoodsOldCode != null) row1["goodscode2"] = gmd.GoodsOldCode; row1["num"] = gmd.GoodsNum.ToString(); row1["kwcode"] = gmd.PostionCode.ToString(); row1["sortno"] = gmd.LockNum.ToString(); tb.Rows.Add(row1); } } } } DataTable dtCopy = tb.Copy(); DataView dv = tb.DefaultView; dv.Sort = "sortno,kwcode"; dtCopy = dv.ToTable(); if (ids2 != null) { DataRow row2 = dtCopy.NewRow(); row2["ordercode"] = ""; row2["goodscode"] = ""; row2["goodscode2"] = ""; row2["num"] = ""; row2["kwcode"] = ""; dtCopy.Rows.Add(row2); row2 = dtCopy.NewRow(); row2["ordercode"] = ""; row2["goodscode"] = ""; row2["goodscode2"] = ""; row2["num"] = ""; row2["kwcode"] = ""; dtCopy.Rows.Add(row2); row2 = dtCopy.NewRow(); row2["ordercode"] = "Total:"; row2["goodscode"] = ""; row2["goodscode2"] = ""; row2["num"] = ""; row2["kwcode"] = ""; dtCopy.Rows.Add(row2); List list8 = DataNew.GetOrderGoodsPostionList22(ids2.Trim(',')); if (list8 != null) { foreach (DT_OrderGoods goods2 in list8) { row2 = dtCopy.NewRow(); row2["ordercode"] = ""; if (goods2.OldTypeDesc != null && goods2.OldTypeDesc != "") row2["goodscode"] = goods2.OldTypeDesc; else row2["goodscode"] = goods2.GoodsCode; row2["goodscode2"] = goods2.GoodsOldCode; row2["num"] = goods2.GoodsNum; row2["kwcode"] = goods2.PostionCode; dtCopy.Rows.Add(row2); } } } string cn = "QTY" + DateTime.Today.ToString("MMdd"); TableColumnCollection listColumns = new TableColumnCollection(); listColumns.Add("ordercode", "OrderCode", DbType.String, ""); listColumns.Add("goodscode", "SKU", DbType.String, ""); listColumns.Add("goodscode2", "GoodsCode2", DbType.String, ""); listColumns.Add("num", cn, DbType.String, ""); listColumns.Add("kwcode", "LOCATION", DbType.String, ""); listColumns.Add("trackcode", "Trackcode", DbType.String, ""); MicrosoftExcel obj2 = new MicrosoftExcel(); return obj2.Export(dtCopy, listColumns); } return ""; } #endregion #region 保存黑名单 [WebMethod(EnableSession = true)] public int Save_BlackName(DT_BlackName Model) { PagesNew.Login(this.Session); Model.userid = Convert.ToInt32(Session["UserId"]); return DataNew.Save_BlackName(Model); } #endregion #region 分页查询 [WebMethod(EnableSession = true)] public JsonModel> GetListBlackName(string cs,int PageIndex, int PageSize) { PagesNew.Login(this.Session); string where = CustomIO.Base64StringToString(cs); if (where!="")where = "where " + where.Substring(4); var resultModel = new JsonModel>(); int RowCount = 0; resultModel.DataSource=DataNew.GetListBlackName(where,PageIndex,PageSize, "", out RowCount); resultModel.RowCount = RowCount; return resultModel; } #endregion #region 删除 [WebMethod(EnableSession = true)] public bool Delete_BlackName(int id) { PagesNew.Login(this.Session); DataNew.Delete_BlackName(id); return true; } #endregion #region 保存 [WebMethod(EnableSession = true)] public int Save_PostVote(DT_PostVote Model, int IsSS) { PagesNew.Login(this.Session); DataNew.UpdateOrderWLSS(Model.OrderId.Value, IsSS); if (IsSS == 0) { DataNew.Delete_PostVote(Model.OrderId.Value); return 1; } Model.inname = Session["Name"].ToString(); Model.indate = DateTime.Now; return DataNew.Save_PostVote(Model); } #endregion #region 删除 [WebMethod(EnableSession = true)] public bool Delete_PostVote(int Id) { PagesNew.Login(this.Session); DataNew.Delete_PostVote(Id); return true; } #endregion #region 删除明细 [WebMethod(EnableSession = true)] public bool Delete_PostVoteDetail(int Id) { PagesNew.Login(this.Session); DataNew.Delete_PostVoteDetail(Id); return true; } #endregion #region 返回Model [WebMethod(EnableSession = true)] public DT_PostVote GetModel_PostVote(int OrderId) { PagesNew.Login(this.Session); var Model = DataNew.GetModel_PostVote(OrderId); return Model; } #endregion #region 平台部门店铺 [WebMethod(EnableSession = true)] public List GetDeptShopListHWC(int PlatType, int DeptId, int CompanyId) { PagesNew.Login(this.Session); if (CompanyId == 0) CompanyId = Convert.ToInt32(Session["CompanyId"]); BaseService obj = new BaseService(); var list = obj.GetDeptShopList(CompanyId, PlatType, DeptId); return list; } #endregion #region 查询没匹配完的订单 [WebMethod(EnableSession = true)] public JsonModel> GetListOrderMateForTM2(int YC_TS,int PlatType, int ShopId, int DateType, DateTime? SDate, DateTime? EDate, int TjType, string Name, int MateState, int IsSku, int IsError, int PostId, int IsDetail, int HBOrder, int StoreId, int IsPost, int OutDays, int PageIndex, int PageSize) { PagesNew.Login(this.Session); var obj = new DD_OrderData(); int CompanyId = Convert.ToInt32(Session["CompanyId"]); RefParameterCollection Param = new RefParameterCollection(); Param.Add("a.CompanyId", "=", CompanyId, DbType.Int32); if(YC_TS==1) Param.Add("a.YC_TS", "=", YC_TS, DbType.Int32); else if (YC_TS == 0) Param.Add("isnull(a.YC_TS,0)", "=", YC_TS, DbType.Int32); if (PlatType > 0) Param.Add("a.PlatId", "=", PlatType, DbType.Int32); if (ShopId > 0) Param.Add("a.ShopId", "=", ShopId, DbType.Int32); if (DateType == 1) { if (SDate != null) Param.Add("a.OrderDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.OrderDate", "<=", EDate, DbType.DateTime); } else if (DateType == 2) { if (SDate != null) Param.Add("a.InDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.InDate", "<=", EDate, DbType.DateTime); } else if (DateType == 3) { if (SDate != null) Param.Add("a.PrintDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.PrintDate", "<=", EDate, DbType.DateTime); } else if (DateType == 4) { if (SDate != null) Param.Add("a.PostDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.PostDate", "<=", EDate, DbType.DateTime); } else if (DateType == 5) { if (SDate != null) Param.Add("a.OrderOutDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.OrderOutDate", "<=", EDate, DbType.DateTime); } if (OutDays > 0) { Param.Add("a.OrderOutDate", "<=", DateTime.Today.AddDays(OutDays), DbType.DateTime); } //if (MateState>-1) //{ if (IsPost == 1) Param.Add("a.PostState", "in", "0,3", DbType.String); else Param.Add("a.PostState", "<>", 1, DbType.Int32); if (StoreId > 0) Param.Add("b.StoreId", "=", StoreId, DbType.Int32); else Param.Add("isnull(a.IsFBA,0)", "=", "0", DbType.Int32); //} if (PostId > 0) Param.Add("b.Post", "=", PostId, DbType.Int32); //else if(IsPost==1) // Param.Add("a.PostState", "=", 0, DbType.Int32); Param.Add("a.MoneyState", "=", 1, DbType.Int32); if (MateState > -1) Param.Add("a.MateState", "=", MateState, DbType.Int32); Param.Add("a.State", "=", 1, DbType.Int32); Param.Add("a.FPDate", "is not", null, DbType.String); if (HBOrder == 1) Param.Add("a.IsJoin", "=", 1, DbType.Int32); if (IsError == 1) { Param.Add("(b.SendAddr", ">", 0, DbType.Int32); Param.Add("b.IsLeaveWord", "=", 1, "or", ")", DbType.Int32); } if (Name != "") { Name = Name.Trim(); if (TjType == 1) { Param.Add("(a.PlatOrderCode", "=", Name, DbType.String); Param.Add("a.JoinOrderCode", "=", Name, "or", ")", DbType.String); } else if (TjType == 2) { Param.Add("b.RevName", "like", Name, DbType.String); } else if (TjType == 3) { Param.Add("b.RevPhone", "like", Name, DbType.String); } else if (TjType == 4) { Param.Add("(b.RevCountry", "=", Name, DbType.String); Param.Add("b.CountryName", "=", Name, "or", DbType.String); Param.Add("b.CountryCode", "=", Name, "or", ")", DbType.String); } else if (TjType == 5) { Param.Add("b.RevPostCode", "=", Name, DbType.String); } else if (TjType == 6) { Param.Add("(b.RevAddr", "like", Name, DbType.String); Param.Add("b.RevProvince", "like", Name, "or", DbType.String); Param.Add("b.RevCity", "like", Name, "or", DbType.String); Param.Add("b.RevArea", "like", Name, "or", ")", DbType.String); } else if (TjType == 9) { Param.Add("(b.ErrorInfo", "like", Name, DbType.String); Param.Add("b.PostError", "like", Name, "or", ")", DbType.String); } //else if (TjType == 10) //{ // Param.Add("b.TrackCode", "like", Name, DbType.String); //} } //Param.Add("a.OrderDate", ">=", 0, DbType.Int32); JsonModel> resultModel = new JsonModel>(); int RowCount = 0; string Sort = "a.OrderLevel desc,a.OrderDate"; Sort = Sort.Trim(','); string GoodsName = ""; string SKU = ""; if (TjType == 7 && Name != "") { GoodsName = Name; } else if (TjType == 8 && Name != "") { SKU = Name; } resultModel.DataSource = DataNew.GetListDT_OrderInfoMate2(GoodsName, SKU, 1, Param, PageIndex, PageSize, Sort, out RowCount); resultModel.RowCount = RowCount; string Ids = ""; if (resultModel.DataSource != null) { foreach (var md in resultModel.DataSource) { Ids += md.OrderId.ToString() + ","; } } if (Ids != "") { var errorlist = obj.GetErrorList(Ids.Trim(',')); if (errorlist != null) { foreach (var md in resultModel.DataSource) { var emd = errorlist.Find(n => n.OrderId == md.OrderId); if (emd != null) { md.ErrorInfo = emd.ErrorInfo; } } } } if (resultModel.DataSource != null) { BaseService obj2 = new BaseService(); var postlist = obj2.GetExpressPostList(CompanyId, 0); var errorlist = new List(); if (Ids != "") { errorlist = obj.GetErrorList(Ids.Trim(',')); } foreach (var md in resultModel.DataSource) { if (errorlist != null && errorlist.Count > 0) { var emd = errorlist.Find(n => n.OrderId == md.OrderId); if (emd != null) { md.ErrorInfo = emd.ErrorInfo; } } if (md.Post > 0 && postlist != null) { var pmd = postlist.Find(n => n.ExpressID == md.Post); if (pmd != null) { md.LocalPost = pmd.Name; } else md.LocalPost = ""; } else md.LocalPost = ""; } } if (IsDetail == 1 && resultModel.DataSource != null) { if (Ids != "") { var list1 = obj.GetOrderGoodsList(Ids.Trim(',')); if (list1 != null) { foreach (var md in resultModel.DataSource) { var list2 = list1.FindAll(n => n.OrderId == md.OrderId); if (list2 != null) { md.GoodsList = list2; } } } } } return resultModel; } #endregion #region 分页查询 [WebMethod(EnableSession = true)] public JsonModel> GetListPostVote(string cs, int PageIndex, int PageSize) { PagesNew.Login(this.Session); string where = CustomIO.Base64StringToString(cs); if (where != "") where = "where " + where.Substring(4); var resultModel = new JsonModel>(); int RowCount = 0; resultModel.DataSource = DataNew.GetListPostVote(where, PageIndex, PageSize, "isnull(bigdifference,0) desc", out RowCount); resultModel.RowCount = RowCount; return resultModel; } #endregion #region 分页查询 [WebMethod(EnableSession = true)] public List GetListGoodsPlanUrlCount(string name) { PagesNew.Login(this.Session); var list = DataNew.GetListGoodsPlanUrlCount(name); return list; } #endregion #region 返回Model [WebMethod(EnableSession = true)] public DT_PostVote GetModel_PostVote2(int Id) { PagesNew.Login(this.Session); var Model = DataNew.GetModel_PostVote2(Id); return Model; } #endregion #region 保存 [WebMethod(EnableSession = true)] public int Save_PostVote2(DT_PostVote Model) { PagesNew.Login(this.Session); return DataNew.Save_PostVote2(Model); } #endregion #region 导入物流申诉 [WebMethod(EnableSession = true)] public string ImportWLSS(string FileName) { PagesNew.Login(this.Session); if (string.IsNullOrEmpty(FileName) == true) return "要导入的文件路径不能为空"; string ServerFileName = AppDomain.CurrentDomain.BaseDirectory + FileName; if (System.IO.File.Exists(ServerFileName) == false) return "要导入的文件路径不存在"; //int CompanyId = Convert.ToInt32(Session["CompanyId"]); try { ExcelNew excel = new ExcelNew(); DataTable tb = excel.ImportExcel(ServerFileName); StringBuilder sb = new StringBuilder(); //Actual Weight Amount Actual Weight Units Rated Weight Amount Rated Weight Units //Dim Length Dim Width Dim Height Dim Divisor Zone Code //Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount //Net Charge Amount estimate fee big difference result if (tb.Columns.Contains("Tracking ID") == false) sb.AppendLine("导入模板错误, 列不存在: Tracking ID"); if (tb.Columns.Contains("Actual Weight Amount") == false) sb.AppendLine("导入模板错误, 列不存在: Actual Weight Amount"); if (tb.Columns.Contains("Actual Weight Units") == false) sb.AppendLine("导入模板错误, 列不存在: Actual Weight Units"); if (tb.Columns.Contains("Rated Weight Amount") == false) sb.AppendLine("导入模板错误, 列不存在: Rated Weight Amount"); if (tb.Columns.Contains("Rated Weight Units") == false) sb.AppendLine("导入模板错误, 列不存在: Rated Weight Units"); if (tb.Columns.Contains("Dim Length") == false) sb.AppendLine("导入模板错误, 列不存在: Dim Length"); if (tb.Columns.Contains("Dim Width") == false) sb.AppendLine("导入模板错误, 列不存在: Dim Width"); if (tb.Columns.Contains("Dim Height") == false) sb.AppendLine("导入模板错误, 列不存在: Dim Height"); if (tb.Columns.Contains("Dim Divisor") == false) sb.AppendLine("导入模板错误, 列不存在: Dim Divisor"); if (tb.Columns.Contains("Dim Unit") == false) sb.AppendLine("导入模板错误, 列不存在: Dim Unit"); if (tb.Columns.Contains("Zone Code") == false) sb.AppendLine("导入模板错误, 列不存在: Zone Code"); if (tb.Columns.Contains("big difference") == false) sb.AppendLine("导入模板错误, 列不存在: big difference"); if (tb.Columns.Contains("result") == false) sb.AppendLine("导入模板错误, 列不存在: result"); if (tb.Columns.Contains("Net Charge Amount") == false) sb.AppendLine("导入模板错误, 列不存在: Net Charge Amount"); if (tb.Columns.Contains("estimate fee") == false) sb.AppendLine("导入模板错误, 列不存在: estimate fee"); if (sb.Length > 0) return sb.ToString(); tb.Columns["Tracking ID"].ColumnName = "trackcode"; tb.Columns["Actual Weight Amount"].ColumnName = "ActualWeightAmount"; tb.Columns["Actual Weight Units"].ColumnName = "ActualWeightUnits"; tb.Columns["Rated Weight Amount"].ColumnName = "RatedWeightAmount"; tb.Columns["Rated Weight Units"].ColumnName = "RatedWeightUnits"; tb.Columns["Dim Length"].ColumnName = "DimLength"; tb.Columns["Dim Width"].ColumnName = "DimWidth"; tb.Columns["Dim Height"].ColumnName = "DimHeight"; tb.Columns["Dim Divisor"].ColumnName = "DimDivisor"; tb.Columns["Dim Unit"].ColumnName = "DimUnit"; tb.Columns["Zone Code"].ColumnName = "ZoneCode"; tb.Columns["big difference"].ColumnName = "bigdifference"; tb.Columns["result"].ColumnName = "result"; tb.Columns["Net Charge Amount"].ColumnName = "NetChargeAmount"; tb.Columns["estimate fee"].ColumnName = "estimatefee"; var ListModel = new List(); foreach (DataRow row in tb.Rows) { int index = tb.Rows.IndexOf(row) + 2; var model = new DT_PostVote(); string trackcode = Convert.ToString(row["trackcode"]); if (string.IsNullOrEmpty(trackcode) == true) { continue; } model.trackcode = trackcode; string ActualWeightAmount = Convert.ToString(row["ActualWeightAmount"]); if (string.IsNullOrEmpty(ActualWeightAmount) == false) model.ActualWeightAmount = DataConvert.ToDecimal(ActualWeightAmount); string ActualWeightUnits = Convert.ToString(row["ActualWeightUnits"]); if (string.IsNullOrEmpty(ActualWeightUnits) == false) model.ActualWeightUnits = ActualWeightUnits; string RatedWeightAmount = Convert.ToString(row["RatedWeightAmount"]); if (string.IsNullOrEmpty(RatedWeightAmount) == false) model.RatedWeightAmount = DataConvert.ToDecimal(RatedWeightAmount); string RatedWeightUnits = Convert.ToString(row["RatedWeightUnits"]); if (string.IsNullOrEmpty(RatedWeightUnits) == false) model.RatedWeightUnits = RatedWeightUnits; string DimLength = Convert.ToString(row["DimLength"]); model.DimLength = DataConvert.ToDecimal(DimLength); string DimWidth = Convert.ToString(row["DimWidth"]); if (string.IsNullOrEmpty(DimWidth) == false) model.DimWidth = DataConvert.ToDecimal(DimWidth); string DimHeight = Convert.ToString(row["DimHeight"]); if (string.IsNullOrEmpty(DimHeight) == false) model.DimHeight = DataConvert.ToDecimal(DimHeight); string DimDivisor = Convert.ToString(row["DimDivisor"]); if (string.IsNullOrEmpty(DimDivisor) == false) model.DimDivisor = DataConvert.ToDecimal(DimDivisor); string DimUnit = Convert.ToString(row["DimUnit"]); if (string.IsNullOrEmpty(DimUnit) == false) model.DimUnit = DimUnit; string ZoneCode = Convert.ToString(row["ZoneCode"]); if (string.IsNullOrEmpty(ZoneCode) == false) model.ZoneCode = DataConvert.ToDecimal(ZoneCode); string bigdifference = Convert.ToString(row["bigdifference"]); if (string.IsNullOrEmpty(bigdifference) == false) model.bigdifference = DataConvert.ToDecimal(bigdifference); string result = Convert.ToString(row["result"]); if (string.IsNullOrEmpty(result) == false) model.result = result; model.int1 = 0; model.indate = DateTime.Now; model.inname = Session["Name"].ToString() + "导入"; string NetChargeAmount = Convert.ToString(row["NetChargeAmount"]); if (string.IsNullOrEmpty(NetChargeAmount) == false) model.NetChargeAmount = DataConvert.ToDecimal(NetChargeAmount); string estimatefee = Convert.ToString(row["estimatefee"]); if (string.IsNullOrEmpty(estimatefee) == false) model.estimatefee = DataConvert.ToDecimal(estimatefee); string Description0 = Convert.ToString(row["Tracking ID Charge Description0"]); string Amount0 = Convert.ToString(row["Tracking ID Charge Amount0"]); var list=new List(); if (string.IsNullOrEmpty(Description0) == false&&string.IsNullOrEmpty(Amount0) == false) { var md=new DT_PostVoteDetail(); md.TrackingIDChargDescription = Description0; md.TrackingIDChargeAmount = DataConvert.ToDecimal(Amount0); list.Add(md); } string Description1 = Convert.ToString(row["Tracking ID Charge Description1"]); string Amount1 = Convert.ToString(row["Tracking ID Charge Amount1"]); if (string.IsNullOrEmpty(Description1) == false && string.IsNullOrEmpty(Amount1) == false) { var md = new DT_PostVoteDetail(); md.TrackingIDChargDescription = Description1; md.TrackingIDChargeAmount = DataConvert.ToDecimal(Amount1); list.Add(md); } string Description2 = Convert.ToString(row["Tracking ID Charge Description2"]); string Amount2 = Convert.ToString(row["Tracking ID Charge Amount2"]); if (string.IsNullOrEmpty(Description2) == false && string.IsNullOrEmpty(Amount2) == false) { var md = new DT_PostVoteDetail(); md.TrackingIDChargDescription = Description2; md.TrackingIDChargeAmount = DataConvert.ToDecimal(Amount2); list.Add(md); } string Description3 = Convert.ToString(row["Tracking ID Charge Description3"]); string Amount3= Convert.ToString(row["Tracking ID Charge Amount3"]); if (string.IsNullOrEmpty(Description3) == false && string.IsNullOrEmpty(Amount3) == false) { var md = new DT_PostVoteDetail(); md.TrackingIDChargDescription = Description3; md.TrackingIDChargeAmount = DataConvert.ToDecimal(Amount3); list.Add(md); } string Description4 = Convert.ToString(row["Tracking ID Charge Description4"]); string Amount4 = Convert.ToString(row["Tracking ID Charge Amount4"]); if (string.IsNullOrEmpty(Description4) == false && string.IsNullOrEmpty(Amount4) == false) { var md = new DT_PostVoteDetail(); md.TrackingIDChargDescription = Description4; md.TrackingIDChargeAmount = DataConvert.ToDecimal(Amount4); list.Add(md); } string Description5 = Convert.ToString(row["Tracking ID Charge Description5"]); string Amount5 = Convert.ToString(row["Tracking ID Charge Amount5"]); if (string.IsNullOrEmpty(Description1) == false && string.IsNullOrEmpty(Amount1) == false) { var md = new DT_PostVoteDetail(); md.TrackingIDChargDescription = Description5; md.TrackingIDChargeAmount = DataConvert.ToDecimal(Amount5); list.Add(md); } model.list = list; ListModel.Add(model); } if (sb.Length > 0) return sb.ToString(); foreach (var item in ListModel) { //item.InUserName = UserName; //item.InUserID = UserId; DataNew.Save_PostVote3(item); } return "导入成功" + ListModel.Count+"条"; } catch (Exception e) { return "文件导入失败!请确定模板格式是否正确,或者重新下载模板,填写数据,重新导入!!!" + e.Message; } return "导入成功"; } #endregion #region 导入广告费 [WebMethod(EnableSession = true)] public string ImportAdFee(string FileName) { PagesNew.Login(this.Session); if (string.IsNullOrEmpty(FileName) == true) return "要导入的文件路径不能为空"; string ServerFileName = AppDomain.CurrentDomain.BaseDirectory + FileName; if (System.IO.File.Exists(ServerFileName) == false) return "要导入的文件路径不存在"; //int CompanyId = Convert.ToInt32(Session["CompanyId"]); try { ExcelNew excel = new ExcelNew(); DataTable tb = excel.ImportExcel(ServerFileName); StringBuilder sb = new StringBuilder(); //Actual Weight Amount Actual Weight Units Rated Weight Amount Rated Weight Units //Dim Length Dim Width Dim Height Dim Divisor Zone Code //Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount //Net Charge Amount estimate fee big difference result if (tb.Columns.Contains("日期") == false) sb.AppendLine("导入模板错误, 列不存在: 日期"); if (tb.Columns.Contains("广告组合名称") == false) sb.AppendLine("导入模板错误, 列不存在: 广告组合名称"); if (tb.Columns.Contains("广告活动名称") == false) sb.AppendLine("导入模板错误, 列不存在: 广告活动名称"); //if (tb.Columns.Contains("Rated Weight Amount") == false) sb.AppendLine("导入模板错误, 列不存在: Rated Weight Amount"); //if (tb.Columns.Contains("Rated Weight Units") == false) sb.AppendLine("导入模板错误, 列不存在: Rated Weight Units"); //if (tb.Columns.Contains("Dim Length") == false) sb.AppendLine("导入模板错误, 列不存在: Dim Length"); //if (tb.Columns.Contains("Dim Width") == false) sb.AppendLine("导入模板错误, 列不存在: Dim Width"); //if (tb.Columns.Contains("Dim Height") == false) sb.AppendLine("导入模板错误, 列不存在: Dim Height"); //if (tb.Columns.Contains("Dim Divisor") == false) sb.AppendLine("导入模板错误, 列不存在: Dim Divisor"); //if (tb.Columns.Contains("Dim Unit") == false) sb.AppendLine("导入模板错误, 列不存在: Dim Unit"); //if (tb.Columns.Contains("Zone Code") == false) sb.AppendLine("导入模板错误, 列不存在: Zone Code"); //if (tb.Columns.Contains("big difference") == false) sb.AppendLine("导入模板错误, 列不存在: big difference"); //if (tb.Columns.Contains("result") == false) sb.AppendLine("导入模板错误, 列不存在: result"); //if (tb.Columns.Contains("Net Charge Amount") == false) sb.AppendLine("导入模板错误, 列不存在: Net Charge Amount"); //if (tb.Columns.Contains("estimate fee") == false) sb.AppendLine("导入模板错误, 列不存在: estimate fee"); //if (sb.Length > 0) return sb.ToString(); //tb.Columns["Tracking ID"].ColumnName = "trackcode"; //tb.Columns["Actual Weight Amount"].ColumnName = "ActualWeightAmount"; //tb.Columns["Actual Weight Units"].ColumnName = "ActualWeightUnits"; //tb.Columns["Rated Weight Amount"].ColumnName = "RatedWeightAmount"; //tb.Columns["Rated Weight Units"].ColumnName = "RatedWeightUnits"; //tb.Columns["Dim Length"].ColumnName = "DimLength"; //tb.Columns["Dim Width"].ColumnName = "DimWidth"; //tb.Columns["Dim Height"].ColumnName = "DimHeight"; //tb.Columns["Dim Divisor"].ColumnName = "DimDivisor"; //tb.Columns["Dim Unit"].ColumnName = "DimUnit"; //tb.Columns["Zone Code"].ColumnName = "ZoneCode"; //tb.Columns["big difference"].ColumnName = "bigdifference"; //tb.Columns["result"].ColumnName = "result"; //tb.Columns["Net Charge Amount"].ColumnName = "NetChargeAmount"; //tb.Columns["estimate fee"].ColumnName = "estimatefee"; //var ListModel = new List(); int count = 0; foreach (DataRow row in tb.Rows) { var md = new DT_AdFee(); md.addate = Convert.ToDateTime(row["日期"].ToString()); md.adname = row["广告组合名称"].ToString(); md.adname2 = row["广告活动名称"].ToString(); md.adname3 = row["广告组名称"].ToString(); md.adsku = row["广告SKU"].ToString(); md.adasin = row["广告ASIN"].ToString(); md.moneycode = row["货币"].ToString(); if (row["展现量"].ToString() != "") md.num1 = Convert.ToInt32(row["展现量"].ToString()); else md.num1 = 0; if (row["点击量"].ToString() != "") md.num2 = Convert.ToInt32(row["点击量"].ToString()); else md.num2 = 0; if (row["点击率(CTR)"].ToString() != "") md.dec1 = Convert.ToDecimal(row["点击率(CTR)"].ToString().Replace("%", "")); if (row["每次点击成本(CPC)"].ToString() != "") md.dec2 = decimal.Round(Convert.ToDecimal(row["每次点击成本(CPC)"].ToString().Replace("$", "")), 4); else md.dec2 = 0; if (row["花费"].ToString() != "") md.dec3 = decimal.Round(Convert.ToDecimal(row["花费"].ToString().Replace("$", "")), 4); else md.dec3 = 0; //if (row["7天总销售额(¥)"].ToString() != "") // md.dec4 = Convert.ToDecimal(row["7天总销售额(¥)"].ToString().Replace("$", "")); //if (row["广告成本销售比(ACoS)"].ToString() != "") // md.dec5 = Convert.ToDecimal(row["广告成本销售比(ACoS)"].ToString().Replace("$", "")); //if (row["投入产出比(RoAS)"].ToString() != "") // md.dec6 = Convert.ToDecimal(row["投入产出比(RoAS)"].ToString().Replace("$", "")); //if (row["7天总订单数(#)"].ToString() != "") // md.num3 = Convert.ToInt32(row["7天总订单数(#)"].ToString()); //if (row["7天总销售量(#)"].ToString() != "") // md.num4 = Convert.ToInt32(row["7天总销售量(#)"].ToString()); //if (row["7天的转化率"].ToString() != "") // md.dec7 = Convert.ToDecimal(row["7天的转化率"].ToString().Replace("$", "")); //if (row["7天内广告SKU销售量(#)"].ToString() != "") // md.num5 = Convert.ToInt32(row["7天内广告SKU销售量(#)"].ToString()); //if (row["7天内其他SKU销售量(#)"].ToString() != "") // md.num6 = Convert.ToInt32(row["7天内其他SKU销售量(#)"].ToString()); //if (row["7天内广告SKU销售额(¥)"].ToString() != "") // md.dec8 = Convert.ToDecimal(row["7天内广告SKU销售额(¥)"].ToString().Replace("$", "")); //if (row["7天内其他SKU销售额(¥)"].ToString() != "") // md.dec9 = Convert.ToDecimal(row["7天内其他SKU销售额(¥)"].ToString().Replace("$", "")); md.indate = DateTime.Now; md.inname = Session["Name"].ToString(); //if(md.num1==2134) DataNew.Save_AdFee(md); count++; } return "导入成功" + count.ToString() + "条"; } catch (Exception e) { return "文件导入失败!请确定模板格式是否正确,或者重新下载模板,填写数据,重新导入!!!" + e.Message; } return "导入成功"; } #endregion #region 导入广告费 [WebMethod(EnableSession = true)] public string ImportAdFee2(string FileName) { PagesNew.Login(this.Session); if (string.IsNullOrEmpty(FileName) == true) return "要导入的文件路径不能为空"; string ServerFileName = AppDomain.CurrentDomain.BaseDirectory + FileName; if (System.IO.File.Exists(ServerFileName) == false) return "要导入的文件路径不存在"; //int CompanyId = Convert.ToInt32(Session["CompanyId"]); try { ExcelNew excel = new ExcelNew(); DataTable tb = excel.ImportExcel(ServerFileName); StringBuilder sb = new StringBuilder(); //Actual Weight Amount Actual Weight Units Rated Weight Amount Rated Weight Units //Dim Length Dim Width Dim Height Dim Divisor Zone Code //Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount //Net Charge Amount estimate fee big difference result if (tb.Columns.Contains("日期") == false) sb.AppendLine("导入模板错误, 列不存在: 日期"); if (tb.Columns.Contains("广告组合名称") == false) sb.AppendLine("导入模板错误, 列不存在: 广告组合名称"); if (tb.Columns.Contains("广告活动名称") == false) sb.AppendLine("导入模板错误, 列不存在: 广告活动名称"); //if (tb.Columns.Contains("Rated Weight Amount") == false) sb.AppendLine("导入模板错误, 列不存在: Rated Weight Amount"); //if (tb.Columns.Contains("Rated Weight Units") == false) sb.AppendLine("导入模板错误, 列不存在: Rated Weight Units"); //if (tb.Columns.Contains("Dim Length") == false) sb.AppendLine("导入模板错误, 列不存在: Dim Length"); //if (tb.Columns.Contains("Dim Width") == false) sb.AppendLine("导入模板错误, 列不存在: Dim Width"); //if (tb.Columns.Contains("Dim Height") == false) sb.AppendLine("导入模板错误, 列不存在: Dim Height"); //if (tb.Columns.Contains("Dim Divisor") == false) sb.AppendLine("导入模板错误, 列不存在: Dim Divisor"); //if (tb.Columns.Contains("Dim Unit") == false) sb.AppendLine("导入模板错误, 列不存在: Dim Unit"); //if (tb.Columns.Contains("Zone Code") == false) sb.AppendLine("导入模板错误, 列不存在: Zone Code"); //if (tb.Columns.Contains("big difference") == false) sb.AppendLine("导入模板错误, 列不存在: big difference"); //if (tb.Columns.Contains("result") == false) sb.AppendLine("导入模板错误, 列不存在: result"); //if (tb.Columns.Contains("Net Charge Amount") == false) sb.AppendLine("导入模板错误, 列不存在: Net Charge Amount"); //if (tb.Columns.Contains("estimate fee") == false) sb.AppendLine("导入模板错误, 列不存在: estimate fee"); //if (sb.Length > 0) return sb.ToString(); //tb.Columns["Tracking ID"].ColumnName = "trackcode"; //tb.Columns["Actual Weight Amount"].ColumnName = "ActualWeightAmount"; //tb.Columns["Actual Weight Units"].ColumnName = "ActualWeightUnits"; //tb.Columns["Rated Weight Amount"].ColumnName = "RatedWeightAmount"; //tb.Columns["Rated Weight Units"].ColumnName = "RatedWeightUnits"; //tb.Columns["Dim Length"].ColumnName = "DimLength"; //tb.Columns["Dim Width"].ColumnName = "DimWidth"; //tb.Columns["Dim Height"].ColumnName = "DimHeight"; //tb.Columns["Dim Divisor"].ColumnName = "DimDivisor"; //tb.Columns["Dim Unit"].ColumnName = "DimUnit"; //tb.Columns["Zone Code"].ColumnName = "ZoneCode"; //tb.Columns["big difference"].ColumnName = "bigdifference"; //tb.Columns["result"].ColumnName = "result"; //tb.Columns["Net Charge Amount"].ColumnName = "NetChargeAmount"; //tb.Columns["estimate fee"].ColumnName = "estimatefee"; //var ListModel = new List(); int count = 0; foreach (DataRow row in tb.Rows) { var md = new DT_AdFee2(); md.addate = Convert.ToDateTime(row["开始日期"].ToString()); md.addate2 = Convert.ToDateTime(row["结束日期"].ToString()); md.adname = row["广告组合名称"].ToString(); md.adname2 = row["广告活动名称"].ToString(); md.adname3 = row["广告组名称"].ToString(); md.adsku = row["广告SKU"].ToString(); md.adasin = row["广告ASIN"].ToString(); md.moneycode = row["货币"].ToString(); if (row["展现量"].ToString() != "") md.num1 = Convert.ToInt32(row["展现量"].ToString()); else md.num1 = 0; if (row["点击量"].ToString() != "") md.num2 = Convert.ToInt32(row["点击量"].ToString()); else md.num2 = 0; if (row["点击率(CTR)"].ToString() != "") md.dec1 = Convert.ToDecimal(row["点击率(CTR)"].ToString().Replace("%", "")); if (row["每次点击成本(CPC)"].ToString() != "") md.dec2 = decimal.Round(Convert.ToDecimal(row["每次点击成本(CPC)"].ToString().Replace("$", "")), 4); else md.dec2 = 0; if (row["花费"].ToString() != "") md.dec3 = decimal.Round(Convert.ToDecimal(row["花费"].ToString().Replace("$", "")), 4); else md.dec3 = 0; //if (row["7天总销售额(¥)"].ToString() != "") // md.dec4 = Convert.ToDecimal(row["7天总销售额(¥)"].ToString().Replace("$", "")); //if (row["广告成本销售比(ACoS)"].ToString() != "") // md.dec5 = Convert.ToDecimal(row["广告成本销售比(ACoS)"].ToString().Replace("$", "")); //if (row["投入产出比(RoAS)"].ToString() != "") // md.dec6 = Convert.ToDecimal(row["投入产出比(RoAS)"].ToString().Replace("$", "")); //if (row["7天总订单数(#)"].ToString() != "") // md.num3 = Convert.ToInt32(row["7天总订单数(#)"].ToString()); //if (row["7天总销售量(#)"].ToString() != "") // md.num4 = Convert.ToInt32(row["7天总销售量(#)"].ToString()); //if (row["7天的转化率"].ToString() != "") // md.dec7 = Convert.ToDecimal(row["7天的转化率"].ToString().Replace("$", "")); //if (row["7天内广告SKU销售量(#)"].ToString() != "") // md.num5 = Convert.ToInt32(row["7天内广告SKU销售量(#)"].ToString()); //if (row["7天内其他SKU销售量(#)"].ToString() != "") // md.num6 = Convert.ToInt32(row["7天内其他SKU销售量(#)"].ToString()); //if (row["7天内广告SKU销售额(¥)"].ToString() != "") // md.dec8 = Convert.ToDecimal(row["7天内广告SKU销售额(¥)"].ToString().Replace("$", "")); //if (row["7天内其他SKU销售额(¥)"].ToString() != "") // md.dec9 = Convert.ToDecimal(row["7天内其他SKU销售额(¥)"].ToString().Replace("$", "")); md.indate = DateTime.Now; md.inname = Session["Name"].ToString(); //if(md.num1==2134) DataNew.Save_AdFee2(md); count++; } return "导入成功" + count.ToString() + "条"; } catch (Exception e) { return "文件导入失败!请确定模板格式是否正确,或者重新下载模板,填写数据,重新导入!!!" + e.Message; } return "导入成功"; } #endregion #region 导入订单实际费用 [WebMethod(EnableSession = true)] public string ImportOrderFactFee(string FileName) { PagesNew.Login(this.Session); if (string.IsNullOrEmpty(FileName) == true) return "要导入的文件路径不能为空"; string ServerFileName = AppDomain.CurrentDomain.BaseDirectory + FileName; if (System.IO.File.Exists(ServerFileName) == false) return "要导入的文件路径不存在"; //int CompanyId = Convert.ToInt32(Session["CompanyId"]); try { ExcelNew excel = new ExcelNew(); DataTable tb = excel.ImportExcel(ServerFileName); StringBuilder sb = new StringBuilder(); //Actual Weight Amount Actual Weight Units Rated Weight Amount Rated Weight Units //Dim Length Dim Width Dim Height Dim Divisor Zone Code //Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount //Net Charge Amount estimate fee big difference result if (tb.Columns.Contains("订单号") == false) sb.AppendLine("导入模板错误, 列不存在: 订单号"); if (tb.Columns.Contains("实际到账金额") == false) sb.AppendLine("导入模板错误, 列不存在: 实际到账金额"); if (tb.Columns.Contains("平台佣金") == false) sb.AppendLine("导入模板错误, 列不存在: 平台佣金"); if (tb.Columns.Contains("税费") == false) sb.AppendLine("导入模板错误, 列不存在: 税费"); if (sb.Length > 0) return sb.ToString(); int j=0; foreach (DataRow row in tb.Rows) { int index = tb.Rows.IndexOf(row) + 2; var model = new DT_PostVote(); string ordercode = Convert.ToString(row["订单号"]); if (ordercode == "") continue; decimal fee1=0M; if(row["实际到账金额"]!=null&&row["实际到账金额"].ToString()!="") fee1 = Convert.ToDecimal(row["实际到账金额"]); decimal fee2 = 0M; if (row["平台佣金"] != null && row["平台佣金"].ToString() != "") fee2 = Convert.ToDecimal(row["平台佣金"]); decimal fee3 = 0M; if (row["税费"] != null && row["税费"].ToString() != "") fee3 = Convert.ToDecimal(row["税费"]); DataNew.Save_OrderFee(ordercode,fee1,fee2,fee3); j++; } return "导入成功" + j.ToString() + "条"; } catch (Exception e) { return "文件导入失败!请确定模板格式是否正确,或者重新下载模板,填写数据,重新导入!!!" + e.Message; } return "导入成功"; } #endregion #region 修改物流数量 [WebMethod(EnableSession = true)] public bool updateTrackCodecount() { PagesNew.Login(this.Session); DataNew.updateTrackCodecount(); return true; } #endregion #region 设置发货 [WebMethod(EnableSession = true)] public string SetLabel(List list) { PagesNew.Login(this.Session); foreach(var md in list) { DataNew.updateAutoTrack(md.OrderId.Value); } return "成功"; } #endregion #region 首页货物排名 [WebMethod(EnableSession = true)] public DT_OrderNum GetOrderCountGoodsPM(int ShopId, string GASIN, DateTime SDate, DateTime EDate) { PagesNew.Login(this.Session); int CompanyId = Convert.ToInt32(Session["CompanyId"]); var obj = new DD_OrderData(); string[] categories = null; DT_OrderNum md = new DT_OrderNum(); var list = new List(); EDate = EDate.AddDays(1); List countlist = DataNew.GetGoodsLinkPMForAsin(GASIN, ShopId, SDate, EDate); if (countlist == null) countlist = new List(); TimeSpan ts = EDate - SDate; int days = ts.Days; categories = new string[days]; for (int i = 0; i < days; i++) { categories[i] = SDate.AddDays(i).ToString("MM月dd日"); } decimal[] data = new decimal[days]; for (int j = 0; j < days; j++) { var gmd = countlist.Find(n => n.InDate >= SDate.AddDays(j) && n.InDate < SDate.AddDays(j + 1)); if (gmd != null && gmd.Int2 != null) { data[j] = gmd.Int2.Value; } else data[j] = 0; } var datamd = new DT_OrderCountData(); datamd.name = "大类排名"; datamd.data = data; list.Add(datamd); md.categories = categories; JavaScriptSerializer JsonConvert = new JavaScriptSerializer(); string postmessage = JsonConvert.Serialize(list); md.Data = postmessage; return md; } #endregion #region 首页货物排名 [WebMethod(EnableSession = true)] public DT_OrderNum GetOrderCountGoodsPM2(int ShopId, string GASIN, DateTime SDate, DateTime EDate) { PagesNew.Login(this.Session); int CompanyId = Convert.ToInt32(Session["CompanyId"]); var obj = new DD_OrderData(); string[] categories = null; DT_OrderNum md = new DT_OrderNum(); var list = new List(); EDate = EDate.AddDays(1); List countlist = DataNew.GetGoodsLinkPMForAsin(GASIN, ShopId, SDate, EDate); if (countlist == null) countlist = new List(); TimeSpan ts = EDate - SDate; int days = ts.Days; categories = new string[days]; for (int i = 0; i < days; i++) { categories[i] = SDate.AddDays(i).ToString("MM月dd日"); } decimal[] data2 = new decimal[days]; for (int j = 0; j < days; j++) { var gmd = countlist.Find(n => n.InDate >= SDate.AddDays(j) && n.InDate < SDate.AddDays(j + 1)); if (gmd != null && gmd.Int3 != null) { data2[j] = gmd.Int3.Value; } else data2[j] = 0; } var datamd = new DT_OrderCountData(); datamd.name = "小类排名"; datamd.data = data2; list.Add(datamd); md.categories = categories; JavaScriptSerializer JsonConvert = new JavaScriptSerializer(); string postmessage = JsonConvert.Serialize(list); md.Data = postmessage; return md; } #endregion #region 首页货物排名 [WebMethod(EnableSession = true)] public DT_OrderNum GetOrderCountGoodsPMNum(int ShopId, DateTime SDate, DateTime EDate) { PagesNew.Login(this.Session); int CompanyId = Convert.ToInt32(Session["CompanyId"]); var obj = new DD_OrderData(); string[] categories = null; DT_OrderNum md = new DT_OrderNum(); var list = new List(); EDate = EDate.AddDays(1); List countlist = DataNew.GetGoodsPMCount(ShopId, SDate, EDate); if (countlist == null) countlist = new List(); TimeSpan ts = EDate - SDate; int days = ts.Days; categories = new string[days]; for (int i = 0; i < days; i++) { categories[i] = SDate.AddDays(i).ToString("MM月dd日"); } decimal[] data2 = new decimal[days]; for (int j = 0; j < days; j++) { var gmd = countlist.FindAll(n => n.InDate >= SDate.AddDays(j) && n.InDate < SDate.AddDays(j + 1)&&n.Int3>=1&&n.Int3<=3); if (gmd != null) { data2[j] = gmd.Count(); } else data2[j] = 0; } var datamd = new DT_OrderCountData(); datamd.name = "1-3名"; datamd.data = data2; list.Add(datamd); data2 = new decimal[days]; for (int j = 0; j < days; j++) { var gmd = countlist.FindAll(n => n.InDate >= SDate.AddDays(j) && n.InDate < SDate.AddDays(j + 1) && n.Int3 >=4 && n.Int3 <=50); if (gmd != null) { data2[j] = gmd.Count(); } else data2[j] = 0; } datamd = new DT_OrderCountData(); datamd.name = "4-50名"; datamd.data = data2; list.Add(datamd); data2 = new decimal[days]; for (int j = 0; j < days; j++) { var gmd = countlist.FindAll(n => n.InDate >= SDate.AddDays(j) && n.InDate < SDate.AddDays(j + 1) && n.Int3 >= 51&& n.Int3 <=100); if (gmd != null) { data2[j] = gmd.Count(); } else data2[j] = 0; } datamd = new DT_OrderCountData(); datamd.name = "51-100名"; datamd.data = data2; list.Add(datamd); data2 = new decimal[days]; for (int j = 0; j < days; j++) { var gmd = countlist.FindAll(n => n.InDate >= SDate.AddDays(j) && n.InDate < SDate.AddDays(j + 1) && n.Int3 >= 101&& n.Int3 <= 150); if (gmd != null) { data2[j] = gmd.Count(); } else data2[j] = 0; } datamd = new DT_OrderCountData(); datamd.name = "101-150名"; datamd.data = data2; list.Add(datamd); data2 = new decimal[days]; for (int j = 0; j < days; j++) { var gmd = countlist.FindAll(n => n.InDate >= SDate.AddDays(j) && n.InDate < SDate.AddDays(j + 1) && n.Int3 >=151 && n.Int3 <= 200); if (gmd != null) { data2[j] = gmd.Count(); } else data2[j] = 0; } datamd = new DT_OrderCountData(); datamd.name = "151-200名"; datamd.data = data2; list.Add(datamd); data2 = new decimal[days]; for (int j = 0; j < days; j++) { var gmd = countlist.FindAll(n => n.InDate >= SDate.AddDays(j) && n.InDate < SDate.AddDays(j + 1) && n.Int3 >=201); if (gmd != null) { data2[j] = gmd.Count(); } else data2[j] = 0; } datamd = new DT_OrderCountData(); datamd.name = "200+名"; datamd.data = data2; list.Add(datamd); md.categories = categories; JavaScriptSerializer JsonConvert = new JavaScriptSerializer(); string postmessage = JsonConvert.Serialize(list); md.Data = postmessage; return md; } #endregion #region 导入库位 [WebMethod(EnableSession = true)] public string ImportStoreKW(string FileName, int StoreId) { PagesNew.Login(this.Session); if (string.IsNullOrEmpty(FileName) == true) return "要导入的文件路径不能为空"; string ServerFileName = AppDomain.CurrentDomain.BaseDirectory + FileName; if (System.IO.File.Exists(ServerFileName) == false) return "要导入的文件路径不存在"; //int CompanyId = Convert.ToInt32(Session["CompanyId"]); try { MicrosoftExcel excel = new MicrosoftExcel(); DataTable tb = excel.ImportExcel(ServerFileName); for (int i = 0; i < tb.Rows.Count; i++) { for (int j = 0; j < tb.Columns.Count; j++) { if (tb.Rows[i][j].ToString().Trim() != "") { var md = new CK_StorePostion(); md.StoreId = StoreId; md.PostionCode = tb.Rows[i][j].ToString(); md.PostionDesc = md.PostionCode; DataNew.Save_StorePostion(md); } } } } catch (Exception e) { return "文件导入失败!请确定模板格式是否正确,或者重新下载模板,填写数据,重新导入!!!" + e.Message; } return "导入成功"; } #endregion #region 分页查询 [WebMethod(EnableSession = true)] public List GetListGoodsAdCount(int shopid,string goodscode,DateTime? sdate,DateTime? edate) { PagesNew.Login(this.Session); edate = edate.Value.AddDays(1); decimal hj = DataNew.GetListTotalPrice2(sdate.Value, edate.Value); TimeSpan ts = edate.Value - sdate.Value; int days = ts.Days; decimal thj = 100000 * 12 * days / 365;//每月10w 每天平摊仓储费 decimal fje = 0; if (hj > 0) fje = thj * 1.00M / hj; var list = DataNew.GetListGoodsStoreCount(shopid,goodscode, sdate, edate, fje); return list; } #endregion #region 分页查询 [WebMethod(EnableSession = true)] public List GetListGoodsAdCount3(string goodscode, DateTime? sdate, DateTime? edate) { PagesNew.Login(this.Session); edate = edate.Value.AddDays(1); var list = DataNew.GetListGoodsStoreCount3(goodscode, sdate, edate); return list; } #endregion #region 广告费利润统计 [WebMethod(EnableSession = true)] public DT_OrderNum GetADCountReport4(string adasin, DateTime? sdate, DateTime? edate) { PagesNew.Login(this.Session); int CompanyId = Convert.ToInt32(Session["CompanyId"]); var obj = new DD_OrderData(); string[] categories = null; DT_OrderNum md = new DT_OrderNum(); var list = new List(); TimeSpan ts = edate.Value - sdate.Value; int days = ts.Days + 1; edate = edate.Value.AddDays(1); categories = new string[days]; if (days > 0) { for (int i = 0; i < days; i++) { categories[i] = (sdate.Value.AddDays(i)).ToString("MM月dd日"); } } var clist = DataNew.GetListGoodsStoreCount4(adasin, sdate, edate, 0); decimal[] data2 = new decimal[days]; if (days > 0) { for (int j = 0; j < days; j++) { var countmd = clist.Find(n => n.OrderDate == sdate.Value.AddDays(j).ToString("yyyy-MM-dd")); if (countmd != null && countmd.ggf != null) data2[j] = countmd.ggf.Value; else data2[j] = 0; } } var datamd2 = new DT_OrderCountData(); datamd2.name = "广告费"; datamd2.data = data2; list.Add(datamd2); decimal[] data3 = new decimal[days]; if (days > 0) { for (int j = 0; j < days; j++) { var countmd = clist.Find(n => n.OrderDate == sdate.Value.AddDays(j).ToString("yyyy-MM-dd")); if (countmd != null && countmd.ml1 != null) data3[j] = countmd.ml1.Value; else data3[j] = 0; } } var datamd3 = new DT_OrderCountData(); datamd3.name = "去广告费后毛利额"; datamd3.data = data3; list.Add(datamd3); md.categories = categories; JavaScriptSerializer JsonConvert = new JavaScriptSerializer(); string postmessage = JsonConvert.Serialize(list); md.Data = postmessage; return md; } #endregion #region 广告费利润统计 [WebMethod(EnableSession = true)] public DT_OrderNum GetADCountReport(string adasin, DateTime? sdate, DateTime? edate) { PagesNew.Login(this.Session); int CompanyId = Convert.ToInt32(Session["CompanyId"]); var obj = new DD_OrderData(); string[] categories = null; DT_OrderNum md = new DT_OrderNum(); var list = new List(); TimeSpan ts = edate.Value - sdate.Value; int days = ts.Days + 1; edate = edate.Value.AddDays(1); decimal hj = DataNew.GetListTotalPrice2(sdate.Value, edate.Value); TimeSpan ts2 = edate.Value - sdate.Value; int days2 = ts2.Days; decimal thj = 100000 * 12 * days2 / 365;//每月10w 每天平摊仓储费 decimal fje = 0; if (hj > 0) fje = thj * 1.00M / hj; categories = new string[days]; if (days > 0) { for (int i = 0; i < days; i++) { categories[i] = (sdate.Value.AddDays(i)).ToString("MM月dd日"); } } var clist = DataNew.GetListGoodsStoreCount2(adasin, sdate, edate, fje); decimal[] data = new decimal[days]; if (days > 0) { for (int j = 0; j < days; j++) { if (clist != null) { var countmd = clist.Find(n => n.OrderDate == sdate.Value.AddDays(j).ToString("yyyy-MM-dd")); if (countmd != null && countmd.TotalPrice!=null) data[j] = countmd.TotalPrice.Value; else data[j] = 0; } else data[j] = 0; } } var datamd = new DT_OrderCountData(); datamd.name = "当日订单总销售额"; datamd.data = data; list.Add(datamd); decimal[] data2 = new decimal[days]; if (days > 0) { for (int j = 0; j < days; j++) { var countmd = clist.Find(n => n.OrderDate == sdate.Value.AddDays(j).ToString("yyyy-MM-dd")); if (countmd != null && countmd.ggf!=null) data2[j] = countmd.ggf.Value; else data2[j] = 0; } } //var datamd2 = new DT_OrderCountData(); //datamd2.name = "广告费"; //datamd2.data = data2; //list.Add(datamd2); decimal[] data3 = new decimal[days]; if (days > 0) { for (int j = 0; j < days; j++) { var countmd = clist.Find(n => n.OrderDate == sdate.Value.AddDays(j).ToString("yyyy-MM-dd")); if (countmd != null && countmd.ordernum != null) data3[j] = countmd.ordernum.Value; else data3[j] = 0; } } var datamd3 = new DT_OrderCountData(); datamd3.name = "当日单量"; datamd3.data = data3; list.Add(datamd3); decimal[] data4 = new decimal[days]; if (days > 0) { for (int j = 0; j < days; j++) { var countmd = clist.Find(n => n.OrderDate == sdate.Value.AddDays(j).ToString("yyyy-MM-dd")); if (countmd != null && countmd.mll1 != null) data4[j] = countmd.mll1.Value; else data4[j] = 0; } } //var datamd4 = new DT_OrderCountData(); //datamd4.name = "毛利率"; //datamd4.data = data4; //list.Add(datamd4); //decimal[] data5= new decimal[days]; //if (days > 0) //{ // for (int j = 0; j < days; j++) // { // var countmd = clist.Find(n => n.OrderDate == sdate.Value.AddDays(j).ToString("yyyy-MM-dd")); // if (countmd != null && countmd.mll2 != null) // data5[j] = countmd.mll2.Value; // else // data5[j] = 0; // } //} //var datamd5 = new DT_OrderCountData(); //datamd5.name = "除去广告费后毛利率"; //datamd5.data = data5; //list.Add(datamd5); //decimal[] data6 = new decimal[days]; //if (days > 0) //{ // for (int j = 0; j < days; j++) // { // var countmd = clist.Find(n => n.OrderDate == sdate.Value.AddDays(j).ToString("yyyy-MM-dd")); // if (countmd != null && countmd.ggzxl != null) // data6[j] = countmd.ggzxl.Value; // else // data6[j] = 0; // } //} //var datamd6 = new DT_OrderCountData(); //datamd6.name = "广告展现率"; //datamd6.data = data6; //list.Add(datamd6); //decimal[] data7 = new decimal[days]; //if (days > 0) //{ // for (int j = 0; j < days; j++) // { // var countmd = clist.Find(n => n.OrderDate == sdate.Value.AddDays(j).ToString("yyyy-MM-dd")); // if (countmd != null && countmd.ggdjl != null) // data7[j] = countmd.ggdjl.Value; // else // data7[j] = 0; // } //} //var datamd7 = new DT_OrderCountData(); //datamd7.name = "广告点击率"; //datamd7.data = data7; //list.Add(datamd7); md.categories = categories; JavaScriptSerializer JsonConvert = new JavaScriptSerializer(); string postmessage = JsonConvert.Serialize(list); md.Data = postmessage; return md; } #endregion #region 广告费利润统计 [WebMethod(EnableSession = true)] public DT_OrderNum GetADCountReport2(string adasin, DateTime? sdate, DateTime? edate) { PagesNew.Login(this.Session); int CompanyId = Convert.ToInt32(Session["CompanyId"]); var obj = new DD_OrderData(); string[] categories = null; DT_OrderNum md = new DT_OrderNum(); var list = new List(); TimeSpan ts = edate.Value - sdate.Value; int days = ts.Days + 1; edate = edate.Value.AddDays(1); decimal hj = DataNew.GetListTotalPrice2(sdate.Value, edate.Value); TimeSpan ts2 = edate.Value - sdate.Value; int days2 = ts2.Days; decimal thj = 100000 * 12 * days2 / 365;//每月10w 每天平摊仓储费 decimal fje = 0; if (hj > 0) fje = thj * 1.00M / hj; categories = new string[days]; if (days > 0) { for (int i = 0; i < days; i++) { categories[i] = (sdate.Value.AddDays(i)).ToString("MM月dd日"); } } var clist = DataNew.GetListGoodsStoreCount2(adasin, sdate, edate, fje); //decimal[] data = new decimal[days]; //if (days > 0) //{ // for (int j = 0; j < days; j++) // { // if (clist != null) // { // var countmd = clist.Find(n => n.OrderDate == sdate.Value.AddDays(j).ToString("yyyy-MM-dd")); // if (countmd != null && countmd.TotalPrice != null) // data[j] = countmd.TotalPrice.Value; // else // data[j] = 0; // } // else // data[j] = 0; // } //} //var datamd = new DT_OrderCountData(); //datamd.name = "总销售额"; //datamd.data = data; //list.Add(datamd); decimal[] data2 = new decimal[days]; if (days > 0) { for (int j = 0; j < days; j++) { var countmd = clist.Find(n => n.OrderDate == sdate.Value.AddDays(j).ToString("yyyy-MM-dd")); if (countmd != null && countmd.ggf != null) data2[j] = countmd.ggf.Value; else data2[j] = 0; } } var datamd2 = new DT_OrderCountData(); datamd2.name = "广告费"; datamd2.data = data2; list.Add(datamd2); decimal[] data3 = new decimal[days]; if (days > 0) { for (int j = 0; j < days; j++) { var countmd = clist.Find(n => n.OrderDate == sdate.Value.AddDays(j).ToString("yyyy-MM-dd")); if (countmd != null && countmd.ordernum != null) data3[j] = countmd.ordernum.Value; else data3[j] = 0; } } //var datamd3 = new DT_OrderCountData(); //datamd3.name = "单量"; //datamd3.data = data3; //list.Add(datamd3); decimal[] data4 = new decimal[days]; if (days > 0) { for (int j = 0; j < days; j++) { var countmd = clist.Find(n => n.OrderDate == sdate.Value.AddDays(j).ToString("yyyy-MM-dd")); if (countmd != null && countmd.ml1 != null) data4[j] = countmd.ml1.Value; else data4[j] = 0; } } var datamd4 = new DT_OrderCountData(); datamd4.name = "毛利额"; datamd4.data = data4; list.Add(datamd4); decimal[] data5 = new decimal[days]; if (days > 0) { for (int j = 0; j < days; j++) { var countmd = clist.Find(n => n.OrderDate == sdate.Value.AddDays(j).ToString("yyyy-MM-dd")); if (countmd != null && countmd.ml2!= null) data5[j] = countmd.ml2.Value; else data5[j] = 0; } } var datamd5 = new DT_OrderCountData(); datamd5.name = "去广告费后毛利额"; datamd5.data = data5; list.Add(datamd5); //decimal[] data6 = new decimal[days]; //if (days > 0) //{ // for (int j = 0; j < days; j++) // { // var countmd = clist.Find(n => n.OrderDate == sdate.Value.AddDays(j).ToString("yyyy-MM-dd")); // if (countmd != null && countmd.ggzxl != null) // data6[j] = countmd.ggzxl.Value; // else // data6[j] = 0; // } //} //var datamd6 = new DT_OrderCountData(); //datamd6.name = "广告展现率"; //datamd6.data = data6; //list.Add(datamd6); //decimal[] data7 = new decimal[days]; //if (days > 0) //{ // for (int j = 0; j < days; j++) // { // var countmd = clist.Find(n => n.OrderDate == sdate.Value.AddDays(j).ToString("yyyy-MM-dd")); // if (countmd != null && countmd.ggdjl != null) // data7[j] = countmd.ggdjl.Value; // else // data7[j] = 0; // } //} //var datamd7 = new DT_OrderCountData(); //datamd7.name = "广告点击率"; //datamd7.data = data7; //list.Add(datamd7); md.categories = categories; JavaScriptSerializer JsonConvert = new JavaScriptSerializer(); string postmessage = JsonConvert.Serialize(list); md.Data = postmessage; return md; } #endregion #region 分页查询 [WebMethod(EnableSession = true)] public JsonModel> GetListAddr(string name, string addr, int jxcs, int? snum, int? endnum, decimal? sprice, decimal? eprice, DateTime? StartDate, DateTime? StopDate, DateTime? StartDate2, DateTime? StopDate2, DateTime? StartDate3, DateTime? StopDate3, string Sort, int PageIndex, int PageSize) { PagesNew.Login(this.Session); RefParameterCollection where = new RefParameterCollection(); if (string.IsNullOrEmpty(name) == false) where.Add(new RefParameter("a.name", "like", name,DbType.String)); if (string.IsNullOrEmpty(addr) == false) where.Add(new RefParameter("a.addr", "like", addr, DbType.String)); if (StartDate != null) where.Add(new RefParameter("a.orderprice", ">=", StartDate, System.Data.DbType.DateTime)); if (StopDate != null) where.Add(new RefParameter("convert(varchar(10), a.orderprice, 120)", "<=", StopDate, System.Data.DbType.DateTime)); if (StartDate2 != null) where.Add(new RefParameter("a.lastdate", ">=", StartDate2, System.Data.DbType.DateTime)); if (StopDate2 != null) where.Add(new RefParameter("convert(varchar(10), a.lastdate, 120)", "<=", StopDate2, System.Data.DbType.DateTime)); if (jxcs > -1 && jxcs<6) where.Add(new RefParameter("a.mailcount", "=", jxcs, System.Data.DbType.Int32)); if (jxcs == 6) where.Add(new RefParameter("a.mailcount", ">", 5, System.Data.DbType.Int32)); if (snum != null) where.Add(new RefParameter("a.ordernum", ">=", snum, System.Data.DbType.Int32)); if (endnum != null) where.Add(new RefParameter("a.ordernum", "<=", endnum, System.Data.DbType.Int32)); if (sprice != null) where.Add(new RefParameter("a.orderprice", ">=", sprice, System.Data.DbType.Decimal)); if (eprice != null) where.Add(new RefParameter("a.orderprice", "<=", eprice, System.Data.DbType.Decimal)); if (StartDate3 != null) where.Add(new RefParameter("a.maildate", ">=", StartDate3, System.Data.DbType.DateTime)); if (StopDate3 != null) where.Add(new RefParameter("convert(varchar(10), a.maildate, 120)", "<=", StopDate3, System.Data.DbType.DateTime)); JsonModel> resultModel = new JsonModel>(); int RowCount = 0; resultModel.DataSource = DataNew.GetListAddr(where, PageIndex, PageSize, Sort, out RowCount); resultModel.RowCount = RowCount; return resultModel; } #endregion #region 分页查询 [WebMethod(EnableSession = true)] public JsonModel> GetListAddrMail(string name, string addr,int state, DateTime? StartDate, DateTime? StopDate, DateTime? StartDate2, DateTime? StopDate2, DateTime? StartDate3, DateTime? StopDate3, string Sort, int PageIndex, int PageSize) { PagesNew.Login(this.Session); RefParameterCollection where = new RefParameterCollection(); if (string.IsNullOrEmpty(name) == false) where.Add(new RefParameter("b.name", "like", name, DbType.String)); if (string.IsNullOrEmpty(addr) == false) where.Add(new RefParameter("b.addr", "like", addr, DbType.String)); if (StartDate != null) where.Add(new RefParameter("a.maildate", ">=", StartDate, System.Data.DbType.DateTime)); if (StopDate != null) where.Add(new RefParameter("convert(varchar(10), a.maildate, 120)", "<=", StopDate, System.Data.DbType.DateTime)); if (StartDate2 != null) where.Add(new RefParameter("a.printdate", ">=", StartDate2, System.Data.DbType.DateTime)); if (StopDate2 != null) where.Add(new RefParameter("convert(varchar(10), a.printdate, 120)", "<=", StopDate2, System.Data.DbType.DateTime)); if (StartDate3 != null) where.Add(new RefParameter("a.postdate", ">=", StartDate3, System.Data.DbType.DateTime)); if (StopDate3 != null) where.Add(new RefParameter("convert(varchar(10), a.postdate, 120)", "<=", StopDate3, System.Data.DbType.DateTime)); if (state>-1)where.Add(new RefParameter("a.state", "=", state, DbType.Int32)); JsonModel> resultModel = new JsonModel>(); int RowCount = 0; resultModel.DataSource = DataNew.GetListAddrMail(where, PageIndex, PageSize, Sort, out RowCount); resultModel.RowCount = RowCount; return resultModel; } #endregion #region 保存价格 [WebMethod(EnableSession = true)] public int Save_GoodsPrice(string code,decimal? price,decimal? rate,DateTime? sdate,DateTime? edate) { PagesNew.Login(this.Session); int a= DataNew.Save_price(code,price,rate,sdate,edate); return a; } #endregion #region 保存 [WebMethod(EnableSession = true)] public int Save_AddrMail(List list) { PagesNew.Login(this.Session); foreach (var md in list) { DT_AddrMail amd = new DT_AddrMail(); amd.addrid = md.id; amd.state = 0; amd.maildate = DateTime.Now; DataNew.Save_AddrMail(amd); } return 1; } #endregion #region 保存 [WebMethod(EnableSession = true)] public int update_AddrMail(List list, int state) { PagesNew.Login(this.Session); string name=Session["Name"].ToString(); foreach (var md in list) { DataNew.Update_AddrMail(md.id.Value, state, name); } return 1; } #endregion #region 获取订单费用 [WebMethod(EnableSession = true)] public DT_OrderFees GetModel_OrderFee(int orderid) { PagesNew.Login(this.Session); var md = DataNew.GetModel_OrderFee(orderid); return md; } #endregion #region 获取订单费用 [WebMethod(EnableSession = true)] public DT_Fees GetModel_OrderFeeNew(int orderid) { PagesNew.Login(this.Session); var md = DataNew.GetOrderFees(orderid.ToString()); if (md != null && md.Count > 0) { if (md[0].PlatId == 2) { var adfee = DataNew.GetOrderAdFeeByOrderID(orderid); if (md != null && md.Count > 0) { md[0].Ad_Fee = adfee; return md[0]; } } else return md[0]; } return null; } #endregion #region 导入退货费 [WebMethod(EnableSession = true)] public string ImportBackFee(string FileName) { PagesNew.Login(this.Session); if (string.IsNullOrEmpty(FileName) == true) return "要导入的文件路径不能为空"; string ServerFileName = AppDomain.CurrentDomain.BaseDirectory + FileName; if (System.IO.File.Exists(ServerFileName) == false) return "要导入的文件路径不存在"; //int CompanyId = Convert.ToInt32(Session["CompanyId"]); try { ExcelNew excel = new ExcelNew(); DataTable tb = excel.ImportExcel(ServerFileName); StringBuilder sb = new StringBuilder(); //Actual Weight Amount Actual Weight Units Rated Weight Amount Rated Weight Units //Dim Length Dim Width Dim Height Dim Divisor Zone Code //Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount //Net Charge Amount estimate fee big difference result if (tb.Columns.Contains("订单号") == false) sb.AppendLine("导入模板错误, 列不存在: 订单号"); if (tb.Columns.Contains("退款金额") == false) sb.AppendLine("导入模板错误, 列不存在:退款金额"); int count = 0; foreach (DataRow row in tb.Rows) { string ordercode= row["订单号"].ToString(); decimal fee=0; if(row["退款金额"]!=null) fee = Convert.ToDecimal(row["退款金额"].ToString()); if (ordercode == "") continue; DataNew.Save_BackFee(ordercode,fee); count++; } return "导入成功" + count.ToString() + "条"; } catch (Exception e) { return "文件导入失败!请确定模板格式是否正确,或者重新下载模板,填写数据,重新导入!!!" + e.Message; } return "导入成功"; } #endregion #region 导入退货运费 [WebMethod(EnableSession = true)] public string ImportBackPostFee(string FileName) { PagesNew.Login(this.Session); if (string.IsNullOrEmpty(FileName) == true) return "要导入的文件路径不能为空"; string ServerFileName = AppDomain.CurrentDomain.BaseDirectory + FileName; if (System.IO.File.Exists(ServerFileName) == false) return "要导入的文件路径不存在"; //int CompanyId = Convert.ToInt32(Session["CompanyId"]); try { ExcelNew excel = new ExcelNew(); DataTable tb = excel.ImportExcel(ServerFileName); StringBuilder sb = new StringBuilder(); //Actual Weight Amount Actual Weight Units Rated Weight Amount Rated Weight Units //Dim Length Dim Width Dim Height Dim Divisor Zone Code //Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount //Net Charge Amount estimate fee big difference result if (tb.Columns.Contains("订单号") == false) sb.AppendLine("导入模板错误, 列不存在: 订单号"); if (tb.Columns.Contains("跟踪码") == false) sb.AppendLine("导入模板错误, 列不存在:跟踪码"); if (tb.Columns.Contains("退货运费") == false) sb.AppendLine("导入模板错误, 列不存在:退货运费"); int count = 0; foreach (DataRow row in tb.Rows) { DT_TrackCodeApply md = new DT_TrackCodeApply(); string ordercode = row["订单号"].ToString(); decimal fee = 0; if (row["退货运费"] != null) fee = Convert.ToDecimal(row["退货运费"].ToString()); string trackcode = row["跟踪码"].ToString(); if (ordercode == "") continue; md.OrderCode = ordercode; md.TrackCode = trackcode; md.PostFee = fee; DataNew.Save_BackPostFee(md); count++; } return "导入成功" + count.ToString() + "条"; } catch (Exception e) { return "文件导入失败!请确定模板格式是否正确,或者重新下载模板,填写数据,重新导入!!!" + e.Message; } return "导入成功"; } #endregion #region 导入退货申诉运费 [WebMethod(EnableSession = true)] public string ImportSSPostFee(string FileName) { PagesNew.Login(this.Session); if (string.IsNullOrEmpty(FileName) == true) return "要导入的文件路径不能为空"; string ServerFileName = AppDomain.CurrentDomain.BaseDirectory + FileName; if (System.IO.File.Exists(ServerFileName) == false) return "要导入的文件路径不存在"; //int CompanyId = Convert.ToInt32(Session["CompanyId"]); try { ExcelNew excel = new ExcelNew(); DataTable tb = excel.ImportExcel(ServerFileName); StringBuilder sb = new StringBuilder(); //Actual Weight Amount Actual Weight Units Rated Weight Amount Rated Weight Units //Dim Length Dim Width Dim Height Dim Divisor Zone Code //Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount //Net Charge Amount estimate fee big difference result if (tb.Columns.Contains("case id") == false) sb.AppendLine("导入模板错误, 列不存在: case id"); if (tb.Columns.Contains("跟踪码") == false) sb.AppendLine("导入模板错误, 列不存在:跟踪码"); if (tb.Columns.Contains("金额") == false) sb.AppendLine("导入模板错误, 列不存在:金额"); int count = 0; foreach (DataRow row in tb.Rows) { DT_TrackCodeApply md = new DT_TrackCodeApply(); string trackcode = row["跟踪码"].ToString(); string caseid = row["case id"].ToString(); decimal fee = 0; if (row["金额"] != null) fee = Convert.ToDecimal(row["金额"].ToString()); if (trackcode == "") continue; md.TrackCode2 = caseid; md.TrackCode = trackcode; md.PostFee = fee; DataNew.Save_SSPostFee(md); count++; } return "导入成功" + count.ToString() + "条"; } catch (Exception e) { return "文件导入失败!请确定模板格式是否正确,或者重新下载模板,填写数据,重新导入!!!" + e.Message; } return "导入成功"; } #endregion #region 导入其他费用 [WebMethod(EnableSession = true)] public string ImportOtherFee(string FileName,DateTime sdt,DateTime edt,int isfg) { PagesNew.Login(this.Session); if (string.IsNullOrEmpty(FileName) == true) return "要导入的文件路径不能为空"; string ServerFileName = AppDomain.CurrentDomain.BaseDirectory + FileName; if (System.IO.File.Exists(ServerFileName) == false) return "要导入的文件路径不存在"; //int CompanyId = Convert.ToInt32(Session["CompanyId"]); string error = ""; try { ExcelNew excel = new ExcelNew(); DataTable tb = excel.ImportExcel(ServerFileName); StringBuilder sb = new StringBuilder(); //Actual Weight Amount Actual Weight Units Rated Weight Amount Rated Weight Units //Dim Length Dim Width Dim Height Dim Divisor Zone Code //Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount //Net Charge Amount estimate fee big difference result // if (tb.Columns.Contains("日期") == false) sb.AppendLine("导入模板错误, 列不存在: 日期"); if (tb.Columns.Contains("人员") == false) sb.AppendLine("导入模板错误, 列不存在:人员"); if (tb.Columns.Contains("货号") == false) sb.AppendLine("导入模板错误, 列不存在:货号"); if (tb.Columns.Contains("金额") == false) sb.AppendLine("导入模板错误, 列不存在:金额"); int count = 0; foreach (DataRow row in tb.Rows) { string name = row["人员"].ToString().Trim(); string goodscode = row["货号"].ToString().Trim(); decimal je = 0; if (row["金额"].ToString().Trim() != "") je = Convert.ToDecimal(row["金额"].ToString().Trim()); if (name == "" || goodscode == "" || je == 0) continue; int a= DataNew.Save_OthersFee(name,goodscode,je,sdt,edt,isfg); if (a == -1) { error += name + goodscode + "货号不存在"; } else if (a == -2) { error += name + goodscode + "人员名字不存在"; } else count++; } return error+"导入成功" + count.ToString() + "条"; } catch (Exception e) { return "文件导入失败!请确定模板格式是否正确,或者重新下载模板,填写数据,重新导入!!!" + e.Message; } return "导入成功"; } #endregion #region 导入广告费用 [WebMethod(EnableSession = true)] public string ImportAdFees(string FileName, DateTime sdt, DateTime edt, int isfg) { PagesNew.Login(this.Session); if (string.IsNullOrEmpty(FileName) == true) return "要导入的文件路径不能为空"; string ServerFileName = AppDomain.CurrentDomain.BaseDirectory + FileName; if (System.IO.File.Exists(ServerFileName) == false) return "要导入的文件路径不存在"; //int CompanyId = Convert.ToInt32(Session["CompanyId"]); string error = ""; try { ExcelNew excel = new ExcelNew(); DataTable tb = excel.ImportExcel(ServerFileName); StringBuilder sb = new StringBuilder(); //Actual Weight Amount Actual Weight Units Rated Weight Amount Rated Weight Units //Dim Length Dim Width Dim Height Dim Divisor Zone Code //Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount //Net Charge Amount estimate fee big difference result // if (tb.Columns.Contains("日期") == false) sb.AppendLine("导入模板错误, 列不存在: 日期"); if (tb.Columns.Contains("人员") == false) sb.AppendLine("导入模板错误, 列不存在:人员"); // if (tb.Columns.Contains("货号") == false) sb.AppendLine("导入模板错误, 列不存在:货号"); if (tb.Columns.Contains("金额") == false) sb.AppendLine("导入模板错误, 列不存在:金额"); int count = 0; foreach (DataRow row in tb.Rows) { string name = row["人员"].ToString().Trim(); string goodscode = "";// row["货号"].ToString().Trim(); decimal je = 0; if (row["金额"].ToString().Trim() != "") je = Convert.ToDecimal(row["金额"].ToString().Trim()); if (name == "" || je == 0) continue; //edt = edt.AddDays(1); int a = DataNew.Save_AdFeeNew(name, goodscode, je, sdt, edt, isfg); if (a == -1) { error += name + goodscode + "货号不存在"; } else if (a == -2) { error += name + goodscode + "人员名字不存在"; } else count++; } return error + "导入成功" + count.ToString() + "条"; } catch (Exception e) { return "文件导入失败!请确定模板格式是否正确,或者重新下载模板,填写数据,重新导入!!!" + e.Message; } return "导入成功"; } #endregion #region 获取订单运费 [WebMethod(EnableSession = true)] public decimal GetOrderPostFee(int orderid,int postid) { PagesNew.Login(this.Session); DataNew.UpdateOrderPostId(orderid, postid); decimal? fee = DataNew.ComputerPostFeeOne(orderid); return fee.Value; } #endregion [WebMethod(EnableSession = true)] public string GetShopeeFeeNo(List list) { PagesNew.Login(base.Session); // int companyId = Convert.ToInt32(base.Session["CompanyId"]); string ids = ""; if (list != null) { foreach (var md in list) { ids += md.OrderId + ","; } } DataNew.ComputerPostFees(ids.TrimEnd(',')); return "重新计算成功"; } #region 修改地址 [WebMethod(EnableSession = true)] public string UpdateOrderAddr2(DT_OrderModel Model) { PagesNew.Login(this.Session); var obj = new DD_OrderData(); BaseService obj1 = new BaseService(); var md = obj1.GetCountryCode(Model.CountryCode); string error = ""; if (md == null || md.Code == null || md.Code == "") { error = "购买国家对应不到,请确定国家全称或者简称填写是否正确"; } else { if (Model.RevPostCode != null) Model.RevPostCode = Model.RevPostCode.Trim(); //if (md.Code == "US" && Model.RevPostCode.Length != 5) //{ // error = "美国邮编必须是5位"; //} //else if (md.Code == "RS" && Model.RevPostCode.Length != 6) //{ // error = "俄罗斯邮编必须是6位"; //} if (Model.CountryName == null || Model.CountryName == "") { Model.RevCountry = md.EnglishName; Model.CountryName = md.CountryName; } int CompanyId = Convert.ToInt32(Session["CompanyId"]); int UserId = Convert.ToInt32(Session["UserId"]); DataNew.UpdateOrderAddr2(Model); PagesNew.SaveLog(UserId, "订单日志", "修改收件人地址信息", Model.OrderId.Value); } return error; } #endregion #region 读取物流渠道 [WebMethod(EnableSession = true)] public List GetJC_PostGroup(int orderid) { PagesNew.Login(this.Session); BaseService obj = new BaseService(); var list = DataNew.GetJC_PostGroup(orderid); return list; } #endregion #region 创建重发单订单 [WebMethod(EnableSession = true)] public int CheckCopyOrder(int OrderId) { PagesNew.Login(this.Session); var obj = new DD_OrderData(); int Id = obj.CheckCopyOrder(OrderId); return Id; } #endregion #region 创建重发单订单 [WebMethod(EnableSession = true)] public int CopyOrder(int OrderId) { PagesNew.Login(this.Session); var obj = new DD_OrderData(); if (CheckCopyOrder(OrderId) > 0) { return -1; } int Id = DataNew.CopyOrderForTM2(OrderId); return Id; } #endregion #region 刷新运费毛利 [WebMethod(EnableSession = true)] public void GetModel_OrderFeeML() { PagesNew.Login(this.Session); DataNew.GetModel_OrderFeeML(); } #endregion #region 刷新运费毛利 [WebMethod(EnableSession = true)] public void ComputerOrderFee_Order(int orderid) { PagesNew.Login(this.Session); DataNew.ComputerOrderFee_Order(orderid); } #endregion #region [WebMethod(EnableSession = true)] public void YC_Order(int orderid) { PagesNew.Login(this.Session); YCService.Ec obj = new YCService.Ec(); StringBuilder sb = new StringBuilder(); sb.Append(""); sb.Append(""); sb.Append(""); sb.Append(""); sb.Append(""); sb.Append("{"); sb.Append("\"platform\":\"OTHER\","); sb.Append("\"allocated_auto\":\"0\","); sb.Append("\"warehouse_code\":\"HRBW\","); sb.Append("\"shipping_method\":\"F4\","); sb.Append("\"reference_no\":\"ref_1399867101_123\""); sb.Append("{"); sb.Append(""); sb.Append("appToken"); sb.Append("appKey"); sb.Append("createOrder"); sb.Append(""); sb.Append(""); sb.Append(""); obj.callService(sb.ToString(), "d45efccfc1a9e3a3199c3abcc37d9ce6", "b28a8987bea38085e14194a8970c8947", "createOrder"); } #endregion [WebMethod(EnableSession = true)] public string SendYC_Order(List list, string ck) { PagesNew.Login(base.Session); // int companyId = Convert.ToInt32(base.Session["CompanyId"]); string ids = ""; if (list != null) { foreach (var md in list) { ids += md.OrderId + ","; } } string error = ""; int count = 0; var olist = DataNew.GetYCOrders(ids.TrimEnd(',')); JavaScriptSerializer JsonConvert = new JavaScriptSerializer(); YCService.Ec obj = new YCService.Ec(); foreach (var md in olist) { YC_createOrder omd = new YC_createOrder(); omd.reference_no = md.PlatOrderCode; omd.aliexpress_order_no = md.PlatOrderCode; //omd.lp_code = md.PlatOrderCode; if (md.PlatId == 2) omd.platform = "AMAZON";//平台, ALIEXPRESS,AMAZON,B2C,EBAY,OTHER 默认OTHER else if (md.PlatId == 3) omd.platform = "EBAY"; else if (md.PlatId == 1) omd.platform = "ALIEXPRESS"; else if (md.PlatId == 2) omd.platform = "OTHER"; omd.country_code = md.CountryCode; omd.shipping_method ="BQSC";// "UPSGROUND"; omd.warehouse_code = ck;// "CAMR"; omd.province = md.RevProvince; omd.city = md.RevCity; omd.district = md.RevArea; omd.address1 = md.RevAddr; omd.address2 = ""; omd.address3 = ""; omd.license = ""; omd.doorplate = ""; omd.company = ""; omd.verify = 1; omd.forceVerify = 1; if (md.RevPhone.Contains("ext")) { var len = md.RevPhone.IndexOf("ext"); omd.phone = md.RevPhone.Substring(0, len - 1); } else omd.phone = md.RevPhone; omd.name = md.RevName; if (md.RevMoblie.Contains("ext")) { var len = md.RevMoblie.IndexOf("ext"); omd.cell_phone = md.RevMoblie.Substring(0, len - 1); } else omd.cell_phone = md.RevMoblie; omd.email = md.RevMail; omd.zipcode = md.RevPostCode; omd.tracking_no = md.TrackCode; if (md.TrackCode == null || md.TrackCode == "") { continue; } omd.platform_shop = md.ShopName; List itemlist = new List(); List relist = new List(); foreach (var gmd in md.GoodsList) { YC_Items imd = new YC_Items(); imd.product_sku = gmd.TypeCode; imd.reference_no = ""; imd.product_declared_value = 5; imd.product_name_en = gmd.GoodsEnglisgName; imd.product_name = gmd.GoodsName; imd.quantity = gmd.GoodsNum; imd.ref_tnx = ""; imd.ref_item_id = ""; imd.ref_buyer_id = ""; itemlist.Add(imd); YC_Report ymd = new YC_Report(); ymd.product_title = gmd.GoodsEnglisgName; ymd.product_title_en = gmd.GoodsName; ymd.product_quantity = gmd.GoodsNum; ymd.product_declared_value = 5; if (gmd.Weight != null) ymd.product_weight = Convert.ToInt32(gmd.Weight.Value); else ymd.product_weight = 100; relist.Add(ymd); } omd.items = itemlist; omd.report = relist; string ojson = JsonConvert.Serialize(omd); // ErrorFollow.TraceWrite("SendYC_Order", "", ojson); string re = obj.callService(ojson, "d45efccfc1a9e3a3199c3abcc37d9ce6", "b28a8987bea38085e14194a8970c8947", "createOrder"); if (re != "") { YC_Result2 ReModel = JsonConvert.Deserialize(re); if (ReModel != null && ReModel.ask == "Success") { count++; DT_YCLog LogModel = new DT_YCLog(); LogModel.orderid = md.OrderId; LogModel.indate = DateTime.Now; LogModel.inname = Session["Name"].ToString(); if (ReModel.order_code != null) LogModel.YC_OrderCode = ReModel.order_code; if (ReModel.message != null) LogModel.YC_Result = ReModel.message; DataNew.Save_YCLog(LogModel); DataNew.Update_YCOrder(md.OrderId.Value, 1, "已推送给易仓"); } else { string mess = ReModel.message; error += md.PlatOrderCode + mess+";"; if (mess.Length >= 300) mess = mess.Substring(0, 290); DataNew.Update_YCOrder(md.OrderId.Value, 0, mess); } } } if (error == "") { return "推送成功" + count.ToString() + "条"; } else { return error+";其他推送成功" + count.ToString() + "条"; } } [WebMethod(EnableSession = true)] public string GetListOrderForHWC_Excel(int CompanyId, int PlatType, int ShopId, int DateType, DateTime? SDate, DateTime? EDate, int TjType, string Name, int PrintState, int MateState, int State, int PageIndex, int PageSize, string Sort) { PagesNew.Login(this.Session); var obj = new DD_OrderData(); // int CompanyId = Convert.ToInt32(Session["CompanyId"]); RefParameterCollection Param = new RefParameterCollection(); Param.Add("a.CompanyId", "=", CompanyId, DbType.Int32); if (PlatType > 0) Param.Add("a.PlatId", "=", PlatType, DbType.Int32); if (ShopId > 0) Param.Add("a.ShopId", "=", ShopId, DbType.Int32); if (DateType == 1) { if (SDate != null) Param.Add("a.OrderDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.OrderDate", "<", EDate.Value.AddDays(1), DbType.DateTime); } else if (DateType == 2) { if (SDate != null) Param.Add("a.InDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.InDate", "<", EDate.Value.AddDays(1), DbType.DateTime); } else if (DateType == 3) { if (SDate != null) Param.Add("a.PrintDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.PrintDate", "<", EDate.Value.AddDays(1), DbType.DateTime); } else if (DateType == 4) { if (SDate != null) Param.Add("a.PostDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.PostDate", "<", EDate.Value.AddDays(1), DbType.DateTime); } else if (DateType == 5) { if (SDate != null) Param.Add("a.OrderOutDate", ">=", SDate, DbType.DateTime); if (EDate != null) Param.Add("a.OrderOutDate", "<", EDate.Value.AddDays(1), DbType.DateTime); } if (MateState == 1) Param.Add("a.FPDate", "is", null, DbType.String); else if (MateState > -1) Param.Add("a.MateState", "=", MateState, DbType.Int32); if (PrintState > -1) Param.Add("a.PrintState", "=", PrintState, DbType.Int32); if (State == 3) Param.Add("a.State", "=", 2, DbType.Int32); else if (State == 4) Param.Add("a.State", "=", 3, DbType.Int32); else if (State == 5) { Param.Add("a.State", "=", 1, DbType.Int32); Param.Add("a.MoneyState", "=", 1, DbType.Int32); } else if (State == 1) { //Param.Add("a.State", "=", 2, DbType.Int32); Param.Add("a.PostState", "=", 1, DbType.Int32); } else if (State == 2) { Param.Add("a.State", "<", 3, DbType.Int32); Param.Add("a.PostState", "=", 2, DbType.Int32); } else if (State == 0) { //Param.Add("a.State", "=", 2, DbType.Int32); Param.Add("a.State", "=", 1, DbType.Int32); } else Param.Add("a.State", ">", 0, DbType.Int32); string TCode = ""; if (Name != "") { Name = Name.Trim(); if (TjType == 1) { Param.Add("(a.PlatOrderCode", "like", Name, DbType.String); Param.Add("OrderCode", "like", Name, "or", DbType.String); Param.Add("a.JoinOrderCode", "like", Name, "or", ")", DbType.String); } else if (TjType == 2) { Param.Add("a.RevName", "like", Name, DbType.String); } else if (TjType == 3) { Param.Add("a.RevPhone", "like", Name, DbType.String); } else if (TjType == 4) { Param.Add("(a.RevCountry", "=", Name, DbType.String); Param.Add("a.CountryName", "=", Name, "or", DbType.String); Param.Add("a.CountryCode", "=", Name, "or", ")", DbType.String); } else if (TjType == 5) { Param.Add("a.RevPostCode", "=", Name, DbType.String); } else if (TjType == 6) { Param.Add("(a.RevAddr", "like", Name, DbType.String); Param.Add("a.RevProvince", "like", Name, "or", DbType.String); Param.Add("a.RevCity", "like", Name, "or", DbType.String); Param.Add("a.RevArea", "like", Name, "or", ")", DbType.String); } else if (TjType == 9) { Param.Add("(a.ErrorInfo", "like", Name, DbType.String); Param.Add("a.PostError", "like", Name, "or", ")", DbType.String); } else if (TjType == 10) { //Param.Add("dbo.getOrderTrackCode(a.OrderId,0)", "like", Name, DbType.String); TCode = Name; } else if (TjType == 11) { Param.Add("a.CustomID", "=", Name, DbType.String); } else if (TjType == 12) { Param.Add("a.RevMail", "=", Name, DbType.String); } } JsonModel> resultModel = new JsonModel>(); int RowCount = 0; //string Sort = "orderid desc"; string GoodsName = ""; string SKU = ""; if (TjType == 7 && Name != "") { GoodsName = Name; } else if (TjType == 8 && Name != "") { SKU = Name; } // if (State == 0 || State == 2) resultModel.DataSource = DataNew.GetListDT_OrderInfoForHWC(CompanyId, GoodsName.Trim(), SKU.Trim(), TCode, -1, 0, Param, PageIndex, PageSize, Sort, out RowCount); // else // resultModel.DataSource = obj.GetListDT_OrderInfoForTM(CompanyId, GoodsName.Trim(), SKU.Trim(), TCode, -1, 0, Param, PageIndex, PageSize, Sort, out RowCount); if (resultModel.DataSource== null) { return ""; } resultModel.RowCount = RowCount; string Ids = ""; if (resultModel.DataSource != null) { foreach (var md in resultModel.DataSource) { Ids += md.OrderId.ToString() + ","; } } //if (Ids != "") //{ // var errorlist = obj.GetErrorList(Ids.Trim(',')); // if (errorlist != null && errorlist.Count > 0) // { // foreach (var md in resultModel.DataSource) // { // var emd = errorlist.Find(n => n.OrderId == md.OrderId); // if (emd != null) // { // md.ErrorInfo = emd.ErrorInfo; // } // } // } //} if (resultModel.DataSource != null) { if (Ids != "") { var list1 = DataNew.GetOrderGoodsListHWC2(Ids.Trim(',')); var listTrack = obj.GetTrackCodeApplyList(Ids.Trim(',')); if (list1 != null) { foreach (var md in resultModel.DataSource) { var list2 = list1.FindAll(n => n.OrderId == md.OrderId); string gnames = ""; if (list2 != null) { md.GoodsList = list2; foreach (var gmd in list2) { gnames += gmd.GoodsSKU+" "; } } md.GoodsName = gnames; } } if (listTrack != null) { foreach (var md in resultModel.DataSource) { var list3 = new List(); if (md.JoinOrderCode != null && md.JoinOrderCode != "") list3 = listTrack.FindAll(n => n.OrderCode == md.JoinOrderCode); else list3 = listTrack.FindAll(n => n.OrderId == md.OrderId); if (list3 != null && list3.Count > 0) { string trackinfo = ""; string TrackCode = ""; foreach (var md1 in list3) { string blank = ""; if (md1.TrackType == 3) blank = "[空包裹]"; if (md1.Weight != null) { string dd = ""; if (md1.ScanDate != null) dd = "发货时间:" + md1.ScanDate.Value.ToString("yyyy-MM-dd HH:mm"); trackinfo += md1.TrackCode + blank + "重量" + md1.Weight.ToString() + "g" + dd + ";"; } else trackinfo += md1.TrackCode + blank + ";"; if (TrackCode == "") TrackCode = md1.TrackCode; } md.TrackInfo = trackinfo; md.TrackCode = TrackCode; } } } } } TableColumnCollection listColumns = new TableColumnCollection(); listColumns.Add("PlatOrderCode", "订单号", DbType.String, ""); listColumns.Add("ShopName", "店铺", DbType.String, ""); listColumns.Add("OrderDate", "订单日期", DbType.String, ""); listColumns.Add("InDate", "导入日期", DbType.String, ""); listColumns.Add("GoodsNum", "数量", DbType.String, ""); listColumns.Add("TotalPrice", "订单金额", DbType.String, ""); listColumns.Add("RevName", "收货人", DbType.String, ""); listColumns.Add("RevAddr", "收件地址", DbType.String, ""); listColumns.Add("RevPostCode", "收件邮编", DbType.String, ""); listColumns.Add("RevCity", "收件城市", DbType.String, ""); listColumns.Add("RevProvince", "收件州省", DbType.String, ""); // listColumns.Add("RevPhone", "收件人电话", DbType.String, ""); // listColumns.Add("RevMoblie", "收件人手机", DbType.String, ""); // listColumns.Add("CountryName", "收件国家", DbType.String, ""); listColumns.Add("GoodsName", "物品描述", DbType.String, ""); listColumns.Add("PostInfo", "物流渠道", DbType.String, ""); listColumns.Add("TrackCode", "跟踪码", DbType.String, ""); listColumns.Add("PostFee", "预估运费", DbType.String, "f2"); listColumns.Add("BoxFee", "账单运费", DbType.String, "f2"); // listColumns.Add("TotalWeight", "重量(克)", DbType.String, "f2"); MicrosoftExcel obj2 = new MicrosoftExcel(); return obj2.Export(resultModel.DataSource, listColumns); } #region 删除订单 [WebMethod(EnableSession = true)] public void DeleteOrderHWC(int OrderId) { PagesNew.Login(this.Session); var obj = new DD_OrderData(); int InUserId = Convert.ToInt32(Session["UserId"]); DataNew.DeleteOrderHWC(OrderId, InUserId); //obj.UpdateDelOrderGoods(OrderId);// 修改货物的订单数量(发货或者取消) } #endregion [WebMethod(EnableSession = true)] public string GetYC_Order(List list) { PagesNew.Login(base.Session); // int companyId = Convert.ToInt32(base.Session["CompanyId"]); string ids = ""; if (list != null) { foreach (var md in list) { ids += md.OrderId + ","; } } // DataNew.ComputerPostFees(ids.TrimEnd(',')); var olist = DataNew.GetYCOrders(ids.TrimEnd(',')); JavaScriptSerializer JsonConvert = new JavaScriptSerializer(); YCService.Ec obj = new YCService.Ec(); string error = ""; int count = 0; foreach (var md in olist) { string ojson = "{\"reference_no\":\""+md.PlatOrderCode+"\"}"; string re = obj.callService(ojson, "d45efccfc1a9e3a3199c3abcc37d9ce6", "b28a8987bea38085e14194a8970c8947", "getOrderByRefCode"); if (re != "") { YC_Result ReModel = JsonConvert.Deserialize(re); if (ReModel != null && ReModel.ask == "Success" && ReModel.Data != null && ReModel.Data.tracking_no!=null) { count++; DataNew.ImportTrackCodeYC(246, 11, md.PlatOrderCode, ReModel.Data.tracking_no, Session["Name"].ToString()); DataNew.Update_YCOrder(md.OrderId.Value, 2, "已推送易仓并获取跟踪码"); } else { string mess = ReModel.message; error += md.PlatOrderCode + mess + ";"; } } } if (error == "") { return "获取成功" + count.ToString() + "条"; } else { return error + ";其他获取成功" + count.ToString() + "条"; } } #region 查询店铺数据 [WebMethod(EnableSession = true)] public List GetShopDataTJ(int platid, DateTime? SDate, DateTime? EDate) { PagesNew.Login(this.Session); var obj = new DD_OrderData(); List list = new List(); var slist = DataNew.GetListShopdata(platid); var snlist = DataNew.GetListShopNo(platid); var olist = DataNew.GetListShopMoney(SDate, EDate.Value.AddDays(1)); if (snlist != null) { foreach (var snmd in snlist) { Shop_DataCount md = new Shop_DataCount(); md.platname = snmd.PlatName; md.shopname =snmd.ShopNo; md.country = snmd.LoginName; if (slist != null) { var ssmd = slist.Find(n =>n.ShopNo==snmd.ShopNo&&n.LoginName == snmd.LoginName && (n.Country.ToUpper() == "MY" || n.Country == "马来西亚")); if (ssmd != null) { md.MY = ssmd.ShopName; } ssmd = slist.Find(n =>n.ShopNo == snmd.ShopNo && n.LoginName == snmd.LoginName && (n.Country.ToUpper() == "PH" || n.Country == "菲律宾")); if (ssmd != null) { md.PH = ssmd.ShopName; } ssmd = slist.Find(n =>n.ShopNo == snmd.ShopNo&&n.LoginName == snmd.LoginName && (n.Country.ToUpper() == "SG" || n.Country == "新加坡")); if (ssmd != null) { md.SG = ssmd.ShopName; } ssmd = slist.Find(n => n.ShopNo == snmd.ShopNo && n.LoginName == snmd.LoginName && (n.Country.ToUpper() == "BR" || n.Country == "巴西")); if (ssmd != null) { md.BR = ssmd.ShopName; } ssmd = slist.Find(n => n.ShopNo == snmd.ShopNo && n.LoginName == snmd.LoginName && (n.Country.ToUpper() == "MX")); if (ssmd != null) { md.MX = ssmd.ShopName; } ssmd = slist.Find(n => n.ShopNo == snmd.ShopNo && n.LoginName == snmd.LoginName && (n.Country.ToUpper() == "ID" || n.Country == "印尼")); if (ssmd != null) { md.ID = ssmd.ShopName; } ssmd = slist.Find(n => n.ShopNo == snmd.ShopNo && n.LoginName == snmd.LoginName && (n.Country.ToUpper() == "TH" || n.Country == "泰国")); if (ssmd != null) { md.TH = ssmd.ShopName; } ssmd = slist.Find(n => n.ShopNo == snmd.ShopNo && n.LoginName == snmd.LoginName && (n.Country.ToUpper() == "TW" || n.Country == "台湾")); if (ssmd != null) { md.TW = ssmd.ShopName; } } list.Add(md); md = new Shop_DataCount(); md.platname = snmd.PlatName; md.shopname = snmd.ShopNo; md.country = "负责人"; if (slist != null) { var ssmd = slist.Find(n => n.ShopNo == snmd.ShopNo && n.LoginName == snmd.LoginName && (n.Country.ToUpper() == "MY" || n.Country == "马来西亚")); if (ssmd != null) { md.MY = ssmd.ShopUser; } ssmd = slist.Find(n => n.ShopNo == snmd.ShopNo && n.LoginName == snmd.LoginName && (n.Country.ToUpper() == "PH" || n.Country == "菲律宾")); if (ssmd != null) { md.PH = ssmd.ShopUser; } ssmd = slist.Find(n => n.ShopNo == snmd.ShopNo && n.LoginName == snmd.LoginName && (n.Country.ToUpper() == "SG" || n.Country == "新加坡")); if (ssmd != null) { md.SG = ssmd.ShopUser; } ssmd = slist.Find(n => n.ShopNo == snmd.ShopNo && n.LoginName == snmd.LoginName && (n.Country.ToUpper() == "BR" || n.Country == "巴西")); if (ssmd != null) { md.BR = ssmd.ShopUser; } ssmd = slist.Find(n => n.ShopNo == snmd.ShopNo && n.LoginName == snmd.LoginName && (n.Country.ToUpper() == "MX")); if (ssmd != null) { md.MX = ssmd.ShopUser; } ssmd = slist.Find(n => n.ShopNo == snmd.ShopNo && n.LoginName == snmd.LoginName && (n.Country.ToUpper() == "ID" || n.Country == "印尼")); if (ssmd != null) { md.ID = ssmd.ShopUser; } ssmd = slist.Find(n => n.ShopNo == snmd.ShopNo && n.LoginName == snmd.LoginName && (n.Country.ToUpper() == "TH" || n.Country == "泰国")); if (ssmd != null) { md.TH = ssmd.ShopUser; } ssmd = slist.Find(n => n.ShopNo == snmd.ShopNo && n.LoginName == snmd.LoginName && (n.Country.ToUpper() == "TW" || n.Country == "台湾")); if (ssmd != null) { md.TW = ssmd.ShopUser; } } list.Add(md); md = new Shop_DataCount(); md.platname = snmd.PlatName; md.shopname = snmd.ShopNo; md.country = "金额"; if (olist != null) { var ssmd = olist.Find(n => n.ShopNo == snmd.ShopNo && n.LoginName == snmd.LoginName && (n.Country.ToUpper() == "MY" || n.Country == "马来西亚")); if (ssmd != null&&ssmd.TotalPrice!=null) { md.MY = ssmd.TotalPrice.Value.ToString("0.00")+"$"; } ssmd = olist.Find(n => n.ShopNo == snmd.ShopNo && n.LoginName == snmd.LoginName && (n.Country.ToUpper() == "PH" || n.Country == "菲律宾")); if (ssmd != null && ssmd.TotalPrice != null) { md.PH = ssmd.TotalPrice.Value.ToString("0.00") + "$"; } ssmd = olist.Find(n => n.ShopNo == snmd.ShopNo && n.LoginName == snmd.LoginName && (n.Country.ToUpper() == "SG" || n.Country == "新加坡")); if (ssmd != null && ssmd.TotalPrice != null) { md.SG = ssmd.TotalPrice.Value.ToString("0.00") + "$"; } ssmd = olist.Find(n => n.ShopNo == snmd.ShopNo && n.LoginName == snmd.LoginName && (n.Country.ToUpper() == "BR" || n.Country == "巴西")); if (ssmd != null && ssmd.TotalPrice != null) { md.BR = ssmd.TotalPrice.Value.ToString("0.00") + "$"; } ssmd = olist.Find(n => n.ShopNo == snmd.ShopNo && n.LoginName == snmd.LoginName && (n.Country.ToUpper() == "MX")); if (ssmd != null && ssmd.TotalPrice != null) { md.MX = ssmd.TotalPrice.Value.ToString("0.00") + "$"; } ssmd = olist.Find(n => n.ShopNo == snmd.ShopNo && n.LoginName == snmd.LoginName && (n.Country.ToUpper() == "ID" || n.Country == "印尼")); if (ssmd != null && ssmd.TotalPrice != null) { md.ID = ssmd.TotalPrice.Value.ToString("0.00") + "$"; } ssmd = olist.Find(n => n.ShopNo == snmd.ShopNo && n.LoginName == snmd.LoginName && (n.Country.ToUpper() == "TH" || n.Country == "泰国")); if (ssmd != null && ssmd.TotalPrice != null) { md.TH = ssmd.TotalPrice.Value.ToString("0.00") + "$"; } ssmd = olist.Find(n => n.ShopNo == snmd.ShopNo && n.LoginName == snmd.LoginName && (n.Country.ToUpper() == "TW" || n.Country == "台湾")); if (ssmd != null && ssmd.TotalPrice != null) { md.TW = ssmd.TotalPrice.Value.ToString("0.00") + "$"; } } list.Add(md); } } return list; } #endregion #region 删除订单 [WebMethod(EnableSession = true)] public void DeleteOrderForHWC(string OrderIds) { PagesNew.Login(this.Session); var obj = new DD_OrderData(); int InUserId = Convert.ToInt32(Session["UserId"]); if (OrderIds != "") { DataNew.DeleteOrderForHWC(OrderIds.Trim(',')); PagesNew.SaveLog(InUserId, "删除订单", OrderIds + "删除订单", 0); } } #endregion #region 判断是否是数字 [WebMethod(EnableSession = true)] public int updatetracking(int id, string tracking_id,int IsOfferUp,int IsMaketPlace) { PagesNew.Login(this.Session); DataNew.updatetracking_id(id, tracking_id, IsOfferUp, IsMaketPlace); return 1; } #endregion #region 判断费用是否够 [WebMethod(EnableSession = true)] public int IsFee(int companyid) { PagesNew.Login(this.Session); if (DataNew.IsFee(companyid) < 0) return 0; else return 1; } #endregion #region 导入退货 [WebMethod(EnableSession = true)] public string ImportReturnOrder(string FileName) { PagesNew.Login(this.Session); if (string.IsNullOrEmpty(FileName) == true) return "要导入的文件路径不能为空"; string ServerFileName = AppDomain.CurrentDomain.BaseDirectory + FileName; if (System.IO.File.Exists(ServerFileName) == false) return "要导入的文件路径不存在"; //int CompanyId = Convert.ToInt32(Session["CompanyId"]); try { ExcelNew excel = new ExcelNew(); DataTable tb = excel.ImportExcel(ServerFileName); StringBuilder sb = new StringBuilder(); //Actual Weight Amount Actual Weight Units Rated Weight Amount Rated Weight Units //Dim Length Dim Width Dim Height Dim Divisor Zone Code //Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount Tracking ID Charge Description Tracking ID Charge Amount //Net Charge Amount estimate fee big difference result if (tb.Columns.Contains("订单号") == false) sb.AppendLine("导入模板错误, 列不存在: 订单号"); if (tb.Columns.Contains("SKU") == false) sb.AppendLine("导入模板错误, 列不存在:SKU"); if (tb.Columns.Contains("退货数量") == false) sb.AppendLine("导入模板错误, 列不存在:退货数量"); if (tb.Columns.Contains("退货运单号") == false) sb.AppendLine("导入模板错误, 列不存在:退货运单号"); int count = 0; string mess = ""; foreach (DataRow row in tb.Rows) { DT_OrderReturn md = new DT_OrderReturn(); string trackcode = row["退货运单号"].ToString(); string ordercode = row["订单号"].ToString(); string SKU = row["SKU"].ToString(); int num = 1; if(row["退货数量"].ToString()!="") num =Convert.ToInt32(row["退货数量"].ToString()); if (ordercode == "") continue; if (SKU == "") { mess += ordercode + "sku不能为空"; continue; } md.orderid = 0; md.detailid = 0; md.ordercode = ordercode; md.merchant_sku = SKU; md.tracking_id = trackcode; md.return_quantity = num; Random rd = new Random(); md.barcode = DateTime.Now.ToString("yyyyMMddHHmmss") + rd.Next(1000, 9999); int a= DataNew.Save_OrderReturnExcel(md); if (a == 0) { mess += ordercode + "订单号或者sku不存在"; continue; } count++; } return "导入成功" + count.ToString() + "条。"+mess; } catch (Exception e) { return "文件导入失败!请确定模板格式是否正确,或者重新下载模板,填写数据,重新导入!!!" + e.Message; } return "导入成功"; } #endregion #region 查询店铺编号排名 [WebMethod(EnableSession = true)] public List GetShopDataPM(int ShopId, DateTime SDate) { PagesNew.Login(this.Session); var obj = new DD_OrderData(); var slist = DataNew.GetGoodsPM(ShopId,SDate.AddDays(-1), SDate); return slist; } #endregion #region 查询店铺编号排名 [WebMethod(EnableSession = true)] public List GetShopDataPM2(int ShopId, DateTime SDate,string GoodsCode,int pm1,int pm2) { PagesNew.Login(this.Session); var obj = new DD_OrderData(); var slist = DataNew.GetGoodsPM2(ShopId, SDate, GoodsCode,pm1,pm2); return slist; } #endregion #region 导入新平台订单 [WebMethod(EnableSession = true)] public string ImportNewOrder8(string FileName, int StoreId, int ShopId) { Pages.Login(this.Session); if (string.IsNullOrEmpty(FileName) == true) return "要导入的文件路径不能为空"; string ServerFileName = AppDomain.CurrentDomain.BaseDirectory + FileName; if (System.IO.File.Exists(ServerFileName) == false) return "要导入的文件路径不存在"; int CompanyId = Convert.ToInt32(Session["CompanyId"]); string UserName = Convert.ToString(Session["Name"]); try { MicrosoftExcel excel = new MicrosoftExcel(); DataTable tb = excel.ImportExcel(ServerFileName); string error = ""; //if (tb.Columns.Contains("商品名") == false) { error = error + "导入模板的 商品名 列不存在"; } //if (tb.Columns.Contains("SKU 信息") == false) { error = error + "导入模板的 SKU 信息 列不存在"; } //if (tb.Columns.Contains("价格") == false) { error = error + "导入模板的 价格 列不存在"; } //if (tb.Columns.Contains("数量") == false) { error = error + "导入模板的 数量 列不存在"; } //if (tb.Columns.Contains("备注") == false) { error = error + "导入模板的 备注 列不存在"; } //if (tb.Columns.Contains("订单号") == false) { error = error + "导入模板的 订单号 列不存在"; } //if (tb.Columns.Contains("收货地址") == false) { error = error + "导入模板的 收货地址 列不存在"; } //if (tb.Columns.Contains("收件人") == false) { error = error + "导入模板的 收件人 列不存在"; } //if (tb.Columns.Contains("联系电话") == false) { error = error + "导入模板的 联系电话 列不存在"; } //if (string.IsNullOrEmpty(error) == false) return error + ";请导入格式不正确"; DD_OrderData obj = new DD_OrderData(); int UserId = Convert.ToInt32(Session["UserId"]); List OrderList = new List(); int Num = 0; int PlatId = 0; var smd = JC_ShopService.GetModel(ShopId); PlatId = smd.PlatType.Value; for (int i = 0; i < tb.Rows.Count; i++) { DT_ExcelOrderInfo md = new DT_ExcelOrderInfo(); md.StoreId = StoreId; string PlatOrderCode = tb.Rows[i]["order-id"].ToString().Trim(); if (PlatOrderCode == "") { // error += "第" + (i + 2).ToString() + " 行的order number没填
"; continue; } md.PlatOrderCode = PlatOrderCode; md.OrderCode = PlatOrderCode; md.PlatId = PlatId; md.ShopId = ShopId; if (tb.Rows[i]["price"].ToString().Trim() == "") { md.TotalPrice = 0; } else { try { md.TotalPrice = Convert.ToDecimal(tb.Rows[i]["price"].ToString().Trim()); } catch (Exception ex) { error += "第" + (i + 2).ToString() + " 行的价格必须是数字
"; continue; } } int PayState = 1; int OrderState = 1; md.OrderDate = DateTime.Now; md.PayDate = DateTime.Now; md.PayState = PayState; md.OrderState = OrderState; md.RevName = tb.Rows[i]["recipient-name"].ToString().Trim(); if (md.RevName == "") { error += "第" + (i + 2).ToString() + " 行的recipient-name没填
"; continue; } //md.OrderName = tb.Rows[i]["sales_order"].ToString().Trim(); md.RevAddr = tb.Rows[i]["ship-address-1"].ToString().Trim() + " " + tb.Rows[i]["ship-address-2"].ToString().Trim(); if (md.RevAddr == "") { error += "第" + (i + 2).ToString() + " 行的ship-address-1没填
"; continue; } try { if (tb.Rows[i]["date"].ToString().Trim() != "") md.OrderDate = Convert.ToDateTime(tb.Rows[i]["date"].ToString().Trim()); else md.OrderDate = DateTime.Today; } catch (Exception ex) { md.OrderDate = DateTime.Today; } md.PayDate = DateTime.Today; md.RevPostCode = tb.Rows[i]["ship-postal-code"].ToString().Trim().Replace("'", ""); if (md.RevPostCode == "") md.RevPostCode = "12345"; md.RevProvince = tb.Rows[i]["ship-state"].ToString().Trim(); md.RevCity = tb.Rows[i]["ship-city"].ToString().Trim(); if (md.RevProvince == null || md.RevProvince == "") md.RevProvince = md.RevCity; md.RevPhone = tb.Rows[i]["buyer-phone-number"].ToString().Trim().Replace("'", "").Replace("+", "").Replace("+", "").Replace("(", "").Replace(")", "").Replace(" ", ""); md.CustomID = ""; md.RevMoblie = ""; md.LeaveWord = ""; md.TrackCode = ""; md.RevCountry = "US"; md.MoneyCode = "USD"; md.CompanyId = CompanyId; md.InUserId = UserId; List Glist = new List(); var GoodsModel = new DT_OrderExcelGoods(); if (tb.Rows[i]["quantity-purchased"].ToString().Trim() == "") { // error += "第" + (i + 2).ToString() + " 行的quantity没填
"; // continue; GoodsModel.GoodsNum = 1; } else { try { GoodsModel.GoodsNum = Convert.ToInt32(tb.Rows[i]["quantity-purchased"].ToString().Trim()); } catch (Exception ex) { error += "第" + (i + 2).ToString() + " 行的数量必须是数字
"; continue; } } GoodsModel.SKU = tb.Rows[i]["sku"].ToString().Trim(); if (GoodsModel.SKU == "") { error += "第" + (i + 2).ToString() + " 行的sku 信息没填
"; continue; } md.GoodsNum = GoodsModel.GoodsNum; GoodsModel.GoodsName = GoodsModel.SKU; GoodsModel.GoodsPrice = md.TotalPrice; Glist.Add(GoodsModel); md.OrderName = ""; md.PostFee = 0; md.RevMail = ""; md.RevFax = ""; md.RevArea = ""; md.PostInfo = ""; md.GoodsList = Glist; if (tb.Columns.Contains("trackCode") && tb.Columns.Contains("postFee")) { md.TrackCode = tb.Rows[i]["trackCode"].ToString().Trim(); md.PostFee = string.IsNullOrEmpty(tb.Rows[i]["postFee"].ToString()) ? 0 : Convert.ToDecimal(tb.Rows[i]["postFee"].ToString().Trim()); } OrderList.Add(md); } if (error != "") { return error; } else if (OrderList.Count > 0) { foreach (var md in OrderList) { var moPostFee = md.PostFee; md.PostFee = 0;//新增订单的时候不录入快递费,等后续一起录入 var orderid = obj.ExcelOrderAdd5(md); if (orderid > 0) { //如果填写了跟踪码和运费,导入时把信息完善 //if (!string.IsNullOrEmpty(md.TrackCode) && md.PostFee.HasValue && md.PostFee.Value > 0) if (!string.IsNullOrEmpty(md.TrackCode)) { if (md.GoodsList != null && md.GoodsList.Count > 0) { if (obj.IsOrderTrackCode(orderid) > 0) { DataNew.DeleteTrackCodeApply(orderid); } var _TWeight = 0m; var _TLong = 0m; var _TWidth = 0m; var _THeight = 0m; var skus = ""; foreach (var gd in md.GoodsList) { var goodInfo = DataNew.GetGoodsInfoDetailBySku(gd.SKU); if (goodInfo == null) throw new Exception("订单号:" + md.OrderCode + "导入面单跟踪码失败:未找到sku对应的商品信息,请删除订单重新导入"); if (goodInfo.Long.HasValue && _TLong < goodInfo.Long) _TLong = goodInfo.Long.Value; if (goodInfo.Width.HasValue && _TWidth < goodInfo.Width) _TWidth = goodInfo.Width.Value; if (goodInfo.Height.HasValue) _THeight = _THeight + (goodInfo.Height.Value * gd.GoodsNum.Value); _TWeight = _TWeight + (goodInfo.Weight.HasValue ? goodInfo.Weight.Value * gd.GoodsNum.Value : 0); if (goodInfo.GoodsId == 5527) //组合商品,对应的SKU需要以SKU14为准 { if (string.IsNullOrEmpty(goodInfo.SKU14)) throw new Exception("SKU:" + goodInfo.SKU1 + "对应的组合sku不能为空"); var skuarr = goodInfo.SKU14.Split(','); foreach (var sku in skuarr) { skus += gd.GoodsNum.ToString() + "x" + sku + "+"; } } else { skus += gd.GoodsNum.ToString() + "x" + goodInfo.SKU1 + "+"; } } DT_TrackCodeApplyNew Model = new DT_TrackCodeApplyNew(); Model.InName = UserName; Model.TrackType = 2; Model.OrderId = orderid; Model.IsSpare = 0; Model.TrackCode = md.TrackCode.Trim(); Model.PostId = 245; Model.State = 1; Model.GetDate = DateTime.Now; Model.OrderCode = md.OrderCode; Model.SKU = string.IsNullOrEmpty(skus) ? "" : skus.TrimEnd('+'); Model.Weight = _TWeight.ToString("0.00"); Model.Weight2 = _TWeight.ToString("0.00"); Model.Long = Math.Ceiling(_TLong).ToString("0.00"); Model.Width = Math.Ceiling(_TWidth).ToString("0.00"); Model.Height = Math.Ceiling(_THeight).ToString("0.00"); DataNew.SaveTrackCodeApply(Model); } DataNew.Save_OrderLTLFee(orderid, moPostFee.Value); DataNew.ImportTrackCode(md.TrackCode, moPostFee.Value, 0); } } } obj.UpdateOrderGoodsNum(); error = "数据导入成功【" + OrderList.Count.ToString() + "条】;" + error; return error; } } catch (Exception e) { return "文件导入失败!请确定模板格式是否正确,或者重新下载模板,填写数据,重新导入!!!" + e.Message; } return "导入成功"; } #endregion #region 订单 [WebMethod(EnableSession = true)] public void UpdateSyncOrder(string OrderCode) { PagesNew.Login(this.Session); var obj = new DD_OrderData(); DataNew.DoApiOrders(OrderCode.Trim()); } #endregion #region 保存 [WebMethod(EnableSession = true)] public int Save_PersonOrder(DT_PersonOrder Model) { PagesNew.Login(this.Session); return DataNew.Save_PersonOrder(Model); } #endregion #region 删除 [WebMethod(EnableSession = true)] public bool Delete_PersonOrder(int id) { PagesNew.Login(this.Session); DataNew.Delete_PersonOrder(id); return true; } #endregion #region 普通查询列表 [WebMethod(EnableSession = true)] public List GetListDT_PersonGoods(int orderid) { PagesNew.Login(this.Session); var ListModel = DataNew.GetListDT_PersonGoods(orderid); return ListModel; } #endregion #region 分页查询 [WebMethod(EnableSession = true)] public JsonModel> GetListPersonOrder(string cs, int PageIndex, int PageSize) { PagesNew.Login(this.Session); string where = CustomIO.Base64StringToString(cs); if (where != "") where = "where " + where.Substring(4); var resultModel = new JsonModel>(); int RowCount = 0; resultModel.DataSource = DataNew.GetListPersonOrder(where, PageIndex, PageSize, "", out RowCount); resultModel.RowCount = RowCount; return resultModel; } #endregion #region [WebMethod(EnableSession = true)] public int UpdateOrderReturn(int id, string ordercode) { PagesNew.Login(this.Session); DataNew.UpdateOrderReturn(id, ordercode); return 1; } #endregion #region [WebMethod(EnableSession = true)] public int Save_OrderLTLFee(int OrderId, decimal FeeLTL) { PagesNew.Login(this.Session); DataNew.Save_OrderLTLFee(OrderId, FeeLTL); return 1; } #endregion #region LTL订单 [WebMethod(EnableSession = true)] public string LTLOrderForTM(List list) { PagesNew.Login(this.Session); var obj = new DD_OrderData(); int InUserId = Convert.ToInt32(Session["UserId"]); if (list == null || list.Count == 0) return ""; int CompanyId = Convert.ToInt32(Session["CompanyId"]); string error = ""; foreach (var md in list) { DataNew.UpdateOrderLTL(md.OrderId.Value); } return error; } #endregion #region LTL订单 [WebMethod(EnableSession = true)] public string LTLOrderForTMBack(List list) { PagesNew.Login(this.Session); var obj = new DD_OrderData(); int InUserId = Convert.ToInt32(Session["UserId"]); if (list == null || list.Count == 0) return ""; int CompanyId = Convert.ToInt32(Session["CompanyId"]); string error = ""; foreach (var md in list) { DataNew.UpdateOrderLTLBack(md.OrderId.Value); } return error; } #endregion #region 获取过去二十周每周的日期范围 [WebMethod(EnableSession = true)] public List GetWeeksDateRange() { var dayIndex = (int)DateTime.Now.DayOfWeek; if (dayIndex == 0) { dayIndex = 7; } DateTime startDate=DateTime.Now, endDate=DateTime.Now; switch (dayIndex) { case 1: startDate = DateTime.Now.AddDays(0); endDate = DateTime.Now.AddDays(6); break; case 2: startDate = DateTime.Now.AddDays(-1); endDate = DateTime.Now.AddDays(5); break; case 3: startDate = DateTime.Now.AddDays(-2); endDate = DateTime.Now.AddDays(4); break; case 4: startDate = DateTime.Now.AddDays(-3); endDate = DateTime.Now.AddDays(3); break; case 5: startDate = DateTime.Now.AddDays(-4); endDate = DateTime.Now.AddDays(2); break; case 6: startDate = DateTime.Now.AddDays(-5); endDate = DateTime.Now.AddDays(1); break; case 7: startDate = DateTime.Now.AddDays(-6); endDate = DateTime.Now.AddDays(0); break; } var dateList = new List(); for(int i = 1; i <= 52; i++) { dateList.Add(startDate.AddDays(-1 * i * 7).ToString("yyyy-MM-dd") + "~" + endDate.AddDays(-1 * i * 7).ToString("yyyy-MM-dd")); } return dateList; } #endregion #region 获取店铺商品上周的ACOS投入产出比 [WebMethod(EnableSession = true)] public JsonModel> GetStoreGoodWeekAcosList(string shopName,string goodCode,string dateRange,string master, int PageIndex,int PageSize) { PagesNew.Login(this.Session); int userId = Convert.ToInt32(Session["UserId"]); string name = Session["Name"].ToString(); JsonModel> resultModel = new JsonModel>(); var dateRanges = dateRange.Split('~'); int rowCount = 0; decimal? hjSpend = null, hj_ad_sale, hj_weeklr; resultModel.DataSource = DataNew.GetStoreGoodWeekAcos(userId,name, shopName, goodCode,master, Convert.ToDateTime(dateRanges[0]), Convert.ToDateTime(dateRanges[1]), PageIndex, PageSize, out rowCount,out hjSpend,out hj_ad_sale,out hj_weeklr); resultModel.RowCount = rowCount; if(resultModel.DataSource!=null && resultModel.DataSource.Count > 0) { //var shops = DataNew.GetAllShopList(); //var weekLRs = DataNew.GetAllGoodsLRList(); //foreach (var md in resultModel.DataSource) //{ // //var shop = shops.Find(r => r.ShopName == md.ShopName); // //md.Master = shop == null ? "" : shop.Master; // var weeklr = weekLRs.Find(r => r.ShopName.ToLower() == md.ShopName.ToLower() && r.GoodsCode == md.SKU); // md.WeekLR = weeklr == null ? null : (weeklr.WeekLR2 - weeklr.WeekFee2); //} var hjModel = new StoreGoodWeekAcos() { ShopName = "合计", Master="", SKU="", ACOS=null, spend = hjSpend, ad_sale = hj_ad_sale, WeekLR = hj_weeklr, GoodName="", MSKU="" }; resultModel.DataSource.Add(hjModel); } return resultModel; } #endregion #region 获取店铺负责人上周ACOS超过50的数量 [WebMethod(EnableSession = true)] public JsonModel> GetMasterStoreGoodWeekAcosList(string dateRange, int PageIndex, int PageSize) { PagesNew.Login(this.Session); int userId = Convert.ToInt32(Session["UserId"]); string name = Session["Name"].ToString(); JsonModel> resultModel = new JsonModel>(); var dateRanges = dateRange.Split('~'); int rowCount = 0; resultModel.DataSource = DataNew.GetMasterStoreGoodAcosCountsList(userId, name, Convert.ToDateTime(dateRanges[0]), Convert.ToDateTime(dateRanges[1]), PageIndex, PageSize, out rowCount); resultModel.RowCount = rowCount; return resultModel; } #endregion #region 获取shopify平台的所有店铺 [WebMethod(EnableSession = true)] public List GetAllShopifyShopsList() { PagesNew.Login(this.Session); return DataNew.GetShopSelectListByPlat(15); } #endregion #region 获取平台的所有店铺 [WebMethod(EnableSession = true)] public List GetAllShopsListByPlat(int platid) { PagesNew.Login(this.Session); return DataNew.GetShopSelectListByPlat(platid); } #endregion #region 获取shopify平台的所有订单 [WebMethod(EnableSession = true)] public JsonModel> GetShopifyShopsAllOrdersList(int ShopId,DateTime? SDate,DateTime? EDate, int PageIndex, int PageSize) { PagesNew.Login(this.Session); JsonModel> resultModel = new JsonModel>(); int rowCount = 0; resultModel.DataSource = DataNew.GetShopifyShopAllOrdersList(SDate, EDate, ShopId, PageIndex, PageSize, out rowCount); resultModel.RowCount = rowCount; string shopify_ids = ""; if(resultModel.DataSource!=null && resultModel.DataSource.Count > 0) { foreach(var rd in resultModel.DataSource) { shopify_ids += "'" + rd.ShopifyOrder_Id + "',"; } } if (!string.IsNullOrEmpty(shopify_ids)) { var imageList = DataNew.GetShopifyShopAllOrdersImageList(shopify_ids.TrimEnd(',')); foreach(var rd in resultModel.DataSource) { var images = imageList.Where(r => r.shopifyorder_id == rd.ShopifyOrder_Id).ToList(); if (images != null) { var imageStr = ""; var sku = ""; foreach(var image in images) { if (string.IsNullOrEmpty(image.LinkUrl)) { imageStr += ""; } else { imageStr += ""; } sku += string.IsNullOrEmpty(image.SKU) ? "" : (image.SKU + ","); } rd.ImageStr = imageStr; rd.SKU = string.IsNullOrEmpty(sku) ? "" : sku.TrimEnd(','); } } } return resultModel; } #endregion #region 根据Shopify订单id更改店铺订单抓取状态 [WebMethod(EnableSession = true)] public ShopifyOrderApiResponseModel UpdateShopifyShopOrderCaptureStatus(int shopid,string orderid) { PagesNew.Login(this.Session); var robj = new ShopifyOrderApiResponseModel(); try { var shopifyOrder = DataNew.GetShopifyOrderModel(orderid); if(shopifyOrder==null) { robj.Code = 0; robj.Message = "订单不存在"; return robj; } if(shopifyOrder.CaptureState==1) { robj.Code = 0; robj.Message = "订单已经抓取成功,不要重复抓取"; return robj; } var shop = DataNew.GetLXShopModel(shopid); var url = string.Format("https://{0}:{1}@{2}.myshopify.com/admin/api/2023-07/orders/{3}/transactions.json", shop.Appkey, shop.DeveKey, shop.ShopName, orderid); string requestBody = "{\"transaction\":{\"kind\":\"capture\"}}"; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls; var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Post, url); request.Headers.Add("X-Shopify-Access-Token", shop.AccessToken); var content = new StringContent(requestBody, null, "application/json"); request.Content = content; var response = client.SendAsync(request).Result; var rcontent = response.Content.ReadAsStringAsync().GetAwaiter().GetResult(); var obj=JsonConvert.DeserializeObject(rcontent); if(obj.transaction.kind== "capture") { robj.Code = 1; robj.Message = "抓取成功"; } else { robj.Code = 0; robj.Message = "抓取失败"; } } catch (Exception ex) { robj.Code = 0; robj.Message = "抓取失败"; } DataNew.UpdateShopifyOrderCaptureState(orderid, robj.Code == 1 ? 1 : 2); return robj; } #endregion #region 同步所有shopify店铺的订单 [WebMethod(EnableSession = true)] public ShopifyOrderApiResponseModel SyncAllShopifyShopOrders() { PagesNew.Login(this.Session); var robj = new ShopifyOrderApiResponseModel(); var shops = DataNew.GetAllShopifyShops(); try { ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls; foreach(var shop in shops) { var url = string.Format("https://{0}:{1}@{3}.myshopify.com/admin/api/2023-07/orders.json?created_at_min={2}&limit=250&status=any", shop.AppKey, shop.Password, DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd") + "T00:00:00-08:00", shop.ShopName); var path = EncryptString(url, "ThisIsShopifyKey12365498"); var path2 = HttpUtility.UrlEncode(path); //var apiurl = "http://50.196.110.198:8081/api/ShopifyHelp/getShopifyOrderList?url=" + path2 + "&accessToken=" + shop.AccessToken; var apiurl = "http://50.196.110.198:8099/api/ShopifyHelp/getShopifyOrderList?url=" + path2 + "&accessToken=" + shop.AccessToken; using (HttpClient client = new HttpClient()) { HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, apiurl); var response = client.SendAsync(request); string responseContent = response.Result.Content.ReadAsStringAsync().GetAwaiter().GetResult(); if (string.IsNullOrEmpty(responseContent) || responseContent == "失败") { robj.Code = 0; robj.Message = string.IsNullOrEmpty(responseContent) ? "暂无订单数据" : responseContent; return robj; } var ordersR = JsonConvert.DeserializeObject(responseContent); if (ordersR == null || ordersR.orders == null) continue; foreach (var od in ordersR.orders) { var sql = @"declare @order_id nvarchar(20) declare @CaptureState int set @CaptureState=0; --如果此订单已存在,获取之前的抓取状态,如果不存在,默认未抓取 select @order_id=ISNULL(ID,0),@CaptureState=ISNULL(CaptureState,0) from dbo.ShopifyShopsOrders where shopifyorder_id='" + od.id + "' " + " \r\n if(@order_id!=0) begin \r\n --已存在,删除相关数据,重新同步 \r\n delete from dbo.ShopifyShopsOrders where shopifyorder_id='" + od.id + "'\r\n delete from dbo.ShopifyShopsOrders_discount_applications where shopifyorder_id='" + od.id + "' \r\n delete from dbo.ShopifyShopsOrders_line_items where shopifyorder_id='" + od.id + "' \r\n delete from dbo.ShopifyShopsOrders_shipping_lines where shopifyorder_id='" + od.id + "' \r\n end "; sql += "\r\n Insert into dbo.ShopifyShopsOrders (shopifyorder_id,shopid,CaptureState,created_at,name,customer,customer_id,customer_email,customer_accepts_marketing,customer_created_at,customer_updated_at,customer_first_name,customer_last_name,customer_state,\r\ncustomer_note,customer_verified_email,customer_tax_exempt,customer_phone,customer_tags,customer_currency,subtotal_price,subtotal_price_set_shopmoney_amount,subtotal_price_set_shopmoney_currency_code,subtotal_price_set_presentmentmoney_amount,subtotal_price_set_presentmentmoney_currency_code,financial_status,fulfillment_status,tags,\r\nshipping_address_first_name,shipping_address_address1,shipping_address_phone,shipping_address_city,shipping_address_zip,shipping_address_province,shipping_address_country,shipping_address_last_name,shipping_address_address2,\r\nshipping_address_company,shipping_address_name,shipping_address_country_code,shipping_address_province_code,CreateTime) Values(" + "'" + od.id + "'," + shop.ShopId + ",@CaptureState,'" + DateTime.Parse(od.created_at).AddHours(-15).ToString("yyyy-MM-dd HH:mm:ss") + "','" + od.name + "'"; if (od.customer != null) sql += ",'" + JsonConvert.SerializeObject(od.customer) + "','" + od.customer.id + "','" + od.customer.email + "','" + od.customer.accepts_marketing + "','" + GetBZDateTime(od.customer.created_at) + "','" + GetBZDateTime(od.customer.updated_at) + "','" + od.customer.first_name + "','" + od.customer.last_name + "','" + od.customer.state + "','" + od.customer.note + "','" + od.customer.verified_email + "','" + od.customer.tax_exempt + "','" + od.customer.phone + "','" + od.customer.tags + "','" + od.customer.currency + "'"; else sql += ",'','','',null,'','','','','','','',null,'','',''"; sql += "," + od.subtotal_price; if (od.subtotal_price_set != null) { if (od.subtotal_price_set.shop_Money != null) sql += "," + od.subtotal_price_set.shop_Money.amount + ",'" + od.subtotal_price_set.shop_Money.currency_code + "'"; else sql += ",null,''"; if (od.subtotal_price_set.presentment_Money != null) sql += "," + od.subtotal_price_set.presentment_Money.amount + ",'" + od.subtotal_price_set.presentment_Money.currency_code + "'"; else sql += ",null,''"; } else { sql += ",null,'',null,''"; } sql += ",'" + od.financial_status + "','" + od.fulfillment_status + "','" + od.tags + "'"; if (od.shipping_address != null) { sql += ",'" + od.shipping_address.first_name + "','" + od.shipping_address.address1 + "','" + od.shipping_address.phone + "','" + od.shipping_address.city + "','" + od.shipping_address.zip + "','" + od.shipping_address.province + "','" + od.shipping_address.country + "','" + od.shipping_address.last_name + "','" + od.shipping_address.address2 + "','" + od.shipping_address.company + "','" + od.shipping_address.name + "','" + od.shipping_address.country_code + "','" + od.shipping_address.province_code + "'"; } else sql += ",'','','','','','','','','','','','',''"; sql += ",GetDate()) "; if (od.discount_applications != null && od.discount_applications.Count > 0) { foreach (var da in od.discount_applications) { sql += "\r\n Insert into dbo.ShopifyShopsOrders_discount_applications(shopifyorder_id,target_type,type,value,value_type,allocation_method,target_selection,title,CreateTime) values ('" + od.id + "','" + da.target_type + "','" + da.type + "'," + da.value + ",'" + da.value_type + "','" + da.allocation_method + "','" + da.target_selection + "','" + da.title + "',GetDate())"; } } if (od.line_items != null && od.line_items.Count > 0) { foreach (var li in od.line_items) { sql += "\r\n Insert into dbo.ShopifyShopsOrders_line_items(shopifyorder_id,line_items_id,admin_graphql_api_id,fulfillable_quantity,fulfillment_service,fulfillment_status,gift_card,grams,name,price,price_set_shopmoney_amount,price_set_shopmoney_currency_code,\r\nprice_set_presentment_money_amount,price_set_presentment_money_currency_code,product_exists,product_id,properties,quantity,requires_shipping,sku,taxable,title,total_discount,total_discount_set_shopmoney_amount,\r\ntotal_discount_set_shopmoney_currency_code,total_discount_set_presentment_money_amount,total_discount_set_presentment_money_currency_code,variant_id,variant_inventory_management,variant_title,vendor,CreateTime)\r\n values(" + "'" + od.id + "','" + li.id + "','" + li.admin_graphql_api_id + "'," + li.fulfillable_quantity + ",'" + li.fulfillment_service + "','" + li.fulfillment_status + "','" + li.gift_card + "'," + li.grams + ",'" + li.name.Replace("'", "''") + "'," + li.price; if (li.price_set != null) { if (li.price_set.shop_Money != null) sql += "," + li.price_set.shop_Money.amount + ",'" + li.price_set.shop_Money.currency_code + "'"; else sql += ",null,''"; if (li.price_set.presentment_Money != null) sql += "," + li.price_set.presentment_Money.amount + ",'" + li.price_set.presentment_Money.currency_code + "'"; else sql += ",null,''"; } else sql += ",null,'',null,''"; sql += ",'" + li.product_exists + "','" + li.product_id + "','" + (li.properties==null?"": string.Join(";", li.properties)) + "'," + li.quantity + ",'" + li.requires_shipping + "','" + li.sku + "','" + li.taxable + "','" + li.title.Replace("'", "''") + "'," + li.total_discount; if (li.total_discount_set != null) { if (li.total_discount_set.shop_Money != null) sql += "," + li.total_discount_set.shop_Money.amount + ",'" + li.total_discount_set.shop_Money.currency_code + "'"; else sql += ",null,''"; if (li.total_discount_set.presentment_Money != null) sql += "," + li.total_discount_set.presentment_Money.amount + ",'" + li.total_discount_set.presentment_Money.currency_code + "'"; else sql += ",null,''"; } else sql += ",null,'',null,''"; sql += ",'" + li.variant_id + "','" + li.variant_inventory_management + "','" + li.variant_title + "','" + li.vendor + "',GetDate()) "; } } if (od.shipping_lines != null && od.shipping_lines.Count > 0) { foreach (var sl in od.shipping_lines) { sql += "\r\n Insert into dbo.ShopifyShopsOrders_shipping_lines(shopifyorder_id,shipping_lines_id,carrier_identifier,code,discounted_price,discounted_price_set_shopmoney_amount,discounted_price_set_shopmoney_currency_code,discounted_price_set_presentment_money_amount,\r\ndiscounted_price_set_presentment_money_currency_code,phone,price,price_set_shopmoney_amount,price_set_shopmoney_currency_code,price_set_presentment_money_amount,price_set_presentment_money_currency_code,requested_fulfillment_service_id,\r\nsource,title,CreateTime) Values(" + "'" + od.id + "','" + sl.id + "','" + sl.carrier_identifier + "','" + sl.code + "'," + sl.discounted_price; if (sl.discounted_price_set != null) { if (sl.discounted_price_set.shop_Money != null) sql += "," + sl.discounted_price_set.shop_Money.amount + ",'" + sl.discounted_price_set.shop_Money.currency_code + "'"; else sql += ",null,''"; if (sl.discounted_price_set.presentment_Money != null) sql += "," + sl.discounted_price_set.presentment_Money.amount + ",'" + sl.discounted_price_set.presentment_Money.currency_code + "'"; else sql += ",null,''"; } else sql += ",null,'',null,''"; sql += ",'" + sl.phone + "'," + sl.price; if (sl.price_set != null) { if (sl.price_set.shop_Money != null) sql += "," + sl.price_set.shop_Money.amount + ",'" + sl.price_set.shop_Money.currency_code + "'"; else sql += ",null,''"; if (sl.price_set.presentment_Money != null) sql += "," + sl.price_set.presentment_Money.amount + ",'" + sl.price_set.presentment_Money.currency_code + "'"; else sql += ",null,''"; } else sql += ",null,'',null,''"; sql += ",'" + sl.requested_fulfillment_service_id + "','" + sl.source + "','" + sl.title + "',GetDate())"; } } try { DataNew.UpdateShopifyShopOrders(sql); } catch (Exception ex) { var errorInfo = ex.Message; } } } #region //using (var client = new HttpClient()) //{ // client.DefaultRequestHeaders.Add("X-Shopify-Access-Token", shop.AccessToken); // // 发送 GET 请求并返回响应结果 // var response = client.GetAsync(url).Result; // var result = response.Content.ReadAsStringAsync().GetAwaiter().GetResult(); // var ordersR = JsonConvert.DeserializeObject(result); // if (ordersR == null || ordersR.orders == null) // continue; // foreach (var od in ordersR.orders) // { // var sql = @"declare @order_id nvarchar(20) // declare @CaptureState int // set @CaptureState=0; // --如果此订单已存在,获取之前的抓取状态,如果不存在,默认未抓取 // select @order_id=ISNULL(ID,0),@CaptureState=ISNULL(CaptureState,0) from dbo.ShopifyShopsOrders where shopifyorder_id='" + od.id + "' " // + " \r\n if(@order_id!=0) begin \r\n --已存在,删除相关数据,重新同步 \r\n delete from dbo.ShopifyShopsOrders where shopifyorder_id='" + od.id + "'\r\n delete from dbo.ShopifyShopsOrders_discount_applications where shopifyorder_id='" + od.id + "' \r\n delete from dbo.ShopifyShopsOrders_line_items where shopifyorder_id='" + od.id + "' \r\n delete from dbo.ShopifyShopsOrders_shipping_lines where shopifyorder_id='" + od.id + "' \r\n end "; // sql += "\r\n Insert into dbo.ShopifyShopsOrders (shopifyorder_id,shopid,CaptureState,created_at,name,customer,customer_id,customer_email,customer_accepts_marketing,customer_created_at,customer_updated_at,customer_first_name,customer_last_name,customer_state,\r\ncustomer_note,customer_verified_email,customer_tax_exempt,customer_phone,customer_tags,customer_currency,subtotal_price,subtotal_price_set_shopmoney_amount,subtotal_price_set_shopmoney_currency_code,subtotal_price_set_presentmentmoney_amount,subtotal_price_set_presentmentmoney_currency_code,financial_status,fulfillment_status,tags,\r\nshipping_address_first_name,shipping_address_address1,shipping_address_phone,shipping_address_city,shipping_address_zip,shipping_address_province,shipping_address_country,shipping_address_last_name,shipping_address_address2,\r\nshipping_address_company,shipping_address_name,shipping_address_country_code,shipping_address_province_code,CreateTime) Values(" // + "'" + od.id + "'," + shop.ShopId + ",@CaptureState,'" + DateTime.Parse(od.created_at).AddHours(-15).ToString("yyyy-MM-dd HH:mm:ss") + "','" + od.name + "'"; // if (od.customer != null) // sql += ",'" + JsonConvert.SerializeObject(od.customer) + "','" + od.customer.id + "','" + od.customer.email + "','" + od.customer.accepts_marketing + "','" + GetBZDateTime(od.customer.created_at) + "','" + GetBZDateTime(od.customer.updated_at) + "','" + od.customer.first_name + "','" + od.customer.last_name + "','" + od.customer.state + "','" + od.customer.note + "','" + od.customer.verified_email + "','" + od.customer.tax_exempt + "','" + od.customer.phone + "','" + od.customer.tags + "','" + od.customer.currency + "'"; // else // sql += ",'','','',null,'','','','','','','',null,'','',''"; // sql += "," + od.subtotal_price; // if (od.subtotal_price_set != null) // { // if (od.subtotal_price_set.shop_Money != null) // sql += "," + od.subtotal_price_set.shop_Money.amount + ",'" + od.subtotal_price_set.shop_Money.currency_code + "'"; // else // sql += ",null,''"; // if (od.subtotal_price_set.presentment_Money != null) // sql += "," + od.subtotal_price_set.presentment_Money.amount + ",'" + od.subtotal_price_set.presentment_Money.currency_code + "'"; // else // sql += ",null,''"; // } // else // { // sql += ",null,'',null,''"; // } // sql += ",'" + od.financial_status + "','" + od.fulfillment_status + "','" + od.tags + "'"; // if (od.shipping_address != null) // { // sql += ",'" + od.shipping_address.first_name + "','" + od.shipping_address.address1 + "','" + od.shipping_address.phone + "','" + od.shipping_address.city + "','" + od.shipping_address.zip + "','" + od.shipping_address.province + "','" + od.shipping_address.country + "','" + od.shipping_address.last_name + "','" + od.shipping_address.address2 + "','" + od.shipping_address.company + "','" + od.shipping_address.name + "','" + od.shipping_address.country_code + "','" + od.shipping_address.province_code + "'"; // } // else // sql += ",'','','','','','','','','','','','',''"; // sql += ",GetDate()) "; // if (od.discount_applications != null && od.discount_applications.Count > 0) // { // foreach (var da in od.discount_applications) // { // sql += "\r\n Insert into dbo.ShopifyShopsOrders_discount_applications(shopifyorder_id,target_type,type,value,value_type,allocation_method,target_selection,title,CreateTime) values ('" + od.id + "','" + da.target_type + "','" + da.type + "'," + da.value + ",'" + da.value_type + "','" + da.allocation_method + "','" + da.target_selection + "','" + da.title + "',GetDate())"; // } // } // if (od.line_items != null && od.line_items.Count > 0) // { // foreach (var li in od.line_items) // { // sql += "\r\n Insert into dbo.ShopifyShopsOrders_line_items(shopifyorder_id,line_items_id,admin_graphql_api_id,fulfillable_quantity,fulfillment_service,fulfillment_status,gift_card,grams,name,price,price_set_shopmoney_amount,price_set_shopmoney_currency_code,\r\nprice_set_presentment_money_amount,price_set_presentment_money_currency_code,product_exists,product_id,properties,quantity,requires_shipping,sku,taxable,title,total_discount,total_discount_set_shopmoney_amount,\r\ntotal_discount_set_shopmoney_currency_code,total_discount_set_presentment_money_amount,total_discount_set_presentment_money_currency_code,variant_id,variant_inventory_management,variant_title,vendor,CreateTime)\r\n values(" // + "'" + od.id + "','" + li.id + "','" + li.admin_graphql_api_id + "'," + li.fulfillable_quantity + ",'" + li.fulfillment_service + "','" + li.fulfillment_status + "','" + li.gift_card + "'," + li.grams + ",'" + li.name.Replace("'","''") + "'," + li.price; // if (li.price_set != null) // { // if (li.price_set.shop_Money != null) // sql += "," + li.price_set.shop_Money.amount + ",'" + li.price_set.shop_Money.currency_code + "'"; // else // sql += ",null,''"; // if (li.price_set.presentment_Money != null) // sql += "," + li.price_set.presentment_Money.amount + ",'" + li.price_set.presentment_Money.currency_code + "'"; // else // sql += ",null,''"; // } // else // sql += ",null,'',null,''"; // sql += ",'" + li.product_exists + "','" + li.product_id + "','" + string.Join(";", li.properties) + "'," + li.quantity + ",'" + li.requires_shipping + "','" + li.sku + "','" + li.taxable + "','" + li.title.Replace("'","''") + "'," + li.total_discount; // if (li.total_discount_set != null) // { // if (li.total_discount_set.shop_Money != null) // sql += "," + li.total_discount_set.shop_Money.amount + ",'" + li.total_discount_set.shop_Money.currency_code + "'"; // else // sql += ",null,''"; // if (li.total_discount_set.presentment_Money != null) // sql += "," + li.total_discount_set.presentment_Money.amount + ",'" + li.total_discount_set.presentment_Money.currency_code + "'"; // else // sql += ",null,''"; // } // else // sql += ",null,'',null,''"; // sql += ",'" + li.variant_id + "','" + li.variant_inventory_management + "','" + li.variant_title + "','" + li.vendor + "',GetDate()) "; // } // } // if (od.shipping_lines != null && od.shipping_lines.Count > 0) // { // foreach (var sl in od.shipping_lines) // { // sql += "\r\n Insert into dbo.ShopifyShopsOrders_shipping_lines(shopifyorder_id,shipping_lines_id,carrier_identifier,code,discounted_price,discounted_price_set_shopmoney_amount,discounted_price_set_shopmoney_currency_code,discounted_price_set_presentment_money_amount,\r\ndiscounted_price_set_presentment_money_currency_code,phone,price,price_set_shopmoney_amount,price_set_shopmoney_currency_code,price_set_presentment_money_amount,price_set_presentment_money_currency_code,requested_fulfillment_service_id,\r\nsource,title,CreateTime) Values(" // + "'" + od.id + "','" + sl.id + "','" + sl.carrier_identifier + "','" + sl.code + "'," + sl.discounted_price; // if (sl.discounted_price_set != null) // { // if (sl.discounted_price_set.shop_Money != null) // sql += "," + sl.discounted_price_set.shop_Money.amount + ",'" + sl.discounted_price_set.shop_Money.currency_code + "'"; // else // sql += ",null,''"; // if (sl.discounted_price_set.presentment_Money != null) // sql += "," + sl.discounted_price_set.presentment_Money.amount + ",'" + sl.discounted_price_set.presentment_Money.currency_code + "'"; // else // sql += ",null,''"; // } // else // sql += ",null,'',null,''"; // sql += ",'" + sl.phone + "'," + sl.price; // if (sl.price_set != null) // { // if (sl.price_set.shop_Money != null) // sql += "," + sl.price_set.shop_Money.amount + ",'" + sl.price_set.shop_Money.currency_code + "'"; // else // sql += ",null,''"; // if (sl.price_set.presentment_Money != null) // sql += "," + sl.price_set.presentment_Money.amount + ",'" + sl.price_set.presentment_Money.currency_code + "'"; // else // sql += ",null,''"; // } // else // sql += ",null,'',null,''"; // sql += ",'" + sl.requested_fulfillment_service_id + "','" + sl.source + "','" + sl.title + "',GetDate())"; // } // } // try // { // DataNew.UpdateShopifyShopOrders(sql); // } // catch (Exception ex) // { // } // } //} #endregion } //重新获取这些订单的capture状态 var spOrders = DataNew.GetNeedCaptureShopifyOrders(); foreach(var spo in spOrders) { var url = string.Format("https://{0}:{1}@{2}.myshopify.com/admin/api/2023-07/orders/{3}/transactions.json", spo.AppKey, spo.DeveKey, spo.ShopName, spo.shopifyorder_id); var path = EncryptString(url, "ThisIsShopifyKey12365498"); var path2 = HttpUtility.UrlEncode(path); //var apiurl = "http://50.196.110.198:8081/api/ShopifyHelp/getShopifyOrderTransactions?url=" + path2 + "&accessToken=" + spo.AccessToken; var apiurl = "http://50.196.110.198:8099/api/ShopifyHelp/getShopifyOrderTransactions?url=" + path2 + "&accessToken=" + spo.AccessToken; using (var client = new HttpClient()) { HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, apiurl); var response = client.SendAsync(request); string responseContent = response.Result.Content.ReadAsStringAsync().GetAwaiter().GetResult(); if (string.IsNullOrEmpty(responseContent) || responseContent == "失败") { continue; } var transR = JsonConvert.DeserializeObject(responseContent); if (transR != null && transR.transactions != null && transR.transactions.Count > 0) { var lastTrans = transR.transactions.OrderByDescending(r => r.created_at).FirstOrDefault(); var fsql = ""; if (lastTrans.kind == "capture") { fsql = @" update dbo.ShopifyShopsOrders set CaptureState=1 where shopifyorder_id='" + spo.shopifyorder_id + "' "; } else { fsql = @" update dbo.ShopifyShopsOrders set CaptureState=0 where shopifyorder_id='" + spo.shopifyorder_id + "' "; } DataNew.UpdateShopifyShopOrders(fsql); } #region //client.DefaultRequestHeaders.Add("X-Shopify-Access-Token", spo.AccessToken); //// 发送 GET 请求并返回响应结果 //var response = client.GetAsync(apiurl).Result; //var result = response.Content.ReadAsStringAsync().GetAwaiter().GetResult(); //var transR = JsonConvert.DeserializeObject(result); //if (transR != null && transR.transactions != null && transR.transactions.Count > 0) //{ // var lastTrans = transR.transactions.OrderByDescending(r => r.created_at).FirstOrDefault(); // var fsql = ""; // if (lastTrans.kind == "capture") // { // fsql = @" update dbo.ShopifyShopsOrders set CaptureState=1 where shopifyorder_id='" + spo.shopifyorder_id + "' "; // } // else // { // fsql = @" update dbo.ShopifyShopsOrders set CaptureState=0 where shopifyorder_id='" + spo.shopifyorder_id + "' "; // } // DataNew.UpdateShopifyShopOrders(fsql); //} #endregion } } robj.Code = 1; robj.Message = "拉取成功"; } catch (Exception ex) { robj.Code = 0; robj.Message = "拉取失败:"+ex.Message; } return robj; } #endregion public string GetBZDateTime(string dt) { if (string.IsNullOrEmpty(dt)) return null; else { //北京时间与当地时间存在15个小时的时差,所以减去15个小时得到当地时间 return DateTime.Parse(dt).AddHours(-15).ToString("yyyy-MM-dd HH:mm:ss"); } } public static string EncryptString(string plainText, string key) { using (Aes aesAlg = Aes.Create()) { aesAlg.Key = Encoding.UTF8.GetBytes(key); aesAlg.IV = new byte[16]; // 使用默认IV ICryptoTransform encryptor = aesAlg.CreateEncryptor(aesAlg.Key, aesAlg.IV); byte[] plainBytes = Encoding.UTF8.GetBytes(plainText); byte[] encryptedBytes; using (var msEncrypt = new System.IO.MemoryStream()) { using (var csEncrypt = new CryptoStream(msEncrypt, encryptor, CryptoStreamMode.Write)) { csEncrypt.Write(plainBytes, 0, plainBytes.Length); csEncrypt.FlushFinalBlock(); encryptedBytes = msEncrypt.ToArray(); } } return Convert.ToBase64String(encryptedBytes); } } #region 获取退货订单列表数据 [WebMethod(EnableSession = true)] public JsonModel> GetRefundOrderList(int? shopId, int dateType, DateTime? sDate, DateTime? eDate, string orderId, int searchType, string search, int? isComp, int pageIndex, int pageSize) { PagesNew.Login(base.Session); var rmodel = new JsonModel>(); int rowCount = 0; rmodel.DataSource = DataNew.GetRefundOrderListDatas(shopId, dateType, sDate, eDate, orderId, searchType, search, isComp, pageIndex, pageSize, out rowCount); var ids = ""; if (rmodel.DataSource != null && rmodel.DataSource.Count > 0) { foreach (var ds in rmodel.DataSource) { ids += ds.ID.ToString() + ","; } var items = DataNew.GetRefundOrderList_ItemDatas(ids.TrimEnd(',')); var labels = DataNew.GetRefundOrderList_LabelDatas(ids.TrimEnd(',')); foreach (var ds in rmodel.DataSource) { var _items = items.Where(r => r.ShopRefundOrderDatasId == ds.ID).ToList(); var _labels = labels.Where(r => r.ShopRefundOrderDatasId == ds.ID).ToList(); ds.ItemDetails = _items; ds.LabelDetails = _labels; ds.ScanDate = (_labels != null && _labels.Count > 0) ? _labels.OrderBy(r => r.ScanDate).First().ScanDate : null; ds.CompleteStateColor = ds.CompleteState == "结束" ? "green" : "red"; } } rmodel.RowCount = rowCount; return rmodel; } #endregion #region 更新退货订单完成状态 [WebMethod(EnableSession = true)] public APIReturnModel UpdateRefundOrderState(int id) { PagesNew.Login(base.Session); var rmodel = new APIReturnModel(); try { DataNew.UpdateRefundOrderState(id); rmodel.Code = 1; rmodel.Message = "成功"; } catch (Exception ex) { rmodel.Code = 0; rmodel.Message = "失败:" + ex.Message; } return rmodel; } #endregion #region 保存跟踪码 [WebMethod(EnableSession = true)] public string SaveTrackCode(int OrderId, int TrackType, string OrderCode, int IsSpare, int PostId, string JoinOrderCode, string trackcode, string sku, string cfzl, string cfc, string cfk, string cfg) { Pages.Login(this.Session); DD_OrderData obj = new DD_OrderData(); if (PostId != 104) //荷兰邮政不验证 { if (obj.IsOrderTrackCode(OrderId, trackcode) > 0) return "该跟踪码已经存在"; } int CompanyId = Convert.ToInt32(Session["CompanyId"]); string Name = Convert.ToString(Session["Name"]); DT_TrackCodeApplyNew Model = new DT_TrackCodeApplyNew(); Model.InName = Name; Model.TrackType = TrackType; Model.OrderId = OrderId; Model.IsSpare = IsSpare; Model.TrackCode = trackcode.Trim(); Model.PostId = PostId; Model.State = 1; Model.GetDate = DateTime.Now; if (JoinOrderCode != "") Model.OrderCode = JoinOrderCode; else Model.OrderCode = OrderCode; Model.IsSpare = IsSpare; Model.JoinOrderCode = JoinOrderCode; Model.SKU = sku; Model.Weight = string.IsNullOrEmpty(cfzl) ? "" : (Convert.ToDecimal(cfzl) * 0.0625m).ToString("0.00"); Model.Weight2 = string.IsNullOrEmpty(cfzl) ? "" : (Convert.ToDecimal(cfzl) * 0.0625m).ToString("0.00"); Model.Long = cfc; Model.Width = cfk; Model.Height = cfg; DataNew.SaveTrackCodeApply(Model); return "成功"; } #endregion #region [WebMethod(EnableSession = true)] public JsonModel> GetOrderReturnTrackingIdList(string searchCode ,int searchType,int inType,int PageSize,int PageIndex) { PagesNew.Login(base.Session); var rmodel = new JsonModel>(); int rowCount = 0; rmodel.DataSource = DataNew.GetAllOrderReturnTrackingId(searchCode, searchType, inType, PageIndex, PageSize, out rowCount); rmodel.RowCount = rowCount; return rmodel; } [WebMethod(EnableSession = true)] public APIReturnModel InsertOrderReturnTrackingId(OrderReturnTrackingId mde) { PagesNew.Login(base.Session); var rmodel =new APIReturnModel(); if (mde.ID == 0) { mde.UserId = Convert.ToInt32(base.Session["UserId"]); } var isSucc = DataNew.InsertOrderReturnTrackingId(mde); if (!isSucc) { rmodel.Code = 0; rmodel.Message = "Save Data Fail"; return rmodel; } if(string.IsNullOrEmpty(mde.OrderCode) || string.IsNullOrEmpty(mde.SKU) || !mde.ReturnNum.HasValue) { rmodel.Code = 0; rmodel.Message = "Order No,SKU,Return Quantity can not be empty"; return rmodel; } else { DT_OrderReturn md = new DT_OrderReturn(); md.orderid = 0; md.detailid = 0; md.ordercode = mde.OrderCode; md.merchant_sku = mde.SKU; md.tracking_id = mde.TrackingId; md.return_quantity = mde.ReturnNum; Random rd = new Random(); md.barcode = DateTime.Now.ToString("yyyyMMddHHmmss") + rd.Next(1000, 9999); int a = DataNew.Save_OrderReturnExcel(md); if (a == 0) { rmodel.Code = 0; rmodel.Message = "OrderCode or SKU non-existent"; return rmodel; } } rmodel.Code = 1; rmodel.Message = "Success"; return rmodel; } [WebMethod(EnableSession = true)] public APIReturnModel DeleteOrderReturnTrackingId(int id) { PagesNew.Login(base.Session); var rmodel = new APIReturnModel(); var isSucc = DataNew.DeleteOrderReturnTrackingId(id); if (!isSucc) { rmodel.Code = 0; rmodel.Message = "Delete Data Fail"; return rmodel; } rmodel.Code = 1; rmodel.Message = "Success"; return rmodel; } #endregion /// /// 更新快递面单SKU信息 /// /// /// /// [WebMethod(EnableSession = true)] public APIReturnModel UpdateTrackingCodeSKU(int id,string sku) { Pages.Login(this.Session); var rmodel = new APIReturnModel(); try { if(string.IsNullOrEmpty(sku)) { rmodel.Code = 0; rmodel.Message = "SKU不能为空"; return rmodel; } var skuArr = sku.Split('+'); for(var i = 0; i < skuArr.Length; i++) { try { var first_x = skuArr[i].IndexOf('x');//SKU中第一次出现x的位置 //var qty = Convert.ToInt32(skuArr[i].Substring(0, first_x)); var _sku = skuArr[i].Substring(first_x + 1); //根据SKU1匹配商品详情 var hw_detail = DataNew.GetGoodsDetailBySku1(_sku); if (hw_detail == null) { rmodel.Code = 0; rmodel.Message = "SKU:" + skuArr[i] + "不正确,请填写商品的SKU1"; return rmodel; } } catch (Exception ex) { throw new Exception("SKU填写格式不正确,请按照1xA+2xB+3xC的格式填写"); } } DataNew.UpdateTrackingCodeSKU(id, sku.Trim()); rmodel.Code = 1; rmodel.Message = "Success"; } catch(Exception ex) { rmodel.Code = 0; rmodel.Message = "失败:" + ex.Message; } return rmodel; } #region temu 运费成本 [WebMethod(EnableSession = true)] public int Save_TemuChengBen(TemuChengBen Model) { PagesNew.Login(this.Session); Model.CreateUserId = Convert.ToInt32(Session["UserId"]); return DataNew.SaveTemuChengBen(Model); } [WebMethod(EnableSession = true)] public JsonModel> GetListTemuChengBen(int GoodsId) { PagesNew.Login(this.Session); var resultModel = new JsonModel>(); resultModel.DataSource = DataNew.GetTemuChengBen(GoodsId); return resultModel; } #endregion #region 获取订单所有预估运费 [WebMethod(EnableSession = true)] public List GetOrderPostFeeEstimatesDatas(int orderid) { PagesNew.Login(base.Session); var rdata = new List(); rdata = DataNew.GetOrderPostFeeEstimatesDatas(orderid); return rdata; } #endregion #region 设置订单预估运费最优 [WebMethod(EnableSession = true)] public APIReturnModel SetOrderPostFeeEstimatesBest(int id, int orderid) { PagesNew.Login(base.Session); var rmodel = new APIReturnModel(); try { DataNew.SetOrderPostFeeEstimatesBestByID(id, orderid); rmodel.Code = 1; rmodel.Message = "成功"; } catch (Exception ex) { rmodel.Code = 0; rmodel.Message = "失败:" + ex.Message; } return rmodel; } #endregion #region 获取Fedex多种运输方式的运费 [WebMethod(EnableSession = true)] public List GetFedexFeeDetailNew(DT_OrderModelNew omd, List glist) { Pages.Login(base.Session); DataNew.DeleteOrderPostFeeEstimates(omd.OrderId.Value); var rmodel = new List(); var postTypes = new List() { "SMART_POST", "FEDEX_2_DAY", "FEDEX_GROUND", "GROUND_HOME_DELIVERY" }; var postIds = new List() { 228, 237 };//W仓,E仓 foreach (var postId in postIds) { int companyId = Convert.ToInt32(base.Session["CompanyId"]); JC_ExpressService service = new JC_ExpressService(); JC_PostAddress address = new BaseService().GetAddressModel2(postId); JC_ExpressPost expressModel = service.GetExpressModel(companyId, postId); decimal num2 = 0M; string Width = ""; string Height = ""; string Lenght = ""; if (glist != null) { Width = Math.Ceiling(glist[0].Width2.Value).ToString(); Height = Math.Ceiling(glist[0].Height2.Value).ToString(); Lenght = Math.Ceiling(glist[0].Length2.Value).ToString(); foreach (DT_OrderMateGoods goods in glist) { decimal? nullable; if (!(goods.Weight.HasValue && !(((nullable = goods.Weight).GetValueOrDefault() <= 0M) && nullable.HasValue))) { return rmodel; } if (goods.Width2.HasValue) { nullable = goods.Width2; if (!((nullable.GetValueOrDefault() <= 0M) && nullable.HasValue) && goods.Length2.HasValue) { nullable = goods.Length2; } } if ((((nullable.GetValueOrDefault() <= 0M) && nullable.HasValue) || !goods.Height2.HasValue) || (((nullable = goods.Height2).GetValueOrDefault() <= 0M) && nullable.HasValue)) { return rmodel; } num2 += goods.Weight.Value * goods.GoodsNum.Value; } } TradeManageNew.FedexRateNew3 rate = new TradeManageNew.FedexRateNew3(); TradeManageNew.FedexRateNew3.Key = expressModel.UserCode; TradeManageNew.FedexRateNew3.Password = expressModel.CheckCode; TradeManageNew.FedexRateNew3.AccountNumber = expressModel.client_id; TradeManageNew.FedexRateNew3.MeterNumber = expressModel.client_secret; TradeManageNew.FedexRateNew3.PayAccountNumber = expressModel.refresh_token; TradeManageNew.FedexRateNew3.HubId = expressModel.Code; TradeManageNew.FedexRateNew3.PostId = postId; TradeManageNew.FedexFeeMdNew md = new TradeManageNew.FedexFeeMdNew { RevName = omd.RevName, RevPhone = omd.RevPhone }; if ((omd.RevPhone == null) || (omd.RevPhone == "")) { md.RevPhone = omd.RevMoblie; } md.OrderId = omd.OrderId; //md.PostType = PostType; md.SendAddr = address.EnglishAddress; md.SendCountry = address.countycode; md.SendCity = address.city; md.SendProv = address.provincecode; md.SendPostCode = address.PostCode; md.RevAddr = omd.RevAddr; md.RevCity = omd.RevCity; if ((omd.RevCity == null) || (omd.RevCity == "")) { md.RevCity = omd.RevProvince; } if ((omd.RevProvinceCode != null) && (omd.RevProvinceCode != "")) { md.RevProv = omd.RevProvinceCode; } else if (((omd.RevProvince != null) && (omd.RevProvince != "")) && (omd.RevProvince.Length > 2)) { md.RevProv = omd.RevProvince.Substring(omd.RevProvince.Length - 2, 2); } else { md.RevProv = omd.RevProvince; } md.RevPostCode = omd.RevPostCode; md.RevCountry = omd.CountryCode; md.Width = Math.Ceiling(glist[0].Width2.Value).ToString(); md.Height = Math.Ceiling(glist[0].Height2.Value).ToString(); md.Lenght = Math.Ceiling(glist[0].Length2.Value).ToString(); md.Weight = new decimal?(num2); foreach (var postType in postTypes) { md.PostType = postType; var feeObj = rate.GetFee(md); var saveObj = new OrderPostFeeEstimate(); if (feeObj != null) { saveObj.OrderId = md.OrderId.Value; if (postId == 228) { saveObj.Warehouse = "W仓"; } else if (postId == 237) { saveObj.Warehouse = "E仓"; } saveObj.ServiceType = postType; saveObj.FenQu = feeObj.FenQu; saveObj.TotalFee = string.IsNullOrEmpty(feeObj.TotalFee) ? 0 : Convert.ToDecimal(feeObj.TotalFee); saveObj.BaseFee = string.IsNullOrEmpty(feeObj.BaseFee) ? 0 : Convert.ToDecimal(feeObj.BaseFee); saveObj.AHS = string.IsNullOrEmpty(feeObj.AHS) ? 0 : Convert.ToDecimal(feeObj.AHS); saveObj.OverSize = string.IsNullOrEmpty(feeObj.OverSize) ? 0 : Convert.ToDecimal(feeObj.OverSize); saveObj.PYAreaFee = string.IsNullOrEmpty(feeObj.PYAreaFee) ? 0 : Convert.ToDecimal(feeObj.PYAreaFee); saveObj.CPYAreaFee = string.IsNullOrEmpty(feeObj.CPYAreaFee) ? 0 : Convert.ToDecimal(feeObj.CPYAreaFee); saveObj.CJPYAreaFee = string.IsNullOrEmpty(feeObj.CJPYAreaFee) ? 0 : Convert.ToDecimal(feeObj.CJPYAreaFee); saveObj.FJDFee = string.IsNullOrEmpty(feeObj.FJDFee) ? 0 : Convert.ToDecimal(feeObj.FJDFee); saveObj.WangJiFee = string.IsNullOrEmpty(feeObj.WangJiFee) ? 0 : Convert.ToDecimal(feeObj.WangJiFee); saveObj.RanYouFee = string.IsNullOrEmpty(feeObj.RanYouFee) ? 0 : Convert.ToDecimal(feeObj.RanYouFee); saveObj.QianShouFee = string.IsNullOrEmpty(feeObj.QianShouFee) ? 0 : Convert.ToDecimal(feeObj.QianShouFee); saveObj.ZZFDZFee = string.IsNullOrEmpty(feeObj.ZZFDZFee) ? 0 : Convert.ToDecimal(feeObj.ZZFDZFee); saveObj.ChaoBiaoFee = string.IsNullOrEmpty(feeObj.ChaoBiaoFee) ? 0 : Convert.ToDecimal(feeObj.ChaoBiaoFee); if (!string.IsNullOrEmpty(feeObj.YuJiSongDa)) { saveObj.YuJiSongDa = Convert.ToDateTime(feeObj.YuJiSongDa); } else saveObj.YuJiSongDa = null; saveObj.TotalDiscountFee = string.IsNullOrEmpty(feeObj.TotalDiscountFee) ? 0 : Convert.ToDecimal(feeObj.TotalDiscountFee); saveObj.TotalBillWeight = string.IsNullOrEmpty(feeObj.TotalBillWeight) ? "" : feeObj.TotalBillWeight; saveObj.IsBest = 0; DataNew.SaveOrderPostFeeEstimate(saveObj); } else { saveObj.OrderId = md.OrderId.Value; if (postId == 228) { saveObj.Warehouse = "W仓"; } else if (postId == 237) { saveObj.Warehouse = "E仓"; } saveObj.ServiceType = postType; saveObj.FenQu = ""; saveObj.TotalFee = null; saveObj.BaseFee = null; saveObj.AHS = null; saveObj.OverSize = null; saveObj.PYAreaFee = null; saveObj.CPYAreaFee = null; saveObj.CJPYAreaFee = null; saveObj.FJDFee = null; saveObj.WangJiFee = null; saveObj.RanYouFee = null; saveObj.QianShouFee = null; saveObj.ZZFDZFee = null; saveObj.ChaoBiaoFee = null; saveObj.YuJiSongDa = null; saveObj.TotalDiscountFee = null; saveObj.TotalBillWeight = null; saveObj.IsBest = 0; DataNew.SaveOrderPostFeeEstimate(saveObj); } Thread.Sleep(500); } } DataNew.SetOrderPostFeeEstimatesBest(omd.OrderId.Value); rmodel = DataNew.GetOrderPostFeeEstimatesDatas(omd.OrderId.Value); return rmodel; } #endregion #region [WebMethod(EnableSession = true)] public APIReturnModel GetFedexFeeDetail2New(DT_OrderModelNew omd, List glist, string postType) { Pages.Login(base.Session); var postIds = new List() { 228, 237 };//W仓,E仓 var rmodel = new APIReturnModel(); try { foreach (var postId in postIds) { int companyId = Convert.ToInt32(base.Session["CompanyId"]); JC_ExpressService service = new JC_ExpressService(); JC_PostAddress address = new BaseService().GetAddressModel2(postId); JC_ExpressPost expressModel = service.GetExpressModel(companyId, postId); decimal num2 = 0M; string Width = ""; string Height = ""; string Lenght = ""; if (glist != null) { Width = Math.Ceiling(glist[0].Width2.Value).ToString(); Height = Math.Ceiling(glist[0].Height2.Value).ToString(); Lenght = Math.Ceiling(glist[0].Length2.Value).ToString(); foreach (DT_OrderMateGoods goods in glist) { decimal? nullable; if (!(goods.Weight.HasValue && !(((nullable = goods.Weight).GetValueOrDefault() <= 0M) && nullable.HasValue))) { return rmodel; } if (goods.Width2.HasValue) { nullable = goods.Width2; if (!((nullable.GetValueOrDefault() <= 0M) && nullable.HasValue) && goods.Length2.HasValue) { nullable = goods.Length2; } } if ((((nullable.GetValueOrDefault() <= 0M) && nullable.HasValue) || !goods.Height2.HasValue) || (((nullable = goods.Height2).GetValueOrDefault() <= 0M) && nullable.HasValue)) { return rmodel; } num2 += goods.Weight.Value * goods.GoodsNum.Value; } } TradeManageNew.FedexRateNew3 rate = new TradeManageNew.FedexRateNew3(); TradeManageNew.FedexRateNew3.Key = expressModel.UserCode; TradeManageNew.FedexRateNew3.Password = expressModel.CheckCode; TradeManageNew.FedexRateNew3.AccountNumber = expressModel.client_id; TradeManageNew.FedexRateNew3.MeterNumber = expressModel.client_secret; TradeManageNew.FedexRateNew3.PayAccountNumber = expressModel.refresh_token; TradeManageNew.FedexRateNew3.HubId = expressModel.Code; TradeManageNew.FedexRateNew3.PostId = postId; TradeManageNew.FedexFeeMdNew md = new TradeManageNew.FedexFeeMdNew { RevName = omd.RevName, RevPhone = omd.RevPhone }; if ((omd.RevPhone == null) || (omd.RevPhone == "")) { md.RevPhone = omd.RevMoblie; } md.OrderId = omd.OrderId; md.PostType = postType; md.SendAddr = address.EnglishAddress; md.SendCountry = address.countycode; md.SendCity = address.city; md.SendProv = address.provincecode; md.SendPostCode = address.PostCode; md.RevAddr = omd.RevAddr; md.RevCity = omd.RevCity; if ((omd.RevCity == null) || (omd.RevCity == "")) { md.RevCity = omd.RevProvince; } if ((omd.RevProvinceCode != null) && (omd.RevProvinceCode != "")) { md.RevProv = omd.RevProvinceCode; } else if (((omd.RevProvince != null) && (omd.RevProvince != "")) && (omd.RevProvince.Length > 2)) { md.RevProv = omd.RevProvince.Substring(omd.RevProvince.Length - 2, 2); } else { md.RevProv = omd.RevProvince; } md.RevPostCode = omd.RevPostCode; md.RevCountry = omd.CountryCode; md.Width = Math.Ceiling(glist[0].Width2.Value).ToString(); md.Height = Math.Ceiling(glist[0].Height2.Value).ToString(); md.Lenght = Math.Ceiling(glist[0].Length2.Value).ToString(); md.Weight = new decimal?(num2); var feeObj = rate.GetFee(md); var saveObj = new OrderPostFeeEstimate(); if (feeObj != null) { saveObj.OrderId = md.OrderId.Value; if (postId == 228) { saveObj.Warehouse = "W仓"; } else if (postId == 237) { saveObj.Warehouse = "E仓"; } saveObj.ServiceType = postType; saveObj.FenQu = feeObj.FenQu; saveObj.TotalFee = string.IsNullOrEmpty(feeObj.TotalFee) ? 0 : Convert.ToDecimal(feeObj.TotalFee); saveObj.BaseFee = string.IsNullOrEmpty(feeObj.BaseFee) ? 0 : Convert.ToDecimal(feeObj.BaseFee); saveObj.AHS = string.IsNullOrEmpty(feeObj.AHS) ? 0 : Convert.ToDecimal(feeObj.AHS); saveObj.OverSize = string.IsNullOrEmpty(feeObj.OverSize) ? 0 : Convert.ToDecimal(feeObj.OverSize); saveObj.PYAreaFee = string.IsNullOrEmpty(feeObj.PYAreaFee) ? 0 : Convert.ToDecimal(feeObj.PYAreaFee); saveObj.CPYAreaFee = string.IsNullOrEmpty(feeObj.CPYAreaFee) ? 0 : Convert.ToDecimal(feeObj.CPYAreaFee); saveObj.CJPYAreaFee = string.IsNullOrEmpty(feeObj.CJPYAreaFee) ? 0 : Convert.ToDecimal(feeObj.CJPYAreaFee); saveObj.FJDFee = string.IsNullOrEmpty(feeObj.FJDFee) ? 0 : Convert.ToDecimal(feeObj.FJDFee); saveObj.WangJiFee = string.IsNullOrEmpty(feeObj.WangJiFee) ? 0 : Convert.ToDecimal(feeObj.WangJiFee); saveObj.RanYouFee = string.IsNullOrEmpty(feeObj.RanYouFee) ? 0 : Convert.ToDecimal(feeObj.RanYouFee); saveObj.QianShouFee = string.IsNullOrEmpty(feeObj.QianShouFee) ? 0 : Convert.ToDecimal(feeObj.QianShouFee); saveObj.ZZFDZFee = string.IsNullOrEmpty(feeObj.ZZFDZFee) ? 0 : Convert.ToDecimal(feeObj.ZZFDZFee); saveObj.ChaoBiaoFee = string.IsNullOrEmpty(feeObj.ChaoBiaoFee) ? 0 : Convert.ToDecimal(feeObj.ChaoBiaoFee); if (!string.IsNullOrEmpty(feeObj.YuJiSongDa)) { saveObj.YuJiSongDa = Convert.ToDateTime(feeObj.YuJiSongDa); } else saveObj.YuJiSongDa = null; saveObj.TotalDiscountFee = string.IsNullOrEmpty(feeObj.TotalDiscountFee) ? 0 : Convert.ToDecimal(feeObj.TotalDiscountFee); saveObj.TotalBillWeight = string.IsNullOrEmpty(feeObj.TotalBillWeight) ? "" : feeObj.TotalBillWeight; saveObj.IsBest = 0; DataNew.SaveOrderPostFeeEstimate(saveObj); } else { saveObj.OrderId = md.OrderId.Value; if (postId == 228) { saveObj.Warehouse = "W仓"; } else if (postId == 237) { saveObj.Warehouse = "E仓"; } saveObj.ServiceType = postType; saveObj.FenQu = ""; saveObj.TotalFee = null; saveObj.BaseFee = null; saveObj.AHS = null; saveObj.OverSize = null; saveObj.PYAreaFee = null; saveObj.CPYAreaFee = null; saveObj.CJPYAreaFee = null; saveObj.FJDFee = null; saveObj.WangJiFee = null; saveObj.RanYouFee = null; saveObj.QianShouFee = null; saveObj.ZZFDZFee = null; saveObj.ChaoBiaoFee = null; saveObj.YuJiSongDa = null; saveObj.TotalDiscountFee = null; saveObj.TotalBillWeight = null; saveObj.IsBest = 0; DataNew.SaveOrderPostFeeEstimate(saveObj); } } rmodel.Code = 1; rmodel.Message = "成功"; } catch (Exception ex) { rmodel.Code = 0; rmodel.Message = "失败:" + ex.Message; } return rmodel; } #endregion #region 删除订单 [WebMethod(EnableSession = true)] public APIReturnModel DeleteOrderForTM2(string OrderIds) { Pages.Login(base.Session); var rmodel = new APIReturnModel(); try { int InUserId = Convert.ToInt32(Session["UserId"]); if (OrderIds != "") { DataNew.DeleteOrderForTM2(OrderIds.Trim(',')); Pages.SaveLog(InUserId, "删除订单", OrderIds + "删除订单", 0); } rmodel.Code = 1; rmodel.Message = "Success"; } catch (Exception ex) { rmodel.Code = 0; rmodel.Message = ex.Message; } return rmodel; } #endregion #region TEMU平台店铺订单申请发货流程 /// /// 获取所有TEMU仓库 /// /// /// /// [WebMethod(EnableSession = true)] public APIReturnModel GetTemuShopWareHouseDatas(int shopid) { //Pages.Login(this.Session); var rmodel = new APIReturnModel(); JC_Shop model = DataNew.GetShopModel(shopid); if(string.IsNullOrEmpty(model.RefreshToken) || string.IsNullOrEmpty(model.DeveKey) || string.IsNullOrEmpty(model.Appkey)) { rmodel.Code = 0; rmodel.Message = "店铺授权信息缺失"; return rmodel; } try { var timeStamp = (long)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; var apiType = "bg.logistics.warehouse.list.get"; var bodyStrArr = new string[] { "access_token" + model.RefreshToken, "app_key" + model.Appkey, "data_typeJSON", "timestamp" + timeStamp, "type" + apiType }; var bodyStr = model.DeveKey + string.Join("", bodyStrArr) + model.DeveKey; var sign = EncryptionHelp.GetMD5(bodyStr); var body = new { access_token = model.RefreshToken, app_key = model.Appkey, data_type = "JSON", timestamp = timeStamp, type = apiType, sign = sign.ToUpper(), }; var json = JsonConvert.SerializeObject(body); var path = EncryptionHelp.EncryptString(json, "ThisIsShopifyKey12365498"); var path2 = HttpUtility.UrlEncode(path); //var url = "http://50.196.110.198:8081/api/TemuHelp/getTemuAPIReturnInfo?apiType=" + apiType + "&bodyStr=" + path2; var url = "http://50.196.110.198:8099/api/TemuHelp/getTemuAPIReturnInfo?apiType=" + apiType + "&bodyStr=" + path2; using (HttpClient client = new HttpClient()) { HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, url); var response = client.SendAsync(request); string responseContent = response.Result.Content.ReadAsStringAsync().GetAwaiter().GetResult(); if (string.IsNullOrEmpty(responseContent) || responseContent == "Fail") { rmodel.Code = 0; rmodel.Message = "调用Temu接口失败"; return rmodel; } else { var rModel = JsonConvert.DeserializeObject(responseContent); if (rModel != null && rModel.result != null) { var warehouseList = rModel.result.warehouseList; if (warehouseList != null) { foreach(var wa in warehouseList) { var md = new TemuShopWareHouse { Shopid = shopid, warehouseId = wa.warehouseId, warehouseName = wa.warehouseName, defaultWarehouse = wa.defaultWarehouse ? 1 : 0 }; DataNew.SaveTemuShopWareHouse(md); } } rmodel.Code = 1; rmodel.Message = "成功"; return rmodel; } else { rmodel.Code = 0; rmodel.Message = "Temu接口未返回值"; return rmodel; } } } } catch (Exception ex) { rmodel.Code = 0; rmodel.Message = "失败:" + ex.Message; } return rmodel; } /// /// 获取所有TEMU仓库 /// /// /// /// [WebMethod(EnableSession = true)] public List GetTemuShopWareHouseList(int shopid) { Pages.Login(this.Session); var rmodel = new APIReturnModel(); var datas = DataNew.GetTemuShopWareHouses(shopid); return datas; } /// /// 获取尺寸重量 /// /// /// [WebMethod(EnableSession = true)] public DT_TrackCodeApplyNew GetOrderSizeWeight(string orderids) { PagesNew.Login(this.Session); var obj = new DD_OrderData(); var orderGoodslist = DataNew.GetOrderGoodsList2(orderids.Trim(',')); if (orderGoodslist == null) return null; string gsku = ""; int gnum = 0; decimal ww = 0; decimal c = 0; decimal k = 0; decimal g = 0; foreach (var gmd in orderGoodslist) { if (gmd.GoodsSKU != null && gmd.GoodsSKU != "") gsku += gmd.GoodsNum.Value + "x" + gmd.GoodsSKU + " "; gnum += gmd.GoodsNum.Value; if (gmd.Weight2 != null) ww += gmd.GoodsNum.Value * gmd.Weight2.Value * 0.0625m; else if (gmd.Weight != null) ww += gmd.GoodsNum.Value * gmd.Weight.Value * Convert.ToDecimal(0.0022046); //转为磅 decimal c2 = 0; decimal k2 = 0; decimal g2 = 0; if (gmd.Long2 != null) c2 = gmd.Long2.Value; if (gmd.Width2 != null) k2 = gmd.Width2.Value; if (gmd.Height2 != null) g2 = gmd.Height2.Value; if (c2 > c) c = c2; if (k2 > k) k = k2; if (g2 > g) g = g2; } DT_TrackCodeApplyNew Model = new DT_TrackCodeApplyNew(); Model.SKU = gsku; if (ww > 0) Model.Weight2 = ww.ToString("0.00"); if (c > 0) Model.Long = Math.Ceiling(c).ToString(); if (g > 0) Model.Height = Math.Ceiling(g).ToString(); if (k > 0) Model.Width = Math.Ceiling(k).ToString(); return Model; } /// /// 获取所有TEMU订单的发货渠道对比(手动填尺寸重量) /// /// /// /// [WebMethod(EnableSession = true)] public APIReturnModel GetTemuShipOrderChannels(int orderid,decimal dlength,decimal dwidth,decimal dheight,decimal dweight) { Pages.Login(this.Session); var rmodel = new APIReturnModel(); var orderMd=DataNew.GetOrderModel(orderid); var orderGoods = DataNew.GetOrderGoodsList3(orderid); if(orderMd==null || orderGoods==null) { rmodel.Code = 0; rmodel.Message = "订单信息错误,请刷新"; return rmodel; } JC_Shop model = JC_ShopService.GetModel(orderMd.ShopId.Value); if (string.IsNullOrEmpty(model.RefreshToken) || string.IsNullOrEmpty(model.DeveKey) || string.IsNullOrEmpty(model.Appkey)) { rmodel.Code = 0; rmodel.Message = "店铺授权信息缺失"; return rmodel; } var wareHouses = DataNew.GetTemuShopWareHouses(orderMd.ShopId.Value); if (wareHouses == null) { rmodel.Code = 0; rmodel.Message = "未找到店铺发货仓库信息"; return rmodel; } try { int _dlength = (int)Math.Ceiling(dlength); var _dwidth = (int)Math.Ceiling(dwidth); var _dheight=(int)Math.Ceiling(dheight); var _dweight = (int)Math.Ceiling(dweight); var orderSnList = orderGoods.Select(r => r.PostInfo).ToArray(); var channels = new List(); foreach(var wh in wareHouses) { var timeStamp = (long)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; var apiType = "bg.logistics.shippingservices.get"; var bodyStrArr = new string[] { "access_token" + model.RefreshToken, "app_key" + model.Appkey, "data_typeJSON", "dimensionUnitin", "height" + _dheight, "length" + _dlength, "orderSnList" + JsonConvert.SerializeObject(orderSnList), "timestamp" + timeStamp, "type" + apiType, "warehouseId" + wh.warehouseId, "weight" + _dweight, "weightUnitlb", "width" + _dwidth }; var bodyStr = model.DeveKey + string.Join("", bodyStrArr) + model.DeveKey; var sign = EncryptionHelp.GetMD5(bodyStr); var body = new { access_token = model.RefreshToken, app_key = model.Appkey, data_type = "JSON", dimensionUnit = "in", height = _dheight, length = _dlength, orderSnList = orderSnList, timestamp = timeStamp, type = apiType, warehouseId = wh.warehouseId, weight = _dweight, weightUnit = "lb", width = _dwidth, sign = sign.ToUpper(), }; var json = JsonConvert.SerializeObject(body); var path = EncryptionHelp.EncryptString(json, "ThisIsShopifyKey12365498"); var path2 = HttpUtility.UrlEncode(path); //var url = "http://50.196.110.198:8081/api/TemuHelp/getTemuAPIReturnInfo?apiType=" + apiType + "&bodyStr=" + path2; var url = "http://50.196.110.198:8099/api/TemuHelp/getTemuAPIReturnInfo?apiType=" + apiType + "&bodyStr=" + path2; using (HttpClient client = new HttpClient()) { HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, url); var response = client.SendAsync(request); string responseContent = response.Result.Content.ReadAsStringAsync().GetAwaiter().GetResult(); if (string.IsNullOrEmpty(responseContent) || responseContent == "Fail") { rmodel.Code = 0; rmodel.Message = "调用Temu接口失败"; return rmodel; } else { var rModel = JsonConvert.DeserializeObject(responseContent); if (rModel != null && rModel.result != null && rModel.result.onlineChannelDtoList != null) { string pattern = @"\$(\d+\.\d+)"; foreach (var channel in rModel.result.onlineChannelDtoList) { channel.wareHouseId = wh.warehouseId; channel.wareHouseName = wh.warehouseName; channels.Add(channel); Match match = Regex.Match(channel.estimatedText, pattern); if (!match.Success) { continue; } var topf = new TemuOrderPostFee() { OrderId = orderid, WareHouseId = wh.warehouseId, WareHouseName = wh.warehouseName, PostFee = Convert.ToDecimal(match.Groups[1].Value), EstimatedText = channel.estimatedText, ShipLogisticsType = channel.shipLogisticsType, ShippingCompanyName = channel.shippingCompanyName, ShipCompanyId = channel.shipCompanyId, ChannelId = channel.channelId, }; DataNew.SaveTemuOrderPostFee(topf); } } else { rmodel.Code = 0; rmodel.Message = "Temu接口未返回值"; return rmodel; } } } //using (WebClient client = new WebClient()) //{ // client.Encoding = Encoding.UTF8; // 设置编码为 UTF-8 // string responseContent = client.DownloadString(url); // if (string.IsNullOrEmpty(responseContent) || responseContent == "Fail") // { // rmodel.Code = 0; // rmodel.Message = "调用Temu接口失败"; // return rmodel; // } // else // { // var rModel = JsonConvert.DeserializeObject(responseContent); // if (rModel != null && rModel.result != null && rModel.result.onlineChannelDtoList != null) // { // foreach (var channel in rModel.result.onlineChannelDtoList) // { // channel.wareHouseId = wh.warehouseId; // channel.wareHouseName = wh.warehouseName; // channels.Add(channel); // } // } // else // { // rmodel.Code = 0; // rmodel.Message = "Temu接口未返回值"; // return rmodel; // } // } //} } rmodel.Code = 1; rmodel.Message = "成功"; rmodel.Datas = channels; return rmodel; } catch (Exception ex) { rmodel.Code = 0; rmodel.Message = "失败:" + ex.Message; } return rmodel; } /// /// TEMU订单发货 /// /// /// /// [WebMethod(EnableSession = true)] public APIReturnModel PostTemuShipOrder(int orderid, decimal dlength, decimal dwidth, decimal dheight, decimal dweight, string warehouseId,long channelId,long shipCompanyId, int sendType,string channelText) { Pages.Login(this.Session); var rmodel = new APIReturnModel(); var orderMd = DataNew.GetOrderModel(orderid); string UserName = Convert.ToString(Session["Name"]); var orderGoods = DataNew.GetTemuShopOrderGoodsDetails(orderMd.OrderCode); if (orderMd == null || orderGoods == null) { rmodel.Code = 0; rmodel.Message = "订单信息错误,请刷新"; return rmodel; } JC_Shop model = JC_ShopService.GetModel(orderMd.ShopId.Value); if (string.IsNullOrEmpty(model.RefreshToken) || string.IsNullOrEmpty(model.DeveKey) || string.IsNullOrEmpty(model.Appkey)) { rmodel.Code = 0; rmodel.Message = "店铺授权信息缺失"; return rmodel; } var trackCode=DataNew.GetDT_TrackCodeApplyNewsByOrderId(orderid); if(trackCode!=null) { rmodel.Code = 0; rmodel.Message = "订单已存在跟踪码,请先删除当前跟踪码,再申请"; return rmodel; } try { int _dlength = (int)Math.Ceiling(dlength); var _dwidth = (int)Math.Ceiling(dwidth); var _dheight = (int)Math.Ceiling(dheight); var _dweight = (int)Math.Ceiling(dweight); var orderList = orderGoods.Select(r => new { goodsId = Convert.ToInt64(r.GoodsId), orderSn = r.OrderSn, parentOrderSn = r.ParentOrderSn, quantity = r.Quantity, skuId = Convert.ToInt64(r.SKUId), }); var sendRequestList = new List() { new { channelId = channelId, dimensionUnit = "in", height = _dheight.ToString(), length = _dlength.ToString(), orderSendInfoList=orderList, shipCompanyId = shipCompanyId, warehouseId = warehouseId, weight = _dweight.ToString(), weightUnit = "lb", width = _dwidth.ToString(), } }; var timeStamp = (long)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; var apiType = "bg.logistics.shipment.create"; var bodyStrArr = new string[] { "access_token" + model.RefreshToken, "app_key" + model.Appkey, "data_typeJSON", "sendRequestList" + JsonConvert.SerializeObject(sendRequestList), "sendType" + sendType, "timestamp" + timeStamp, "type" + apiType }; var bodyStr = model.DeveKey + string.Join("", bodyStrArr) + model.DeveKey; var sign = EncryptionHelp.GetMD5(bodyStr); var body = new { access_token = model.RefreshToken, app_key = model.Appkey, data_type = "JSON", sendRequestList = sendRequestList, sendType = sendType, timestamp = timeStamp, type = apiType, sign = sign.ToUpper(), }; var json = JsonConvert.SerializeObject(body); var path = EncryptionHelp.EncryptString(json, "ThisIsShopifyKey12365498"); var path2 = HttpUtility.UrlEncode(path); var url = "http://50.196.110.198:8099/api/TemuHelp/getTemuAPIReturnInfo?apiType=" + apiType + "&bodyStr=" + path2; using (WebClient client = new WebClient()) { client.Encoding = Encoding.UTF8; // 设置编码为 UTF-8 string responseContent = client.DownloadString(url); if (string.IsNullOrEmpty(responseContent) || responseContent == "Fail") { rmodel.Code = 0; rmodel.Message = "调用Temu接口失败"; return rmodel; } else { var rModel = JsonConvert.DeserializeObject(responseContent); if (rModel != null && rModel.result != null && rModel.result.packageSnList.Count>0) { foreach(var packageSn in rModel.result.packageSnList) { var topa = new TemuOrderShipPackageSn() { OrderId = orderid, OrderCode = orderMd.OrderCode, PackageSn = packageSn }; DataNew.SaveTemuOrderShipPackageSn(topa); } Thread.Sleep(2000); //订单物流下单之后,调用接口查询是否下单成功 string error = ""; var packageSns = GetPackageInfoResultLists(rModel.result.packageSnList, orderMd.ShopId.Value, out error); if(!string.IsNullOrEmpty(error) || packageSns == null) { rmodel.Code = 0; rmodel.Message = "物流发货下单查询失败,请到TEMU后台确认;失败原因:" + error; return rmodel; } var shipLabels = GetTemuShipLabels(packageSns.Select(r => r.packageSn).ToList(), orderMd.ShopId.Value, out error); if(!string.IsNullOrEmpty(error) || shipLabels == null) { rmodel.Code = 0; rmodel.Message = "获取物流面单地址失败,请到TEMU后台确认;失败原因:" + error; return rmodel; } var _trackCode = DataNew.GetDT_TrackCodeApplyNewsByOrderId(orderid); if (_trackCode != null) { rmodel.Code = 0; rmodel.Message = "订单已存在跟踪码,请先删除当前跟踪码,再申请"; return rmodel; } //根据面单地址去下载面单文件,并且生成面单发货信息 var errorMsg = ""; foreach(var label in shipLabels) { var packageSn = packageSns.Where(r => r.packageSn == label.packageSn).FirstOrDefault(); if(packageSn!=null && string.IsNullOrEmpty(packageSn.failReasonText)) { var endFileType = label.url.Split('?')[0].Split('.').Last();//面单文件格式 var filePath = AppDomain.CurrentDomain.BaseDirectory + "attached\\khzt\\" + packageSn.trackingNumber + "." + endFileType; var isDownFile = DownTemuShipLableFile(label.url, orderMd.ShopId.Value, packageSn.trackingNumber, endFileType, out error); if (!isDownFile || !string.IsNullOrEmpty(error) || !File.Exists(filePath)) { rmodel.Code = 0; rmodel.Message = "跟踪码为:" + packageSn.trackingNumber + "的面单下载失败,请手动上传"; return rmodel; } FileInfo fileInfo = new FileInfo(filePath); if (fileInfo.Length <= 0) { rmodel.Code = 0; rmodel.Message = "跟踪码为:" + packageSn.trackingNumber + "的面单下载失败,请手动上传"; return rmodel; } var skuStr = ""; if (packageSn.orderSendInfoList != null) { var _orderGoodsGB = packageSn.orderSendInfoList.GroupBy(r => new { r.goodsId, r.skuId }).Select(g => new { goodsid = g.Key.goodsId, skuid = g.Key.skuId, quantity = g.Sum(r => r.quantity) }).ToList(); foreach (var pd in _orderGoodsGB) { var detail = DataNew.GetHW_GoodsDetailByTemuSKUid(orderid, pd.goodsid, pd.skuid); if (detail != null) { skuStr = skuStr + pd.quantity.ToString() + "x" + detail.SKU1 + "+"; } else { throw new Exception("订单信息出错,请删除此订单,并重新同步此订单"); } } } DT_TrackCodeApplyNew Model = new DT_TrackCodeApplyNew(); Model.InName = UserName; Model.TrackType = 2; Model.OrderId = orderid; Model.IsSpare = 0; Model.TrackCode = packageSn.trackingNumber; Model.LabelUrl = packageSn.trackingNumber + "." + endFileType; Model.PostId = 245; Model.State = 1; Model.GetDate = DateTime.Now; Model.OrderCode = orderMd.OrderCode; Model.SKU = string.IsNullOrEmpty(skuStr) ? "" : skuStr.TrimEnd('+'); Model.Weight = string.IsNullOrEmpty(packageSn.weight) ? "0" : packageSn.weight; Model.Weight2 = string.IsNullOrEmpty(packageSn.weight) ? "0" : packageSn.weight; Model.Long = string.IsNullOrEmpty(packageSn.length) ? "0" : packageSn.length; Model.Width = string.IsNullOrEmpty(packageSn.width) ? "0" : packageSn.width; Model.Height = string.IsNullOrEmpty(packageSn.height) ? "0" : packageSn.height; DataNew.SaveTrackCodeApply(Model); if (string.IsNullOrEmpty(skuStr)) { errorMsg = "订单跟踪码:" + packageSn.trackingNumber + "对应的SKU信息为空,请手动补全"; } } try { string pattern = @"\$(\d+\.\d+)"; Match match = Regex.Match(channelText, pattern); if (match.Success) { string postFee = match.Groups[1].Value; if (!string.IsNullOrEmpty(postFee)) { DataNew.Save_OrderLTLFee(orderid, Convert.ToDecimal(postFee)); } else { errorMsg = "运费更新失败,请手动填写"; } } else { errorMsg = "运费更新失败,请手动填写"; } } catch(Exception ex) { errorMsg = "运费更新失败,请手动填写"; } } rmodel.Code = 1; rmodel.Message = errorMsg; return rmodel; } else { rmodel.Code = 0; rmodel.Message = "发货失败,未返回发货包裹编号,请在TEMU后台确认是否已发货"; return rmodel; } } } } catch (Exception ex) { rmodel.Code = 0; rmodel.Message = "失败:" + ex.Message; } return rmodel; } /// /// TEMU订单发货检查 /// /// /// /// [WebMethod(EnableSession = true)] public APIReturnModel PostTemuShipOrderCheck(int orderid,string channelText) { Pages.Login(this.Session); var rmodel = new APIReturnModel(); var orderMd = DataNew.GetOrderModel(orderid); string UserName = Convert.ToString(Session["Name"]); var orderGoods = DataNew.GetTemuShopOrderGoodsDetails(orderMd.OrderCode); if (orderMd == null || orderGoods == null) { rmodel.Code = 0; rmodel.Message = "订单信息错误,请刷新"; return rmodel; } var trackCode = DataNew.GetDT_TrackCodeApplyNewsByOrderId(orderid); if (trackCode != null) { rmodel.Code = 0; rmodel.Message = "订单已存在跟踪码,请先删除当前跟踪码,再操作"; return rmodel; } try { var cpackageSns = DataNew.GetTemuOrderShipPackageSn(orderid); if (cpackageSns != null && cpackageSns.Count > 0) { //订单物流下单之后,调用接口查询是否下单成功 string error = ""; var packageSns = GetPackageInfoResultLists(cpackageSns.Select(r=>r.PackageSn).ToList(), orderMd.ShopId.Value, out error); if (!string.IsNullOrEmpty(error) || packageSns == null) { rmodel.Code = 0; rmodel.Message = "物流发货下单查询失败,请到TEMU后台确认;失败原因:" + error; return rmodel; } var shipLabels = GetTemuShipLabels(packageSns.Select(r => r.packageSn).ToList(), orderMd.ShopId.Value, out error); if (!string.IsNullOrEmpty(error) || shipLabels == null) { rmodel.Code = 0; rmodel.Message = "获取物流面单地址失败,请到TEMU后台确认;失败原因:" + error; return rmodel; } var _trackCode = DataNew.GetDT_TrackCodeApplyNewsByOrderId(orderid); if (_trackCode != null) { rmodel.Code = 0; rmodel.Message = "订单已存在跟踪码,请先删除当前跟踪码,再操作"; return rmodel; } //根据面单地址去下载面单文件,并且生成面单发货信息 var errorMsg = ""; foreach (var label in shipLabels) { var packageSn = packageSns.Where(r => r.packageSn == label.packageSn).FirstOrDefault(); if (packageSn != null && string.IsNullOrEmpty(packageSn.failReasonText)) { var endFileType = label.url.Split('?')[0].Split('.').Last();//面单文件格式 var filePath = AppDomain.CurrentDomain.BaseDirectory + "attached\\khzt\\" + packageSn.trackingNumber + "." + endFileType; var isDownFile = DownTemuShipLableFile(label.url, orderMd.ShopId.Value, packageSn.trackingNumber, endFileType, out error); if (!isDownFile || !string.IsNullOrEmpty(error) || !File.Exists(filePath)) { rmodel.Code = 0; rmodel.Message = "跟踪码为:" + packageSn.trackingNumber + "的面单下载失败,请手动上传"; return rmodel; } FileInfo fileInfo = new FileInfo(filePath); if(fileInfo.Length<=0) { rmodel.Code = 0; rmodel.Message = "跟踪码为:" + packageSn.trackingNumber + "的面单下载失败,请手动上传"; return rmodel; } var skuStr = ""; if (packageSn.orderSendInfoList != null) { var _orderGoodsGB = packageSn.orderSendInfoList.GroupBy(r => new { r.goodsId, r.skuId }).Select(g => new { goodsid = g.Key.goodsId, skuid = g.Key.skuId, quantity = g.Sum(r => r.quantity) }).ToList(); foreach (var pd in _orderGoodsGB) { var detail = DataNew.GetHW_GoodsDetailByTemuSKUid(orderid, pd.goodsid, pd.skuid); if (detail != null) { skuStr = skuStr + pd.quantity.ToString() + "x" + detail.SKU1 + "+"; } else { throw new Exception("订单信息出错,请删除此订单,并重新同步此订单"); } } } DT_TrackCodeApplyNew Model = new DT_TrackCodeApplyNew(); Model.InName = UserName; Model.TrackType = 2; Model.OrderId = orderid; Model.IsSpare = 0; Model.TrackCode = packageSn.trackingNumber; Model.LabelUrl = packageSn.trackingNumber + "." + endFileType; Model.PostId = 245; Model.State = 1; Model.GetDate = DateTime.Now; Model.OrderCode = orderMd.OrderCode; Model.SKU = string.IsNullOrEmpty(skuStr) ? "" : skuStr.TrimEnd('+'); Model.Weight = string.IsNullOrEmpty(packageSn.weight) ? "0" : packageSn.weight; Model.Weight2 = string.IsNullOrEmpty(packageSn.weight) ? "0" : packageSn.weight; Model.Long = string.IsNullOrEmpty(packageSn.length) ? "0" : packageSn.length; Model.Width = string.IsNullOrEmpty(packageSn.width) ? "0" : packageSn.width; Model.Height = string.IsNullOrEmpty(packageSn.height) ? "0" : packageSn.height; DataNew.SaveTrackCodeApply(Model); if (string.IsNullOrEmpty(skuStr)) { errorMsg = "订单跟踪码:" + packageSn.trackingNumber + "对应的SKU信息为空,请手动补全"; } } try { string pattern = @"\$(\d+\.\d+)"; Match match = Regex.Match(channelText, pattern); if (match.Success) { string postFee = match.Groups[1].Value; if (!string.IsNullOrEmpty(postFee)) { DataNew.Save_OrderLTLFee(orderid, Convert.ToDecimal(postFee)); } else { errorMsg = "运费更新失败,请手动填写"; } } else { errorMsg = "运费更新失败,请手动填写"; } } catch (Exception ex) { errorMsg = "运费更新失败,请手动填写"; } } rmodel.Code = 1; rmodel.Message = errorMsg; return rmodel; } else { rmodel.Code = 0; rmodel.Message = "未查询到订单发货包裹编号,请在TEMU后台确认是否已发货"; return rmodel; } } catch (Exception ex) { rmodel.Code = 0; rmodel.Message = "失败:" + ex.Message; } return rmodel; } /// /// TEMU订单发货查询接口 /// /// /// /// [WebMethod(EnableSession = true)] public APIReturnModel GetTemuShipOrderPostInfo(List packageSnList,int orderid) { //Pages.Login(this.Session); var rmodel = new APIReturnModel(); var orderMd = DataNew.GetOrderModel(orderid); var orderGoods = DataNew.GetTemuShopOrderGoodsDetails(orderMd.OrderCode); if (orderMd == null || orderGoods == null) { rmodel.Code = 0; rmodel.Message = "订单信息错误,请刷新"; return rmodel; } JC_Shop model = JC_ShopService.GetModel(orderMd.ShopId.Value); if (string.IsNullOrEmpty(model.RefreshToken) || string.IsNullOrEmpty(model.DeveKey) || string.IsNullOrEmpty(model.Appkey)) { rmodel.Code = 0; rmodel.Message = "店铺授权信息缺失"; return rmodel; } try { var timeStamp = (long)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; var apiType = "bg.logistics.shipment.result.get"; var bodyStrArr = new string[] { "access_token" + model.RefreshToken, "app_key" + model.Appkey, "data_typeJSON", "packageSnList"+JsonConvert.SerializeObject(packageSnList), "timestamp" + timeStamp, "type" + apiType }; var bodyStr = model.DeveKey + string.Join("", bodyStrArr) + model.DeveKey; var sign = EncryptionHelp.GetMD5(bodyStr); var body = new { access_token = model.RefreshToken, app_key = model.Appkey, data_type = "JSON", packageSnList=packageSnList, timestamp = timeStamp, type = apiType, sign = sign.ToUpper(), }; var json = JsonConvert.SerializeObject(body); var path = EncryptionHelp.EncryptString(json, "ThisIsShopifyKey12365498"); var path2 = HttpUtility.UrlEncode(path); var url = "http://50.196.110.198:8099/api/TemuHelp/getTemuAPIReturnInfo?apiType=" + apiType + "&bodyStr=" + path2; using (HttpClient client = new HttpClient()) { HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, url); var response = client.SendAsync(request); string responseContent = response.Result.Content.ReadAsStringAsync().GetAwaiter().GetResult(); if (string.IsNullOrEmpty(responseContent) || responseContent == "Fail") { rmodel.Code = 0; rmodel.Message = "调用Temu接口失败"; return rmodel; } else { var rModel = JsonConvert.DeserializeObject(responseContent); if (rModel != null && rModel.result != null) { rmodel.Code = 1; rmodel.Message = "成功"; rmodel.Datas = rModel.result.packageInfoResultList; return rmodel; } else { rmodel.Code = 0; rmodel.Message = "Temu接口未返回值"; return rmodel; } } } } catch (Exception ex) { rmodel.Code = 0; rmodel.Message = "失败:" + ex.Message; } return rmodel; } /// /// 查询订单物流下单是否正常 /// /// /// /// /// public List GetPackageInfoResultLists(List packageSnList, int shopid,out string error) { try { JC_Shop model = JC_ShopService.GetModel(shopid); if (string.IsNullOrEmpty(model.RefreshToken) || string.IsNullOrEmpty(model.DeveKey) || string.IsNullOrEmpty(model.Appkey)) { error = "店铺没有授权信息"; return null; } var timeStamp = (long)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; var apiType = "bg.logistics.shipment.result.get"; var bodyStrArr = new string[] { "access_token" + model.RefreshToken, "app_key" + model.Appkey, "data_typeJSON", "packageSnList" + JsonConvert.SerializeObject(packageSnList), "timestamp" + timeStamp, "type" + apiType }; var bodyStr = model.DeveKey + string.Join("", bodyStrArr) + model.DeveKey; var sign = EncryptionHelp.GetMD5(bodyStr); var body = new { access_token = model.RefreshToken, app_key = model.Appkey, data_type = "JSON", packageSnList = packageSnList, timestamp = timeStamp, type = apiType, sign = sign.ToUpper(), }; var json = JsonConvert.SerializeObject(body); var path = EncryptionHelp.EncryptString(json, "ThisIsShopifyKey12365498"); var path2 = HttpUtility.UrlEncode(path); var url = "http://50.196.110.198:8099/api/TemuHelp/getTemuAPIReturnInfo?apiType=" + apiType + "&bodyStr=" + path2; using (WebClient client = new WebClient()) { client.Encoding = Encoding.UTF8; // 设置编码为 UTF-8 string responseContent = client.DownloadString(url); if (string.IsNullOrEmpty(responseContent) || responseContent == "Fail") { error= "调用Temu接口失败"; return null; } else { var rModel = JsonConvert.DeserializeObject(responseContent); if (rModel != null && rModel.result != null) { error = ""; return rModel.result.packageInfoResultList; } else { error = "接口未返回值"; return null; } } } } catch(Exception ex) { error = "异常:" + ex.Message; return null; } } /// /// TEMU订单发货打印面单接口 /// /// /// /// [WebMethod(EnableSession = true)] public APIReturnModel GetTemuShipOrderPrintTrackCode(List packageSnList, int orderid) { //Pages.Login(this.Session); var rmodel = new APIReturnModel(); var orderMd = DataNew.GetOrderModel(orderid); var orderGoods = DataNew.GetTemuShopOrderGoodsDetails(orderMd.OrderCode); if (orderMd == null || orderGoods == null) { rmodel.Code = 0; rmodel.Message = "订单信息错误,请刷新"; return rmodel; } JC_Shop model = JC_ShopService.GetModel(orderMd.ShopId.Value); if (string.IsNullOrEmpty(model.RefreshToken) || string.IsNullOrEmpty(model.DeveKey) || string.IsNullOrEmpty(model.Appkey)) { rmodel.Code = 0; rmodel.Message = "店铺授权信息缺失"; return rmodel; } try { var timeStamp = (long)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; var apiType = "bg.logistics.shipment.document.get"; var bodyStrArr = new string[] { "access_token" + model.RefreshToken, "app_key" + model.Appkey, "data_typeJSON", "packageSnList" + JsonConvert.SerializeObject(packageSnList), "timestamp" + timeStamp, "type" + apiType }; var bodyStr = model.DeveKey + string.Join("", bodyStrArr) + model.DeveKey; var sign = EncryptionHelp.GetMD5(bodyStr); var body = new { access_token = model.RefreshToken, app_key = model.Appkey, data_type = "JSON", packageSnList = packageSnList, timestamp = timeStamp, type = apiType, sign = sign.ToUpper(), }; var json = JsonConvert.SerializeObject(body); var path = EncryptionHelp.EncryptString(json, "ThisIsShopifyKey12365498"); var path2 = HttpUtility.UrlEncode(path); var url = "http://50.196.110.198:8099/api/TemuHelp/getTemuAPIReturnInfo?apiType=" + apiType + "&bodyStr=" + path2; using (HttpClient client = new HttpClient()) { HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, url); var response = client.SendAsync(request); string responseContent = response.Result.Content.ReadAsStringAsync().GetAwaiter().GetResult(); if (string.IsNullOrEmpty(responseContent) || responseContent == "Fail") { rmodel.Code = 0; rmodel.Message = "调用Temu接口失败"; return rmodel; } else { var rModel = JsonConvert.DeserializeObject(responseContent); if (rModel != null && rModel.result != null) { rmodel.Code = 1; rmodel.Message = "成功"; rmodel.Datas = rModel.result.shippingLabelUrlList; return rmodel; } else { rmodel.Code = 0; rmodel.Message = "Temu接口未返回值"; return rmodel; } } } } catch (Exception ex) { rmodel.Code = 0; rmodel.Message = "失败:" + ex.Message; } return rmodel; } /// /// 获取包裹面单地址 /// /// /// /// /// public List GetTemuShipLabels(List packageSnList,int shopid,out string error) { try { JC_Shop model = JC_ShopService.GetModel(shopid); if (string.IsNullOrEmpty(model.RefreshToken) || string.IsNullOrEmpty(model.DeveKey) || string.IsNullOrEmpty(model.Appkey)) { error = "店铺没有授权信息"; return null; } var timeStamp = (long)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; var apiType = "bg.logistics.shipment.document.get"; var bodyStrArr = new string[] { "access_token" + model.RefreshToken, "app_key" + model.Appkey, "data_typeJSON", "packageSnList" + JsonConvert.SerializeObject(packageSnList), "timestamp" + timeStamp, "type" + apiType }; var bodyStr = model.DeveKey + string.Join("", bodyStrArr) + model.DeveKey; var sign = EncryptionHelp.GetMD5(bodyStr); var body = new { access_token = model.RefreshToken, app_key = model.Appkey, data_type = "JSON", packageSnList = packageSnList, timestamp = timeStamp, type = apiType, sign = sign.ToUpper(), }; var json = JsonConvert.SerializeObject(body); var path = EncryptionHelp.EncryptString(json, "ThisIsShopifyKey12365498"); var path2 = HttpUtility.UrlEncode(path); var url = "http://50.196.110.198:8099/api/TemuHelp/getTemuAPIReturnInfo?apiType=" + apiType + "&bodyStr=" + path2; using (WebClient client = new WebClient()) { client.Encoding = Encoding.UTF8; // 设置编码为 UTF-8 string responseContent = client.DownloadString(url); if (string.IsNullOrEmpty(responseContent) || responseContent == "Fail") { error = "调用Temu接口失败"; return null; } else { var rModel = JsonConvert.DeserializeObject(responseContent); if (rModel != null && rModel.result != null) { error = ""; return rModel.result.shippingLabelUrlList; } else { error = "Temu接口未返回值"; return null; } } } } catch (Exception ex) { error = "异常:" + ex.Message; return null; } } /// /// TEMU面单地址获取面单 /// /// /// /// [WebMethod(EnableSession = true)] public bool GetTemuShipOrderTrackCodeFile(string filePath, int shopid, string trackCode,string fileType) { try { JC_Shop model = JC_ShopService.GetModel(shopid); if (string.IsNullOrEmpty(model.RefreshToken) || string.IsNullOrEmpty(model.DeveKey) || string.IsNullOrEmpty(model.Appkey)) { return false; } var randomStr = ""; var random = new Random(); for (var i = 0; i < 32; i++) { randomStr += random.Next(0, 9).ToString(); // 生成0到9之间的随机数字并连接起来 } var timeStamp = (long)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; var bodyStrArr = new string[] { "toa-access-token" + model.RefreshToken, "toa-app-key" + model.Appkey, "toa-random" + randomStr, "toa-timestamp" + timeStamp.ToString() }; var bodyStr = model.DeveKey + string.Join("", bodyStrArr) + model.DeveKey; var sign = EncryptionHelp.GetMD5(bodyStr); using (HttpClient client = new HttpClient()) { client.DefaultRequestHeaders.Add("toa-access-token", model.RefreshToken); client.DefaultRequestHeaders.Add("toa-app-key", model.Appkey); client.DefaultRequestHeaders.Add("toa-random", randomStr); client.DefaultRequestHeaders.Add("toa-timestamp", timeStamp.ToString()); client.DefaultRequestHeaders.Add("toa-sign", sign.ToUpper()); // 发送GET请求 HttpResponseMessage response = client.GetAsync(filePath).Result; var pdfBytes = response.Content.ReadAsByteArrayAsync().Result; //var fileName = AppDomain.CurrentDomain + "attached/khzt/" + trackCode + ".pdf"; var fileName = "C:\\Users\\Administrator\\Desktop\\TestImage\\" + trackCode + "." + fileType; //var fileName = AppDomain.CurrentDomain.BaseDirectory + "attached\\khzt\\" + trackCode + "." + fileType; if (File.Exists(fileName)) { File.Delete(fileName); } using (System.IO.FileStream fs = new System.IO.FileStream(fileName, System.IO.FileMode.Create)) { fs.Write(pdfBytes, 0, pdfBytes.Length); } return true; } //var client = new HttpClient(); //var request = new HttpRequestMessage(HttpMethod.Get, filePath); ////request.Headers.Add("toa-access-token", model.RefreshToken); ////request.Headers.Add("toa-app-key", model.Appkey); ////request.Headers.Add("toa-timestamp", timeStamp); ////request.Headers.Add("toa-random", randomStr); ////request.Headers.Add("toa-sign", sign.ToUpper()); //request.Headers.Add("toa-access-token", "eirzsk2jf4d8whhtw4cwc6fbvvp6xmyjlgdvl6ezx6upvzznwuifimyc"); //request.Headers.Add("toa-app-key", "0ba677e1f52bef865cec0bc11543ad2c"); //request.Headers.Add("toa-timestamp", "1717485314"); //request.Headers.Add("toa-random", "42517463877210376230532652152765"); //request.Headers.Add("toa-sign", "21D5DB81D2595488D750D4DD79F52359"); //var response1 = client.SendAsync(request).Result; //var pdfBytes = response1.Content.ReadAsByteArrayAsync().Result; //var fileName = "C:\\Users\\Administrator\\Desktop\\TestImage\\" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".png"; //using (System.IO.FileStream fs = new System.IO.FileStream(fileName, System.IO.FileMode.Create)) //{ // fs.Write(pdfBytes, 0, pdfBytes.Length); //} //return true; } catch (Exception ex) { return false; } } /// /// 下载TEMU面单文件 /// /// /// /// /// public bool DownTemuShipLableFile(string filePath,int shopid,string trackCode,string fileType, out string error) { try { JC_Shop model = JC_ShopService.GetModel(shopid); if (string.IsNullOrEmpty(model.RefreshToken) || string.IsNullOrEmpty(model.DeveKey) || string.IsNullOrEmpty(model.Appkey)) { error = "店铺没有授权信息"; return false; } var randomStr = ""; var random = new Random(); for (var i = 0; i < 32; i++) { randomStr += random.Next(0, 9).ToString(); // 生成0到9之间的随机数字并连接起来 } var timeStamp = (long)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; var bodyStrArr = new string[] { "toa-access-token" + model.RefreshToken, "toa-app-key" + model.Appkey, "toa-random" + randomStr, "toa-timestamp" + timeStamp.ToString() }; var bodyStr = model.DeveKey + string.Join("", bodyStrArr) + model.DeveKey; ErrorFollow.TraceWrite("TEMU订单下载面单加密字符串", "DownTemuShipLableFile", bodyStr); var sign = EncryptionHelp.GetMD5(bodyStr); //using (HttpClient client = new HttpClient()) //{ // client.DefaultRequestHeaders.Add("toa-access-token", model.RefreshToken); // client.DefaultRequestHeaders.Add("toa-app-key", model.Appkey); // client.DefaultRequestHeaders.Add("toa-random", randomStr); // client.DefaultRequestHeaders.Add("toa-timestamp", timeStamp.ToString()); // client.DefaultRequestHeaders.Add("toa-sign", sign.ToUpper()); // // 发送GET请求 // HttpResponseMessage response = client.GetAsync(filePath).Result; // ErrorFollow.TraceWrite("TEMU订单下载面单response", "DownTemuShipLableFile", response.ToString()); // var pdfBytes = response.Content.ReadAsByteArrayAsync().Result; // ErrorFollow.TraceWrite("TEMU订单下载面单pdfBytes", "DownTemuShipLableFile", "面单文件字节长度:" + pdfBytes.Length.ToString()); // var fileName = AppDomain.CurrentDomain.BaseDirectory + "attached\\khzt\\" + trackCode + "." + fileType; // //var fileName= "C:\\Users\\Administrator\\Desktop\\TestImage\\" + trackCode + ".pdf"; // if (File.Exists(fileName)) // { // File.Delete(fileName); // } // using (System.IO.FileStream fs = new System.IO.FileStream(fileName, System.IO.FileMode.Create)) // { // fs.Write(pdfBytes, 0, pdfBytes.Length); // } // error = ""; // return true; //} ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls; using (WebClient client = new WebClient()) { client.Headers.Add("toa-access-token", model.RefreshToken); client.Headers.Add("toa-app-key", model.Appkey); client.Headers.Add("toa-random", randomStr); client.Headers.Add("toa-timestamp", timeStamp.ToString()); client.Headers.Add("toa-sign", sign.ToUpper()); // 发送GET请求 var pdfBytes = client.DownloadData(filePath); ErrorFollow.TraceWrite("TEMU订单下载面单pdfBytes", "DownTemuShipLableFile", "面单文件字节长度:" + pdfBytes.Length.ToString()); var fileName = AppDomain.CurrentDomain.BaseDirectory + "attached\\khzt\\" + trackCode + "." + fileType; //var fileName= "C:\\Users\\Administrator\\Desktop\\TestImage\\" + trackCode + ".pdf"; if (File.Exists(fileName)) { File.Delete(fileName); } using (System.IO.FileStream fs = new System.IO.FileStream(fileName, System.IO.FileMode.Create)) { fs.Write(pdfBytes, 0, pdfBytes.Length); } error = ""; return true; } } catch(Exception ex) { error = "异常:" + ex.Message; return false; } } /// /// 获取所有TEMU订单的发货渠道对比 /// /// /// /// [WebMethod(EnableSession = true)] public APIReturnModel GetAllTemuShipOrderChannels(int orderid) { Pages.Login(this.Session); var rmodel = new APIReturnModel(); var tmfee = DataNew.GetOrdertemuFee(orderid); var temuChannels2 = new List(); if (tmfee != null && tmfee.Count > 0)//费用已经存起来 { rmodel.Code = 1; rmodel.Message = ""; foreach (var fmd in tmfee) { TemuShipChannel cmd = new TemuShipChannel(); cmd.wareHouseId = fmd.WareHouseId; cmd.wareHouseName = fmd.WareHouseName; if (fmd.PostFee == null) fmd.PostFee = 0; cmd.postPrice = fmd.PostFee.Value; cmd.shipLogisticsType = fmd.ShipLogisticsType; cmd.shippingCompanyName = fmd.ShippingCompanyName; cmd.estimatedText = fmd.EstimatedText; temuChannels2.Add(cmd); } rmodel.Datas = temuChannels2.OrderBy(r => r.postPrice); return rmodel; //费用已经存起来直接返回 } var orderMd = DataNew.GetOrderModel(orderid); var orderGoods = DataNew.GetOrderGoodsList3(orderid); if (orderMd == null || orderGoods == null) { rmodel.Code = 0; rmodel.Message = "订单信息错误,请刷新"; return rmodel; } JC_Shop model = JC_ShopService.GetModel(orderMd.ShopId.Value); if (string.IsNullOrEmpty(model.RefreshToken) || string.IsNullOrEmpty(model.DeveKey) || string.IsNullOrEmpty(model.Appkey)) { rmodel.Code = 0; rmodel.Message = "店铺授权信息缺失"; return rmodel; } string errorMsg = ""; var dweight = 0m;//重量转为磅 decimal _length = 0; decimal _width = 0; decimal _height = 0; foreach (var og in orderGoods) { if (og.Weight2 != null) dweight += og.GoodsNum.Value * og.Weight2.Value * 0.0625m; else if (og.Weight != null) dweight += og.GoodsNum.Value * og.Weight.Value * Convert.ToDecimal(0.0022046); else errorMsg = og.GoodsCode + "重量未填,无法计算"; if(!og.Long2.HasValue) errorMsg = og.GoodsCode + "长度英寸未填,无法计算"; if (!og.Width2.HasValue) errorMsg = og.GoodsCode + "宽度英寸未填,无法计算"; if (!og.Height2.HasValue) errorMsg = og.GoodsCode + "高度英寸未填,无法计算"; decimal _length2 = 0; decimal _width2 = 0; decimal _height2 = 0; if (og.Long2 != null) _length2 = og.Long2.Value; if (og.Width2 != null) _width2 = og.Width2.Value; if (og.Height2 != null) _height2 = og.Height2.Value; if (_length2 > _length) _length = _length2; if (_width2 > _width) _width = _width2; if (_height2 > _height) _height = _height2; } if(!string.IsNullOrEmpty(errorMsg)) { rmodel.Code = 0; rmodel.Message = errorMsg; return rmodel; } var wareHouses = DataNew.GetTemuShopWareHouses(orderMd.ShopId.Value); if(wareHouses==null) { rmodel.Code = 0; rmodel.Message = "未找到店铺发货仓库信息"; return rmodel; } try { int _dlength = (int)Math.Ceiling(_length); var _dwidth = (int)Math.Ceiling(_width); var _dheight = (int)Math.Ceiling(_height); var _dweight = (int)Math.Ceiling(dweight); var orderSnList = orderGoods.Select(r => r.PostInfo).ToArray(); var temuChannels = new List(); foreach(var wh in wareHouses) { var timeStamp = (long)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; var apiType = "bg.logistics.shippingservices.get"; var bodyStrArr = new string[] { "access_token" + model.RefreshToken, "app_key" + model.Appkey, "data_typeJSON", "dimensionUnitin", "height" + _dheight, "length" + _dlength, "orderSnList" + JsonConvert.SerializeObject(orderSnList), "timestamp" + timeStamp, "type" + apiType, "warehouseId" + wh.warehouseId, "weight" + _dweight, "weightUnitlb", "width" + _dwidth }; var bodyStr = model.DeveKey + string.Join("", bodyStrArr) + model.DeveKey; var sign = EncryptionHelp.GetMD5(bodyStr); var body = new { access_token = model.RefreshToken, app_key = model.Appkey, data_type = "JSON", dimensionUnit = "in", height = _dheight, length = _dlength, orderSnList = orderSnList, timestamp = timeStamp, type = apiType, warehouseId = wh.warehouseId, weight = _dweight, weightUnit = "lb", width = _dwidth, sign = sign.ToUpper(), }; var json = JsonConvert.SerializeObject(body); var path = EncryptionHelp.EncryptString(json, "ThisIsShopifyKey12365498"); var path2 = HttpUtility.UrlEncode(path); var url = "http://50.196.110.198:8099/api/TemuHelp/getTemuAPIReturnInfo?apiType=" + apiType + "&bodyStr=" + path2; using (HttpClient client = new HttpClient()) { HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, url); var response = client.SendAsync(request); string responseContent = response.Result.Content.ReadAsStringAsync().GetAwaiter().GetResult(); if (string.IsNullOrEmpty(responseContent) || responseContent == "Fail") { rmodel.Code = 0; rmodel.Message = "调用Temu接口失败"; return rmodel; } else { var rModel = JsonConvert.DeserializeObject(responseContent); if (rModel != null && rModel.result != null && rModel.result.onlineChannelDtoList != null) { string pattern = @"\$(\d+\.\d+)"; foreach (var channel in rModel.result.onlineChannelDtoList) { channel.wareHouseId = wh.warehouseId; channel.wareHouseName = wh.warehouseName; channel.postPrice = GetPostPrice(channel.estimatedText); temuChannels.Add(channel); Match match = Regex.Match(channel.estimatedText, pattern); if (!match.Success) { continue; } var topf = new TemuOrderPostFee() { OrderId = orderid, WareHouseId = wh.warehouseId, WareHouseName = wh.warehouseName, PostFee = Convert.ToDecimal(match.Groups[1].Value), EstimatedText = channel.estimatedText, ShipLogisticsType = channel.shipLogisticsType, ShippingCompanyName = channel.shippingCompanyName, ShipCompanyId = channel.shipCompanyId, ChannelId = channel.channelId, }; DataNew.SaveTemuOrderPostFee(topf); } } } } //using (WebClient client = new WebClient()) //{ // client.Encoding = Encoding.UTF8; // 设置编码为 UTF-8 // string responseContent = client.DownloadString(url); // if (string.IsNullOrEmpty(responseContent) || responseContent == "Fail") // { // rmodel.Code = 0; // rmodel.Message = "调用Temu接口失败"; // return rmodel; // } // else // { // var rModel = JsonConvert.DeserializeObject(responseContent); // if (rModel != null && rModel.result != null && rModel.result.onlineChannelDtoList != null) // { // foreach (var channel in rModel.result.onlineChannelDtoList) // { // channel.wareHouseId = wh.warehouseId; // channel.wareHouseName = wh.warehouseName; // temuChannels.Add(channel); // } // } // } //} } rmodel.Code = 1; rmodel.Message = ""; rmodel.Datas = temuChannels.OrderBy(r=>r.postPrice); } catch (Exception ex) { rmodel.Code = 0; rmodel.Message = "失败:" + ex.Message; } return rmodel; } public decimal GetPostPrice(string text) { try { // 使用正则表达式匹配价格信息 string pattern = @"\$([\d.]+)"; Match match = Regex.Match(text, pattern); if (match.Success) { string priceStr = match.Groups[1].Value; return Convert.ToDecimal(priceStr); } else { return 0; } } catch(Exception ex) { return 0; } } #endregion #region 修改订单基础信息 [WebMethod(EnableSession = true)] public string UpdateOrderBase2(DT_OrderModelSave Model) { Pages.Login(this.Session); int UserId = Convert.ToInt32(Session["UserId"]); DataNew.UpdateOrderBaseInfo23(Model); Pages.SaveLog(UserId, "订单日志", "修改订单基本信息", Model.OrderId.Value); return ""; } #endregion #region 20240627二手售卖相关代码 [WebMethod(EnableSession = true)] public List GetOrderGoodsListForTMSecond(int OrderId) { PagesNew.Login(base.Session); DD_OrderData data = new DD_OrderData(); List orderGoodsListNew = DataNew.GetOrderGoodsListNew5(OrderId); DT_FeesTC TCModel = DataNew.GetModel_FeesTC(); decimal? tcfee = 0; if (TCModel != null && TCModel.tc_fee != null) tcfee = TCModel.tc_fee.Value; decimal goodssolid = 0M; if (orderGoodsListNew != null) { //连接 var orderGoodsModel = orderGoodsListNew.FirstOrDefault(); if (orderGoodsModel != null) { var linklist = DataNew.GetHWBuyLinkModelForGoodIds(((int)orderGoodsModel.GoodsId).ToString()); if (linklist != null) { var newLinkUrl = linklist.Where(t => t.LinkUrl.Contains(orderGoodsModel.productImgUrl)).Select(t => t.LinkUrl).FirstOrDefault(); orderGoodsModel.LinkUrl = newLinkUrl; orderGoodsModel.LinkUrlList = linklist; } } // // JC_Money money; List.Enumerator enumerator; decimal? hWCFee; decimal num4; decimal? nullable3; decimal num = Convert.ToDecimal((double)6.5); List list2 = new BaseService().GetMoneyList2(); List orderGoodsPostionCode = DataNew.GetOrderGoodsPostionCodeSecond(OrderId); decimal num2 = 0M; decimal num3 = 0M; decimal hwsfee = 0M; if ((orderGoodsPostionCode != null) && (orderGoodsPostionCode.Count > 0)) { using (enumerator = orderGoodsListNew.GetEnumerator()) { Predicate match = null; Predicate predicate2 = null; DT_OrderMateGoods_New md; while (enumerator.MoveNext()) { md = enumerator.Current; md.RMBMoney = 0; if (match == null) { match = delegate (JC_Money n) { int? nullable; int? nullable2; return (n.MCode == "USD") && (((nullable = n.PlatId).GetValueOrDefault() == (nullable2 = md.PlatId).GetValueOrDefault()) && (nullable.HasValue == nullable2.HasValue)); }; } money = list2.Find(match); if (money != null) { num = money.MRate.Value; } if (predicate2 == null) { predicate2 = n => n.Id == md.Id; } DT_OrderMateGoods_New goods = orderGoodsPostionCode.Find(predicate2); if (goods != null) { md.PostionCode = goods.PostionCode; md.Price = 0; if (goods.Price > 0 && md.GoodsPrice > 0) { md.RMBMoney = (goods.Price.Value * goods.GoodsPrice.Value * md.GoodsNum.Value * Convert.ToDecimal(0.01)) / num; } if (goods.Price.HasValue && md.GoodsNum.HasValue) { num4 = (goods.Price.Value * md.GoodsNum.Value) / num; md.Price = new decimal?(Convert.ToDecimal(num4.ToString("0.00"))); } md.PostPrice = 0; if (goods.PostPrice.HasValue && md.GoodsNum.HasValue) { num4 = (goods.PostPrice.Value * md.GoodsNum.Value) / num; md.PostPrice = new decimal?(Convert.ToDecimal(num4.ToString("0.00"))); } hWCFee = goods.HWCFee; num4 = md.GoodsNum.Value; md.HWCFee = hWCFee.HasValue ? new decimal?(hWCFee.GetValueOrDefault() * num4) : ((decimal?)(nullable3 = null)); num2 += ((goods.Price.Value * md.GoodsNum.Value) + (goods.PostPrice.Value * md.GoodsNum.Value)) / num; num3 += md.HWCFee.Value; hwsfee += md.RMBMoney.Value; } } } if (orderGoodsListNew.Count > 0) { orderGoodsListNew[0].GoodsCB = new decimal?(Convert.ToDecimal(num2.ToString("0.00"))); orderGoodsListNew[0].GoodsCB2 = new decimal?(Convert.ToDecimal(num3.ToString("0.00"))); orderGoodsListNew[0].RMBMoney = new decimal?(Convert.ToDecimal(hwsfee.ToString("0.00"))); } // return orderGoodsListNew; } num2 = 0M; num3 = 0M; hwsfee = 0M; decimal Ratefee = 0M; using (enumerator = orderGoodsListNew.GetEnumerator()) { Predicate predicate3 = null; DT_OrderMateGoods_New md; while (enumerator.MoveNext()) { md = enumerator.Current; if (md.Solid != null) goodssolid += md.Solid.Value * md.GoodsNum.Value; if (predicate3 == null) { predicate3 = delegate (JC_Money n) { int? nullable; int? nullable2; return (n.MCode == "USD") && (((nullable = n.PlatId).GetValueOrDefault() == (nullable2 = md.PlatId).GetValueOrDefault()) && (nullable.HasValue == nullable2.HasValue)); }; } money = list2.Find(predicate3); if (money != null) { num = money.MRate.Value; } num4 = (md.InPrice.Value * md.GoodsNum.Value) / num; md.Price = new decimal?(Convert.ToDecimal(num4.ToString("0.00"))); md.PostPrice = 0; md.HWCFee = 0; if (md.Solid != null) { hWCFee = md.Solid * 170M * md.GoodsNum.Value;//预估头程 // num4 = md.GoodsNum.Value; md.HWCFee = hWCFee; } if (md.GoodsPrice != null) Ratefee += md.Price.Value * md.GoodsPrice.Value * 0.01M;//预估税费 num2 += md.Price.Value; num3 += md.HWCFee.Value; } } if (orderGoodsListNew.Count > 0) { orderGoodsListNew[0].OldTypeDesc = num2.ToString("0.00");//预估成本 orderGoodsListNew[0].OldTypeCode = Ratefee.ToString("0.00");//预估税费 orderGoodsListNew[0].MoneyCode = num3.ToString("0.00");//预估头程 if (orderGoodsListNew[0].GoodsCB == null || orderGoodsListNew[0].GoodsCB == 0) orderGoodsListNew[0].GoodsCB = new decimal?(Convert.ToDecimal(num2.ToString("0.00"))); if (orderGoodsListNew[0].GoodsCB2 == null || orderGoodsListNew[0].GoodsCB2 == 0) orderGoodsListNew[0].GoodsCB2 = new decimal?(Convert.ToDecimal(num3.ToString("0.00"))); // if (orderGoodsListNew[0].RMBMoney == null || orderGoodsListNew[0].RMBMoney == 0) // orderGoodsListNew[0].RMBMoney = new decimal?(Convert.ToDecimal(Ratefee.ToString("0.00"))); // orderGoodsListNew[0].Length2 = goodssolid;//货物立方 } } return orderGoodsListNew; } #region 更新提货信息 [WebMethod(EnableSession = true)] public int UpdateSecondHandBuyer(int id, bool isSecondHandBuyer, string SecondHandBuyerName, string SecondHandBuyerPhone, string SecondHandBuyerTime) { PagesNew.Login(this.Session); DataNew.UpdateSecondHandBuyer(id, isSecondHandBuyer, SecondHandBuyerName, SecondHandBuyerPhone, SecondHandBuyerTime); return 1; } #endregion #region 更新提货信息 [WebMethod(EnableSession = true)] public int UpdateSecondHandType(int id, int SecondHandType) { PagesNew.Login(this.Session); DataNew.UpdateSecondHandType(id, SecondHandType); return 1; } #endregion [WebMethod(EnableSession = true)] public JsonModel> GetListOrderForReturnSecond(int ShopId, int changestate, string InType, string ScanState, DateTime? SDate, DateTime? EDate, DateTime? SDate2, DateTime? EDate2, string trackcode, string OrderCode, string SKU, int trackcz, int PageIndex, int PageSize, string Sort, int warehouse, int SecondState) { PagesNew.Login(base.Session); RefParameterCollection where = new RefParameterCollection(); if (changestate == 0) where.Add(new RefParameter("a.orderid", "=", 0, DbType.Int32)); if (ShopId != 0) where.Add(new RefParameter("c.ShopId", "=", ShopId, DbType.Int32)); if (SDate != null) where.Add(new RefParameter("order_date", ">=", SDate, System.Data.DbType.DateTime)); if (EDate != null) where.Add(new RefParameter("convert(varchar(10), order_date, 120)", "<=", EDate, System.Data.DbType.DateTime)); if (SDate2 != null) where.Add(new RefParameter("ScanDate", ">=", SDate2, System.Data.DbType.DateTime)); if (EDate2 != null) where.Add(new RefParameter("convert(varchar(10), ScanDate, 120)", "<=", EDate2, System.Data.DbType.DateTime)); if (InType != "0") where.Add(new RefParameter("a.InType", "=", InType, DbType.String)); if (SecondState == 0) { where.Add(new RefParameter("isnull(a.SecondHandType,0)", "=", 0, DbType.Int32)); } if (SecondState != -1 && SecondState != 0) { where.Add(new RefParameter("a.SecondHandType", "=", SecondState, DbType.Int32)); } if (ScanState != "-1") where.Add(new RefParameter("isnull(a.ScanState,0)", "=", ScanState, DbType.String)); if (string.IsNullOrEmpty(trackcode) == false) { where.Add(new RefParameter("(a.tracking_id", "=", trackcode, DbType.String)); where.Add(new RefParameter("a.BarCode", "=", trackcode, "or", ")", DbType.String)); } if (string.IsNullOrEmpty(OrderCode) == false) where.Add(new RefParameter("a.ordercode", "like", OrderCode, DbType.String)); if (string.IsNullOrEmpty(SKU) == false) where.Add(new RefParameter("a.merchant_sku", "like", SKU, DbType.String)); if (trackcz == 0) where.Add(new RefParameter("a.tracking_id", "=", "", DbType.String)); if (trackcz == 1) where.Add(new RefParameter("a.tracking_id", "<>", "", DbType.String)); if (warehouse == 0) where.Add(new RefParameter("d.WorkDesc", "=", "西仓", DbType.String)); if (warehouse == 1) where.Add(new RefParameter("d.WorkDesc", "=", "东仓", DbType.String)); JsonModel> resultModel = new JsonModel>(); int RowCount = 0; resultModel.DataSource = DataNew.GetListOrderReturnSecond(where, PageIndex, PageSize, Sort, out RowCount); resultModel.RowCount = RowCount; return resultModel; } #region 更新二手状态 [WebMethod(EnableSession = true)] public int UpdatePutawayMsg(int id, decimal SecondHandSalePrice, int IsOfferUp, int IsMaketPlace) { PagesNew.Login(this.Session); DataNew.UpdatePutawayMsgSecond(id, SecondHandSalePrice, IsOfferUp, IsMaketPlace); return 1; } #endregion #endregion #region 二手商品上架Shopify [WebMethod(EnableSession = true)] public JsonModel> OrderUsedSalePlatformPage(string Code,string BarCode,bool? IsPrinted,TradeUsedSale.Enums.UsedSalePlatformStatus? Status,string WarehousePositionCode,int PageIndex=1,int PageSize=50) { // PagesNew.Login(base.Session); var result = new JsonModel>(); using (var db = new TradeUsedSale.Repositories.ErpDbContext()) { var query = db.DT_OrderUsedSalePlatform.AsQueryable(); if (!string.IsNullOrWhiteSpace(Code)) { query = query.Where(x => x.ProductCode.Contains(Code) || x.SkuCode.Contains(Code)); } if (!string.IsNullOrWhiteSpace(BarCode)) { query = query.Where(x => x.BarCode == BarCode); } if (IsPrinted.HasValue) { query = query.Where(x => x.IsPrinted == IsPrinted.Value); } if (Status.HasValue) { query = query.Where(x => x.Status == Status.Value); } if (!string.IsNullOrWhiteSpace(WarehousePositionCode)) { query = query.Where(x => x.WarehousePositionCode == WarehousePositionCode); } query = query.OrderByDescending(x => x.CreationTime); var count = query.Count(); result.RowCount = count; if (count > 0) { var page= query.Skip((PageIndex - 1) * PageSize).Take(PageSize).ToList(); result.DataSource = page; } } return result; } [WebMethod(EnableSession = true)] public APIReturnModel OrderUsedSalePlatformPrint(List Ids) { // PagesNew.Login(base.Session); using (var db = new TradeUsedSale.Repositories.ErpDbContext()) { db.DT_OrderUsedSalePlatform .Where(x => Ids.Contains(x.Id)) .Set(x => x.IsPrinted, true) .Update(); return new APIReturnModel { Code = 1, Message = "Success", Datas = null }; } } [WebMethod(EnableSession = true)] public APIReturnModel OrderUsedSalePlatformPublish(List Ids) { // PagesNew.Login(base.Session); using (var db = new TradeUsedSale.Repositories.ErpDbContext()) { var orderUsedSalePlatformList = db.DT_OrderUsedSalePlatform.Where(x => Ids.Contains(x.Id)).ToList(); foreach (var orderUsedSalePlatform in orderUsedSalePlatformList) { if (orderUsedSalePlatform.Status != TradeUsedSale.Enums.UsedSalePlatformStatus.NotListed) { continue; } //系统产品信息 var product = db.HW_GoodsInfo.FirstOrDefault(x => x.GoodsId == orderUsedSalePlatform.ProductId); if (product is null) { var message = $"系统中不存在编码为[{orderUsedSalePlatform.ProductCode}]的产品信息,无法推送至Shopify"; db.DT_OrderUsedSalePlatform.Where(x => x.Id == orderUsedSalePlatform.Id) .Set(x => x.PublishMessage, message) .Update(); continue; } //毛重 if (product.Weight is null || product.Weight <= 0) { var message = $"产品[{product.GoodsCode}]无毛重信息,无法推送至Shopify"; db.DT_OrderUsedSalePlatform.Where(x => x.Id == orderUsedSalePlatform.Id) .Set(x => x.PublishMessage, message) .Update(); continue; } //建议售价 if (product.JYPrice is null || product.JYPrice <= 0) { var message = $"产品[{product.GoodsCode}]无建议售价,无法推送至Shopify"; db.DT_OrderUsedSalePlatform.Where(x => x.Id == orderUsedSalePlatform.Id) .Set(x => x.PublishMessage, message) .Update(); continue; } //预估运费 var postFee = db.HW_PostFee.FirstOrDefault(x => x.GoodsId == orderUsedSalePlatform.ProductId); if (postFee is null) { db.DT_OrderUsedSalePlatform.Where(x => x.Id == orderUsedSalePlatform.Id) .Set(x => x.PublishMessage, $"产品[{product.GoodsCode}]无预估运费,无法推送至Shopify") .Update(); continue; } var fees = new List() { postFee.Fee1, //postFee.Fee2, postFee.Fee3, postFee.Fee4, postFee.Fee5, //postFee.Fee6, postFee.Fee7, postFee.Fee8, }.Where(x => x != null).ToList(); var feeCost = fees.Any() ? fees.Min() : 0; if (feeCost <= 0) { db.DT_OrderUsedSalePlatform.Where(x => x.Id == orderUsedSalePlatform.Id) .Set(x => x.PublishMessage, $"产品[{product.GoodsCode}]预估运费小于0,无法推送至Shopify") .Update(); continue; } string shopifyProductId; //判断时候在Shopify已创建过产品 var shopifyProductGoodsMap = db.DT_ShopifyProductGoodsMap.FirstOrDefault(x => x.SkuId == orderUsedSalePlatform.SkuId); //获取SKU的资料信息 var shopifyProductProfile = db.DT_ShopifyUsedSaleProduct.FirstOrDefault(x => x.Sku == orderUsedSalePlatform.SkuCode); //Shopify客户端 var shopifyApiClient = new ShopifyAPIClient(); if (shopifyProductGoodsMap is null) { try { //在Shopify创建产品信息 var createShopifyProductParameter = new Body2 { ProductBaseData = new ProductBaseData { SKU = shopifyProductProfile?.Sku ?? orderUsedSalePlatform.SkuCode, Title = shopifyProductProfile?.Title ?? product.GoodsEnglisgName, ImagePath = shopifyProductProfile?.ImagePath ?? product.FirstImgUrl, ProductType = shopifyProductProfile?.Category, Tags = shopifyProductProfile?.Tags, Weight = product.Weight.Value, JYPrice = product.JYPrice.Value, ShippingFee = feeCost.Value, } }; var shopifyProductRes = shopifyApiClient.CreateProductAsync(createShopifyProductParameter) .ConfigureAwait(false) .GetAwaiter() .GetResult(); if (string.IsNullOrWhiteSpace(shopifyProductRes?.Data?.Id)) { var message = $"产品[{product.GoodsCode}]推送Shopify产品失败,原因:{shopifyProductRes.Message}"; db.DT_OrderUsedSalePlatform.Where(x => x.Id == orderUsedSalePlatform.Id) .Set(x => x.PublishMessage, message) .Update(); continue; } shopifyProductId = shopifyProductRes.Data.Id; var newMap = new TradeUsedSale.Repositories.Models.DT_ShopifyProductGoodsMap { ShopifyProductId = shopifyProductId, SkuId = orderUsedSalePlatform.SkuId, SkuCode = orderUsedSalePlatform.SkuCode, CreationTime = DateTime.Now }; db.InsertWithInt32Identity(newMap); } catch (Exception ex) { var message = $"产品[{product.GoodsCode}]推送Shopify产品失败,原因:{ex.Message}"; db.DT_OrderUsedSalePlatform.Where(x => x.Id == orderUsedSalePlatform.Id) .Set(x => x.PublishMessage, message) .Update(); continue; } } else { shopifyProductId = shopifyProductGoodsMap.ShopifyProductId; } try { var imageUrls = JsonConvert.DeserializeObject>(orderUsedSalePlatform.ImageUrls); //在Shopify创建产品变体信息 var createShopifyVariantParameter = new AddVariantRequest { ProductBaseData = new ProductBaseData2 { ShoifyGoodsId = shopifyProductId, SKU = shopifyProductProfile?.Sku ?? orderUsedSalePlatform.SkuCode, Title = shopifyProductProfile?.Title ?? product.GoodsEnglisgName, ImagePath = shopifyProductProfile?.ImagePath ?? product.FirstImgUrl, ProductType = shopifyProductProfile?.Category, Tags = shopifyProductProfile?.Tags, Weight = product.Weight.Value, JYPrice = product.JYPrice.Value, ShippingFee = feeCost.Value }, Variants = new Variants { Return_quantity = 1, ImgUrl = imageUrls.Count > 0 ? imageUrls[0] : null, ImgUrl2 = imageUrls.Count > 0 ? imageUrls[0] : null, ImgUrl3 = imageUrls.Count > 0 ? imageUrls[0] : null, ImgUrl4 = imageUrls.Count > 0 ? imageUrls[0] : null, ImgUrl5 = imageUrls.Count > 0 ? imageUrls[0] : null, StoreName = orderUsedSalePlatform.WarehouseLocation == TradeUsedSale.Enums.WarehouseLocation.East ? "E" : "W", Code = orderUsedSalePlatform.BarCode, }, }; var productVariantRes = shopifyApiClient.AddProductVariantAsync(createShopifyVariantParameter).ConfigureAwait(false) .GetAwaiter() .GetResult(); if (productVariantRes.Success == false) { var message = $"产品[{product.GoodsCode}]推送Shopify变体失败,原因:{productVariantRes.Message}"; db.DT_OrderUsedSalePlatform.Where(x => x.Id == orderUsedSalePlatform.Id) .Set(x => x.PublishMessage, message) .Update(); continue; } //推送Shopify成功 db.DT_OrderUsedSalePlatform.Where(x => x.Id == orderUsedSalePlatform.Id) .Set(x => x.Status, TradeUsedSale.Enums.UsedSalePlatformStatus.Listed) .Set(x => x.PublishMessage, "推送成功") .Update(); } catch (Exception ex) { var message = $"产品[{product.GoodsCode}]推送Shopify变体失败,原因:{ex.Message}"; db.DT_OrderUsedSalePlatform.Where(x => x.Id == orderUsedSalePlatform.Id) .Set(x => x.PublishMessage, message) .Update(); continue; } } } return new APIReturnModel { Code = 1, Message = "Success", Datas = null }; } [WebMethod(EnableSession = true)] public APIReturnModel PlaceShopifyUsedSaleOrderCallback(string originJson) { if (string.IsNullOrWhiteSpace(originJson)) { return new APIReturnModel { Code = 0, Message = "下单Json数据为空,请检查", Datas = null }; } var originJsonData = ShopifyUsedSaleOrderDto.FromJson(originJson); using (var db = new TradeUsedSale.Repositories.ErpDbContext()) { var newDtShopifyUsedSaleOrder = new TradeUsedSale.Repositories.Models.DT_ShopifyUsedSaleOrder { OrderId = originJsonData.Order.OrderId, OrderNumber = originJsonData.Order.OrderNumber, OrderName = originJsonData.Order.OrderName, CreatedAt = originJsonData.Order.CreatedAt.DateTime, UpdatedAt = originJsonData.Order.UpdatedAt.DateTime, ProcessedAt = originJsonData.Order.ProcessedAt.DateTime, Name = originJsonData.Recipient.Name, Phone = originJsonData.Recipient.Phone, Full = originJsonData.Recipient.Address.Full, Detail = originJsonData.Recipient.Address.Detail, Detail2 = originJsonData.Recipient.Address.Detail2, City = originJsonData.Recipient.Address.City, Province = originJsonData.Recipient.Address.Province, ProvinceCode = originJsonData.Recipient.Address.ProvinceCode, Zip = originJsonData.Recipient.Address.Zip, Country = originJsonData.Recipient.Address.Country, CountryCode = originJsonData.Recipient.Address.CountryCode, Currency = originJsonData.Financial.Currency, TotalPrice = originJsonData.Financial.TotalPrice, SubtotalPrice = originJsonData.Financial.SubtotalPrice, TotalTax = originJsonData.Financial.TotalTax, TotalDiscounts = originJsonData.Financial.TotalDiscounts, ShippingPrice = originJsonData.Financial.ShippingPrice, PaymentMethod = originJsonData.Financial.PaymentMethod, FinancialStatus = originJsonData.Financial.FinancialStatus, RefundedAmount = originJsonData.Financial.RefundedAmount, OriginJson = originJson }; var dtShopifyUsedSaleOrderId = db.InsertWithInt32Identity(newDtShopifyUsedSaleOrder); foreach (var item in originJsonData.Items) { var newDtShopifyUsedSaleOrderItem = new TradeUsedSale.Repositories.Models.DT_ShopifyUsedSaleOrderItem { DtShopifyUsedSaleOrderId = dtShopifyUsedSaleOrderId, OriginSku = item.OriginSku, Sku = item.Sku, ProductCode = item.ProductCode, Quantity = item.Quantity, Price = item.Price, Title = item.Title, VariantTitle = item.VariantTitle, ProductId = item.ProductId, VariantId = item.VariantId, Image = item.Image, ShippingMethod = item.ShippingMethod }; db.InsertWithInt32Identity(newDtShopifyUsedSaleOrderItem); } } return new APIReturnModel { Code = 1, Message = "Success", Datas = null }; } #endregion #region 订单同步零星 [WebMethod(EnableSession = true)] public string UpdateSync_LX(List olist,string logisticsChannel) { Pages.Login(this.Session); if (olist == null || olist.Count == 0) return ""; string orderids = ""; foreach (var omd in olist) { orderids += omd.OrderId.ToString() + ","; } string orderinfo = ""; var list = DataNew.GetOrderList_LX(orderids.TrimEnd(',')); string Name = Convert.ToString(Session["Name"]); if (list != null) { if (orderids != "") { var skulist = DataNew.GetOrderSKU_LX(orderids.TrimEnd(',')); List oolist = new List(); foreach (var omd in list) { LX_OrderInfo lxmd = new LX_OrderInfo(); if (logisticsChannel == "0"&&omd.Upload_label == 2)//不推送//根据地址规则匹配物流 continue; switch (omd.PlatId) { case 1: lxmd.salesPlatform = "AliExpress"; break; case 2: lxmd.salesPlatform = "Amazon"; break; case 3: lxmd.salesPlatform = "eBay"; break; case 4: lxmd.salesPlatform = "Wish"; break; case 5: lxmd.salesPlatform = "Lazada"; break; case 6: lxmd.salesPlatform = "Walmart"; break; case 15: lxmd.salesPlatform = "Shopify"; break; case 18: lxmd.salesPlatform = "Wayfair"; break; case 21: lxmd.salesPlatform = "Shein"; break; case 22: lxmd.salesPlatform = "TikTok"; break; case 23: lxmd.salesPlatform = "Temu"; break; default: lxmd.salesPlatform = "Other"; break; } if (omd.StoreId == 11) lxmd.whCode = "JAX";//JAX else lxmd.whCode = "LAX"; lxmd.subOrderType = 1; lxmd.thirdOrderNo = omd.PlatOrderCode; lxmd.referOrderNo = omd.PlatOrderCode; lxmd.receiver = omd.RevName; if (omd.CountryCode != "" && omd.CountryCode.Length == 2) lxmd.countryRegionCode = omd.CountryCode; else lxmd.countryRegionCode = "US"; var skumd = skulist.FindAll(n => n.OrderId == omd.OrderId); if (skumd == null || skumd.Count == 0) { continue; } List plist = new List(); decimal weight = 0; foreach (var ssku in skumd) { if(ssku.BoxRate==1) weight += ssku.GoodsNum.Value * ssku.Weight.Value; else weight += ssku.GoodsNum.Value * ssku.Weight2.Value; LX_OrderProductList pmd = new LX_OrderProductList(); pmd.sku = ssku.SKU; pmd.quantity = ssku.GoodsNum; plist.Add(pmd); } lxmd.productList = plist; if (logisticsChannel == "0")//根据地址规则匹配物流 { if (omd.Upload_label == 1) lxmd.logisticsChannel = "Upload_Shipping_Label"; else if (omd.StoreId == 11) { if (weight < 3) //小于3磅走 USPS Ground Advantage { lxmd.logisticsChannel = "USPS Ground Advantage"; } else if (weight < 8) //小于8磅走 Economy { lxmd.logisticsChannel = "Service with the lowest price"; } else if (omd.RevFax.ToLower() == "residential") { lxmd.logisticsChannel = "FedEx Home Delivery"; } else { lxmd.logisticsChannel = "FEDEX_GROUND"; } } else { if (weight < 3) //小于3磅走 USPS Ground Advantage { lxmd.logisticsChannel = "USPS Ground Advantage"; } else if (weight < 8) //小于8磅走 Economy { lxmd.logisticsChannel = "Service with the lowest price"; } else if (omd.RevFax.ToLower() == "residential") { lxmd.logisticsChannel = "FedEx West Home Delivery"; } else { lxmd.logisticsChannel = "FEDEX_West_GROUND"; } } if (lxmd.logisticsChannel == null || lxmd.logisticsChannel == "") lxmd.logisticsChannel = "Service with the lowest price"; } else lxmd.logisticsChannel = logisticsChannel; // "Service with the lowest price"; lxmd.provinceCode = omd.RevProvinceCode; lxmd.provinceName = omd.RevProvince; lxmd.postCode = omd.RevPostCode; if (omd.RevMoblie != null && omd.RevMoblie != "") lxmd.telephone = omd.RevMoblie; else lxmd.telephone = omd.RevPhone; if (lxmd.telephone == null|| lxmd.telephone == "") { DataNew.Save_OrderLXSate(omd.PlatOrderCode, 2, "["+ Name +"手动推送]失败:手机和电话不存在", ""); continue; } if (omd.RevCity != null && omd.RevCity != "" && omd.RevAddr.Contains(omd.RevCity) == true)//详细地址包含城市的话替换城市 lxmd.addressOne = omd.RevAddr.Replace(omd.RevCity, ""); else lxmd.addressOne = omd.RevAddr; lxmd.cityName = omd.RevCity; lxmd.email = ""; // lxmd.insureMoney =0; lxmd.logisticsTrackNo = ""; lxmd.logisticsCarrier = ""; // lxmd.needInsure =1; // lxmd.needSign = 1; lxmd.platformOrderNo = omd.PlatOrderCode; // if (omd.BuyRemark != null) lxmd.remark = omd.ShopName; oolist.Add(lxmd); } var settings = new JsonSerializerSettings { ContractResolver = new SortContractResolver() // NullValueHandling= NullValueHandling.Ignore }; if (oolist == null || oolist.Count == 0) return "同步完成"; string data = JsonConvert.SerializeObject(oolist, settings); string reqTime = GetTimeStamp(DateTime.Now).ToString(); Dictionary paramDic = new Dictionary(); //client_id:app注册时,分配给app的唯一标示,又称appKey paramDic.Add("appKey", "906617eddb314e90bc752095cb3974d0"); paramDic.Add("data", data); paramDic.Add("reqTime", reqTime); string secretKey = "5bff96344418438d978d031da99664d7"; string key = signPath(paramDic, secretKey); string url = "https://api.xlwms.com/openapi/v1/outboundOrder/create?authcode=" + key; LX_DataNew lxdata = new LX_DataNew(); lxdata.appKey = "906617eddb314e90bc752095cb3974d0"; lxdata.data = oolist; lxdata.reqTime = reqTime; string data2 = JsonConvert.SerializeObject(lxdata); byte[] bdata = Encoding.UTF8.GetBytes(data2); string error = ""; string re = HttpRequest2(url, "Post", "application/json", null, null, bdata, out error); if (error == "" && re != null) { //{"code":200,"data":[{"orderNo":"OBS0202412070RS","thirdOrderNo":"113-2984193-9145864","msg":"成功","success":true},{"orderNo":"OBS0202412070RT","thirdOrderNo":"103869999024350","msg":"成功","success":true}],"msg":"操作成功"} LX_Result LX_Result = JsonConvert.DeserializeObject(re); if (LX_Result.code == "200") { if (LX_Result.data != null) { foreach (var oomd in LX_Result.data) { if (oomd.success == true)//成功 { DataNew.Save_OrderLXSate(oomd.thirdOrderNo, 1, "[" + Name + "手动推送]同步成功,领星发货单号"+ oomd.orderNo, oomd.orderNo); } else //失败 { orderinfo += oomd.thirdOrderNo + "["+ oomd.msg + "];"; DataNew.Save_OrderLXSate(oomd.thirdOrderNo, 2, "[" + Name + "手动推送]" + oomd.msg, oomd.orderNo); } } } } else { ErrorFollow.TraceWrite("同步领星 异常", url + ";" + data2, LX_Result.code + LX_Result.msg); } } else { orderinfo=error; ErrorFollow.TraceWrite("同步领星 异常", url + ";" + data2, error); } } } return orderinfo; } #endregion // 将DateTime转换为时间戳 private int GetTimeStamp(DateTime dt) { DateTime dateStart = new DateTime(1970, 1, 1, 8, 0, 0); int timeStamp = Convert.ToInt32((dt - dateStart).TotalSeconds); return timeStamp; } private string signPath(Dictionary paramDic, string secretKey) { paramDic.OrderBy(n => n.Key); string tmp = ""; foreach (KeyValuePair kv in paramDic) { tmp = tmp + kv.Value; } // 使用 String.Format // string message1 = String.Format("906617eddb314e90bc752095cb3974d0\"{0}\"1733459498","[{\"whCode\":\"LAX\",\"salesPlatform\":\"Amazon\",\"referOrderNo\":null,\"platformOrderNo\":null,\"thirdOrderNo\":\"95285770811022\",\"subOrderType\":1,\"logisticsChannel\":\"Service with the lowest price\",\"logisticsTrackNo\":null,\"logisticsCarrier\":null,\"needSign\":null,\"needInsure\":null,\"insureMoney\":null,\"remark\":null,\"receiver\":\"Ernestas Simkevicius\",\"telephone\":\"37065662700\",\"email\":null,\"countryRegionCode\":\"LT\",\"provinceCode\":null,\"provinceName\":\"Lithuania\",\"cityName\":\"Kacergine\",\"postCode\":\"53445\",\"addressOne\":null,\"productList\":[{\"sku\":\"DR1010\",\"quantity\":1}]}]"); // string aa = "906617eddb314e90bc752095cb3974d0"+"\""; // tmp = "906617eddb314e90bc752095cb3974d0"+"\""+ "[{\\\"whCode\\\":\\\"LAX\\\",\\\"salesPlatform\\\":\\\"Amazon\\\",\\\"referOrderNo\\\":null,\\\"platformOrderNo\\\":null,\\\"thirdOrderNo\\\":\\\"95285770811022\\\",\\\"subOrderType\\\":1,\\\"logisticsChannel\\\":\\\"Service with the lowest price\\\",\\\"logisticsTrackNo\\\":null,\\\"logisticsCarrier\\\":null,\\\"needSign\\\":null,\\\"needInsure\\\":null,\\\"insureMoney\\\":null,\\\"remark\\\":null,\\\"receiver\\\":\\\"Ernestas Simkevicius\\\",\\\"telephone\\\":\\\"37065662700\\\",\\\"email\\\":null,\\\"countryRegionCode\\\":\\\"LT\\\",\\\"provinceCode\\\":null,\\\"provinceName\\\":\\\"Lithuania\\\",\\\"cityName\\\":\\\"Kacergine\\\",\\\"postCode\\\":\\\"53445\\\",\\\"addressOne\\\":null,\\\"productList\\\":[{\\\"sku\\\":\\\"DR1010\\\",\\\"quantity\\\":1}]}]"+"\"" + "1733459498"; string code = HmacSHA256(tmp, secretKey).ToLower(); return code; } public static string HmacSHA256(string data, string secret) { var encoding = new UTF8Encoding(); byte[] keyByte = encoding.GetBytes(secret); byte[] messageBytes = encoding.GetBytes(data); using (var hmacsha256 = new HMACSHA256(keyByte)) { byte[] hashmessage = hmacsha256.ComputeHash(messageBytes); StringBuilder sb = new StringBuilder(); for (int i = 0; i < hashmessage.Length; i++) { sb.Append(hashmessage[i].ToString("x2")); } return sb.ToString(); } } #region Http请求2 public static string HttpRequest2(string url, string Method, string ContentType, List ListHeader, Version ver, byte[] bytes, out string ErrorMessage) { try { ErrorMessage = ""; if (string.IsNullOrEmpty(ContentType) == true) ContentType = "application/x-www-form-urlencoded"; HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(url); ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11; myRequest.Method = Method; //GET,POST myRequest.ContentType = ContentType; myRequest.KeepAlive = true; //myRequest.UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; qihu theworld)"; //myRequest.Headers.Add("Accept-Language: zh-CN"); // myRequest.Headers["Pragma"] = "no-cache"; //禁用缓存 // myRequest.Headers["Cache-Control"] = "no-cache"; //禁用缓存 myRequest.Timeout = 3 * 60 * 1000; if (ver != null) myRequest.ProtocolVersion = ver; if (ListHeader != null) { foreach (var item in ListHeader) { myRequest.Headers.Add(item); } } if (bytes != null && bytes.Length > 0) { //myRequest.GetRequestStream().Write(bytes, 0, bytes.Length); Stream stream = myRequest.GetRequestStream(); stream.Write(bytes, 0, bytes.Length); stream.Close(); } else myRequest.ContentLength = 0; //获得接口返回值 HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse(); Stream myResponseStream = myResponse.GetResponseStream(); StreamReader reader = new StreamReader(myResponseStream, Encoding.UTF8); string content = reader.ReadToEnd(); reader.Close(); myResponseStream.Close(); myRequest.Abort(); myResponse.Close(); return content; } catch (Exception ex) { ErrorFollow.TraceWrite(ex.TargetSite.Name, ex.StackTrace, ex.Message); ErrorMessage = ex.Message; } return ""; } #endregion } public class SortContractResolver : DefaultContractResolver { protected override IList CreateProperties(Type type, MemberSerialization memberSerialization) { IList properties = base.CreateProperties(type, memberSerialization); return properties.OrderBy(x => x.PropertyName).ToList(); } } }