1成人用品上传到草稿箱 2随机商品跳过资质商品 3ai短标题 4记住类目保证金筛选功能

This commit is contained in:
wule committed 2026-03-03 14:03:31 +08:00
1 parent cce4c9da2d
commit ce42448b29
15 files changed
+851 -389

No files matched your search

@@ -164,6 +164,10 @@ namespace TemuKJD.WXForms.ProductForms
this.chkUpDraft.CheckedChanged -= chkUpDraft_CheckedChanged;
this.chkPreSale.CheckedChanged -= chkPreSale_CheckedChanged;
this.txtTitleHeadWord.TextChanged -= txtTitleHeadWord_TextChanged;
this.chkAiShortTitle.CheckedChanged -= chkAiShotTitle_CheckedChanged;
this.chkSaveBound.CheckedChanged -= chkSaveBound_CheckedChanged;
this.txtFilterBoundMin.TextChanged -= txtFilterBoundMin_TextChanged;
this.txtFilterBoundMax.TextChanged -= txtFilterBoundMax_TextChanged;
this.txtPreDays.Text = wxUploadRule.PreSaleDays.ParseToString();
this.txtReplaceText.Text = wxUploadRule.FilterWords.ParseToString();
@@ -175,6 +179,13 @@ namespace TemuKJD.WXForms.ProductForms
this.chkUpDraft.Checked = wxUploadRule.UpDraft.ParseToBool();
this.chkPreSale.Checked = wxUploadRule.IsPreSale.ParseToBool();
this.txtTitleHeadWord.Text = wxUploadRule.TitleHeadWords.ParseToString();
this.chkAiShortTitle.Checked = wxUploadRule.IsAiShortTitle;
this.chkSaveBound.Checked = wxUploadRule.IsSaveBound;
if (wxUploadRule.IsSaveBound)
{
this.txtFilterBoundMin.Text = wxUploadRule.FilterBoundMinSave.ParseToString();
this.txtFilterBoundMax.Text = wxUploadRule.FilterBoundMaxSave.ParseToString();
}
this.txtPreDays.TextChanged += txtPreDays_TextChanged;
this.txtReplaceText.TextChanged += txtReplaceText_TextChanged;
@@ -186,6 +197,10 @@ namespace TemuKJD.WXForms.ProductForms
this.chkUpDraft.CheckedChanged += chkUpDraft_CheckedChanged;
this.chkPreSale.CheckedChanged += chkPreSale_CheckedChanged;
this.txtTitleHeadWord.TextChanged += txtTitleHeadWord_TextChanged;
this.chkAiShortTitle.CheckedChanged += chkAiShotTitle_CheckedChanged;
this.chkSaveBound.CheckedChanged += chkSaveBound_CheckedChanged;
this.txtFilterBoundMin.TextChanged += txtFilterBoundMin_TextChanged;
this.txtFilterBoundMax.TextChanged += txtFilterBoundMax_TextChanged;
this.lblWaitToUp.Text = "待上传 " + lstTemuDBProductSelect.Count + " 件";
@@ -269,7 +284,7 @@ namespace TemuKJD.WXForms.ProductForms
//#endif
if (BaseClass.SaLevel == 1)
{
chkImgRandomBlock.Visible = true;
//chkImgRandomBlock.Visible = true;
}
IsLoadComplate = true;
@@ -1569,11 +1584,7 @@ namespace TemuKJD.WXForms.ProductForms
#region 设置标题
string prodTitle = dbProd.product_name.IsNullOrEmpty() ? prodInfo.detail.goods_name : dbProd.product_name;
upProdInitParam.product.info.title = prodTitle;
//标题前缀
if (!string.IsNullOrEmpty(wxUploadRule.TitleHeadWords))
upProdInitParam.product.info.title = wxUploadRule.TitleHeadWords + upProdInitParam.product.info.title;
upProdParam.product.info.title = upProdInitParam.product.info.title;
upProdParam.product.info.title = prodTitle;
upProdParam.sessionInfo.sessionId = upProdInitParam.product.sessionId;
#endregion
@@ -2042,8 +2053,8 @@ namespace TemuKJD.WXForms.ProductForms
}
#endregion
#region 短标题 // ai获取短标题 // 暂时注释
if (1 == 2)
#region ai短标题 // ai获取短标题
if (wxUploadRule.IsAiShortTitle)
{
if (cell != null)
{
@@ -2073,9 +2084,15 @@ namespace TemuKJD.WXForms.ProductForms
}
upProdParam.product.info.shortTitle = BaseRegex.GetStringJson(ref shortTitleRst, "shortTitle");
upProdParam.product.info.aiGenShortTitle = upProdParam.product.info.shortTitle;
upProdParam.product.info.title = upProdParam.product.info.shortTitle + upProdParam.product.info.title;
}
#endregion
#region 标题前缀,加在最前面
if (!string.IsNullOrWhiteSpace(wxUploadRule.TitleHeadWords))
upProdParam.product.info.title = wxUploadRule.TitleHeadWords + upProdParam.product.info.title;
#endregion
#region 售后信息
if (cell != null)
@@ -2780,6 +2797,8 @@ namespace TemuKJD.WXForms.ProductForms
attrValue = "1 kg";
else if (attr.value == "g;kg;ml;L")
attrValue = "100 g";
else if (attr.value == "cm")
attrValue = "20 cm";
}
var wxPropParam = new propParam();
@@ -3144,7 +3163,7 @@ namespace TemuKJD.WXForms.ProductForms
}
#endregion
#region 书籍类生成书籍图片
#region 标签图 书籍类生成书籍图片
//qualificationList
if (upProdParam.product.info.category.FirstOrDefault()?.name == "图书" || prodInfo.detail.cats.FirstOrDefault() == "书籍/杂志/报纸")
{
@@ -3218,7 +3237,7 @@ namespace TemuKJD.WXForms.ProductForms
}
#endregion
#region 食品类生成食品图片
#region 标签图 食品类生成食品图片
//qualificationList
if (upProdParam.product.info.category.FirstOrDefault()?.name == "食品饮料" || prodInfo.detail.cats.FirstOrDefault() == "食品饮料")
{
@@ -3306,6 +3325,100 @@ namespace TemuKJD.WXForms.ProductForms
}
#endregion
#region 标签图 成人用品
//qualificationList
if (upProdParam.product.info.category.FirstOrDefault()?.name == "成人用品" && upProdParam.product.info.category[1].name != "情趣内衣")
{
if (cell != null)
{
Invoke(new Action(() =>
{
cell.Value = "正在生成成人用品专有信息";
}));
}
string prodName = "产品名称:" +
(upProdParam.product.info.category.Count > 2 ? upProdParam.product.info.category[2].name : upProdParam.product.info.category.LastOrDefault()?.name);
string company = "生产企业:浙江邦臣医药有限公司";
string address = "制造商地址:浙江省金华市婺城区神丽路1399号6号厂房";
string model = "产品型号:见包装";
string material = "材质:其他";
string user = "适用人群:18岁以上成年人";
foreach (var propParam in upProdParam.product.info.param)
{
//if (propParam.categorys[0].name.Contains("产品名称"))
// prodName = "产品名称:" + propParam.categorys[1].name;
}
var bookStr = prodName + "\r\n" + "\r\n" +
company + "\r\n" + "\r\n" +
address + "\r\n" + "\r\n" +
model + "\r\n" + "\r\n" +
material + "\r\n" + "\r\n" +
user;
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 = "50000089", qualificationUrl = new List<string>() { location }, });
}
if (upProdParam.product.info.category.FirstOrDefault()?.name == "成人用品" && upProdParam.product.info.category[1].name != "情趣内衣")
{
if (cell != null)
{
Invoke(new Action(() =>
{
cell.Value = "正在生成成人用品专有信息";
}));
}
string prodName = (upProdParam.product.info.category.Count > 2 ? upProdParam.product.info.category[2].name : upProdParam.product.info.category.LastOrDefault()?.name);
var baseImg = TemuKJD.Properties.Resources.qingxu;
var newImg = new Bitmap(baseImg.Width, baseImg.Height);
using (Graphics g = Graphics.FromImage(newImg))
{
//g.Clear(Color.White);
g.DrawImage(baseImg, new Rectangle(0, 0, newImg.Width, newImg.Height), 0, 0, baseImg.Width, baseImg.Height, GraphicsUnit.Pixel);
g.FillRectangle(Brushes.White, 860.ParseToInt(), (1024 - 4).ParseToInt(), 500, 120);
//Font font = new Font("宋体", txtSize.Text.Trim().ParseToInt(), FontStyle.Bold);
Font font = new Font("宋体", 44.ParseToInt(), FontStyle.Regular);
//Font font = new Font("微软雅黑", 15, FontStyle.Regular);
Brush textBrush = Brushes.Black;
textBrush = new SolidBrush(Color.FromArgb(0, 0, 0));
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
RectangleF rectF = new RectangleF(860, 1024, baseImg.Width - 80, baseImg.Height - 80);
if (!string.IsNullOrWhiteSpace(prodName.Trim()))
g.DrawString(prodName.Trim(), font, textBrush, rectF);
}
Thread.Sleep(Randomx.GetId(500, 800));
var locationStr = UploadImg(shop, newImg, cell);
if (!locationStr.Contains("\"success\":true"))
return locationStr;
var location = BaseRegex.GetStringJson(ref locationStr, "Location");
upProdParam.product.info.qualificationList.Add(new qualificationParam() { qualificationId = "50000115", qualificationUrl = new List<string>() { location }, });
}
#endregion
if (cell != null)
{
Invoke(new Action(() =>
@@ -3696,6 +3809,12 @@ namespace TemuKJD.WXForms.ProductForms
this.cancellationTokenSource.Cancel();
}
CancellationTokenSource getProdTokenSource = null;
private void pbSelectProd_Click(object sender, EventArgs e)
{
if (getProdTokenSource != null)
getProdTokenSource.Cancel();
}
private void btnRandomAdd_Click(object sender, EventArgs e)
{
btnRandomAdd.Enabled = false;
@@ -3709,24 +3828,31 @@ namespace TemuKJD.WXForms.ProductForms
}));
});
int addCount = txtAddCount.Text.Trim().ParseToInt();
if (getProdTokenSource != null)
getProdTokenSource.Cancel();
getProdTokenSource = new CancellationTokenSource();
Task.Run(() =>
{
List<KJDDBProduct> prodLst = new List<KJDDBProduct>();
int index = 0;
int pageSize = 50;
while (addCount > 0)
{
if (getProdTokenSource.IsCancellationRequested)
break;
index++;
int prodCount = 0;
// 如果产品数量在0到50之间,说明数据库商品数量不足,无需再重复筛选,直接随机打乱
if (prodLst.Count == 0 || prodLst.Count == Math.Min(50, addCount))
if (prodLst.Count == 0 || prodLst.Count == Math.Min(pageSize, addCount))
{
if (index > 1 && prodCount > 0)
{
prodLst = GetRandomProductList(out prodCount, 1, Math.Min(50, addCount), true, prodCount);
prodLst = GetRandomProductList(out prodCount, 1, Math.Min(pageSize, addCount), true, prodCount);
}
else
{
prodLst = GetRandomProductList(out prodCount, 1, Math.Min(50, addCount));
prodLst = GetRandomProductList(out prodCount, 1, Math.Min(pageSize, addCount));
}
//Thread.Sleep(Randomx.GetId(50, 100));
Thread.Sleep(Randomx.GetId(250, 500));
@@ -3766,7 +3892,7 @@ namespace TemuKJD.WXForms.ProductForms
{
pbSelectProd.Visible = false;
}));
});
}, getProdTokenSource.Token);
}
public List<KJDDBProduct> GetRandomProductList(out int totalCount, int page = 1, int pageSize = 50, bool isNotCount = false, int totalProdCount = 0)
@@ -3805,6 +3931,12 @@ namespace TemuKJD.WXForms.ProductForms
if (!string.IsNullOrEmpty(cmbCateFilter1.Text) && cate1 != null)
data += "&wx_cat_1=" + cate1.cat_id;
else if (chkSkipQualification.Checked)
{
// 厂商直采普通店铺不要随特殊商品
data += "&wx_cat_1=" + string.Join(",", GlobalConfig.WxCatList.Where(c=>c.level == 1 && !(c.name == "图书" || c.name == "食品饮料" || c.name == "成人用品"))
.Select(c => c.cat_id));
}
if (!string.IsNullOrEmpty(cmbCateFilter2.Text) && cate2 != null)
data += "&wx_cat_2=" + cate2.cat_id;
if (!string.IsNullOrEmpty(cmbCateFilter3.Text) && cate3 != null)
@@ -3929,7 +4061,8 @@ namespace TemuKJD.WXForms.ProductForms
if (row.Cells["colCheck"].Value.ParseToBool() == true)
{
var draft_id = row.Cells["colDraftId"].Value.ParseToString();
upload_draft_product_lst.RemoveAll(p => p.draft_id == draft_id);
var add_time = row.Cells["colAddTime"].Value.ParseToString().ParseToDateTime();
upload_draft_product_lst.RemoveAll(p => p.draft_id.ParseToString() == draft_id && p.add_time.ToString("yyyyMMddHHmmss") == add_time.ToString("yyyyMMddHHmmss"));
this.dgvSelectProduct.Rows.Remove(row);
}
@@ -3972,6 +4105,7 @@ namespace TemuKJD.WXForms.ProductForms
cmbCateFilter1.Text = "";
cmbWxSafe.Text = "安全+未校验";
cmbSourceType.Text = "厂商直采";
chkSkipQualification.Checked = false;
int prodCount;
pbSelectProd.Visible = true;
@@ -4330,6 +4464,41 @@ namespace TemuKJD.WXForms.ProductForms
private void txtTitleHeadWord_TextChanged(object sender, EventArgs e)
{
wxUploadRule.TitleHeadWords = txtTitleHeadWord.Text.Trim();
NaiBa.Util.Helper.ConfigHelper.SaveConfig("wx_upload_rule", wxUploadRule);
}
private void chkSaveBound_CheckedChanged(object sender, EventArgs e)
{
wxUploadRule.IsSaveBound = chkSaveBound.Checked;
if (chkSaveBound.Checked)
{
wxUploadRule.FilterBoundMinSave = txtFilterBoundMin.Text.ParseToInt();
wxUploadRule.FilterBoundMaxSave = txtFilterBoundMax.Text.ParseToInt();
}
NaiBa.Util.Helper.ConfigHelper.SaveConfig("wx_upload_rule", wxUploadRule);
}
private void txtFilterBoundMin_TextChanged(object sender, EventArgs e)
{
if (wxUploadRule.IsSaveBound)
{
wxUploadRule.FilterBoundMinSave = txtFilterBoundMin.Text.ParseToInt();
NaiBa.Util.Helper.ConfigHelper.SaveConfig("wx_upload_rule", wxUploadRule);
}
}
private void txtFilterBoundMax_TextChanged(object sender, EventArgs e)
{
if (wxUploadRule.IsSaveBound)
{
wxUploadRule.FilterBoundMaxSave = txtFilterBoundMax.Text.ParseToInt();
NaiBa.Util.Helper.ConfigHelper.SaveConfig("wx_upload_rule", wxUploadRule);
}
}
private void chkAiShotTitle_CheckedChanged(object sender, EventArgs e)
{
wxUploadRule.IsAiShortTitle = chkAiShortTitle.Checked;
NaiBa.Util.Helper.ConfigHelper.SaveConfig("wx_upload_rule", wxUploadRule);
}
}
@@ -4744,5 +4913,10 @@ Content-Type: application/octet-stream
public bool UpDraft { get; set; } = false;
public bool IsPreSale { get; set; } = false;
public string TitleHeadWords { get; set; } = "";
public bool IsSaveBound { get; set; } = false;
public int FilterBoundMinSave { get; set; } = 1000;
public int FilterBoundMaxSave { get; set; } = 1000;
public bool IsAiShortTitle { get; set; } = false;
}
}