聚水潭上传微信小店相关逻辑

This commit is contained in:
wule committed 2026-01-29 20:54:17 +08:00
1 parent 625f4d9420
commit b4fa5cacb1
26 files changed
+2570 -487

No files matched your search

+97 -56
View File
@@ -35,13 +35,10 @@ namespace TemuKJD.ToolForms
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle9 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle10 = new System.Windows.Forms.DataGridViewCellStyle();
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.splitContainer2 = new System.Windows.Forms.SplitContainer();
this.btnNext = new System.Windows.Forms.Button();
this.btnPrev = new System.Windows.Forms.Button();
this.txtAddress = new System.Windows.Forms.TextBox();
this.tabPage2 = new System.Windows.Forms.TabPage();
this.pbLoading = new System.Windows.Forms.PictureBox();
this.dgvProduct = new TemuKJD.UserComponent.DataGridViewEx();
this.colCheck = new System.Windows.Forms.DataGridViewCheckBoxColumn();
@@ -56,10 +53,15 @@ namespace TemuKJD.ToolForms
this.colDel = new System.Windows.Forms.DataGridViewLinkColumn();
this.colMsg = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.ucTabControlMetro1 = new PinBaoBao.UserControls.UcTabControlMetro();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.tabPage2 = new System.Windows.Forms.TabPage();
this.pnlMultiLogin = new System.Windows.Forms.Panel();
this.cmbMultiCookieName = new DevComponents.DotNetBar.Controls.ComboBoxEx();
this.btnMultiLogin = new DevComponents.DotNetBar.PanelEx();
this.btnDel = new DevComponents.DotNetBar.PanelEx();
this.txtTitle = new System.Windows.Forms.TextBox();
this.btnSearchTitle = new DevComponents.DotNetBar.PanelEx();
this.chkSkip = new TemuKJD.UserComponent.UcCheckBox(this.components);
this.chkOverride = new TemuKJD.UserComponent.UcCheckBox(this.components);
this.label1 = new System.Windows.Forms.Label();
@@ -82,46 +84,21 @@ namespace TemuKJD.ToolForms
this.btnSaveCookie = new DevComponents.DotNetBar.PanelEx();
this.btnImportCookie = new DevComponents.DotNetBar.PanelEx();
this.label2 = new System.Windows.Forms.Label();
this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit();
this.splitContainer2.Panel1.SuspendLayout();
this.splitContainer2.SuspendLayout();
this.tabPage2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pbLoading)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.dgvProduct)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.ucTabControlMetro1.SuspendLayout();
this.tabPage1.SuspendLayout();
this.tabPage2.SuspendLayout();
this.pnlMultiLogin.SuspendLayout();
this.SuspendLayout();
//
// tabControl1
//
this.tabControl1.Controls.Add(this.tabPage1);
this.tabControl1.Controls.Add(this.tabPage2);
this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tabControl1.ItemSize = new System.Drawing.Size(80, 24);
this.tabControl1.Location = new System.Drawing.Point(0, 0);
this.tabControl1.Multiline = true;
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(1404, 471);
this.tabControl1.TabIndex = 0;
//
// tabPage1
//
this.tabPage1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.tabPage1.Controls.Add(this.splitContainer2);
this.tabPage1.Location = new System.Drawing.Point(4, 28);
this.tabPage1.Name = "tabPage1";
this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
this.tabPage1.Size = new System.Drawing.Size(1396, 439);
this.tabPage1.TabIndex = 0;
this.tabPage1.Text = " 商品页面 ";
this.tabPage1.UseVisualStyleBackColor = true;
//
// splitContainer2
//
this.splitContainer2.BackColor = System.Drawing.Color.White;
@@ -136,7 +113,7 @@ namespace TemuKJD.ToolForms
this.splitContainer2.Panel1.Controls.Add(this.btnNext);
this.splitContainer2.Panel1.Controls.Add(this.btnPrev);
this.splitContainer2.Panel1.Controls.Add(this.txtAddress);
this.splitContainer2.Size = new System.Drawing.Size(1388, 431);
this.splitContainer2.Size = new System.Drawing.Size(1390, 438);
this.splitContainer2.SplitterDistance = 26;
this.splitContainer2.TabIndex = 6;
//
@@ -167,27 +144,15 @@ namespace TemuKJD.ToolForms
this.txtAddress.Location = new System.Drawing.Point(64, 3);
this.txtAddress.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.txtAddress.Name = "txtAddress";
this.txtAddress.Size = new System.Drawing.Size(1324, 23);
this.txtAddress.Size = new System.Drawing.Size(1326, 23);
this.txtAddress.TabIndex = 7;
this.txtAddress.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtAddress_KeyDown);
//
// tabPage2
//
this.tabPage2.Controls.Add(this.pbLoading);
this.tabPage2.Controls.Add(this.dgvProduct);
this.tabPage2.Location = new System.Drawing.Point(4, 28);
this.tabPage2.Name = "tabPage2";
this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
this.tabPage2.Size = new System.Drawing.Size(1396, 439);
this.tabPage2.TabIndex = 1;
this.tabPage2.Text = " 商品列表 ";
this.tabPage2.UseVisualStyleBackColor = true;
//
// 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(673, 197);
this.pbLoading.Location = new System.Drawing.Point(673, 196);
this.pbLoading.Name = "pbLoading";
this.pbLoading.Size = new System.Drawing.Size(50, 50);
this.pbLoading.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
@@ -231,7 +196,7 @@ namespace TemuKJD.ToolForms
this.dgvProduct.Name = "dgvProduct";
this.dgvProduct.ReadOnly = true;
this.dgvProduct.RowTemplate.Height = 23;
this.dgvProduct.Size = new System.Drawing.Size(1390, 433);
this.dgvProduct.Size = new System.Drawing.Size(1390, 437);
this.dgvProduct.TabIndex = 7;
this.dgvProduct.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvProduct_CellContentClick);
//
@@ -335,12 +300,14 @@ namespace TemuKJD.ToolForms
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.ucTabControlMetro1);
this.splitContainer1.Panel1.Controls.Add(this.pnlMultiLogin);
this.splitContainer1.Panel1.Controls.Add(this.tabControl1);
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.BackColor = System.Drawing.Color.White;
this.splitContainer1.Panel2.Controls.Add(this.txtTitle);
this.splitContainer1.Panel2.Controls.Add(this.btnSearchTitle);
this.splitContainer1.Panel2.Controls.Add(this.chkSkip);
this.splitContainer1.Panel2.Controls.Add(this.chkOverride);
this.splitContainer1.Panel2.Controls.Add(this.label1);
@@ -364,10 +331,50 @@ namespace TemuKJD.ToolForms
this.splitContainer1.Panel2.Controls.Add(this.btnImportCookie);
this.splitContainer1.Panel2.Controls.Add(this.label2);
this.splitContainer1.Size = new System.Drawing.Size(1404, 561);
this.splitContainer1.SplitterDistance = 471;
this.splitContainer1.SplitterDistance = 474;
this.splitContainer1.SplitterWidth = 3;
this.splitContainer1.TabIndex = 4;
//
// ucTabControlMetro1
//
this.ucTabControlMetro1.BackgroundColor = System.Drawing.Color.FromArgb(((int)(((byte)(251)))), ((int)(((byte)(251)))), ((int)(((byte)(251)))));
this.ucTabControlMetro1.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(174)))), ((int)(((byte)(157)))));
this.ucTabControlMetro1.Controls.Add(this.tabPage1);
this.ucTabControlMetro1.Controls.Add(this.tabPage2);
this.ucTabControlMetro1.Dock = System.Windows.Forms.DockStyle.Fill;
this.ucTabControlMetro1.Location = new System.Drawing.Point(0, 0);
this.ucTabControlMetro1.Name = "ucTabControlMetro1";
this.ucTabControlMetro1.SelectedIndex = 0;
this.ucTabControlMetro1.ShowCloseButton = false;
this.ucTabControlMetro1.Size = new System.Drawing.Size(1404, 474);
this.ucTabControlMetro1.TabIndex = 462;
this.ucTabControlMetro1.TabSelectColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
this.ucTabControlMetro1.TabSelectTextColor = System.Drawing.Color.Gray;
this.ucTabControlMetro1.TabUnSelectTextColor = System.Drawing.Color.White;
//
// tabPage1
//
this.tabPage1.Controls.Add(this.splitContainer2);
this.tabPage1.Location = new System.Drawing.Point(4, 26);
this.tabPage1.Name = "tabPage1";
this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
this.tabPage1.Size = new System.Drawing.Size(1396, 444);
this.tabPage1.TabIndex = 0;
this.tabPage1.Text = "商品页面";
this.tabPage1.UseVisualStyleBackColor = true;
//
// tabPage2
//
this.tabPage2.Controls.Add(this.pbLoading);
this.tabPage2.Controls.Add(this.dgvProduct);
this.tabPage2.Location = new System.Drawing.Point(4, 26);
this.tabPage2.Name = "tabPage2";
this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
this.tabPage2.Size = new System.Drawing.Size(1396, 443);
this.tabPage2.TabIndex = 1;
this.tabPage2.Text = "采集列表";
this.tabPage2.UseVisualStyleBackColor = true;
//
// pnlMultiLogin
//
this.pnlMultiLogin.Controls.Add(this.cmbMultiCookieName);
@@ -440,6 +447,39 @@ namespace TemuKJD.ToolForms
this.btnDel.TabIndex = 409;
this.btnDel.Text = "删";
//
// txtTitle
//
this.txtTitle.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.txtTitle.Location = new System.Drawing.Point(319, 33);
this.txtTitle.Name = "txtTitle";
this.txtTitle.Size = new System.Drawing.Size(202, 23);
this.txtTitle.TabIndex = 968;
//
// btnSearchTitle
//
this.btnSearchTitle.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnSearchTitle.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
this.btnSearchTitle.Cursor = System.Windows.Forms.Cursors.Hand;
this.btnSearchTitle.DisabledBackColor = System.Drawing.Color.Empty;
this.btnSearchTitle.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnSearchTitle.Location = new System.Drawing.Point(523, 33);
this.btnSearchTitle.Name = "btnSearchTitle";
this.btnSearchTitle.Size = new System.Drawing.Size(56, 23);
this.btnSearchTitle.Style.Alignment = System.Drawing.StringAlignment.Center;
this.btnSearchTitle.Style.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
this.btnSearchTitle.Style.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
this.btnSearchTitle.Style.BorderColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder;
this.btnSearchTitle.Style.BorderDashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
this.btnSearchTitle.Style.BorderSide = DevComponents.DotNetBar.eBorderSide.None;
this.btnSearchTitle.Style.ForeColor.Color = System.Drawing.Color.White;
this.btnSearchTitle.Style.GradientAngle = 90;
this.btnSearchTitle.StyleMouseOver.Alignment = System.Drawing.StringAlignment.Center;
this.btnSearchTitle.StyleMouseOver.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(102)))), ((int)(((byte)(255)))));
this.btnSearchTitle.StyleMouseOver.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(102)))), ((int)(((byte)(255)))));
this.btnSearchTitle.TabIndex = 967;
this.btnSearchTitle.Text = "搜索标题";
this.btnSearchTitle.Click += new System.EventHandler(this.btnSearchTitle_Click);
//
// chkSkip
//
this.chkSkip.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
@@ -792,13 +832,10 @@ namespace TemuKJD.ToolForms
this.Name = "GetJuShuitanProdForm";
this.Text = "获取厂商产品";
this.Load += new System.EventHandler(this.GetJuShuitanProdForm_Load);
this.tabControl1.ResumeLayout(false);
this.tabPage1.ResumeLayout(false);
this.splitContainer2.Panel1.ResumeLayout(false);
this.splitContainer2.Panel1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit();
this.splitContainer2.ResumeLayout(false);
this.tabPage2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pbLoading)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dgvProduct)).EndInit();
this.splitContainer1.Panel1.ResumeLayout(false);
@@ -806,16 +843,15 @@ namespace TemuKJD.ToolForms
this.splitContainer1.Panel2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
this.splitContainer1.ResumeLayout(false);
this.ucTabControlMetro1.ResumeLayout(false);
this.tabPage1.ResumeLayout(false);
this.tabPage2.ResumeLayout(false);
this.pnlMultiLogin.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.TabControl tabControl1;
private System.Windows.Forms.TabPage tabPage1;
private System.Windows.Forms.TabPage tabPage2;
private System.Windows.Forms.SplitContainer splitContainer2;
private System.Windows.Forms.Button btnNext;
private System.Windows.Forms.Button btnPrev;
@@ -860,5 +896,10 @@ namespace TemuKJD.ToolForms
private System.Windows.Forms.ComboBox cmbPlatformType;
private UserComponent.UcCheckBox chkOverride;
private UserComponent.UcCheckBox chkSkip;
private PinBaoBao.UserControls.UcTabControlMetro ucTabControlMetro1;
private System.Windows.Forms.TabPage tabPage1;
private System.Windows.Forms.TabPage tabPage2;
private System.Windows.Forms.TextBox txtTitle;
private DevComponents.DotNetBar.PanelEx btnSearchTitle;
}
}
+253 -79
View File
@@ -1,11 +1,13 @@
using AllBase;
using AllBase.Model.Result;
using AllBase.Model.Result.PDDResult;
using CefSharp;
using CefSharp.WinForms;
using NaiBa.CefHelper;
using NaiBa.CefHelper.Handler;
using NaiBa.Util;
using NaiBa.Util.Extension;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@@ -39,6 +41,7 @@ namespace TemuKJD.ToolForms
int filterSaleCountDays = 7;
int filterSaleCount = 100;
string platformType = "Pinduoduo";
string jstPddShopId = "";
ConcurrentList<JSTListProductInfo> lstJSTListProductInfo = new ConcurrentList<JSTListProductInfo>();
public GetJuShuitanProdForm()
@@ -199,11 +202,16 @@ namespace TemuKJD.ToolForms
private void CefWebBrowser_AddressChanged(object sender, CefSharp.AddressChangedEventArgs e)
{
if (this.Created && !this.Disposing && !this.IsDisposed)
Invoke(new Action(() =>
{
Task.Run(() =>
{
currentUrl = e.Address;
txtAddress.Text = e.Address;
}));
Invoke(new Action(() =>
{
currentUrl = e.Address;
txtAddress.Text = e.Address;
}));
});
}
}
private void CefWebBrowser_LoadError(object sender, CefSharp.LoadErrorEventArgs e)
{
@@ -308,12 +316,19 @@ namespace TemuKJD.ToolForms
BaseMsgForm.ShowError("请在网页上选择要搜索的供应商商品列表页面");
return;
}
if (dgvProduct.Rows.Count > 0)
{
if (BaseMsgForm.ShowConfirm("当前列表已有采集数据,是否重新采集?").DialogResult == DialogResult.Cancel)
{
return;
}
}
this.pbLoading.Visible = true;
dgvProduct.Rows.Clear();
lstJSTListProductInfo.Clear();
if (cancellationTokenSource == null || cancellationTokenSource.IsCancellationRequested)
cancellationTokenSource = new CancellationTokenSource();
lstJSTListProductInfo.Clear();
//if (cancellationTokenSource == null || cancellationTokenSource.IsCancellationRequested)
cancellationTokenSource = new CancellationTokenSource();
Task.Run(() =>
{
try
@@ -356,14 +371,7 @@ namespace TemuKJD.ToolForms
Thread.Sleep(Randomx.GetId(1000, 2000));
page++;
string url = "https://sc.scm121.com/api/goods/buyer/supplier/goods/list";
string referer = "https://sc.scm121.com/manage/goods/qualitySupplier/detail/" + Jobj["supplierId"] + "?showErpList=1";
var lstRst = JSTHttpResponseBLL.JSTPostResponse(shop, url, JsonHelper.SerializeObject(Jobj), referer, appVersion);
for (int i = 0; i < 3 && !lstRst.Contains("\"success\":true"); i++)
{
Thread.Sleep(Randomx.GetId(1000, 2000));
lstRst = JSTHttpResponseBLL.JSTPostResponse(shop, url, JsonHelper.SerializeObject(Jobj), referer, appVersion);
}
var lstRst = GetGoodsLst(shop, Jobj);
if (!lstRst.Contains("\"success\":true"))
{
var errMsg = BaseRegex.GetStringJson(ref lstRst, "message");
@@ -415,25 +423,30 @@ namespace TemuKJD.ToolForms
jstLst = jstLst.Where(p => !lstJSTListProductInfo.Any(p1 => p1.id == p.id)).ToList();
lstJSTListProductInfo.AddRange(jstLst);
foreach (var prod in jstLst)
{
//var t = Task.Run(() =>
//{
Invoke(new Action(() =>
{
var id = dgvProduct.Rows.Add(
true,
prod.id,
(prod.itemMainImage?.FirstOrDefault()).ParseToString().Replace("https://", "http://"),
DataGridViewExtension.defaultBitmap,
prod.itemName,
prod.saleSeven,
prod.saleThirty,
prod.categoryName,
"预估:" + prod.minSalesPrice + " 采集详情后显示实际值",
"删除"
);
dgvProduct.Rows[id].Height = 60;
foreach (var prod in jstLst)
{
var id = dgvProduct.Rows.Add(
true,
prod.id,
(prod.itemMainImage?.FirstOrDefault()).ParseToString().Replace("https://", "http://"),
DataGridViewExtension.defaultBitmap,
prod.itemName,
prod.saleSeven,
prod.saleThirty,
prod.categoryName,
"预估:" + prod.minSalesPrice + " 采集详情后显示实际值",
"删除"
);
dgvProduct.Rows[id].Height = 60;
}
}));
}
//});
//t.Wait(5000);
}
catch (Exception ex)
{
@@ -490,27 +503,31 @@ namespace TemuKJD.ToolForms
private void btnSaveDb_Click(object sender, EventArgs e)
{
Task.Run(() => { });
//"&product_get_type=" + HttpUtility.UrlEncode("厂商直采", Encoding.UTF8);
List<Cookie> cookieList = CEFBrowser.GetCookieList(".scm121.com", cefWebBrowser.GetCookieManager(null));
var shop = new ShopLoginInfo();
shop.Cookies = JsonHelper.SerializeObject(cookieList);
List<DataGridViewRow> rowLst = new List<DataGridViewRow>();
rowLst.AddRange(dgvProduct.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["colCheck"].Value.ParseToBool() == true));
if (cancellationTokenSource == null || cancellationTokenSource.IsCancellationRequested)
cancellationTokenSource = new CancellationTokenSource();
//if (cancellationTokenSource == null || cancellationTokenSource.IsCancellationRequested)
cancellationTokenSource = new CancellationTokenSource();
this.pbLoading.Visible = true;
var t = Task.Run(() =>
{
List<Cookie> cookieList = CEFBrowser.GetCookieList(".scm121.com", cefWebBrowser.GetCookieManager(null));
var shop = new ShopLoginInfo();
shop.Cookies = JsonHelper.SerializeObject(cookieList);
foreach (var row in rowLst)
{
if (cancellationTokenSource.IsCancellationRequested)
break;
Invoke(new Action(() =>
{
this.statusBar.lblTaskStatus.Text = "正在入库表格第 " + (row.Index + 1) + " 行数据";
}));
var prodId = row.Cells["colProductId"].Value.ParseToString();
var prod = lstJSTListProductInfo.FirstOrDefault(c => c.id == prodId);
if (prod == null || prod.dbProduct == null || prod.dbProduct.product_json.Length < 10)
@@ -537,7 +554,7 @@ namespace TemuKJD.ToolForms
isExist = true;
}
var SetPartnerSpuRst = "";
//var SetPartnerSpuRst = "";
var url = BaseClass.BuildObjString("product/add_product");
if (isExist)
{
@@ -554,10 +571,24 @@ namespace TemuKJD.ToolForms
continue;
}
}
else
//else
{
SetPartnerSpuRst = SetPartnerSpu(shop, prod);
//{"success":true,"total":null,"data":{"message":"成功添加1款分销商品,系统会自动按商品拆分订单并推送给对应供应商","count":1,"shelvesType":"DISTRIBUTION"},"message":null,"code":"0000","hasNext":false,"now":1769330182209,"extra":{}}
////设置分销
//SetPartnerSpuRst = SetPartnerSpu(shop, prod);
//for (int i = 0; i < 3 && !SetPartnerSpuRst.Contains("\"success\":true"); i++)
//{
// Thread.Sleep(Randomx.GetId(2000, 4000));
// SetPartnerSpuRst = SetPartnerSpu(shop, prod);
//}
//if (!SetPartnerSpuRst.Contains("\"success\":true"))
//{
// Invoke(new Action(() =>
// {
// row.Cells["colMsg"].Value = "分销设置失败,请下次重试,暂时跳过入库";
// }));
// continue;
//}
////{"success":true,"total":null,"data":{"message":"成功添加1款分销商品,系统会自动按商品拆分订单并推送给对应供应商","count":1,"shelvesType":"DISTRIBUTION"},"message":null,"code":"0000","hasNext":false,"now":1769330182209,"extra":{}}
}
var data = Work.UserLogin.GetSignaturex() +
@@ -568,10 +599,6 @@ namespace TemuKJD.ToolForms
"&spu_id=" + prod.dbProduct.spu_id.ParseToString() +
"&skc_id=" + prod.dbProduct.skc_id.ParseToString() +
"&price_text=" + prod.dbProduct.price_text +
"&main_cat_id=" + prod.dbProduct.main_cat_id +
"&main_cat_name=" + HttpUtility.UrlEncode(prod.dbProduct.main_cat_name.ParseToString(), Encoding.UTF8) +
"&cat_id=" + prod.dbProduct.cat_id +
"&cat_name=" + HttpUtility.UrlEncode((prod.dbProduct.cat_name ?? prod.categoryName).ParseToString(), Encoding.UTF8) +
"&ext_code=" + HttpUtility.UrlEncode(prod.dbProduct.ext_code, Encoding.UTF8) +
"&product_name=" + HttpUtility.UrlEncode(prod.dbProduct.product_name, Encoding.UTF8) +
"&product_json=" + HttpUtility.UrlEncode(dbProd.product_json, Encoding.UTF8) +
@@ -580,7 +607,18 @@ namespace TemuKJD.ToolForms
"&sale_count_text=" + HttpUtility.UrlEncode(dbProd.sale_count_text, Encoding.UTF8) +
"&main_img=" + HttpUtility.UrlEncode(dbProd.main_img, Encoding.UTF8) +
"&product_get_type=" + HttpUtility.UrlEncode("厂商直采", Encoding.UTF8);
if (SetPartnerSpuRst.Contains("\"success\":true"))
if (!isExist)
{
data += "&main_cat_id=" + prod.dbProduct.main_cat_id +
"&main_cat_name=" + HttpUtility.UrlEncode(prod.dbProduct.main_cat_name.ParseToString(), Encoding.UTF8) +
"&cat_id=" + prod.dbProduct.cat_id +
"&cat_name=" + HttpUtility.UrlEncode((prod.dbProduct.cat_name ?? prod.categoryName).ParseToString(), Encoding.UTF8);
}
//if (SetPartnerSpuRst.Contains("\"success\":true"))
//{
// data += "&distribution_set=1";
//}
if (prod.dbProduct.distribution_set > 0)
{
data += "&distribution_set=1";
}
@@ -658,35 +696,38 @@ namespace TemuKJD.ToolForms
//https://sc.scm121.com/manage/goods/qualitySupplier/detail/93D12D2BD21649DC8240E2265BE37E2A?showErpList=1
this.pbLoading.Visible = true;
if (cancellationTokenSource == null || cancellationTokenSource.IsCancellationRequested)
cancellationTokenSource = new CancellationTokenSource();
List<Cookie> cookieList = CEFBrowser.GetCookieList(".scm121.com", cefWebBrowser.GetCookieManager(null));
var shop = new ShopLoginInfo();
shop.Cookies = JsonHelper.SerializeObject(cookieList);
List<DataGridViewRow> rowLst = new List<DataGridViewRow>();
rowLst.AddRange(dgvProduct.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["colCheck"].Value.ParseToBool() == true));
//if (cancellationTokenSource == null || cancellationTokenSource.IsCancellationRequested)
cancellationTokenSource = new CancellationTokenSource();
Task.Run(() =>
{
List<Cookie> cookieList = CEFBrowser.GetCookieList(".scm121.com", cefWebBrowser.GetCookieManager(null));
var shop = new ShopLoginInfo();
shop.Cookies = JsonHelper.SerializeObject(cookieList);
List<string> pIds = new List<string>();
pIds.AddRange(dgvProduct.Rows.Cast<DataGridViewRow>().Select(r => r.Cells["colProductId"].Value.ParseToString()).ToList());
foreach (var prodId in pIds)
foreach (var row in rowLst)
{
if (cancellationTokenSource.IsCancellationRequested)
break;
var row = dgvProduct.Rows.Cast<DataGridViewRow>().FirstOrDefault(r => r.Cells["colProductId"].Value.ParseToString() == prodId);
if (row == null || row.Index < 0 || row.Cells["colCheck"].Value.ParseToBool() != true)
continue;
Invoke(new Action(() =>
{
this.statusBar.lblTaskStatus.Text = "正在采集表格第 " + (row.Index + 1) + " 行详情数据";
}));
var prodId = row.Cells["colProductId"].Value.ParseToString();
var prod = lstJSTListProductInfo.FirstOrDefault(c => c.id == prodId);
// 不存在或已经采集过
if (prod == null || prod?.dbProduct?.product_json?.ParseToString().Length > 10)
continue;
Thread.Sleep(Randomx.GetId(500, 1500));
if (chkSkip.Checked)
{
if (prod.getProductMsg == "商品已存在,跳过详情采集")
continue;
bool isExist = false;
var existUrl = BaseClass.BuildObjString("product/get_product_list");
string existData = UserLogin.GetSignaturex() + "&search_spu=" + prod.spuId;
@@ -713,12 +754,33 @@ namespace TemuKJD.ToolForms
continue;
}
}
Thread.Sleep(Randomx.GetId(500, 1500));
string url = "https://sc.scm121.com/api/goods/goods/goGoodsPdd/queryBaseData?itemSpuId=" + prod.itemSpuId + "&shelvesType=DISTRIBUTION&originator=SUPPLIER&itemCoId=" + prod.itemCoId;
string referer = "https://sc.scm121.com/manage/goods/qualitySupplier/detail/" + prod.supplierId + "?showErpList=1";
var getDetailRst = JSTHttpResponseBLL.JSTGetResponse(shop, url, referer, appVersion);
if (!getDetailRst.Contains("\"success\":true"))
getDetailRst = JSTHttpResponseBLL.JSTGetResponse(shop, url, referer, appVersion);
//设置分销
var SetPartnerSpuRst = SetPartnerSpu(shop, prod);
for (int i = 0; i < 3 && !SetPartnerSpuRst.Contains("\"success\":true"); i++)
{
Thread.Sleep(Randomx.GetId(2000, 4000));
SetPartnerSpuRst = SetPartnerSpu(shop, prod);
}
if (!SetPartnerSpuRst.Contains("\"success\":true"))
{
Invoke(new Action(() =>
{
row.Cells["colMsg"].Value = "分销设置失败,请下次重试,暂时跳过入库";
}));
continue;
}
else
{
prod.dbProduct.distribution_set = 1;
}
//{"success":true,"total":null,"data":{"message":"成功添加1款分销商品,系统会自动按商品拆分订单并推送给对应供应商","count":1,"shelvesType":"DISTRIBUTION"},"message":null,"code":"0000","hasNext":false,"now":1769330182209,"extra":{}}
// 采集商品详情
var getDetailRst = GetPddBaseData(shop, prod);
if (!getDetailRst.Contains("\"success\":true"))
{
var errMsg = BaseRegex.GetStringJson(ref getDetailRst, "message");
@@ -736,9 +798,46 @@ namespace TemuKJD.ToolForms
{
var jObj = JsonHelper.JObjectParse(getDetailRst)["data"];
prod.dbProduct.cat_id = jObj["catId"].ParseToString();
if (string.IsNullOrEmpty(jstPddShopId))
{
var getShopIdRst = GetPddShopId(shop, prod);
//{"success":true,"total":1,"data":[{"shopId":"20115638","supplierId":"14791477","shopName":"阿杰小铺浦哈哈","shopType":"拼多多","shopTypeKey":"拼多多","shopTypeValue":"拼多多","itemSpuId":null,"shopItemSpuId":null,"shopAuthorizationDate":"2027-01-23 11:17:00","userName":null,"shelvesStatus":false,"updated":null,"sessionStatus":2,"sessionUid":null,"created":null,"hasPermission":true,"enabled":true,"mainSpuId":null,"shelved":false,"appCid":0,"riskVerifyUrl":null,"storeType":"COMMON"}],"message":null,"code":"0000","hasNext":false,"now":1769588598917,"extra":{}}
jstPddShopId = BaseRegex.GetStringJson(ref getShopIdRst, "shopId");
}
var getPropRst = GetPddProp(shop, prod, prod.dbProduct.cat_id, jstPddShopId);
if (!getPropRst.Contains("\"success\":true"))
{
var errMsg = BaseRegex.GetStringJson(ref getPropRst, "message");
if (string.IsNullOrEmpty(errMsg))
errMsg = getPropRst;
prod.getProductMsg = "采集失败 " + errMsg;
Invoke(new Action(() =>
{
try { row.Cells["colMsg"].Value = prod.getProductMsg; } catch { }
}));
continue;
}
List<PDDPropRefPidNameMap> pddPropMap = new List<PDDPropRefPidNameMap>();
var pddPropObj = JsonHelper.JObjectParse(getPropRst)["data"];
foreach (JObject pObj in pddPropObj["properties"])
{
pddPropMap.Add(new PDDPropRefPidNameMap()
{
id = pObj["id"].IsJTokenNullOrEmpty() ? new long?() : pObj["id"].ParseToLong(),
ref_pid = pObj["ref_pid"].IsJTokenNullOrEmpty() ? new long?() : pObj["ref_pid"].ParseToLong(),
name = pObj["name"].IsJTokenNullOrEmpty() ? null : pObj["name"].ParseToString(),
name_alias = pObj["name_alias"].IsJTokenNullOrEmpty() ? null : pObj["name_alias"].ParseToString(),
});
}
// 不进行类目属性预测
//var getPropRstV2 = GetPddPropForecastV2(shop, prod, prod.dbProduct.cat_id);
prod.dbProduct.main_cat_id = jObj["categoryData"].FirstOrDefault().ParseToString();
var prodDataJson = JsonHelper.SerializeObject(jObj);
prod.dbProduct.product_json = "{\"pddData\":" + prodDataJson + ",\"jstProd\":" + prod.jstProductJson + "}";
var propMapJson = JsonHelper.SerializeObject(pddPropMap);
prod.dbProduct.product_json = "{\"pddData\":" + prodDataJson + ",\"pddPropMap\":" + propMapJson + ",\"jstProd\":" + prod.jstProductJson + "}";
var priceMin = jObj["skuInfo"]["goodsSkuDetail"].Min(s => s["supplyPrice"].ParseToDecimal());
var priceMax = jObj["skuInfo"]["goodsSkuDetail"].Max(s => s["supplyPrice"].ParseToDecimal());
prod.dbProduct.price_text = priceMin + "-" + priceMax;
@@ -760,7 +859,7 @@ namespace TemuKJD.ToolForms
}));
}
if (pIds.IndexOf(prodId) % 20 == 0 )
if (row.Index % 20 == 0 )
NaiBa.Util.Helper.ConfigHelper.SaveConfig("supplier_product_list_" + MainForm.ProcessCount, lstJSTListProductInfo);
}
NaiBa.Util.Helper.ConfigHelper.SaveConfig("supplier_product_list_" + MainForm.ProcessCount, lstJSTListProductInfo);
@@ -775,8 +874,8 @@ namespace TemuKJD.ToolForms
private void GetDyProd()
{
this.pbLoading.Visible = true;
if (cancellationTokenSource == null || cancellationTokenSource.IsCancellationRequested)
cancellationTokenSource = new CancellationTokenSource();
//if (cancellationTokenSource == null || cancellationTokenSource.IsCancellationRequested)
cancellationTokenSource = new CancellationTokenSource();
Task.Run(() =>
{
@@ -811,11 +910,11 @@ namespace TemuKJD.ToolForms
html = GetHtml.PostUtf8(existUrl, existData);
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
{
//Invoke(new Action(() =>
//{
// row.Cells["colMsg"].Value = "采集详情失败,产品数据库连接失败";
//}));
//continue;
Invoke(new Action(() =>
{
row.Cells["colMsg"].Value = "采集详情失败,产品数据库连接失败";
}));
continue;
}
else
{
@@ -830,11 +929,7 @@ namespace TemuKJD.ToolForms
}
}
string url = "https://sc.scm121.com/api/goods/goods/goGoodsDouyin/queryBaseData?itemSpuId=" + prod.itemSpuId + "&shelvesType=DISTRIBUTION&originator=SUPPLIER&itemCoId=" + prod.itemCoId;
string referer = "https://sc.scm121.com/manage/goods/qualitySupplier/detail/" + prod.supplierId + "?showErpList=1";
var getDetailRst = JSTHttpResponseBLL.JSTGetResponse(shop, url, referer, appVersion);
if (!getDetailRst.Contains("\"success\":true"))
getDetailRst = JSTHttpResponseBLL.JSTGetResponse(shop, url, referer);
var getDetailRst = GetPddBaseData(shop, prod);
if (!getDetailRst.Contains("\"success\":true"))
{
var errMsg = BaseRegex.GetStringJson(ref getDetailRst, "message");
@@ -886,6 +981,62 @@ namespace TemuKJD.ToolForms
}, cancellationTokenSource.Token);
}
public string GetGoodsLst(ShopLoginInfo shop, JObject searchDataObj)
{
string url = "https://sc.scm121.com/api/goods/buyer/supplier/goods/list";
string referer = "https://sc.scm121.com/manage/goods/qualitySupplier/detail/" + searchDataObj["supplierId"] + "?showErpList=1";
var lstRst = JSTHttpResponseBLL.JSTPostResponse(shop, url, JsonHelper.SerializeObject(searchDataObj), referer, appVersion);
for (int i = 0; i < 3 && !lstRst.Contains("\"success\":true"); i++)
{
Thread.Sleep(Randomx.GetId(1000, 2000));
lstRst = JSTHttpResponseBLL.JSTPostResponse(shop, url, JsonHelper.SerializeObject(searchDataObj), referer, appVersion);
}
return lstRst;
}
public string GetPddBaseData(ShopLoginInfo shop, JSTListProductInfo jstLstProd)
{
string url = "https://sc.scm121.com/api/goods/goods/goGoodsPdd/queryBaseData?itemSpuId=" + jstLstProd.itemSpuId + "&shelvesType=DISTRIBUTION&originator=SUPPLIER&itemCoId=" + jstLstProd.itemCoId;
string referer = "https://sc.scm121.com/manage/goods/qualitySupplier/detail/" + jstLstProd.supplierId + "?showErpList=1";
var getDetailRst = JSTHttpResponseBLL.JSTGetResponse(shop, url, referer, appVersion);
for (int i = 0; i< 3 && !getDetailRst.Contains("\"success\":true"); i++)
{
Thread.Sleep(Randomx.GetId(1000, 2000));
getDetailRst = JSTHttpResponseBLL.JSTGetResponse(shop, url, referer, appVersion);
}
return getDetailRst;
}
public string GetPddShopId(ShopLoginInfo shop, JSTListProductInfo jstLstProd)
{
string url = "https://sc.scm121.com/api/goods/shelves/mxStoresInformation/selectStoresInfo?shopTypeKey=%E6%8B%BC%E5%A4%9A%E5%A4%9A&spuId=" +
jstLstProd.spuId + "&itemCoId=" + jstLstProd.itemCoId + "&isUpdate=false&pageNum=1&pageSize=20";
string referer = "https://sc.scm121.com/manage/goods/qualitySupplier/detail/" + jstLstProd.supplierId + "?showErpList=1";
var response = JSTHttpResponseBLL.JSTGetResponse(shop, url, referer, appVersion);
return response;
}
public string GetPddProp(ShopLoginInfo shop, JSTListProductInfo jstLstProd, string catId, string shopId = "20115638")
{
string url = "https://sc.scm121.com/api/goods/shelves/pddShelves/queryGoodsTemplate?catId=" + catId + "&shopId=" + shopId;
string referer = "https://sc.scm121.com/manage/goods/qualitySupplier/detail/" + jstLstProd.supplierId + "?itemCoId=" + jstLstProd.itemCoId + "&noBack=true";
var response = JSTHttpResponseBLL.JSTGetResponse(shop, url, referer, appVersion);
return response;
}
/// <summary>
/// 没有商品属性的,类目属性预测
/// </summary>
public string GetPddPropForecastV2(ShopLoginInfo shop, JSTListProductInfo jstProd, string catId, string shopId = "20115638")
{
//string url = "https://sc.scm121.com/api/goods/platform/category/categoryPropForecastV2?shopId=20115638&itemSpuId=DD0FCC6A42C94EAC9D2A0BFEBA33A683&itemCoId=10361546&shopType=Pinduoduo&categoryId=10799";
string url = "https://sc.scm121.com/api/goods/platform/category/categoryPropForecastV2?shopId=" + shopId +
"&itemSpuId=" + jstProd.itemSpuId + "&itemCoId=" + jstProd.itemCoId + "&shopType=Pinduoduo&categoryId=" + catId;
string referer = "https://sc.scm121.com/manage/goods/qualitySupplier/detail/" + jstProd.supplierId + "?showErpList=1";
var response = JSTHttpResponseBLL.JSTGetResponse(shop, url, referer, appVersion);
return response;
}
public string SetPartnerSpu(ShopLoginInfo shop, JSTListProductInfo jstProd)
{
string url = "https://sc.scm121.com/api/goods/buyer/partnerSpu/add";
@@ -894,5 +1045,28 @@ namespace TemuKJD.ToolForms
var response = JSTHttpResponseBLL.JSTPostResponse(shop, url, data, referer, appVersion);
return response;
}
private void btnSearchTitle_Click(object sender, EventArgs e)
{
pbLoading.Visible = true;
Task.Run(() =>
{
foreach (DataGridViewRow row in dgvProduct.Rows)
{
Invoke(new Action(() =>
{
row.Visible = (row.Cells["colGoodsName"].Value.ParseToString().Contains(txtTitle.Text.Trim()) || txtTitle.Text.Trim() == "");
if (row.Visible == false)
row.Cells["colCheck"].Value = false;
}));
}
Invoke(new Action(() =>
{
pbLoading.Visible = false;
}));
});
}
}
}