Files
KJD/Work/Api/DownUpProductExploder.cs
T

219 lines
9.2 KiB
C#

using System.Threading;
using AllBase;
using System;
using Work.CollectClass;
namespace Work.Api
{
public class DownUpProductExploder
{
public string Name;
public bool SetOn;
public string GoodsId;
public string Cookies = "";
public ShopChatBase Shop;
public DownUpProductExploder(string name, bool setOn, string goodsId)
{
Name = name;
SetOn = setOn;
GoodsId = goodsId;
}
public void Get()
{
string data = "{\"goodsIds\":[" + GoodsId + "]}";
string urlx = "https://mms.pinduoduo.com/vodka/v2/mms/batchOffSale";
string refere = "https://mms.pinduoduo.com/Pdd.html";
string html = GetPostTaobaoHtml.UploadTaobaoPost(urlx, refere, true, data, Cookies);
if (html.Contains("{\"success\":true"))
{
string[] l = GoodsId.Split(',');
foreach (string s in l)
{
var good = Shop.OnlineProduct.Find(p => p.GoodsId == long.Parse(s));
good.Message = "下架成功";
UploadPinduoduoMain.ProductReplaceTemp.Add(good);
LogSave.Add(Name, "下架产品成功:" + s);
}
return;
}
if (html.Contains("手速太快了"))
{
LogSave.Add(Name, "手速太快了,休眠30秒后,继续执行");
Thread.Sleep(30*1000);
string[] l = GoodsId.Split(',');
urlx = "https://mms.pinduoduo.com/vodka/v2/mms/pc/offSale";
for (int i = 0; i < l.Length; i++)
{
data = "{\"goodsId\":"+l[i]+"}";
html = GetPostTaobaoHtml.UploadTaobaoPost(urlx, refere, true, data, Cookies);
var good = Shop.OnlineProduct.Find(p => p.GoodsId == long.Parse(l[i]));
if (good != null)
{
good.Message = "下架成功";
UploadPinduoduoMain.ProductReplaceTemp.Add(good);
}
Thread.Sleep(3*1000);
LogSave.Add(Name, "下架产品成功:" + l[i]);
if(!html.Contains("success"))
Thread.Sleep(60*1000);
}
//html = GetPostTaobaoHtml.UploadTaobaoPost(urlx, refere, true, data, Cookies);
}
if (string.IsNullOrEmpty(html) || html.Contains("过于频繁"))
{
Thread.Sleep(30 * 1000);
html = GetPostTaobaoHtml.UploadTaobaoPost(urlx, refere, true, data, Cookies);
if (string.IsNullOrEmpty(html) || html.Contains("过于频繁"))
{
Thread.Sleep(90 * 1000);
html = GetPostTaobaoHtml.UploadTaobaoPost(urlx, refere, true, data, Cookies);
}
if (!string.IsNullOrEmpty(html) && html.Contains("过于频繁"))
{
LogSave.Add(Name, "速度太快,休眠2-5分钟");
}
else
{
LogSave.Add(Name, html);
}
}
else
{
string[] l = GoodsId.Split(',');
foreach (string s in l)
{
var good= Shop.OnlineProduct.Find(p => p.GoodsId == long.Parse(s));
good.Message = "下架成功";
UploadPinduoduoMain.ProductReplaceTemp.Add(good);
LogSave.Add(Name, "下架产品成功:" + s);
}
}
}
public void Up()
{
string data = "{\"goodsIds\":[" + GoodsId + "]}";
string urlx = "https://mms.pinduoduo.com/vodka/v2/mms/batchOnSale";
string refere = "https://mms.pinduoduo.com/Pdd.html";
string html = GetPostTaobaoHtml.UploadTaobaoPost(urlx, refere, true, data, Cookies);
if (!string.IsNullOrEmpty(html) && html.Contains("{\"success\":true"))
{
string[] l = GoodsId.Split(',');
foreach (string s in l)
{
var good = Shop.OnlineProduct.Find(p => p.GoodsId == long.Parse(s));
good.Message = "上架成功";
UploadPinduoduoMain.ProductReplaceTemp.Add(good);
}
return;
}
if (html.Contains("手速太快了"))
{
LogSave.Add(Name, "手速太快了,休眠30秒后,继续执行");
Thread.Sleep(30 * 1000);
string[] l = GoodsId.Split(',');
urlx = "https://mms.pinduoduo.com/vodka/v2/mms/pc/onSale";
for (int i = 0; i < l.Length; i++)
{
data = "{\"goodsId\":" + l[i] + "}";
html = GetPostTaobaoHtml.UploadTaobaoPost(urlx, refere, true, data, Cookies);
Thread.Sleep(3 * 1000);
LogSave.Add(Name, "下架产品成功:" + l[i]);
if (!html.Contains("success"))
Thread.Sleep(30 * 1000);
}
//Thread.Sleep(30 * 60 * 1000);
//html = GetPostTaobaoHtml.UploadTaobaoPost(urlx, refere, true, data, Cookies);
}
if (string.IsNullOrEmpty(html) || html.Contains("过于频繁"))
{
Thread.Sleep(30 * 1000);
html = GetPostTaobaoHtml.UploadTaobaoPost(urlx, refere, true, data, Cookies);
if (string.IsNullOrEmpty(html) || html.Contains("过于频繁"))
{
Thread.Sleep(90 * 1000);
html = GetPostTaobaoHtml.UploadTaobaoPost(urlx, refere, true, data, Cookies);
}
if (!string.IsNullOrEmpty(html) && html.Contains("过于频繁"))
{
LogSave.Add(Name, "速度太快,休眠2-5分钟");
}
else
{
LogSave.Add(Name, html);
}
}
else
{
string[] l = GoodsId.Split(',');
foreach (string s in l)
{
LogSave.Add(Name, "上架产品成功:" + s);
}
}
}
public string Delete()
{
//var api = new PinduoduoApiGetProduct(Shop);
//string html = api.DelGoods("["+GoodsId+"]");
string url = "https://mms.pinduoduo.com/plutus/api/plutus/bin/goods/delete/batch";
string refere = "http://mms.pinduoduo.com/Pdd.html";
string data = "{\"goods_ids\":[" + GoodsId + "],\"mall_id\":" + Shop.MallId + ",\"creator\":\"" + Shop.ShopName + "\",\"creator_id\":" + Shop.ReceiverId + "}";
string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, Cookies);
Thread.Sleep(1000);
return html;
}
public void OffSale()
{
string NoCode = "";
string strTime = BaseClass.GetTime(DateTime.Now).ToString() + "000";
if (string.IsNullOrEmpty(NoCode))
{
string htmlx = GetHtml.Gbk("http://nano.qixiaoke.com/nano.txt");
NoCode = BaseRegex.GetMatchRegexString(ref htmlx, @"([\w\W]+?)-----");
}
if (string.IsNullOrEmpty(PinduoduoAuth.strContent))
{
PinduoduoAuth.strContent = GetVisitProductNew.strJs;//FileBase.ReadAllText(path);
}
string codex = "";
//using (IJsEngine jsEngine = new V8JsEngine())
//{
// jsEngine.Execute(GetProductOnlineClass.JsCodeGetSms);
// codex = jsEngine.CallFunction("aaa", "").ToString();
//}
codex = Work.ManageClass.CpsSetAllGoods.getAnti0aon();
string refere = "https://mms.pinduoduo.com/Pdd.html";
string urlx = "https://mms.pinduoduo.com/vodka/v2/mms/pc/offSale";
string data = "{\"goodsId\":" + GoodsId + ",\"crawlerInfo\":\"" + codex + "\"}";
//string html = GetPostTaobaoHtml.UploadTaobaoPost(urlx, refere, true, data, Cookies);
string html = Work.ManageClass.CpsSetAllGoods.Request_mms_pinduoduo_com(urlx, refere, Cookies, data, codex);
Thread.Sleep(5*1000);
}
public void OffSaleApi()
{
var api = new PinduoduoApiGetProduct(Shop);
try
{
var html = api.SetOnline(Convert.ToInt64(GoodsId), false);
}
catch { }
Thread.Sleep(3 * 1000);
}
public string GetPidsStore()
{
string data = "{\"goodsIds\":[" + GoodsId + "]}";
string urlx = "https://mms.pinduoduo.com/vodka/v2/mms/batchOffSale";
string refere = "https://mms.pinduoduo.com/Pdd.html";
string html = GetPostTaobaoHtml.UploadTaobaoPost(urlx, refere, true, data, Cookies);
Thread.Sleep(1000);
return html;
}
}
}