private string CalcSF(FedExQueryAdv ship) { var result = string.Empty; //1:CNY 2:USD ship.CoinType = ConfigurationManager.AppSettings["CoinType"] == "1" ? "CNY" : "USD"; ShipmentEx shipment = null; //获得采购商地址 ShopInfo shop = ServiceHelper.Create <IShopService>().GetShop(ship.ShopId, true); if (shop != null) { ship.OrigId = shop.CompanyRegionId; ship.OrigAddress = shop.CompanyAddress; ship.OrigPostCode = shop.ZipCode; } shipment = ServiceHelper.Create <IShipmentService>().CalcSFCostAdv(ship); if (shipment != null) { result = Newtonsoft.Json.JsonConvert.SerializeObject(shipment); } return(result); }
public JsonResult SubmitOrderFun(string json) { //1:CNY 2:USD string CoinType = ConfigurationManager.AppSettings["CoinType"] == null ? "2" : ConfigurationManager.AppSettings["CoinType"]; try { MarginBillModel margin = Newtonsoft.Json.JsonConvert.DeserializeObject <MarginBillModel>(json); // MargainBill model = Newtonsoft.Json.JsonConvert.DeserializeObject<MargainBill>(json); MargainBill model = null; ShipmentEx ship = null; if (margin != null) { model = Newtonsoft.Json.JsonConvert.DeserializeObject <MargainBill>(margin.Bill); ship = Newtonsoft.Json.JsonConvert.DeserializeObject <ShipmentEx>(margin.Ship); } if (model != null) { //if (model.DeliverDate.Date < DateTime.Now.Date) //{ // return Json(new { success = false, state = 1, msg = "发货时间在今天之前!" }); //} model.BillStatus = EnumBillStatus.SubmitBargain; model.CreateDate = DateTime.Now; model.IsDelete = 0; model.MemberId = CurrentUser.Id; model.TotalAmount = 0; foreach (var item in model._MargainBillDetail) { item.CreateDate = DateTime.Now; item.IsDelete = 0; model.TotalAmount += item.PurchasePrice; item.Bidder = base.CurrentUser.Id; } model.CoinType = long.Parse(CoinType); ServiceHelper.Create <IMargainBillService>().SubmitOrder(model, ship); long userid = ServiceHelper.Create <IManagerService>().GetMemberIdByShopId(model.ShopId) == null ? 0 : ServiceHelper.Create <IManagerService>().GetMemberIdByShopId(model.ShopId).Id; string messagecontent = "用户" + base.CurrentUser.UserName + "向你提交了订单,单号:" + model.BillNo + "。请查看。"; ServiceHelper.Create <ISiteMessagesService>().SendSiteMessages(userid, (int)MessageSetting.MessageModuleStatus.OrderCreated, messagecontent, base.CurrentUser.UserName); return(Json(new { success = true, msg = "success!" })); } else { return(Json(new { success = false, state = 0, msg = "提交失败!" })); } } catch (Exception) { return(Json(new { success = false, state = 1, msg = "提交失败!" })); } }
// GET: Shipment/Index public ActionResult Index(long orderId) { ShipmentEx ship = ServiceHelper.Create <IShipmentService>().GetShipmnet(orderId); if (ship != null) { ViewBag.model = ship; } return(View()); }
/// <summary> /// 货物fed物流信息 /// </summary> /// <param name="orderId"></param> /// <returns></returns> public ShipmentEx GetShipmentByOrder(long orderId) { ShipmentEx shipEx = null; try { //shipEx = new ShipmentEx(); Shipment ship = context.Shipment.FirstOrDefault(x => x.OrderId == orderId); if (ship != null) { ShipmentAddress orgAddress = context.ShipmentAddress.FirstOrDefault(x => (x.ShipmentId == ship.Id) && (x.State == "Origin")); ShipmentAddress destAddress = context.ShipmentAddress.FirstOrDefault(x => (x.ShipmentId == ship.Id) && (x.State == "Dest")); List <ShipmentPackage> pkgList = context.ShipmentPackage.Where(x => x.ShipmentId == ship.Id).ToList(); Address orgAddressEx = new Address(orgAddress.Line1, orgAddress.Line2, orgAddress.Line3, orgAddress.City, "", orgAddress.PostalCode, orgAddress.CountryCode); orgAddressEx.CountryName = orgAddress.CountryName; Address destAddressEx = new Address(destAddress.Line1, destAddress.Line2, destAddress.Line3, destAddress.City, "", destAddress.PostalCode, destAddress.CountryCode); destAddressEx.CountryName = destAddress.CountryName; List <Package> pkgExList = new List <Package>(); Package package = null; string packType = string.Empty; foreach (ShipmentPackage item in pkgList) { WeightUnit wUnit = item.ShipWeightUnit == "KG" ? WeightUnit.KG : WeightUnit.LB; LinearUnit lUnit = item.ShipLinearUnit == "CM" ? LinearUnit.CM : LinearUnit.IN; package = new Package(item.Length, item.Width, item.Height, item.Weight, item.InsuredValue, wUnit, lUnit); dicList.TryGetValue(item.PackageType, out packType); dicList.TryGetValue(item.PackageType, out packType); package.PackageType = packType; pkgExList.Add(package); } Rate rate = new Rate(ship.RateProvider, ship.RateProviderCode, ship.RateName, ship.TotalCharges, ship.GurDeliveryDate); shipEx = new ShipmentEx(orgAddressEx, destAddressEx, pkgExList); shipEx.RateValue = rate; } } catch { } return(shipEx); }
public string CalcPriceAdv(FedExQueryAdv ship) { var result = string.Empty; //1:CNY 2:USD ship.CoinType = ConfigurationManager.AppSettings["CoinType"] == "1" ? "CNY" : "USD"; var appSettings = ConfigurationManager.AppSettings; ship.FedexKey = appSettings["FedExKey"]; ship.FedexPassword = appSettings["FedExPassword"]; ship.FedexAccountNumber = appSettings["FedExAccountNumber"]; ship.FedexMeterNumber = appSettings["FedExMeterNumber"]; ShipmentEx shipment = null; if (ship.ShopId > 0) { //获得采购商地址 ShopInfo shop = ServiceHelper.Create <IShopService>().GetShop(ship.ShopId, true); ship.OrigId = shop.CompanyRegionId; ship.OrigAddress = shop.CompanyAddress; ship.OrigPostCode = shop.ZipCode; shipment = ServiceHelper.Create <IShipmentService>().CalcPriceAdv(ship); if (shipment != null) { result = Newtonsoft.Json.JsonConvert.SerializeObject(shipment); } } else { shipment = ServiceHelper.Create <IShipmentService>().CalcPrice(ship); if (shipment != null) { result = Newtonsoft.Json.JsonConvert.SerializeObject(shipment); } } return(result); }
/// <summary> /// 下单 /// </summary> /// <param name="model"></param> public void SubmitOrder(MargainBill margainbill, ShipmentEx shipment) { try { //订单号 ChemCloud.Service.Order.Business.OrderBO _orderBO = new ChemCloud.Service.Order.Business.OrderBO(); long orderid = _orderBO.GenerateOrderNumber(); //收货信息 ShippingAddressService _ShippingAddressService = new ShippingAddressService(); ShippingAddressInfo addressinfo = _ShippingAddressService.GetUserShippingAddress(long.Parse(margainbill.RegionId.ToString())); //供应商 ShopService _ShopService = new ShopService(); string shopname = _ShopService.GetShopName(margainbill.ShopId); //会员 MemberService _MemberService = new MemberService(); string username = _MemberService.GetMember(margainbill.MemberId) == null ? "" : (_MemberService.GetMember(margainbill.MemberId).UserName == null ? "" : _MemberService.GetMember(margainbill.MemberId).UserName); using (TransactionScope transactionScope = new TransactionScope()) { OrderInfo orderInfo = new OrderInfo(); orderInfo.Id = orderid; //订单号 orderInfo.ShopId = margainbill.ShopId; //供应商编号ChemCloud_Shops orderInfo.ShopName = shopname; orderInfo.UserId = margainbill.MemberId; //采购商ChemCloud_Members orderInfo.UserName = username; orderInfo.OrderDate = DateTime.Now; //订单日期 orderInfo.ExpressCompanyName = margainbill.DeliverType; //物流配送方式 orderInfo.Freight = margainbill.DeliverCost; //运费 //orderInfo.ShippingDate = margainbill.DeliverDate; //发货日期 orderInfo.PaymentTypeName = margainbill.PayMode; //支付方式 orderInfo.ProductTotalAmount = margainbill.TotalAmount; //产品金额 orderInfo.CoinType = margainbill.CoinType; //货币种类 orderInfo.ShipTo = addressinfo.ShipTo; //收货人 orderInfo.TopRegionId = addressinfo.RegionId; //RegionId orderInfo.RegionId = addressinfo.RegionId; //RegionId orderInfo.RegionFullName = addressinfo.RegionFullName; //省市区街道 orderInfo.Address = addressinfo.Address; orderInfo.CellPhone = addressinfo.Phone; orderInfo.OrderStatus = OrderInfo.OrderOperateStatus.WaitPay;//订单 orderInfo.IsPrinted = false; orderInfo.RefundTotalAmount = new decimal(0); orderInfo.CommisTotalAmount = new decimal(0); orderInfo.RefundCommisAmount = new decimal(0); orderInfo.Platform = PlatformType.PC; /*发票信息*/ if (margainbill.InvoiceType == 0) { orderInfo.InvoiceType = InvoiceType.None; } else if (margainbill.InvoiceType == 1) { orderInfo.InvoiceType = InvoiceType.VATInvoice; } else if (margainbill.InvoiceType == 2) { orderInfo.InvoiceType = InvoiceType.OrdinaryInvoices; } else if (margainbill.InvoiceType == 3) { orderInfo.InvoiceType = InvoiceType.SpecialTicket; } orderInfo.InvoiceTitle = margainbill.InvoiceTitle; //名称 orderInfo.InvoiceContext = margainbill.InvoiceContext; //纳税人识别号 orderInfo.SellerPhone = margainbill.SellerPhone; //电话 orderInfo.SellerRemark = margainbill.SellerRemark; //开户行及账号 orderInfo.SellerAddress = margainbill.SellerAddress; //地址 /*发票信息*/ orderInfo.DiscountAmount = new decimal(0); orderInfo.ActiveType = OrderInfo.ActiveTypes.None; orderInfo.IntegralDiscount = new decimal(0); orderInfo.IsInsurance = margainbill.IsInsurance; orderInfo.Insurancefee = margainbill.Insurancefee; //保险费 orderInfo.Transactionfee = 0; //交易费 orderInfo.Counterfee = 0; //手续费 context.OrderInfo.Add(orderInfo); context.SaveChanges(); foreach (MargainBillDetail billdetail in margainbill._MargainBillDetail) { OrderItemInfo orderInfoitem = new OrderItemInfo(); orderInfoitem.OrderId = orderid; orderInfoitem.ShopId = margainbill.ShopId; orderInfoitem.ProductId = billdetail.ProductId; orderInfoitem.ProductName = billdetail.ProductName; orderInfoitem.Quantity = billdetail.Num; orderInfoitem.SalePrice = billdetail.PurchasePrice; orderInfoitem.PackingUnit = billdetail.PackingUnit; orderInfoitem.Purity = billdetail.Purity; orderInfoitem.SpecLevel = billdetail.SpecLevel; orderInfoitem.ReturnQuantity = long.Parse("1"); orderInfoitem.CostPrice = 0; orderInfoitem.DiscountAmount = 0; orderInfoitem.RealTotalPrice = 0; orderInfoitem.RefundPrice = 0; orderInfoitem.CommisRate = 0; orderInfoitem.IsLimitBuy = false; context.OrderItemInfo.Add(orderInfoitem); context.SaveChanges(); } //下单成功 更改状态 margainbill.BillStatus = EnumBillStatus.BargainSucceed; context.SaveChanges(); //保存物流信息 if (shipment != null) { ShipmentService ship = new ShipmentService(); ship.SaveShipmentEx(shipment, orderid); } transactionScope.Complete(); } //保存物流信息 //if (shipment != null) //{ // ShipmentService ship = new ShipmentService(); // ship.SaveShipment(shipment, orderid); //} } catch (DbEntityValidationException ex) { } }
/// <summary> /// 生成运单 /// </summary> public ShipReply CreateShip(CreateShipQuery shipQuery) { ShipReply reply = new ShipReply(); FedExShipService shipService = new FedExShipService(shipQuery.Url, shipQuery.Key, shipQuery.Password, shipQuery.AccountNumber, shipQuery.MeterNumber); List <Package> packages = new List <Package>(); Package pkg; foreach (ShipPackage item in shipQuery.ShipPkgs) { //pkg = GetPackage(item); //pkg.Currency = shipQuery.CoinType; //pkg.Description = item.Description; //pkg.PackageCount = item.Num; //pkg.PackageType = "自备包装"; //packages.Add(pkg); if (item.Num > 0) { for (int i = 0; i < item.Num; i++) { pkg = GetPackage(item); pkg.Currency = shipQuery.CoinType; pkg.Description = item.Description; pkg.PackageCount = 1; pkg.PackageType = "自备包装"; packages.Add(pkg); } } } try { ShipmentEx shipEx = new ShipmentEx(shipQuery.Origin, shipQuery.Dest, packages); shipEx.Currency = shipQuery.CoinType; CreateShipRep shipRep = shipService.CreateShip(shipEx); List <ShipReply> replyList = shipRep.ReplyList; reply.ErrorMessage = shipRep.Message; if (replyList != null) { foreach (ShipReply item in replyList) { OrderShip orderShip = new OrderShip() { OrderId = shipQuery.OrderId, OrderItemId = shipQuery.OrderItemId, TrackFormId = item.TrackFormId, TrackNumber = item.TrackNumber }; // orderShip.LabelImage = item.LabelImage; string result = System.Text.Encoding.UTF8.GetString(item.LabelImage); orderShip.LabelImage = item.LabelImage; orderShip.Master = item.Master; context.OrderShip.Add(orderShip); } context.SaveChanges(); List <ShipReply> tmpShip = replyList.Where(x => x.Master == true).ToList(); if (tmpShip.Count > 0) { reply = tmpShip[0]; } } } catch (DbEntityValidationException dbEx) { } catch (Exception ex) { } return(reply); }
/// <summary> /// 计算顺丰物流费用 /// </summary> /// <param name="ship"></param> /// <returns></returns> public ShipmentEx CalcSFCostAdv(FedExQueryAdv ship) { ShipmentEx result = null; try { SFRateRequest rateRequest = new SFRateRequest(); string countyCode = string.Empty; string countyName = string.Empty; CountryInfo county = null; var packages = new List <Package>(); Package pkg = null; CountryInfo ortCity = context.CountryInfo.SingleOrDefault(x => x.ID == ship.OrigId); if (ortCity != null) { county = GetCountry(ortCity.PID); if (county != null) { countyCode = county.Code; countyName = county.ContryNameEN; if (countyCode.ToUpper() != "CN") { rateRequest.OriginCode = county.SFCode; rateRequest.ParentOriginCode = county.SFCode; } else { rateRequest.OriginCode = ortCity.SFCode; rateRequest.ParentOriginCode = ortCity.SFCode; } } } var origin = new Address(ship.OrigAddress, "", "", ortCity.ContryNameEN, "", ship.OrigPostCode, countyCode); origin.CountryName = countyName; //获取目的地 ShippingAddressInfo destAddress = context.ShippingAddressInfo.SingleOrDefault(x => x.Id == ship.DestId); CountryInfo destCity = context.CountryInfo.SingleOrDefault(x => x.ID == destAddress.RegionId); if (destCity != null) { county = null; county = GetCountry(destCity.PID); if (county != null) { countyCode = county.Code; countyName = county.ContryNameEN; if (countyCode.ToUpper() != "CN") { rateRequest.DestCode = county.SFCode; rateRequest.ParentDestCode = county.SFCode; } else { rateRequest.DestCode = destCity.SFCode; rateRequest.ParentDestCode = destCity.SFCode; } } } var destination = new Address(destAddress.Address, "", "", destCity.ContryNameEN, "", destAddress.PostCode, countyCode); destination.CountryName = countyName; rateRequest.Volume = 0; rateRequest.QueryType = 5; rateRequest.Lang = "sc"; rateRequest.Region = "cn"; foreach (ShipPackage item in ship.PackagesList) { pkg = GetPackage(item, 6000); pkg.Currency = ship.CoinType; pkg.PackageCount = item.Num; pkg.PackageType = "自备包装"; packages.Add(pkg); } rateRequest.Weight = Math.Round(packages.Sum(x => x.Weight), 2); // rateRequest.Time = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd hh:mm");//"2016-07-06T13%3A30%3A00%2B08%3A00" DateTime dtNow = DateTime.Now; rateRequest.Time = string.Format("{0}T{1}%3A{2}%3A{3}%2B08%3A00", dtNow.ToString("yyyy-MM-dd"), dtNow.ToString("hh"), dtNow.ToString("mm"), dtNow.ToString("ss")); var rateManager = new RateManager(); rateManager.AddProvider(new SFProvider(rateRequest)); result = rateManager.GetRates(origin, destination, packages); if (result.Rates != null && result.Rates.Count > 0) { result.RateValue = result.Rates[0]; } } catch (Exception ex) { } return(result); }
/// <summary> /// 保存物流信息 /// </summary> /// <param name="shipment"></param> /// <param name="orderId"></param> public void SaveShipmentEx(ShipmentEx shipment, long orderId) { try { Shipment ship = new Shipment(); Address oriAddress = shipment.OriginAddress; Address destAddress = shipment.DestinationAddress; Rate rate = null; if (shipment.RateValue != null) { rate = shipment.RateValue; } else { rate = new Rate(); rate.GuaranteedDelivery = DateTime.Now; } ship.Id = GenerateNumber(); ship.OrderId = orderId; ship.PackageCount = shipment.PackageCount; ship.TotalPackageWeight = shipment.TotalPackageWeight; if (!string.IsNullOrWhiteSpace(rate.Name)) { ship.RateName = rate.Name.Trim(); } else { ship.RateName = null; } ship.GurDeliveryDate = rate.GuaranteedDelivery == null ? DateTime.Now : Convert.ToDateTime(rate.GuaranteedDelivery); ship.RateProvider = rate.Provider; ship.RateProviderCode = rate.ProviderCode; ship.TotalCharges = rate.TotalCharges; context.Shipment.Add(ship); ShipmentAddress orgAddress = new ShipmentAddress(); orgAddress.ShipmentId = ship.Id; orgAddress.City = oriAddress.City; orgAddress.CountryCode = oriAddress.CountryCode; orgAddress.CountryName = oriAddress.CountryName; orgAddress.Line1 = oriAddress.Line1; orgAddress.Line2 = oriAddress.Line2; orgAddress.Line3 = oriAddress.Line3; orgAddress.State = "Origin"; orgAddress.PostalCode = oriAddress.PostalCode; context.ShipmentAddress.Add(orgAddress); ShipmentAddress DAddress = new ShipmentAddress(); DAddress.ShipmentId = ship.Id; DAddress.City = destAddress.City; DAddress.CountryCode = destAddress.CountryCode; DAddress.CountryName = destAddress.CountryName; DAddress.Line1 = destAddress.Line1; DAddress.Line2 = destAddress.Line2; DAddress.Line3 = destAddress.Line3; DAddress.State = "Dest"; DAddress.PostalCode = destAddress.PostalCode; context.ShipmentAddress.Add(DAddress); //包裹 List <Package> packages = shipment.Packages; ShipmentPackage shipPgk = null; foreach (Package item in packages) { shipPgk = new ShipmentPackage(); shipPgk.ShipmentId = ship.Id; shipPgk.Currency = item.Currency; shipPgk.Height = item.Height; shipPgk.InsuredValue = item.InsuredValue; shipPgk.Length = item.Length; shipPgk.PackageType = item.PackageType; shipPgk.ShipLinearUnit = item.ShipLinearUnit == LinearUnit.CM ? "CM" : "IN"; shipPgk.ShipWeightUnit = item.ShipWeightUnit == WeightUnit.KG ? "KG" : "LB"; shipPgk.Weight = item.Weight; shipPgk.Width = item.Width; context.ShipmentPackage.Add(shipPgk); } context.SaveChanges(); } catch (DbEntityValidationException ex) { } }
/// <summary> /// 计算Fedex费用 /// </summary> /// <param name="ship"></param> /// <returns></returns> public ShipmentEx CalcPriceAdv(FedExQueryAdv ship) { ShipmentEx result = null; try { string countyCode = string.Empty; string countyName = string.Empty; CountryInfo county = null; var packages = new List <Package>(); Package pkg = null; //获取始发地 //ShippingAddressInfo orgAddress = context.ShippingAddressInfo.SingleOrDefault(x => x.Id == ship.OrigId); //CountryInfo ortCity = context.CountryInfo.SingleOrDefault(x => x.ID == orgAddress.RegionId); //county = GetCountry(ortCity.PID); //if (county != null) //{ // countyCode = county.Code; // countyName = county.ContryNameEN; //} //var origin = new Address(orgAddress.Address, "", "", ortCity.ContryNameEN, "", ortCity.Code, countyCode); //origin.CountryName = countyName; CountryInfo ortCity = context.CountryInfo.SingleOrDefault(x => x.ID == ship.OrigId); county = GetCountry(ortCity.PID); if (county != null) { countyCode = county.Code; countyName = county.ContryNameEN; } var origin = new Address(ship.OrigAddress, "", "", ortCity.ContryNameEN, "", ship.OrigPostCode, countyCode); origin.CountryName = countyName; //获取目的地 ShippingAddressInfo destAddress = context.ShippingAddressInfo.SingleOrDefault(x => x.Id == ship.DestId); CountryInfo destCity = context.CountryInfo.SingleOrDefault(x => x.ID == destAddress.RegionId); county = null; county = GetCountry(destCity.PID); if (county != null) { countyCode = county.Code; countyName = county.ContryNameEN; } var destination = new Address(destAddress.Address, "", "", destCity.ContryNameEN, "", destAddress.PostCode, countyCode); destination.CountryName = countyName; foreach (ShipPackage item in ship.PackagesList) { //if (item.Num > 0) //{ // for (int i = 0; i < item.Num; i++) // { // pkg = GetPackage(item); // pkg.Currency = ship.CoinType; // pkg.PackageCount = 1; // pkg.PackageType = "自备包装"; // packages.Add(pkg); // } //} pkg = GetPackage(item); pkg.Currency = ship.CoinType; pkg.PackageCount = item.Num; pkg.PackageType = "自备包装"; packages.Add(pkg); } var rateManager = new RateManager(); rateManager.AddProvider(new FedExProvider(ship.FedexKey, ship.FedexPassword, ship.FedexAccountNumber, ship.FedexMeterNumber)); result = rateManager.GetRates(origin, destination, packages); if (result.Rates != null && result.Rates.Count > 0) { result.RateValue = result.Rates[0]; } } catch (Exception ex) { } return(result); }
/// <summary> /// 保存物流信息 /// </summary> /// <param name="shipment"></param> /// <param name="orderId"></param> /// <returns></returns> public int SaveShipment(ShipmentEx shipment, long orderId) { int result = 0; try { List <string> sqlList = new List <string>(); long ident = -1; Rate rate = null; if (shipment.Rates.Count > 0) { rate = shipment.Rates[0]; } else { rate = new Rate(); } long shipObj = GenerateNumber(); //物流信息 StringBuilder sqlString = new StringBuilder(); sqlString.AppendFormat(@"INSERT INTO ChemCloud_Shipment (Id,OrderId,PackageCount,TotalPackageWeight,GurDeliveryDate,RateName,RateProvider,RateProviderCode,TotalCharges) VALUES({0},{1},{2},{3},'{4}','{5}','{6}','{7}',{8})", shipObj, orderId, shipment.PackageCount, shipment.TotalPackageWeight, rate.GurDeliveryDate, rate.Name, rate.Provider, rate.ProviderCode, rate.TotalCharges); sqlList.Add(sqlString.ToString()); sqlString.Clear(); ident = shipObj; Address oriAddress = shipment.OriginAddress; //始运地 sqlString.AppendFormat(@"INSERT INTO ChemCloud_ShipmentAddress (ShipmentId,CountryCode,CountryName,PostalCode,City,State,Line1,Line2,Line3) VALUES({0},'{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}')", ident, oriAddress.CountryCode, oriAddress.CountryName, oriAddress.PostalCode, oriAddress.City, "Origin", oriAddress.Line1, oriAddress.Line2, oriAddress.Line3); sqlList.Add(sqlString.ToString()); sqlString.Clear(); //目的地 Address destAddress = shipment.DestinationAddress; sqlString.AppendFormat(@"INSERT INTO ChemCloud_ShipmentAddress (ShipmentId,CountryCode,CountryName,PostalCode,City,State,Line1,Line2,Line3) VALUES({0},'{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}')", ident, destAddress.CountryCode, destAddress.CountryName, destAddress.PostalCode, destAddress.City, "Dest", destAddress.Line1, destAddress.Line2, destAddress.Line3); sqlList.Add(sqlString.ToString()); //包裹 List <Package> packages = shipment.Packages; foreach (Package item in packages) { sqlString.Clear(); sqlString.AppendFormat(@"INSERT INTO ChemCloud_ShipmentPackage (ShipmentId,Weight,ShipWeightUnit,Currency,PackageType,Length,Width,Height,InsuredValue,ShipLinearUnit) VALUES({0},{1},'{2}','{3}','{4}','{5}',{6},{7},{8},'{9}')", ident, item.Weight, item.ShipWeightUnit, item.Currency, item.PackageType, item.Length, item.Weight, item.Height, item.InsuredValue, item.ShipLinearUnit); sqlList.Add(sqlString.ToString()); } using (TransactionScope transactionScope = new TransactionScope()) { result = DbHelperSQL.ExecuteSqlTran(sqlList); transactionScope.Complete(); } } catch (Exception ex) { } return(result); }