This commit is contained in:
chfei authored and chfei committed 2026-09-14 09:16:59 +08:00
1 parent 0a3e5af6a9
commit c2dcedd238
59 files changed
+2053 -1274

No files matched your search

@@ -1,5 +1,6 @@
using AllBase;
using AllBase.Extension;
using NaiBa.Util.Extension;
using AllBase.Helper;
using AllBase.Model.Config;
using AllBase.Model.DBModel;
@@ -20,7 +21,6 @@ using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using Work;
namespace Store.Product.Publish.Steps.Wx;
@@ -35,16 +35,16 @@ public sealed class MatchProductPropertiesStep : WxProductPublishStepBase
protected override Task ExecuteProvider(WXPublishContext context, CancellationToken cancellationToken)
{
//真丝、蚕丝、香云纱、羊绒、羊毛、羊羔毛、羽绒、皮草
upProdParam.product.info.param = new List<wxPropParam>(); // 商品属性值
productAttr = upProdParam.product.info.category.LastOrDefault().catInfo.productAttr;
context.Parameters.ProductParameter.product.info.param = new List<wxPropParam>(); // 商品属性值
context.Parameters.ProductAttr = context.Parameters.ProductParameter.product.info.category.LastOrDefault().catInfo.productAttr;
// 直接转换微信回采
if (BaseClass.UserAuthority.ParseToString().Contains("微信回采") && chkUseWXComplateProd.Checked && dbProd.has_wx_format == "1" && wxEditProdInfo != null)
if (BaseClass.UserAuthority.ParseToString().Contains("微信回采") && context.Parameters.IsUseWXComplateProd && context.Product.HasWxFormat == "1" && context.Parameters.WxEditProdInfo != null)
{
foreach (var wxEditPropParam in wxEditProdInfo.product.info.param)
foreach (var wxEditPropParam in context.Parameters.WxEditProdInfo.product.info.param)
{
var wxPropParam = new wxPropParam();
upProdParam.product.info.param.Add(wxPropParam);
context.Parameters.ProductParameter.product.info.param.Add(wxPropParam);
foreach (var wxEditCategoryParam in wxEditPropParam.categorys)
{
var wxCategoryParam = new categoryPropParam()
@@ -63,18 +63,18 @@ public sealed class MatchProductPropertiesStep : WxProductPublishStepBase
}
}
// 直接转换微信店采
else if (dbProd.product_get_type_text == "微信店采")
else if (context.Product.ProductGetTypeText == "微信店采")
{
foreach (var wxEditPropParam in wxEditProdInfo.product.info.param)
foreach (var wxEditPropParam in context.Parameters.WxEditProdInfo.product.info.param)
{
var wxPropParam = new wxPropParam();
upProdParam.product.info.param.Add(wxPropParam);
context.Parameters.ProductParameter.product.info.param.Add(wxPropParam);
foreach (var wxEditCategoryParam in wxEditPropParam.categorys)
{
// 修改书名
if (wxEditPropParam.categorys.FirstOrDefault().name == "书名" && wxEditCategoryParam == wxEditPropParam.categorys.LastOrDefault())
{
wxEditCategoryParam.name = prodTitle;
wxEditCategoryParam.name = context.Product.Title;
}
var wxCategoryParam = new categoryPropParam()
{
@@ -93,7 +93,7 @@ public sealed class MatchProductPropertiesStep : WxProductPublishStepBase
}
else
{
foreach (var propInfo in prodInfo.property.goods_properties)
foreach (var propInfo in context.Parameters.ProdInfo.property.goods_properties)
{
if (propInfo.name == "容量")
{
@@ -107,9 +107,9 @@ public sealed class MatchProductPropertiesStep : WxProductPublishStepBase
continue;
var attr = productAttr.attr.FirstOrDefault(r => r.name == propInfo.name);
var attr = context.Parameters.ProductAttr.attr.FirstOrDefault(r => r.name == propInfo.name);
if (attr == null)
attr = productAttr.attr.FirstOrDefault(r => r.name.Replace("填充材料", "填充材质") == propInfo.name ||
attr = context.Parameters.ProductAttr.attr.FirstOrDefault(r => r.name.Replace("填充材料", "填充材质") == propInfo.name ||
r.name.Replace("材质", "材质种类") == propInfo.name);
// 材质 产品名称 适用年龄 面料 生产企业名称 CCC证书编号 尺寸(长) 尺寸(宽) 尺寸(高) 物品(含配件)清单 型号 产品名称
if (propInfo.name == "生产日期" && propInfo.values.Count > 0)
@@ -121,69 +121,69 @@ public sealed class MatchProductPropertiesStep : WxProductPublishStepBase
{
if (propInfo.name.Contains("面料俗称"))
{
attr = productAttr.attr.FirstOrDefault(r => r.name == "面料材质");
attr = context.Parameters.ProductAttr.attr.FirstOrDefault(r => r.name == "面料材质");
}
if (propInfo.name.Contains("适用年龄"))
{
attr = productAttr.attr.FirstOrDefault(r => r.name == "适用年龄" || r.name == "适用年龄段");
attr = context.Parameters.ProductAttr.attr.FirstOrDefault(r => r.name == "适用年龄" || r.name == "适用年龄段");
}
if (propInfo.name.Contains("填充物"))
{
attr = productAttr.attr.FirstOrDefault(r => r.name == "填充物种类" || r.name == "填充物");
attr = context.Parameters.ProductAttr.attr.FirstOrDefault(r => r.name == "填充物种类" || r.name == "填充物");
}
// 书籍类目属性匹配
if (upProdParam.product.info.category.FirstOrDefault()?.name == "图书" || prodInfo.detail.cats.FirstOrDefault() == "书籍/杂志/报纸")
if (context.Parameters.ProductParameter.product.info.category.FirstOrDefault()?.name == "图书" || context.Parameters.ProdInfo.detail.cats.FirstOrDefault() == "书籍/杂志/报纸")
{
if (propInfo.name == "出版社名称")
attr = productAttr.attr.FirstOrDefault(r => r.name == "出版社名称");
else if ((propInfo.name == "ISBN编号" || propInfo.name == "书号") && !prodInfo.property.goods_properties.Any(p => p.name == "ISBN版号/CN刊号"))
attr = productAttr.attr.FirstOrDefault(r => r.name == "ISBN版号/CN刊号");
attr = context.Parameters.ProductAttr.attr.FirstOrDefault(r => r.name == "出版社名称");
else if ((propInfo.name == "ISBN编号" || propInfo.name == "书号") && !context.Parameters.ProdInfo.property.goods_properties.Any(p => p.name == "ISBN版号/CN刊号"))
attr = context.Parameters.ProductAttr.attr.FirstOrDefault(r => r.name == "ISBN版号/CN刊号");
else if (propInfo.name == "书名")
attr = productAttr.attr.FirstOrDefault(r => r.name == "书名");
attr = context.Parameters.ProductAttr.attr.FirstOrDefault(r => r.name == "书名");
else if (propInfo.name == "定价")
attr = productAttr.attr.FirstOrDefault(r => r.name == "定价");
attr = context.Parameters.ProductAttr.attr.FirstOrDefault(r => r.name == "定价");
else if (propInfo.name == "作者")
attr = productAttr.attr.FirstOrDefault(r => r.name == "作者");
attr = context.Parameters.ProductAttr.attr.FirstOrDefault(r => r.name == "作者");
else if (propInfo.name == "出版时间")
attr = productAttr.attr.FirstOrDefault(r => r.name == "出版时间");
attr = context.Parameters.ProductAttr.attr.FirstOrDefault(r => r.name == "出版时间");
else if (propInfo.name == "版次")
attr = productAttr.attr.FirstOrDefault(r => r.name == "版次");
attr = context.Parameters.ProductAttr.attr.FirstOrDefault(r => r.name == "版次");
else if (propInfo.name == "装帧类型")
attr = productAttr.attr.FirstOrDefault(r => r.name == "包装");
attr = context.Parameters.ProductAttr.attr.FirstOrDefault(r => r.name == "包装");
else if (propInfo.name == "包册数")
attr = productAttr.attr.FirstOrDefault(r => r.name == "图书册数");
attr = context.Parameters.ProductAttr.attr.FirstOrDefault(r => r.name == "图书册数");
}
if (upProdParam.product.info.category.FirstOrDefault()?.name == "食品饮料" || prodInfo.detail.cats.FirstOrDefault() == "食品饮料")
if (context.Parameters.ProductParameter.product.info.category.FirstOrDefault()?.name == "食品饮料" || context.Parameters.ProdInfo.detail.cats.FirstOrDefault() == "食品饮料")
{
if (propInfo.name == "厂名")
attr = productAttr.attr.FirstOrDefault(r => r.name == "生产企业名称");
attr = context.Parameters.ProductAttr.attr.FirstOrDefault(r => r.name == "生产企业名称");
else if (propInfo.name == "食品生产许可证编号")
attr = productAttr.attr.FirstOrDefault(r => r.name == "食品生产许可证编号");
attr = context.Parameters.ProductAttr.attr.FirstOrDefault(r => r.name == "食品生产许可证编号");
else if (propInfo.name == "产品标准号")
attr = productAttr.attr.FirstOrDefault(r => r.name == "产品标准号");
attr = context.Parameters.ProductAttr.attr.FirstOrDefault(r => r.name == "产品标准号");
else if (propInfo.name == "保质期")
attr = productAttr.attr.FirstOrDefault(r => r.name == "保质期");
attr = context.Parameters.ProductAttr.attr.FirstOrDefault(r => r.name == "保质期");
else if (propInfo.name == "生产日期")
{
attr = productAttr.attr.FirstOrDefault(r => r.name == "生产日期");
attr = context.Parameters.ProductAttr.attr.FirstOrDefault(r => r.name == "生产日期");
}
else if (propInfo.name == "产品重量")
{
attr = productAttr.attr.FirstOrDefault(r => r.name == "单件净含量");
attr = context.Parameters.ProductAttr.attr.FirstOrDefault(r => r.name == "单件净含量");
if (attr == null)
attr = productAttr.attr.FirstOrDefault(r => r.name == "净含量");
attr = context.Parameters.ProductAttr.attr.FirstOrDefault(r => r.name == "净含量");
}
else if (propInfo.name == "包装方式")
attr = productAttr.attr.FirstOrDefault(r => r.name == "包装方式");
attr = context.Parameters.ProductAttr.attr.FirstOrDefault(r => r.name == "包装方式");
//else if (propInfo.name == "配料表")
// attr = productAttr.attr.FirstOrDefault(r => r.name == "配料表");
//else if (propInfo.name == "联系方式")
// attr = productAttr.attr.FirstOrDefault(r => r.name == "联系方式");
else if (propInfo.name == "厂址")
attr = productAttr.attr.FirstOrDefault(r => r.name == "地址");
attr = context.Parameters.ProductAttr.attr.FirstOrDefault(r => r.name == "地址");
else if (propInfo.name == "储藏方法")
attr = productAttr.attr.FirstOrDefault(r => r.name == "贮存条件");
attr = context.Parameters.ProductAttr.attr.FirstOrDefault(r => r.name == "贮存条件");
}
}
if (attr == null)
@@ -227,12 +227,12 @@ public sealed class MatchProductPropertiesStep : WxProductPublishStepBase
attrValue = propInfo.values.FirstOrDefault()?.value;
}
//书籍属性处理
if (upProdParam.product.info.category.FirstOrDefault()?.name == "图书" || prodInfo.detail.cats.FirstOrDefault() == "书籍/杂志/报纸")
if (context.Parameters.ProductParameter.product.info.category.FirstOrDefault()?.name == "图书" || context.Parameters.ProdInfo.detail.cats.FirstOrDefault() == "书籍/杂志/报纸")
{
// 修改书名 作者
if (attr.name == "书名" /*&& dbProd.product_get_type_text == "微信小店"*/)
if (attr.name == "书名" /*&& context.Product.ProductGetTypeText == "微信小店"*/)
{
attrValue = prodTitle;
attrValue = context.Product.Title;
}
if (attr.name == "作者" && attrValue == "无")
{
@@ -275,9 +275,9 @@ public sealed class MatchProductPropertiesStep : WxProductPublishStepBase
attrValue = "中国大陆";
else
{
var value = values.FirstOrDefault(v => prodTitle.ParseToString().Contains(v));
var value = values.FirstOrDefault(v => context.Product.Title.ParseToString().Contains(v));
if (value == null)
value = values.FirstOrDefault(v => prodTitle.ParseToString().Contains(string.Join("", v.Take(2))));
value = values.FirstOrDefault(v => context.Product.Title.ParseToString().Contains(string.Join("", v.Take(2))));
if (value == null)
value = values.FirstOrDefault(v => "北京;天津;上海;重庆;河北;山西;内蒙古;辽宁;吉林;黑龙江;江苏;浙江;安徽;福建;江西;山东;河南;湖北;湖南;广东;广西;海南;四川;贵州;云南;西藏;陕西;甘肃;青海;宁夏;新疆".Contains(string.Join("", v.Take(2))));
attrValue = value;
@@ -461,7 +461,7 @@ public sealed class MatchProductPropertiesStep : WxProductPublishStepBase
}
else
{
var param = recommendParamRst.productInfo.param.FirstOrDefault(p => p.categorys?.FirstOrDefault()?.name == attr.name);
var param = context.Parameters.RecommendParamRst.productInfo.param.FirstOrDefault(p => p.categorys?.FirstOrDefault()?.name == attr.name);
if (param != null && param.categorys.Count == 2)
{
attrValue = param.categorys[1].name;
@@ -499,7 +499,7 @@ public sealed class MatchProductPropertiesStep : WxProductPublishStepBase
continue;
var wxPropParam = new wxPropParam();
upProdParam.product.info.param.Add(wxPropParam);
context.Parameters.ProductParameter.product.info.param.Add(wxPropParam);
var wxCategoryParam1 = new categoryPropParam()
{
catType = 7,
@@ -516,22 +516,22 @@ public sealed class MatchProductPropertiesStep : WxProductPublishStepBase
wxPropParam.categorys.Add(wxCategoryParam2);
}
}
foreach (var wxPropParam in upProdParam.product.info.param)
foreach (var wxPropParam in context.Parameters.ProductParameter.product.info.param)
{
if (wxPropParam.categorys.Count > 0 &&
wxPropParam.categorys.FirstOrDefault().name == "作者" && (wxPropParam.categorys.LastOrDefault().name == "无" ||
wxPropParam.categorys.LastOrDefault().name == "-" || wxPropParam.categorys.LastOrDefault().name == "/"))
{
wxPropParam.categorys.LastOrDefault().name = upProdParam.product.info.param.FirstOrDefault(p => p.categorys.FirstOrDefault()?.name == "出版社名称").categorys.LastOrDefault()?.name;
wxPropParam.categorys.LastOrDefault().name = context.Parameters.ProductParameter.product.info.param.FirstOrDefault(p => p.categorys.FirstOrDefault()?.name == "出版社名称").categorys.LastOrDefault()?.name;
}
}
foreach (var attr in productAttr.attr)
foreach (var attr in context.Parameters.ProductAttr.attr)
{
if (attr.isRequired != true)
continue;
// 已填写内没有但是必填属性
if (upProdParam.product.info.param.Any(p => p.categorys.FirstOrDefault()?.name == attr.name))
if (context.Parameters.ProductParameter.product.info.param.Any(p => p.categorys.FirstOrDefault()?.name == attr.name))
continue;
var attrValueLst = attr.value.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries).ToList();
@@ -571,9 +571,9 @@ public sealed class MatchProductPropertiesStep : WxProductPublishStepBase
attrValue = "中国大陆";
else
{
var value = values.FirstOrDefault(v => prodTitle.ParseToString().Contains(v));
var value = values.FirstOrDefault(v => context.Product.Title.ParseToString().Contains(v));
if (value == null)
value = values.FirstOrDefault(v => prodTitle.ParseToString().Contains(string.Join("", v.Take(2))));
value = values.FirstOrDefault(v => context.Product.Title.ParseToString().Contains(string.Join("", v.Take(2))));
if (value == null)
value = values.FirstOrDefault(v => "北京;天津;上海;重庆;河北;山西;内蒙古;辽宁;吉林;黑龙江;江苏;浙江;安徽;福建;江西;山东;河南;湖北;湖南;广东;广西;海南;四川;贵州;云南;西藏;陕西;甘肃;青海;宁夏;新疆".Contains(string.Join("", v.Take(2))));
attrValue = value;
@@ -600,12 +600,12 @@ public sealed class MatchProductPropertiesStep : WxProductPublishStepBase
attrValue = attrValueLst.Where(v => !"真丝、蚕丝、香云纱、羊绒、羊毛、羊羔绒、羊羔毛、羽绒、皮草".Contains(v)).OrderBy(x => Guid.NewGuid()).FirstOrDefault();
//书籍属性处理
if (upProdParam.product.info.category.FirstOrDefault()?.name == "图书" || prodInfo.detail.cats.FirstOrDefault() == "书籍/杂志/报纸")
if (context.Parameters.ProductParameter.product.info.category.FirstOrDefault()?.name == "图书" || context.Parameters.ProdInfo.detail.cats.FirstOrDefault() == "书籍/杂志/报纸")
{
//if (attr.name == "ISBN版号/CN刊号")
// attrValue = "9787922575016";
if (attr.name == "书名")
attrValue = prodTitle;
attrValue = context.Product.Title;
if (attr.name == "是否为单一书号丛书")
attrValue = "是";
if (attr.name == "图书册数")
@@ -622,10 +622,10 @@ public sealed class MatchProductPropertiesStep : WxProductPublishStepBase
if (attr.name == "出版时间")
attrValue = DateTime.Now.AddMonths(0 - Randomx.GetId(3, 7)).ToString("yyyy-MM");
}
if (upProdParam.product.info.category.FirstOrDefault()?.name == "食品饮料" || prodInfo.detail.cats.FirstOrDefault() == "食品饮料")
if (context.Parameters.ProductParameter.product.info.category.FirstOrDefault()?.name == "食品饮料" || context.Parameters.ProdInfo.detail.cats.FirstOrDefault() == "食品饮料")
{
if (attr.name == "食品名称")
attrValue = prodTitle;
attrValue = context.Product.Title;
if (attr.name == "生产企业名称")
attrValue = "见包装";
if (attr.name == "食品生产许可证编号")
@@ -659,21 +659,21 @@ public sealed class MatchProductPropertiesStep : WxProductPublishStepBase
//if (attr.name == "保质期")
//{
// if (chkDefaultBestBefore.Checked == false)
// if (context.Parameters.IsDefaultBestBefore == false)
//throw new Exception("食品属性不含保质期,跳过上传");
// if (txtDefaultBestBefore.Text.ParseToInt() < 15)
// if (context.Parameters.DefaultBestBeforeDays < 15)
//throw new Exception("食品默认保质期设置小于15天,跳过上传");
// attrValue = txtDefaultBestBefore.Text.ParseToInt() + " 天";
// attrValue = context.Parameters.DefaultBestBeforeDays + " 天";
//}
}
if (attr.name == "保质期")
{
if (chkDefaultBestBefore.Checked == false)
if (context.Parameters.IsDefaultBestBefore == false)
throw new Exception("属性不含保质期,跳过上传");
if (txtDefaultBestBefore.Text.ParseToInt() < 3)
if (context.Parameters.DefaultBestBeforeDays < 3)
throw new Exception("默认保质期设置小于3天,跳过上传");
attrValue = txtDefaultBestBefore.Text.ParseToInt() + " 天";
attrValue = context.Parameters.DefaultBestBeforeDays + " 天";
}
}
if (attrValue.IsNullOrEmpty() && attr.type == "string")
@@ -683,7 +683,7 @@ public sealed class MatchProductPropertiesStep : WxProductPublishStepBase
if ((attrValue.IsNullOrEmpty() || attrValue == "见包装" || attrValue == "%") && (attr.type == "decimal4_unit" || attr.type == "integer_unit"))
{
// 走系统推荐
var param = recommendParamRst.productInfo.param.FirstOrDefault(p => p.categorys?.FirstOrDefault()?.name == attr.name);
var param = context.Parameters.RecommendParamRst.productInfo.param.FirstOrDefault(p => p.categorys?.FirstOrDefault()?.name == attr.name);
if (param != null && param.categorys.Count == 2)
{
attrValue = param.categorys[1].name;
@@ -726,7 +726,7 @@ public sealed class MatchProductPropertiesStep : WxProductPublishStepBase
}
var wxPropParam = new wxPropParam();
upProdParam.product.info.param.Add(wxPropParam);
context.Parameters.ProductParameter.product.info.param.Add(wxPropParam);
var wxCategoryParam1 = new categoryPropParam()
{
catType = 7,
@@ -742,18 +742,19 @@ public sealed class MatchProductPropertiesStep : WxProductPublishStepBase
wxPropParam.categorys.Add(wxCategoryParam1);
wxPropParam.categorys.Add(wxCategoryParam2);
}
if (upProdParam.product.info.category.FirstOrDefault()?.name == "图书" || prodInfo.detail.cats.FirstOrDefault() == "书籍/杂志/报纸")
if (context.Parameters.ProductParameter.product.info.category.FirstOrDefault()?.name == "图书" || context.Parameters.ProdInfo.detail.cats.FirstOrDefault() == "书籍/杂志/报纸")
{
foreach (var param in upProdParam.product.info.param.ToList())
foreach (var param in context.Parameters.ProductParameter.product.info.param.ToList())
{
if (param.categorys.FirstOrDefault()?.name == "作者" && param.categorys.LastOrDefault()?.name == "无")
{
param.categorys.LastOrDefault().name = upProdParam.product.info.param.FirstOrDefault(p => p.categorys.FirstOrDefault()?.name == "出版社名称")?.categorys?.LastOrDefault()?.name;
param.categorys.LastOrDefault().name = context.Parameters.ProductParameter.product.info.param.FirstOrDefault(p => p.categorys.FirstOrDefault()?.name == "出版社名称")?.categorys?.LastOrDefault()?.name;
if (param.categorys.LastOrDefault().name.IsNullOrEmpty())
param.categorys.LastOrDefault().name = "无";
break;
}
}
}
return Task.CompletedTask;
}
}