You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ERP/ERPOMS/DD_OrderServiceNew.asmx.cs

2754 lines
115 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using NetLibrary.Data;
using NetLibrary.Express;
using NetLibrary.OnlineTrade;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using TradeData;
using TradeManage;
using TradeManageNew;
using TradeModel;
using System.Threading;
namespace ERPOMS
{
/// <summary>
/// DD_OrderServiceNew 的摘要说明
/// </summary>
[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 JsonModel<List<DT_OrderListNew>> 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<List<DT_OrderListNew>> model = new JsonModel<List<DT_OrderListNew>>();
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<int> shopids = new List<int>();
DateTime? maxDate = null, minDate = null;
var wlist = DataNew.GetExpressList();
List<DT_OrderModelNew> maplist = null;
if (model.DataSource != null)
{
foreach (DT_OrderListNew md in model.DataSource)
{
ids += md.OrderId.ToString() + ",";
if (md.Post != null && md.Post > 0)
{
var wlmd = wlist.Find(n => n.ExpressID == md.Post);
if (wlmd != null)
{
md.TrackInfo = wlmd.Name;
}
}
if (md.StoreId == 11)
md.RevFax = "E";
else
md.RevFax = "W";
if (md.ShopId.HasValue)
shopids.Add(md.ShopId.Value);
//if (maplist != null && md.RevProvince != null && md.RevProvince != "")
//{
// var mmd = maplist.Find(n => n.code == md.RevProvince.ToUpper() || n.ename == md.RevProvince);
// if (mmd != null)
// {
// if (mmd.IsEast == 1)
// {
// md.RevFax = "E";
// }
// else
// md.RevFax = "W";
// }
//}
}
maxDate = model.DataSource.OrderByDescending(r => r.OrderDate.Value).First().OrderDate.Value;
minDate = model.DataSource.OrderBy(r => r.OrderDate.Value).First().OrderDate.Value;
}
var linklist = new List<HW_BuyLinkNew>();
if (ids != "")
{
maplist = DataNew.GetListUSMap4(ids.Trim(','));
List<DT_OrderError> errorList = DataNew.GetErrorList(ids.Trim(','));
linklist = DataNew.GetListMBLinkOrder(ids.Trim(','));
if ((errorList != null) && (errorList.Count > 0))
{
foreach (var md in model.DataSource)
{
DT_OrderError error = errorList.Find(n => n.OrderId == md.OrderId);
if (error != null)
{
md.ErrorInfo = error.ErrorInfo;
}
}
}
}
if (shopids != null && shopids.Count > 0)
shopids = shopids.Distinct().ToList();
List<DT_OrderBackMoneyApply> saleBackModelList = null;
List<DT_Fees> flist = null;
if ((IsDetail == 1) && (model.DataSource != null))
{
int? trackType;
if (ids != "")
{
List<DT_OrderGoodsListNew> orderGoodsList = DataNew.GetOrderGoodsListNew2_New(ids.Trim(','));
List<DT_TrackCodeApply> trackCodeApplyList = DataNew.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<HW_JZLink> JZLinklist = DataNew.GetListJZLinkOrder(ids.Trim(','));
List<GoodAD_LastWeek_Spend> adSpendList = DataNew.GetAllGoodWeekAdSpend();
//List<OrderListGoodAdfee> 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<DT_OrderGoodsListNew> list5 = orderGoodsList.FindAll(n => n.OrderId == md.OrderId);
var totalAdfee = 0m;//订单广告总花费
var hyfcj = 0m;//海运费差价
if (list5 != null)
{
md.GoodsList = list5;
foreach (var mdg in md.GoodsList)
{
if (mdg.WestNum < mdg.GoodsNum)
kcW = false;
if (mdg.EastNum < mdg.GoodsNum)
kcE = false;
if (mdg.GoodsId.HasValue && md.ShopId.HasValue)
{
if (adSpendList != null)
{
var adspend = adSpendList.Where(r => r.shopid == md.ShopId.Value && r.goodsid == mdg.GoodsId.Value).FirstOrDefault();
mdg.goodWeekAdFee = adspend == null ? 0 : (adspend.spend.HasValue ? adspend.spend.Value : 0);
}
if (last2DayadFees != null)
{
var last2DayFee = last2DayadFees.Where(r => r.shopid == md.ShopId.Value && r.goodsid == mdg.GoodsId.Value).FirstOrDefault();
mdg.last2DayAdFee = last2DayFee == null ? 0 : (last2DayFee.spend.HasValue ? last2DayFee.spend.Value : 0);
}
//if (orderGoodsAdList != null)
//{
// var adFee = orderGoodsAdList.Where(r => r.OrderDate == md.OrderDate.Value.ToString("yyyy-MM-dd") && r.ShopId == md.ShopId && r.GoodsId == mdg.GoodsId.Value).FirstOrDefault();
// mdg.goodWeekAdFee = adFee == null ? 0 : (adFee.AvgAdfee.HasValue ? adFee.AvgAdfee.Value : 0);
//}
}
else
{
mdg.goodWeekAdFee = 0;
mdg.last2DayAdFee = 0;
}
totalAdfee = totalAdfee + (mdg.adfee.HasValue ? mdg.adfee.Value : 0);
hyfcj += (mdg.GoodsNum.HasValue && mdg.Solid2.HasValue) ? (mdg.GoodsNum.Value * mdg.Solid2.Value) : 0;
}
if (pmlist != null)
{
foreach (var mmd in list5)
{
var pmmd = pmlist.Find(n => n.asin == mmd.productImgUrl2 && n.ShopId == md.ShopId && n.OrderDate.Date == md.OrderDate.Value.Date);
if (pmmd != null)
{
string imgurl = "";
if (pmmd.Int10 != null && pmmd.Int10 == 1)
{
imgurl = "<img src='../image/up.jpg' width='40px' height='30px' gpm='" + mmd.productImgUrl2 + "' spm='" + md.ShopId + "' />";
}
if (pmmd.Int10 != null && pmmd.Int10 == 2)
{
imgurl = "<img src='../image/ph.jpg' width='40px' height='30px' gpm='" + mmd.productImgUrl2 + "' spm='" + md.ShopId + "' />";
}
if (pmmd.Int10 != null && pmmd.Int10 == 3)
{
imgurl = "<img src='../image/down.jpg' width='40px' height='30px' gpm='" + mmd.productImgUrl2 + "' spm='" + md.ShopId + "' />";
}
if (pmmd.Int3 < 100)
mmd.OldTypeDesc = "<font color='red' gpm=" + mmd.productImgUrl2 + " spm=" + md.ShopId + ">排名:" + pmmd.Int3.ToString();
else
mmd.OldTypeDesc = "<font gpm=" + mmd.productImgUrl2 + " spm=" + md.ShopId + ">排名:" + pmmd.Int3.ToString();
if (pmmd.Int2 != null)
mmd.OldTypeDesc += "/" + pmmd.Int2.ToString();
mmd.OldTypeDesc += "</font>" + imgurl;
}
else
mmd.OldTypeDesc = "";
}
}
}
md.TotalAdFee = totalAdfee;
//ups和fedex比较运费,再东西部都有库存的情况下UPS需要和Fedex的W仓和E仓两个二比较
//如果收货地址是Residential住宅区则UPS和Fedex的Smart_Post、GROUND_HOME_DELIVERY比较;
//如果收货地址是Commercial或者Officeups就和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<DT_TrackCodeApply> list6 = new List<DT_TrackCodeApply>();
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") + "<br/>";
}
string str9 = str5;
str5 = str9 + apply.TrackCode + str7 + "<br/>重量" + apply.Weight.ToString() + "g" + str8 + "<br/>";
}
else
{
str5 = str5 + apply.TrackCode + str7 + "<br/>";
}
if (str6 == "")
{
str6 = apply.TrackCode;
}
}
md.TrackInfo += str5;
md.TrackCode = str6;
}
}
}
decimal moneyrate = Convert.ToDecimal((double)6.5);
List<JC_Money> list7 = DataNew.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 += "<a><font style='color:blue'>" + lmd.SKU1 + ":【S】" + lmd.GoodsHJNum2 + "</font>";
// else
// jplink += "<a><font style='color:blue'>【S】" + lmd.GoodsHJNum2 + "</font>";
// if (lmd.Num != null)
// {
// if (lmd.GoodsHJNum2 >= lmd.Num)
// jplink += "<font style='color:red'>【TS】" + lmd.Num + "</font>";
// else
// jplink += "<font style='color:blue'>【TS】" + lmd.Num + "</font>";
// }
// jplink += "</a><br/>";
// if (pm2 > 0)
// jplink += "<a><font style='color:blue'>【R】" + pm2 + "</font>";
// else
// jplink += "<a><font style='color:blue'>【R】无</font>";
// if (lmd.PM != null)
// {
// if (pm2 > 0 && lmd.PM >= pm2)
// jplink += "<font style='color:red'>【TR】" + lmd.PM + "</font>";
// else
// jplink += "<font style='color:blue'>【TR】" + lmd.PM + "</font>";
// }
// jplink += "</a><br/>";
// }
// }
// 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 += "<a style='cursor: pointer;color:blue' target='_blank' href='" + jzmmd.LinkUrl + "'>竟品" + i.ToString() + "价格:" + jzmmd.Price.Value + "$</a><br/>";
// else
// jplink += "<a style='cursor: pointer;color:blue' target='_blank' href='" + jzmmd.LinkUrl + "'>竟品" + i.ToString() + "</a><br/>";
// i++;
// }
// }
// md.OrderName = jplink;
//}
#endregion
if (fmd.moneyrate != null)
moneyrate = fmd.moneyrate.Value;
else
{
JC_Money money = list7.Find(n => n.MCode == "USD" && n.PlatId == md.PlatId);
if (money != null)
{
moneyrate = money.MRate.Value;
}
else
{
money = list7.Find(n => n.MCode == "USD");
moneyrate = money.MRate.Value;
}
}
decimal TotalPrice = 0M;
if (md.TotalPrice != null)
{
TotalPrice = md.TotalPrice.Value;
}
decimal YJPrice = 0M;
decimal sjyf = 0;
if (fmd.sjyf != null)
sjyf = fmd.sjyf.Value;
decimal ygyf = 0;
if (fmd.yf != null)
ygyf = fmd.yf.Value;
md.PostFee = sjyf;
md.BoxFee = ygyf;
if (fmd.yj != null)
YJPrice = fmd.yj.Value;
decimal GoodsFee = 0;
if (fmd.sjcb != null)
GoodsFee = fmd.sjcb.Value;
if (fmd.sjhwsf != null)
GoodsFee += fmd.sjhwsf.Value;
if (moneyrate == 0)
moneyrate = 6.5M;
GoodsFee = GoodsFee / moneyrate;
decimal YJGoodsFee = 0;
if (fmd.cb != null)
YJGoodsFee = fmd.cb.Value;
if (fmd.hwsf != null)
YJGoodsFee += fmd.hwsf.Value;
md.Fee8 = 0;
md.Fee8 = fmd.ck;
decimal sjtc = 0;
if (fmd.sjtc == null || fmd.sjtc == 0)
sjtc = fmd.tc.Value;
else
sjtc = fmd.sjtc.Value;
YJGoodsFee = YJGoodsFee / moneyrate;
if (md.PlatId != 2)
md.TotalAdFee = fmd.Ad_Fee;
decimal LR = TotalPrice - YJPrice - fmd.escrowFee.Value - GoodsFee - sjyf - sjtc - fmd.DR_BackFee.Value - fmd.DR_PostFee.Value - fmd.Other_Fee.Value + fmd.DR_SSFee.Value - fmd.md.Value + fmd.SubsidyFee.Value - (md.TotalAdFee.HasValue ? md.TotalAdFee.Value : 0);
decimal YGLR = TotalPrice - YJPrice - fmd.escrowFee.Value - YJGoodsFee - ygyf - fmd.tc.Value - fmd.DR_PostFee.Value - fmd.Other_Fee.Value + fmd.DR_SSFee.Value - fmd.md.Value + fmd.SubsidyFee.Value - (md.TotalAdFee.HasValue ? md.TotalAdFee.Value : 0);
md.LR = new decimal?(Convert.ToDecimal(LR.ToString("0.00")));
md.YGLR = new decimal?(Convert.ToDecimal(YGLR.ToString("0.00")));
}
}
}
return model;
}
#endregion
#region 取消订单
[WebMethod(EnableSession = true)]
public string DeleteCancelOrderForTM(List<DT_Order> list)
{
PagesNew.Login(this.Session);
int InUserId = Convert.ToInt32(Session["UserId"]);
if (list == null || list.Count == 0)
return "";
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
string Name = Convert.ToString(Session["Name"]);
string error = "";
foreach (var md in list)
{
if (DataNew.IsOrderState(md.OrderId.Value) > 0)
{
error += md.PlatOrderCode + "已经匹配库存不能取消";
}
else
{
DataNew.DeleteCancelOrder2(md.OrderId.Value, InUserId);
DataNew.UpdateCancelOrderGoodsForTM2(md.OrderId.Value, Name, CompanyId);// 修改货物的订单数量(发货或者取消)
}
}
return error;
}
#endregion
#region 获取订单费用
[WebMethod(EnableSession = true)]
public DT_Fees GetModel_OrderFeeNew(int orderid)
{
PagesNew.Login(this.Session);
var md = DataNew.GetOrderFees(orderid.ToString());
if (md != null && md.Count > 0)
{
if (md[0].PlatId == 2)
{
var adfee = DataNew.GetOrderAdFeeByOrderID(orderid);
if (md != null && md.Count > 0)
{
md[0].Ad_Fee = adfee;
return md[0];
}
}
else
return md[0];
}
return null;
}
#endregion
#region 返回订单Model
[WebMethod(EnableSession = true)]
public DT_OrderModelNew GetOrderModelNew2(int OrderId)
{
PagesNew.Login(this.Session);
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
var md = DataNew.GetOrderModel2(OrderId);
if (md.CompanyId != CompanyId)
return null;
if (md.IsSpare == 1)
{
string TrackCodes = "";
var splist = DataNew.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 List<DT_OrderMateGoods> GetOrderGoodsListForTM(int OrderId)
{
PagesNew.Login(base.Session);
DD_OrderData data = new DD_OrderData();
List<DT_OrderMateGoods> orderGoodsListNew = DataNew.GetOrderGoodsListNew(OrderId);
DT_FeesTC TCModel = DataNew.GetModel_FeesTC();
decimal? tcfee = 0;
if (TCModel != null && TCModel.tc_fee != null)
tcfee = TCModel.tc_fee.Value;
decimal goodssolid = 0M;
if (orderGoodsListNew != null)
{
JC_Money money;
List<DT_OrderMateGoods>.Enumerator enumerator;
decimal? hWCFee;
decimal num4;
decimal? nullable3;
decimal num = Convert.ToDecimal((double)6.5);
List<JC_Money> list2 = DataNew.GetMoneyList2();
List<DT_OrderMateGoods> orderGoodsPostionCode = DataNew.GetOrderGoodsPostionCode(OrderId);
decimal num2 = 0M;
decimal num3 = 0M;
decimal hwsfee = 0M;
if ((orderGoodsPostionCode != null) && (orderGoodsPostionCode.Count > 0))
{
using (enumerator = orderGoodsListNew.GetEnumerator())
{
Predicate<JC_Money> match = null;
Predicate<DT_OrderMateGoods> 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<JC_Money> 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;
}
#region 查询订单跟踪码
[WebMethod(EnableSession = true)]
public List<DT_TrackCodeApplyNew> GetOrderTrackCodeList(int OrderId, string JoinOrderCode)
{
PagesNew.Login(this.Session);
var obj = new DD_OrderData();
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
var list = DataNew.GetOrderTrackCodeNew(OrderId, JoinOrderCode);
if (list != null)
{
foreach (var md in list)
{
md.SKUstr = md.SKU;
string sku = "";
sku += md.SKU;
if (md.Weight2 != null)
sku += md.Weight2 + "磅";
if (md.Long != null)
sku += "长:" + md.Long + "in";
if (md.Width != null)
sku += "宽:" + md.Width + "in";
if (md.Height != null)
sku += "高:" + md.Height + "in";
md.SKU = sku;
}
}
return list;
}
#endregion
#region 获取物流sku
[WebMethod(EnableSession = true)]
public List<DT_SpareFee> GetOrderFedexSKU3(int OrderId)
{
PagesNew.Login(this.Session);
var obj = new DD_OrderData();
var olist = DataNew.GetListSpareFee(OrderId);
return olist;
}
#endregion
#region 返回Model
[WebMethod(EnableSession = true)]
public DT_PostVote GetModel_PostVote(int OrderId)
{
PagesNew.Login(this.Session);
var Model = DataNew.GetModel_PostVote(OrderId);
return Model;
}
#endregion
#region 修改订单基础信息
[WebMethod(EnableSession = true)]
public string UpdateOrderBase2(DT_OrderModelSave Model)
{
Pages.Login(this.Session);
int UserId = Convert.ToInt32(Session["UserId"]);
DataNew.UpdateOrderBaseInfo23(Model);
Pages.SaveLog(UserId, "订单日志", "修改订单基本信息", Model.OrderId.Value);
return "";
}
#endregion
#region 修改地址
[WebMethod(EnableSession = true)]
public string UpdateOrderAddr2(DT_OrderModel Model)
{
Pages.Login(this.Session);
var obj = new DD_OrderData();
var md = DataNew.GetCountryCode(Model.CountryCode);
string error = "";
if (md == null || md.Code == null || md.Code == "")
{
error = "购买国家对应不到,请确定国家全称或者简称填写是否正确";
}
else
{
if (Model.RevPostCode != null)
Model.RevPostCode = Model.RevPostCode.Trim();
//if (md.Code == "US" && Model.RevPostCode.Length != 5)
//{
// error = "美国邮编必须是5位";
//}
//else if (md.Code == "RS" && Model.RevPostCode.Length != 6)
//{
// error = "俄罗斯邮编必须是6位";
//}
if (Model.CountryName == null || Model.CountryName == "")
{
Model.RevCountry = md.EnglishName;
Model.CountryName = md.CountryName;
}
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
int UserId = Convert.ToInt32(Session["UserId"]);
DataNew.UpdateOrderAddr2(Model);
Pages.SaveLog(UserId, "订单日志", "修改收件人地址信息", Model.OrderId.Value);
}
return error;
}
#endregion
#region 保存黑名单
[WebMethod(EnableSession = true)]
public int Save_BlackName(DT_BlackName Model)
{
PagesNew.Login(this.Session);
Model.userid = Convert.ToInt32(Session["UserId"]);
return DataNew.Save_BlackName(Model);
}
#endregion
#region 读取sku货物
[WebMethod(EnableSession = true)]
public List<HW_GoodsSKUModel> GetGoodsModelFromGoodsCode(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 = DataNew.GetGoodsModelFromGoodsCode(TJ, CompanyId, GoodsCode, TypeCode);
//string jsonString = new JavaScriptSerializer().Serialize(list);
return list;// jsonString;
}
#endregion
#region 修改货物
[WebMethod(EnableSession = true)]
public string UpdateOrderGoodsSKUForTM2(int OrderId, int Id, decimal? GoodsPrice, int GoodsNum, int DetailId, string GoodsSKU, string GoodsName, string GoodsCode, int GoodsId, string OldTypeCode)
{
Pages.Login(this.Session);
var obj = new DD_OrderData();
bool bk = BaseService.SyncLock3();
if (bk == false)
return "当前有其他人正在操作库存匹配,为保证库存数据准确您暂时无法操作";
int a = obj.IsOrderState(OrderId);
if (a > 0)
return "该订单已经匹配库存不能改分配";
string message = "";
string OldTypeDesc = "";
if (OldTypeCode != null && OldTypeCode != "")
{
string TypeDesc = DataNew.GetGoodsDetailTypeDesc(GoodsId, OldTypeCode);
if (TypeDesc == "")
{
return "找不到需要改成这个发货的型号";
}
else
{
OldTypeDesc = TypeDesc;
var temp = DataNew.GetGoodsDetailForTM(DetailId);
if (temp != null)
{
if (message == "") message = "注意:";
message += temp.TypeDesc + "改" + TypeDesc + "\r\n";
}
}
}
var list = DataNew.GetOrderChangeGoods(OrderId, Id);
int UserId = Convert.ToInt32(Session["UserId"]);
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
string Name = Convert.ToString(Session["Name"]);
obj.UpdateOrderGoodsSKUForTM2(Id, CompanyId, Name, OrderId, GoodsPrice, GoodsNum, DetailId, GoodsSKU, GoodsName, GoodsCode, OldTypeCode, OldTypeDesc);
// obj.UpdateOrderBuyDate(OrderId);
Pages.SaveLog(UserId, "订单日志", GoodsSKU + "修改分配", OrderId);
if (list != null)
{
foreach (var md in list)
{
var ulist = DataNew.GetOrderChangeNotice(md.DetailId.Value);
if (ulist != null)
{
foreach (var umd in ulist)
{
JC_OpenMess mess = new JC_OpenMess();
mess.InUserId = UserId;
mess.UserId = umd.UserId;
mess.UserType = "p";
mess.Content = "编号:" + md.GoodsCode + "型号:" + md.TypeCode + "描述:" + md.TypeDesc + "改分配,可能产生库存,请注意是否可以取消购买 From【" + Name + "】";
mess.IsRead = 0;
mess.OpenDate = DateTime.Now;
DataNew.SaveOpenMess(mess);
//mess = new JC_OpenMess();
//mess.InUserId = UserId;
//mess.UserId = 52;
//mess.UserType = "p";
//mess.Content = "编号:" + md.GoodsCode + "型号:" + md.TypeCode + "描述:" + md.TypeDesc + "改分配,可能产生库存,请注意是否可以取消购买 From【" + Name + "】";
//mess.IsRead = 0;
//mess.OpenDate = DateTime.Now;
//BaseService.SaveOpenMess(mess);
mess = new JC_OpenMess();
mess.InUserId = UserId;
mess.UserId = 70;
mess.UserType = "p";
mess.Content = "编号:" + md.GoodsCode + "型号:" + md.TypeCode + "描述:" + md.TypeDesc + "改分配,可能产生库存,请注意是否可以取消购买 From【" + Name + "】";
mess.IsRead = 0;
mess.OpenDate = DateTime.Now;
DataNew.SaveOpenMess(mess);
//mess = new JC_OpenMess();
//mess.InUserId = UserId;
//mess.UserId = 149;
//mess.UserType = "p";
//mess.Content = "编号:" + md.GoodsCode + "型号:" + md.TypeCode + "描述:" + md.TypeDesc + "改分配,可能产生库存,请注意是否可以取消购买 From【" + Name + "】";
//mess.IsRead = 0;
//mess.OpenDate = DateTime.Now;
//BaseService.SaveOpenMess(mess);
}
}
}
}
if (message != "") return message;
else
return "成功";
}
#endregion
#region 新增货物
[WebMethod(EnableSession = true)]
public string AddOrderGoodsSKUForTM2(List<DT_OrderGoods> list)
{
Pages.Login(this.Session);
string message = "";
if (list == null || list.Count == 0)
return "";
var obj = new DD_OrderData();
bool bk = BaseService.SyncLock3();
if (bk == false)
return "当前有其他人正在操作库存匹配,为保证库存数据准确您暂时无法操作";
int a = obj.IsOrderState(list[0].OrderId.Value);
if (a > 0)
return "该订单已经匹配库存,不能增加分配";
int UserId = Convert.ToInt32(Session["UserId"]);
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
string Name = Convert.ToString(Session["Name"]);
string error = "";
foreach (var md in list)
{
var obj1 = new HuoWuData();
if (md.OldTypeCode != null && md.OldTypeCode != "")
{
string TypeDesc = obj1.GetGoodsDetailTypeDesc(md.GoodsId.Value, md.OldTypeCode);
if (TypeDesc == "")
{
error += md.OldTypeCode + "找不到该型号;";
}
else
{
md.OldTypeDesc = TypeDesc;
var temp = DataNew.GetGoodsDetailForTM(md.DetailId.GetValueOrDefault(0));
if (temp != null)
{
if (message == "") message = "注意:";
message += temp.TypeDesc + "改" + TypeDesc + "\r\n";
}
}
}
}
if (error != "")
return error;
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);
}
return message;
}
#endregion
#region 取消分配
[WebMethod(EnableSession = true)]
public string UpdateOrderNoBuyForTM(int OrderId)
{
Pages.Login(this.Session);
bool bk = BaseService.SyncLock3();
if (bk == false)
return "当前有其他人正在操作库存匹配,为保证库存数据准确您暂时无法操作";
var obj = new DD_OrderData();
int b = obj.IsOrderState(OrderId);
if (b == 2)
{
return "订单状态已匹配不允许取消分配";
}
if (b == 1)
{
return "订单状态已经有匹配的货物,不允许取消分配,跟仓库联系";
}
var list = DataNew.GetOrderChangeGoods(OrderId, 0);
int UserId = Convert.ToInt32(Session["UserId"]);
string Name = Convert.ToString(Session["Name"]);
int a = obj.UpdateOrderNoBuyForTM(OrderId);
Pages.SaveLog(UserId, "订单日志", "取消货物分配", OrderId);
if (list != null)
{
foreach (var md in list)
{
var ulist = DataNew.GetOrderChangeNotice(md.DetailId.Value);
if (ulist != null)
{
foreach (var umd in ulist)
{
JC_OpenMess mess = new JC_OpenMess();
mess.UserId = umd.UserId;
mess.UserType = "p";
mess.Content = "编号:" + md.GoodsCode + "型号:" + md.TypeCode + "描述:" + md.TypeDesc + "取消分配,可能产生库存,请注意是否可以取消购买 From【" + Name + "】";
mess.IsRead = 0;
mess.OpenDate = DateTime.Now;
DataNew.SaveOpenMess(mess);
//mess = new JC_OpenMess();
//mess.UserId = 52;
//mess.UserType = "p";
//mess.Content = "编号:" + md.GoodsCode + "型号:" + md.TypeCode + "描述:" + md.TypeDesc + "取消分配,可能产生库存,请注意是否可以取消购买 From【" + Name + "】";
//mess.IsRead = 0;
//mess.OpenDate = DateTime.Now;
//BaseService.SaveOpenMess(mess);
mess = new JC_OpenMess();
mess.UserId = 70;
mess.UserType = "p";
mess.Content = "编号:" + md.GoodsCode + "型号:" + md.TypeCode + "描述:" + md.TypeDesc + "取消分配,可能产生库存,请注意是否可以取消购买 From【" + Name + "】";
mess.IsRead = 0;
mess.OpenDate = DateTime.Now;
DataNew.SaveOpenMess(mess);
}
}
}
}
return "成功";
}
#endregion
#region 删除货物
[WebMethod(EnableSession = true)]
public int DeleteOrderGoodsSKUForTM(int OrderId, int Id, string GoodsSKU, string GoodsName)
{
Pages.Login(this.Session);
var obj = new DD_OrderData();
bool bk = BaseService.SyncLock3();
if (bk == false)
return 3;//"当前有其他人正在操作库存匹配,为保证库存数据准确您暂时无法取消分配";
int a = obj.IsOrderState(OrderId);
if (a > 0)
return a;
var list = DataNew.GetOrderChangeGoods(OrderId, Id);
int UserId = Convert.ToInt32(Session["UserId"]);
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
string Name = Convert.ToString(Session["Name"]);
obj.DeleteOrderGoodsSKUForTM(Id, CompanyId, Name);
Pages.SaveLog(UserId, "订单日志", GoodsName + "[" + GoodsSKU + "]货物被删除", OrderId);
if (list != null)
{
foreach (var md in list)
{
var ulist = DataNew.GetOrderChangeNotice(md.DetailId.Value);
if (ulist != null)
{
foreach (var umd in ulist)
{
JC_OpenMess mess = new JC_OpenMess();
mess.UserId = umd.UserId;
mess.UserType = "p";
mess.Content = "编号:" + md.GoodsCode + "型号:" + md.TypeCode + "描述:" + md.TypeDesc + "取消分配,可能产生库存,请注意是否可以取消购买 From【" + Name + "】";
mess.IsRead = 0;
mess.OpenDate = DateTime.Now;
mess.InUserId = UserId;
DataNew.SaveOpenMess(mess);
mess = new JC_OpenMess();
mess.UserId = 52;
mess.UserType = "p";
mess.Content = "编号:" + md.GoodsCode + "型号:" + md.TypeCode + "描述:" + md.TypeDesc + "取消分配,可能产生库存,请注意是否可以取消购买 From【" + Name + "】";
mess.IsRead = 0;
mess.InUserId = UserId;
mess.OpenDate = DateTime.Now;
DataNew.SaveOpenMess(mess);
mess = new JC_OpenMess();
mess.UserId = 70;
mess.UserType = "p";
mess.Content = "编号:" + md.GoodsCode + "型号:" + md.TypeCode + "描述:" + md.TypeDesc + "取消分配,可能产生库存,请注意是否可以取消购买 From【" + Name + "】";
mess.IsRead = 0;
mess.InUserId = UserId;
mess.OpenDate = DateTime.Now;
DataNew.SaveOpenMess(mess);
mess = new JC_OpenMess();
mess.InUserId = UserId;
mess.UserId = 149;
mess.UserType = "p";
mess.Content = "编号:" + md.GoodsCode + "型号:" + md.TypeCode + "描述:" + md.TypeDesc + "改分配,可能产生库存,请注意是否可以取消购买 From【" + Name + "】";
mess.IsRead = 0;
mess.OpenDate = DateTime.Now;
DataNew.SaveOpenMess(mess);
}
}
}
}
return 0;
}
#endregion
[WebMethod(EnableSession = true)]
public string SaveOrderSpare(int OrderId, List<DT_SpareFee> 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 string GetFedexFee2(DT_OrderModelNew omd, List<DT_OrderMateGoods> glist, int PostId, string PostType)
{
PagesNew.Login(base.Session);
int companyId = Convert.ToInt32(base.Session["CompanyId"]);
JC_ExpressService service = new JC_ExpressService();
JC_PostAddress address = new BaseService().GetAddressModel2(PostId);
JC_ExpressPost expressModel = service.GetExpressModel(companyId, PostId);
decimal num2 = 0M;
if (glist != null)
{
foreach (DT_OrderMateGoods goods in glist)
{
decimal? nullable;
if (!(goods.Weight.HasValue && !(((nullable = goods.Weight).GetValueOrDefault() <= 0M) && nullable.HasValue)))
{
return (goods.GoodsName + "重量没填,无法计算");
}
if (goods.Width2.HasValue)
{
nullable = goods.Width2;
if (!((nullable.GetValueOrDefault() <= 0M) && nullable.HasValue) && goods.Length2.HasValue)
{
nullable = goods.Length2;
}
}
if ((((nullable.GetValueOrDefault() <= 0M) && nullable.HasValue) || !goods.Height2.HasValue) || (((nullable = goods.Height2).GetValueOrDefault() <= 0M) && nullable.HasValue))
{
return (goods.GoodsName + "长宽高没填,无法计算");
}
num2 += goods.Weight.Value * goods.GoodsNum.Value;
}
}
TradeManageNew.FedexRateNew rate = new TradeManageNew.FedexRateNew();
TradeManageNew.FedexRateNew.Key = expressModel.UserCode;
TradeManageNew.FedexRateNew.Password = expressModel.CheckCode;
TradeManageNew.FedexRateNew.AccountNumber = expressModel.client_id;
TradeManageNew.FedexRateNew.MeterNumber = expressModel.client_secret;
TradeManageNew.FedexRateNew.PayAccountNumber = expressModel.refresh_token;
TradeManageNew.FedexRateNew.HubId = expressModel.Code;
TradeManageNew.FedexRateNew.PostId = PostId;
TradeManageNew.FedexFeeMdNew md = new TradeManageNew.FedexFeeMdNew
{
RevName = omd.RevName,
RevPhone = omd.RevPhone
};
if ((omd.RevPhone == null) || (omd.RevPhone == ""))
{
md.RevPhone = omd.RevMoblie;
}
md.OrderId = omd.OrderId;
md.PostType = PostType;
md.SendAddr = address.EnglishAddress;
md.SendCountry = address.countycode;
md.SendCity = address.city;
md.SendProv = address.provincecode;
md.SendPostCode = address.PostCode;
md.RevAddr = omd.RevAddr;
md.RevCity = omd.RevCity;
if ((omd.RevCity == null) || (omd.RevCity == ""))
{
md.RevCity = omd.RevProvince;
}
if ((omd.RevProvinceCode != null) && (omd.RevProvinceCode != ""))
{
md.RevProv = omd.RevProvinceCode;
}
else if (((omd.RevProvince != null) && (omd.RevProvince != "")) && (omd.RevProvince.Length > 2))
{
md.RevProv = omd.RevProvince.Substring(omd.RevProvince.Length - 2, 2);
}
else
{
md.RevProv = omd.RevProvince;
}
md.RevPostCode = omd.RevPostCode;
md.RevCountry = omd.CountryCode;
md.Width = Math.Ceiling(glist[0].Width2.Value).ToString();
md.Height = Math.Ceiling(glist[0].Height2.Value).ToString();
md.Lenght = Math.Ceiling(glist[0].Length2.Value).ToString();
md.Weight = new decimal?(num2);
string outError = "";
string fee = rate.GetFee(md, out outError);
if (outError != "")
{
return outError;
}
return fee;
}
[WebMethod(EnableSession = true)]
public string GetUPSFee(DT_OrderModelNew omd, List<DT_OrderMateGoods> glist, int PostId, string PostType)
{
PagesNew.Login(base.Session);
int companyId = Convert.ToInt32(base.Session["CompanyId"]);
JC_ExpressService service = new JC_ExpressService();
JC_PostAddress address = new BaseService().GetAddressModel2(PostId);
JC_ExpressPost expressModel = service.GetExpressModel(companyId, PostId);
decimal num2 = 0M;
int totalNum = 0;
if (glist != null)
{
foreach (DT_OrderMateGoods goods in glist)
{
decimal? nullable;
if (!(goods.Weight.HasValue && !(((nullable = goods.Weight).GetValueOrDefault() <= 0M) && nullable.HasValue)))
{
return (goods.GoodsName + "重量没填,无法计算");
}
//if (goods.Width2.HasValue)
//{
// nullable = goods.Width2;
// if (!((nullable.GetValueOrDefault() <= 0M) && nullable.HasValue) && goods.Length2.HasValue)
// {
// nullable = goods.Length2;
// }
//}
//if ((((nullable.GetValueOrDefault() <= 0M) && nullable.HasValue) || !goods.Height2.HasValue) || (((nullable = goods.Height2).GetValueOrDefault() <= 0M) && nullable.HasValue))
//{
// return (goods.GoodsName + "长宽高没填,无法计算");
//}
num2 += goods.Weight.Value * goods.GoodsNum.Value;
totalNum += goods.GoodsNum.Value;
}
}
TradeManageNew.UPSRate rate = new TradeManageNew.UPSRate();
TradeManageNew.UPSRate.AccessLicenseNumber = expressModel.client_id;
TradeManageNew.UPSRate.Username = expressModel.UserCode;
TradeManageNew.UPSRate.Password = expressModel.CheckCode;
TradeManageNew.UPSRate.ShipperNumber = expressModel.Code;
TradeManageNew.FedexFeeMdNew md = new TradeManageNew.FedexFeeMdNew
{
RevName = omd.RevName,
RevPhone = omd.RevPhone
};
if ((omd.RevPhone == null) || (omd.RevPhone == ""))
{
md.RevPhone = omd.RevMoblie;
}
md.OrderId = omd.OrderId;
md.PostType = PostType;
md.packType = "02";
md.SendAddr = address.EnglishAddress;
md.SendCountry = address.countycode;
md.SendCity = address.city;
md.SendProv = address.provincecode;
md.SendPostCode = address.PostCode;
md.RevAddr = omd.RevAddr;
md.RevCity = omd.RevCity;
if ((omd.RevCity == null) || (omd.RevCity == ""))
{
md.RevCity = omd.RevProvince;
}
if ((omd.RevProvinceCode != null) && (omd.RevProvinceCode != ""))
{
md.RevProv = omd.RevProvinceCode;
}
else if (((omd.RevProvince != null) && (omd.RevProvince != "")) && (omd.RevProvince.Length > 2))
{
md.RevProv = omd.RevProvince.Substring(omd.RevProvince.Length - 2, 2);
}
else
{
md.RevProv = omd.RevProvince;
}
md.RevPostCode = omd.RevPostCode;
md.RevCountry = omd.CountryCode;
md.Width = Math.Ceiling(glist[0].Width2.Value).ToString();
md.Height = Math.Ceiling(glist[0].Height2.Value).ToString();
md.Lenght = Math.Ceiling(glist[0].Length2.Value).ToString();
md.Weight = num2 * 0.0625M;
md.TotalNum = totalNum.ToString();
string outError = "";
string fee = rate.GetFeeNew(md);
//获取到的ups运费更新到订单中
if (!fee.Contains("ErrorMessage:"))
{
var infos = fee.Split('&');
DataNew.UpdateOrderUPSPostFee(omd.OrderId.Value, string.IsNullOrEmpty(infos[0]) ? 0 : Convert.ToDecimal(infos[0]), PostId, infos[1]);
}
else
{
DataNew.UpdateOrderUPSLog(omd.OrderId.Value, fee);
}
return fee;
}
#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
#region 获取物流单号
[WebMethod(EnableSession = true)]
public string GetOrderPostCodeOne(string OrderIds, int PostId, int CompanyId, string SKU, int Num, int IsSpare, decimal? weight, decimal? cd, decimal? kd, decimal? gd, int IsQS)
{
PagesNew.Login(this.Session);
var obj = new DD_OrderData();
if (CompanyId == 0)
CompanyId = Convert.ToInt32(Session["CompanyId"]);
var companymd = new JC_PostAddress();
var obj1 = new JC_ExpressService();
var obj11 = new BaseService();
companymd = obj11.GetAddressModel2(PostId);
string ErrorInfo = "";
string PostCode = "";
var obj2 = new BaseService();
var md = DataNew.GetExpressModel(CompanyId, PostId);
//var orderlist = obj.GetOrderModelList(OrderIds.Trim(','));
var orderlist = DataNew.GetOrderModelList(OrderIds.Trim(','));
var orderGoodslist = DataNew.GetOrderGoodsList2(OrderIds.Trim(','));
if (orderlist == null || orderGoodslist == null || md == null)
return "";
foreach (var ordermd in orderlist)
{
if ((ordermd.RevPhone == null || ordermd.RevPhone == "") && (ordermd.RevPhone == null || ordermd.RevPhone == ""))
ErrorInfo += ordermd.PlatOrderCode + "收件人电话没填";
if (ordermd.RevPostCode == null || ordermd.RevPostCode == "")
ErrorInfo += ordermd.PlatOrderCode + "收件人邮编没填";
if (ordermd.RevProvince == null || ordermd.RevProvince == "")
ErrorInfo += ordermd.PlatOrderCode + "州没填";
}
if (ErrorInfo != "")
{
return ErrorInfo;
}
var plist = new List<DT_TrackCodeApplyNew>();
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<FedexGoods> fedlist = new List<FedexGoods>();
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<UpsGoods> upslist = new List<UpsGoods>();
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 保存跟踪码
[WebMethod(EnableSession = true)]
public string SaveTrackCode(int OrderId, int TrackType, string OrderCode, int IsSpare, int PostId, string JoinOrderCode, string trackcode, string sku, string cfzl, string cfc, string cfk, string cfg)
{
Pages.Login(this.Session);
DD_OrderData obj = new DD_OrderData();
if (PostId != 104) //荷兰邮政不验证
{
if (obj.IsOrderTrackCode(OrderId, trackcode) > 0)
return "该跟踪码已经存在";
}
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
string Name = Convert.ToString(Session["Name"]);
DT_TrackCodeApplyNew Model = new DT_TrackCodeApplyNew();
Model.InName = Name;
Model.TrackType = TrackType;
Model.OrderId = OrderId;
Model.IsSpare = IsSpare;
Model.TrackCode = trackcode.Trim();
Model.PostId = PostId;
Model.State = 1;
Model.GetDate = DateTime.Now;
if (JoinOrderCode != "")
Model.OrderCode = JoinOrderCode;
else
Model.OrderCode = OrderCode;
Model.IsSpare = IsSpare;
Model.JoinOrderCode = JoinOrderCode;
Model.SKU = sku;
Model.Weight = string.IsNullOrEmpty(cfzl) ? "" : (Convert.ToDecimal(cfzl) * 0.0625m).ToString("0.00");
Model.Weight2 = string.IsNullOrEmpty(cfzl) ? "" : (Convert.ToDecimal(cfzl) * 0.0625m).ToString("0.00");
Model.Long = cfc;
Model.Width = cfk;
Model.Height = cfg;
DataNew.SaveTrackCodeApply(Model);
return "成功";
}
#endregion
#region
[WebMethod(EnableSession = true)]
public int Save_OrderLTLFee(int OrderId, decimal FeeLTL)
{
PagesNew.Login(this.Session);
DataNew.Save_OrderLTLFee(OrderId, FeeLTL);
return 1;
}
#endregion
#region 返回订单Model
[WebMethod(EnableSession = true)]
public int Save_ErrorJH(int OrderId, int JHError, string JHRemark)
{
PagesNew.Login(this.Session);
var obj = new DD_OrderData();
string name = Convert.ToString(Session["Name"]);
if (JHError == 0)
JHRemark += " 取消人:" + name + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
else
JHRemark += " 设置人:" + name + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
var md = DataNew.Save_ErrorJH(JHError, JHRemark, OrderId);
return md;
}
#endregion
#region 保存
[WebMethod(EnableSession = true)]
public int Save_PostVote(DT_PostVote Model, int IsSS)
{
PagesNew.Login(this.Session);
DataNew.UpdateOrderWLSS(Model.OrderId.Value, IsSS);
if (IsSS == 0)
{
DataNew.Delete_PostVote(Model.OrderId.Value);
return 1;
}
Model.inname = Session["Name"].ToString();
Model.indate = DateTime.Now;
return DataNew.Save_PostVote(Model);
}
#endregion
#region 保存赔款申请
[WebMethod(EnableSession = true)]
public int SaveBackMoneyApply2(int BackState, DT_OrderBackMoneyApply model)
{
PagesNew.Login(this.Session);
int UserId = Convert.ToInt32(Session["UserId"]);
int DeptId = Convert.ToInt32(Session["DeptId"]);
string Name = Convert.ToString(Session["Name"]);
DD_OrderData obj = new DD_OrderData();
BaseService obj1 = new BaseService();
//if (model.Id == null || model.Id == 0)
//{
// int a = obj.IsOrderBackMoney(model.OrderCode);
// if (a > 0)
// return 1;
//}
//if (model.Id == null || model.Id == 0)
//{
// int orderid = obj.IsOrderBackMoney2(model.OrderCode);
// if (orderid==0)
// return 2;
// model.OrderId = orderid;
//}
model.Indate = DateTime.Now;
model.InUserId = UserId;
model.InName = Name;
//var clist = obj1.GetDeptCharge2(DeptId);
//if (clist != null && clist.Count > 0)
//{
// model.CompanyName1 = clist[0].Name;
// model.CompanyUserId = clist[0].UserId;
//}
model.OrderCode = model.OrderCode.Trim();
model.GoodsCode = model.GoodsCode.Trim();
model.BackDate = DateTime.Now;
string imgids = "";
if (model.imglist != null)
{
foreach (var md in model.imglist)
{
imgids += md.id + ",";
}
}
if (imgids != "")
model.ImageIds = imgids.Trim(',');
obj.SaveBackMoneyForOrder(model.OrderId.Value, BackState);
DataNew.SaveBackMoneyApply2(BackState, model);
//if (model.FactPrice != null && model.BackDate != null)
//{
// model.OrderCode = model.OrderCode.Trim();
// obj.SaveBackMoneyFact(model);
//}
BaseService.SendOpenMess(1, Name + "有个订单退货赔款申请需要你审批", "");
return 0;
}
#endregion
#region 刷新运费毛利
[WebMethod(EnableSession = true)]
public void ComputerOrderFee_Order(int orderid)
{
PagesNew.Login(this.Session);
DataNew.ComputerOrderFee_Order(orderid);
}
#endregion
/// <summary>
/// 更新快递面单SKU信息
/// </summary>
/// <param name="id"></param>
/// <param name="sku"></param>
/// <returns></returns>
[WebMethod(EnableSession = true)]
public APIReturnModel UpdateTrackingCodeSKU(int id, string sku)
{
Pages.Login(this.Session);
var rmodel = new APIReturnModel();
try
{
if (string.IsNullOrEmpty(sku))
{
rmodel.Code = 0;
rmodel.Message = "SKU不能为空";
return rmodel;
}
var skuArr = sku.Split('+');
for (var i = 0; i < skuArr.Length; i++)
{
try
{
var first_x = skuArr[i].IndexOf('x');//SKU中第一次出现x的位置
//var qty = Convert.ToInt32(skuArr[i].Substring(0, first_x));
var _sku = skuArr[i].Substring(first_x + 1);
//根据SKU1匹配商品详情
var hw_detail = DataNew.GetGoodsDetailBySku1(_sku);
if (hw_detail == null)
{
rmodel.Code = 0;
rmodel.Message = "SKU:" + skuArr[i] + "不正确请填写商品的SKU1";
return rmodel;
}
}
catch (Exception ex)
{
throw new Exception("SKU填写格式不正确请按照1xA+2xB+3xC的格式填写");
}
}
DataNew.UpdateTrackingCodeSKU(id, sku.Trim());
rmodel.Code = 1;
rmodel.Message = "Success";
}
catch (Exception ex)
{
rmodel.Code = 0;
rmodel.Message = "失败:" + ex.Message;
}
return rmodel;
}
#region 删除跟踪码
[WebMethod(EnableSession = true)]
public void DeleteTrackCode(int Id, int OrderId)
{
Pages.Login(this.Session);
var obj = new DD_OrderData();
obj.DeleteTrackCode(Id, OrderId);
}
#endregion
#region 恢复订单
[WebMethod(EnableSession = true)]
public void CancelBackOrderForTM(List<DT_Order> list)
{
Pages.Login(this.Session);
var obj = new DD_OrderData();
int InUserId = Convert.ToInt32(Session["UserId"]);
if (list == null || list.Count == 0)
return;
foreach (var md in list)
{
obj.CancelBackOrder2(md.OrderId.Value, InUserId);
obj.UpdateBuyOrderGoodsForTM2(md.OrderId.Value);// 修改货物的订单数量(购买)
Pages.SaveLog(InUserId, "订单日志", "恢复订单", list[0].OrderId.Value);
}
}
#endregion
#region LTL订单
[WebMethod(EnableSession = true)]
public string LTLOrderForTM(List<DT_Order> list)
{
PagesNew.Login(this.Session);
var obj = new DD_OrderData();
int InUserId = Convert.ToInt32(Session["UserId"]);
if (list == null || list.Count == 0)
return "";
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
string error = "";
foreach (var md in list)
{
DataNew.UpdateOrderLTL(md.OrderId.Value);
}
return error;
}
#endregion
#region LTL订单
[WebMethod(EnableSession = true)]
public string LTLOrderForTMBack(List<DT_Order> list)
{
PagesNew.Login(this.Session);
var obj = new DD_OrderData();
int InUserId = Convert.ToInt32(Session["UserId"]);
if (list == null || list.Count == 0)
return "";
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
string error = "";
foreach (var md in list)
{
DataNew.UpdateOrderLTLBack(md.OrderId.Value);
}
return error;
}
#endregion
#region 修改允许发货
[WebMethod(EnableSession = true)]
public void UpdateHWC(List<DT_Order> list, int IsFBa)
{
Pages.Login(this.Session);
if (list != null)
{
var obj = new DD_OrderData();
foreach (var md in list)
{
obj.UpdateHWC(md.OrderId.Value, IsFBa);
}
}
}
#endregion
#region 删除订单
[WebMethod(EnableSession = true)]
public APIReturnModel DeleteOrderForTM2(string OrderIds)
{
Pages.Login(base.Session);
var rmodel = new APIReturnModel();
try
{
int InUserId = Convert.ToInt32(Session["UserId"]);
if (OrderIds != "")
{
DataNew.DeleteOrderForTM2(OrderIds.Trim(','));
Pages.SaveLog(InUserId, "删除订单", OrderIds + "删除订单", 0);
}
rmodel.Code = 1;
rmodel.Message = "Success";
}
catch (Exception ex)
{
rmodel.Code = 0;
rmodel.Message = ex.Message;
}
return rmodel;
}
#endregion
#region 保存留言
[WebMethod(EnableSession = true)]
public void SaveLY_Content(List<LY_Content> list)
{
Pages.Login(this.Session);
BaseService obj1 = new BaseService();
int UserId = Convert.ToInt32(Session["UserId"]);
if (list == null)
return;
JC_Shop ShopModel = null;
int ShopId = 0;
foreach (var model in list)
{
model.InUserId = UserId;
model.InDate = DateTime.Now;
obj1.SaveLY_Content(model);
AlibabaApi obj = new AlibabaApi();
if (ShopId != model.ShopId.Value)
ShopModel = DataNew.GetModel(model.ShopId.Value);
ShopId = model.ShopId.Value;
obj.Appkey = ShopModel.Appkey;
obj.DeveKey = ShopModel.DeveKey;
obj.RefreshToken = ShopModel.RefreshToken;
obj.AccessToken = ShopModel.AccessToken;
obj.GroupName = ShopModel.ShopName;
obj.RefreshTokenSaveTime = ShopModel.RefreshTokenSaveTime;
obj.AccessTokenUpdateTime = ShopModel.AccessTokenUpdateTime;
//obj.Code = "66ef3e1d-ecc3-4008-adf5-5a57f11e66bb";
string mess = "";
if (model.OrderCode.StartsWith("H"))
model.OrderCode = model.OrderCode.Substring(1);
string detail = obj.GetOrderstr(model.OrderCode, out mess);
JObject sigle = (JObject)JsonConvert.DeserializeObject(detail);
string country = sigle["receiptAddress"]["country"].ToString();
string buyid = sigle["buyerloginid"].ToString();
obj.BackLeaveWord(model.OrderCode, buyid, model.BackContent, "order_msg", out mess);
//obj.GetMsgData(model.OrderCode, out mess);
Pages.SaveLog(UserId, "回复留言", model.OrderCode.ToString() + "留言", 0);
}
}
#endregion
#region API数据导入
[WebMethod(EnableSession = true)]
public string ImportApiAll()
{
Pages.Login(this.Session);
int UserId = Convert.ToInt32(Session["UserId"]);
string Name = Convert.ToString(Session["Name"]);
BaseService.SyncLockAll(UserId, Name, DateTime.Today.AddDays(-3), DateTime.Today);
return "已经开始同步订单,请耐心等待一会儿再刷新订单查询";
}
#endregion
[WebMethod(EnableSession = true)]
public string GetFedexFeeNo(List<DT_Order> list)
{
PagesNew.Login(base.Session);
GetFedexFeeNo2(list, 228);
Thread.Sleep(3000);
GetFedexFeeNo2(list, 237);
return "重新计算成功";
}
public string GetFedexFeeNo2(List<DT_Order> list, int PostId)
{
PagesNew.Login(base.Session);
// int companyId = Convert.ToInt32(base.Session["CompanyId"]);
string ids = "";
if (list != null)
{
foreach (var md in list)
{
ids += md.OrderId + ",";
}
}
var GoodsList = DataNew.GetFedexOrderGoodsList(ids.TrimEnd(','));
var OrderList = DataNew.GetFedexOrderList2(ids.TrimEnd(','));
if (OrderList == null || GoodsList == null)
return "重新计算成功0单";
JC_ExpressService service = new JC_ExpressService();
JC_PostAddress address = new BaseService().GetAddressModel2(PostId);
JC_ExpressPost expressModel = service.GetExpressModel(1, PostId);
TradeManageNew.FedexRateNew rate = new FedexRateNew();
TradeManageNew.FedexRateNew.Key = expressModel.UserCode;
TradeManageNew.FedexRateNew.Password = expressModel.CheckCode;
TradeManageNew.FedexRateNew.AccountNumber = expressModel.client_id;
TradeManageNew.FedexRateNew.MeterNumber = expressModel.client_secret;
TradeManageNew.FedexRateNew.PayAccountNumber = expressModel.refresh_token;
TradeManageNew.FedexRateNew.HubId = expressModel.Code;
TradeManageNew.FedexRateNew.PostId = PostId;
int Num = 0;
foreach (var omd in OrderList)
{
var glist = GoodsList.FindAll(n => n.OrderId == omd.OrderId);
if (glist == null)
continue;
decimal weight = 0M;
decimal width = 0;
decimal slong = 0;
decimal height = 0;
foreach (var goods in glist)
{
if (goods.Weight != null && goods.Weight > 0 && goods.GoodsNum != null)
{
weight += goods.Weight.Value * goods.GoodsNum.Value;
}
if (goods.Width2 == null || goods.Length2 == null || goods.Height2 == null || goods.Length2 <= 0 || goods.Width2 <= 0 || goods.Height2 <= 0)
{
weight = 0;
}
if (goods.Width2 > width)
width = goods.Width2.Value;
if (goods.Length2 > slong)
slong = goods.Length2.Value;
if (goods.Height2 > height)
height = goods.Height2.Value;
}
if (weight == 0)
continue;
FedexFeeMdNew md = new FedexFeeMdNew
{
RevName = omd.RevName,
RevPhone = omd.RevPhone
};
if ((omd.RevPhone == null) || (omd.RevPhone == ""))
{
md.RevPhone = omd.RevMoblie;
}
md.OrderId = omd.OrderId;
md.SendAddr = address.EnglishAddress;
md.SendCountry = address.countycode;
md.SendCity = address.city;
md.SendProv = address.provincecode;
md.SendPostCode = address.PostCode;
if ((omd.RevAddr != null) && (omd.RevAddr != ""))
{
md.RevAddr = omd.RevAddr;
}
else
{
md.RevAddr = "street No 18";
}
md.RevCity = omd.RevCity;
if (omd.RevCity == null || omd.RevCity == "")
{
md.RevCity = omd.RevProvince;
}
if (omd.RevProvinceCode != null && omd.RevProvinceCode != "")
{
md.RevProv = omd.RevProvinceCode;
}
else if (omd.RevProvince != null && omd.RevProvince != "" && omd.RevProvince.Length > 2)
{
md.RevProv = omd.RevProvince.Substring(omd.RevProvince.Length - 2, 2);
}
else
{
md.RevProv = omd.RevProvince;
}
md.RevPostCode = omd.RevPostCode;
md.RevCountry = omd.CountryCode;
if (md.RevCountry == null || md.RevCountry == "")
md.RevCountry = "US";
md.Width = Math.Ceiling(width).ToString();
md.Height = Math.Ceiling(height).ToString();
md.Lenght = Math.Ceiling(slong).ToString();
md.Weight = weight;
// Thread.Sleep(1000);
md.PostType = "SMART_POST";
string outError = "";
rate.GetFee(md, out outError);
// Thread.Sleep(1000);
md.PostType = "FEDEX_GROUND";
string outError2 = "";
rate.GetFee(md, out outError2);
// Thread.Sleep(1000);
md.PostType = "GROUND_HOME_DELIVERY";
string outError3 = "";
rate.GetFee(md, out outError3);
if (outError == "" || outError2 == "" || outError3 == "")
{
Num++;
}
}
return "重新计算成功" + Num + "单";
}
#region 刷新运费毛利
[WebMethod(EnableSession = true)]
public void GetModel_OrderFeeML()
{
PagesNew.Login(this.Session);
DataNew.GetModel_OrderFeeML();
}
#endregion
}
}