From e4b726fc51c779adc96a4d8af113b7ff93509097 Mon Sep 17 00:00:00 2001 From: wule Date: Thu, 14 Aug 2025 19:22:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E4=BB=B7=E5=8A=9F=E8=83=BD=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=88=E6=9A=82=E6=97=B6=E5=8A=A0=E4=BB=B7=E4=B8=8D?= =?UTF-8?q?=E5=BC=80=E6=94=BE=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AllBase/BaseClass.cs | 4 +- KJDService/KJD_WebService/BLL/PriceManage.cs | 5 +- .../DbProductSelectListManageForm.cs | 38 +++ .../DbProductPriceMarkUpForm.Designer.cs | 217 ++++++++++-------- .../Price/DbProductPriceMarkUpForm.cs | 196 ++++++++++++---- .../Price/DbProductPriceMarkUpForm.resx | 5 +- ...oductThirdSelectListManageForm.Designer.cs | 6 +- 7 files changed, 320 insertions(+), 151 deletions(-) diff --git a/AllBase/BaseClass.cs b/AllBase/BaseClass.cs index d2c25f1..2ac5ff1 100644 --- a/AllBase/BaseClass.cs +++ b/AllBase/BaseClass.cs @@ -27,8 +27,8 @@ namespace AllBase /// /// 版本ID /// - public static int VersionCount = 525; - //public static int VersionCount = 525; + public static int VersionCount = 526; + //public static int VersionCount = 526; /// /// 版本号 diff --git a/KJDService/KJD_WebService/BLL/PriceManage.cs b/KJDService/KJD_WebService/BLL/PriceManage.cs index f827f59..9ea5d0b 100644 --- a/KJDService/KJD_WebService/BLL/PriceManage.cs +++ b/KJDService/KJD_WebService/BLL/PriceManage.cs @@ -106,7 +106,8 @@ namespace KJD_Web.BLL paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "@end_markup_times", Value = end_markup_times.ParseToInt(), }); paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "@start_extra_price", Value = start_extra_price.ParseToInt(), }); paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "@end_extra_price", Value = end_extra_price.ParseToInt(), }); - paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@in_ext_code", Value = "'" + in_ext_code?.Replace(",","','") + "'", }); + //paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@in_ext_code", Value = "'" + in_ext_code?.Replace(",", "','") + "'", }); + paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@in_ext_code", Value = in_ext_code.ParseToString() }); string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; MysqlUtils mySql = new MysqlUtils(conn); @@ -131,7 +132,7 @@ namespace KJD_Web.BLL if (!string.IsNullOrWhiteSpace(end_extra_price)) where += " and p.extra_price <= @end_extra_price"; if (!string.IsNullOrEmpty(in_ext_code)) - where += " and p.ext_code in (@in_ext_code)"; + where += " and p.ext_code in ('" + in_ext_code?.Replace(",", "','") + "')"; sql += where; var count = mySql.ExecuteRowCount(sql, paramLst.ToArray()); diff --git a/TEMUKJD/KJDForms/ProductSelectForms/DbProductSelectListManageForm.cs b/TEMUKJD/KJDForms/ProductSelectForms/DbProductSelectListManageForm.cs index 00e3dc8..0099554 100644 --- a/TEMUKJD/KJDForms/ProductSelectForms/DbProductSelectListManageForm.cs +++ b/TEMUKJD/KJDForms/ProductSelectForms/DbProductSelectListManageForm.cs @@ -29,6 +29,7 @@ namespace TemuKJD.KJDForms.ProductSelectForms { List lstAdminTemuDBProductSelect = new List(); List shopLst = new List(); + List lstDbPrice = new List(); public DbProductSelectListManageForm() { @@ -486,6 +487,11 @@ namespace TemuKJD.KJDForms.ProductSelectForms => row.Cells["colSelect"]?.Value.ParseToBool() == true).Select(r => r.Cells["colSelectId"]?.Value.ToString()).ToList(); var prodList = this.lstAdminTemuDBProductSelect.Where(p => lstProdId.Contains(p.id.ParseToString())).ToArray(); + // 上传前先获取加价信息 + var extCodes = prodList.Select(s => s.ext_code).Where(s => !string.IsNullOrWhiteSpace(s)).Distinct().ToList(); + lstDbPrice.Clear(); + lstDbPrice.AddRange(GetServerPriceLst(extCodes)); + if (prodList.Count() > 0) { this.btnAdd.Enabled = false; @@ -1154,6 +1160,9 @@ namespace TemuKJD.KJDForms.ProductSelectForms JsonHelper.SerializeObject(skuInfo.productSkuWhExtAttr.productSkuWeight)), }; skuItem.supplierPrice = skuInfo.supplierPrice; + //var dbPrice = lstDbPrice.FirstOrDefault(p => p.ext_code == dbProd.ext_code); + //if (dbPrice != null) + // skuItem.supplierPrice = dbPrice.original_price * dbPrice.markup_times + dbPrice.extra_price; #region 使用随机sku价格上传(第一个sku价格不变,此处有bug,平台最后的sku排列不是按照提交上去的顺序排的) if (skuCount != 1 && chkSkuRandomPrice.Checked) @@ -1604,5 +1613,34 @@ namespace TemuKJD.KJDForms.ProductSelectForms SearchDbProdSelect(this.ucSplitPage1.CurrentPage); }); } + + public List GetServerPriceLst(List extCodeList) + { + List list = new List(); + + var url = BaseClass.BuildObjString("price/get_price_list"); + var data = UserLogin.GetSignaturex(); + data += "&page=1"; + data += "&page_size=200"; + data += "&in_ext_code=" + string.Join(",", extCodeList); + var html = GetHtml.PostUtf8(url, data); + if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200")) + html = GetHtml.PostUtf8(url, data); + if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200")) + html = GetHtml.PostUtf8(url, data); + if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200")) + { + return list; + } + + if (!html.Contains("data")) + return list; + + var jArr = JObject.Parse(html)["data"]; + if (jArr.Count() == 0) + return list; + + return JsonHelper.DeserializeJsonToList(jArr.ToString()); + } } } diff --git a/TEMUKJD/KJDForms/ProductSelectForms/Price/DbProductPriceMarkUpForm.Designer.cs b/TEMUKJD/KJDForms/ProductSelectForms/Price/DbProductPriceMarkUpForm.Designer.cs index 306255e..16b8ee8 100644 --- a/TEMUKJD/KJDForms/ProductSelectForms/Price/DbProductPriceMarkUpForm.Designer.cs +++ b/TEMUKJD/KJDForms/ProductSelectForms/Price/DbProductPriceMarkUpForm.Designer.cs @@ -30,14 +30,15 @@ namespace TemuKJD.KJDForms.ProductSelectForms private void InitializeComponent() { this.components = new System.ComponentModel.Container(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = 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(); this.splitContainer1 = new System.Windows.Forms.SplitContainer(); this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel(); this.panel5 = new System.Windows.Forms.Panel(); this.chkShowDelete = new TemuKJD.UserComponent.UcCheckBox(this.components); this.btnDelete = new TemuKJD.UserControls.ButtonEx(); this.panel4 = new System.Windows.Forms.Panel(); + this.btnImport = new DevComponents.DotNetBar.PanelEx(); this.loginPanel = new DevComponents.DotNetBar.PanelEx(); this.numericUpDown6 = new System.Windows.Forms.NumericUpDown(); this.numericUpDown5 = new System.Windows.Forms.NumericUpDown(); @@ -59,18 +60,18 @@ namespace TemuKJD.KJDForms.ProductSelectForms this.splitContainer2 = new System.Windows.Forms.SplitContainer(); this.pbLoading = new System.Windows.Forms.PictureBox(); this.dgvPrice = new TemuKJD.UserComponent.DataGridViewEx(); + this.chkAutoDrag = new System.Windows.Forms.CheckBox(); + this.ucSplitPage1 = new TemuKJD.UserControls.UcSplitPage(); + this.statusBar = new TemuKJD.UserControls.StatusBarUserControl(); this.colSelect = new System.Windows.Forms.DataGridViewCheckBoxColumn(); - this.colExtCpde = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.colId = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.colExtCode = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.colOriginalPrice = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.colMarkupTimes = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.colExtraPrice = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.conNotes = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.colEdit = new System.Windows.Forms.DataGridViewLinkColumn(); this.colDelete = new System.Windows.Forms.DataGridViewLinkColumn(); - this.chkAutoDrag = new System.Windows.Forms.CheckBox(); - this.ucSplitPage1 = new TemuKJD.UserControls.UcSplitPage(); - this.statusBar = new TemuKJD.UserControls.StatusBarUserControl(); - this.btnImport = new DevComponents.DotNetBar.PanelEx(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout(); @@ -165,6 +166,7 @@ namespace TemuKJD.KJDForms.ProductSelectForms this.btnDelete.Text = "删除选中"; this.btnDelete.UseVisualStyleBackColor = false; this.btnDelete.Visible = false; + this.btnDelete.Click += new System.EventHandler(this.btnDelete_Click); // // panel4 // @@ -193,6 +195,30 @@ namespace TemuKJD.KJDForms.ProductSelectForms this.panel4.Size = new System.Drawing.Size(1087, 40); this.panel4.TabIndex = 0; // + // btnImport + // + this.btnImport.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; + this.btnImport.Cursor = System.Windows.Forms.Cursors.Hand; + this.btnImport.DisabledBackColor = System.Drawing.Color.Empty; + this.btnImport.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.btnImport.Location = new System.Drawing.Point(11, 8); + this.btnImport.Name = "btnImport"; + this.btnImport.Size = new System.Drawing.Size(48, 26); + this.btnImport.Style.Alignment = System.Drawing.StringAlignment.Center; + this.btnImport.Style.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255))))); + this.btnImport.Style.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255))))); + this.btnImport.Style.BorderColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder; + this.btnImport.Style.BorderDashStyle = System.Drawing.Drawing2D.DashStyle.Dash; + this.btnImport.Style.BorderSide = DevComponents.DotNetBar.eBorderSide.None; + this.btnImport.Style.ForeColor.Color = System.Drawing.Color.White; + this.btnImport.Style.GradientAngle = 90; + this.btnImport.StyleMouseOver.Alignment = System.Drawing.StringAlignment.Center; + this.btnImport.StyleMouseOver.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(102)))), ((int)(((byte)(255))))); + this.btnImport.StyleMouseOver.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(102)))), ((int)(((byte)(255))))); + this.btnImport.TabIndex = 451; + this.btnImport.Text = "导入"; + this.btnImport.Click += new System.EventHandler(this.btnImport_Click); + // // loginPanel // this.loginPanel.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; @@ -481,27 +507,28 @@ namespace TemuKJD.KJDForms.ProductSelectForms this.pbLoading.TabStop = false; this.pbLoading.Visible = false; // - // dgvShop + // dgvPrice // this.dgvPrice.AllowUserToAddRows = false; this.dgvPrice.AllowUserToDeleteRows = false; - dataGridViewCellStyle5.BackColor = System.Drawing.Color.WhiteSmoke; - this.dgvPrice.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle5; + dataGridViewCellStyle1.BackColor = System.Drawing.Color.WhiteSmoke; + this.dgvPrice.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; this.dgvPrice.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dgvPrice.BackgroundColor = System.Drawing.Color.White; this.dgvPrice.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255))))); - dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle6.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle6.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle6.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle6.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle6.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle6.WrapMode = System.Windows.Forms.DataGridViewTriState.False; - this.dgvPrice.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle6; + 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.dgvPrice.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2; this.dgvPrice.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dgvPrice.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.colSelect, - this.colExtCpde, + this.colId, + this.colExtCode, this.colOriginalPrice, this.colMarkupTimes, this.colExtraPrice, @@ -510,69 +537,12 @@ namespace TemuKJD.KJDForms.ProductSelectForms this.colDelete}); this.dgvPrice.Dock = System.Windows.Forms.DockStyle.Fill; this.dgvPrice.Location = new System.Drawing.Point(4, 0); - this.dgvPrice.Name = "dgvShop"; + this.dgvPrice.Name = "dgvPrice"; this.dgvPrice.ReadOnly = true; this.dgvPrice.RowTemplate.Height = 23; this.dgvPrice.Size = new System.Drawing.Size(1299, 456); this.dgvPrice.TabIndex = 5; - // - // colSelect - // - this.colSelect.FillWeight = 26F; - this.colSelect.HeaderText = "选"; - this.colSelect.Name = "colSelect"; - this.colSelect.ReadOnly = true; - this.colSelect.Resizable = System.Windows.Forms.DataGridViewTriState.True; - this.colSelect.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; - // - // colExtCpde - // - this.colExtCpde.FillWeight = 69.42599F; - this.colExtCpde.HeaderText = "商品货号"; - this.colExtCpde.Name = "colExtCpde"; - this.colExtCpde.ReadOnly = true; - // - // colOriginalPrice - // - this.colOriginalPrice.FillWeight = 69.42599F; - this.colOriginalPrice.HeaderText = "商品原价"; - this.colOriginalPrice.Name = "colOriginalPrice"; - this.colOriginalPrice.ReadOnly = true; - // - // colMarkupTimes - // - this.colMarkupTimes.HeaderText = "加价倍数"; - this.colMarkupTimes.Name = "colMarkupTimes"; - this.colMarkupTimes.ReadOnly = true; - // - // colExtraPrice - // - this.colExtraPrice.HeaderText = "额外加价"; - this.colExtraPrice.Name = "colExtraPrice"; - this.colExtraPrice.ReadOnly = true; - // - // conNotes - // - this.conNotes.HeaderText = "备注"; - this.conNotes.Name = "conNotes"; - this.conNotes.ReadOnly = true; - // - // colEdit - // - this.colEdit.FillWeight = 46F; - this.colEdit.HeaderText = "编辑"; - this.colEdit.Name = "colEdit"; - this.colEdit.ReadOnly = true; - this.colEdit.Resizable = System.Windows.Forms.DataGridViewTriState.True; - this.colEdit.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; - // - // colDelete - // - this.colDelete.FillWeight = 46F; - this.colDelete.HeaderText = "删除"; - this.colDelete.Name = "colDelete"; - this.colDelete.ReadOnly = true; - this.colDelete.Visible = false; + this.dgvPrice.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvPrice_CellContentClick); // // chkAutoDrag // @@ -609,29 +579,71 @@ namespace TemuKJD.KJDForms.ProductSelectForms this.statusBar.Size = new System.Drawing.Size(1307, 25); this.statusBar.TabIndex = 1; // - // btnImport + // colSelect // - this.btnImport.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; - this.btnImport.Cursor = System.Windows.Forms.Cursors.Hand; - this.btnImport.DisabledBackColor = System.Drawing.Color.Empty; - this.btnImport.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.btnImport.Location = new System.Drawing.Point(11, 8); - this.btnImport.Name = "btnImport"; - this.btnImport.Size = new System.Drawing.Size(48, 26); - this.btnImport.Style.Alignment = System.Drawing.StringAlignment.Center; - this.btnImport.Style.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255))))); - this.btnImport.Style.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255))))); - this.btnImport.Style.BorderColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder; - this.btnImport.Style.BorderDashStyle = System.Drawing.Drawing2D.DashStyle.Dash; - this.btnImport.Style.BorderSide = DevComponents.DotNetBar.eBorderSide.None; - this.btnImport.Style.ForeColor.Color = System.Drawing.Color.White; - this.btnImport.Style.GradientAngle = 90; - this.btnImport.StyleMouseOver.Alignment = System.Drawing.StringAlignment.Center; - this.btnImport.StyleMouseOver.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(102)))), ((int)(((byte)(255))))); - this.btnImport.StyleMouseOver.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(102)))), ((int)(((byte)(255))))); - this.btnImport.TabIndex = 451; - this.btnImport.Text = "导入"; - this.btnImport.Click += new System.EventHandler(this.btnImport_Click); + this.colSelect.FillWeight = 26F; + this.colSelect.HeaderText = "选"; + this.colSelect.Name = "colSelect"; + this.colSelect.ReadOnly = true; + this.colSelect.Resizable = System.Windows.Forms.DataGridViewTriState.True; + this.colSelect.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; + // + // colId + // + this.colId.HeaderText = "数据库编号"; + this.colId.Name = "colId"; + this.colId.ReadOnly = true; + this.colId.Visible = false; + // + // colExtCode + // + this.colExtCode.FillWeight = 69.42599F; + this.colExtCode.HeaderText = "商品货号"; + this.colExtCode.Name = "colExtCode"; + this.colExtCode.ReadOnly = true; + // + // colOriginalPrice + // + this.colOriginalPrice.FillWeight = 69.42599F; + this.colOriginalPrice.HeaderText = "商品原价"; + this.colOriginalPrice.Name = "colOriginalPrice"; + this.colOriginalPrice.ReadOnly = true; + // + // colMarkupTimes + // + this.colMarkupTimes.HeaderText = "加价倍数"; + this.colMarkupTimes.Name = "colMarkupTimes"; + this.colMarkupTimes.ReadOnly = true; + // + // colExtraPrice + // + this.colExtraPrice.HeaderText = "额外加价"; + this.colExtraPrice.Name = "colExtraPrice"; + this.colExtraPrice.ReadOnly = true; + // + // conNotes + // + this.conNotes.HeaderText = "备注"; + this.conNotes.Name = "conNotes"; + this.conNotes.ReadOnly = true; + // + // colEdit + // + this.colEdit.FillWeight = 46F; + this.colEdit.HeaderText = "编辑"; + this.colEdit.Name = "colEdit"; + this.colEdit.ReadOnly = true; + this.colEdit.Resizable = System.Windows.Forms.DataGridViewTriState.True; + this.colEdit.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; + this.colEdit.Visible = false; + // + // colDelete + // + this.colDelete.FillWeight = 46F; + this.colDelete.HeaderText = "删除"; + this.colDelete.Name = "colDelete"; + this.colDelete.ReadOnly = true; + this.colDelete.Visible = false; // // DbPriceMarkUpForm // @@ -701,14 +713,15 @@ namespace TemuKJD.KJDForms.ProductSelectForms private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label8; private DevComponents.DotNetBar.PanelEx loginPanel; + private DevComponents.DotNetBar.PanelEx btnImport; private System.Windows.Forms.DataGridViewCheckBoxColumn colSelect; - private System.Windows.Forms.DataGridViewTextBoxColumn colExtCpde; + private System.Windows.Forms.DataGridViewTextBoxColumn colId; + private System.Windows.Forms.DataGridViewTextBoxColumn colExtCode; private System.Windows.Forms.DataGridViewTextBoxColumn colOriginalPrice; private System.Windows.Forms.DataGridViewTextBoxColumn colMarkupTimes; private System.Windows.Forms.DataGridViewTextBoxColumn colExtraPrice; private System.Windows.Forms.DataGridViewTextBoxColumn conNotes; private System.Windows.Forms.DataGridViewLinkColumn colEdit; private System.Windows.Forms.DataGridViewLinkColumn colDelete; - private DevComponents.DotNetBar.PanelEx btnImport; } } \ No newline at end of file diff --git a/TEMUKJD/KJDForms/ProductSelectForms/Price/DbProductPriceMarkUpForm.cs b/TEMUKJD/KJDForms/ProductSelectForms/Price/DbProductPriceMarkUpForm.cs index ef830ab..5aa51f4 100644 --- a/TEMUKJD/KJDForms/ProductSelectForms/Price/DbProductPriceMarkUpForm.cs +++ b/TEMUKJD/KJDForms/ProductSelectForms/Price/DbProductPriceMarkUpForm.cs @@ -10,6 +10,7 @@ using System.Drawing; using System.IO; using System.Linq; using System.Text; +using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using TemuKJD.Extension; @@ -61,11 +62,11 @@ namespace TemuKJD.KJDForms.ProductSelectForms private void btnImport_Click(object sender, EventArgs e) { ImportShop(); + SearchPrice(this.ucSplitPage1.CurrentPage); } void ImportShop() { - this.btnImport.Enabled = false; string text = "货号加价导入格式:\r\n\r\n" + "1.货号,价格/元,申报价格倍数,额外加价金额/元\r\n" + "2.货号,价格/元,申报价格倍数,额外加价金额/元,备注\r\n" + @@ -79,50 +80,85 @@ namespace TemuKJD.KJDForms.ProductSelectForms openFileDialog.FilterIndex = 1; if (openFileDialog.ShowDialog() == DialogResult.OK) { - using (StreamReader sr = new StreamReader(openFileDialog.FileName, System.Text.Encoding.UTF8)) - //using (StreamReader sr = new StreamReader(openFileDialog.FileName, Encoding.GetEncoding("gb2312"))) + this.btnImport.Enabled = false; + this.pbLoading.Enabled = true; + Task.Run(() => { - string fileName = openFileDialog.FileName; - string importStr = sr.ReadToEnd().Trim(); - var strArr = importStr.Split(new string[] { "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < strArr.Length; i++) + using (StreamReader sr = new StreamReader(openFileDialog.FileName, System.Text.Encoding.UTF8)) + //using (StreamReader sr = new StreamReader(openFileDialog.FileName, Encoding.GetEncoding("gb2312"))) { - try + string fileName = openFileDialog.FileName; + string importStr = sr.ReadToEnd().Trim(); + var strArr = importStr.Split(new string[] { "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries); + Dictionary errMsgDic = new Dictionary(); + int count = 0; + for (int i = 0; i < strArr.Length; i++) { - // 通用格式 - //货号,价格/元,申报价格(加价比例), - //001-007,9,2倍+3, - if (strArr[i].Contains("倍+")) + try { - var productArr = strArr[i].Split(new string[] { " ", "\t", ",", "倍+" }, StringSplitOptions.RemoveEmptyEntries); - if (productArr.Length > 3) + Invoke(new Action(() => { - TemuDBPriceInfo price = new TemuDBPriceInfo + this.statusBar.lblTaskStatus.Text = "正在导入..."; + this.statusBar.pgbTaskProgress.Maximum = strArr.Length; + this.statusBar.UpdateProgressBar(i+1); + })); + // 通用格式 + //货号,价格/元,申报价格(加价比例), + //001-007,9,2倍+3, + if (strArr[i].Contains("倍+")) + { + var productArr = strArr[i].Split(new string[] { " ", "\t", ",", "倍+" }, StringSplitOptions.RemoveEmptyEntries); + if (productArr.Length > 3) { - ext_code = productArr[0], - original_price = (productArr[1].ParseToDecimal() * 100).ParseToInt(), - markup_times = productArr[2].ParseToInt(), - extra_price = (productArr[3].ParseToDecimal() * 100).ParseToInt(), - }; - if (productArr.Length > 4) - { - price.notes = productArr[4]; - } + count++; + TemuDBPriceInfo price = new TemuDBPriceInfo + { + ext_code = productArr[0], + original_price = (productArr[1].ParseToDecimal() * 100).ParseToInt(), + markup_times = productArr[2].ParseToInt(), + extra_price = (productArr[3].ParseToDecimal() * 100).ParseToInt(), + }; + if (productArr.Length > 4) + { + price.notes = productArr[4]; + } - AddDbPrice(price); + var msg = AddDbPrice(price, false); + if (msg != "success") + { + errMsgDic[price.ext_code] = msg; + } + } } } + catch (Exception ex) + { + } } - catch (Exception ex) + int failCount = errMsgDic.Keys.Count; + string failReason = string.Join(",", errMsgDic.Values.Distinct().ToArray()); + if (failReason.Length > 200) + failReason = failReason.Substring(0, 200) + "..."; + string resultMsg = "加价信息导入完成,共导入 " + (count - failCount) + " 条数据"; + if (!string.IsNullOrWhiteSpace(failReason)) + resultMsg += "\r\n\r\n失败 " + failCount + " 条数据主要原因如下:\r\n" + failReason; + + Invoke(new Action(() => { - } + this.statusBar.lblTaskStatus.Text = "导入结束"; + BaseMsgForm.ShowInfo(resultMsg, "", FormLevel.LARGE); + })); } - } + Invoke(new Action(() => + { + this.pbLoading.Visible = false; + this.btnImport.Enabled = true; + })); + }); } - this.btnImport.Enabled = true; } - public string AddDbPrice(TemuDBPriceInfo _price) + public string AddDbPrice(TemuDBPriceInfo _price, bool isShowErrMsg = true) { var url = BaseClass.BuildObjString("price/add_price"); var data = UserLogin.GetSignaturex() @@ -142,9 +178,13 @@ namespace TemuKJD.KJDForms.ProductSelectForms var msg = BaseRegex.GetStringJson(ref result, "msg"); if (string.IsNullOrEmpty(msg)) msg = "加价保存失败!"; - BaseMsgForm.ShowError(msg); + + if (isShowErrMsg) + BaseMsgForm.ShowError(msg); + + return msg; } - return result; + return "success"; } private void pnlEmpty_Click(object sender, EventArgs e) @@ -198,10 +238,11 @@ namespace TemuKJD.KJDForms.ProductSelectForms { int rowIndex = this.dgvPrice.Rows.Add( extCodeList.Contains(price.ext_code), + price.id, price.ext_code, - price.original_price, + price.original_price * 0.01, price.markup_times, - price.extra_price, + price.extra_price * 0.01, price.notes, "编辑", "删除"); @@ -236,19 +277,19 @@ namespace TemuKJD.KJDForms.ProductSelectForms var url = BaseClass.BuildObjString("price/get_price_list"); var data = UserLogin.GetSignaturex(); - data += "&page=" + page; - data += "&page_size=" + pageSize; + data += "&page=" + page; + data += "&page_size=" + pageSize; if (numericUpDown1.Value > 0) data += "&start_original_price=" + numericUpDown1.Value * 100; - data += "&end_original_price=" + numericUpDown2.Value * 100; + data += "&end_original_price=" + numericUpDown2.Value * 100; if (numericUpDown3.Value > 0) data += "&start_markup_times=" + numericUpDown3.Value; - data += "&end_markup_times=" + numericUpDown4.Value; + data += "&end_markup_times=" + numericUpDown4.Value; if (numericUpDown5.Value > 0) data += "&start_extra_price=" + numericUpDown5.Value * 100; - data += "&end_extra_price=" + numericUpDown6.Value * 100; - data += "&search_ext_code=" + txtExtCode.Text.Trim(); - data += "&search_notes=" + txtNotes.Text.Trim(); + data += "&end_extra_price=" + numericUpDown6.Value * 100; + data += "&search_ext_code=" + txtExtCode.Text.Trim(); + data += "&search_notes=" + txtNotes.Text.Trim(); if (BaseClass.SaLevel > 1) data += "&operate_sub_sa_name=" + BaseClass.UserName; var html = GetHtml.PostUtf8(url, data); @@ -274,5 +315,78 @@ namespace TemuKJD.KJDForms.ProductSelectForms return JsonHelper.DeserializeJsonToList(jArr.ToString()); } + + private void dgvPrice_CellContentClick(object sender, DataGridViewCellEventArgs e) + { + if (e.ColumnIndex < 0 || e.RowIndex < 0) + return; + string headerText = dgvPrice.Columns[e.ColumnIndex].HeaderText; + string extCode = dgvPrice.Rows[e.RowIndex].Cells["colExtCode"].Value.ParseToString(); + string dbId = dgvPrice.Rows[e.RowIndex].Cells["colId"].Value.ParseToString(); + + switch (headerText) + { + case "删除": + if (BaseMsgForm.ShowConfirm("确定删除加价数据吗?删除后不可恢复!").DialogResult == DialogResult.Cancel) + return; + var rst = DeleteServerPrice(dbId); + if (rst) + SearchPrice(this.ucSplitPage1.CurrentPage); + break; + case "编辑": + //ShopAddEditForm editForm = new ShopAddEditForm(shop); + //editForm.SaveCompleteWithDescribe += EditForm_SaveCompleteWithDescribe; + //editForm.ShowDialog(); + break; + default: + dgvPrice.Rows[e.RowIndex].Cells["colSelect"].Value = !(bool)dgvPrice.Rows[e.RowIndex].Cells["colSelect"].Value; + break; + } + } + + bool DeleteServerPrice(string dbId, bool isShowErrMsg = true) + { + var url = BaseClass.BuildObjString("price/del_db_price"); + var data = UserLogin.GetSignaturex() + "&db_id=" + dbId; + var result = GetHtml.PostUtf8(url, data); + if (!result.Contains("\"code\":200")) + { + if (isShowErrMsg) + BaseMsgForm.ShowError("删除失败:" + BaseRegex.GetStringJson(ref result, "msg")); + return false; + } + else + { + return true; + } + } + + private void btnDelete_Click(object sender, EventArgs e) + { + if (BaseMsgForm.ShowConfirm("确定删除加价参数吗?删除后不可恢复!").DialogResult == DialogResult.Cancel) + return; + + pbLoading.Visible = true; + var dbIds = dgvPrice.Rows.Cast().Where(r => r.Cells["colSelect"].Value.ParseToBool() == true) + .Select(r => r.Cells["colId"].Value.ParseToString()); + + Task.Run(() => + { + foreach (var dbId in dbIds) + { + Thread.Sleep(50); + var rst = DeleteServerPrice(dbId, false); + if (rst == false) + { + Invoke(new Action(() => + { + BaseMsgForm.ShowError("数据删除失败,请稍后重试!"); + })); + break; + } + }; + SearchPrice(this.ucSplitPage1.CurrentPage); + }); + } } } diff --git a/TEMUKJD/KJDForms/ProductSelectForms/Price/DbProductPriceMarkUpForm.resx b/TEMUKJD/KJDForms/ProductSelectForms/Price/DbProductPriceMarkUpForm.resx index af7c095..fcee99e 100644 --- a/TEMUKJD/KJDForms/ProductSelectForms/Price/DbProductPriceMarkUpForm.resx +++ b/TEMUKJD/KJDForms/ProductSelectForms/Price/DbProductPriceMarkUpForm.resx @@ -120,7 +120,10 @@ True - + + True + + True diff --git a/TEMUKJD/KJDForms/ProductThirdSelectForms/ProductThirdSelectListManageForm.Designer.cs b/TEMUKJD/KJDForms/ProductThirdSelectForms/ProductThirdSelectListManageForm.Designer.cs index 59f2f95..d722457 100644 --- a/TEMUKJD/KJDForms/ProductThirdSelectForms/ProductThirdSelectListManageForm.Designer.cs +++ b/TEMUKJD/KJDForms/ProductThirdSelectForms/ProductThirdSelectListManageForm.Designer.cs @@ -264,7 +264,7 @@ "全部", "重上", "已买"}); - this.cmbUserNotes.Location = new System.Drawing.Point(1044, 5); + this.cmbUserNotes.Location = new System.Drawing.Point(1044, 8); this.cmbUserNotes.Margin = new System.Windows.Forms.Padding(0); this.cmbUserNotes.Name = "cmbUserNotes"; this.cmbUserNotes.Size = new System.Drawing.Size(65, 25); @@ -281,7 +281,7 @@ "核价成功", "核价成功(重复)", "重复"}); - this.cmbNotes.Location = new System.Drawing.Point(917, 5); + this.cmbNotes.Location = new System.Drawing.Point(917, 8); this.cmbNotes.Margin = new System.Windows.Forms.Padding(0); this.cmbNotes.Name = "cmbNotes"; this.cmbNotes.Size = new System.Drawing.Size(65, 25); @@ -308,7 +308,7 @@ "已上传", "草稿箱", "全部"}); - this.cmbStatus.Location = new System.Drawing.Point(814, 5); + this.cmbStatus.Location = new System.Drawing.Point(814, 8); this.cmbStatus.Margin = new System.Windows.Forms.Padding(0); this.cmbStatus.Name = "cmbStatus"; this.cmbStatus.Size = new System.Drawing.Size(65, 25);