导入微信格式数据 增加上架时间判断,如果大于指定时间则不上传
This commit is contained in:
1 parent
967f1488fd
commit
c75735db0c
7 files changed
+123
-50
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
|
||||
|
||||
@@ -298,7 +310,7 @@ namespace TemuKJD.BLL.ImportConverters
|
||||
/// <summary>
|
||||
/// 获取SKU和规格信息
|
||||
/// </summary>
|
||||
private Tuple<List<SkuItem>, List<SpecItem>> GetSkusAndSpecs()
|
||||
private Tuple<List<SkuItem>, List<SpecItem>> GetSkusAndSpecs()
|
||||
{
|
||||
var skuList = new List<SkuItem>();
|
||||
var specList = new List<SpecItem>();
|
||||
|
||||
@@ -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和规格解析
|
||||
|
||||
@@ -17,7 +17,7 @@ using Work;
|
||||
namespace TemuKJD.BLL
|
||||
{
|
||||
public class PDDProdFormConverter
|
||||
{
|
||||
{
|
||||
/// <summary>
|
||||
/// 拼多多前端采集转拼多多后台采集数据
|
||||
/// </summary>
|
||||
@@ -330,11 +330,11 @@ namespace TemuKJD.BLL
|
||||
dbProd.product_json = JsonHelper.SerializeObject(prodInfo);
|
||||
|
||||
if (!isSaveDb)
|
||||
return "success" + dbProd.product_json;
|
||||
return "success" + dbProd.product_json;
|
||||
|
||||
|
||||
// 商品采集权限用户采集的数据加上用户前缀(商品前缀显示给用户的时候隐藏)
|
||||
string collectAuthorityTag = "";
|
||||
// 商品采集权限用户采集的数据加上用户前缀(商品前缀显示给用户的时候隐藏)
|
||||
string collectAuthorityTag = "";
|
||||
if (IsCollectAuthorityUser)
|
||||
collectAuthorityTag = "-" + BaseClass.UserName;
|
||||
|
||||
@@ -806,10 +806,10 @@ namespace TemuKJD.BLL
|
||||
dbProd.product_json = JsonHelper.SerializeObject(prodInfo);
|
||||
|
||||
if (!isSaveDb)
|
||||
return "success" + dbProd.product_json;
|
||||
return "success" + dbProd.product_json;
|
||||
|
||||
// 商品采集权限用户采集的数据加上用户前缀(商品前缀显示给用户的时候隐藏)
|
||||
string collectAuthorityTag = "";
|
||||
// 商品采集权限用户采集的数据加上用户前缀(商品前缀显示给用户的时候隐藏)
|
||||
string collectAuthorityTag = "";
|
||||
if (IsCollectAuthorityUser)
|
||||
collectAuthorityTag = "-" + BaseClass.UserName;
|
||||
|
||||
@@ -968,7 +968,7 @@ namespace TemuKJD.BLL
|
||||
});
|
||||
galleryIndex++;
|
||||
}
|
||||
foreach (var videoGallery in frontProdInfo.goods.videoGallery)
|
||||
foreach (var videoGallery in frontProdInfo.goods.videoGallery)
|
||||
{
|
||||
prodInfo.detail.galleries.Add(new gallery_item()
|
||||
{
|
||||
@@ -1209,11 +1209,11 @@ namespace TemuKJD.BLL
|
||||
dbProd.main_img = prodInfo.detail.galleries.FirstOrDefault(g => g.type == 1).url;
|
||||
dbProd.product_json = JsonHelper.SerializeObject(prodInfo);
|
||||
|
||||
if (!isSaveDb)
|
||||
return "success" + dbProd.product_json;
|
||||
if (!isSaveDb)
|
||||
return "success" + dbProd.product_json;
|
||||
|
||||
// 商品采集权限用户采集的数据加上用户前缀(商品前缀显示给用户的时候隐藏)
|
||||
string collectAuthorityTag = "";
|
||||
// 商品采集权限用户采集的数据加上用户前缀(商品前缀显示给用户的时候隐藏)
|
||||
string collectAuthorityTag = "";
|
||||
if (IsCollectAuthorityUser)
|
||||
collectAuthorityTag = "-" + BaseClass.UserName;
|
||||
|
||||
@@ -1614,11 +1614,11 @@ namespace TemuKJD.BLL
|
||||
dbProd.main_img = prodInfo.detail.galleries.FirstOrDefault(g => g.type == 1).url;
|
||||
dbProd.product_json = JsonHelper.SerializeObject(prodInfo);
|
||||
|
||||
if (!isSaveDb)
|
||||
return "success" + dbProd.product_json;
|
||||
if (!isSaveDb)
|
||||
return "success" + dbProd.product_json;
|
||||
|
||||
// 商品采集权限用户采集的数据加上用户前缀(商品前缀显示给用户的时候隐藏)
|
||||
string collectAuthorityTag = "";
|
||||
// 商品采集权限用户采集的数据加上用户前缀(商品前缀显示给用户的时候隐藏)
|
||||
string collectAuthorityTag = "";
|
||||
if (IsCollectAuthorityUser)
|
||||
collectAuthorityTag = "-" + BaseClass.UserName;
|
||||
|
||||
@@ -1689,21 +1689,21 @@ namespace TemuKJD.BLL
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 外来格式V5
|
||||
/// </summary>
|
||||
/// <param name="outProdJson"></param>
|
||||
/// <param name="UpdateOldData"></param>
|
||||
/// <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)
|
||||
/// <summary>
|
||||
/// 外来格式V5
|
||||
/// </summary>
|
||||
/// <param name="outProdJson"></param>
|
||||
/// <param name="UpdateOldData"></param>
|
||||
/// <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, DateTime? listingTime = null)
|
||||
{
|
||||
PDDFrontProductInfo5 frontProdInfo = null;
|
||||
try
|
||||
{
|
||||
if (!content.IsNullOrEmpty())
|
||||
frontProdInfo = ConverterToPddFactory.SetContentConvert(content);
|
||||
frontProdInfo = ConverterToPddFactory.SetContentConvert(content);
|
||||
else
|
||||
frontProdInfo = ConverterToPddFactory.Convert(filePath);
|
||||
}
|
||||
@@ -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()
|
||||
@@ -2010,10 +2016,10 @@ namespace TemuKJD.BLL
|
||||
dbProd.product_json = JsonHelper.SerializeObject(prodInfo);
|
||||
|
||||
if (!isSaveDb)
|
||||
return "success" + dbProd.product_json;
|
||||
return "success" + dbProd.product_json;
|
||||
|
||||
// 商品采集权限用户采集的数据加上用户前缀(商品前缀显示给用户的时候隐藏)
|
||||
string collectAuthorityTag = "";
|
||||
// 商品采集权限用户采集的数据加上用户前缀(商品前缀显示给用户的时候隐藏)
|
||||
string collectAuthorityTag = "";
|
||||
if (IsCollectAuthorityUser)
|
||||
collectAuthorityTag = "-" + BaseClass.UserName;
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -149,9 +149,9 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
btnGetProdWxCate.Visible = false;
|
||||
btnStopStop.Visible = false;
|
||||
btnImportPddOutData.Visible = false;
|
||||
btnOut1688ProdSaveDb.Visible = false;
|
||||
btn_import_wx.Visible = false;
|
||||
btnAITitleFission.Visible = false;
|
||||
btnOut1688ProdSaveDb.Visible = false;
|
||||
btn_import_wx.Visible = false;
|
||||
btnAITitleFission.Visible = false;
|
||||
this.dgvDbProduct.Columns["col_edit"].Visible = false;
|
||||
}
|
||||
}
|
||||
@@ -196,21 +196,21 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
{
|
||||
var cancelToken = cancellationTokenSource.Token;
|
||||
|
||||
int pageCount;
|
||||
int pageCount;
|
||||
int totalCount;
|
||||
int pageSize = 100;
|
||||
decimal seconds;
|
||||
Invoke(new Action(() => { pageSize = this.ucSplitPage1.PageSize; }));
|
||||
var list = GetProductList(out pageCount, out totalCount, out seconds, page, pageSize, isNotCount);
|
||||
|
||||
if (cancelToken.IsCancellationRequested)
|
||||
return;
|
||||
if (cancelToken.IsCancellationRequested)
|
||||
return;
|
||||
|
||||
lstTemuDbProduct.AddRange(list);
|
||||
this.ucSplitPage1.TotalPage = pageCount;
|
||||
this.ucSplitPage1.TotalCount = totalCount;
|
||||
lstTemuDbProduct.AddRange(list);
|
||||
this.ucSplitPage1.TotalPage = pageCount;
|
||||
this.ucSplitPage1.TotalCount = totalCount;
|
||||
|
||||
if (defaultBitmap == null)
|
||||
if (defaultBitmap == null)
|
||||
defaultBitmap = new Bitmap(80, 80);
|
||||
// 获取Bitmap的Graphics对象
|
||||
using (Graphics g = Graphics.FromImage(defaultBitmap))
|
||||
@@ -282,9 +282,9 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
}));
|
||||
}
|
||||
|
||||
if (cancelToken.IsCancellationRequested)
|
||||
return;
|
||||
Invoke(new Action(() =>
|
||||
if (cancelToken.IsCancellationRequested)
|
||||
return;
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
ShowDgvImg();
|
||||
this.pbLoading.Visible = false;
|
||||
@@ -388,7 +388,7 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
List<KJDDBProduct> list = new List<KJDDBProduct>();
|
||||
pageCount = 1;
|
||||
totalNum = 0;
|
||||
seconds = 0;
|
||||
seconds = 0;
|
||||
|
||||
var url = BaseClass.BuildPDDObjString("product/get_product_list");
|
||||
if (shop != null && shop.DbId.ParseToInt() != 0)
|
||||
@@ -497,7 +497,7 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
// 采集来源判断
|
||||
data += "&product_get_type=" + cmbSourceType.Text.Trim().Replace("已采集数据", "1688外部数据")
|
||||
.Replace("多多商品", "机会商品,多多外部数据").Replace("1688商品", "1688厂家,1688外部数据").Replace("微信商品", "微信店采,微信外部数据");
|
||||
}
|
||||
}
|
||||
|
||||
if (shop != null && !string.IsNullOrEmpty(shop.ShopId))
|
||||
{
|
||||
@@ -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>
|
||||
|
||||
Reference in new issue
Block a user