using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using TradeManageNew;
using NetLibrary;
using System.Data;
using TradeData;
using TradeModel;
using NetLibrary.Data;
using NetLibrary.Express;
using NetLibrary.ReportPrint;
using System.Threading;
using NetLibrary.Log;
using NetLibrary.OnlineTrade;
using ApiNew;
using System.Text;
using System.Web.Script.Serialization;
using NPOI.HSSF.Record.Formula.Functions;
using System.ComponentModel.DataAnnotations;
namespace TradeManage
{
///
/// DD_OrderServiceNew 的摘要说明
///
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。
[System.Web.Script.Services.ScriptService]
public class DD_OrderServiceNew : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
#region 导入新平台订单
[WebMethod(EnableSession = true)]
public string ImportNewOrderHWC(string FileName, int CompanyId, int ShopId, int StoreId)
{
PagesNew.Login(this.Session);
if (string.IsNullOrEmpty(FileName) == true) return "要导入的文件路径不能为空";
string ServerFileName = AppDomain.CurrentDomain.BaseDirectory + FileName;
if (System.IO.File.Exists(ServerFileName) == false) return "要导入的文件路径不存在";
//int CompanyId = Convert.ToInt32(Session["CompanyId"]);
try
{
MicrosoftExcel excel = new MicrosoftExcel();
DataTable tb = excel.ImportExcel(ServerFileName);
string error = "";
if (tb.Columns.Contains("订单日期") == false) { error = error + "导入模板的 订单日期 列不存在"; }
if (tb.Columns.Contains("订单号") == false) { error = error + "导入模板的 订单号 列不存在"; }
if (tb.Columns.Contains("收件人") == false) { error = error + "导入模板的 收件人 列不存在"; }
if (tb.Columns.Contains("地址1") == false) { error = error + "导入模板的 地址1 列不存在"; }
if (tb.Columns.Contains("sku") == false) { error = error + "导入模板的 sku 列不存在"; }
if (tb.Columns.Contains("订单金额$") == false) { error = error + "导入模板的 订单金额$ 列不存在"; }
if (string.IsNullOrEmpty(error) == false) return error + ";请导入格式不正确";
DD_OrderData obj = new DD_OrderData();
int UserId = Convert.ToInt32(Session["UserId"]);
List OrderList = new List();
int Num = 0;
int PlatId = 0;
var smd = JC_ShopService.GetModel(ShopId);
PlatId = smd.PlatType.Value;
for (int i = 0; i < tb.Rows.Count; i++)
{
DT_ExcelOrderInfo md = new DT_ExcelOrderInfo();
string PlatOrderCode = tb.Rows[i]["订单号"].ToString().Trim();
if (PlatOrderCode == "")
{
// error += "第" + (i + 2).ToString() + " 行的order number没填
";
continue;
}
md.PlatOrderCode = PlatOrderCode;
md.OrderCode = PlatOrderCode;
md.PlatId = PlatId;
md.ShopId = ShopId;
if (tb.Rows[i]["订单金额$"].ToString().Trim() == "")
{
md.TotalPrice = 0;
}
else
{
try
{
md.TotalPrice = Convert.ToDecimal(tb.Rows[i]["订单金额$"].ToString().Trim());
}
catch (Exception ex)
{
error += "第" + (i + 2).ToString() + " 行的价格必须是数字
";
continue;
}
}
int PayState = 1;
int OrderState = 1;
md.OrderDate = DateTime.Now;
md.PayDate = DateTime.Now;
md.PayState = PayState;
md.OrderState = OrderState;
md.RevName = tb.Rows[i]["收件人"].ToString().Trim();
if (md.RevName == "")
{
error += "第" + (i + 2).ToString() + " 行的收件人没填
";
continue;
}
//md.OrderName = tb.Rows[i]["sales_order"].ToString().Trim();
md.RevAddr = tb.Rows[i]["地址1"].ToString().Trim() + " " + tb.Rows[i]["地址2"].ToString().Trim();
if (md.RevAddr == "")
{
error += "第" + (i + 2).ToString() + " 行的地址1没填
";
continue;
}
try
{
if (tb.Rows[i]["订单日期"].ToString().Trim() != "")
md.OrderDate = Convert.ToDateTime(tb.Rows[i]["订单日期"].ToString().Trim());
else
md.OrderDate = DateTime.Today;
}
catch (Exception ex)
{
md.OrderDate = DateTime.Today;
}
md.PayDate = DateTime.Today;
md.RevPostCode = tb.Rows[i]["邮编"].ToString().Trim().Replace("'", "");
if (md.RevPostCode == "")
md.RevPostCode = "12345";
md.RevProvince = tb.Rows[i]["省州"].ToString().Trim();
md.RevCity = tb.Rows[i]["城市"].ToString().Trim();
if (md.RevProvince == null || md.RevProvince == "")
md.RevProvince = md.RevCity;
md.RevPhone = tb.Rows[i]["电话"].ToString().Trim().Replace("'", "").Replace("+", "").Replace("+", "").Replace("(", "").Replace(")", "").Replace(" ", "");
md.CustomID = "";
md.RevMoblie = tb.Rows[i]["电话"].ToString().Trim().Replace("'", "").Replace("+", "").Replace("+", "").Replace("(", "").Replace(")", "").Replace(" ", "");
md.LeaveWord = "";
md.TrackCode = "";
md.RevCountry = "US";
md.MoneyCode = "USD";
md.CompanyId = CompanyId;
md.InUserId = UserId;
List Glist = new List();
var GoodsModel = new DT_OrderExcelGoods();
if (tb.Rows[i]["数量"].ToString().Trim() == "")
{
// error += "第" + (i + 2).ToString() + " 行的quantity没填
";
// continue;
GoodsModel.GoodsNum = 1;
}
else
{
try
{
GoodsModel.GoodsNum = Convert.ToInt32(tb.Rows[i]["数量"].ToString().Trim());
}
catch (Exception ex)
{
error += "第" + (i + 2).ToString() + " 行的数量必须是数字
";
continue;
}
}
GoodsModel.SKU = tb.Rows[i]["sku"].ToString().Trim();
if (GoodsModel.SKU == "")
{
error += "第" + (i + 2).ToString() + " 行的sku 信息没填
";
continue;
}
md.GoodsNum = GoodsModel.GoodsNum;
GoodsModel.GoodsName = GoodsModel.SKU;
GoodsModel.GoodsPrice = md.TotalPrice;
if (OrderList != null)
{
var omd = OrderList.Find(n => n.PlatOrderCode == PlatOrderCode);
if (omd != null)//相同订单号 sku合并
{
omd.GoodsList.Add(GoodsModel);
continue;
}
}
GoodsModel.CompanyId = CompanyId;
Glist.Add(GoodsModel);
md.OrderName = "";
md.PostFee = 0;
md.RevMail = "";
md.RevFax = "";
md.RevArea = "";
md.PostInfo = "";
md.GoodsList = Glist;
OrderList.Add(md);
}
if (error != "")
{
return error;
}
else if (OrderList.Count > 0)
{
string OrderIds = "";
foreach (var md in OrderList)
{
md.StoreId = StoreId;
int OrderId = obj.ExcelOrderAdd4(md);
OrderIds += OrderId.ToString() + ",";
}
obj.UpdateOrderGoodsNum();
if (OrderIds != "")
PartOrderGoodsLockForHWC(CompanyId, 0, 6, OrderIds.TrimEnd(','), "");
error = "数据导入成功【" + OrderList.Count.ToString() + "条】;" + error;
return error;
}
}
catch (Exception e)
{
return "文件导入失败!请确定模板格式是否正确,或者重新下载模板,填写数据,重新导入!!!" + e.Message;
}
return "导入成功";
}
#endregion
#region 全部订单锁定匹配货物海外仓
[WebMethod(EnableSession = true)]
public string AllOrderGoodsLockForHWC(int CompanyId,int IsError, int StoreId)
{
Pages.Login(this.Session);
var obj = new DD_OrderData();
int Num = 0;
if (CompanyId == 1)
return "";
int UserId = Convert.ToInt32(Session["UserId"]);
try
{
string Sort = "a.OrderLevel desc,a.OrderDate";
obj.SetStore();//仓库调整
var orderlist = DataNew.GetLockOrderListForHWC(CompanyId, IsError, StoreId, Sort);
var list = DataNew.GetLockOrderGoodsForHWC(CompanyId, StoreId, IsError);
var KClist = DataNew.GetNowKCGoodsHWC(CompanyId,IsError, StoreId);
var nfplist = obj.GetNoFPOrderList();
List mlist = new List();
if (orderlist != null && list != null && KClist != null && orderlist.Count > 0 && list.Count > 0 && KClist.Count > 0)
{
var hwlist2 = new List();
var OrderMatelist = new List();
List JoinOrderList = new List();
foreach (var ordermd in orderlist)
{
//if (ordermd.OrderId == 5329133)
//{
// string a = "";
//}
string JoinOrderCode = "";
if (ordermd.JoinOrderCode != null && ordermd.JoinOrderCode != "")
JoinOrderCode = ordermd.JoinOrderCode;
if (JoinOrderCode != "")
{
if (JoinOrderList != null && JoinOrderList.Count > 0)
{
var jmd = JoinOrderList.Find(n => n.JoinOrderCode == JoinOrderCode);
DT_OrderMateKCOrder nmd = null;
if (nfplist != null && nfplist.Count > 0)
nmd = nfplist.Find(n => n.JoinOrderCode == JoinOrderCode);
if (jmd != null || nmd != null)
continue;
else
{
var jmd1 = new DT_OrderMateKCGoods();
jmd1.JoinOrderCode = JoinOrderCode;
JoinOrderList.Add(jmd1);
}
}
else
{
var jmd1 = new DT_OrderMateKCGoods();
jmd1.JoinOrderCode = JoinOrderCode;
JoinOrderList.Add(jmd1);
}
}
List listGoods = new List();
List OutList = new List();
var Goodslist = new List();
if (JoinOrderCode == "")
Goodslist = list.FindAll(n => n.OrderId == ordermd.OrderId);
else //合并订单
Goodslist = list.FindAll(n => n.JoinOrderCode == JoinOrderCode);
if (Goodslist != null && Goodslist.Count > 0)
{
var hwlist1 = new List();
bool qbFlag = true;//全部货物满足
bool Flag = false;//全部货物满足
foreach (var goodsmd in Goodslist)
{
int DDNum = goodsmd.GoodsNum.Value;
int LeftNum = DDNum;
var kcmdlist = KClist.FindAll(n => n.DetailId == goodsmd.DetailId && n.KCNum - n.LockNum > 0);
if (kcmdlist == null || kcmdlist.Count == 0)
{
qbFlag = false;
Flag = false;
continue;
}
foreach (var kcmd in kcmdlist)
{
if (kcmd.KCNum - kcmd.LockNum >= LeftNum)
{
kcmd.LockNum += LeftNum;
var ckmd = new DT_OrderNowKCGoods();
ckmd.OrderNum = LeftNum;
ckmd.InId = kcmd.InId;
ckmd.OrderId = ordermd.OrderId;
ckmd.OrderGoodsId = goodsmd.Id;
ckmd.StoreId = kcmd.StoreId;
ckmd.PostionId = kcmd.PostionId;
ckmd.DetailId = kcmd.DetailId;
hwlist1.Add(ckmd);
LeftNum = 0;
break;
}
else
{
var ckmd = new DT_OrderNowKCGoods();
ckmd.OrderNum = kcmd.KCNum.Value - kcmd.LockNum.Value;
ckmd.InId = kcmd.InId;
ckmd.OrderId = ordermd.OrderId;
ckmd.OrderGoodsId = goodsmd.Id;
ckmd.StoreId = kcmd.StoreId;
ckmd.PostionId = kcmd.PostionId;
ckmd.DetailId = kcmd.DetailId;
hwlist1.Add(ckmd);
LeftNum = LeftNum - kcmd.KCNum.Value + kcmd.LockNum.Value;
kcmd.LockNum = kcmd.KCNum;
}
}
if (LeftNum <= 0)
{
Flag = true;
goodsmd.IsMate = 1;
}
else
{
qbFlag = false;
Flag = false;
goodsmd.IsMate = 0;
}
}
if (qbFlag == true && Flag == true)
{
mlist.Add(ordermd);
ordermd.IsMate = 1;
if (hwlist1 != null)
{
foreach (var hmd in hwlist1)
{
hwlist2.Add(hmd);
}
}
}
else
{
foreach (var hmd in hwlist1)
{
var opmd = new HW_OrderMate();
opmd.InId = hmd.InId;
opmd.Num = hmd.OrderNum;
opmd.DetailId = hmd.DetailId;
opmd.GoodsOrderId = hmd.OrderGoodsId;
opmd.StoreId = hmd.StoreId;
opmd.PostionId = hmd.PostionId;
OrderMatelist.Add(opmd);
}
hwlist1.Clear();
}
}
}
// var olist=orderlist.FindAll(n=>n.IsMate==1);
if (mlist != null)
{
Num = mlist.Count;
//string OrderIds = "";
// string JoinOrderCodes = "";
foreach (var omd in mlist)
{
int OrderId = 0;
string JoinOrderCode = "";
if (omd.JoinOrderCode != null && omd.JoinOrderCode != "")
JoinOrderCode = omd.JoinOrderCode;
else
OrderId = omd.OrderId.Value;
var cklist = hwlist2.FindAll(n => n.OrderId == omd.OrderId);
if (cklist != null && cklist.Count > 0)
DataNew.UpdateOrderGoodsLockForHWC(OrderId, JoinOrderCode, cklist);
}
//if (OrderIds != "" || JoinOrderCodes != "")
// obj.UpdateOrderGoodsLockForTM31(OrderIds.Trim(','), JoinOrderCodes.Trim(','));
}
//obj.DeleteOrderMate();
//if (OrderMatelist != null)
//{
// foreach (var mmd in OrderMatelist)
// {
// obj.SaveOrderMate(mmd);
// }
//}
}
}
catch (Exception ex)
{
return ex.Message;
}
return "匹配" + Num.ToString() + "条";
}
#endregion
#region 海外仓订单匹配货物
[WebMethod(EnableSession = true)]
public string PartOrderGoodsLockForHWC(int CompanyId, int IsError, int StoreId, string OrderIds, string JoinOrderCodes)
{
PagesNew.Login(this.Session);
var obj = new DD_OrderData();
int Num = 0;
int UserId = Convert.ToInt32(Session["UserId"]);
if (CompanyId == 1)
return "";
try
{
string Sort = "a.OrderLevel desc,a.OrderDate";
var orderlist = DataNew.GetLockPartOrderListForHWC(CompanyId, OrderIds.Trim(','), JoinOrderCodes.Trim(','), IsError, StoreId, Sort);
var list = DataNew.GetLockPartOrderGoodsForHWC(CompanyId, OrderIds.Trim(','), JoinOrderCodes.Trim(','), StoreId, IsError);
var nfplist = DataNew.GetNoFPOrderList2(CompanyId);
if (orderlist != null && list != null)
{
var hwlist = new List(); //货物占用
var hwlist2 = new List();
var hwnolist = new List(); //不够的货物
List JoinOrderList = new List();
foreach (var ordermd in orderlist)
{
string JoinOrderCode = "";
if (ordermd.JoinOrderCode != null && ordermd.JoinOrderCode != "")
JoinOrderCode = ordermd.JoinOrderCode;
List listGoods = new List();
List OutList = new List();
var Goodslist = new List();
if (JoinOrderCode == "")
Goodslist = list.FindAll(n => n.OrderId == ordermd.OrderId);
else //合并订单
Goodslist = list.FindAll(n => n.JoinOrderCode == JoinOrderCode);
if (JoinOrderCode != "")
{
if (JoinOrderList != null && JoinOrderList.Count > 0)
{
var jmd = JoinOrderList.Find(n => n.JoinOrderCode == JoinOrderCode);
DT_OrderMateKCOrder nmd = null;
if (nfplist != null && nfplist.Count > 0)
nmd = nfplist.Find(n => n.JoinOrderCode == JoinOrderCode);
if (jmd != null || nmd != null)
continue;
else
{
var jmd1 = new DT_OrderGoods();
jmd1.JoinOrderCode = JoinOrderCode;
JoinOrderList.Add(jmd1);
}
}
else
{
var jmd1 = new DT_OrderGoods();
jmd1.JoinOrderCode = JoinOrderCode;
JoinOrderList.Add(jmd1);
}
}
if (Goodslist != null)
{
bool Flag = false; //匹配标记
bool qbFlag = true;//全部货物满足
foreach (var goodsmd in Goodslist)
{
int ZYNum = 0;//占用数量
int DDNum = goodsmd.GoodsNum.Value;//订单数量
if (hwnolist != null)
{
var hwnodetail = hwnolist.Find(n => n.DetailId == goodsmd.DetailId);
if (hwnodetail != null)//已经在没有库存记录里
{
Flag = false;
qbFlag = false;
continue;
}
}
if (hwlist != null)
{
var hwdetail = hwlist.Find(n => n.DetailId == goodsmd.DetailId);
if (hwdetail != null)//已经在没有满足库存记录里
{
ZYNum = hwdetail.KCNum.Value;
}
}
var inlist = DataNew.GetMateOrderGoodsInForHWC(goodsmd.DetailId.Value, StoreId);
if (inlist == null || inlist.Count == 0)//没有库存
{
Flag = false;
qbFlag = false;
HW_GoodsOutDetail hwnomd = new HW_GoodsOutDetail();
hwnomd.DetailId = goodsmd.DetailId;
hwnolist.Add(hwnomd);
continue;
}
int LeftNum = DDNum;
foreach (var kcmd in inlist)
{
if (kcmd.KCNum.Value >= LeftNum + ZYNum)
{
HW_GoodsInDetail hwinmd = new HW_GoodsInDetail();
hwinmd.DetailId = goodsmd.DetailId;
hwinmd.InId = kcmd.InId;
hwinmd.Price = kcmd.Price;
hwinmd.PostPrice = kcmd.PostPrice;
hwinmd.OrderGoodsId = goodsmd.Id;
hwinmd.KCNum = LeftNum;
hwlist2.Add(hwinmd);
LeftNum = 0;
break;
}
else
if (kcmd.KCNum.Value < LeftNum + ZYNum)
{
HW_GoodsInDetail hwinmd = new HW_GoodsInDetail();
hwinmd.DetailId = goodsmd.DetailId;
hwinmd.InId = kcmd.InId;
hwinmd.Price = kcmd.Price;
hwinmd.PostPrice = kcmd.PostPrice;
hwinmd.OrderGoodsId = goodsmd.Id;
hwinmd.KCNum = kcmd.KCNum.Value;
hwlist2.Add(hwinmd);
LeftNum = LeftNum - kcmd.KCNum.Value;
}
}
if (LeftNum == 0) //够分配
{
Flag = true;
}
else //不够分配
{
Flag = false;
qbFlag = false;
var bgmd = hwlist.Find(n => n.DetailId == goodsmd.DetailId);
if (bgmd != null)
{
bgmd.KCNum += DDNum;
}
else
{
var bgmd1 = new HW_GoodsInDetail();
bgmd1.KCNum = DDNum;
hwlist.Add(bgmd1);
}
}
}
if (Flag == true && qbFlag == true)//已经分配
{
decimal GoodsFee = 0; //货物采购均价
decimal PostFee = 0;//货物快递成本
if (hwlist2 != null)
{
Num++;
//int Num = hwlist2.Count;
foreach (var md in hwlist2)
{
if (md.Price != null)
GoodsFee += md.Price.Value * md.KCNum.Value;
if (md.PostPrice != null)
PostFee += md.PostPrice.Value * md.KCNum.Value;
}
//if (Num > 0)
//{
// GoodsFee = GoodsFee / Num;
// PostFee = PostFee / Num;
//}
}
DataNew.UpdateOrderGoodsLockForHWC(ordermd.OrderId.Value, 2, GoodsFee, PostFee, JoinOrderCode, hwlist2);
hwlist2.Clear();
}
else //未分配
{
if (hwlist2 != null)
{
foreach (var md in hwlist2)
{
var bgmd = hwlist.Find(n => n.DetailId == md.DetailId);
if (bgmd != null)
{
bgmd.KCNum += md.KCNum.Value;
}
else
{
var bgmd1 = new HW_GoodsInDetail();
bgmd1.KCNum = md.KCNum.Value;
hwlist.Add(bgmd1);
}
}
hwlist2.Clear();
}
}
}
}
}
}
catch (Exception ex)
{
return ex.Message;
}
return "匹配" + Num.ToString() + "条";
}
#endregion
#region 查询订单
[WebMethod(EnableSession = true)]
public JsonModel> GetListOrderForHWC(int CompanyId, int PlatType, int ShopId, int DateType, DateTime? SDate, DateTime? EDate, int TjType, string Name, int PrintState, int MateState, int State, int PageIndex, int PageSize, string Sort)
{
PagesNew.Login(this.Session);
var obj = new DD_OrderData();
// int CompanyId = Convert.ToInt32(Session["CompanyId"]);
RefParameterCollection Param = new RefParameterCollection();
Param.Add("a.CompanyId", "=", CompanyId, DbType.Int32);
if (PlatType > 0)
Param.Add("a.PlatId", "=", PlatType, DbType.Int32);
if (ShopId > 0)
Param.Add("a.ShopId", "=", ShopId, DbType.Int32);
if (DateType == 1)
{
if (SDate != null)
Param.Add("a.OrderDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.OrderDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
else
if (DateType == 2)
{
if (SDate != null)
Param.Add("a.InDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.InDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
else
if (DateType == 3)
{
if (SDate != null)
Param.Add("a.PrintDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.PrintDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
else
if (DateType == 4)
{
if (SDate != null)
Param.Add("a.PostDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.PostDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
else
if (DateType == 5)
{
if (SDate != null)
Param.Add("a.OrderOutDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.OrderOutDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
if (MateState==1)
Param.Add("a.FPDate", "is", null, DbType.String);
else if (MateState > -1)
Param.Add("a.MateState", "=", MateState, DbType.Int32);
if (PrintState > -1)
Param.Add("a.PrintState", "=", PrintState, DbType.Int32);
if (State == 3)
Param.Add("a.State", "=", 2, DbType.Int32);
else if (State == 4)
Param.Add("a.State", "=", 3, DbType.Int32);
else if (State == 5)
{
Param.Add("a.State", "=", 1, DbType.Int32);
Param.Add("a.MoneyState", "=", 1, DbType.Int32);
}
else if (State == 1)
{
//Param.Add("a.State", "=", 2, DbType.Int32);
Param.Add("a.PostState", "=", 1, DbType.Int32);
}
else if (State == 2)
{
Param.Add("a.State", "<", 3, DbType.Int32);
Param.Add("a.PostState", "=", 2, DbType.Int32);
}
else if (State == 0)
{
//Param.Add("a.State", "=", 2, DbType.Int32);
Param.Add("a.State", "=", 1, DbType.Int32);
}
else
Param.Add("a.State", ">", 0, DbType.Int32);
string TCode = "";
if (Name != "")
{
Name = Name.Trim();
if (TjType == 1)
{
Param.Add("(a.PlatOrderCode", "like", Name, DbType.String);
Param.Add("OrderCode", "like", Name, "or", DbType.String);
Param.Add("a.JoinOrderCode", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 2)
{
Param.Add("a.RevName", "like", Name, DbType.String);
}
else if (TjType == 3)
{
Param.Add("a.RevPhone", "like", Name, DbType.String);
}
else if (TjType == 4)
{
Param.Add("(a.RevCountry", "=", Name, DbType.String);
Param.Add("a.CountryName", "=", Name, "or", DbType.String);
Param.Add("a.CountryCode", "=", Name, "or", ")", DbType.String);
}
else if (TjType == 5)
{
Param.Add("a.RevPostCode", "=", Name, DbType.String);
}
else if (TjType == 6)
{
Param.Add("(a.RevAddr", "like", Name, DbType.String);
Param.Add("a.RevProvince", "like", Name, "or", DbType.String);
Param.Add("a.RevCity", "like", Name, "or", DbType.String);
Param.Add("a.RevArea", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 9)
{
Param.Add("(a.ErrorInfo", "like", Name, DbType.String);
Param.Add("a.PostError", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 10)
{
//Param.Add("dbo.getOrderTrackCode(a.OrderId,0)", "like", Name, DbType.String);
TCode = Name;
}
else if (TjType == 11)
{
Param.Add("a.CustomID", "=", Name, DbType.String);
}
else if (TjType == 12)
{
Param.Add("a.RevMail", "=", Name, DbType.String);
}
}
JsonModel> resultModel = new JsonModel>();
int RowCount = 0;
//string Sort = "orderid desc";
string GoodsName = "";
string SKU = "";
if (TjType == 7 && Name != "")
{
GoodsName = Name;
}
else
if (TjType == 8 && Name != "")
{
SKU = Name;
}
// if (State == 0 || State == 2)
resultModel.DataSource = DataNew.GetListDT_OrderInfoForHWC(CompanyId, GoodsName.Trim(), SKU.Trim(), TCode, -1, 0, Param, PageIndex, PageSize, Sort, out RowCount);
// else
// resultModel.DataSource = obj.GetListDT_OrderInfoForTM(CompanyId, GoodsName.Trim(), SKU.Trim(), TCode, -1, 0, Param, PageIndex, PageSize, Sort, out RowCount);
resultModel.RowCount = RowCount;
string Ids = "";
if (resultModel.DataSource != null)
{
foreach (var md in resultModel.DataSource)
{
Ids += md.OrderId.ToString() + ",";
}
}
if (Ids != "")
{
var errorlist = obj.GetErrorList(Ids.Trim(','));
if (errorlist != null && errorlist.Count > 0)
{
foreach (var md in resultModel.DataSource)
{
var emd = errorlist.Find(n => n.OrderId == md.OrderId);
if (emd != null)
{
md.ErrorInfo = emd.ErrorInfo;
}
}
}
}
if (resultModel.DataSource != null)
{
if (Ids != "")
{
var list1 = DataNew.GetOrderGoodsListHWC(Ids.Trim(','));
var listTrack = obj.GetTrackCodeApplyList(Ids.Trim(','));
if (list1 != null)
{
foreach (var md in resultModel.DataSource)
{
var list2 = list1.FindAll(n => n.OrderId == md.OrderId);
if (list2 != null)
{
md.GoodsList = list2;
}
}
}
if (listTrack != null)
{
foreach (var md in resultModel.DataSource)
{
var list3 = new List();
if (md.JoinOrderCode != null && md.JoinOrderCode != "")
list3 = listTrack.FindAll(n => n.OrderCode == md.JoinOrderCode);
else
list3 = listTrack.FindAll(n => n.OrderId == md.OrderId);
if (list3 != null && list3.Count > 0)
{
string trackinfo = "";
string TrackCode = "";
foreach (var md1 in list3)
{
string blank = "";
if (md1.TrackType == 3)
blank = "[空包裹]";
if (md1.Weight != null)
{
string dd = "";
if (md1.ScanDate != null)
dd = "发货时间:" + md1.ScanDate.Value.ToString("yyyy-MM-dd HH:mm");
trackinfo += md1.TrackCode + blank + "重量" + md1.Weight.ToString() + "g" + dd + "
";
}
else
trackinfo += md1.TrackCode + blank + "
";
if (TrackCode == "")
TrackCode = md1.TrackCode;
}
md.TrackInfo = trackinfo;
md.TrackCode = TrackCode;
}
}
}
}
}
return resultModel;
}
#endregion
#region 删除订单
[WebMethod(EnableSession = true)]
public void DeleteOrderHWC(int OrderId)
{
PagesNew.Login(this.Session);
var obj = new DD_OrderData();
int InUserId = Convert.ToInt32(Session["UserId"]);
DataNew.DeleteOrderHWC(OrderId, InUserId);
//obj.UpdateDelOrderGoods(OrderId);// 修改货物的订单数量(发货或者取消)
}
#endregion
[WebMethod(EnableSession = true)]
public string GetListOrderForHWC_Excel(int CompanyId, int PlatType, int ShopId, int DateType, DateTime? SDate, DateTime? EDate, int TjType, string Name, int PrintState, int MateState, int State, int PageIndex, int PageSize, string Sort)
{
PagesNew.Login(this.Session);
var obj = new DD_OrderData();
// int CompanyId = Convert.ToInt32(Session["CompanyId"]);
RefParameterCollection Param = new RefParameterCollection();
Param.Add("a.CompanyId", "=", CompanyId, DbType.Int32);
if (PlatType > 0)
Param.Add("a.PlatId", "=", PlatType, DbType.Int32);
if (ShopId > 0)
Param.Add("a.ShopId", "=", ShopId, DbType.Int32);
if (DateType == 1)
{
if (SDate != null)
Param.Add("a.OrderDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.OrderDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
else
if (DateType == 2)
{
if (SDate != null)
Param.Add("a.InDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.InDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
else
if (DateType == 3)
{
if (SDate != null)
Param.Add("a.PrintDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.PrintDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
else
if (DateType == 4)
{
if (SDate != null)
Param.Add("a.PostDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.PostDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
else
if (DateType == 5)
{
if (SDate != null)
Param.Add("a.OrderOutDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.OrderOutDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
if (MateState == 1)
Param.Add("a.FPDate", "is", null, DbType.String);
else if (MateState > -1)
Param.Add("a.MateState", "=", MateState, DbType.Int32);
if (PrintState > -1)
Param.Add("a.PrintState", "=", PrintState, DbType.Int32);
if (State == 3)
Param.Add("a.State", "=", 2, DbType.Int32);
else if (State == 4)
Param.Add("a.State", "=", 3, DbType.Int32);
else if (State == 5)
{
Param.Add("a.State", "=", 1, DbType.Int32);
Param.Add("a.MoneyState", "=", 1, DbType.Int32);
}
else if (State == 1)
{
//Param.Add("a.State", "=", 2, DbType.Int32);
Param.Add("a.PostState", "=", 1, DbType.Int32);
}
else if (State == 2)
{
Param.Add("a.State", "<", 3, DbType.Int32);
Param.Add("a.PostState", "=", 2, DbType.Int32);
}
else if (State == 0)
{
//Param.Add("a.State", "=", 2, DbType.Int32);
Param.Add("a.State", "=", 1, DbType.Int32);
}
else
Param.Add("a.State", ">", 0, DbType.Int32);
string TCode = "";
if (Name != "")
{
Name = Name.Trim();
if (TjType == 1)
{
Param.Add("(a.PlatOrderCode", "like", Name, DbType.String);
Param.Add("OrderCode", "like", Name, "or", DbType.String);
Param.Add("a.JoinOrderCode", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 2)
{
Param.Add("a.RevName", "like", Name, DbType.String);
}
else if (TjType == 3)
{
Param.Add("a.RevPhone", "like", Name, DbType.String);
}
else if (TjType == 4)
{
Param.Add("(a.RevCountry", "=", Name, DbType.String);
Param.Add("a.CountryName", "=", Name, "or", DbType.String);
Param.Add("a.CountryCode", "=", Name, "or", ")", DbType.String);
}
else if (TjType == 5)
{
Param.Add("a.RevPostCode", "=", Name, DbType.String);
}
else if (TjType == 6)
{
Param.Add("(a.RevAddr", "like", Name, DbType.String);
Param.Add("a.RevProvince", "like", Name, "or", DbType.String);
Param.Add("a.RevCity", "like", Name, "or", DbType.String);
Param.Add("a.RevArea", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 9)
{
Param.Add("(a.ErrorInfo", "like", Name, DbType.String);
Param.Add("a.PostError", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 10)
{
//Param.Add("dbo.getOrderTrackCode(a.OrderId,0)", "like", Name, DbType.String);
TCode = Name;
}
else if (TjType == 11)
{
Param.Add("a.CustomID", "=", Name, DbType.String);
}
else if (TjType == 12)
{
Param.Add("a.RevMail", "=", Name, DbType.String);
}
}
JsonModel> resultModel = new JsonModel>();
int RowCount = 0;
//string Sort = "orderid desc";
string GoodsName = "";
string SKU = "";
if (TjType == 7 && Name != "")
{
GoodsName = Name;
}
else
if (TjType == 8 && Name != "")
{
SKU = Name;
}
// if (State == 0 || State == 2)
resultModel.DataSource = DataNew.GetListDT_OrderInfoForHWC(CompanyId, GoodsName.Trim(), SKU.Trim(), TCode, -1, 0, Param, PageIndex, PageSize, Sort, out RowCount);
// else
// resultModel.DataSource = obj.GetListDT_OrderInfoForTM(CompanyId, GoodsName.Trim(), SKU.Trim(), TCode, -1, 0, Param, PageIndex, PageSize, Sort, out RowCount);
resultModel.RowCount = RowCount;
string Ids = "";
if (resultModel.DataSource != null)
{
foreach (var md in resultModel.DataSource)
{
Ids += md.OrderId.ToString() + ",";
}
}
//if (Ids != "")
//{
// var errorlist = obj.GetErrorList(Ids.Trim(','));
// if (errorlist != null && errorlist.Count > 0)
// {
// foreach (var md in resultModel.DataSource)
// {
// var emd = errorlist.Find(n => n.OrderId == md.OrderId);
// if (emd != null)
// {
// md.ErrorInfo = emd.ErrorInfo;
// }
// }
// }
//}
if (resultModel.DataSource != null)
{
if (Ids != "")
{
var list1 = DataNew.GetOrderGoodsListHWC2(Ids.Trim(','));
var listTrack = obj.GetTrackCodeApplyList(Ids.Trim(','));
if (list1 != null)
{
foreach (var md in resultModel.DataSource)
{
var list2 = list1.FindAll(n => n.OrderId == md.OrderId);
string gnames = "";
if (list2 != null)
{
md.GoodsList = list2;
foreach (var gmd in list2)
{
gnames += gmd.GoodsSKU + " ";
}
}
md.GoodsName = gnames;
}
}
if (listTrack != null)
{
foreach (var md in resultModel.DataSource)
{
var list3 = new List();
if (md.JoinOrderCode != null && md.JoinOrderCode != "")
list3 = listTrack.FindAll(n => n.OrderCode == md.JoinOrderCode);
else
list3 = listTrack.FindAll(n => n.OrderId == md.OrderId);
if (list3 != null && list3.Count > 0)
{
string trackinfo = "";
string TrackCode = "";
foreach (var md1 in list3)
{
string blank = "";
if (md1.TrackType == 3)
blank = "[空包裹]";
if (md1.Weight != null)
{
string dd = "";
if (md1.ScanDate != null)
dd = "发货时间:" + md1.ScanDate.Value.ToString("yyyy-MM-dd HH:mm");
trackinfo += md1.TrackCode + blank + "重量" + md1.Weight.ToString() + "g" + dd + ";";
}
else
trackinfo += md1.TrackCode + blank + ";";
if (TrackCode == "")
TrackCode = md1.TrackCode;
}
md.TrackInfo = trackinfo;
md.TrackCode = TrackCode;
}
}
}
}
}
TableColumnCollection listColumns = new TableColumnCollection();
listColumns.Add("PlatOrderCode", "订单号", DbType.String, "");
listColumns.Add("ShopName", "店铺", DbType.String, "");
listColumns.Add("OrderDate", "订单日期", DbType.String, "");
listColumns.Add("InDate", "导入日期", DbType.String, "");
listColumns.Add("GoodsNum", "数量", DbType.String, "");
listColumns.Add("TotalPrice", "订单金额", DbType.String, "");
listColumns.Add("RevName", "收货人", DbType.String, "");
listColumns.Add("RevAddr", "收件地址", DbType.String, "");
listColumns.Add("RevPostCode", "收件邮编", DbType.String, "");
listColumns.Add("RevCity", "收件城市", DbType.String, "");
listColumns.Add("RevProvince", "收件州省", DbType.String, "");
// listColumns.Add("RevPhone", "收件人电话", DbType.String, "");
// listColumns.Add("RevMoblie", "收件人手机", DbType.String, "");
// listColumns.Add("CountryName", "收件国家", DbType.String, "");
listColumns.Add("GoodsName", "物品描述", DbType.String, "");
listColumns.Add("PostInfo", "物流渠道", DbType.String, "");
listColumns.Add("TrackCode", "跟踪码", DbType.String, "");
listColumns.Add("PostFee", "预估运费", DbType.String, "f2");
listColumns.Add("BoxFee", "账单运费", DbType.String, "f2");
// listColumns.Add("TotalWeight", "重量(克)", DbType.String, "f2");
MicrosoftExcel obj2 = new MicrosoftExcel();
return obj2.Export(resultModel.DataSource, listColumns);
}
#region 查询物流订单
[WebMethod(EnableSession = true)]
public JsonModel> GetListOrderExpressHWC(int CompanyId, int Num, int PlatType, int TrackState, int MateState, int ShopId, int DateType, DateTime? SDate, DateTime? EDate, int OutDays, int TjType, string Name, int ExpressState, int IsSku, int IsError, int IsDetail, int HBOrder, int PostId, int LogisticsId, int Addr, int PageIndex, int PageSize, string Sort)
{
Pages.Login(this.Session);
var obj = new DD_OrderData();
RefParameterCollection Param = new RefParameterCollection();
if (Num == 1)
Param.Add("a.GoodsNum", "=", 1, DbType.Int32);
else if (Num == 2)
Param.Add("a.GoodsNum", ">", 1, DbType.Int32);
Param.Add("a.CompanyId", "=", CompanyId, DbType.Int32);
if (MateState > -1)
Param.Add("a.MateState", "=", MateState, DbType.Int32);
int IsTrack = TrackState;
//if (ExpressState>-1)
Param.Add("isnull(a.PrintState,0)", "=", 0, DbType.Int32);
if (PlatType > 0)
Param.Add("a.PlatId", "=", PlatType, DbType.Int32);
if (ShopId > 0)
Param.Add("a.ShopId", "=", ShopId, DbType.Int32);
if (DateType == 1)
{
if (SDate != null)
Param.Add("a.OrderDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.OrderDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
else
if (DateType == 2)
{
if (SDate != null)
Param.Add("a.InDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.InDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
else
if (DateType == 3)
{
if (SDate != null)
Param.Add("a.PrintDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.PrintDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
else
if (DateType == 4)
{
if (SDate != null)
Param.Add("a.PostDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.PostDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
else
if (DateType == 5)
{
if (SDate != null)
Param.Add("a.OrderOutDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.OrderOutDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
if (OutDays > 0)
{
Param.Add("a.OrderOutDate", "<=", DateTime.Now.AddHours(OutDays), DbType.DateTime);
Param.Add("a.OrderOutDate", ">=", DateTime.Now, DbType.DateTime);
}
if (LogisticsId > 0)
Param.Add("b.LogisticsId", "=", LogisticsId, DbType.String);
if (ExpressState == 0)
{
Param.Add("isnull(b.Post,0)", "=", 0, DbType.Int32);
}
else if (ExpressState == 2)
{
Param.Add("b.Post", ">", 0, DbType.Int32);
Param.Add("isnull(b.TrackState,0)", "=", 0, DbType.Int32);
}
else
if (ExpressState == 1)
{
Param.Add("b.Post", ">", 0, DbType.Int32);
Param.Add("b.TrackState", ">", 0, DbType.Int32);
}
if (PostId > 0)
Param.Add("b.Post", "=", PostId, DbType.Int32);
Param.Add("a.State", "=", 1, DbType.Int32);
if (HBOrder == 1)
Param.Add("a.IsJoin", "=", 1, DbType.Int32);
if (IsError == 1)
{
Param.Add("(b.SendAddr", ">", 0, DbType.Int32);
Param.Add("b.IsLeaveWord", "=", 1, "or", ")", DbType.Int32);
}
string TCode = "";
if (Name != "")
{
if (TjType == 1)
{
Param.Add("(a.PlatOrderCode", "=", Name, DbType.String);
Param.Add("a.JoinOrderCode", "=", Name, "or", ")", DbType.String);
}
else if (TjType == 2)
{
Param.Add("b.RevName", "like", Name, DbType.String);
}
else if (TjType == 3)
{
Param.Add("b.RevPhone", "like", Name, DbType.String);
}
else if (TjType == 4)
{
Param.Add("(b.RevCountry", "=", Name, DbType.String);
Param.Add("b.CountryName", "=", Name, "or", DbType.String);
Param.Add("b.CountryCode", "=", Name, "or", ")", DbType.String);
}
else if (TjType == 5)
{
Param.Add("b.RevPostCode", "=", Name, DbType.String);
}
else if (TjType == 6)
{
Param.Add("(b.RevAddr", "like", Name, DbType.String);
Param.Add("b.RevProvince", "like", Name, "or", DbType.String);
Param.Add("b.RevCity", "like", Name, "or", DbType.String);
Param.Add("b.RevArea", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 9)
{
Param.Add("(b.ErrorInfo", "like", Name, DbType.String);
Param.Add("b.PostError", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 10)
{
// Param.Add("dbo.getOrderTrackCode(a.OrderId,1)", "like", Name, DbType.String);
TCode = Name;
}
}
if (IsSku == 0)
Param.Add("a.FPDate", "is", null, DbType.String);
else if (IsSku == 1)
Param.Add("a.FPDate", "is not", null, DbType.String);
//if (Addr > -1)
//{
// Param.Add("b.SendAddr", "=", Addr, DbType.Int32);
//}
// Param.Add("a.OrderDate", ">=", 0, DbType.Int32);
JsonModel> resultModel = new JsonModel>();
int RowCount = 0;
//var pxlist = obj.GetLevelConfig(CompanyId, 0);
// string Sort = "JoinOrderCode,PlatOrderCode";
//if (pxlist != null)
//{
// Sort = "";
// foreach (var md in pxlist)
// {
// if (md.SortType == 1)
// Sort += "a.OrderLevel desc,";
// else if (md.SortType == 2)
// Sort += "a.OrderDate,";
// else if (md.SortType == 3)
// Sort += "c.LevelGrade desc,";
// else if (md.SortType == 4)
// Sort += "a.RMBPrice desc,";
// }
//}
//Sort = Sort.Trim(',');
string GoodsName = "";
string SKU = "";
if (TjType == 7 && Name != "")
{
GoodsName = Name;
}
else
if (TjType == 8 && Name != "")
{
SKU = Name;
}
resultModel.DataSource = DataNew.GetListDT_OrderInfoExpressHWC(IsTrack, TCode, GoodsName, SKU, IsSku, Param, PageIndex, PageSize, Sort, out RowCount);
resultModel.RowCount = RowCount;
string Ids = "";
if (resultModel.DataSource != null)
{
foreach (var md in resultModel.DataSource)
{
Ids += md.OrderId.ToString() + ",";
}
}
if (Ids != "")
{
JC_ExpressService obj3 = new JC_ExpressService();
var elist = obj3.GetExpressTypeList();
var plist = obj3.GetExpressList();
var errorlist = obj.GetErrorList(Ids.Trim(','));
if (errorlist != null || elist != null || plist != null)
{
foreach (var md in resultModel.DataSource)
{
if (errorlist != null && errorlist.Count > 0)
{
var emd = errorlist.Find(n => n.OrderId == md.OrderId);
if (emd != null)
{
md.ErrorInfo = emd.ErrorInfo;
}
}
//if (md.LogisticsId>0&&elist != null && elist.Count > 0)
//{
// var emd = elist.Find(n => n.LogisticsId == md.LogisticsId);
// if (emd != null)
// {
// md.PostInfo = emd.LogisticsName;
// }
//}
if (md.Post > 0 && plist != null && plist.Count > 0)
{
var emd = plist.Find(n => n.ExpressID == md.Post);
if (emd != null)
{
md.LocalPost = emd.Name;
}
}
}
}
}
if (resultModel.DataSource != null)
{
if (Ids != "")
{
if (IsDetail == 1)
{
var list1 = obj.GetOrderGoodsList(Ids.Trim(','));
if (list1 != null)
{
foreach (var md in resultModel.DataSource)
{
var list2 = list1.FindAll(n => n.OrderId == md.OrderId);
if (list2 != null)
{
md.GoodsList = list2;
}
}
}
}
var listTrack = obj.GetTrackCodeApplyList(Ids.Trim(','));
if (listTrack != null)
{
foreach (var md in resultModel.DataSource)
{
List list3 = new List();
if (md.JoinOrderCode != null && md.JoinOrderCode != "")
{
list3 = listTrack.FindAll(n => n.OrderCode == md.JoinOrderCode);
}
else
list3 = listTrack.FindAll(n => n.OrderId == md.OrderId);
if (list3 != null && list3.Count > 0)
{
string trackinfo = "";
string blank = "";
string trackinfo1 = "";
foreach (var md1 in list3)
{
if (md1.TrackType == 3)
blank = "[空包裹]";
if (md1.Weight != null)
trackinfo += md1.TrackCode + blank + "重量" + md1.Weight.ToString() + "g;
";
else
trackinfo += md1.TrackCode + blank + "
";
trackinfo1 = md1.TrackCode + blank + "
";
}
md.TrackInfo = trackinfo;
md.TrackCode = trackinfo1;
}
}
}
}
}
return resultModel;
}
#endregion
#region 获取物流单号
[WebMethod(EnableSession = true)]
public string GetOrderPostCodeList(string OrderIds, int PostId, int CompanyId)
{
PagesNew.Login(this.Session);
var obj = new DD_OrderData();
if (CompanyId == 0)
CompanyId = Convert.ToInt32(Session["CompanyId"]);
var companymd = new JC_PostAddress();
var obj1 = new JC_ExpressService();
var obj11 = new BaseService();
companymd = obj11.GetAddressModel2(PostId);
string ErrorInfo = "";
string PostCode = "";
var obj2 = new BaseService();
var md = DataNew.GetExpressModel(CompanyId, PostId);
var orderlist = obj.GetOrderModelList(OrderIds.Trim(','));
var orderGoodslist = DataNew.GetOrderGoodsList2(OrderIds.Trim(','));
if(orderlist==null||orderGoodslist==null||md==null)
return "";
foreach (var ordermd in orderlist)
{
if ((ordermd.RevPhone == null || ordermd.RevPhone == "") && (ordermd.RevPhone == null || ordermd.RevPhone == ""))
ErrorInfo += ordermd.PlatOrderCode + "收件人电话没填";
if(ordermd.RevPostCode==null||ordermd.RevPostCode=="")
ErrorInfo += ordermd.PlatOrderCode + "收件人邮编没填";
if (ordermd.RevProvince == null || ordermd.RevProvince == "")
ErrorInfo += ordermd.PlatOrderCode + "州没填";
var goodslist = orderGoodslist.FindAll(n => n.OrderId == ordermd.OrderId);
if (goodslist == null)
ErrorInfo += ordermd.PlatOrderCode + "货物没有分配";
else
{
foreach (var gmd in goodslist)
{
if (gmd.Weight == null && gmd.Weight2 == null)
{
ErrorInfo += ordermd.PlatOrderCode+" "+gmd.GoodsSKU + "货物重量没填";
}
if (gmd.Long == null && gmd.Long2== null)
{
ErrorInfo += ordermd.PlatOrderCode + " " + gmd.GoodsSKU + "货物尺寸没填";
}
else if (gmd.Width == null && gmd.Width2 == null)
{
ErrorInfo += ordermd.PlatOrderCode + " " + gmd.GoodsSKU + "货物尺寸没填";
}
else if (gmd.Height == null && gmd.Height2 == null)
{
ErrorInfo += ordermd.PlatOrderCode + " " + gmd.GoodsSKU + "货物尺寸没填";
}
}
}
}
if (ErrorInfo != "")
{
return ErrorInfo;
}
var plist = new List();
foreach (var ordermd in orderlist)
{
var goodslist = orderGoodslist.FindAll(n => n.OrderId == ordermd.OrderId);
if (md.Name.Contains("Fedex") && md.customercode != null && md.customercode != "")
{
FedexSmartPostNew fedexobj = new FedexSmartPostNew();
FedexSmartPostNew.Key = md.UserCode;
FedexSmartPostNew.Password = md.CheckCode;
FedexSmartPostNew.AccountNumber = md.client_id;
FedexSmartPostNew.MeterNumber = md.client_secret;
FedexSmartPostNew.PayAccountNumber = md.refresh_token;
FedexSmartPostNew.HubId = md.Code;
FedexSmartPostNew.PostName = md.customercode;
FedexSmartPostNew.IsQM = 0;
FedexOrder fdorder = new FedexOrder();
Shiper shiper = new Shiper
{
City = companymd.city,
CompanyName = companymd.SendEnglishName,
PersonName = companymd.SendEnglishName,
PhoneNumber = companymd.Phone,
PostalCode = companymd.PostCode,
StateOrProvinceCode = companymd.provincecode,
StreetLines = companymd.EnglishAddress,
CountryCode = companymd.countycode
};
fdorder.Shiper = shiper;
fdorder.CustomerTransactionId = ordermd.PlatOrderCode;
fdorder.PostId = new int?(PostId);
string Phone=ordermd.RevMoblie;
if(ordermd.RevPhone!=null&&ordermd.RevPhone!="")
Phone=ordermd.RevPhone;
Rever rever = new Rever
{
City = ordermd.RevCity,
CompanyName = ordermd.RevName,
PersonName = ordermd.RevName,
PhoneNumber =Phone,
PostalCode = ordermd.RevPostCode
};
if ((ordermd.RevProvince == null) || (ordermd.RevProvince == ""))
{
rever.StateOrProvinceCode = ordermd.RevCity;
}
else
{
rever.StateOrProvinceCode = ordermd.RevProvince;
}
rever.StreetLines = ordermd.RevAddr;
rever.CountryCode = ordermd.CountryCode;
fdorder.Rever = rever;
List fedlist = new List();
string gsku = "";
int gnum = 0;
decimal ww = 0;
decimal c = 0;
decimal k = 0;
decimal g = 0;
foreach (var gmd in goodslist)
{
if(gmd.GoodsSKU!=null&&gmd.GoodsSKU!="")
gsku += gmd.GoodsNum.Value+"x"+gmd.GoodsSKU;
gnum += gmd.GoodsNum.Value;
if (gmd.Weight2 != null)
ww += gmd.GoodsNum.Value * gmd.Weight2.Value *Convert.ToDecimal(0.0625);
else if (gmd.Weight != null)
ww += gmd.GoodsNum.Value * gmd.Weight.Value * Convert.ToDecimal(0.0022046);
if (gmd.Long2 != null)
c += gmd.Long2.Value;
else if (gmd.Long != null)
c += gmd.Long.Value* Convert.ToDecimal(0.3937008);
if (gmd.Width2 != null)
k += gmd.Width2.Value;
else if (gmd.Width != null)
k += gmd.Width.Value * Convert.ToDecimal(0.3937008);
if (gmd.Height2 != null)
g += gmd.Height2.Value;
else if (gmd.Height != null)
g += gmd.Height.Value * Convert.ToDecimal(0.3937008);
}
FedexGoods fgmd = new FedexGoods
{
Amount = 10.000M,
SKU = gsku,
Description = gsku,
NumberOfPieces = gnum.ToString(),
Weight = ww,
Height=Math.Ceiling(g).ToString(),
Lenght = Math.Ceiling(c).ToString(),
Width = Math.Ceiling(k).ToString(),
Quantity = gnum
};
fedlist.Add(fgmd);
fdorder.GoodsList = fedlist;
string error = "";
PostCode = fedexobj.GetFedex(fdorder, out error);
if (error != "")
ErrorInfo += error;
else if (PostCode != null && PostCode != "" && !PostCode.Contains("失败"))
{
DT_TrackCodeApplyNew Model = new DT_TrackCodeApplyNew();
if (PostCode.Contains(','))
{
string[] tracklist = PostCode.Split(',');
if (tracklist.Length > 1)
{
Model.TrackCode = tracklist[0].ToString();
Model.TrackCode2 = tracklist[1].ToString();
}
}
else
{
Model.TrackCode = PostCode;
}
Model.GetDate = DateTime.Now;
Model.InName = Session["Name"].ToString();
if (ordermd.JoinOrderCode != null && ordermd.JoinOrderCode != "")
Model.OrderCode = ordermd.JoinOrderCode;
else
Model.OrderCode = ordermd.PlatOrderCode;
Model.OrderCode2 = fdorder.CustomerTransactionId;
Model.SKU = gsku;
Model.Weight2 = ww.ToString("0.00");
Model.Long = Math.Ceiling(c).ToString();
Model.Height = Math.Ceiling(g).ToString();
Model.Width = Math.Ceiling(k).ToString();
Model.OrderId = ordermd.OrderId;
Model.PostId = PostId;
Model.State = 1;
Model.TrackType = 1;
Model.UpdateTime = DateTime.Now;
Model.IsSpare = 0;
Model.LabelUrl = PostCode + ".png";
Model.JoinOrderCode = ordermd.JoinOrderCode;
plist.Add(Model);
}
}
}
if (plist != null && plist.Count > 0)
{
foreach (var pmd in plist)
{
if (pmd.TrackCode != null)
{
if(pmd.TrackCode!="")
DataNew.SaveTrackCodeApply(pmd);
}
}
}
if (ErrorInfo == "")
return "";
else
return ErrorInfo+";其他订单获取成功";
}
#endregion
#region 获取物流单号
[WebMethod(EnableSession = true)]
public string GetOrderPostCodeOne(string OrderIds, int PostId, int CompanyId, string SKU, int Num, int IsSpare, decimal? weight, decimal? cd, decimal? kd, decimal? gd, int IsQS)
{
PagesNew.Login(this.Session);
var obj = new DD_OrderData();
if (CompanyId == 0)
CompanyId = Convert.ToInt32(Session["CompanyId"]);
var companymd = new JC_PostAddress();
var obj1 = new JC_ExpressService();
var obj11 = new BaseService();
companymd = obj11.GetAddressModel2(PostId);
string ErrorInfo = "";
string PostCode = "";
var obj2 = new BaseService();
var md = DataNew.GetExpressModel(CompanyId, PostId);
var orderlist = obj.GetOrderModelList(OrderIds.Trim(','));
var orderGoodslist = DataNew.GetOrderGoodsList2(OrderIds.Trim(','));
if (orderlist == null || orderGoodslist == null || md == null)
return "";
foreach (var ordermd in orderlist)
{
if ((ordermd.RevPhone == null || ordermd.RevPhone == "") && (ordermd.RevPhone == null || ordermd.RevPhone == ""))
ErrorInfo += ordermd.PlatOrderCode + "收件人电话没填";
if (ordermd.RevPostCode == null || ordermd.RevPostCode == "")
ErrorInfo += ordermd.PlatOrderCode + "收件人邮编没填";
if (ordermd.RevProvince == null || ordermd.RevProvince == "")
ErrorInfo += ordermd.PlatOrderCode + "州没填";
}
if (ErrorInfo != "")
{
return ErrorInfo;
}
var plist = new List();
foreach (var ordermd in orderlist)
{
var goodslist = orderGoodslist.FindAll(n => n.OrderId == ordermd.OrderId);
if (md.Name.Contains("Fedex") && md.customercode != null && md.customercode != "")
{
FedexSmartPostNew2 fedexobj = new FedexSmartPostNew2();
FedexSmartPostNew2.Key = md.UserCode;
FedexSmartPostNew2.Password = md.CheckCode;
FedexSmartPostNew2.AccountNumber = md.client_id;
FedexSmartPostNew2.MeterNumber = md.client_secret;
FedexSmartPostNew2.PayAccountNumber = md.refresh_token;
FedexSmartPostNew2.HubId = md.Code;
FedexSmartPostNew2.PostName = md.customercode;
if (IsQS == 1)
FedexSmartPostNew2.IsQM = 1;
else
FedexSmartPostNew2.IsQM = 0;
FedexOrder fdorder = new FedexOrder();
string SendName = companymd.SendName;
string PersonName = companymd.SendEnglishName;
if (goodslist != null && goodslist[0].SendName != null && goodslist[0].SendName != "")
{
SendName = goodslist[0].SendName;
PersonName = goodslist[0].SendName;
}
Shiper shiper = new Shiper
{
City = companymd.city,
CompanyName = SendName,
PersonName = PersonName,
PhoneNumber = companymd.Phone,
PostalCode = companymd.PostCode,
StateOrProvinceCode = companymd.provincecode,
StreetLines = companymd.EnglishAddress,
CountryCode = companymd.countycode
};
fdorder.Shiper = shiper;
Random rd = new Random();
if (IsSpare == 1)
fdorder.CustomerTransactionId = ordermd.PlatOrderCode + rd.Next(100, 999);
else
fdorder.CustomerTransactionId = ordermd.PlatOrderCode;
fdorder.PostId = new int?(PostId);
string Phone = ordermd.RevMoblie;
if (ordermd.RevPhone != null && ordermd.RevPhone != "")
Phone = ordermd.RevPhone;
Rever rever = new Rever
{
City = ordermd.RevCity,
CompanyName = ordermd.RevName,
PersonName = ordermd.RevName,
PhoneNumber = Phone,
CountryCode = ordermd.CountryCode,
PostalCode = ordermd.RevPostCode
};
if ((ordermd.RevProvince == null) || (ordermd.RevProvince == ""))
{
rever.StateOrProvinceCode = ordermd.RevCity;
}
else
{
rever.StateOrProvinceCode = ordermd.RevProvince;
}
if (ordermd.PlatId == 22) //TikTok的申请快递面单的详细地址过长,需要减去国家,省,市等,否则面单显示不下
{
rever.StreetLines = string.IsNullOrEmpty(ordermd.RevAddr) ? "" : (ordermd.RevAddr.Split(',').Last());
}
else
rever.StreetLines = ordermd.RevAddr;
rever.CountryCode = ordermd.CountryCode;
fdorder.Rever = rever;
List fedlist = new List();
string gsku = "";
int gnum = 0;
decimal ww = 0;
decimal c = 0;
decimal k = 0;
decimal g = 0;
if (SKU != "")
{
gsku += SKU + " ";
ww = weight.Value * Convert.ToDecimal(0.0625);
c = cd.Value;
k = kd.Value;
g = gd.Value;
gnum = Num;
}
else
{
foreach (var gmd in goodslist)
{
if (gmd.GoodsSKU != null && gmd.GoodsSKU != "")
gsku += gmd.GoodsNum.Value + "x" + gmd.GoodsSKU + " ";
gnum += gmd.GoodsNum.Value;
if (gmd.Weight2 != null)
ww += gmd.GoodsNum.Value * gmd.Weight2.Value * Convert.ToDecimal(0.0625);
else if (gmd.Weight != null)
ww += gmd.GoodsNum.Value * gmd.Weight.Value * Convert.ToDecimal(0.0022046);
if (gmd.Long2 != null)
c += gmd.Long2.Value;
else if (gmd.Long != null)
c += gmd.Long.Value * Convert.ToDecimal(0.3937008);
if (gmd.Width2 != null)
k += gmd.Width2.Value;
else if (gmd.Width != null)
k += gmd.Width.Value * Convert.ToDecimal(0.3937008);
if (gmd.Height2 != null)
g += gmd.Height2.Value;
else if (gmd.Height != null)
g += gmd.Height.Value * Convert.ToDecimal(0.3937008);
}
}
FedexGoods fgmd = new FedexGoods
{
Amount = 10.000M,
SKU = gsku,
Description = gsku,
NumberOfPieces = gnum.ToString(),
Weight = ww,
Height = Math.Ceiling(g).ToString(),
Lenght = Math.Ceiling(c).ToString(),
Width = Math.Ceiling(k).ToString(),
Quantity = gnum
};
fedlist.Add(fgmd);
fdorder.GoodsList = fedlist;
string error = "";
var fmd = fedexobj.GetFedex(fdorder, out error);
if (fmd != null && fmd.CustomerTransactionId != null && fdorder.CustomerTransactionId == fmd.CustomerTransactionId)
PostCode = fmd.PostCode;
else if (fmd != null && fmd.CustomerTransactionId != null)
{
PostCode = "";
error = "获取失败,重新获取";
}
if (error != "")
ErrorInfo += ordermd.PlatOrderCode + ":" + error;
else if (PostCode != null && PostCode != "" && !PostCode.Contains("失败"))
{
DT_TrackCodeApplyNew Model = new DT_TrackCodeApplyNew();
if (PostCode.Contains(','))
{
string[] tracklist = PostCode.Split(',');
if (tracklist.Length > 1)
{
Model.TrackCode = tracklist[0].ToString();
Model.TrackCode2 = tracklist[1].ToString();
}
}
else
{
Model.TrackCode = PostCode;
}
Model.GetDate = DateTime.Now;
Model.InName = Session["Name"].ToString();
if (ordermd.JoinOrderCode != null && ordermd.JoinOrderCode != "")
Model.OrderCode = ordermd.JoinOrderCode;
else
Model.OrderCode = ordermd.PlatOrderCode;
Model.OrderCode2 = fdorder.CustomerTransactionId;
Model.SKU = gsku;
Model.Weight2 = ww.ToString("0.00");
Model.Long = Math.Ceiling(c).ToString();
Model.Height = Math.Ceiling(g).ToString();
Model.Width = Math.Ceiling(k).ToString();
Model.OrderId = ordermd.OrderId;
Model.PostId = PostId;
Model.State = 1;
Model.TrackType = 1;
Model.UpdateTime = DateTime.Now;
Model.IsSpare = 0;
Model.LabelUrl = PostCode + ".png";
Model.JoinOrderCode = ordermd.JoinOrderCode;
plist.Add(Model);
}
}
else if (md.Name.Contains("UPS"))
{
UpsShip fedexobj = new UpsShip();
UpsShip.AccessLicenseNumber = md.client_id;
UpsShip.Username = md.UserCode;
UpsShip.Password = md.CheckCode;
UpsShip.ShipperNumber = md.Code;
UPSOrder fdorder = new UPSOrder();
fdorder.shipservicecode = md.customercode;
fdorder.packType = "02";
Shiper shiper = new Shiper
{
City = companymd.city,
CompanyName = companymd.SendName,
PersonName = companymd.SendEnglishName,
PhoneNumber = companymd.Phone,
PostalCode = companymd.PostCode,
StateOrProvinceCode = companymd.provincecode,
StreetLines = companymd.EnglishAddress,
CountryCode = companymd.countycode
};
fdorder.Shiper = shiper;
Random rd = new Random();
if (IsSpare == 1)
fdorder.CustomerTransactionId = ordermd.PlatOrderCode + rd.Next(100, 999);
else
fdorder.CustomerTransactionId = ordermd.PlatOrderCode;
fdorder.PostId = new int?(PostId);
string Phone = ordermd.RevMoblie;
if (ordermd.RevPhone != null && ordermd.RevPhone != "")
Phone = ordermd.RevPhone;
Rever rever = new Rever
{
City = ordermd.RevCity,
CompanyName = ordermd.RevName,
PersonName = ordermd.RevName,
PhoneNumber = Phone,
PostalCode = ordermd.RevPostCode
};
if ((ordermd.RevProvince == null) || (ordermd.RevProvince == ""))
{
rever.StateOrProvinceCode = ordermd.RevCity;
}
else
{
rever.StateOrProvinceCode = ordermd.RevProvince;
}
rever.StreetLines = ordermd.RevAddr;
rever.CountryCode = ordermd.CountryCode;
fdorder.Rever = rever;
List upslist = new List();
string gsku = "";
int gnum = 0;
decimal ww = 0;
decimal c = 0;
decimal k = 0;
decimal g = 0;
if (SKU != "")
{
gsku += SKU + " ";
ww = weight.Value * Convert.ToDecimal(0.0625);
c = cd.Value;
k = kd.Value;
g = gd.Value;
gnum = Num;
}
else
{
foreach (var gmd in goodslist)
{
if (gmd.GoodsSKU != null && gmd.GoodsSKU != "")
gsku += gmd.GoodsNum.Value + "x" + gmd.GoodsSKU + " ";
gnum += gmd.GoodsNum.Value;
if (gmd.Weight2 != null)
ww += gmd.GoodsNum.Value * gmd.Weight2.Value * Convert.ToDecimal(0.0625);
else if (gmd.Weight != null)
ww += gmd.GoodsNum.Value * gmd.Weight.Value * Convert.ToDecimal(0.0022046);
if (gmd.Long2 != null)
c += gmd.Long2.Value;
else if (gmd.Long != null)
c += gmd.Long.Value * Convert.ToDecimal(0.3937008);
if (gmd.Width2 != null)
k += gmd.Width2.Value;
else if (gmd.Width != null)
k += gmd.Width.Value * Convert.ToDecimal(0.3937008);
if (gmd.Height2 != null)
g += gmd.Height2.Value;
else if (gmd.Height != null)
g += gmd.Height.Value * Convert.ToDecimal(0.3937008);
}
}
UpsGoods fgmd = new UpsGoods
{
Amount = 10.000M,
SKU = gsku,
Description = gsku,
NumberOfPieces = gnum.ToString(),
Weight = ww,
Height = Math.Ceiling(g).ToString(),
Lenght = Math.Ceiling(c).ToString(),
Width = Math.Ceiling(k).ToString(),
Quantity = gnum
};
upslist.Add(fgmd);
fdorder.GoodsList = upslist;
string error = "";
UpsShip upsobj = new UpsShip();
string LabelUrl = "";
string tcode = upsobj.GetTrackCodeNew(fdorder, out error);
if (error != "")
{
ErrorInfo += ordermd.PlatOrderCode + ":" + error;
}
else if (tcode == "")
{
PostCode = "";
error = "获取失败,重新获取";
}
else
{
PostCode = tcode;
UpsLabel objlb = new UpsLabel();
UpsLabel.AccessLicenseNumber = md.client_id;
UpsLabel.Username = md.UserCode;
UpsLabel.Password = md.CheckCode;
UpsLabel.ShipperNumber = md.Code;
//string lberror = "";
//objlb.GetLabel(PostCode, out lberror);
//if (lberror == "")
//{
// LabelUrl = PostCode + ".png";
//}
LabelUrl = PostCode + ".png";
}
if (PostCode != null && PostCode != "" && !PostCode.Contains("失败"))
{
DT_TrackCodeApplyNew Model = new DT_TrackCodeApplyNew();
if (PostCode.Contains(','))
{
string[] tracklist = PostCode.Split(',');
if (tracklist.Length > 1)
{
Model.TrackCode = tracklist[0].ToString();
Model.TrackCode2 = tracklist[1].ToString();
}
}
else
{
Model.TrackCode = PostCode;
}
Model.GetDate = DateTime.Now;
Model.InName = Session["Name"].ToString();
if (ordermd.JoinOrderCode != null && ordermd.JoinOrderCode != "")
Model.OrderCode = ordermd.JoinOrderCode;
else
Model.OrderCode = ordermd.PlatOrderCode;
Model.OrderCode2 = fdorder.CustomerTransactionId;
Model.SKU = gsku;
Model.Weight2 = ww.ToString("0.00");
Model.Long = Math.Ceiling(c).ToString();
Model.Height = Math.Ceiling(g).ToString();
Model.Width = Math.Ceiling(k).ToString();
Model.OrderId = ordermd.OrderId;
Model.PostId = PostId;
Model.State = 1;
Model.TrackType = 1;
Model.UpdateTime = DateTime.Now;
Model.IsSpare = 0;
Model.LabelUrl = LabelUrl;// PostCode + ".png";
Model.JoinOrderCode = ordermd.JoinOrderCode;
plist.Add(Model);
}
}
}
if (plist != null && plist.Count > 0)
{
foreach (var pmd in plist)
{
if (pmd.TrackCode != null)
{
if (pmd.TrackCode != "")
DataNew.SaveTrackCodeApply(pmd);
}
}
}
if (ErrorInfo == "")
return "";
else
return ErrorInfo + ";";
}
#endregion
#region 获取物流sku
[WebMethod(EnableSession = true)]
public DT_TrackCodeApplyNew GetOrderFedexSKU(string OrderIds)
{
PagesNew.Login(this.Session);
var obj = new DD_OrderData();
var orderGoodslist = DataNew.GetOrderGoodsList2(OrderIds.Trim(','));
if (orderGoodslist == null)
return null;
string gsku = "";
int gnum = 0;
decimal ww = 0;
decimal c = 0;
decimal k = 0;
decimal g = 0;
foreach (var gmd in orderGoodslist)
{
if (gmd.GoodsSKU != null && gmd.GoodsSKU != "")
gsku += gmd.GoodsNum.Value + "x" + gmd.GoodsSKU + " ";
gnum += gmd.GoodsNum.Value;
if (gmd.Weight2 != null)
ww += gmd.GoodsNum.Value * gmd.Weight2.Value;
else if (gmd.Weight != null)
ww += gmd.GoodsNum.Value * gmd.Weight.Value * Convert.ToDecimal(0.035274);
decimal c2 = 0;
decimal k2 = 0;
decimal g2 = 0;
if (gmd.Long2 != null)
c2 = gmd.Long2.Value;
// else if (gmd.Long != null)
// c2 = gmd.Long.Value * Convert.ToDecimal(0.3937008);
if (gmd.Width2 != null)
k2 = gmd.Width2.Value;
// else if (gmd.Width != null)
// k2 = gmd.Width.Value * Convert.ToDecimal(0.3937008);
if (gmd.Height2 != null)
g2 = gmd.Height2.Value;
// else if (gmd.Height != null)
// g2 = gmd.Height.Value * Convert.ToDecimal(0.3937008);
if (c2 > c)
c = c2;
if (k2 > k)
k = k2;
if (g2 > g)
g = g2;
}
DT_TrackCodeApplyNew Model = new DT_TrackCodeApplyNew();
Model.SKU = gsku;
if (ww > 0)
Model.Weight2 = ww.ToString("0.00");
if (c > 0)
Model.Long = Math.Ceiling(c).ToString();
if (g > 0)
Model.Height = Math.Ceiling(g).ToString();
if (k > 0)
Model.Width = Math.Ceiling(k).ToString();
return Model;
}
#endregion
#region 获取物流sku
[WebMethod(EnableSession = true)]
public List GetOrderFedexSKU2(int OrderId)
{
PagesNew.Login(this.Session);
var obj = new DD_OrderData();
var olist = DataNew.GetListSpareFee(OrderId);
if (olist != null && olist.Count > 0)
return olist;
var orderGoodslist = DataNew.GetOrderGoodsList3(OrderId);
if (orderGoodslist == null)
return null;
List list = new List();
foreach (var gmd in orderGoodslist)
{
if (gmd.GoodsNum > 0)
{
for (int i = 0; i < gmd.GoodsNum; i++)
{
DT_SpareFee Model = new DT_SpareFee();
Model.Sku = gmd.GoodsSKU;
decimal ww = 0;
decimal c = 0;
decimal k = 0;
decimal g = 0;
if (gmd.Weight2 != null)
ww = gmd.Weight2.Value;
else if (gmd.Weight != null)
ww = gmd.Weight.Value * Convert.ToDecimal(0.035274);
Model.Weight = ww.ToString("0.00");
if (gmd.Long2 != null)
c = gmd.Long2.Value;
// else if (gmd.Long != null)
// c = gmd.Long.Value * Convert.ToDecimal(0.3937008);
if (gmd.Width2 != null)
k = gmd.Width2.Value;
// else if (gmd.Width != null)
// k = gmd.Width.Value * Convert.ToDecimal(0.3937008);
if (gmd.Height2 != null)
g = gmd.Height2.Value;
// else if (gmd.Height != null)
// g = gmd.Height.Value * Convert.ToDecimal(0.3937008);
if (c > 0)
Model.Long = Math.Ceiling(c).ToString();
if (g > 0)
Model.Height = Math.Ceiling(g).ToString();
if (k > 0)
Model.Width = Math.Ceiling(k).ToString();
list.Add(Model);
}
}
}
return list;
}
#endregion
#region 获取物流sku
[WebMethod(EnableSession = true)]
public List GetOrderFedexSKU3(int OrderId)
{
PagesNew.Login(this.Session);
var obj = new DD_OrderData();
var olist = DataNew.GetListSpareFee(OrderId);
return olist;
}
#endregion
#region 查询订单跟踪码
[WebMethod(EnableSession = true)]
public List GetOrderTrackCodeList(int OrderId, string JoinOrderCode)
{
Pages.Login(this.Session);
var obj = new DD_OrderData();
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
var list = DataNew.GetOrderTrackCodeNew(OrderId, JoinOrderCode);
if (list != null)
{
foreach (var md in list)
{
md.SKUstr = md.SKU;
string sku = "";
sku += md.SKU;
if (md.Weight2 != null)
sku += md.Weight2 + "磅";
if(md.Long!=null)
sku +="长:" +md.Long + "in";
if (md.Width != null)
sku += "宽:" + md.Width + "in";
if (md.Height != null)
sku += "高:" + md.Height + "in";
md.SKU = sku;
}
}
return list;
}
#endregion
#region 查询物流订单
[WebMethod(EnableSession = true)]
public JsonModel> GetListOrderExpressForTM(int SortId, int DeptId, int PlatType, int TrackState, int MateState, int ShopId, int DateType, DateTime? SDate, DateTime? EDate, int OutDays, int TjType, string Name, int ExpressState, int IsSku, int IsError, int IsDetail, int HBOrder, int PostId, int LogisticsId, int Addr, int PageIndex, int PageSize, string Sort,int GoodsNum)
{
Pages.Login(this.Session);
var obj = new DD_OrderData();
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
RefParameterCollection Param = new RefParameterCollection();
if (DeptId > 0)
Param.Add("c.DeptId", "=", DeptId, DbType.Int32);
Param.Add("a.CompanyId", "=", CompanyId, DbType.Int32);
if (MateState > -1)
Param.Add("a.MateState", "=", MateState, DbType.Int32);
if(GoodsNum==1)
Param.Add("a.GoodsNum", "=", 1, DbType.Int32);
int IsTrack = TrackState;
//if (ExpressState>-1)
Param.Add("isnull(a.PrintState,0)", "=", 0, DbType.Int32);
if (PlatType > 0)
Param.Add("a.PlatId", "=", PlatType, DbType.Int32);
if (ShopId > 0)
Param.Add("a.ShopId", "=", ShopId, DbType.Int32);
if (DateType == 1)
{
if (SDate != null)
Param.Add("a.OrderDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.OrderDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
else
if (DateType == 2)
{
if (SDate != null)
Param.Add("a.InDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.InDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
else
if (DateType == 3)
{
if (SDate != null)
Param.Add("a.PrintDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.PrintDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
else
if (DateType == 4)
{
if (SDate != null)
Param.Add("a.PostDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.PostDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
else
if (DateType == 5)
{
if (SDate != null)
Param.Add("a.OrderOutDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.OrderOutDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
if (OutDays > 0)
{
Param.Add("a.OrderOutDate", "<=", DateTime.Now.AddHours(OutDays), DbType.DateTime);
Param.Add("a.OrderOutDate", ">=", DateTime.Now, DbType.DateTime);
}
if (LogisticsId > 0)
Param.Add("b.LogisticsId", "=", LogisticsId, DbType.String);
if (ExpressState == 0)
{
Param.Add("isnull(b.Post,0)", "=", 0, DbType.Int32);
}
else if (ExpressState == 2)
{
Param.Add("b.Post", ">", 0, DbType.Int32);
Param.Add("isnull(b.TrackState,0)", "=", 0, DbType.Int32);
}
else
if (ExpressState == 1)
{
Param.Add("b.Post", ">", 0, DbType.Int32);
Param.Add("b.TrackState", ">", 0, DbType.Int32);
}
if (PostId > 0)
Param.Add("b.Post", "=", PostId, DbType.Int32);
Param.Add("a.State", "=", 1, DbType.Int32);
if (HBOrder == 1)
Param.Add("a.IsJoin", "=", 1, DbType.Int32);
if (IsError == 1)
{
Param.Add("(b.SendAddr", ">", 0, DbType.Int32);
Param.Add("b.IsLeaveWord", "=", 1, "or", ")", DbType.Int32);
}
string TCode = "";
if (Name != "")
{
if (TjType == 1)
{
Param.Add("(a.PlatOrderCode", "=", Name, DbType.String);
Param.Add("a.JoinOrderCode", "=", Name, "or", ")", DbType.String);
}
else if (TjType == 2)
{
Param.Add("b.RevName", "like", Name, DbType.String);
}
else if (TjType == 3)
{
Param.Add("b.RevPhone", "like", Name, DbType.String);
}
else if (TjType == 4)
{
Param.Add("(b.RevCountry", "=", Name, DbType.String);
Param.Add("b.CountryName", "=", Name, "or", DbType.String);
Param.Add("b.CountryCode", "=", Name, "or", ")", DbType.String);
}
else if (TjType == 5)
{
Param.Add("b.RevPostCode", "=", Name, DbType.String);
}
else if (TjType == 6)
{
Param.Add("(b.RevAddr", "like", Name, DbType.String);
Param.Add("b.RevProvince", "like", Name, "or", DbType.String);
Param.Add("b.RevCity", "like", Name, "or", DbType.String);
Param.Add("b.RevArea", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 9)
{
Param.Add("(b.ErrorInfo", "like", Name, DbType.String);
Param.Add("b.PostError", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 10)
{
// Param.Add("dbo.getOrderTrackCode(a.OrderId,1)", "like", Name, DbType.String);
TCode = Name;
}
}
if (IsSku == 0)
Param.Add("a.FPDate", "is", null, DbType.String);
else if (IsSku == 1)
Param.Add("a.FPDate", "is not", null, DbType.String);
//if (Addr > -1)
//{
// Param.Add("b.SendAddr", "=", Addr, DbType.Int32);
//}
// Param.Add("a.OrderDate", ">=", 0, DbType.Int32);
JsonModel> resultModel = new JsonModel>();
int RowCount = 0;
//var pxlist = obj.GetLevelConfig(CompanyId, 0);
// string Sort = "JoinOrderCode,PlatOrderCode";
//if (pxlist != null)
//{
// Sort = "";
// foreach (var md in pxlist)
// {
// if (md.SortType == 1)
// Sort += "a.OrderLevel desc,";
// else if (md.SortType == 2)
// Sort += "a.OrderDate,";
// else if (md.SortType == 3)
// Sort += "c.LevelGrade desc,";
// else if (md.SortType == 4)
// Sort += "a.RMBPrice desc,";
// }
//}
//Sort = Sort.Trim(',');
string GoodsName = "";
string SKU = "";
if (TjType == 7 && Name != "")
{
GoodsName = Name;
}
else
if (TjType == 8 && Name != "")
{
SKU = Name;
}
if (ExpressState == -1)
resultModel.DataSource = obj.GetListDT_OrderInfoExpressForTM(SortId, IsTrack, TCode, GoodsName, SKU, IsSku, Param, PageIndex, PageSize, Sort, out RowCount);
else
resultModel.DataSource = obj.GetListDT_OrderInfoExpressForTM2(SortId, IsTrack, TCode, GoodsName, SKU, IsSku, Param, PageIndex, PageSize, Sort, out RowCount);
resultModel.RowCount = RowCount;
string Ids = "";
if (resultModel.DataSource != null)
{
foreach (var md in resultModel.DataSource)
{
Ids += md.OrderId.ToString() + ",";
}
}
if (Ids != "")
{
JC_ExpressService obj3 = new JC_ExpressService();
var elist = obj3.GetExpressTypeList();
var plist = obj3.GetExpressList();
var errorlist = obj.GetErrorList(Ids.Trim(','));
if (errorlist != null || elist != null || plist != null)
{
foreach (var md in resultModel.DataSource)
{
if (errorlist != null && errorlist.Count > 0)
{
var emd = errorlist.Find(n => n.OrderId == md.OrderId);
if (emd != null)
{
md.ErrorInfo = emd.ErrorInfo;
}
}
//if (md.LogisticsId>0&&elist != null && elist.Count > 0)
//{
// var emd = elist.Find(n => n.LogisticsId == md.LogisticsId);
// if (emd != null)
// {
// md.PostInfo = emd.LogisticsName;
// }
//}
if (md.Post > 0 && plist != null && plist.Count > 0)
{
var emd = plist.Find(n => n.ExpressID == md.Post);
if (emd != null)
{
md.LocalPost = emd.Name;
}
}
}
}
}
if (resultModel.DataSource != null)
{
if (Ids != "")
{
if (IsDetail == 1)
{
var list1 = obj.GetOrderGoodsList(Ids.Trim(','));
if (list1 != null)
{
foreach (var md in resultModel.DataSource)
{
var list2 = list1.FindAll(n => n.OrderId == md.OrderId);
if (list2 != null)
{
md.GoodsList = list2;
}
}
}
}
var listTrack = obj.GetTrackCodeApplyList(Ids.Trim(','));
if (listTrack != null)
{
foreach (var md in resultModel.DataSource)
{
List list3 = new List();
if (md.JoinOrderCode != null && md.JoinOrderCode != "")
{
list3 = listTrack.FindAll(n => n.OrderCode == md.JoinOrderCode);
}
else
list3 = listTrack.FindAll(n => n.OrderId == md.OrderId);
if (list3 != null && list3.Count > 0)
{
string trackinfo = "";
string blank = "";
string trackinfo1 = "";
foreach (var md1 in list3)
{
if (md1.TrackType == 3)
blank = "[空包裹]";
if (md1.Weight != null)
trackinfo += md1.TrackCode + blank + "重量" + md1.Weight.ToString() + "g;
";
else
trackinfo += md1.TrackCode + blank + "
";
trackinfo1 = md1.TrackCode + blank + "
";
}
md.TrackInfo = trackinfo;
md.TrackCode = trackinfo1;
}
}
}
}
}
return resultModel;
}
#endregion
#region 返回订单Model
[WebMethod(EnableSession = true)]
public DT_OrderModel GetOrderModelNew(int OrderId)
{
Pages.Login(this.Session);
var obj = new DD_OrderData();
//int CompanyId = Convert.ToInt32(Session["CompanyId"]);
var md = obj.GetOrderModel(OrderId);
if (md==null)
return null;
if (md.IsSpare == 1)
{
string TrackCodes = "";
var splist = obj.GetOrderSpareList(OrderId);
if (splist != null)
{
for (int i = 0; i < splist.Count; i++)
{
TrackCodes += splist[i].TrackCode.ToString() + ",";
}
}
md.TrackCode = TrackCodes.Trim(',');
}
return md;
}
#endregion
[WebMethod(EnableSession = true)]
public string GetFedexLabelNew2(string OrderIds, int PostId,int CompanyId)
{
PagesNew.Login(base.Session);
OrderPrintData data = new OrderPrintData();
List source = null;
var obj = new DD_OrderData();
if (source == null)
{
source = DataNew.GetOrderPrintListForFedex(OrderIds.TrimEnd(','), 0);
}
if (source == null || source.Count == 0)
{
return "";
}
BaseService obj2 = new BaseService();
var expressmd = DataNew.GetExpressModel2(PostId, CompanyId);
JC_ExpressService service = new JC_ExpressService();
DataTable table = new DataTable();
table.Columns.Add("SKU");
table.Columns.Add("OrderCode");
table.Columns.Add("SKU3");
table.Columns.Add("Photo3");
table.Columns.Add("SKU2");
table.Columns.Add("Photo2");
table.Columns.Add("SKU4");
table.Columns.Add("Photo4");
table.Columns.Add("SKU5");
table.Columns.Add("Photo5");
table.Columns.Add("Photo0");
string str2 = "";
string wordTemplatePath = "";
foreach (var order2 in source)
{
wordTemplatePath = expressmd.PrintTemplateName;
DataRow row = table.NewRow();
row["Photo0"] = AppDomain.CurrentDomain.BaseDirectory + "attached/fedex/" + order2.TrackCode.ToString() + ".png";
row["OrderCode"] = order2.OrderCode;
row["SKU"] = "";
if (order2.GoodsList != null && order2.GoodsList.Count > 0 && order2.GoodsList[0].GoodsUrl != null && order2.GoodsList[0].GoodsUrl != "")
{
row["Photo2"] = AppDomain.CurrentDomain.BaseDirectory + order2.GoodsList[0].GoodsUrl.Replace("../", "");
}
if ((order2.GoodsList != null && order2.GoodsList.Count > 0))
{
row["SKU2"] = order2.GoodsList[0].SKU1 + " " + order2.GoodsList[0].GoodsName + order2.GoodsList[0].GoodsCode + " " + order2.GoodsList[0].TypeDesc + "[Number]:" + order2.GoodsList[0].GoodsNum + " [Storage Location]:" + order2.GoodsList[0].PostionDesc;
}
if (order2.GoodsList != null && order2.GoodsList.Count > 1 && order2.GoodsList[1].GoodsUrl != null && order2.GoodsList[1].GoodsUrl != "")
{
row["Photo3"] = AppDomain.CurrentDomain.BaseDirectory + order2.GoodsList[1].GoodsUrl.Replace("../", "");
}
if (order2.GoodsList != null && order2.GoodsList.Count > 1)
{
row["SKU3"] = order2.GoodsList[1].SKU1 + " " + order2.GoodsList[1].GoodsName + order2.GoodsList[1].GoodsCode + " " + order2.GoodsList[1].TypeDesc + "[Number]:" + order2.GoodsList[1].GoodsNum + " [Storage Location]:" + order2.GoodsList[1].PostionDesc;
}
if (order2.GoodsList != null && order2.GoodsList.Count > 2 && order2.GoodsList[2].GoodsUrl != null && order2.GoodsList[2].GoodsUrl != "")
{
row["Photo4"] = AppDomain.CurrentDomain.BaseDirectory + order2.GoodsList[2].GoodsUrl.Replace("../", "");
}
if ((order2.GoodsList != null && order2.GoodsList.Count > 2))
{
row["SKU4"] = order2.GoodsList[2].SKU1 + " " + order2.GoodsList[2].GoodsName + order2.GoodsList[2].GoodsCode + " " + order2.GoodsList[2].TypeDesc + "[Number]:" + order2.GoodsList[2].GoodsNum + " [Storage Location]:" + order2.GoodsList[2].PostionDesc;
}
if (order2.GoodsList != null && order2.GoodsList.Count > 3 && order2.GoodsList[3].GoodsUrl != null && order2.GoodsList[3].GoodsUrl != "")
{
row["Photo4"] = AppDomain.CurrentDomain.BaseDirectory + order2.GoodsList[3].GoodsUrl.Replace("../", "");
}
if ((order2.GoodsList != null && order2.GoodsList.Count > 3))
{
row["SKU4"] = order2.GoodsList[3].SKU1 + " " + order2.GoodsList[3].GoodsName + order2.GoodsList[3].GoodsCode + " " + order2.GoodsList[3].TypeDesc + "[Number]:" + order2.GoodsList[3].GoodsNum + " [Storage Location]:" + order2.GoodsList[3].PostionDesc;
}
if (order2.GoodsList.Count > 4)
{
for (int i = 4; i < order2.GoodsList.Count; i++)
{
row["SKU"] += order2.GoodsList[i].SKU1 + "[Number]:" + order2.GoodsList[i].GoodsNum + " [Storage Location]:" + order2.GoodsList[i].PostionDesc + ";";
}
}
table.Rows.Add(row);
}
TableColumnCollection listColumns = new TableColumnCollection();
listColumns.Add("SKU", "SKU", DbType.String, "");
listColumns.Add("OrderCode", "OrderCode", DbType.String, "");
listColumns.Add("SKU2", "SKU2", DbType.String, "");
listColumns.Add("Photo2", "Photo2", DbType.Object, "40*40");
listColumns.Add("SKU3", "SKU3", DbType.String, "");
listColumns.Add("Photo3", "Photo3", DbType.Object, "40*40");
listColumns.Add("SKU4", "SKU4", DbType.String, "");
listColumns.Add("Photo4", "Photo4", DbType.Object, "40*40");
listColumns.Add("SKU5", "SKU5", DbType.String, "");
listColumns.Add("Photo5", "Photo5", DbType.Object, "40*40");
listColumns.Add("Photo0", "Photo0", DbType.Object, "265*390");
MicrosoftWord word = new MicrosoftWord();
if (wordTemplatePath != null)
{
str2 = word.Export(wordTemplatePath, table, listColumns, ".pdf");
}
return str2;
}
[WebMethod(EnableSession = true)]
public string GetFedexLabelNew(string OrderIds, int PostId)
{
PagesNew.Login(base.Session);
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
OrderPrintData data = new OrderPrintData();
List source = null;
var obj = new DD_OrderData();
if (source == null)
{
source = DataNew.GetOrderPrintListForFedex(OrderIds.TrimEnd(','), 0);
}
if (source == null || source.Count == 0)
{
return "";
}
string[] oids = OrderIds.TrimEnd(',').Split(',');
List source2 = new List();
for (int i = 0; i < oids.Length; i++)
{
var omdlist = source.FindAll(n => n.OrderId == Convert.ToInt32(oids[i]));
if (omdlist != null)
{
foreach (var omd in omdlist)
{
source2.Add(omd);
}
}
}
BaseService obj2 = new BaseService();
var expressmd = DataNew.GetExpressModel2(PostId, CompanyId);
JC_ExpressService service = new JC_ExpressService();
DataTable table = new DataTable();
table.Columns.Add("SKU");
table.Columns.Add("OrderCode");
table.Columns.Add("SKU3");
table.Columns.Add("Photo3");
table.Columns.Add("SKU2");
table.Columns.Add("Photo2");
table.Columns.Add("SKU4");
table.Columns.Add("Photo4");
table.Columns.Add("SKU5");
table.Columns.Add("Photo5");
table.Columns.Add("Photo0");
string str2 = "";
string wordTemplatePath = "";
foreach (var order2 in source2)
{
wordTemplatePath = expressmd.PrintTemplateName;
DataRow row = table.NewRow();
row["Photo0"] = AppDomain.CurrentDomain.BaseDirectory + "attached/fedex/" + order2.TrackCode.ToString() + ".png";
row["OrderCode"] = order2.OrderCode;
row["SKU"] = "";
// row["SKU2"] = "1*KM0207";
if (order2.GoodsList != null && order2.GoodsList.Count > 0 && order2.GoodsList[0].GoodsUrl != null && order2.GoodsList[0].GoodsUrl != "")
{
row["Photo2"] = AppDomain.CurrentDomain.BaseDirectory + order2.GoodsList[0].GoodsUrl.Replace("../", "");
}
string SKU2 = "";
if (order2.GoodsList != null)
{
foreach (var ggmd in order2.GoodsList)
{
SKU2 = ggmd.GoodsNum.ToString() + "x" + ggmd.SKU1 + " ";
}
}
row["SKU2"] = SKU2;
//if ((order2.GoodsList != null && order2.GoodsList.Count > 0))
//{
// row["SKU2"] = order2.GoodsList[0].SKU1 + " " + order2.GoodsList[0].GoodsName + order2.GoodsList[0].GoodsCode + " " + order2.GoodsList[0].TypeDesc + "[Number]:" + order2.GoodsList[0].GoodsNum + " [Storage Location]:" + order2.GoodsList[0].PostionDesc;
//}
if (order2.GoodsList != null && order2.GoodsList.Count > 1 && order2.GoodsList[1].GoodsUrl != null && order2.GoodsList[1].GoodsUrl != "")
{
row["Photo3"] = AppDomain.CurrentDomain.BaseDirectory + order2.GoodsList[1].GoodsUrl.Replace("../", "");
}
if (order2.GoodsList != null && order2.GoodsList.Count > 1)
{
row["SKU3"] = order2.GoodsList[1].SKU1 + " " + order2.GoodsList[1].GoodsName + order2.GoodsList[1].GoodsCode + " " + order2.GoodsList[1].TypeDesc + "[Number]:" + order2.GoodsList[1].GoodsNum + " [Storage Location]:" + order2.GoodsList[1].PostionDesc;
}
if (order2.GoodsList != null && order2.GoodsList.Count > 2 && order2.GoodsList[2].GoodsUrl != null && order2.GoodsList[2].GoodsUrl != "")
{
row["Photo4"] = AppDomain.CurrentDomain.BaseDirectory + order2.GoodsList[2].GoodsUrl.Replace("../", "");
}
if ((order2.GoodsList != null && order2.GoodsList.Count > 2))
{
row["SKU4"] = order2.GoodsList[2].SKU1 + " " + order2.GoodsList[2].GoodsName + order2.GoodsList[2].GoodsCode + " " + order2.GoodsList[2].TypeDesc + "[Number]:" + order2.GoodsList[2].GoodsNum + " [Storage Location]:" + order2.GoodsList[2].PostionDesc;
}
if (order2.GoodsList != null && order2.GoodsList.Count > 3 && order2.GoodsList[3].GoodsUrl != null && order2.GoodsList[3].GoodsUrl != "")
{
row["Photo4"] = AppDomain.CurrentDomain.BaseDirectory + order2.GoodsList[3].GoodsUrl.Replace("../", "");
}
if ((order2.GoodsList != null && order2.GoodsList.Count > 3))
{
row["SKU4"] = order2.GoodsList[3].SKU1 + " " + order2.GoodsList[3].GoodsName + order2.GoodsList[3].GoodsCode + " " + order2.GoodsList[3].TypeDesc + "[Number]:" + order2.GoodsList[3].GoodsNum + " [Storage Location]:" + order2.GoodsList[3].PostionDesc;
}
if (order2.GoodsList.Count > 4)
{
for (int i = 4; i < order2.GoodsList.Count; i++)
{
row["SKU"] += order2.GoodsList[i].SKU1 + "[Number]:" + order2.GoodsList[i].GoodsNum + " [Storage Location]:" + order2.GoodsList[i].PostionDesc + ";";
}
}
table.Rows.Add(row);
}
TableColumnCollection listColumns = new TableColumnCollection();
listColumns.Add("SKU", "SKU", DbType.String, "");
listColumns.Add("OrderCode", "OrderCode", DbType.String, "");
listColumns.Add("Photo2", "Photo2", DbType.Object, "40*40");
listColumns.Add("SKU3", "SKU3", DbType.String, "");
listColumns.Add("Photo3", "Photo3", DbType.Object, "40*40");
listColumns.Add("SKU4", "SKU4", DbType.String, "");
listColumns.Add("Photo4", "Photo4", DbType.Object, "40*40");
listColumns.Add("SKU5", "SKU5", DbType.String, "");
listColumns.Add("Photo5", "Photo5", DbType.Object, "40*40");
listColumns.Add("Photo0", "Photo0", DbType.Object, "265*390");
listColumns.Add("SKU2", "SKU2", DbType.String, "");
MicrosoftWord word = new MicrosoftWord();
if (wordTemplatePath != null)
{
str2 = word.Export(wordTemplatePath, table, listColumns, ".pdf");
}
return str2;
}
[WebMethod(EnableSession = true)]
public string GetFedexLabelNewUPS(string OrderIds, int PostId)
{
PagesNew.Login(base.Session);
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
OrderPrintData data = new OrderPrintData();
List source = null;
var obj = new DD_OrderData();
if (source == null)
{
source = DataNew.GetOrderPrintListForFedex(OrderIds.TrimEnd(','), 0);
}
if (source == null || source.Count == 0)
{
return "";
}
string[] oids = OrderIds.TrimEnd(',').Split(',');
List source2 = new List();
for (int i = 0; i < oids.Length; i++)
{
var omdlist = source.FindAll(n => n.OrderId == Convert.ToInt32(oids[i]));
if (omdlist != null)
{
foreach (var omd in omdlist)
{
source2.Add(omd);
}
}
}
BaseService obj2 = new BaseService();
var expressmd = DataNew.GetExpressModel2(PostId, CompanyId);
JC_ExpressService service = new JC_ExpressService();
DataTable table = new DataTable();
table.Columns.Add("SKU");
table.Columns.Add("OrderCode");
table.Columns.Add("SKU3");
table.Columns.Add("Photo3");
table.Columns.Add("SKU2");
table.Columns.Add("Photo2");
table.Columns.Add("SKU4");
table.Columns.Add("Photo4");
table.Columns.Add("SKU5");
table.Columns.Add("Photo5");
table.Columns.Add("Photo0");
string str2 = "";
string wordTemplatePath = "";
foreach (var order2 in source2)
{
wordTemplatePath = expressmd.PrintTemplateName;
DataRow row = table.NewRow();
row["Photo0"] = AppDomain.CurrentDomain.BaseDirectory + "attached/ups/" + order2.TrackCode.ToString() + ".png";
row["OrderCode"] = order2.OrderCode;
// if (order2.GoodsList != null && order2.GoodsList.Count > 0)
row["SKU2"] = order2.SKU;
//if (order2.GoodsList != null && order2.GoodsList.Count > 0 && order2.GoodsList[0].GoodsUrl != null && order2.GoodsList[0].GoodsUrl != "")
//{
// row["Photo2"] = AppDomain.CurrentDomain.BaseDirectory + order2.GoodsList[0].GoodsUrl.Replace("../", "");
//}
//if ((order2.GoodsList != null && order2.GoodsList.Count > 0))
//{
// row["SKU2"] = order2.GoodsList[0].SKU1 + " " + order2.GoodsList[0].GoodsName + order2.GoodsList[0].GoodsCode + " " + order2.GoodsList[0].TypeDesc + "[Number]:" + order2.GoodsList[0].GoodsNum + " [Storage Location]:" + order2.GoodsList[0].PostionDesc;
//}
//if (order2.GoodsList != null && order2.GoodsList.Count > 1 && order2.GoodsList[1].GoodsUrl != null && order2.GoodsList[1].GoodsUrl != "")
//{
// row["Photo3"] = AppDomain.CurrentDomain.BaseDirectory + order2.GoodsList[1].GoodsUrl.Replace("../", "");
//}
//if (order2.GoodsList != null && order2.GoodsList.Count > 1)
//{
// row["SKU3"] = order2.GoodsList[1].SKU1 + " " + order2.GoodsList[1].GoodsName + order2.GoodsList[1].GoodsCode + " " + order2.GoodsList[1].TypeDesc + "[Number]:" + order2.GoodsList[1].GoodsNum + " [Storage Location]:" + order2.GoodsList[1].PostionDesc;
//}
//if (order2.GoodsList != null && order2.GoodsList.Count > 2 && order2.GoodsList[2].GoodsUrl != null && order2.GoodsList[2].GoodsUrl != "")
//{
// row["Photo4"] = AppDomain.CurrentDomain.BaseDirectory + order2.GoodsList[2].GoodsUrl.Replace("../", "");
//}
//if ((order2.GoodsList != null && order2.GoodsList.Count > 2))
//{
// row["SKU4"] = order2.GoodsList[2].SKU1 + " " + order2.GoodsList[2].GoodsName + order2.GoodsList[2].GoodsCode + " " + order2.GoodsList[2].TypeDesc + "[Number]:" + order2.GoodsList[2].GoodsNum + " [Storage Location]:" + order2.GoodsList[2].PostionDesc;
//}
//if (order2.GoodsList != null && order2.GoodsList.Count > 3 && order2.GoodsList[3].GoodsUrl != null && order2.GoodsList[3].GoodsUrl != "")
//{
// row["Photo4"] = AppDomain.CurrentDomain.BaseDirectory + order2.GoodsList[3].GoodsUrl.Replace("../", "");
//}
//if ((order2.GoodsList != null && order2.GoodsList.Count > 3))
//{
// row["SKU4"] = order2.GoodsList[3].SKU1 + " " + order2.GoodsList[3].GoodsName + order2.GoodsList[3].GoodsCode + " " + order2.GoodsList[3].TypeDesc + "[Number]:" + order2.GoodsList[3].GoodsNum + " [Storage Location]:" + order2.GoodsList[3].PostionDesc;
//}
//if (order2.GoodsList.Count > 4)
//{
// for (int i = 4; i < order2.GoodsList.Count; i++)
// {
// row["SKU"] += order2.GoodsList[i].SKU1 + "[Number]:" + order2.GoodsList[i].GoodsNum + " [Storage Location]:" + order2.GoodsList[i].PostionDesc + ";";
// }
//}
table.Rows.Add(row);
}
TableColumnCollection listColumns = new TableColumnCollection();
listColumns.Add("SKU", "SKU", DbType.String, "");
listColumns.Add("OrderCode", "OrderCode", DbType.String, "");
listColumns.Add("SKU2", "SKU2", DbType.String, "");
listColumns.Add("Photo2", "Photo2", DbType.Object, "40*40");
listColumns.Add("SKU3", "SKU3", DbType.String, "");
listColumns.Add("Photo3", "Photo3", DbType.Object, "40*40");
listColumns.Add("SKU4", "SKU4", DbType.String, "");
listColumns.Add("Photo4", "Photo4", DbType.Object, "40*40");
listColumns.Add("SKU5", "SKU5", DbType.String, "");
listColumns.Add("Photo5", "Photo5", DbType.Object, "40*40");
listColumns.Add("Photo0", "Photo0", DbType.Object, "265*390");
MicrosoftWord word = new MicrosoftWord();
if (wordTemplatePath != null)
{
str2 = word.Export(wordTemplatePath, table, listColumns, ".pdf");
}
return str2;
}
[WebMethod(EnableSession = true)]
public string GetFedexFee22(DT_OrderFedexModel omd, decimal weight, decimal width, decimal slong, decimal height, int Uint, int PostId, string PostType)
{
Pages.Login(base.Session);
// int companyId = Convert.ToInt32(base.Session["CompanyId"]);
JC_ExpressService service = new JC_ExpressService();
JC_PostAddress address = new BaseService().GetAddressModel2(PostId);
JC_ExpressPost expressModel = service.GetExpressModel(1, PostId);
FedexRate rate = new FedexRate();
FedexRate.Key = expressModel.UserCode;
FedexRate.Password = expressModel.CheckCode;
FedexRate.AccountNumber = expressModel.client_id;
FedexRate.MeterNumber = expressModel.client_secret;
FedexRate.PayAccountNumber = expressModel.refresh_token;
FedexRate.HubId = expressModel.Code;
FedexFeeMd md = new FedexFeeMd
{
RevName = omd.RevName,
RevPhone = omd.RevPhone
};
if ((omd.RevPhone == null) || (omd.RevPhone == ""))
{
md.RevPhone = omd.RevMoblie;
}
md.OrderId = 0;
md.PostType = PostType;
md.SendAddr = address.EnglishAddress;
md.SendCountry = address.countycode;
md.SendCity = address.city;
md.SendProv = address.provincecode;
md.SendPostCode = address.PostCode;
if ((omd.RevAddr != null) && (omd.RevAddr != ""))
{
md.RevAddr = omd.RevAddr;
}
else
{
md.RevAddr = "street No 18";
}
md.RevCity = omd.RevCity;
if ((omd.RevCity == null) || (omd.RevCity == ""))
{
md.RevCity = omd.RevProvince;
}
if ((omd.RevProvinceCode != null) && (omd.RevProvinceCode != ""))
{
md.RevProv = omd.RevProvinceCode;
}
else if (((omd.RevProvince != null) && (omd.RevProvince != "")) && (omd.RevProvince.Length > 2))
{
md.RevProv = omd.RevProvince.Substring(omd.RevProvince.Length - 2, 2);
}
else
{
md.RevProv = omd.RevProvince;
}
md.RevPostCode = omd.RevPostCode;
md.RevCountry = omd.CountryCode;
md.Width = Math.Ceiling(width).ToString();
md.Height = Math.Ceiling(height).ToString();
md.Lenght = Math.Ceiling(slong).ToString();
md.Weight = new decimal?(weight);
if (Uint == 2)
{
md.Weight = new decimal?(weight * Convert.ToDecimal((double)2.2046226));
}
else if (Uint == 3)
{
md.Weight = new decimal?(weight * Convert.ToDecimal((double)0.0625));
}
string outError = "";
string fee = rate.GetFee(md, out outError);
if (outError != "")
{
return outError;
}
return fee;
}
#region 查询订单打印
[WebMethod(EnableSession = true)]
public JsonModel> GetListOrderPrintHWC(int CompanyId, int StoreId, int PlatType, int ShopId, int DateType, DateTime? SDate, DateTime? EDate, int OutDays, int TjType, string Name, int PrintState, int State, int IsSku, int IsError, int IsDetail, int PostId, string KWCode, string GoodsInfo, int TrackState, int FHState, int PageIndex, int PageSize, String Sort)
{
PagesNew.Login(this.Session);
var obj = new DD_OrderData();
RefParameterCollection Param = new RefParameterCollection();
Param.Add("a.CompanyId", "=", CompanyId, DbType.Int32);
Param.Add("a.MateState", "=", 2, DbType.Int32);
if (StoreId > 0)
Param.Add("b.StoreId", "=", StoreId, DbType.Int32);
if (PlatType > 0)
Param.Add("a.PlatId", "=", PlatType, DbType.Int32);
if (ShopId > 0)
Param.Add("a.ShopId", "=", ShopId, DbType.Int32);
if (TrackState == 1)
{
Param.Add("b.TrackState", ">", 0, DbType.Int32);
if (PostId == 0)
Param.Add("b.Post", ">", 0, DbType.Int32);
}
else
if (TrackState == 0)
{
Param.Add("b.TrackState", "=", 0, DbType.Int32);
}
if (DateType == 1)
{
if (SDate != null)
Param.Add("a.OrderDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.OrderDate", "<=", EDate, DbType.DateTime);
}
else
if (DateType == 2)
{
if (SDate != null)
Param.Add("a.InDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.InDate", "<=", EDate, DbType.DateTime);
}
else
if (DateType == 3)
{
if (SDate != null)
Param.Add("a.PrintDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.PrintDate", "<=", EDate, DbType.DateTime);
}
else
if (DateType == 4)
{
if (SDate != null)
Param.Add("a.PostDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.PostDate", "<=", EDate, DbType.DateTime);
}
else
if (DateType == 5)
{
if (SDate != null)
Param.Add("a.OrderOutDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.OrderOutDate", "<=", EDate, DbType.DateTime);
}
if (OutDays > 0)
{
Param.Add("a.OrderOutDate", "<=", DateTime.Today.AddDays(OutDays), DbType.DateTime);
}
if (PrintState == -1 && FHState > -1)
{
Param.Add("a.poststate", "=", FHState, DbType.Int32);
if (IsError == 1)
{
Param.Add("isnull(b.ErrorInfo,'')", "<>", "", DbType.String);
}
}
else
{
if (IsError == 1)
{
Param.Add("(a.PostState", "=", 2, DbType.Int32);
Param.Add("isnull(b.ErrorInfo,'')", "<>", "", "or", ")", DbType.String);
}
else
Param.Add("a.PostState", "<", 2, DbType.Int32);
}
if (PrintState > -1)
Param.Add("a.PrintState", "=", PrintState, DbType.Int32);
if (PrintState > -1)
Param.Add("a.State", "=", 1, DbType.Int32);
else
{
Param.Add("a.State", ">", 0, DbType.Int32);
Param.Add("a.State", "<", 3, DbType.Int32);
//Param.Add("b.RevPhone", "is", null, "or",")",DbType.String);
}
if (PostId > 0)
Param.Add("b.Post", "=", PostId, DbType.Int32);
string TCode = "";
if (Name != "")
{
Name = Name.Trim();
if (TjType == 1)
{
Param.Add("(a.PlatOrderCode", "=", Name, DbType.String);
Param.Add("a.JoinOrderCode", "=", Name, "or", ")", DbType.String);
}
else if (TjType == 2)
{
Param.Add("b.RevName", "like", Name, DbType.String);
}
else if (TjType == 3)
{
Param.Add("b.RevPhone", "like", Name, DbType.String);
}
else if (TjType == 4)
{
Param.Add("(b.RevCountry", "=", Name, DbType.String);
Param.Add("b.CountryName", "=", Name, "or", DbType.String);
Param.Add("b.CountryCode", "=", Name, "or", ")", DbType.String);
}
else if (TjType == 5)
{
Param.Add("b.RevPostCode", "=", Name, DbType.String);
}
else if (TjType == 6)
{
Param.Add("(b.RevAddr", "like", Name, DbType.String);
Param.Add("b.RevProvince", "like", Name, "or", DbType.String);
Param.Add("b.RevCity", "like", Name, "or", DbType.String);
Param.Add("b.RevArea", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 9)
{
Param.Add("(b.ErrorInfo", "like", Name, DbType.String);
Param.Add("b.PostError", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 10)
{
TCode = Name;
}
}
JsonModel> resultModel = new JsonModel>();
int RowCount = 0;
string GoodsName = "";
string Code = "";
if (GoodsInfo != "")
{
GoodsName = GoodsInfo.Trim();
if (GoodsInfo.Trim().Contains(' '))
{
GoodsName = GoodsInfo.Trim().Split(' ')[0].Trim();
Code = GoodsInfo.Trim().Split(' ')[1].Trim();
}
}
resultModel.DataSource = obj.GetListDT_PrintOrderInfoForTM(CompanyId, TCode, GoodsName, 0, Code, KWCode, IsSku, Param, PageIndex, PageSize, Sort, out RowCount);
resultModel.RowCount = RowCount;
string Ids = "";
if (resultModel.DataSource != null)
{
foreach (var md in resultModel.DataSource)
{
Ids += md.OrderId.ToString() + ",";
}
}
if (Ids != "")
{
JC_ExpressService obj3 = new JC_ExpressService();
// var elist = obj3.GetExpressTypeList();
var plist = obj3.GetExpressList();
var errorlist = obj.GetErrorList(Ids.Trim(','));
if (errorlist != null || plist != null)
{
foreach (var md in resultModel.DataSource)
{
if (errorlist != null && errorlist.Count > 0)
{
var emd = errorlist.Find(n => n.OrderId == md.OrderId);
if (emd != null)
{
md.ErrorInfo = emd.ErrorInfo;
}
}
if (md.Post > 0 && plist != null && plist.Count > 0)
{
var emd = plist.Find(n => n.ExpressID == md.Post);
if (emd != null)
{
md.PostInfo = emd.Name;
}
}
}
}
}
if (IsDetail == 0)
{
if (Ids != "")
{
var listTrack = obj.GetTrackCodeApplyList2(Ids.Trim(','));
if (listTrack != null)
{
foreach (var md in resultModel.DataSource)
{
var list3 = new List();
if (md.JoinOrderCode != null && md.JoinOrderCode != "")
list3 = listTrack.FindAll(n => n.OrderCode == md.JoinOrderCode);
else
list3 = listTrack.FindAll(n => n.OrderId == md.OrderId);
if (list3 != null && list3.Count > 0)
{
string trackinfo = "";
int tcount = 0;
foreach (var md1 in list3)
{
if (md1.TrackType < 3)
{
trackinfo += md1.TrackCode + "
";
tcount++;
}
}
md.TrackCode = trackinfo;
}
}
}
}
}
else
if (IsDetail == 1)
{
if (Ids != "")
{
var listTrack = obj.GetTrackCodeApplyList2(Ids.Trim(','));
var list1 = DataNew.GetOrderGoodsPostionHWC(Ids.Trim(','));
if (list1 != null)
{
foreach (var md in resultModel.DataSource)
{
var list2 = list1.FindAll(n => n.OrderId == md.OrderId);
if (list2 != null)
{
md.GoodsList = list2;
}
var list3 = new List();
if (listTrack != null)
{
if (md.JoinOrderCode != null && md.JoinOrderCode != "")
list3 = listTrack.FindAll(n => n.OrderCode == md.JoinOrderCode);
else
list3 = listTrack.FindAll(n => n.OrderId == md.OrderId);
}
if (list3 != null && list3.Count > 0)
{
string trackinfo = "";
int tcount = 0;
foreach (var md1 in list3)
{
if (md1.TrackType < 3)
{
trackinfo += md1.TrackCode + "
";
tcount++;
}
}
md.TrackCode = trackinfo;
}
}
}
}
}
return resultModel;
}
#endregion
#region 查询订单打印导出
[WebMethod(EnableSession = true)]
public string GetListOrderPrintHWCExcel(int CompanyId, int StoreId, int PlatType, int ShopId, int DateType, DateTime? SDate, DateTime? EDate, int OutDays, int TjType, string Name, int PrintState, int State, int IsSku, int IsError, int IsDetail, int PostId, string KWCode, string GoodsInfo, int TrackState, int FHState, int PageIndex, int PageSize, String Sort)
{
PagesNew.Login(this.Session);
var obj = new DD_OrderData();
RefParameterCollection Param = new RefParameterCollection();
Param.Add("a.CompanyId", "=", CompanyId, DbType.Int32);
Param.Add("a.MateState", "=", 2, DbType.Int32);
if (StoreId > 0)
Param.Add("b.StoreId", "=", StoreId, DbType.Int32);
if (PlatType > 0)
Param.Add("a.PlatId", "=", PlatType, DbType.Int32);
if (ShopId > 0)
Param.Add("a.ShopId", "=", ShopId, DbType.Int32);
if (TrackState == 1)
{
Param.Add("b.TrackState", ">", 0, DbType.Int32);
if (PostId == 0)
Param.Add("b.Post", ">", 0, DbType.Int32);
}
else
if (TrackState == 0)
{
Param.Add("b.TrackState", "=", 0, DbType.Int32);
}
if (DateType == 1)
{
if (SDate != null)
Param.Add("a.OrderDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.OrderDate", "<=", EDate, DbType.DateTime);
}
else
if (DateType == 2)
{
if (SDate != null)
Param.Add("a.InDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.InDate", "<=", EDate, DbType.DateTime);
}
else
if (DateType == 3)
{
if (SDate != null)
Param.Add("a.PrintDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.PrintDate", "<=", EDate, DbType.DateTime);
}
else
if (DateType == 4)
{
if (SDate != null)
Param.Add("a.PostDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.PostDate", "<=", EDate, DbType.DateTime);
}
else
if (DateType == 5)
{
if (SDate != null)
Param.Add("a.OrderOutDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.OrderOutDate", "<=", EDate, DbType.DateTime);
}
if (OutDays > 0)
{
Param.Add("a.OrderOutDate", "<=", DateTime.Today.AddDays(OutDays), DbType.DateTime);
}
if (PrintState == -1 && FHState > -1)
{
Param.Add("a.poststate", "=", FHState, DbType.Int32);
if (IsError == 1)
{
Param.Add("isnull(b.ErrorInfo,'')", "<>", "", DbType.String);
}
}
else
{
if (IsError == 1)
{
Param.Add("(a.PostState", "=", 2, DbType.Int32);
Param.Add("isnull(b.ErrorInfo,'')", "<>", "", "or", ")", DbType.String);
}
else
Param.Add("a.PostState", "<", 2, DbType.Int32);
}
if (PrintState > -1)
Param.Add("a.PrintState", "=", PrintState, DbType.Int32);
if (PrintState > -1)
Param.Add("a.State", "=", 1, DbType.Int32);
else
{
Param.Add("a.State", ">", 0, DbType.Int32);
Param.Add("a.State", "<", 3, DbType.Int32);
//Param.Add("b.RevPhone", "is", null, "or",")",DbType.String);
}
if (PostId > 0)
Param.Add("b.Post", "=", PostId, DbType.Int32);
string TCode = "";
if (Name != "")
{
Name = Name.Trim();
if (TjType == 1)
{
Param.Add("(a.PlatOrderCode", "=", Name, DbType.String);
Param.Add("a.JoinOrderCode", "=", Name, "or", ")", DbType.String);
}
else if (TjType == 2)
{
Param.Add("b.RevName", "like", Name, DbType.String);
}
else if (TjType == 3)
{
Param.Add("b.RevPhone", "like", Name, DbType.String);
}
else if (TjType == 4)
{
Param.Add("(b.RevCountry", "=", Name, DbType.String);
Param.Add("b.CountryName", "=", Name, "or", DbType.String);
Param.Add("b.CountryCode", "=", Name, "or", ")", DbType.String);
}
else if (TjType == 5)
{
Param.Add("b.RevPostCode", "=", Name, DbType.String);
}
else if (TjType == 6)
{
Param.Add("(b.RevAddr", "like", Name, DbType.String);
Param.Add("b.RevProvince", "like", Name, "or", DbType.String);
Param.Add("b.RevCity", "like", Name, "or", DbType.String);
Param.Add("b.RevArea", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 9)
{
Param.Add("(b.ErrorInfo", "like", Name, DbType.String);
Param.Add("b.PostError", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 10)
{
TCode = Name;
}
}
JsonModel> resultModel = new JsonModel>();
int RowCount = 0;
string GoodsName = "";
string Code = "";
if (GoodsInfo != "")
{
GoodsName = GoodsInfo.Trim();
if (GoodsInfo.Trim().Contains(' '))
{
GoodsName = GoodsInfo.Trim().Split(' ')[0].Trim();
Code = GoodsInfo.Trim().Split(' ')[1].Trim();
}
}
resultModel.DataSource = obj.GetListDT_PrintOrderInfoForTM(CompanyId, TCode, GoodsName, 0, Code, KWCode, IsSku, Param, PageIndex, PageSize, Sort, out RowCount);
resultModel.RowCount = RowCount;
string Ids = "";
if (resultModel.DataSource != null)
{
foreach (var md in resultModel.DataSource)
{
Ids += md.OrderId.ToString() + ",";
}
}
if (Ids != "")
{
JC_ExpressService obj3 = new JC_ExpressService();
// var elist = obj3.GetExpressTypeList();
var plist = obj3.GetExpressList();
var errorlist = obj.GetErrorList(Ids.Trim(','));
if (errorlist != null || plist != null)
{
foreach (var md in resultModel.DataSource)
{
if (errorlist != null && errorlist.Count > 0)
{
var emd = errorlist.Find(n => n.OrderId == md.OrderId);
if (emd != null)
{
md.ErrorInfo = emd.ErrorInfo;
}
}
if (md.Post > 0 && plist != null && plist.Count > 0)
{
var emd = plist.Find(n => n.ExpressID == md.Post);
if (emd != null)
{
md.PostInfo = emd.Name;
}
}
}
}
}
if (IsDetail == 0)
{
if (Ids != "")
{
var listTrack = obj.GetTrackCodeApplyList2(Ids.Trim(','));
if (listTrack != null)
{
foreach (var md in resultModel.DataSource)
{
var list3 = new List();
if (md.JoinOrderCode != null && md.JoinOrderCode != "")
list3 = listTrack.FindAll(n => n.OrderCode == md.JoinOrderCode);
else
list3 = listTrack.FindAll(n => n.OrderId == md.OrderId);
if (list3 != null && list3.Count > 0)
{
string trackinfo = "";
int tcount = 0;
foreach (var md1 in list3)
{
if (md1.TrackType < 3)
{
trackinfo += md1.TrackCode + "
";
tcount++;
}
}
md.TrackCode = trackinfo;
}
}
}
}
}
else
if (IsDetail == 1)
{
if (Ids != "")
{
var listTrack = obj.GetTrackCodeApplyList2(Ids.Trim(','));
var list1 = DataNew.GetOrderGoodsPostionHWC2(Ids.Trim(','));
if (list1 != null)
{
foreach (var md in resultModel.DataSource)
{
var list2 = list1.FindAll(n => n.OrderId == md.OrderId);
if (list2 != null)
{
md.GoodsList = list2;
}
var list3 = new List();
if (listTrack != null)
{
if (md.JoinOrderCode != null && md.JoinOrderCode != "")
list3 = listTrack.FindAll(n => n.OrderCode == md.JoinOrderCode);
else
list3 = listTrack.FindAll(n => n.OrderId == md.OrderId);
}
if (list3 != null && list3.Count > 0)
{
string trackinfo = "";
int tcount = 0;
foreach (var md1 in list3)
{
if (md1.TrackType < 3)
{
trackinfo += md1.TrackCode + "
";
tcount++;
}
}
md.TrackCode = trackinfo;
}
}
}
}
}
DataTable tb = new DataTable();
tb.Columns.Add("ordercode", Type.GetType("System.String"));
//tb.Columns.Add("hbordercode", Type.GetType("System.String"));
tb.Columns.Add("goodscode", Type.GetType("System.String"));
tb.Columns.Add("goodscode2", Type.GetType("System.String"));
tb.Columns.Add("num", Type.GetType("System.String"));
tb.Columns.Add("kwcode", Type.GetType("System.String"));
tb.Columns.Add("sortno", Type.GetType("System.String"));
tb.Columns.Add("trackcode", Type.GetType("System.String"));
string ids2 = "";
if (resultModel.DataSource != null)
{
foreach (var md in resultModel.DataSource)
{
ids2 += md.OrderId + ",";
DataRow row = tb.NewRow();
if (md.JoinOrderCode != null && md.JoinOrderCode != "")
row["ordercode"] = md.PlatOrderCode + " [合" + md.JoinOrderCode + "]";
else
row["ordercode"] = md.PlatOrderCode;
// row["hbordercode"] = md.JoinOrderCode;
row["trackcode"] = md.TrackCode.TrimEnd(',');
//tb.Rows.Add(row);
if (md.GoodsList != null)
{
int i = 0;
foreach (var gmd in md.GoodsList)
{
i++;
if (i == 1)
{
if (gmd.OldTypeDesc != null && gmd.OldTypeDesc != "")
row["goodscode"] = gmd.OldTypeDesc;
else
row["goodscode"] = gmd.GoodsCode;
if (gmd.GoodsOldCode != null)
row["goodscode2"] = gmd.GoodsOldCode;
row["num"] = gmd.GoodsNum.ToString();
row["kwcode"] = gmd.PostionCode.ToString();
row["sortno"] = gmd.LockNum.ToString();
tb.Rows.Add(row);
}
else
{
DataRow row1 = tb.NewRow();
row1["ordercode"] = "";
if (gmd.OldTypeDesc != null && gmd.OldTypeDesc != "")
row1["goodscode"] = gmd.OldTypeDesc;
else
row1["goodscode"] = gmd.GoodsCode;
if (gmd.GoodsOldCode != null)
row1["goodscode2"] = gmd.GoodsOldCode;
row1["num"] = gmd.GoodsNum.ToString();
row1["kwcode"] = gmd.PostionCode.ToString();
row1["sortno"] = gmd.LockNum.ToString();
tb.Rows.Add(row1);
}
}
}
}
DataTable dtCopy = tb.Copy();
DataView dv = tb.DefaultView;
dv.Sort = "sortno,kwcode";
dtCopy = dv.ToTable();
if (ids2 != null)
{
DataRow row2 = dtCopy.NewRow();
row2["ordercode"] = "";
row2["goodscode"] = "";
row2["goodscode2"] = "";
row2["num"] = "";
row2["kwcode"] = "";
dtCopy.Rows.Add(row2);
row2 = dtCopy.NewRow();
row2["ordercode"] = "";
row2["goodscode"] = "";
row2["goodscode2"] = "";
row2["num"] = "";
row2["kwcode"] = "";
dtCopy.Rows.Add(row2);
row2 = dtCopy.NewRow();
row2["ordercode"] = "Total:";
row2["goodscode"] = "";
row2["goodscode2"] = "";
row2["num"] = "";
row2["kwcode"] = "";
dtCopy.Rows.Add(row2);
List list8 = DataNew.GetOrderGoodsPostionList22(ids2.Trim(','));
if (list8 != null)
{
foreach (DT_OrderGoods goods2 in list8)
{
row2 = dtCopy.NewRow();
row2["ordercode"] = "";
if (goods2.OldTypeDesc != null && goods2.OldTypeDesc != "")
row2["goodscode"] = goods2.OldTypeDesc;
else
row2["goodscode"] = goods2.GoodsCode;
row2["goodscode2"] = goods2.GoodsOldCode;
row2["num"] = goods2.GoodsNum;
row2["kwcode"] = goods2.PostionCode;
dtCopy.Rows.Add(row2);
}
}
}
string cn = "QTY" + DateTime.Today.ToString("MMdd");
TableColumnCollection listColumns = new TableColumnCollection();
listColumns.Add("ordercode", "OrderCode", DbType.String, "");
listColumns.Add("goodscode", "SKU", DbType.String, "");
listColumns.Add("goodscode2", "GoodsCode2", DbType.String, "");
listColumns.Add("num", cn, DbType.String, "");
listColumns.Add("kwcode", "LOCATION", DbType.String, "");
listColumns.Add("trackcode", "Trackcode", DbType.String, "");
MicrosoftExcel obj2 = new MicrosoftExcel();
return obj2.Export(dtCopy, listColumns);
}
return "";
}
#endregion
#region 导出订单
[WebMethod(EnableSession = true)]
public string GetListOrderPrintForExcel2(int PlatType, int IsWeight, int ShopId, int DateType, DateTime? SDate, DateTime? EDate, int OutDays, int TjType, string Name, int PrintState, int State, int IsSku, int IsError, int IsDetail, int HBOrder, int PostId, int IsAddr, int IsFP, string KWCode, string GoodsInfo, int TrackState, int FHState, int GM, int SNum, int ENum, int PageIndex, int PageSize, String Sort, string PostionCode, string PostionCode2,int StoreId)
{
PagesNew.Login(this.Session);
var obj = new DD_OrderData();
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
RefParameterCollection Param = new RefParameterCollection();
if (IsFP > -1)
Param.Add("isnull(a.BillPrint,0)", "=", IsFP, DbType.Int32);
Param.Add("a.CompanyId", "=", CompanyId, DbType.Int32);
Param.Add("a.MateState", "=", 2, DbType.Int32);
if(StoreId>0)
Param.Add("b.StoreId", "=", StoreId, DbType.Int32);
if (PlatType > 0)
Param.Add("a.PlatId", "=", PlatType, DbType.Int32);
if (ShopId > 0)
Param.Add("a.ShopId", "=", ShopId, DbType.Int32);
if (TrackState == 1)
{
Param.Add("b.TrackState", ">", 0, DbType.Int32);
if (PostId == 0)
Param.Add("b.Post", ">", 0, DbType.Int32);
}
else
if (TrackState == 0)
{
Param.Add("b.TrackState", "=", 0, DbType.Int32);
}
if (DateType == 1)
{
if (SDate != null)
Param.Add("a.OrderDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.OrderDate", "<=", EDate, DbType.DateTime);
}
else
if (DateType == 2)
{
if (SDate != null)
Param.Add("a.InDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.InDate", "<=", EDate, DbType.DateTime);
}
else
if (DateType == 3)
{
if (SDate != null)
Param.Add("a.PrintDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.PrintDate", "<=", EDate, DbType.DateTime);
}
else
if (DateType == 4)
{
if (SDate != null)
Param.Add("a.PostDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.PostDate", "<=", EDate, DbType.DateTime);
}
else
if (DateType == 5)
{
if (SDate != null)
Param.Add("a.OrderOutDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.OrderOutDate", "<=", EDate, DbType.DateTime);
}
if (OutDays > 0)
{
Param.Add("a.OrderOutDate", "<=", DateTime.Today.AddDays(OutDays), DbType.DateTime);
}
if (PrintState == -1 && FHState > -1)
{
Param.Add("a.poststate", "=", FHState, DbType.Int32);
if (IsError == 1)
{
Param.Add("isnull(b.ErrorInfo,'')", "<>", "", DbType.String);
}
}
else
{
if (IsError == 1)
{
Param.Add("(a.PostState", "=", 2, DbType.Int32);
Param.Add("isnull(b.ErrorInfo,'')", "<>", "", "or", ")", DbType.String);
}
else
Param.Add("a.PostState", "<", 2, DbType.Int32);
}
if (PrintState > -1)
Param.Add("a.PrintState", "=", PrintState, DbType.Int32);
if (PrintState > -1)
Param.Add("a.State", "=", 1, DbType.Int32);
else
{
Param.Add("a.State", ">", 0, DbType.Int32);
Param.Add("a.State", "<", 3, DbType.Int32);
//Param.Add("b.RevPhone", "is", null, "or",")",DbType.String);
}
if (PostId > 0)
Param.Add("b.Post", "=", PostId, DbType.Int32);
if (HBOrder == 1)
Param.Add("a.IsJoin", "=", 1, DbType.Int32);
//if (IsError == 1)
//{
// Param.Add("(b.SendAddr", ">", 0, DbType.Int32);
// Param.Add("b.IsLeaveWord", "=", 1, "or", ")", DbType.Int32);
//}
if (IsAddr > -1)
{
Param.Add("b.SendAddr", "=", IsAddr, DbType.Int32);
}
string TCode = "";
if (Name != "")
{
Name = Name.Trim();
if (TjType == 1)
{
Param.Add("(a.PlatOrderCode", "=", Name, DbType.String);
Param.Add("a.JoinOrderCode", "=", Name, "or", ")", DbType.String);
}
else if (TjType == 2)
{
Param.Add("b.RevName", "like", Name, DbType.String);
}
else if (TjType == 3)
{
Param.Add("b.RevPhone", "like", Name, DbType.String);
}
else if (TjType == 4)
{
Param.Add("(b.RevCountry", "=", Name, DbType.String);
Param.Add("b.CountryName", "=", Name, "or", DbType.String);
Param.Add("b.CountryCode", "=", Name, "or", ")", DbType.String);
}
else if (TjType == 5)
{
Param.Add("b.RevPostCode", "=", Name, DbType.String);
}
else if (TjType == 6)
{
Param.Add("(b.RevAddr", "like", Name, DbType.String);
Param.Add("b.RevProvince", "like", Name, "or", DbType.String);
Param.Add("b.RevCity", "like", Name, "or", DbType.String);
Param.Add("b.RevArea", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 9)
{
Param.Add("(b.ErrorInfo", "like", Name, DbType.String);
Param.Add("b.PostError", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 10)
{
// Param.Add("b.TrackCode", "like", Name, DbType.String);
TCode = Name;
}
}
//if (IsError == 2)
//{
// Param.Add("(a.SendAddr", ">", 0, DbType.Int32);
// Param.Add("a.IsLeaveWord", "=", 1, "or", ")", DbType.Int32);
//}
if (IsWeight == 2)
{
Param.Add("isnull(a.IsSpare,0)", "=", 1, DbType.Int32);
}
else
if (IsWeight == 1)
{
Param.Add("isnull(a.IsSpare,0)", "=", 0, DbType.Int32);
}
//if (IsSku == 0)
// Param.Add("a.FPDate", "is", null, DbType.String);
//else if (IsSku == 1)
// Param.Add("a.FPDate", "is not", null, DbType.String);
//Param.Add("a.OrderDate", ">=", 0, DbType.Int32);
JsonModel> resultModel = new JsonModel>();
int RowCount = 0;
//string Sort = "orderid desc";
//if (PrintState == 0)
// Sort = "orderid";
string GoodsName = "";
string Code = "";
if (GoodsInfo != "")
{
GoodsName = GoodsInfo.Trim();
if (GoodsInfo.Trim().Contains(' '))
{
GoodsName = GoodsInfo.Trim().Split(' ')[0].Trim();
Code = GoodsInfo.Trim().Split(' ')[1].Trim();
}
}
//else
// if (TjType == 8 && Name != "")
// {
// SKU = Name;
// }
List orderlist = new List();
List ordertemp = new List();
if (PrintState > -1)
orderlist = DataNew.GetListDT_PrintOrderInfoForTM2(CompanyId, TCode, GoodsName, 0, Code, KWCode, IsSku, GM, PrintState, Param, PageIndex, PageSize, Sort, out RowCount);
else
orderlist = obj.GetListDT_PrintOrderInfoForTM(CompanyId, TCode, GoodsName, 0, Code, KWCode, IsSku, Param, PageIndex, PageSize, Sort, out RowCount);
string Ids = "";
if (orderlist != null)
{
foreach (var md in orderlist)
{
Ids += md.OrderId.ToString() + ",";
ordertemp.Add(md);
}
}
orderlist = new List();
if (Ids != "")
{
JC_ExpressService obj3 = new JC_ExpressService();
// var elist = obj3.GetExpressTypeList();
var plist = obj3.GetExpressList();
// var errorlist = obj.GetErrorList(Ids.Trim(','));
if (plist != null)
{
foreach (var md in ordertemp)
{
// if (errorlist != null && errorlist.Count > 0)
// {
// var emd = errorlist.Find(n => n.OrderId == md.OrderId);
// if (emd != null)
// {
// md.ErrorInfo = emd.ErrorInfo;
// }
// }
if (md.Post > 0 && plist != null && plist.Count > 0)
{
var emd = plist.Find(n => n.ExpressID == md.Post);
if (emd != null)
{
md.PostInfo = emd.Name;
}
}
}
}
}
if (IsDetail == 0 && ordertemp != null)
{
if (Ids != "")
{
var listTrack = obj.GetTrackCodeApplyList2(Ids.Trim(','));
if (listTrack != null)
{
foreach (var md in ordertemp)
{
var list3 = new List();
if (md.JoinOrderCode != null && md.JoinOrderCode != "")
list3 = listTrack.FindAll(n => n.OrderCode == md.JoinOrderCode);
else
list3 = listTrack.FindAll(n => n.OrderId == md.OrderId);
if (list3 != null && list3.Count > 0)
{
string trackinfo = "";
int tcount = 0;
foreach (var md1 in list3)
{
if (md1.TrackType < 3)
{
trackinfo += md1.TrackCode + ",";
tcount++;
}
}
if (IsWeight == 1 && tcount > 1 && IsError == 2)
{
ordertemp.Remove(md);
}
if (IsError == 5 && IsWeight == 1 && tcount > 1)
{
orderlist.Add(md);
}
md.TrackCode = trackinfo;
}
}
}
}
}
else
if (IsDetail == 1 && ordertemp != null)
{
if (Ids != "")
{
var listTrack = obj.GetTrackCodeApplyList2(Ids.Trim(','));
var list1 = DataNew.GetOrderGoodsPostionList(Ids.Trim(','));
if (list1 != null)
{
foreach (var md in ordertemp)
{
var list2 = list1.FindAll(n => n.OrderId == md.OrderId);
md.OrderLevel = 0;
md.OrderName = "";
md.GoodsCode = "";
md.IsBlank = 0;
if (list2 != null)
{
md.GoodsList = list2;
if (PostionCode != "")
{
var pmd = list2.Find(n => n.PostionCode.Contains(PostionCode) == true);
if (pmd != null)
md.IsBlank = 1;
}
if (list2.Count > 0)
{
md.OrderLevel = list2[0].LockNum;
md.OrderName = list2[0].PostionCode;
md.GoodsCode = list2[0].GoodsCode;
}
if (SNum > 0 && ENum == 0)
{
if (list2.Sum(o => o.GoodsNum).GetValueOrDefault(0) >= SNum)
{
orderlist.Add(md);
}
}
if (SNum > 0 && ENum > 0)
{
if (list2.Sum(o => o.GoodsNum).GetValueOrDefault(0) >= SNum && list2.Sum(o => o.GoodsNum).GetValueOrDefault(0) <= ENum)
{
orderlist.Add(md);
}
}
if (SNum == 0 && ENum > 0)
{
if (list2.Sum(o => o.GoodsNum).GetValueOrDefault(0) <= ENum)
{
orderlist.Add(md);
}
}
}
var list3 = new List();
if (listTrack != null)
{
if (md.JoinOrderCode != null && md.JoinOrderCode != "")
list3 = listTrack.FindAll(n => n.OrderCode == md.JoinOrderCode);
else
list3 = listTrack.FindAll(n => n.OrderId == md.OrderId);
}
if (list3 != null && list3.Count > 0)
{
string trackinfo = "";
int tcount = 0;
foreach (var md1 in list3)
{
if (md1.TrackType < 3)
{
trackinfo += md1.TrackCode + ",";
tcount++;
}
}
if (IsWeight == 1 && tcount > 1 && IsError == 2)
{
ordertemp.Remove(md);
}
if (IsError == 5 && IsWeight == 1 && tcount > 1)
{
orderlist.Add(md);
}
md.TrackCode = trackinfo;
}
}
}
}
}
if (IsError == 5) ordertemp = orderlist;
if (orderlist != null)
{
if (orderlist.Count() > 0)
ordertemp = orderlist;
}
if (PostionCode2 != "")
{
ordertemp = ordertemp.FindAll(n => n.IsBlank == 0);
}
else
if (PostionCode != "")
{
ordertemp = ordertemp.FindAll(n => n.IsBlank == 1);
}
List orderList2 = ordertemp.OrderBy(s => s.OrderLevel).ThenBy(s => s.OrderName).ThenBy(s => s.GoodsCode).ToList();
resultModel.DataSource = orderList2.Take(PageSize).Skip(PageSize * (PageIndex - 1)).ToList();
DataTable tb = new DataTable();
tb.Columns.Add("ordercode", Type.GetType("System.String"));
//tb.Columns.Add("hbordercode", Type.GetType("System.String"));
tb.Columns.Add("goodscode", Type.GetType("System.String"));
tb.Columns.Add("goodscode2", Type.GetType("System.String"));
tb.Columns.Add("num", Type.GetType("System.String"));
tb.Columns.Add("kwcode", Type.GetType("System.String"));
tb.Columns.Add("sortno", Type.GetType("System.String"));
tb.Columns.Add("trackcode", Type.GetType("System.String"));
string ids2 = "";
if (resultModel.DataSource != null)
{
foreach (var md in resultModel.DataSource)
{
ids2 += md.OrderId + ",";
DataRow row = tb.NewRow();
if (md.JoinOrderCode != null && md.JoinOrderCode != "")
row["ordercode"] = md.PlatOrderCode + " [合" + md.JoinOrderCode + "]";
else
row["ordercode"] = md.PlatOrderCode;
// row["hbordercode"] = md.JoinOrderCode;
row["trackcode"] = md.TrackCode.TrimEnd(',');
//tb.Rows.Add(row);
if (md.GoodsList != null)
{
int i = 0;
foreach (var gmd in md.GoodsList)
{
i++;
if (i == 1)
{
if (gmd.OldTypeDesc != null && gmd.OldTypeDesc != "")
row["goodscode"] = gmd.OldTypeDesc;
else
row["goodscode"] = gmd.GoodsCode;
if (gmd.GoodsOldCode != null)
row["goodscode2"] = gmd.GoodsOldCode;
row["num"] = gmd.GoodsNum.ToString();
row["kwcode"] = gmd.PostionCode.ToString();
row["sortno"] = gmd.LockNum.ToString();
tb.Rows.Add(row);
}
else
{
DataRow row1 = tb.NewRow();
row1["ordercode"] = "";
if (gmd.OldTypeDesc != null && gmd.OldTypeDesc != "")
row1["goodscode"] = gmd.OldTypeDesc;
else
row1["goodscode"] = gmd.GoodsCode;
if (gmd.GoodsOldCode != null)
row1["goodscode2"] = gmd.GoodsOldCode;
row1["num"] = gmd.GoodsNum.ToString();
row1["kwcode"] = gmd.PostionCode.ToString();
row1["sortno"] = gmd.LockNum.ToString();
tb.Rows.Add(row1);
}
}
}
}
DataTable dtCopy = tb.Copy();
DataView dv = tb.DefaultView;
dv.Sort = "sortno,kwcode";
dtCopy = dv.ToTable();
if (ids2 != null)
{
DataRow row2 = dtCopy.NewRow();
row2["ordercode"] = "";
row2["goodscode"] = "";
row2["goodscode2"] = "";
row2["num"] = "";
row2["kwcode"] = "";
dtCopy.Rows.Add(row2);
row2 = dtCopy.NewRow();
row2["ordercode"] = "";
row2["goodscode"] = "";
row2["goodscode2"] = "";
row2["num"] = "";
row2["kwcode"] = "";
dtCopy.Rows.Add(row2);
row2 = dtCopy.NewRow();
row2["ordercode"] = "Total:";
row2["goodscode"] = "";
row2["goodscode2"] = "";
row2["num"] = "";
row2["kwcode"] = "";
dtCopy.Rows.Add(row2);
List list8 = DataNew.GetOrderGoodsPostionList22(ids2.Trim(','));
if (list8 != null)
{
foreach (DT_OrderGoods goods2 in list8)
{
row2 = dtCopy.NewRow();
row2["ordercode"] = "";
if (goods2.OldTypeDesc != null && goods2.OldTypeDesc != "")
row2["goodscode"] = goods2.OldTypeDesc;
else
row2["goodscode"] = goods2.GoodsCode;
row2["goodscode2"] = goods2.GoodsOldCode;
row2["num"] = goods2.GoodsNum;
row2["kwcode"] = goods2.PostionCode;
dtCopy.Rows.Add(row2);
}
}
}
string cn = "QTY" + DateTime.Today.ToString("MMdd");
TableColumnCollection listColumns = new TableColumnCollection();
listColumns.Add("ordercode", "OrderCode", DbType.String, "");
listColumns.Add("goodscode", "SKU", DbType.String, "");
listColumns.Add("goodscode2", "GoodsCode2", DbType.String, "");
listColumns.Add("num", cn, DbType.String, "");
listColumns.Add("kwcode", "LOCATION", DbType.String, "");
listColumns.Add("trackcode", "Trackcode", DbType.String, "");
MicrosoftExcel obj2 = new MicrosoftExcel();
return obj2.Export(dtCopy, listColumns);
}
return "";
}
#endregion
#region 修改允许发货
[WebMethod(EnableSession = true)]
public void UpdatePostState2(List list)
{
PagesNew.Login(this.Session);
if (list != null)
{
var obj = new DD_OrderData();
foreach (var md in list)
{
DataNew.UpdatePostState2(md.OrderId.Value);
}
}
}
#endregion
[WebMethod(EnableSession = true)]
public DT_OrderModel ScanOrderPost333(int OrderId, int Post, string CountryCode, int PostState, int Weight, int BagUserId, string TrackCode, string OrderCode, string JoinOrderCode, int OrderState, int TrackId, int IsBlank, int IsCSM)
{
Pages.Login(base.Session);
DD_OrderData data = new DD_OrderData();
int num = Convert.ToInt32(base.Session["CompanyId"]);
int userId = Convert.ToInt32(base.Session["UserId"]);
string str = Convert.ToString(base.Session["Name"]);
DT_OrderModel model = new DT_OrderModel();
DT_TrackCodeScan scan = new DT_TrackCodeScan
{
PostId = new int?(Post),
OrderId = new int?(OrderId),
InName = str,
InDate = new DateTime?(DateTime.Now),
IsSure = 0,
PostFee = 0,
OldPostFee = 0,
Weight = new int?(Weight),
BagUserId = new int?(BagUserId),
TrackCode = TrackCode
};
if ((JoinOrderCode != null) && (JoinOrderCode != ""))
{
scan.OrderCode = JoinOrderCode;
}
else
{
scan.OrderCode = OrderCode;
}
scan.TrackId = new int?(TrackId);
scan.Count = 1;
scan.JoinOrderCode = JoinOrderCode;
scan.IsCSM = new int?(IsCSM);
data.SaveTrackCodeScan2(scan);
model.PostState = 1;
Pages.SaveLog(userId, "订单发货", scan.OrderCode + "发货扫描", OrderId);
model.PostFee = 0;
return model;
}
[WebMethod(EnableSession = true)]
public List GetOrderGoodsListForTM(int OrderId)
{
PagesNew.Login(base.Session);
DD_OrderData data = new DD_OrderData();
List orderGoodsListNew = DataNew.GetOrderGoodsListNew(OrderId);
if (orderGoodsListNew != null)
{
JC_Money money;
List.Enumerator enumerator;
decimal? hWCFee;
decimal num4;
decimal? nullable3;
decimal num = Convert.ToDecimal((double)6.5);
List list2 = new BaseService().GetMoneyList2();
List orderGoodsPostionCode = DataNew.GetOrderGoodsPostionCode(OrderId);
decimal num2 = 0M;
decimal num3 = 0M;
decimal hwsfee = 0M;
decimal goodssolid = 0M;
if ((orderGoodsPostionCode != null) && (orderGoodsPostionCode.Count > 0))
{
using (enumerator = orderGoodsListNew.GetEnumerator())
{
Predicate match = null;
Predicate predicate2 = null;
DT_OrderMateGoods md;
while (enumerator.MoveNext())
{
md = enumerator.Current;
md.RMBMoney = 0;
if (match == null)
{
match = delegate(JC_Money n)
{
int? nullable;
int? nullable2;
return (n.MCode == "USD") && (((nullable = n.PlatId).GetValueOrDefault() == (nullable2 = md.PlatId).GetValueOrDefault()) && (nullable.HasValue == nullable2.HasValue));
};
}
money = list2.Find(match);
if (money != null)
{
num = money.MRate.Value;
}
if (predicate2 == null)
{
predicate2 = n => n.Id == md.Id;
}
DT_OrderMateGoods goods = orderGoodsPostionCode.Find(predicate2);
if (goods != null)
{
md.PostionCode = goods.PostionCode;
md.Price = 0;
if (goods.Price > 0 && md.GoodsPrice > 0)
{
md.RMBMoney = (goods.Price.Value * goods.GoodsPrice.Value * md.GoodsNum.Value * Convert.ToDecimal(0.01)) / num;
}
if (goods.Price.HasValue && md.GoodsNum.HasValue)
{
num4 = (goods.Price.Value * md.GoodsNum.Value) / num;
md.Price = new decimal?(Convert.ToDecimal(num4.ToString("0.00")));
}
md.PostPrice = 0;
if (goods.PostPrice.HasValue && md.GoodsNum.HasValue)
{
num4 = (goods.PostPrice.Value * md.GoodsNum.Value) / num;
md.PostPrice = new decimal?(Convert.ToDecimal(num4.ToString("0.00")));
}
hWCFee = goods.HWCFee;
num4 = md.GoodsNum.Value;
md.HWCFee = hWCFee.HasValue ? new decimal?(hWCFee.GetValueOrDefault() * num4) : ((decimal?)(nullable3 = null));
num2 += ((goods.Price.Value * md.GoodsNum.Value) + (goods.PostPrice.Value * md.GoodsNum.Value)) / num;
num3 += md.HWCFee.Value;
hwsfee += md.RMBMoney.Value;
}
}
}
if (orderGoodsListNew.Count > 0)
{
orderGoodsListNew[0].GoodsCB = new decimal?(Convert.ToDecimal(num2.ToString("0.00")));
orderGoodsListNew[0].GoodsCB2 = new decimal?(Convert.ToDecimal(num3.ToString("0.00")));
orderGoodsListNew[0].RMBMoney = new decimal?(Convert.ToDecimal(hwsfee.ToString("0.00")));
}
// return orderGoodsListNew;
}
num2 = 0M;
num3 = 0M;
hwsfee = 0M;
decimal Ratefee = 0M;
using (enumerator = orderGoodsListNew.GetEnumerator())
{
Predicate predicate3 = null;
DT_OrderMateGoods md;
while (enumerator.MoveNext())
{
md = enumerator.Current;
if (md.Solid != null)
goodssolid += md.Solid.Value * md.GoodsNum.Value;
if (predicate3 == null)
{
predicate3 = delegate(JC_Money n)
{
int? nullable;
int? nullable2;
return (n.MCode == "USD") && (((nullable = n.PlatId).GetValueOrDefault() == (nullable2 = md.PlatId).GetValueOrDefault()) && (nullable.HasValue == nullable2.HasValue));
};
}
money = list2.Find(predicate3);
if (money != null)
{
num = money.MRate.Value;
}
num4 = (md.InPrice.Value * md.GoodsNum.Value) / num;
md.Price = new decimal?(Convert.ToDecimal(num4.ToString("0.00")));
md.PostPrice = 0;
md.HWCFee = 0;
if (md.Solid != null)
{
hWCFee = md.Solid * 170M * md.GoodsNum.Value;
// num4 = md.GoodsNum.Value;
md.HWCFee = hWCFee;
}
if (md.GoodsPrice != null)
Ratefee += md.Price.Value * md.GoodsPrice.Value * 0.01M;//预估税费
num2 += md.Price.Value;
num3 += md.HWCFee.Value;
}
}
if (orderGoodsListNew.Count > 0)
{
orderGoodsListNew[0].OldTypeDesc = num2.ToString("0.00");//预估成本
orderGoodsListNew[0].OldTypeCode = Ratefee.ToString("0.00");//预估税费
orderGoodsListNew[0].MoneyCode = num3.ToString("0.00");//预估头程
if (orderGoodsListNew[0].GoodsCB == null || orderGoodsListNew[0].GoodsCB == 0)
orderGoodsListNew[0].GoodsCB = new decimal?(Convert.ToDecimal(num2.ToString("0.00")));
if (orderGoodsListNew[0].GoodsCB2 == null || orderGoodsListNew[0].GoodsCB2 == 0)
orderGoodsListNew[0].GoodsCB2 = new decimal?(Convert.ToDecimal(num3.ToString("0.00")));
// if (orderGoodsListNew[0].RMBMoney == null || orderGoodsListNew[0].RMBMoney == 0)
// orderGoodsListNew[0].RMBMoney = new decimal?(Convert.ToDecimal(Ratefee.ToString("0.00")));
// orderGoodsListNew[0].Length2 = goodssolid;//货物立方
}
}
return orderGoodsListNew;
}
[WebMethod(EnableSession = true)]
public List GetOrderGoodsListForTM4(int OrderId)
{
PagesNew.Login(base.Session);
DD_OrderData data = new DD_OrderData();
List orderGoodsListNew = DataNew.GetOrderGoodsListNew(OrderId);
if (orderGoodsListNew != null)
{
JC_Money money;
List.Enumerator enumerator;
decimal? hWCFee;
decimal num4;
decimal? nullable3;
decimal num = Convert.ToDecimal((double)6.5);
List list2 = new BaseService().GetMoneyList2();
List orderGoodsPostionCode = DataNew.GetOrderGoodsPostionCode(OrderId);
decimal num2 = 0M;
decimal num3 = 0M;
decimal hwsfee = 0M;
if ((orderGoodsPostionCode != null) && (orderGoodsPostionCode.Count > 0))
{
using (enumerator = orderGoodsListNew.GetEnumerator())
{
Predicate match = null;
Predicate predicate2 = null;
DT_OrderMateGoods md;
while (enumerator.MoveNext())
{
md = enumerator.Current;
md.RMBMoney = 0;
if (match == null)
{
match = delegate(JC_Money n)
{
int? nullable;
int? nullable2;
return (n.MCode == "USD") && (((nullable = n.PlatId).GetValueOrDefault() == (nullable2 = md.PlatId).GetValueOrDefault()) && (nullable.HasValue == nullable2.HasValue));
};
}
money = list2.Find(match);
if (money != null)
{
num = money.MRate.Value;
}
num = 1;//按人民币算
if (predicate2 == null)
{
predicate2 = n => n.Id == md.Id;
}
DT_OrderMateGoods goods = orderGoodsPostionCode.Find(predicate2);
if (goods != null)
{
md.PostionCode = goods.PostionCode;
md.Price = 0;
if (goods.Price > 0 && md.GoodsPrice > 0)
{
md.RMBMoney = (goods.Price.Value * goods.GoodsPrice.Value * md.GoodsNum.Value * Convert.ToDecimal(0.01)) / num;
}
if (goods.Price.HasValue && md.GoodsNum.HasValue)
{
num4 = (goods.Price.Value * md.GoodsNum.Value) / num;
md.Price = new decimal?(Convert.ToDecimal(num4.ToString("0.00")));
}
md.PostPrice = 0;
if (goods.PostPrice.HasValue && md.GoodsNum.HasValue)
{
num4 = (goods.PostPrice.Value * md.GoodsNum.Value) / num;
md.PostPrice = new decimal?(Convert.ToDecimal(num4.ToString("0.00")));
}
hWCFee = goods.HWCFee;
num4 = md.GoodsNum.Value;
md.HWCFee = hWCFee.HasValue ? new decimal?(hWCFee.GetValueOrDefault() * num4) : ((decimal?)(nullable3 = null));
num2 += ((goods.Price.Value * md.GoodsNum.Value) + (goods.PostPrice.Value * md.GoodsNum.Value)) / num;
num3 += md.HWCFee.Value;
hwsfee += md.RMBMoney.Value;
}
}
}
if (orderGoodsListNew.Count > 0)
{
orderGoodsListNew[0].GoodsCB = new decimal?(Convert.ToDecimal(num2.ToString("0.00")));
orderGoodsListNew[0].GoodsCB2 = new decimal?(Convert.ToDecimal(num3.ToString("0.00")));
orderGoodsListNew[0].RMBMoney = new decimal?(Convert.ToDecimal(hwsfee.ToString("0.00")));
}
// return orderGoodsListNew;
}
num2 = 0M;
num3 = 0M;
hwsfee = 0M;
decimal Ratefee = 0M;
using (enumerator = orderGoodsListNew.GetEnumerator())
{
Predicate predicate3 = null;
DT_OrderMateGoods md;
while (enumerator.MoveNext())
{
md = enumerator.Current;
if (predicate3 == null)
{
predicate3 = delegate(JC_Money n)
{
int? nullable;
int? nullable2;
return (n.MCode == "USD") && (((nullable = n.PlatId).GetValueOrDefault() == (nullable2 = md.PlatId).GetValueOrDefault()) && (nullable.HasValue == nullable2.HasValue));
};
}
money = list2.Find(predicate3);
if (money != null)
{
num = money.MRate.Value;
}
num = 1;//按人民币算
num4 = (md.InPrice.Value * md.GoodsNum.Value) / num;
md.Price = new decimal?(Convert.ToDecimal(num4.ToString("0.00")));
md.PostPrice = 0;
md.HWCFee = 0;
if (md.Solid != null)
{
hWCFee = md.Solid * 170M * md.GoodsNum.Value;//预估头程
// num4 = md.GoodsNum.Value;
md.HWCFee = hWCFee;
}
if (md.GoodsPrice != null)
Ratefee += md.Price.Value * md.GoodsPrice.Value * 0.01M;//预估税费
num2 += md.Price.Value;
num3 += md.HWCFee.Value;
}
}
if (orderGoodsListNew.Count > 0)
{
orderGoodsListNew[0].OldTypeDesc = num2.ToString("0.00");//预估成本
orderGoodsListNew[0].OldTypeCode = Ratefee.ToString("0.00");//预估税费
orderGoodsListNew[0].MoneyCode = num3.ToString("0.00");//预估头程
if (orderGoodsListNew[0].GoodsCB == null || orderGoodsListNew[0].GoodsCB == 0)
orderGoodsListNew[0].GoodsCB = new decimal?(Convert.ToDecimal(num2.ToString("0.00")));
if (orderGoodsListNew[0].GoodsCB2 == null || orderGoodsListNew[0].GoodsCB2 == 0)
orderGoodsListNew[0].GoodsCB2 = new decimal?(Convert.ToDecimal(num3.ToString("0.00")));
// if (orderGoodsListNew[0].RMBMoney == null || orderGoodsListNew[0].RMBMoney == 0)
// orderGoodsListNew[0].RMBMoney = new decimal?(Convert.ToDecimal(Ratefee.ToString("0.00")));
}
}
return orderGoodsListNew;
}
[WebMethod(EnableSession = true)]
public void GetGoodsFee()
{
PagesNew.Login(base.Session);
DataNew.GetGoodsFee();
DataNew.GetGoodsBack();
}
#region 扫描订单发货
[WebMethod(EnableSession = true)]
public DT_OrderModel ScanOrderPost2(int OrderId, int Post, string CountryCode, int PostState, int Weight, int BagUserId, string TrackCode, string OrderCode, string JoinOrderCode, int OrderState, int TrackId, int IsBlank, int IsCSM)
{
PagesNew.Login(this.Session);
var obj = new DD_OrderData();
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
int UserId = Convert.ToInt32(Session["UserId"]);
string Name = Convert.ToString(Session["Name"]);
DT_OrderModel md = new DT_OrderModel();
//if (Weight > 2000)
//{
// int isweight = JC_ExpressService.GetExpressWeight(Post);
// if (isweight >= 2000)
// {
// md.PostError = "超出重量限制";
// return md;
// }
//}
//int weightrate md.WeightRate.Value;
//if (Weight > GoodsWeight * (1 + Convert.ToDecimal(weightrate * 1.00) / 100))
//{
// md.PostError = "根据订单计算重量为" + GoodsWeight + "g,称重重量超过订单重量的" + weightrate.ToString() + "%;请确定货物是否正确再发货";
//}
//else
// if (Weight < GoodsWeight * (1 - Convert.ToDecimal(weightrate * 1.00) / 100))
// {
// md.PostError = "根据订单计算重量为" + GoodsWeight + "g,重量验证低于实际重量的" + weightrate.ToString() + "%;请确定货物是否正确再发货";
// }
//if (IsJe == 1 && GoodsPrice > 0 && postfee > GoodsPrice * Convert.ToDecimal(1.2))
//{
// md.PostError = "运费";
//}
//else
//{
DT_TrackCodeScan Model = new DT_TrackCodeScan();
Model.PostId = Post;
Model.OrderId = OrderId;
Model.InName = Name;
Model.InDate = DateTime.Now;
Model.IsSure = 0;
Model.PostFee = 0;
Model.OldPostFee = 0;
Model.Weight = Weight;
Model.BagUserId = BagUserId;
Model.TrackCode = TrackCode;
if (JoinOrderCode != null && JoinOrderCode != "")
Model.OrderCode = JoinOrderCode;
else
Model.OrderCode = OrderCode;
Model.TrackId = TrackId;
Model.Count = 1;
Model.JoinOrderCode = JoinOrderCode;
Model.IsCSM = IsCSM;
DataNew.SaveTrackCodeScan3(Model);
md.PostState = 1;
string log = Model.OrderCode;
if (IsBlank == 1)
log += "空包裹";
Pages.SaveLog(UserId, "订单发货", log + "发货扫描", OrderId);
//if (OrderState == 2) //空包裹
//{
// obj.UpdateBlankBagForTM(OrderId, Weight, postfee);
//}
//else
// obj.UpdateOrderGoodsForTM(OrderId, Weight, postfee, JoinOrderCode);
// }
md.PostFee = 0;
return md;
}
#endregion
#region 获取订单费用
[WebMethod(EnableSession = true)]
public DT_Fees GetModel_OrderFeeNew(int orderid)
{
PagesNew.Login(this.Session);
var md = DataNew.GetOrderFees(orderid.ToString());
if(md!=null && md.Count > 0)
{
if (md[0].PlatId == 2)
{
var adfee = DataNew.GetOrderAdFeeByOrderID(orderid);
if (md != null && md.Count > 0)
{
md[0].Ad_Fee = adfee;
return md[0];
}
}
else
return md[0];
}
return null;
}
#endregion
[WebMethod(EnableSession = true)]
public JsonModel> GetListOrderForTM22(int IsYJ, string MName,string groupName, int StoreId, int DeptId, int PlatType, int ShopId, int DateType, DateTime? SDate, DateTime? EDate, int TjType, string Name, int PrintState, int MateState, int MoneyState, int OutDays, int State, int IsSku, int IsError, int IsE, int IsDetail, int HBOrder, int IsSD, int SaleState, int IsBuy, int WLId, int PostId, int IsDH, int SFLY, int yfcy, int storeyc, int PageIndex, int PageSize, string Sort)
{
PagesNew.Login(base.Session);
DD_OrderData data = new DD_OrderData();
int num = Convert.ToInt32(base.Session["CompanyId"]);
RefParameterCollection where = new RefParameterCollection();
if (storeyc == 1)//仓库异常
{
var olist = DataNew.GetListStoreYC(DateTime.Today);
string sids = "0,";
if (olist != null)
{
foreach (var smd in olist)
{
sids += smd.OrderId.ToString() + ",";
}
}
where.Add("a.OrderId", "in", sids.TrimEnd(','), DbType.String);
}
if (IsYJ == 1)
{
where.Add("a.PlatId", "=", 2, DbType.Int32);
where.Add("isnull(a.Fee6,0)", "=", 0, DbType.Int32);
where.Add("isnull(a.Fee7,0)", "=", 0, DbType.Int32);
where.Add("isnull(a.Fee8,0)", "=", 0, DbType.Int32);
}
if (StoreId > 0)
{
where.Add("a.StoreId", "=", StoreId, DbType.Int32);
}
if (IsBuy == 1)
{
where.Add("a.BuyDate", "is not", null, DbType.String);
}
else if (IsBuy == 0)
{
where.Add("a.BuyDate", "is", null, DbType.String);
}
where.Add("a.CompanyId", "=", num, DbType.Int32);
// where.Add("isnull(a.IsSDan,0)", "=", IsSD, DbType.Int32);
if (yfcy == 1)
where.Add("a.WLSS", "=", 1, DbType.Int32);
if (SaleState > 0)
{
where.Add("a.SaleState", "=", SaleState, DbType.Int32);
}
if (WLId > 0)
{
where.Add("a.LogisticsId", "=", WLId, DbType.Int32);
}
if (PostId > 0)
{
where.Add("a.Post", "=", PostId, DbType.Int32);
}
if (DeptId > 0)
{
where.Add("c.DeptId", "=", DeptId, DbType.Int32);
}
if (PlatType > 0)
{
where.Add("a.PlatId", "=", PlatType, DbType.Int32);
}
if (ShopId > 0)
{
where.Add("a.ShopId", "=", ShopId, DbType.Int32);
}
if (DateType == 1)
{
if (SDate.HasValue)
{
where.Add("a.OrderDate", ">=", SDate, DbType.DateTime);
}
if (EDate.HasValue)
{
where.Add("a.OrderDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime);
}
}
else if (DateType == 2)
{
if (SDate.HasValue)
{
where.Add("a.InDate", ">=", SDate, DbType.DateTime);
}
if (EDate.HasValue)
{
where.Add("a.InDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime);
}
}
else if (DateType == 3)
{
if (SDate.HasValue)
{
where.Add("a.PrintDate", ">=", SDate, DbType.DateTime);
}
if (EDate.HasValue)
{
where.Add("a.PrintDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime);
}
}
else if (DateType == 4)
{
if (SDate.HasValue)
{
where.Add("a.PostDate", ">=", SDate, DbType.DateTime);
}
if (EDate.HasValue)
{
where.Add("a.PostDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime);
}
}
else if (DateType == 5)
{
if (SDate.HasValue)
{
where.Add("a.OrderOutDate", ">=", SDate, DbType.DateTime);
}
if (EDate.HasValue)
{
where.Add("a.OrderOutDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime);
}
}
if (OutDays > 0)
{
where.Add("a.OrderOutDate", "<=", DateTime.Now.AddDays((double)OutDays), DbType.DateTime);
where.Add("a.OrderOutDate", ">=", DateTime.Now, DbType.DateTime);
}
if (MateState > -1)
{
where.Add("a.MateState", "=", MateState, DbType.Int32);
}
if (MoneyState > -1)
{
where.Add("a.MoneyState", "=", MoneyState, DbType.Int32);
}
if (PrintState > -1)
{
where.Add("a.PrintState", "=", PrintState, DbType.Int32);
}
if (State == 3)
{
where.Add("a.State", "=", 2, DbType.Int32);
}
else if (State == 4)
{
where.Add("a.State", "=", 3, DbType.Int32);
}
else if (State == 5)
{
where.Add("a.State", "=", 1, DbType.Int32);
where.Add("a.MoneyState", "=", 1, DbType.Int32);
}
else if (State == 7)
{
where.Add("a.OrderState2", "=", 1, DbType.Int32);
}
else if (State == 1)
{
where.Add("a.PostState", "=", 1, DbType.Int32);
}
else if (State == 2)
{
where.Add("a.State", "<", 3, DbType.Int32);
where.Add("a.PostState", "=", 2, DbType.Int32);
}
else if (State == 0)
{
where.Add("a.State", "=", 1, DbType.Int32);
}
else if (State == 8)
{
where.Add("a.State", "<", 3, DbType.Int32);
where.Add("a.PostState", "=", 3, DbType.Int32);
}
else
{
where.Add("a.State", ">", 0, DbType.Int32);
}
if (HBOrder == 1)
{
where.Add("a.IsJoin", "=", 1, DbType.Int32);
}
if (IsError == 1)
{
where.Add("(a.SendAddr", ">", 0, DbType.Int32);
where.Add("a.IsLeaveWord", "=", 1, "or", ")", DbType.Int32);
}
if (IsE == 1)
{
where.Add("a.PostState", "=", 2, DbType.Int32);
}
if (IsE == 0)
{
where.Add("a.PostState", "<", 2, DbType.Int32);
}
string trackCode = "";
if (Name != "")
{
Name = Name.Trim();
if (TjType == 1)
{
where.Add("(a.PlatOrderCode", "like", Name, DbType.String);
where.Add("OrderCode", "like", Name, "or", DbType.String);
where.Add("a.JoinOrderCode", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 2)
{
where.Add("a.RevName", "like", Name, DbType.String);
}
else if (TjType == 3)
{
where.Add("a.RevPhone", "like", Name, DbType.String);
}
else if (TjType == 4)
{
where.Add("(a.RevCountry", "=", Name, DbType.String);
where.Add("a.CountryName", "=", Name, "or", DbType.String);
where.Add("a.CountryCode", "=", Name, "or", ")", DbType.String);
}
else if (TjType == 5)
{
where.Add("a.RevPostCode", "=", Name, DbType.String);
}
else if (TjType == 6)
{
where.Add("(a.RevAddr", "like", Name, DbType.String);
where.Add("a.RevProvince", "like", Name, "or", DbType.String);
where.Add("a.RevCity", "like", Name, "or", DbType.String);
where.Add("a.RevArea", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 9)
{
where.Add("(a.ErrorInfo", "like", Name, DbType.String);
where.Add("a.PostError", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 10)
{
trackCode = Name;
}
else if (TjType == 11)
{
where.Add("a.CustomID", "=", Name, DbType.String);
}
else if (TjType == 12)
{
where.Add("a.RevMail", "=", Name, DbType.String);
}
}
if (IsSku == 0)
{
where.Add("a.FPDate", "is", null, DbType.String);
}
else if (IsSku == 1)
{
where.Add("a.FPDate", "is not", null, DbType.String);
}
JsonModel> model = new JsonModel>();
int rowCount = 0;
string str2 = "";
string str3 = "";
if ((TjType == 7) && (Name != ""))
{
str2 = Name;
}
else if ((TjType == 8) && (Name != ""))
{
str3 = Name;
}
if (TjType == 13 && Name != "")//根据人员查询
{
model.DataSource = DataNew.GetListDT_OrderInfoForUser_New(num, SDate, str2.Trim(), Name, trackCode, -1, IsDH, where, PageIndex, PageSize, Sort, out rowCount);
}
else
{
//if (SFLY > 0)
//{
// if (SFLY == 1)
// {
// model.DataSource = data.GetListDT_OrderInfoForTM6(num, str2.Trim(), str3.Trim(), trackCode, -1, IsDH, where, PageIndex, PageSize, Sort, out rowCount);
// }
// if (SFLY == 2)
// {
// model.DataSource = data.GetListDT_OrderInfoForTM7(num, str2.Trim(), str3.Trim(), trackCode, -1, IsDH, where, PageIndex, PageSize, Sort, out rowCount);
// }
//}
//else
//{
model.DataSource = DataNew.GetListDT_OrderInfoForTM2_New(num, MName, str2.Trim(), str3.Trim(), trackCode, -1, IsDH, where, PageIndex, PageSize, Sort, out rowCount,groupName);
// }
}
model.RowCount = rowCount;
string ids = "";
List shopids = new List();
DateTime? maxDate=null, minDate=null;
JC_ExpressService wlobj = new JC_ExpressService();
var wlist = wlobj.GetExpressList();
List maplist = null;
if (model.DataSource != null)
{
foreach (DT_OrderListNew md in model.DataSource)
{
ids += md.OrderId.ToString() + ",";
if (md.Post != null && md.Post > 0)
{
var wlmd = wlist.Find(n => n.ExpressID == md.Post);
if (wlmd != null)
{
md.TrackInfo = wlmd.Name;
}
}
if (md.StoreId == 11)
md.RevFax = "E";
else
md.RevFax = "W";
if(md.ShopId.HasValue)
shopids.Add(md.ShopId.Value);
//if (maplist != null && md.RevProvince != null && md.RevProvince != "")
//{
// var mmd = maplist.Find(n => n.code == md.RevProvince.ToUpper() || n.ename == md.RevProvince);
// if (mmd != null)
// {
// if (mmd.IsEast == 1)
// {
// md.RevFax = "E";
// }
// else
// md.RevFax = "W";
// }
//}
}
maxDate = model.DataSource.OrderByDescending(r => r.OrderDate.Value).First().OrderDate.Value;
minDate = model.DataSource.OrderBy(r => r.OrderDate.Value).First().OrderDate.Value;
}
if (shopids != null && shopids.Count > 0)
shopids = shopids.Distinct().ToList();
var linklist = new List();
if (ids != "")
{
maplist = DataNew.GetListUSMap4(ids.Trim(','));
List errorList = data.GetErrorList(ids.Trim(','));
linklist = DataNew.GetListMBLinkOrder(ids.Trim(','));
if ((errorList != null) && (errorList.Count > 0))
{
foreach (var md in model.DataSource)
{
DT_OrderError error = errorList.Find(n => n.OrderId == md.OrderId);
if (error != null)
{
md.ErrorInfo = error.ErrorInfo;
}
}
}
}
List saleBackModelList = null;
List flist = null;
if ((IsDetail == 1) && (model.DataSource != null))
{
int? trackType;
if (ids != "")
{
List orderGoodsList = DataNew.GetOrderGoodsListNew2_New(ids.Trim(','));
List trackCodeApplyList = data.GetTrackCodeApplyList(ids.Trim(','));
//saleBackModelList = data.GetSaleBackModelList(ids.Trim(','));
flist = DataNew.GetOrderFees(ids.Trim(','));
//var pmlist = DataNew.GetOrderGoodsCodeData();
var pmlist = DataNew.GetGoodsRankModelList(string.Join(",", shopids), maxDate, minDate);
List JZLinklist = DataNew.GetListJZLinkOrder(ids.Trim(','));
List adSpendList = DataNew.GetAllGoodWeekAdSpend();
//List orderGoodsAdList = DataNew.GetOrderListGoodsAdFeeByOrderID(ids.Trim(','));
var last2DayadFees = DataNew.GetGoodsLast2DayAdFeeListByOrders(ids.TrimEnd(','));//商品前天的广告花费
if (orderGoodsList != null)
{
foreach (var md in model.DataSource)
{
bool kcW = true; bool kcE = true;//W仓,E仓库存是否足够发货,足够发货才能和UPS比较运费
List list5 = orderGoodsList.FindAll(n => n.OrderId == md.OrderId);
var totalAdfee = 0m;//订单广告总花费
var hyfcj = 0m;//海运费差价
if (list5 != null)
{
md.GoodsList = list5;
foreach (var mdg in md.GoodsList)
{
if (mdg.WestNum < mdg.GoodsNum)
kcW = false;
if (mdg.EastNum < mdg.GoodsNum)
kcE = false;
if (mdg.GoodsId.HasValue && md.ShopId.HasValue)
{
//mdg.goodWeekAdFee = DataNew.GetGoodWeekAdSpend(mdg.GoodsId.Value, md.ShopId.Value);
if (adSpendList != null)
{
var adspend = adSpendList.Where(r => r.shopid == md.ShopId.Value && r.goodsid == mdg.GoodsId.Value).FirstOrDefault();
mdg.goodWeekAdFee = adspend == null ? 0 : (adspend.spend.HasValue ? adspend.spend.Value : 0);
}
if (last2DayadFees != null)
{
var last2DayFee = last2DayadFees.Where(r => r.shopid == md.ShopId.Value && r.goodsid == mdg.GoodsId.Value).FirstOrDefault();
mdg.last2DayAdFee = last2DayFee == null ? 0 : (last2DayFee.spend.HasValue ? last2DayFee.spend.Value : 0);
}
//if (orderGoodsAdList != null)
//{
// var adFee = orderGoodsAdList.Where(r => r.OrderDate == md.OrderDate.Value.ToString("yyyy-MM-dd") && r.ShopId == md.ShopId && r.GoodsId == mdg.GoodsId.Value).FirstOrDefault();
// mdg.goodWeekAdFee = adFee == null ? 0 : (adFee.AvgAdfee.HasValue ? adFee.AvgAdfee.Value : 0);
//}
}
else
{
mdg.goodWeekAdFee = 0;
mdg.last2DayAdFee = 0;
}
totalAdfee = totalAdfee + (mdg.adfee.HasValue ? mdg.adfee.Value : 0);
hyfcj += (mdg.GoodsNum.HasValue && mdg.Solid2.HasValue) ? (mdg.GoodsNum.Value * mdg.Solid2.Value) : 0;
}
md.TotalAdFee = totalAdfee;
if (pmlist != null)
{
foreach (var mmd in list5)
{
var pmmd = pmlist.Find(n => n.asin == mmd.productImgUrl2 && n.ShopId == md.ShopId && n.OrderDate.Date == md.OrderDate.Value.Date);
if (pmmd != null)
{
string imgurl = "";
if (pmmd.Int10 != null && pmmd.Int10 == 1)
{
imgurl = "
";
}
if (pmmd.Int10 != null && pmmd.Int10 == 2)
{
imgurl = "
";
}
if (pmmd.Int10 != null && pmmd.Int10 == 3)
{
imgurl = "
";
}
if (pmmd.Int3 < 100)
mmd.OldTypeDesc = "排名:" + pmmd.Int3.ToString();
else
mmd.OldTypeDesc = "排名:" + pmmd.Int3.ToString();
if (pmmd.Int2 != null)
mmd.OldTypeDesc += "/" + pmmd.Int2.ToString();
mmd.OldTypeDesc += "" + imgurl;
}
else
mmd.OldTypeDesc = "";
}
}
}
//ups和fedex比较运费,再东西部都有库存的情况下,UPS需要和Fedex的W仓和E仓两个二比较,
//如果收货地址是Residential住宅区,则UPS和Fedex的Smart_Post、GROUND_HOME_DELIVERY比较;
//如果收货地址是Commercial或者Office,ups就和Fedex的Smart_Post、Fedex_Ground比较;Fedex的E仓比较时需要加上海运费差价
if (md.UpsFeeR.HasValue)
{
if(md.AddressType == "Commercial" || md.AddressType == "Office")
{
if (kcW)
{
md.UPSFee = (md.UpsFeeR < md.Fee6 && md.UpsFeeR < md.Fee7) ? md.UpsFeeR : 0;
}
if (kcE)
{
if(!kcW ||( md.UPSFee.HasValue && md.UPSFee.Value > 0)) //如果西部没有库存 或者 此时md.UPSFee有值并且大于0,说明UPS快递费小于Fedex的西部费用,接下来和Fedex的东部费用比较
{
md.UPSFee = (md.UpsFeeR < (md.Fee11 + hyfcj * 30) && md.UpsFeeR < (md.Fee12 + hyfcj * 30)) ? md.UpsFeeR : 0;
}
else
md.UPSFee = 0;
}
}
else
{
if (kcW)
{
md.UPSFee = (md.UpsFeeR < md.Fee6 && md.UpsFeeR < md.Fee8) ? md.UpsFeeR : 0;
}
if (kcE)
{
if (!kcW ||(md.UPSFee.HasValue && md.UPSFee.Value > 0)) //如果西部没有库存 或者 此时md.UPSFee有值并且大于0,说明UPS快递费小于Fedex的西部费用,接下来和Fedex的东部费用比较
{
md.UPSFee = (md.UpsFeeR < (md.Fee11 + hyfcj * 30) && md.UpsFeeR < (md.Fee13 + hyfcj * 30)) ? md.UpsFeeR : 0;
}
else
md.UPSFee = 0;
}
}
}
else
md.UPSFee = 0;
//if (md.UpsFeeR.HasValue && md.UpsFeeE.HasValue)
//{
// md.UPSFee = md.UpsFeeR > md.UpsFeeE ? md.UpsFeeE : md.UpsFeeR;
//}
//else if(!md.UpsFeeR.HasValue && !md.UpsFeeE.HasValue)
//{
// md.UPSFee = 0;
//}
//else
//{
// md.UPSFee = md.UpsFeeR.HasValue ? md.UpsFeeR.Value : md.UpsFeeE.Value;
//}
//if(md.UPSFee>md.Fee8 || md.UPSFee > (md.Fee13 + hyfcj*30))
//{
// md.UPSFee = 0;
//}
}
}
if (trackCodeApplyList != null)
{
foreach (var md in model.DataSource)
{
List list6 = new List();
if ((md.JoinOrderCode != null) && (md.JoinOrderCode != ""))
{
list6 = trackCodeApplyList.FindAll(n => n.OrderCode == md.JoinOrderCode);
}
else
{
list6 = trackCodeApplyList.FindAll(n => n.OrderId == md.OrderId);
}
if ((list6 != null) && (list6.Count > 0))
{
string str5 = "";
string str6 = "";
foreach (DT_TrackCodeApply apply in list6)
{
string str7 = "";
trackType = apply.TrackType;
if (trackType != null && trackType == 3)
{
str7 = "[空包裹]";
}
if (apply.Weight.HasValue)
{
string str8 = "";
if (apply.ScanDate.HasValue)
{
str8 = "扫描时间:" + apply.ScanDate.Value.ToString("yyyy-MM-dd HH:mm") + "
";
}
string str9 = str5;
str5 = str9 + apply.TrackCode + str7 + "
重量" + apply.Weight.ToString() + "g" + str8 + "
";
}
else
{
str5 = str5 + apply.TrackCode + str7 + "
";
}
if (str6 == "")
{
str6 = apply.TrackCode;
}
}
md.TrackInfo += str5;
md.TrackCode = str6;
}
}
}
decimal moneyrate = Convert.ToDecimal((double)6.5);
List list7 = new BaseService().GetMoneyList2();
//decimal ckfee = 0;
//decimal mdfee = 0;
//decimal adfee = 0;
//decimal DR_BackFee = 0;
//decimal DR_SSFee = 0;
//decimal DR_PostFee = 0;
foreach (var md in model.DataSource)
{
var fmd = flist.Find(n => n.orderid == md.OrderId);
if (fmd == null)
fmd = new DT_Fees();
md.OrderName = (fmd != null && fmd.SubsidyFee.HasValue && fmd.SubsidyFee.Value > 0) ? fmd.SubsidyFee.Value.ToString("0.00") : "";
#region 注释竞品信息改为显示补贴金额2024-05-17
//string jplink = "";
//if (linklist != null)
//{
// var lmdlist = linklist.FindAll(n => n.OrderId == md.OrderId && n.ShopId == md.ShopId);
// if (lmdlist != null)
// {
// foreach (var lmd in lmdlist)
// {
// int pm2 = 0;
// var pmmd = pmlist != null ? pmlist.Find(n => n.GoodsId == lmd.GoodsId && n.ShopId == md.ShopId) : null;
// if (pmmd != null && pmmd.Int3 != null)
// {
// pm2 = pmmd.Int3.Value;
// }
// if (lmdlist.Count > 1)
// jplink += "" + lmd.SKU1 + ":【S】" + lmd.GoodsHJNum2 + "";
// else
// jplink += "【S】" + lmd.GoodsHJNum2 + "";
// if (lmd.Num != null)
// {
// if (lmd.GoodsHJNum2 >= lmd.Num)
// jplink += "【TS】" + lmd.Num + "";
// else
// jplink += "【TS】" + lmd.Num + "";
// }
// jplink += "
";
// if (pm2 > 0)
// jplink += "【R】" + pm2 + "";
// else
// jplink += "【R】无";
// if (lmd.PM != null)
// {
// if (pm2 > 0 && lmd.PM >= pm2)
// jplink += "【TR】" + lmd.PM + "";
// else
// jplink += "【TR】" + lmd.PM + "";
// }
// jplink += "
";
// }
// }
// md.OrderName = jplink;
//}
//if (JZLinklist != null)
//{
// var jzmd = JZLinklist.FindAll(n => n.OrderId == md.OrderId && n.ShopId == md.ShopId);
// if (jzmd != null)
// {
// int i = 1;
// foreach (var jzmmd in jzmd)
// {
// if (jzmmd.Price != null)
// jplink += "竟品" + i.ToString() + "价格:" + jzmmd.Price.Value + "$
";
// else
// jplink += "竟品" + i.ToString() + "
";
// i++;
// }
// }
// md.OrderName = jplink;
//}
#endregion
if (fmd.moneyrate != null)
moneyrate = fmd.moneyrate.Value;
else
{
JC_Money money = list7.Find(n => n.MCode == "USD" && n.PlatId == md.PlatId);
if (money != null)
{
moneyrate = money.MRate.Value;
}
else
{
money = list7.Find(n => n.MCode == "USD");
moneyrate = money.MRate.Value;
}
}
decimal TotalPrice = 0M;
if (md.TotalPrice != null)
{
TotalPrice = md.TotalPrice.Value;
}
decimal YJPrice = 0M;
decimal sjyf = 0;
if (fmd.sjyf != null)
sjyf = fmd.sjyf.Value;
decimal ygyf = 0;
if (fmd.yf != null)
ygyf = fmd.yf.Value;
md.PostFee = sjyf;
md.BoxFee = ygyf;
if (fmd.yj != null)
YJPrice = fmd.yj.Value;
decimal GoodsFee = 0;
if (fmd.sjcb != null)
GoodsFee = fmd.sjcb.Value;
if (fmd.sjhwsf != null)
GoodsFee += fmd.sjhwsf.Value;
if (moneyrate == 0)
moneyrate = 6.5M;
GoodsFee = GoodsFee / moneyrate;
decimal YJGoodsFee = 0;
if (fmd.cb != null)
YJGoodsFee = fmd.cb.Value;
if (fmd.hwsf != null)
YJGoodsFee += fmd.hwsf.Value;
md.Fee8 = 0;
md.Fee8 = fmd.ck;
decimal sjtc = 0;
if (fmd.sjtc == null || fmd.sjtc == 0)
sjtc = fmd.tc.Value;
else
sjtc = fmd.sjtc.Value;
YJGoodsFee = YJGoodsFee / moneyrate;
//decimal LR = TotalPrice - YJPrice - fmd.escrowFee.Value - GoodsFee - sjyf - sjtc - fmd.DR_BackFee.Value - fmd.DR_PostFee.Value - fmd.Other_Fee.Value - fmd.Ad_Fee.Value + fmd.DR_SSFee.Value - fmd.md.Value - (md.TotalAdFee.HasValue ? md.TotalAdFee.Value : 0);
//decimal YGLR = TotalPrice - YJPrice - fmd.escrowFee.Value - YJGoodsFee - ygyf - fmd.tc.Value - fmd.DR_PostFee.Value - fmd.Other_Fee.Value - fmd.Ad_Fee.Value + fmd.DR_SSFee.Value - fmd.md.Value - (md.TotalAdFee.HasValue ? md.TotalAdFee.Value : 0);
if (md.PlatId != 2)
md.TotalAdFee = fmd.Ad_Fee;
decimal LR = TotalPrice - YJPrice - fmd.escrowFee.Value - GoodsFee - sjyf - sjtc - fmd.DR_BackFee.Value - fmd.DR_PostFee.Value - fmd.Other_Fee.Value + fmd.DR_SSFee.Value - fmd.md.Value + fmd.SubsidyFee.Value - (md.TotalAdFee.HasValue ? md.TotalAdFee.Value : 0);
decimal YGLR = TotalPrice - YJPrice - fmd.escrowFee.Value - YJGoodsFee - ygyf - fmd.tc.Value - fmd.DR_PostFee.Value - fmd.Other_Fee.Value + fmd.DR_SSFee.Value - fmd.md.Value + fmd.SubsidyFee.Value - (md.TotalAdFee.HasValue ? md.TotalAdFee.Value : 0);
md.LR = new decimal?(Convert.ToDecimal(LR.ToString("0.00")));
md.YGLR = new decimal?(Convert.ToDecimal(YGLR.ToString("0.00")));
}
}
}
return model;
}
[WebMethod(EnableSession = true)]
public JsonModel> GetListOrderForTM22_old(int IsYJ, string MName, int StoreId, int DeptId, int PlatType, int ShopId, int DateType, DateTime? SDate, DateTime? EDate, int TjType, string Name, int PrintState, int MateState, int MoneyState, int OutDays, int State, int IsSku, int IsError, int IsE, int IsDetail, int HBOrder, int IsSD, int SaleState, int IsBuy, int WLId, int IsDH, int SFLY, int yfcy, int storeyc, int PageIndex, int PageSize, string Sort)
{
PagesNew.Login(base.Session);
DD_OrderData data = new DD_OrderData();
int num = Convert.ToInt32(base.Session["CompanyId"]);
RefParameterCollection where = new RefParameterCollection();
if (storeyc == 1)//仓库异常
{
var olist = DataNew.GetListStoreYC(DateTime.Today);
string sids = "0,";
if (olist != null)
{
foreach (var smd in olist)
{
sids += smd.OrderId.ToString() + ",";
}
}
where.Add("a.OrderId", "in", sids.TrimEnd(','), DbType.String);
}
if (IsYJ == 1)
{
where.Add("a.PlatId", "=", 2, DbType.Int32);
where.Add("isnull(a.Fee6,0)", "=", 0, DbType.Int32);
where.Add("isnull(a.Fee7,0)", "=", 0, DbType.Int32);
where.Add("isnull(a.Fee8,0)", "=", 0, DbType.Int32);
}
if (StoreId > 0)
{
where.Add("a.StoreId", "=", StoreId, DbType.Int32);
}
if (IsBuy == 1)
{
where.Add("a.BuyDate", "is not", null, DbType.String);
}
else if (IsBuy == 0)
{
where.Add("a.BuyDate", "is", null, DbType.String);
}
where.Add("a.CompanyId", "=", num, DbType.Int32);
// where.Add("isnull(a.IsSDan,0)", "=", IsSD, DbType.Int32);
if (yfcy == 1)
where.Add("a.WLSS", "=", 1, DbType.Int32);
if (SaleState > 0)
{
where.Add("a.SaleState", "=", SaleState, DbType.Int32);
}
if (WLId > 0)
{
where.Add("a.LogisticsId", "=", WLId, DbType.Int32);
}
if (DeptId > 0)
{
where.Add("c.DeptId", "=", DeptId, DbType.Int32);
}
if (PlatType > 0)
{
where.Add("a.PlatId", "=", PlatType, DbType.Int32);
}
if (ShopId > 0)
{
where.Add("a.ShopId", "=", ShopId, DbType.Int32);
}
if (DateType == 1)
{
if (SDate.HasValue)
{
where.Add("a.OrderDate", ">=", SDate, DbType.DateTime);
}
if (EDate.HasValue)
{
where.Add("a.OrderDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime);
}
}
else if (DateType == 2)
{
if (SDate.HasValue)
{
where.Add("a.InDate", ">=", SDate, DbType.DateTime);
}
if (EDate.HasValue)
{
where.Add("a.InDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime);
}
}
else if (DateType == 3)
{
if (SDate.HasValue)
{
where.Add("a.PrintDate", ">=", SDate, DbType.DateTime);
}
if (EDate.HasValue)
{
where.Add("a.PrintDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime);
}
}
else if (DateType == 4)
{
if (SDate.HasValue)
{
where.Add("a.PostDate", ">=", SDate, DbType.DateTime);
}
if (EDate.HasValue)
{
where.Add("a.PostDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime);
}
}
else if (DateType == 5)
{
if (SDate.HasValue)
{
where.Add("a.OrderOutDate", ">=", SDate, DbType.DateTime);
}
if (EDate.HasValue)
{
where.Add("a.OrderOutDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime);
}
}
if (OutDays > 0)
{
where.Add("a.OrderOutDate", "<=", DateTime.Now.AddDays((double)OutDays), DbType.DateTime);
where.Add("a.OrderOutDate", ">=", DateTime.Now, DbType.DateTime);
}
if (MateState > -1)
{
where.Add("a.MateState", "=", MateState, DbType.Int32);
}
if (MoneyState > -1)
{
where.Add("a.MoneyState", "=", MoneyState, DbType.Int32);
}
if (PrintState > -1)
{
where.Add("a.PrintState", "=", PrintState, DbType.Int32);
}
if (State == 3)
{
where.Add("a.State", "=", 2, DbType.Int32);
}
else if (State == 4)
{
where.Add("a.State", "=", 3, DbType.Int32);
}
else if (State == 5)
{
where.Add("a.State", "=", 1, DbType.Int32);
where.Add("a.MoneyState", "=", 1, DbType.Int32);
}
else if (State == 7)
{
where.Add("a.OrderState2", "=", 1, DbType.Int32);
}
else if (State == 1)
{
where.Add("a.PostState", "=", 1, DbType.Int32);
}
else if (State == 2)
{
where.Add("a.State", "<", 3, DbType.Int32);
where.Add("a.PostState", "=", 2, DbType.Int32);
}
else if (State == 0)
{
where.Add("a.State", "=", 1, DbType.Int32);
}
else
{
where.Add("a.State", ">", 0, DbType.Int32);
}
if (HBOrder == 1)
{
where.Add("a.IsJoin", "=", 1, DbType.Int32);
}
if (IsError == 1)
{
where.Add("(a.SendAddr", ">", 0, DbType.Int32);
where.Add("a.IsLeaveWord", "=", 1, "or", ")", DbType.Int32);
}
if (IsE == 1)
{
where.Add("a.PostState", "=", 2, DbType.Int32);
}
if (IsE == 0)
{
where.Add("a.PostState", "<", 2, DbType.Int32);
}
string trackCode = "";
if (Name != "")
{
Name = Name.Trim();
if (TjType == 1)
{
where.Add("(a.PlatOrderCode", "like", Name, DbType.String);
where.Add("OrderCode", "like", Name, "or", DbType.String);
where.Add("a.JoinOrderCode", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 2)
{
where.Add("a.RevName", "like", Name, DbType.String);
}
else if (TjType == 3)
{
where.Add("a.RevPhone", "like", Name, DbType.String);
}
else if (TjType == 4)
{
where.Add("(a.RevCountry", "=", Name, DbType.String);
where.Add("a.CountryName", "=", Name, "or", DbType.String);
where.Add("a.CountryCode", "=", Name, "or", ")", DbType.String);
}
else if (TjType == 5)
{
where.Add("a.RevPostCode", "=", Name, DbType.String);
}
else if (TjType == 6)
{
where.Add("(a.RevAddr", "like", Name, DbType.String);
where.Add("a.RevProvince", "like", Name, "or", DbType.String);
where.Add("a.RevCity", "like", Name, "or", DbType.String);
where.Add("a.RevArea", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 9)
{
where.Add("(a.ErrorInfo", "like", Name, DbType.String);
where.Add("a.PostError", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 10)
{
trackCode = Name;
}
else if (TjType == 11)
{
where.Add("a.CustomID", "=", Name, DbType.String);
}
else if (TjType == 12)
{
where.Add("a.RevMail", "=", Name, DbType.String);
}
}
if (IsSku == 0)
{
where.Add("a.FPDate", "is", null, DbType.String);
}
else if (IsSku == 1)
{
where.Add("a.FPDate", "is not", null, DbType.String);
}
JsonModel> model = new JsonModel>();
int rowCount = 0;
string str2 = "";
string str3 = "";
if ((TjType == 7) && (Name != ""))
{
str2 = Name;
}
else if ((TjType == 8) && (Name != ""))
{
str3 = Name;
}
if (TjType == 13 && Name != "")//根据人员查询
{
model.DataSource = DataNew.GetListDT_OrderInfoForUser(num, SDate, str2.Trim(), Name, trackCode, -1, IsDH, where, PageIndex, PageSize, Sort, out rowCount);
}
else
{
//if (SFLY > 0)
//{
// if (SFLY == 1)
// {
// model.DataSource = data.GetListDT_OrderInfoForTM6(num, str2.Trim(), str3.Trim(), trackCode, -1, IsDH, where, PageIndex, PageSize, Sort, out rowCount);
// }
// if (SFLY == 2)
// {
// model.DataSource = data.GetListDT_OrderInfoForTM7(num, str2.Trim(), str3.Trim(), trackCode, -1, IsDH, where, PageIndex, PageSize, Sort, out rowCount);
// }
//}
//else
//{
model.DataSource = DataNew.GetListDT_OrderInfoForTM2(num, MName, str2.Trim(), str3.Trim(), trackCode, -1, IsDH, where, PageIndex, PageSize, Sort, out rowCount);
// }
}
model.RowCount = rowCount;
string ids = "";
JC_ExpressService wlobj = new JC_ExpressService();
var wlist = wlobj.GetExpressList();
List maplist = null;
if (model.DataSource != null)
{
foreach (DT_Order md in model.DataSource)
{
ids += md.OrderId.ToString() + ",";
if (md.Post != null && md.Post > 0)
{
var wlmd = wlist.Find(n => n.ExpressID == md.Post);
if (wlmd != null)
{
md.TrackInfo = wlmd.Name;
}
}
if (md.StoreId == 11)
md.RevFax = "E";
else
md.RevFax = "W";
//if (maplist != null && md.RevProvince != null && md.RevProvince != "")
//{
// var mmd = maplist.Find(n => n.code == md.RevProvince.ToUpper() || n.ename == md.RevProvince);
// if (mmd != null)
// {
// if (mmd.IsEast == 1)
// {
// md.RevFax = "E";
// }
// else
// md.RevFax = "W";
// }
//}
}
}
var linklist = new List();
if (ids != "")
{
maplist = DataNew.GetListUSMap4(ids.Trim(','));
List errorList = data.GetErrorList(ids.Trim(','));
linklist = DataNew.GetListMBLinkOrder(ids.Trim(','));
if ((errorList != null) && (errorList.Count > 0))
{
foreach (var md in model.DataSource)
{
DT_OrderError error = errorList.Find(n => n.OrderId == md.OrderId);
if (error != null)
{
md.ErrorInfo = error.ErrorInfo;
}
}
}
}
List saleBackModelList = null;
List flist = null;
if ((IsDetail == 1) && (model.DataSource != null))
{
int? trackType;
if (ids != "")
{
List orderGoodsList = DataNew.GetOrderGoodsListNew2(ids.Trim(','));
List trackCodeApplyList = data.GetTrackCodeApplyList(ids.Trim(','));
//saleBackModelList = data.GetSaleBackModelList(ids.Trim(','));
flist = DataNew.GetOrderFees(ids.Trim(','));
var pmlist = DataNew.GetOrderGoodsCodeData();
List JZLinklist = DataNew.GetListJZLinkOrder(ids.Trim(','));
if (orderGoodsList != null)
{
foreach (var md in model.DataSource)
{
List list5 = orderGoodsList.FindAll(n => n.OrderId == md.OrderId);
if (list5 != null)
{
md.GoodsList = list5;
if (pmlist != null)
{
foreach (var mmd in list5)
{
var pmmd = pmlist.Find(n => n.asin == mmd.productImgUrl2 && n.ShopId == md.ShopId);
if (pmmd != null)
{
string imgurl = "";
if (pmmd.Int10 != null && pmmd.Int10 == 1)
{
imgurl = "
";
}
if (pmmd.Int10 != null && pmmd.Int10 == 2)
{
imgurl = "
";
}
if (pmmd.Int10 != null && pmmd.Int10 == 3)
{
imgurl = "
";
}
if (pmmd.Int3 < 100)
mmd.OldTypeDesc = "排名:" + pmmd.Int3.ToString();
else
mmd.OldTypeDesc = "排名:" + pmmd.Int3.ToString();
if (pmmd.Int2 != null)
mmd.OldTypeDesc += "/" + pmmd.Int2.ToString();
mmd.OldTypeDesc += "" + imgurl;
}
else
mmd.OldTypeDesc = "";
}
}
}
}
}
if (trackCodeApplyList != null)
{
foreach (var md in model.DataSource)
{
List list6 = new List();
if ((md.JoinOrderCode != null) && (md.JoinOrderCode != ""))
{
list6 = trackCodeApplyList.FindAll(n => n.OrderCode == md.JoinOrderCode);
}
else
{
list6 = trackCodeApplyList.FindAll(n => n.OrderId == md.OrderId);
}
if ((list6 != null) && (list6.Count > 0))
{
string str5 = "";
string str6 = "";
foreach (DT_TrackCodeApply apply in list6)
{
string str7 = "";
trackType = apply.TrackType;
if (trackType != null && trackType == 3)
{
str7 = "[空包裹]";
}
if (apply.Weight.HasValue)
{
string str8 = "";
if (apply.ScanDate.HasValue)
{
str8 = "扫描时间:" + apply.ScanDate.Value.ToString("yyyy-MM-dd HH:mm") + "
";
}
string str9 = str5;
str5 = str9 + apply.TrackCode + str7 + "
重量" + apply.Weight.ToString() + "g" + str8 + "
";
}
else
{
str5 = str5 + apply.TrackCode + str7 + "
";
}
if (str6 == "")
{
str6 = apply.TrackCode;
}
}
md.TrackInfo += str5;
md.TrackCode = str6;
}
}
}
decimal moneyrate = Convert.ToDecimal((double)6.5);
List list7 = new BaseService().GetMoneyList2();
//decimal ckfee = 0;
//decimal mdfee = 0;
//decimal adfee = 0;
//decimal DR_BackFee = 0;
//decimal DR_SSFee = 0;
//decimal DR_PostFee = 0;
foreach (var md in model.DataSource)
{
var fmd = flist.Find(n => n.orderid == md.OrderId);
if (fmd == null)
fmd = new DT_Fees();
md.OrderName = "";
string jplink = "";
if (linklist != null)
{
var lmdlist = linklist.FindAll(n => n.OrderId == md.OrderId && n.ShopId == md.ShopId);
if (lmdlist != null)
{
foreach (var lmd in lmdlist)
{
int pm2 = 0;
var pmmd = pmlist.Find(n => n.GoodsId == lmd.GoodsId && n.ShopId == md.ShopId);
if (pmmd != null && pmmd.Int3 != null)
{
pm2 = pmmd.Int3.Value;
}
if (lmdlist.Count > 1)
jplink += "" + lmd.SKU1 + ":【S】" + lmd.GoodsHJNum2 + "";
else
jplink += "【S】" + lmd.GoodsHJNum2 + "";
if (lmd.Num != null)
{
if (lmd.GoodsHJNum2 >= lmd.Num)
jplink += "【TS】" + lmd.Num + "";
else
jplink += "【TS】" + lmd.Num + "";
}
jplink += "
";
if (pm2 > 0)
jplink += "【R】" + pm2 + "";
else
jplink += "【R】无";
if (lmd.PM != null)
{
if (pm2 > 0 && lmd.PM >= pm2)
jplink += "【TR】" + lmd.PM + "";
else
jplink += "【TR】" + lmd.PM + "";
}
jplink += "
";
}
}
md.OrderName = jplink;
}
if (JZLinklist != null)
{
var jzmd = JZLinklist.FindAll(n => n.OrderId == md.OrderId && n.ShopId == md.ShopId);
if (jzmd != null)
{
int i = 1;
foreach (var jzmmd in jzmd)
{
if (jzmmd.Price != null)
jplink += "竟品" + i.ToString() + "价格:" + jzmmd.Price.Value + "$
";
else
jplink += "竟品" + i.ToString() + "
";
i++;
}
}
md.OrderName = jplink;
}
if (fmd.moneyrate != null)
moneyrate = fmd.moneyrate.Value;
else
{
JC_Money money = list7.Find(n => n.MCode == "USD" && n.PlatId == md.PlatId);
if (money != null)
{
moneyrate = money.MRate.Value;
}
else
{
money = list7.Find(n => n.MCode == "USD");
moneyrate = money.MRate.Value;
}
}
decimal TotalPrice = 0M;
if (md.TotalPrice != null)
{
TotalPrice = md.TotalPrice.Value;
}
decimal YJPrice = 0M;
decimal sjyf = 0;
if (fmd.sjyf != null)
sjyf = fmd.sjyf.Value;
decimal ygyf = 0;
if (fmd.yf != null)
ygyf = fmd.yf.Value;
md.PostFee = sjyf;
md.BoxFee = ygyf;
if (fmd.yj != null)
YJPrice = fmd.yj.Value;
decimal GoodsFee = 0;
if (fmd.sjcb != null)
GoodsFee = fmd.sjcb.Value;
if (fmd.sjhwsf != null)
GoodsFee += fmd.sjhwsf.Value;
if (moneyrate == 0)
moneyrate = 6.5M;
GoodsFee = GoodsFee / moneyrate;
decimal YJGoodsFee = 0;
if (fmd.cb != null)
YJGoodsFee = fmd.cb.Value;
if (fmd.hwsf != null)
YJGoodsFee += fmd.hwsf.Value;
md.Fee8 = 0;
md.Fee8 = fmd.ck;
decimal sjtc = 0;
if (fmd.sjtc == null || fmd.sjtc == 0)
sjtc = fmd.tc.Value;
else
sjtc = fmd.sjtc.Value;
YJGoodsFee = YJGoodsFee / moneyrate;
decimal LR = TotalPrice - YJPrice - fmd.escrowFee.Value - GoodsFee - sjyf - sjtc - fmd.DR_BackFee.Value - fmd.DR_PostFee.Value - fmd.Other_Fee.Value - fmd.Ad_Fee.Value + fmd.DR_SSFee.Value - fmd.md.Value;
decimal YGLR = TotalPrice - YJPrice - fmd.escrowFee.Value - YJGoodsFee - ygyf - fmd.tc.Value - fmd.DR_PostFee.Value - fmd.Other_Fee.Value - fmd.Ad_Fee.Value + fmd.DR_SSFee.Value - fmd.md.Value;
md.LR = new decimal?(Convert.ToDecimal(LR.ToString("0.00")));
md.YGLR = new decimal?(Convert.ToDecimal(YGLR.ToString("0.00")));
}
}
}
return model;
}
[WebMethod(EnableSession = true)]
public JsonModel> GetListOrderForTM2222222(int IsYJ, int StoreId, int DeptId, int PlatType, int ShopId, int DateType, DateTime? SDate, DateTime? EDate, int TjType, string Name, int PrintState, int MateState, int MoneyState, int OutDays, int State, int IsSku, int IsError, int IsE, int IsDetail, int HBOrder, int IsSD, int SaleState, int IsBuy, int WLId, int IsDH, int SFLY, int yfcy, int PageIndex, int PageSize, string Sort)
{
PagesNew.Login(base.Session);
DD_OrderData data = new DD_OrderData();
int num = Convert.ToInt32(base.Session["CompanyId"]);
RefParameterCollection where = new RefParameterCollection();
if (IsYJ == 1)
{
where.Add("a.PlatId", "=", 2, DbType.Int32);
where.Add("isnull(a.Fee6,0)", "=", 0, DbType.Int32);
where.Add("isnull(a.Fee7,0)", "=", 0, DbType.Int32);
where.Add("isnull(a.Fee8,0)", "=", 0, DbType.Int32);
}
if (StoreId > 0)
{
where.Add("a.StoreId", "=", StoreId, DbType.Int32);
}
if (IsBuy == 1)
{
where.Add("a.BuyDate", "is not", null, DbType.String);
}
else if (IsBuy == 0)
{
where.Add("a.BuyDate", "is", null, DbType.String);
}
where.Add("a.CompanyId", "=", num, DbType.Int32);
// where.Add("isnull(a.IsSDan,0)", "=", IsSD, DbType.Int32);
if (yfcy == 1)
where.Add("a.WLSS", "=", 1, DbType.Int32);
if (SaleState > 0)
{
where.Add("a.SaleState", "=", SaleState, DbType.Int32);
}
if (WLId > 0)
{
where.Add("a.LogisticsId", "=", WLId, DbType.Int32);
}
if (DeptId > 0)
{
where.Add("c.DeptId", "=", DeptId, DbType.Int32);
}
if (PlatType > 0)
{
where.Add("a.PlatId", "=", PlatType, DbType.Int32);
}
if (ShopId > 0)
{
where.Add("a.ShopId", "=", ShopId, DbType.Int32);
}
if (DateType == 1)
{
if (SDate.HasValue)
{
where.Add("a.OrderDate", ">=", SDate, DbType.DateTime);
}
if (EDate.HasValue)
{
where.Add("a.OrderDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime);
}
}
else if (DateType == 2)
{
if (SDate.HasValue)
{
where.Add("a.InDate", ">=", SDate, DbType.DateTime);
}
if (EDate.HasValue)
{
where.Add("a.InDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime);
}
}
else if (DateType == 3)
{
if (SDate.HasValue)
{
where.Add("a.PrintDate", ">=", SDate, DbType.DateTime);
}
if (EDate.HasValue)
{
where.Add("a.PrintDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime);
}
}
else if (DateType == 4)
{
if (SDate.HasValue)
{
where.Add("a.PostDate", ">=", SDate, DbType.DateTime);
}
if (EDate.HasValue)
{
where.Add("a.PostDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime);
}
}
else if (DateType == 5)
{
if (SDate.HasValue)
{
where.Add("a.OrderOutDate", ">=", SDate, DbType.DateTime);
}
if (EDate.HasValue)
{
where.Add("a.OrderOutDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime);
}
}
if (OutDays > 0)
{
where.Add("a.OrderOutDate", "<=", DateTime.Now.AddDays((double)OutDays), DbType.DateTime);
where.Add("a.OrderOutDate", ">=", DateTime.Now, DbType.DateTime);
}
if (MateState > -1)
{
where.Add("a.MateState", "=", MateState, DbType.Int32);
}
if (MoneyState > -1)
{
where.Add("a.MoneyState", "=", MoneyState, DbType.Int32);
}
if (PrintState > -1)
{
where.Add("a.PrintState", "=", PrintState, DbType.Int32);
}
if (State == 3)
{
where.Add("a.State", "=", 2, DbType.Int32);
}
else if (State == 4)
{
where.Add("a.State", "=", 3, DbType.Int32);
}
else if (State == 5)
{
where.Add("a.State", "=", 1, DbType.Int32);
where.Add("a.MoneyState", "=", 1, DbType.Int32);
}
else if (State == 7)
{
where.Add("a.OrderState2", "=", 1, DbType.Int32);
}
else if (State == 1)
{
where.Add("a.PostState", "=", 1, DbType.Int32);
}
else if (State == 2)
{
where.Add("a.State", "<", 3, DbType.Int32);
where.Add("a.PostState", "=", 2, DbType.Int32);
}
else if (State == 0)
{
where.Add("a.State", "=", 1, DbType.Int32);
}
else
{
where.Add("a.State", ">", 0, DbType.Int32);
}
if (HBOrder == 1)
{
where.Add("a.IsJoin", "=", 1, DbType.Int32);
}
if (IsError == 1)
{
where.Add("(a.SendAddr", ">", 0, DbType.Int32);
where.Add("a.IsLeaveWord", "=", 1, "or", ")", DbType.Int32);
}
if (IsE == 1)
{
where.Add("a.PostState", "=", 2, DbType.Int32);
}
if (IsE == 0)
{
where.Add("a.PostState", "<", 2, DbType.Int32);
}
string trackCode = "";
if (Name != "")
{
Name = Name.Trim();
if (TjType == 1)
{
where.Add("(a.PlatOrderCode", "like", Name, DbType.String);
where.Add("OrderCode", "like", Name, "or", DbType.String);
where.Add("a.JoinOrderCode", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 2)
{
where.Add("a.RevName", "like", Name, DbType.String);
}
else if (TjType == 3)
{
where.Add("a.RevPhone", "like", Name, DbType.String);
}
else if (TjType == 4)
{
where.Add("(a.RevCountry", "=", Name, DbType.String);
where.Add("a.CountryName", "=", Name, "or", DbType.String);
where.Add("a.CountryCode", "=", Name, "or", ")", DbType.String);
}
else if (TjType == 5)
{
where.Add("a.RevPostCode", "=", Name, DbType.String);
}
else if (TjType == 6)
{
where.Add("(a.RevAddr", "like", Name, DbType.String);
where.Add("a.RevProvince", "like", Name, "or", DbType.String);
where.Add("a.RevCity", "like", Name, "or", DbType.String);
where.Add("a.RevArea", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 9)
{
where.Add("(a.ErrorInfo", "like", Name, DbType.String);
where.Add("a.PostError", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 10)
{
trackCode = Name;
}
else if (TjType == 11)
{
where.Add("a.CustomID", "=", Name, DbType.String);
}
else if (TjType == 12)
{
where.Add("a.RevMail", "=", Name, DbType.String);
}
}
if (IsSku == 0)
{
where.Add("a.FPDate", "is", null, DbType.String);
}
else if (IsSku == 1)
{
where.Add("a.FPDate", "is not", null, DbType.String);
}
JsonModel> model = new JsonModel>();
int rowCount = 0;
string str2 = "";
string str3 = "";
if ((TjType == 7) && (Name != ""))
{
str2 = Name;
}
else if ((TjType == 8) && (Name != ""))
{
str3 = Name;
}
if (TjType == 13 && Name != "")//根据人员查询
{
model.DataSource = DataNew.GetListDT_OrderInfoForUser(num, SDate, str2.Trim(), Name, trackCode, -1, IsDH, where, PageIndex, PageSize, Sort, out rowCount);
}
else
{
if (SFLY > 0)
{
if (SFLY == 1)
{
model.DataSource = data.GetListDT_OrderInfoForTM6(num, str2.Trim(), str3.Trim(), trackCode, -1, IsDH, where, PageIndex, PageSize, Sort, out rowCount);
}
if (SFLY == 2)
{
model.DataSource = data.GetListDT_OrderInfoForTM7(num, str2.Trim(), str3.Trim(), trackCode, -1, IsDH, where, PageIndex, PageSize, Sort, out rowCount);
}
}
else
{
model.DataSource = DataNew.GetListDT_OrderInfoForTM2(num, "",str2.Trim(), str3.Trim(), trackCode, -1, IsDH, where, PageIndex, PageSize, Sort, out rowCount);
}
}
model.RowCount = rowCount;
string ids = "";
JC_ExpressService wlobj = new JC_ExpressService();
var wlist = wlobj.GetExpressList();
List maplist = null;
if (model.DataSource != null)
{
foreach (DT_Order md in model.DataSource)
{
ids += md.OrderId.ToString() + ",";
if (md.Post != null && md.Post > 0)
{
var wlmd = wlist.Find(n => n.ExpressID == md.Post);
if (wlmd != null)
{
md.TrackInfo = wlmd.Name;
}
}
md.RevFax = "";
//if (maplist != null && md.RevProvince != null && md.RevProvince != "")
//{
// var mmd = maplist.Find(n => n.code == md.RevProvince.ToUpper() || n.ename == md.RevProvince);
// if (mmd != null)
// {
// if (mmd.IsEast == 1)
// {
// md.RevFax = "E";
// }
// else
// md.RevFax = "W";
// }
//}
}
}
if (ids != "")
{
maplist = DataNew.GetListUSMap4(ids.Trim(','));
List errorList = data.GetErrorList(ids.Trim(','));
if ((errorList != null) && (errorList.Count > 0))
{
foreach (var md in model.DataSource)
{
DT_OrderError error = errorList.Find(n => n.OrderId == md.OrderId);
if (error != null)
{
md.ErrorInfo = error.ErrorInfo;
}
}
}
}
List saleBackModelList = null;
if ((IsDetail == 1) && (model.DataSource != null))
{
int? trackType;
if (ids != "")
{
List orderGoodsList = DataNew.GetOrderGoodsListNew2(ids.Trim(','));
List trackCodeApplyList = data.GetTrackCodeApplyList(ids.Trim(','));
saleBackModelList = data.GetSaleBackModelList(ids.Trim(','));
var pmlist = DataNew.GetOrderGoodsCodeData();
List JZLinklist = DataNew.GetListJZLinkOrder(ids.Trim(','));
if (orderGoodsList != null)
{
foreach (var md in model.DataSource)
{
List list5 = orderGoodsList.FindAll(n => n.OrderId == md.OrderId);
if (list5 != null)
{
md.GoodsList = list5;
if (pmlist != null)
{
foreach (var mmd in list5)
{
var pmmd = pmlist.Find(n => n.GoodsId == mmd.GoodsId && n.ShopId == md.ShopId);
if (pmmd != null)
{
string imgurl = "";
if (pmmd.Int10 != null && pmmd.Int10 == 1)
{
imgurl = "
";
}
if (pmmd.Int10 != null && pmmd.Int10 == 2)
{
imgurl = "
";
}
if (pmmd.Int10 != null && pmmd.Int10 == 3)
{
imgurl = "
";
}
if (pmmd.Int3 < 100)
mmd.OldTypeDesc = "排名:" + pmmd.Int3.ToString();
else
mmd.OldTypeDesc = "排名:" + pmmd.Int3.ToString();
if (pmmd.Int2 != null)
mmd.OldTypeDesc += "/" + pmmd.Int2.ToString();
mmd.OldTypeDesc += "" + imgurl;
}
else
mmd.OldTypeDesc = "";
}
}
}
}
}
if (trackCodeApplyList != null)
{
foreach (var md in model.DataSource)
{
List list6 = new List();
if ((md.JoinOrderCode != null) && (md.JoinOrderCode != ""))
{
list6 = trackCodeApplyList.FindAll(n => n.OrderCode == md.JoinOrderCode);
}
else
{
list6 = trackCodeApplyList.FindAll(n => n.OrderId == md.OrderId);
}
if ((list6 != null) && (list6.Count > 0))
{
string str5 = "";
string str6 = "";
foreach (DT_TrackCodeApply apply in list6)
{
string str7 = "";
trackType = apply.TrackType;
if (trackType != null && trackType == 3)
{
str7 = "[空包裹]";
}
if (apply.Weight.HasValue)
{
string str8 = "";
if (apply.ScanDate.HasValue)
{
str8 = "扫描时间:" + apply.ScanDate.Value.ToString("yyyy-MM-dd HH:mm") + "
";
}
string str9 = str5;
str5 = str9 + apply.TrackCode + str7 + "
重量" + apply.Weight.ToString() + "g" + str8 + "
";
}
else
{
str5 = str5 + apply.TrackCode + str7 + "
";
}
if (str6 == "")
{
str6 = apply.TrackCode;
}
}
md.TrackInfo += str5;
md.TrackCode = str6;
}
}
}
decimal moneyrate = Convert.ToDecimal((double)6.5);
List list7 = new BaseService().GetMoneyList2();
decimal ckfee = 0;
decimal mdfee = 0;
decimal adfee = 0;
decimal DR_BackFee = 0;
decimal DR_SSFee = 0;
decimal DR_PostFee = 0;
foreach (var md in model.DataSource)
{
md.OrderName = "";
string jplink = "";
if (JZLinklist != null)
{
var jzmd = JZLinklist.FindAll(n => n.OrderId == md.OrderId && n.ShopId == md.ShopId);
if (jzmd != null)
{
int i = 1;
foreach (var jzmmd in jzmd)
{
if (jzmmd.Price != null)
jplink += "竟品" + i.ToString() + "价格:" + jzmmd.Price.Value + "$
";
else
jplink += "竟品" + i.ToString() + "
";
i++;
}
}
md.OrderName = jplink;
}
JC_Money money = list7.Find(n => n.MCode == "USD" && n.PlatId == md.PlatId);
if (money != null)
{
moneyrate = money.MRate.Value;
}
else
{
money = list7.Find(n => n.MCode == "USD");
moneyrate = money.MRate.Value;
}
decimal TotalPrice = 0M;
if (md.TotalPrice != null)
{
TotalPrice = md.TotalPrice.Value;
}
decimal YJPrice = 0M;
YJPrice = TotalPrice * Convert.ToDecimal((double)0.15);
int PlatId = md.PlatId.Value;
if (PlatId == 1)
{
YJPrice = TotalPrice * Convert.ToDecimal((double)0.05);
}
else if (PlatId == 4)
{
YJPrice = 0;
}
else if (PlatId == 5)
{
YJPrice = TotalPrice * Convert.ToDecimal((double)0.1);
}
else if (PlatId == 15)
{
YJPrice = TotalPrice * Convert.ToDecimal((double)0.029) + 0.3M;
}
var admd = DataNew.GetModel_OrderFee(md.OrderId.Value);///仓储 面单 广告费
if (admd != null)
{
ckfee = admd.ckfee.Value;
mdfee = admd.mdfee.Value;
adfee = admd.adfee.Value;
DR_BackFee = admd.DR_BackFee.Value;
DR_PostFee = admd.DR_PostFee.Value;
DR_SSFee = admd.DR_SSFee.Value;
}
decimal GoodsFee = 0M;
decimal YJGoodsFee = 0M;
decimal TCFee = 0M;
decimal YJTCFee = 0M;
decimal TSolid = 0M;
decimal YGFeeRate = 0M;
string AddrType = "";
decimal twight = 0;
if (md.GoodsList != null && md.GoodsList.Count > 0)
{
AddrType = md.GoodsList[0].JoinOrderCode;
if (md.GoodsList[0].Weight != null)
twight = md.GoodsList[0].Weight.Value;
foreach (DT_OrderGoods goods in md.GoodsList)
{
if (goods.GoodsFee.HasValue && (goods.GoodsFee.Value > 0M))
{
GoodsFee += goods.GoodsFee.Value;
}
if (goods.GoodsPrice.HasValue)
{
if (GoodsFee == 0)
GoodsFee += goods.GoodsPrice.Value * goods.GoodsNum.Value;
YJGoodsFee += goods.GoodsPrice.Value * goods.GoodsNum.Value;
if (goods.BGPrice != null)
YGFeeRate += goods.GoodsPrice.Value * goods.GoodsNum.Value * goods.BGPrice.Value * Convert.ToDecimal(0.01);
}
if (goods.TCFee != null && goods.TCFee > 0)
{
TCFee += goods.TCFee.Value;
}
if (goods.Solid2.HasValue)
{
TSolid += goods.Solid2.Value * goods.GoodsNum.Value;
}
}
}
if (GoodsFee > 0M)
{
GoodsFee = GoodsFee / moneyrate;
YJGoodsFee = YJGoodsFee / moneyrate;//预估货物成本
YGFeeRate = YGFeeRate / moneyrate;//预估税费
}
decimal escrowFee = 0M;
if ((TCFee == 0M) && (TSolid > 0M))
{
TCFee = Convert.ToDecimal(170) * TSolid;
}
if (TSolid > 0M)
{
YJTCFee = Convert.ToDecimal(130) * TSolid;//预估头程
}
if (md.escrowFee.HasValue)
{
escrowFee = md.escrowFee.Value;//页面上手填的税费
}
decimal PostFee = 0M;
if (md.PostFee.HasValue)
{
PostFee = md.PostFee.Value;
}
decimal BackFactPrice = 0M;
decimal BackPostFee = 0M;
int BackState = -1;
if (md.OrderState2 != null)
BackState = md.OrderState2.Value;
if (BackState == 1 && (saleBackModelList != null))
{
DT_OrderBackMoneyApply backmd = saleBackModelList.Find(n => n.OrderId == md.OrderId);
if (backmd != null)
{
if (backmd.OrderState == 0)
{
YJPrice = TotalPrice * Convert.ToDecimal((double)0.2);
TotalPrice = 0M;
}
if (backmd.OrderState == 1 || backmd.OrderState == 2)
{
GoodsFee = 0M;
YJGoodsFee = 0M;
}
if (backmd.FactPrice.HasValue)
{
BackFactPrice = backmd.FactPrice.Value;
}
if (backmd.PostFee.HasValue)
{
BackPostFee = backmd.PostFee.Value;
}
}
}
decimal PostFeeYJ = 0M;
//if (md.Post == 222 || md.Post == 226 || md.Post == 227)
//{
// PostFeeYJ = PostFee * Convert.ToDecimal((double)0.1);
//}
decimal ygyf = 0M;
decimal ygyf2 = 0M;
int storeid = 6;
md.RevFax = "W";
if (maplist != null)
{
var mmd = maplist.Find(n => n.OrderId == md.OrderId);
if (mmd != null && mmd.StoreId != null)
{
if (mmd.StoreId == 11)
{
storeid = 11;
md.RevFax = "E";
}
if (mmd.Fee11 != null && mmd.Fee11 > 0)
{
ygyf = mmd.Fee11.Value;
}
if (ygyf == 0 && mmd.Fee12 != null && mmd.Fee12 > 0)
ygyf = mmd.Fee12.Value;
if (mmd.Fee12 != null && mmd.Fee12 > 0 && mmd.Fee12 < ygyf)
{
ygyf = mmd.Fee12.Value;
}
if (ygyf == 0 && mmd.Fee13 != null && mmd.Fee13 > 0)
ygyf = mmd.Fee13.Value;
if (mmd.Fee13 != null && mmd.Fee13 > 0 && mmd.Fee13 < ygyf)
{
ygyf = mmd.Fee13.Value;
}
if (ygyf == 0 && mmd.Fee14 != null && mmd.Fee14 > 0)
ygyf = mmd.Fee14.Value;
if (mmd.Fee14 != null && mmd.Fee14 > 0 && mmd.Fee14 < ygyf)
{
ygyf = mmd.Fee14.Value;
}
if (AddrType == "Residential" || AddrType == "RESIDENTIAL")
{
if (mmd.Fee11 > 0 && mmd.Fee11 < mmd.Fee13)
{
ygyf = mmd.Fee11.Value;
}
else if (mmd.Fee11 > 0 && mmd.Fee11 > mmd.Fee13)
{
ygyf = mmd.Fee13.Value;
}
}
if (AddrType == "Commercial" || AddrType == "OFFICE")
{
if (mmd.Fee11 > 0 && mmd.Fee11 < mmd.Fee12)
{
ygyf = mmd.Fee11.Value;
}
else if (mmd.Fee12 > 0 && mmd.Fee11 > mmd.Fee12)
{
ygyf = mmd.Fee12.Value;
}
}
if (twight >= 1120 && mmd.Fee12 > 0)
ygyf = mmd.Fee12.Value;
// if (ygyf > 0)
// ygyf = ygyf * 1.1M;
}
}
if (md.Fee6 != null && md.Fee6 > 0)
{
ygyf2 = md.Fee6.Value;
}
if (ygyf2 == 0 && md.Fee7 != null && md.Fee7 > 0)
ygyf2 = md.Fee7.Value;
if (md.Fee7 != null && md.Fee7 > 0 && md.Fee7 < ygyf2)
{
ygyf2 = md.Fee7.Value;
}
if (ygyf2 == 0 && md.Fee8 != null && md.Fee8 > 0)
ygyf2 = md.Fee8.Value;
if (md.Fee8 != null && md.Fee8 > 0 && md.Fee8 < ygyf2)
{
ygyf2 = md.Fee8.Value;
}
if (AddrType == "Residential" || AddrType == "RESIDENTIAL")
{
if (md.Fee6 > 0 && md.Fee6 < md.Fee8)
{
ygyf2 = md.Fee6.Value;
}
else if (md.Fee8 > 0 && md.Fee6 > md.Fee8)
{
ygyf2 = md.Fee8.Value;
}
}
if (AddrType == "Commercial" || AddrType == "OFFICE")
{
if (md.Fee6 > 0 && md.Fee6 < md.Fee7)
{
ygyf2 = md.Fee6.Value;
}
else if (md.Fee7 > 0 && md.Fee6 > md.Fee7)
{
ygyf2 = md.Fee7.Value;
}
}
if (twight >= 1120 && md.Fee7 > 0)
ygyf2 = md.Fee7.Value;
md.PostFee = new decimal?(PostFee);
decimal ygyf0 = ygyf;
if (ygyf == 0)
ygyf0 = ygyf2;
if (ygyf > 0 && ygyf <= ygyf2)
ygyf0 = ygyf;
else if (ygyf2 > 0 && ygyf2 < ygyf)
ygyf0 = ygyf2;
md.BoxFee = new decimal?(ygyf0);
decimal LR = 0M;
decimal YGLR = 0M;
LR = TotalPrice - YJPrice - escrowFee - GoodsFee - PostFee - PostFeeYJ - TCFee - BackFactPrice - BackPostFee - ckfee - mdfee - adfee - DR_BackFee - DR_PostFee + DR_SSFee;
YGLR = TotalPrice - YJPrice - escrowFee - YJGoodsFee - YGFeeRate - ygyf0 - YJTCFee - BackFactPrice - BackPostFee - ckfee - mdfee - adfee - DR_BackFee - DR_PostFee + DR_SSFee;
md.LR = new decimal?(Convert.ToDecimal(LR.ToString("0.00")));
md.YGLR = new decimal?(Convert.ToDecimal(YGLR.ToString("0.00")));
}
}
}
return model;
}
[WebMethod(EnableSession = true)]
public JsonModel> GetListOrderForTM44(int IsYJ, int StoreId, int DeptId, int PlatType, int ShopId, int DateType, DateTime? SDate, DateTime? EDate, int TjType, string Name, int PrintState, int MateState, int MoneyState, int OutDays, int State, int IsSku, int IsError, int IsE, int IsDetail, int HBOrder, int IsSD, int SaleState, int IsBuy, int WLId, int IsDH, int SFLY, int yfcy, int PageIndex, int PageSize, string Sort)
{
PagesNew.Login(base.Session);
DD_OrderData data = new DD_OrderData();
int num = Convert.ToInt32(base.Session["CompanyId"]);
RefParameterCollection where = new RefParameterCollection();
if (IsYJ == 1)
{
where.Add("a.PlatId", "=", 2, DbType.Int32);
where.Add("isnull(a.Fee6,0)", "=", 0, DbType.Int32);
where.Add("isnull(a.Fee7,0)", "=", 0, DbType.Int32);
where.Add("isnull(a.Fee8,0)", "=", 0, DbType.Int32);
}
if (StoreId > 0)
{
where.Add("a.StoreId", "=", StoreId, DbType.Int32);
}
if (IsBuy == 1)
{
where.Add("a.BuyDate", "is not", null, DbType.String);
}
else if (IsBuy == 0)
{
where.Add("a.BuyDate", "is", null, DbType.String);
}
where.Add("a.CompanyId", "=", num, DbType.Int32);
// where.Add("isnull(a.IsSDan,0)", "=", IsSD, DbType.Int32);
if (yfcy == 1)
where.Add("a.WLSS", "=", 1, DbType.Int32);
if (SaleState > 0)
{
where.Add("a.SaleState", "=", SaleState, DbType.Int32);
}
if (WLId > 0)
{
where.Add("a.LogisticsId", "=", WLId, DbType.Int32);
}
if (DeptId > 0)
{
where.Add("c.DeptId", "=", DeptId, DbType.Int32);
}
if (PlatType > 0)
{
where.Add("a.PlatId", "=", PlatType, DbType.Int32);
}
if (ShopId > 0)
{
where.Add("a.ShopId", "=", ShopId, DbType.Int32);
}
if (DateType == 1)
{
if (SDate.HasValue)
{
where.Add("a.OrderDate", ">=", SDate, DbType.DateTime);
}
if (EDate.HasValue)
{
where.Add("a.OrderDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime);
}
}
else if (DateType == 2)
{
if (SDate.HasValue)
{
where.Add("a.InDate", ">=", SDate, DbType.DateTime);
}
if (EDate.HasValue)
{
where.Add("a.InDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime);
}
}
else if (DateType == 3)
{
if (SDate.HasValue)
{
where.Add("a.PrintDate", ">=", SDate, DbType.DateTime);
}
if (EDate.HasValue)
{
where.Add("a.PrintDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime);
}
}
else if (DateType == 4)
{
if (SDate.HasValue)
{
where.Add("a.PostDate", ">=", SDate, DbType.DateTime);
}
if (EDate.HasValue)
{
where.Add("a.PostDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime);
}
}
else if (DateType == 5)
{
if (SDate.HasValue)
{
where.Add("a.OrderOutDate", ">=", SDate, DbType.DateTime);
}
if (EDate.HasValue)
{
where.Add("a.OrderOutDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime);
}
}
if (OutDays > 0)
{
where.Add("a.OrderOutDate", "<=", DateTime.Now.AddDays((double)OutDays), DbType.DateTime);
where.Add("a.OrderOutDate", ">=", DateTime.Now, DbType.DateTime);
}
if (MateState > -1)
{
where.Add("a.MateState", "=", MateState, DbType.Int32);
}
if (MoneyState > -1)
{
where.Add("a.MoneyState", "=", MoneyState, DbType.Int32);
}
if (PrintState > -1)
{
where.Add("a.PrintState", "=", PrintState, DbType.Int32);
}
if (State == 3)
{
where.Add("a.State", "=", 2, DbType.Int32);
}
else if (State == 4)
{
where.Add("a.State", "=", 3, DbType.Int32);
}
else if (State == 5)
{
where.Add("a.State", "=", 1, DbType.Int32);
where.Add("a.MoneyState", "=", 1, DbType.Int32);
}
else if (State == 7)
{
where.Add("a.OrderState2", "=", 1, DbType.Int32);
}
else if (State == 1)
{
where.Add("a.PostState", "=", 1, DbType.Int32);
}
else if (State == 2)
{
where.Add("a.State", "<", 3, DbType.Int32);
where.Add("a.PostState", "=", 2, DbType.Int32);
}
else if (State == 0)
{
where.Add("a.State", "=", 1, DbType.Int32);
}
else
{
where.Add("a.State", ">", 0, DbType.Int32);
}
if (HBOrder == 1)
{
where.Add("a.IsJoin", "=", 1, DbType.Int32);
}
if (IsError == 1)
{
where.Add("(a.SendAddr", ">", 0, DbType.Int32);
where.Add("a.IsLeaveWord", "=", 1, "or", ")", DbType.Int32);
}
if (IsE == 1)
{
where.Add("a.PostState", "=", 2, DbType.Int32);
}
if (IsE == 0)
{
where.Add("a.PostState", "<", 2, DbType.Int32);
}
string trackCode = "";
if (Name != "")
{
Name = Name.Trim();
if (TjType == 1)
{
where.Add("(a.PlatOrderCode", "like", Name, DbType.String);
where.Add("OrderCode", "like", Name, "or", DbType.String);
where.Add("a.JoinOrderCode", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 2)
{
where.Add("a.RevName", "like", Name, DbType.String);
}
else if (TjType == 3)
{
where.Add("a.RevPhone", "like", Name, DbType.String);
}
else if (TjType == 4)
{
where.Add("(a.RevCountry", "=", Name, DbType.String);
where.Add("a.CountryName", "=", Name, "or", DbType.String);
where.Add("a.CountryCode", "=", Name, "or", ")", DbType.String);
}
else if (TjType == 5)
{
where.Add("a.RevPostCode", "=", Name, DbType.String);
}
else if (TjType == 6)
{
where.Add("(a.RevAddr", "like", Name, DbType.String);
where.Add("a.RevProvince", "like", Name, "or", DbType.String);
where.Add("a.RevCity", "like", Name, "or", DbType.String);
where.Add("a.RevArea", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 9)
{
where.Add("(a.ErrorInfo", "like", Name, DbType.String);
where.Add("a.PostError", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 10)
{
trackCode = Name;
}
else if (TjType == 11)
{
where.Add("a.CustomID", "=", Name, DbType.String);
}
else if (TjType == 12)
{
where.Add("a.RevMail", "=", Name, DbType.String);
}
}
if (IsSku == 0)
{
where.Add("a.FPDate", "is", null, DbType.String);
}
else if (IsSku == 1)
{
where.Add("a.FPDate", "is not", null, DbType.String);
}
JsonModel> model = new JsonModel>();
int rowCount = 0;
string str2 = "";
string str3 = "";
if ((TjType == 7) && (Name != ""))
{
str2 = Name;
}
else if ((TjType == 8) && (Name != ""))
{
str3 = Name;
}
if (TjType == 13 && Name != "")//根据人员查询
{
model.DataSource = DataNew.GetListDT_OrderInfoForUser(num, SDate, str2.Trim(), Name, trackCode, -1, IsDH, where, PageIndex, PageSize, Sort, out rowCount);
}
else
{
if (SFLY > 0)
{
if (SFLY == 1)
{
model.DataSource = data.GetListDT_OrderInfoForTM6(num, str2.Trim(), str3.Trim(), trackCode, -1, IsDH, where, PageIndex, PageSize, Sort, out rowCount);
}
if (SFLY == 2)
{
model.DataSource = data.GetListDT_OrderInfoForTM7(num, str2.Trim(), str3.Trim(), trackCode, -1, IsDH, where, PageIndex, PageSize, Sort, out rowCount);
}
}
else
{
model.DataSource = DataNew.GetListDT_OrderInfoForTM2(num,"", str2.Trim(), str3.Trim(), trackCode, -1, IsDH, where, PageIndex, PageSize, Sort, out rowCount);
}
}
model.RowCount = rowCount;
string ids = "";
JC_ExpressService wlobj = new JC_ExpressService();
var wlist = wlobj.GetExpressList();
List maplist = null;
if (model.DataSource != null)
{
foreach (DT_Order md in model.DataSource)
{
ids += md.OrderId.ToString() + ",";
if (md.Post != null && md.Post > 0)
{
var wlmd = wlist.Find(n => n.ExpressID == md.Post);
if (wlmd != null)
{
md.TrackInfo = wlmd.Name;
}
}
md.RevFax = "";
//if (maplist != null && md.RevProvince != null && md.RevProvince != "")
//{
// var mmd = maplist.Find(n => n.code == md.RevProvince.ToUpper() || n.ename == md.RevProvince);
// if (mmd != null)
// {
// if (mmd.IsEast == 1)
// {
// md.RevFax = "E";
// }
// else
// md.RevFax = "W";
// }
//}
}
}
if (ids != "")
{
maplist = DataNew.GetListUSMap4(ids.Trim(','));
List errorList = data.GetErrorList(ids.Trim(','));
if ((errorList != null) && (errorList.Count > 0))
{
foreach (var md in model.DataSource)
{
DT_OrderError error = errorList.Find(n => n.OrderId == md.OrderId);
if (error != null)
{
md.ErrorInfo = error.ErrorInfo;
}
}
}
}
decimal zje = 0;
decimal zyf = 0;
decimal zcb = 0;
decimal zyj = 0;
decimal zlr = 0;
if ((IsDetail == 1) && (model.DataSource != null))
{
int? trackType;
if (ids != "")
{
List orderGoodsList = DataNew.GetOrderGoodsListNew2(ids.Trim(','));
List trackCodeApplyList = data.GetTrackCodeApplyList(ids.Trim(','));
// saleBackModelList = data.GetSaleBackModelList(ids.Trim(','));
// var pmlist = DataNew.GetOrderGoodsCodeData();
// List JZLinklist = DataNew.GetListJZLinkOrder(ids.Trim(','));
if (orderGoodsList != null)
{
foreach (var md in model.DataSource)
{
List list5 = orderGoodsList.FindAll(n => n.OrderId == md.OrderId);
if (list5 != null)
{
md.GoodsList = list5;
}
}
}
if (trackCodeApplyList != null)
{
foreach (var md in model.DataSource)
{
List list6 = new List();
if ((md.JoinOrderCode != null) && (md.JoinOrderCode != ""))
{
list6 = trackCodeApplyList.FindAll(n => n.OrderCode == md.JoinOrderCode);
}
else
{
list6 = trackCodeApplyList.FindAll(n => n.OrderId == md.OrderId);
}
if ((list6 != null) && (list6.Count > 0))
{
string str5 = "";
string str6 = "";
foreach (DT_TrackCodeApply apply in list6)
{
string str7 = "";
trackType = apply.TrackType;
if (trackType != null && trackType == 3)
{
str7 = "[空包裹]";
}
if (apply.Weight.HasValue)
{
string str8 = "";
if (apply.ScanDate.HasValue)
{
str8 = "扫描时间:" + apply.ScanDate.Value.ToString("yyyy-MM-dd HH:mm") + "
";
}
string str9 = str5;
str5 = str9 + apply.TrackCode + str7 + "
重量" + apply.Weight.ToString() + "g" + str8 + "
";
}
else
{
str5 = str5 + apply.TrackCode + str7 + "
";
}
if (str6 == "")
{
str6 = apply.TrackCode;
}
}
md.TrackInfo += str5;
md.TrackCode = str6;
}
}
}
decimal moneyrate = 1;
decimal moneyrate2 = 1;
List list7 = new BaseService().GetMoneyList2();
decimal ckfee = 0;
decimal mdfee = 0;
decimal adfee = 0;
decimal DR_BackFee = 0;
decimal DR_SSFee = 0;
decimal DR_PostFee = 0;
foreach (var md in model.DataSource)
{
md.OrderName = "";
JC_Money money = list7.Find(n => n.MCode == md.MoneyCode && n.PlatId == md.PlatId);
if (money != null)
{
moneyrate = money.MRate.Value;
}
else
{
money = list7.Find(n => n.MCode == md.MoneyCode);
if (money != null)
moneyrate = money.MRate.Value;
}
JC_Money money2 = list7.Find(n => n.MCode == "USD" && n.PlatId == md.PlatId);
if (money2 != null)
{
moneyrate2 = money2.MRate.Value;
}
else
{
money2 = list7.Find(n => n.MCode == "USD");
if (money2 != null)
moneyrate2 = money2.MRate.Value;
}
decimal TotalPrice = 0M;
if (md.TotalPrice != null)
{
TotalPrice = md.TotalPrice.Value;
}
decimal YJPrice = 0M;
if (md.escrowFee != null)
YJPrice = md.escrowFee.Value;//佣金
int PlatId = md.PlatId.Value;
if (PlatId == 1)
{
YJPrice = TotalPrice * Convert.ToDecimal((double)0.05);
}
else if (PlatId == 4)
{
YJPrice = 0;
}
else if (PlatId == 5)
{
YJPrice = TotalPrice * Convert.ToDecimal((double)0.04);
decimal payfee = 0; //lazada paymentfee
if (md.CountryCode == "VN")
{
payfee = TotalPrice * 0.0384M;
}
else if (md.CountryCode == "TH")
{
payfee = TotalPrice * 0.028M;
}
else if (md.CountryCode == "ID")
{
payfee = TotalPrice * 0.0182M;
}
else
{
payfee = TotalPrice * 0.02M;
}
YJPrice = YJPrice + payfee;
}
else if (PlatId == 15)
{
YJPrice = TotalPrice * Convert.ToDecimal((double)0.029) + 0.3M;
}
else if (PlatId == 16)
{
YJPrice = TotalPrice * 0.15M;
}
if (TotalPrice > 0)
TotalPrice = TotalPrice * moneyrate / moneyrate2; //总金额 转美金
if (YJPrice > 0)
YJPrice = YJPrice * moneyrate / moneyrate2; //总金额 转美金
decimal GoodsFee = 0M;
decimal YJGoodsFee = 0M;
decimal TCFee = 0M;
decimal YJTCFee = 0M;
decimal TSolid = 0M;
decimal YGFeeRate = 0M;
string AddrType = "";
decimal twight = 0;
if (md.GoodsList != null && md.GoodsList.Count > 0)
{
AddrType = md.GoodsList[0].JoinOrderCode;
if (md.GoodsList[0].Weight != null)
twight = md.GoodsList[0].Weight.Value;
foreach (DT_OrderGoods goods in md.GoodsList)
{
if (goods.GoodsFee.HasValue && (goods.GoodsFee.Value > 0M))
{
GoodsFee += goods.GoodsFee.Value;
}
if (goods.GoodsPrice.HasValue)
{
YJGoodsFee += goods.GoodsPrice.Value * goods.GoodsNum.Value;
// if (goods.BGPrice != null)
// YGFeeRate += goods.GoodsPrice.Value * goods.GoodsNum.Value * goods.BGPrice.Value * Convert.ToDecimal(0.01);//预估成本
}
}
}
if (GoodsFee == 0)
GoodsFee = YJGoodsFee;
GoodsFee = GoodsFee / moneyrate2;//转美金
YGFeeRate = YGFeeRate / moneyrate2;//转美金
decimal PostFee = 0M;
if (md.PostFee.HasValue)
{
PostFee = md.PostFee.Value;
}
decimal BackFactPrice = 0M;
decimal BackPostFee = 0M;
int BackState = -1;
if (md.OrderState2 != null)
BackState = md.OrderState2.Value;
decimal PostFeeYJ = 0M;
if (md.Fee7 != null)
PostFeeYJ = md.Fee7.Value;
// if (PostFeeYJ > 0)
// PostFeeYJ = PostFeeYJ * moneyrate;
md.BoxFee = PostFeeYJ;
decimal LR = 0M;
decimal YGLR = 0M;
if (GoodsFee > 0)
YJGoodsFee = GoodsFee;
LR = TotalPrice - YJPrice - GoodsFee - PostFee - TCFee - BackFactPrice - BackPostFee - ckfee - mdfee - adfee - DR_BackFee - DR_PostFee + DR_SSFee;
YGLR = TotalPrice - YJPrice - YJGoodsFee - YGFeeRate - PostFeeYJ - BackFactPrice - BackPostFee - ckfee - mdfee - adfee - DR_BackFee - DR_PostFee + DR_SSFee;
if (PostFeeYJ > 0)
{
zje += TotalPrice;
zyf += PostFeeYJ;
zcb += YJGoodsFee;
zyj += YJPrice;
zlr += YGLR;
}
md.LR = new decimal?(Convert.ToDecimal(LR.ToString("0.00")));
md.YGLR = new decimal?(Convert.ToDecimal(YGLR.ToString("0.00")));
md.Fee8 = TotalPrice;
}
}
}
return model;
}
[WebMethod(EnableSession = true)]
public JsonModel> GetListOrderForTM2222(int IsYJ, int StoreId, int DeptId, int PlatType, int ShopId, int DateType, DateTime? SDate, DateTime? EDate, int TjType, string Name, int PrintState, int MateState, int MoneyState, int OutDays, int State, int IsSku, int IsError, int IsE, int IsDetail, int HBOrder, int IsSD, int SaleState, int IsBuy, int WLId, int IsDH, int SFLY, int yfcy, int PageIndex, int PageSize, string Sort)
{
PagesNew.Login(base.Session);
DD_OrderData data = new DD_OrderData();
int num = Convert.ToInt32(base.Session["CompanyId"]);
// Session["KTSKU"] = "DC";
string ktsku = Session["KTSKU"].ToString();
RefParameterCollection where = new RefParameterCollection();
if (IsYJ == 1)
{
where.Add("a.PlatId", "=", 2, DbType.Int32);
where.Add("isnull(a.Fee6,0)", "=", 0, DbType.Int32);
where.Add("isnull(a.Fee7,0)", "=", 0, DbType.Int32);
where.Add("isnull(a.Fee8,0)", "=", 0, DbType.Int32);
}
if (StoreId > 0)
{
where.Add("a.StoreId", "=", StoreId, DbType.Int32);
}
if (IsBuy == 1)
{
where.Add("a.BuyDate", "is not", null, DbType.String);
}
else if (IsBuy == 0)
{
where.Add("a.BuyDate", "is", null, DbType.String);
}
where.Add("a.CompanyId", "=", num, DbType.Int32);
// where.Add("isnull(a.IsSDan,0)", "=", IsSD, DbType.Int32);
if (yfcy == 1)
where.Add("a.WLSS", "=", 1, DbType.Int32);
if (SaleState > 0)
{
where.Add("a.SaleState", "=", SaleState, DbType.Int32);
}
if (WLId > 0)
{
where.Add("a.LogisticsId", "=", WLId, DbType.Int32);
}
if (DeptId > 0)
{
where.Add("c.DeptId", "=", DeptId, DbType.Int32);
}
if (PlatType > 0)
{
where.Add("a.PlatId", "=", PlatType, DbType.Int32);
}
if (ShopId > 0)
{
where.Add("a.ShopId", "=", ShopId, DbType.Int32);
}
if (DateType == 1)
{
if (SDate.HasValue)
{
where.Add("a.OrderDate", ">=", SDate, DbType.DateTime);
}
if (EDate.HasValue)
{
where.Add("a.OrderDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime);
}
}
else if (DateType == 2)
{
if (SDate.HasValue)
{
where.Add("a.InDate", ">=", SDate, DbType.DateTime);
}
if (EDate.HasValue)
{
where.Add("a.InDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime);
}
}
else if (DateType == 3)
{
if (SDate.HasValue)
{
where.Add("a.PrintDate", ">=", SDate, DbType.DateTime);
}
if (EDate.HasValue)
{
where.Add("a.PrintDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime);
}
}
else if (DateType == 4)
{
if (SDate.HasValue)
{
where.Add("a.PostDate", ">=", SDate, DbType.DateTime);
}
if (EDate.HasValue)
{
where.Add("a.PostDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime);
}
}
else if (DateType == 5)
{
if (SDate.HasValue)
{
where.Add("a.OrderOutDate", ">=", SDate, DbType.DateTime);
}
if (EDate.HasValue)
{
where.Add("a.OrderOutDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime);
}
}
if (OutDays > 0)
{
where.Add("a.OrderOutDate", "<=", DateTime.Now.AddDays((double)OutDays), DbType.DateTime);
where.Add("a.OrderOutDate", ">=", DateTime.Now, DbType.DateTime);
}
if (MateState > -1)
{
where.Add("a.MateState", "=", MateState, DbType.Int32);
}
if (MoneyState > -1)
{
where.Add("a.MoneyState", "=", MoneyState, DbType.Int32);
}
if (PrintState > -1)
{
where.Add("a.PrintState", "=", PrintState, DbType.Int32);
}
if (State == 3)
{
where.Add("a.State", "=", 2, DbType.Int32);
}
else if (State == 4)
{
where.Add("a.State", "=", 3, DbType.Int32);
}
else if (State == 5)
{
where.Add("a.State", "=", 1, DbType.Int32);
where.Add("a.MoneyState", "=", 1, DbType.Int32);
}
else if (State == 7)
{
where.Add("a.OrderState2", "=", 1, DbType.Int32);
}
else if (State == 1)
{
where.Add("a.PostState", "=", 1, DbType.Int32);
}
else if (State == 2)
{
where.Add("a.State", "<", 3, DbType.Int32);
where.Add("a.PostState", "=", 2, DbType.Int32);
}
else if (State == 0)
{
where.Add("a.State", "=", 1, DbType.Int32);
}
else
{
where.Add("a.State", ">", 0, DbType.Int32);
}
if (HBOrder == 1)
{
where.Add("a.IsJoin", "=", 1, DbType.Int32);
}
if (IsError == 1)
{
where.Add("(a.SendAddr", ">", 0, DbType.Int32);
where.Add("a.IsLeaveWord", "=", 1, "or", ")", DbType.Int32);
}
if (IsE == 1)
{
where.Add("a.PostState", "=", 2, DbType.Int32);
}
if (IsE == 0)
{
where.Add("a.PostState", "<", 2, DbType.Int32);
}
string trackCode = "";
if (Name != "")
{
Name = Name.Trim();
if (TjType == 1)
{
where.Add("(a.PlatOrderCode", "like", Name, DbType.String);
where.Add("OrderCode", "like", Name, "or", DbType.String);
where.Add("a.JoinOrderCode", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 2)
{
where.Add("a.RevName", "like", Name, DbType.String);
}
else if (TjType == 3)
{
where.Add("a.RevPhone", "like", Name, DbType.String);
}
else if (TjType == 4)
{
where.Add("(a.RevCountry", "=", Name, DbType.String);
where.Add("a.CountryName", "=", Name, "or", DbType.String);
where.Add("a.CountryCode", "=", Name, "or", ")", DbType.String);
}
else if (TjType == 5)
{
where.Add("a.RevPostCode", "=", Name, DbType.String);
}
else if (TjType == 6)
{
where.Add("(a.RevAddr", "like", Name, DbType.String);
where.Add("a.RevProvince", "like", Name, "or", DbType.String);
where.Add("a.RevCity", "like", Name, "or", DbType.String);
where.Add("a.RevArea", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 9)
{
where.Add("(a.ErrorInfo", "like", Name, DbType.String);
where.Add("a.PostError", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 10)
{
trackCode = Name;
}
else if (TjType == 11)
{
where.Add("a.CustomID", "=", Name, DbType.String);
}
else if (TjType == 12)
{
where.Add("a.RevMail", "=", Name, DbType.String);
}
}
if (IsSku == 0)
{
where.Add("a.FPDate", "is", null, DbType.String);
}
else if (IsSku == 1)
{
where.Add("a.FPDate", "is not", null, DbType.String);
}
JsonModel> model = new JsonModel>();
int rowCount = 0;
string str2 = "";
string str3 = "";
if ((TjType == 7) && (Name != ""))
{
str2 = Name;
}
else if ((TjType == 8) && (Name != ""))
{
str3 = Name;
}
model.DataSource = DataNew.GetListDT_OrderInfoForTM222(num, str2.Trim(),ktsku, str3.Trim(), trackCode, -1, IsDH, where, PageIndex, PageSize, Sort, out rowCount);
model.RowCount = rowCount;
string ids = "";
JC_ExpressService wlobj = new JC_ExpressService();
var wlist = wlobj.GetExpressList();
List maplist = null;
if (model.DataSource != null)
{
foreach (DT_Order md in model.DataSource)
{
ids += md.OrderId.ToString() + ",";
if (md.Post != null && md.Post > 0)
{
var wlmd = wlist.Find(n => n.ExpressID == md.Post);
if (wlmd != null)
{
md.TrackInfo = wlmd.Name;
}
}
md.RevFax = "";
//if (maplist != null && md.RevProvince != null && md.RevProvince != "")
//{
// var mmd = maplist.Find(n => n.code == md.RevProvince.ToUpper() || n.ename == md.RevProvince);
// if (mmd != null)
// {
// if (mmd.IsEast == 1)
// {
// md.RevFax = "E";
// }
// else
// md.RevFax = "W";
// }
//}
}
}
if (ids != "")
{
maplist = DataNew.GetListUSMap4(ids.Trim(','));
List errorList = data.GetErrorList(ids.Trim(','));
if ((errorList != null) && (errorList.Count > 0))
{
foreach (var md in model.DataSource)
{
DT_OrderError error = errorList.Find(n => n.OrderId == md.OrderId);
if (error != null)
{
md.ErrorInfo = error.ErrorInfo;
}
}
}
}
List saleBackModelList = null;
if ((IsDetail == 1) && (model.DataSource != null))
{
int? trackType;
if (ids != "")
{
List orderGoodsList = DataNew.GetOrderGoodsListNew2(ids.Trim(','));
List trackCodeApplyList = data.GetTrackCodeApplyList(ids.Trim(','));
saleBackModelList = data.GetSaleBackModelList(ids.Trim(','));
var pmlist = DataNew.GetOrderGoodsCodeData();
List JZLinklist = DataNew.GetListJZLinkOrder(ids.Trim(','));
if (orderGoodsList != null)
{
foreach (var md in model.DataSource)
{
List list5 = orderGoodsList.FindAll(n => n.OrderId == md.OrderId);
if (list5 != null)
{
md.GoodsList = list5;
if (pmlist != null)
{
foreach (var mmd in list5)
{
var pmmd = pmlist.Find(n => n.GoodsId == mmd.GoodsId && n.ShopId == md.ShopId);
if (pmmd != null)
{
string imgurl = "";
if (pmmd.Int10 != null && pmmd.Int10 == 1)
{
imgurl = "
";
}
if (pmmd.Int10 != null && pmmd.Int10 == 2)
{
imgurl = "
";
}
if (pmmd.Int10 != null && pmmd.Int10 == 3)
{
imgurl = "
";
}
if (pmmd.Int3 < 100)
mmd.OldTypeDesc = "排名:" + pmmd.Int3.ToString();
else
mmd.OldTypeDesc = "排名:" + pmmd.Int3.ToString();
if (pmmd.Int2 != null)
mmd.OldTypeDesc += "/" + pmmd.Int2.ToString();
mmd.OldTypeDesc += "" + imgurl;
}
else
mmd.OldTypeDesc = "";
}
}
}
}
}
if (trackCodeApplyList != null)
{
foreach (var md in model.DataSource)
{
List list6 = new List();
if ((md.JoinOrderCode != null) && (md.JoinOrderCode != ""))
{
list6 = trackCodeApplyList.FindAll(n => n.OrderCode == md.JoinOrderCode);
}
else
{
list6 = trackCodeApplyList.FindAll(n => n.OrderId == md.OrderId);
}
if ((list6 != null) && (list6.Count > 0))
{
string str5 = "";
string str6 = "";
foreach (DT_TrackCodeApply apply in list6)
{
string str7 = "";
trackType = apply.TrackType;
if (trackType != null && trackType == 3)
{
str7 = "[空包裹]";
}
if (apply.Weight.HasValue)
{
string str8 = "";
if (apply.ScanDate.HasValue)
{
str8 = "扫描时间:" + apply.ScanDate.Value.ToString("yyyy-MM-dd HH:mm") + "
";
}
string str9 = str5;
str5 = str9 + apply.TrackCode + str7 + "
重量" + apply.Weight.ToString() + "g" + str8 + "
";
}
else
{
str5 = str5 + apply.TrackCode + str7 + "
";
}
if (str6 == "")
{
str6 = apply.TrackCode;
}
}
md.TrackInfo += str5;
md.TrackCode = str6;
}
}
}
decimal moneyrate = Convert.ToDecimal((double)6.5);
List list7 = new BaseService().GetMoneyList2();
foreach (var md in model.DataSource)
{
md.OrderName = "";
string jplink = "";
if (JZLinklist != null)
{
var jzmd = JZLinklist.FindAll(n => n.OrderId == md.OrderId && n.ShopId == md.ShopId);
if (jzmd != null)
{
int i = 1;
foreach (var jzmmd in jzmd)
{
if (jzmmd.Price != null)
jplink += "竟品" + i.ToString() + "价格:" + jzmmd.Price.Value + "$
";
else
jplink += "竟品" + i.ToString() + "
";
i++;
}
}
md.OrderName = jplink;
}
JC_Money money = list7.Find(n => n.MCode == "USD" && n.PlatId == md.PlatId);
if (money != null)
{
moneyrate = money.MRate.Value;
}
else
{
money = list7.Find(n => n.MCode == "USD");
moneyrate = money.MRate.Value;
}
decimal TotalPrice = 0M;
if (md.TotalPrice != null)
{
TotalPrice = md.TotalPrice.Value;
}
decimal YJPrice = 0M;
YJPrice = TotalPrice * Convert.ToDecimal((double)0.15);
int PlatId = md.PlatId.Value;
if (PlatId == 1)
{
YJPrice = TotalPrice * Convert.ToDecimal((double)0.05);
}
else if (PlatId == 4)
{
YJPrice = 0;
}
else if (PlatId == 5)
{
YJPrice = TotalPrice * Convert.ToDecimal((double)0.1);
}
decimal GoodsFee = 0M;
decimal YJGoodsFee = 0M;
decimal TCFee = 0M;
decimal YJTCFee = 0M;
decimal TSolid = 0M;
decimal YGFeeRate = 0M;
string AddrType = "";
decimal twight = 0;
if (md.GoodsList != null && md.GoodsList.Count > 0)
{
AddrType = md.GoodsList[0].JoinOrderCode;
if (md.GoodsList[0].Weight != null)
twight = md.GoodsList[0].Weight.Value;
foreach (DT_OrderGoods goods in md.GoodsList)
{
if (goods.GoodsFee.HasValue && (goods.GoodsFee.Value > 0M))
{
GoodsFee += goods.GoodsFee.Value;
}
if (goods.GoodsPrice.HasValue)
{
if (GoodsFee == 0)
GoodsFee += goods.GoodsPrice.Value * goods.GoodsNum.Value;
YJGoodsFee += goods.GoodsPrice.Value * goods.GoodsNum.Value;
if (goods.BGPrice != null)
YGFeeRate += goods.GoodsPrice.Value * goods.GoodsNum.Value * goods.BGPrice.Value * Convert.ToDecimal(0.01);
}
if (goods.TCFee != null && goods.TCFee > 0)
{
TCFee += goods.TCFee.Value;
}
if (goods.Solid2.HasValue)
{
TSolid += goods.Solid2.Value * goods.GoodsNum.Value;
}
}
}
if (GoodsFee > 0M)
{
GoodsFee = GoodsFee / moneyrate;
YJGoodsFee = YJGoodsFee / moneyrate;//预估货物成本
YGFeeRate = YGFeeRate / moneyrate;//预估税费
}
decimal escrowFee = 0M;
if ((TCFee == 0M) && (TSolid > 0M))
{
TCFee = Convert.ToDecimal(65) * TSolid;
}
if (TSolid > 0M)
{
YJTCFee = Convert.ToDecimal(65) * TSolid;//预估头程
}
if (md.escrowFee.HasValue)
{
escrowFee = md.escrowFee.Value;//页面上手填的税费
}
decimal PostFee = 0M;
if (md.PostFee.HasValue)
{
PostFee = md.PostFee.Value;
}
decimal BackFactPrice = 0M;
decimal BackPostFee = 0M;
int BackState = -1;
if (md.OrderState2 != null)
BackState = md.OrderState2.Value;
if (BackState == 1 && (saleBackModelList != null))
{
DT_OrderBackMoneyApply backmd = saleBackModelList.Find(n => n.OrderId == md.OrderId);
if (backmd != null)
{
if (backmd.OrderState == 0)
{
YJPrice = TotalPrice * Convert.ToDecimal((double)0.2);
TotalPrice = 0M;
}
if (backmd.OrderState == 1 || backmd.OrderState == 2)
{
GoodsFee = 0M;
YJGoodsFee = 0M;
}
if (backmd.FactPrice.HasValue)
{
BackFactPrice = backmd.FactPrice.Value;
}
if (backmd.PostFee.HasValue)
{
BackPostFee = backmd.PostFee.Value;
}
}
}
decimal PostFeeYJ = 0M;
//if (md.Post == 222 || md.Post == 226 || md.Post == 227)
//{
// PostFeeYJ = PostFee * Convert.ToDecimal((double)0.1);
//}
decimal ygyf = 0M;
decimal ygyf2 = 0M;
int storeid = 6;
md.RevFax = "W";
if (maplist != null)
{
var mmd = maplist.Find(n => n.OrderId == md.OrderId);
if (mmd != null && mmd.StoreId != null)
{
if (mmd.StoreId == 11)
{
storeid = 11;
md.RevFax = "E";
}
if (mmd.Fee11 != null && mmd.Fee11 > 0)
{
ygyf = mmd.Fee11.Value;
}
if (ygyf == 0 && mmd.Fee12 != null && mmd.Fee12 > 0)
ygyf = mmd.Fee12.Value;
if (mmd.Fee12 != null && mmd.Fee12 > 0 && mmd.Fee12 < ygyf)
{
ygyf = mmd.Fee12.Value;
}
if (ygyf == 0 && mmd.Fee13 != null && mmd.Fee13 > 0)
ygyf = mmd.Fee13.Value;
if (mmd.Fee13 != null && mmd.Fee13 > 0 && mmd.Fee13 < ygyf)
{
ygyf = mmd.Fee13.Value;
}
if (ygyf == 0 && mmd.Fee14 != null && mmd.Fee14 > 0)
ygyf = mmd.Fee14.Value;
if (mmd.Fee14 != null && mmd.Fee14 > 0 && mmd.Fee14 < ygyf)
{
ygyf = mmd.Fee14.Value;
}
if (AddrType == "Residential" || AddrType == "RESIDENTIAL")
{
if (mmd.Fee11 > 0 && mmd.Fee11 < mmd.Fee13)
{
ygyf = mmd.Fee11.Value;
}
else if (mmd.Fee11 > 0 && mmd.Fee11 > mmd.Fee13)
{
ygyf = mmd.Fee13.Value;
}
}
if (AddrType == "Commercial" || AddrType == "OFFICE")
{
if (mmd.Fee11 > 0 && mmd.Fee11 < mmd.Fee12)
{
ygyf = mmd.Fee11.Value;
}
else if (mmd.Fee12 > 0 && mmd.Fee11 > mmd.Fee12)
{
ygyf = mmd.Fee12.Value;
}
}
if (twight >= 1120 && mmd.Fee12 > 0)
ygyf = mmd.Fee12.Value;
// if (ygyf > 0)
// ygyf = ygyf * 1.1M;
}
}
if (md.Fee6 != null && md.Fee6 > 0)
{
ygyf2 = md.Fee6.Value;
}
if (ygyf2 == 0 && md.Fee7 != null && md.Fee7 > 0)
ygyf2 = md.Fee7.Value;
if (md.Fee7 != null && md.Fee7 > 0 && md.Fee7 < ygyf2)
{
ygyf2 = md.Fee7.Value;
}
if (ygyf2 == 0 && md.Fee8 != null && md.Fee8 > 0)
ygyf2 = md.Fee8.Value;
if (md.Fee8 != null && md.Fee8 > 0 && md.Fee8 < ygyf2)
{
ygyf2 = md.Fee8.Value;
}
if (AddrType == "Residential" || AddrType == "RESIDENTIAL")
{
if (md.Fee6 > 0 && md.Fee6 < md.Fee8)
{
ygyf2 = md.Fee6.Value;
}
else if (md.Fee8 > 0 && md.Fee6 > md.Fee8)
{
ygyf2 = md.Fee8.Value;
}
}
if (AddrType == "Commercial" || AddrType == "OFFICE")
{
if (md.Fee6 > 0 && md.Fee6 < md.Fee7)
{
ygyf2 = md.Fee6.Value;
}
else if (md.Fee7 > 0 && md.Fee6 > md.Fee7)
{
ygyf2 = md.Fee7.Value;
}
}
if (twight >= 1120 && md.Fee7 > 0)
ygyf2 = md.Fee7.Value;
md.PostFee = new decimal?(PostFee);
decimal ygyf0 = ygyf;
if (ygyf == 0)
ygyf0 = ygyf2;
if (ygyf > 0 && ygyf <= ygyf2)
ygyf0 = ygyf;
else if (ygyf2 > 0 && ygyf2 < ygyf)
ygyf0 = ygyf2;
md.BoxFee = new decimal?(ygyf0);
decimal LR = 0M;
decimal YGLR = 0M;
LR = TotalPrice - YJPrice - escrowFee - GoodsFee - PostFee - PostFeeYJ - TCFee - BackFactPrice - BackPostFee;
YGLR = TotalPrice - YJPrice - escrowFee - YJGoodsFee - YGFeeRate - ygyf0 - YJTCFee - BackFactPrice - BackPostFee;
md.LR = new decimal?(Convert.ToDecimal(LR.ToString("0.00")));
md.YGLR = new decimal?(Convert.ToDecimal(YGLR.ToString("0.00")));
}
}
}
return model;
}
[WebMethod(EnableSession = true)]
public string GetFedexFeeNo(List list, int PostId)
{
PagesNew.Login(base.Session);
// int companyId = Convert.ToInt32(base.Session["CompanyId"]);
string ids = "";
if (list != null)
{
foreach (var md in list)
{
ids += md.OrderId + ",";
}
}
var GoodsList = DataNew.GetFedexOrderGoodsList(ids.TrimEnd(','));
var OrderList = DataNew.GetFedexOrderList2(ids.TrimEnd(','));
if (OrderList == null || GoodsList == null)
return "重新计算成功0单";
JC_ExpressService service = new JC_ExpressService();
JC_PostAddress address = new BaseService().GetAddressModel2(PostId);
JC_ExpressPost expressModel = service.GetExpressModel(1, PostId);
FedexRate rate = new FedexRate();
FedexRate.Key = expressModel.UserCode;
FedexRate.Password = expressModel.CheckCode;
FedexRate.AccountNumber = expressModel.client_id;
FedexRate.MeterNumber = expressModel.client_secret;
FedexRate.PayAccountNumber = expressModel.refresh_token;
FedexRate.HubId = expressModel.Code;
int Num = 0;
foreach (var omd in OrderList)
{
var glist = GoodsList.FindAll(n => n.OrderId == omd.OrderId);
if (glist == null)
continue;
decimal weight = 0M;
decimal width = 0;
decimal slong = 0;
decimal height = 0;
foreach (var goods in glist)
{
if (goods.Weight!= null&&goods.Weight>0&&goods.GoodsNum != null)
{
weight += goods.Weight.Value * goods.GoodsNum.Value;
}
if (goods.Width2 == null || goods.Length2 == null || goods.Height2 == null || goods.Length2 <= 0 || goods.Width2 <= 0 || goods.Height2 <= 0)
{
weight = 0;
}
if (goods.Width2 > width)
width = goods.Width2.Value;
if (goods.Length2 > slong)
slong = goods.Length2.Value;
if (goods.Height2 > height)
height = goods.Height2.Value;
}
if (weight == 0)
continue;
FedexFeeMd md = new FedexFeeMd
{
RevName = omd.RevName,
RevPhone = omd.RevPhone
};
if ((omd.RevPhone == null) || (omd.RevPhone == ""))
{
md.RevPhone = omd.RevMoblie;
}
md.OrderId = omd.OrderId;
md.SendAddr = address.EnglishAddress;
md.SendCountry = address.countycode;
md.SendCity = address.city;
md.SendProv = address.provincecode;
md.SendPostCode = address.PostCode;
if ((omd.RevAddr != null) && (omd.RevAddr != ""))
{
md.RevAddr = omd.RevAddr;
}
else
{
md.RevAddr = "street No 18";
}
md.RevCity = omd.RevCity;
if (omd.RevCity == null || omd.RevCity == "")
{
md.RevCity = omd.RevProvince;
}
if (omd.RevProvinceCode != null && omd.RevProvinceCode != "")
{
md.RevProv = omd.RevProvinceCode;
}
else if (omd.RevProvince != null && omd.RevProvince != "" && omd.RevProvince.Length > 2)
{
md.RevProv = omd.RevProvince.Substring(omd.RevProvince.Length - 2, 2);
}
else
{
md.RevProv = omd.RevProvince;
}
md.RevPostCode = omd.RevPostCode;
md.RevCountry = omd.CountryCode;
if (md.RevCountry == null || md.RevCountry == "")
md.RevCountry = "US";
md.Width = Math.Ceiling(width).ToString();
md.Height = Math.Ceiling(height).ToString();
md.Lenght = Math.Ceiling(slong).ToString();
md.Weight = weight;
// Thread.Sleep(1000);
md.PostType = "SMART_POST";
string outError = "";
rate.GetFee(md, out outError);
// Thread.Sleep(1000);
md.PostType = "FEDEX_GROUND";
string outError2 = "";
rate.GetFee(md, out outError2);
// Thread.Sleep(1000);
md.PostType = "GROUND_HOME_DELIVERY";
string outError3 = "";
rate.GetFee(md, out outError3);
if (outError == "" || outError2 == "" || outError3=="")
{
Num++;
}
}
return "重新计算成功" + Num+"单";
}
#region 新增货物
[WebMethod(EnableSession = true)]
public string AddOrderGoodsSKUHWC(int CompanyId,string JoinOrderCode,List list,int StoreId)
{
Pages.Login(this.Session);
string message = "";
if (list == null || list.Count == 0)
return "";
var obj = new DD_OrderData();
int UserId = Convert.ToInt32(Session["UserId"]);
// int CompanyId = Convert.ToInt32(Session["CompanyId"]);
string Name = Convert.ToString(Session["Name"]);
foreach (var md in list)
{
obj.UpdateOrderGoodsSKUForTM(0, CompanyId, Name, md.OrderId.Value, md.GoodsPrice, md.GoodsNum.Value, md.DetailId.Value, md.GoodsSKU, md.GoodsName, md.OldTypeCode, md.OldTypeDesc);
// Pages.SaveLog(UserId, "订单日志", md.GoodsSKU + "修改分配", md.OrderId.Value);
}
PartOrderGoodsLockForHWC(CompanyId, 1, StoreId, list[0].OrderId.Value.ToString(), JoinOrderCode);
return message;
}
#endregion
#region 查询订单匹配货物
[WebMethod(EnableSession = true)]
public List GetOrderGoodsListForHWC(int OrderId)
{
PagesNew.Login(this.Session);
var obj = new DD_OrderData();
//int CompanyId = Convert.ToInt32(Session["CompanyId"]);
var list = obj.GetOrderGoodsListNew(OrderId);
if (list != null)
{
decimal USDRate = Convert.ToDecimal(6.5);
var obj2 = new BaseService();
var mlist = obj2.GetMoneyList2();
var plist = DataNew.GetOrderGoodsPostionCodeHWC(OrderId);
decimal GoodsFee = 0;
if (plist != null && plist.Count > 0)
{
foreach (var md in list)
{
var opmd = mlist.Find(n => n.MCode == "USD" && n.PlatId == md.PlatId);
if (opmd != null)
USDRate = opmd.MRate.Value;
var pmd = plist.Find(n => n.Id == md.Id);
if (pmd != null)
{
md.PostionCode = pmd.PostionCode;
md.Price = pmd.Price * md.GoodsNum.Value / USDRate;
md.PostPrice = pmd.PostPrice * md.GoodsNum.Value / USDRate;
md.HWCFee = pmd.HWCFee * md.GoodsNum.Value;
GoodsFee += (pmd.Price.Value * md.GoodsNum.Value + pmd.PostPrice.Value * md.GoodsNum.Value) / USDRate + md.HWCFee.Value;
}
}
if (list.Count > 0)
list[0].GoodsCB = Convert.ToDecimal(GoodsFee.ToString("0.00"));
}
}
return list;
}
#endregion
#region 读取物流渠道
[WebMethod(EnableSession = true)]
public List GetExpressPostList(int LogisticsId, int CompanyId)
{
PagesNew.Login(this.Session);
BaseService obj = new BaseService();
var list = DataNew.GetExpressPostList(CompanyId, LogisticsId);
return list;
}
#endregion
#region 修改订单物流
[WebMethod(EnableSession = true)]
public string ChangeOrderPostForHWC(int OrderId, int PostId, int CompanyId)
{
PagesNew.Login(this.Session);
var md = new DT_TrackCode();
// int CompanyId = Convert.ToInt32(Session["CompanyId"]);
var obj1 = new JC_ExpressService();
var md1 = DataNew.GetExpressModel(PostId);
//if (md1 == null || md1.DefaultAddr == null || md1.DefaultAddr == 0)
//{
// string Error = "该物流渠道没有设置过发货地址,请先到系统管理下面的物流快递处设置发货地址";
// return Error;
//}
string TrackCode = "";
var obj = new DD_OrderData();
var ordermd = obj.GetOrderModel(OrderId);
string error = UpdateOrderPostForTM(md1, OrderId, md1.LogisticsId.Value, PostId, CompanyId, ordermd.PlatOrderCode, ordermd.JoinOrderCode, ordermd.CountryCode, out TrackCode);
return error;
}
#endregion
#region 修改物流
public string UpdateOrderPostForTM(JC_ExpressPost md, int OrderId, int LogisticsId, int PostId, int CompanyId, string PlatOrderCode, string JoinOrderCode, string CountryCode, out string TrackCode)
{
var obj = new DD_OrderData();
var companymd = new JC_PostAddress();
var obj1 = new JC_ExpressService();
var obj11 = new BaseService();
//var ordermd = obj.GetOrderModel(OrderId);
TrackCode = "";
//var goodslist = obj.GetOrderGoodsDetailList(OrderId);
//var md = obj1.GetExpressModel(CompanyId, PostId);
//if (md != null && PostId == 9) //线上发货
//{
// //obj.UpdateTrackPost(PostId, OrderId);
// return "";
//}
string ErrorInfo = "";
var obj2 = new BaseService();
if (CountryCode == null || CountryCode == "")
{
ErrorInfo = PlatOrderCode + "的订单国家代码没对应;";
return ErrorInfo;
}
//if (LogisticsId != 80)
//{
// if (obj2.IsExpress2(CompanyId, PostId, CountryCode) <= 0)
// {
// ErrorInfo = PlatOrderCode + "的订单国家不支持该物流发送;";
// return ErrorInfo;
// }
//}
if (ErrorInfo == "")
obj.UpdateTrackPostForTM2(PostId, LogisticsId, OrderId);
return ErrorInfo;
}
#endregion
#region 读取sku货物
[WebMethod(EnableSession = true)]
public List GetGoodsModelFromGoodsCodeHWC(int CompanyId,int TJ, string SKU)
{
Pages.Login(this.Session);
var obj = new DD_OrderData();
//int CompanyId = Convert.ToInt32(Session["CompanyId"]);
string GoodsCode = SKU.Trim();
string TypeCode = "";
if (TJ == 1 && GoodsCode.Contains("-") == true)
{
GoodsCode = SKU.Trim().Split('-')[0].Trim();
TypeCode = SKU.Trim().Split('-')[1].Trim();
}
else
if (TJ == 1 && GoodsCode.Contains(" ") == true)
{
GoodsCode = SKU.Trim().Split(' ')[0].Trim();
TypeCode = SKU.Trim().Split(' ')[1].Trim();
}
var list = obj.GetGoodsModelFromGoodsCode(TJ, CompanyId, GoodsCode, TypeCode);
//string jsonString = new JavaScriptSerializer().Serialize(list);
return list;// jsonString;
}
#endregion
#region 打印确定
[WebMethod(EnableSession = true)]
public void GetOrderDonePrintForHWC2(int CompanyId, int state, List list,DateTime? InDate)
{
PagesNew.Login(this.Session);
// int CompanyId = Convert.ToInt32(Session["CompanyId"]);
int UserId = Convert.ToInt32(Session["UserId"]);
//var CompanyModel = JC_CompanyService.GetModel(CompanyId);
var obj = new DD_OrderData();
var obj1 = new HuoWuData();
string JoinOrderCodes = "";
string OrderIds = "";
foreach (var pmd in list)
{
if (pmd.JoinOrderCode != null && pmd.JoinOrderCode != "")
{
JoinOrderCodes += "'" + pmd.JoinOrderCode + "',";
}
else
{
OrderIds += pmd.OrderId + ",";
}
}
var printlist = new List();
if (JoinOrderCodes != "" || OrderIds != "")
{
if (state > -1)
printlist = obj.GetPrintOrderList2(OrderIds.Trim(','), JoinOrderCodes.Trim(','));
else
printlist = obj.GetPrintOrderList3(OrderIds.Trim(','), JoinOrderCodes.Trim(','));
}
if (printlist != null)
{
foreach (var md in printlist)
{
if (md.PrintState == 0)
{
// var GoodsList = obj.GetOrderGoodsList(md.OrderId.Value);
HW_GoodsOutRecord model = new HW_GoodsOutRecord();
model.OutCode = GetOutCode();
model.OutReason = "订单发货";
model.CompanyId = CompanyId;
model.InDate = DateTime.Now;
model.InUserId = UserId;
model.IsDelete = 0;
model.OrderId = md.OrderId;
// int Num = 0;
model.OutNum = md.GoodsNum;
var OutId = DataNew.UpdateOrderPrintHWC(model); //生成出库记录
}
}
}
foreach (var md in list)
{
DataNew.SaveTrackCodeScanHWC(md.OrderId.Value, InDate.Value, UserId);
}
}
#endregion
#region 打印确定
[WebMethod(EnableSession = true)]
public void GetOrderDonePrintForHWC(int CompanyId,int state, List list)
{
PagesNew.Login(this.Session);
// int CompanyId = Convert.ToInt32(Session["CompanyId"]);
int UserId = Convert.ToInt32(Session["UserId"]);
//var CompanyModel = JC_CompanyService.GetModel(CompanyId);
var obj = new DD_OrderData();
var obj1 = new HuoWuData();
string JoinOrderCodes = "";
string OrderIds = "";
foreach (var pmd in list)
{
if (pmd.JoinOrderCode != null && pmd.JoinOrderCode != "")
{
JoinOrderCodes += "'" + pmd.JoinOrderCode + "',";
}
else
{
OrderIds += pmd.OrderId + ",";
}
}
var printlist = new List();
if (JoinOrderCodes != "" || OrderIds != "")
{
if (state > -1)
printlist = obj.GetPrintOrderList2(OrderIds.Trim(','), JoinOrderCodes.Trim(','));
else
printlist = obj.GetPrintOrderList3(OrderIds.Trim(','), JoinOrderCodes.Trim(','));
}
if (printlist != null)
{
foreach (var md in printlist)
{
if (md.PrintState == 0)
{
// var GoodsList = obj.GetOrderGoodsList(md.OrderId.Value);
HW_GoodsOutRecord model = new HW_GoodsOutRecord();
model.OutCode = GetOutCode();
model.OutReason = "订单发货";
model.CompanyId = CompanyId;
model.InDate = DateTime.Now;
model.InUserId = UserId;
model.IsDelete = 0;
model.OrderId = md.OrderId;
// int Num = 0;
model.OutNum = md.GoodsNum;
var OutId = DataNew.UpdateOrderPrintHWC(model); //生成出库记录
//if (GoodsList != null)
//{
// foreach (var gmd in GoodsList)
// {
// HW_GoodsOutCK ckmd = new HW_GoodsOutCK();
// ckmd.OutId = OutId;
// ckmd.OutNum = gmd.GoodsNum;
// ckmd.DetailId = gmd.DetailId;
// int CKId = obj1.SaveGoodsOutDetailNew(ckmd);
// obj1.UpdateGoodsOutId(gmd.Id.Value, CKId);
// }
//}
//obj.UpdateOrderPrint(md.OrderId.Value);//修改打印状态
//obj.UpdateOrderGoodsForPrint(md.OrderId.Value);//修改库存
//else
// obj.UpdateOrderPrint(md.OrderId.Value);//修改打印状态
Pages.SaveLog(UserId, "订单打印", "标记打印", md.OrderId.Value);
}
}
}
}
#endregion
public string GetOutCode()
{
Pages.Login(this.Session);
var obj = new CG_ChaseData();
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
Random r = new Random();
string a = r.Next(10000, 99999).ToString();
string Code = DateTime.Now.ToString("yyyyMMddhhmmss") + a;
return Code;
}
#region 查询订单
[WebMethod(EnableSession = true)]
public JsonModel> GetListOrderForTM2(int StoreId, int DeptId, int PlatType, int ShopId, int DateType, DateTime? SDate, DateTime? EDate, int TjType, string Name, int PrintState, int MateState, int MoneyState, int OutDays, int State, int IsSku, int IsError, int IsE, int IsDetail, int HBOrder, int IsSD, int SaleState, int IsBuy, int WLId, int PostId, int IsDH, int SFLY, int PageIndex, int PageSize, string Sort)
{
PagesNew.Login(this.Session);
var obj = new DD_OrderData();
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
RefParameterCollection Param = new RefParameterCollection();
if (StoreId > 0)
Param.Add("a.StoreId", "=", StoreId, DbType.Int32);
if (IsBuy == 1)
Param.Add("a.BuyDate", "is not", null, DbType.String);
else if (IsBuy == 0)
Param.Add("a.BuyDate", "is", null, DbType.String);
Param.Add("a.CompanyId", "=", CompanyId, DbType.Int32);
if (IsSD == 2) Param.Add("isnull(a.IsSDan,0)", ">", 1, DbType.Int32);
else
if (IsSD > -1) Param.Add("isnull(a.TrackState,0)", "=", IsSD, DbType.Int32);
if (SaleState > 0)
Param.Add("a.SaleState", "=", SaleState, DbType.Int32);
if (WLId > 0)
Param.Add("a.LogisticsId", "=", WLId, DbType.Int32);
if (PostId > 0)
Param.Add("a.Post", "=", PostId, DbType.Int32);
if (DeptId > 0)
Param.Add("c.DeptId", "=", DeptId, DbType.Int32);
if (PlatType > 0)
Param.Add("a.PlatId", "=", PlatType, DbType.Int32);
if (ShopId > 0)
Param.Add("a.ShopId", "=", ShopId, DbType.Int32);
if (DateType == 1)
{
if (SDate != null)
Param.Add("a.OrderDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.OrderDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
else
if (DateType == 2)
{
if (SDate != null)
Param.Add("a.InDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.InDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
else
if (DateType == 3)
{
if (SDate != null)
Param.Add("a.PrintDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.PrintDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
else
if (DateType == 4)
{
if (SDate != null)
Param.Add("a.PostDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.PostDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
else
if (DateType == 5)
{
if (SDate != null)
Param.Add("a.OrderOutDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.OrderOutDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
}
if (OutDays > 0)
{
Param.Add("a.OrderOutDate", "<=", DateTime.Now.AddDays(OutDays), DbType.DateTime);
Param.Add("a.OrderOutDate", ">=", DateTime.Now, DbType.DateTime);
}
if (MateState > -1)
Param.Add("a.MateState", "=", MateState, DbType.Int32);
if (MoneyState > -1)
Param.Add("a.MoneyState", "=", MoneyState, DbType.Int32);
if (PrintState > -1)
Param.Add("a.PrintState", "=", PrintState, DbType.Int32);
if (State == 3)
Param.Add("a.State", "=", 2, DbType.Int32);
else if (State == 4)
Param.Add("a.State", "=", 3, DbType.Int32);
else if (State == 5)
{
Param.Add("a.State", "=", 1, DbType.Int32);
Param.Add("a.MoneyState", "=", 1, DbType.Int32);
}
else if (State == 1)
{
//Param.Add("a.State", "=", 2, DbType.Int32);
Param.Add("a.PostState", "=", 1, DbType.Int32);
}
else if (State == 2)
{
Param.Add("a.State", "<", 3, DbType.Int32);
Param.Add("a.PostState", "=", 2, DbType.Int32);
}
else if (State == 0)
{
//Param.Add("a.State", "=", 2, DbType.Int32);
Param.Add("a.State", "=", 1, DbType.Int32);
}
else if (State == 8)
{
//Param.Add("a.State", "=", 2, DbType.Int32);
Param.Add("a.State", "<", 3, DbType.Int32);
Param.Add("a.PostState", "=", 3, DbType.Int32);
}
else
Param.Add("a.State", ">", 0, DbType.Int32);
if (HBOrder == 1)
Param.Add("a.IsJoin", "=", 1, DbType.Int32);
if (IsError == 1)
{
Param.Add("(a.SendAddr", ">", 0, DbType.Int32);
Param.Add("a.IsLeaveWord", "=", 1, "or", ")", DbType.Int32);
}
if (IsE == 1)
{
Param.Add("a.PostState", "=", 2, DbType.Int32);
}
if (IsE == 0)
{
Param.Add("a.PostState", "<", 2, DbType.Int32);
}
string TCode = "";
if (Name != "")
{
Name = Name.Trim();
if (TjType == 1)
{
Param.Add("(a.PlatOrderCode", "like", Name, DbType.String);
Param.Add("OrderCode", "like", Name, "or", DbType.String);
Param.Add("a.JoinOrderCode", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 2)
{
Param.Add("a.RevName", "like", Name, DbType.String);
}
else if (TjType == 3)
{
Param.Add("a.RevPhone", "like", Name, DbType.String);
}
else if (TjType == 4)
{
Param.Add("(a.RevCountry", "=", Name, DbType.String);
Param.Add("a.CountryName", "=", Name, "or", DbType.String);
Param.Add("a.CountryCode", "=", Name, "or", ")", DbType.String);
}
else if (TjType == 5)
{
Param.Add("a.RevPostCode", "=", Name, DbType.String);
}
else if (TjType == 6)
{
Param.Add("(a.RevAddr", "like", Name, DbType.String);
Param.Add("a.RevProvince", "like", Name, "or", DbType.String);
Param.Add("a.RevCity", "like", Name, "or", DbType.String);
Param.Add("a.RevArea", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 16)
{
Param.Add("a.RevProvince", "=", Name, DbType.String);
}
else if (TjType == 9)
{
Param.Add("(a.ErrorInfo", "like", Name, DbType.String);
Param.Add("a.PostError", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 10)
{
//Param.Add("dbo.getOrderTrackCode(a.OrderId,0)", "like", Name, DbType.String);
TCode = Name;
}
else if (TjType == 11)
{
Param.Add("a.CustomID", "=", Name, DbType.String);
}
else if (TjType == 12)
{
Param.Add("a.RevMail", "=", Name, DbType.String);
}
}
if (IsSku == 0)
Param.Add("a.FPDate", "is", null, DbType.String);
else if (IsSku == 1)
Param.Add("a.FPDate", "is not", null, DbType.String);
JsonModel> resultModel = new JsonModel>();
int RowCount = 0;
//string Sort = "orderid desc";
string GoodsName = "";
string SKU = "";
if (TjType == 7 && Name != "")
{
GoodsName = Name;
}
else
if (TjType == 8 && Name != "")
{
SKU = Name;
}
if (SFLY > 0)
{
if (SFLY == 1)
{
resultModel.DataSource = obj.GetListDT_OrderInfoForTM6(CompanyId, GoodsName.Trim(), SKU.Trim(), TCode, -1, IsDH, Param, PageIndex, PageSize, Sort, out RowCount);
}
if (SFLY == 2)
{
resultModel.DataSource = obj.GetListDT_OrderInfoForTM7(CompanyId, GoodsName.Trim(), SKU.Trim(), TCode, -1, IsDH, Param, PageIndex, PageSize, Sort, out RowCount);
}
}
else
{
if (State == 0 || State == 2)
resultModel.DataSource = obj.GetListDT_OrderInfoForTM1(CompanyId, GoodsName.Trim(), SKU.Trim(), TCode, -1, IsDH, Param, PageIndex, PageSize, Sort, out RowCount);
else
resultModel.DataSource = obj.GetListDT_OrderInfoForTM(CompanyId, GoodsName.Trim(), SKU.Trim(), TCode, -1, IsDH, Param, PageIndex, PageSize, Sort, out RowCount);
}
resultModel.RowCount = RowCount;
string Ids = "";
if (resultModel.DataSource != null)
{
foreach (var md in resultModel.DataSource)
{
Ids += md.OrderId.ToString() + ",";
}
}
if (Ids != "")
{
var errorlist = obj.GetErrorList(Ids.Trim(','));
if (errorlist != null && errorlist.Count > 0)
{
foreach (var md in resultModel.DataSource)
{
var emd = errorlist.Find(n => n.OrderId == md.OrderId);
if (emd != null)
{
md.ErrorInfo = emd.ErrorInfo;
}
}
}
}
if (IsDetail == 1 && resultModel.DataSource != null)
{
if (Ids != "")
{
var list1 = obj.GetOrderGoodsList(Ids.Trim(','));
var listTrack = obj.GetTrackCodeApplyList(Ids.Trim(','));
if (list1 != null)
{
foreach (var md in resultModel.DataSource)
{
var list2 = list1.FindAll(n => n.OrderId == md.OrderId);
if (list2 != null)
{
md.GoodsList = list2;
}
}
}
if (listTrack != null)
{
foreach (var md in resultModel.DataSource)
{
var list3 = new List();
if (md.JoinOrderCode != null && md.JoinOrderCode != "")
list3 = listTrack.FindAll(n => n.OrderCode == md.JoinOrderCode);
else
list3 = listTrack.FindAll(n => n.OrderId == md.OrderId);
if (list3 != null && list3.Count > 0)
{
string trackinfo = "";
string TrackCode = "";
foreach (var md1 in list3)
{
string blank = "";
if (md1.TrackType == 3)
blank = "[空包裹]";
if (md1.Weight != null)
{
string dd = "";
if (md1.ScanDate != null)
dd = "扫描时间:" + md1.ScanDate.Value.ToString("yyyy-MM-dd HH:mm");
trackinfo += md1.TrackCode + blank + "重量" + md1.Weight.ToString() + "g" + dd + "
";
}
else
trackinfo += md1.TrackCode + blank + "
";
if (TrackCode == "")
TrackCode = md1.TrackCode;
}
md.TrackInfo = trackinfo;
md.TrackCode = TrackCode;
}
}
}
}
}
return resultModel;
}
#endregion
#region 导出订单
[WebMethod(EnableSession = true)]
public string GetListOrderPrintForExcel3(int PlatType, int IsWeight, int ShopId, int DateType, DateTime? SDate, DateTime? EDate, int OutDays, int TjType, string Name, int PrintState, int State, int IsSku, int IsError, int IsDetail, int HBOrder, int PostId, int IsAddr, int IsFP, string KWCode, string GoodsInfo, int TrackState, int FHState, int GM, int SNum, int ENum, int PageIndex, int PageSize,int StoreId, String Sort)
{
PagesNew.Login(this.Session);
var obj = new DD_OrderData();
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
RefParameterCollection Param = new RefParameterCollection();
if (IsFP > -1)
Param.Add("isnull(a.BillPrint,0)", "=", IsFP, DbType.Int32);
Param.Add("a.CompanyId", "=", CompanyId, DbType.Int32);
Param.Add("a.MateState", "=", 2, DbType.Int32);
if (StoreId >0)
Param.Add("b.StoreId", "=", "StoreId", DbType.Int32);
if (PlatType > 0)
Param.Add("a.PlatId", "=", PlatType, DbType.Int32);
if (ShopId > 0)
Param.Add("a.ShopId", "=", ShopId, DbType.Int32);
if (TrackState == 1)
{
Param.Add("b.TrackState", ">", 0, DbType.Int32);
if (PostId == 0)
Param.Add("b.Post", ">", 0, DbType.Int32);
}
else
if (TrackState == 0)
{
Param.Add("b.TrackState", "=", 0, DbType.Int32);
}
if (DateType == 1)
{
if (SDate != null)
Param.Add("a.OrderDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.OrderDate", "<=", EDate, DbType.DateTime);
}
else
if (DateType == 2)
{
if (SDate != null)
Param.Add("a.InDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.InDate", "<=", EDate, DbType.DateTime);
}
else
if (DateType == 3)
{
if (SDate != null)
Param.Add("a.PrintDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.PrintDate", "<=", EDate, DbType.DateTime);
}
else
if (DateType == 4)
{
if (SDate != null)
Param.Add("a.PostDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.PostDate", "<=", EDate, DbType.DateTime);
}
else
if (DateType == 5)
{
if (SDate != null)
Param.Add("a.OrderOutDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.OrderOutDate", "<=", EDate, DbType.DateTime);
}
if (OutDays > 0)
{
Param.Add("a.OrderOutDate", "<=", DateTime.Today.AddDays(OutDays), DbType.DateTime);
}
if (PrintState == -1 && FHState > -1)
{
Param.Add("a.poststate", "=", FHState, DbType.Int32);
if (IsError == 1)
{
Param.Add("isnull(b.ErrorInfo,'')", "<>", "", DbType.String);
}
}
else
{
if (IsError == 1)
{
Param.Add("(a.PostState", "=", 2, DbType.Int32);
Param.Add("isnull(b.ErrorInfo,'')", "<>", "", "or", ")", DbType.String);
}
else
Param.Add("a.PostState", "<", 2, DbType.Int32);
}
if (PrintState > -1)
Param.Add("a.PrintState", "=", PrintState, DbType.Int32);
if (PrintState > -1)
Param.Add("a.State", "=", 1, DbType.Int32);
else
{
Param.Add("a.State", ">", 0, DbType.Int32);
Param.Add("a.State", "<", 3, DbType.Int32);
//Param.Add("b.RevPhone", "is", null, "or",")",DbType.String);
}
if (PostId > 0)
Param.Add("b.Post", "=", PostId, DbType.Int32);
if (HBOrder == 1)
Param.Add("a.IsJoin", "=", 1, DbType.Int32);
//if (IsError == 1)
//{
// Param.Add("(b.SendAddr", ">", 0, DbType.Int32);
// Param.Add("b.IsLeaveWord", "=", 1, "or", ")", DbType.Int32);
//}
if (IsAddr > -1)
{
Param.Add("b.SendAddr", "=", IsAddr, DbType.Int32);
}
string TCode = "";
if (Name != "")
{
Name = Name.Trim();
if (TjType == 1)
{
Param.Add("(a.PlatOrderCode", "=", Name, DbType.String);
Param.Add("a.JoinOrderCode", "=", Name, "or", ")", DbType.String);
}
else if (TjType == 2)
{
Param.Add("b.RevName", "like", Name, DbType.String);
}
else if (TjType == 3)
{
Param.Add("b.RevPhone", "like", Name, DbType.String);
}
else if (TjType == 4)
{
Param.Add("(b.RevCountry", "=", Name, DbType.String);
Param.Add("b.CountryName", "=", Name, "or", DbType.String);
Param.Add("b.CountryCode", "=", Name, "or", ")", DbType.String);
}
else if (TjType == 5)
{
Param.Add("b.RevPostCode", "=", Name, DbType.String);
}
else if (TjType == 6)
{
Param.Add("(b.RevAddr", "like", Name, DbType.String);
Param.Add("b.RevProvince", "like", Name, "or", DbType.String);
Param.Add("b.RevCity", "like", Name, "or", DbType.String);
Param.Add("b.RevArea", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 9)
{
Param.Add("(b.ErrorInfo", "like", Name, DbType.String);
Param.Add("b.PostError", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 10)
{
// Param.Add("b.TrackCode", "like", Name, DbType.String);
TCode = Name;
}
}
//if (IsError == 2)
//{
// Param.Add("(a.SendAddr", ">", 0, DbType.Int32);
// Param.Add("a.IsLeaveWord", "=", 1, "or", ")", DbType.Int32);
//}
if (IsWeight == 2)
{
Param.Add("isnull(a.IsSpare,0)", "=", 1, DbType.Int32);
}
else
if (IsWeight == 1)
{
Param.Add("isnull(a.IsSpare,0)", "=", 0, DbType.Int32);
}
//if (IsSku == 0)
// Param.Add("a.FPDate", "is", null, DbType.String);
//else if (IsSku == 1)
// Param.Add("a.FPDate", "is not", null, DbType.String);
//Param.Add("a.OrderDate", ">=", 0, DbType.Int32);
JsonModel> resultModel = new JsonModel>();
int RowCount = 0;
//string Sort = "orderid desc";
//if (PrintState == 0)
// Sort = "orderid";
string GoodsName = "";
string Code = "";
if (GoodsInfo != "")
{
GoodsName = GoodsInfo.Trim();
if (GoodsInfo.Trim().Contains(' '))
{
GoodsName = GoodsInfo.Trim().Split(' ')[0].Trim();
Code = GoodsInfo.Trim().Split(' ')[1].Trim();
}
}
//else
// if (TjType == 8 && Name != "")
// {
// SKU = Name;
// }
List orderlist = new List();
if (PrintState > -1)
orderlist = DataNew.GetListDT_PrintOrderInfoForTM2(CompanyId, TCode, GoodsName, 0, Code, KWCode, IsSku, GM, PrintState, Param, PageIndex, PageSize, Sort, out RowCount);
else
orderlist = obj.GetListDT_PrintOrderInfoForTM(CompanyId, TCode, GoodsName, 0, Code, KWCode, IsSku, Param, PageIndex, PageSize, Sort, out RowCount);
string Ids = "";
if (orderlist != null)
{
foreach (var md in orderlist)
{
Ids += md.OrderId.ToString() + ",";
}
}
if (Ids == "")
return "";
var GoodsList = DataNew.GetOrderGoodsInfos(Ids.TrimEnd(','));
//order # country Name Address 1 City State Zip TEL SKU QTY Weight(oz) W(inch) L D Service Type Dept Note
DataTable tb = new DataTable();
tb.Columns.Add("ordercode", Type.GetType("System.String"));
tb.Columns.Add("country", Type.GetType("System.String"));
tb.Columns.Add("Name", Type.GetType("System.String"));
tb.Columns.Add("Address", Type.GetType("System.String"));
tb.Columns.Add("City", Type.GetType("System.String"));
tb.Columns.Add("State", Type.GetType("System.String"));
tb.Columns.Add("Zip", Type.GetType("System.String"));
tb.Columns.Add("TEL", Type.GetType("System.String"));
tb.Columns.Add("SKU", Type.GetType("System.String"));
tb.Columns.Add("GoodsCode2", Type.GetType("System.String"));
tb.Columns.Add("QTY", Type.GetType("System.String"));
tb.Columns.Add("Weight", Type.GetType("System.String"));
tb.Columns.Add("W", Type.GetType("System.String"));
tb.Columns.Add("L", Type.GetType("System.String"));
tb.Columns.Add("D", Type.GetType("System.String"));
tb.Columns.Add("Service", Type.GetType("System.String"));
tb.Columns.Add("Note", Type.GetType("System.String"));
if (orderlist != null)
{
foreach (var md in orderlist)
{
DataRow row = tb.NewRow();
row["ordercode"] = md.PlatOrderCode;
row["country"] = md.RevCountry;
row["Name"] = md.RevName;
row["Address"] = md.RevAddr;
row["City"] = md.RevCity;
row["State"] = md.RevProvince;
row["Zip"] = md.RevPostCode;
if (md.RevPhone != null && md.RevPhone != "")
row["TEL"] = md.RevPhone;
else if (md.RevMoblie != null && md.RevMoblie != "")
row["TEL"] = md.RevMoblie;
string ginfo = "";
decimal weight = 0;
decimal Long = 0;
decimal Width = 0;
decimal Height = 0;
string ginfo2 = "";
int Num = 0;
if (GoodsList != null)
{
var dlist = GoodsList.FindAll(n => n.OrderId == md.OrderId);
if (dlist != null)
{
foreach (var gmd in dlist)
{
Num += gmd.GoodsNum.Value;
ginfo += gmd.GoodsNum + "x" + gmd.OldTypeDesc + ",";
ginfo2 += gmd.GoodsNum + "x" + gmd.GoodsOldCode + ",";
if (gmd.Weight != null)
weight += gmd.Weight.Value * gmd.GoodsNum.Value;
if (gmd.Long2 != null)
{
if (gmd.Long2 > Long)
Long = gmd.Long2.Value;
}
else if (gmd.Long != null)
{
if (gmd.Long.Value * Convert.ToDecimal(0.3937008) > Long)
Long = gmd.Long.Value * Convert.ToDecimal(0.3937008);
}
if (gmd.Width2 != null)
{
if (gmd.Width2 > Width)
Width = gmd.Width2.Value;
}
else if (gmd.Width != null)
{
if (gmd.Width.Value * Convert.ToDecimal(0.3937008) > Width)
Width = gmd.Width.Value * Convert.ToDecimal(0.3937008);
}
if (gmd.Height2 != null)
{
if (gmd.Height2 > Height)
Height = gmd.Height2.Value;
}
else if (gmd.Height != null)
{
if (gmd.Height.Value * Convert.ToDecimal(0.3937008) > Height)
Height = gmd.Height.Value * Convert.ToDecimal(0.3937008);
}
}
row["SKU"] = ginfo.TrimEnd(',');
row["GoodsCode2"] = ginfo2.TrimEnd(',');
}
}
row["QTY"] = Num.ToString();
row["Weight"] = weight.ToString("0.00");
row["W"] = Width.ToString("0.00");
row["L"] = Long.ToString("0.00");
row["D"] = Height.ToString("0.00");
tb.Rows.Add(row);
}
}
// country Name Address 1 City State Zip TEL SKU QTY Weight(oz) W(inch) L D Service Type Dept Note
TableColumnCollection listColumns = new TableColumnCollection();
listColumns.Add("ordercode", "order #", DbType.String, "");
listColumns.Add("country", "country", DbType.String, "");
listColumns.Add("Name", "Name", DbType.String, "");
listColumns.Add("Address", "Address 1", DbType.String, "");
listColumns.Add("City", "City", DbType.String, "");
listColumns.Add("State", "State", DbType.String, "");
listColumns.Add("Zip", "Zip", DbType.String, "");
listColumns.Add("TEL", "TEL", DbType.String, "");
listColumns.Add("SKU", "SKU", DbType.String, "");
listColumns.Add("GoodsCode2", "GoodsCode2", DbType.String, "");
listColumns.Add("QTY", "QTY", DbType.String, "");
listColumns.Add("Weight", "Weight(oz)", DbType.String, "");
listColumns.Add("W", "W(inch)", DbType.String, "");
listColumns.Add("L", "L", DbType.String, "");
listColumns.Add("D", "D", DbType.String, "");
listColumns.Add("Service", "Service Type", DbType.String, "");
listColumns.Add("Note", "Dept Note", DbType.String, "");
MicrosoftExcel obj2 = new MicrosoftExcel();
return obj2.Export(tb, listColumns);
}
#endregion
#region 全部订单锁定匹配货物
[WebMethod(EnableSession = true)]
public string AllOrderGoodsLockForTM6(int IsError, int StoreId, int StoreId2)
{
PagesNew.Login(this.Session);
var obj = new DD_OrderData();
int Num = 0;
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
int UserId = Convert.ToInt32(Session["UserId"]);
bool bk = BaseService.SyncLock(CompanyId, 2, UserId, DateTime.Now);
if (bk == false)
return "当前有其他人正在操作库存匹配,为保证库存数据准确您暂时无法尝试此操作";
try
{
string Sort = "a.OrderLevel desc,a.OrderDate";
obj.SetStore();//仓库调整
var orderlist = obj.GetLockOrderListForTM4(CompanyId, IsError, StoreId, Sort);
var list = obj.GetLockOrderGoodsForTM4(CompanyId, StoreId, IsError);
var KClist = DataNew.GetNowKCGoods5(IsError, StoreId, StoreId2);
var nfplist = obj.GetNoFPOrderList();
List mlist = new List();
if (orderlist != null && list != null && KClist != null && orderlist.Count > 0 && list.Count > 0 && KClist.Count > 0)
{
var hwlist2 = new List();
var OrderMatelist = new List();
List JoinOrderList = new List();
foreach (var ordermd in orderlist)
{
//if (ordermd.OrderId == 5329133)
//{
// string a = "";
//}
string JoinOrderCode = "";
if (ordermd.JoinOrderCode != null && ordermd.JoinOrderCode != "")
JoinOrderCode = ordermd.JoinOrderCode;
if (JoinOrderCode != "")
{
if (JoinOrderList != null && JoinOrderList.Count > 0)
{
var jmd = JoinOrderList.Find(n => n.JoinOrderCode == JoinOrderCode);
DT_OrderMateKCOrder nmd = null;
if (nfplist != null && nfplist.Count > 0)
nmd = nfplist.Find(n => n.JoinOrderCode == JoinOrderCode);
if (jmd != null || nmd != null)
continue;
else
{
var jmd1 = new DT_OrderMateKCGoods();
jmd1.JoinOrderCode = JoinOrderCode;
JoinOrderList.Add(jmd1);
}
}
else
{
var jmd1 = new DT_OrderMateKCGoods();
jmd1.JoinOrderCode = JoinOrderCode;
JoinOrderList.Add(jmd1);
}
}
List listGoods = new List();
List OutList = new List();
var Goodslist = new List();
if (JoinOrderCode == "")
Goodslist = list.FindAll(n => n.OrderId == ordermd.OrderId);
else //合并订单
Goodslist = list.FindAll(n => n.JoinOrderCode == JoinOrderCode);
if (Goodslist != null && Goodslist.Count > 0)
{
var hwlist1 = new List();
bool qbFlag = true;//全部货物满足
bool Flag = false;//全部货物满足
foreach (var goodsmd in Goodslist)
{
int DDNum = goodsmd.GoodsNum.Value;
int LeftNum = DDNum;
List kcmdlist = new List();
if (StoreId == 5)
{
kcmdlist = KClist.FindAll(n => n.PostionCode == ordermd.ShopName && n.DetailId == goodsmd.DetailId && n.KCNum - n.LockNum > 0);
}
else
{
kcmdlist = KClist.FindAll(n => n.DetailId == goodsmd.DetailId && n.KCNum - n.LockNum > 0);
kcmdlist = kcmdlist.OrderBy(s => s.SortNo).ThenBy(s => s.PostionId).ToList();
}
if (kcmdlist == null || kcmdlist.Count == 0)
{
qbFlag = false;
Flag = false;
continue;
}
foreach (var kcmd in kcmdlist)
{
if (kcmd.KCNum - kcmd.LockNum >= LeftNum)
{
kcmd.LockNum += LeftNum;
var ckmd = new DT_OrderNowKCGoods();
ckmd.OrderNum = LeftNum;
ckmd.InId = kcmd.InId;
ckmd.OrderId = ordermd.OrderId;
ckmd.OrderGoodsId = goodsmd.Id;
ckmd.StoreId = kcmd.StoreId;
ckmd.PostionId = kcmd.PostionId;
ckmd.DetailId = kcmd.DetailId;
hwlist1.Add(ckmd);
LeftNum = 0;
break;
}
else
{
var ckmd = new DT_OrderNowKCGoods();
ckmd.OrderNum = kcmd.KCNum.Value - kcmd.LockNum.Value;
ckmd.InId = kcmd.InId;
ckmd.OrderId = ordermd.OrderId;
ckmd.OrderGoodsId = goodsmd.Id;
ckmd.StoreId = kcmd.StoreId;
ckmd.PostionId = kcmd.PostionId;
ckmd.DetailId = kcmd.DetailId;
hwlist1.Add(ckmd);
LeftNum = LeftNum - kcmd.KCNum.Value + kcmd.LockNum.Value;
kcmd.LockNum = kcmd.KCNum;
}
}
if (LeftNum <= 0)
{
Flag = true;
goodsmd.IsMate = 1;
}
else
{
qbFlag = false;
Flag = false;
goodsmd.IsMate = 0;
}
}
if (qbFlag == true && Flag == true)
{
mlist.Add(ordermd);
ordermd.IsMate = 1;
if (hwlist1 != null)
{
foreach (var hmd in hwlist1)
{
hwlist2.Add(hmd);
}
}
}
else
{
foreach (var hmd in hwlist1)
{
var opmd = new HW_OrderMate();
opmd.InId = hmd.InId;
opmd.Num = hmd.OrderNum;
opmd.DetailId = hmd.DetailId;
opmd.GoodsOrderId = hmd.OrderGoodsId;
opmd.StoreId = hmd.StoreId;
opmd.PostionId = hmd.PostionId;
OrderMatelist.Add(opmd);
}
hwlist1.Clear();
}
}
}
// var olist=orderlist.FindAll(n=>n.IsMate==1);
if (mlist != null)
{
Num = mlist.Count;
//string OrderIds = "";
// string JoinOrderCodes = "";
foreach (var omd in mlist)
{
int OrderId = 0;
string JoinOrderCode = "";
if (omd.JoinOrderCode != null && omd.JoinOrderCode != "")
JoinOrderCode = omd.JoinOrderCode;
else
OrderId = omd.OrderId.Value;
var cklist = hwlist2.FindAll(n => n.OrderId == omd.OrderId);
if (cklist != null && cklist.Count > 0)
DataNew.UpdateOrderGoodsLockForTM3(OrderId, JoinOrderCode, cklist);
}
//if (OrderIds != "" || JoinOrderCodes != "")
// obj.UpdateOrderGoodsLockForTM31(OrderIds.Trim(','), JoinOrderCodes.Trim(','));
}
obj.DeleteOrderMate();
if (OrderMatelist != null)
{
foreach (var mmd in OrderMatelist)
{
obj.SaveOrderMate(mmd);
}
}
}
}
catch (Exception ex)
{
BaseService.UnSyncLock(CompanyId, 2, DateTime.Now);
return ex.Message;
}
BaseService.UnSyncLock(CompanyId, 2, DateTime.Now);
return "匹配" + Num.ToString() + "条";
}
#endregion
#region 选择订单锁定匹配货物
[WebMethod(EnableSession = true)]
public string PartOrderGoodsLockForTM4(int IsError, int StoreId, int StoreId2, string OrderIds, string JoinOrderCodes)
{
PagesNew.Login(this.Session);
var obj = new DD_OrderData();
int Num = 0;
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
int UserId = Convert.ToInt32(Session["UserId"]);
bool bk = BaseService.SyncLock(CompanyId, 2, UserId, DateTime.Now);
if (bk == false)
return "当前有其他人正在操作库存分配,为保证库存数据准确您暂时无法尝试此操作";
try
{
string Sort = "a.OrderLevel desc,a.OrderDate";
var orderlist = obj.GetLockPartOrderListForTM2(CompanyId, OrderIds.Trim(','), JoinOrderCodes.Trim(','), IsError, StoreId, Sort);
var list = obj.GetLockPartOrderGoodsForTM2(CompanyId, OrderIds.Trim(','), JoinOrderCodes.Trim(','), StoreId, IsError);
var nfplist = obj.GetNoFPOrderList();
if (orderlist != null && list != null)
{
var hwlist = new List(); //货物占用
var hwlist2 = new List();
var hwnolist = new List(); //不够的货物
List JoinOrderList = new List();
foreach (var ordermd in orderlist)
{
string JoinOrderCode = "";
if (ordermd.JoinOrderCode != null && ordermd.JoinOrderCode != "")
JoinOrderCode = ordermd.JoinOrderCode;
List listGoods = new List();
List OutList = new List();
var Goodslist = new List();
if (JoinOrderCode == "")
Goodslist = list.FindAll(n => n.OrderId == ordermd.OrderId);
else //合并订单
Goodslist = list.FindAll(n => n.JoinOrderCode == JoinOrderCode);
if (JoinOrderCode != "")
{
if (JoinOrderList != null && JoinOrderList.Count > 0)
{
var jmd = JoinOrderList.Find(n => n.JoinOrderCode == JoinOrderCode);
DT_OrderMateKCOrder nmd = null;
if (nfplist != null && nfplist.Count > 0)
nmd = nfplist.Find(n => n.JoinOrderCode == JoinOrderCode);
if (jmd != null || nmd != null)
continue;
else
{
var jmd1 = new DT_OrderGoods();
jmd1.JoinOrderCode = JoinOrderCode;
JoinOrderList.Add(jmd1);
}
}
else
{
var jmd1 = new DT_OrderGoods();
jmd1.JoinOrderCode = JoinOrderCode;
JoinOrderList.Add(jmd1);
}
}
if (Goodslist != null)
{
bool Flag = false; //匹配标记
bool qbFlag = true;//全部货物满足
foreach (var goodsmd in Goodslist)
{
int ZYNum = 0;//占用数量
int DDNum = goodsmd.GoodsNum.Value;//订单数量
if (hwnolist != null)
{
var hwnodetail = hwnolist.Find(n => n.DetailId == goodsmd.DetailId);
if (hwnodetail != null)//已经在没有库存记录里
{
Flag = false;
qbFlag = false;
continue;
}
}
if (hwlist != null)
{
var hwdetail = hwlist.Find(n => n.DetailId == goodsmd.DetailId);
if (hwdetail != null)//已经在没有满足库存记录里
{
ZYNum = hwdetail.KCNum.Value;
}
}
List inlist = null;
if (StoreId == 5)
{
inlist = DataNew.GetMateOrderGoodsInForTM35(goodsmd.DetailId.Value, StoreId, ordermd.ShopName);
}
else
{
inlist = DataNew.GetMateOrderGoodsInForTM34(goodsmd.DetailId.Value, StoreId2);
}
if (inlist == null || inlist.Count == 0)//没有库存
{
Flag = false;
qbFlag = false;
HW_GoodsOutDetail hwnomd = new HW_GoodsOutDetail();
hwnomd.DetailId = goodsmd.DetailId;
hwnolist.Add(hwnomd);
continue;
}
int LeftNum = DDNum;
foreach (var kcmd in inlist)
{
if (kcmd.KCNum.Value >= LeftNum + ZYNum)
{
HW_GoodsInDetail hwinmd = new HW_GoodsInDetail();
hwinmd.DetailId = goodsmd.DetailId;
hwinmd.InId = kcmd.InId;
hwinmd.Price = kcmd.Price;
hwinmd.PostPrice = kcmd.PostPrice;
hwinmd.OrderGoodsId = goodsmd.Id;
hwinmd.KCNum = LeftNum;
hwlist2.Add(hwinmd);
LeftNum = 0;
break;
}
else
if (kcmd.KCNum.Value < LeftNum + ZYNum)
{
HW_GoodsInDetail hwinmd = new HW_GoodsInDetail();
hwinmd.DetailId = goodsmd.DetailId;
hwinmd.InId = kcmd.InId;
hwinmd.Price = kcmd.Price;
hwinmd.PostPrice = kcmd.PostPrice;
hwinmd.OrderGoodsId = goodsmd.Id;
hwinmd.KCNum = kcmd.KCNum.Value;
hwlist2.Add(hwinmd);
LeftNum = LeftNum - kcmd.KCNum.Value;
}
}
if (LeftNum == 0) //够分配
{
Flag = true;
}
else //不够分配
{
Flag = false;
qbFlag = false;
var bgmd = hwlist.Find(n => n.DetailId == goodsmd.DetailId);
if (bgmd != null)
{
bgmd.KCNum += DDNum;
}
else
{
var bgmd1 = new HW_GoodsInDetail();
bgmd1.KCNum = DDNum;
hwlist.Add(bgmd1);
}
}
}
if (Flag == true && qbFlag == true)//已经分配
{
decimal GoodsFee = 0; //货物采购均价
decimal PostFee = 0;//货物快递成本
if (hwlist2 != null)
{
Num++;
//int Num = hwlist2.Count;
foreach (var md in hwlist2)
{
if (md.Price != null)
GoodsFee += md.Price.Value * md.KCNum.Value;
if (md.PostPrice != null)
PostFee += md.PostPrice.Value * md.KCNum.Value;
}
//if (Num > 0)
//{
// GoodsFee = GoodsFee / Num;
// PostFee = PostFee / Num;
//}
}
DataNew.UpdateOrderGoodsLockForTM2(ordermd.OrderId.Value, 2, GoodsFee, PostFee, JoinOrderCode, hwlist2);
hwlist2.Clear();
}
else //未分配
{
if (hwlist2 != null)
{
foreach (var md in hwlist2)
{
var bgmd = hwlist.Find(n => n.DetailId == md.DetailId);
if (bgmd != null)
{
bgmd.KCNum += md.KCNum.Value;
}
else
{
var bgmd1 = new HW_GoodsInDetail();
bgmd1.KCNum = md.KCNum.Value;
hwlist.Add(bgmd1);
}
}
hwlist2.Clear();
}
}
}
}
}
}
catch (Exception ex)
{
BaseService.UnSyncLock(CompanyId, 2, DateTime.Now);
return ex.Message;
}
BaseService.UnSyncLock(CompanyId, 2, DateTime.Now);
return "匹配" + Num.ToString() + "条";
}
#endregion
#region 判断是否是数字
[WebMethod(EnableSession = true)]
public int CheckNum(string str)
{
try
{
string count = str.Trim();
str = count.PadLeft(5, '0');
str = str.Substring(0, 5);
int temp = Convert.ToInt32(str);
return 1;
}
catch
{
return 0;
}
}
#endregion
#region 查询订单
[WebMethod(EnableSession = true)]
public JsonModel> GetListOrderPrintForTM(int PlatType, int IsWeight, int ShopId, int DateType, DateTime? SDate, DateTime? EDate, int OutDays, int TjType, string Name, int PrintState, int State, int IsSku, int IsError, int IsDetail, int HBOrder, int LogicId, int PostId, int IsAddr, int IsFP, string KWCode, string GoodsInfo, int TrackState, int FHState, int GM, int SNum, int ENum, int PageIndex, int PageSize, String Sort, string PostionCode, string PostionCode2, int StoreId)
{
PagesNew.Login(this.Session);
var obj = new DD_OrderData();
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
RefParameterCollection Param = new RefParameterCollection();
if (IsFP > -1)
Param.Add("isnull(a.BillPrint,0)", "=", IsFP, DbType.Int32);
Param.Add("a.CompanyId", "=", CompanyId, DbType.Int32);
Param.Add("a.MateState", "=", 2, DbType.Int32);
if (PlatType > 0)
Param.Add("a.PlatId", "=", PlatType, DbType.Int32);
if (ShopId > 0)
Param.Add("a.ShopId", "=", ShopId, DbType.Int32);
if (TrackState == 1)
{
Param.Add("b.TrackState", ">", 0, DbType.Int32);
if (PostId == 0)
Param.Add("b.Post", ">", 0, DbType.Int32);
}
else
if (TrackState == 0)
{
Param.Add("b.TrackState", "=", 0, DbType.Int32);
}
if (DateType == 1)
{
if (SDate != null)
Param.Add("a.OrderDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.OrderDate", "<=", EDate, DbType.DateTime);
}
else
if (DateType == 2)
{
if (SDate != null)
Param.Add("a.InDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.InDate", "<=", EDate, DbType.DateTime);
}
else
if (DateType == 3)
{
if (SDate != null)
Param.Add("a.PrintDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.PrintDate", "<=", EDate, DbType.DateTime);
}
else
if (DateType == 4)
{
if (SDate != null)
Param.Add("a.PostDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.PostDate", "<=", EDate, DbType.DateTime);
}
else
if (DateType == 5)
{
if (SDate != null)
Param.Add("a.OrderOutDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.OrderOutDate", "<=", EDate, DbType.DateTime);
}
if (OutDays > 0)
{
Param.Add("a.OrderOutDate", "<=", DateTime.Today.AddDays(OutDays), DbType.DateTime);
}
if (PrintState == -1 && FHState > -1)
{
Param.Add("a.poststate", "=", FHState, DbType.Int32);
if (IsError == 1)
{
Param.Add("isnull(b.ErrorInfo,'')", "<>", "", DbType.String);
}
}
else
{
if (IsError == 1)
{
Param.Add("(a.PostState", "=", 2, DbType.Int32);
Param.Add("isnull(b.ErrorInfo,'')", "<>", "", "or", ")", DbType.String);
}
else
Param.Add("a.PostState", "<", 2, DbType.Int32);
}
if (PrintState > -1)
Param.Add("a.PrintState", "=", PrintState, DbType.Int32);
if (PrintState > -1)
Param.Add("a.State", "=", 1, DbType.Int32);
else
{
Param.Add("a.State", ">", 0, DbType.Int32);
Param.Add("a.State", "<", 3, DbType.Int32);
//Param.Add("b.RevPhone", "is", null, "or",")",DbType.String);
}
if (LogicId == -2)
Param.Add("b.LogisticsId", "in", "10,13", DbType.String);
else
if (LogicId > 0)
Param.Add("b.LogisticsId", "=", LogicId, DbType.Int32);
if (PostId > 0)
Param.Add("b.Post", "=", PostId, DbType.Int32);
if (HBOrder == 1)
Param.Add("a.IsJoin", "=", 1, DbType.Int32);
//if (IsError == 1)
//{
// Param.Add("(b.SendAddr", ">", 0, DbType.Int32);
// Param.Add("b.IsLeaveWord", "=", 1, "or", ")", DbType.Int32);
//}
if (IsAddr > -1)
{
Param.Add("b.SendAddr", "=", IsAddr, DbType.Int32);
}
string TCode = "";
if (Name != "")
{
Name = Name.Trim();
if (TjType == 1)
{
Param.Add("(a.PlatOrderCode", "=", Name, DbType.String);
Param.Add("a.JoinOrderCode", "=", Name, "or", ")", DbType.String);
}
else if (TjType == 2)
{
Param.Add("b.RevName", "like", Name, DbType.String);
}
else if (TjType == 3)
{
Param.Add("b.RevPhone", "like", Name, DbType.String);
}
else if (TjType == 4)
{
Param.Add("(b.RevCountry", "=", Name, DbType.String);
Param.Add("b.CountryName", "=", Name, "or", DbType.String);
Param.Add("b.CountryCode", "=", Name, "or", ")", DbType.String);
}
else if (TjType == 5)
{
Param.Add("b.RevPostCode", "=", Name, DbType.String);
}
else if (TjType == 6)
{
Param.Add("(b.RevAddr", "like", Name, DbType.String);
Param.Add("b.RevProvince", "like", Name, "or", DbType.String);
Param.Add("b.RevCity", "like", Name, "or", DbType.String);
Param.Add("b.RevArea", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 9)
{
Param.Add("(b.ErrorInfo", "like", Name, DbType.String);
Param.Add("b.PostError", "like", Name, "or", ")", DbType.String);
}
else if (TjType == 10)
{
// Param.Add("b.TrackCode", "like", Name, DbType.String);
TCode = Name;
}
}
if (StoreId > 0)
{
if (StoreId == 6)
{
Param.Add("b.StoreId", "in", "6,9", DbType.String);
}
else
Param.Add("b.StoreId", "=", StoreId, DbType.Int32);
}
//if (IsError == 2)
//{
// Param.Add("(a.SendAddr", ">", 0, DbType.Int32);
// Param.Add("a.IsLeaveWord", "=", 1, "or", ")", DbType.Int32);
//}
if (IsWeight == 2)
{
Param.Add("isnull(a.IsSpare,0)", "=", 1, DbType.Int32);
}
else
if (IsWeight == 1)
{
Param.Add("isnull(a.IsSpare,0)", "=", 0, DbType.Int32);
}
//if (IsSku == 0)
// Param.Add("a.FPDate", "is", null, DbType.String);
//else if (IsSku == 1)
// Param.Add("a.FPDate", "is not", null, DbType.String);
//Param.Add("a.OrderDate", ">=", 0, DbType.Int32);
JsonModel> resultModel = new JsonModel>();
int RowCount = 0;
//string Sort = "orderid desc";
//if (PrintState == 0)
// Sort = "orderid";
string GoodsName = "";
string Code = "";
if (GoodsInfo != "")
{
GoodsName = GoodsInfo.Trim();
if (GoodsInfo.Trim().Contains(' '))
{
GoodsName = GoodsInfo.Trim().Split(' ')[0].Trim();
Code = GoodsInfo.Trim().Split(' ')[1].Trim();
}
}
//else
// if (TjType == 8 && Name != "")
// {
// SKU = Name;
// }
List orderlist = new List();
List ordertemp = new List();
if (PrintState > -1)
orderlist = DataNew.GetListDT_PrintOrderInfoForTM2(CompanyId, TCode, GoodsName, 0, Code, KWCode, IsSku, GM, PrintState, Param, PageIndex, PageSize, Sort, out RowCount);
else
orderlist = DataNew.GetListDT_PrintOrderInfoForTM(CompanyId, TCode, GoodsName, 0, Code, KWCode, IsSku, Param, PageIndex, PageSize, Sort, out RowCount);
string Ids = "";
if (orderlist != null)
{
foreach (var md in orderlist)
{
Ids += md.OrderId.ToString() + ",";
if (IsError > 0)
{
if (IsError == 3)
{
int check = CheckNum(md.RevPostCode);
if (check == 0)
{
ordertemp.Add(md);
}
}
else if (IsError == 2)
{
int check = CheckNum(md.RevPostCode);
if (check == 1 && md.ErrorInfo == "")
{
ordertemp.Add(md);
}
}
else
{
ordertemp.Add(md);
}
}
else
{
ordertemp.Add(md);
}
}
}
orderlist = new List();
if (Ids != "")
{
JC_ExpressService obj3 = new JC_ExpressService();
// var elist = obj3.GetExpressTypeList();
var plist = obj3.GetExpressList();
var errorlist = obj.GetErrorList(Ids.Trim(','));
if (errorlist != null || plist != null)
{
foreach (var md in ordertemp)
{
if (errorlist != null && errorlist.Count > 0)
{
var emd = errorlist.Find(n => n.OrderId == md.OrderId);
if (emd != null)
{
md.ErrorInfo = emd.ErrorInfo;
}
}
if (md.Post > 0 && plist != null && plist.Count > 0)
{
var emd = plist.Find(n => n.ExpressID == md.Post);
if (emd != null)
{
md.PostInfo = emd.Name;
}
}
}
}
}
if (IsDetail == 0 && ordertemp != null)
{
if (Ids != "")
{
var listTrack = obj.GetTrackCodeApplyList2(Ids.Trim(','));
if (listTrack != null)
{
foreach (var md in ordertemp)
{
var list3 = new List();
if (md.JoinOrderCode != null && md.JoinOrderCode != "")
list3 = listTrack.FindAll(n => n.OrderCode == md.JoinOrderCode);
else
list3 = listTrack.FindAll(n => n.OrderId == md.OrderId);
if (list3 != null && list3.Count > 0)
{
string trackinfo = "";
int tcount = 0;
foreach (var md1 in list3)
{
if (md1.TrackType < 3)
{
trackinfo += md1.TrackCode + "
";
tcount++;
}
}
if (IsWeight == 1 && tcount > 1 && IsError == 2)
{
ordertemp.Remove(md);
}
if (IsError == 5 && IsWeight == 1 && tcount > 1)
{
orderlist.Add(md);
}
md.TrackCode = trackinfo;
}
}
}
}
}
else
if (IsDetail == 1 && ordertemp != null)
{
if (Ids != "")
{
var listTrack = obj.GetTrackCodeApplyList2(Ids.Trim(','));
// ErrorFollow.TraceWrite("GetOrderGoodsPostionList", Ids, DateTime.Now.ToString("HH:mm:ss fff"));
var list1 = DataNew.GetOrderGoodsPostionList(Ids.Trim(','));
// ErrorFollow.TraceWrite("GetOrderGoodsPostionList", "2", DateTime.Now.ToString("HH:mm:ss fff"));
if (list1 != null)
{
foreach (var md in ordertemp)
{
md.OrderLevel = 0;
md.OrderName = "";
md.GoodsCode = "";
var list2 = list1.FindAll(n => n.OrderId == md.OrderId);
if (list2 != null)
{
md.GoodsList = list2;
md.IsBlank = 0;
if (PostionCode != "")
{
var pmd = list2.Find(n => n.PostionCode.Contains(PostionCode) == true);
if (pmd != null)
md.IsBlank = 1;
}
if (list2.Count > 0)
{
md.OrderLevel = list2[0].LockNum;
md.OrderName = list2[0].PostionCode;
md.GoodsCode = list2[0].GoodsCode;
}
if (SNum > 0 && ENum == 0)
{
if (list2.Sum(o => o.GoodsNum).GetValueOrDefault(0) >= SNum)
{
orderlist.Add(md);
}
}
if (SNum > 0 && ENum > 0)
{
if (list2.Sum(o => o.GoodsNum).GetValueOrDefault(0) >= SNum && list2.Sum(o => o.GoodsNum).GetValueOrDefault(0) <= ENum)
{
orderlist.Add(md);
}
}
if (SNum == 0 && ENum > 0)
{
if (list2.Sum(o => o.GoodsNum).GetValueOrDefault(0) <= ENum)
{
orderlist.Add(md);
}
}
}
var list3 = new List();
if (listTrack != null)
{
if (md.JoinOrderCode != null && md.JoinOrderCode != "")
list3 = listTrack.FindAll(n => n.OrderCode == md.JoinOrderCode);
else
list3 = listTrack.FindAll(n => n.OrderId == md.OrderId);
}
if (list3 != null && list3.Count > 0)
{
string trackinfo = "";
int tcount = 0;
foreach (var md1 in list3)
{
if (md1.TrackType < 3)
{
trackinfo += md1.TrackCode + "
";
tcount++;
}
}
if (IsWeight == 1 && tcount > 1 && IsError == 2)
{
ordertemp.Remove(md);
}
if (IsError == 5 && IsWeight == 1 && tcount > 1)
{
orderlist.Add(md);
}
md.TrackCode = trackinfo;
}
}
}
}
}
// ErrorFollow.TraceWrite("GetOrderGoodsPostionList", "3", DateTime.Now.ToString("HH:mm:ss fff"));
if (IsError == 5) ordertemp = orderlist;
if (orderlist != null)
{
if (orderlist.Count() > 0)
ordertemp = orderlist;
}
if (PostionCode2 != "")
{
ordertemp = ordertemp.FindAll(n => n.IsBlank == 0);
}
else
if (PostionCode != "")
{
ordertemp = ordertemp.FindAll(n => n.IsBlank == 1);
}
// ErrorFollow.TraceWrite("GetOrderGoodsPostionList", "4", DateTime.Now.ToString("HH:mm:ss fff"));
List orderList2 = new List();
// if (PostionCode == "" || PostionCode2 != "")
// orderList2 = ordertemp.OrderBy(s => s.OrderLevel).ThenBy(s => s.OrderName).ThenBy(s => s.GoodsCode).ToList();
// else
var query = from s in ordertemp
orderby s.OrderLevel, s.OrderName, s.GoodsCode, s.GoodsNum descending //排序
select s;
orderList2 = query.ToList();
//orderList2 = orderList2.OrderBy(s => s.OrderName).ToList();
//orderList2 = orderList2.OrderBy(s => s.GoodsCode).ToList();
//orderList2 = orderList2.OrderByDescending(s => s.GoodsNum).ToList();
// ErrorFollow.TraceWrite("GetOrderGoodsPostionList", "5", DateTime.Now.ToString("HH:mm:ss fff"));
resultModel.DataSource = orderList2.Take(PageSize).Skip(PageSize * (PageIndex - 1)).ToList();
int count = 0;
if (orderList2 != null) count = orderList2.Count();
resultModel.RowCount = count;
return resultModel;
}
#endregion
#region 修改货物
[WebMethod(EnableSession = true)]
public void UpdateOrderGoodsListForTM(int GoodsNum, int OrderId)
{
PagesNew.Login(this.Session);
var obj = new DD_OrderData();
DataNew.UpdateOrderBuyDateForTM2(OrderId, GoodsNum);
}
#endregion
[WebMethod(EnableSession = true)]
public string GetFedexFee2(DT_OrderModelNew omd, List glist, int PostId, string PostType)
{
Pages.Login(base.Session);
int companyId = Convert.ToInt32(base.Session["CompanyId"]);
JC_ExpressService service = new JC_ExpressService();
JC_PostAddress address = new BaseService().GetAddressModel2(PostId);
JC_ExpressPost expressModel = service.GetExpressModel(companyId, PostId);
decimal num2 = 0M;
string Width = "";
string Height = "";
string Lenght = "";
if (glist != null)
{
Width = Math.Ceiling(glist[0].Width2.Value).ToString();
Height = Math.Ceiling(glist[0].Height2.Value).ToString();
Lenght = Math.Ceiling(glist[0].Length2.Value).ToString();
foreach (DT_OrderMateGoods goods in glist)
{
decimal? nullable;
if (!(goods.Weight.HasValue && !(((nullable = goods.Weight).GetValueOrDefault() <= 0M) && nullable.HasValue)))
{
return (goods.GoodsName + "重量没填,无法计算");
}
if (goods.Width2.HasValue)
{
nullable = goods.Width2;
if (!((nullable.GetValueOrDefault() <= 0M) && nullable.HasValue) && goods.Length2.HasValue)
{
nullable = goods.Length2;
}
}
if ((((nullable.GetValueOrDefault() <= 0M) && nullable.HasValue) || !goods.Height2.HasValue) || (((nullable = goods.Height2).GetValueOrDefault() <= 0M) && nullable.HasValue))
{
return (goods.GoodsName + "长宽高没填,无法计算");
}
num2 += goods.Weight.Value * goods.GoodsNum.Value;
}
}
TradeManageNew.FedexRateNew rate = new TradeManageNew.FedexRateNew();
TradeManageNew.FedexRateNew.Key = expressModel.UserCode;
TradeManageNew.FedexRateNew.Password = expressModel.CheckCode;
TradeManageNew.FedexRateNew.AccountNumber = expressModel.client_id;
TradeManageNew.FedexRateNew.MeterNumber = expressModel.client_secret;
TradeManageNew.FedexRateNew.PayAccountNumber = expressModel.refresh_token;
TradeManageNew.FedexRateNew.HubId = expressModel.Code;
TradeManageNew.FedexRateNew.PostId = PostId;
TradeManageNew.FedexFeeMdNew md = new TradeManageNew.FedexFeeMdNew
{
RevName = omd.RevName,
RevPhone = omd.RevPhone
};
if ((omd.RevPhone == null) || (omd.RevPhone == ""))
{
md.RevPhone = omd.RevMoblie;
}
md.OrderId = omd.OrderId;
md.PostType = PostType;
md.SendAddr = address.EnglishAddress;
md.SendCountry = address.countycode;
md.SendCity = address.city;
md.SendProv = address.provincecode;
md.SendPostCode = address.PostCode;
md.RevAddr = omd.RevAddr;
md.RevCity = omd.RevCity;
if ((omd.RevCity == null) || (omd.RevCity == ""))
{
md.RevCity = omd.RevProvince;
}
if ((omd.RevProvinceCode != null) && (omd.RevProvinceCode != ""))
{
md.RevProv = omd.RevProvinceCode;
}
else if (((omd.RevProvince != null) && (omd.RevProvince != "")) && (omd.RevProvince.Length > 2))
{
md.RevProv = omd.RevProvince.Substring(omd.RevProvince.Length - 2, 2);
}
else
{
md.RevProv = omd.RevProvince;
}
md.RevPostCode = omd.RevPostCode;
md.RevCountry = omd.CountryCode;
md.Width = Math.Ceiling(glist[0].Width2.Value).ToString();
md.Height = Math.Ceiling(glist[0].Height2.Value).ToString();
md.Lenght = Math.Ceiling(glist[0].Length2.Value).ToString();
md.Weight = new decimal?(num2);
string outError = "";
string fee = rate.GetFee(md, out outError);
if (outError != "")
{
return outError;
}
return fee;
}
#region 获取Fedex多种运输方式的运费
[WebMethod(EnableSession = true)]
public List GetFedexFeeDetail(DT_OrderModelNew omd,List glist)
{
Pages.Login(base.Session);
var rmodel=new List();
var postTypes = new List() { "SMART_POST", "FEDEX_2_DAY", "FEDEX_GROUND", "GROUND_HOME_DELIVERY" };
var postIds = new List() { 228, 237 };//W仓,E仓
foreach(var postId in postIds)
{
int companyId = Convert.ToInt32(base.Session["CompanyId"]);
JC_ExpressService service = new JC_ExpressService();
JC_PostAddress address = new BaseService().GetAddressModel2(postId);
JC_ExpressPost expressModel = service.GetExpressModel(companyId, postId);
decimal num2 = 0M;
string Width = "";
string Height = "";
string Lenght = "";
if (glist != null)
{
Width = Math.Ceiling(glist[0].Width2.Value).ToString();
Height = Math.Ceiling(glist[0].Height2.Value).ToString();
Lenght = Math.Ceiling(glist[0].Length2.Value).ToString();
foreach (DT_OrderMateGoods goods in glist)
{
decimal? nullable;
if (!(goods.Weight.HasValue && !(((nullable = goods.Weight).GetValueOrDefault() <= 0M) && nullable.HasValue)))
{
return rmodel;
}
if (goods.Width2.HasValue)
{
nullable = goods.Width2;
if (!((nullable.GetValueOrDefault() <= 0M) && nullable.HasValue) && goods.Length2.HasValue)
{
nullable = goods.Length2;
}
}
if ((((nullable.GetValueOrDefault() <= 0M) && nullable.HasValue) || !goods.Height2.HasValue) || (((nullable = goods.Height2).GetValueOrDefault() <= 0M) && nullable.HasValue))
{
return rmodel;
}
num2 += goods.Weight.Value * goods.GoodsNum.Value;
}
}
TradeManageNew.FedexRateNew3 rate = new TradeManageNew.FedexRateNew3();
TradeManageNew.FedexRateNew3.Key = expressModel.UserCode;
TradeManageNew.FedexRateNew3.Password = expressModel.CheckCode;
TradeManageNew.FedexRateNew3.AccountNumber = expressModel.client_id;
TradeManageNew.FedexRateNew3.MeterNumber = expressModel.client_secret;
TradeManageNew.FedexRateNew3.PayAccountNumber = expressModel.refresh_token;
TradeManageNew.FedexRateNew3.HubId = expressModel.Code;
TradeManageNew.FedexRateNew3.PostId = postId;
TradeManageNew.FedexFeeMdNew md = new TradeManageNew.FedexFeeMdNew
{
RevName = omd.RevName,
RevPhone = omd.RevPhone
};
if ((omd.RevPhone == null) || (omd.RevPhone == ""))
{
md.RevPhone = omd.RevMoblie;
}
md.OrderId = omd.OrderId;
//md.PostType = PostType;
md.SendAddr = address.EnglishAddress;
md.SendCountry = address.countycode;
md.SendCity = address.city;
md.SendProv = address.provincecode;
md.SendPostCode = address.PostCode;
md.RevAddr = omd.RevAddr;
md.RevCity = omd.RevCity;
if ((omd.RevCity == null) || (omd.RevCity == ""))
{
md.RevCity = omd.RevProvince;
}
if ((omd.RevProvinceCode != null) && (omd.RevProvinceCode != ""))
{
md.RevProv = omd.RevProvinceCode;
}
else if (((omd.RevProvince != null) && (omd.RevProvince != "")) && (omd.RevProvince.Length > 2))
{
md.RevProv = omd.RevProvince.Substring(omd.RevProvince.Length - 2, 2);
}
else
{
md.RevProv = omd.RevProvince;
}
md.RevPostCode = omd.RevPostCode;
md.RevCountry = omd.CountryCode;
md.Width = Math.Ceiling(glist[0].Width2.Value).ToString();
md.Height = Math.Ceiling(glist[0].Height2.Value).ToString();
md.Lenght = Math.Ceiling(glist[0].Length2.Value).ToString();
md.Weight = new decimal?(num2);
foreach (var postType in postTypes)
{
md.PostType = postType;
var feeObj = rate.GetFee(md);
if (feeObj != null)
{
rmodel.Add(feeObj);
}
Thread.Sleep(1000);
}
}
return rmodel;
}
[WebMethod(EnableSession = true)]
public List GetFedexFeeDetail2(DT_OrderModelNew omd, List glist,string postType)
{
Pages.Login(base.Session);
var rmodel = new List();
var postIds = new List() { 228, 237 };//W仓,E仓
foreach (var postId in postIds)
{
int companyId = Convert.ToInt32(base.Session["CompanyId"]);
JC_ExpressService service = new JC_ExpressService();
JC_PostAddress address = new BaseService().GetAddressModel2(postId);
JC_ExpressPost expressModel = service.GetExpressModel(companyId, postId);
decimal num2 = 0M;
string Width = "";
string Height = "";
string Lenght = "";
if (glist != null)
{
Width = Math.Ceiling(glist[0].Width2.Value).ToString();
Height = Math.Ceiling(glist[0].Height2.Value).ToString();
Lenght = Math.Ceiling(glist[0].Length2.Value).ToString();
foreach (DT_OrderMateGoods goods in glist)
{
decimal? nullable;
if (!(goods.Weight.HasValue && !(((nullable = goods.Weight).GetValueOrDefault() <= 0M) && nullable.HasValue)))
{
return rmodel;
}
if (goods.Width2.HasValue)
{
nullable = goods.Width2;
if (!((nullable.GetValueOrDefault() <= 0M) && nullable.HasValue) && goods.Length2.HasValue)
{
nullable = goods.Length2;
}
}
if ((((nullable.GetValueOrDefault() <= 0M) && nullable.HasValue) || !goods.Height2.HasValue) || (((nullable = goods.Height2).GetValueOrDefault() <= 0M) && nullable.HasValue))
{
return rmodel;
}
num2 += goods.Weight.Value * goods.GoodsNum.Value;
}
}
TradeManageNew.FedexRateNew3 rate = new TradeManageNew.FedexRateNew3();
TradeManageNew.FedexRateNew3.Key = expressModel.UserCode;
TradeManageNew.FedexRateNew3.Password = expressModel.CheckCode;
TradeManageNew.FedexRateNew3.AccountNumber = expressModel.client_id;
TradeManageNew.FedexRateNew3.MeterNumber = expressModel.client_secret;
TradeManageNew.FedexRateNew3.PayAccountNumber = expressModel.refresh_token;
TradeManageNew.FedexRateNew3.HubId = expressModel.Code;
TradeManageNew.FedexRateNew3.PostId = postId;
TradeManageNew.FedexFeeMdNew md = new TradeManageNew.FedexFeeMdNew
{
RevName = omd.RevName,
RevPhone = omd.RevPhone
};
if ((omd.RevPhone == null) || (omd.RevPhone == ""))
{
md.RevPhone = omd.RevMoblie;
}
md.OrderId = omd.OrderId;
md.PostType = postType;
md.SendAddr = address.EnglishAddress;
md.SendCountry = address.countycode;
md.SendCity = address.city;
md.SendProv = address.provincecode;
md.SendPostCode = address.PostCode;
md.RevAddr = omd.RevAddr;
md.RevCity = omd.RevCity;
if ((omd.RevCity == null) || (omd.RevCity == ""))
{
md.RevCity = omd.RevProvince;
}
if ((omd.RevProvinceCode != null) && (omd.RevProvinceCode != ""))
{
md.RevProv = omd.RevProvinceCode;
}
else if (((omd.RevProvince != null) && (omd.RevProvince != "")) && (omd.RevProvince.Length > 2))
{
md.RevProv = omd.RevProvince.Substring(omd.RevProvince.Length - 2, 2);
}
else
{
md.RevProv = omd.RevProvince;
}
md.RevPostCode = omd.RevPostCode;
md.RevCountry = omd.CountryCode;
md.Width = Math.Ceiling(glist[0].Width2.Value).ToString();
md.Height = Math.Ceiling(glist[0].Height2.Value).ToString();
md.Lenght = Math.Ceiling(glist[0].Length2.Value).ToString();
md.Weight = new decimal?(num2);
var feeObj = rate.GetFee(md);
if (feeObj != null)
{
rmodel.Add(feeObj);
}
}
return rmodel;
}
#endregion
[WebMethod(EnableSession = true)]
public string GetFedexFee22(DT_OrderModel omd, DT_OrderMateGoods gmd, int PostId, string PostType)
{
Pages.Login(base.Session);
int companyId = Convert.ToInt32(base.Session["CompanyId"]);
JC_ExpressService service = new JC_ExpressService();
JC_PostAddress address = new BaseService().GetAddressModel2(PostId);
JC_ExpressPost expressModel = service.GetExpressModel(companyId, PostId);
decimal num2 = 0M;
var goods = gmd;
decimal? nullable;
if (!(goods.Weight.HasValue && !(((nullable = goods.Weight).GetValueOrDefault() <= 0M) && nullable.HasValue)))
{
return (goods.GoodsName + "重量没填,无法计算");
}
if (goods.Width2.HasValue)
{
nullable = goods.Width2;
if (!((nullable.GetValueOrDefault() <= 0M) && nullable.HasValue) && goods.Length2.HasValue)
{
nullable = goods.Length2;
}
}
if ((((nullable.GetValueOrDefault() <= 0M) && nullable.HasValue) || !goods.Height2.HasValue) || (((nullable = goods.Height2).GetValueOrDefault() <= 0M) && nullable.HasValue))
{
return (goods.GoodsName + "长宽高没填,无法计算");
}
num2 += goods.Weight.Value * goods.GoodsNum.Value;
TradeManageNew.FedexRateNew rate = new TradeManageNew.FedexRateNew();
TradeManageNew.FedexRateNew.Key = expressModel.UserCode;
TradeManageNew.FedexRateNew.Password = expressModel.CheckCode;
TradeManageNew.FedexRateNew.AccountNumber = expressModel.client_id;
TradeManageNew.FedexRateNew.MeterNumber = expressModel.client_secret;
TradeManageNew.FedexRateNew.PayAccountNumber = expressModel.refresh_token;
TradeManageNew.FedexRateNew.HubId = expressModel.Code;
TradeManageNew.FedexFeeMdNew md = new TradeManageNew.FedexFeeMdNew
{
RevName = omd.RevName,
RevPhone = omd.RevPhone
};
if ((omd.RevPhone == null) || (omd.RevPhone == ""))
{
md.RevPhone = omd.RevMoblie;
}
md.OrderId = -1;
md.OrderGoodsId = gmd.Id;
md.PostType = PostType;
md.SendAddr = address.EnglishAddress;
md.SendCountry = address.countycode;
md.SendCity = address.city;
md.SendProv = address.provincecode;
md.SendPostCode = address.PostCode;
md.RevAddr = omd.RevAddr;
md.RevCity = omd.RevCity;
if ((omd.RevCity == null) || (omd.RevCity == ""))
{
md.RevCity = omd.RevProvince;
}
if ((omd.RevProvinceCode != null) && (omd.RevProvinceCode != ""))
{
md.RevProv = omd.RevProvinceCode;
}
else if (((omd.RevProvince != null) && (omd.RevProvince != "")) && (omd.RevProvince.Length > 2))
{
md.RevProv = omd.RevProvince.Substring(omd.RevProvince.Length - 2, 2);
}
else
{
md.RevProv = omd.RevProvince;
}
md.RevPostCode = omd.RevPostCode;
md.RevCountry = omd.CountryCode;
md.Width = Math.Ceiling(gmd.Width2.Value).ToString();
md.Height = Math.Ceiling(gmd.Height2.Value).ToString();
md.Lenght = Math.Ceiling(gmd.Length2.Value).ToString();
md.Weight = new decimal?(num2);
string outError = "";
string fee = rate.GetFee(md, out outError);
if (outError != "")
{
return outError;
}
return fee;
}
[WebMethod(EnableSession = true)]
public string GetFedexFee33(DT_OrderModelNew omd, List list, int PostId, string PostType)
{
PagesNew.Login(base.Session);
if (list == null)
return "";
int UserId = Convert.ToInt32(Session["UserId"]);
JC_ExpressService service = new JC_ExpressService();
JC_PostAddress address = new BaseService().GetAddressModel2(PostId);
JC_ExpressPost expressModel = service.GetExpressModel(1, PostId);
TradeManageNew.FedexRateNew rate = new TradeManageNew.FedexRateNew();
TradeManageNew.FedexRateNew.Key = expressModel.UserCode;
TradeManageNew.FedexRateNew.Password = expressModel.CheckCode;
TradeManageNew.FedexRateNew.AccountNumber = expressModel.client_id;
TradeManageNew.FedexRateNew.MeterNumber = expressModel.client_secret;
TradeManageNew.FedexRateNew.PayAccountNumber = expressModel.refresh_token;
TradeManageNew.FedexRateNew.HubId = expressModel.Code;
TradeManageNew.FedexRateNew.PostId = PostId;
TradeManageNew.FedexFeeMdNew md = new TradeManageNew.FedexFeeMdNew
{
RevName = omd.RevName,
RevPhone = omd.RevPhone
};
if ((omd.RevPhone == null) || (omd.RevPhone == ""))
{
md.RevPhone = omd.RevMoblie;
}
md.OrderId = omd.OrderId;
md.OrderGoodsId = 1;
md.PostType = PostType;
md.SendAddr = address.EnglishAddress;
md.SendCountry = address.countycode;
md.SendCity = address.city;
md.SendProv = address.provincecode;
md.SendPostCode = address.PostCode;
md.RevAddr = omd.RevAddr;
md.RevCity = omd.RevCity;
if ((omd.RevCity == null) || (omd.RevCity == ""))
{
md.RevCity = omd.RevProvince;
}
if ((omd.RevProvinceCode != null) && (omd.RevProvinceCode != ""))
{
md.RevProv = omd.RevProvinceCode;
}
else if (((omd.RevProvince != null) && (omd.RevProvince != "")) && (omd.RevProvince.Length > 2))
{
md.RevProv = omd.RevProvince.Substring(omd.RevProvince.Length - 2, 2);
}
else
{
md.RevProv = omd.RevProvince;
}
md.RevPostCode = omd.RevPostCode;
md.RevCountry = omd.CountryCode;
//DataNew.Delete_SpareFee(omd.OrderId.Value);
string error = "";
string fee = "";
foreach (var gmd in list)
{
gmd.OrderId = omd.OrderId;
gmd.InDate = DateTime.Now;
gmd.InUserId = UserId;
// int Id = DataNew.Save_SpareFee(gmd);
md.OrderGoodsId = gmd.Id.Value;
md.Width = Math.Ceiling(Convert.ToDecimal(gmd.Width)).ToString();
md.Height = Math.Ceiling(Convert.ToDecimal(gmd.Height)).ToString();
md.Lenght = Math.Ceiling(Convert.ToDecimal(gmd.Long)).ToString();
md.Weight = Math.Ceiling(Convert.ToDecimal(gmd.Weight));
string outError = "";
fee += rate.GetFee(md, out outError);
System.Threading.Thread.Sleep(1000);
if (outError != "")
{
error += outError;
}
}
//DataNew.Delete_SpareFee2(omd.OrderId.Value);
DataNew.Sum_SpareFee(PostId,omd.OrderId.Value, PostType);
if (error != "")
return error;
else
return fee;
}
[WebMethod(EnableSession = true)]
public string GetUPSFee(DT_OrderModelNew omd, List glist, int PostId, string PostType)
{
PagesNew.Login(base.Session);
int companyId = Convert.ToInt32(base.Session["CompanyId"]);
JC_ExpressService service = new JC_ExpressService();
JC_PostAddress address = new BaseService().GetAddressModel2(PostId);
JC_ExpressPost expressModel = service.GetExpressModel(companyId, PostId);
decimal num2 = 0M;
int totalNum = 0;
if (glist != null)
{
foreach (DT_OrderMateGoods goods in glist)
{
decimal? nullable;
if (!(goods.Weight.HasValue && !(((nullable = goods.Weight).GetValueOrDefault() <= 0M) && nullable.HasValue)))
{
return (goods.GoodsName + "重量没填,无法计算");
}
//if (goods.Width2.HasValue)
//{
// nullable = goods.Width2;
// if (!((nullable.GetValueOrDefault() <= 0M) && nullable.HasValue) && goods.Length2.HasValue)
// {
// nullable = goods.Length2;
// }
//}
//if ((((nullable.GetValueOrDefault() <= 0M) && nullable.HasValue) || !goods.Height2.HasValue) || (((nullable = goods.Height2).GetValueOrDefault() <= 0M) && nullable.HasValue))
//{
// return (goods.GoodsName + "长宽高没填,无法计算");
//}
num2 += goods.Weight.Value * goods.GoodsNum.Value;
totalNum += goods.GoodsNum.Value;
}
}
TradeManageNew.UPSRate rate = new TradeManageNew.UPSRate();
TradeManageNew.UPSRate.AccessLicenseNumber = expressModel.client_id;
TradeManageNew.UPSRate.Username = expressModel.UserCode;
TradeManageNew.UPSRate.Password = expressModel.CheckCode;
TradeManageNew.UPSRate.ShipperNumber = expressModel.Code;
TradeManageNew.FedexFeeMdNew md = new TradeManageNew.FedexFeeMdNew
{
RevName = omd.RevName,
RevPhone = omd.RevPhone
};
if ((omd.RevPhone == null) || (omd.RevPhone == ""))
{
md.RevPhone = omd.RevMoblie;
}
md.OrderId = omd.OrderId;
md.PostType = PostType;
md.packType = "02";
md.SendAddr = address.EnglishAddress;
md.SendCountry = address.countycode;
md.SendCity = address.city;
md.SendProv = address.provincecode;
md.SendPostCode = address.PostCode;
md.RevAddr = omd.RevAddr;
md.RevCity = omd.RevCity;
if ((omd.RevCity == null) || (omd.RevCity == ""))
{
md.RevCity = omd.RevProvince;
}
if ((omd.RevProvinceCode != null) && (omd.RevProvinceCode != ""))
{
md.RevProv = omd.RevProvinceCode;
}
else if (((omd.RevProvince != null) && (omd.RevProvince != "")) && (omd.RevProvince.Length > 2))
{
md.RevProv = omd.RevProvince.Substring(omd.RevProvince.Length - 2, 2);
}
else
{
md.RevProv = omd.RevProvince;
}
md.RevPostCode = omd.RevPostCode;
md.RevCountry = omd.CountryCode;
md.Width = Math.Ceiling(glist[0].Width2.Value).ToString();
md.Height = Math.Ceiling(glist[0].Height2.Value).ToString();
md.Lenght = Math.Ceiling(glist[0].Length2.Value).ToString();
md.Weight = num2*0.0625M;
md.TotalNum = totalNum.ToString();
string outError = "";
string fee = rate.GetFeeNew(md);
//if (fee != "")
//{
// return outError;
//}
//获取到的ups运费更新到订单中
if (!fee.Contains("ErrorMessage:"))
{
var infos = fee.Split('&');
DataNew.UpdateOrderUPSPostFee(omd.OrderId.Value, string.IsNullOrEmpty(infos[0]) ? 0 : Convert.ToDecimal(infos[0]), PostId, infos[1]);
}
else
{
DataNew.UpdateOrderUPSLog(omd.OrderId.Value, fee);
}
return fee;
}
[WebMethod(EnableSession = true)]
public string SaveOrderSpare(int OrderId, List list)
{
PagesNew.Login(base.Session);
if (list == null)
return "";
int UserId = Convert.ToInt32(Session["UserId"]);
foreach (var gmd in list)
{
gmd.OrderId =OrderId;
gmd.InDate = DateTime.Now;
gmd.InUserId = UserId;
int Id = DataNew.Save_SpareFee(gmd);
}
return "";
}
[WebMethod(EnableSession = true)]
public void DeketeOrderSpare(int Id)
{
PagesNew.Login(base.Session);
DataNew.Delete_SpareFee3(Id);
}
#region 亚马逊上传跟踪码
[WebMethod(EnableSession = true)]
public string AmazonTrack(List list)
{
PagesNew.Login(this.Session);
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
int UserId = Convert.ToInt32(Session["UserId"]);
string str = "";
BaseService obj1 = new BaseService();
ApiNew.Amazonapinew obj = new ApiNew.Amazonapinew();
AmazonNewApi obj3 = new AmazonNewApi();
DD_OrderData obj2 = new DD_OrderData();
Amazon_SPApi obj4 = new Amazon_SPApi();
string ordecodes = "";
foreach (var md in list)
{
ordecodes += "'" + md.PlatOrderCode + "',";
}
var glist = DataNew.GetAmGoodsList(ordecodes.TrimEnd(','));
try
{
string error = "";
if (list != null)
{
int PostId = 0;
JC_Shop shopmodel = JC_ShopService.GetModel(list[0].ShopId.Value);
JC_Express emd = null;
if (shopmodel == null)
return "店铺未授权";
if (shopmodel.Code == "new2")
{
// obj3.SellerId = shopmodel.Appkey;
// obj3.MWSAuthToken = shopmodel.AccessToken;// ShopModel.AccessToken;
obj4.SellerId = shopmodel.Appkey;
//obj2.MWSAuthToken = "amzn.mws.94ba1459-809f-6157-a36f-967c9209c99b";// ShopModel.AccessToken;
obj4.SumoolToKen = shopmodel.AccessToken;//obj2.marketplaceId = "ATVPDKIKX0DER";// ShopModel.DeveKey;
// obj3.SumoolToKen = shopmodel.RefreshToken;//obj2.marketplaceId = "ATVPDKIKX0DER";// ShopModel.DeveKey;
obj4.country = shopmodel.Country;
obj4.MarketplaceId = shopmodel.DeveKey;
foreach (var md in list)
{
if (md.TrackCode == null || md.TrackCode == "")
{
str = str + md.PlatOrderCode + ";";
continue;
}
if (md.TrackCode != "" && md.TrackCode.Contains(","))
md.TrackCode = md.TrackCode.Split(',')[0];
if (PostId != md.Post.Value)
emd = obj1.GetExpressModel(md.Post.Value, CompanyId);
PostId = md.Post.Value;
string carrname = md.PostInfo2;
if (emd.Remark != null && emd.Remark != "")
carrname = emd.Remark;
md.serviceName = carrname;
if (glist != null)
{
var gmd = glist.FindAll(n => n.OrderCode == md.PlatOrderCode);
md.BackGoodsList = gmd;
}
}
//obj.GetFeedSubmissionResult("54888017651");
bool a = obj4.createFeedDocument(list, out error);
}
else
if (shopmodel.Code == "new")
{
obj3.SellerId = shopmodel.Appkey;
obj3.MWSAuthToken = shopmodel.AccessToken;// ShopModel.AccessToken;
obj3.SumoolToKen = shopmodel.RefreshToken;//obj2.marketplaceId = "ATVPDKIKX0DER";// ShopModel.DeveKey;
obj3.country = shopmodel.Country;
foreach (var md in list)
{
if (md.TrackCode == null || md.TrackCode == "")
{
str = str + md.PlatOrderCode + ";";
continue;
}
if (md.TrackCode != "" && md.TrackCode.Contains(","))
md.TrackCode = md.TrackCode.Split(',')[0];
if (PostId != md.Post.Value)
emd = obj1.GetExpressModel(md.Post.Value, CompanyId);
PostId = md.Post.Value;
string carrname = md.PostInfo2;
if (emd.Remark != null && emd.Remark != "")
carrname = emd.Remark;
md.serviceName = carrname;
if (glist != null)
{
var gmd = glist.FindAll(n => n.OrderCode == md.PlatOrderCode);
md.BackGoodsList = gmd;
}
//if (md.BackGoodsList == null || md.BackGoodsList.Count <= 0)
//{
// //str += md.PlatOrderCode + "货物明细没有,";
// return md.PlatOrderCode + "货物明细没有,";
//}
//obj.UploadAMOrder(md.PlatOrderCode, md.serviceName, md.TrackCode,md.BackGoodsList[0].GoodsDesc, 1);
// List list2 = new List();
// list2.Add(md);
// string error = "";
// a = obj.UploadAMOrder2(list2,out error);
// if(error!="")
// str += md.PlatOrderCode+error+";";
}
//obj.GetFeedSubmissionResult("54888017651");
bool a = obj3.UploadAMOrder2(list, out error);
}
else
{
obj.accessKeyId = shopmodel.RefreshToken;
obj.secretAccessKey = shopmodel.AccessToken;
obj.merchantId = shopmodel.Appkey;
obj.marketplaceId = shopmodel.DeveKey;
obj.country = shopmodel.Country;
obj.MWSAuthToken = shopmodel.Code;
foreach (var md in list)
{
if (md.TrackCode == null || md.TrackCode == "")
{
str = str + md.PlatOrderCode + ";";
continue;
}
if (md.TrackCode != "" && md.TrackCode.Contains(","))
md.TrackCode = md.TrackCode.Split(',')[0];
if (PostId != md.Post.Value)
emd = obj1.GetExpressModel(md.Post.Value, CompanyId);
PostId = md.Post.Value;
string carrname = md.PostInfo2;
if (emd.Remark != null && emd.Remark != "")
carrname = emd.Remark;
md.serviceName = carrname;
if (glist != null)
{
var gmd = glist.FindAll(n => n.OrderCode == md.PlatOrderCode);
md.BackGoodsList = gmd;
}
//if (md.BackGoodsList == null || md.BackGoodsList.Count <= 0)
//{
// //str += md.PlatOrderCode + "货物明细没有,";
// return md.PlatOrderCode + "货物明细没有,";
//}
//obj.UploadAMOrder(md.PlatOrderCode, md.serviceName, md.TrackCode,md.BackGoodsList[0].GoodsDesc, 1);
// List