商品可以选择类目再进行上传
This commit is contained in:
1 parent
e73359e283
commit
7d5daf27ad
8 files changed
+531
-165
No files matched your search
+94
-94
@@ -120,100 +120,100 @@ namespace TemuKJD
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
|
||||
List<Task> tList = new List<Task>();
|
||||
var tick = BaseClass.DateTimeToTimestampSeconds(new DateTime(2022, 4, 25));
|
||||
while (true)
|
||||
{
|
||||
if (GlobalConfig.ShopLoginList.All(shop => shop.ApiAuthStatus != "授权成功"
|
||||
|| GlobalConfig.SameProductCheckParamList.Any(sp => sp.ShopId == shop.ShopId && sp.IsGetSuccess)))
|
||||
{
|
||||
Thread.Sleep(1000);
|
||||
continue;
|
||||
}
|
||||
|
||||
tList.Clear();
|
||||
foreach (var shop in GlobalConfig.ShopLoginList)
|
||||
{
|
||||
if (GlobalConfig.SameProductCheckParamList.Any(sp => sp.ShopId == shop.ShopId && sp.IsGetSuccess))
|
||||
continue;
|
||||
|
||||
if (shop.ApiAuthStatus != "授权成功")
|
||||
continue;
|
||||
|
||||
var t = Task.Run(() =>
|
||||
{
|
||||
var shopTemp = shop;
|
||||
try
|
||||
{
|
||||
var sameProductCheckParam = GlobalConfig.SameProductCheckParamList.FirstOrDefault(sp => sp.ShopId == shop.ShopId);
|
||||
if (sameProductCheckParam == null)
|
||||
{
|
||||
sameProductCheckParam = new SameProductCheckParam()
|
||||
{
|
||||
ShopId = shopTemp.ShopId,
|
||||
ShopName = shopTemp.ShopAccount,
|
||||
ShopSamePrpductItemList = new List<ShopOurterProductItemParam>(),
|
||||
};
|
||||
}
|
||||
for (int i = 1; i <= 500; i++)
|
||||
{
|
||||
if (sameProductCheckParam.ShopSamePrpductItemList != null && sameProductCheckParam.ShopSamePrpductItemList.Count > 0)
|
||||
tick = sameProductCheckParam.ShopSamePrpductItemList.Min(it => it.create_time).ParseToInt() - 1;
|
||||
|
||||
DouyinApi douApi = new DouyinApi(shopTemp);
|
||||
douApi.JsonData["page"] = "1";
|
||||
douApi.JsonData["size"] = "100";
|
||||
douApi.JsonData["end_time"] = tick.ToString();
|
||||
// check_status 指定审核状态返回商品列表:1未提审 2审核中 3审核通过 4审核驳回 5封禁 7审核通过,待上架状态
|
||||
//douApi.JsonData["check_status"] = "3";
|
||||
//douApi.JsonData["check_status"] = "1";
|
||||
//douApi.JsonData["status"] = "0";
|
||||
var resultOnline = douApi.GetProductList();
|
||||
if (resultOnline.Contains("已过期"))
|
||||
{
|
||||
shopTemp.ApiAuthStatus = "未授权";
|
||||
return;
|
||||
}
|
||||
while (!resultOnline.Contains("\"code\":10000"))
|
||||
{
|
||||
Thread.Sleep(Randomx.GetId(500, 1000) * tList.Count);
|
||||
resultOnline = douApi.GetProductList();
|
||||
}
|
||||
if (resultOnline != null && resultOnline.Contains("\"data\":[]"))
|
||||
{
|
||||
sameProductCheckParam.IsGetSuccess = true;
|
||||
break;
|
||||
}
|
||||
|
||||
Newtonsoft.Json.Linq.JObject jObj = JsonHelper.JObjectParse(resultOnline);
|
||||
var itemList = JsonHelper.DeserializeJsonToList<ShopOurterProductItemParam>(jObj["data"]?["data"]?.ToString());
|
||||
sameProductCheckParam.ShopSamePrpductItemList.AddRange(itemList);
|
||||
|
||||
if (i % 10 == 9)
|
||||
{
|
||||
if (!GlobalConfig.SameProductCheckParamList.Contains(sameProductCheckParam))
|
||||
GlobalConfig.SameProductCheckParamList.Add(sameProductCheckParam);
|
||||
sameProductCheckParam.ShopSamePrpductItemList = sameProductCheckParam.ShopSamePrpductItemList.DistinctBy(it => it.product_id).ToList();
|
||||
NaiBa.Util.Helper.ConfigHelper.SaveConfig<List<SameProductCheckParam>>("same_product_check_list", GlobalConfig.SameProductCheckParamList);
|
||||
}
|
||||
|
||||
Thread.Sleep(Randomx.GetId(500, 1000) * tList.Count);
|
||||
}
|
||||
if (!GlobalConfig.SameProductCheckParamList.Contains(sameProductCheckParam))
|
||||
GlobalConfig.SameProductCheckParamList.Add(sameProductCheckParam);
|
||||
sameProductCheckParam.ShopSamePrpductItemList = sameProductCheckParam.ShopSamePrpductItemList.DistinctBy(it => it.product_id).ToList();
|
||||
NaiBa.Util.Helper.ConfigHelper.SaveConfig<List<SameProductCheckParam>>("same_product_check_list", GlobalConfig.SameProductCheckParamList);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
});
|
||||
tList.Add(t);
|
||||
}
|
||||
Task.WaitAll(tList.ToArray());
|
||||
|
||||
Thread.Sleep(10000);
|
||||
}
|
||||
//List<Task> tList = new List<Task>();
|
||||
//var tick = BaseClass.DateTimeToTimestampSeconds(new DateTime(2022, 4, 25));
|
||||
//while (true)
|
||||
//{
|
||||
// if (GlobalConfig.ShopLoginList.All(shop => shop.ApiAuthStatus != "授权成功"
|
||||
// || GlobalConfig.SameProductCheckParamList.Any(sp => sp.ShopId == shop.ShopId && sp.IsGetSuccess)))
|
||||
// {
|
||||
// Thread.Sleep(1000);
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// tList.Clear();
|
||||
// foreach (var shop in GlobalConfig.ShopLoginList)
|
||||
// {
|
||||
// if (GlobalConfig.SameProductCheckParamList.Any(sp => sp.ShopId == shop.ShopId && sp.IsGetSuccess))
|
||||
// continue;
|
||||
//
|
||||
// if (shop.ApiAuthStatus != "授权成功")
|
||||
// continue;
|
||||
//
|
||||
// var t = Task.Run(() =>
|
||||
// {
|
||||
// var shopTemp = shop;
|
||||
// try
|
||||
// {
|
||||
// var sameProductCheckParam = GlobalConfig.SameProductCheckParamList.FirstOrDefault(sp => sp.ShopId == shop.ShopId);
|
||||
// if (sameProductCheckParam == null)
|
||||
// {
|
||||
// sameProductCheckParam = new SameProductCheckParam()
|
||||
// {
|
||||
// ShopId = shopTemp.ShopId,
|
||||
// ShopName = shopTemp.ShopAccount,
|
||||
// ShopSamePrpductItemList = new List<ShopOurterProductItemParam>(),
|
||||
// };
|
||||
// }
|
||||
// for (int i = 1; i <= 500; i++)
|
||||
// {
|
||||
// if (sameProductCheckParam.ShopSamePrpductItemList != null && sameProductCheckParam.ShopSamePrpductItemList.Count > 0)
|
||||
// tick = sameProductCheckParam.ShopSamePrpductItemList.Min(it => it.create_time).ParseToInt() - 1;
|
||||
//
|
||||
// DouyinApi douApi = new DouyinApi(shopTemp);
|
||||
// douApi.JsonData["page"] = "1";
|
||||
// douApi.JsonData["size"] = "100";
|
||||
// douApi.JsonData["end_time"] = tick.ToString();
|
||||
// // check_status 指定审核状态返回商品列表:1未提审 2审核中 3审核通过 4审核驳回 5封禁 7审核通过,待上架状态
|
||||
// //douApi.JsonData["check_status"] = "3";
|
||||
// //douApi.JsonData["check_status"] = "1";
|
||||
// //douApi.JsonData["status"] = "0";
|
||||
// var resultOnline = douApi.GetProductList();
|
||||
// if (resultOnline.Contains("已过期"))
|
||||
// {
|
||||
// shopTemp.ApiAuthStatus = "未授权";
|
||||
// return;
|
||||
// }
|
||||
// while (!resultOnline.Contains("\"code\":10000"))
|
||||
// {
|
||||
// Thread.Sleep(Randomx.GetId(500, 1000) * tList.Count);
|
||||
// resultOnline = douApi.GetProductList();
|
||||
// }
|
||||
// if (resultOnline != null && resultOnline.Contains("\"data\":[]"))
|
||||
// {
|
||||
// sameProductCheckParam.IsGetSuccess = true;
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// Newtonsoft.Json.Linq.JObject jObj = JsonHelper.JObjectParse(resultOnline);
|
||||
// var itemList = JsonHelper.DeserializeJsonToList<ShopOurterProductItemParam>(jObj["data"]?["data"]?.ToString());
|
||||
// sameProductCheckParam.ShopSamePrpductItemList.AddRange(itemList);
|
||||
//
|
||||
// if (i % 10 == 9)
|
||||
// {
|
||||
// if (!GlobalConfig.SameProductCheckParamList.Contains(sameProductCheckParam))
|
||||
// GlobalConfig.SameProductCheckParamList.Add(sameProductCheckParam);
|
||||
// sameProductCheckParam.ShopSamePrpductItemList = sameProductCheckParam.ShopSamePrpductItemList.DistinctBy(it => it.product_id).ToList();
|
||||
// NaiBa.Util.Helper.ConfigHelper.SaveConfig<List<SameProductCheckParam>>("same_product_check_list", GlobalConfig.SameProductCheckParamList);
|
||||
// }
|
||||
//
|
||||
// Thread.Sleep(Randomx.GetId(500, 1000) * tList.Count);
|
||||
// }
|
||||
// if (!GlobalConfig.SameProductCheckParamList.Contains(sameProductCheckParam))
|
||||
// GlobalConfig.SameProductCheckParamList.Add(sameProductCheckParam);
|
||||
// sameProductCheckParam.ShopSamePrpductItemList = sameProductCheckParam.ShopSamePrpductItemList.DistinctBy(it => it.product_id).ToList();
|
||||
// NaiBa.Util.Helper.ConfigHelper.SaveConfig<List<SameProductCheckParam>>("same_product_check_list", GlobalConfig.SameProductCheckParamList);
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// }
|
||||
// });
|
||||
// tList.Add(t);
|
||||
// }
|
||||
// Task.WaitAll(tList.ToArray());
|
||||
//
|
||||
// Thread.Sleep(10000);
|
||||
//}
|
||||
});
|
||||
#endregion
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user