|
@ -26,10 +26,12 @@ namespace BBWYB.Server.Business |
|
|
//private ConcurrentDictionary<string, (Purchaser purchaser, IList<PurchaseSchemeProductSku> purchaseSchemeProductSkus)> productChaches;
|
|
|
//private ConcurrentDictionary<string, (Purchaser purchaser, IList<PurchaseSchemeProductSku> purchaseSchemeProductSkus)> productChaches;
|
|
|
|
|
|
|
|
|
private IDictionary<string, string> _1688ProductDetailRequestHeader; |
|
|
private IDictionary<string, string> _1688ProductDetailRequestHeader; |
|
|
|
|
|
private IDictionary<string, string> _1688FactoryCardRequestHeader; |
|
|
|
|
|
|
|
|
private List<int> _1688ColorPropertyFieldIdList; |
|
|
private List<int> _1688ColorPropertyFieldIdList; |
|
|
private List<string> locationIdList; |
|
|
private List<string> locationIdList; |
|
|
private List<string> priceIdList; |
|
|
private List<string> priceIdList; |
|
|
|
|
|
private List<string> purchaserNameIdList; |
|
|
|
|
|
|
|
|
private IList<string> invalidPurchaserNameList; |
|
|
private IList<string> invalidPurchaserNameList; |
|
|
|
|
|
|
|
@ -46,6 +48,14 @@ namespace BBWYB.Server.Business |
|
|
{ "Accept-Encoding","gzip, deflate, br"}, |
|
|
{ "Accept-Encoding","gzip, deflate, br"}, |
|
|
{ "Accept-Language","zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6"} |
|
|
{ "Accept-Language","zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6"} |
|
|
}; |
|
|
}; |
|
|
|
|
|
_1688FactoryCardRequestHeader = new Dictionary<string, string>() |
|
|
|
|
|
{ |
|
|
|
|
|
{ "Host","sale.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"}, |
|
|
|
|
|
{ "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-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); |
|
|
purchaseProductCacheTimeSpan = TimeSpan.FromDays(1); |
|
|
_1688ColorPropertyFieldIdList = new List<int>() { 3216, 1627207, 1234, 3151, 7853, 446, 374, 404, 100019516, 3114, 2068 }; |
|
|
_1688ColorPropertyFieldIdList = new List<int>() { 3216, 1627207, 1234, 3151, 7853, 446, 374, 404, 100019516, 3114, 2068 }; |
|
|
//jobject["data"]["1081181309101"] != null ?
|
|
|
//jobject["data"]["1081181309101"] != null ?
|
|
@ -57,6 +67,8 @@ namespace BBWYB.Server.Business |
|
|
// jobject["data"]["1081181309582"]["data"]["priceModel"]["currentPrices"][0].Value<decimal>("price") :
|
|
|
// jobject["data"]["1081181309582"]["data"]["priceModel"]["currentPrices"][0].Value<decimal>("price") :
|
|
|
// jobject["data"]["16347413030316"]["data"]["priceModel"]["currentPrices"][0].Value<decimal>("price");
|
|
|
// jobject["data"]["16347413030316"]["data"]["priceModel"]["currentPrices"][0].Value<decimal>("price");
|
|
|
priceIdList = new List<string>() { "1081181309582", "1081181309582", "16347413030316", "13772573013151" }; |
|
|
priceIdList = new List<string>() { "1081181309582", "1081181309582", "16347413030316", "13772573013151" }; |
|
|
|
|
|
|
|
|
|
|
|
purchaserNameIdList = new List<string>() { "38229149", "38229148", "38229150" }; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public PurchaseSkuBasicInfoResponse GetProductInfo(PurchaseSkuBasicInfoRequest request) |
|
|
public PurchaseSkuBasicInfoResponse GetProductInfo(PurchaseSkuBasicInfoRequest request) |
|
@ -241,9 +253,11 @@ namespace BBWYB.Server.Business |
|
|
var jsonStr = match.Groups[2].Value; |
|
|
var jsonStr = match.Groups[2].Value; |
|
|
var jobject = JObject.Parse(jsonStr); |
|
|
var jobject = JObject.Parse(jsonStr); |
|
|
|
|
|
|
|
|
|
|
|
var memberId = jobject["globalData"]?["tempModel"]?["sellerMemberId"]?.ToString(); |
|
|
|
|
|
|
|
|
#region 验证purchaserName
|
|
|
#region 验证purchaserName
|
|
|
var purchaserName = jobject["globalData"]["tempModel"]["companyName"].ToString(); |
|
|
var purchaserName = jobject["globalData"]["tempModel"]["companyName"].ToString(); |
|
|
if (invalidPurchaserNameList.Contains(purchaserName)) |
|
|
if (invalidPurchaserNameList.Any(x => purchaserName.Contains(x))) |
|
|
{ |
|
|
{ |
|
|
var storeDataMatch = Regex.Match(_1688pageResult.Content, @"(window\.__STORE_DATA=)(.*)(\r*\n*\s*</script>)"); |
|
|
var storeDataMatch = Regex.Match(_1688pageResult.Content, @"(window\.__STORE_DATA=)(.*)(\r*\n*\s*</script>)"); |
|
|
if (storeDataMatch.Success) |
|
|
if (storeDataMatch.Success) |
|
@ -252,16 +266,37 @@ namespace BBWYB.Server.Business |
|
|
{ |
|
|
{ |
|
|
var jsonStr_storeData = storeDataMatch.Groups[2].Value; |
|
|
var jsonStr_storeData = storeDataMatch.Groups[2].Value; |
|
|
var jobject_storeData = JObject.Parse(jsonStr_storeData); |
|
|
var jobject_storeData = JObject.Parse(jsonStr_storeData); |
|
|
var purchaserName_storeData = jobject_storeData["components"]?["38229149"]?["moduleData"]?["companyName"].ToString(); |
|
|
foreach (var purchaserNodeId in purchaserNameIdList) |
|
|
if (string.IsNullOrEmpty(purchaserName_storeData)) |
|
|
{ |
|
|
purchaserName_storeData = jobject_storeData["components"]?["38229148"]?["moduleData"]?["companyName"].ToString(); |
|
|
var purchaserTempName = jobject_storeData["components"]?[purchaserNodeId]?["moduleData"]?["companyName"].ToString(); |
|
|
if (string.IsNullOrEmpty(purchaserName_storeData)) |
|
|
if (!string.IsNullOrEmpty(purchaserTempName)) |
|
|
purchaserName_storeData = jobject_storeData["components"]?["38229150"]?["moduleData"]?["companyName"].ToString(); |
|
|
{ |
|
|
if (!string.IsNullOrEmpty(purchaserName_storeData)) |
|
|
purchaserName = purchaserTempName; |
|
|
purchaserName = purchaserName_storeData; |
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
catch { } |
|
|
catch { } |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (invalidPurchaserNameList.Any(x => purchaserName.Contains(x)) && !string.IsNullOrEmpty(memberId)) |
|
|
|
|
|
{ |
|
|
|
|
|
//https://sale.1688.com/factory/card.html?memberId=b2b-4204371240a61bf
|
|
|
|
|
|
var _1688FactoryCardResult = restApiService.SendRequest("https://sale.1688.com", |
|
|
|
|
|
"factory/card.html", |
|
|
|
|
|
$"memberId={memberId}", |
|
|
|
|
|
_1688FactoryCardRequestHeader, |
|
|
|
|
|
HttpMethod.Get, |
|
|
|
|
|
httpClientName: "gzip"); |
|
|
|
|
|
if (_1688FactoryCardResult.StatusCode == System.Net.HttpStatusCode.OK) |
|
|
|
|
|
{ |
|
|
|
|
|
var titleMatch = Regex.Match(_1688FactoryCardResult.Content, @"<title>(.*)-(.*)-(.*)</title>"); |
|
|
|
|
|
if (titleMatch.Success) |
|
|
|
|
|
{ |
|
|
|
|
|
purchaserName = titleMatch.Groups[1].Value; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
#endregion
|
|
|
#endregion
|
|
|
|
|
|
|
|
@ -280,10 +315,12 @@ namespace BBWYB.Server.Business |
|
|
Id = jobject["globalData"]["tempModel"]["sellerUserId"].ToString(), |
|
|
Id = jobject["globalData"]["tempModel"]["sellerUserId"].ToString(), |
|
|
Id2 = jobject["globalData"]["tempModel"]["sellerLoginId"]?.ToString(), |
|
|
Id2 = jobject["globalData"]["tempModel"]["sellerLoginId"]?.ToString(), |
|
|
Name = purchaserName, |
|
|
Name = purchaserName, |
|
|
MemberId = jobject["globalData"]?["tempModel"]?["sellerMemberId"]?.ToString(), |
|
|
MemberId = memberId, |
|
|
Location = location, |
|
|
Location = location, |
|
|
Platform = Enums.Platform.阿里巴巴 |
|
|
Platform = Enums.Platform.阿里巴巴 |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var fidJToken = jobject["globalData"]["skuModel"]["skuProps"].FirstOrDefault(j => _1688ColorPropertyFieldIdList.Contains(j.Value<int>("fid"))); |
|
|
var fidJToken = jobject["globalData"]["skuModel"]["skuProps"].FirstOrDefault(j => _1688ColorPropertyFieldIdList.Contains(j.Value<int>("fid"))); |
|
|
if (fidJToken == null) |
|
|
if (fidJToken == null) |
|
|
fidJToken = jobject["globalData"]["skuModel"]["skuProps"].FirstOrDefault(j => j.Value<string>("prop").Contains("颜色")); |
|
|
fidJToken = jobject["globalData"]["skuModel"]["skuProps"].FirstOrDefault(j => j.Value<string>("prop").Contains("颜色")); |
|
|