using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Services; using TradeManageNew; using NetLibrary; using System.Data; using TradeData; using TradeModel; using NetLibrary.Data; using NetLibrary.Express; using NetLibrary.ReportPrint; using System.Threading; using NetLibrary.Log; using NetLibrary.OnlineTrade; using ApiNew; using System.Text; using System.Web.Script.Serialization; using NPOI.HSSF.Record.Formula.Functions; using System.ComponentModel.DataAnnotations; namespace TradeManage { /// /// 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 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) { Pages.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; int UserId = Convert.ToInt32(Session["UserId"]); if (CompanyId == 1) return ""; 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 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); 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 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 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); 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 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) { Pages.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(); Shiper shiper = new Shiper { City = companymd.city, CompanyName = companymd.SendEnglishName, PersonName = companymd.SendEnglishName, PhoneNumber = companymd.Phone, PostalCode = companymd.PostCode, StateOrProvinceCode = companymd.provincecode, StreetLines = companymd.EnglishAddress, CountryCode = companymd.countycode }; fdorder.Shiper = shiper; fdorder.CustomerTransactionId = ordermd.PlatOrderCode; fdorder.PostId = new int?(PostId); 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 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 获取物流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) { Pages.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) { Pages.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 #region 返回订单Model [WebMethod(EnableSession = true)] public DT_OrderModel GetOrderModelNew(int OrderId) { Pages.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 [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; } 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 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"] = ""; // row["SKU2"] = "1*KM0207"; 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("../", ""); } 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 > 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("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) { Pages.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 = 0; 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; } #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 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 = 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() + ","; 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 = ordertemp.OrderBy(s => s.OrderLevel).ThenBy(s => s.OrderName).ThenBy(s => s.GoodsCode).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 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 DT_OrderModel ScanOrderPost333(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) { Pages.Login(base.Session); DD_OrderData data = new DD_OrderData(); int num = Convert.ToInt32(base.Session["CompanyId"]); int userId = Convert.ToInt32(base.Session["UserId"]); string str = Convert.ToString(base.Session["Name"]); DT_OrderModel model = new DT_OrderModel(); DT_TrackCodeScan scan = new DT_TrackCodeScan { PostId = new int?(Post), OrderId = new int?(OrderId), InName = str, InDate = new DateTime?(DateTime.Now), IsSure = 0, PostFee = 0, OldPostFee = 0, Weight = new int?(Weight), BagUserId = new int?(BagUserId), TrackCode = TrackCode }; if ((JoinOrderCode != null) && (JoinOrderCode != "")) { scan.OrderCode = JoinOrderCode; } else { scan.OrderCode = OrderCode; } scan.TrackId = new int?(TrackId); scan.Count = 1; scan.JoinOrderCode = JoinOrderCode; scan.IsCSM = new int?(IsCSM); data.SaveTrackCodeScan2(scan); model.PostState = 1; Pages.SaveLog(userId, "订单发货", scan.OrderCode + "发货扫描", OrderId); model.PostFee = 0; return model; } [WebMethod(EnableSession = true)] public List GetOrderGoodsListForTM(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; decimal goodssolid = 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 += "空包裹"; Pages.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 #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 [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; } if (shopids != null && shopids.Count > 0) shopids = shopids.Distinct().ToList(); 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_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) { //mdg.goodWeekAdFee = DataNew.GetGoodWeekAdSpend(mdg.GoodsId.Value, md.ShopId.Value); 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; } md.TotalAdFee = totalAdfee; 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 = ""; } } } //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; //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 - (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.Ad_Fee.Value + fmd.DR_SSFee.Value - fmd.md.Value - (md.TotalAdFee.HasValue ? md.TotalAdFee.Value : 0); 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; } [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> GetListOrderForTM2222222(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; } 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(130) * 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 - 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> 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(65) * TSolid; } if (TSolid > 0M) { YJTCFee = Convert.ToDecimal(65) * 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, 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); 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; 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; FedexFeeMd md = new FedexFeeMd { 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 string AddOrderGoodsSKUHWC(int CompanyId,string JoinOrderCode,List list,int StoreId) { Pages.Login(this.Session); string message = ""; if (list == null || list.Count == 0) return ""; var obj = new DD_OrderData(); int UserId = Convert.ToInt32(Session["UserId"]); // int CompanyId = Convert.ToInt32(Session["CompanyId"]); string Name = Convert.ToString(Session["Name"]); foreach (var md in list) { obj.UpdateOrderGoodsSKUForTM(0, CompanyId, Name, md.OrderId.Value, md.GoodsPrice, md.GoodsNum.Value, md.DetailId.Value, md.GoodsSKU, md.GoodsName, md.OldTypeCode, md.OldTypeDesc); // Pages.SaveLog(UserId, "订单日志", md.GoodsSKU + "修改分配", md.OrderId.Value); } PartOrderGoodsLockForHWC(CompanyId, 1, StoreId, list[0].OrderId.Value.ToString(), JoinOrderCode); return message; } #endregion #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) { Pages.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);//修改打印状态 Pages.SaveLog(UserId, "订单打印", "标记打印", md.OrderId.Value); } } } } #endregion public string GetOutCode() { Pages.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 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(); if (PrintState > -1) orderlist = DataNew.GetListDT_PrintOrderInfoForTM2(CompanyId, TCode, GoodsName, 0, Code, KWCode, IsSku, GM, PrintState, Param, PageIndex, PageSize, Sort, out RowCount); else orderlist = 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 (Ids == "") return ""; var GoodsList = DataNew.GetOrderGoodsInfos(Ids.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 (orderlist != null) { foreach (var md in orderlist) { 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 + ","; ginfo2 += gmd.GoodsNum + "x" + gmd.GoodsOldCode + ","; 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 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 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 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(); 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 var query = from s in ordertemp orderby s.OrderLevel, s.OrderName, s.GoodsCode, s.GoodsNum descending  //排序 select s; orderList2 = query.ToList(); //orderList2 = orderList2.OrderBy(s => s.OrderName).ToList(); //orderList2 = orderList2.OrderBy(s => s.GoodsCode).ToList(); //orderList2 = orderList2.OrderByDescending(s => s.GoodsNum).ToList(); // ErrorFollow.TraceWrite("GetOrderGoodsPostionList", "5", DateTime.Now.ToString("HH:mm:ss fff")); 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 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) { Pages.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; 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 (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) { Pages.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); //if (fee != "") //{ // return outError; //} //获取到的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 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 ""; } [WebMethod(EnableSession = true)] public void DeketeOrderSpare(int Id) { PagesNew.Login(base.Session); DataNew.Delete_SpareFee3(Id); } #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) { Pages.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 = "CMAP"; 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); } //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) { Pages.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 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 = 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.SKU = list2[0].GoodsCode; 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("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 全部订单锁定匹配货物(判断认购) [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 /// /// 修改认购匹配数 /// /// /// 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 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 #region 删除订单锁定 [WebMethod(EnableSession = true)] public void UpdateMateGoodsListForTM(List list) { Pages.Login(this.Session); int InUserId = Convert.ToInt32(Session["UserId"]); 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); Pages.SaveLog(InUserId, "删除订单锁定", md.OrderId.Value + "删除订单锁定", 0); } } if (orderids != "" || joinordercodes != "") { DataNew.UpdateUserMate(orderids.TrimEnd(','), joinordercodes.TrimEnd(',')); } } #endregion /// /// 回退认购匹配数 /// /// /// public void BackShopKC(List mlist) { if (mlist == null && mlist.Count==0) return; string ids = ""; 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); } } } } #region 删除订单锁定 [WebMethod(EnableSession = true)] public void UpdateMateGoodsForTM(int OrderId) { PagesNew.Login(this.Session); try { 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"); } catch(Exception ex) { } } #endregion #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 创建重发单订单 [WebMethod(EnableSession = true)] public int CheckCopyOrder(int OrderId) { Pages.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) { Pages.Login(this.Session); var obj = new DD_OrderData(); if (CheckCopyOrder(OrderId) > 0) { return -1; } int Id = DataNew.CopyOrderForTM2(OrderId); return Id; } #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 设置发货 [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 设置不允许发货 [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 [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"]); JC_ExpressService service = new JC_ExpressService(); JC_PostAddress address = new BaseService().GetAddressModel2(PostId); JC_ExpressPost expressModel = service.GetExpressModel(1, 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; } #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 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; } 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, "", out RowCount); resultModel.RowCount = RowCount; return resultModel; } #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 { MicrosoftExcel excel = new MicrosoftExcel(); DataTable tb = excel.ImportExcel(ServerFileName); StringBuilder sb = new StringBuilder(); if (tb.Columns.Contains("OrderId") == false) sb.AppendLine("导入模板错误, 列不存在: OrderId"); if (tb.Columns.Contains("trackcode") == false) sb.AppendLine("导入模板错误, 列不存在: trackcode"); if (tb.Columns.Contains("ActualWeightAmount") == false) sb.AppendLine("导入模板错误, 列不存在: ActualWeightAmount"); if (tb.Columns.Contains("ActualWeightUnits") == false) sb.AppendLine("导入模板错误, 列不存在: ActualWeightUnits"); if (tb.Columns.Contains("RatedWeightAmount") == false) sb.AppendLine("导入模板错误, 列不存在: RatedWeightAmount"); if (tb.Columns.Contains("RatedWeightUnits") == false) sb.AppendLine("导入模板错误, 列不存在: RatedWeightUnits"); if (tb.Columns.Contains("DimLength") == false) sb.AppendLine("导入模板错误, 列不存在: DimLength"); if (tb.Columns.Contains("DimWidth") == false) sb.AppendLine("导入模板错误, 列不存在: DimWidth"); if (tb.Columns.Contains("DimHeight") == false) sb.AppendLine("导入模板错误, 列不存在: DimHeight"); if (tb.Columns.Contains("DimDivisor") == false) sb.AppendLine("导入模板错误, 列不存在: DimDivisor"); if (tb.Columns.Contains("DimUnit") == false) sb.AppendLine("导入模板错误, 列不存在: DimUnit"); if (tb.Columns.Contains("ZoneCode") == false) sb.AppendLine("导入模板错误, 列不存在: ZoneCode"); if (tb.Columns.Contains("bigdifference") == false) sb.AppendLine("导入模板错误, 列不存在: bigdifference"); if (tb.Columns.Contains("result") == false) sb.AppendLine("导入模板错误, 列不存在: result"); if (tb.Columns.Contains("sku") == false) sb.AppendLine("导入模板错误, 列不存在: sku"); if (tb.Columns.Contains("indate") == false) sb.AppendLine("导入模板错误, 列不存在: indate"); if (tb.Columns.Contains("inname") == false) sb.AppendLine("导入模板错误, 列不存在: inname"); if (tb.Columns.Contains("fee1") == false) sb.AppendLine("导入模板错误, 列不存在: fee1"); if (tb.Columns.Contains("fee2") == false) sb.AppendLine("导入模板错误, 列不存在: fee2"); if (tb.Columns.Contains("fee3") == false) sb.AppendLine("导入模板错误, 列不存在: fee3"); if (tb.Columns.Contains("fee4") == false) sb.AppendLine("导入模板错误, 列不存在: fee4"); if (tb.Columns.Contains("fee5") == false) sb.AppendLine("导入模板错误, 列不存在: fee5"); if (tb.Columns.Contains("int1") == false) sb.AppendLine("导入模板错误, 列不存在: int1"); if (tb.Columns.Contains("int2") == false) sb.AppendLine("导入模板错误, 列不存在: int2"); if (tb.Columns.Contains("int3") == false) sb.AppendLine("导入模板错误, 列不存在: int3"); if (tb.Columns.Contains("str1") == false) sb.AppendLine("导入模板错误, 列不存在: str1"); if (tb.Columns.Contains("str2") == false) sb.AppendLine("导入模板错误, 列不存在: str2"); if (tb.Columns.Contains("str3") == false) sb.AppendLine("导入模板错误, 列不存在: str3"); if (tb.Columns.Contains("NetChargeAmount") == false) sb.AppendLine("导入模板错误, 列不存在: NetChargeAmount"); if (tb.Columns.Contains("estimatefee") == false) sb.AppendLine("导入模板错误, 列不存在: estimatefee"); if (sb.Length > 0) return sb.ToString(); tb.Columns["OrderId"].ColumnName = "OrderId"; tb.Columns["trackcode"].ColumnName = "trackcode"; tb.Columns["ActualWeightAmount"].ColumnName = "ActualWeightAmount"; tb.Columns["ActualWeightUnits"].ColumnName = "ActualWeightUnits"; tb.Columns["RatedWeightAmount"].ColumnName = "RatedWeightAmount"; tb.Columns["RatedWeightUnits"].ColumnName = "RatedWeightUnits"; tb.Columns["DimLength"].ColumnName = "DimLength"; tb.Columns["DimWidth"].ColumnName = "DimWidth"; tb.Columns["DimHeight"].ColumnName = "DimHeight"; tb.Columns["DimDivisor"].ColumnName = "DimDivisor"; tb.Columns["DimUnit"].ColumnName = "DimUnit"; tb.Columns["ZoneCode"].ColumnName = "ZoneCode"; tb.Columns["bigdifference"].ColumnName = "bigdifference"; tb.Columns["result"].ColumnName = "result"; tb.Columns["sku"].ColumnName = "sku"; tb.Columns["indate"].ColumnName = "indate"; tb.Columns["inname"].ColumnName = "inname"; tb.Columns["fee1"].ColumnName = "fee1"; tb.Columns["fee2"].ColumnName = "fee2"; tb.Columns["fee3"].ColumnName = "fee3"; tb.Columns["fee4"].ColumnName = "fee4"; tb.Columns["fee5"].ColumnName = "fee5"; tb.Columns["int1"].ColumnName = "int1"; tb.Columns["int2"].ColumnName = "int2"; tb.Columns["int3"].ColumnName = "int3"; tb.Columns["str1"].ColumnName = "str1"; tb.Columns["str2"].ColumnName = "str2"; tb.Columns["str3"].ColumnName = "str3"; tb.Columns["NetChargeAmount"].ColumnName = "NetChargeAmount"; tb.Columns["estimatefee"].ColumnName = "estimatefee"; int CompanyId = Convert.ToInt32(Session["SchId"]); int UserId = Convert.ToInt32(Session["UserId"]); //string UserName = Convert.ToInt32(Session["Name"]); //var ListClass= NetData.BaseService.GetListClass(CompanyId,0); //班级 //var ListKey= NetData.BaseService.GetListBaseCode("KeyName"); //var ListDept= NetData.BaseService.GetListDept(CompanyId); //部门 //var ListUser= NetData.BaseService.GetListUser(CompanyId,0); //教师 //var ListSub= NetData.BaseService.GetListSub(CompanyId,0); //学科 //var ListMajor= NetData.BaseService.GetListMajor(CompanyId); //专业 //var ListStudent= NetData.BaseService.GetListStudent2(0); //学生 var ListModel = new List(); foreach (DataRow row in tb.Rows) { int index = tb.Rows.IndexOf(row) + 2; var model = new DT_PostVote(); string OrderId = Convert.ToString(row["OrderId"]); if (string.IsNullOrEmpty(OrderId) == true) {sb.AppendLine("第" + index + "行OrderId错误, 不能为空");continue;} model.OrderId = DataConvert.ToInt32(OrderId); if (model.OrderId == null) {sb.AppendLine("第" + index + "行OrderId错误, 只能是数字格式:"+OrderId);continue;} string trackcode = Convert.ToString(row["trackcode"]); if (string.IsNullOrEmpty(trackcode) == true) {sb.AppendLine("第" + index + "行trackcode错误, 不能为空");continue;} model.trackcode = trackcode; string ActualWeightAmount = Convert.ToString(row["ActualWeightAmount"]); if (string.IsNullOrEmpty(ActualWeightAmount) == true) {sb.AppendLine("第" + index + "行ActualWeightAmount错误, 不能为空");continue;} model.ActualWeightAmount = DataConvert.ToDecimal(ActualWeightAmount); if (model.ActualWeightAmount == null) {sb.AppendLine("第" + index + "行ActualWeightAmount错误, 只能是浮点数格式:"+ActualWeightAmount);continue;} string ActualWeightUnits = Convert.ToString(row["ActualWeightUnits"]); if (string.IsNullOrEmpty(ActualWeightUnits) == true) {sb.AppendLine("第" + index + "行ActualWeightUnits错误, 不能为空");continue;} model.ActualWeightUnits = ActualWeightUnits; string RatedWeightAmount = Convert.ToString(row["RatedWeightAmount"]); if (string.IsNullOrEmpty(RatedWeightAmount) == true) {sb.AppendLine("第" + index + "行RatedWeightAmount错误, 不能为空");continue;} model.RatedWeightAmount = DataConvert.ToDecimal(RatedWeightAmount); if (model.RatedWeightAmount == null) {sb.AppendLine("第" + index + "行RatedWeightAmount错误, 只能是浮点数格式:"+RatedWeightAmount);continue;} string RatedWeightUnits = Convert.ToString(row["RatedWeightUnits"]); if (string.IsNullOrEmpty(RatedWeightUnits) == true) {sb.AppendLine("第" + index + "行RatedWeightUnits错误, 不能为空");continue;} model.RatedWeightUnits = RatedWeightUnits; string DimLength = Convert.ToString(row["DimLength"]); if (string.IsNullOrEmpty(DimLength) == true) {sb.AppendLine("第" + index + "行DimLength错误, 不能为空");continue;} model.DimLength = DataConvert.ToDecimal(DimLength); if (model.DimLength == null) {sb.AppendLine("第" + index + "行DimLength错误, 只能是浮点数格式:"+DimLength);continue;} string DimWidth = Convert.ToString(row["DimWidth"]); if (string.IsNullOrEmpty(DimWidth) == true) {sb.AppendLine("第" + index + "行DimWidth错误, 不能为空");continue;} model.DimWidth = DataConvert.ToDecimal(DimWidth); if (model.DimWidth == null) {sb.AppendLine("第" + index + "行DimWidth错误, 只能是浮点数格式:"+DimWidth);continue;} string DimHeight = Convert.ToString(row["DimHeight"]); if (string.IsNullOrEmpty(DimHeight) == true) {sb.AppendLine("第" + index + "行DimHeight错误, 不能为空");continue;} model.DimHeight = DataConvert.ToDecimal(DimHeight); if (model.DimHeight == null) {sb.AppendLine("第" + index + "行DimHeight错误, 只能是浮点数格式:"+DimHeight);continue;} string DimDivisor = Convert.ToString(row["DimDivisor"]); if (string.IsNullOrEmpty(DimDivisor) == true) {sb.AppendLine("第" + index + "行DimDivisor错误, 不能为空");continue;} model.DimDivisor = DataConvert.ToDecimal(DimDivisor); if (model.DimDivisor == null) {sb.AppendLine("第" + index + "行DimDivisor错误, 只能是浮点数格式:"+DimDivisor);continue;} string DimUnit = Convert.ToString(row["DimUnit"]); if (string.IsNullOrEmpty(DimUnit) == true) {sb.AppendLine("第" + index + "行DimUnit错误, 不能为空");continue;} model.DimUnit = DimUnit; string ZoneCode = Convert.ToString(row["ZoneCode"]); if (string.IsNullOrEmpty(ZoneCode) == true) {sb.AppendLine("第" + index + "行ZoneCode错误, 不能为空");continue;} model.ZoneCode = DataConvert.ToDecimal(ZoneCode); if (model.ZoneCode == null) {sb.AppendLine("第" + index + "行ZoneCode错误, 只能是浮点数格式:"+ZoneCode);continue;} string bigdifference = Convert.ToString(row["bigdifference"]); if (string.IsNullOrEmpty(bigdifference) == true) {sb.AppendLine("第" + index + "行bigdifference错误, 不能为空");continue;} model.bigdifference = DataConvert.ToDecimal(bigdifference); if (model.bigdifference == null) {sb.AppendLine("第" + index + "行bigdifference错误, 只能是浮点数格式:"+bigdifference);continue;} string result = Convert.ToString(row["result"]); if (string.IsNullOrEmpty(result) == true) {sb.AppendLine("第" + index + "行result错误, 不能为空");continue;} model.result = result; string sku = Convert.ToString(row["sku"]); if (string.IsNullOrEmpty(sku) == true) {sb.AppendLine("第" + index + "行sku错误, 不能为空");continue;} model.sku = sku; string indate = Convert.ToString(row["indate"]); if (string.IsNullOrEmpty(indate) == true) {sb.AppendLine("第" + index + "行indate错误, 不能为空");continue;} model.indate = DataConvert.ToDateTime(indate); if (model.indate == null) {sb.AppendLine("第" + index + "行indate错误, 只能是日期格式:"+indate);continue;} string inname = Convert.ToString(row["inname"]); if (string.IsNullOrEmpty(inname) == true) {sb.AppendLine("第" + index + "行inname错误, 不能为空");continue;} model.inname = inname; string fee1 = Convert.ToString(row["fee1"]); if (string.IsNullOrEmpty(fee1) == true) {sb.AppendLine("第" + index + "行fee1错误, 不能为空");continue;} model.fee1 = DataConvert.ToDecimal(fee1); if (model.fee1 == null) {sb.AppendLine("第" + index + "行fee1错误, 只能是浮点数格式:"+fee1);continue;} string fee2 = Convert.ToString(row["fee2"]); if (string.IsNullOrEmpty(fee2) == true) {sb.AppendLine("第" + index + "行fee2错误, 不能为空");continue;} model.fee2 = DataConvert.ToDecimal(fee2); if (model.fee2 == null) {sb.AppendLine("第" + index + "行fee2错误, 只能是浮点数格式:"+fee2);continue;} string fee3 = Convert.ToString(row["fee3"]); if (string.IsNullOrEmpty(fee3) == true) {sb.AppendLine("第" + index + "行fee3错误, 不能为空");continue;} model.fee3 = DataConvert.ToDecimal(fee3); if (model.fee3 == null) {sb.AppendLine("第" + index + "行fee3错误, 只能是浮点数格式:"+fee3);continue;} string fee4 = Convert.ToString(row["fee4"]); if (string.IsNullOrEmpty(fee4) == true) {sb.AppendLine("第" + index + "行fee4错误, 不能为空");continue;} model.fee4 = DataConvert.ToDecimal(fee4); if (model.fee4 == null) {sb.AppendLine("第" + index + "行fee4错误, 只能是浮点数格式:"+fee4);continue;} string fee5 = Convert.ToString(row["fee5"]); if (string.IsNullOrEmpty(fee5) == true) {sb.AppendLine("第" + index + "行fee5错误, 不能为空");continue;} model.fee5 = DataConvert.ToDecimal(fee5); if (model.fee5 == null) {sb.AppendLine("第" + index + "行fee5错误, 只能是浮点数格式:"+fee5);continue;} string int1 = Convert.ToString(row["int1"]); if (string.IsNullOrEmpty(int1) == true) {sb.AppendLine("第" + index + "行int1错误, 不能为空");continue;} model.int1 = DataConvert.ToInt32(int1); if (model.int1 == null) {sb.AppendLine("第" + index + "行int1错误, 只能是数字格式:"+int1);continue;} string int2 = Convert.ToString(row["int2"]); if (string.IsNullOrEmpty(int2) == true) {sb.AppendLine("第" + index + "行int2错误, 不能为空");continue;} model.int2 = DataConvert.ToInt32(int2); if (model.int2 == null) {sb.AppendLine("第" + index + "行int2错误, 只能是数字格式:"+int2);continue;} string int3 = Convert.ToString(row["int3"]); if (string.IsNullOrEmpty(int3) == true) {sb.AppendLine("第" + index + "行int3错误, 不能为空");continue;} model.int3 = DataConvert.ToInt32(int3); if (model.int3 == null) {sb.AppendLine("第" + index + "行int3错误, 只能是数字格式:"+int3);continue;} string str1 = Convert.ToString(row["str1"]); if (string.IsNullOrEmpty(str1) == true) {sb.AppendLine("第" + index + "行str1错误, 不能为空");continue;} model.str1 = str1; string str2 = Convert.ToString(row["str2"]); if (string.IsNullOrEmpty(str2) == true) {sb.AppendLine("第" + index + "行str2错误, 不能为空");continue;} model.str2 = str2; string str3 = Convert.ToString(row["str3"]); if (string.IsNullOrEmpty(str3) == true) {sb.AppendLine("第" + index + "行str3错误, 不能为空");continue;} model.str3 = str3; string NetChargeAmount = Convert.ToString(row["NetChargeAmount"]); if (string.IsNullOrEmpty(NetChargeAmount) == true) {sb.AppendLine("第" + index + "行NetChargeAmount错误, 不能为空");continue;} model.NetChargeAmount = DataConvert.ToDecimal(NetChargeAmount); if (model.NetChargeAmount == null) {sb.AppendLine("第" + index + "行NetChargeAmount错误, 只能是浮点数格式:"+NetChargeAmount);continue;} string estimatefee = Convert.ToString(row["estimatefee"]); if (string.IsNullOrEmpty(estimatefee) == true) {sb.AppendLine("第" + index + "行estimatefee错误, 不能为空");continue;} model.estimatefee = DataConvert.ToDecimal(estimatefee); if (model.estimatefee == null) {sb.AppendLine("第" + index + "行estimatefee错误, 只能是浮点数格式:"+estimatefee);continue;} ListModel.Add(model); } if (sb.Length > 0) return sb.ToString(); foreach (var item in ListModel) { //item.InUserName = UserName; //item.InUserID = UserId; } return ""; } 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 返回订单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 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 DT_OrderFees GetModel_OrderFee(int orderid) { PagesNew.Login(this.Session); var md = DataNew.GetModel_OrderFee(orderid); return md; } #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 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"]); int ind = 0; 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 = ""; string postinfo = tb.Columns.Contains("买家指定物流") ? tb.Rows[i]["买家指定物流"].ToString().Trim() : ""; md.PostInfo = 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) { ind++; 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 string UpdateOrderAddr2(DT_OrderModel Model) { Pages.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); Pages.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 void GetModel_OrderFeeML() { PagesNew.Login(this.Session); DataNew.GetModel_OrderFeeML(); } #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 void ComputerOrderFee_Order(int orderid) { PagesNew.Login(this.Session); DataNew.ComputerOrderFee_Order(orderid); } #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(); TradeManageNew.YCService.Ec obj = new TradeManageNew.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 = "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); } omd.name = md.RevName; if (md.RevMoblie.Contains("ext")) { var len = md.RevMoblie.IndexOf("ext"); omd.cell_phone = md.RevMoblie.Substring(0, len - 1); } omd.email = md.RevMail; omd.zipcode = md.RevPostCode; omd.platform_shop = md.ShopName; List itemlist = new List(); List relist = new List(); foreach (var gmd in md.GoodsList) { YC_Items imd = new YC_Items(); imd.product_sku = gmd.TypeCode; imd.reference_no = ""; imd.product_declared_value = 5; imd.product_name_en = gmd.GoodsEnglisgName; imd.product_name = gmd.GoodsName; imd.quantity = gmd.GoodsNum; imd.ref_tnx = ""; imd.ref_item_id = ""; imd.ref_buyer_id = ""; itemlist.Add(imd); YC_Report ymd = new YC_Report(); ymd.product_title = gmd.GoodsEnglisgName; ymd.product_title_en = gmd.GoodsName; ymd.product_quantity = gmd.GoodsNum; ymd.product_declared_value = 5; if (gmd.Weight != null) ymd.product_weight = Convert.ToInt32(gmd.Weight.Value); else ymd.product_weight = 100; relist.Add(ymd); } omd.items = itemlist; omd.report = relist; string ojson = JsonConvert.Serialize(omd); string re = obj.callService(ojson, "d45efccfc1a9e3a3199c3abcc37d9ce6", "b28a8987bea38085e14194a8970c8947", "createOrder"); 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() + "条"; } } #region 删除订单 [WebMethod(EnableSession = true)] public void DeleteOrderForHWC(string OrderIds) { Pages.Login(this.Session); var obj = new DD_OrderData(); int InUserId = Convert.ToInt32(Session["UserId"]); if (OrderIds != "") { DataNew.DeleteOrderForHWC(OrderIds.Trim(',')); Pages.SaveLog(InUserId, "删除订单", OrderIds + "删除订单", 0); } } #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(); TradeManageNew.YCService.Ec obj = new TradeManageNew.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 void UpdateSyncOrder(string OrderCode) { Pages.Login(this.Session); var obj = new DD_OrderData(); DataNew.DoApiOrders(OrderCode.Trim()); } #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 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 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 } }