Browse Source

修复1688爬虫问题

pjzs_starttask_update
sanji 2 years ago
parent
commit
fea8e7e573
  1. 44
      BBWY.Client/APIServices/PurchaseProductAPIService.cs
  2. 40
      BBWY.Server.Business/PurchaseScheme/PurchaseProductAPIService.cs

44
BBWY.Client/APIServices/PurchaseProductAPIService.cs

@ -25,6 +25,9 @@ namespace BBWY.Client.APIServices
private string qtAppId = "BBWY2023022001";
private string qtAppSecret = "908e131365d5448ca651ba20ed7ddefe";
private List<string> locationIdList;
private List<string> priceIdList;
private TimeSpan purchaseProductCacheTimeSpan;
//private TimeSpan _1688SessionIdTimeSpan;
@ -48,6 +51,17 @@ namespace BBWY.Client.APIServices
};
purchaseProductCacheTimeSpan = TimeSpan.FromDays(1);
this.quanTanProductClient = quanTanProductClient;
locationIdList = new List<string>()
{
"300252630336272",
"1081181309101",
"16347413030323"
};
priceIdList = new List<string>() {
"300252630336263",
"1081181309582",
"16347413030316"
};
}
public (Purchaser purchaser, IList<PurchaseSchemeProductSku> purchaseSchemeProductSkus)? GetProductInfo(Platform platform, string productId, string skuId, string purchaseProductId, PurchaseOrderMode priceMode, PurchaseProductAPIMode apiMode)
@ -200,11 +214,18 @@ namespace BBWY.Client.APIServices
var purchaser = new Purchaser()
{
Id = jobject["globalData"]["tempModel"]["sellerUserId"].ToString(),
Name = jobject["globalData"]["tempModel"]["companyName"].ToString(),
Location = jobject["data"]["1081181309101"] != null ?
jobject["data"]["1081181309101"]["data"]["location"].ToString() :
jobject["data"]["16347413030323"]["data"]["location"].ToString()
Name = jobject["globalData"]["tempModel"]["companyName"].ToString()
};
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 ||
j.Value<int>("fid") == 1627207 ||
@ -217,9 +238,18 @@ namespace BBWY.Client.APIServices
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 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 firstPrice = 0M;
foreach (var pid in priceIdList)
{
if (jobject["data"][pid] != null)
{
firstPrice = jobject["data"][pid]["data"]["priceModel"]["currentPrices"][0].Value<decimal>("price");
break;
}
}
var purchaseSchemeProductSkus = new List<PurchaseSchemeProductSku>();

40
BBWY.Server.Business/PurchaseScheme/PurchaseProductAPIService.cs

@ -25,6 +25,9 @@ namespace BBWY.Server.Business
private string qtAppId = "BBWY2023022001";
private string qtAppSecret = "908e131365d5448ca651ba20ed7ddefe";
private List<string> locationIdList;
private List<string> priceIdList;
private TimeSpan purchaseProductCacheTimeSpan;
//private TimeSpan _1688SessionIdTimeSpan;
@ -48,6 +51,17 @@ namespace BBWY.Server.Business
};
purchaseProductCacheTimeSpan = TimeSpan.FromDays(1);
this.quanTanProductClient = quanTanProductClient;
locationIdList = new List<string>()
{
"300252630336272",
"1081181309101",
"16347413030323"
};
priceIdList = new List<string>() {
"300252630336263",
"1081181309582",
"16347413030316"
};
}
public PurchaseSkuBasicInfoResponse GetProductInfo(PurchaseSkuBasicInfoRequest request)
@ -210,12 +224,16 @@ namespace BBWY.Server.Business
var purchaser = new Purchaser()
{
Id = jobject["globalData"]["tempModel"]["sellerUserId"].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.
Name = jobject["globalData"]["tempModel"]["companyName"].ToString()
};
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 ||
j.Value<int>("fid") == 1627207 ||
@ -228,9 +246,15 @@ namespace BBWY.Server.Business
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 firstPrice = 0M;
foreach (var pid in priceIdList)
{
if (jobject["data"][pid] != null)
{
firstPrice = jobject["data"][pid]["data"]["priceModel"]["currentPrices"][0].Value<decimal>("price");
break;
}
}
var list = new List<PurchaseSkuItemBasicInfoResponse>();

Loading…
Cancel
Save