188 lines
8.8 KiB
C#
188 lines
8.8 KiB
C#
using AllBase;
|
|
using JavaScriptEngineSwitcher.Core;
|
|
using JavaScriptEngineSwitcher.V8;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.IO.Compression;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using Work.Api;
|
|
|
|
namespace Work.CollectClass
|
|
{
|
|
public class WithDrawAmount
|
|
{
|
|
public static string Name = "提现记录";
|
|
public ShopChatBase currentShop;
|
|
public static List<DrawAmount> TempShops = new List<DrawAmount>();
|
|
|
|
public static string Request_mms_pinduoduo_com(string url, string referer, string cookie, string data, string antiContent, IWebProxy proxy = null)
|
|
{
|
|
string responseText = "";
|
|
HttpWebResponse response = null;
|
|
|
|
try
|
|
{
|
|
//HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://mms.pinduoduo.com/cps/api/coupon/createCommonCoupon");
|
|
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
|
|
|
|
request.KeepAlive = true;
|
|
request.Accept = "application/json";
|
|
//request.Headers.Add("Anti-Content", @"0aoAfxnUgOQoU9dVEHIuLKYezEfQ51QpOcKVg_S0aww9S8dseM_tTxYptgFssmH7wfRCpRvfISyXp-bZ8hcq7ux0Z1kvhFUkfIMk7EsEefUAZS7Jv1vYHm1Cplb4GZ43dSFtKu19dO7snIyL-VRj0JFy0ETKDkf1EdaPbWEu22sZ4s1duGD6WO9lgeS-oTsEwwa9ohcX2E_DG2PggPHqIuxcN_tIthAewaqklSPvPmFwzYxrlo256wd2i74SMvTzGTB--UkZ3gPl5t6K-6IVCz1MDD7WDS9HeoGm4RBmyd0LIpXG400lOfKBvPh-z09PL3_hjiL1KiBCENrs1ANosN35LJ8zhlCRi0YrDxphd8LGJFWDG0LrARGRuMW7d3d4IlWlEKFFMiucGGNlIZqDyExDIMny-8T-KY8fJ8BnNuzWyr");
|
|
request.Headers.Add("Anti-Content", antiContent);
|
|
//request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36";
|
|
request.UserAgent = BaseClass.ChromeUserAgent;
|
|
request.ContentType = "application/json;charset=UTF-8";
|
|
request.Headers.Add("Origin", @"https://mms.pinduoduo.com");
|
|
request.Headers.Add("Sec-Fetch-Site", @"same-origin");
|
|
request.Headers.Add("Sec-Fetch-Mode", @"cors");
|
|
request.Headers.Add("Sec-Fetch-Dest", @"empty");
|
|
request.Referer = referer;
|
|
request.Headers.Set(HttpRequestHeader.AcceptEncoding, "gzip, deflate, br");
|
|
request.Headers.Set(HttpRequestHeader.AcceptLanguage, "zh-CN,zh;q=0.9");
|
|
request.Headers.Set(HttpRequestHeader.Cookie, cookie);
|
|
if (proxy != null)
|
|
request.Proxy = proxy;
|
|
|
|
request.Method = "POST";
|
|
request.ServicePoint.Expect100Continue = false;
|
|
|
|
string body = data;
|
|
byte[] postBytes = System.Text.Encoding.UTF8.GetBytes(body);
|
|
request.ContentLength = postBytes.Length;
|
|
Stream stream = request.GetRequestStream();
|
|
stream.Write(postBytes, 0, postBytes.Length);
|
|
stream.Close();
|
|
|
|
response = (HttpWebResponse)request.GetResponse();
|
|
}
|
|
catch (WebException e)
|
|
{
|
|
if (e.Status == WebExceptionStatus.ProtocolError) response = (HttpWebResponse)e.Response;
|
|
else responseText = "error," + e.Message;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
responseText = "error," + ex.Message;
|
|
}
|
|
if (response != null)
|
|
{
|
|
if (string.IsNullOrEmpty(responseText))
|
|
responseText = ReadResponse(response);
|
|
response.Close();
|
|
}
|
|
|
|
Thread.Sleep(50 + Randomx.GetId(100));
|
|
|
|
return responseText;
|
|
}
|
|
public static string ReadResponse(HttpWebResponse response)
|
|
{
|
|
using (Stream responseStream = response.GetResponseStream())
|
|
{
|
|
Stream streamToRead = responseStream;
|
|
if (response.ContentEncoding.ToLower().Contains("gzip"))
|
|
{
|
|
streamToRead = new GZipStream(streamToRead, CompressionMode.Decompress);
|
|
}
|
|
else if (response.ContentEncoding.ToLower().Contains("deflate"))
|
|
{
|
|
streamToRead = new DeflateStream(streamToRead, CompressionMode.Decompress);
|
|
}
|
|
|
|
using (StreamReader streamReader = new StreamReader(streamToRead, Encoding.UTF8))
|
|
{
|
|
return streamReader.ReadToEnd();
|
|
}
|
|
}
|
|
}
|
|
public static string getAnti0aon()
|
|
{
|
|
string anti = "";
|
|
using (IJsEngine jsEngine = new V8JsEngine())
|
|
{
|
|
jsEngine.Execute(GetProductOnlineClass.PinDuoDUo_0ao);
|
|
anti = jsEngine.CallFunction("get_anti", "").ToString();
|
|
try
|
|
{ anti = "0ao" + anti.Substring(3); }
|
|
catch { }
|
|
}
|
|
return anti;
|
|
}
|
|
|
|
public void GetWithDraw()
|
|
{
|
|
for (int i = 0; i < GetShopLoginInfo.Shops.Count; i++)
|
|
{
|
|
var shop = GetShopLoginInfo.Shops[i];
|
|
if (!shop.SelectWithMoney)
|
|
continue;
|
|
LogSave.Add(Name, "正在读取店铺"+shop.ShopName+"提现记录");
|
|
string url = "https://mms.pinduoduo.com/uranus/api/balance/withdrawList";
|
|
string refere = "https://mms.pinduoduo.com/finance/balance";
|
|
string data = "{\"size\":10,\"page\":1,\"typeList\":[0,1]}";
|
|
string html = Request_mms_pinduoduo_com(url, refere, shop.Cookies, data, getAnti0aon());
|
|
//string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, shop.Cookies);
|
|
int reusltTotal = BaseRegex.GetIntJson(ref html, "total");
|
|
int page = reusltTotal / 10 + (reusltTotal % 10 > 0 ? 1 : 0);
|
|
for (int n = 1; n <= page; n++)
|
|
{
|
|
//非第一页匹配结果
|
|
if (n != 1)
|
|
{
|
|
data = "{\"size\":10,\"page\":"+n+",\"typeList\":[0,1]}";
|
|
html = Request_mms_pinduoduo_com(url, refere, shop.Cookies, data, getAnti0aon());
|
|
}
|
|
//获取所有订单金额
|
|
var ordersm = BaseRegex.GetMatchRegex(ref html, @"{[^}]+}");
|
|
for (int j = 0; ordersm != null && j < ordersm.Count; j++)
|
|
{
|
|
string orderItem = ordersm[j].Groups[0].Value;
|
|
long createdTime = BaseRegex.GetLongJson(ref orderItem, "createdTime");
|
|
long amount= BaseRegex.GetLongJson(ref orderItem, "amount");
|
|
int status = BaseRegex.GetIntJson(ref orderItem, "status");
|
|
string bankAccountId = BaseRegex.GetStringJson(ref orderItem, "bankAccountId");
|
|
string bankAccountName = BaseRegex.GetStringJson(ref orderItem, "bankAccountName");
|
|
string bankName = BaseRegex.GetStringJson(ref orderItem, "bankName");
|
|
string statusMessage = BaseRegex.GetStringJson(ref orderItem, "statusMessage");
|
|
string noteMessage = BaseRegex.GetStringJson(ref orderItem, "noteMessage");
|
|
string message = BaseRegex.GetStringJson(ref orderItem, "message");
|
|
DrawAmount drawAmount = new DrawAmount();
|
|
drawAmount.shopName = shop.ShopName;
|
|
drawAmount.name = shop.Name;
|
|
drawAmount.status = status;
|
|
drawAmount.createTime = new DateTime((Convert.ToInt64(createdTime) * 10000) + 621355968000000000).ToString();
|
|
drawAmount.bankAmount = (amount/100M).ToString();
|
|
drawAmount.bankCard = bankName +"\r\n"+ bankAccountId.Substring(bankAccountId.Length-4) + "|"+bankAccountName;
|
|
drawAmount.bankStatus = statusMessage+"\r\n"+message;
|
|
drawAmount.remark = noteMessage;
|
|
TempShops.Add(drawAmount);
|
|
}
|
|
}
|
|
}
|
|
LogSave.Add(Name, "读取店铺提现记录完成");
|
|
}
|
|
}
|
|
public class DrawAmount
|
|
{
|
|
public string shopName = "";
|
|
public string name = "";
|
|
public int status = 0;
|
|
public string createTime = "";
|
|
public string bankAmount = "";
|
|
public string bankCard = "";
|
|
public string bankStatus = "";
|
|
public string remark = "";
|
|
}
|
|
public class ShopWithDraw
|
|
{
|
|
public string shopName = "";
|
|
public decimal successAmount = 0M;
|
|
public decimal failAmount = 0M;
|
|
}
|
|
}
|