using NetLibrary.Data;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using TradeData;
using NetLibrary;
using TradeModel;
using NetLibrary.Express;
using System.Web.Script.Serialization;
using NetLibrary.ReportPrint;
using NetLibrary.OnlineTrade;
using System.Text;
using System.Text.RegularExpressions;
namespace TradeManage.DingDan
{
///
/// DD_OrderService 的摘要说明
///
[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_OrderService : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
#region 查询物流跟踪信息
[WebMethod(EnableSession = true)]
public JsonModel> GetOrderPostInfo(int DeptId, int PlatType, int ShopId,int DateType, DateTime? SDate, DateTime? EDate, string Country, string OrderCode, string TrackCode, int OutDays, int IsDetail,int LogisticsId, int PostId, int State,int Days,int TJ, int PageIndex, int PageSize, string Sort)
{
Pages.Login(this.Session);
var obj = new DD_OrderData();
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
RefParameterCollection Param = new RefParameterCollection();
if (Days > 0)
{
if (TJ == 1)
{
Param.Add("a.State", "<>", 2, DbType.Int32);
Param.Add("a.ScanDate", "<=", DateTime.Now.AddDays(Days*-1), DbType.DateTime);
}
else if (TJ ==2)
{
Param.Add("a.PostDate1", "is", null, DbType.DateTime);
Param.Add("a.ScanDate", "<=", DateTime.Now.AddDays(Days * -1), DbType.DateTime);
}
else if (TJ == 3)
{
Param.Add("a.PostDate2", "is", null, DbType.DateTime);
Param.Add("a.ScanDate", "<=", DateTime.Now.AddDays(Days * -1), DbType.DateTime);
}
else if (TJ == 4)
{
Param.Add("a.PostDate3", "is", null, DbType.DateTime);
Param.Add("a.ScanDate", "<=", DateTime.Now.AddDays(Days * -1), DbType.DateTime);
}
}
if (State > -1 && State != 7 && State != 6)
Param.Add("a.State", "=", State, DbType.Int32);
if (State == 7)
{
Param.Add("a.State", "<>", 2, DbType.Int32);
Param.Add("DATEDIFF(day,a.ScanDate,getdate())-isnull(c.DoneDays,0)", ">=", 0, DbType.Int32);
}
else
if (State == 6)
{
Param.Add("a.State", "<>", 2, DbType.Int32);
Param.Add("DATEDIFF(day,a.ScanDate,getdate())-isnull(c.DoneDays,0)-10", ">=", 0, DbType.Int32);
}
if (LogisticsId>0)
Param.Add("c.LogisticsId", "=", LogisticsId, DbType.Int32);
if (PostId>0)
Param.Add("a.PostId", "=", PostId, DbType.Int32);
if (DateType == 1)
{
if (SDate!=null)
Param.Add("a.ScanDate", ">=", SDate, DbType.DateTime);
if (EDate!= null)
Param.Add("a.ScanDate", "<=", EDate, DbType.DateTime);
}
else
if (DateType == 2)
{
if (SDate != null)
Param.Add("a.DoneDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.DoneDate", "<=", EDate, DbType.DateTime);
}
else
if (DateType == 3)
{
if (SDate != null)
Param.Add("a.PostDate1", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.PostDate1", "<=", EDate, DbType.DateTime);
}
else
if (DateType == 4)
{
if (SDate != null)
Param.Add("a.PostDate2", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.PostDate2", "<=", EDate, DbType.DateTime);
}
else
if (DateType == 5)
{
if (SDate != null)
Param.Add("a.PostDate2", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.PostDate2", "<=", EDate, DbType.DateTime);
}
if (DeptId > 0)
Param.Add("b.DeptId", "=", DeptId, DbType.Int32);
if (PlatType > 0)
Param.Add("b.PlatType", "=", PlatType, DbType.Int32);
if (ShopId > 0)
Param.Add("a.ShopId", "=", ShopId, DbType.Int32);
if (OrderCode.Trim() != "")
{
Param.Add("(a.OrderCode", "like", OrderCode.Trim(), DbType.String);
Param.Add("a.JoinOrderCode", "like", OrderCode.Trim(), "or", ")", DbType.String);
}
if (TrackCode.Trim() != "")
{
Param.Add("a.TrackCode", "like", TrackCode.Trim(), DbType.String);
}
if (Country.Trim() != "")
{
Param.Add("a.CountryName", "like", Country.Trim(), DbType.String);
}
JsonModel> resultModel = new JsonModel>();
int RowCount = 0;
//string Sort = "orderid desc";
resultModel.DataSource = obj.GetListDT_PostInfo("", Param, PageIndex, PageSize, Sort, out RowCount);
resultModel.RowCount = RowCount;
if (resultModel.DataSource != null)
{
string Ids = "";
if (resultModel.DataSource != null)
{
foreach (var md in resultModel.DataSource)
{
Ids += md.Id.ToString() + ",";
}
}
if (Ids != "")
{
var PostInfolist = obj.GetPostInfoList(Ids.Trim(','));
if (PostInfolist != null && PostInfolist.Count > 0)
{
foreach (var md in resultModel.DataSource)
{
var emd = PostInfolist.Find(n => n.Id == md.Id);
if (emd != null)
{
if (emd.PostInfo != null)
{
md.PostInfo = emd.PostInfo.Replace("\n", "
");
md.PostInfo00 = emd.PostInfo.Replace("
", "\n");
}
else
{
md.PostInfo ="";
md.PostInfo00 = "";
}
if (emd.PostInfo1 != null)
{
md.PostInfo1 = emd.PostInfo1.Replace("\n", "
");
md.PostInfo11 = emd.PostInfo1.Replace("
", "\n");
}
else
{
md.PostInfo1 = "";
md.PostInfo11 = "";
}
if (emd.PostInfo2 != null)
{
md.PostInfo2 = emd.PostInfo2.Replace("\n", "
");
md.PostInfo22 = emd.PostInfo2.Replace("
", "\n");
}
else
{
md.PostInfo2 = "";
md.PostInfo22 = "";
}
}
}
}
}
}
return resultModel;
}
#endregion
#region 查询订单
[WebMethod(EnableSession = true)]
public JsonModel> GetListOrder(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 IsDetail, int HBOrder, int PageIndex, int PageSize)
{
Pages.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 (OutDays > 0)
{
Param.Add("a.OrderOutDate", "<=", DateTime.Today.AddDays(OutDays), 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 > -1)
{
Param.Add("a.State", ">",0, DbType.Int32);
Param.Add("a.PostState", "=", State, 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("(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("OrderCode", "=", Name,"or", DbType.String);
Param.Add("a.PlatOrderCode", "=", "C"+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;
}
resultModel.DataSource = obj.GetListDT_OrderInfo(CompanyId, GoodsName.Trim(), SKU.Trim(), IsSku, Param, PageIndex, PageSize, Sort, out RowCount);
resultModel.RowCount = RowCount;
if (IsDetail == 1 && resultModel.DataSource != null)
{
string Ids = "";
foreach (var md in resultModel.DataSource)
{
Ids += md.OrderId.ToString() + ",";
}
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> GetListOrderForTM(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)
{
Pages.Login(this.Session);
var obj = new DD_OrderData();
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
RefParameterCollection Param = new RefParameterCollection();
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);
Param.Add("isnull(a.IsSDan,0)", "=", IsSD, DbType.Int32);
if (SaleState > 0)
Param.Add("a.SaleState", "=", SaleState, DbType.Int32);
if (WLId > 0)
Param.Add("a.LogisticsId", "=", WLId, DbType.Int32);
if (DeptId > 0)
Param.Add("c.DeptId", "=", DeptId, DbType.Int32);
if (PlatType > 0)
Param.Add("a.PlatId", "=", PlatType, DbType.Int32);
if (ShopId > 0)
Param.Add("a.ShopId", "=", ShopId, DbType.Int32);
if (DateType == 1)
{
if (SDate != null)
Param.Add("a.OrderDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.OrderDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
else
if (DateType == 2)
{
if (SDate != null)
Param.Add("a.InDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.InDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
else
if (DateType == 3)
{
if (SDate != null)
Param.Add("a.PrintDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.PrintDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
else
if (DateType == 4)
{
if (SDate != null)
Param.Add("a.PostDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.PostDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
else
if (DateType == 5)
{
if (SDate != null)
Param.Add("a.OrderOutDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.OrderOutDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
if (OutDays > 0)
{
Param.Add("a.OrderOutDate", "<=", DateTime.Now.AddDays(OutDays), DbType.DateTime);
Param.Add("a.OrderOutDate", ">=", DateTime.Now, DbType.DateTime);
}
if (MateState > -1)
Param.Add("a.MateState", "=", MateState, DbType.Int32);
if (MoneyState > -1)
Param.Add("a.MoneyState", "=", MoneyState, DbType.Int32);
if (PrintState > -1)
Param.Add("a.PrintState", "=", PrintState, DbType.Int32);
if (State == 3)
Param.Add("a.State", "=", 2, DbType.Int32);
else if (State == 4)
Param.Add("a.State", "=", 3, DbType.Int32);
else if (State == 5)
{
Param.Add("a.State", "=", 1, DbType.Int32);
Param.Add("a.MoneyState", "=", 1, DbType.Int32);
}
else if (State == 1)
{
//Param.Add("a.State", "=", 2, DbType.Int32);
Param.Add("a.PostState", "=", 1, DbType.Int32);
}
else if (State == 2)
{
Param.Add("a.State", "<", 3, DbType.Int32);
Param.Add("a.PostState", "=", 2, DbType.Int32);
}
else if (State == 0)
{
//Param.Add("a.State", "=", 2, DbType.Int32);
Param.Add("a.State", "=", 1, DbType.Int32);
}
else
Param.Add("a.State", ">", 0, DbType.Int32);
if (HBOrder == 1)
Param.Add("a.IsJoin", "=", 1, DbType.Int32);
if (IsError == 1)
{
Param.Add("(a.SendAddr", ">", 0, DbType.Int32);
Param.Add("a.IsLeaveWord", "=", 1, "or", ")", DbType.Int32);
}
if (IsE == 1)
{
Param.Add("a.PostState", "=", 2, DbType.Int32);
}
if (IsE == 0)
{
Param.Add("a.PostState", "<", 2, DbType.Int32);
}
string TCode = "";
if (Name != "")
{
Name = Name.Trim();
if (TjType == 1)
{
Param.Add("(a.PlatOrderCode", "like", Name, DbType.String);
Param.Add("OrderCode", "like", Name, "or", DbType.String);
Param.Add("a.JoinOrderCode", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 2)
{
Param.Add("a.RevName", "like", Name, DbType.String);
}
else if (TjType == 3)
{
Param.Add("a.RevPhone", "like", Name, DbType.String);
}
else if (TjType == 4)
{
Param.Add("(a.RevCountry", "=", Name, DbType.String);
Param.Add("a.CountryName", "=", Name, "or", DbType.String);
Param.Add("a.CountryCode", "=", Name, "or", ")", DbType.String);
}
else if (TjType == 5)
{
Param.Add("a.RevPostCode", "=", Name, DbType.String);
}
else if (TjType == 6)
{
Param.Add("(a.RevAddr", "like", Name, DbType.String);
Param.Add("a.RevProvince", "like", Name, "or", DbType.String);
Param.Add("a.RevCity", "like", Name, "or", DbType.String);
Param.Add("a.RevArea", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 9)
{
Param.Add("(a.ErrorInfo", "like", Name, DbType.String);
Param.Add("a.PostError", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 10)
{
//Param.Add("dbo.getOrderTrackCode(a.OrderId,0)", "like", Name, DbType.String);
TCode = Name;
}
else if (TjType == 11)
{
Param.Add("a.CustomID", "=", Name, DbType.String);
}
else if (TjType == 12)
{
Param.Add("a.RevMail", "=", Name, DbType.String);
}
}
if (IsSku == 0)
Param.Add("a.FPDate", "is", null, DbType.String);
else if (IsSku == 1)
Param.Add("a.FPDate", "is not", null, DbType.String);
JsonModel> resultModel = new JsonModel>();
int RowCount = 0;
//string Sort = "orderid desc";
string GoodsName = "";
string SKU = "";
if (TjType == 7 && Name != "")
{
GoodsName = Name;
}
else
if (TjType == 8 && Name != "")
{
SKU = Name;
}
if (SFLY > 0)
{
if (SFLY == 1)
{
resultModel.DataSource = obj.GetListDT_OrderInfoForTM6(CompanyId, GoodsName.Trim(), SKU.Trim(), TCode, -1, IsDH, Param, PageIndex, PageSize, Sort, out RowCount);
}
if (SFLY == 2)
{
resultModel.DataSource = obj.GetListDT_OrderInfoForTM7(CompanyId, GoodsName.Trim(), SKU.Trim(), TCode, -1, IsDH, Param, PageIndex, PageSize, Sort, out RowCount);
}
}
else
{
if (State == 0 || State == 2)
resultModel.DataSource = obj.GetListDT_OrderInfoForTM1(CompanyId, GoodsName.Trim(), SKU.Trim(), TCode, -1, IsDH, Param, PageIndex, PageSize, Sort, out RowCount);
else
resultModel.DataSource = obj.GetListDT_OrderInfoForTM(CompanyId, GoodsName.Trim(), SKU.Trim(), TCode, -1, IsDH, Param, PageIndex, PageSize, Sort, out RowCount);
}
resultModel.RowCount = RowCount;
string Ids = "";
if (resultModel.DataSource != null)
{
foreach (var md in resultModel.DataSource)
{
Ids += md.OrderId.ToString() + ",";
}
}
if (Ids != "")
{
var errorlist = obj.GetErrorList(Ids.Trim(','));
if (errorlist != null && errorlist.Count > 0)
{
foreach (var md in resultModel.DataSource)
{
var emd = errorlist.Find(n => n.OrderId == md.OrderId);
if (emd != null)
{
md.ErrorInfo = emd.ErrorInfo;
}
}
}
}
if (IsDetail == 1 && resultModel.DataSource != null)
{
if (Ids != "")
{
var list1 = obj.GetOrderGoodsList(Ids.Trim(','));
var listTrack = obj.GetTrackCodeApplyList(Ids.Trim(','));
if (list1 != null)
{
foreach (var md in resultModel.DataSource)
{
var list2 = list1.FindAll(n => n.OrderId == md.OrderId);
if (list2 != null)
{
md.GoodsList = list2;
}
}
}
if (listTrack != null)
{
foreach (var md in resultModel.DataSource)
{
var list3 = new List();
if (md.JoinOrderCode != null && md.JoinOrderCode != "")
list3 = listTrack.FindAll(n => n.OrderCode == md.JoinOrderCode);
else
list3 = listTrack.FindAll(n => n.OrderId == md.OrderId);
if (list3 != null && list3.Count > 0)
{
string trackinfo = "";
string TrackCode = "";
foreach (var md1 in list3)
{
string blank = "";
if (md1.TrackType == 3)
blank = "[空包裹]";
if (md1.Weight != null)
{
string dd = "";
if (md1.ScanDate != null)
dd = "扫描时间:" + md1.ScanDate.Value.ToString("yyyy-MM-dd HH:mm");
trackinfo += md1.TrackCode + blank + "重量" + md1.Weight.ToString() + "g" + dd + "
";
}
else
trackinfo += md1.TrackCode + blank + "
";
if (TrackCode == "")
TrackCode = md1.TrackCode;
}
md.TrackInfo = trackinfo;
md.TrackCode = TrackCode;
}
}
}
}
}
return resultModel;
}
#endregion
#region 查询订单
[WebMethod(EnableSession = true)]
public JsonModel> GetListOrderForTM3(int DeptId,int StoreId, 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)
{
Pages.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);
Param.Add("isnull(a.IsSDan,0)", "=", IsSD, DbType.Int32);
if (SaleState > 0)
Param.Add("a.SaleState", "=", SaleState, DbType.Int32);
if (WLId > 0)
Param.Add("a.LogisticsId", "=", WLId, DbType.Int32);
if (DeptId > 0)
Param.Add("c.DeptId", "=", DeptId, DbType.Int32);
if (PlatType > 0)
Param.Add("a.PlatId", "=", PlatType, DbType.Int32);
if (ShopId > 0)
Param.Add("a.ShopId", "=", ShopId, DbType.Int32);
if (DateType == 1)
{
if (SDate != null)
Param.Add("a.OrderDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.OrderDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
else
if (DateType == 2)
{
if (SDate != null)
Param.Add("a.InDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.InDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
else
if (DateType == 3)
{
if (SDate != null)
Param.Add("a.PrintDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.PrintDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
else
if (DateType == 4)
{
if (SDate != null)
Param.Add("a.PostDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.PostDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
else
if (DateType == 5)
{
if (SDate != null)
Param.Add("a.OrderOutDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.OrderOutDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
if (OutDays > 0)
{
Param.Add("a.OrderOutDate", "<=", DateTime.Now.AddDays(OutDays), DbType.DateTime);
Param.Add("a.OrderOutDate", ">=", DateTime.Now, DbType.DateTime);
}
if (MateState > -1)
Param.Add("a.MateState", "=", MateState, DbType.Int32);
if (MoneyState > -1)
Param.Add("a.MoneyState", "=", MoneyState, DbType.Int32);
if (PrintState > -1)
Param.Add("a.PrintState", "=", PrintState, DbType.Int32);
if (State == 3)
Param.Add("a.State", "=", 2, DbType.Int32);
else if (State == 4)
Param.Add("a.State", "=", 3, DbType.Int32);
else if (State == 5)
{
Param.Add("a.State", "=", 1, DbType.Int32);
Param.Add("a.MoneyState", "=", 1, DbType.Int32);
}
else if (State == 1)
{
//Param.Add("a.State", "=", 2, DbType.Int32);
Param.Add("a.PostState", "=", 1, DbType.Int32);
}
else if (State == 2)
{
Param.Add("a.State", "<", 3, DbType.Int32);
Param.Add("a.PostState", "=", 2, DbType.Int32);
}
else if (State == 0)
{
//Param.Add("a.State", "=", 2, DbType.Int32);
Param.Add("a.State", "=", 1, DbType.Int32);
}
else
Param.Add("a.State", ">", 0, DbType.Int32);
if (HBOrder == 1)
Param.Add("a.IsJoin", "=", 1, DbType.Int32);
if (IsError == 1)
{
Param.Add("(a.SendAddr", ">", 0, DbType.Int32);
Param.Add("a.IsLeaveWord", "=", 1, "or", ")", DbType.Int32);
}
if (IsE == 1)
{
Param.Add("a.PostState", "=", 2, DbType.Int32);
}
if (IsE == 0)
{
Param.Add("a.PostState", "<", 2, DbType.Int32);
}
string TCode = "";
if (Name != "")
{
Name = Name.Trim();
if (TjType == 1)
{
Param.Add("(a.PlatOrderCode", "like", Name, DbType.String);
Param.Add("OrderCode", "like", Name, "or", DbType.String);
Param.Add("a.JoinOrderCode", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 2)
{
Param.Add("a.RevName", "like", Name, DbType.String);
}
else if (TjType == 3)
{
Param.Add("a.RevPhone", "like", Name, DbType.String);
}
else if (TjType == 4)
{
Param.Add("(a.RevCountry", "=", Name, DbType.String);
Param.Add("a.CountryName", "=", Name, "or", DbType.String);
Param.Add("a.CountryCode", "=", Name, "or", ")", DbType.String);
}
else if (TjType == 5)
{
Param.Add("a.RevPostCode", "=", Name, DbType.String);
}
else if (TjType == 6)
{
Param.Add("(a.RevAddr", "like", Name, DbType.String);
Param.Add("a.RevProvince", "like", Name, "or", DbType.String);
Param.Add("a.RevCity", "like", Name, "or", DbType.String);
Param.Add("a.RevArea", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 9)
{
Param.Add("(a.ErrorInfo", "like", Name, DbType.String);
Param.Add("a.PostError", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 10)
{
//Param.Add("dbo.getOrderTrackCode(a.OrderId,0)", "like", Name, DbType.String);
TCode = Name;
}
else if (TjType == 11)
{
Param.Add("a.CustomID", "=", Name, DbType.String);
}
else if (TjType == 12)
{
Param.Add("a.RevMail", "=", Name, DbType.String);
}
}
if (IsSku == 0)
Param.Add("a.FPDate", "is", null, DbType.String);
else if (IsSku == 1)
Param.Add("a.FPDate", "is not", null, DbType.String);
JsonModel> resultModel = new JsonModel>();
int RowCount = 0;
//string Sort = "orderid desc";
string GoodsName = "";
string SKU = "";
if (TjType == 7 && Name != "")
{
GoodsName = Name;
}
else
if (TjType == 8 && Name != "")
{
SKU = Name;
}
if (SFLY > 0)
{
if (SFLY == 1)
{
resultModel.DataSource = obj.GetListDT_OrderInfoForTM6(CompanyId, GoodsName.Trim(), SKU.Trim(), TCode, -1, IsDH, Param, PageIndex, PageSize, Sort, out RowCount);
}
if (SFLY == 2)
{
resultModel.DataSource = obj.GetListDT_OrderInfoForTM7(CompanyId, GoodsName.Trim(), SKU.Trim(), TCode, -1, IsDH, Param, PageIndex, PageSize, Sort, out RowCount);
}
}
else
{
if (State == 0 || State == 2)
resultModel.DataSource = obj.GetListDT_OrderInfoForTM1(CompanyId, GoodsName.Trim(), SKU.Trim(), TCode, -1, IsDH, Param, PageIndex, PageSize, Sort, out RowCount);
else
resultModel.DataSource = obj.GetListDT_OrderInfoForTM(CompanyId, GoodsName.Trim(), SKU.Trim(), TCode, -1, IsDH, Param, PageIndex, PageSize, Sort, out RowCount);
}
resultModel.RowCount = RowCount;
string Ids = "";
if (resultModel.DataSource != null)
{
foreach (var md in resultModel.DataSource)
{
Ids += md.OrderId.ToString() + ",";
}
}
if (Ids != "")
{
var errorlist = obj.GetErrorList(Ids.Trim(','));
if (errorlist != null && errorlist.Count > 0)
{
foreach (var md in resultModel.DataSource)
{
var emd = errorlist.Find(n => n.OrderId == md.OrderId);
if (emd != null)
{
md.ErrorInfo = emd.ErrorInfo;
}
}
}
}
if (IsDetail == 1 && resultModel.DataSource != null)
{
if (Ids != "")
{
var list1 = obj.GetOrderGoodsList(Ids.Trim(','));
var listTrack = obj.GetTrackCodeApplyList(Ids.Trim(','));
if (list1 != null)
{
foreach (var md in resultModel.DataSource)
{
var list2 = list1.FindAll(n => n.OrderId == md.OrderId);
if (list2 != null)
{
md.GoodsList = list2;
}
}
}
if (listTrack != null)
{
foreach (var md in resultModel.DataSource)
{
var list3 = new List();
if (md.JoinOrderCode != null && md.JoinOrderCode != "")
list3 = listTrack.FindAll(n => n.OrderCode == md.JoinOrderCode);
else
list3 = listTrack.FindAll(n => n.OrderId == md.OrderId);
if (list3 != null && list3.Count > 0)
{
string trackinfo = "";
string TrackCode = "";
foreach (var md1 in list3)
{
string blank = "";
if (md1.TrackType == 3)
blank = "[空包裹]";
if (md1.Weight != null)
{
string dd = "";
if (md1.ScanDate != null)
dd = "扫描时间:" + md1.ScanDate.Value.ToString("yyyy-MM-dd HH:mm");
trackinfo += md1.TrackCode + blank + "重量" + md1.Weight.ToString() + "g" + dd + "
";
}
else
trackinfo += md1.TrackCode + blank + "
";
if (TrackCode == "")
TrackCode = md1.TrackCode;
}
md.TrackInfo = trackinfo;
md.TrackCode = TrackCode;
}
}
}
}
}
return resultModel;
}
#endregion
#region 查询订单
[WebMethod(EnableSession = true)]
public JsonModel> 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 IsDH, int SFLY, int PageIndex, int PageSize, string Sort)
{
Pages.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);
Param.Add("isnull(a.IsSDan,0)", "=", IsSD, DbType.Int32);
if (SaleState > 0)
Param.Add("a.SaleState", "=", SaleState, DbType.Int32);
if (WLId > 0)
Param.Add("a.LogisticsId", "=", WLId, DbType.Int32);
if (DeptId > 0)
Param.Add("c.DeptId", "=", DeptId, DbType.Int32);
if (PlatType > 0)
Param.Add("a.PlatId", "=", PlatType, DbType.Int32);
if (ShopId > 0)
Param.Add("a.ShopId", "=", ShopId, DbType.Int32);
if (DateType == 1)
{
if (SDate != null)
Param.Add("a.OrderDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.OrderDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
else
if (DateType == 2)
{
if (SDate != null)
Param.Add("a.InDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.InDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
else
if (DateType == 3)
{
if (SDate != null)
Param.Add("a.PrintDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.PrintDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
else
if (DateType == 4)
{
if (SDate != null)
Param.Add("a.PostDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.PostDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
else
if (DateType == 5)
{
if (SDate != null)
Param.Add("a.OrderOutDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.OrderOutDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
if (OutDays > 0)
{
Param.Add("a.OrderOutDate", "<=", DateTime.Now.AddDays(OutDays), DbType.DateTime);
Param.Add("a.OrderOutDate", ">=", DateTime.Now, DbType.DateTime);
}
if (MateState > -1)
Param.Add("a.MateState", "=", MateState, DbType.Int32);
if (MoneyState > -1)
Param.Add("a.MoneyState", "=", MoneyState, DbType.Int32);
if (PrintState > -1)
Param.Add("a.PrintState", "=", PrintState, DbType.Int32);
if (State == 3)
Param.Add("a.State", "=", 2, DbType.Int32);
else if (State == 4)
Param.Add("a.State", "=", 3, DbType.Int32);
else if (State == 5)
{
Param.Add("a.State", "=", 1, DbType.Int32);
Param.Add("a.MoneyState", "=", 1, DbType.Int32);
}
else if (State == 1)
{
//Param.Add("a.State", "=", 2, DbType.Int32);
Param.Add("a.PostState", "=", 1, DbType.Int32);
}
else if (State == 2)
{
Param.Add("a.State", "<", 3, DbType.Int32);
Param.Add("a.PostState", "=", 2, DbType.Int32);
}
else if (State == 0)
{
//Param.Add("a.State", "=", 2, DbType.Int32);
Param.Add("a.State", "=", 1, DbType.Int32);
}
else
Param.Add("a.State", ">", 0, DbType.Int32);
if (HBOrder == 1)
Param.Add("a.IsJoin", "=", 1, DbType.Int32);
if (IsError == 1)
{
Param.Add("(a.SendAddr", ">", 0, DbType.Int32);
Param.Add("a.IsLeaveWord", "=", 1, "or", ")", DbType.Int32);
}
if (IsE == 1)
{
Param.Add("a.PostState", "=", 2, DbType.Int32);
}
if (IsE == 0)
{
Param.Add("a.PostState", "<", 2, DbType.Int32);
}
string TCode = "";
if (Name != "")
{
Name = Name.Trim();
if (TjType == 1)
{
Param.Add("(a.PlatOrderCode", "like", Name, DbType.String);
Param.Add("OrderCode", "like", Name, "or", DbType.String);
Param.Add("a.JoinOrderCode", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 2)
{
Param.Add("a.RevName", "like", Name, DbType.String);
}
else if (TjType == 3)
{
Param.Add("a.RevPhone", "like", Name, DbType.String);
}
else if (TjType == 4)
{
Param.Add("(a.RevCountry", "=", Name, DbType.String);
Param.Add("a.CountryName", "=", Name, "or", DbType.String);
Param.Add("a.CountryCode", "=", Name, "or", ")", DbType.String);
}
else if (TjType == 5)
{
Param.Add("a.RevPostCode", "=", Name, DbType.String);
}
else if (TjType == 6)
{
Param.Add("(a.RevAddr", "like", Name, DbType.String);
Param.Add("a.RevProvince", "like", Name, "or", DbType.String);
Param.Add("a.RevCity", "like", Name, "or", DbType.String);
Param.Add("a.RevArea", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 9)
{
Param.Add("(a.ErrorInfo", "like", Name, DbType.String);
Param.Add("a.PostError", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 10)
{
//Param.Add("dbo.getOrderTrackCode(a.OrderId,0)", "like", Name, DbType.String);
TCode = Name;
}
else if (TjType == 11)
{
Param.Add("a.CustomID", "=", Name, DbType.String);
}
else if (TjType == 12)
{
Param.Add("a.RevMail", "=", Name, DbType.String);
}
}
if (IsSku == 0)
Param.Add("a.FPDate", "is", null, DbType.String);
else if (IsSku == 1)
Param.Add("a.FPDate", "is not", null, DbType.String);
JsonModel> resultModel = new JsonModel>();
int RowCount = 0;
//string Sort = "orderid desc";
string GoodsName = "";
string SKU = "";
if (TjType == 7 && Name != "")
{
GoodsName = Name;
}
else
if (TjType == 8 && Name != "")
{
SKU = Name;
}
if (SFLY > 0)
{
if (SFLY == 1)
{
resultModel.DataSource = obj.GetListDT_OrderInfoForTM6(CompanyId, GoodsName.Trim(), SKU.Trim(), TCode, -1, IsDH, Param, PageIndex, PageSize, Sort, out RowCount);
}
if (SFLY == 2)
{
resultModel.DataSource = obj.GetListDT_OrderInfoForTM7(CompanyId, GoodsName.Trim(), SKU.Trim(), TCode, -1, IsDH, Param, PageIndex, PageSize, Sort, out RowCount);
}
}
else
{
if (State == 0 || State == 2)
resultModel.DataSource = obj.GetListDT_OrderInfoForTM1(CompanyId, GoodsName.Trim(), SKU.Trim(), TCode, -1, IsDH, Param, PageIndex, PageSize, Sort, out RowCount);
else
resultModel.DataSource = obj.GetListDT_OrderInfoForTM(CompanyId, GoodsName.Trim(), SKU.Trim(), TCode, -1, IsDH, Param, PageIndex, PageSize, Sort, out RowCount);
}
resultModel.RowCount = RowCount;
string Ids = "";
if (resultModel.DataSource != null)
{
foreach (var md in resultModel.DataSource)
{
Ids += md.OrderId.ToString() + ",";
}
}
if (Ids != "")
{
var errorlist = obj.GetErrorList(Ids.Trim(','));
if (errorlist != null && errorlist.Count > 0)
{
foreach (var md in resultModel.DataSource)
{
var emd = errorlist.Find(n => n.OrderId == md.OrderId);
if (emd != null)
{
md.ErrorInfo = emd.ErrorInfo;
}
}
}
}
if (IsDetail == 1 && resultModel.DataSource != null)
{
if (Ids != "")
{
var list1 = obj.GetOrderGoodsList(Ids.Trim(','));
var listTrack = obj.GetTrackCodeApplyList(Ids.Trim(','));
if (list1 != null)
{
foreach (var md in resultModel.DataSource)
{
var list2 = list1.FindAll(n => n.OrderId == md.OrderId);
if (list2 != null)
{
md.GoodsList = list2;
}
}
}
if (listTrack != null)
{
foreach (var md in resultModel.DataSource)
{
var list3 = new List();
if (md.JoinOrderCode != null && md.JoinOrderCode != "")
list3 = listTrack.FindAll(n => n.OrderCode == md.JoinOrderCode);
else
list3 = listTrack.FindAll(n => n.OrderId == md.OrderId);
if (list3 != null && list3.Count > 0)
{
string trackinfo = "";
string TrackCode = "";
foreach (var md1 in list3)
{
string blank = "";
if (md1.TrackType == 3)
blank = "[空包裹]";
if (md1.Weight != null)
{
string dd = "";
if (md1.ScanDate != null)
dd = "扫描时间:" + md1.ScanDate.Value.ToString("yyyy-MM-dd HH:mm");
trackinfo += md1.TrackCode + blank + "重量" + md1.Weight.ToString() + "g" + dd + "
";
}
else
trackinfo += md1.TrackCode + blank + "
";
if (TrackCode == "")
TrackCode = md1.TrackCode;
}
md.TrackInfo = trackinfo;
md.TrackCode = TrackCode;
}
}
}
}
}
return resultModel;
}
#endregion
#region 查询订单
[WebMethod(EnableSession = true)]
public JsonModel> 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)
{
Pages.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.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 = obj.GetListDT_OrderInfoForTM1(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 = obj.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 string GetListOrderForExcel(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)
{
Pages.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);
Param.Add("isnull(a.IsSDan,0)", "=", IsSD, DbType.Int32);
if (SaleState > 0)
Param.Add("a.SaleState", "=", SaleState, DbType.Int32);
if (WLId > 0)
Param.Add("a.LogisticsId", "=", WLId, DbType.Int32);
if (DeptId > 0)
Param.Add("c.DeptId", "=", DeptId, DbType.Int32);
if (PlatType > 0)
Param.Add("a.PlatId", "=", PlatType, DbType.Int32);
if (ShopId > 0)
Param.Add("a.ShopId", "=", ShopId, DbType.Int32);
if (DateType == 1)
{
if (SDate != null)
Param.Add("a.OrderDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.OrderDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
else
if (DateType == 2)
{
if (SDate != null)
Param.Add("a.InDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.InDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
else
if (DateType == 3)
{
if (SDate != null)
Param.Add("a.PrintDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.PrintDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
else
if (DateType == 4)
{
if (SDate != null)
Param.Add("a.PostDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.PostDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
else
if (DateType == 5)
{
if (SDate != null)
Param.Add("a.OrderOutDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.OrderOutDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
if (OutDays > 0)
{
Param.Add("a.OrderOutDate", "<=", DateTime.Now.AddDays(OutDays), DbType.DateTime);
Param.Add("a.OrderOutDate", ">=", DateTime.Now, DbType.DateTime);
}
if (MateState > -1)
Param.Add("a.MateState", "=", MateState, DbType.Int32);
if (MoneyState > -1)
Param.Add("a.MoneyState", "=", MoneyState, DbType.Int32);
if (PrintState > -1)
Param.Add("a.PrintState", "=", PrintState, DbType.Int32);
if (State == 3)
Param.Add("a.State", "=", 2, DbType.Int32);
else if (State == 4)
Param.Add("a.State", "=", 3, DbType.Int32);
else if (State == 5)
{
Param.Add("a.State", "=", 1, DbType.Int32);
Param.Add("a.MoneyState", "=", 1, DbType.Int32);
}
else if (State == 1)
{
//Param.Add("a.State", "=", 2, DbType.Int32);
Param.Add("a.PostState", "=", 1, DbType.Int32);
}
else if (State == 2)
{
Param.Add("a.State", "<", 3, DbType.Int32);
Param.Add("a.PostState", "=", 2, DbType.Int32);
}
else if (State == 0)
{
//Param.Add("a.State", "=", 2, DbType.Int32);
Param.Add("a.State", "=", 1, DbType.Int32);
}
else
Param.Add("a.State", ">", 0, DbType.Int32);
if (HBOrder == 1)
Param.Add("a.IsJoin", "=", 1, DbType.Int32);
if (IsError == 1)
{
Param.Add("(a.SendAddr", ">", 0, DbType.Int32);
Param.Add("a.IsLeaveWord", "=", 1, "or", ")", DbType.Int32);
}
if (IsE == 1)
{
Param.Add("a.PostState", "=", 2, DbType.Int32);
}
if (IsE == 0)
{
Param.Add("a.PostState", "<", 2, DbType.Int32);
}
string TCode = "";
if (Name != "")
{
Name = Name.Trim();
if (TjType == 1)
{
Param.Add("(a.PlatOrderCode", "like", Name, DbType.String);
Param.Add("OrderCode", "like", Name, "or", DbType.String);
Param.Add("a.JoinOrderCode", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 2)
{
Param.Add("a.RevName", "like", Name, DbType.String);
}
else if (TjType == 3)
{
Param.Add("a.RevPhone", "like", Name, DbType.String);
}
else if (TjType == 4)
{
Param.Add("(a.RevCountry", "=", Name, DbType.String);
Param.Add("a.CountryName", "=", Name, "or", DbType.String);
Param.Add("a.CountryCode", "=", Name, "or", ")", DbType.String);
}
else if (TjType == 5)
{
Param.Add("a.RevPostCode", "=", Name, DbType.String);
}
else if (TjType == 6)
{
Param.Add("(a.RevAddr", "like", Name, DbType.String);
Param.Add("a.RevProvince", "like", Name, "or", DbType.String);
Param.Add("a.RevCity", "like", Name, "or", DbType.String);
Param.Add("a.RevArea", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 9)
{
Param.Add("(a.ErrorInfo", "like", Name, DbType.String);
Param.Add("a.PostError", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 10)
{
//Param.Add("dbo.getOrderTrackCode(a.OrderId,0)", "like", Name, DbType.String);
TCode = Name;
}
else if (TjType == 11)
{
Param.Add("a.CustomID", "=", Name, DbType.String);
}
else if (TjType == 12)
{
Param.Add("a.RevMail", "=", Name, DbType.String);
}
}
if (IsSku == 0)
Param.Add("a.FPDate", "is", null, DbType.String);
else if (IsSku == 1)
Param.Add("a.FPDate", "is not", null, DbType.String);
JsonModel> resultModel = new JsonModel>();
int RowCount = 0;
//string Sort = "orderid desc";
string GoodsName = "";
string SKU = "";
if (TjType == 7 && Name != "")
{
GoodsName = Name;
}
else
if (TjType == 8 && Name != "")
{
SKU = Name;
}
if (SFLY > 0)
{
if (SFLY == 1)
{
resultModel.DataSource = obj.GetListDT_OrderInfoForTM6(CompanyId, GoodsName.Trim(), SKU.Trim(), TCode, -1, IsDH, Param, PageIndex, PageSize, Sort, out RowCount);
}
if (SFLY == 2)
{
resultModel.DataSource = obj.GetListDT_OrderInfoForTM7(CompanyId, GoodsName.Trim(), SKU.Trim(), TCode, -1, IsDH, Param, PageIndex, PageSize, Sort, out RowCount);
}
}
else
{
if (State == 0 || State == 2)
resultModel.DataSource = obj.GetListDT_OrderInfoForTM1(CompanyId, GoodsName.Trim(), SKU.Trim(), TCode, -1, IsDH, Param, PageIndex, PageSize, Sort, out RowCount);
else
resultModel.DataSource = obj.GetListDT_OrderInfoForTM(CompanyId, GoodsName.Trim(), SKU.Trim(), TCode, -1, IsDH, Param, PageIndex, PageSize, Sort, out RowCount);
}
resultModel.RowCount = RowCount;
string Ids = "";
if (resultModel.DataSource != null)
{
foreach (var md in resultModel.DataSource)
{
Ids += md.OrderId.ToString() + ",";
}
}
if (Ids != "")
{
var errorlist = obj.GetErrorList(Ids.Trim(','));
if (errorlist != null && errorlist.Count > 0)
{
foreach (var md in resultModel.DataSource)
{
var emd = errorlist.Find(n => n.OrderId == md.OrderId);
if (emd != null)
{
md.ErrorInfo = emd.ErrorInfo;
}
}
}
}
if (IsDetail == 1 && resultModel.DataSource != null)
{
if (Ids != "")
{
var list1 = obj.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;
}
}
}
}
}
TableColumnCollection listColumns = new TableColumnCollection();
listColumns.Add("PlatOrderCode", "订单号", DbType.String, "");
listColumns.Add("JoinOrderCode", "合并订单号", DbType.String, "");
listColumns.Add("ShopName", "店铺", DbType.String, "");
listColumns.Add("InDate", "导入日期", DbType.String, "yyyy-MM-dd HH:mm");
listColumns.Add("CountryName", "国家", DbType.String, "");
listColumns.Add("TotalPrice", "金额", DbType.String, "");
listColumns.Add("MoneyCode", "货币单位", DbType.String, "");
listColumns.Add("GoodsNum", "货物数量", DbType.String, "");
listColumns.Add("StateName", "订单状态", DbType.String, "");
listColumns.Add("PostDate", "发货时间", DbType.String, "yyyy-MM-dd HH:mm");
listColumns.Add("TrackCode", "跟踪码", DbType.String, "");
listColumns.Add("TrackInfo", "发货信息", DbType.String, "");
MicrosoftExcel obj2 = new MicrosoftExcel();
return obj2.Export(resultModel.DataSource, listColumns);
}
#endregion
#region 查询订单
[WebMethod(EnableSession = true)]
public string GetListOrderForExcel2(int StoreId, int DeptId, int PlatType, int ShopId, int DateType, DateTime? SDate, DateTime? EDate, int TjType, string Name, int PrintState, int MateState, int MoneyState, int OutDays, int State, int IsSku, int IsError, int IsE, int IsDetail, int HBOrder, int IsSD, int SaleState, int IsBuy, int WLId, int IsDH, int SFLY, int PageIndex, int PageSize, string Sort)
{
Pages.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);
Param.Add("isnull(a.IsSDan,0)", "=", IsSD, DbType.Int32);
if (SaleState > 0)
Param.Add("a.SaleState", "=", SaleState, DbType.Int32);
if (WLId > 0)
Param.Add("a.LogisticsId", "=", WLId, DbType.Int32);
if (DeptId > 0)
Param.Add("c.DeptId", "=", DeptId, DbType.Int32);
if (PlatType > 0)
Param.Add("a.PlatId", "=", PlatType, DbType.Int32);
if (ShopId > 0)
Param.Add("a.ShopId", "=", ShopId, DbType.Int32);
if (DateType == 1)
{
if (SDate != null)
Param.Add("a.OrderDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.OrderDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
else
if (DateType == 2)
{
if (SDate != null)
Param.Add("a.InDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.InDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
else
if (DateType == 3)
{
if (SDate != null)
Param.Add("a.PrintDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.PrintDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
else
if (DateType == 4)
{
if (SDate != null)
Param.Add("a.PostDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.PostDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
else
if (DateType == 5)
{
if (SDate != null)
Param.Add("a.OrderOutDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.OrderOutDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
if (OutDays > 0)
{
Param.Add("a.OrderOutDate", "<=", DateTime.Now.AddDays(OutDays), DbType.DateTime);
Param.Add("a.OrderOutDate", ">=", DateTime.Now, DbType.DateTime);
}
if (MateState > -1)
Param.Add("a.MateState", "=", MateState, DbType.Int32);
if (MoneyState > -1)
Param.Add("a.MoneyState", "=", MoneyState, DbType.Int32);
if (PrintState > -1)
Param.Add("a.PrintState", "=", PrintState, DbType.Int32);
if (State == 3)
Param.Add("a.State", "=", 2, DbType.Int32);
else if (State == 4)
Param.Add("a.State", "=", 3, DbType.Int32);
else if (State == 5)
{
Param.Add("a.State", "=", 1, DbType.Int32);
Param.Add("a.MoneyState", "=", 1, DbType.Int32);
}
else if (State == 1)
{
//Param.Add("a.State", "=", 2, DbType.Int32);
Param.Add("a.PostState", "=", 1, DbType.Int32);
}
else if (State == 2)
{
Param.Add("a.State", "<", 3, DbType.Int32);
Param.Add("a.PostState", "=", 2, DbType.Int32);
}
else if (State == 0)
{
//Param.Add("a.State", "=", 2, DbType.Int32);
Param.Add("a.State", "=", 1, DbType.Int32);
}
else
Param.Add("a.State", ">", 0, DbType.Int32);
if (HBOrder == 1)
Param.Add("a.IsJoin", "=", 1, DbType.Int32);
if (IsError == 1)
{
Param.Add("(a.SendAddr", ">", 0, DbType.Int32);
Param.Add("a.IsLeaveWord", "=", 1, "or", ")", DbType.Int32);
}
if (IsE == 1)
{
Param.Add("a.PostState", "=", 2, DbType.Int32);
}
if (IsE == 0)
{
Param.Add("a.PostState", "<", 2, DbType.Int32);
}
string TCode = "";
if (Name != "")
{
Name = Name.Trim();
if (TjType == 1)
{
Param.Add("(a.PlatOrderCode", "like", Name, DbType.String);
Param.Add("OrderCode", "like", Name, "or", DbType.String);
Param.Add("a.JoinOrderCode", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 2)
{
Param.Add("a.RevName", "like", Name, DbType.String);
}
else if (TjType == 3)
{
Param.Add("a.RevPhone", "like", Name, DbType.String);
}
else if (TjType == 4)
{
Param.Add("(a.RevCountry", "=", Name, DbType.String);
Param.Add("a.CountryName", "=", Name, "or", DbType.String);
Param.Add("a.CountryCode", "=", Name, "or", ")", DbType.String);
}
else if (TjType == 5)
{
Param.Add("a.RevPostCode", "=", Name, DbType.String);
}
else if (TjType == 6)
{
Param.Add("(a.RevAddr", "like", Name, DbType.String);
Param.Add("a.RevProvince", "like", Name, "or", DbType.String);
Param.Add("a.RevCity", "like", Name, "or", DbType.String);
Param.Add("a.RevArea", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 9)
{
Param.Add("(a.ErrorInfo", "like", Name, DbType.String);
Param.Add("a.PostError", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 10)
{
//Param.Add("dbo.getOrderTrackCode(a.OrderId,0)", "like", Name, DbType.String);
TCode = Name;
}
else if (TjType == 11)
{
Param.Add("a.CustomID", "=", Name, DbType.String);
}
else if (TjType == 12)
{
Param.Add("a.RevMail", "=", Name, DbType.String);
}
}
if (IsSku == 0)
Param.Add("a.FPDate", "is", null, DbType.String);
else if (IsSku == 1)
Param.Add("a.FPDate", "is not", null, DbType.String);
JsonModel> resultModel = new JsonModel>();
int RowCount = 0;
//string Sort = "orderid desc";
string GoodsName = "";
string SKU = "";
if (TjType == 7 && Name != "")
{
GoodsName = Name;
}
else
if (TjType == 8 && Name != "")
{
SKU = Name;
}
if (SFLY > 0)
{
if (SFLY == 1)
{
resultModel.DataSource = obj.GetListDT_OrderInfoForTM6(CompanyId, GoodsName.Trim(), SKU.Trim(), TCode, -1, IsDH, Param, PageIndex, PageSize, Sort, out RowCount);
}
if (SFLY == 2)
{
resultModel.DataSource = obj.GetListDT_OrderInfoForTM7(CompanyId, GoodsName.Trim(), SKU.Trim(), TCode, -1, IsDH, Param, PageIndex, PageSize, Sort, out RowCount);
}
}
else
{
if (State == 0 || State == 2)
resultModel.DataSource = obj.GetListDT_OrderInfoForTM1(CompanyId, GoodsName.Trim(), SKU.Trim(), TCode, -1, IsDH, Param, PageIndex, PageSize, Sort, out RowCount);
else
resultModel.DataSource = obj.GetListDT_OrderInfoForTM(CompanyId, GoodsName.Trim(), SKU.Trim(), TCode, -1, IsDH, Param, PageIndex, PageSize, Sort, out RowCount);
}
resultModel.RowCount = RowCount;
string Ids = "";
if (resultModel.DataSource != null)
{
foreach (var md in resultModel.DataSource)
{
Ids += md.OrderId.ToString() + ",";
}
}
//if (Ids != "")
//{
// var errorlist = obj.GetErrorList(Ids.Trim(','));
// if (errorlist != null && errorlist.Count > 0)
// {
// foreach (var md in resultModel.DataSource)
// {
// var emd = errorlist.Find(n => n.OrderId == md.OrderId);
// if (emd != null)
// {
// md.ErrorInfo = emd.ErrorInfo;
// }
// }
// }
//}
if (IsDetail == 1 && resultModel.DataSource != null)
{
if (Ids != "")
{
var list1 = obj.GetOrderGoodsList22(Ids.Trim(','));
var listTrack = obj.GetTrackCodeApplyList(Ids.Trim(','));
if (list1 != null)
{
foreach (var md in resultModel.DataSource)
{
var list2 = list1.FindAll(n => n.OrderId == md.OrderId);
if (list2 != null && list2.Count>0)
{
md.SKU = list2[0].GoodsCode;
if(list2[0].Weight!=null)
md.GWeight = list2[0].Weight.Value.ToString("0");
if (list2[0].Height2 != null)
md.GHeight = list2[0].Height2.Value.ToString("0.0");
if (list2[0].Width2 != null)
md.GWidth = list2[0].Width2.Value.ToString("0.0");
if (list2[0].Long2 != null)
md.GLong = list2[0].Long2.Value.ToString("0.0");
}
}
}
if (listTrack != null)
{
foreach (var md in resultModel.DataSource)
{
var list3 = new List();
if (md.JoinOrderCode != null && md.JoinOrderCode != "")
list3 = listTrack.FindAll(n => n.OrderCode == md.JoinOrderCode);
else
list3 = listTrack.FindAll(n => n.OrderId == md.OrderId);
if (list3 != null && list3.Count > 0)
{
string trackinfo = "";
string TrackCode = "";
foreach (var md1 in list3)
{
trackinfo += md1.TrackCode+",";
if (TrackCode == "")
TrackCode = md1.TrackCode;
}
md.TrackCode = TrackCode;
}
}
}
}
}
// 订单号 收货人国家 收货人姓名 地址1+地址2 收货人城市 收货人州/省 邮编 收货人手机 收货人电话 SKU 产品数量 报关重量(oz) 长(inch) 宽(inch)
TableColumnCollection listColumns = new TableColumnCollection();
listColumns.Add("PlatOrderCode", "订单号", DbType.String, "");
listColumns.Add("RevCountry", "收货人国家", DbType.String, "");
listColumns.Add("RevName", "收货人姓名", DbType.String, "");
listColumns.Add("RevAddr", "地址1+地址2", DbType.String, "yyyy-MM-dd HH:mm");
listColumns.Add("RevCity", "收货人城市", DbType.String, "");
listColumns.Add("RevProvince", "收货人州/省", DbType.String, "");
listColumns.Add("RevPostCode", "邮编", DbType.String, "");
listColumns.Add("RevMoblie", "收货人手机", DbType.String, "");
listColumns.Add("RevPhone", "收货人电话", DbType.String, "");
listColumns.Add("SKU", "SKU", DbType.String, "yyyy-MM-dd HH:mm");
listColumns.Add("GoodsNum", "产品数量", DbType.String, "");
listColumns.Add("GWeight", "报关重量(oz)", DbType.String, "");
listColumns.Add("GLong", "长(inch)", DbType.String, "");
listColumns.Add("GWidth", "宽(inch)", DbType.String, "");
listColumns.Add("GHeight", "高(inch)", DbType.String, "");
listColumns.Add("TrackCode", "跟踪码", DbType.String, "");
MicrosoftExcel obj2 = new MicrosoftExcel();
return obj2.Export(resultModel.DataSource, listColumns);
}
#endregion
#region 查询空包裹订单
[WebMethod(EnableSession = true)]
public JsonModel> GetListOrderBlank(int PlatType, int ShopId, int DateType, DateTime? SDate, DateTime? EDate, int TjType, string Name, int PrintState, int PostState, int PostId, int PageIndex, int PageSize)
{
Pages.Login(this.Session);
var obj = new DD_OrderData();
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
RefParameterCollection Param = new RefParameterCollection();
Param.Add("b.CompanyId", "=", CompanyId, DbType.Int32);
if (PostId > 0)
Param.Add("a.Post", "=", PostId, DbType.Int32);
if (PlatType > 0)
Param.Add("b.PlatId", "=", PlatType, DbType.Int32);
if (ShopId > 0)
Param.Add("b.ShopId", "=", ShopId, DbType.Int32);
if (DateType == 1)
{
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 == 2)
{
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 == 3)
{
if (SDate != null)
Param.Add("a.PostDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.PostDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
if (PrintState == 1)
Param.Add("a.State", "=", 2, DbType.Int32);
else if (PrintState == 0)
Param.Add("a.State", "=", 1, DbType.Int32);
if (PostState == 0)
Param.Add("a.State", "=", 1, DbType.Int32);
else if (PostState == 1)
Param.Add("a.State", "=", 3, DbType.Int32);
if (Name != "")
{
Name = Name.Trim();
if (TjType == 1)
{
Param.Add("b.PlatOrderCode", "like", Name, 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 == 10)
{
Param.Add("a.TrackCode", "like", Name, DbType.String);
}
}
// Param.Add("a.OrderDate", ">=", 0, DbType.Int32);
JsonModel> resultModel = new JsonModel>();
int RowCount = 0;
string Sort = "id desc";
resultModel.DataSource = obj.GetListDT_OrderBlank(Param, PageIndex, PageSize, Sort, out RowCount);
resultModel.RowCount = RowCount;
return resultModel;
}
#endregion
#region 查询订单导出
public DataTable GetListOrderExcel(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 IsDetail, int HBOrder)
{
Pages.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 (OutDays > 0)
{
Param.Add("a.OrderOutDate", "<=", DateTime.Today.AddDays(OutDays), 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 > -1)
{
Param.Add("a.State", ">", 0, DbType.Int32);
Param.Add("a.PostState", "=", State, 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("(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.PlatOrderCode", "=", "C" + 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;
}
DataTable tb = obj.GetExcelDT_OrderInfo(CompanyId, GoodsName.Trim(), SKU.Trim(), IsSku, Param, Sort);
if (tb != null)
{
BaseService obj2 = new BaseService();
var postlist = obj2.GetExpressPostList(CompanyId, 0);
for (int i = 0; i < tb.Rows.Count; i++)
{
if (tb.Rows[i]["Post"] != null && Convert.ToInt32(tb.Rows[i]["Post"]) > 0 && postlist != null)
{
var pmd = postlist.Find(n => n.ExpressID == Convert.ToInt32(tb.Rows[i]["Post"]));
if (pmd != null)
{
tb.Rows[i]["PostInfo"] = pmd.Name;
}
else
tb.Rows[i]["PostInfo"] = "";
}
else
tb.Rows[i]["PostInfo"] = "";
}
}
return tb;
}
#endregion
#region 查询修改状态订单
[WebMethod(EnableSession = true)]
public JsonModel> GetListStateOrder(int PlatType, int ShopId, int DateType, DateTime? SDate, DateTime? EDate, int TjType, string Name, int State, int IsDetail,int DYState, int PageIndex, int PageSize)
{
Pages.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 (State == 1)
{
Param.Add("a.PostState", "=", 1, DbType.Int32);
Param.Add("a.State", "=", 2, DbType.Int32);
}
else if (State == 2)
{
Param.Add("a.PrintState", "=", 1, DbType.Int32);
Param.Add("a.State", "=", 1, DbType.Int32);
}
else if (State == 3)
{
Param.Add("a.State", "=", 1, DbType.Int32);
Param.Add("a.MateState", "=", 2, DbType.Int32);
}
if (State == 3 && DYState>-1&& DYState < 2)
Param.Add("a.PostState", "=", DYState, DbType.Int32);
if (State == 3 && DYState==2)
Param.Add("a.MoneyState", "=", 0, DbType.Int32);
string TCode = "";
if (Name != "")
{
Name = Name.Trim();
if (TjType == 1)
{
Param.Add("(a.PlatOrderCode", "like", Name, DbType.String);
Param.Add("a.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("b.TrackCode", "like", Name, DbType.String);
TCode = Name;
}
}
// 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;
}
resultModel.DataSource = obj.GetListDT_OrderInfoForTM(CompanyId, GoodsName.Trim(), SKU.Trim(), TCode, 0, -1, Param, PageIndex, PageSize, Sort, out RowCount);
resultModel.RowCount = RowCount;
if (IsDetail == 1 && resultModel.DataSource != null)
{
string Ids = "";
foreach (var md in resultModel.DataSource)
{
Ids += md.OrderId.ToString() + ",";
}
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> GetErrorListOrder(int PlatType, int ShopId, int DateType, DateTime? SDate, DateTime? EDate, int TjType, string Name, int PrintState, int MateState, int OutDays, int State, int IsError, int IsDetail, int HBOrder, int PageIndex, int PageSize)
{
Pages.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 (OutDays > 0)
{
Param.Add("a.OrderOutDate", "<=", DateTime.Today.AddDays(OutDays), DbType.DateTime);
}
Param.Add("a.State", "=", 1, DbType.Int32);
int IsSku = 0;
if (IsError == 1)
{
IsSku = 1;
}
else
if (IsError == 2)
{
Param.Add("b.IsLeaveWord", "=", 1, DbType.Int32);
Param.Add("a.PostState", "=", 2, DbType.Int32);
}
else if (IsError == 3)
{
Param.Add("b.SendAddr", ">", 0, DbType.Int32);
Param.Add("a.PostState", "=", 2, DbType.Int32);
}
else if (IsError == 5)
{
Param.Add("a.MoneyState", "=", 0, DbType.Int32);
Param.Add("a.PostState", "=", 2, DbType.Int32);
}
else if (IsError == 6)
{
Param.Add("a.MoneyState", "=", 0, DbType.Int32);
Param.Add("a.PostState", "=", 2, DbType.Int32);
}
//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 > -1)
//{
// Param.Add("a.State", "=", 1, DbType.Int32);
// Param.Add("a.PostState", "=", State, 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("b.OrderState", "=", 2, DbType.Int32);
//}
if (Name != "")
{
Name = Name.Trim();
if (TjType == 1)
Param.Add("a.PlatOrderCode", "=", Name, 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;
}
resultModel.DataSource = obj.GetListDT_OrderErrorInfo(CompanyId, GoodsName.Trim(), SKU.Trim(), IsSku, Param, PageIndex, PageSize, Sort, out RowCount);
resultModel.RowCount = RowCount;
if (IsDetail == 1 && resultModel.DataSource != null)
{
string Ids = "";
foreach (var md in resultModel.DataSource)
{
Ids += md.OrderId.ToString() + ",";
}
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> GetErrorListOrderForTM(int DeptId, int PlatType, int ShopId, int DateType, DateTime? SDate, DateTime? EDate, int TjType, string Name, int OutDays, int IsError, int IsDetail, int HBOrder, int SFLY, int PageIndex, int PageSize)
{
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 (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.InDate", "<=", DateTime.Now.AddDays(OutDays * -1), DbType.DateTime);
//Param.Add("a.OrderOutDate", ">=", DateTime.Now, DbType.DateTime);
}
if (IsError != 8 || SFLY < 0)
Param.Add("a.State", "=", 1, DbType.Int32);
int IsSku = 0;
int IsNoGoods = 0;
if (IsError == 1)
{
Param.Add("a.FPDate", "is", null, DbType.String);
}
else
if (IsError == 2)
{
Param.Add("b.IsLeaveWord", "=", 1, DbType.Int32);
Param.Add("a.FPDate", "is", null, DbType.Int32);
}
else if (IsError == 3)
{
Param.Add("b.SendAddr", ">", 0, DbType.Int32);
Param.Add("a.PostState", "=", 2, DbType.Int32);
}
else if (IsError == 5)
{
Param.Add("a.MoneyState", "=", 0, DbType.Int32);
//Param.Add("a.PostState", "=", 2, DbType.Int32);
}
else if (IsError == 6)
{
IsNoGoods = 1;
Param.Add("a.MateState", "=", 0, DbType.String);
}
else if (IsError == 9)
{
IsNoGoods = 2;
Param.Add("a.MateState", "=", 0, DbType.String);
}
else if (IsError == 7)
{
Param.Add("a.PostState", "=", 2, DbType.Int32);
}
if (HBOrder == 1)
Param.Add("a.IsJoin", "=", 1, DbType.Int32);
if (Name != "")
{
Name = Name.Trim();
if (TjType == 1)
Param.Add("a.PlatOrderCode", "=", Name, 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);
}
else if (TjType == 11)
{
Param.Add("b.RevMail", "=", 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 (SFLY > 0)
{
if (SFLY == 1)
{
resultModel.DataSource = obj.GetListDT_OrderErrorInfoForTM4(CompanyId, IsNoGoods, GoodsName.Trim(), SKU.Trim(), IsSku, Param, PageIndex, PageSize, Sort, out RowCount);
}
if (SFLY == 2)
{
resultModel.DataSource = obj.GetListDT_OrderErrorInfoForTM5(CompanyId, IsNoGoods, GoodsName.Trim(), SKU.Trim(), IsSku, Param, PageIndex, PageSize, Sort, out RowCount);
}
}
else
{
if (IsError == 8)
{
resultModel.DataSource = obj.GetListDT_OrderErrorInfoForTM3(CompanyId, IsNoGoods, GoodsName.Trim(), SKU.Trim(), IsSku, Param, PageIndex, PageSize, Sort, out RowCount);
}
else
{
resultModel.DataSource = obj.GetListDT_OrderErrorInfoForTM2(CompanyId, IsNoGoods, GoodsName.Trim(), SKU.Trim(), 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 != "")
{
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 (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> GetListOrderPrint(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 PageIndex, int PageSize)
{
Pages.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);
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 (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.Today.AddDays(OutDays), DbType.DateTime);
}
if (PrintState > -1)
Param.Add("a.PrintState", "=", PrintState, DbType.Int32);
Param.Add("a.PostState", "<", 2, 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);
}
Param.Add("b.Post", ">", 0, 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);
}
if (Name != "")
{
Name = Name.Trim();
if (TjType == 1)
Param.Add("a.PlatOrderCode", "=", Name, 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);
}
}
if (IsWeight == 2)
{
Param.Add("a.IsSpare", "=", 1, DbType.Int32);
IsWeight = 0;
}
//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 SKU = "";
if (TjType == 7 && Name != "")
{
GoodsName = Name;
}
else
if (TjType == 8 && Name != "")
{
SKU = Name;
}
resultModel.DataSource = obj.GetListDT_PrintOrderInfo(CompanyId, GoodsName.Trim(), IsWeight, SKU, IsSku, Param, PageIndex, PageSize, Sort, out RowCount);
resultModel.RowCount = RowCount;
if (resultModel.DataSource != null)
{
BaseService obj2 = new BaseService();
var postlist = obj2.GetExpressPostList(CompanyId,0);
foreach (var md in resultModel.DataSource)
{
if (md.IsSpare == 1)
{
string TrackCodes = "拆分发包:
";
var splist = obj.GetOrderSpareList(md.OrderId.Value);
if (splist != null)
{
for (int i = 0; i < splist.Count; i++)
{
if (i % 2 == 1 && splist[i].TrackCode != null)
TrackCodes += splist[i].TrackCode.ToString() + "
";
else if (splist[i].TrackCode != null)
TrackCodes += splist[i].TrackCode.ToString() + ",";
}
}
md.TrackCode = TrackCodes.Trim(',');
}
if (md.Post > 0 && postlist != null)
{
var pmd = postlist.Find(n => n.ExpressID == md.Post);
if (pmd != null)
{
md.PostInfo = pmd.Name;
md.PrintTemplateName = pmd.PrintTemplateName;
}
else
md.PostInfo = "";
}
else
md.PostInfo = "";
}
}
if (IsDetail == 1 && resultModel.DataSource != null)
{
string Ids = "";
foreach (var md in resultModel.DataSource)
{
Ids += md.OrderId.ToString() + ",";
}
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> 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 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)
{
Pages.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 (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 = obj.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 (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(','));
var list1 = obj.GetOrderGoodsPostionList(Ids.Trim(','));
if (list1 != null)
{
foreach (var md in ordertemp)
{
var list2 = list1.FindAll(n => n.OrderId == md.OrderId);
if (list2 != null)
{
md.GoodsList = list2;
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;
}
resultModel.DataSource = ordertemp.Take(PageSize).Skip(PageSize*(PageIndex-1)).ToList();
int count = 0;
if (ordertemp != null) count = ordertemp.Count();
resultModel.RowCount = count;
return resultModel;
}
#endregion
#region 查询订单
[WebMethod(EnableSession = true)]
public JsonModel> GetListOrderPrintForTM2(int MateState,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)
{
Pages.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);
if (MateState == 2)
Param.Add("a.MateState", "=", 2, DbType.Int32);
else if (MateState == 0)
Param.Add("a.MateState", "=", 0, 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 = obj.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 (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(','));
var list11 = obj.GetOrderGoodsNoPostionList(Ids.Trim(','));
var list1 = obj.GetOrderGoodsPostionList(Ids.Trim(','));
if (list1 != null)
{
foreach (var md in ordertemp)
{
var list2 = list1.FindAll(n => n.OrderId == md.OrderId);
if (list2 != null)
{
md.GoodsList = list2;
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);
}
}
}
}
}
if (list11 != null)
{
foreach (var md in ordertemp)
{
if (md.GoodsList == null || md.GoodsList.Count==0)
{
var list12 = list11.FindAll(n => n.OrderId == md.OrderId);
if (list12 != null)
{
md.GoodsList = list12;
}
}
}
}
if (listTrack != null)
{
foreach (var md in ordertemp)
{
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;
}
resultModel.DataSource = ordertemp.Take(PageSize).Skip(PageSize * (PageIndex - 1)).ToList();
int count = 0;
if (ordertemp != null) count = ordertemp.Count();
resultModel.RowCount = count;
return resultModel;
}
#endregion
#region 查询订单
[WebMethod(EnableSession = true)]
public JsonModel> GetListOrderPrintForTM3(int MateState,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)
{
Pages.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);
if (MateState==2)
Param.Add("a.MateState", "=", 2, DbType.Int32);
else if (MateState == 0)
Param.Add("a.MateState", "=", 0, 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 = obj.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);
resultModel.DataSource = orderlist;
resultModel.RowCount = RowCount;
string Ids = "";
if (orderlist != null)
{
foreach (var md in orderlist)
{
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 orderlist)
{
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 && orderlist != null)
{
if (Ids != "")
{
var listTrack = obj.GetTrackCodeApplyList2(Ids.Trim(','));
if (listTrack != null)
{
foreach (var md in orderlist)
{
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 && orderlist != null)
{
if (Ids != "")
{
var listTrack = obj.GetTrackCodeApplyList2(Ids.Trim(','));
var list1 = obj.GetOrderGoodsPostionList(Ids.Trim(','));
var list11 = obj.GetOrderGoodsNoPostionList(Ids.Trim(','));
if (list1 != null)
{
foreach (var md in orderlist)
{
var list2 = list1.FindAll(n => n.OrderId == md.OrderId);
if (list2 != null)
{
md.GoodsList = list2;
}
}
}
if (list11 != null)
{
foreach (var md in orderlist)
{
if (md.GoodsList == null)
{
var list12 = list11.FindAll(n => n.OrderId == md.OrderId);
if (list12 != null)
{
md.GoodsList = list12;
}
}
}
}
foreach (var md in orderlist)
{
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 GetListOrderPrintForExcel(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)
{
Pages.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 (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 = obj.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 (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 (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 = obj.GetOrderGoodsPostionList(Ids.Trim(','));
if (list1 != null)
{
foreach (var md in ordertemp)
{
var list2 = list1.FindAll(n => n.OrderId == md.OrderId);
if (list2 != null)
{
md.GoodsList = list2;
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;
}
resultModel.DataSource = ordertemp.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("shopname", Type.GetType("System.String"));
tb.Columns.Add("indate", Type.GetType("System.String"));
tb.Columns.Add("country", Type.GetType("System.String"));
tb.Columns.Add("post", Type.GetType("System.String"));
tb.Columns.Add("trackcode", Type.GetType("System.String"));
if (resultModel.DataSource != null)
{
foreach (var md in resultModel.DataSource)
{
DataRow row = tb.NewRow();
row["ordercode"] = md.PlatOrderCode;
row["hbordercode"] = md.JoinOrderCode;
row["shopname"] = md.ShopName;
if (md.OrderDate!=null)
row["indate"] = md.OrderDate.Value.ToString("yyyy-MM-dd HH:mm");
row["country"] = md.CountryName;
row["post"] = md.PostInfo;
row["trackcode"] = md.TrackCode.TrimEnd(',');
tb.Rows.Add(row);
if (md.GoodsList != null)
{
foreach (var gmd in md.GoodsList)
{
DataRow row1 = tb.NewRow();
row1["ordercode"] = "";
row1["hbordercode"] = "";
row1["shopname"] ="";
string oldtypedec = "";
if (gmd.OldTypeDesc != null && gmd.OldTypeDesc != "")
oldtypedec = "改" + gmd.OldTypeDesc + "发";
row1["indate"] ="";
row1["country"] = "";
row1["post"] = "";
row1["trackcode"] = "商品:[" + gmd.GoodsCode + "]" + gmd.GoodsName + " " + gmd.TypeDesc + gmd.TypeCode + oldtypedec + "数量:" + gmd.GoodsNum+"库位:【" + gmd.PostionCode + "】";
tb.Rows.Add(row1);
}
}
}
TableColumnCollection listColumns = new TableColumnCollection();
listColumns.Add("ordercode", "订单号", DbType.String, "");
listColumns.Add("hbordercode", "合并单号", DbType.String, "");
listColumns.Add("shopname", "店铺", DbType.String, "");
listColumns.Add("indate", "订单日期", DbType.String, "");
listColumns.Add("country", "国家", DbType.String, "");
listColumns.Add("post", "物流", DbType.String, "");
listColumns.Add("trackcode", "跟踪码", DbType.String, "");
MicrosoftExcel obj2 = new MicrosoftExcel();
return obj2.Export(tb, 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)
{
Pages.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 (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 = obj.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 (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 (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 = obj.GetOrderGoodsPostionList(Ids.Trim(','));
if (list1 != null)
{
foreach (var md in ordertemp)
{
var list2 = list1.FindAll(n => n.OrderId == md.OrderId);
if (list2 != null)
{
md.GoodsList = list2;
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;
}
resultModel.DataSource = ordertemp.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("indate", Type.GetType("System.String"));
tb.Columns.Add("num", Type.GetType("System.String"));
tb.Columns.Add("kwcode", Type.GetType("System.String"));
// tb.Columns.Add("trackcode", Type.GetType("System.String"));
if (resultModel.DataSource != null)
{
foreach (var md in resultModel.DataSource)
{
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;
//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 + " " + gmd.TypeDesc + " " + gmd.GoodsName;
else
row["goodscode"] = gmd.GoodsCode + "-" + gmd.TypeCode + " " + gmd.TypeDesc + " " + gmd.GoodsName;
row["num"] = gmd.GoodsNum.ToString();
row["kwcode"] = gmd.PostionCode.ToString();
tb.Rows.Add(row);
}
else
{
DataRow row1 = tb.NewRow();
row1["ordercode"] = "";
if (gmd.OldTypeDesc != null && gmd.OldTypeDesc != "")
row1["goodscode"] = gmd.OldTypeDesc + " " + gmd.TypeDesc + " " + gmd.GoodsName;
else
row1["goodscode"] = gmd.GoodsCode + "-" + gmd.TypeCode + " " + gmd.TypeDesc + " " + gmd.GoodsName;
row1["num"] = gmd.GoodsNum.ToString();
row1["kwcode"] = gmd.PostionCode.ToString();
tb.Rows.Add(row1);
}
}
}
}
if (Ids != null)
{
DataRow row2 = tb.NewRow();
row2["ordercode"] = "";
row2["goodscode"] = "";
row2["num"] = "";
row2["kwcode"] = "";
tb.Rows.Add(row2);
row2 = tb.NewRow();
row2["ordercode"] = "";
row2["goodscode"] = "";
row2["num"] = "";
row2["kwcode"] = "";
tb.Rows.Add(row2);
row2 = tb.NewRow();
row2["ordercode"] = "合计(sum):";
row2["goodscode"] = "";
row2["num"] = "";
row2["kwcode"] = "";
tb.Rows.Add(row2);
List list8 = obj.GetOrderGoodsPostionList22(Ids.Trim(','));
if (list8 != null)
{
foreach (DT_OrderGoods goods2 in list8)
{
row2 = tb.NewRow();
row2["ordercode"] = "";
if (goods2.OldTypeDesc != null && goods2.OldTypeDesc != "")
row2["goodscode"] = goods2.OldTypeDesc + " " + goods2.TypeDesc + " " + goods2.GoodsName;
else
row2["goodscode"] = goods2.GoodsCode + " " + goods2.TypeDesc + " " + goods2.GoodsName;
row2["num"] = goods2.GoodsNum;
row2["kwcode"] = goods2.PostionCode;
tb.Rows.Add(row2);
}
}
}
TableColumnCollection listColumns = new TableColumnCollection();
listColumns.Add("ordercode", "订单号", DbType.String, "");
listColumns.Add("goodscode", "货号", DbType.String, "");
listColumns.Add("num", "数量", DbType.String, "");
listColumns.Add("kwcode", "库位", DbType.String, "");
MicrosoftExcel obj2 = new MicrosoftExcel();
return obj2.Export(tb, listColumns);
}
return "";
}
#endregion
[WebMethod(EnableSession = true)]
public JsonModel> GetListOrderForTM222(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)
{
List.Enumerator enumerator;
Pages.Login(base.Session);
DD_OrderData data = new DD_OrderData();
int num = Convert.ToInt32(base.Session["CompanyId"]);
RefParameterCollection where = new RefParameterCollection();
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 (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 == 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 (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 = data.GetListDT_OrderInfoForTM(num, str2.Trim(), str3.Trim(), trackCode, -1, IsDH, where, PageIndex, PageSize, Sort, out rowCount);
}
model.RowCount = rowCount;
string str4 = "";
if (model.DataSource != null)
{
foreach (DT_Order order in model.DataSource)
{
str4 = str4 + order.OrderId.ToString() + ",";
}
}
if (str4 != "")
{
List errorList = data.GetErrorList(str4.Trim(new char[] { ',' }));
if ((errorList != null) && (errorList.Count > 0))
{
using (enumerator = model.DataSource.GetEnumerator())
{
Predicate match = null;
DT_Order md;
while (enumerator.MoveNext())
{
md = enumerator.Current;
if (match == null)
{
match = n => n.OrderId == md.OrderId;
}
DT_OrderError error = errorList.Find(match);
if (error != null)
{
md.ErrorInfo = error.ErrorInfo;
}
}
}
}
}
List saleBackModelList = null;
if ((IsDetail == 1) && (model.DataSource != null))
{
int? trackType;
if (str4 != "")
{
List orderGoodsList = data.GetOrderGoodsList(str4.Trim(new char[] { ',' }));
List trackCodeApplyList = data.GetTrackCodeApplyList(str4.Trim(new char[] { ',' }));
saleBackModelList = data.GetSaleBackModelList(str4.Trim(new char[] { ',' }));
if (orderGoodsList != null)
{
using (enumerator = model.DataSource.GetEnumerator())
{
Predicate predicate2 = null;
DT_Order md;
while (enumerator.MoveNext())
{
md = enumerator.Current;
if (predicate2 == null)
{
predicate2 = n => n.OrderId == md.OrderId;
}
List list5 = orderGoodsList.FindAll(predicate2);
if (list5 != null)
{
md.GoodsList = list5;
}
}
}
}
if (trackCodeApplyList != null)
{
using (enumerator = model.DataSource.GetEnumerator())
{
Predicate predicate3 = null;
Predicate predicate4 = null;
DT_Order md;
while (enumerator.MoveNext())
{
md = enumerator.Current;
List list6 = new List();
if ((md.JoinOrderCode != null) && (md.JoinOrderCode != ""))
{
if (predicate3 == null)
{
predicate3 = n => n.OrderCode == md.JoinOrderCode;
}
list6 = trackCodeApplyList.FindAll(predicate3);
}
else
{
if (predicate4 == null)
{
predicate4 = n => n.OrderId == md.OrderId;
}
list6 = trackCodeApplyList.FindAll(predicate4);
}
if ((list6 != null) && (list6.Count > 0))
{
string str5 = "";
string str6 = "";
foreach (DT_TrackCodeApply apply in list6)
{
string str7 = "";
trackType = apply.TrackType;
if ((trackType.GetValueOrDefault() == 3) && trackType.HasValue)
{
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 num3 = Convert.ToDecimal((double)6.5);
List list7 = new BaseService().GetMoneyList2();
using (enumerator = model.DataSource.GetEnumerator())
{
Predicate predicate5 = null;
Predicate predicate6 = null;
DT_Order md;
while (enumerator.MoveNext())
{
decimal? nullable3;
md = enumerator.Current;
if (predicate5 == null)
{
predicate5 = delegate(JC_Money n)
{
int? nullable;
int? nullable2;
return (n.MCode == "USD") && (((nullable = n.PlatId).GetValueOrDefault() == (nullable2 = md.PlatId).GetValueOrDefault()) && (nullable.HasValue == nullable2.HasValue));
};
}
JC_Money money = list7.Find(predicate5);
if (money != null)
{
num3 = money.MRate.Value;
}
decimal num4 = 0M;
if (md.TotalPrice.HasValue)
{
num4 = md.TotalPrice.Value;
}
decimal num5 = 0M;
num5 = num4 * Convert.ToDecimal((double)0.15);
trackType = md.PlatId;
if ((trackType.GetValueOrDefault() == 1) && trackType.HasValue)
{
num5 = num4 * Convert.ToDecimal((double)0.05);
}
else
{
trackType = md.PlatId;
if ((trackType.GetValueOrDefault() == 4) && trackType.HasValue)
{
num5 = num4 * Convert.ToDecimal(0);
}
else
{
trackType = md.PlatId;
if ((trackType.GetValueOrDefault() == 5) && trackType.HasValue)
{
num5 = num4 * Convert.ToDecimal(0);
}
}
}
decimal num6 = 0M;
decimal num7 = 0M;
decimal num8 = 0M;
if (md.GoodsList != null)
{
foreach (DT_OrderGoods goods in md.GoodsList)
{
if (goods.GoodsFee.HasValue && (goods.GoodsFee.Value > 0M))
{
num6 += goods.GoodsFee.Value;
}
else if (goods.GoodsPrice.HasValue)
{
num6 += goods.GoodsPrice.Value * goods.GoodsNum.Value;
}
if (goods.TCFee.HasValue && (((nullable3 = goods.TCFee).GetValueOrDefault() > 0M) && nullable3.HasValue))
{
num7 += goods.TCFee.Value;
}
if (goods.Solid2.HasValue)
{
num8 += goods.Solid2.Value * goods.GoodsNum.Value;
}
}
}
if (num6 > 0M)
{
num6 /= num3;
}
decimal num9 = 0M;
if ((num7 == 0M) && (num8 > 0M))
{
num7 = Convert.ToDecimal(0x41) * num8;
}
if (md.escrowFee.HasValue)
{
num9 = md.escrowFee.Value;
}
decimal num10 = 0M;
if (md.PostFee.HasValue)
{
num10 = md.PostFee.Value;
}
decimal num11 = 0M;
decimal num12 = 0M;
trackType = md.OrderState2;
if (((trackType.GetValueOrDefault() == 1) && trackType.HasValue) && (saleBackModelList != null))
{
if (predicate6 == null)
{
predicate6 = n => n.OrderId == md.OrderId;
}
DT_OrderBackMoneyApply apply2 = saleBackModelList.Find(predicate6);
if (apply2 != null)
{
trackType = apply2.OrderState;
if ((trackType.GetValueOrDefault() == 0) && trackType.HasValue)
{
num5 *= Convert.ToDecimal((double)0.2);
num4 = 0M;
}
trackType = apply2.BackState;
if (((trackType.GetValueOrDefault() == 1) && trackType.HasValue) || (((trackType = apply2.BackState).GetValueOrDefault() == 2) && trackType.HasValue))
{
num6 = 0M;
}
if (apply2.FactPrice.HasValue)
{
num11 = apply2.FactPrice.Value;
}
if (apply2.PostFee.HasValue)
{
num12 = apply2.PostFee.Value;
}
}
}
decimal num13 = 0M;
if (md.Post == 0x41)
{
num13 = num10 * Convert.ToDecimal((double)0.1);
}
decimal num14 = 0M;
if (md.Fee6.HasValue && (((nullable3 = md.Fee6).GetValueOrDefault() > 0M) && nullable3.HasValue))
{
num14 = md.Fee6.Value;
}
else if (md.Fee7.HasValue && (((nullable3 = md.Fee7).GetValueOrDefault() > 0M) && nullable3.HasValue))
{
num14 = md.Fee7.Value;
}
else if (md.Fee8.HasValue && (((nullable3 = md.Fee8).GetValueOrDefault() > 0M) && nullable3.HasValue))
{
num14 = md.Fee8.Value;
}
if (md.Fee7.HasValue)
{
nullable3 = md.Fee7;
}
if (md.Fee7!=null&&md.Fee7.Value < num14)
{
num14 = md.Fee7.Value;
}
if (md.Fee8.HasValue)
{
nullable3 = md.Fee8;
}
if (md.Fee8!=null&&md.Fee8.Value < num14)
{
num14 = md.Fee8.Value;
}
md.PostFee = new decimal?(num10);
md.BoxFee = new decimal?(num14);
decimal num15 = 0M;
decimal num16 = 0M;
num15 = (((((((num4 - num5) - num6) - num9) - num10) - num13) - num7) - num11) - num12;
num16 = ((((((num4 - num5) - num6) - num9) - num14) - num7) - num11) - num12;
md.LR = new decimal?(Convert.ToDecimal(num15.ToString("0.00")));
md.YGLR = new decimal?(Convert.ToDecimal(num16.ToString("0.00")));
}
}
}
return model;
}
[WebMethod(EnableSession = true)]
public JsonModel> GetListOrderForTM22(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)
{
Pages.Login(base.Session);
DD_OrderData data = new DD_OrderData();
int num = Convert.ToInt32(base.Session["CompanyId"]);
RefParameterCollection where = new RefParameterCollection();
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 (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 == 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 (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 = data.GetListDT_OrderInfoForTM(num, str2.Trim(), str3.Trim(), trackCode, -1, IsDH, where, PageIndex, PageSize, Sort, out rowCount);
}
model.RowCount = rowCount;
string str4 = "";
if (model.DataSource != null)
{
foreach (DT_Order order in model.DataSource)
{
str4 = str4 + order.OrderId.ToString() + ",";
}
}
if (str4 != "")
{
List errorList = data.GetErrorList(str4.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 (str4 != "")
{
List orderGoodsList = data.GetOrderGoodsList(str4.Trim(','));
List trackCodeApplyList = data.GetTrackCodeApplyList(str4.Trim(','));
saleBackModelList = data.GetSaleBackModelList(str4.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 num3 = Convert.ToDecimal((double)6.5);
List list7 = new BaseService().GetMoneyList2();
foreach (var md in model.DataSource)
{
JC_Money money = list7.Find(n => n.MCode == "USD" && n.PlatId == md.PlatId);
if (money != null)
{
num3 = money.MRate.Value;
}
else
{
money = list7.Find(n => n.MCode == "USD");
num3 = money.MRate.Value;
}
decimal num4 = 0M;
if (md.TotalPrice.HasValue)
{
num4 = md.TotalPrice.Value;
}
decimal num5 = 0M;
num5 = num4 * Convert.ToDecimal((double)0.15);
trackType = md.PlatId;
if ((trackType.GetValueOrDefault() == 1) && trackType.HasValue)
{
num5 = num4 * Convert.ToDecimal((double)0.05);
}
else
{
trackType = md.PlatId;
if ((trackType.GetValueOrDefault() == 4) && trackType.HasValue)
{
num5 = num4 * Convert.ToDecimal(0);
}
else
{
trackType = md.PlatId;
if ((trackType.GetValueOrDefault() == 5) && trackType.HasValue)
{
num5 = num4 * Convert.ToDecimal(0);
}
}
}
decimal num6 = 0M;
decimal num7 = 0M;
decimal num8 = 0M;
if (md.GoodsList != null)
{
foreach (DT_OrderGoods goods in md.GoodsList)
{
if (goods.GoodsFee.HasValue && (goods.GoodsFee.Value > 0M))
{
num6 += goods.GoodsFee.Value;
}
else if (goods.GoodsPrice.HasValue)
{
num6 += goods.GoodsPrice.Value * goods.GoodsNum.Value;
}
if (goods.TCFee != null && goods.TCFee > 0)
{
num7 += goods.TCFee.Value;
}
if (goods.Solid2.HasValue)
{
num8 += goods.Solid2.Value * goods.GoodsNum.Value;
}
}
}
if (num6 > 0M)
{
num6 /= num3;
}
decimal num9 = 0M;
if ((num7 == 0M) && (num8 > 0M))
{
num7 = Convert.ToDecimal(0x41) * num8;
}
if (md.escrowFee.HasValue)
{
num9 = md.escrowFee.Value;
}
decimal num10 = 0M;
if (md.PostFee.HasValue)
{
num10 = md.PostFee.Value;
}
decimal num11 = 0M;
decimal num12 = 0M;
trackType = md.OrderState2;
if (((trackType.GetValueOrDefault() == 1) && trackType.HasValue) && (saleBackModelList != null))
{
DT_OrderBackMoneyApply apply2 = saleBackModelList.Find(n => n.OrderId == md.OrderId);
if (apply2 != null)
{
trackType = apply2.OrderState;
if ((trackType.GetValueOrDefault() == 0) && trackType.HasValue)
{
num5 *= Convert.ToDecimal((double)0.2);
num4 = 0M;
}
trackType = apply2.BackState;
if (((trackType.GetValueOrDefault() == 1) && trackType.HasValue) || (((trackType = apply2.BackState).GetValueOrDefault() == 2) && trackType.HasValue))
{
num6 = 0M;
}
if (apply2.FactPrice.HasValue)
{
num11 = apply2.FactPrice.Value;
}
if (apply2.PostFee.HasValue)
{
num12 = apply2.PostFee.Value;
}
}
}
decimal num13 = 0M;
if (md.Post == 0x41)
{
num13 = num10 * Convert.ToDecimal((double)0.1);
}
decimal num14 = 0M;
if (md.Fee6 != null && md.Fee6 > 0)
{
num14 = md.Fee6.Value;
}
else if (md.Fee7 != null && md.Fee7 > 0 && md.Fee7 < num14)
{
num14 = md.Fee7.Value;
}
else if (md.Fee8 != null && md.Fee8 > 0 && md.Fee8 < num14)
{
num14 = md.Fee8.Value;
}
md.PostFee = new decimal?(num10);
md.BoxFee = new decimal?(num14);
decimal num15 = 0M;
decimal num16 = 0M;
num15 = (((((((num4 - num5) - num6) - num9) - num10) - num13) - num7) - num11) - num12;
num16 = ((((((num4 - num5) - num6) - num9) - num14) - num7) - num11) - num12;
md.LR = new decimal?(Convert.ToDecimal(num15.ToString("0.00")));
md.YGLR = new decimal?(Convert.ToDecimal(num16.ToString("0.00")));
}
}
}
return model;
}
#region 查询返回跟踪码订单
[WebMethod(EnableSession = true)]
public JsonModel> GetListOrderBackCode(int BackState,int PostState,int PlatType, int ShopId, int DateType, DateTime? SDate, DateTime? EDate, int OutDays, int TjType, string Name, int PostId, int PageIndex, int PageSize)
{
Pages.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.TrackState", "=", BackState, 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.Today.AddDays(OutDays), DbType.DateTime);
}
Param.Add("a.PostState", "=", PostState, DbType.Int32);
Param.Add("a.State", ">", 0, DbType.Int32);
Param.Add("b.Post", ">", 0, DbType.Int32);
if (PostId>0)
Param.Add("b.Post", "=", PostId, DbType.Int32);
if (Name != "")
{
if (TjType == 1)
Param.Add("a.PlatOrderCode", "=", Name, 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;
}
resultModel.DataSource = obj.GetListDT_OrderTrackInfo(CompanyId, GoodsName, SKU, 0, Param, PageIndex, PageSize, Sort, out RowCount);
resultModel.RowCount = RowCount;
if (resultModel.DataSource != null)
{
BaseService obj2 = new BaseService();
var postlist = obj2.GetExpressPostList(CompanyId,0);
foreach (var md in resultModel.DataSource)
{
if (md.Post > 0 && postlist != null)
{
var pmd = postlist.Find(n => n.ExpressID == md.Post);
if (pmd != null)
{
md.PostInfo = pmd.Name;
}
else
md.PostInfo = "";
}
else
md.PostInfo = "";
}
}
return resultModel;
}
#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)
{
Pages.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);
}
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 tlist2 =new List();
if(hborders!="")
tlist2 = obj.Get_OrderTrackList3(hborders.Trim(','));
if (tlist != null || tlist2 != null)
{
foreach (var md in resultModel.DataSource)
{
var plist =new List();
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
#region 查询返回修改发货订单
[WebMethod(EnableSession = true)]
public JsonModel> GetListOrderSendGoods(int PlatType,int MateState, int IsDetail,int ShopId, int DateType, DateTime? SDate, DateTime? EDate, int OutDays, int TjType, string Name, int PostId, int PageIndex, int PageSize)
{
Pages.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 (OutDays > 0)
{
Param.Add("a.OrderOutDate", "<=", DateTime.Today.AddDays(OutDays), DbType.DateTime);
}
Param.Add("a.MateState", "=", MateState, DbType.Int32);
Param.Add("a.PostState", "in", "0,3", DbType.String);
Param.Add("a.State", "=", 1, DbType.Int32);
if (PostId > 0)
Param.Add("b.Post", "=", PostId, DbType.Int32);
if (Name != "")
{
if (TjType == 1)
Param.Add("a.PlatOrderCode", "=", Name, 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;
}
resultModel.DataSource = obj.GetListDT_OrderSendInfo(CompanyId, GoodsName, SKU, 0, Param, PageIndex, PageSize, Sort, out RowCount);
resultModel.RowCount = RowCount;
if (resultModel.DataSource != null)
{
BaseService obj2 = new BaseService();
var postlist = obj2.GetExpressPostList(CompanyId, 0);
foreach (var md in resultModel.DataSource)
{
if (md.Post > 0 && postlist != null)
{
var pmd = postlist.Find(n => n.ExpressID == md.Post);
if (pmd != null)
{
md.PostInfo = pmd.Name;
}
else
md.PostInfo = "";
}
else
md.PostInfo = "";
}
}
if (IsDetail == 1 && resultModel.DataSource != null)
{
string Ids = "";
foreach (var md in resultModel.DataSource)
{
Ids += md.OrderId.ToString() + ",";
}
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> GetListOrderWeightGoods(int PlatType, int State,int MateState, int IsDetail, int ShopId, int DateType, DateTime? SDate, DateTime? EDate, int OutDays, int TjType, string Name, int PostId, int PageIndex, int PageSize)
{
Pages.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 (OutDays > 0)
{
Param.Add("a.OrderOutDate", "<=", DateTime.Today.AddDays(OutDays), DbType.DateTime);
}
Param.Add("a.MateState", "=", MateState, DbType.Int32);
Param.Add("a.State", "=", State, DbType.Int32);
if (PostId > 0)
Param.Add("b.Post", "=", PostId, DbType.Int32);
if (Name != "")
{
if (TjType == 1)
Param.Add("a.PlatOrderCode", "=", Name, 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;
}
resultModel.DataSource = obj.GetListDT_OrderSendInfo(CompanyId, GoodsName, SKU, 0, Param, PageIndex, PageSize, Sort, out RowCount);
resultModel.RowCount = RowCount;
if (resultModel.DataSource != null)
{
BaseService obj2 = new BaseService();
var postlist = obj2.GetExpressPostList(CompanyId, 0);
foreach (var md in resultModel.DataSource)
{
if (md.Post > 0 && postlist != null)
{
var pmd = postlist.Find(n => n.ExpressID == md.Post);
if (pmd != null)
{
md.PostInfo = pmd.Name;
}
else
md.PostInfo = "";
}
else
md.PostInfo = "";
}
}
if (IsDetail == 1 && resultModel.DataSource != null)
{
string Ids = "";
foreach (var md in resultModel.DataSource)
{
Ids += md.OrderId.ToString() + ",";
}
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 string GetListExcelOrderWeightGoods(int PlatType, int State, int MateState, int IsDetail, int ShopId, int DateType, DateTime? SDate, DateTime? EDate, int OutDays, int TjType, string Name, int PostId)
{
Pages.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 (OutDays > 0)
{
Param.Add("a.OrderOutDate", "<=", DateTime.Today.AddDays(OutDays), DbType.DateTime);
}
Param.Add("a.MateState", "=", MateState, DbType.Int32);
Param.Add("a.State", "=", State, DbType.Int32);
if (PostId > 0)
Param.Add("b.Post", "=", PostId, DbType.Int32);
if (Name != "")
{
if (TjType == 1)
Param.Add("a.PlatOrderCode", "=", Name, 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>();
string Sort = "orderid desc";
string GoodsName = "";
string SKU = "";
if (TjType == 7 && Name != "")
{
GoodsName = Name;
}
else
if (TjType == 8 && Name != "")
{
SKU = Name;
}
DataTable tb= obj.GetExcelDT_OrderInfo(CompanyId, GoodsName, SKU, 0, Param, Sort);
TableColumnCollection listColumns = new TableColumnCollection();
listColumns.Add("PlatOrderCode", "订单号", DbType.String, "");
listColumns.Add("ShopName", "店铺", DbType.String, "");
listColumns.Add("OrderDate", "订单日期", DbType.String, "");
listColumns.Add("PostInfo", "物流渠道", DbType.String, "");
listColumns.Add("TrackCode", "跟踪码", DbType.String, "");
listColumns.Add("PostFee", "运费", DbType.String, "f2");
listColumns.Add("TotalWeight", "重量(克)", DbType.String, "f2");
MicrosoftExcel obj2 = new MicrosoftExcel();
return obj2.Export(tb, listColumns);
}
#endregion
#region 查询没匹配完的订单
[WebMethod(EnableSession = true)]
public JsonModel> GetListOrderMate(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 OutDays, int PageIndex, int PageSize)
{
Pages.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 (OutDays > 0)
{
Param.Add("a.OrderOutDate", "<=", DateTime.Today.AddDays(OutDays), DbType.DateTime);
}
//if (MateState>-1)
//{
Param.Add("a.PostState", "in", "0,3", DbType.String);
//}
if (PostId > 0)
Param.Add("b.Post", "=", PostId, DbType.Int32);
//else if(IsPost==1)
// Param.Add("a.PostState", "=", 0, DbType.Int32);
if (MateState > -1)
Param.Add("a.MateState", "=", MateState, 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);
}
if (Name != "")
{
if (TjType == 1)
Param.Add("a.PlatOrderCode", "=", Name, 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;
var pxlist = obj.GetLevelConfig(CompanyId,0);
string Sort = "orderid desc";
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 = obj.GetListDT_OrderInfoMate(GoodsName, SKU, IsSku, Param, PageIndex, PageSize, Sort, out RowCount);
resultModel.RowCount = RowCount;
if (resultModel.DataSource != null)
{
BaseService obj2 = new BaseService();
var postlist = obj2.GetExpressPostList(CompanyId, 0);
foreach (var md in resultModel.DataSource)
{
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)
{
string Ids = "";
foreach (var md in resultModel.DataSource)
{
Ids += md.OrderId.ToString() + ",";
}
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> GetListOrderMateForTM(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 IsFBA,int IsPost, int OutDays, int PageIndex, int PageSize)
{
Pages.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 (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(IsFBA==1)
Param.Add("a.IsFBA", "=", "1", 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 = obj.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> GetListOrderMateForTM2(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)
{
Pages.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 (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 = obj.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> GetListOrderExpress(int SortId, 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, string PostInfo, int Addr, int PageIndex, int PageSize)
{
Pages.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 (MateState>-1)
Param.Add("a.MateState", "=", MateState, DbType.Int32);
int IsTrack = TrackState;
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.Today.AddDays(OutDays), DbType.DateTime);
}
if (ExpressState==0)
{
Param.Add("b.Post", "=", 0, DbType.Int32);
if(PostInfo!="-全部-")
Param.Add("b.PostInfo", "=", PostInfo, DbType.String);
}
if (ExpressState == 1)
{
Param.Add("b.Post", ">", 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);
}
if (Name != "")
{
if (TjType == 1)
Param.Add("a.PlatOrderCode", "=", Name, 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);
}
}
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 = "orderid desc";
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 = obj.GetListDT_OrderInfoExpress(SortId,IsTrack, GoodsName, SKU, IsSku, Param, PageIndex, PageSize, Sort, out RowCount);
resultModel.RowCount = RowCount;
if (resultModel.DataSource != null)
{
BaseService obj2 = new BaseService();
var postlist=obj2.GetExpressPostList(CompanyId,0);
foreach (var md in resultModel.DataSource)
{
if (md.IsSpare == 1)
{
string TrackCodes = "拆分发包:
";
var splist = obj.GetOrderSpareList(md.OrderId.Value);
if (splist != null)
{
for (int i = 0; i < splist.Count;i++)
{
if (i % 2 == 1 && splist[i].TrackCode!=null)
TrackCodes += splist[i].TrackCode.ToString() + "
";
else if (splist[i].TrackCode != null)
TrackCodes += splist[i].TrackCode.ToString() + ",";
}
}
md.TrackCode = TrackCodes.Trim(',');
}
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)
{
string Ids = "";
foreach (var md in resultModel.DataSource)
{
Ids += md.OrderId.ToString() + ",";
}
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> 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)
{
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);
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 查询线上物流订单
[WebMethod(EnableSession = true)]
public JsonModel> GetListOrderOnlineExpress(int SortId, 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, string PostId, int Addr, int PageIndex, int PageSize)
{
Pages.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 (MateState > -1)
Param.Add("a.MateState", "=", MateState, DbType.Int32);
int IsTrack = TrackState;
Param.Add("a.PlatId", "=", 1, 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.Today.AddDays(OutDays), DbType.DateTime);
}
if (ExpressState == 0)
{
Param.Add("b.Post", "=", 0, DbType.Int32);
}
if (ExpressState == 1)
{
Param.Add("b.Post", "=", 9, DbType.Int32);
}
if (PostId!="0")
Param.Add("b.OnlinePostId", "=", PostId, DbType.String);
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);
}
if (Name != "")
{
if (TjType == 1)
Param.Add("a.PlatOrderCode", "=", Name, 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);
}
}
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 = "shopId,orderid desc";
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 = obj.GetOnlineDT_OrderInfoExpress(SortId, IsTrack, GoodsName, SKU, IsSku, Param, PageIndex, PageSize, Sort, out RowCount);
resultModel.RowCount = RowCount;
if (resultModel.DataSource != null)
{
BaseService obj2 = new BaseService();
var postlist = obj2.GetOnlineLogisticsList();
foreach (var md in resultModel.DataSource)
{
if (md.OnlinePostId != null && md.OnlinePostId!="" && postlist != null)
{
var pmd = postlist.Find(n => n.logisticsServiceId == md.OnlinePostId);
if (pmd != null)
{
md.LocalPost = pmd.logisticsServiceName;
}
else
md.LocalPost = "";
}
else
md.LocalPost = "";
}
}
if (IsDetail == 1 && resultModel.DataSource != null)
{
string Ids = "";
foreach (var md in resultModel.DataSource)
{
Ids += md.OrderId.ToString() + ",";
}
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> GetListOrderOnlineExpressForTM(int SortId, 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, string PostId, int Addr, int PageIndex, int PageSize)
{
Pages.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 (MateState > -1)
Param.Add("a.MateState", "=", MateState, DbType.Int32);
int IsTrack = TrackState;
Param.Add("a.PlatId", "=", 1, 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.Today.AddDays(OutDays), DbType.DateTime);
}
if (ExpressState == 0)
{
Param.Add("isnull(b.LogisticsId,0)", "=", 0, DbType.Int32);
}
if (ExpressState == 1)
{
Param.Add("b.LogisticsId", "=", 9, DbType.Int32);
}
if (PostId != "0")
Param.Add("b.OnlinePostId", "=", PostId, DbType.String);
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);
}
if (Name != "")
{
if (TjType == 1)
Param.Add("a.PlatOrderCode", "=", Name, 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);
}
}
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 = "shopId,orderid desc";
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 = obj.GetOnlineDT_OrderInfoExpress(SortId, IsTrack, GoodsName, SKU, IsSku, Param, PageIndex, PageSize, Sort, out RowCount);
resultModel.RowCount = RowCount;
if (resultModel.DataSource != null)
{
BaseService obj2 = new BaseService();
var postlist = obj2.GetOnlineLogisticsList();
foreach (var md in resultModel.DataSource)
{
if (md.OnlinePostId != null && md.OnlinePostId != "" && postlist != null)
{
var pmd = postlist.Find(n => n.logisticsServiceId == md.OnlinePostId);
if (pmd != null)
{
md.LocalPost = pmd.logisticsServiceName;
}
else
md.LocalPost = "";
}
else
md.LocalPost = "";
}
}
if (IsDetail == 1 && resultModel.DataSource != null)
{
string Ids = "";
foreach (var md in resultModel.DataSource)
{
Ids += md.OrderId.ToString() + ",";
}
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 void MateOrderGoods(List list)
{
Pages.Login(this.Session);
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
var obj = new DD_OrderData();
if (list != null)
{
foreach (var md in list)
{
obj.MateGoods(CompanyId,md.OrderId.Value, md.MateState.Value);
}
}
}
#endregion
#region 全部匹配订单货物
[WebMethod(EnableSession = true)]
public void AllMateOrderGoods(int PlatType, int ShopId, DateTime? SDate, DateTime? EDate, DateTime? SDate1, DateTime? EDate1, int TjType, string Name, int MateState, int IsSku, int IsError,int HBOrder)
{
Pages.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 (SDate != null)
Param.Add("a.OrderDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.OrderDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
if (SDate1 != null)
Param.Add("a.InDate", ">=", SDate1, DbType.DateTime);
if (EDate1 != null)
Param.Add("a.InDate", "<", EDate1.Value.AddDays(1), DbType.DateTime);
if (MateState > -1 && MateState<2)
Param.Add("a.MateState", "=", MateState, DbType.Int32);
else if (MateState == -1)
{
Param.Add("a.MateState", ">=", 0, DbType.Int32);
Param.Add("a.MateState", "<", 2, DbType.Int32);
}
else
if (MateState == 2)
{
return;
}
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);
}
if (Name != "")
{
if (TjType == 1)
Param.Add("a.PlatOrderCode", "like", Name, DbType.String);
else if (TjType == 2)
Param.Add("b.RevName", "like", Name, DbType.String);
}
Param.Add("a.OrderDate", ">=", 0, DbType.Int32);
List resultModel = new List();
string Sort = "orderid desc";
var pxlist = obj.GetLevelConfig(CompanyId, 0);
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 == 3 && Name != "")
{
GoodsName = Name;
}
else
if (TjType == 4 && Name != "")
{
SKU = Name;
}
resultModel = obj.GetAllListDT_OrderInfo(CompanyId, GoodsName, SKU, IsSku, Param, Sort);
if (resultModel != null)
{
foreach (var md in resultModel)
{
obj.MateGoods(CompanyId,md.OrderId.Value, md.MateState.Value);
}
}
}
#endregion
#region 全部订单锁定匹配货物
[WebMethod(EnableSession = true)]
public string AllOrderGoodsLock(int IsError)
{
Pages.Login(this.Session);
var obj = new DD_OrderData();
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 = "orderid desc";
var pxlist = obj.GetLevelConfig(CompanyId, 0);
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 += "d.LevelGrade desc,";
else if (md.SortType == 4)
Sort += "a.RMBPrice desc,";
}
Sort += "a.Orderid";
}
Sort = Sort.Trim(',');
var orderlist = obj.GetLockOrderList(CompanyId, IsError, Sort);
var list = obj.GetLockOrderGoods(CompanyId, IsError);
//var list1 = obj.GetAllOrderGoodsInList(CompanyId, IsError);
if (orderlist != null)
{
foreach (var ordermd in orderlist)
{
bool flag = false; //匹配状态
int IsFba = 0;
if (ordermd.IsFba != null)
IsFba = ordermd.IsFba.Value;
string ShopId = "," + ordermd.ShopId.ToString() + ",";
string CountryCode = "";
if (ordermd.RevCountry != null)
CountryCode = "," + ordermd.RevCountry.ToLower() + ",";
List listGoods = new List();
List OutList = new List();
var Goodslist = list.FindAll(n => n.OrderId == ordermd.OrderId);
if (Goodslist != null)
{
foreach (var goodsmd in Goodslist)
{
flag = false;
List OutList1 = new List();
DT_OrderGoods mdOrderGoods = new DT_OrderGoods();
mdOrderGoods.Id = goodsmd.Id;
var inlist = obj.GetMateOrderGoodsInList(ordermd.OrderId.Value, goodsmd.DetailId.Value); //list1.FindAll(n => n.DetailId == goodsmd.DetailId);
int StoreId = 0;
int LockNum = 0;
int GoodsNum = goodsmd.GoodsNum.Value;
int LeftLockNum = goodsmd.GoodsNum.Value;
if (inlist == null) //没有匹配货物
{
flag = false;
break;
}
else
{
foreach (var inmd in inlist)
{
if (StoreId > 0 && StoreId != inmd.StoreId.Value) //不同仓库
{
LockNum = 0;
LeftLockNum = GoodsNum;
OutList1.Clear();
}
StoreId = inmd.StoreId.Value;
if (IsFba == 1 && inmd.StoreType != 2) //不是海外仓
{
continue;
}
else if (IsFba == 0 && inmd.StoreType == 2) //海外仓不支持
{
string useshops = "," + inmd.UseShop + ",";
string usecountrys = "," + inmd.UseCountry.ToLower() + ",";
if (!useshops.Contains(ShopId) || !usecountrys.Contains(CountryCode))
continue;
}
DT_OrderGoodsOutList mdOut = new DT_OrderGoodsOutList();
mdOut.OrderGoodsId = goodsmd.Id;
mdOut.OrderId = ordermd.OrderId.Value;
if (LeftLockNum > inmd.GoodsNum.Value)
mdOut.LockNum = inmd.GoodsNum.Value;
else
mdOut.LockNum = LeftLockNum;
mdOut.Price = inmd.Price;
mdOut.PostPrice = inmd.PostPrice;
mdOut.InId = inmd.InId;
OutList1.Add(mdOut);
if (LeftLockNum > inmd.GoodsNum.Value)
{
LockNum += inmd.GoodsNum.Value;
LeftLockNum -= inmd.GoodsNum.Value;
}
else
{
LockNum += LeftLockNum;
LeftLockNum = 0;
}
if (LockNum >= GoodsNum) //循环时候就满足数量
{
flag = true;
break;
}
}
if (LockNum < GoodsNum) //循环完还是不满足数量
{
flag = false;
OutList1.Clear();
listGoods.Clear();
break; //库存不满足,不匹配
}
else
{
flag = true;
if (OutList1 != null)
{
foreach (var md in OutList1)
{
OutList.Add(md);
}
}
listGoods.Add(mdOrderGoods);
}
}
}
if (flag == true)
{
decimal GoodsFee = 0; //货物采购均价
decimal PostFee = 0;//货物快递成本
if (OutList != null)
{
int Num = 0;
foreach (var md in OutList)
{
Num += md.LockNum.Value;
if (md.Price != null)
GoodsFee += md.Price.Value * md.LockNum.Value;
if (md.PostPrice != null)
PostFee += md.PostPrice.Value * md.LockNum.Value;
}
GoodsFee = GoodsFee / Num;
PostFee = PostFee / Num;
}
obj.UpdateOrderGoodsLock(ordermd.OrderId.Value, GoodsFee, PostFee, listGoods, OutList);
}
}
}
}
}
catch(Exception ex)
{
BaseService.UnSyncLock(CompanyId, 2, DateTime.Now);
return ex.Message;
}
BaseService.UnSyncLock(CompanyId, 2, DateTime.Now);
return "分配完成";
}
#endregion
#region 选择订单锁定匹配货物
[WebMethod(EnableSession = true)]
public string PartOrderGoodsLock(int IsError,string OrderIds)
{
Pages.Login(this.Session);
var obj = new DD_OrderData();
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 = "orderid desc";
var pxlist = obj.GetLevelConfig(CompanyId, 0);
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 += "d.LevelGrade desc,";
else if (md.SortType == 4)
Sort += "a.RMBPrice desc,";
}
Sort += "a.Orderid";
}
Sort = Sort.Trim(',');
var orderlist = obj.GetLockPartOrderList(CompanyId,OrderIds.Trim(','), IsError, Sort);
var list = obj.GetLockPartOrderGoods(CompanyId, OrderIds.Trim(','), IsError);
//var list1 = obj.GetAllOrderGoodsInList(CompanyId, IsError);
if (orderlist != null)
{
bool allflag = true; //完全匹配状态
foreach (var ordermd in orderlist)
{
bool flag = false; //匹配状态
int IsFba = 0;
if (ordermd.IsFba != null)
IsFba = ordermd.IsFba.Value;
string ShopId = "," + ordermd.ShopId.ToString() + ",";
string CountryCode = "";
if (ordermd.RevCountry != null)
CountryCode = "," + ordermd.RevCountry.ToLower() + ",";
List listGoods = new List();
List OutList = new List();
var Goodslist = list.FindAll(n => n.OrderId == ordermd.OrderId);
if (Goodslist != null)
{
foreach (var goodsmd in Goodslist)
{
flag = false;
List OutList1 = new List();
DT_OrderGoods mdOrderGoods = new DT_OrderGoods();
mdOrderGoods.Id = goodsmd.Id;
var inlist = obj.GetMateOrderGoodsInList(ordermd.OrderId.Value, goodsmd.DetailId.Value); //list1.FindAll(n => n.DetailId == goodsmd.DetailId);
int StoreId = 0;
int LockNum = 0;
if (goodsmd.LockNum != null)
LockNum = goodsmd.LockNum.Value;
int OutNum = 0;
if (goodsmd.OutNum != null)
OutNum = goodsmd.OutNum.Value;
int GoodsNum = goodsmd.GoodsNum.Value - LockNum;
int LeftLockNum = GoodsNum;
if (inlist == null) //没有匹配货物
{
flag = false;
allflag = false;
continue;
}
else
{
foreach (var inmd in inlist)
{
if (StoreId > 0 && StoreId != inmd.StoreId.Value) //不同仓库
{
LockNum = 0;
if (goodsmd.LockNum != null)
LockNum = goodsmd.LockNum.Value;
LeftLockNum = GoodsNum;
OutList1.Clear();
}
StoreId = inmd.StoreId.Value;
if (IsFba == 1 && inmd.StoreType != 2) //不是海外仓
{
continue;
}
else if (IsFba == 0 && inmd.StoreType == 2) //海外仓不支持
{
string useshops = "," + inmd.UseShop + ",";
string usecountrys = "," + inmd.UseCountry.ToLower() + ",";
if (!useshops.Contains(ShopId) || !usecountrys.Contains(CountryCode))
continue;
}
DT_OrderGoodsOutList mdOut = new DT_OrderGoodsOutList();
mdOut.OrderGoodsId = goodsmd.Id;
mdOut.OrderId = ordermd.OrderId.Value;
if (LeftLockNum > inmd.GoodsNum.Value)
mdOut.LockNum = inmd.GoodsNum.Value;
else
mdOut.LockNum = LeftLockNum;
mdOut.Price = inmd.Price;
mdOut.PostPrice = inmd.PostPrice;
mdOut.InId = inmd.InId;
OutList1.Add(mdOut);
if (LeftLockNum > inmd.GoodsNum.Value)
{
LockNum += inmd.GoodsNum.Value;
LeftLockNum -= inmd.GoodsNum.Value;
}
else
{
LockNum += LeftLockNum;
LeftLockNum = 0;
}
if (LockNum >= GoodsNum) //循环时候就满足数量
{
flag = true;
break;
}
}
if (LockNum < GoodsNum) //循环完还是不满足数量
{
flag = false;
//OutList1.Clear();
//listGoods.Clear();
allflag = false;
//break; //库存不满足,不匹配
}
else
{
flag = true;
}
if (OutList1 != null)
{
foreach (var md in OutList1)
{
OutList.Add(md);
}
}
mdOrderGoods.LockNum =GoodsNum-LeftLockNum;
listGoods.Add(mdOrderGoods);
}
}
decimal GoodsFee = 0; //货物采购均价
decimal PostFee = 0;//货物快递成本
if (OutList != null)
{
int Num = 0;
foreach (var md in OutList)
{
Num += md.LockNum.Value;
if (md.Price != null)
GoodsFee += md.Price.Value * md.LockNum.Value;
if (md.PostPrice != null)
PostFee += md.PostPrice.Value * md.LockNum.Value;
}
if (Num > 0)
{
GoodsFee = GoodsFee / Num;
PostFee = PostFee / Num;
}
}
if (allflag == true&&flag == true)
{
obj.UpdateOrderGoodsLockNew(ordermd.OrderId.Value,2, GoodsFee, PostFee, listGoods, OutList);
}
else if (listGoods.Count>0)
obj.UpdateOrderGoodsLockNew(ordermd.OrderId.Value, 1, GoodsFee, PostFee, listGoods, OutList);
}
}
}
}
catch (Exception ex)
{
BaseService.UnSyncLock(CompanyId, 2, DateTime.Now);
return ex.Message;
}
BaseService.UnSyncLock(CompanyId, 2, DateTime.Now);
return "分配完成";
}
#endregion
#region 全部订单锁定匹配货物
[WebMethod(EnableSession = true)]
public string AllOrderGoodsLockNew(int IsError)
{
Pages.Login(this.Session);
var obj = new DD_OrderData();
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 = "orderid desc";
var pxlist = obj.GetLevelConfig(CompanyId, 0);
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 += "d.LevelGrade desc,";
else if (md.SortType == 4)
Sort += "a.RMBPrice desc,";
}
Sort += "a.Orderid";
}
Sort = Sort.Trim(',');
var orderlist = obj.GetLockOrderList(CompanyId, IsError, Sort);
var list = obj.GetLockOrderGoods(CompanyId, IsError);
//var list1 = obj.GetAllOrderGoodsInList(CompanyId, IsError);
if (orderlist != null)
{
foreach (var ordermd in orderlist)
{
bool flag = false; //匹配状态
int IsFba = 0;
if (ordermd.IsFba != null)
IsFba = ordermd.IsFba.Value;
string ShopId = "," + ordermd.ShopId.ToString() + ",";
string CountryCode = "";
if (ordermd.RevCountry != null)
CountryCode = "," + ordermd.RevCountry.ToLower() + ",";
List listGoods = new List();
List OutList = new List();
var Goodslist = list.FindAll(n => n.OrderId == ordermd.OrderId);
if (Goodslist != null)
{
foreach (var goodsmd in Goodslist)
{
flag = false;
List OutList1 = new List();
DT_OrderGoods mdOrderGoods = new DT_OrderGoods();
mdOrderGoods.Id = goodsmd.Id;
var inlist = obj.GetMateOrderGoodsInList(ordermd.OrderId.Value, goodsmd.DetailId.Value); //list1.FindAll(n => n.DetailId == goodsmd.DetailId);
int StoreId = 0;
int LockNum = 0;
if (goodsmd.LockNum != null)
LockNum = goodsmd.LockNum.Value;
int OutNum = 0;
if(goodsmd.OutNum!=null)
OutNum=goodsmd.OutNum.Value;
int GoodsNum = goodsmd.GoodsNum.Value - LockNum;
int LeftLockNum = GoodsNum;
if (LeftLockNum == 0)
continue;
if (inlist == null) //没有匹配货物
{
flag = false;
break;
}
else
{
foreach (var inmd in inlist)
{
if (StoreId > 0 && StoreId != inmd.StoreId.Value) //不同仓库
{
LockNum = 0;
if (goodsmd.LockNum != null)
LockNum = goodsmd.LockNum.Value;
LeftLockNum = GoodsNum;
OutList1.Clear();
}
StoreId = inmd.StoreId.Value;
if (IsFba == 1 && inmd.StoreType != 2) //不是海外仓
{
continue;
}
else if (IsFba == 0 && inmd.StoreType == 2) //海外仓不支持
{
string useshops = "," + inmd.UseShop + ",";
string usecountrys = "," + inmd.UseCountry.ToLower() + ",";
if (!useshops.Contains(ShopId) || !usecountrys.Contains(CountryCode))
continue;
}
DT_OrderGoodsOutList mdOut = new DT_OrderGoodsOutList();
mdOut.OrderGoodsId = goodsmd.Id;
mdOut.OrderId = ordermd.OrderId.Value;
if (LeftLockNum > inmd.GoodsNum.Value)
mdOut.LockNum = inmd.GoodsNum.Value;
else
mdOut.LockNum = LeftLockNum;
mdOut.Price = inmd.Price;
mdOut.PostPrice = inmd.PostPrice;
mdOut.InId = inmd.InId;
OutList1.Add(mdOut);
if (LeftLockNum > inmd.GoodsNum.Value)
{
LockNum += inmd.GoodsNum.Value;
LeftLockNum -= inmd.GoodsNum.Value;
}
else
{
LockNum += LeftLockNum;
LeftLockNum = 0;
}
if (LockNum >= GoodsNum) //循环时候就满足数量
{
flag = true;
break;
}
}
if (LockNum < GoodsNum) //循环完还是不满足数量
{
flag = false;
OutList1.Clear();
listGoods.Clear();
break; //库存不满足,不匹配
}
else
{
flag = true;
if (OutList1 != null)
{
foreach (var md in OutList1)
{
OutList.Add(md);
}
}
mdOrderGoods.LockNum = GoodsNum;
listGoods.Add(mdOrderGoods);
}
}
}
if (flag == true)
{
decimal GoodsFee = 0; //货物采购均价
decimal PostFee = 0;//货物快递成本
if (OutList != null)
{
int Num = 0;
foreach (var md in OutList)
{
Num += md.LockNum.Value;
if (md.Price != null)
GoodsFee += md.Price.Value * md.LockNum.Value;
if (md.PostPrice != null)
PostFee += md.PostPrice.Value * md.LockNum.Value;
}
GoodsFee = GoodsFee / Num;
PostFee = PostFee / Num;
}
obj.UpdateOrderGoodsLockNew(ordermd.OrderId.Value,2, GoodsFee, PostFee, listGoods, OutList);
}
}
}
}
}
catch (Exception ex)
{
BaseService.UnSyncLock(CompanyId, 2, DateTime.Now);
return ex.Message;
}
BaseService.UnSyncLock(CompanyId, 2, DateTime.Now);
return "分配完成";
}
#endregion
#region 选择订单锁定匹配货物
[WebMethod(EnableSession = true)]
public string PartOrderGoodsLockNew(int IsError, string OrderIds)
{
Pages.Login(this.Session);
var obj = new DD_OrderData();
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 = "orderid desc";
var pxlist = obj.GetLevelConfig(CompanyId, 0);
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 += "d.LevelGrade desc,";
else if (md.SortType == 4)
Sort += "a.RMBPrice desc,";
}
Sort += "a.Orderid";
}
Sort = Sort.Trim(',');
var orderlist = obj.GetLockPartOrderList(CompanyId, OrderIds.Trim(','), IsError, Sort);
var list = obj.GetLockPartOrderGoods(CompanyId, OrderIds.Trim(','), IsError);
//var list1 = obj.GetAllOrderGoodsInList(CompanyId, IsError);
if (orderlist != null && list!=null)
{
foreach (var ordermd in orderlist)
{
bool allflag = true; //完全匹配状态
bool flag = false; //匹配状态
int IsFba = 0;
if (ordermd.IsFba != null)
IsFba = ordermd.IsFba.Value;
string ShopId = "," + ordermd.ShopId.ToString() + ",";
string CountryCode = "";
if (ordermd.RevCountry != null)
CountryCode = "," + ordermd.RevCountry.ToLower() + ",";
List listGoods = new List();
List OutList = new List();
var Goodslist = list.FindAll(n => n.OrderId == ordermd.OrderId);
if (Goodslist != null)
{
foreach (var goodsmd in Goodslist)
{
flag = false;
List OutList1 = new List();
DT_OrderGoods mdOrderGoods = new DT_OrderGoods();
mdOrderGoods.Id = goodsmd.Id;
var inlist = obj.GetMateOrderGoodsInListNew(ordermd.OrderId.Value, goodsmd.DetailId.Value); //list1.FindAll(n => n.DetailId == goodsmd.DetailId);
int StoreId = 0;
int LockNum = 0;
if (goodsmd.LockNum != null)
LockNum = goodsmd.LockNum.Value;
int OutNum = 0;
if (goodsmd.OutNum != null)
OutNum = goodsmd.OutNum.Value;
int GoodsNum = goodsmd.GoodsNum.Value - LockNum;
int LeftLockNum = GoodsNum;
if (inlist == null || inlist.Count==0) //没有匹配货物
{
flag = false;
allflag = false;
continue;
}
else
{
foreach (var inmd in inlist)
{
if (StoreId > 0 && StoreId != inmd.StoreId.Value) //不同仓库
{
LockNum = 0;
if (goodsmd.LockNum != null)
LockNum = goodsmd.LockNum.Value;
GoodsNum = goodsmd.GoodsNum.Value - LockNum;
LeftLockNum = GoodsNum;
OutList1.Clear();
}
StoreId = inmd.StoreId.Value;
if (IsFba == 1 && inmd.StoreType != 2) //不是海外仓
{
continue;
}
else if (IsFba == 0 && inmd.StoreType == 2) //海外仓不支持
{
string useshops = "," + inmd.UseShop + ",";
string usecountrys = "," + inmd.UseCountry.ToLower() + ",";
if (!useshops.Contains(ShopId) || !usecountrys.Contains(CountryCode))
continue;
}
HW_GoodsInDetail mdOut = new HW_GoodsInDetail();
mdOut.OrderGoodsId = goodsmd.Id;
mdOut.Price = inmd.Price;
mdOut.PostPrice = inmd.PostPrice;
mdOut.InId = inmd.InId;
OutList1.Add(mdOut);
if (LeftLockNum > 1)
{
LockNum += 1;
LeftLockNum -= 1;
}
else
{
LockNum += LeftLockNum;
LeftLockNum = 0;
}
if (LockNum >= GoodsNum) //循环时候就满足数量
{
flag = true;
break;
}
}
if (LockNum < GoodsNum) //循环完还是不满足数量
{
flag = false;
//OutList1.Clear();
//listGoods.Clear();
allflag = false;
//break; //库存不满足,不匹配
}
else
{
flag = true;
}
if (OutList1 != null)
{
foreach (var md in OutList1)
{
OutList.Add(md);
}
}
mdOrderGoods.LockNum = GoodsNum - LeftLockNum;
listGoods.Add(mdOrderGoods);
}
}
decimal GoodsFee = 0; //货物采购均价
decimal PostFee = 0;//货物快递成本
if (OutList != null)
{
int Num = OutList.Count;
foreach (var md in OutList)
{
if (md.Price != null)
GoodsFee += md.Price.Value;
if (md.PostPrice != null)
PostFee += md.PostPrice.Value;
}
if (Num > 0)
{
GoodsFee = GoodsFee / Num;
PostFee = PostFee / Num;
}
}
if (allflag == true && flag == true)
{
obj.UpdateOrderGoodsLockNew2(ordermd.OrderId.Value, 2, GoodsFee, PostFee, listGoods, OutList);
}
else if (listGoods.Count > 0)
obj.UpdateOrderGoodsLockNew2(ordermd.OrderId.Value, 1, GoodsFee, PostFee, listGoods, OutList);
}
}
}
}
catch (Exception ex)
{
BaseService.UnSyncLock(CompanyId, 2, DateTime.Now);
return ex.Message;
}
BaseService.UnSyncLock(CompanyId, 2, DateTime.Now);
return "分配完成";
}
#endregion
#region 全部订单锁定匹配货物
[WebMethod(EnableSession = true)]
public string AllOrderGoodsLockNew2(int IsError)
{
Pages.Login(this.Session);
var obj = new DD_OrderData();
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 = "orderid desc";
var pxlist = obj.GetLevelConfig(CompanyId, 0);
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 += "d.LevelGrade desc,";
else if (md.SortType == 4)
Sort += "a.RMBPrice desc,";
}
Sort += "a.Orderid";
}
Sort = Sort.Trim(',');
var orderlist = obj.GetLockOrderList(CompanyId, IsError, Sort);
var list = obj.GetLockOrderGoods(CompanyId, IsError);
//var list1 = obj.GetAllOrderGoodsInList(CompanyId, IsError);
if (orderlist != null)
{
foreach (var ordermd in orderlist)
{
bool flag = false; //匹配状态
int IsFba = 0;
if (ordermd.IsFba != null)
IsFba = ordermd.IsFba.Value;
string ShopId = "," + ordermd.ShopId.ToString() + ",";
string CountryCode = "";
if (ordermd.RevCountry != null)
CountryCode = "," + ordermd.RevCountry.ToLower() + ",";
List listGoods = new List();
List OutList = new List();
var Goodslist = list.FindAll(n => n.OrderId == ordermd.OrderId);
if (Goodslist != null)
{
foreach (var goodsmd in Goodslist)
{
List OutList1 = new List();
DT_OrderGoods mdOrderGoods = new DT_OrderGoods();
mdOrderGoods.Id = goodsmd.Id;
var inlist = obj.GetMateOrderGoodsInListNew(ordermd.OrderId.Value, goodsmd.DetailId.Value); //list1.FindAll(n => n.DetailId == goodsmd.DetailId);
int StoreId = 0;
int LockNum = 0;
if (goodsmd.LockNum != null)
LockNum = goodsmd.LockNum.Value;
int OutNum = 0;
if (goodsmd.OutNum != null)
OutNum = goodsmd.OutNum.Value;
int GoodsNum = goodsmd.GoodsNum.Value - LockNum;
int LeftLockNum = GoodsNum;
if (LeftLockNum == 0)
{
continue;
}
else
flag = false;
if (inlist == null || inlist.Count < LeftLockNum) //没有匹配货物或者货物不够
{
flag = false;
break;
}
else
{
foreach (var inmd in inlist)
{
if (StoreId > 0 && StoreId != inmd.StoreId.Value) //不同仓库
{
LockNum = 0;
if (goodsmd.LockNum != null)
LockNum = goodsmd.LockNum.Value;
GoodsNum = goodsmd.GoodsNum.Value - LockNum;
LeftLockNum = GoodsNum;
OutList1.Clear();
}
StoreId = inmd.StoreId.Value;
if (IsFba == 1 && inmd.StoreType != 2) //不是海外仓
{
continue;
}
else if (IsFba == 0 && inmd.StoreType == 2) //海外仓不支持
{
string useshops = "," + inmd.UseShop + ",";
string usecountrys = "," + inmd.UseCountry.ToLower() + ",";
if (!useshops.Contains(ShopId) || !usecountrys.Contains(CountryCode))
continue;
}
HW_GoodsInDetail mdOut = new HW_GoodsInDetail();
mdOut.OrderGoodsId = goodsmd.Id;
mdOut.Price = inmd.Price;
mdOut.PostPrice = inmd.PostPrice;
mdOut.InId = inmd.InId;
OutList1.Add(mdOut);
if (LeftLockNum > 1)
{
LockNum += 1;
LeftLockNum -=1;
}
else
{
LockNum += LeftLockNum;
LeftLockNum = 0;
}
if (LockNum >= GoodsNum) //循环时候就满足数量
{
flag = true;
break;
}
}
if (LockNum < GoodsNum) //循环完还是不满足数量
{
flag = false;
OutList1.Clear();
listGoods.Clear();
break; //库存不满足,不匹配
}
else
{
flag = true;
if (OutList1 != null)
{
foreach (var md in OutList1)
{
OutList.Add(md);
}
}
mdOrderGoods.LockNum = GoodsNum;
listGoods.Add(mdOrderGoods);
}
}
}
if (flag == true)
{
decimal GoodsFee = 0; //货物采购均价
decimal PostFee = 0;//货物快递成本
if (OutList != null)
{
int Num = OutList.Count;
foreach (var md in OutList)
{
if (md.Price != null)
GoodsFee += md.Price.Value ;
if (md.PostPrice != null)
PostFee += md.PostPrice.Value;
}
GoodsFee = GoodsFee / Num;
PostFee = PostFee / Num;
}
obj.UpdateOrderGoodsLockNew2(ordermd.OrderId.Value, 2, GoodsFee, PostFee, listGoods, OutList);
}
}
}
}
}
catch (Exception ex)
{
BaseService.UnSyncLock(CompanyId, 2, DateTime.Now);
return ex.Message;
}
BaseService.UnSyncLock(CompanyId, 2, DateTime.Now);
return "分配完成";
}
#endregion
#region 全部订单锁定匹配货物
[WebMethod(EnableSession = true)]
public string AllOrderGoodsLockForTMBak(int IsError)
{
Pages.Login(this.Session);
var obj = new DD_OrderData();
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.GetLockOrderList(CompanyId, IsError, Sort);
var list = obj.GetLockOrderGoods(CompanyId, IsError);
//var list1 = obj.GetAllOrderGoodsInList(CompanyId, IsError);
if (orderlist != null && list != null)
{
foreach (var ordermd in orderlist)
{
bool allflag = true; //完全匹配状态
bool flag = false; //匹配状态
int IsFba = 0;
if (ordermd.IsFba != null)
IsFba = ordermd.IsFba.Value;
string ShopId = "," + ordermd.ShopId.ToString() + ",";
string CountryCode = "";
if (ordermd.RevCountry != null)
CountryCode = "," + ordermd.RevCountry.ToLower() + ",";
List listGoods = new List();
List OutList = new List();
var Goodslist = list.FindAll(n => n.OrderId == ordermd.OrderId);
if (Goodslist != null)
{
foreach (var goodsmd in Goodslist)
{
flag = false;
List OutList1 = new List();
DT_OrderGoods mdOrderGoods = new DT_OrderGoods();
mdOrderGoods.Id = goodsmd.Id;
var inlist = obj.GetMateOrderGoodsInListNew(ordermd.OrderId.Value, goodsmd.DetailId.Value); //list1.FindAll(n => n.DetailId == goodsmd.DetailId);
int StoreId = 0;
int LockNum = 0;
if (goodsmd.LockNum != null)
LockNum = goodsmd.LockNum.Value;
int OutNum = 0;
if (goodsmd.OutNum != null)
OutNum = goodsmd.OutNum.Value;
int GoodsNum = goodsmd.GoodsNum.Value - LockNum;
int LeftLockNum = GoodsNum;
if (inlist == null || inlist.Count == 0) //没有匹配货物
{
flag = false;
allflag = false;
continue;
}
else
{
foreach (var inmd in inlist)
{
if (StoreId > 0 && StoreId != inmd.StoreId.Value) //不同仓库
{
LockNum = 0;
if (goodsmd.LockNum != null)
LockNum = goodsmd.LockNum.Value;
GoodsNum = goodsmd.GoodsNum.Value - LockNum;
LeftLockNum = GoodsNum;
OutList1.Clear();
}
StoreId = inmd.StoreId.Value;
if (IsFba == 1 && inmd.StoreType != 2) //不是海外仓
{
continue;
}
else if (IsFba == 0 && inmd.StoreType == 2) //海外仓不支持
{
string useshops = "," + inmd.UseShop + ",";
string usecountrys = "," + inmd.UseCountry.ToLower() + ",";
if (!useshops.Contains(ShopId) || !usecountrys.Contains(CountryCode))
continue;
}
HW_GoodsInDetail mdOut = new HW_GoodsInDetail();
mdOut.OrderGoodsId = goodsmd.Id;
mdOut.Price = inmd.Price;
mdOut.PostPrice = inmd.PostPrice;
mdOut.InId = inmd.InId;
OutList1.Add(mdOut);
if (LeftLockNum > 1)
{
LockNum += 1;
LeftLockNum -= 1;
}
else
{
LockNum += LeftLockNum;
LeftLockNum = 0;
}
if (LockNum >= GoodsNum) //循环时候就满足数量
{
flag = true;
break;
}
}
if (LockNum < GoodsNum) //循环完还是不满足数量
{
flag = false;
allflag = false;
}
else
{
flag = true;
}
if (OutList1 != null)
{
foreach (var md in OutList1)
{
OutList.Add(md);
}
}
mdOrderGoods.LockNum = GoodsNum - LeftLockNum;
listGoods.Add(mdOrderGoods);
}
}
decimal GoodsFee = 0; //货物采购均价
decimal PostFee = 0;//货物快递成本
if (OutList != null)
{
int Num = OutList.Count;
foreach (var md in OutList)
{
if (md.Price != null)
GoodsFee += md.Price.Value;
if (md.PostPrice != null)
PostFee += md.PostPrice.Value;
}
if (Num > 0)
{
GoodsFee = GoodsFee / Num;
PostFee = PostFee / Num;
}
}
if (allflag == true && flag == true)
{
obj.UpdateOrderGoodsLockNew2(ordermd.OrderId.Value, 2, GoodsFee, PostFee, listGoods, OutList);
}
else if (listGoods.Count > 0)
obj.UpdateOrderGoodsLockNew2(ordermd.OrderId.Value, 1, GoodsFee, PostFee, listGoods, OutList);
}
}
}
}
catch (Exception ex)
{
BaseService.UnSyncLock(CompanyId, 2, DateTime.Now);
return ex.Message;
}
BaseService.UnSyncLock(CompanyId, 2, DateTime.Now);
return "匹配完成";
}
#endregion
#region 全部订单锁定匹配货物
[WebMethod(EnableSession = true)]
public string AllOrderGoodsLockForTM(int IsError,int IsFBA)
{
Pages.Login(this.Session);
var obj = new DD_OrderData();
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.GetLockOrderListForTM(CompanyId, IsError,IsFBA, Sort);
var list = obj.GetLockOrderGoodsForTM(CompanyId,IsFBA, IsError);
//var list1 = obj.GetAllOrderGoodsInList(CompanyId, IsError);
int StoreId = 1;
if (IsFBA == 1)
StoreId = 2;
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);
if (jmd != 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;
}
}
var inlist = obj.GetMateOrderGoodsInForTM(ordermd.OrderId.Value, goodsmd.DetailId.Value, StoreId, JoinOrderCode);
if (inlist == null || inlist.Count==0)//没有库存
{
Flag = false;
qbFlag = false;
HW_GoodsOutDetail hwnomd = new HW_GoodsOutDetail();
hwnomd.DetailId = goodsmd.DetailId;
hwnolist.Add(hwnomd);
continue;
}
if(hwlist!=null)
{
var hwdetail = hwlist.FindAll(n => n.DetailId == goodsmd.DetailId);
if (hwdetail == null || hwdetail.Count == 0)
ZYNum = 0;
else
ZYNum = hwdetail.Count;
}
if (inlist.Count >= DDNum + ZYNum) //够分配
{
Flag = true;
for (int i = 0; i < DDNum; i++)
{
HW_GoodsInDetail hwinmd = new HW_GoodsInDetail();
hwinmd.DetailId = goodsmd.DetailId;
hwinmd.InId = inlist[i].InId;
hwinmd.Price = inlist[i].Price;
hwinmd.PostPrice = inlist[i].PostPrice;
hwinmd.OrderGoodsId = goodsmd.Id;
hwlist2.Add(hwinmd);
}
}
else //不够分配
{
Flag = false;
for (int i = 0; i < inlist.Count; i++)
{
HW_GoodsInDetail hwinmd = new HW_GoodsInDetail();
hwinmd.DetailId = goodsmd.DetailId;
hwinmd.InId = inlist[i].InId;
hwinmd.Price = inlist[i].Price;
hwinmd.PostPrice = inlist[i].PostPrice;
hwinmd.OrderGoodsId = goodsmd.Id;
hwlist2.Add(hwinmd);
}
}
}
if (Flag == true&& qbFlag ==true)//已经分配
{
decimal GoodsFee = 0; //货物采购均价
decimal PostFee = 0;//货物快递成本
if (hwlist2 != null)
{
int Num = hwlist2.Count;
foreach (var md in hwlist2)
{
if (md.Price != null)
GoodsFee += md.Price.Value;
if (md.PostPrice != null)
PostFee += md.PostPrice.Value;
}
if (Num > 0)
{
GoodsFee = GoodsFee / Num;
PostFee = PostFee / Num;
}
}
obj.UpdateOrderGoodsLockForTM(ordermd.OrderId.Value, 2, GoodsFee, PostFee,JoinOrderCode, hwlist2);
hwlist2.Clear();
}
else //未分配
{
if (hwlist2 != null)
{
foreach (var md in hwlist2)
{
hwlist.Add(md);
}
hwlist2.Clear();
}
}
}
}
}
}
catch (Exception ex)
{
BaseService.UnSyncLock(CompanyId, 2, DateTime.Now);
return ex.Message;
}
BaseService.UnSyncLock(CompanyId, 2, DateTime.Now);
return "分配完成";
}
#endregion
#region 全部订单锁定匹配货物
[WebMethod(EnableSession = true)]
public string AllOrderGoodsLockForTM2(int IsError, int IsFBA)
{
Pages.Login(this.Session);
var obj = new DD_OrderData();
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.GetLockOrderListForTM(CompanyId, IsError, IsFBA, Sort);
var list = obj.GetLockOrderGoodsForTM(CompanyId, IsFBA, IsError);
//var list1 = obj.GetAllOrderGoodsInList(CompanyId, IsError);
int StoreId = 1;
if (IsFBA == 1)
StoreId = 2;
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);
if (jmd != 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 = obj.GetMateOrderGoodsInForTM2(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 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)
{
//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;
//}
}
obj.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 "分配完成";
}
#endregion
#region 全部订单锁定匹配货物
[WebMethod(EnableSession = true)]
public string AllOrderGoodsLockForTM3(int IsError, int IsFBA)
{
Pages.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.GetLockOrderListForTM3(CompanyId, IsError, IsFBA, Sort);
var list = obj.GetLockOrderGoodsForTM3(CompanyId, IsFBA, IsError);
var KClist = obj.GetNowKCGoods(IsError);
var nfplist = obj.GetNoFPOrderList();
int StoreId = 1;
if (IsFBA == 1)
StoreId = 2;
List mlist = new List();
if (orderlist != null && list != null && KClist != null && orderlist.Count > 0 && list.Count > 0 && KClist.Count > 0)
{
var hwlist2 = new List();
List JoinOrderList = new List();
foreach (var ordermd in orderlist)
{
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);
var 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;
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;
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
{
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)
obj.UpdateOrderGoodsLockForTM3(OrderId, JoinOrderCode,cklist);
}
//if (OrderIds != "" || JoinOrderCodes != "")
// obj.UpdateOrderGoodsLockForTM31(OrderIds.Trim(','), JoinOrderCodes.Trim(','));
}
}
}
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 AllOrderGoodsLockForTM4(int IsError, int IsFBA)
{
Pages.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.GetLockOrderListForTM3(CompanyId, IsError, IsFBA, Sort);
var list = obj.GetLockOrderGoodsForTM3(CompanyId, IsFBA, IsError);
var KClist = obj.GetNowKCGoods2(IsError,IsFBA);
var nfplist = obj.GetNoFPOrderList();
int StoreId = 1;
if (IsFBA == 1)
StoreId = 0;
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)
obj.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 AllOrderGoodsLockForTM5(int IsError, int StoreId)
{
Pages.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 = obj.GetNowKCGoods4(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