|
|
@ -25,6 +25,10 @@ namespace BBWYB.Client.APIServices |
|
|
|
|
|
|
|
private IDictionary<string, string> _1688ProductDetailRequestHeader; |
|
|
|
|
|
|
|
private List<int> _1688ColorPropertyFieldIdList; |
|
|
|
private List<string> locationIdList; |
|
|
|
private List<string> priceIdList; |
|
|
|
|
|
|
|
public PurchaseProductAPIService(RestApiService restApiService, IMemoryCache memoryCache) |
|
|
|
{ |
|
|
|
this.restApiService = restApiService; |
|
|
@ -38,6 +42,10 @@ namespace BBWYB.Client.APIServices |
|
|
|
{ "Accept-Language","zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6"} |
|
|
|
}; |
|
|
|
purchaseProductCacheTimeSpan = TimeSpan.FromDays(1); |
|
|
|
|
|
|
|
_1688ColorPropertyFieldIdList = new List<int>() { 3216, 1627207, 1234, 3151, 7853, 446, 374, 404, 100019516, 3114, 2068 }; |
|
|
|
locationIdList = new List<string>() { "1081181309101", "16347413030323", "13772573013156" }; |
|
|
|
priceIdList = new List<string>() { "1081181309582", "1081181309582", "16347413030316", "13772573013151" }; |
|
|
|
} |
|
|
|
|
|
|
|
public (Purchaser purchaser, IList<PurchaseSchemeProductSku> purchaseSchemeProductSkus)? GetProductInfo(Platform platform, string productId, string skuId, string purchaseProductId, PurchaseOrderMode priceMode, PurchaseProductAPIMode apiMode) |
|
|
@ -186,31 +194,47 @@ namespace BBWYB.Client.APIServices |
|
|
|
var jsonStr = match.Groups[2].Value; |
|
|
|
var jobject = JObject.Parse(jsonStr); |
|
|
|
|
|
|
|
var location = ""; |
|
|
|
for (var i = 0; i < locationIdList.Count(); i++) |
|
|
|
{ |
|
|
|
if (jobject["data"][locationIdList[i]] != null) |
|
|
|
{ |
|
|
|
location = jobject["data"][locationIdList[i]]["data"]["location"].ToString(); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//16347413030323
|
|
|
|
var purchaser = new Purchaser() |
|
|
|
{ |
|
|
|
Id = jobject["globalData"]["tempModel"]["sellerUserId"].ToString(), |
|
|
|
Id2 = jobject["globalData"]["tempModel"]["sellerLoginId"]?.ToString(), |
|
|
|
Name = jobject["globalData"]["tempModel"]["companyName"].ToString(), |
|
|
|
Location = jobject["data"]["1081181309101"] != null ? |
|
|
|
jobject["data"]["1081181309101"]["data"]["location"].ToString() : |
|
|
|
jobject["data"]["16347413030323"]["data"]["location"].ToString() |
|
|
|
Location = location, |
|
|
|
Platform = platform |
|
|
|
}; |
|
|
|
|
|
|
|
var colorsProperty = jobject["globalData"]["skuModel"]["skuProps"].FirstOrDefault(j => j.Value<int>("fid") == 3216 || |
|
|
|
j.Value<int>("fid") == 1627207 || |
|
|
|
j.Value<int>("fid") == 1234 || |
|
|
|
j.Value<int>("fid") == 3151)["value"] |
|
|
|
.Children() |
|
|
|
.Select(j => new |
|
|
|
{ |
|
|
|
name = j.Value<string>("name"), |
|
|
|
imageUrl = j.Value<string>("imageUrl") |
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
var firstPrice = jobject["data"]["1081181309582"] != null ? |
|
|
|
jobject["data"]["1081181309582"]["data"]["priceModel"]["currentPrices"][0].Value<decimal>("price") : |
|
|
|
jobject["data"]["16347413030316"]["data"]["priceModel"]["currentPrices"][0].Value<decimal>("price"); |
|
|
|
var fidJToken = jobject["globalData"]["skuModel"]["skuProps"].FirstOrDefault(j => _1688ColorPropertyFieldIdList.Contains(j.Value<int>("fid"))); |
|
|
|
if (fidJToken == null) |
|
|
|
fidJToken = jobject["globalData"]["skuModel"]["skuProps"].FirstOrDefault(j => j.Value<string>("prop").Contains("颜色")); |
|
|
|
if (fidJToken == null && jobject["globalData"]["skuModel"]["skuProps"].Children().Count() == 1) |
|
|
|
fidJToken = jobject["globalData"]["skuModel"]["skuProps"].FirstOrDefault(); |
|
|
|
var colorsProperty = fidJToken["value"].Children() |
|
|
|
.Select(j => new |
|
|
|
{ |
|
|
|
name = j.Value<string>("name"), |
|
|
|
imageUrl = j.Value<string>("imageUrl") |
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
var firstPrice = 0.0M; |
|
|
|
for (var i = 0; i < priceIdList.Count(); i++) |
|
|
|
{ |
|
|
|
if (jobject["data"][priceIdList[i]] != null) |
|
|
|
{ |
|
|
|
firstPrice = jobject["data"][priceIdList[i]]["data"]["priceModel"]["currentPrices"][0].Value<decimal>("price"); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
var purchaseSchemeProductSkus = new List<PurchaseSchemeProductSku>(); |
|
|
|
|
|
|
|