|
|
@ -38,7 +38,11 @@ namespace BBWY.Client.APIServices |
|
|
|
|
|
|
|
public (Purchaser purchaser, IList<PurchaseSchemeProductSku> purchaseSchemeProductSkus)? GetProductInfo(Platform platform, string productId, string skuId, string purchaseProductId, PurchaseOrderMode priceMode, PurchaseProductAPIMode apiMode) |
|
|
|
{ |
|
|
|
if (productChaches.TryGetValue($"{purchaseProductId}_{priceMode}", out (Purchaser purchaser, IList<PurchaseSchemeProductSku> purchaseSchemeProductSkus) tuple)) |
|
|
|
return tuple.Copy(); |
|
|
|
|
|
|
|
(Purchaser purchaser, IList<PurchaseSchemeProductSku> purchaseSchemeProductSkus)? data = null; |
|
|
|
|
|
|
|
if (apiMode == PurchaseProductAPIMode.Spider) |
|
|
|
{ |
|
|
|
data = LoadFromSpider(platform, productId, skuId, purchaseProductId, priceMode); |
|
|
@ -52,6 +56,8 @@ namespace BBWY.Client.APIServices |
|
|
|
data = LoadFromSpider(platform, productId, skuId, purchaseProductId, priceMode); |
|
|
|
} |
|
|
|
|
|
|
|
if (data != null) |
|
|
|
productChaches.TryAdd($"{purchaseProductId}_{priceMode}", data.Value); |
|
|
|
return data?.Copy(); |
|
|
|
} |
|
|
|
|
|
|
@ -66,9 +72,6 @@ namespace BBWY.Client.APIServices |
|
|
|
if (string.IsNullOrEmpty(platformStr)) |
|
|
|
return null; |
|
|
|
|
|
|
|
if (productChaches.TryGetValue($"{purchaseProductId}_{priceMode}", out (Purchaser purchaser, IList<PurchaseSchemeProductSku> purchaseSchemeProductSkus) tuple)) |
|
|
|
return tuple; |
|
|
|
|
|
|
|
var result = restApiService.SendRequest("https://api-gw.onebound.cn/", $"{platformStr}/item_get", $"key={oneBoundKey}&secret={oneBoundSecret}&num_iid={purchaseProductId}&lang=zh-CN&cache=no&agent={(priceMode == PurchaseOrderMode.批发 ? 0 : 1)}", null, HttpMethod.Get, paramPosition: ParamPosition.Query, enableRandomTimeStamp: true); |
|
|
|
if (result.StatusCode != System.Net.HttpStatusCode.OK) |
|
|
|
throw new Exception($"{result.StatusCode} {result.Content}"); |
|
|
@ -102,16 +105,12 @@ namespace BBWY.Client.APIServices |
|
|
|
purchaserName = j["item"]["seller_info"].Value<string>("shop_name"); |
|
|
|
var purchaserLocation = j["item"].Value<string>("location"); |
|
|
|
|
|
|
|
tuple = (new Purchaser() |
|
|
|
return (new Purchaser() |
|
|
|
{ |
|
|
|
Id = purchaserId, |
|
|
|
Name = purchaserName, |
|
|
|
Location = purchaserLocation |
|
|
|
}, list); |
|
|
|
|
|
|
|
productChaches.TryAdd($"{purchaseProductId}_{priceMode}", tuple); |
|
|
|
|
|
|
|
return tuple; |
|
|
|
} |
|
|
|
} |
|
|
|
catch { } |
|
|
@ -136,9 +135,6 @@ namespace BBWY.Client.APIServices |
|
|
|
|
|
|
|
private (Purchaser purchaser, IList<PurchaseSchemeProductSku> purchaseSchemeProductSkus)? LoadFromSpider(Platform platform, string productId, string skuId, string purchaseProductId, PurchaseOrderMode priceMode) |
|
|
|
{ |
|
|
|
if (productChaches.TryGetValue($"{purchaseProductId}_{priceMode}", out (Purchaser purchaser, IList<PurchaseSchemeProductSku> purchaseSchemeProductSkus) tuple)) |
|
|
|
return tuple; |
|
|
|
|
|
|
|
switch (platform) |
|
|
|
{ |
|
|
|
case Platform.阿里巴巴: |
|
|
@ -217,10 +213,7 @@ namespace BBWY.Client.APIServices |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
var tuple = (purchaser, purchaseSchemeProductSkus); |
|
|
|
productChaches.TryAdd($"{purchaseProductId}_{priceMode}", tuple); |
|
|
|
|
|
|
|
return tuple; |
|
|
|
return (purchaser, purchaseSchemeProductSkus); |
|
|
|
} |
|
|
|
catch |
|
|
|
{ |
|
|
|