580 lines
30 KiB
C#
580 lines
30 KiB
C#
using AllBase;
|
|
using AllBase.Helper;
|
|
using AllBase.Model.Result;
|
|
using AllBase.Model.Result.PDDResult;
|
|
using NaiBa.Util.Extension;
|
|
using Newtonsoft.Json.Linq;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using TemuKJD.BaseForms;
|
|
using TemuKJD.BLL;
|
|
using TemuKJD.PDDForms.AdminForms;
|
|
using TemuKJD.PDDForms.ProductThirdSelectForms;
|
|
using Work;
|
|
|
|
namespace TemuKJD.PDDForms.ShopForms
|
|
{
|
|
public class PDDShopBrowserObject
|
|
{
|
|
public delegate void InfoReceivedHandler(string information);
|
|
public event InfoReceivedHandler OnInfoReceived;
|
|
|
|
public string getProduct(string sProdId, string supplierId)
|
|
{
|
|
var prodId = sProdId.ParseToLong();
|
|
if (prodId <= 0)
|
|
{
|
|
BaseMsgForm.ShowError("商品Id不存在!");
|
|
return "failed";
|
|
}
|
|
var shop = GlobalConfig.ShopLoginList.FirstOrDefault(s => s.ShopId == supplierId.ParseToString());
|
|
if (string.IsNullOrEmpty(supplierId) || shop == null)
|
|
{
|
|
BaseMsgForm.ShowError("店铺不存在!");
|
|
return "failed";
|
|
}
|
|
|
|
Task.Run(() =>
|
|
{
|
|
try
|
|
{
|
|
var sourceShop = shop;
|
|
var sourceProdId = prodId;
|
|
string success_err_msg = "";
|
|
//string errorMsg = "";
|
|
var commit_id_rst = GetPddProdCommitId(sourceShop, sourceProdId.ToString());
|
|
if (!commit_id_rst.Contains("\"success\":true") || !commit_id_rst.Contains("\"result\""))
|
|
{
|
|
var errMsg = BaseRegex.GetStringJson(ref commit_id_rst, "error_msg");
|
|
if (string.IsNullOrEmpty(errMsg))
|
|
errMsg = commit_id_rst;
|
|
OnInfoReceived("商品获取失败!" + errMsg);
|
|
return;
|
|
}
|
|
var commitId = BaseRegex.GetStringJson(ref commit_id_rst, "goods_commit_id");
|
|
if (string.IsNullOrEmpty(commitId))
|
|
{
|
|
OnInfoReceived("商品获取失败!商品提交编号获取失败!");
|
|
return;
|
|
}
|
|
|
|
var detail_json = "{}";
|
|
PDDProductDetailInfo product = null;
|
|
try
|
|
{
|
|
var prod_detail_rst = GetPddProdDetail(sourceShop, sourceProdId.ToString(), commitId);
|
|
JObject prod_detail_obj = JObject.Parse(prod_detail_rst);
|
|
detail_json = JsonHelper.SerializeObject(prod_detail_obj["result"]);
|
|
product = JsonHelper.DeserializeJsonToObject<PDDProductDetailInfo>(detail_json);
|
|
if (product == null)
|
|
{
|
|
OnInfoReceived("商品获取失败!商品数据格式获取失败!");
|
|
return;
|
|
}
|
|
}
|
|
catch (Exception ex) { }
|
|
|
|
var property_json = "{}";
|
|
PDDProductPropertyInfo property = null;
|
|
try
|
|
{
|
|
var prod_property_rst = GetPddProdProperty(sourceShop, sourceProdId.ToString(), commitId);
|
|
prod_property_rst = GetHtml.Unicode2String(prod_property_rst);
|
|
JObject prod_property_obj = JObject.Parse(prod_property_rst);
|
|
property_json = JsonHelper.SerializeObject(prod_property_obj["result"]);
|
|
property = JsonHelper.DeserializeJsonToObject<PDDProductPropertyInfo>(property_json);
|
|
}
|
|
catch (Exception ex) { }
|
|
if (property == null)
|
|
{
|
|
OnInfoReceived("商品获取失败!商品属性获取失败!");
|
|
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;
|
|
//try
|
|
//{
|
|
// var prop_template_rst = GetPddCatPropTemplate(sourceShop, product.cat_id.ParseToString(), sourceProdId.ToString(), commitId);
|
|
// JObject prop_template_obj = JObject.Parse(prop_template_rst);
|
|
// prop_template_json = JsonHelper.SerializeObject(prop_template_obj["result"]);
|
|
// templateInfo = JsonHelper.DeserializeJsonToObject<PDDProductTemplateInfo>(prop_template_json);
|
|
//}
|
|
//catch (Exception ex) { }
|
|
//if (templateInfo == null)
|
|
//{
|
|
// OnInfoReceived("商品获取失败!商品属性模板获取失败!");
|
|
// return;
|
|
//}
|
|
|
|
var sizeRst = "";
|
|
//尺码表暂时注释
|
|
//if (product.sizeTemplateId > 0)
|
|
//{
|
|
// html = SizeSpecQuery(shop1, prodId1.ToString(), product.sizeTemplateId.ToString());
|
|
// if(!html.Contains("\"success\":true"))
|
|
// {
|
|
// success_err_msg += " 尺码表获取失败!" + BaseRegex.GetStringJson(ref html, "errorMsg");
|
|
// }
|
|
// else
|
|
// {
|
|
// obj = JObject.Parse(html);
|
|
// sizeRst = JsonHelper.SerializeObject(obj["result"]);
|
|
// }
|
|
//}
|
|
|
|
bool isExist = false;
|
|
var existUrl = BaseClass.BuildObjString("product/get_product_list");
|
|
string existData = UserLogin.GetSignaturex() + "&search_spu=" + product.goods_id;
|
|
string html = GetHtml.PostUtf8(existUrl, existData);
|
|
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
|
html = GetHtml.PostUtf8(existUrl, existData);
|
|
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
|
html = GetHtml.PostUtf8(existUrl, existData);
|
|
if (!string.IsNullOrEmpty(html) && html.Contains("\"code\":200"))
|
|
{
|
|
if (html.Contains("\"data\":[") && !html.Contains("\"data\":[]"))
|
|
isExist = true;
|
|
}
|
|
|
|
string product_json = "{\"detail\":" + detail_json + ",\"decoration\":" + decoration_json + ",\"property\":" + property_json + "}";
|
|
string main_img = product.image_url;
|
|
if (string.IsNullOrEmpty(main_img))
|
|
main_img = product.hd_thumb_url;
|
|
if (string.IsNullOrEmpty(main_img))
|
|
main_img = product.thumb_url;
|
|
if (string.IsNullOrEmpty(main_img))
|
|
main_img = (product.galleries?.FirstOrDefault()?.url).ParseToString().Replace("https://", "http://");
|
|
var url = BaseClass.BuildObjString("product/add_product");
|
|
if (isExist)
|
|
{
|
|
bool isCover = false;
|
|
MainForm.instance.Invoke(new Action(() =>
|
|
{
|
|
var ok = BaseMsgForm.ShowConfirm("产品库内已存在相同id商品,是否更新?").DialogResult;
|
|
if (ok == DialogResult.OK)
|
|
isCover = true;
|
|
}));
|
|
if (isCover)
|
|
url = BaseClass.BuildObjString("product/mdy_product");
|
|
else
|
|
return;
|
|
}
|
|
|
|
var data = Work.UserLogin.GetSignaturex() +
|
|
"&from_shop_id=" + shop.ShopId +
|
|
"&spu_id=" + product.goods_id.ParseToString() +
|
|
"&skc_id=" + product.goods_id.ParseToString() +
|
|
"&cat_id=" + (product.cat_id).ParseToString() +
|
|
"&cat_name=" + HttpUtility.UrlEncode((product.cats?.LastOrDefault(c => !string.IsNullOrEmpty(c))).ParseToString(), Encoding.UTF8) +
|
|
"&ext_code=" + HttpUtility.UrlEncode(product.out_goods_sn, Encoding.UTF8) +
|
|
"&product_name=" + HttpUtility.UrlEncode(product.goods_name, Encoding.UTF8) +
|
|
"&product_json=" + HttpUtility.UrlEncode(product_json, Encoding.UTF8) +
|
|
"&size_json=" + HttpUtility.UrlEncode(sizeRst, Encoding.UTF8) +
|
|
"&main_img=" + HttpUtility.UrlEncode(main_img, Encoding.UTF8);
|
|
|
|
html = GetHtml.PostUtf8(url, data);
|
|
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
|
html = GetHtml.PostUtf8(url, data);
|
|
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
|
html = GetHtml.PostUtf8(url, data);
|
|
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
|
{
|
|
string msg = "选品商品保存失败!请检查网络连接:" +
|
|
BaseRegex.GetStringJson(ref html, "msg");
|
|
OnInfoReceived(msg);
|
|
}
|
|
else
|
|
{
|
|
OnInfoReceived("选品商品保存成功!" + success_err_msg);
|
|
}
|
|
|
|
//// 创建 SaveFileDialog 的实例
|
|
//SaveFileDialog saveFileDialog = new SaveFileDialog();
|
|
|
|
//// 单线程单元(STA)模式运行文件对话框,否则会报错。
|
|
//System.Threading.Thread InvokeThread = new System.Threading.Thread(new System.Threading.ThreadStart(()=> {
|
|
|
|
// // 设置对话框的属性
|
|
// saveFileDialog.Title = "保存商品";
|
|
// saveFileDialog.Filter = "商品文件 (*.prd)|*.prd|所有文件 (*.*)|*.*"; // 过滤文件类型
|
|
// saveFileDialog.FileName = product.productId.ParseToString(); // 默认文件名
|
|
// saveFileDialog.DefaultExt = "txt"; // 默认文件扩展名
|
|
|
|
// // 显示对话框并获取结果
|
|
// if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
|
// {
|
|
// // 用户点击了“保存”按钮,此时可以获取文件的路径
|
|
// string filePath = saveFileDialog.FileName;
|
|
// // 在这里处理文件保存逻辑,例如写入数据到文件
|
|
// System.IO.File.WriteAllText(filePath, result);
|
|
|
|
// //BaseMsgForm.ShowInfo("商品保存成功!");
|
|
// }
|
|
//}));
|
|
//InvokeThread.SetApartmentState(System.Threading.ApartmentState.STA);
|
|
//InvokeThread.Start();
|
|
//InvokeThread.Join();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
}
|
|
});
|
|
|
|
return "success";
|
|
}
|
|
|
|
/// <summary>
|
|
/// 第三方获取商品并直接提交到第三方待上传列表
|
|
/// </summary>
|
|
/// <param name="sProdId"></param>
|
|
/// <param name="supplierId"></param>
|
|
/// <returns></returns>
|
|
public string getThirdProduct(string sProdId, string supplierId)
|
|
{
|
|
var prodId = sProdId.ParseToLong();
|
|
if (prodId <= 0)
|
|
{
|
|
BaseMsgForm.ShowError("商品Id不存在!");
|
|
return "failed";
|
|
}
|
|
var shop = GlobalConfig.ShopLoginList.FirstOrDefault(s => s.ShopId == supplierId.ParseToString());
|
|
if (string.IsNullOrEmpty(supplierId) || shop == null)
|
|
{
|
|
BaseMsgForm.ShowError("店铺不存在!");
|
|
return "failed";
|
|
}
|
|
|
|
Task.Run(() =>
|
|
{
|
|
try
|
|
{
|
|
var sourceShop = shop;
|
|
var sourceProdId = prodId;
|
|
string success_err_msg = "";
|
|
string errorMsg = "";
|
|
var html = GetPddProdCommitId(sourceShop, sourceProdId.ToString());
|
|
if (!html.Contains("\"success\":true") || !html.Contains("\"result\""))
|
|
{
|
|
var errMsg = BaseRegex.GetStringJson(ref html, "error_msg");
|
|
if (string.IsNullOrEmpty(errMsg))
|
|
errMsg = html;
|
|
OnInfoReceived("商品获取失败!" + errMsg);
|
|
return;
|
|
}
|
|
var commitId = BaseRegex.GetStringJson(ref html, "goods_commit_id");
|
|
if (string.IsNullOrEmpty(commitId))
|
|
{
|
|
OnInfoReceived("商品获取失败!商品提交编号获取失败!");
|
|
return;
|
|
}
|
|
html = GetPddProdDetail(sourceShop, sourceProdId.ToString(), commitId);
|
|
|
|
JObject obj = JObject.Parse(html);
|
|
var result = JsonHelper.SerializeObject(obj["result"]);
|
|
var sizeRst = "";
|
|
PDDProductDetailInfo product = JsonHelper.DeserializeJsonToObject<PDDProductDetailInfo>(result);
|
|
if (product == null)
|
|
{
|
|
OnInfoReceived("商品获取失败!商品数据格式获取失败!");
|
|
return;
|
|
}
|
|
|
|
//拼多多暂时注释尺码
|
|
//if (product.sizeTemplateId > 0)
|
|
//{
|
|
// html = SizeSpecQuery(sourceShop, sourceProdId.ToString(), product.sizeTemplateId.ToString());
|
|
// if (!html.Contains("\"success\":true"))
|
|
// {
|
|
// success_err_msg += " 尺码表获取失败!" + BaseRegex.GetStringJson(ref html, "errorMsg");
|
|
// }
|
|
// else
|
|
// {
|
|
// obj = JObject.Parse(html);
|
|
// sizeRst = JsonHelper.SerializeObject(obj["result"]);
|
|
// }
|
|
//}
|
|
|
|
List<ShopLoginInfo> shopLst = new List<ShopLoginInfo>();
|
|
PDDShopListForm.Instance.Invoke(new Action(() =>
|
|
{
|
|
PDDThirdProdSelectAddShopForm shopForm = new PDDThirdProdSelectAddShopForm();
|
|
shopForm.ShowDialog();
|
|
shopLst.AddRange(shopForm.lstSelectShop);
|
|
}));
|
|
if (shopLst.Count == 0)
|
|
{
|
|
OnInfoReceived("库存上传操作取消或未选择上传店铺!");
|
|
return;
|
|
}
|
|
|
|
var main_img = product.image_url;
|
|
if (string.IsNullOrEmpty(main_img))
|
|
main_img = product.hd_thumb_url;
|
|
if (string.IsNullOrEmpty(main_img))
|
|
main_img = product.thumb_url;
|
|
if (string.IsNullOrEmpty(main_img))
|
|
main_img = (product.galleries?.FirstOrDefault()?.url).ParseToString().Replace("https://", "http://");
|
|
var url = BaseClass.BuildObjString("product_third/add_product");
|
|
var data = UserLogin.GetSignaturex() +
|
|
"&from_shop_id=" + shop.ShopId +
|
|
"&spu_id=" + product.goods_id.ParseToString() +
|
|
"&skc_id=" + product.goods_id.ParseToString() +
|
|
"&cat_id=" + (product.cat_id).ParseToString() +
|
|
"&cat_name=" + HttpUtility.UrlEncode((product.cats?.LastOrDefault(c => !string.IsNullOrEmpty(c))).ParseToString(), Encoding.UTF8) +
|
|
"&ext_code=" + HttpUtility.UrlEncode(product.out_goods_sn, Encoding.UTF8) +
|
|
"&product_name=" + HttpUtility.UrlEncode(product.goods_name, Encoding.UTF8) +
|
|
"&product_json=" + HttpUtility.UrlEncode(result, Encoding.UTF8) +
|
|
"&size_json=" + HttpUtility.UrlEncode(sizeRst, Encoding.UTF8) +
|
|
"&main_img=" + HttpUtility.UrlEncode(main_img, Encoding.UTF8);
|
|
html = GetHtml.PostUtf8(url, data);
|
|
//if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
|
// html = GetHtml.PostUtf8(url, data);
|
|
//if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
|
// html = GetHtml.PostUtf8(url, data);
|
|
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
|
{
|
|
errorMsg = "库存商品保存失败!请检查网络连接:" +
|
|
BaseRegex.GetStringJson(ref html, "msg").ParseToString().Replace("'", "\\'").Replace("\"", "\\\"");
|
|
}
|
|
var id = BaseRegex.GetLongJson(ref html, "id");
|
|
if (id == 0)
|
|
goto end;
|
|
|
|
foreach (var addProdShop in shopLst)
|
|
{
|
|
url = BaseClass.BuildObjString("product_third/add_user_select_product");
|
|
data = UserLogin.GetSignaturex() +
|
|
"&out_product_id=" + id +
|
|
"&shop_id=" + addProdShop.ShopId +
|
|
"&shop_account=" + addProdShop.ShopAccount +
|
|
"&main_user_name=" + addProdShop.UserName +
|
|
"&sub_user_name=" + addProdShop.SubUserName +
|
|
"&add_product_remaining=" + addProdShop.AddProductRemaining +
|
|
"&status=待上传";
|
|
html = GetHtml.PostUtf8(url, data);
|
|
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
|
html = GetHtml.PostUtf8(url, data);
|
|
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
|
html = GetHtml.PostUtf8(url, data);
|
|
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
|
{
|
|
errorMsg += product?.goods_id + " " + BaseRegex.GetStringJson(ref html, "msg") + "; ";
|
|
}
|
|
else
|
|
{
|
|
addProdShop.AddProductRemaining = addProdShop.AddProductRemaining - 1;
|
|
}
|
|
}
|
|
end:;
|
|
if (!string.IsNullOrEmpty(errorMsg))
|
|
{
|
|
OnInfoReceived(errorMsg);
|
|
}
|
|
else
|
|
{
|
|
OnInfoReceived("库存上传保存成功!" + success_err_msg);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
OnInfoReceived("发生错误:" + ex.Message);
|
|
}
|
|
});
|
|
|
|
return "success";
|
|
}
|
|
|
|
TemuCat GetCat(TemuDetailProductInfo product)
|
|
{
|
|
if (product == null)
|
|
return new TemuCat();
|
|
|
|
var cat = product.categories.cat10;
|
|
if (string.IsNullOrWhiteSpace(cat.catName))
|
|
cat = product.categories.cat9;
|
|
if (string.IsNullOrWhiteSpace(cat.catName))
|
|
cat = product.categories.cat8;
|
|
if (string.IsNullOrWhiteSpace(cat.catName))
|
|
cat = product.categories.cat7;
|
|
if (string.IsNullOrWhiteSpace(cat.catName))
|
|
cat = product.categories.cat6;
|
|
if (string.IsNullOrWhiteSpace(cat.catName))
|
|
cat = product.categories.cat5;
|
|
if (string.IsNullOrWhiteSpace(cat.catName))
|
|
cat = product.categories.cat4;
|
|
if (string.IsNullOrWhiteSpace(cat.catName))
|
|
cat = product.categories.cat3;
|
|
if (string.IsNullOrWhiteSpace(cat.catName))
|
|
cat = product.categories.cat2;
|
|
if (string.IsNullOrWhiteSpace(cat.catName))
|
|
cat = product.categories.cat1;
|
|
|
|
return cat;
|
|
}
|
|
|
|
|
|
|
|
private string GetPddProdCommitId(ShopLoginInfo shop, string prodId)
|
|
{
|
|
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/glide/v2/mms/edit/commit/create_by_sn";
|
|
string body = @"{""goods_id"":" + prodId + "}";
|
|
string refere = "https://mms.pinduoduo.com/goods/goods_list?msfrom=mms_sidenav";
|
|
var result = HttpResponseBLL.PDDPostResponse(shop, url, body, refere, anti);
|
|
for (int i = 0; i < 5 && result.Contains("网络繁忙,请不要频繁操作"); i++)
|
|
{
|
|
shop.AntiContents.Remove(anti);
|
|
anti = shop.AntiContents.FirstOrDefault().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 GetPddProdDetail(ShopLoginInfo shop, string prodId, string commitId)
|
|
{
|
|
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/glide/v2/mms/query/commit/on_shop/detail"; //on_shop获取到的结构不对
|
|
string url = "https://mms.pinduoduo.com/glide/v2/mms/query/commit/detail";
|
|
//string body = @"{""goods_id"":" + prodId + "}";
|
|
string body = @"{""goods_commit_id"":""" + commitId + @""",""goods_id"":""" + prodId + @"""}";
|
|
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("网络繁忙,请不要频繁操作"); i++)
|
|
{
|
|
shop.AntiContents.Remove(anti);
|
|
anti = shop.AntiContents.FirstOrDefault().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 GetPddProdProperty(ShopLoginInfo shop, string prodId, string commitId)
|
|
{
|
|
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/draco-ms/mms/query-goods-property";
|
|
string body = @"{""goods_id"":" + prodId + "}";
|
|
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("网络繁忙,请不要频繁操作"); i++)
|
|
{
|
|
shop.AntiContents.Remove(anti);
|
|
anti = shop.AntiContents.FirstOrDefault().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 GetPddProdDecoration(ShopLoginInfo shop, string prodId, string commitId)
|
|
{
|
|
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/gorse/mms/goods/decoration/commit/query/V2";
|
|
string body = @"{""goods_commit_id"":" + commitId + @",""goods_id"":" + prodId + @"}";
|
|
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("网络繁忙,请不要频繁操作"); i++)
|
|
{
|
|
shop.AntiContents.Remove(anti);
|
|
anti = shop.AntiContents.FirstOrDefault().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();
|
|
if (shop.AntiContents.Count > 0)
|
|
anti = shop.AntiContents[Randomx.GetId(shop.AntiContents.Count)];
|
|
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";
|
|
var result = HttpResponseBLL.PDDGetResponse(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.PDDGetResponse(shop, url, body, refere, anti);
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
private string SizeSpecQuery(ShopLoginInfo shop, string prodId, string sizeSpecId)
|
|
{
|
|
//string url = "https://seller.kuajingmaihuo.com/bg-anniston-mms/sizespec/query";
|
|
//string body = @"{""businessId"":" + sizeSpecId + @",""reusable"":false}";
|
|
//string refere = "https://seller.kuajingmaihuo.com/goods/product-create/product-edit?from=productList&productId=" + prodId;
|
|
//return HttpResponseBLL.PostResponse(shop, url, body, refere);
|
|
|
|
return "";
|
|
}
|
|
}
|
|
}
|