154 lines
4.0 KiB
C#
154 lines
4.0 KiB
C#
using AllBase.Model.Result.PDDResult;
|
|
using System.Text;
|
|
using TemuKJD.BLL;
|
|
using TemuKJD.BLL.ImportConverts;
|
|
using Work;
|
|
using Work.GoodDetail;
|
|
|
|
namespace KJD.Test
|
|
{
|
|
public class Tests
|
|
{
|
|
[SetUp]
|
|
public void Setup()
|
|
{
|
|
}
|
|
|
|
[Test]
|
|
public void Test1()
|
|
{
|
|
string json = File.ReadAllText(@"C:\Users\chaih\Documents\xwechat_files\hongfei357_a567\msg\file\2026-08\850\531430339344.txt");
|
|
|
|
}
|
|
|
|
[Test]
|
|
public void TestWXToPDD()
|
|
{
|
|
string folderPath = @"C:\Users\chaih\Documents\xwechat_files\hongfei357_a567\msg\file\2026-08\破局(1)";
|
|
if (!Directory.Exists(folderPath))
|
|
{
|
|
Console.WriteLine($"文件夹不存在: {folderPath}");
|
|
return;
|
|
}
|
|
|
|
// 获取所有 txt 文件
|
|
var txtFiles = Directory.GetFiles(folderPath, "*.txt", SearchOption.AllDirectories);
|
|
|
|
if (txtFiles.Length == 0)
|
|
{
|
|
Console.WriteLine("未找到任何 .txt 文件");
|
|
return;
|
|
}
|
|
|
|
Console.WriteLine($"共找到 {txtFiles.Length} 个 txt 文件,开始扫描...\n");
|
|
Console.WriteLine(new string('-', 60));
|
|
|
|
var matchedFiles = new List<string>();
|
|
var unmatchedFiles = new List<string>();
|
|
var errorFiles = new List<string>();
|
|
|
|
foreach (var filePath in txtFiles)
|
|
{
|
|
try
|
|
{
|
|
// 读取文件内容
|
|
var frontProdInfo = ConverterToPddFactory.Convert(filePath);
|
|
var isMatch = frontProdInfo != null;
|
|
|
|
string fileName = Path.GetFileName(filePath);
|
|
string result = isMatch ? "✅ 匹配" : "❌ 不匹配";
|
|
|
|
Console.WriteLine($"[{result}] {fileName}");
|
|
|
|
if (isMatch)
|
|
{
|
|
matchedFiles.Add(fileName);
|
|
}
|
|
else
|
|
{
|
|
unmatchedFiles.Add(fileName);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string fileName = Path.GetFileName(filePath);
|
|
Console.WriteLine($"[⚠️ 读取失败] {fileName} - {ex.Message}");
|
|
errorFiles.Add(fileName);
|
|
}
|
|
}
|
|
|
|
// 输出统计结果
|
|
Console.WriteLine(new string('-', 60));
|
|
Console.WriteLine($"\n📊 扫描完成统计:");
|
|
Console.WriteLine($" ✅ 匹配: {matchedFiles.Count} 个");
|
|
Console.WriteLine($" ❌ 不匹配: {unmatchedFiles.Count} 个");
|
|
Console.WriteLine($" ⚠️ 读取失败: {errorFiles.Count} 个");
|
|
|
|
if (matchedFiles.Count > 0)
|
|
{
|
|
Console.WriteLine($"\n📋 匹配文件列表:");
|
|
foreach (var file in matchedFiles)
|
|
{
|
|
Console.WriteLine($" - {file}");
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
[Test]
|
|
public void TestWXToPDDV2()
|
|
{
|
|
string filePath = @"C:\Users\chaih\Documents\xwechat_files\hongfei357_a567\msg\file\2026-08\10000525304068.txt";
|
|
var frontProdInfo = ConverterToPddFactory.Convert(filePath);
|
|
var isMatch = frontProdInfo != null;
|
|
}
|
|
|
|
[Test]
|
|
public void TestWXToPDDV3()
|
|
{
|
|
string filePath = @"C:\Users\chaih\Documents\xwechat_files\hongfei357_a567\msg\file\2026-08\10000247042728(1).json";
|
|
var frontProdInfo = ConverterToPddFactory.Convert(filePath);
|
|
var isMatch = frontProdInfo != null;
|
|
|
|
PDDProductInfo prodInfo = new PDDProductInfo();
|
|
prodInfo.detail = new PDDProductDetailInfo();
|
|
prodInfo.detail.sku = new List<sku_item>();
|
|
foreach (var skuItem in frontProdInfo.Skus)
|
|
{
|
|
sku_item skuInfo = new sku_item()
|
|
{
|
|
spec = new List<spec_item>()
|
|
};
|
|
|
|
|
|
var specList = skuItem.Spec.Split([';'], StringSplitOptions.RemoveEmptyEntries).ToList();
|
|
foreach (var spec in specList)
|
|
{
|
|
string specKey = spec.Split(':')[0];
|
|
string specValue = spec.Split(':')[1];
|
|
var specItem = frontProdInfo.Specs.FirstOrDefault(a => a.SpecKey == specKey && a.SpecValue == specValue);
|
|
if (specItem == null) continue;
|
|
skuInfo.spec.Add(new spec_item()
|
|
{
|
|
parent_name = specItem.SpecKey,
|
|
spec_name = specItem.SpecValue,
|
|
});
|
|
}
|
|
prodInfo.detail.sku.Add(skuInfo);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
[Test]
|
|
public void TestWXToPDDV4()
|
|
{
|
|
string filePath = @"C:\Users\chaih\Documents\xwechat_files\hongfei357_a567\msg\attach\cde4474908f6a5f2da5f7c82f4a8c5d0\2026-10\Rec\e65980801fd61508\F\0\10000182390569(1).txt";
|
|
var frontProdInfo = ConverterToPddFactory.Convert(filePath);
|
|
var isMatch = frontProdInfo != null;
|
|
Console.WriteLine(frontProdInfo.Skus.Count);
|
|
}
|
|
}
|
|
|
|
}
|