自动上报违规商品
上货自动检测违规商品
自动下架违规商品
This commit is contained in:
chfei committed 2026-10-30 14:14:14 +08:00
1 parent a319af0e91
commit d5e38dd518
9 files changed
+308 -19

No files matched your search

+3
View File
@@ -44,6 +44,9 @@
<Compile Update="InitForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Update="KJDForms\SystemForms\SystemViolationDetectionForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Update="PDDForms\AdminForms\RandomComProductForm.cs">
<SubType>Form</SubType>
</Compile>
+5 -2
View File
@@ -29,8 +29,9 @@
private void InitializeComponent()
{
System.Windows.Forms.TreeNode treeNode1 = new System.Windows.Forms.TreeNode("解除限制");
System.Windows.Forms.TreeNode violationNode = new System.Windows.Forms.TreeNode("违规检测");
System.Windows.Forms.TreeNode treeNode2 = new System.Windows.Forms.TreeNode("系统设置", new System.Windows.Forms.TreeNode[] {
treeNode1});
treeNode1, violationNode});
this.panel1 = new System.Windows.Forms.Panel();
this.panel3 = new System.Windows.Forms.Panel();
this.panel2 = new System.Windows.Forms.Panel();
@@ -103,6 +104,8 @@
this.tv.Name = "tv";
treeNode1.Name = "解除限制";
treeNode1.Text = "解除限制";
violationNode.Name = "违规检测";
violationNode.Text = "违规检测";
treeNode2.Name = "系统设置";
treeNode2.Text = "系统设置";
this.tv.Nodes.AddRange(new System.Windows.Forms.TreeNode[] {
@@ -162,4 +165,4 @@
private UserComponent.UcTreeView tv;
private System.Windows.Forms.SplitContainer splitContainer1;
}
}
}
@@ -15,6 +15,7 @@ namespace TemuKJD.KJDForms.SystemForms
public partial class SystemForm : BaseForm
{
public Lazy<SystemRemoveRestrictionsForm> systemRemoveRestrictionsForm = new Lazy<SystemRemoveRestrictionsForm>();
public Lazy<SystemViolationDetectionForm> systemViolationDetectionForm = new Lazy<SystemViolationDetectionForm>();
public SystemForm()
{
InitializeComponent();
@@ -46,6 +47,9 @@ namespace TemuKJD.KJDForms.SystemForms
case "解除限制":
SetForm(systemRemoveRestrictionsForm.Value);
break;
case "违规检测":
SetForm(systemViolationDetectionForm.Value);
break;
//case "商品管理":
// SetForm(shopProductForm.Value);
// break;
@@ -0,0 +1,61 @@
namespace TemuKJD.KJDForms.SystemForms
{
partial class SystemViolationDetectionForm
{
private System.ComponentModel.IContainer components = null;
protected override void Dispose(bool disposing)
{
if (disposing && components != null)
components.Dispose();
base.Dispose(disposing);
}
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.chkAutoReport = new TemuKJD.UserComponent.UcCheckBox(this.components);
this.chkAutoExcludeOnUpload = new TemuKJD.UserComponent.UcCheckBox(this.components);
this.chkAutoDelist = new TemuKJD.UserComponent.UcCheckBox(this.components);
this.SuspendLayout();
// chkAutoReport
this.chkAutoReport.AutoSize = true;
this.chkAutoReport.Location = new System.Drawing.Point(24, 24);
this.chkAutoReport.Name = "chkAutoReport";
this.chkAutoReport.TabIndex = 0;
this.chkAutoReport.Text = "自动上报违规商品";
this.chkAutoReport.UseVisualStyleBackColor = true;
// chkAutoExcludeOnUpload
this.chkAutoExcludeOnUpload.AutoSize = true;
this.chkAutoExcludeOnUpload.Location = new System.Drawing.Point(24, 64);
this.chkAutoExcludeOnUpload.Name = "chkAutoExcludeOnUpload";
this.chkAutoExcludeOnUpload.TabIndex = 1;
this.chkAutoExcludeOnUpload.Text = "上货自动剔除违规商品";
this.chkAutoExcludeOnUpload.UseVisualStyleBackColor = true;
// chkAutoDelist
this.chkAutoDelist.AutoSize = true;
this.chkAutoDelist.Location = new System.Drawing.Point(24, 104);
this.chkAutoDelist.Name = "chkAutoDelist";
this.chkAutoDelist.TabIndex = 2;
this.chkAutoDelist.Text = "自动下架违规商品";
this.chkAutoDelist.UseVisualStyleBackColor = true;
// SystemViolationDetectionForm
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.AutoScroll = true;
this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.chkAutoReport);
this.Controls.Add(this.chkAutoExcludeOnUpload);
this.Controls.Add(this.chkAutoDelist);
this.Font = new System.Drawing.Font("微软雅黑", 9F);
this.Name = "SystemViolationDetectionForm";
this.Text = "违规检测";
this.ResumeLayout(false);
this.PerformLayout();
}
private UserComponent.UcCheckBox chkAutoReport;
private UserComponent.UcCheckBox chkAutoExcludeOnUpload;
private UserComponent.UcCheckBox chkAutoDelist;
}
}
@@ -0,0 +1,32 @@
using System;
using AllBase.Helper;
using TemuKJD.BaseForms;
namespace TemuKJD.KJDForms.SystemForms
{
public partial class SystemViolationDetectionForm : BaseForm
{
public SystemViolationDetectionForm()
{
InitializeComponent();
var settings = GlobalConfig.GlobalSettings;
chkAutoReport.Checked = settings.AutoReportViolationProducts;
chkAutoExcludeOnUpload.Checked = settings.AutoExcludeViolationProductsOnUpload;
chkAutoDelist.Checked = settings.AutoDelistViolationProducts;
chkAutoReport.CheckedChanged += Settings_CheckedChanged;
chkAutoExcludeOnUpload.CheckedChanged += Settings_CheckedChanged;
chkAutoDelist.CheckedChanged += Settings_CheckedChanged;
}
private void Settings_CheckedChanged(object sender, EventArgs e)
{
var settings = GlobalConfig.GlobalSettings;
settings.AutoReportViolationProducts = chkAutoReport.Checked;
settings.AutoExcludeViolationProductsOnUpload = chkAutoExcludeOnUpload.Checked;
settings.AutoDelistViolationProducts = chkAutoDelist.Checked;
StartUp.SaveGlobalSettings();
}
}
}
@@ -34,6 +34,10 @@ namespace TemuKJD.PDDForms.ProductForms
if (shop.LoginStatus != "登录成功")
continue;
// 开启自动下架时,后台检测当前店铺在售商品并下架违规商品。
if (GlobalConfig.GlobalSettings.AutoDelistViolationProducts)
CloudGoodsService.CheckAndOffShelfViolations(shop);
Thread.Sleep(Randomx.GetId(500, 1500));
WXProdViolationGetInfo info = new WXProdViolationGetInfo() { shopId = shop.ShopId, updateDay = DateTime.Now.ToString("yyMMdd") };
@@ -52,7 +56,9 @@ namespace TemuKJD.PDDForms.ProductForms
info.failReason = "";
var result = getShopiolationProd(shop);
CloudGoodsService.ReportViolationsFromJson(result);
// 开启自动上报时,后台解析店铺处罚记录并上报违规商品。
if (GlobalConfig.GlobalSettings.AutoReportViolationProducts)
CloudGoodsService.ReportViolationsFromJson(result, shop);
Thread.Sleep(Randomx.GetId(1000, 2000));
if (!result.Contains("\"code\":0"))
@@ -675,7 +675,7 @@ namespace TemuKJD.WXForms.ProductForms
item.Cells["colSelect"].Value = wxUploadRule.SelectedShopIds.Contains(shopId);
}
}
isInit = true;
}
@@ -1715,6 +1715,36 @@ namespace TemuKJD.WXForms.ProductForms
}));
}
// 开启上货自动剔除时,上传前检测违规状态;违规或检测失败均禁止上传。
if (GlobalConfig.GlobalSettings.AutoExcludeViolationProductsOnUpload)
{
try
{
if (!long.TryParse(dbProd.spu_id, out var goodsId) || goodsId <= 0)
throw new Exception("商品ID无效");
var statuses = CloudGoodsService.GetViolationStatus(new List<long> { goodsId }).GetAwaiter().GetResult();
var status = statuses.FirstOrDefault(item => item.GoodsId == goodsId);
if (status == null)
throw new Exception("未返回当前商品的违规状态");
if (status.IsViolation)
return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"当前商品违规,禁止上传\"}";
}
catch (Exception ex)
{
if (cell != null)
Invoke(new Action(() => cell.Value = "商品违规检测失败,禁止上传"));
return JsonConvert.SerializeObject(new
{
success = false,
draftId = 0,
status = "未上传",
errMsg = "商品违规检测失败,禁止上传:" + ex.Message
});
}
}
#region 裂变标题
if (BaseClass.UserAuthority.Contains("裂变调试") && chkFissionGoodsName.Checked)
{