diff --git a/BBWY.Client/Models/APIModel/Response/PurchaseSchemeResponse.cs b/BBWY.Client/Models/APIModel/Response/PurchaseSchemeResponse.cs index c03b1f40..79b3a1bc 100644 --- a/BBWY.Client/Models/APIModel/Response/PurchaseSchemeResponse.cs +++ b/BBWY.Client/Models/APIModel/Response/PurchaseSchemeResponse.cs @@ -27,6 +27,11 @@ namespace BBWY.Client.Models public string SkuId { get; set; } public long ShopId { get; set; } + /// + /// 采购平台 + /// + public Platform PurchasePlatform { get; set; } + public List PurchaseSchemeProductList { get; set; } } diff --git a/BBWY.Client/Models/Product/PurchaseScheme.cs b/BBWY.Client/Models/Product/PurchaseScheme.cs index 46a34d68..12ffed8f 100644 --- a/BBWY.Client/Models/Product/PurchaseScheme.cs +++ b/BBWY.Client/Models/Product/PurchaseScheme.cs @@ -31,6 +31,11 @@ namespace BBWY.Client.Models public string PurchaseProductId4 { get; set; } public int PurchaseProductSkuCount4 { get; set; } + /// + /// 采购平台 + /// + public Platform PurchasePlatform { get; set; } + /// /// 采购方案的商品集合 /// @@ -58,7 +63,8 @@ namespace BBWY.Client.Models RealCost = apiModel.RealCost ?? 0, PurchaserId = apiModel.PurchaserId, PurchaserName = apiModel.PurchaserName, - PurchaserLocation = apiModel.PurchaserLocation + PurchaserLocation = apiModel.PurchaserLocation, + PurchasePlatform = apiModel.PurchasePlatform }; foreach (var apiProduct in apiModel.PurchaseSchemeProductList) diff --git a/BBWY.Client/ViewModels/Ware/BindingPurchaseProductViewModel.cs b/BBWY.Client/ViewModels/Ware/BindingPurchaseProductViewModel.cs index a9ca386c..171aa833 100644 --- a/BBWY.Client/ViewModels/Ware/BindingPurchaseProductViewModel.cs +++ b/BBWY.Client/ViewModels/Ware/BindingPurchaseProductViewModel.cs @@ -115,7 +115,7 @@ namespace BBWY.Client.ViewModels foreach (var purchaseSchemeProduct in sku.SelectedPurchaseScheme.PurchaseSchemeProductList) { purchaseSchemeProduct.IsEditing = false; - LoadPurchaseProduct(purchaseSchemeProduct); + LoadPurchaseProduct(sku.SelectedPurchaseScheme.PurchasePlatform, purchaseSchemeProduct); } ewh.Set(); ewh.Dispose(); @@ -127,7 +127,7 @@ namespace BBWY.Client.ViewModels } } - public void LoadPurchaseProduct(PurchaseSchemeProduct purchaseSchemeProduct, IList skuList = null) + public void LoadPurchaseProduct(Platform platform, PurchaseSchemeProduct purchaseSchemeProduct, IList skuList = null) { App.Current.Dispatcher.Invoke(() => { @@ -136,7 +136,23 @@ namespace BBWY.Client.ViewModels }); if (skuList == null) - skuList = LoadPurchaseProductCore(purchaseSchemeProduct.PurchaseProductId, out _, out _, out _, out _, null); + { + //skuList = LoadPurchaseProductCore(purchaseSchemeProduct.PurchaseProductId, out _, out _, out _, out _, null); + var data = purchaseProductAPIService.GetProductInfo(platform, + purchaseSchemeProduct.ProductId, + purchaseSchemeProduct.SkuId, + purchaseSchemeProduct.PurchaseProductId, + PurchaseOrderMode.批发, + PurchaseProductAPIMode.Spider); + if (data != null) + { + PurchaserId = data.Value.purchaser.Id; + PurchaserName = data.Value.purchaser.Name; + PurchaserLocation = data.Value.purchaser.Location; + } + + } + if (skuList == null) return; @@ -154,63 +170,63 @@ namespace BBWY.Client.ViewModels }); } - private IList LoadPurchaseProductCore(string purchseProductId, - out string errorMsg, - out string purchaserId, - out string purchaserName, - out string purchaserLocation, - Func checkPurchaserFunc) - { - errorMsg = string.Empty; - purchaserId = string.Empty; - purchaserName = string.Empty; - purchaserLocation = string.Empty; - //1688商品详情接口 - var response = oneBoundAPIService.GetProductInfo("1688", purchseProductId); - if (!response.Success) - { - //记录日志 - - errorMsg = response.Msg; - return null; - } - var jobject = response.Data; - purchaserId = jobject["item"]["seller_info"].Value("user_num_id"); - purchaserName = jobject["item"]["seller_info"].Value("title"); - if (string.IsNullOrEmpty(purchaserName)) - purchaserName = jobject["item"]["seller_info"].Value("shop_name"); - purchaserLocation = jobject["item"].Value("location"); - if (checkPurchaserFunc != null) - { - errorMsg = checkPurchaserFunc(purchaserId); - if (!string.IsNullOrEmpty(errorMsg)) - return null; - } - //else if (PurchaserId != shopId) - //{ - // errorMsg = "同一条采购方案内的商品所属店铺必须相同"; - // return null; - //} - - var skuJArray = (JArray)jobject["item"]["skus"]["sku"]; - if (skuJArray.Count == 0) - { - errorMsg = $"商品{purchseProductId}缺少sku信息"; - return null; - } - - return skuJArray.Select(j => new PurchaseSchemeProductSku() - { - //ProductId = Product.Id, - //SkuId = purchaseSchemeProduct.SkuId, - PurchaseProductId = purchseProductId, - Price = j.Value("price"), - PurchaseSkuId = j.Value("sku_id"), - PurchaseSkuSpecId = j.Value("spec_id"), - Title = j.Value("properties_name"), - Logo = GetSkuLogo(j, (JArray)jobject["item"]["prop_imgs"]["prop_img"]) - }).ToList(); - } + //private IList LoadPurchaseProductCore(string purchseProductId, + // out string errorMsg, + // out string purchaserId, + // out string purchaserName, + // out string purchaserLocation, + // Func checkPurchaserFunc) + //{ + // errorMsg = string.Empty; + // purchaserId = string.Empty; + // purchaserName = string.Empty; + // purchaserLocation = string.Empty; + // //1688商品详情接口 + // var response = oneBoundAPIService.GetProductInfo("1688", purchseProductId); + // if (!response.Success) + // { + // //记录日志 + + // errorMsg = response.Msg; + // return null; + // } + // var jobject = response.Data; + // purchaserId = jobject["item"]["seller_info"].Value("user_num_id"); + // purchaserName = jobject["item"]["seller_info"].Value("title"); + // if (string.IsNullOrEmpty(purchaserName)) + // purchaserName = jobject["item"]["seller_info"].Value("shop_name"); + // purchaserLocation = jobject["item"].Value("location"); + // if (checkPurchaserFunc != null) + // { + // errorMsg = checkPurchaserFunc(purchaserId); + // if (!string.IsNullOrEmpty(errorMsg)) + // return null; + // } + // //else if (PurchaserId != shopId) + // //{ + // // errorMsg = "同一条采购方案内的商品所属店铺必须相同"; + // // return null; + // //} + + // var skuJArray = (JArray)jobject["item"]["skus"]["sku"]; + // if (skuJArray.Count == 0) + // { + // errorMsg = $"商品{purchseProductId}缺少sku信息"; + // return null; + // } + + // return skuJArray.Select(j => new PurchaseSchemeProductSku() + // { + // //ProductId = Product.Id, + // //SkuId = purchaseSchemeProduct.SkuId, + // PurchaseProductId = purchseProductId, + // Price = j.Value("price"), + // PurchaseSkuId = j.Value("sku_id"), + // PurchaseSkuSpecId = j.Value("spec_id"), + // Title = j.Value("properties_name"), + // Logo = GetSkuLogo(j, (JArray)jobject["item"]["prop_imgs"]["prop_img"]) + // }).ToList(); + //} private string GetSkuLogo(JToken skuJToken, JArray prop_img) {