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.

822 lines
46 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 System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Reflection;
using System.Text;
using System.IO;
using TradeModel;
using NetLibrary;
using NetLibrary.Data;
using NetLibrary.Express;
using System.Data.Common;
namespace TradeData
{
public class OrderPrintData
{
public List<Order> GetOrderPrint(string ids, int CompanyId, int printType)
{
//Pages.Login(this.Session);
//int CompanyId = Convert.ToInt32(Session["CompanyId"]);
//var CompanyModel = JC_CompanyService.GetModel(CompanyId);
var obj = new DD_OrderData();
var obj11 = new BaseService();
List<Order> ListModel = new List<Order>();
//for (int i = 0; i < list.Count(); i++)
//{
string ErrorInfo = "";
// var ordermodellist = obj.GetOrderPrintModelForTM(list[i], printType);
List<DT_OrderPrintModel> ordermodellist=null;
if (printType == 2)
{
ordermodellist = obj.GetOrderPrintListForTM2(ids, 0);
}
else
ordermodellist = obj.GetOrderPrintListForTM(ids, printType);
var jlist = obj.GetOrderCountry();
#region 拆分订单
//if (ordermodel.IsSpare == 1) //拆分订单
//{
// var splist = obj.GetOrderSpareList(list[i]);
// var GoodsList = obj.GetPrintSpareGoodsModel(list[i]);
// if (splist != null)
// {
// foreach (var spmd in splist)
// {
// if (spmd != null)
// {
// Order model = null;
// OrderDetail model2 = null;
// //eub
// model = new Order();
// BaseService obj2 = new BaseService();
// var expressmd = obj2.GetExpressModel(ordermodel.Post.GetValueOrDefault(0), CompanyId);
// JC_PostAddress CompanyModel = null;
// if (expressmd.DefaultAddr != null)
// {
// CompanyModel = obj11.GetAddressModel(expressmd.DefaultAddr.Value);
// }
// if (CompanyModel == null)
// continue;
// if (expressmd != null)
// {
// if (expressmd.PrintTemplateName != null)
// {
// model.ExpressRPT = expressmd.PrintTemplateName;
// }
// else continue;
// model.ExpressID = ordermodel.Post.GetValueOrDefault(0);
// model.ExpressService = expressmd.Name;
// }
// else continue;
// string PostCode = ordermodel.RevPostCode;
// if (model.ExpressType == 1 || model.ExpressType == 6)
// {
// var PostCodeRulelist = obj2.GetPostCodeRule(ordermodel.CountryCode);
// if (PostCodeRulelist != null && PostCodeRulelist.Count > 0)
// {
// if (PostCodeRulelist[0].PostCodeLen > 0 && PostCodeRulelist[0].PostCodeLen != PostCode.Length)
// {
// ErrorInfo = "邮编位数不正确";
// }
// else if (PostCodeRulelist[0].FirstLen > 0 && PostCode.Length >= PostCodeRulelist[0].FirstLen)
// {
// string firstNum = PostCode.Substring(0, PostCodeRulelist[0].FirstLen.Value);
// if (PostCodeRulelist[0].GDNum != null && PostCodeRulelist[0].GDNum.ToString() != "")
// {
// var ppmd = PostCodeRulelist.Find(n => n.GDNum == firstNum);
// if (ppmd != null)
// model.AreaSerial = ppmd.DYNum;
// }
// else
// {
// int Num = Convert.ToInt32(firstNum);
// var ppmd = PostCodeRulelist.Find(n => n.SNum <= Num && n.ENum >= Num);
// if (ppmd != null)
// model.AreaSerial = ppmd.DYNum;
// }
// }
// else if (PostCodeRulelist[0].FirstLen == 0)
// {
// string firstNum = PostCode;
// if (PostCodeRulelist[0].GDNum.ToString() != "")
// {
// var ppmd = PostCodeRulelist.Find(n => n.GDNum == firstNum);
// if (ppmd != null)
// model.AreaSerial = ppmd.DYNum;
// }
// else
// {
// int Num = Convert.ToInt32(firstNum);
// var ppmd = PostCodeRulelist.Find(n => n.SNum <= Num && n.ENum >= Num);
// if (ppmd != null)
// model.AreaSerial = ppmd.DYNum;
// }
// }
// }
// }
// else
// {
// var groupmd = obj2.GetExpressGroupNew(ordermodel.Post.GetValueOrDefault(0), ordermodel.CountryCode);
// if (groupmd != null && groupmd.Groups != null && groupmd.Groups != "")
// model.AreaSerial = groupmd.Groups;
// else
// model.AreaSerial = "1";
// if (groupmd != null && groupmd.Groups2 != null && groupmd.Groups2 != "")
// model.AreaSerial2 = groupmd.Groups2;
// else
// model.AreaSerial2 = "";
// }
// model.RevCountry = ordermodel.RevCountry;
// model.CountryCode = ordermodel.CountryCode;
// model.CountryName = ordermodel.CountryName;
// if (ordermodel.RevMoblie != null)
// model.RevMobile = ordermodel.RevMoblie;
// else
// model.RevMobile = "";
// model.RevPerson = ordermodel.RevName;
// string RevArea = "";
// if (ordermodel.RevArea != null && ordermodel.RevArea != "")
// RevArea = ordermodel.RevArea + ",";
// string RevCity = "";
// if (ordermodel.RevCity != null && ordermodel.RevCity != "")
// RevCity = ordermodel.RevCity + ",";
// string RevProvince = "";
// if (ordermodel.RevProvince != null && ordermodel.RevProvince != "")
// RevProvince = ordermodel.RevProvince + ",";
// model.RevAddress = ordermodel.RevName + "\r\n" + ordermodel.RevAddr + "," + RevArea + RevCity + RevProvince + ordermodel.RevPostCode + "," + ordermodel.RevCountry;
// if (ordermodel.RevMoblie != null)
// model.RevPhone = ordermodel.RevPhone;
// else
// model.RevPhone = "";
// model.RevZip = ordermodel.RevPostCode;
// if (model.ExpressID == 1 && ordermodel.CountryCode.ToUpper() == "US")
// {
// model.RevZip = ordermodel.RevPostCode;
// //model.CreateRevZipBarCode();
// }
// if (model.ExpressService == "西班牙平邮")
// {
// //西班牙平邮
// model.RevAddress = ordermodel.RevAddr + "," + RevArea + RevCity + RevProvince;
// //西班牙平邮
// model.RevZip = (ordermodel.RevPostCode + " " + RevCity + " " + RevProvince).Replace(",", ""); ;
// }
// //One World
// if (model.ExpressService == "One World" || model.ExpressService == "俄罗斯平邮" || model.ExpressService == "巴西平邮" || model.ExpressService == "OneDDU" || model.ExpressService == "东欧平邮" || model.ExpressService == "东欧小包")
// {
// model.RevAddress = model.RevAddress.Replace(",", "\r\n");
// }
// model.ShopName = ordermodel.ShopName;
// model.SendPerson = CompanyModel.SendEnglishName;
// model.SendAddress = CompanyModel.EnglishAddress;
// model.SendPhone = CompanyModel.Phone;
// model.SendZip = CompanyModel.PostCode;
// model.BarCode = spmd.TrackCode;
// model.OrderCode = ordermodel.PlatOrderCode;
// model.YCXX = ordermodel.ErrorInfo;
// int GoodsNum = 0;
// decimal Weight = 0;
// if (GoodsList != null)
// {
// List<OrderDetail> listod = new List<OrderDetail>();
// var spGoodsList = GoodsList.FindAll(n => n.SpareId == spmd.Id).OrderBy(n=>n.GoodsCode);
// string goodinfo = "";
// string goodno="";
// foreach (var md1 in spGoodsList)
// {
// if (goodno != md1.GoodsCode)
// {
// goodno = md1.GoodsCode;
// goodinfo += md1.GoodsCode + "," + md1.GoodsName + "," + md1.TypeDesc + "[" + md1.GoodsNum.ToString() + "][" + md1.PostionDesc + "];";
// }
// else
// {
// goodinfo += md1.TypeDesc + "[" + md1.GoodsNum.ToString() + "][" + md1.PostionDesc + "];";
// }
// model2 = new OrderDetail();
// model.OrderId = md1.SpareId.GetValueOrDefault(0);
// model2.OrderId = md1.SpareId.GetValueOrDefault(0);
// model2.GoodsCode = md1.GoodsCode;
// model2.GoodsNum = md1.GoodsNum.ToString();
// if (md1.GoodsNum != null)
// GoodsNum += md1.GoodsNum.Value;
// model2.GoodsPrice = "10.0";
// if (md1.Weight != null)
// {
// model2.GoodsWeight = (md1.Weight.Value / 1000).ToString();
// Weight += md1.Weight.Value / 1000;
// }
// else
// {
// model2.GoodsWeight = "0.20";
// Weight += Convert.ToDecimal(0.2);
// }
// model2.GoodsName = md1.GoodsName + "," + md1.TypeDesc + "[" + md1.SKU1 + "]";
// if (md1.PostionDesc != null && md1.PostionDesc != "")
// model2.GoodsName = md1.GoodsName + "," + md1.TypeDesc + "[" + md1.SKU1 + "][" + md1.PostionDesc + "]";
// // if (md1.GoodsEnglisgName != null && md1.GoodsEnglisgName != "")
// model2.GoodsSimpleName = md1.GoodsName + "," + md1.TypeDesc + "[" + md1.SKU1 + "]";// md1.GoodsEnglisgName.ToString();
// if (md1.PostionDesc != null && md1.PostionDesc != "")
// model2.GoodsSimpleName = md1.GoodsName + "," + md1.TypeDesc + "[" + md1.SKU1 + "][" + md1.PostionDesc + "]";
// model2.GoodsOrigin = "China";
// model2.GoodsSku = md1.SKU1;
// listod.Add(model2);
// //model.ListModel.Add(model2);
// if (model.ExpressService == "BPost")
// {
// model.GoodDes = md1.SKU1;
// }
// else
// {
// model.GoodDes = md1.GoodsEnglisgName;
// }
// }
// if (model.GoodDes == "") model.GoodDes = "Daily Goods";
// model.ListModel = listod;
// model.CountGoodsNum = GoodsNum.ToString();
// model.CountGoodsPrice = (GoodsNum * 10).ToString();
// model.CountGoodsWeight = Weight.ToString();
// model.GoodDetail = goodinfo;
// }
// ListModel.Add(model);
// }
// }
// }
//}
#endregion
//else
//{
if (ordermodellist != null)
{
foreach (var ordermodel in ordermodellist)
{
var cmd = jlist.Find(n => n.Code == ordermodel.RevCountry);
if (cmd != null)
ordermodel.RevCountry = cmd.EnglishName;
var GoodsList = ordermodel.GoodsList;
//var GoodsList = obj.GetPrintGoodsModelForTM(list[i], printType);
if (ordermodel != null)
{
Order model = null;
OrderDetail model2 = null;
//eub
model = new Order();
BaseService obj2 = new BaseService();
var expressmd = obj2.GetExpressModel(ordermodel.Post.GetValueOrDefault(0), CompanyId);
JC_PostAddress CompanyModel = null;
if (expressmd.DefaultAddr != null)
{
CompanyModel = obj11.GetAddressModel(expressmd.DefaultAddr.Value);
}
if (CompanyModel == null)
continue;
if (expressmd != null)
{
if (expressmd.PrintTemplateName != null)
{
model.ExpressRPT = expressmd.PrintTemplateName;
}
else continue;
model.ExpressID = ordermodel.Post.GetValueOrDefault(0);
model.ExpressService = expressmd.Name;
model.ExpressType = expressmd.PostType.GetValueOrDefault(0);
}
else continue;
string[] tempPostCode = ordermodel.RevPostCode.Split('-');
string PostCode = tempPostCode[0];
if (model.ExpressType == 1 || model.ExpressType == 6)
{
var PostCodeRulelist = obj2.GetPostCodeRule(ordermodel.CountryCode);
if (PostCodeRulelist != null && PostCodeRulelist.Count > 0)
{
if (PostCodeRulelist[0].PostCodeLen > 0 && PostCodeRulelist[0].PostCodeLen != PostCode.Length)
{
ErrorInfo = "邮编位数不正确";
}
else if (PostCodeRulelist[0].FirstLen > 0 && PostCode.Length >= PostCodeRulelist[0].FirstLen)
{
string firstNum = PostCode.Substring(0, PostCodeRulelist[0].FirstLen.Value);
if (PostCodeRulelist[0].GDNum != null && PostCodeRulelist[0].GDNum.ToString() != "")
{
var ppmd = PostCodeRulelist.Find(n => n.GDNum == firstNum);
if (ppmd != null)
model.AreaSerial = ppmd.DYNum;
}
else
{
int Num = 0;
bool b1 = int.TryParse(firstNum, out Num);
//int Num = Convert.ToInt32(firstNum);
var ppmd = PostCodeRulelist.Find(n => n.SNum <= Num && n.ENum >= Num);
if (ppmd != null)
model.AreaSerial = ppmd.DYNum;
}
}
else if (PostCodeRulelist[0].FirstLen == 0)
{
string firstNum = PostCode;
if (PostCodeRulelist[0].GDNum.ToString() != "")
{
var ppmd = PostCodeRulelist.Find(n => n.GDNum == firstNum);
if (ppmd != null)
model.AreaSerial = ppmd.DYNum;
}
else
{
int Num = Convert.ToInt32(firstNum);
var ppmd = PostCodeRulelist.Find(n => n.SNum <= Num && n.ENum >= Num);
if (ppmd != null)
model.AreaSerial = ppmd.DYNum;
}
}
}
}
else
{
var groupmd = obj2.GetExpressGroupNew(ordermodel.Post.GetValueOrDefault(0), ordermodel.CountryCode);
if (groupmd != null && groupmd.Groups != null && groupmd.Groups != "")
model.AreaSerial = groupmd.Groups;
else
model.AreaSerial = "1";
if (groupmd != null && groupmd.Groups2 != null && groupmd.Groups2 != "")
model.AreaSerial2 = groupmd.Groups2;
else
model.AreaSerial2 = "";
}
model.RevCountry = ordermodel.RevCountry.ToUpper();
model.CountryCode = ordermodel.CountryCode;
model.CountryName = ordermodel.CountryName;
model.RevMobile = ordermodel.RevMoblie;
if (ordermodel.RevMoblie == null) model.RevMobile = "";
model.RevPerson = ordermodel.RevName;
string RevArea = "";
if (ordermodel.RevArea != null && ordermodel.RevArea != "")
RevArea = ordermodel.RevArea + ",";
string RevCity = "";
if (ordermodel.RevCity != null && ordermodel.RevCity != "")
RevCity = ordermodel.RevCity + ",";
string RevProvince = "";
if (ordermodel.RevProvince != null && ordermodel.RevProvince != "")
RevProvince = ordermodel.RevProvince + ",";
model.RevAddress = ordermodel.RevName + "\r\n" + ordermodel.RevAddr + "," + RevArea + RevCity + RevProvince + ordermodel.RevPostCode + "," + ordermodel.RevCountry;
//One World
if (model.ExpressService == "One World" || model.ExpressService == "俄罗斯平邮" || model.ExpressService == "巴西平邮" || model.ExpressService == "OneDDU" || model.ExpressService == "东欧平邮" || model.ExpressService == "东欧小包")
{
model.RevAddress = model.RevAddress.Replace(",", "\r\n");
}
model.RevPhone = ordermodel.RevPhone;
model.RevZip = ordermodel.RevPostCode;
if (model.ExpressService == "西班牙平邮")
{
//西班牙平邮
model.RevAddress = ordermodel.RevAddr + "," + RevArea + RevCity + RevProvince;
//西班牙平邮
model.RevZip = model.RevZip = (ordermodel.RevPostCode + " " + RevCity + " " + RevProvince).Replace(",", "");
}
if (model.ExpressID == 1 && ordermodel.CountryCode.ToUpper() == "US")
{
model.RevZip = ordermodel.RevPostCode;
//model.CreateRevZipBarCode();
}
List<DT_HBOrder> HBlist = null;
if (model.ExpressService.Contains("EUB") || model.ExpressService.Contains("E邮宝"))
{
if (ordermodel.JoinOrderCode != null && ordermodel.JoinOrderCode!="")
HBlist = obj.GetNowHBOrderForTM(ordermodel.JoinOrderCode);
//ErrorInfo = "邮编位数不正确";
if (model.ExpressService == ("EUB美国") || model.ExpressService == ("EUB(美国)") || model.ExpressService == ("EUB美国") || model.ExpressService == ("EUB") || model.ExpressService == ("线上EUB") || model.ExpressService == ("Wish-E邮宝") || model.ExpressService == ("燕文上海E邮宝线下)") || model.ExpressService == ("燕文上海E邮宝(美国)") || model.ExpressService == ("EUB慈溪"))
{
GetZIPModelForTM();
string tempcode = Getcode(ordermodel.RevPostCode);
model.AreaSerial = tempcode;
}
if (model.ExpressService.Contains("加拿大"))
{
string tempcode = GetcodeCA(ordermodel.RevPostCode);
model.AreaSerial = tempcode;
}
if (model.ExpressService.Contains("俄") || model.ExpressService.Contains("俄罗斯"))
{
GetZIPModelForTMELS();
string tempcode = GetcodeRU(ordermodel.RevPostCode);
model.AreaSerial = tempcode;
}
string tempstate = "";
GetStateModelForTM();
if (ordermodel.RevProvince != null && ordermodel.RevProvince!="")
{
tempstate = Getcustomera(ordermodel.RevProvince);
}
//ordermodel.RevProvince = tempstate;
model.RevAddress = ordermodel.RevName + "\r\n" + ordermodel.RevAddr + " " + RevArea + "\r\n" + RevCity + " " + tempstate + " " + ordermodel.RevPostCode + " " + "\r\n"+ordermodel.CountryCode;
}
if (model.ExpressService == ("燕文德邮其它") || model.ExpressService == ("燕文荷兰挂号(电)"))
{
var PostCodeRulelist = obj2.GetPostCodeRule2(ordermodel.CountryCode);
if (PostCodeRulelist != null)
{
model.AreaSerial2 = "#"+PostCodeRulelist.DYNum;
if (PostCodeRulelist.GDNum!=null&&PostCodeRulelist.GDNum != "")
model.AreaSerial = PostCodeRulelist.GDNum;
else
model.AreaSerial = "";
}
}
if (model.ExpressService == ("顺丰国际挂号(美国)"))
{
model.AreaSerial="4R-JFK";
if (model.RevZip != null && model.RevZip != "")
{
if (model.RevZip.Length!=5&&model.RevZip.Contains("-"))
{
model.RevZip = model.RevZip.Split('-')[0];
}
}
if (model.RevZip != null && model.RevZip.Length == 5)
{
try
{
int sfzip=Convert.ToInt32(model.RevZip);
var sflist = obj2.GetPostCodeRuleSF();
if (sflist != null)
{
var sfmd = sflist.Find(n => n.SCode <= sfzip && n.ECode >= sfzip);
if (sfmd != null)
model.AreaSerial = sfmd.AreaCode;
}
}
catch
{
}
}
}
if (model.ExpressService == ("顺丰国际挂号(其它)"))
{
model.AreaSerial = "1R-" + ordermodel.CountryCode + "-*";
//var sflist = obj2.GetPostCodeRuleSF();
//if (sflist != null)
//{
// var sfmd = sflist.Find(n => n.Area==ordermodel.CountryCode);
// if (sfmd != null)
// model.AreaSerial = sfmd.AreaCode;
//}
}
if (model.ExpressService.Contains("DHL"))
{
model.AreaSerial2 = "CNAEV543" + ordermodel.OrderId.ToString();
}
model.ShopName = ordermodel.ShopName;
model.SendPerson = CompanyModel.SendEnglishName;
model.SendAddress = CompanyModel.EnglishAddress;
model.SendPhone = CompanyModel.Phone;
model.SendZip = CompanyModel.PostCode;
model.BarCode = ordermodel.TrackCode;
model.BarOther = expressmd.UserCode;
model.OrderCode = ordermodel.PlatOrderCode;
model.JoinOrderCode = ordermodel.JoinOrderCode;
model.YCXX = ordermodel.ErrorInfo;
decimal totalprice = 0;
decimal djprice = 5;
int GoodsNum = 0;
decimal Weight = 0;
if (GoodsList != null)
{
List<OrderDetail> listod = new List<OrderDetail>();
string goodinfo = "";
string goodno = "";
foreach (var md1 in GoodsList)
{
decimal dj =5;
if (md1.BGPrice != null)
dj = md1.BGPrice.Value;
if (md1.GoodsNum != null)
{
totalprice += md1.GoodsNum.Value * dj;
GoodsNum += md1.GoodsNum.Value;
}
}
if (totalprice > 10)
totalprice = 10;
if(GoodsNum>0)
djprice = totalprice / GoodsNum;
foreach (var md1 in GoodsList)
{
if (goodno != md1.GoodsCode)
{
goodno = md1.GoodsCode;
if (md1.OldTypeDesc != null && md1.OldTypeDesc != "")
goodinfo +=md1.GoodsCode + "," + md1.GoodsName + ",[*" + md1.TypeCode + md1.TypeDesc + "-C*]" + md1.OldTypeDesc + ":[" + md1.GoodsNum.ToString() + "][" + md1.PostionDesc + "]; ";
else
goodinfo += md1.GoodsCode + "," + md1.GoodsName + ",[" + md1.TypeCode + "]" + md1.TypeDesc + ":[" + md1.GoodsNum.ToString() + "][" + md1.PostionDesc + "]; ";
}
else
{
if (md1.OldTypeDesc != null && md1.OldTypeDesc != "")
goodinfo += "[*" + md1.TypeCode + md1.TypeDesc + "-C*]" + md1.OldTypeDesc + ":[" + md1.GoodsNum.ToString() + "][" + md1.PostionDesc + "]; ";
else
goodinfo +="["+md1.TypeCode+"]"+md1.TypeDesc + ":[" + md1.GoodsNum.ToString() + "][" + md1.PostionDesc + "]; ";
}
model2 = new OrderDetail();
model.OrderId = md1.OrderId.GetValueOrDefault(0);
model2.OrderId = md1.OrderId.GetValueOrDefault(0);
var check = ListModel.Where(o => o.JoinOrderCode == ordermodel.JoinOrderCode && ordermodel.JoinOrderCode != null && ordermodel.JoinOrderCode != "").ToList();
if (check.Count()>1)
{
model.OrderId = check.First().OrderId;
model2.OrderId = check.First().OrderId;
}
else
{
var check2 = listod.Where(o => o.JoinOrderCode == ordermodel.JoinOrderCode);
if (check2.Count() > 0)
{
model2.OrderId = check2.First().OrderId;
model.OrderId = check2.First().OrderId;
}
}
model2.JoinOrderCode = ordermodel.JoinOrderCode;
model2.BarCode = ordermodel.TrackCode;
model2.GoodsCode =md1.GoodsCode;
if (md1.GoodsCode == null) model2.GoodsCode = "";
model2.GoodsNum = md1.GoodsNum.ToString();
//if (md1.GoodsNum != null)
// GoodsNum += md1.GoodsNum.Value;
//totalprice = 5;
//if (md1.BGPrice != null)
// totalprice = md1.BGPrice.Value;
//if (totalprice > 10) totalprice = 10;
//else if (md1.BGPrice != null)
// totalprice = md1.BGPrice.Value;
//else
// totalprice = 5;
//decimal goodprice = totalprice / md1.GoodsNum.GetValueOrDefault(1);
model2.GoodsPrice = djprice.ToString("0.0");
//totalprice += goodprice;
if (md1.Weight != null)
{
model2.GoodsWeight = (md1.Weight.Value / 1000).ToString();
Weight += md1.Weight.Value / 1000;
}
else
{
model2.GoodsWeight = "0.20";
Weight += Convert.ToDecimal(0.2);
}
model2.GoodsName =md1.GoodsName + "," + md1.TypeDesc;
if (md1.PostionDesc != null && md1.PostionDesc != "")
model2.GoodsName = md1.GoodsName + "," + md1.TypeDesc + ":[" + md1.PostionDesc + "]";
// if (md1.GoodsEnglisgName != null && md1.GoodsEnglisgName != "")
if (md1.OldTypeDesc != null && md1.OldTypeDesc != "")
model2.GoodsSimpleName = md1.GoodsName + ",[*" + md1.TypeCode + md1.TypeDesc + "-C*]" + md1.OldTypeDesc;
else
model2.GoodsSimpleName =md1.GoodsName + ",[" + md1.TypeCode + "]" + md1.TypeDesc;// md1.GoodsEnglisgName.ToString();
if (md1.PostionDesc != null && md1.PostionDesc != "")
{
if (md1.OldTypeDesc != null && md1.OldTypeDesc != "")
model2.GoodsSimpleName = md1.GoodsName + ",[*" + md1.TypeCode + md1.TypeDesc + "-C*]" + md1.OldTypeDesc + ":[" + md1.PostionDesc + "]";
else
model2.GoodsSimpleName = md1.GoodsName + ",[" + md1.TypeCode + "]" + md1.TypeDesc + ":[" + md1.PostionDesc + "]";
}
model2.GoodsOrigin = "China";
model2.TypeDesc = md1.TypeDesc;
model2.GoodsSku = md1.SKU1;
listod.Add(model2);
//model.ListModel.Add(model2);
if (model.ExpressService == "BPost")
{
model.GoodDes = md1.SKU1;
}
else
{
model.GoodDes = md1.GoodsEnglisgName;
}
if (model.ExpressService.Contains("EUB") || model.ExpressService.Contains("E邮宝"))
{
string Platcode="";
if (HBlist != null)
{
var data = HBlist.Where(o=>o.OrderId==md1.OrderId);
if(data.Count()>0)
{
Platcode = data.First().PlatOrderCode;
}
else
{
Platcode = ordermodel.PlatOrderCode;
}
}
else
{
Platcode = ordermodel.PlatOrderCode;
}
model2.GoodsSku =Platcode;
}
}
if (model.GoodDes == "") model.GoodDes = "Daily Goods";
model.ListModel = listod;
if (totalprice <= 0) totalprice = 5;
model.CountGoodsNum = GoodsNum.ToString();
if (totalprice > 10) totalprice = 10;
model.CountGoodsPrice =Math.Round(totalprice,2).ToString();
if (Weight == 0) Weight = 0.2M;
model.CountGoodsWeight = Weight.ToString();
model.GoodDetail = goodinfo;
}
if (ordermodel.Post.Value == 200 || ordermodel.Post.Value == 201 || ordermodel.Post.Value == 202)//线上西邮标准小包,无忧物流-标准(普货),无忧物流-标准(带电、化妆品)
{
if (ordermodel.TrackCode2 != null && ordermodel.TrackCode2 != "" && ordermodel.TrackCode2.Contains(","))
{
model.AreaSerial = ordermodel.TrackCode2.Split(',')[0];
model.AreaSerial2 = ordermodel.TrackCode2.Split(',')[1];
}
}
ListModel.Add(model);
}
}
}
//}
// }
return ListModel;
}
#region 返回邮编对应代码
public string Getcode(string zip)
{
try
{
if (ziplist == null)
return zip;
var str = "无";
string result = "无";
string count = zip.Trim();
str = count.PadLeft(5, '0');
str = str.Substring(0, 5);
string code = count[0].ToString() + count[1].ToString() + count[2].ToString();
var check = ziplist.Where(o => o.ZipBegin <= Convert.ToInt32(code) && o.ZipEnd >= Convert.ToInt32(code));
if (check != null && check.Count() > 0)
{
result = check.First().Code;
}
return result;
}
catch {
return "邮编格式不对";
}
}
public string GetcodeRU(string data)
{
var str = "1";
try
{
string temp = data.Substring(0, 3);
var check = ZRlist.Where(o => o.SNum <= Convert.ToInt32(temp) && o.ENum >= Convert.ToInt32(temp)&&o.Country=="RU");
if (check.Count() > 0)
{
str = check.First().DYNum;
}
}
catch
{
}
return str;
}
#endregion
List<StateAbbreviation> statelist = new List<StateAbbreviation>();
#region 返回对应格式地址
public string Getcustomera(string state)
{
if (statelist == null)
return state;
var check = statelist.Where(o => o.StateName.ToUpper().Trim() == state.Trim().ToUpper());
if (check!=null&&check.Count() > 0) state = check.First().StateCode;
return state;
}
#endregion
List<ZipCode> ziplist = new List<ZipCode>();
List<JC_PostCodeRule> ZRlist = new List<JC_PostCodeRule>();
#region 返回邮编对应列表
public void GetZIPModelForTM()
{
//List<ZipCode> list = null;
if (ziplist != null && ziplist.Count > 0)
return;
string tsql = @"SELECT * FROM ZipCode";
Database db = DatabaseFactory.CreateDatabase();
DbCommand cmd = db.GetSqlStringCommand(tsql);
DataSet ds = db.ExecuteDataSet(cmd);
ziplist = ds.Tables[0].ToList<ZipCode>();
}
public void GetZIPModelForTMELS()
{
//List<ZipCode> list = null;
if (ZRlist != null && ZRlist.Count > 0)
return;
string tsql = @"SELECT * FROM JC_PostCodeRule";
Database db = DatabaseFactory.CreateDatabase();
DbCommand cmd = db.GetSqlStringCommand(tsql);
DataSet ds = db.ExecuteDataSet(cmd);
ZRlist = ds.Tables[0].ToList<JC_PostCodeRule>();
}
public string GetcodeCA(string data)
{
var str = "A";
try
{
string zip = data;
//string zm1 = "ABCDEFGHIJKLMNOP";
string zm2 = "RSTUVWXYZ";
string temp = zip.Substring(0, 1);
if (zm2.Contains(temp.ToUpper()))
{
str = "B"; ;
}
}
catch
{
}
return str;
}
#endregion
#region 返回州对应列表
public void GetStateModelForTM()
{
if (statelist != null && statelist.Count > 0)
return;
string tsql = @"SELECT * FROM StateAbb";
Database db = DatabaseFactory.CreateDatabase();
DbCommand cmd = db.GetSqlStringCommand(tsql);
DataSet ds = db.ExecuteDataSet(cmd);
statelist = ds.Tables[0].ToList<StateAbbreviation>();
}
#endregion
}
}