diff --git a/TEMUKJD/PDDForms/ProductSelectForms/PDDDBProdListForm.Designer.cs b/TEMUKJD/PDDForms/ProductSelectForms/PDDDBProdListForm.Designer.cs index a1175e4..5929054 100644 --- a/TEMUKJD/PDDForms/ProductSelectForms/PDDDBProdListForm.Designer.cs +++ b/TEMUKJD/PDDForms/ProductSelectForms/PDDDBProdListForm.Designer.cs @@ -29,6 +29,7 @@ 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(); @@ -38,6 +39,8 @@ 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.chkHighestPriceSku = new TemuKJD.UserComponent.UcCheckBox(this.components); + this.chkSameSpecPrice = new TemuKJD.UserComponent.UcCheckBox(this.components); this.label9 = new System.Windows.Forms.Label(); this.txtMinPrice = new System.Windows.Forms.TextBox(); this.label8 = new System.Windows.Forms.Label(); @@ -133,6 +136,8 @@ namespace TemuKJD.PDDForms.ProductSelectForms // // splitContainer1.Panel1 // + this.splitContainer1.Panel1.Controls.Add(this.chkHighestPriceSku); + this.splitContainer1.Panel1.Controls.Add(this.chkSameSpecPrice); this.splitContainer1.Panel1.Controls.Add(this.label9); this.splitContainer1.Panel1.Controls.Add(this.txtMinPrice); this.splitContainer1.Panel1.Controls.Add(this.label8); @@ -148,9 +153,35 @@ namespace TemuKJD.PDDForms.ProductSelectForms // this.splitContainer1.Panel2.Controls.Add(this.splitContainer2); this.splitContainer1.Size = new System.Drawing.Size(1438, 686); - this.splitContainer1.SplitterDistance = 53; + this.splitContainer1.SplitterDistance = 76; this.splitContainer1.TabIndex = 1; // + // chkHighestPriceSku + // + this.chkHighestPriceSku.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.chkHighestPriceSku.AutoSize = true; + this.chkHighestPriceSku.Checked = true; + this.chkHighestPriceSku.CheckState = System.Windows.Forms.CheckState.Checked; + this.chkHighestPriceSku.Location = new System.Drawing.Point(1235, 52); + this.chkHighestPriceSku.Name = "chkHighestPriceSku"; + this.chkHighestPriceSku.Size = new System.Drawing.Size(119, 21); + this.chkHighestPriceSku.TabIndex = 728; + this.chkHighestPriceSku.Text = "只保留最高价sku"; + this.chkHighestPriceSku.UseVisualStyleBackColor = true; + // + // chkSameSpecPrice + // + this.chkSameSpecPrice.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.chkSameSpecPrice.AutoSize = true; + this.chkSameSpecPrice.Checked = true; + this.chkSameSpecPrice.CheckState = System.Windows.Forms.CheckState.Checked; + this.chkSameSpecPrice.Location = new System.Drawing.Point(1141, 52); + this.chkSameSpecPrice.Name = "chkSameSpecPrice"; + this.chkSameSpecPrice.Size = new System.Drawing.Size(99, 21); + this.chkSameSpecPrice.TabIndex = 718; + this.chkSameSpecPrice.Text = "颜色规格同价"; + this.chkSameSpecPrice.UseVisualStyleBackColor = true; + // // label9 // this.label9.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); @@ -176,7 +207,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms // 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.Location = new System.Drawing.Point(1138, 31); 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); @@ -230,7 +261,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms this.tableLayoutPanel1.Controls.Add(this.btnSearch, 14, 0); this.tableLayoutPanel1.Controls.Add(this.lblGroup, 10, 0); this.tableLayoutPanel1.Controls.Add(this.pnlEmpty, 15, 0); - this.tableLayoutPanel1.Location = new System.Drawing.Point(4, 3); + this.tableLayoutPanel1.Location = new System.Drawing.Point(4, 13); this.tableLayoutPanel1.Name = "tableLayoutPanel1"; this.tableLayoutPanel1.RowCount = 1; this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); @@ -439,9 +470,9 @@ namespace TemuKJD.PDDForms.ProductSelectForms this.btnExportTxt.Cursor = System.Windows.Forms.Cursors.Hand; this.btnExportTxt.DisabledBackColor = System.Drawing.Color.Empty; this.btnExportTxt.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.btnExportTxt.Location = new System.Drawing.Point(1345, 15); + this.btnExportTxt.Location = new System.Drawing.Point(1344, 25); this.btnExportTxt.Name = "btnExportTxt"; - this.btnExportTxt.Size = new System.Drawing.Size(84, 25); + this.btnExportTxt.Size = new System.Drawing.Size(89, 25); this.btnExportTxt.Style.Alignment = System.Drawing.StringAlignment.Center; this.btnExportTxt.Style.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255))))); this.btnExportTxt.Style.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255))))); @@ -464,7 +495,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms this.btnDelSelect.Cursor = System.Windows.Forms.Cursors.Hand; this.btnDelSelect.DisabledBackColor = System.Drawing.Color.Empty; this.btnDelSelect.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.btnDelSelect.Location = new System.Drawing.Point(1038, 15); + this.btnDelSelect.Location = new System.Drawing.Point(1038, 25); this.btnDelSelect.Name = "btnDelSelect"; this.btnDelSelect.Size = new System.Drawing.Size(84, 25); this.btnDelSelect.Style.Alignment = System.Drawing.StringAlignment.Center; @@ -486,7 +517,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms // this.cmbGroup.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.cmbGroup.FormattingEnabled = true; - this.cmbGroup.Location = new System.Drawing.Point(845, 15); + this.cmbGroup.Location = new System.Drawing.Point(845, 25); this.cmbGroup.Name = "cmbGroup"; this.cmbGroup.Size = new System.Drawing.Size(85, 25); this.cmbGroup.TabIndex = 640; @@ -498,7 +529,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms this.btnSetGroup.Cursor = System.Windows.Forms.Cursors.Hand; this.btnSetGroup.DisabledBackColor = System.Drawing.Color.Empty; this.btnSetGroup.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.btnSetGroup.Location = new System.Drawing.Point(932, 15); + this.btnSetGroup.Location = new System.Drawing.Point(932, 25); this.btnSetGroup.Name = "btnSetGroup"; this.btnSetGroup.Size = new System.Drawing.Size(84, 25); this.btnSetGroup.Style.Alignment = System.Drawing.StringAlignment.Center; @@ -549,8 +580,8 @@ namespace TemuKJD.PDDForms.ProductSelectForms // this.splitContainer2.Panel2.Controls.Add(this.ucSplitPage1); this.splitContainer2.Panel2.Controls.Add(this.statusBar); - this.splitContainer2.Size = new System.Drawing.Size(1438, 629); - this.splitContainer2.SplitterDistance = 600; + this.splitContainer2.Size = new System.Drawing.Size(1438, 606); + this.splitContainer2.SplitterDistance = 577; this.splitContainer2.TabIndex = 0; // // pnlEditExtCodePrice @@ -560,7 +591,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms this.pnlEditExtCodePrice.Controls.Add(this.lblExtCode); this.pnlEditExtCodePrice.Controls.Add(this.panel2); this.pnlEditExtCodePrice.Controls.Add(this.lblExtCodePrice); - this.pnlEditExtCodePrice.Location = new System.Drawing.Point(482, 96); + this.pnlEditExtCodePrice.Location = new System.Drawing.Point(482, 84); this.pnlEditExtCodePrice.Name = "pnlEditExtCodePrice"; this.pnlEditExtCodePrice.Size = new System.Drawing.Size(474, 146); this.pnlEditExtCodePrice.TabIndex = 434; @@ -655,7 +686,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(694, 275); + this.pbLoading.Location = new System.Drawing.Point(694, 263); this.pbLoading.Name = "pbLoading"; this.pbLoading.Size = new System.Drawing.Size(50, 50); this.pbLoading.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; @@ -757,7 +788,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms this.dgvDbProduct.Name = "dgvDbProduct"; this.dgvDbProduct.ReadOnly = true; this.dgvDbProduct.RowTemplate.Height = 23; - this.dgvDbProduct.Size = new System.Drawing.Size(1430, 600); + this.dgvDbProduct.Size = new System.Drawing.Size(1430, 577); this.dgvDbProduct.TabIndex = 6; this.dgvDbProduct.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvDbProduct_CellContentClick); this.dgvDbProduct.Scroll += new System.Windows.Forms.ScrollEventHandler(this.dgvDbProduct_Scroll); @@ -1112,5 +1143,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms private System.Windows.Forms.Label label9; private System.Windows.Forms.TextBox txtMinPrice; private System.Windows.Forms.Label label8; + private UserComponent.UcCheckBox chkSameSpecPrice; + private UserComponent.UcCheckBox chkHighestPriceSku; } } \ No newline at end of file diff --git a/TEMUKJD/PDDForms/ProductSelectForms/PDDDBProdListForm.cs b/TEMUKJD/PDDForms/ProductSelectForms/PDDDBProdListForm.cs index f6c2f53..d6d5b9f 100644 --- a/TEMUKJD/PDDForms/ProductSelectForms/PDDDBProdListForm.cs +++ b/TEMUKJD/PDDForms/ProductSelectForms/PDDDBProdListForm.cs @@ -799,6 +799,93 @@ namespace TemuKJD.PDDForms.ProductSelectForms // 替换编辑过的sku if (!string.IsNullOrEmpty(dbProd.sku_edit_json)) prodJObj["detail"]["sku"] = JArray.Parse(JsonHelper.SerializeObject(JsonHelper.DeserializeJsonToList(dbProd.sku_edit_json))); + if (chkSameSpecPrice.Checked) + { + var priceTextLst = dbProd.price_text.Split('-'); + if (priceTextLst.Length != 2 || priceTextLst[0] != priceTextLst[1]) + { + Dictionary specPriceDic = new Dictionary(); + Dictionary specMultiPriceDic = new Dictionary(); + var skuJArr = prodJObj["detail"]["sku"] as JArray; + //bool hasColorSpec = false; + try + { + // 计算主spec的最高价 + foreach (var skuJObj in skuJArr) + { + var specJArr = skuJObj["spec"] as JArray; + if (!specPriceDic.ContainsKey(specJArr[0]["spec_name"].ParseToString()) || skuJObj["price"].ParseToInt() > specPriceDic[specJArr[0]["spec_name"].ParseToString()]) + { + specPriceDic[specJArr[0]["spec_name"].ParseToString()] = skuJObj["price"].ParseToInt(); + } + if (!specMultiPriceDic.ContainsKey(specJArr[0]["spec_name"].ParseToString()) || skuJObj["multi_price"].ParseToInt() > specMultiPriceDic[specJArr[0]["spec_name"].ParseToString()]) + { + specMultiPriceDic[specJArr[0]["spec_name"].ParseToString()] = skuJObj["multi_price"].ParseToInt(); + } + //foreach (var specJObj in specJArr) + //{ + // if (specJObj["parent_id"].ParseToString() == "8640" || specJObj["parent_name"].ParseToString() == "颜色分类") + // hasColorSpec = true; + // if (specJObj["parent_id"].ParseToString() == "1215" || specJObj["parent_name"].ParseToString() == "颜色") + // hasColorSpec = true; + // if (specJObj["parent_id"].ParseToString() == "1473" || specJObj["parent_name"].ParseToString() == "型号") + // hasColorSpec = true; + //} + } + // 统一按最高价设置 + foreach (var skuJObj in skuJArr) + { + var specJArr = skuJObj["spec"] as JArray; + skuJObj["price"] = specPriceDic[specJArr[0]["spec_name"].ParseToString()]; + skuJObj["multi_price"] = specMultiPriceDic[specJArr[0]["spec_name"].ParseToString()]; + } + } + catch + { + continue; + } + //if (!hasColorSpec) + //{ + // continue; + //} + } + } + if (chkHighestPriceSku.Checked) + { + int price = 0; + var skuJArr = prodJObj["detail"]["sku"] as JArray; + try + { + // 计算主spec的最高价 + foreach (var skuJObj in skuJArr) + { + if (price < skuJObj["multi_price"].ParseToInt()) + price = skuJObj["multi_price"].ParseToInt(); + } + + var product_json_tmp = JsonHelper.SerializeObject(prodJObj); + + // 移除第一组所有sku + 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() >= price) + skuJArr.Add(skuJObj2); + } + if (skuJArr.Count == 0) + { + continue; + } + } + catch + { + continue; + } + } // 过滤低价sku,如果所有sku都不达标,跳过商品 if (!string.IsNullOrEmpty(txtMinPrice.Text)) {