|
|
@ -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<PurchaseSchemeProductSku> skuList = null) |
|
|
|
public void LoadPurchaseProduct(Platform platform, PurchaseSchemeProduct purchaseSchemeProduct, IList<PurchaseSchemeProductSku> 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<PurchaseSchemeProductSku> LoadPurchaseProductCore(string purchseProductId, |
|
|
|
out string errorMsg, |
|
|
|
out string purchaserId, |
|
|
|
out string purchaserName, |
|
|
|
out string purchaserLocation, |
|
|
|
Func<string, string> 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<string>("user_num_id"); |
|
|
|
purchaserName = jobject["item"]["seller_info"].Value<string>("title"); |
|
|
|
if (string.IsNullOrEmpty(purchaserName)) |
|
|
|
purchaserName = jobject["item"]["seller_info"].Value<string>("shop_name"); |
|
|
|
purchaserLocation = jobject["item"].Value<string>("location"); |
|
|
|
if (checkPurchaserFunc != null) |
|
|
|
{ |
|
|
|
errorMsg = checkPurchaserFunc(purchaserId); |
|
|
|
if (!string.IsNullOrEmpty(errorMsg)) |
|
|
|
return null; |
|
|
|
} |
|
|
|
//else if (PurchaserId != shopId)
|
|
|
|
//private IList<PurchaseSchemeProductSku> LoadPurchaseProductCore(string purchseProductId,
|
|
|
|
// out string errorMsg,
|
|
|
|
// out string purchaserId,
|
|
|
|
// out string purchaserName,
|
|
|
|
// out string purchaserLocation,
|
|
|
|
// Func<string, string> checkPurchaserFunc)
|
|
|
|
//{
|
|
|
|
// errorMsg = string.Empty;
|
|
|
|
// purchaserId = string.Empty;
|
|
|
|
// purchaserName = string.Empty;
|
|
|
|
// purchaserLocation = string.Empty;
|
|
|
|
// //1688商品详情接口
|
|
|
|
// var response = oneBoundAPIService.GetProductInfo("1688", purchseProductId);
|
|
|
|
// if (!response.Success)
|
|
|
|
// {
|
|
|
|
// errorMsg = "同一条采购方案内的商品所属店铺必须相同";
|
|
|
|
// //记录日志
|
|
|
|
|
|
|
|
// errorMsg = response.Msg;
|
|
|
|
// return null;
|
|
|
|
// }
|
|
|
|
// var jobject = response.Data;
|
|
|
|
// purchaserId = jobject["item"]["seller_info"].Value<string>("user_num_id");
|
|
|
|
// purchaserName = jobject["item"]["seller_info"].Value<string>("title");
|
|
|
|
// if (string.IsNullOrEmpty(purchaserName))
|
|
|
|
// purchaserName = jobject["item"]["seller_info"].Value<string>("shop_name");
|
|
|
|
// purchaserLocation = jobject["item"].Value<string>("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;
|
|
|
|
// }
|
|
|
|
|
|
|
|
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<decimal>("price"), |
|
|
|
PurchaseSkuId = j.Value<string>("sku_id"), |
|
|
|
PurchaseSkuSpecId = j.Value<string>("spec_id"), |
|
|
|
Title = j.Value<string>("properties_name"), |
|
|
|
Logo = GetSkuLogo(j, (JArray)jobject["item"]["prop_imgs"]["prop_img"]) |
|
|
|
}).ToList(); |
|
|
|
} |
|
|
|
// return skuJArray.Select(j => new PurchaseSchemeProductSku()
|
|
|
|
// {
|
|
|
|
// //ProductId = Product.Id,
|
|
|
|
// //SkuId = purchaseSchemeProduct.SkuId,
|
|
|
|
// PurchaseProductId = purchseProductId,
|
|
|
|
// Price = j.Value<decimal>("price"),
|
|
|
|
// PurchaseSkuId = j.Value<string>("sku_id"),
|
|
|
|
// PurchaseSkuSpecId = j.Value<string>("spec_id"),
|
|
|
|
// Title = j.Value<string>("properties_name"),
|
|
|
|
// Logo = GetSkuLogo(j, (JArray)jobject["item"]["prop_imgs"]["prop_img"])
|
|
|
|
// }).ToList();
|
|
|
|
//}
|
|
|
|
|
|
|
|
private string GetSkuLogo(JToken skuJToken, JArray prop_img) |
|
|
|
{ |
|
|
|