修复导入数据 缺少SKU spec

This commit is contained in:
chfei committed 2026-10-22 18:30:45 +08:00
1 parent 8b89d13573
commit 628e2d3786
4 files changed
+20 -19

No files matched your search

@@ -344,7 +344,7 @@ namespace TemuKJD.BLL.ImportConverters
/// <summary> /// <summary>
/// 获取SKU和规格信息 /// 获取SKU和规格信息
/// </summary> /// </summary>
private Tuple<List<SkuItem> ,List<SpecItem>> GetSkusAndSpecs() private Tuple<List<SkuItem>, List<SpecItem>> GetSkusAndSpecs()
{ {
var skuList = new List<SkuItem>(); var skuList = new List<SkuItem>();
var specList = new List<SpecItem>(); var specList = new List<SpecItem>();
@@ -360,6 +360,7 @@ namespace TemuKJD.BLL.ImportConverters
{ {
var skuId = spec["skuId"]?.Value<string>(); var skuId = spec["skuId"]?.Value<string>();
var specText = spec["spec"]?.Value<string>(); var specText = spec["spec"]?.Value<string>();
specText = specText.Replace('+', ';');
if (!string.IsNullOrEmpty(skuId) && !string.IsNullOrEmpty(specText)) if (!string.IsNullOrEmpty(skuId) && !string.IsNullOrEmpty(specText))
{ {
skuSpecDict[skuId] = specText; skuSpecDict[skuId] = specText;
@@ -386,7 +387,7 @@ namespace TemuKJD.BLL.ImportConverters
{ {
specText = cachedSpec; specText = cachedSpec;
// 解析 "颜色分类:牛油果/尺码:S" 格式 // 解析 "颜色分类:牛油果/尺码:S" 格式
foreach (var part in cachedSpec.Split('/')) foreach (var part in cachedSpec.Split(new char[] { '/', '+', ';' }, StringSplitOptions.RemoveEmptyEntries))
{ {
var kv = part.Split(':'); var kv = part.Split(':');
if (kv.Length == 2) if (kv.Length == 2)
+2 -2
View File
@@ -1959,8 +1959,8 @@ namespace TemuKJD.BLL
var specList = skuItem.Spec.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries).ToList(); var specList = skuItem.Spec.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries).ToList();
foreach (var spec in specList) foreach (var spec in specList)
{ {
string specKey = spec.Split(':')[0]; string specKey = spec.Split(':')[0].Trim();
string specValue = spec.Split(':')[1]; string specValue = spec.Split(':')[1].Trim();
var specItem = frontProdInfo.Specs.FirstOrDefault(a => a.SpecKey == specKey && a.SpecValue == specValue); var specItem = frontProdInfo.Specs.FirstOrDefault(a => a.SpecKey == specKey && a.SpecValue == specValue);
if (specItem == null) continue; if (specItem == null) continue;
skuInfo.spec.Add(new spec_item() skuInfo.spec.Add(new spec_item()
@@ -94,6 +94,7 @@ namespace TemuKJD.WXForms.ProductForms
this.chkTime = new TemuKJD.UserComponent.UcCheckBox(this.components); this.chkTime = new TemuKJD.UserComponent.UcCheckBox(this.components);
this.dtpStart = new System.Windows.Forms.DateTimePicker(); this.dtpStart = new System.Windows.Forms.DateTimePicker();
this.dtpEnd = new System.Windows.Forms.DateTimePicker(); this.dtpEnd = new System.Windows.Forms.DateTimePicker();
this.label10 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label(); this.label7 = new System.Windows.Forms.Label();
this.splitContainer2 = new System.Windows.Forms.SplitContainer(); this.splitContainer2 = new System.Windows.Forms.SplitContainer();
this.lblRelation = new System.Windows.Forms.Label(); this.lblRelation = new System.Windows.Forms.Label();
@@ -153,7 +154,6 @@ namespace TemuKJD.WXForms.ProductForms
this.col_select_product = new System.Windows.Forms.DataGridViewLinkColumn(); this.col_select_product = new System.Windows.Forms.DataGridViewLinkColumn();
this.ucSplitPage1 = new TemuKJD.UserControls.UcSplitPage(); this.ucSplitPage1 = new TemuKJD.UserControls.UcSplitPage();
this.statusBar = new TemuKJD.UserControls.StatusBarUserControl(); this.statusBar = new TemuKJD.UserControls.StatusBarUserControl();
this.label10 = new System.Windows.Forms.Label();
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
this.txt_listing_time = new System.Windows.Forms.TextBox(); this.txt_listing_time = new System.Windows.Forms.TextBox();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
@@ -977,6 +977,18 @@ namespace TemuKJD.WXForms.ProductForms
this.dtpEnd.Size = new System.Drawing.Size(99, 23); this.dtpEnd.Size = new System.Drawing.Size(99, 23);
this.dtpEnd.TabIndex = 982; this.dtpEnd.TabIndex = 982;
// //
// 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, "导入数据时超出时间(天)范围的不导入");
//
// label7 // label7
// //
this.label7.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.label7.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
@@ -1643,18 +1655,6 @@ namespace TemuKJD.WXForms.ProductForms
this.statusBar.Size = new System.Drawing.Size(1438, 25); this.statusBar.Size = new System.Drawing.Size(1438, 25);
this.statusBar.TabIndex = 5; 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 // txt_listing_time
// //
this.txt_listing_time.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) this.txt_listing_time.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
@@ -1666,7 +1666,7 @@ namespace TemuKJD.WXForms.ProductForms
this.txt_listing_time.Name = "txt_listing_time"; this.txt_listing_time.Name = "txt_listing_time";
this.txt_listing_time.Size = new System.Drawing.Size(101, 25); this.txt_listing_time.Size = new System.Drawing.Size(101, 25);
this.txt_listing_time.TabIndex = 984; this.txt_listing_time.TabIndex = 984;
this.txt_listing_time.Text = "30"; this.txt_listing_time.Text = "365";
// //
// WXUserCollectAuthProdListForm // WXUserCollectAuthProdListForm
// //
+1 -1
View File
@@ -143,7 +143,7 @@ namespace KJD.Test
[Test] [Test]
public void TestWXToPDDV4() public void TestWXToPDDV4()
{ {
string filePath = @"C:\Users\chaih\Documents\xwechat_files\hongfei357_a567\msg\file\2026-10\导入失败数据包\10000023711970.txt"; string filePath = @"C:\Users\chaih\Documents\xwechat_files\hongfei357_a567\msg\file\2026-10\10001443620622.json";
var frontProdInfo = ConverterToPddFactory.Convert(filePath); var frontProdInfo = ConverterToPddFactory.Convert(filePath);
var isMatch = frontProdInfo != null; var isMatch = frontProdInfo != null;
Console.WriteLine(frontProdInfo.Skus.Count); Console.WriteLine(frontProdInfo.Skus.Count);