1688上传类目转换等优化 充值用户服务充值和用户续费店铺功能

This commit is contained in:
wule committed 2026-05-27 22:01:04 +08:00
1 parent ecb291e3d7
commit aab73b978f
56 files changed
+4532 -1748

No files matched your search

+126 -54
View File
@@ -29,12 +29,13 @@ using Work;
namespace TemuKJD.ToolForms
{
public partial class WXSaleAssistantForm : BaseForms.BaseForm
public partial class WXSaleAssistantForm : BaseGeneralForm
{
public string OpenType { get; set; } = "collect";
public string InitUrl { get; set; } = "https://store.weixin.qq.com/talent/pool/home"; // https://store.weixin.qq.com/talent/home
public bool isGetingProdWithCef = false;
public CancellationTokenSource cancellationTokenSource { get; set; } = null;
ConcurrentList<WXSaleAssistantSpuItemInfo> lstWxSaleAssistantSpuItemInfo = new ConcurrentList<WXSaleAssistantSpuItemInfo>();
string InitUrl = "https://store.weixin.qq.com/talent/pool/home";
public ChromiumWebBrowser cefWebBrowser = null;
private string currentUrl = "";
int pageStart = 1;
@@ -50,53 +51,65 @@ namespace TemuKJD.ToolForms
InitializeComponent();
}
private void GetJuShuitanProdForm_Load(object sender, EventArgs e)
private void WXSaleAssistantForm_Load(object sender, EventArgs e)
{
//this.ucTabControlMetro1.TabPages.Remove(tabPage3);
if (OpenType == "login")
{
this.ucTabControlMetro1.TabPages.Remove(tabPage2);
this.Height = 900;
this.Width = 1360;
this.splitContainer1.SplitterDistance = splitContainer1.Height - 10;
this.CenterToScreen();
}
//this.splitContainer1.SplitterDistance = 472;
this.dgvProduct.AddSelectorColumn("colCheck");
this.dgvProduct.AddImgColumn("colImg", "colImgUrl");
lstWxSaleAssistantSpuItemInfo = NaiBa.Util.Helper.ConfigHelper.LoadConfig<ConcurrentList<WXSaleAssistantSpuItemInfo>>("wx_sale_assistant_list_" + MainForm.ProcessCount);
if (lstWxSaleAssistantSpuItemInfo == null)
lstWxSaleAssistantSpuItemInfo = new ConcurrentList<WXSaleAssistantSpuItemInfo>();
pbLoading.Visible = true;
Task.Run(() =>
if (OpenType == "collect")
{
int id = 0;
foreach (var prod in lstWxSaleAssistantSpuItemInfo)
pbLoading.Visible = true;
Task.Run(() =>
{
id++;
if (id % 50 == 0)
Thread.Sleep(1);
int id = 0;
foreach (var prod in lstWxSaleAssistantSpuItemInfo)
{
id++;
if (id % 50 == 0)
Thread.Sleep(1);
Invoke(new Action(() =>
{
var rowId = this.dgvProduct.Rows.Add(
true,
prod.shop.appId,
prod.shop.name,
prod.spu.id,
prod.spu.headImage, //.Replace("https://", "http://"),
DataGridViewExtension.defaultBitmap,
prod.spu.name,
prod.spu.sales.monthlySales,
prod.spu.sales.cumulativeSales,
"", // 没有类目信息,不填
prod.spu.price.sellingPrice * 0.01m,
"删除",
prod.operateMsg
);
dgvProduct.Rows[rowId].Height = 60;
}));
}
Invoke(new Action(() =>
{
var rowId = this.dgvProduct.Rows.Add(
true,
prod.shop.appId,
prod.shop.name,
prod.spu.id,
prod.spu.headImage, //.Replace("https://", "http://"),
DataGridViewExtension.defaultBitmap,
prod.spu.name,
prod.spu.sales.monthlySales,
prod.spu.sales.cumulativeSales,
"", // 没有类目信息,不填
prod.spu.price.sellingPrice * 0.01m,
"删除",
prod.operateMsg
);
dgvProduct.Rows[rowId].Height = 60;
pbLoading.Visible = false;
}));
}
Invoke(new Action(() =>
{
pbLoading.Visible = false;
}));
});
});
}
InitCef();
}
@@ -128,24 +141,33 @@ namespace TemuKJD.ToolForms
Task.Run(() =>
{
string serverCookie = "";
var url = BaseClass.BuildWXObjString("user/get_wx_sale_assistant_cookie");
var data = UserLogin.GetSignaturex();
var result = GetHtml.PostUtf8(url, data);
if (!result.Contains("\"code\":200"))
result = GetHtml.PostUtf8(url, data);
List<Cookie> cookieLst = new List<Cookie>();
try
if (OpenType == "collect")
{
serverCookie = JsonHelper.SerializeObject(JsonHelper.JObjectParse(result)["cookie"]);
cookieLst = JsonHelper.DeserializeJsonToList<CefSharp.Cookie>(serverCookie);
string serverCookie = "";
var url = BaseClass.BuildWXObjString("user/get_wx_sale_assistant_cookie");
var data = UserLogin.GetSignaturex();
var result = GetHtml.PostUtf8(url, data);
if (!result.Contains("\"code\":200"))
result = GetHtml.PostUtf8(url, data);
try
{
serverCookie = JsonHelper.SerializeObject(JsonHelper.JObjectParse(result)["cookie"]);
cookieLst = JsonHelper.DeserializeJsonToList<CefSharp.Cookie>(serverCookie);
if (cookieLst == null)
cookieLst = new List<Cookie>();
}
catch
{
}
}
if (OpenType == "login")
{
cookieLst = NaiBa.Util.Helper.ConfigHelper.LoadConfig<List<Cookie>>("wx_sale_assistant_cookies");
if (cookieLst == null)
cookieLst = new List<Cookie>();
}
catch
{
}
// cef138必须init后方可设置或删除cookie
@@ -169,7 +191,40 @@ namespace TemuKJD.ToolForms
private void CefWebBrowser_FrameLoadEnd(object sender, CefSharp.FrameLoadEndEventArgs e)
{
Task.Run(() =>
{
var jsStr = @"(function() { return document.body.innerHTML.indexOf('登录超时,请重新'); })();";
var client = cefWebBrowser.GetDevToolsClient();
if (client != null)
{
var result = client.Runtime.EvaluateAsync(jsStr, null, true, null, null, true, null, true);
result.Wait(5000);
string resultStr = result.Result.Result.Value.ParseToString();
if (resultStr.ParseToInt() > 0)
{
CEFBrowser.DeleteCookie(cefWebBrowser.GetCookieManager(null));
cefWebBrowser.Load("https://store.weixin.qq.com/talent/?redirect_url=%2Fpool%2Fhome");
return;
}
}
if (OpenType == "login" && !isLogin && (cefWebBrowser.Address.StartsWith("https://store.weixin.qq.com/talent/home") ||
cefWebBrowser.Address.StartsWith("https://store.weixin.qq.com/talent/pool/home")))
{
isLogin = true;
Thread.Sleep(500);
List<Cookie> cookieList = CEFBrowser.GetCookieList("store.weixin.qq.com", cefWebBrowser.GetCookieManager(null));
NaiBa.Util.Helper.ConfigHelper.SaveConfig("wx_sale_assistant_cookies", cookieList);
if (this.Created)
Invoke(new Action(() =>
{
BaseMsgForm.ShowInfo("登录成功");
this.Close();
}));
}
});
}
bool isLogin = false;
private void RequestHandler_ResourceLoadComplete(object sender, string url, string postData, string responseData, IRequest request)
{
@@ -276,11 +331,12 @@ namespace TemuKJD.ToolForms
{
Task.Run(() =>
{
Invoke(new Action(() =>
{
currentUrl = e.Address;
txtAddress.Text = e.Address;
}));
if (this.Created)
Invoke(new Action(() =>
{
currentUrl = e.Address;
txtAddress.Text = e.Address;
}));
});
}
}
@@ -573,7 +629,7 @@ namespace TemuKJD.ToolForms
//{"code":0,"pageContextResp":{"hasNext":false},"requestId":"1778688044492"}
int errorCnt = 0;
int nomoreCnt = 0;
var spuItemsData = GetAssistant.wxGetAssistant(cookieShop, getSpuItemsParams);
var spuItemsData = WxGetAssistant.wxGetAssistant(cookieShop, getSpuItemsParams);
for (int i = 1; i <= noNextPageRetryTimes; i++) // 重试50次
{
if (!spuItemsData.Contains("\"code\":0") || spuItemsData.Contains("\"hasNext\":false"))
@@ -608,7 +664,7 @@ namespace TemuKJD.ToolForms
sleepTime = (int)(getDetailWaitSeconds * 1000) - 100 + Randomx.GetId(101, 501);
Thread.Sleep(Math.Max(100, sleepTime));
spuItemsData = GetAssistant.wxGetAssistant(cookieShop, getSpuItemsParams);
spuItemsData = WxGetAssistant.wxGetAssistant(cookieShop, getSpuItemsParams);
}
if (i % 10 == 0 && spuItemsData.Contains("\"hasNext\":false"))
{
@@ -814,7 +870,7 @@ namespace TemuKJD.ToolForms
public int? cumulativeSales { get; set; } // 71960
}
public class GetAssistant
public class WxGetAssistant
{
public static string wxGetAssistant(ShopLoginInfo shop, JObject wxCateAuthParam)
{
@@ -824,5 +880,21 @@ namespace TemuKJD.ToolForms
var result = WXHttpResponseBLL.WeiXinAssistantPostResponse(shop, url, data, referer);
return result;
}
// {"filter":{"spuFilter":{"monthlySalesRange":null,"goodEvaluationRatioRange":null,"shopScoreRange":null},"spuSort":{"sortOrder":0,"sortType":0},"category":null},"pageContext":{"pageContext":null,"limit":15},"requestContext":{"sessionId":"1779790694673","requestId":"1779790757479","parentSearchId":"53","displayedSpus":null},"keyword":"10000708952443"}
public static string wxGetAssistant(ShopLoginInfo shop, string prodId)
{
string url = "https://store.weixin.qq.com/shop-faas/mmeckolpoolnode/ecSearchSelectionSpuItems?token=&lang=zh_CN";
string referer = "https://store.weixin.qq.com/talent/pool/home?keyword=" + prodId;
string body = @"{""filter"":{""spuFilter"":{""monthlySalesRange"":null,""goodEvaluationRatioRange"":null,""shopScoreRange"":null},
""spuSort"":{""sortOrder"":0,""sortType"":0},""category"":null},""pageContext"":{""pageContext"":null,""limit"":15},
""requestContext"":{""sessionId"":""" + BaseClass.DateTimeToTimestampMilliseconds(DateTime.Now.AddSeconds(-Randomx.GetId(10, 100))) + @""",
""requestId"":""" + BaseClass.DateTimeToTimestampMilliseconds(DateTime.Now) + @""",""parentSearchId"":""53"",""displayedSpus"":null},
""keyword"":""" + prodId + @"""}";
var result = WXHttpResponseBLL.WeiXinAssistantPostResponse(shop, url, body, referer);
return result;
}
}
}