1商品调价功能 2单品参加活动功能优化

This commit is contained in:
wule committed 2025-10-28 18:44:08 +08:00
1 parent ab33a9c0c0
commit 0d3ab6321e
16 files changed
+2260 -421

No files matched your search

@@ -112,6 +112,8 @@
this.chkAddPrice = new TemuKJD.UserComponent.UcCheckBox(this.components);
this.chkEnglishProdName = new TemuKJD.UserComponent.UcCheckBox(this.components);
this.splitContainer2 = new System.Windows.Forms.SplitContainer();
this.pnlError = new System.Windows.Forms.Panel();
this.lblError = new System.Windows.Forms.Label();
this.pbLoading = new System.Windows.Forms.PictureBox();
this.lblCustomImgNum = new System.Windows.Forms.Label();
this.numSeconds = new System.Windows.Forms.NumericUpDown();
@@ -147,8 +149,6 @@
this.colOpResult = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.ucSplitPage1 = new TemuKJD.UserControls.UcSplitPage();
this.statusBar = new TemuKJD.UserControls.StatusBarUserControl();
this.pnlError = new System.Windows.Forms.Panel();
this.lblError = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
@@ -172,10 +172,10 @@
this.splitContainer2.Panel1.SuspendLayout();
this.splitContainer2.Panel2.SuspendLayout();
this.splitContainer2.SuspendLayout();
this.pnlError.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pbLoading)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numSeconds)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.dgvSelectProduct)).BeginInit();
this.pnlError.SuspendLayout();
this.SuspendLayout();
//
// splitContainer1
@@ -1302,15 +1302,14 @@
//
this.chkEnglishProdName.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.chkEnglishProdName.AutoSize = true;
this.chkEnglishProdName.Checked = true;
this.chkEnglishProdName.CheckState = System.Windows.Forms.CheckState.Checked;
this.chkEnglishProdName.Location = new System.Drawing.Point(1179, 73);
this.chkEnglishProdName.Location = new System.Drawing.Point(1203, 73);
this.chkEnglishProdName.Margin = new System.Windows.Forms.Padding(6, 0, 0, 0);
this.chkEnglishProdName.Name = "chkEnglishProdName";
this.chkEnglishProdName.Size = new System.Drawing.Size(99, 21);
this.chkEnglishProdName.Size = new System.Drawing.Size(75, 21);
this.chkEnglishProdName.TabIndex = 679;
this.chkEnglishProdName.Text = "英文标题翻译";
this.chkEnglishProdName.Text = "英文标题";
this.chkEnglishProdName.UseVisualStyleBackColor = true;
this.chkEnglishProdName.CheckedChanged += new System.EventHandler(this.chkEnglishProdName_CheckedChanged);
//
// splitContainer2
//
@@ -1340,6 +1339,26 @@
this.splitContainer2.SplitterDistance = 505;
this.splitContainer2.TabIndex = 0;
//
// pnlError
//
this.pnlError.Anchor = System.Windows.Forms.AnchorStyles.Top;
this.pnlError.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(244)))), ((int)(((byte)(224)))));
this.pnlError.Controls.Add(this.lblError);
this.pnlError.Location = new System.Drawing.Point(650, 95);
this.pnlError.Name = "pnlError";
this.pnlError.Size = new System.Drawing.Size(259, 120);
this.pnlError.TabIndex = 488;
this.pnlError.Visible = false;
//
// lblError
//
this.lblError.ForeColor = System.Drawing.Color.Red;
this.lblError.Location = new System.Drawing.Point(32, 26);
this.lblError.Name = "lblError";
this.lblError.Size = new System.Drawing.Size(200, 69);
this.lblError.TabIndex = 0;
this.lblError.Text = "错误tip";
//
// pbLoading
//
this.pbLoading.Anchor = System.Windows.Forms.AnchorStyles.None;
@@ -1718,26 +1737,6 @@
this.statusBar.Size = new System.Drawing.Size(1558, 25);
this.statusBar.TabIndex = 5;
//
// pnlError
//
this.pnlError.Anchor = System.Windows.Forms.AnchorStyles.Top;
this.pnlError.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(244)))), ((int)(((byte)(224)))));
this.pnlError.Controls.Add(this.lblError);
this.pnlError.Location = new System.Drawing.Point(650, 95);
this.pnlError.Name = "pnlError";
this.pnlError.Size = new System.Drawing.Size(259, 120);
this.pnlError.TabIndex = 488;
this.pnlError.Visible = false;
//
// lblError
//
this.lblError.ForeColor = System.Drawing.Color.Red;
this.lblError.Location = new System.Drawing.Point(32, 26);
this.lblError.Name = "lblError";
this.lblError.Size = new System.Drawing.Size(200, 69);
this.lblError.TabIndex = 0;
this.lblError.Text = "错误tip";
//
// DbProductSelectListManageForm
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
@@ -1778,10 +1777,10 @@
this.splitContainer2.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit();
this.splitContainer2.ResumeLayout(false);
this.pnlError.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pbLoading)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numSeconds)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dgvSelectProduct)).EndInit();
this.pnlError.ResumeLayout(false);
this.ResumeLayout(false);
}
@@ -1095,6 +1095,15 @@ namespace TemuKJD.KJDForms.ProductSelectForms
string endWords = "";
if (this.chkFission.Checked)
{
string originProductName = dbProd.product_name;
string joinText = ",";
//如果有裂变词并且勾选了英文标题,则删除中文标题全部使用英文裂变词组成新的标题并写入英文标题
if (chkEnglishProdName.Checked && dbProd.fission_words.Length > 10 && CountChineseCharacters(dbProd.fission_words) < 10)
{
originProductName = "";
joinText = ", ";
}
// 头词
if (chkHeadWords.Checked)
{
@@ -1131,14 +1140,14 @@ namespace TemuKJD.KJDForms.ProductSelectForms
// 标题部分打乱
List<string> fissionLst = new List<string>();
fissionLst.AddRange(dbProd.fission_words.ParseToString().Split(new string[] { "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries));
string centerWords = ",";
string centerWords = joinText;
while (fissionLst.Count > 0)
{
int id = Randomx.GetId(fissionLst.Count);
var fissionTxt = fissionLst[id];
fissionLst.RemoveAt(id);
var allTxt = headWords + dbProd.product_name + centerWords + fissionTxt + "," + endWords;
//var allTxt = dbProd.product_name + centerWords + fissionTxt + ",";
var allTxt = headWords + originProductName + centerWords + fissionTxt + joinText + endWords;
//var allTxt = originProductName + centerWords + fissionTxt + joinText;
byte[] bytes = Encoding.GetEncoding("gb2312").GetBytes(allTxt);
int titleLength = allTxt.Length;
if (chkLongTitle.Checked)
@@ -1155,9 +1164,9 @@ namespace TemuKJD.KJDForms.ProductSelectForms
break;
}
}
centerWords += fissionTxt + ",";
centerWords += fissionTxt + joinText;
}
string centerName = dbProd.product_name + centerWords.ParseToString();
string centerName = originProductName + centerWords.ParseToString();
// 标题完全打乱
if (chkReFissionAllProdName.Checked)
@@ -1169,13 +1178,13 @@ namespace TemuKJD.KJDForms.ProductSelectForms
while (centerNameLst.Count > 0)
{
int id = Randomx.GetId(centerNameLst.Count);
newCenterName += centerNameLst[id] + ",";
newCenterName += centerNameLst[id] + joinText;
centerNameLst.RemoveAt(id);
}
centerName = newCenterName;
}
prodParam.productName = (headWords + centerName + endWords).Trim(',');
//prodParam.productName = centerName.Trim(',');
prodParam.productName = (headWords + centerName + endWords).Trim(',', ',', ' ');
//prodParam.productName = centerName.Trim(',', ',', ' ');
}
prodParam.productNonAuditExtAttrReq = new ProductNonAuditExtAttrReq()
@@ -1736,41 +1745,57 @@ namespace TemuKJD.KJDForms.ProductSelectForms
//{
//}
//翻译英文标题
//英文标题
if (chkEnglishProdName.Checked)
{
var realName = AdminProductPriceCheckForm.RestoreProductName(prodParam.productName);
var transRst = translate(shop, realName);
var transRstTxt = BaseRegex.GetStringJson(ref transRst, "dst");
if (!string.IsNullOrEmpty(transRstTxt))
{
var transEndWords = "";
if (realName.EndsWith("不同的搭配场景") || realName.EndsWith("不同的搭配风格") ||
realName.EndsWith("different matching scenarios") || realName.EndsWith("different matching styles"))
{
transEndWords = transRstTxt.Substring(Math.Max(0, transRstTxt.LastIndexOf(',')));
}
while ((transRstTxt.Replace(transEndWords, "") + transEndWords).Length > 500)
{
transRstTxt = transRstTxt.Substring(0, Math.Max(1, transRstTxt.LastIndexOf(',')));
}
if (!string.IsNullOrEmpty(transEndWords))
transRstTxt = (transRstTxt.Replace(transEndWords, "") + transEndWords);
#region 调用百度翻译翻译英文标题 暂时作废
//var realName = AdminProductPriceCheckForm.RestoreProductName(prodParam.productName);
//var transRst = translate(shop, realName);
//var transRstTxt = BaseRegex.GetStringJson(ref transRst, "dst");
//if (!string.IsNullOrEmpty(transRstTxt))
//{
// var transEndWords = "";
// if (realName.EndsWith("不同的搭配场景") || realName.EndsWith("不同的搭配风格") ||
// realName.EndsWith("different matching scenarios") || realName.EndsWith("different matching styles"))
// {
// transEndWords = transRstTxt.Substring(Math.Max(0, transRstTxt.LastIndexOf(',')));
// }
// while ((transRstTxt.Replace(transEndWords, "") + transEndWords).Length > 500)
// {
// transRstTxt = transRstTxt.Substring(0, Math.Max(1, transRstTxt.LastIndexOf(',')));
// }
// if (!string.IsNullOrEmpty(transEndWords))
// transRstTxt = (transRstTxt.Replace(transEndWords, "") + transEndWords);
prodParam.productI18nReqs = new List<productI18nParam>();
productI18nParam productI18nEn = new productI18nParam
{
language = "en",
productName = transRstTxt,
};
prodParam.productI18nReqs.Add(productI18nEn);
}
else
// prodParam.productI18nReqs = new List<productI18nParam>();
// productI18nParam productI18nEn = new productI18nParam
// {
// language = "en",
// productName = transRstTxt,
// };
// prodParam.productI18nReqs.Add(productI18nEn);
//}
//else
//{
// Invoke(new Action(() =>
// {
// this.pnlError.Visible = true;
// this.lblError.Text = "调用翻译功能失败……";
// }));
// Task.Run(() =>
// {
// Thread.Sleep(5000);
// this.pnlError.Visible = false;
// });
//}
#endregion
if (CountChineseCharacters(prodParam.productName) > 2)
{
Invoke(new Action(() =>
{
this.pnlError.Visible = true;
this.lblError.Text = "调用翻译功能失败……";
this.lblError.Text = "标题内含有中文,跳过英文标题设置";
}));
Task.Run(() =>
{
@@ -1778,6 +1803,16 @@ namespace TemuKJD.KJDForms.ProductSelectForms
this.pnlError.Visible = false;
});
}
else
{
prodParam.productI18nReqs = new List<productI18nParam>();
productI18nParam productI18nEn = new productI18nParam
{
language = "en",
productName = prodParam.productName,
};
prodParam.productI18nReqs.Add(productI18nEn);
}
}
html = SaveDraft(shop, prodParam.productDraftId.ToString(), prodParam);
@@ -2505,5 +2540,22 @@ Content-Disposition: form-data; name=""upload_sign""
if (cancellationTokenSource != null)
cancellationTokenSource.Cancel();
}
private void chkEnglishProdName_CheckedChanged(object sender, EventArgs e)
{
if (chkEnglishProdName.Checked && !chkFission.Checked)
{
BaseMsgForm.ShowInfo("需要先勾选重组标题!");
chkEnglishProdName.Checked = false;
}
}
public static int CountChineseCharacters(string text)
{
// 使用正则表达式匹配中文字符
string pattern = @"[\u4e00-\u9fff]";
MatchCollection matches = Regex.Matches(text, pattern);
return matches.Count;
}
}
}