From 2ae38c8105adddb2ac4cdbcf6a9341f84fd1de42 Mon Sep 17 00:00:00 2001 From: wule_5900x Date: Sun, 18 Jan 2026 20:40:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B9=A6=E7=B1=8D=E7=B1=BB=E7=9B=AE=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AllBase/BaseClass.cs | 2 +- .../Param/WXParam/WXUploadProductParam.cs | 8 +- .../Result/PDDResult/PDDProductDetailInfo.cs | 2 +- .../PDDDBProdEditForm.Designer.cs | 28 +++ .../ProductSelectForms/PDDDBProdEditForm.cs | 60 +++++ .../PDDDBProdUserSelectForm.cs | 4 +- .../PDDGetChanceProdForm.Designer.cs | 32 +-- .../PDDGetChanceProdForm.cs | 19 +- .../WXDBProdUploadForm.Designer.cs | 66 +++--- .../ProductForms/WXDBProdUploadForm.cs | 207 +++++++++++++++--- 10 files changed, 339 insertions(+), 89 deletions(-) diff --git a/AllBase/BaseClass.cs b/AllBase/BaseClass.cs index a3680d5..5cc2f93 100644 --- a/AllBase/BaseClass.cs +++ b/AllBase/BaseClass.cs @@ -27,7 +27,7 @@ namespace AllBase /// /// 版本ID /// - public static int VersionCount = 790; + public static int VersionCount = 792; //public static int VersionCount = 613; /// diff --git a/AllBase/Model/Param/WXParam/WXUploadProductParam.cs b/AllBase/Model/Param/WXParam/WXUploadProductParam.cs index 65dabf8..c307ee9 100644 --- a/AllBase/Model/Param/WXParam/WXUploadProductParam.cs +++ b/AllBase/Model/Param/WXParam/WXUploadProductParam.cs @@ -222,7 +222,7 @@ namespace AllBase.Model.Param.WXParam public List thirdCategoryHistories { get; set; } = new List(); public List headVideoInfo { get; set; } = new List(); public List labels { get; set; } = new List(); - public List qualificationList { get; set; } = new List(); + public List qualificationList { get; set; } = new List(); public List productHeadimgInfo { get; set; } public List deliverAcctType { get; set; } = new List(); public List headImgInfos { get; set; } @@ -323,6 +323,12 @@ namespace AllBase.Model.Param.WXParam public leagueItemInfoParam leagueItemInfo { get; set; } = new leagueItemInfoParam(); } + public class qualificationParam + { + public string qualificationId { get; set; } // "1111485", + public List qualificationUrl { get; set; } // ["https://wst.wxapp.tc.qq.com/160/20304/snscosdownload/SH/reserved/6xykWLEnztJZvEhHrozpFIFJu2hgPuZS72J5BOmTnibDpt88NgTZLfmt6ziacLk1IIc3BLlnfc0XpyNmeiaCWeMVw?token=x5Y29zUxcibDicBLjG2rgWiaf29nSfAfsLNARZEJicqTfdyR6p5hONtKibWlnRrqOsNsA&idx=1&expire=1768988129"] + } + public class timingOnsaleInfoParam { public int? status { get; set; } = 0; diff --git a/AllBase/Model/Result/PDDResult/PDDProductDetailInfo.cs b/AllBase/Model/Result/PDDResult/PDDProductDetailInfo.cs index a222f6a..c597e9c 100644 --- a/AllBase/Model/Result/PDDResult/PDDProductDetailInfo.cs +++ b/AllBase/Model/Result/PDDResult/PDDProductDetailInfo.cs @@ -284,7 +284,7 @@ namespace AllBase.Model.Result.PDDResult public class spec_item { - public int? parent_id { get; set; } + public long? parent_id { get; set; } public string parent_name { get; set; } public long? spec_id { get; set; } public string spec_name { get; set; } diff --git a/TEMUKJD/PDDForms/ProductSelectForms/PDDDBProdEditForm.Designer.cs b/TEMUKJD/PDDForms/ProductSelectForms/PDDDBProdEditForm.Designer.cs index 527a43b..89a7649 100644 --- a/TEMUKJD/PDDForms/ProductSelectForms/PDDDBProdEditForm.Designer.cs +++ b/TEMUKJD/PDDForms/ProductSelectForms/PDDDBProdEditForm.Designer.cs @@ -30,6 +30,7 @@ { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PDDDBProdEditForm)); this.panel2 = new System.Windows.Forms.Panel(); + this.btnBookImg = new DevComponents.DotNetBar.PanelEx(); this.btnEditDetail = new DevComponents.DotNetBar.PanelEx(); this.btnSelect = new TemuKJD.UserControls.ButtonEx(); this.buttonEx1 = new TemuKJD.UserControls.ButtonEx(); @@ -61,6 +62,7 @@ // panel2 // this.panel2.BackColor = System.Drawing.Color.White; + this.panel2.Controls.Add(this.btnBookImg); this.panel2.Controls.Add(this.btnEditDetail); this.panel2.Controls.Add(this.btnSelect); this.panel2.Controls.Add(this.buttonEx1); @@ -90,6 +92,31 @@ this.panel2.Size = new System.Drawing.Size(464, 651); this.panel2.TabIndex = 1; // + // btnBookImg + // + this.btnBookImg.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; + this.btnBookImg.Cursor = System.Windows.Forms.Cursors.Hand; + this.btnBookImg.DisabledBackColor = System.Drawing.Color.Empty; + this.btnBookImg.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.btnBookImg.Location = new System.Drawing.Point(341, 523); + this.btnBookImg.Name = "btnBookImg"; + this.btnBookImg.Size = new System.Drawing.Size(85, 26); + this.btnBookImg.Style.Alignment = System.Drawing.StringAlignment.Center; + this.btnBookImg.Style.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255))))); + this.btnBookImg.Style.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255))))); + this.btnBookImg.Style.BorderColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder; + this.btnBookImg.Style.BorderDashStyle = System.Drawing.Drawing2D.DashStyle.Dash; + this.btnBookImg.Style.BorderSide = DevComponents.DotNetBar.eBorderSide.None; + this.btnBookImg.Style.ForeColor.Color = System.Drawing.Color.White; + this.btnBookImg.Style.GradientAngle = 90; + this.btnBookImg.StyleMouseOver.Alignment = System.Drawing.StringAlignment.Center; + this.btnBookImg.StyleMouseOver.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(102)))), ((int)(((byte)(255))))); + this.btnBookImg.StyleMouseOver.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(102)))), ((int)(((byte)(255))))); + this.btnBookImg.TabIndex = 654; + this.btnBookImg.Text = "生成书籍图片"; + this.btnBookImg.Visible = false; + this.btnBookImg.Click += new System.EventHandler(this.btnBookImg_Click); + // // btnEditDetail // this.btnEditDetail.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; @@ -415,5 +442,6 @@ private UserControls.ButtonEx buttonEx1; private UserControls.ButtonEx btnSelect; private DevComponents.DotNetBar.PanelEx btnEditDetail; + private DevComponents.DotNetBar.PanelEx btnBookImg; } } \ No newline at end of file diff --git a/TEMUKJD/PDDForms/ProductSelectForms/PDDDBProdEditForm.cs b/TEMUKJD/PDDForms/ProductSelectForms/PDDDBProdEditForm.cs index 579c201..cfd77a4 100644 --- a/TEMUKJD/PDDForms/ProductSelectForms/PDDDBProdEditForm.cs +++ b/TEMUKJD/PDDForms/ProductSelectForms/PDDDBProdEditForm.cs @@ -240,5 +240,65 @@ namespace TemuKJD.PDDForms.ProductSelectForms PDDDBProdEditDetailForm editDetailForm = new PDDDBProdEditDetailForm(this.dbProd); editDetailForm.ShowDialog(); } + + private void btnBookImg_Click(object sender, EventArgs e) + { + var prodJson = this.dbProd.product_json; + var prodInfo = JsonHelper.DeserializeJsonToObject(prodJson); + if (prodInfo != null) + { + string publisher = "出版社:" + new List () { "技术出版社", "文化出版社", "美术出版社" }[Randomx.GetId(3)]; + string isbn = "ISBN:"; + string bookName = "书名:"; + string bookPrice = "定价:" + prodInfo.detail.sku.Max(s => s.multi_price) * 0.01; + string author = "作者:王老师"; + string publishTime = "出版时间:" + DateTime.Now.AddMonths(-3); + string edition = "版次:1"; + string binding = "装帧:平装"; + + foreach (var propInfo in prodInfo.property.goods_properties) + { + if (propInfo.name.Contains("出版社名称")) + publisher = "出版社:" + propInfo.values.FirstOrDefault()?.value; + else if (propInfo.name.Contains("ISBN")) + isbn = "ISBN:" + propInfo.values.FirstOrDefault()?.value; + else if (propInfo.name.Contains("书名")) + bookName = "书名:" + propInfo.values.FirstOrDefault()?.value; + else if (propInfo.name.Contains("定价")) + bookPrice = "定价:" + propInfo.values.FirstOrDefault()?.value; + else if (propInfo.name.Contains("作者")) + author = "作者:" + propInfo.values.FirstOrDefault()?.value; + else if (propInfo.name.Contains("出版时间")) + publishTime = "出版时间:" + propInfo.values.FirstOrDefault()?.value; + else if (propInfo.name.Contains("版次")) + edition = "版次:" + propInfo.values.FirstOrDefault()?.value; + else if (propInfo.name.Contains("装帧")) + binding = "装帧:" + propInfo.values.FirstOrDefault()?.value; + } + + var bookStr = publisher + "\r\n" + "\r\n" + + isbn + "\r\n" + "\r\n" + + bookName + "\r\n" + "\r\n" + + bookPrice + "\r\n" + "\r\n" + + author + "\r\n" + "\r\n" + + publishTime + "\r\n" + "\r\n" + + edition + "\r\n" + "\r\n" + + binding; + + var imageBg = new Bitmap(800, 800); + using (Graphics g = Graphics.FromImage(imageBg)) + { + g.Clear(Color.White); + //Font font = new Font("宋体", 15, FontStyle.Bold); + Font font = new Font("微软雅黑", 15, FontStyle.Regular); + Brush textBrush = Brushes.Black; + g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; + RectangleF rectF = new RectangleF(80, 80, 800 - 80, 800 - 80); + g.DrawString(bookStr, font, textBrush, rectF); + } + ShowImgForm imgFrom = new ShowImgForm(imageBg); + imgFrom.ShowDialog(); + } + } } } diff --git a/TEMUKJD/PDDForms/ProductSelectForms/PDDDBProdUserSelectForm.cs b/TEMUKJD/PDDForms/ProductSelectForms/PDDDBProdUserSelectForm.cs index e32d401..4a3f5e2 100644 --- a/TEMUKJD/PDDForms/ProductSelectForms/PDDDBProdUserSelectForm.cs +++ b/TEMUKJD/PDDForms/ProductSelectForms/PDDDBProdUserSelectForm.cs @@ -5220,7 +5220,7 @@ Content-Disposition: form-data; name=""pic_operations"" } public static string GetChanceGoodsList(ShopLoginInfo shop, string searchWord, List labels = null, string desc="", int page = 1, - long? cat1 = null, long? cat2 = null, int? price1 = null, int? price2 = null) + long? cat1 = null, long? cat2 = null, decimal? price1 = null, decimal? price2 = null) { //labels //newinfashion_new 当季新品 @@ -5245,7 +5245,7 @@ Content-Disposition: form-data; name=""pic_operations"" } if (string.IsNullOrEmpty(searchWord)) { - jObj["banner_type"] = 0; + //jObj["banner_type"] = 0; } else { diff --git a/TEMUKJD/PDDForms/ProductSelectForms/PDDGetChanceProdForm.Designer.cs b/TEMUKJD/PDDForms/ProductSelectForms/PDDGetChanceProdForm.Designer.cs index 15b9983..bd85cc7 100644 --- a/TEMUKJD/PDDForms/ProductSelectForms/PDDGetChanceProdForm.Designer.cs +++ b/TEMUKJD/PDDForms/ProductSelectForms/PDDGetChanceProdForm.Designer.cs @@ -40,8 +40,8 @@ namespace TemuKJD.PDDForms.ProductSelectForms this.splitContainer1 = new System.Windows.Forms.SplitContainer(); this.ucGroupBoxEx1 = new TemuKJD.UserComponent.UcGroupBoxEx(this.components); this.label11 = new System.Windows.Forms.Label(); - this.txtMaxPrice = new System.Windows.Forms.TextBox(); - this.textBox1 = new System.Windows.Forms.TextBox(); + this.txtSearchMaxPrice = new System.Windows.Forms.TextBox(); + this.txtSearchMinPrice = new System.Windows.Forms.TextBox(); this.label10 = new System.Windows.Forms.Label(); this.label7 = new System.Windows.Forms.Label(); this.cmbCat2 = new System.Windows.Forms.ComboBox(); @@ -149,8 +149,8 @@ namespace TemuKJD.PDDForms.ProductSelectForms 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.label11); - this.ucGroupBoxEx1.Controls.Add(this.txtMaxPrice); - this.ucGroupBoxEx1.Controls.Add(this.textBox1); + this.ucGroupBoxEx1.Controls.Add(this.txtSearchMaxPrice); + this.ucGroupBoxEx1.Controls.Add(this.txtSearchMinPrice); this.ucGroupBoxEx1.Controls.Add(this.label10); this.ucGroupBoxEx1.Controls.Add(this.label7); this.ucGroupBoxEx1.Controls.Add(this.cmbCat2); @@ -198,19 +198,19 @@ namespace TemuKJD.PDDForms.ProductSelectForms this.label11.TabIndex = 943; this.label11.Text = "至"; // - // txtMaxPrice + // txtSearchMaxPrice // - this.txtMaxPrice.Location = new System.Drawing.Point(704, 59); - this.txtMaxPrice.Name = "txtMaxPrice"; - this.txtMaxPrice.Size = new System.Drawing.Size(40, 23); - this.txtMaxPrice.TabIndex = 942; + this.txtSearchMaxPrice.Location = new System.Drawing.Point(704, 59); + this.txtSearchMaxPrice.Name = "txtSearchMaxPrice"; + this.txtSearchMaxPrice.Size = new System.Drawing.Size(40, 23); + this.txtSearchMaxPrice.TabIndex = 942; // - // textBox1 + // txtSearchMinPrice // - this.textBox1.Location = new System.Drawing.Point(644, 59); - this.textBox1.Name = "textBox1"; - this.textBox1.Size = new System.Drawing.Size(40, 23); - this.textBox1.TabIndex = 941; + this.txtSearchMinPrice.Location = new System.Drawing.Point(644, 59); + this.txtSearchMinPrice.Name = "txtSearchMinPrice"; + this.txtSearchMinPrice.Size = new System.Drawing.Size(40, 23); + this.txtSearchMinPrice.TabIndex = 941; // // label10 // @@ -1094,8 +1094,8 @@ namespace TemuKJD.PDDForms.ProductSelectForms private System.Windows.Forms.ComboBox cmbCat1; private System.Windows.Forms.Label label8; private System.Windows.Forms.Label label11; - private System.Windows.Forms.TextBox txtMaxPrice; - private System.Windows.Forms.TextBox textBox1; + private System.Windows.Forms.TextBox txtSearchMaxPrice; + private System.Windows.Forms.TextBox txtSearchMinPrice; private System.Windows.Forms.Label label10; } } \ No newline at end of file diff --git a/TEMUKJD/PDDForms/ProductSelectForms/PDDGetChanceProdForm.cs b/TEMUKJD/PDDForms/ProductSelectForms/PDDGetChanceProdForm.cs index 8f8c301..e11c6b8 100644 --- a/TEMUKJD/PDDForms/ProductSelectForms/PDDGetChanceProdForm.cs +++ b/TEMUKJD/PDDForms/ProductSelectForms/PDDGetChanceProdForm.cs @@ -417,7 +417,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms int totalPage = 1; int getCount = 0; int total = 2000; - while(getCount < searchCount && page <=totalPage) + while(getCount < searchCount && page <= totalPage) { if (shop == null) break; @@ -455,14 +455,14 @@ namespace TemuKJD.PDDForms.ProductSelectForms long? cat1 = null; long? cat2 = null; - int? price1 = null; - int? price2 = null; + decimal? price1 = null; + decimal? price2 = null; Invoke(new Action(() => { cat1 = lstChanceCateInfo.FirstOrDefault(c => c.cate_lvl == 1 && c.cate_name == cmbCat1.Text)?.cate_id; cat2 = lstChanceCateInfo.FirstOrDefault(c => cat1 != null && c.cate_lvl == 2 && c.cate_name == cmbCat2.Text)?.cate_id; - price1 = txtMinPrice.Text.Trim().ParseToInt(); - price2 = txtMaxPrice.Text.Trim().ParseToInt(); + price1 = txtSearchMinPrice.Text.Trim().ParseToDecimal(); + price2 = txtSearchMaxPrice.Text.Trim().ParseToDecimal(); if (price1 == 0 || price2 == 0) price1 = price2 = null; })); @@ -527,7 +527,12 @@ namespace TemuKJD.PDDForms.ProductSelectForms return; } total = BaseRegex.GetIntJson(ref rst, "total"); - totalPage = total / getResult.list.Count; + if (getResult.list.Count == 0) + totalPage = 0; + else + { + totalPage = Math.Ceiling(total * 1.0 / getResult.list.Count).ParseToInt(); + } page++; } @@ -583,7 +588,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms } private string GetChanceGoodsList(ShopLoginInfo shop, string searchWord, List labels = null, string desc="", int page = 1, - long? cat1 = null, long? cat2 = null, int? price1 = null, int? price2 = null) + long? cat1 = null, long? cat2 = null, decimal? price1 = null, decimal? price2 = null) { return PDDDBProdUserSelectForm.GetChanceGoodsList(shop, searchWord, labels, desc, page, cat1, cat2, price1, price2); } diff --git a/TEMUKJD/WXForms/ProductForms/WXDBProdUploadForm.Designer.cs b/TEMUKJD/WXForms/ProductForms/WXDBProdUploadForm.Designer.cs index bed6a02..5c9482b 100644 --- a/TEMUKJD/WXForms/ProductForms/WXDBProdUploadForm.Designer.cs +++ b/TEMUKJD/WXForms/ProductForms/WXDBProdUploadForm.Designer.cs @@ -32,12 +32,12 @@ namespace TemuKJD.WXForms.ProductForms 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 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 dataGridViewCellStyle17 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle18 = new System.Windows.Forms.DataGridViewCellStyle(); this.splitContainer1 = new System.Windows.Forms.SplitContainer(); this.ucGroupBoxEx2 = new TemuKJD.UserComponent.UcGroupBoxEx(this.components); this.chkSkipUploaded = new TemuKJD.UserComponent.UcCheckBox(this.components); @@ -201,6 +201,7 @@ namespace TemuKJD.WXForms.ProductForms this.ucGroupBoxEx2.Controls.Add(this.label8); this.ucGroupBoxEx2.Controls.Add(this.txtReplaceText); this.ucGroupBoxEx2.Controls.Add(this.label3); + this.ucGroupBoxEx2.Controls.Add(this.chkUpDraft); this.ucGroupBoxEx2.Controls.Add(this.chkHighestPriceSku); this.ucGroupBoxEx2.Controls.Add(this.label7); this.ucGroupBoxEx2.Controls.Add(this.txtWaitSeconds); @@ -1010,7 +1011,6 @@ namespace TemuKJD.WXForms.ProductForms this.splitContainer2.Panel2.Controls.Add(this.pbLoading); this.splitContainer2.Panel2.Controls.Add(this.label11); this.splitContainer2.Panel2.Controls.Add(this.txtSinglePriceAdd); - this.splitContainer2.Panel2.Controls.Add(this.chkUpDraft); this.splitContainer2.Panel2.Controls.Add(this.dgvSelectProduct); this.splitContainer2.Panel2.Padding = new System.Windows.Forms.Padding(0, 0, 4, 0); this.splitContainer2.Size = new System.Drawing.Size(1523, 362); @@ -1021,19 +1021,19 @@ namespace TemuKJD.WXForms.ProductForms // this.dgvShop.AllowUserToAddRows = false; this.dgvShop.AllowUserToDeleteRows = false; - dataGridViewCellStyle1.BackColor = System.Drawing.Color.WhiteSmoke; - this.dgvShop.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; + dataGridViewCellStyle13.BackColor = System.Drawing.Color.WhiteSmoke; + this.dgvShop.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle13; 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; + dataGridViewCellStyle14.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle14.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle14.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle14.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle14.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle14.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle14.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.dgvShop.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle14; this.dgvShop.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dgvShop.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.colSelect, @@ -1210,33 +1210,31 @@ namespace TemuKJD.WXForms.ProductForms // // chkUpDraft // - this.chkUpDraft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.chkUpDraft.AutoSize = true; - this.chkUpDraft.Location = new System.Drawing.Point(999, 31); + this.chkUpDraft.Location = new System.Drawing.Point(678, 91); this.chkUpDraft.Name = "chkUpDraft"; this.chkUpDraft.Size = new System.Drawing.Size(99, 21); this.chkUpDraft.TabIndex = 769; this.chkUpDraft.Text = "上传到草稿箱"; this.chkUpDraft.UseVisualStyleBackColor = true; - this.chkUpDraft.Visible = false; // // dgvSelectProduct // this.dgvSelectProduct.AllowUserToAddRows = false; this.dgvSelectProduct.AllowUserToDeleteRows = false; - dataGridViewCellStyle3.BackColor = System.Drawing.Color.WhiteSmoke; - this.dgvSelectProduct.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle3; + dataGridViewCellStyle15.BackColor = System.Drawing.Color.WhiteSmoke; + this.dgvSelectProduct.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle15; this.dgvSelectProduct.AutoRowNumber = true; this.dgvSelectProduct.BackgroundColor = System.Drawing.Color.White; this.dgvSelectProduct.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.dgvSelectProduct.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle4; + dataGridViewCellStyle16.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle16.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle16.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle16.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle16.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle16.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle16.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.dgvSelectProduct.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle16; this.dgvSelectProduct.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dgvSelectProduct.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.colCheck, @@ -1296,8 +1294,8 @@ namespace TemuKJD.WXForms.ProductForms // // colSupplierName // - dataGridViewCellStyle5.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.colSupplierName.DefaultCellStyle = dataGridViewCellStyle5; + dataGridViewCellStyle17.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.colSupplierName.DefaultCellStyle = dataGridViewCellStyle17; this.colSupplierName.Frozen = true; this.colSupplierName.HeaderText = "店铺名称"; this.colSupplierName.Name = "colSupplierName"; @@ -1375,8 +1373,8 @@ namespace TemuKJD.WXForms.ProductForms // // colProductName // - dataGridViewCellStyle6.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.colProductName.DefaultCellStyle = dataGridViewCellStyle6; + dataGridViewCellStyle18.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.colProductName.DefaultCellStyle = dataGridViewCellStyle18; this.colProductName.HeaderText = "商品标题"; this.colProductName.Name = "colProductName"; this.colProductName.ReadOnly = true; diff --git a/TEMUKJD/WXForms/ProductForms/WXDBProdUploadForm.cs b/TEMUKJD/WXForms/ProductForms/WXDBProdUploadForm.cs index 0a99cab..d2890d1 100644 --- a/TEMUKJD/WXForms/ProductForms/WXDBProdUploadForm.cs +++ b/TEMUKJD/WXForms/ProductForms/WXDBProdUploadForm.cs @@ -1286,7 +1286,7 @@ namespace TemuKJD.WXForms.ProductForms } // 检测是否有类目上传权限 - long leafCatId = (upProdParam.product.info.category.LastOrDefault()?.catId).ParseToLong(); + long leafCatId = (upProdParam.product.info.category.LastOrDefault()?.catId).ParseToLong(); //哲学经典著作 var cateUpCheckRst = WXUpload.batchCheckCategoryRelation(shop, leafCatId); if (!cateUpCheckRst.Contains("\"code\":0") && !cateUpCheckRst.Contains("\"success\":true")) { @@ -1333,7 +1333,6 @@ namespace TemuKJD.WXForms.ProductForms upProdParam.product.info.aiGenShortTitle = upProdParam.product.info.shortTitle; #endregion - #region 售后信息 var addressRst = WXUpload.getAddress(shop); if (!addressRst.Contains("\"code\":0") && !addressRst.Contains("\"success\":true")) @@ -1360,6 +1359,7 @@ namespace TemuKJD.WXForms.ProductForms upProdParam.product.info.expressInfo.templateId = BaseRegex.GetStringJson(ref expressRst, "templateId"); #endregion + #region 详情图 if (cell != null) { Invoke(new Action(() => @@ -1368,9 +1368,11 @@ namespace TemuKJD.WXForms.ProductForms })); } Thread.Sleep(Randomx.GetId(500, 800)); - #region 详情图 upProdParam.product.info.detail = new productDetailParam(); // 详情图 - foreach (var gallery_item in prodInfo.detail.galleries.Where(g => g.type == 2)) + var detailGalleries = prodInfo.detail.galleries.Where(g => g.type == 2).ToList(); + if (detailGalleries.Count == 0) + detailGalleries.Add(new gallery_item() { type = 2, url = prodInfo.detail.galleries.FirstOrDefault(g => g.type == 1)?.url }); + foreach (var gallery_item in detailGalleries) { var locationStr = UploadImg(shop, gallery_item.url, cell); if (!locationStr.Contains("\"success\":true")) @@ -1402,6 +1404,29 @@ namespace TemuKJD.WXForms.ProductForms { attr = productAttr.attr.FirstOrDefault(r => r.name == "填充物种类" || r.name == "填充物"); } + + // 书籍类目匹配 + if (upProdParam.product.info.category.FirstOrDefault()?.name == "图书" || prodInfo.detail.cats.FirstOrDefault() == "书籍/杂志/报纸") + { + if (propInfo.name == "出版社名称") + attr = productAttr.attr.FirstOrDefault(r => r.name == "出版社名称"); + else if (propInfo.name == "ISBN编号") + attr = productAttr.attr.FirstOrDefault(r => r.name == "ISBN版号/CN刊号"); + else if (propInfo.name == "书名") + attr = productAttr.attr.FirstOrDefault(r => r.name == "书名"); + else if (propInfo.name == "定价") + attr = productAttr.attr.FirstOrDefault(r => r.name == "定价"); + else if (propInfo.name == "作者") + attr = productAttr.attr.FirstOrDefault(r => r.name == "作者"); + else if (propInfo.name == "出版时间") + attr = productAttr.attr.FirstOrDefault(r => r.name == "出版时间"); + else if (propInfo.name == "版次") + attr = productAttr.attr.FirstOrDefault(r => r.name == "版次"); + else if (propInfo.name == "装帧类型") + attr = productAttr.attr.FirstOrDefault(r => r.name == "包装"); + else if (propInfo.name == "包册数") + attr = productAttr.attr.FirstOrDefault(r => r.name == "图书册数"); + } } if (attr == null) { @@ -1417,6 +1442,18 @@ namespace TemuKJD.WXForms.ProductForms { attrValue = propInfo.values.FirstOrDefault()?.value; } + if (upProdParam.product.info.category.FirstOrDefault()?.name == "图书" || prodInfo.detail.cats.FirstOrDefault() == "书籍/杂志/报纸") + { + if (attrValue.IsNullOrEmpty() && attr.type == "integer_unit" && (propInfo.values.FirstOrDefault()?.value).IsNumber()) + { + attrValue = propInfo.values.FirstOrDefault()?.value + " " + attr.value.Split(';').FirstOrDefault(); + } + if (attrValue.IsNullOrEmpty() && attr.name == "包装") + { + if (propInfo.values.FirstOrDefault()?.value == "平装-胶订") + attrValue = "平装"; + } + } if (attrValue.IsNullOrEmpty() && attr.isRequired == true) { if (attrValueLst.Contains("其他")) @@ -1481,10 +1518,6 @@ namespace TemuKJD.WXForms.ProductForms var attrValueLst = attr.value.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries).ToList(); string attrValue = ""; - if (attr.type == "string") - { - attrValue = "其他"; - } if (attrValue.IsNullOrEmpty() && attr.isRequired == true) { if (attrValueLst.Contains("其他")) @@ -1503,6 +1536,25 @@ namespace TemuKJD.WXForms.ProductForms } else attrValue = attrValueLst.Where(v => !"真丝、蚕丝、香云纱、羊绒、羊毛、羊羔绒、羊羔毛、羽绒、皮草".Contains(v)).OrderBy(x => Guid.NewGuid()).FirstOrDefault(); + + //书籍属性处理 + if (upProdParam.product.info.category.FirstOrDefault()?.name == "图书" || prodInfo.detail.cats.FirstOrDefault() == "书籍/杂志/报纸") + { + if (attr.name == "是否为单一书号丛书") + attrValue = "是"; + if (attr.name == "图书册数") + attrValue = "1 册"; + if (attr.name == "出版社名称") + attrValue = new List() { "技术出版社", "文化出版社", "美术出版社" }[Randomx.GetId(3)]; + if (attr.name == "作者") + attrValue = new List() { "李老师", "张老师", "王老师" }[Randomx.GetId(3)]; + if (attr.name == "包装") + attrValue = "平装"; + } + } + if (attrValue.IsNullOrEmpty() && attr.type == "string") + { + attrValue = "其他"; } if (attr.type == "decimal4_unit" || attr.type == "integer_unit") { @@ -1535,6 +1587,7 @@ namespace TemuKJD.WXForms.ProductForms } #endregion + #region sku规格属性 if (cell != null) { @@ -1545,8 +1598,17 @@ namespace TemuKJD.WXForms.ProductForms } Thread.Sleep(1000); - #region sku规格属性 upProdParam.product.info.productSaleAttrs = new List(); + if (prodInfo.detail.sku == null) + prodInfo.detail.sku = new List(); + if (prodInfo.detail.sku.Count == 0) + prodInfo.detail.sku.Add(new sku_item() { spec = new List() }); + if (prodInfo.detail.sku.FirstOrDefault().spec == null) + prodInfo.detail.sku.FirstOrDefault().spec = new List(); + if (prodInfo.detail.sku.FirstOrDefault().spec.Count == 0) + prodInfo.detail.sku.FirstOrDefault().spec.Add(new spec_item() { parent_name = "规格", spec_name = "默认" }); + if (prodInfo.detail.sku.FirstOrDefault().thumb_url.IsNullOrEmpty()) + prodInfo.detail.sku.FirstOrDefault().thumb_url = prodInfo.detail.galleries.FirstOrDefault(g => g.type == 1)?.url; if (prodInfo.detail.sku.FirstOrDefault()?.spec?.Count > 0) { productSaleAttrParam attrParam = new productSaleAttrParam() @@ -1692,6 +1754,76 @@ namespace TemuKJD.WXForms.ProductForms } #endregion + #region 书籍类生成书籍图片 + //qualificationList + if (1 == 1) + { + if (cell != null) + { + Invoke(new Action(() => + { + cell.Value = "正在生成图书专有信息"; + })); + } + + string publisher = "出版社:" + new List() { "技术出版社", "文化出版社", "美术出版社" }[Randomx.GetId(3)]; + string isbn = "ISBN:"; + string bookName = "书名:"; + string bookPrice = "定价:" + upProdParam.product.productSkus.Max(s => s.productSkuInfo.salePrice) * 0.01; + string author = "作者:王老师"; + string publishTime = "出版时间:" + DateTime.Now.AddMonths(-3); + string edition = "版次:1"; + string binding = "装帧:平装"; + + foreach (var propParam in upProdParam.product.info.param) + { + if (propParam.categorys[0].name.Contains("出版社名称")) + publisher = "出版社:" + propParam.categorys[1].name; + else if (propParam.categorys[0].name.Contains("ISBN版号/CN刊号")) + isbn = "ISBN:" + propParam.categorys[1].name; + else if (propParam.categorys[0].name.Contains("书名")) + bookName = "书名:" + propParam.categorys[1].name; + else if (propParam.categorys[0].name.Contains("定价")) + bookPrice = "定价:" + propParam.categorys[1].name; + else if (propParam.categorys[0].name.Contains("作者")) + author = "作者:" + propParam.categorys[1].name; + else if (propParam.categorys[0].name.Contains("出版时间")) + publishTime = "出版时间:" + propParam.categorys[1].name; + else if (propParam.categorys[0].name.Contains("版次")) + edition = "版次:" + propParam.categorys[1].name; + else if (propParam.categorys[0].name.Contains("包装")) + binding = "装帧:" + propParam.categorys[1].name; + } + + var bookStr = publisher + "\r\n" + "\r\n" + + isbn + "\r\n" + "\r\n" + + bookName + "\r\n" + "\r\n" + + bookPrice + "\r\n" + "\r\n" + + author + "\r\n" + "\r\n" + + publishTime + "\r\n" + "\r\n" + + edition + "\r\n" + "\r\n" + + binding; + + var bookImg = new Bitmap(800, 800); + using (Graphics g = Graphics.FromImage(bookImg)) + { + g.Clear(Color.White); + //Font font = new Font("宋体", 15, FontStyle.Bold); + Font font = new Font("微软雅黑", 15, FontStyle.Regular); + Brush textBrush = Brushes.Black; + g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; + RectangleF rectF = new RectangleF(80, 80, 800 - 80, 800 - 80); + g.DrawString(bookStr, font, textBrush, rectF); + } + + Thread.Sleep(Randomx.GetId(500, 800)); + var locationStr = UploadImg(shop, bookImg, cell); + if (!locationStr.Contains("\"success\":true")) + return locationStr; + var location = BaseRegex.GetStringJson(ref locationStr, "Location"); + upProdParam.product.info.qualificationList.Add(new qualificationParam() { qualificationId = "1111485", qualificationUrl = new List() { location }, }); + } + #endregion if (cell != null) { @@ -1738,6 +1870,8 @@ namespace TemuKJD.WXForms.ProductForms if (!uploadProdRst.Contains("\"code\":0") && !uploadProdRst.Contains("\"success\":true")) { var error = BaseRegex.GetStringJson(ref uploadProdRst, "msg"); + if (string.IsNullOrEmpty(error)) + error = BaseRegex.GetStringJson(ref uploadProdRst, "errmsg"); if (string.IsNullOrEmpty(error)) error = uploadProdRst; return "{\"success\":false,\"draftId\":" + upProdParam.product.productKey.productId + ",\"status\":\"草稿箱\",\"errMsg\":\"上架失败 " + error + "\"}"; @@ -1782,11 +1916,36 @@ namespace TemuKJD.WXForms.ProductForms return "{\"success\":true,\"draftId\":" + upProdParam.product.productKey.productId + ",\"status\":\"已上传\",\"msg\":\"上传成功\"}"; } - - - - + + public string UploadImg(ShopLoginInfo shop, string img_url, DataGridViewCell cell = null) + { + string getImgError; + var image = GetHtml.GetUrlImg(img_url.Replace("https://", "http://"), out getImgError); + if (image == null) + image = new Bitmap(800, 800); + var imageBg = new Bitmap(image.Width, image.Height); + if (!string.IsNullOrEmpty(getImgError) || image == null) + { + return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"初始化图片上传失败\"}"; + } + try + { + using (Graphics g = Graphics.FromImage(imageBg)) + { + g.DrawImage(image, new Rectangle(0, 0, imageBg.Width, imageBg.Height), 0, 0, image.Width, image.Height, GraphicsUnit.Pixel); + } + } + catch (Exception ex) + { + return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"" + "修改图片失败 " + ex.Message + "\"}"; + } + return UploadImg(shop, imageBg, cell); + } + + + + public string UploadImg(ShopLoginInfo shop, Bitmap img, DataGridViewCell cell = null) { var upImgAuthRst = WXUpload.getUploadTempImgAuth(shop); for (int i = 0; i < 10 && upImgAuthRst.Contains("LogicError"); i++) @@ -1814,23 +1973,12 @@ namespace TemuKJD.WXForms.ProductForms string imgBase64 = ""; //------------------------------------------------------------------------------------------------------------------------------------- - //生成详情图base64字符串 - string getImgError; - var image = GetHtml.GetUrlImg(img_url.Replace("https://", "http://"), out getImgError); - var imageBg = new Bitmap(image.Width, image.Height); - if (!string.IsNullOrEmpty(getImgError) || image == null) - { - return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"初始化图片上传失败\"}"; - } + //生成图片base64字符串 try { - using (Graphics g = Graphics.FromImage(imageBg)) - { - g.DrawImage(image, new Rectangle(0, 0, imageBg.Width, imageBg.Height), 0, 0, image.Width, image.Height, GraphicsUnit.Pixel); - } using (MemoryStream memoryStream = new MemoryStream()) { - imageBg.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Jpeg); + img.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Jpeg); byte[] imageBytes = memoryStream.ToArray(); imgBase64 = Convert.ToBase64String(imageBytes); } @@ -1841,7 +1989,7 @@ namespace TemuKJD.WXForms.ProductForms } //------------------------------------------------------------------------------------------------------------------------------------- - //上传详情图,获取图片路径 + //上传图片,获取图片路径 var upImgRst = WXUpload.adtimageupload(shop, imgBase64, disK, disT, ext).ParseToString(); var location = BaseRegex.GetStringJson(ref upImgRst, "Location"); if (string.IsNullOrEmpty(location)) @@ -2270,6 +2418,11 @@ Content-Type: image/jpeg string referer = "https://store.weixin.qq.com/shop/goods/entry"; string body = @"{""categoryInfo"":{""categories"":[{""id"":""" + catId + @"""}]},""brandIdList"":[],""leafCategoryId"":""" + catId + @""",""reuse"":0,""applyType"":1}"; var result = WXHttpResponseBLL.WeiXinPostResponse(shop, url, body, referer); + //{"categoryInfo":{"categories":[{"id":10000257},{"id":10000245},{"id":112888}],"categoryDeposit":"10000.00","isNewApplyCat":true,"licenseGroupList":[{"licenseGroupId":"17","license":{"licenseId":"5","cosIdList":["1768635607165-orc0V2WjFHdNvjNnk967_g14awFw-7487"],"licenseFieldList":[{"key":"audit_license_no","value":"新出发皖字第1027号"},{"key":"audit_license_validty_period","value":"2029-04-30"}],"isReuse":true}}],"ruleVersion":5234,"certificate":[]},"brandIdList":[],"leafCategoryId":112888,"reuse":0,"applyType":"normalApply"} + //{"code":0,"baseResp":{"errcode":0,"errmsg":"ok"},"auditId":"8362856529"} + //string body = @"{""categoryInfo"":{""categories"":[{""id"":10000257},{""id"":10000245},{""id"":112888}],""categoryDeposit"":""10000.00"",""isNewApplyCat"":true,""licenseGroupList"":[{""licenseGroupId"":""17"",""license"":{""licenseId"":""5"",""cosIdList"":[""1768635607165-orc0V2WjFHdNvjNnk967_g14awFw-7487""],""licenseFieldList"":[{""key"":""audit_license_no"",""value"":""新出发皖字第1027号""},{""key"":""audit_license_validty_period"",""value"":""2029-04-30""}],""isReuse"":true}}],""ruleVersion"":5234,""certificate"":[]},""brandIdList"":[],""leafCategoryId"":112888,""reuse"":0,""applyType"":""normalApply""}"; + // request.Referer = "https://store.weixin.qq.com/shop/brandAndCat/category/apply?defaultCategoryIds=%5B%2210000257%22%2C%2210000245%22%2C%22112888%22%5D&source=goods&type=apply"; + return result; }