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++)
|
||||
{
|
||||
|
||||
@@ -33,64 +33,6 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
private bool isLoading { get; set; } = false;
|
||||
|
||||
#region 服务端店铺管理
|
||||
public static string AddServerPddShop(ShopLoginInfo _shop)
|
||||
{
|
||||
var url = BaseClass.BuildObjString("shop/add_shop");
|
||||
var data = UserLogin.GetSignaturex()
|
||||
+ "&login_name=" + _shop.LoginName
|
||||
+ "&login_pass=" + GetHtml.UrlEncodeUtf8(_shop.Password)
|
||||
+ "&shop_id=" + _shop.ShopId
|
||||
+ "&shop_account=" + _shop.ShopAccount
|
||||
+ "&cookie=" + _shop.Cookies
|
||||
+ "&cookie2=" + _shop.Cookies2
|
||||
+ "&anti_contents=" + JsonHelper.SerializeObject(_shop.AntiContents)
|
||||
+ "&shop_group=" + GetHtml.UrlEncodeUtf8(_shop.GroupName)
|
||||
+ "&sub_user_name=" + GetHtml.UrlEncodeUtf8(_shop.SubUserName)
|
||||
+ "¬es=" + GetHtml.UrlEncodeUtf8(_shop.Notes)
|
||||
+ "&login_status=" + _shop.LoginStatus;
|
||||
|
||||
var result = GetHtml.PostUtf8(url, data);
|
||||
if (!result.Contains("\"code\":200") && !result.Contains("已达上限") && !result.Contains("已存在"))
|
||||
result = GetHtml.PostUtf8(url, data);
|
||||
if (!result.Contains("\"code\":200") && !result.Contains("已达上限") && !result.Contains("已存在"))
|
||||
result = GetHtml.PostUtf8(url, data);
|
||||
if (!result.Contains("\"code\":200"))
|
||||
{
|
||||
var msg = BaseRegex.GetStringJson(ref result, "msg");
|
||||
if (string.IsNullOrEmpty(msg))
|
||||
msg = "店铺保存失败!";
|
||||
BaseMsgForm.ShowError(msg);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static string MdyServerPddShop(ShopLoginInfo _shop)
|
||||
{
|
||||
var url = BaseClass.BuildObjString("shop/mdy_shop");
|
||||
var data = UserLogin.GetSignaturex()
|
||||
+ "&login_name=" + _shop.LoginName
|
||||
+ "&login_pass=" + GetHtml.UrlEncodeUtf8(_shop.Password)
|
||||
+ "&shop_id=" + _shop.ShopId
|
||||
+ "&shop_account=" + _shop.ShopAccount
|
||||
+ "&shop_group=" + GetHtml.UrlEncodeUtf8(_shop.GroupName)
|
||||
+ "&sub_user_name=" + _shop.SubUserName
|
||||
+ "¬es=" + GetHtml.UrlEncodeUtf8(_shop.Notes);
|
||||
|
||||
var result = GetHtml.PostUtf8(url, data);
|
||||
if (!result.Contains("\"code\":200") && !result.Contains("已达上限") && !result.Contains("已存在"))
|
||||
result = GetHtml.PostUtf8(url, data);
|
||||
if (!result.Contains("\"code\":200") && !result.Contains("已达上限") && !result.Contains("已存在"))
|
||||
result = GetHtml.PostUtf8(url, data);
|
||||
if (!result.Contains("\"code\":200"))
|
||||
{
|
||||
var msg = BaseRegex.GetStringJson(ref result, "msg");
|
||||
if (string.IsNullOrEmpty(msg))
|
||||
msg = "店铺保存失败!";
|
||||
BaseMsgForm.ShowError(msg);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void UpdateShop()
|
||||
{
|
||||
// 获取本地店铺和服务端店铺。将服务端相关信息与本地店铺合并后暂时存在内存中(不保存敏感信息)。
|
||||
@@ -320,13 +262,13 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
}
|
||||
else
|
||||
{
|
||||
PDDShopListForm.AddServerPddShop(shopInfo);
|
||||
ShopBLL.AddServerShop(shopInfo);
|
||||
btnRefreshCookie_Click(null, null);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PDDShopListForm.MdyServerPddShop(shopInfo);
|
||||
ShopBLL.MdyServerShopSubInfo(shopInfo);
|
||||
btnRefreshCookie_Click(null, null);
|
||||
}
|
||||
}
|
||||
@@ -410,7 +352,7 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
else
|
||||
GlobalConfig.ShopLoginList.Add(shop);
|
||||
StartUp.SaveLocalShopLoginInfo();
|
||||
PDDShopListForm.AddServerPddShop(shop);
|
||||
ShopBLL.AddServerShop(shop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Work;
|
||||
using Work.BLL.Tools;
|
||||
using TemuKJD.BLL;
|
||||
|
||||
namespace TemuKJD.PDDForms.ShopForms
|
||||
{
|
||||
@@ -165,7 +166,7 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
if (oldShop == null)
|
||||
{
|
||||
GlobalConfig.ShopLoginList.Add(newShop);
|
||||
PDDShopListForm.AddServerPddShop(newShop); // 店铺写入到服务端
|
||||
ShopBLL.AddServerShop(newShop); // 店铺写入到服务端
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -188,12 +189,7 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
+ "&shop_account=" + oldShop.ShopAccount;
|
||||
var result = GetHtml.PostUtf8(url, data);
|
||||
|
||||
var urlAddress = BaseClass.BuildObjString("shop/mdy_anti_content");
|
||||
data = UserLogin.GetSignaturex()
|
||||
+ "&login_name=" + shop.LoginName
|
||||
+ "&shop_id=" + shop.ShopId
|
||||
+ "&anti_contents=" + JsonHelper.SerializeObject(shop.AntiContents);
|
||||
result = GetHtml.PostUtf8(urlAddress, data);
|
||||
ShopBLL.MdyAntiContent(oldShop);
|
||||
}
|
||||
}
|
||||
var lstShop = GlobalConfig.ShopLoginList.Where(l => l.LoginName == shop.LoginName).ToList();
|
||||
@@ -460,28 +456,23 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
cefWebBrowser.GetBrowser().MainFrame.EvaluateScriptAsync(sb.ToString());
|
||||
}
|
||||
|
||||
int GetAntiContentsTimes = 40;
|
||||
static int GetAntiContentsTimes = 40;
|
||||
private void RequestHandler_ResourceLoadComplete(object sender, string url, string postData, string responseData, IRequest request)
|
||||
{
|
||||
var antiContent = request.Headers.AllKeys.Contains("Anti-Content") ? request.Headers["Anti-Content"] : "";
|
||||
if (shop != null && !url.StartsWith("https://mms.pinduoduo.com/janus/api/userinfo") && !string.IsNullOrEmpty(antiContent))
|
||||
{
|
||||
GetAntiContentsTimes++;
|
||||
Invoke(new Action(() => { this.TitleText = "店铺登录 - " + GetAntiContentsTimes; }));
|
||||
shop.AntiContents.Add(antiContent);
|
||||
while (shop.AntiContents.Count > 50)
|
||||
shop.AntiContents.RemoveAt(0);
|
||||
if (!string.IsNullOrEmpty(shop.ShopId) && GetAntiContentsTimes > 50)
|
||||
if (!string.IsNullOrEmpty(shop.ShopId) && GetAntiContentsTimes > 500)
|
||||
{
|
||||
GetAntiContentsTimes = 0;
|
||||
var antis = shop.AntiContents;
|
||||
Task.Run(() =>
|
||||
{
|
||||
var urlAddress = BaseClass.BuildObjString("shop/mdy_anti_content");
|
||||
var data = UserLogin.GetSignaturex()
|
||||
+ "&login_name=" + shop.LoginName
|
||||
+ "&shop_id=" + shop.ShopId
|
||||
+ "&anti_contents=" + JsonHelper.SerializeObject(antis);
|
||||
var result = GetHtml.PostUtf8(urlAddress, data);
|
||||
ShopBLL.MdyAntiContent(shop);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -312,7 +312,7 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
if (updateFrom != SetCookieFromEnum.normal_user)
|
||||
ShopBLL.AdminAddServerShop(newShop); // 店铺写入到服务端
|
||||
else
|
||||
PDDShopListForm.AddServerPddShop(newShop); // 店铺写入到服务端
|
||||
ShopBLL.AddServerShop(newShop); // 店铺写入到服务端
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user