From 8c0462e35f3d2e3ccd3b747cf0a445e1cd88571f Mon Sep 17 00:00:00 2001 From: wufan Date: Fri, 17 Jan 2025 15:42:27 +0800 Subject: [PATCH] :bug: --- TradeManageNew/DD_OrderServiceNew.asmx.cs | 89 +++++++++++++++++-- .../FedexValidateAddressModel.cs | 48 ++++++++++ .../OrderUsedSalePlatformPageDto.cs | 4 + TradeManageNew/TradeManageNew.csproj | 1 + 4 files changed, 137 insertions(+), 5 deletions(-) create mode 100644 TradeManageNew/Models/ShopifyUsedSale/FedexValidateAddressModel.cs diff --git a/TradeManageNew/DD_OrderServiceNew.asmx.cs b/TradeManageNew/DD_OrderServiceNew.asmx.cs index 8f79fb6..b87495b 100644 --- a/TradeManageNew/DD_OrderServiceNew.asmx.cs +++ b/TradeManageNew/DD_OrderServiceNew.asmx.cs @@ -28717,18 +28717,23 @@ namespace TradeManageNew var products = db.HW_GoodsInfo.Where(x => productIds.Contains(x.GoodsId)).Select(o => new { ProductId = o.GoodsId, + ProductName = o.GoodsName, + ProductEnName = o.GoodsEnglisgName, o.FirstImgUrl }).ToList(); foreach (var pageItem in page) { + var product = products.FirstOrDefault(x => x.ProductId == pageItem.ProductId); + var resultItem = new OrderUsedSalePlatformPageDto { Id = pageItem.Id, ProductId = pageItem.ProductId, ProductCode = pageItem.ProductCode, - ProductImageUrl = products.FirstOrDefault(x => x.ProductId == pageItem.ProductId) - ?.FirstImgUrl, + ProductImageUrl = product?.FirstImgUrl, + ProductName=product?.ProductName, + ProductEnName=product?.ProductEnName, SkuId = pageItem.SkuId, SkuCode = pageItem.SkuCode, BarCode = pageItem.BarCode, @@ -28768,8 +28773,8 @@ namespace TradeManageNew { var shopifyOrder = shopifyOrders.FirstOrDefault(x => x.Id == shopifyOrderItem.DtShopifyUsedSaleOrderId); - - var shopifyOrderDto =new ShopifyUsedSaleOrderInfoDto + + var shopifyOrderDto = new ShopifyUsedSaleOrderInfoDto { OrderId = shopifyOrder?.OrderId, OrderNumber = shopifyOrder?.OrderNumber, @@ -28791,6 +28796,7 @@ namespace TradeManageNew Currency = shopifyOrder?.Currency, TotalPrice = shopifyOrder?.TotalPrice, }; + resultItem.ShopifyOrder = shopifyOrderDto; } } @@ -29579,6 +29585,36 @@ namespace TradeManageNew Datas = null }; } + + var getAddressTypeParameter = new FedexValidateAddressModel + { + addressesToValidate = new List() + { + new addressesToValidate + { + address = new validateAddress() + { + streetLines = new[] { shopifyUsedSaleOrder.Full }, + city = shopifyUsedSaleOrder.City, + stateOrProvinceCode = shopifyUsedSaleOrder.ProvinceCode, + countryCode = shopifyUsedSaleOrder.CountryCode, + postalCode = shopifyUsedSaleOrder.Zip, + } + } + } + }; + var addressType = GetValidateAddressJump(getAddressTypeParameter, out var getAddressTypeError); + if (addressType == null || !string.IsNullOrEmpty(getAddressTypeError)) + { + return new APIReturnModel + { + Code = 0, + Message = $"[{orderUsedSalePlatform.BarCode}]获取地址类型失败,请稍后再试", + Datas = null + }; + } + //是否住宅地址 + bool isResidential = !(addressType.ToUpper() == "BUSINESS" || addressType.ToUpper() == "OFFICE"); //获取Fedex运费和面单 var fedexCredential = new FedexCredential(isDebugMode: true) { ReadResponseAsString = true }; @@ -29652,7 +29688,7 @@ namespace TradeManageNew StateOrProvinceCode = shopifyUsedSaleOrder.ProvinceCode, PostalCode = shopifyUsedSaleOrder.Zip, CountryCode = shopifyUsedSaleOrder.CountryCode, - Residential = null + Residential = isResidential }, Contact = new PartyContact { @@ -29716,6 +29752,17 @@ namespace TradeManageNew { var apiRequestInfo = new StringBuilder(); + //住宅地址无法获取Fedex_GROUND渠道 商业地址无法获取Fedex_HOME_DELIVERY + if (isResidential && serviceType == RequestedShipmentServiceType.FEDEX_GROUND) + { + continue; + } + + if (!isResidential && serviceType == RequestedShipmentServiceType.GROUND_HOME_DELIVERY) + { + continue; + } + try { //判断地址类型来跳过部分服务并且收获地址添加是否住宅 @@ -29814,6 +29861,38 @@ namespace TradeManageNew return null; } } + + public static string GetValidateAddressJump(FedexValidateAddressModel model, out string msg) + { + try + { + var path = EncryptString(JsonConvert.SerializeObject(model), "ThisIsShopifyKey12365498"); + var path2 = HttpUtility.UrlEncode(path); + var url = "http://50.196.110.198:8099" + "/api/FedexHelp/getValidateAddress?address=" + path2; + + using (WebClient client = new WebClient()) + { + string responseContent = client.DownloadString(url); + + if (string.IsNullOrEmpty(responseContent) || responseContent.Contains("Fail")) + { + msg = responseContent; + return null; + } + else + { + msg = ""; + var rmodel = JsonConvert.DeserializeObject(responseContent); + return rmodel.output.resolvedAddresses[0].classification; + } + } + } + catch (Exception ex) + { + msg = "失败"; + return null; + } + } #endregion diff --git a/TradeManageNew/Models/ShopifyUsedSale/FedexValidateAddressModel.cs b/TradeManageNew/Models/ShopifyUsedSale/FedexValidateAddressModel.cs new file mode 100644 index 0000000..4b543c4 --- /dev/null +++ b/TradeManageNew/Models/ShopifyUsedSale/FedexValidateAddressModel.cs @@ -0,0 +1,48 @@ +using System.Collections.Generic; + +namespace TradeManageNew.Models.ShopifyUsedSale +{ + /// + ///地址验证model + /// + public class FedexValidateAddressModel + { + public List addressesToValidate { get; set; } + } + + public class addressesToValidate + { + public validateAddress address { get; set; } + } + + public class validateAddress + { + public string[] streetLines { get; set; } + public string city { get; set; } + public string stateOrProvinceCode { get; set; } + public string postalCode { get; set; } + public string countryCode { get; set; } + } + + + /// + /// 地址验证返回model + /// + public class FedexValidateAddressReturnModel + { + public ValidateAddressOutput output { get; set; } + } + + public class ValidateAddressOutput + { + public List resolvedAddresses { get; set; } + } + + public class resolvedAddresses + { + /// + /// 地址类型BUSINESS商业地址,RESIDENTIAL住宅地址 + /// + public string classification { get; set; } + } +} \ No newline at end of file diff --git a/TradeManageNew/Models/ShopifyUsedSale/OrderUsedSalePlatformPageDto.cs b/TradeManageNew/Models/ShopifyUsedSale/OrderUsedSalePlatformPageDto.cs index 435bdf0..9b96aa7 100644 --- a/TradeManageNew/Models/ShopifyUsedSale/OrderUsedSalePlatformPageDto.cs +++ b/TradeManageNew/Models/ShopifyUsedSale/OrderUsedSalePlatformPageDto.cs @@ -23,6 +23,10 @@ namespace TradeManageNew.Models.ShopifyUsedSale /// public string ProductImageUrl { get; set; } + public string ProductName { get; set; } + + public string ProductEnName { get; set; } + /// /// SKU ID /// diff --git a/TradeManageNew/TradeManageNew.csproj b/TradeManageNew/TradeManageNew.csproj index b228d18..9de2119 100644 --- a/TradeManageNew/TradeManageNew.csproj +++ b/TradeManageNew/TradeManageNew.csproj @@ -2924,6 +2924,7 @@ +