增加 导入外部微信数据
This commit is contained in:
1 parent
5ed558e343
commit
a9f7b1f831
13 files changed
+520
-21
No files matched your search
@@ -235,6 +235,7 @@
|
|||||||
<Compile Include="Model\Result\PDDResult\PDDFrontProductInfo3.cs" />
|
<Compile Include="Model\Result\PDDResult\PDDFrontProductInfo3.cs" />
|
||||||
<Compile Include="Model\Result\PDDResult\PDDFrontProductInfo5.cs" />
|
<Compile Include="Model\Result\PDDResult\PDDFrontProductInfo5.cs" />
|
||||||
<Compile Include="Model\Result\PDDResult\PDDFrontProductInfo4.cs" />
|
<Compile Include="Model\Result\PDDResult\PDDFrontProductInfo4.cs" />
|
||||||
|
<Compile Include="Model\Result\PlatformType.cs" />
|
||||||
<Compile Include="Model\Result\VDianShopLoginInfo.cs" />
|
<Compile Include="Model\Result\VDianShopLoginInfo.cs" />
|
||||||
<Compile Include="Model\Result\WXResult\DSRShopScoreInfo.cs" />
|
<Compile Include="Model\Result\WXResult\DSRShopScoreInfo.cs" />
|
||||||
<Compile Include="Model\Result\WXResult\WxActivityData.cs" />
|
<Compile Include="Model\Result\WXResult\WxActivityData.cs" />
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ namespace AllBase.Model.Result.PDDResult
|
|||||||
{
|
{
|
||||||
public class PDDFrontProductInfo5
|
public class PDDFrontProductInfo5
|
||||||
{
|
{
|
||||||
|
public PlatformType Platform { get; set; }
|
||||||
[Description("商品编号")]
|
[Description("商品编号")]
|
||||||
public long GoodsId { get; set; }
|
public long GoodsId { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -4,10 +4,11 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace TemuKJD.BLL
|
namespace AllBase.Model.Result
|
||||||
{
|
{
|
||||||
public enum PlatformType
|
public enum PlatformType
|
||||||
{
|
{
|
||||||
|
None,
|
||||||
PDD,
|
PDD,
|
||||||
WX,
|
WX,
|
||||||
}
|
}
|
||||||
@@ -13,15 +13,17 @@ namespace TemuKJD.BLL.ImportConverts
|
|||||||
private static List<IGoodsConverter> _converters = new List<IGoodsConverter>
|
private static List<IGoodsConverter> _converters = new List<IGoodsConverter>
|
||||||
{
|
{
|
||||||
new ConverterToPddV5(),
|
new ConverterToPddV5(),
|
||||||
|
new ConverterWXToPddV1(),
|
||||||
};
|
};
|
||||||
public static PDDFrontProductInfo5 Convert(string data)
|
public static PDDFrontProductInfo5 Convert(string filePath)
|
||||||
{
|
{
|
||||||
|
|
||||||
foreach (var item in _converters)
|
foreach (IGoodsConverter item in _converters)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (item.IsMatch(data))
|
item.ReadContent(filePath);
|
||||||
|
if (item.IsMatch())
|
||||||
{
|
{
|
||||||
return item.Convert();
|
return item.Convert();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using AllBase.Model.Result.PDDResult;
|
using AllBase.Model.Result;
|
||||||
|
using AllBase.Model.Result.PDDResult;
|
||||||
using CefSharp.DevTools.CSS;
|
using CefSharp.DevTools.CSS;
|
||||||
using NaiBa.Util.Extension;
|
using NaiBa.Util.Extension;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|||||||
@@ -0,0 +1,314 @@
|
|||||||
|
using AllBase.Model.Result;
|
||||||
|
using AllBase.Model.Result.PDDResult;
|
||||||
|
using NaiBa.Util.Extension;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace TemuKJD.BLL.ImportConverters
|
||||||
|
{
|
||||||
|
internal class ConverterWXToPddV1 : GoodsConverterBase
|
||||||
|
{
|
||||||
|
private JObject jsonRoot;
|
||||||
|
|
||||||
|
public override string ConverterName => "微信转拼多多数据源";
|
||||||
|
|
||||||
|
public override PlatformType Platform => PlatformType.WX;
|
||||||
|
|
||||||
|
|
||||||
|
protected override bool IsMatchProvider()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
jsonRoot = JsonConvert.DeserializeObject<JObject>(RawData);
|
||||||
|
if (jsonRoot == null) return false;
|
||||||
|
|
||||||
|
// 1. 检查 extra_service 是否存在且为对象类型
|
||||||
|
var extraService = jsonRoot.SelectToken("$.extra_service");
|
||||||
|
if (extraService == null || extraService.Type != JTokenType.Object) return false;
|
||||||
|
|
||||||
|
// 2. 检查 out_product_id 是否存在且为字符串类型(非空)
|
||||||
|
var outProductId = jsonRoot.SelectToken("$.out_product_id")?.ToString();
|
||||||
|
if (string.IsNullOrEmpty(outProductId)) return false;
|
||||||
|
|
||||||
|
// 3. 检查 skus 是否存在且为数组,且第一个元素包含 out_sku_id
|
||||||
|
var skus = jsonRoot.SelectToken("$.skus");
|
||||||
|
if (skus == null) return true;
|
||||||
|
if (skus.Type != JTokenType.Array) return false;
|
||||||
|
var skusArray = skus as JArray;
|
||||||
|
if (skusArray.Count == 0) return true;
|
||||||
|
|
||||||
|
var outSkuId = skusArray[0]?.SelectToken("$.out_sku_id")?.ToString();
|
||||||
|
if (string.IsNullOrEmpty(outSkuId)) return false;
|
||||||
|
|
||||||
|
// 三个条件全部通过
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
protected override PDDFrontProductInfo5 ConverterProvider()
|
||||||
|
{
|
||||||
|
var product = new PDDFrontProductInfo5();
|
||||||
|
|
||||||
|
product.Platform = Platform;
|
||||||
|
// 解析JSON数据
|
||||||
|
var jsonData = JsonConvert.DeserializeObject<JObject>(RawData);
|
||||||
|
product.GoodsId = Path.GetFileNameWithoutExtension(FilePath).ParseToLong();
|
||||||
|
// 商品基本信息
|
||||||
|
product.Title = jsonData["title"]?.Value<string>() ?? "";
|
||||||
|
product.Description = jsonData["short_title"]?.Value<string>() ?? "";
|
||||||
|
|
||||||
|
// 品牌ID - 转换为long
|
||||||
|
product.BrandId = jsonData["brand_id"]?.Value<long>() ?? 0;
|
||||||
|
|
||||||
|
// 类目信息
|
||||||
|
product.CategoryId = GetCategoryIdFromCats(jsonData);
|
||||||
|
product.CategoryPath = GetCategoryPathFromCats(jsonData);
|
||||||
|
|
||||||
|
// 主图
|
||||||
|
product.MainImages = GetMainImagesFromNewFormat(jsonData);
|
||||||
|
|
||||||
|
// 详情图
|
||||||
|
product.DetailImages = GetDetailImagesFromNewFormat(jsonData);
|
||||||
|
|
||||||
|
// 商品属性
|
||||||
|
product.Propertys = GetPropertiesFromNewFormat(jsonData);
|
||||||
|
|
||||||
|
// SKU和规格信息
|
||||||
|
product.Skus = GetSkusFromNewFormat(jsonData);
|
||||||
|
product.Specs = GetSpecsFromNewFormat(jsonData);
|
||||||
|
|
||||||
|
// 其他默认值
|
||||||
|
product.ThumbUrl = jsonData["head_imgs"]?[0]?.Value<string>() ?? "";
|
||||||
|
product.MallId = 0; // 新格式中没有mallID
|
||||||
|
product.Price = GetMinPrice(jsonData); // 从SKU中获取最低价
|
||||||
|
product.Videos = new List<string>(); // 新格式中没有视频信息
|
||||||
|
|
||||||
|
return product;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 从cats_v2中获取类目ID
|
||||||
|
/// </summary>
|
||||||
|
private int GetCategoryIdFromCats(JObject jsonData)
|
||||||
|
{
|
||||||
|
var cats = jsonData["cats_v2"] as JArray;
|
||||||
|
if (cats == null || cats.Count == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// 获取最后一个类目(最细分类目)
|
||||||
|
var lastCat = cats.Last;
|
||||||
|
return lastCat?["cat_id"]?.Value<int>() ?? 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 从cats_v2中获取类目路径
|
||||||
|
/// </summary>
|
||||||
|
private List<int> GetCategoryPathFromCats(JObject jsonData)
|
||||||
|
{
|
||||||
|
var result = new List<int>();
|
||||||
|
var cats = jsonData["cats_v2"] as JArray;
|
||||||
|
|
||||||
|
if (cats == null)
|
||||||
|
return result;
|
||||||
|
|
||||||
|
foreach (var cat in cats)
|
||||||
|
{
|
||||||
|
var catId = cat["cat_id"]?.Value<int>();
|
||||||
|
if (catId.HasValue && catId.Value > 0)
|
||||||
|
result.Add(catId.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取主图(新格式)
|
||||||
|
/// </summary>
|
||||||
|
private List<string> GetMainImagesFromNewFormat(JObject jsonData)
|
||||||
|
{
|
||||||
|
var result = new List<string>();
|
||||||
|
var headImgs = jsonData["head_imgs"] as JArray;
|
||||||
|
|
||||||
|
if (headImgs == null)
|
||||||
|
return result;
|
||||||
|
|
||||||
|
foreach (var img in headImgs)
|
||||||
|
{
|
||||||
|
var url = img?.Value<string>();
|
||||||
|
if (!string.IsNullOrEmpty(url))
|
||||||
|
result.Add(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取详情图(新格式)
|
||||||
|
/// </summary>
|
||||||
|
private List<string> GetDetailImagesFromNewFormat(JObject jsonData)
|
||||||
|
{
|
||||||
|
var result = new List<string>();
|
||||||
|
var descInfo = jsonData["desc_info"];
|
||||||
|
|
||||||
|
if (descInfo == null)
|
||||||
|
return result;
|
||||||
|
|
||||||
|
var imgs = descInfo["imgs"] as JArray;
|
||||||
|
if (imgs == null)
|
||||||
|
return result;
|
||||||
|
|
||||||
|
foreach (var img in imgs)
|
||||||
|
{
|
||||||
|
var url = img?.Value<string>();
|
||||||
|
if (!string.IsNullOrEmpty(url))
|
||||||
|
result.Add(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取商品属性(新格式)
|
||||||
|
/// </summary>
|
||||||
|
private List<Property> GetPropertiesFromNewFormat(JObject jsonData)
|
||||||
|
{
|
||||||
|
var result = new List<Property>();
|
||||||
|
var attrs = jsonData["attrs"] as JArray;
|
||||||
|
|
||||||
|
if (attrs == null)
|
||||||
|
return result;
|
||||||
|
|
||||||
|
foreach (var attr in attrs)
|
||||||
|
{
|
||||||
|
var key = attr["attr_key"]?.Value<string>();
|
||||||
|
var value = attr["attr_value"]?.Value<string>();
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(key) && !string.IsNullOrEmpty(value))
|
||||||
|
{
|
||||||
|
result.Add(new Property
|
||||||
|
{
|
||||||
|
Key = key,
|
||||||
|
Value = value
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取SKU(新格式)
|
||||||
|
/// </summary>
|
||||||
|
private List<SkuItem> GetSkusFromNewFormat(JObject jsonData)
|
||||||
|
{
|
||||||
|
var result = new List<SkuItem>();
|
||||||
|
var skus = jsonData["skus"] as JArray;
|
||||||
|
|
||||||
|
if (skus == null)
|
||||||
|
return result;
|
||||||
|
|
||||||
|
foreach (var sku in skus)
|
||||||
|
{
|
||||||
|
var skuAttrs = sku["sku_attrs"] as JArray;
|
||||||
|
var specValues = new List<string>();
|
||||||
|
|
||||||
|
if (skuAttrs != null)
|
||||||
|
{
|
||||||
|
foreach (var attr in skuAttrs)
|
||||||
|
{
|
||||||
|
var key = attr["attr_key"]?.Value<string>();
|
||||||
|
var value = attr["attr_value"]?.Value<string>();
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(key) && !string.IsNullOrEmpty(value))
|
||||||
|
specValues.Add($"{key}:{value}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// sale_price 是分,需要转换为元
|
||||||
|
var salePriceInCents = sku["sale_price"]?.Value<decimal>() ?? 0;
|
||||||
|
var salePriceInYuan = salePriceInCents / 100;
|
||||||
|
|
||||||
|
result.Add(new SkuItem
|
||||||
|
{
|
||||||
|
SkuId = sku["out_sku_id"]?.Value<string>() ?? "",
|
||||||
|
Spec = string.Join(";", specValues),
|
||||||
|
Price = salePriceInYuan,
|
||||||
|
OriginalPrice = salePriceInCents.ToString(), // 保留原始价格(分)
|
||||||
|
Stock = 999, // 新格式中没有库存,设置默认值
|
||||||
|
SpecImage = sku["thumb_img"]?.Value<string>() ?? ""
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取规格(新格式)
|
||||||
|
/// </summary>
|
||||||
|
private List<SpecItem> GetSpecsFromNewFormat(JObject jsonData)
|
||||||
|
{
|
||||||
|
var result = new List<SpecItem>();
|
||||||
|
var skus = jsonData["skus"] as JArray;
|
||||||
|
|
||||||
|
if (skus == null)
|
||||||
|
return result;
|
||||||
|
|
||||||
|
foreach (var sku in skus)
|
||||||
|
{
|
||||||
|
var skuAttrs = sku["sku_attrs"] as JArray;
|
||||||
|
if (skuAttrs == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
foreach (var attr in skuAttrs)
|
||||||
|
{
|
||||||
|
var specKey = attr["attr_key"]?.Value<string>() ?? "";
|
||||||
|
var specValue = attr["attr_value"]?.Value<string>() ?? "";
|
||||||
|
|
||||||
|
// 去重
|
||||||
|
if (result.Any(x => x.SpecKey == specKey && x.SpecValue == specValue))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
result.Add(new SpecItem
|
||||||
|
{
|
||||||
|
SpecKey = specKey,
|
||||||
|
SpecValue = specValue,
|
||||||
|
SpecKeyId = 0, // 新格式中没有ID
|
||||||
|
SpecValueId = 0
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取最低价格
|
||||||
|
/// </summary>
|
||||||
|
private decimal GetMinPrice(JObject jsonData)
|
||||||
|
{
|
||||||
|
var skus = jsonData["skus"] as JArray;
|
||||||
|
if (skus == null || skus.Count == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
var minPrice = decimal.MaxValue;
|
||||||
|
foreach (var sku in skus)
|
||||||
|
{
|
||||||
|
var price = sku["sale_price"]?.Value<decimal>() ?? 0;
|
||||||
|
if (price > 0 && price < minPrice)
|
||||||
|
minPrice = price;
|
||||||
|
}
|
||||||
|
|
||||||
|
return minPrice > 0 ? minPrice / 100 : 0; // 转换为元
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,11 +1,14 @@
|
|||||||
using AllBase.Model.Result.PDDResult;
|
using AllBase.Model.Result;
|
||||||
|
using AllBase.Model.Result.PDDResult;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Web.UI.WebControls;
|
||||||
|
|
||||||
namespace TemuKJD.BLL.ImportConverters
|
namespace TemuKJD.BLL.ImportConverters
|
||||||
{
|
{
|
||||||
@@ -29,10 +32,15 @@ namespace TemuKJD.BLL.ImportConverters
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
PlatformType Platform { get; }
|
PlatformType Platform { get; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// 读取内容
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filePath"></param>
|
||||||
|
void ReadContent(string filePath);
|
||||||
|
/// <summary>
|
||||||
/// 判断是否匹配当前转换器
|
/// 判断是否匹配当前转换器
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>是否匹配</returns>
|
/// <returns>是否匹配</returns>
|
||||||
bool IsMatch(string data);
|
bool IsMatch();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 转换为标准商品模型
|
/// 转换为标准商品模型
|
||||||
@@ -43,15 +51,29 @@ namespace TemuKJD.BLL.ImportConverters
|
|||||||
public abstract class GoodsConverterBase : IGoodsConverter
|
public abstract class GoodsConverterBase : IGoodsConverter
|
||||||
{
|
{
|
||||||
private bool _isMatch = false;
|
private bool _isMatch = false;
|
||||||
|
public string FilePath { get; private set; }
|
||||||
public string RawData { get; private set; }
|
public string RawData { get; private set; }
|
||||||
public abstract string ConverterName { get; }
|
public abstract string ConverterName { get; }
|
||||||
public abstract PlatformType Platform { get; }
|
public abstract PlatformType Platform { get; }
|
||||||
|
|
||||||
|
void IGoodsConverter.ReadContent(string filePath)
|
||||||
|
{
|
||||||
|
ReadContent(filePath);
|
||||||
|
}
|
||||||
|
protected virtual void ReadContent(string filePath)
|
||||||
|
{
|
||||||
|
if (File.Exists(filePath) == false) throw new Exception("文件不存在");
|
||||||
|
FilePath = filePath;
|
||||||
|
using (StreamReader sr = new StreamReader(filePath, Work.Api.UploadPinduoduoMain.GetFileEncoding(filePath)))
|
||||||
|
{
|
||||||
|
RawData = sr.ReadToEnd();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public virtual bool IsMatch(string data)
|
|
||||||
|
public virtual bool IsMatch()
|
||||||
{
|
{
|
||||||
_isMatch = true;
|
_isMatch = true;
|
||||||
RawData = data;
|
|
||||||
return IsMatchProvider();
|
return IsMatchProvider();
|
||||||
}
|
}
|
||||||
protected abstract bool IsMatchProvider();
|
protected abstract bool IsMatchProvider();
|
||||||
@@ -83,8 +105,5 @@ namespace TemuKJD.BLL.ImportConverters
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected abstract PDDFrontProductInfo5 ConverterProvider();
|
protected abstract PDDFrontProductInfo5 ConverterProvider();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1672,12 +1672,12 @@ namespace TemuKJD.BLL
|
|||||||
/// <param name="specialProdType"></param>
|
/// <param name="specialProdType"></param>
|
||||||
/// <param name="IsCollectAuthorityUser"></param>
|
/// <param name="IsCollectAuthorityUser"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public string PddFrontToPddBackConvertFactory(string outProdJson, bool UpdateOldData = true, string specialProdType = null, bool IsCollectAuthorityUser = false)
|
public string PddFrontToPddBackConvertFactory(string filePath, bool UpdateOldData = true, string specialProdType = null, bool IsCollectAuthorityUser = false)
|
||||||
{
|
{
|
||||||
PDDFrontProductInfo5 frontProdInfo = null;
|
PDDFrontProductInfo5 frontProdInfo = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
frontProdInfo = ConverterToPddFactory.Convert(outProdJson);
|
frontProdInfo = ConverterToPddFactory.Convert(filePath);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -2016,7 +2016,14 @@ namespace TemuKJD.BLL
|
|||||||
return "已存在相同id商品,跳过";
|
return "已存在相同id商品,跳过";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
string product_get_type = "多多外部数据";
|
||||||
|
|
||||||
|
switch (frontProdInfo.Platform)
|
||||||
|
{
|
||||||
|
case PlatformType.WX:
|
||||||
|
product_get_type = "微信外部数据";
|
||||||
|
break;
|
||||||
|
}
|
||||||
var data = Work.UserLogin.GetSignaturex() +
|
var data = Work.UserLogin.GetSignaturex() +
|
||||||
"&from_shop_id=" + frontProdInfo.MallId +
|
"&from_shop_id=" + frontProdInfo.MallId +
|
||||||
"&spu_id=" + prodInfo.detail.goods_id.ParseToString() + collectAuthorityTag +
|
"&spu_id=" + prodInfo.detail.goods_id.ParseToString() + collectAuthorityTag +
|
||||||
@@ -2033,7 +2040,8 @@ namespace TemuKJD.BLL
|
|||||||
"&main_img=" + HttpUtility.UrlEncode(dbProd.main_img, Encoding.UTF8) +
|
"&main_img=" + HttpUtility.UrlEncode(dbProd.main_img, Encoding.UTF8) +
|
||||||
"&sale_count=" + HttpUtility.UrlEncode(prodInfo.sale_count, Encoding.UTF8) +
|
"&sale_count=" + HttpUtility.UrlEncode(prodInfo.sale_count, Encoding.UTF8) +
|
||||||
"&sale_count_text=" + HttpUtility.UrlEncode(prodInfo.sale_count_text, Encoding.UTF8) +
|
"&sale_count_text=" + HttpUtility.UrlEncode(prodInfo.sale_count_text, Encoding.UTF8) +
|
||||||
"&product_get_type=" + HttpUtility.UrlEncode("多多外部数据", Encoding.UTF8);
|
"&product_get_type=" + HttpUtility.UrlEncode(product_get_type, Encoding.UTF8);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(specialProdType))
|
if (!string.IsNullOrEmpty(specialProdType))
|
||||||
data += "&special_prod_type=" + HttpUtility.UrlEncode(specialProdType, Encoding.UTF8);
|
data += "&special_prod_type=" + HttpUtility.UrlEncode(specialProdType, Encoding.UTF8);
|
||||||
if (IsCollectAuthorityUser)
|
if (IsCollectAuthorityUser)
|
||||||
|
|||||||
+1
-1
@@ -144,6 +144,7 @@
|
|||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="BLL\AuthorBLL.cs" />
|
<Compile Include="BLL\AuthorBLL.cs" />
|
||||||
<Compile Include="BLL\HttpResponseWxAiTalkBLL.cs" />
|
<Compile Include="BLL\HttpResponseWxAiTalkBLL.cs" />
|
||||||
|
<Compile Include="BLL\ImportConverters\ConverterWXToPddV1.cs" />
|
||||||
<Compile Include="BLL\ImportConverters\ConvertToPddFactory.cs" />
|
<Compile Include="BLL\ImportConverters\ConvertToPddFactory.cs" />
|
||||||
<Compile Include="BLL\ImportConverters\ConverterToPddV5.cs" />
|
<Compile Include="BLL\ImportConverters\ConverterToPddV5.cs" />
|
||||||
<Compile Include="BLL\ImportConverters\IGoodsConverter.cs" />
|
<Compile Include="BLL\ImportConverters\IGoodsConverter.cs" />
|
||||||
@@ -152,7 +153,6 @@
|
|||||||
<Compile Include="BLL\Pdd\PddApiHelper.cs" />
|
<Compile Include="BLL\Pdd\PddApiHelper.cs" />
|
||||||
<Compile Include="BLL\Pdd\PddApi.cs" />
|
<Compile Include="BLL\Pdd\PddApi.cs" />
|
||||||
<Compile Include="BLL\PDDProdFormConverter.cs" />
|
<Compile Include="BLL\PDDProdFormConverter.cs" />
|
||||||
<Compile Include="BLL\PlatformType.cs" />
|
|
||||||
<Compile Include="BLL\ProductSelectBLL.cs" />
|
<Compile Include="BLL\ProductSelectBLL.cs" />
|
||||||
<Compile Include="BLL\Tools\DownloadBLL.cs" />
|
<Compile Include="BLL\Tools\DownloadBLL.cs" />
|
||||||
<Compile Include="BLL\VDian\VDianUpProdMappingApiBLL.cs" />
|
<Compile Include="BLL\VDian\VDianUpProdMappingApiBLL.cs" />
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ namespace TemuKJD.WXForms.ProductForms
|
|||||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle17 = new System.Windows.Forms.DataGridViewCellStyle();
|
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle17 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(WXUserCollectAuthProdListForm));
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(WXUserCollectAuthProdListForm));
|
||||||
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
|
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
|
||||||
|
this.btn_import_wx = new DevComponents.DotNetBar.PanelEx();
|
||||||
this.btnBatchEditCate = new DevComponents.DotNetBar.PanelEx();
|
this.btnBatchEditCate = new DevComponents.DotNetBar.PanelEx();
|
||||||
this.cmbBatchEditNotes = new System.Windows.Forms.ComboBox();
|
this.cmbBatchEditNotes = new System.Windows.Forms.ComboBox();
|
||||||
this.btnEditNotes = new DevComponents.DotNetBar.PanelEx();
|
this.btnEditNotes = new DevComponents.DotNetBar.PanelEx();
|
||||||
@@ -176,6 +177,7 @@ namespace TemuKJD.WXForms.ProductForms
|
|||||||
//
|
//
|
||||||
// splitContainer1.Panel1
|
// splitContainer1.Panel1
|
||||||
//
|
//
|
||||||
|
this.splitContainer1.Panel1.Controls.Add(this.btn_import_wx);
|
||||||
this.splitContainer1.Panel1.Controls.Add(this.btnBatchEditCate);
|
this.splitContainer1.Panel1.Controls.Add(this.btnBatchEditCate);
|
||||||
this.splitContainer1.Panel1.Controls.Add(this.cmbBatchEditNotes);
|
this.splitContainer1.Panel1.Controls.Add(this.cmbBatchEditNotes);
|
||||||
this.splitContainer1.Panel1.Controls.Add(this.btnEditNotes);
|
this.splitContainer1.Panel1.Controls.Add(this.btnEditNotes);
|
||||||
@@ -201,6 +203,31 @@ namespace TemuKJD.WXForms.ProductForms
|
|||||||
this.splitContainer1.SplitterDistance = 115;
|
this.splitContainer1.SplitterDistance = 115;
|
||||||
this.splitContainer1.TabIndex = 1;
|
this.splitContainer1.TabIndex = 1;
|
||||||
//
|
//
|
||||||
|
// btn_import_wx
|
||||||
|
//
|
||||||
|
this.btn_import_wx.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.btn_import_wx.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
|
||||||
|
this.btn_import_wx.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||||
|
this.btn_import_wx.DisabledBackColor = System.Drawing.Color.Empty;
|
||||||
|
this.btn_import_wx.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||||
|
this.btn_import_wx.Location = new System.Drawing.Point(1214, 80);
|
||||||
|
this.btn_import_wx.Name = "btn_import_wx";
|
||||||
|
this.btn_import_wx.Size = new System.Drawing.Size(105, 25);
|
||||||
|
this.btn_import_wx.Style.Alignment = System.Drawing.StringAlignment.Center;
|
||||||
|
this.btn_import_wx.Style.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
|
||||||
|
this.btn_import_wx.Style.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
|
||||||
|
this.btn_import_wx.Style.BorderColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder;
|
||||||
|
this.btn_import_wx.Style.BorderDashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
|
||||||
|
this.btn_import_wx.Style.BorderSide = DevComponents.DotNetBar.eBorderSide.None;
|
||||||
|
this.btn_import_wx.Style.ForeColor.Color = System.Drawing.Color.White;
|
||||||
|
this.btn_import_wx.Style.GradientAngle = 90;
|
||||||
|
this.btn_import_wx.StyleMouseOver.Alignment = System.Drawing.StringAlignment.Center;
|
||||||
|
this.btn_import_wx.StyleMouseOver.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(102)))), ((int)(((byte)(255)))));
|
||||||
|
this.btn_import_wx.StyleMouseOver.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(102)))), ((int)(((byte)(255)))));
|
||||||
|
this.btn_import_wx.TabIndex = 1162;
|
||||||
|
this.btn_import_wx.Text = "导入微信数据";
|
||||||
|
this.btn_import_wx.Click += new System.EventHandler(this.bt_import_wx_Click);
|
||||||
|
//
|
||||||
// btnBatchEditCate
|
// btnBatchEditCate
|
||||||
//
|
//
|
||||||
this.btnBatchEditCate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
this.btnBatchEditCate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
@@ -339,7 +366,7 @@ namespace TemuKJD.WXForms.ProductForms
|
|||||||
this.btnOut1688ProdSaveDb.Cursor = System.Windows.Forms.Cursors.Hand;
|
this.btnOut1688ProdSaveDb.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||||
this.btnOut1688ProdSaveDb.DisabledBackColor = System.Drawing.Color.Empty;
|
this.btnOut1688ProdSaveDb.DisabledBackColor = System.Drawing.Color.Empty;
|
||||||
this.btnOut1688ProdSaveDb.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
this.btnOut1688ProdSaveDb.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||||
this.btnOut1688ProdSaveDb.Location = new System.Drawing.Point(1221, 78);
|
this.btnOut1688ProdSaveDb.Location = new System.Drawing.Point(1108, 80);
|
||||||
this.btnOut1688ProdSaveDb.Name = "btnOut1688ProdSaveDb";
|
this.btnOut1688ProdSaveDb.Name = "btnOut1688ProdSaveDb";
|
||||||
this.btnOut1688ProdSaveDb.Size = new System.Drawing.Size(105, 25);
|
this.btnOut1688ProdSaveDb.Size = new System.Drawing.Size(105, 25);
|
||||||
this.btnOut1688ProdSaveDb.Style.Alignment = System.Drawing.StringAlignment.Center;
|
this.btnOut1688ProdSaveDb.Style.Alignment = System.Drawing.StringAlignment.Center;
|
||||||
@@ -364,7 +391,7 @@ namespace TemuKJD.WXForms.ProductForms
|
|||||||
this.btnImportPddOutData.Cursor = System.Windows.Forms.Cursors.Hand;
|
this.btnImportPddOutData.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||||
this.btnImportPddOutData.DisabledBackColor = System.Drawing.Color.Empty;
|
this.btnImportPddOutData.DisabledBackColor = System.Drawing.Color.Empty;
|
||||||
this.btnImportPddOutData.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
this.btnImportPddOutData.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||||
this.btnImportPddOutData.Location = new System.Drawing.Point(1115, 78);
|
this.btnImportPddOutData.Location = new System.Drawing.Point(1002, 80);
|
||||||
this.btnImportPddOutData.Name = "btnImportPddOutData";
|
this.btnImportPddOutData.Name = "btnImportPddOutData";
|
||||||
this.btnImportPddOutData.Size = new System.Drawing.Size(105, 25);
|
this.btnImportPddOutData.Size = new System.Drawing.Size(105, 25);
|
||||||
this.btnImportPddOutData.Style.Alignment = System.Drawing.StringAlignment.Center;
|
this.btnImportPddOutData.Style.Alignment = System.Drawing.StringAlignment.Center;
|
||||||
@@ -1749,5 +1776,6 @@ namespace TemuKJD.WXForms.ProductForms
|
|||||||
public System.Windows.Forms.ComboBox cmbNotes;
|
public System.Windows.Forms.ComboBox cmbNotes;
|
||||||
public System.Windows.Forms.ComboBox cmbBatchEditNotes;
|
public System.Windows.Forms.ComboBox cmbBatchEditNotes;
|
||||||
private DevComponents.DotNetBar.PanelEx btnBatchEditCate;
|
private DevComponents.DotNetBar.PanelEx btnBatchEditCate;
|
||||||
|
private DevComponents.DotNetBar.PanelEx btn_import_wx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -16,6 +16,7 @@ using System.Drawing;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
using System.Security.Cryptography;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
@@ -1152,7 +1153,7 @@ namespace TemuKJD.WXForms.ProductForms
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rst = new PDDProdFormConverter().PddFrontToPddBackConvertFactory(sourceContent, true, null, true);
|
rst = new PDDProdFormConverter().PddFrontToPddBackConvertFactory(path, true, null, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -1185,6 +1186,53 @@ namespace TemuKJD.WXForms.ProductForms
|
|||||||
bool isCollectAuthorityUser = true;
|
bool isCollectAuthorityUser = true;
|
||||||
Get1688ProductForm.Out1688ProductImport(isCollectAuthorityUser, this.statusBar, this.pbLoading, OutProdSaveDbCallBack);
|
Get1688ProductForm.Out1688ProductImport(isCollectAuthorityUser, this.statusBar, this.pbLoading, OutProdSaveDbCallBack);
|
||||||
}
|
}
|
||||||
|
private void bt_import_wx_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
OpenFileDialog openFileDialog = new OpenFileDialog();
|
||||||
|
openFileDialog.Multiselect = true;
|
||||||
|
// 设置过滤条件,只显示文本文件
|
||||||
|
openFileDialog.Filter = "文本文件 (*.txt)|*.txt|All files (*.*)|*.*";
|
||||||
|
// 显示对话框并获取结果
|
||||||
|
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
var filePathLst = openFileDialog.FileNames.ToList();
|
||||||
|
int successNum = 0;
|
||||||
|
int failedNum = 0;
|
||||||
|
foreach (var filePath in filePathLst)
|
||||||
|
{
|
||||||
|
string sourceContent = "";
|
||||||
|
string content = "";
|
||||||
|
string rst = "商品未识别";
|
||||||
|
try
|
||||||
|
{
|
||||||
|
rst = new PDDProdFormConverter().PddFrontToPddBackConvertFactory(filePath, true, null, true);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
rst = ex.Message;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(rst))
|
||||||
|
successNum++;
|
||||||
|
else
|
||||||
|
failedNum++;
|
||||||
|
|
||||||
|
Invoke(new Action(() =>
|
||||||
|
{
|
||||||
|
this.statusBar.UpdateProgressBar(this.statusBar.pgbTaskProgress.Value + 1);
|
||||||
|
this.statusBar.lblTaskStatus.Text = "正在导入,尝试导入" + (successNum + failedNum) + ",成功" + successNum + ",失败" + failedNum;
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
SearchDbProd(1, " 导入完成,尝试导入" + (successNum + failedNum) + ",成功" + successNum + ",失败" + failedNum);
|
||||||
|
Invoke(new Action(() =>
|
||||||
|
{
|
||||||
|
pbLoading.Visible = false;
|
||||||
|
this.statusBar.lblTaskStatus.Text = "导入完成,尝试导入" + (successNum + failedNum) + ",成功" + successNum + ",失败" + failedNum;
|
||||||
|
BaseMsgForm.ShowInfo("导入完成!");
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void OutProdSaveDbCallBack(object msg)
|
void OutProdSaveDbCallBack(object msg)
|
||||||
{
|
{
|
||||||
@@ -1290,5 +1338,7 @@ namespace TemuKJD.WXForms.ProductForms
|
|||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
SearchDbProd(this.ucSplitPage1.CurrentPage);
|
SearchDbProd(this.ucSplitPage1.CurrentPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net9.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using TemuKJD.BLL;
|
using TemuKJD.BLL;
|
||||||
|
using TemuKJD.BLL.ImportConverts;
|
||||||
|
|
||||||
namespace KJD.Test
|
namespace KJD.Test
|
||||||
{
|
{
|
||||||
@@ -13,7 +14,80 @@ namespace KJD.Test
|
|||||||
public void Test1()
|
public void Test1()
|
||||||
{
|
{
|
||||||
string json = File.ReadAllText(@"C:\Users\chaih\Documents\xwechat_files\hongfei357_a567\msg\file\2026-08\850\531430339344.txt");
|
string json = File.ReadAllText(@"C:\Users\chaih\Documents\xwechat_files\hongfei357_a567\msg\file\2026-08\850\531430339344.txt");
|
||||||
new PDDProdFormConverter().PddFrontToPddBackConvertFactory(json);
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[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}");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user