优化拼多多上传 优化拼多多活动报名

This commit is contained in:
wule committed 2026-04-21 21:08:50 +08:00
1 parent 79a752027a
commit ec559bd6cc
10 files changed
+449 -228

No files matched your search

@@ -32,16 +32,17 @@ namespace TemuKJD.PDDForms.ProductForms.ActivityForms
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
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();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle15 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle16 = new System.Windows.Forms.DataGridViewCellStyle();
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();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.ucGroupBoxEx2 = new TemuKJD.UserComponent.UcGroupBoxEx(this.components);
this.chkLowPrice = new TemuKJD.UserComponent.UcCheckBox(this.components);
this.label6 = new System.Windows.Forms.Label();
this.txtMultiCnt = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
@@ -136,7 +137,6 @@ namespace TemuKJD.PDDForms.ProductForms.ActivityForms
this.btnClear = new DevComponents.DotNetBar.PanelEx();
this.panelEx1 = new DevComponents.DotNetBar.PanelEx();
this.panel1 = new System.Windows.Forms.Panel();
this.chkLowPrice = new TemuKJD.UserComponent.UcCheckBox(this.components);
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
@@ -233,6 +233,18 @@ namespace TemuKJD.PDDForms.ProductForms.ActivityForms
this.ucGroupBoxEx2.TabStop = false;
this.ucGroupBoxEx2.Text = "活动价格配置";
//
// chkLowPrice
//
this.chkLowPrice.AutoSize = true;
this.chkLowPrice.Checked = true;
this.chkLowPrice.CheckState = System.Windows.Forms.CheckState.Checked;
this.chkLowPrice.Location = new System.Drawing.Point(662, 90);
this.chkLowPrice.Name = "chkLowPrice";
this.chkLowPrice.Size = new System.Drawing.Size(71, 21);
this.chkLowPrice.TabIndex = 914;
this.chkLowPrice.Text = "低价sku";
this.chkLowPrice.UseVisualStyleBackColor = true;
//
// label6
//
this.label6.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
@@ -283,7 +295,7 @@ namespace TemuKJD.PDDForms.ProductForms.ActivityForms
this.txtSleepTime.Name = "txtSleepTime";
this.txtSleepTime.Size = new System.Drawing.Size(38, 23);
this.txtSleepTime.TabIndex = 891;
this.txtSleepTime.Text = "5";
this.txtSleepTime.Text = "1";
this.txtSleepTime.TextChanged += new System.EventHandler(this.txtSleepTime_TextChanged);
//
// chk23456
@@ -1041,19 +1053,19 @@ namespace TemuKJD.PDDForms.ProductForms.ActivityForms
//
this.dgvShop.AllowUserToAddRows = false;
this.dgvShop.AllowUserToDeleteRows = false;
dataGridViewCellStyle9.BackColor = System.Drawing.Color.WhiteSmoke;
this.dgvShop.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle9;
dataGridViewCellStyle1.BackColor = System.Drawing.Color.WhiteSmoke;
this.dgvShop.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1;
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)))));
dataGridViewCellStyle10.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle10.BackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle10.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
dataGridViewCellStyle10.ForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle10.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle10.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle10.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
this.dgvShop.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle10;
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;
this.dgvShop.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgvShop.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.colSelect,
@@ -1258,19 +1270,19 @@ namespace TemuKJD.PDDForms.ProductForms.ActivityForms
//
this.dgvActProduct.AllowUserToAddRows = false;
this.dgvActProduct.AllowUserToDeleteRows = false;
dataGridViewCellStyle11.BackColor = System.Drawing.Color.WhiteSmoke;
this.dgvActProduct.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle11;
dataGridViewCellStyle3.BackColor = System.Drawing.Color.WhiteSmoke;
this.dgvActProduct.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle3;
this.dgvActProduct.AutoRowNumber = true;
this.dgvActProduct.BackgroundColor = System.Drawing.Color.White;
this.dgvActProduct.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
dataGridViewCellStyle12.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle12.BackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle12.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
dataGridViewCellStyle12.ForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle12.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle12.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle12.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
this.dgvActProduct.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle12;
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.dgvActProduct.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle4;
this.dgvActProduct.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgvActProduct.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.colCheck,
@@ -1319,8 +1331,8 @@ namespace TemuKJD.PDDForms.ProductForms.ActivityForms
//
// colSupplierName
//
dataGridViewCellStyle13.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.colSupplierName.DefaultCellStyle = dataGridViewCellStyle13;
dataGridViewCellStyle5.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.colSupplierName.DefaultCellStyle = dataGridViewCellStyle5;
this.colSupplierName.Frozen = true;
this.colSupplierName.HeaderText = "店铺名称";
this.colSupplierName.Name = "colSupplierName";
@@ -1375,8 +1387,8 @@ namespace TemuKJD.PDDForms.ProductForms.ActivityForms
//
// colProductName
//
dataGridViewCellStyle14.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.colProductName.DefaultCellStyle = dataGridViewCellStyle14;
dataGridViewCellStyle6.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.colProductName.DefaultCellStyle = dataGridViewCellStyle6;
this.colProductName.HeaderText = "商品标题";
this.colProductName.Name = "colProductName";
this.colProductName.ReadOnly = true;
@@ -1403,8 +1415,8 @@ namespace TemuKJD.PDDForms.ProductForms.ActivityForms
//
// colUpdateTime
//
dataGridViewCellStyle15.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.colUpdateTime.DefaultCellStyle = dataGridViewCellStyle15;
dataGridViewCellStyle7.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.colUpdateTime.DefaultCellStyle = dataGridViewCellStyle7;
this.colUpdateTime.FillWeight = 80F;
this.colUpdateTime.HeaderText = "上架时间";
this.colUpdateTime.Name = "colUpdateTime";
@@ -1420,8 +1432,8 @@ namespace TemuKJD.PDDForms.ProductForms.ActivityForms
//
// colOpResult
//
dataGridViewCellStyle16.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.colOpResult.DefaultCellStyle = dataGridViewCellStyle16;
dataGridViewCellStyle8.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.colOpResult.DefaultCellStyle = dataGridViewCellStyle8;
this.colOpResult.HeaderText = "操作结果";
this.colOpResult.Name = "colOpResult";
this.colOpResult.ReadOnly = true;
@@ -1518,18 +1530,6 @@ namespace TemuKJD.PDDForms.ProductForms.ActivityForms
this.panel1.TabIndex = 189;
this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint);
//
// chkLowPrice
//
this.chkLowPrice.AutoSize = true;
this.chkLowPrice.Checked = true;
this.chkLowPrice.CheckState = System.Windows.Forms.CheckState.Checked;
this.chkLowPrice.Location = new System.Drawing.Point(662, 90);
this.chkLowPrice.Name = "chkLowPrice";
this.chkLowPrice.Size = new System.Drawing.Size(71, 21);
this.chkLowPrice.TabIndex = 914;
this.chkLowPrice.Text = "低价sku";
this.chkLowPrice.UseVisualStyleBackColor = true;
//
// PDDAddActivityForm
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
@@ -2973,6 +2973,7 @@ namespace TemuKJD.PDDForms.ProductForms.ActivityForms
}));
continue;
}
prodInfo.ship_price = shipPrice;
}
#endregion
@@ -3257,25 +3258,33 @@ namespace TemuKJD.PDDForms.ProductForms.ActivityForms
}));
var lowPrice = prodParam.skus.Where(s => s.sku69_code != "yes" && s.quantity_delta != 0).ToList().Min(s => s.multi_price);
var skuTmp = prodParam.skus.Where(s => s.sku69_code != "yes" && s.quantity_delta != 0).ToList().FirstOrDefault(s => s.multi_price == lowPrice);
var skuTmpLst = prodParam.skus.Where(s => s.spec[0].spec_id == skuTmp.spec[0].spec_id && s.multi_price == lowPrice).ToList();
//var skuTmp = prodParam.skus.Where(s => s.sku69_code != "yes" && s.quantity_delta != 0).ToList().FirstOrDefault(s => s.multi_price == lowPrice);
//var skuTmpLst = prodParam.skus.Where(s => s.spec[0].spec_id == skuTmp.spec[0].spec_id && s.multi_price == lowPrice).ToList();
var skuTmpLst = prodParam.skus.Where(s => s.multi_price == lowPrice).ToList();
var prodInfo = lstActListProdInfo.FirstOrDefault(a => a.goods_id == prodParam.goods_id).productInfo;
var skuInfos = prodInfo.detail.sku.Where(s => skuTmpLst.Any(st => st.out_sku_sn == s.out_sku_sn)).ToList();
//var newMultiPrice = skuInfos.Max(s => s.multi_price) + (prodInfo.ship_price * defaultAddPriceRule.AddShippingFeeTimes).ParseToInt();
var newMultiPrice = skuInfos.Max(s => s.multi_price) + prodInfo.ship_price;
PddEditProdStockQuantity prodQuantity = new PddEditProdStockQuantity();
prodQuantity.data = new List<quantityData>();
int index = 1;
foreach (var sku in skuTmpLst)
{
// 相同低价商品,只有一个设置1个库存,其他0库存
prodQuantity.data.Add(new quantityData()
{
beforeQuantity = sku.quantity_delta,
goodsId = prodParam.goods_id,
quantity = -sku.quantity_delta + 1,
quantity = -sku.quantity_delta + (index == 1 ? 1 : 0),
skuId = sku.sku_id,
});
index++;
var prodInfo = lstActListProdInfo.FirstOrDefault(a => a.goods_id == prodParam.goods_id).productInfo;
var skuInfo = prodInfo.detail.sku.FirstOrDefault(s => s.out_sku_sn == sku.out_sku_sn);
if (skuInfo != null)
sku.multi_price = skuInfo.multi_price;
//var skuInfo = prodInfo.detail.sku.FirstOrDefault(s => s.out_sku_sn == sku.out_sku_sn);
//if (skuInfo != null)
// sku.multi_price = skuInfo.multi_price;
sku.multi_price = newMultiPrice;
}
var mdyQuantityRst = increase_prod_stock_quantity(shop, prodQuantity);
@@ -3283,8 +3292,10 @@ namespace TemuKJD.PDDForms.ProductForms.ActivityForms
{
Thread.Sleep(Randomx.GetId(500, 1500));
mdyQuantityRst = increase_prod_stock_quantity(shop, prodQuantity);
if (mdyQuantityRst.Contains("\"errorMsg\":\"库存未修改\""))
break;
}
if (!mdyQuantityRst.Contains("\"success\":true"))
if (!mdyQuantityRst.Contains("\"success\":true") && !mdyQuantityRst.Contains("\"errorMsg\":\"库存未修改\""))
{
goodsIds.Add(prodParam.goods_id);
var error = BaseRegex.GetStringJson(ref mdyQuantityRst, "error_msg");
@@ -3299,6 +3310,8 @@ namespace TemuKJD.PDDForms.ProductForms.ActivityForms
continue;
}
}
// 移除修改库存失败的商品
prodParamLst.RemoveAll(p => goodsIds.Contains(p.goods_id));
}
string activityRsts = SignActivity(shop, prodParamLst, sign22347, sign20981, sign21365, sign15996, sign23513, sign23730, sign23456);
@@ -3429,7 +3442,7 @@ namespace TemuKJD.PDDForms.ProductForms.ActivityForms
}
}
public decimal moreSleepTime = 5;
public decimal moreSleepTime = 1;
private void txtSleepTime_TextChanged(object sender, EventArgs e)
{
moreSleepTime = txtSleepTime.Text.Trim().ParseToDecimal();