导入微信格式数据 增加上架时间判断,如果大于指定时间则不上传

This commit is contained in:
chfei committed 2026-10-09 17:52:02 +08:00
1 parent 967f1488fd
commit c75735db0c
7 files changed
+79 -6

No files matched your search

@@ -75,6 +75,8 @@ namespace AllBase.Model.Result.PDDResult
return Skus?.Max(a => a.Price) ?? 0;
}
}
[Description("上架时间")]
public DateTime? ListingTime { get; set; }
}
/// <summary>
/// 属性
@@ -88,7 +88,7 @@ namespace TemuKJD.BLL.ImportConverters
Platform = Platform,
GoodsId = ParseGoodsId()
};
product.ListingTime = GetListingTime();
// ========== 1. 商品基本信息 ==========
product.Title = GetStringValue(_infoNode, "title");
product.Description = GetStringValue(_infoNode, "short_title");
@@ -290,6 +290,18 @@ namespace TemuKJD.BLL.ImportConverters
return result;
}
private DateTime? GetListingTime()
{
string time = _infoNode["listing_time"].ToString();
if (time != null)
{
if (int.TryParse(time, out int v))
{
return NaiBa.Util.Helper.DateTimeHelper.IntStampToDateTime(v);
}
}
return null;
}
#endregion
@@ -88,7 +88,7 @@ namespace TemuKJD.BLL.ImportConverters
Platform = Platform,
GoodsId = ParseGoodsId()
};
product.ListingTime = GetListingTime();
// ========== 1. 商品基本信息 ==========
product.Title = GetStringValue(_rawNode, "title");
product.Description = GetStringValue(_rawNode, "subTitle");
@@ -325,7 +325,18 @@ namespace TemuKJD.BLL.ImportConverters
return result;
}
private DateTime? GetListingTime()
{
string time = _rawNode["listingTime"].ToString();
if (time != null)
{
if (int.TryParse(time, out int v))
{
return NaiBa.Util.Helper.DateTimeHelper.IntStampToDateTime(v);
}
}
return null;
}
#endregion
#region SKU和规格解析
+8 -2
View File
@@ -1697,7 +1697,7 @@ namespace TemuKJD.BLL
/// <param name="specialProdType"></param>
/// <param name="IsCollectAuthorityUser"></param>
/// <returns></returns>
public string PddFrontToPddBackConvertFactory(string filePath, bool UpdateOldData = true, string specialProdType = null, bool IsCollectAuthorityUser = false, bool isSaveDb = true, string content = null)
public string PddFrontToPddBackConvertFactory(string filePath, bool UpdateOldData = true, string specialProdType = null, bool IsCollectAuthorityUser = false, bool isSaveDb = true, string content = null, DateTime? listingTime = null)
{
PDDFrontProductInfo5 frontProdInfo = null;
try
@@ -1716,7 +1716,13 @@ namespace TemuKJD.BLL
{
return "商品数据信息为空";
}
if (frontProdInfo.ListingTime != null && listingTime != null)
{
if (frontProdInfo.ListingTime <= listingTime)
{
return "上架日期超出范围";
}
}
KJDDBProduct dbProd = new KJDDBProduct() { size_json = "{}" };
PDDProductInfo prodInfo = new PDDProductInfo()
@@ -153,6 +153,9 @@ namespace TemuKJD.WXForms.ProductForms
this.col_select_product = new System.Windows.Forms.DataGridViewLinkColumn();
this.ucSplitPage1 = new TemuKJD.UserControls.UcSplitPage();
this.statusBar = new TemuKJD.UserControls.StatusBarUserControl();
this.label10 = new System.Windows.Forms.Label();
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
this.txt_listing_time = new System.Windows.Forms.TextBox();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
@@ -606,6 +609,8 @@ namespace TemuKJD.WXForms.ProductForms
this.tableLayoutPanel1.Controls.Add(this.chkTime, 0, 2);
this.tableLayoutPanel1.Controls.Add(this.dtpStart, 1, 2);
this.tableLayoutPanel1.Controls.Add(this.dtpEnd, 3, 2);
this.tableLayoutPanel1.Controls.Add(this.label10, 10, 2);
this.tableLayoutPanel1.Controls.Add(this.txt_listing_time, 11, 2);
this.tableLayoutPanel1.Location = new System.Drawing.Point(4, 6);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 3;
@@ -1615,13 +1620,16 @@ namespace TemuKJD.WXForms.ProductForms
this.ucSplitPage1.CurrentPage = 1;
this.ucSplitPage1.Dock = System.Windows.Forms.DockStyle.Right;
this.ucSplitPage1.IsShowPageSize = true;
this.ucSplitPage1.IsShowTotalCount = false;
this.ucSplitPage1.Location = new System.Drawing.Point(985, 0);
this.ucSplitPage1.Margin = new System.Windows.Forms.Padding(0);
this.ucSplitPage1.MaxPageSizeValue = 5000;
this.ucSplitPage1.Name = "ucSplitPage1";
this.ucSplitPage1.Padding = new System.Windows.Forms.Padding(0, 0, 1, 0);
this.ucSplitPage1.PageSize = 100;
this.ucSplitPage1.Size = new System.Drawing.Size(453, 25);
this.ucSplitPage1.TabIndex = 6;
this.ucSplitPage1.TotalCount = ((long)(0));
this.ucSplitPage1.TotalPage = 1;
//
// statusBar
@@ -1635,6 +1643,31 @@ namespace TemuKJD.WXForms.ProductForms
this.statusBar.Size = new System.Drawing.Size(1438, 25);
this.statusBar.TabIndex = 5;
//
// label10
//
this.label10.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(832, 77);
this.label10.Margin = new System.Windows.Forms.Padding(3, 7, 0, 0);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(56, 17);
this.label10.TabIndex = 983;
this.label10.Text = "上架日期";
this.toolTip1.SetToolTip(this.label10, "导入数据时超出时间(天)范围的不导入");
//
// txt_listing_time
//
this.txt_listing_time.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txt_listing_time.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.txt_listing_time.Font = new System.Drawing.Font("微软雅黑", 10F);
this.txt_listing_time.Location = new System.Drawing.Point(888, 73);
this.txt_listing_time.Margin = new System.Windows.Forms.Padding(0, 3, 3, 3);
this.txt_listing_time.Name = "txt_listing_time";
this.txt_listing_time.Size = new System.Drawing.Size(101, 25);
this.txt_listing_time.TabIndex = 984;
this.txt_listing_time.Text = "30";
//
// WXUserCollectAuthProdListForm
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
@@ -1777,5 +1810,8 @@ namespace TemuKJD.WXForms.ProductForms
public System.Windows.Forms.ComboBox cmbBatchEditNotes;
private DevComponents.DotNetBar.PanelEx btnBatchEditCate;
private DevComponents.DotNetBar.PanelEx btn_import_wx;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.ToolTip toolTip1;
private System.Windows.Forms.TextBox txt_listing_time;
}
}
@@ -1217,14 +1217,17 @@ namespace TemuKJD.WXForms.ProductForms
var filePathLst = openFileDialog.FileNames.ToList();
int successNum = 0;
int failedNum = 0;
var pddtoWxFactory = new PDDProdFormConverter();
foreach (var filePath in filePathLst)
{
string sourceContent = "";
string content = "";
string rst = "商品未识别";
int day = txt_listing_time.Text.ParseToInt(0) * -1;
try
{
rst = new PDDProdFormConverter().PddFrontToPddBackConvertFactory(filePath, true, null, true);
rst = pddtoWxFactory.PddFrontToPddBackConvertFactory(filePath, true, null, true, listingTime: DateTime.Now.AddDays(day));
}
catch (Exception ex)
{
@@ -117,6 +117,9 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="colSelect.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>