优化机会商品采集

This commit is contained in:
wule committed 2026-01-03 15:07:17 +08:00
1 parent d70b2eb6a7
commit 88675637ab
4 files changed
+123 -34

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 = 775; public static int VersionCount = 776;
//public static int VersionCount = 613; //public static int VersionCount = 613;
/// <summary> /// <summary>
+3 -2
View File
@@ -49,6 +49,7 @@ namespace TemuKJD
public partial class MainForm : BaseForm public partial class MainForm : BaseForm
{ {
public static string sCurrentModule = string.Empty; public static string sCurrentModule = string.Empty;
public static int ProcessCount = 0;
public static MainForm instance; public static MainForm instance;
public string LoginType; public string LoginType;
@@ -191,9 +192,9 @@ namespace TemuKJD
settings.LogSeverity = LogSeverity.Disable; settings.LogSeverity = LogSeverity.Disable;
var pName = Process.GetCurrentProcess().ProcessName; var pName = Process.GetCurrentProcess().ProcessName;
var pCount = Process.GetProcesses().Count(p => p.ProcessName == pName); ProcessCount = Process.GetProcesses().Count(p => p.ProcessName == pName);
//138版cef自己不会分缓存,会因占用导致报错,手动分缓存 //138版cef自己不会分缓存,会因占用导致报错,手动分缓存
settings.CachePath = Path.Combine(Environment.CurrentDirectory, "Cache\\" + pCount); settings.CachePath = Path.Combine(Environment.CurrentDirectory, "Cache\\" + ProcessCount);
//settings.CachePath = null; //禁止缓存 //settings.CachePath = null; //禁止缓存
//settings.CefCommandLineArgs.Add("enable-javascript", "1"); //settings.CefCommandLineArgs.Add("enable-javascript", "1");
//settings.CefCommandLineArgs.Add("disable-features", "NetworkService,NetworkServiceInProcess"); //settings.CefCommandLineArgs.Add("disable-features", "NetworkService,NetworkServiceInProcess");
@@ -39,6 +39,9 @@ namespace TemuKJD.PDDForms.ProductSelectForms
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle14 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle14 = new System.Windows.Forms.DataGridViewCellStyle();
this.splitContainer1 = new System.Windows.Forms.SplitContainer(); this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.ucGroupBoxEx1 = new TemuKJD.UserComponent.UcGroupBoxEx(this.components); this.ucGroupBoxEx1 = new TemuKJD.UserComponent.UcGroupBoxEx(this.components);
this.label7 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.txtMinPrice = new System.Windows.Forms.TextBox();
this.btnStopStop = new DevComponents.DotNetBar.PanelEx(); this.btnStopStop = new DevComponents.DotNetBar.PanelEx();
this.btnSelectSuccess = new DevComponents.DotNetBar.PanelEx(); this.btnSelectSuccess = new DevComponents.DotNetBar.PanelEx();
this.btnStop = new DevComponents.DotNetBar.PanelEx(); this.btnStop = new DevComponents.DotNetBar.PanelEx();
@@ -90,9 +93,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms
this.chk = new TemuKJD.UserComponent.UcCheckBox(this.components); this.chk = new TemuKJD.UserComponent.UcCheckBox(this.components);
this.statusBar = new TemuKJD.UserControls.StatusBarUserControl(); this.statusBar = new TemuKJD.UserControls.StatusBarUserControl();
this.ucSplitPage1 = new TemuKJD.UserControls.UcSplitPage(); this.ucSplitPage1 = new TemuKJD.UserControls.UcSplitPage();
this.txtMinPrice = new System.Windows.Forms.TextBox(); this.btnClear = new DevComponents.DotNetBar.PanelEx();
this.label6 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout();
@@ -139,6 +140,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.ucGroupBoxEx1.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255))))); this.ucGroupBoxEx1.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
this.ucGroupBoxEx1.BorderStyle = TemuKJD.UserComponent.UcGroupBoxEx.GroupBoxBorderStyle.ROUND; this.ucGroupBoxEx1.BorderStyle = TemuKJD.UserComponent.UcGroupBoxEx.GroupBoxBorderStyle.ROUND;
this.ucGroupBoxEx1.Controls.Add(this.btnClear);
this.ucGroupBoxEx1.Controls.Add(this.label7); this.ucGroupBoxEx1.Controls.Add(this.label7);
this.ucGroupBoxEx1.Controls.Add(this.label6); this.ucGroupBoxEx1.Controls.Add(this.label6);
this.ucGroupBoxEx1.Controls.Add(this.txtMinPrice); this.ucGroupBoxEx1.Controls.Add(this.txtMinPrice);
@@ -171,6 +173,35 @@ namespace TemuKJD.PDDForms.ProductSelectForms
this.ucGroupBoxEx1.TabStop = false; this.ucGroupBoxEx1.TabStop = false;
this.ucGroupBoxEx1.Text = "操作"; this.ucGroupBoxEx1.Text = "操作";
// //
// label7
//
this.label7.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(1004, 79);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(44, 17);
this.label7.TabIndex = 844;
this.label7.Text = "元SKU";
//
// label6
//
this.label6.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(849, 79);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(116, 17);
this.label6.TabIndex = 843;
this.label6.Text = "入库时移除价格低于";
//
// txtMinPrice
//
this.txtMinPrice.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.txtMinPrice.Location = new System.Drawing.Point(965, 76);
this.txtMinPrice.Name = "txtMinPrice";
this.txtMinPrice.Size = new System.Drawing.Size(39, 23);
this.txtMinPrice.TabIndex = 842;
this.txtMinPrice.Text = "10";
//
// btnStopStop // btnStopStop
// //
this.btnStopStop.CanvasColor = System.Drawing.SystemColors.Control; this.btnStopStop.CanvasColor = System.Drawing.SystemColors.Control;
@@ -853,34 +884,29 @@ namespace TemuKJD.PDDForms.ProductSelectForms
this.ucSplitPage1.TotalPage = 1; this.ucSplitPage1.TotalPage = 1;
this.ucSplitPage1.PageChange += new System.Action<object>(this.ucSplitPage1_PageChange); this.ucSplitPage1.PageChange += new System.Action<object>(this.ucSplitPage1_PageChange);
// //
// txtMinPrice // btnClear
// //
this.txtMinPrice.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.btnClear.CanvasColor = System.Drawing.SystemColors.Control;
this.txtMinPrice.Location = new System.Drawing.Point(965, 76); this.btnClear.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
this.txtMinPrice.Name = "txtMinPrice"; this.btnClear.DisabledBackColor = System.Drawing.Color.Empty;
this.txtMinPrice.Size = new System.Drawing.Size(39, 23); this.btnClear.Location = new System.Drawing.Point(588, 75);
this.txtMinPrice.TabIndex = 842; this.btnClear.Name = "btnClear";
this.txtMinPrice.Text = "10"; this.btnClear.Size = new System.Drawing.Size(100, 25);
// this.btnClear.Style.Alignment = System.Drawing.StringAlignment.Center;
// label6 this.btnClear.Style.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(185)))), ((int)(((byte)(215)))), ((int)(((byte)(255)))));
// this.btnClear.Style.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(185)))), ((int)(((byte)(215)))), ((int)(((byte)(255)))));
this.label6.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.btnClear.Style.Border = DevComponents.DotNetBar.eBorderType.SingleLine;
this.label6.AutoSize = true; this.btnClear.Style.BorderColor.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
this.label6.Location = new System.Drawing.Point(849, 79); this.btnClear.Style.ForeColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelText;
this.label6.Name = "label6"; this.btnClear.Style.GradientAngle = 90;
this.label6.Size = new System.Drawing.Size(116, 17); this.btnClear.StyleMouseDown.Alignment = System.Drawing.StringAlignment.Center;
this.label6.TabIndex = 843; this.btnClear.StyleMouseOver.Alignment = System.Drawing.StringAlignment.Center;
this.label6.Text = "入库时移除价格低于"; this.btnClear.StyleMouseOver.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
// this.btnClear.StyleMouseOver.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
// label7 this.btnClear.StyleMouseOver.ForeColor.Color = System.Drawing.Color.White;
// this.btnClear.TabIndex = 875;
this.label7.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.btnClear.Text = "清除列表";
this.label7.AutoSize = true; this.btnClear.Click += new System.EventHandler(this.btnClear_Click);
this.label7.Location = new System.Drawing.Point(1004, 79);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(44, 17);
this.label7.TabIndex = 844;
this.label7.Text = "元SKU";
// //
// PDDGetChanceProdForm // PDDGetChanceProdForm
// //
@@ -973,5 +999,6 @@ namespace TemuKJD.PDDForms.ProductSelectForms
private System.Windows.Forms.Label label7; private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label6; private System.Windows.Forms.Label label6;
private System.Windows.Forms.TextBox txtMinPrice; private System.Windows.Forms.TextBox txtMinPrice;
private DevComponents.DotNetBar.PanelEx btnClear;
} }
} }
@@ -8,6 +8,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Data; using System.Data;
using System.Diagnostics;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -44,6 +45,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms
this.panel2.Location = new Point(45, 55); this.panel2.Location = new Point(45, 55);
this.panel2.Width = Math.Max(10, this.panel2.Parent.Width - 90); this.panel2.Width = Math.Max(10, this.panel2.Parent.Width - 90);
this.panel2.Height = Math.Max(10, this.panel2.Parent.Height - 90); this.panel2.Height = Math.Max(10, this.panel2.Parent.Height - 90);
this.panel2.SendToBack();
chkSelectAll = dgvShop.Columns["colSelect"].AddHeaderCheckBox(HorizontalAlignment.Center, 0, 0, null, null, false, null, true); chkSelectAll = dgvShop.Columns["colSelect"].AddHeaderCheckBox(HorizontalAlignment.Center, 0, 0, null, null, false, null, true);
chkSelectAll.CheckedChanged += chkSelectAll_CheckedChanged; chkSelectAll.CheckedChanged += chkSelectAll_CheckedChanged;
@@ -60,6 +62,51 @@ namespace TemuKJD.PDDForms.ProductSelectForms
this.txtNotes.TextChanged += Txt_TextChanged; this.txtNotes.TextChanged += Txt_TextChanged;
this.txtShopId.TextChanged += Txt_TextChanged; this.txtShopId.TextChanged += Txt_TextChanged;
this.txtShopName.TextChanged += Txt_TextChanged; this.txtShopName.TextChanged += Txt_TextChanged;
var tmpChanceProductLst = NaiBa.Util.Helper.ConfigHelper.LoadConfig<List<ChanceProductResult>>("pdd_chance_product_list_" + MainForm.ProcessCount);
if (tmpChanceProductLst == null)
tmpChanceProductLst = new List<ChanceProductResult>();
lstChanceProductResult.AddRange(tmpChanceProductLst);
pbLoading.Visible = true;
Task.Run(() =>
{
int id = 0;
foreach (var chanceProductResult in lstChanceProductResult)
{
id++;
if (id % 50 == 0)
Thread.Sleep(1);
Invoke(new Action(() =>
{
var rowId = this.dgvChanceProduct.Rows.Add(
true,
chanceProductResult.chance_id,
chanceProductResult.pic_url.Replace("https://", "http://"),
DataGridViewExtension.defaultBitmap,
chanceProductResult.keywords,
chanceProductResult.hot_index,
chanceProductResult.cat_id_3.ParseToLong() == 0 ? new long?() : chanceProductResult.cat_id_3.ParseToLong(),
"采集详情后显示",
"删除",
chanceProductResult.getProductMsg
);
dgvChanceProduct.Rows[rowId].Height = 60;
if (chanceProductResult.dbProduct != null)
{
var dbProd = chanceProductResult.dbProduct;
var row = dgvChanceProduct.Rows[rowId];
row.Cells["colGoodsName"].Value = dbProd.product_name;
row.Cells["colCate"].Value = dbProd.cat_name;
row.Cells["colPrice"].Value = dbProd.price_text;
}
}));
}
Invoke(new Action(() =>
{
pbLoading.Visible = false;
}));
});
} }
private void Txt_TextChanged(object sender, EventArgs e) private void Txt_TextChanged(object sender, EventArgs e)
{ {
@@ -449,6 +496,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms
//DeleteProduct(dbId); //DeleteProduct(dbId);
dgvChanceProduct.Rows.Remove(row); dgvChanceProduct.Rows.Remove(row);
lstChanceProductResult.Remove(chanceProd); lstChanceProductResult.Remove(chanceProd);
NaiBa.Util.Helper.ConfigHelper.SaveConfig("pdd_chance_product_list_" + MainForm.ProcessCount, lstChanceProductResult);
break; break;
case "图片": case "图片":
var imgUrl = dgvChanceProduct.Rows[e.RowIndex].Cells["colImgUrl"].Value.ParseToString().Replace("?imageView2/2/w/90/h/90", ""); var imgUrl = dgvChanceProduct.Rows[e.RowIndex].Cells["colImgUrl"].Value.ParseToString().Replace("?imageView2/2/w/90/h/90", "");
@@ -616,8 +664,11 @@ namespace TemuKJD.PDDForms.ProductSelectForms
row.Cells["colMsg"].Value = chanceProd.getProductMsg; row.Cells["colMsg"].Value = chanceProd.getProductMsg;
})); }));
} }
}
if (rowLst.IndexOf(row) % 20 == 0)
NaiBa.Util.Helper.ConfigHelper.SaveConfig("pdd_chance_product_list_" + MainForm.ProcessCount, lstChanceProductResult);
}
NaiBa.Util.Helper.ConfigHelper.SaveConfig("pdd_chance_product_list_" + MainForm.ProcessCount, lstChanceProductResult);
Invoke(new Action(() => Invoke(new Action(() =>
{ {
@@ -849,6 +900,16 @@ namespace TemuKJD.PDDForms.ProductSelectForms
} }
} }
} }
private void btnClear_Click(object sender, EventArgs e)
{
if(BaseMsgForm.ShowConfirm("确定清除列表数据?").DialogResult == DialogResult.OK)
{
dgvChanceProduct.Rows.Clear();
lstChanceProductResult.Clear();
NaiBa.Util.Helper.ConfigHelper.SaveConfig("pdd_chance_product_list_" + MainForm.ProcessCount, lstChanceProductResult);
}
}
} }
public class ChanceProductConfig public class ChanceProductConfig