|
@ -25,6 +25,9 @@ namespace BBWY.Server.Business |
|
|
private string qtAppId = "BBWY2023022001"; |
|
|
private string qtAppId = "BBWY2023022001"; |
|
|
private string qtAppSecret = "908e131365d5448ca651ba20ed7ddefe"; |
|
|
private string qtAppSecret = "908e131365d5448ca651ba20ed7ddefe"; |
|
|
|
|
|
|
|
|
|
|
|
private List<string> locationIdList; |
|
|
|
|
|
private List<string> priceIdList; |
|
|
|
|
|
|
|
|
private TimeSpan purchaseProductCacheTimeSpan; |
|
|
private TimeSpan purchaseProductCacheTimeSpan; |
|
|
//private TimeSpan _1688SessionIdTimeSpan;
|
|
|
//private TimeSpan _1688SessionIdTimeSpan;
|
|
|
|
|
|
|
|
@ -40,7 +43,7 @@ namespace BBWY.Server.Business |
|
|
this.restApiService = restApiService; |
|
|
this.restApiService = restApiService; |
|
|
_1688ProductDetailRequestHeader = new Dictionary<string, string>() |
|
|
_1688ProductDetailRequestHeader = new Dictionary<string, string>() |
|
|
{ |
|
|
{ |
|
|
{ "Host","detail.1688.com"}, |
|
|
//{ "Host","detail.1688.com"},
|
|
|
{ "User-Agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.102 Safari/537.36 Edg/104.0.1293.70"}, |
|
|
{ "User-Agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.102 Safari/537.36 Edg/104.0.1293.70"}, |
|
|
{ "Accept","text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"}, |
|
|
{ "Accept","text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"}, |
|
|
{ "Accept-Encoding","gzip, deflate, br"}, |
|
|
{ "Accept-Encoding","gzip, deflate, br"}, |
|
@ -48,6 +51,17 @@ namespace BBWY.Server.Business |
|
|
}; |
|
|
}; |
|
|
purchaseProductCacheTimeSpan = TimeSpan.FromDays(1); |
|
|
purchaseProductCacheTimeSpan = TimeSpan.FromDays(1); |
|
|
this.quanTanProductClient = quanTanProductClient; |
|
|
this.quanTanProductClient = quanTanProductClient; |
|
|
|
|
|
locationIdList = new List<string>() |
|
|
|
|
|
{ |
|
|
|
|
|
"300252630336272", |
|
|
|
|
|
"1081181309101", |
|
|
|
|
|
"16347413030323" |
|
|
|
|
|
}; |
|
|
|
|
|
priceIdList = new List<string>() { |
|
|
|
|
|
"300252630336263", |
|
|
|
|
|
"1081181309582", |
|
|
|
|
|
"16347413030316" |
|
|
|
|
|
}; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public PurchaseSkuBasicInfoResponse GetProductInfo(PurchaseSkuBasicInfoRequest request) |
|
|
public PurchaseSkuBasicInfoResponse GetProductInfo(PurchaseSkuBasicInfoRequest request) |
|
@ -193,12 +207,13 @@ namespace BBWY.Server.Business |
|
|
$"clickid={Guid.NewGuid().ToString().Md5Encrypt()}&sessionid={Guid.NewGuid().ToString().Md5Encrypt()}&sk={(request.PriceMode == Enums.PurchaseOrderMode.批发 ? "order" : "consign")}", |
|
|
$"clickid={Guid.NewGuid().ToString().Md5Encrypt()}&sessionid={Guid.NewGuid().ToString().Md5Encrypt()}&sk={(request.PriceMode == Enums.PurchaseOrderMode.批发 ? "order" : "consign")}", |
|
|
_1688ProductDetailRequestHeader, |
|
|
_1688ProductDetailRequestHeader, |
|
|
HttpMethod.Get, |
|
|
HttpMethod.Get, |
|
|
httpClientName: "gzip"); |
|
|
httpClientName: "gzip", |
|
|
|
|
|
getResponseHeader: true); |
|
|
|
|
|
|
|
|
if (_1688pageResult.StatusCode != System.Net.HttpStatusCode.OK) |
|
|
if (_1688pageResult.StatusCode != System.Net.HttpStatusCode.OK) |
|
|
return null; |
|
|
return null; |
|
|
|
|
|
|
|
|
var match = Regex.Match(_1688pageResult.Content, @"(window\.__INIT_DATA=)(.*)(\r*\n*\s*</script>)"); |
|
|
var match = Regex.Match(_1688pageResult.Content, @"(window\.__INIT_DATA\s?=)(.*)(\r*\n*\s*</script>)"); |
|
|
if (!match.Success) |
|
|
if (!match.Success) |
|
|
return null; |
|
|
return null; |
|
|
|
|
|
|
|
@ -209,12 +224,16 @@ namespace BBWY.Server.Business |
|
|
var purchaser = new Purchaser() |
|
|
var purchaser = new Purchaser() |
|
|
{ |
|
|
{ |
|
|
Id = jobject["globalData"]["tempModel"]["sellerUserId"].ToString(), |
|
|
Id = jobject["globalData"]["tempModel"]["sellerUserId"].ToString(), |
|
|
Name = jobject["globalData"]["tempModel"]["companyName"].ToString(), |
|
|
Name = jobject["globalData"]["tempModel"]["companyName"].ToString() |
|
|
Location = jobject["data"]["1081181309101"] != null ? |
|
|
|
|
|
jobject["data"]["1081181309101"]["data"]["location"].ToString() : |
|
|
|
|
|
jobject["data"]["16347413030323"]["data"]["location"].ToString(), |
|
|
|
|
|
Platform = Enums.Platform.阿里巴巴 |
|
|
|
|
|
}; |
|
|
}; |
|
|
|
|
|
foreach (var lid in locationIdList) |
|
|
|
|
|
{ |
|
|
|
|
|
if (jobject["data"][lid] != null) |
|
|
|
|
|
{ |
|
|
|
|
|
purchaser.Location = jobject["data"][lid]["data"]["location"].ToString(); |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
var colorsProperty = jobject["globalData"]["skuModel"]["skuProps"].FirstOrDefault(j => j.Value<int>("fid") == 3216 || |
|
|
var colorsProperty = jobject["globalData"]["skuModel"]["skuProps"].FirstOrDefault(j => j.Value<int>("fid") == 3216 || |
|
|
j.Value<int>("fid") == 1627207 || |
|
|
j.Value<int>("fid") == 1627207 || |
|
@ -227,9 +246,15 @@ namespace BBWY.Server.Business |
|
|
imageUrl = j.Value<string>("imageUrl") |
|
|
imageUrl = j.Value<string>("imageUrl") |
|
|
}).ToList(); |
|
|
}).ToList(); |
|
|
|
|
|
|
|
|
var firstPrice = jobject["data"]["1081181309582"] != null ? |
|
|
var firstPrice = 0M; |
|
|
jobject["data"]["1081181309582"]["data"]["priceModel"]["currentPrices"][0].Value<decimal>("price") : |
|
|
foreach (var pid in priceIdList) |
|
|
jobject["data"]["16347413030316"]["data"]["priceModel"]["currentPrices"][0].Value<decimal>("price"); |
|
|
{ |
|
|
|
|
|
if (jobject["data"][pid] != null) |
|
|
|
|
|
{ |
|
|
|
|
|
firstPrice = jobject["data"][pid]["data"]["priceModel"]["currentPrices"][0].Value<decimal>("price"); |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
var list = new List<PurchaseSkuItemBasicInfoResponse>(); |
|
|
var list = new List<PurchaseSkuItemBasicInfoResponse>(); |
|
|
|
|
|
|
|
@ -246,7 +271,7 @@ namespace BBWY.Server.Business |
|
|
{ |
|
|
{ |
|
|
PurchaseProductId = request.PurchaseProductId, |
|
|
PurchaseProductId = request.PurchaseProductId, |
|
|
Price = skuPrice == 0M ? firstPrice : skuPrice, |
|
|
Price = skuPrice == 0M ? firstPrice : skuPrice, |
|
|
Title = name, |
|
|
Title = matchName, //name
|
|
|
PurchaseSkuId = value.Value<string>("skuId"), |
|
|
PurchaseSkuId = value.Value<string>("skuId"), |
|
|
PurchaseSkuSpecId = value.Value<string>("specId"), |
|
|
PurchaseSkuSpecId = value.Value<string>("specId"), |
|
|
Logo = colorsProperty.FirstOrDefault(c => c.name == matchName)?.imageUrl ?? "pack://application:,,,/Resources/Images/defaultItem.png" |
|
|
Logo = colorsProperty.FirstOrDefault(c => c.name == matchName)?.imageUrl ?? "pack://application:,,,/Resources/Images/defaultItem.png" |
|
|