public JsonResult CreateShipInfo(string orderid) { ShipReply reply = null; try { long orderId = long.Parse(orderid); OrderInfo order = ServiceHelper.Create <IOrderService>().GetOrder(orderId); ISiteSettingService siteService = ServiceHelper.Create <ISiteSettingService>(); string FedExKey = siteService.GetSiteValue("FedExKey"); string FedExPassword = siteService.GetSiteValue("FedExPassword"); string FedExAccountNumber = siteService.GetSiteValue("FedExAccountNumber"); string FedExMeterNumber = siteService.GetSiteValue("FedExMeterNumber"); string FedShipUrl = siteService.GetSiteValue("FedShipUrl"); string FedPersonName = siteService.GetSiteValue("PlatformCollectionPersonName"); string FedCompanyName = siteService.GetSiteValue("PlatformCollectionCompanyName"); string FedPhoneNumber = siteService.GetSiteValue("PlatformCollectionPhoneNumber"); string FedStreetLine = siteService.GetSiteValue("PlatformCollectionStreetLine"); string FedCity = siteService.GetSiteValue("PlatformCollectionCity"); string FedPostalCode = siteService.GetSiteValue("PlatformCollectionPostalCode"); string FedCountryCode = siteService.GetSiteValue("PlatformCollectionCountryCode"); IShipmentService shipmentService = ServiceHelper.Create <IShipmentService>(); Address origin = new Address(FedStreetLine, "", "", FedCity, "", FedPostalCode, FedCountryCode); origin.PersonName = FedPersonName; origin.PhoneNumber = FedPhoneNumber; origin.CompanyName = FedCompanyName; Address dest = shipmentService.GetAddress(order.UserId, order.RegionId); if (dest != null) { dest.Line1 = order.Address; dest.PersonName = order.ShipTo; dest.PhoneNumber = order.CellPhone; } else { dest = new Address(order.Address, null, null, null, null, null, null); dest.PersonName = order.ShipTo; dest.PhoneNumber = order.CellPhone; } List <OrderItemInfo> itemInfoList = order.OrderItemInfo.OrderBy(x => x.Id).ToList(); if (itemInfoList != null && itemInfoList.Count > 0) { List <ShipPackage> pkgList = new List <ShipPackage>(); foreach (OrderItemInfo item in itemInfoList) { ShipPackage package = new ShipPackage() { Num = Convert.ToInt32(item.Quantity), PackingUnit = item.PackingUnit }; package.OrderItemId = item.Id; package.Description = string.Format("{0}-{1}", item.ProductName, item.SpecLevel); pkgList.Add(package); } CreateShipQuery query = new CreateShipQuery() { Url = FedShipUrl, Key = FedExKey, Password = FedExPassword, AccountNumber = FedExAccountNumber, MeterNumber = FedExMeterNumber }; query.ShipPkgs = pkgList; query.Origin = origin; query.Dest = dest; query.CoinType = order.CoinType == 1 ? "CNY" : "USD"; query.OrderId = orderId; reply = shipmentService.CreateShip(query); } if (reply != null) { if (!String.IsNullOrEmpty(reply.TrackNumber)) { return(Json(new { Success = true, TrackNumber = reply.TrackNumber })); } else { return(Json(new { TrackNumber = "", msg = reply.ErrorMessage })); } } else { return(Json(new { TrackNumber = "" })); } } catch (Exception ex) { return(Json(new { msg = ex.Message })); } }