商品可以选择类目再进行上传

This commit is contained in:
wule committed 2025-08-20 14:58:43 +08:00
1 parent e73359e283
commit 7d5daf27ad
8 files changed
+531 -165

No files matched your search

@@ -31,48 +31,155 @@ namespace TemuKJD.KJDForms.ProductSelectForms
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DbProductCategorySearch));
this.panel2 = new System.Windows.Forms.Panel();
this.label1 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.txtProductName = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.lblNewCategory = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.btnSearch = new DevComponents.DotNetBar.PanelEx();
this.listBox1 = new System.Windows.Forms.ListBox();
this.lblOldCategory = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.btnSave = new DevComponents.DotNetBar.PanelEx();
this.txtSearchText = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.panel2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
//
// panel2
//
this.panel2.BackColor = System.Drawing.Color.White;
this.panel2.Controls.Add(this.txtProductName);
this.panel2.Controls.Add(this.label3);
this.panel2.Controls.Add(this.pictureBox1);
this.panel2.Controls.Add(this.lblNewCategory);
this.panel2.Controls.Add(this.label4);
this.panel2.Controls.Add(this.btnSearch);
this.panel2.Controls.Add(this.listBox1);
this.panel2.Controls.Add(this.lblOldCategory);
this.panel2.Controls.Add(this.label2);
this.panel2.Controls.Add(this.btnSave);
this.panel2.Controls.Add(this.textBox1);
this.panel2.Controls.Add(this.txtSearchText);
this.panel2.Controls.Add(this.label1);
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel2.Location = new System.Drawing.Point(1, 33);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(798, 366);
this.panel2.Size = new System.Drawing.Size(898, 330);
this.panel2.TabIndex = 1;
//
// label1
// txtProductName
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(37, 48);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(53, 12);
this.label1.TabIndex = 0;
this.label1.Text = "类目搜索";
this.txtProductName.Location = new System.Drawing.Point(181, 31);
this.txtProductName.Multiline = true;
this.txtProductName.Name = "txtProductName";
this.txtProductName.ReadOnly = true;
this.txtProductName.Size = new System.Drawing.Size(675, 38);
this.txtProductName.TabIndex = 504;
//
// textBox1
// label3
//
this.textBox1.Location = new System.Drawing.Point(93, 45);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(653, 21);
this.textBox1.TabIndex = 1;
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(124, 34);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(65, 12);
this.label3.TabIndex = 503;
this.label3.Text = "商品标题:";
//
// pictureBox1
//
this.pictureBox1.Location = new System.Drawing.Point(33, 32);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(86, 86);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pictureBox1.TabIndex = 502;
this.pictureBox1.TabStop = false;
//
// lblNewCategory
//
this.lblNewCategory.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.lblNewCategory.AutoSize = true;
this.lblNewCategory.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
this.lblNewCategory.Location = new System.Drawing.Point(103, 277);
this.lblNewCategory.Name = "lblNewCategory";
this.lblNewCategory.Size = new System.Drawing.Size(41, 12);
this.lblNewCategory.TabIndex = 495;
this.lblNewCategory.Text = "新类目";
//
// label4
//
this.label4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(33, 277);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(77, 12);
this.label4.TabIndex = 494;
this.label4.Text = "商品新类目:";
//
// btnSearch
//
this.btnSearch.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnSearch.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
this.btnSearch.Cursor = System.Windows.Forms.Cursors.Hand;
this.btnSearch.DisabledBackColor = System.Drawing.Color.Empty;
this.btnSearch.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnSearch.Location = new System.Drawing.Point(794, 101);
this.btnSearch.Name = "btnSearch";
this.btnSearch.Size = new System.Drawing.Size(62, 21);
this.btnSearch.Style.Alignment = System.Drawing.StringAlignment.Center;
this.btnSearch.Style.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
this.btnSearch.Style.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
this.btnSearch.Style.BorderColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder;
this.btnSearch.Style.BorderDashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
this.btnSearch.Style.BorderSide = DevComponents.DotNetBar.eBorderSide.None;
this.btnSearch.Style.ForeColor.Color = System.Drawing.Color.White;
this.btnSearch.Style.GradientAngle = 90;
this.btnSearch.StyleMouseOver.Alignment = System.Drawing.StringAlignment.Center;
this.btnSearch.StyleMouseOver.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(102)))), ((int)(((byte)(255)))));
this.btnSearch.StyleMouseOver.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(102)))), ((int)(((byte)(255)))));
this.btnSearch.TabIndex = 487;
this.btnSearch.Text = "搜索";
this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
//
// listBox1
//
this.listBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.listBox1.FormattingEnabled = true;
this.listBox1.ItemHeight = 12;
this.listBox1.Location = new System.Drawing.Point(181, 122);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(675, 136);
this.listBox1.TabIndex = 483;
this.listBox1.SelectedIndexChanged += new System.EventHandler(this.listBox1_SelectedIndexChanged);
//
// lblOldCategory
//
this.lblOldCategory.AutoSize = true;
this.lblOldCategory.Location = new System.Drawing.Point(183, 77);
this.lblOldCategory.Name = "lblOldCategory";
this.lblOldCategory.Size = new System.Drawing.Size(41, 12);
this.lblOldCategory.TabIndex = 482;
this.lblOldCategory.Text = "原类目";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(123, 77);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(65, 12);
this.label2.TabIndex = 481;
this.label2.Text = "商品类目:";
//
// btnSave
//
this.btnSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnSave.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
this.btnSave.Cursor = System.Windows.Forms.Cursors.Hand;
this.btnSave.DisabledBackColor = System.Drawing.Color.Empty;
this.btnSave.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnSave.Location = new System.Drawing.Point(670, 288);
this.btnSave.Location = new System.Drawing.Point(780, 274);
this.btnSave.Name = "btnSave";
this.btnSave.Size = new System.Drawing.Size(76, 26);
this.btnSave.Style.Alignment = System.Drawing.StringAlignment.Center;
@@ -88,21 +195,42 @@ namespace TemuKJD.KJDForms.ProductSelectForms
this.btnSave.StyleMouseOver.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(102)))), ((int)(((byte)(255)))));
this.btnSave.TabIndex = 477;
this.btnSave.Text = "保存类目";
this.btnSave.Visible = false;
this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
//
// txtSearchText
//
this.txtSearchText.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txtSearchText.Location = new System.Drawing.Point(181, 101);
this.txtSearchText.MaxLength = 50;
this.txtSearchText.Name = "txtSearchText";
this.txtSearchText.Size = new System.Drawing.Size(611, 21);
this.txtSearchText.TabIndex = 1;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(124, 106);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(65, 12);
this.label1.TabIndex = 0;
this.label1.Text = "类目搜索:";
//
// DbProductCategorySearch
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 400);
this.ClientSize = new System.Drawing.Size(900, 364);
this.Controls.Add(this.panel2);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "DbProductCategorySearch";
this.Text = "商品类目查询";
this.TitleText = "商品类目查询";
this.Load += new System.EventHandler(this.DbProductCategorySearch_Load);
this.Controls.SetChildIndex(this.panel2, 0);
this.panel2.ResumeLayout(false);
this.panel2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false);
}
@@ -110,8 +238,17 @@ namespace TemuKJD.KJDForms.ProductSelectForms
private System.Windows.Forms.Panel panel2;
#endregion
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox txtSearchText;
private System.Windows.Forms.Label label1;
private DevComponents.DotNetBar.PanelEx btnSave;
private System.Windows.Forms.Label lblOldCategory;
private System.Windows.Forms.Label label2;
private DevComponents.DotNetBar.PanelEx btnSearch;
private System.Windows.Forms.ListBox listBox1;
private System.Windows.Forms.Label lblNewCategory;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox txtProductName;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.PictureBox pictureBox1;
}
}
@@ -1,4 +1,8 @@
using System;
using AllBase;
using AllBase.Model.Result;
using NaiBa.Util.Extension;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
@@ -8,14 +12,162 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using TemuKJD.KJDForms.BaseForms;
using Work;
namespace TemuKJD.KJDForms.ProductSelectForms
{
public partial class DbProductCategorySearch : LRBaseForm
{
public DbProductCategorySearch()
ShopLoginInfo Shop;
TemuDBProductSelect ProdSelect;
SetProductSelectNotesType SelectType;
//string ChangeCatId = "";
//string ChangeCatName = "";
Dictionary<string, string> cateIdNameMap = new Dictionary<string, string>();
public DbProductCategorySearch(ShopLoginInfo shop, TemuDBProductSelect prodSelect, SetProductSelectNotesType selectType = SetProductSelectNotesType.DbProduct)
{
InitializeComponent();
Shop = shop;
SelectType = selectType;
ProdSelect = prodSelect;
}
private void DbProductCategorySearch_Load(object sender, EventArgs e)
{
this.listBox1.Visible = false;
this.lblOldCategory.Text = string.IsNullOrWhiteSpace(ProdSelect.change_cat_name) ? ProdSelect.cat_name : ProdSelect.change_cat_name;
this.lblNewCategory.Text = "";
this.pictureBox1.ImageLocation = ProdSelect.main_img.Replace("https", "http");
this.txtProductName.Text = ProdSelect.product_name;
}
private void btnSave_Click(object sender, EventArgs e)
{
var url = BaseClass.BuildObjString("product/mdy_product_category");
if (this.SelectType == SetProductSelectNotesType.ThirdProduct)
url = BaseClass.BuildObjString("product_third/mdy_product_category");
var data = UserLogin.GetSignaturex() +
"&db_id=" + this.ProdSelect.out_product_Id;
data += "&change_cat_name=" + this.lblNewCategory.Text.Trim();
data += "&change_cat_id=" + this.cateIdNameMap[this.lblNewCategory.Text.Trim()].Trim();
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"))
{
BaseMsgForm.ShowError("商品类目编辑失败,请重试!" + BaseRegex.GetStringJson(ref html, "msg"));
}
else
{
ProdSelect.change_cat_name = this.lblNewCategory.Text.Trim();
ProdSelect.change_cat_id = this.cateIdNameMap[this.lblNewCategory.Text.Trim()].Trim();
this.OnSaveComplete(ProdSelect);
this.Close();
}
}
private void btnSearch_Click(object sender, EventArgs e)
{
if (string.IsNullOrWhiteSpace(txtSearchText.Text))
{
BaseMsgForm.ShowError("搜索项目不能为空");
return;
}
if (Shop.LoginStatus2 != "国际版在线")
{
BaseMsgForm.ShowError("查询失败 店铺已掉线");
return;
}
this.listBox1.Items.Clear();
cateIdNameMap.Clear();
Task.Run(() =>
{
string html = SearchCategory(Shop, this.txtSearchText.Text.Trim());
if (html.Contains("\"success\":true"))
{
Dictionary<int, TemuCat> catIdDic = new Dictionary<int, TemuCat>();
try
{
//var catObj = JObject.Parse(html)["result"]["categoryPaths"][0];
foreach (var catObj in JObject.Parse(html)["result"]["categoryPaths"])
{
catIdDic[1] = catObj["cat1NodeVO"].IsNullOrEmpty() ?
null : JsonHelper.DeserializeJsonToObject<TemuCat>(catObj["cat1NodeVO"].ToString());
catIdDic[2] = catObj["cat2NodeVO"].IsNullOrEmpty() ?
null : JsonHelper.DeserializeJsonToObject<TemuCat>(catObj["cat2NodeVO"].ToString());
catIdDic[3] = catObj["cat3NodeVO"].IsNullOrEmpty() ?
null : JsonHelper.DeserializeJsonToObject<TemuCat>(catObj["cat3NodeVO"].ToString());
catIdDic[4] = catObj["cat4NodeVO"].IsNullOrEmpty() ?
null : JsonHelper.DeserializeJsonToObject<TemuCat>(catObj["cat4NodeVO"].ToString());
catIdDic[5] = catObj["cat5NodeVO"].IsNullOrEmpty() ?
null : JsonHelper.DeserializeJsonToObject<TemuCat>(catObj["cat5NodeVO"].ToString());
catIdDic[6] = catObj["cat6NodeVO"].IsNullOrEmpty() ?
null : JsonHelper.DeserializeJsonToObject<TemuCat>(catObj["cat6NodeVO"].ToString());
catIdDic[7] = catObj["cat7NodeVO"].IsNullOrEmpty() ?
null : JsonHelper.DeserializeJsonToObject<TemuCat>(catObj["cat7NodeVO"].ToString());
catIdDic[8] = catObj["cat8NodeVO"].IsNullOrEmpty() ?
null : JsonHelper.DeserializeJsonToObject<TemuCat>(catObj["cat8NodeVO"].ToString());
catIdDic[9] = catObj["cat9NodeVO"].IsNullOrEmpty() ?
null : JsonHelper.DeserializeJsonToObject<TemuCat>(catObj["cat9NodeVO"].ToString());
catIdDic[10] = catObj["cat10NodeVO"].IsNullOrEmpty() ?
null : JsonHelper.DeserializeJsonToObject<TemuCat>(catObj["cat10NodeVO"].ToString());
string changeCatId = "";
string changeCatName = "";
for (int i = 1; i <= 10; i++)
{
changeCatId += catIdDic[i]?.catId + ">";
changeCatName += catIdDic[i]?.catName + ">";
}
changeCatId = changeCatId.Trim('>');
changeCatName = changeCatName.Trim('>');
cateIdNameMap[changeCatName] = changeCatId;
Invoke(new Action(() =>
{
listBox1.Visible = true;
this.listBox1.Items.Add(changeCatName);
}));
}
}
catch (Exception ex)
{
Invoke(new Action(() =>
{
BaseMsgForm.ShowError("查询失败 " + ex.Message);
}));
}
}
else
{
string err = BaseRegex.GetStringJson(ref html, "errorMsg");
if (string.IsNullOrEmpty(err))
err = BaseRegex.GetStringJson(ref html, "error_msg");
if (err == null)
err = "";
Invoke(new Action(() =>
{
BaseMsgForm.ShowError("查询失败 " + err.Replace("Invalid Login State", "店铺已掉线"));
}));
}
});
}
private string SearchCategory(ShopLoginInfo shop, string searchStr)
{
string url = "https://agentseller.temu.com/anniston-agent-seller/category/search";
string body = @"{""searchText"":""" + searchStr + @"""}";
string refere = "https://agentseller.temu.com/goods/create/category";
return KJDHttpResponse.PostResponse2(shop, url, body, refere);
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
this.lblNewCategory.Text = listBox1.SelectedItem.ToString();
}
}
}