列表shift多选,修复客服无法筛选店铺bug

This commit is contained in:
wule_5900x committed 2026-03-14 21:05:50 +08:00
1 parent b27c473c99
commit 679bae7c42
11 files changed
+272 -110

No files matched your search

+1 -1
View File
@@ -27,7 +27,7 @@ namespace AllBase
/// <summary> /// <summary>
/// 版本ID /// 版本ID
/// </summary> /// </summary>
public static int VersionCount = 909; public static int VersionCount = 912;
//public static int VersionCount = 613; //public static int VersionCount = 613;
/// <summary> /// <summary>
@@ -1288,8 +1288,8 @@ namespace KJD_Web.BLL.BXX
//sql += " ORDER BY RAND()"; //sql += " ORDER BY RAND()";
//sql += " limit " + Math.Max(page - 1, 0) * page_size + "," + page_size; //sql += " limit " + Math.Max(page - 1, 0) * page_size + "," + page_size;
var limit = RandomUtils.GetId(Math.Max(1, count - page_size)); var limit = RandomUtils.GetId(Math.Max(0, count - page_size));
sql += " limit " + limit + "," + page_size; sql += " limit " + limit + "," + 5000;
dt = mySql.ExecuteDataTable(sql); dt = mySql.ExecuteDataTable(sql);
Thread.Sleep(100); Thread.Sleep(100);
@@ -1299,7 +1299,7 @@ namespace KJD_Web.BLL.BXX
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\",\"data\":[],\"count\":" + 0 + "}"; return "{\"code\":500,\"msg\":\"" + mySql.Message + "\",\"data\":[],\"count\":" + 0 + "}";
} }
var db_ids = string.Join(",", dt.Rows.Cast<DataRow>().Select(r => r["id"].ParseToInt())); var db_ids = string.Join(",", dt.Rows.Cast<DataRow>().Select(r => r["id"].ParseToInt()).OrderBy(x => RandomUtils.GetId(10000000)).Take(page_size));
sql = "select p.id,p.from_shop_id,p.spu_id,p.skc_id,p.main_cat_id,p.main_cat_name,p.cat_id,p.cat_name,p.price_text,p.ext_code," + sql = "select p.id,p.from_shop_id,p.spu_id,p.skc_id,p.main_cat_id,p.main_cat_name,p.cat_id,p.cat_name,p.price_text,p.ext_code," +
" p.product_name,p.main_img,p.group,p.notes,p.add_time,p.mdy_time,p.product_get_type," + " p.product_name,p.main_img,p.group,p.notes,p.add_time,p.mdy_time,p.product_get_type," +
" p.wx_safe_status,p.special_prod_type,p.wx_cat_1,p.wx_cat_2,p.wx_cat_3,p.send_to_out_server," + " p.wx_safe_status,p.special_prod_type,p.wx_cat_1,p.wx_cat_2,p.wx_cat_3,p.send_to_out_server," +
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup> <PropertyGroup>
<UseIISExpress>true</UseIISExpress> <UseIISExpress>true</UseIISExpress>
+14 -9
View File
@@ -671,22 +671,27 @@ namespace TemuKJD.BLL
} }
var itemNo = jSku["itemNo"].ParseToString(); var itemNo = jSku["itemNo"].ParseToString();
var baseSkuId = jSku["baseSkuId"].ParseToString(); var baseSkuId = jSku["baseSkuId"].ParseToString();
var skuId = jstSecretCodeLst["skus"].FirstOrDefault(s => s["skuCode"].ParseToString() == itemNo)?["skuId"].ParseToString(); // skuCode可能不唯一,使用skuId取加密后的货号
// skuCode可能不唯一 //var skuId = jstSecretCodeLst["skus"].FirstOrDefault(s => s["skuCode"].ParseToString() == itemNo)?["skuId"].ParseToString();
skuId = jstSecretCodeLst["skus"].FirstOrDefault(s => s["warehouseSkuId"].ParseToString() == baseSkuId)?["skuId"].ParseToString(); var skuId = jstSecretCodeLst["skus"].FirstOrDefault(s => s["warehouseSkuId"].ParseToString() == baseSkuId)?["skuId"].ParseToString();
if (skuId.IsNullOrEmpty()) if (skuId.IsNullOrEmpty() || string.IsNullOrEmpty(itemNo))
{ {
convertRst = "SKU货号不存在"; convertRst = "SKU货号不存在";
return null; return null;
} }
if (jstSecretCodeLst["skus"].Select(s => s["spuCode"].ParseToString()).Distinct().Count() != jstSecretCodeLst["skus"].Count()) // 外部编码(货号)
{
convertRst = "SKU货号重复";
return null;
}
skuInfo.out_sku_sn = skuId; skuInfo.out_sku_sn = skuId;
prodInfo.detail.sku.Add(skuInfo); prodInfo.detail.sku.Add(skuInfo);
} }
// 测试发现skuCoke重复可能对推单有影响,先吧skuCode重复的排除掉
var skuCount = jstGoodsObj["skuInfo"]["goodsSkuDetail"].Select(s => s["baseSkuId"].ParseToString()).Distinct().Count();
var itemNoCount = jstGoodsObj["skuInfo"]["goodsSkuDetail"].Select(s => s["itemNo"].ParseToString()).Distinct().Count();
var skusStr = jstGoodsObj["skuInfo"]["goodsSkuDetail"].ParseToString();
if (skuCount != itemNoCount)
{
convertRst = "SKU货号重复";
return null;
}
prodInfo.detail.sku_type = null; prodInfo.detail.sku_type = null;
prodInfo.detail.song_huo_an_zhuang = null; prodInfo.detail.song_huo_an_zhuang = null;
prodInfo.detail.song_huo_ru_hu = null; prodInfo.detail.song_huo_ru_hu = null;
@@ -591,36 +591,36 @@ namespace TemuKJD.PDDForms.ProductSelectForms
break; break;
case "": case "":
dgvDbProduct.Rows[e.RowIndex].Cells["colSelect"].Value = !(bool)dgvDbProduct.Rows[e.RowIndex].Cells["colSelect"].Value; dgvDbProduct.Rows[e.RowIndex].Cells["colSelect"].Value = !(bool)dgvDbProduct.Rows[e.RowIndex].Cells["colSelect"].Value;
rowIndex1 = rowIndex2; //rowIndex1 = rowIndex2;
rowIndex2 = e.RowIndex; //rowIndex2 = e.RowIndex;
if (IsShiftDown) //if (IsShiftDown)
{ //{
if (rowIndex1 > -1 && rowIndex2 > -1) // if (rowIndex1 > -1 && rowIndex2 > -1)
{ // {
try // try
{ // {
if (rowIndex1 > rowIndex2) // if (rowIndex1 > rowIndex2)
{ // {
for (int i = rowIndex2; i <= rowIndex1; i++) // for (int i = rowIndex2; i <= rowIndex1; i++)
{ // {
dgvDbProduct.Rows[i].Cells["colSelect"].Value = dgvDbProduct.Rows[rowIndex1].Cells["colSelect"].Value; // dgvDbProduct.Rows[i].Cells["colSelect"].Value = dgvDbProduct.Rows[rowIndex1].Cells["colSelect"].Value;
} // }
} // }
else // else
{ // {
for (int i = rowIndex1; i <= rowIndex2; i++) // for (int i = rowIndex1; i <= rowIndex2; i++)
{ // {
dgvDbProduct.Rows[i].Cells["colSelect"].Value = dgvDbProduct.Rows[rowIndex1].Cells["colSelect"].Value; // dgvDbProduct.Rows[i].Cells["colSelect"].Value = dgvDbProduct.Rows[rowIndex1].Cells["colSelect"].Value;
} // }
} // }
} // }
catch // catch
{ // {
} // }
//rowIndex1 = -1; // //rowIndex1 = -1;
//rowIndex2 = -1; // //rowIndex2 = -1;
} // }
} //}
break; break;
default: default:
break; break;
@@ -1747,35 +1747,35 @@ namespace TemuKJD.PDDForms.ProductSelectForms
}); });
} }
int rowIndex1 = -1; //int rowIndex1 = -1;
int rowIndex2 = -1; //int rowIndex2 = -1;
bool IsShiftDown = false; //bool IsShiftDown = false;
private void PDDDBProdListForm_KeyDown(object sender, KeyEventArgs e) private void PDDDBProdListForm_KeyDown(object sender, KeyEventArgs e)
{ {
switch (e.KeyCode) //switch (e.KeyCode)
{ //{
case Keys.Shift: // case Keys.Shift:
case Keys.ShiftKey: // case Keys.ShiftKey:
case Keys.LShiftKey: // case Keys.LShiftKey:
case Keys.RShiftKey: // case Keys.RShiftKey:
IsShiftDown = true; // IsShiftDown = true;
break; // break;
} //}
} }
private void PDDDBProdListForm_KeyUp(object sender, KeyEventArgs e) private void PDDDBProdListForm_KeyUp(object sender, KeyEventArgs e)
{ {
switch (e.KeyCode) //switch (e.KeyCode)
{ //{
case Keys.Shift: // case Keys.Shift:
case Keys.ShiftKey: // case Keys.ShiftKey:
case Keys.LShiftKey: // case Keys.LShiftKey:
case Keys.RShiftKey: // case Keys.RShiftKey:
IsShiftDown = false; // IsShiftDown = false;
rowIndex1 = -1; // rowIndex1 = -1;
rowIndex2 = -1; // rowIndex2 = -1;
break; // break;
} //}
} }
private void cmbSourceType_SelectedIndexChanged(object sender, EventArgs e) private void cmbSourceType_SelectedIndexChanged(object sender, EventArgs e)
+91
View File
@@ -7,16 +7,19 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using DevComponents.DotNetBar.Controls; using DevComponents.DotNetBar.Controls;
using NaiBa.Util.Extension;
namespace TemuKJD.UserComponent namespace TemuKJD.UserComponent
{ {
public class DataGridViewEx : DataGridView public class DataGridViewEx : DataGridView
{ {
Form parentForm = null;
public DataGridViewEx() public DataGridViewEx()
{ {
BackgroundColor = Color.White; BackgroundColor = Color.White;
AlternatingRowsDefaultCellStyle.BackColor = Color.FromArgb(249, 249, 249); AlternatingRowsDefaultCellStyle.BackColor = Color.FromArgb(249, 249, 249);
RowPostPaint += DataGridViewEx_RowPostPaint; RowPostPaint += DataGridViewEx_RowPostPaint;
this.CellContentClick += DataGridViewEx_CellContentClick;
this.SetStyle( this.SetStyle(
ControlStyles.OptimizedDoubleBuffer | ControlStyles.OptimizedDoubleBuffer |
@@ -24,6 +27,94 @@ namespace TemuKJD.UserComponent
ControlStyles.ResizeRedraw | ControlStyles.ResizeRedraw |
ControlStyles.AllPaintingInWmPaint, ControlStyles.AllPaintingInWmPaint,
true); true);
Task.Run(() =>
{
for (int i = 0; i < 50; i++)
{
System.Threading.Thread.Sleep(100);
parentForm = FindForm();
if (parentForm != null)
{
parentForm.KeyPreview = true;
parentForm.KeyDown += ParentForm_KeyDown;
parentForm.KeyUp += ParentForm_KeyUp;
break;
}
}
});
}
private void DataGridViewEx_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex < 0)
return;
var colIndex = this.Columns.Cast<DataGridViewColumn>().FirstOrDefault(c => c is DataGridViewCheckBoxColumn).Index;
if (colIndex < 0 || e.ColumnIndex != colIndex)
return;
rowIndex1 = rowIndex2;
rowIndex2 = e.RowIndex;
if (IsShiftDown)
{
if (rowIndex1 > -1 && rowIndex2 > -1)
{
try
{
if (rowIndex1 > rowIndex2)
{
for (int i = rowIndex2; i <= rowIndex1 - 1; i++)
{
this.Rows[i].Cells[colIndex].Value = this.Rows[rowIndex1].Cells[colIndex].Value;
}
this.Rows[rowIndex1].Cells[rowIndex1].Value = !this.Rows[rowIndex1].Cells[rowIndex2].Value.ParseToBool();
}
else
{
for (int i = rowIndex1; i <= rowIndex2 - 1; i++)
{
this.Rows[i].Cells[colIndex].Value = this.Rows[rowIndex1].Cells[colIndex].Value;
}
this.Rows[rowIndex1].Cells[rowIndex2].Value = !this.Rows[rowIndex1].Cells[rowIndex1].Value.ParseToBool();
}
}
catch
{
}
//rowIndex1 = -1;
//rowIndex2 = -1;
}
}
}
int rowIndex1 = -1;
int rowIndex2 = -1;
bool IsShiftDown = false;
private void ParentForm_KeyDown(object sender, KeyEventArgs e)
{
switch (e.KeyCode)
{
case Keys.Shift:
case Keys.ShiftKey:
case Keys.LShiftKey:
case Keys.RShiftKey:
IsShiftDown = true;
break;
}
}
private void ParentForm_KeyUp(object sender, KeyEventArgs e)
{
switch (e.KeyCode)
{
case Keys.Shift:
case Keys.ShiftKey:
case Keys.LShiftKey:
case Keys.RShiftKey:
IsShiftDown = false;
rowIndex1 = -1;
rowIndex2 = -1;
break;
}
} }
private Color _BorderColor = Color.FromArgb(63, 126, 255); private Color _BorderColor = Color.FromArgb(63, 126, 255);
@@ -820,6 +820,7 @@ namespace TemuKJD.WXForms.ShopForms
shopMultiLoginForm.openType = EnumOpenType.multi_login; shopMultiLoginForm.openType = EnumOpenType.multi_login;
//shopMultiLoginForm.WindowState = FormWindowState.Maximized; //shopMultiLoginForm.WindowState = FormWindowState.Maximized;
shopMultiLoginForm.ShowDialog(); shopMultiLoginForm.ShowDialog();
RefreshDataGridView(true, shopMultiLoginForm.lstSwitchShop.ToList());
} }
} }
break; break;
+20 -3
View File
@@ -32,6 +32,7 @@
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(WXShopMultiLoginForm)); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(WXShopMultiLoginForm));
this.splitContainer1 = new System.Windows.Forms.SplitContainer(); this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.pbLoading = new System.Windows.Forms.PictureBox();
this.dgvShop = new TemuKJD.UserComponent.DataGridViewEx(); this.dgvShop = new TemuKJD.UserComponent.DataGridViewEx();
this.colSelect = new System.Windows.Forms.DataGridViewCheckBoxColumn(); this.colSelect = new System.Windows.Forms.DataGridViewCheckBoxColumn();
this.colShopLoginName = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.colShopLoginName = new System.Windows.Forms.DataGridViewTextBoxColumn();
@@ -50,6 +51,7 @@
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel2.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout(); this.splitContainer1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pbLoading)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.dgvShop)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dgvShop)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit();
this.splitContainer2.Panel1.SuspendLayout(); this.splitContainer2.Panel1.SuspendLayout();
@@ -73,12 +75,25 @@
// splitContainer1.Panel2 // splitContainer1.Panel2
// //
this.splitContainer1.Panel2.BackColor = System.Drawing.Color.White; this.splitContainer1.Panel2.BackColor = System.Drawing.Color.White;
this.splitContainer1.Panel2.Controls.Add(this.pbLoading);
this.splitContainer1.Panel2.Controls.Add(this.dgvShop); this.splitContainer1.Panel2.Controls.Add(this.dgvShop);
this.splitContainer1.Size = new System.Drawing.Size(1438, 659); this.splitContainer1.Size = new System.Drawing.Size(1438, 659);
this.splitContainer1.SplitterDistance = 1106; this.splitContainer1.SplitterDistance = 1108;
this.splitContainer1.SplitterWidth = 3; this.splitContainer1.SplitterWidth = 3;
this.splitContainer1.TabIndex = 4; this.splitContainer1.TabIndex = 4;
// //
// pbLoading
//
this.pbLoading.Anchor = System.Windows.Forms.AnchorStyles.None;
this.pbLoading.Image = global::TemuKJD.Properties.Resources.loading_blue;
this.pbLoading.Location = new System.Drawing.Point(139, 304);
this.pbLoading.Name = "pbLoading";
this.pbLoading.Size = new System.Drawing.Size(50, 50);
this.pbLoading.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pbLoading.TabIndex = 676;
this.pbLoading.TabStop = false;
this.pbLoading.Visible = false;
//
// dgvShop // dgvShop
// //
this.dgvShop.AllowUserToAddRows = false; this.dgvShop.AllowUserToAddRows = false;
@@ -112,7 +127,7 @@
this.dgvShop.ReadOnly = true; this.dgvShop.ReadOnly = true;
this.dgvShop.RowHeadersWidth = 25; this.dgvShop.RowHeadersWidth = 25;
this.dgvShop.RowTemplate.Height = 23; this.dgvShop.RowTemplate.Height = 23;
this.dgvShop.Size = new System.Drawing.Size(329, 659); this.dgvShop.Size = new System.Drawing.Size(327, 659);
this.dgvShop.TabIndex = 7; this.dgvShop.TabIndex = 7;
// //
// colSelect // colSelect
@@ -277,7 +292,7 @@
this.btnRefreshNum.StyleMouseOver.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(102)))), ((int)(((byte)(255))))); this.btnRefreshNum.StyleMouseOver.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(102)))), ((int)(((byte)(255)))));
this.btnRefreshNum.StyleMouseOver.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(102)))), ((int)(((byte)(255))))); this.btnRefreshNum.StyleMouseOver.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(102)))), ((int)(((byte)(255)))));
this.btnRefreshNum.TabIndex = 442; this.btnRefreshNum.TabIndex = 442;
this.btnRefreshNum.Text = "自动切换登录"; this.btnRefreshNum.Text = "自动批量登录";
this.btnRefreshNum.Click += new System.EventHandler(this.btnRefreshNum_Click); this.btnRefreshNum.Click += new System.EventHandler(this.btnRefreshNum_Click);
// //
// WXShopMultiLoginForm // WXShopMultiLoginForm
@@ -297,6 +312,7 @@
this.splitContainer1.Panel2.ResumeLayout(false); this.splitContainer1.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
this.splitContainer1.ResumeLayout(false); this.splitContainer1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pbLoading)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dgvShop)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dgvShop)).EndInit();
this.splitContainer2.Panel1.ResumeLayout(false); this.splitContainer2.Panel1.ResumeLayout(false);
this.splitContainer2.Panel1.PerformLayout(); this.splitContainer2.Panel1.PerformLayout();
@@ -329,5 +345,6 @@
private System.Windows.Forms.DataGridViewCheckBoxColumn colCanUse; private System.Windows.Forms.DataGridViewCheckBoxColumn colCanUse;
private System.Windows.Forms.DataGridViewTextBoxColumn colMessage; private System.Windows.Forms.DataGridViewTextBoxColumn colMessage;
private DevComponents.DotNetBar.PanelEx btnRefreshNum; private DevComponents.DotNetBar.PanelEx btnRefreshNum;
private System.Windows.Forms.PictureBox pbLoading;
} }
} }
@@ -40,16 +40,16 @@ namespace TemuKJD.WXForms.ShopForms
public string MultiLoginCookieName = ""; public string MultiLoginCookieName = "";
public string InitUrl = ""; public string InitUrl = "";
public ChromiumWebBrowser cefWebBrowser = null; public ChromiumWebBrowser cefWebBrowser = null;
public ShopLoginInfo mainShop = null;
public ConcurrentList<ShopLoginInfo> lstSwitchShop = new ConcurrentList<ShopLoginInfo>();
public ConcurrentList<ShopSwitchInfo> lstSwitchInfo = new ConcurrentList<ShopSwitchInfo>();
const string DefaultUrl = "https://store.weixin.qq.com/shop/home"; const string DefaultUrl = "https://store.weixin.qq.com/shop/home";
const string shopLoginUrl = "https://store.weixin.qq.com/shop?redirect_url=%2Fhome"; const string shopLoginUrl = "https://store.weixin.qq.com/shop?redirect_url=%2Fhome";
private string currentUrl = ""; private string currentUrl = "";
private string shopCookieHead = "store.weixin.qq.com"; private string shopCookieHead = "store.weixin.qq.com";
private ShopLoginInfo mainShop = null;
private ConcurrentList<ShopCompany> lstShopCompany = new ConcurrentList<ShopCompany>(); private ConcurrentList<ShopCompany> lstShopCompany = new ConcurrentList<ShopCompany>();
private ConcurrentList<ShopLoginInfo> lstSwitchShop = new ConcurrentList<ShopLoginInfo>();
private ConcurrentList<ShopSwitchInfo> lstSwitchInfo = new ConcurrentList<ShopSwitchInfo>();
public WXShopMultiLoginForm(ShopLoginInfo shopInfo) public WXShopMultiLoginForm(ShopLoginInfo shopInfo)
@@ -328,52 +328,91 @@ namespace TemuKJD.WXForms.ShopForms
private void btnRefreshNum_Click(object sender, EventArgs e) private void btnRefreshNum_Click(object sender, EventArgs e)
{ {
foreach (var shop in lstSwitchShop) pbLoading.Visible = true;
btnRefreshNum.Enabled = false;
Task.Run(() =>
{ {
var switchInfo = lstSwitchInfo.FirstOrDefault(s => s.appid == shop.ShopId); foreach (var shop in lstSwitchShop)
var row = dgvShop.Rows.Cast<DataGridViewRow>().FirstOrDefault(r => r.Cells["colShopId"].Value.ParseToString() == shop.ShopId);
Invoke(new Action(() =>
{ {
row.Cells["colMessage"].Value = "-"; var switchInfo = lstSwitchInfo.FirstOrDefault(s => s.appid == shop.ShopId);
})); var row = dgvShop.Rows.Cast<DataGridViewRow>().FirstOrDefault(r => r.Cells["colShopId"].Value.ParseToString() == shop.ShopId);
WXShopListForm.Instance.CheckShopLogin(new ShopLoginInfo[] { shop }, false);
if (shop.LoginStatus == "登录成功")
{
Thread.Sleep(100);
Invoke(new Action(() => Invoke(new Action(() =>
{ {
row.Cells["colMessage"].Value = "登录成功"; row.Cells["colMessage"].Value = "-";
})); }));
continue;
}
string jsStr1 = @"document.getElementsByClassName('shop-info-popover')[0].style =''; WXShopListForm.Instance.CheckShopLogin(new ShopLoginInfo[] { shop }, false);
if (shop.LoginStatus == "登录成功")
{
Thread.Sleep(100);
Invoke(new Action(() =>
{
row.Cells["colMessage"].Value = "登录成功";
}));
continue;
}
string jsStr1 = @"document.getElementsByClassName('shop-info-popover')[0].style ='';
var divLst = document.getElementsByClassName('shop-info-popover')[0].getElementsByTagName('div'); var divLst = document.getElementsByClassName('shop-info-popover')[0].getElementsByTagName('div');
for (i=0; i<divLst.length; i++){ for (i=0; i<divLst.length; i++){
if(divLst[i].innerHTML.indexOf('切换店铺') >= 0){ if(divLst[i].innerHTML.indexOf('切换店铺') >= 0){
divLst[i].click(); divLst[i].click();
//return 'success' //return 'success'
} }
}"; }";
var t1 = cefWebBrowser.GetMainFrame().EvaluateScriptAsync(jsStr1); var t1 = cefWebBrowser.GetMainFrame().EvaluateScriptAsync(jsStr1);
t1.Wait(5000); t1.Wait(5000);
Thread.Sleep(Randomx.GetId(500, 1000)); Thread.Sleep(Randomx.GetId(500, 1000));
jsStr1 = @"for (i=0; i<divLst.length; i++){ jsStr1 = @"for (i=0; i<divLst.length; i++){
if(divLst[i].innerHTML.indexOf('" + switchInfo.nickname + @"') >= 0){ if(divLst[i].innerHTML.indexOf('" + switchInfo.nickname + @"') >= 0){
divLst[i].click(); divLst[i].click();
} }
}"; }";
t1 = cefWebBrowser.GetMainFrame().EvaluateScriptAsync(jsStr1); t1 = cefWebBrowser.GetMainFrame().EvaluateScriptAsync(jsStr1);
t1.Wait(5000); t1.Wait(5000);
Thread.Sleep(Randomx.GetId(2000, 3000)); Thread.Sleep(Randomx.GetId(3000, 3500));
List<Cookie> cookieList = CEFBrowser.GetCookieList(shopCookieHead, cefWebBrowser.GetCookieManager(null)); List<Cookie> cookieList = CEFBrowser.GetCookieList(shopCookieHead, cefWebBrowser.GetCookieManager(null));
break; var cookies = cookieList.Where(c => c.Domain == this.shopCookieHead).ToList();
} if (!cookies.Any(c => c.Name == "biz_ticket"))
{
cookies.Add(new CefSharp.Cookie()
{
Name = "biz_ticket",
Value = "",
Domain = "store.weixin.qq.com",
Expires = null,
HttpOnly = true,
Path = "/",
Priority = CefSharp.Enums.CookiePriority.Medium,
SameSite = CefSharp.Enums.CookieSameSite.Unspecified,
Secure = true,
});
}
WXShopUpdateCookieForm.CheckCookieUpdate(shop, cookies);
Invoke(new Action(() =>
{
bool canUse = shop.LoginStatus == "登录成功";
row.Cells["colMessage"].Value = canUse ? "登录成功" : "登录失败,请稍后重试";
row.Cells["colLoginStatus"].Value = canUse ? "在线" : "掉线";
row.Cells["colCanUse"].Value = canUse;
displayAuthStatus(shop);
}));
Thread.Sleep(Randomx.GetId(2500, 5000));
}
Invoke(new Action(() =>
{
btnRefreshNum.Enabled = true;
pbLoading.Visible = false;
BaseMsgForm.ShowInfo("操作完成!");
}));
});
} }
void displayAuthStatus(ShopLoginInfo shop) void displayAuthStatus(ShopLoginInfo shop)
@@ -110,15 +110,15 @@ namespace TemuKJD.WXForms.ShopForms
string RK = BaseRegex.GetStringCookie(ref txt, "RK").ParseToString().Trim('\''); string RK = BaseRegex.GetStringCookie(ref txt, "RK").ParseToString().Trim('\'');
string yyb_muid = BaseRegex.GetStringCookie(ref txt, "yyb_muid").ParseToString().Trim('\''); string yyb_muid = BaseRegex.GetStringCookie(ref txt, "yyb_muid").ParseToString().Trim('\'');
cookieLst.Add(new CefSharp.Cookie() { Name = "_qimei_uuid42", Value = _qimei_uuid42, Domain = ".qq.com", Expires = DateTime.Now.AddMonths(1) }); //cookieLst.Add(new CefSharp.Cookie() { Name = "_qimei_uuid42", Value = _qimei_uuid42, Domain = ".qq.com", Expires = DateTime.Now.AddMonths(1) });
cookieLst.Add(new CefSharp.Cookie() { Name = "_qpsvr_localtk", Value = _qpsvr_localtk, Domain = ".qq.com", Expires = DateTime.Now.AddMonths(1) }); //cookieLst.Add(new CefSharp.Cookie() { Name = "_qpsvr_localtk", Value = _qpsvr_localtk, Domain = ".qq.com", Expires = DateTime.Now.AddMonths(1) });
cookieLst.Add(new CefSharp.Cookie() { Name = "biz_magic", Value = biz_magic, Domain = "store.weixin.qq.com", Expires = DateTime.Now.AddMonths(1) }); cookieLst.Add(new CefSharp.Cookie() { Name = "biz_magic", Value = biz_magic, Domain = "store.weixin.qq.com", Expires = DateTime.Now.AddMonths(1) });
cookieLst.Add(new CefSharp.Cookie() { Name = "biz_rand", Value = biz_rand, Domain = "store.weixin.qq.com", Expires = DateTime.Now.AddMonths(1) }); cookieLst.Add(new CefSharp.Cookie() { Name = "biz_rand", Value = biz_rand, Domain = "store.weixin.qq.com", Expires = DateTime.Now.AddMonths(1) });
cookieLst.Add(new CefSharp.Cookie() { Name = "biz_ticket", Value = biz_ticket, Domain = "store.weixin.qq.com", Expires = DateTime.Now.AddMonths(1) }); cookieLst.Add(new CefSharp.Cookie() { Name = "biz_ticket", Value = biz_ticket, Domain = "store.weixin.qq.com", Expires = DateTime.Now.AddMonths(1) });
cookieLst.Add(new CefSharp.Cookie() { Name = "biz_token", Value = biz_token, Domain = "store.weixin.qq.com", Expires = DateTime.Now.AddMonths(1) }); cookieLst.Add(new CefSharp.Cookie() { Name = "biz_token", Value = biz_token, Domain = "store.weixin.qq.com", Expires = DateTime.Now.AddMonths(1) });
cookieLst.Add(new CefSharp.Cookie() { Name = "ptcz", Value = ptcz, Domain = ".qq.com", Expires = DateTime.Now.AddMonths(1) }); //cookieLst.Add(new CefSharp.Cookie() { Name = "ptcz", Value = ptcz, Domain = ".qq.com", Expires = DateTime.Now.AddMonths(1) });
cookieLst.Add(new CefSharp.Cookie() { Name = "RK", Value = RK, Domain = ".qq.com", Expires = DateTime.Now.AddMonths(1) }); //cookieLst.Add(new CefSharp.Cookie() { Name = "RK", Value = RK, Domain = ".qq.com", Expires = DateTime.Now.AddMonths(1) });
cookieLst.Add(new CefSharp.Cookie() { Name = "yyb_muid", Value = yyb_muid, Domain = ".qq.com", Expires = DateTime.Now.AddMonths(1) }); //cookieLst.Add(new CefSharp.Cookie() { Name = "yyb_muid", Value = yyb_muid, Domain = ".qq.com", Expires = DateTime.Now.AddMonths(1) });
if (string.IsNullOrEmpty(biz_magic)) if (string.IsNullOrEmpty(biz_magic))
{ {
@@ -126,6 +126,17 @@ namespace TemuKJD.WXForms.ShopForms
return false; return false;
} }
string chkRst = CheckCookieUpdate(shopLoginInfo, cookieLst);
if (!string.IsNullOrEmpty(chkRst))
{
BaseMsgForm.ShowError(chkRst);
return false;
}
return true;
}
public static string CheckCookieUpdate(ShopLoginInfo shopLoginInfo, List<CefSharp.Cookie> cookieLst)
{
// 建立一个临时店铺并用这个店铺去登录 // 建立一个临时店铺并用这个店铺去登录
var cookieShop = new ShopLoginInfo(); var cookieShop = new ShopLoginInfo();
cookieShop.Cookies = JsonHelper.SerializeObject(cookieLst); cookieShop.Cookies = JsonHelper.SerializeObject(cookieLst);
@@ -137,8 +148,7 @@ namespace TemuKJD.WXForms.ShopForms
var indexEnd = data.IndexOf(";window.__USE_VITE__="); var indexEnd = data.IndexOf(";window.__USE_VITE__=");
if (index < 1000) if (index < 1000)
{ {
BaseMsgForm.ShowError("cookie已失效!"); return "cookie已失效!";
return false;
} }
var dataStr = data.Substring(index, indexEnd - index); var dataStr = data.Substring(index, indexEnd - index);
dataStr = GetHtml.Unicode2String(dataStr); dataStr = GetHtml.Unicode2String(dataStr);
@@ -147,15 +157,14 @@ namespace TemuKJD.WXForms.ShopForms
var nickName = BaseRegex.GetStringJson(ref data, "nickName"); var nickName = BaseRegex.GetStringJson(ref data, "nickName");
if (shopLoginInfo.ShopId != shopId) if (shopLoginInfo.ShopId != shopId)
{ {
BaseMsgForm.ShowError("cookie与店铺不匹配,请核对店铺!"); return "cookie与店铺不匹配,请核对店铺!";
return false;
} }
shopLoginInfo.Cookies = JsonHelper.SerializeObject(cookieLst); shopLoginInfo.Cookies = JsonHelper.SerializeObject(cookieLst);
shopLoginInfo.ShopAccount = nickName; shopLoginInfo.ShopAccount = nickName;
shopLoginInfo.LoginStatus = "登录成功"; shopLoginInfo.LoginStatus = "登录成功";
WXShopListForm.UpdateServerShopCookies(shopLoginInfo); // 店铺cookie写入服务端,多店共用一个登录账号一组cookie WXShopListForm.UpdateServerShopCookies(shopLoginInfo); // 店铺cookie写入服务端,多店共用一个登录账号一组cookie
return true; return "";
} }
/// <summary> /// <summary>
+1 -1
View File
@@ -1385,7 +1385,7 @@ namespace TemuKJD.WXForms.TalkForms
List<string> notesLst = notes.Split(new string[] { ";", ";", ",", "," }, StringSplitOptions.RemoveEmptyEntries).ToList(); List<string> notesLst = notes.Split(new string[] { ";", ";", ",", "," }, StringSplitOptions.RemoveEmptyEntries).ToList();
foreach(DataGridViewRow row in dgvShop.Rows) foreach(DataGridViewRow row in dgvShop.Rows)
{ {
if (string.IsNullOrEmpty(notes) || notesLst.Contains(row.Cells["colShopNotes"].Value.ParseToString()) && row.Cells["colShopName"].Value.ParseToString().Contains(shopName)) if ((string.IsNullOrEmpty(notes) || notesLst.Contains(row.Cells["colShopNotes"].Value.ParseToString())) && row.Cells["colShopName"].Value.ParseToString().Contains(shopName))
{ {
row.Visible = true; row.Visible = true;
} }