pdd上货逻辑继续优化 temu选品数据店铺筛选功能
This commit is contained in:
1 parent
0e6a034d5f
commit
b868c718f0
19 files changed
+562
-271
No files matched your search
@@ -64,6 +64,7 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
return;
|
||||
}
|
||||
|
||||
Thread.Sleep(Randomx.GetId(10, 50));
|
||||
var detail_json = "{}";
|
||||
PDDProductDetailInfo product = null;
|
||||
try
|
||||
@@ -84,6 +85,7 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
return;
|
||||
}
|
||||
|
||||
Thread.Sleep(Randomx.GetId(10, 50));
|
||||
var size_json = "{}";
|
||||
if (product.size_spec_id.ParseToLong() != 0)
|
||||
{
|
||||
@@ -121,6 +123,7 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
// }
|
||||
//}
|
||||
|
||||
Thread.Sleep(Randomx.GetId(10, 50));
|
||||
var property_json = "{}";
|
||||
PDDProductPropertyInfo property = null;
|
||||
try
|
||||
@@ -138,35 +141,6 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
return;
|
||||
}
|
||||
|
||||
var decoration_json = "{}";
|
||||
PDDProductDecorationInfo decoration = null;
|
||||
try
|
||||
{
|
||||
var prod_decoration_rst = GetPddProdDecoration(sourceShop, sourceProdId.ToString(), commitId);
|
||||
if (!prod_decoration_rst.Contains("\"success\":true"))
|
||||
{
|
||||
var errMsg = BaseRegex.GetStringJson(ref prod_decoration_rst, "error_msg");
|
||||
if (string.IsNullOrEmpty(errMsg))
|
||||
errMsg = commit_id_rst;
|
||||
OnInfoReceived("商品获取失败!商品详情图获取失败!" + errMsg);
|
||||
return;
|
||||
}
|
||||
JObject prod_decoration_obj = JObject.Parse(prod_decoration_rst);
|
||||
if (!prod_decoration_obj["result"].IsNullOrEmpty())
|
||||
decoration_json = JsonHelper.SerializeObject(prod_decoration_obj["result"]);
|
||||
decoration = JsonHelper.DeserializeJsonToObject<PDDProductDecorationInfo>(decoration_json);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
OnInfoReceived("商品获取失败!商品详情图获取失败!" + ex.Message);
|
||||
return;
|
||||
}
|
||||
if (decoration == null)
|
||||
{
|
||||
OnInfoReceived("商品获取失败!商品详情图获取失败!");
|
||||
return;
|
||||
}
|
||||
|
||||
// 属性模板暂时注释
|
||||
//var prop_template_json = "{}";
|
||||
//PDDProductTemplateInfo templateInfo = null;
|
||||
@@ -184,6 +158,97 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
// return;
|
||||
//}
|
||||
|
||||
Thread.Sleep(Randomx.GetId(10, 50));
|
||||
var decoration_json = "{}";
|
||||
PDDProductDecorationInfo decoration = null;
|
||||
try
|
||||
{
|
||||
var prod_decoration_rst = GetPddProdDecoration(sourceShop, sourceProdId.ToString(), commitId);
|
||||
if (!prod_decoration_rst.Contains("\"success\":true"))
|
||||
{
|
||||
var errMsg = BaseRegex.GetStringJson(ref prod_decoration_rst, "error_msg");
|
||||
if (string.IsNullOrEmpty(errMsg))
|
||||
errMsg = prod_decoration_rst;
|
||||
OnInfoReceived("商品获取失败!商品详情图获取失败!" + errMsg);
|
||||
return;
|
||||
}
|
||||
JObject prod_decoration_obj = JObject.Parse(prod_decoration_rst);
|
||||
if (!prod_decoration_obj["result"].IsNullOrEmpty())
|
||||
decoration_json = JsonHelper.SerializeObject(prod_decoration_obj["result"]);
|
||||
decoration = JsonHelper.DeserializeJsonToObject<PDDProductDecorationInfo>(decoration_json);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
OnInfoReceived("商品获取失败!商品详情图获取失败!" + ex.Message);
|
||||
return;
|
||||
}
|
||||
if (decoration == null)
|
||||
{
|
||||
OnInfoReceived("商品获取失败!商品详情图获取失败!");
|
||||
return;
|
||||
}
|
||||
|
||||
Thread.Sleep(Randomx.GetId(10, 50));
|
||||
var material3_json = "{}";
|
||||
PDDMaterialInfo material3 = null;
|
||||
try
|
||||
{
|
||||
var material3_rst = GetPddGoodsMaterial(sourceShop, sourceProdId.ToString(), commitId, 3);
|
||||
if (!material3_rst.Contains("\"success\":true"))
|
||||
{
|
||||
var errMsg = BaseRegex.GetStringJson(ref material3_rst, "error_msg");
|
||||
if (string.IsNullOrEmpty(errMsg))
|
||||
errMsg = material3_rst;
|
||||
OnInfoReceived("商品获取失败!商品长图获取失败!" + errMsg);
|
||||
return;
|
||||
}
|
||||
JObject material3_obj = JObject.Parse(material3_rst);
|
||||
if (!material3_obj["result"].IsNullOrEmpty())
|
||||
material3_json = JsonHelper.SerializeObject(material3_obj["result"]);
|
||||
material3 = JsonHelper.DeserializeJsonToObject<PDDMaterialInfo>(material3_json);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
OnInfoReceived("商品获取失败!商品长图获取失败!" + ex.Message);
|
||||
return;
|
||||
}
|
||||
if (material3 == null)
|
||||
{
|
||||
OnInfoReceived("商品获取失败!商品长图获取失败!");
|
||||
return;
|
||||
}
|
||||
|
||||
Thread.Sleep(Randomx.GetId(10, 50));
|
||||
var material1_json = "{}";
|
||||
PDDMaterialInfo material1 = null;
|
||||
try
|
||||
{
|
||||
var material1_rst = GetPddGoodsMaterial(sourceShop, sourceProdId.ToString(), commitId, 1);
|
||||
if (!material1_rst.Contains("\"success\":true"))
|
||||
{
|
||||
var errMsg = BaseRegex.GetStringJson(ref material1_rst, "error_msg");
|
||||
if (string.IsNullOrEmpty(errMsg))
|
||||
errMsg = material1_rst;
|
||||
OnInfoReceived("商品获取失败!商品白底图获取失败!" + errMsg);
|
||||
return;
|
||||
}
|
||||
JObject material1_obj = JObject.Parse(material1_rst);
|
||||
if (!material1_obj["result"].IsNullOrEmpty())
|
||||
material1_json = JsonHelper.SerializeObject(material1_obj["result"]);
|
||||
material1 = JsonHelper.DeserializeJsonToObject<PDDMaterialInfo>(material1_json);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
OnInfoReceived("商品获取失败!商品白底图获取失败!" + ex.Message);
|
||||
return;
|
||||
}
|
||||
if (material1 == null)
|
||||
{
|
||||
OnInfoReceived("商品获取失败!商品白底图获取失败!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
bool isExist = false;
|
||||
var existUrl = BaseClass.BuildObjString("product/get_product_list");
|
||||
string existData = UserLogin.GetSignaturex() + "&search_spu=" + product.goods_id;
|
||||
@@ -199,7 +264,8 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
}
|
||||
|
||||
|
||||
string product_json = "{\"detail\":" + detail_json + ",\"size\":" + size_json + ",\"decoration\":" + decoration_json + ",\"property\":" + property_json + "}";
|
||||
string product_json = "{\"detail\":" + detail_json + ",\"size\":" + size_json + ",\"decoration\":" + decoration_json +
|
||||
",\"material3\":" + material3_json + ",\"material1\":" + material1_json + ",\"property\":" + property_json + "}";
|
||||
string main_img = product.image_url;
|
||||
if (string.IsNullOrEmpty(main_img))
|
||||
main_img = product.hd_thumb_url;
|
||||
@@ -594,6 +660,38 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取物料详情 type = 1 或者 3 1是白底图,3是长图
|
||||
/// </summary>
|
||||
/// <param name="shop"></param>
|
||||
/// <param name="catId"></param>
|
||||
/// <param name="prodId"></param>
|
||||
/// <param name="commitId"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
private string GetPddGoodsMaterial(ShopLoginInfo shop, string prodId, string commitId, int type)
|
||||
{
|
||||
var anti = shop.AntiContents.LastOrDefault().ParseToString();
|
||||
if (shop.AntiContents.Count > 0)
|
||||
anti = shop.AntiContents[Randomx.GetId(shop.AntiContents.Count)];
|
||||
string url = "https://mms.pinduoduo.com/giraffe/mms/material/goodsMaterialInfo";
|
||||
string body = @"{""goods_id"":" + prodId + @",""type"":" + type + "}";
|
||||
string refere = "https://mms.pinduoduo.com/goods/goods_add/index?id=" + commitId + "&goods_id=" + prodId + "&type=edit";
|
||||
var result = HttpResponseBLL.PDDPostResponse(shop, url, body, refere, anti);
|
||||
for (int i = 0; i < 5 && (result.Contains("操作太过频繁") || result.Contains("网络繁忙,请不要频繁操作")); i++)
|
||||
{
|
||||
shop.AntiContents.Remove(anti);
|
||||
anti = shop.AntiContents.LastOrDefault().ParseToString();
|
||||
if (shop.AntiContents.Count > 0)
|
||||
{
|
||||
Thread.Sleep(Randomx.GetId(300, 500));
|
||||
anti = shop.AntiContents[Randomx.GetId(shop.AntiContents.Count)];
|
||||
result = HttpResponseBLL.PDDPostResponse(shop, url, body, refere, anti);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private string GetPddCatPropTemplate(ShopLoginInfo shop, string catId, string prodId, string commitId)
|
||||
{
|
||||
var anti = shop.AntiContents.LastOrDefault().ParseToString();
|
||||
@@ -602,8 +700,7 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
string url = "https://mms.pinduoduo.com/draco-ms/mms/template/mall?catId=" + catId +
|
||||
"&goodsCommitId=" + commitId + "&goodsId=" + prodId;
|
||||
string body = @"";
|
||||
string refere = "https://mms.pinduoduo.com/goods/goods_add/index?type=add&from=category&id=" + commitId +
|
||||
"&goods_id=" + prodId + "&sourcePage=goodsList";
|
||||
string refere = "https://mms.pinduoduo.com/goods/goods_add/index?id=" + commitId + "&goods_id=" + prodId + "&type=edit";
|
||||
var result = HttpResponseBLL.PDDGetResponse(shop, url, body, refere, anti);
|
||||
for (int i = 0; i < 5 && (result.Contains("操作太过频繁") || result.Contains("网络繁忙,请不要频繁操作")); i++)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user