优化pdd上货和机会商品采集

This commit is contained in:
wule committed 2026-01-02 16:03:25 +08:00
1 parent ab99113f09
commit 15cea5d4fd
7 files changed
+312 -136

No files matched your search

+1 -1
View File
@@ -27,7 +27,7 @@ namespace AllBase
/// <summary>
/// 版本ID
/// </summary>
public static int VersionCount = 772;
public static int VersionCount = 775;
//public static int VersionCount = 613;
/// <summary>
@@ -8,7 +8,7 @@
<IISExpressWindowsAuthentication />
<IISExpressUseClassicPipelineMode />
<UseGlobalApplicationHostFile />
<LastActiveSolutionConfig>Release|Any CPU</LastActiveSolutionConfig>
<LastActiveSolutionConfig>Debug|Any CPU</LastActiveSolutionConfig>
<ProjectView>ShowAllFiles</ProjectView>
</PropertyGroup>
<ProjectExtensions>
@@ -38,6 +38,9 @@ namespace TemuKJD.PDDForms.ProductSelectForms
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PDDDBProdListForm));
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.label9 = new System.Windows.Forms.Label();
this.txtMinPrice = new System.Windows.Forms.TextBox();
this.label8 = new System.Windows.Forms.Label();
this.txtReplaceText = new System.Windows.Forms.TextBox();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.label5 = new System.Windows.Forms.Label();
@@ -130,6 +133,9 @@ namespace TemuKJD.PDDForms.ProductSelectForms
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.label9);
this.splitContainer1.Panel1.Controls.Add(this.txtMinPrice);
this.splitContainer1.Panel1.Controls.Add(this.label8);
this.splitContainer1.Panel1.Controls.Add(this.txtReplaceText);
this.splitContainer1.Panel1.Controls.Add(this.tableLayoutPanel1);
this.splitContainer1.Panel1.Controls.Add(this.btnExportTxt);
@@ -145,10 +151,42 @@ namespace TemuKJD.PDDForms.ProductSelectForms
this.splitContainer1.SplitterDistance = 53;
this.splitContainer1.TabIndex = 1;
//
// label9
//
this.label9.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(1268, 31);
this.label9.Margin = new System.Windows.Forms.Padding(3, 0, 0, 0);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(76, 17);
this.label9.TabIndex = 708;
this.label9.Text = "元时跳过sku";
//
// 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(1235, 28);
this.txtMinPrice.Margin = new System.Windows.Forms.Padding(0, 3, 3, 3);
this.txtMinPrice.Name = "txtMinPrice";
this.txtMinPrice.Size = new System.Drawing.Size(33, 23);
this.txtMinPrice.TabIndex = 707;
this.txtMinPrice.Text = "10";
//
// label8
//
this.label8.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(1138, 30);
this.label8.Margin = new System.Windows.Forms.Padding(3, 0, 0, 0);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(104, 17);
this.label8.TabIndex = 706;
this.label8.Text = "导出时价格低于:";
//
// txtReplaceText
//
this.txtReplaceText.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.txtReplaceText.Location = new System.Drawing.Point(1235, 16);
this.txtReplaceText.Location = new System.Drawing.Point(1235, 4);
this.txtReplaceText.Margin = new System.Windows.Forms.Padding(0, 3, 3, 3);
this.txtReplaceText.Name = "txtReplaceText";
this.txtReplaceText.Size = new System.Drawing.Size(104, 23);
@@ -482,7 +520,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms
//
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(1138, 19);
this.label7.Location = new System.Drawing.Point(1138, 7);
this.label7.Margin = new System.Windows.Forms.Padding(3, 0, 0, 0);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(104, 17);
@@ -1071,5 +1109,8 @@ namespace TemuKJD.PDDForms.ProductSelectForms
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
private System.Windows.Forms.TextBox txtReplaceText;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.TextBox txtMinPrice;
private System.Windows.Forms.Label label8;
}
}
@@ -750,64 +750,87 @@ namespace TemuKJD.PDDForms.ProductSelectForms
{
foreach (var pId in lstProdId)
{
var prod = this.lstTemuDbProduct.FirstOrDefault(p => p.spu_id == pId);
if (string.IsNullOrEmpty(prod.product_json))
var dbProd = this.lstTemuDbProduct.FirstOrDefault(p => p.spu_id == pId);
if (string.IsNullOrEmpty(dbProd.product_json))
{
prod = PDDDBProdUserSelectForm.GetProductDetail(prod.id.ParseToString());
dbProd = PDDDBProdUserSelectForm.GetProductDetail(dbProd.id.ParseToString());
Thread.Sleep(200);
}
StreamWriter sw = new StreamWriter(Path.Combine(path, prod.spu_id + ".txt"), false, Encoding.UTF8);
JObject jObj = new JObject();
JObject prodJObj = new JObject();
try
{
jObj = JObject.Parse(prod.product_json);
prodJObj = JObject.Parse(dbProd.product_json);
// 过滤标题内指定词语
if (lstTitleReplaceText.Count > 0)
{
var goods_name = jObj["detail"]["goods_name"].ParseToString();
var goods_name = prodJObj["detail"]["goods_name"].ParseToString();
foreach (var txt in lstTitleReplaceText)
{
goods_name = goods_name.Replace(txt, "");
}
jObj["detail"]["goods_name"] = goods_name;
prodJObj["detail"]["goods_name"] = goods_name;
var tiny_name = jObj["detail"]["tiny_name"].ParseToString();
var tiny_name = prodJObj["detail"]["tiny_name"].ParseToString();
foreach (var txt in lstTitleReplaceText)
{
tiny_name = tiny_name.Replace(txt, "");
}
jObj["detail"]["tiny_name"] = tiny_name;
prodJObj["detail"]["tiny_name"] = tiny_name;
var goods_desc = jObj["detail"]["goods_desc"].ParseToString();
var goods_desc = prodJObj["detail"]["goods_desc"].ParseToString();
foreach (var txt in lstTitleReplaceText)
{
goods_desc = goods_desc.Replace(txt, "");
}
jObj["detail"]["goods_desc"] = goods_desc;
prodJObj["detail"]["goods_desc"] = goods_desc;
var share_desc = jObj["detail"]["share_desc"].ParseToString();
var share_desc = prodJObj["detail"]["share_desc"].ParseToString();
foreach (var txt in lstTitleReplaceText)
{
share_desc = share_desc.Replace(txt, "");
}
jObj["detail"]["share_desc"] = share_desc;
prodJObj["detail"]["share_desc"] = share_desc;
}
// 替换货号
if (!string.IsNullOrEmpty(prod.ext_code))
jObj["detail"]["out_goods_sn"] = prod.ext_code;
if (!string.IsNullOrEmpty(dbProd.ext_code))
prodJObj["detail"]["out_goods_sn"] = dbProd.ext_code;
// 替换编辑过的sku
if (!string.IsNullOrEmpty(prod.sku_edit_json))
jObj["detail"]["sku"] = JArray.Parse(JsonHelper.SerializeObject(JsonHelper.DeserializeJsonToList<sku_item>(prod.sku_edit_json)));
}
catch (Exception ex) { }
if (!string.IsNullOrEmpty(dbProd.sku_edit_json))
prodJObj["detail"]["sku"] = JArray.Parse(JsonHelper.SerializeObject(JsonHelper.DeserializeJsonToList<sku_item>(dbProd.sku_edit_json)));
// 过滤低价sku,如果所有sku都不达标,跳过商品
if (!string.IsNullOrEmpty(txtMinPrice.Text))
{
var product_json_tmp = JsonHelper.SerializeObject(prodJObj);
string exportData = JsonHelper.SerializeObject(jObj);
//sw.Write(prod.product_json);
sw.Write(exportData);
sw.Close();
// 移除第一组所有sku
var skuJArr = prodJObj["detail"]["sku"] as JArray;
skuJArr.RemoveAll();
// 序列化第二组,从组中挑选符合价格条件的sku往第一组内填写
var prodJObj2 = JObject.Parse(product_json_tmp);
var skuJArr2 = prodJObj2["detail"]["sku"] as JArray;
foreach (var skuJObj2 in skuJArr2)
{
if (skuJObj2["multi_price"].ParseToInt() >= this.txtMinPrice.Text.Trim().ParseToDecimal() * 100)
skuJArr.Add(skuJObj2);
}
if (skuJArr.Count == 0)
{
continue;
}
}
string exportData = JsonHelper.SerializeObject(prodJObj);
using (StreamWriter sw = new StreamWriter(Path.Combine(path, dbProd.spu_id + ".txt"), false, Encoding.UTF8))
{
sw.Write(exportData);
}
}
catch (Exception ex)
{
}
Invoke(new Action(() =>
{
@@ -902,8 +902,17 @@ namespace TemuKJD.PDDForms.ProductSelectForms
if (cancellationTokenSource.IsCancellationRequested)
break;
//var prodDetailJson = GetHtml.UrlDecode(kjdDbProd.product_json);
result = UploadProduct(shop, kjdDbProd, prod, row.Cells["colOpResult"], startTime); //将商品上传
//将商品上传
result = UploadProduct(shop, kjdDbProd, prod, row.Cells["colOpResult"], startTime);
//额外等待时间(无论失败与否)
var waitTime = 0;
Invoke(new Action(() => { waitTime = txtWaitSeconds.Text.Trim().ParseToInt(); }));
if (waitTime > 0)
Thread.Sleep(Randomx.GetId(waitTime * 1000, (waitTime + 10) * 1000));
Invoke(new Action(() =>
{
row.Cells["colSkuFakeImgUrl"].Value = kjdDbProd.sku_img_replace_url;
@@ -2281,12 +2290,6 @@ namespace TemuKJD.PDDForms.ProductSelectForms
}
}
var waitTime = 0;
Invoke(new Action(() => { waitTime = txtWaitSeconds.Text.Trim().ParseToInt(); }));
if (waitTime > 0)
Thread.Sleep(Randomx.GetId(waitTime * 1000, (waitTime + 10) * 1000));
var size_result = "";
if (prodInfo.size != null && prodInfo.size.classId != null)
{
@@ -30,13 +30,13 @@ namespace TemuKJD.PDDForms.ProductSelectForms
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle();
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();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle11 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle12 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle13 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle14 = new System.Windows.Forms.DataGridViewCellStyle();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.ucGroupBoxEx1 = new TemuKJD.UserComponent.UcGroupBoxEx(this.components);
this.btnStopStop = new DevComponents.DotNetBar.PanelEx();
@@ -77,9 +77,6 @@ namespace TemuKJD.PDDForms.ProductSelectForms
this.pbLoading = new System.Windows.Forms.PictureBox();
this.panel2 = new System.Windows.Forms.Panel();
this.dgvChanceProduct = new TemuKJD.UserComponent.DataGridViewEx();
this.chk = new TemuKJD.UserComponent.UcCheckBox(this.components);
this.statusBar = new TemuKJD.UserControls.StatusBarUserControl();
this.ucSplitPage1 = new TemuKJD.UserControls.UcSplitPage();
this.colCheck = new System.Windows.Forms.DataGridViewCheckBoxColumn();
this.colChanceId = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.colImgUrl = new System.Windows.Forms.DataGridViewTextBoxColumn();
@@ -90,6 +87,12 @@ namespace TemuKJD.PDDForms.ProductSelectForms
this.colPrice = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.colDel = new System.Windows.Forms.DataGridViewLinkColumn();
this.colMsg = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.chk = new TemuKJD.UserComponent.UcCheckBox(this.components);
this.statusBar = new TemuKJD.UserControls.StatusBarUserControl();
this.ucSplitPage1 = new TemuKJD.UserControls.UcSplitPage();
this.txtMinPrice = new System.Windows.Forms.TextBox();
this.label6 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
@@ -125,7 +128,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.splitContainer2);
this.splitContainer1.Size = new System.Drawing.Size(1179, 635);
this.splitContainer1.Size = new System.Drawing.Size(1344, 635);
this.splitContainer1.SplitterDistance = 120;
this.splitContainer1.TabIndex = 4;
//
@@ -136,6 +139,9 @@ namespace TemuKJD.PDDForms.ProductSelectForms
| System.Windows.Forms.AnchorStyles.Right)));
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.Controls.Add(this.label7);
this.ucGroupBoxEx1.Controls.Add(this.label6);
this.ucGroupBoxEx1.Controls.Add(this.txtMinPrice);
this.ucGroupBoxEx1.Controls.Add(this.btnStopStop);
this.ucGroupBoxEx1.Controls.Add(this.btnSelectSuccess);
this.ucGroupBoxEx1.Controls.Add(this.btnStop);
@@ -160,7 +166,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms
this.ucGroupBoxEx1.Controls.Add(this.chkOverride);
this.ucGroupBoxEx1.Location = new System.Drawing.Point(3, 2);
this.ucGroupBoxEx1.Name = "ucGroupBoxEx1";
this.ucGroupBoxEx1.Size = new System.Drawing.Size(1174, 118);
this.ucGroupBoxEx1.Size = new System.Drawing.Size(1339, 118);
this.ucGroupBoxEx1.TabIndex = 0;
this.ucGroupBoxEx1.TabStop = false;
this.ucGroupBoxEx1.Text = "操作";
@@ -196,7 +202,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms
this.btnSelectSuccess.Cursor = System.Windows.Forms.Cursors.Hand;
this.btnSelectSuccess.DisabledBackColor = System.Drawing.Color.Empty;
this.btnSelectSuccess.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnSelectSuccess.Location = new System.Drawing.Point(776, 75);
this.btnSelectSuccess.Location = new System.Drawing.Point(1022, 22);
this.btnSelectSuccess.Name = "btnSelectSuccess";
this.btnSelectSuccess.Size = new System.Drawing.Size(170, 25);
this.btnSelectSuccess.Style.Alignment = System.Drawing.StringAlignment.Center;
@@ -278,7 +284,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms
this.btnAddToDb.Cursor = System.Windows.Forms.Cursors.Hand;
this.btnAddToDb.DisabledBackColor = System.Drawing.Color.Empty;
this.btnAddToDb.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnAddToDb.Location = new System.Drawing.Point(1033, 75);
this.btnAddToDb.Location = new System.Drawing.Point(1198, 75);
this.btnAddToDb.Name = "btnAddToDb";
this.btnAddToDb.Size = new System.Drawing.Size(116, 25);
this.btnAddToDb.Style.Alignment = System.Drawing.StringAlignment.Center;
@@ -303,7 +309,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms
this.btnGetDetail.Cursor = System.Windows.Forms.Cursors.Hand;
this.btnGetDetail.DisabledBackColor = System.Drawing.Color.Empty;
this.btnGetDetail.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnGetDetail.Location = new System.Drawing.Point(1033, 22);
this.btnGetDetail.Location = new System.Drawing.Point(1198, 22);
this.btnGetDetail.Name = "btnGetDetail";
this.btnGetDetail.Size = new System.Drawing.Size(116, 25);
this.btnGetDetail.Style.Alignment = System.Drawing.StringAlignment.Center;
@@ -494,11 +500,11 @@ namespace TemuKJD.PDDForms.ProductSelectForms
//
this.chkOverride.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.chkOverride.AutoSize = true;
this.chkOverride.Location = new System.Drawing.Point(952, 77);
this.chkOverride.Location = new System.Drawing.Point(1058, 77);
this.chkOverride.Name = "chkOverride";
this.chkOverride.Size = new System.Drawing.Size(87, 21);
this.chkOverride.Size = new System.Drawing.Size(135, 21);
this.chkOverride.TabIndex = 757;
this.chkOverride.Text = "覆盖已存在";
this.chkOverride.Text = "覆盖库中已存在商品";
this.chkOverride.UseVisualStyleBackColor = true;
//
// splitContainer2
@@ -519,7 +525,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms
this.splitContainer2.Panel2.Controls.Add(this.chk);
this.splitContainer2.Panel2.Controls.Add(this.statusBar);
this.splitContainer2.Panel2.Controls.Add(this.ucSplitPage1);
this.splitContainer2.Size = new System.Drawing.Size(1179, 511);
this.splitContainer2.Size = new System.Drawing.Size(1344, 511);
this.splitContainer2.SplitterDistance = 482;
this.splitContainer2.TabIndex = 0;
//
@@ -540,7 +546,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms
this.splitContainer3.Panel2.Controls.Add(this.pbLoading);
this.splitContainer3.Panel2.Controls.Add(this.panel2);
this.splitContainer3.Panel2.Controls.Add(this.dgvChanceProduct);
this.splitContainer3.Size = new System.Drawing.Size(1171, 482);
this.splitContainer3.Size = new System.Drawing.Size(1336, 482);
this.splitContainer3.SplitterDistance = 290;
this.splitContainer3.TabIndex = 9;
//
@@ -559,19 +565,19 @@ namespace TemuKJD.PDDForms.ProductSelectForms
//
this.dgvShop.AllowUserToAddRows = false;
this.dgvShop.AllowUserToDeleteRows = false;
dataGridViewCellStyle1.BackColor = System.Drawing.Color.WhiteSmoke;
this.dgvShop.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1;
dataGridViewCellStyle8.BackColor = System.Drawing.Color.WhiteSmoke;
this.dgvShop.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle8;
this.dgvShop.AutoRowNumber = true;
this.dgvShop.BackgroundColor = System.Drawing.Color.White;
this.dgvShop.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
this.dgvShop.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2;
dataGridViewCellStyle9.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle9.BackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle9.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
dataGridViewCellStyle9.ForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle9.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle9.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle9.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
this.dgvShop.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle9;
this.dgvShop.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgvShop.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.colSelect,
@@ -669,7 +675,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms
//
this.pbLoading.Anchor = System.Windows.Forms.AnchorStyles.None;
this.pbLoading.Image = global::TemuKJD.Properties.Resources.loading_blue;
this.pbLoading.Location = new System.Drawing.Point(413, 216);
this.pbLoading.Location = new System.Drawing.Point(496, 216);
this.pbLoading.Name = "pbLoading";
this.pbLoading.Size = new System.Drawing.Size(50, 50);
this.pbLoading.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
@@ -684,27 +690,27 @@ namespace TemuKJD.PDDForms.ProductSelectForms
| System.Windows.Forms.AnchorStyles.Right)));
this.panel2.Location = new System.Drawing.Point(409, 355);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(445, 107);
this.panel2.Size = new System.Drawing.Size(610, 107);
this.panel2.TabIndex = 8;
//
// dgvChanceProduct
//
this.dgvChanceProduct.AllowUserToAddRows = false;
this.dgvChanceProduct.AllowUserToDeleteRows = false;
dataGridViewCellStyle3.BackColor = System.Drawing.Color.WhiteSmoke;
this.dgvChanceProduct.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle3;
dataGridViewCellStyle10.BackColor = System.Drawing.Color.WhiteSmoke;
this.dgvChanceProduct.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle10;
this.dgvChanceProduct.AutoRowNumber = true;
this.dgvChanceProduct.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
this.dgvChanceProduct.BackgroundColor = System.Drawing.Color.White;
this.dgvChanceProduct.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle4.BackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle4.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
dataGridViewCellStyle4.ForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle4.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle4.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
this.dgvChanceProduct.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle4;
dataGridViewCellStyle11.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle11.BackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle11.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
dataGridViewCellStyle11.ForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle11.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle11.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle11.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
this.dgvChanceProduct.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle11;
this.dgvChanceProduct.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgvChanceProduct.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.colCheck,
@@ -722,50 +728,10 @@ namespace TemuKJD.PDDForms.ProductSelectForms
this.dgvChanceProduct.Name = "dgvChanceProduct";
this.dgvChanceProduct.ReadOnly = true;
this.dgvChanceProduct.RowTemplate.Height = 23;
this.dgvChanceProduct.Size = new System.Drawing.Size(877, 482);
this.dgvChanceProduct.Size = new System.Drawing.Size(1042, 482);
this.dgvChanceProduct.TabIndex = 6;
this.dgvChanceProduct.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvChanceProduct_CellContentClick);
//
// chk
//
this.chk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.chk.AutoSize = true;
this.chk.Checked = true;
this.chk.CheckState = System.Windows.Forms.CheckState.Checked;
this.chk.Location = new System.Drawing.Point(1112, 3);
this.chk.Name = "chk";
this.chk.Size = new System.Drawing.Size(63, 21);
this.chk.TabIndex = 671;
this.chk.Text = "多选框";
this.chk.UseVisualStyleBackColor = true;
this.chk.Visible = false;
//
// statusBar
//
this.statusBar.BackColor = System.Drawing.Color.White;
this.statusBar.Dock = System.Windows.Forms.DockStyle.Left;
this.statusBar.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.statusBar.Location = new System.Drawing.Point(296, 0);
this.statusBar.Margin = new System.Windows.Forms.Padding(0);
this.statusBar.Name = "statusBar";
this.statusBar.Size = new System.Drawing.Size(743, 25);
this.statusBar.TabIndex = 5;
//
// ucSplitPage1
//
this.ucSplitPage1.CurrentPage = 1;
this.ucSplitPage1.Dock = System.Windows.Forms.DockStyle.Left;
this.ucSplitPage1.IsShowPageSize = false;
this.ucSplitPage1.Location = new System.Drawing.Point(0, 0);
this.ucSplitPage1.Margin = new System.Windows.Forms.Padding(0);
this.ucSplitPage1.Name = "ucSplitPage1";
this.ucSplitPage1.Padding = new System.Windows.Forms.Padding(0, 0, 1, 0);
this.ucSplitPage1.PageSize = 50;
this.ucSplitPage1.Size = new System.Drawing.Size(296, 25);
this.ucSplitPage1.TabIndex = 6;
this.ucSplitPage1.TotalPage = 1;
this.ucSplitPage1.PageChange += new System.Action<object>(this.ucSplitPage1_PageChange);
//
// colCheck
//
this.colCheck.FillWeight = 26F;
@@ -802,8 +768,8 @@ namespace TemuKJD.PDDForms.ProductSelectForms
//
// colGoodsName
//
dataGridViewCellStyle5.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.colGoodsName.DefaultCellStyle = dataGridViewCellStyle5;
dataGridViewCellStyle12.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.colGoodsName.DefaultCellStyle = dataGridViewCellStyle12;
this.colGoodsName.FillWeight = 120F;
this.colGoodsName.HeaderText = "商品名称";
this.colGoodsName.Name = "colGoodsName";
@@ -824,8 +790,8 @@ namespace TemuKJD.PDDForms.ProductSelectForms
//
// colPrice
//
dataGridViewCellStyle6.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.colPrice.DefaultCellStyle = dataGridViewCellStyle6;
dataGridViewCellStyle13.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.colPrice.DefaultCellStyle = dataGridViewCellStyle13;
this.colPrice.FillWeight = 70F;
this.colPrice.HeaderText = "价格";
this.colPrice.Name = "colPrice";
@@ -840,17 +806,86 @@ namespace TemuKJD.PDDForms.ProductSelectForms
//
// colMsg
//
dataGridViewCellStyle7.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.colMsg.DefaultCellStyle = dataGridViewCellStyle7;
dataGridViewCellStyle14.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.colMsg.DefaultCellStyle = dataGridViewCellStyle14;
this.colMsg.FillWeight = 200F;
this.colMsg.HeaderText = "操作结果";
this.colMsg.Name = "colMsg";
this.colMsg.ReadOnly = true;
//
// chk
//
this.chk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.chk.AutoSize = true;
this.chk.Checked = true;
this.chk.CheckState = System.Windows.Forms.CheckState.Checked;
this.chk.Location = new System.Drawing.Point(1277, 3);
this.chk.Name = "chk";
this.chk.Size = new System.Drawing.Size(63, 21);
this.chk.TabIndex = 671;
this.chk.Text = "多选框";
this.chk.UseVisualStyleBackColor = true;
this.chk.Visible = false;
//
// statusBar
//
this.statusBar.BackColor = System.Drawing.Color.White;
this.statusBar.Dock = System.Windows.Forms.DockStyle.Left;
this.statusBar.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.statusBar.Location = new System.Drawing.Point(296, 0);
this.statusBar.Margin = new System.Windows.Forms.Padding(0);
this.statusBar.Name = "statusBar";
this.statusBar.Size = new System.Drawing.Size(743, 25);
this.statusBar.TabIndex = 5;
//
// ucSplitPage1
//
this.ucSplitPage1.CurrentPage = 1;
this.ucSplitPage1.Dock = System.Windows.Forms.DockStyle.Left;
this.ucSplitPage1.IsShowPageSize = false;
this.ucSplitPage1.Location = new System.Drawing.Point(0, 0);
this.ucSplitPage1.Margin = new System.Windows.Forms.Padding(0);
this.ucSplitPage1.Name = "ucSplitPage1";
this.ucSplitPage1.Padding = new System.Windows.Forms.Padding(0, 0, 1, 0);
this.ucSplitPage1.PageSize = 50;
this.ucSplitPage1.Size = new System.Drawing.Size(296, 25);
this.ucSplitPage1.TabIndex = 6;
this.ucSplitPage1.TotalPage = 1;
this.ucSplitPage1.PageChange += new System.Action<object>(this.ucSplitPage1_PageChange);
//
// 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";
//
// 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 = "入库时移除价格低于";
//
// 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";
//
// PDDGetChanceProdForm
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.ClientSize = new System.Drawing.Size(1179, 635);
this.ClientSize = new System.Drawing.Size(1344, 635);
this.Controls.Add(this.splitContainer1);
this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.Name = "PDDGetChanceProdForm";
@@ -935,5 +970,8 @@ namespace TemuKJD.PDDForms.ProductSelectForms
private System.Windows.Forms.DataGridViewTextBoxColumn colPrice;
private System.Windows.Forms.DataGridViewLinkColumn colDel;
private System.Windows.Forms.DataGridViewTextBoxColumn colMsg;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.TextBox txtMinPrice;
}
}
@@ -671,10 +671,64 @@ namespace TemuKJD.PDDForms.ProductSelectForms
continue;
var dbProd = chanceProd.dbProduct;
var product = JsonHelper.DeserializeJsonToObject<PDDProductInfo>(dbProd.product_json).detail;
PDDProductDetailInfo prodDetail = null;
try
{
// 序列化第一组,从中获取所有价格不达标需要剔除的spec
var prodJObj = JObject.Parse(dbProd.product_json);
var skuJArr = prodJObj["detail"]["sku"] as JArray;
List<long> specIdLst = new List<long>();
List<string> specNameLst = new List<string>();
foreach (var skuJObj in skuJArr)
{
if (skuJObj["multi_price"].ParseToInt() < this.txtMinPrice.Text.Trim().ParseToDecimal() * 100)
{
foreach(var specJObj in skuJObj["spec"] as JArray)
{
specIdLst.Add(specJObj["spec_id"].ParseToLong());
specNameLst.Add(specJObj["spec_name"].ParseToString());
}
}
}
skuJArr.RemoveAll();
// 序列化第二组,从组中挑选符合价格条件的sku往第一组内填写
var prodJObj2 = JObject.Parse(dbProd.product_json);
var skuJArr2 = prodJObj2["detail"]["sku"] as JArray;
foreach (var skuJObj2 in skuJArr2)
{
//var specJArr2 = skuJArr2["spec"] as JArray;
//if (specJArr2.Count > 0 && specIdLst.Contains(specJArr2[0]["spec_id"].ParseToLong()))
// continue;
//if (specJArr2.Count > 1 && specIdLst.Contains(specJArr2[1]["spec_id"].ParseToLong()))
// continue;
if (skuJObj2["multi_price"].ParseToInt() >= this.txtMinPrice.Text.Trim().ParseToDecimal() * 100)
skuJArr.Add(skuJObj2);
}
if (skuJArr.Count == 0)
{
Invoke(new Action(() =>
{
row.Cells["colMsg"].Value = "商品价格低于设定,跳过";
}));
continue;
}
dbProd.product_json = JsonHelper.SerializeObject(prodJObj);
prodDetail = JsonHelper.DeserializeJsonToObject<PDDProductInfo>(dbProd.product_json).detail;
}
catch (Exception ex)
{
Invoke(new Action(() =>
{
row.Cells["colMsg"].Value = "商品入库错误:" + ex.Message;
}));
continue;
}
bool isExist = false;
var existUrl = BaseClass.BuildObjString("product/get_product_list");
// 每次获取的机会商品goods_id都不同,此处根据机会商品的chanceId来获取库中是否存在
string existData = UserLogin.GetSignaturex() + "&from_shop_id=" + chanceId;
string html = GetHtml.PostUtf8(existUrl, existData);
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
@@ -686,12 +740,29 @@ namespace TemuKJD.PDDForms.ProductSelectForms
if (html.Contains("\"data\":[") && !html.Contains("\"data\":[]"))
isExist = true;
}
else
{
Invoke(new Action(() =>
{
row.Cells["colMsg"].Value = "入库失败,产品数据库连接失败";
}));
continue;
}
var url = BaseClass.BuildObjString("product/add_product");
if (isExist)
{
if (chkOverride.Checked)
{
var oldSpuId = BaseRegex.GetLongJson(ref html, "spu_id");
if (oldSpuId > 0)
{
// 将商品Id替换成老的商品Id
dbProd.product_json = dbProd.product_json.Replace(prodDetail.goods_id.ParseToString(), oldSpuId.ParseToString());
prodDetail.goods_id = oldSpuId;
}
url = BaseClass.BuildObjString("product/mdy_product");
}
else
{
Invoke(new Action(() =>
@@ -704,15 +775,15 @@ namespace TemuKJD.PDDForms.ProductSelectForms
var data = Work.UserLogin.GetSignaturex() +
"&from_shop_id=" + chanceId +
"&spu_id=" + product.goods_id.ParseToString() +
"&skc_id=" + product.goods_id.ParseToString() +
"&price_text=" + product.sku.Min(s => s.multi_price).ParseToInt() * 0.01m + "-" + product.sku.Max(s => s.multi_price).ParseToInt() * 0.01m +
"&main_cat_id=" + (product.cat_ids?.FirstOrDefault(c => c != null)).ParseToString() +
"&main_cat_name=" + HttpUtility.UrlEncode((product.cats?.FirstOrDefault(c => !string.IsNullOrEmpty(c))).ParseToString(), Encoding.UTF8) +
"&cat_id=" + (product.cat_id).ParseToString() +
"&cat_name=" + HttpUtility.UrlEncode((product.cats?.LastOrDefault(c => !string.IsNullOrEmpty(c))).ParseToString(), Encoding.UTF8) +
"&ext_code=" + HttpUtility.UrlEncode(product.out_goods_sn, Encoding.UTF8) +
"&product_name=" + HttpUtility.UrlEncode(product.goods_name, Encoding.UTF8) +
"&spu_id=" + prodDetail.goods_id.ParseToString() +
"&skc_id=" + prodDetail.goods_id.ParseToString() +
"&price_text=" + prodDetail.sku.Min(s => s.multi_price).ParseToInt() * 0.01m + "-" + prodDetail.sku.Max(s => s.multi_price).ParseToInt() * 0.01m +
"&main_cat_id=" + (prodDetail.cat_ids?.FirstOrDefault(c => c != null)).ParseToString() +
"&main_cat_name=" + HttpUtility.UrlEncode((prodDetail.cats?.FirstOrDefault(c => !string.IsNullOrEmpty(c))).ParseToString(), Encoding.UTF8) +
"&cat_id=" + (prodDetail.cat_id).ParseToString() +
"&cat_name=" + HttpUtility.UrlEncode((prodDetail.cats?.LastOrDefault(c => !string.IsNullOrEmpty(c))).ParseToString(), Encoding.UTF8) +
"&ext_code=" + HttpUtility.UrlEncode(prodDetail.out_goods_sn, Encoding.UTF8) +
"&product_name=" + HttpUtility.UrlEncode(prodDetail.goods_name, Encoding.UTF8) +
"&product_json=" + HttpUtility.UrlEncode(dbProd.product_json, Encoding.UTF8) +
"&size_json=" + HttpUtility.UrlEncode(dbProd.size_json, Encoding.UTF8) +
"&main_img=" + HttpUtility.UrlEncode(dbProd.main_img, Encoding.UTF8) +