761 lines
42 KiB
C#
761 lines
42 KiB
C#
using AllBase;
|
||
using AllBase.Extension;
|
||
using NaiBa.Util.Extension;
|
||
using AllBase.Helper;
|
||
using AllBase.Model.Config;
|
||
using AllBase.Model.DBModel;
|
||
using AllBase.Model.Param.WXParam;
|
||
using AllBase.Model.Result;
|
||
using AllBase.Model.Result.PDDResult;
|
||
using AllBase.Model.Result.WXResult;
|
||
using Newtonsoft.Json;
|
||
using Newtonsoft.Json.Linq;
|
||
using Store.Product.Models.PublishParameters.Wx;
|
||
using Store.Product.Publish;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Drawing;
|
||
using System.Drawing.Drawing2D;
|
||
using System.IO;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Threading;
|
||
using System.Threading.Tasks;
|
||
using Work;
|
||
|
||
namespace Store.Product.Publish.Steps.Wx;
|
||
/// <summary>
|
||
/// 由 WXDBProdUploadForm.UploadProduct 的“匹配产品属性”区段迁移。
|
||
/// TODO(迁移): 原区段中的 TEMUKJD/WXUpload/窗体服务引用需按 Store.Product 运行时适配逐项核对。
|
||
/// </summary>
|
||
public sealed class MatchProductPropertiesStep : WxProductPublishStepBase
|
||
{
|
||
public override string Description => "匹配产品属性";
|
||
|
||
protected override Task ExecuteProvider(WXPublishContext context, CancellationToken cancellationToken)
|
||
{
|
||
//真丝、蚕丝、香云纱、羊绒、羊毛、羊羔毛、羽绒、皮草
|
||
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("微信回采") && context.Parameters.IsUseWXComplateProd && context.Product.HasWxFormat == "1" && context.Parameters.WxEditProdInfo != null)
|
||
{
|
||
foreach (var wxEditPropParam in context.Parameters.WxEditProdInfo.product.info.param)
|
||
{
|
||
var wxPropParam = new wxPropParam();
|
||
context.Parameters.ProductParameter.product.info.param.Add(wxPropParam);
|
||
foreach (var wxEditCategoryParam in wxEditPropParam.categorys)
|
||
{
|
||
var wxCategoryParam = new categoryPropParam()
|
||
{
|
||
catType = wxEditCategoryParam.catType,
|
||
name = wxEditCategoryParam.name,
|
||
catInfo = new catInfoParam()
|
||
{
|
||
inputType = wxEditCategoryParam.catInfo.inputType,
|
||
isRequired = wxEditCategoryParam.catInfo.isRequired,
|
||
isCustomize = wxEditCategoryParam.catInfo.isCustomize,
|
||
}
|
||
};
|
||
wxPropParam.categorys.Add(wxCategoryParam);
|
||
}
|
||
}
|
||
}
|
||
// 直接转换微信店采
|
||
else if (context.Product.ProductGetTypeText == "微信店采")
|
||
{
|
||
foreach (var wxEditPropParam in context.Parameters.WxEditProdInfo.product.info.param)
|
||
{
|
||
var wxPropParam = new 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 = context.Product.Title;
|
||
}
|
||
var wxCategoryParam = new categoryPropParam()
|
||
{
|
||
catType = wxEditCategoryParam.catType,
|
||
name = wxEditCategoryParam.name,
|
||
catInfo = new catInfoParam()
|
||
{
|
||
inputType = wxEditCategoryParam?.catInfo?.inputType,
|
||
isRequired = wxEditCategoryParam?.catInfo?.isRequired,
|
||
isCustomize = wxEditCategoryParam?.catInfo?.isCustomize,
|
||
}
|
||
};
|
||
wxPropParam.categorys.Add(wxCategoryParam);
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
foreach (var propInfo in context.Parameters.ProdInfo.property.goods_properties)
|
||
{
|
||
if (propInfo.name == "容量")
|
||
{
|
||
|
||
}
|
||
if (propInfo.name == "格数")
|
||
{
|
||
|
||
}
|
||
if (propInfo.values.Count == 0)
|
||
continue;
|
||
|
||
|
||
var attr = context.Parameters.ProductAttr.attr.FirstOrDefault(r => r.name == propInfo.name);
|
||
if (attr == null)
|
||
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)
|
||
{
|
||
propInfo.values.FirstOrDefault().value = DateTime.Now.Date.AddDays(-15).ToString("yyyy-MM-dd");
|
||
propInfo.values.FirstOrDefault().raw_value = propInfo.values.FirstOrDefault().value;
|
||
}
|
||
if (attr == null)
|
||
{
|
||
if (propInfo.name.Contains("面料俗称"))
|
||
{
|
||
attr = context.Parameters.ProductAttr.attr.FirstOrDefault(r => r.name == "面料材质");
|
||
}
|
||
if (propInfo.name.Contains("适用年龄"))
|
||
{
|
||
attr = context.Parameters.ProductAttr.attr.FirstOrDefault(r => r.name == "适用年龄" || r.name == "适用年龄段");
|
||
}
|
||
if (propInfo.name.Contains("填充物"))
|
||
{
|
||
attr = context.Parameters.ProductAttr.attr.FirstOrDefault(r => r.name == "填充物种类" || r.name == "填充物");
|
||
}
|
||
|
||
// 书籍类目属性匹配
|
||
if (context.Parameters.ProductParameter.product.info.category.FirstOrDefault()?.name == "图书" || context.Parameters.ProdInfo.detail.cats.FirstOrDefault() == "书籍/杂志/报纸")
|
||
{
|
||
if (propInfo.name == "出版社名称")
|
||
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 = context.Parameters.ProductAttr.attr.FirstOrDefault(r => r.name == "书名");
|
||
else if (propInfo.name == "定价")
|
||
attr = context.Parameters.ProductAttr.attr.FirstOrDefault(r => r.name == "定价");
|
||
else if (propInfo.name == "作者")
|
||
attr = context.Parameters.ProductAttr.attr.FirstOrDefault(r => r.name == "作者");
|
||
else if (propInfo.name == "出版时间")
|
||
attr = context.Parameters.ProductAttr.attr.FirstOrDefault(r => r.name == "出版时间");
|
||
else if (propInfo.name == "版次")
|
||
attr = context.Parameters.ProductAttr.attr.FirstOrDefault(r => r.name == "版次");
|
||
else if (propInfo.name == "装帧类型")
|
||
attr = context.Parameters.ProductAttr.attr.FirstOrDefault(r => r.name == "包装");
|
||
else if (propInfo.name == "包册数")
|
||
attr = context.Parameters.ProductAttr.attr.FirstOrDefault(r => r.name == "图书册数");
|
||
}
|
||
if (context.Parameters.ProductParameter.product.info.category.FirstOrDefault()?.name == "食品饮料" || context.Parameters.ProdInfo.detail.cats.FirstOrDefault() == "食品饮料")
|
||
{
|
||
if (propInfo.name == "厂名")
|
||
attr = context.Parameters.ProductAttr.attr.FirstOrDefault(r => r.name == "生产企业名称");
|
||
else if (propInfo.name == "食品生产许可证编号")
|
||
attr = context.Parameters.ProductAttr.attr.FirstOrDefault(r => r.name == "食品生产许可证编号");
|
||
else if (propInfo.name == "产品标准号")
|
||
attr = context.Parameters.ProductAttr.attr.FirstOrDefault(r => r.name == "产品标准号");
|
||
else if (propInfo.name == "保质期")
|
||
attr = context.Parameters.ProductAttr.attr.FirstOrDefault(r => r.name == "保质期");
|
||
else if (propInfo.name == "生产日期")
|
||
{
|
||
attr = context.Parameters.ProductAttr.attr.FirstOrDefault(r => r.name == "生产日期");
|
||
}
|
||
else if (propInfo.name == "产品重量")
|
||
{
|
||
attr = context.Parameters.ProductAttr.attr.FirstOrDefault(r => r.name == "单件净含量");
|
||
if (attr == null)
|
||
attr = context.Parameters.ProductAttr.attr.FirstOrDefault(r => r.name == "净含量");
|
||
}
|
||
else if (propInfo.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 = context.Parameters.ProductAttr.attr.FirstOrDefault(r => r.name == "地址");
|
||
else if (propInfo.name == "储藏方法")
|
||
attr = context.Parameters.ProductAttr.attr.FirstOrDefault(r => r.name == "贮存条件");
|
||
}
|
||
}
|
||
if (attr == null)
|
||
{
|
||
continue;
|
||
}
|
||
var attrValueLst = attr.value.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
||
var attrValue = attrValueLst.FirstOrDefault(v => v == propInfo.values.FirstOrDefault()?.value);
|
||
if (attrValue.IsNullOrEmpty())
|
||
attrValue = attrValueLst.FirstOrDefault(v => v.Replace("高硼硅玻璃", "耐热玻璃(高硼硅)") == propInfo.values.FirstOrDefault()?.value);
|
||
if (propInfo.name == "保质期")
|
||
{
|
||
attrValue = "30 天";
|
||
if (propInfo.values.Count > 0)
|
||
{
|
||
if (propInfo.values.FirstOrDefault().value.Contains("年") || propInfo.values.FirstOrDefault().value.Contains("月")
|
||
|| propInfo.values.FirstOrDefault().value.Contains("日") || propInfo.values.FirstOrDefault().value.Contains("天")
|
||
|| propInfo.values.FirstOrDefault().value.Contains("见包装"))
|
||
{
|
||
attrValue = propInfo.values.FirstOrDefault().value;
|
||
}
|
||
if (attrValue.Contains("天") && attrValue.Replace("天", "").ParseToInt() < 30)
|
||
{
|
||
throw new Exception("食品保质期小于30天,跳过上传");
|
||
}
|
||
}
|
||
}
|
||
|
||
if (propInfo.name == "产品重量")
|
||
{
|
||
attrValue = "10g";
|
||
if (propInfo.values.FirstOrDefault().value.Contains("g") || propInfo.values.FirstOrDefault().value.Contains("kg"))
|
||
attrValue = propInfo.values.FirstOrDefault().value;
|
||
}
|
||
if (propInfo.name == "风格" && attrValue == null)
|
||
{
|
||
attrValue = attrValueLst.FirstOrDefault(v => v == propInfo.values.FirstOrDefault().value + "风");
|
||
}
|
||
if (attr.type == "string")
|
||
{
|
||
attrValue = propInfo.values.FirstOrDefault()?.value;
|
||
}
|
||
//书籍属性处理
|
||
if (context.Parameters.ProductParameter.product.info.category.FirstOrDefault()?.name == "图书" || context.Parameters.ProdInfo.detail.cats.FirstOrDefault() == "书籍/杂志/报纸")
|
||
{
|
||
// 修改书名 作者
|
||
if (attr.name == "书名" /*&& context.Product.ProductGetTypeText == "微信小店"*/)
|
||
{
|
||
attrValue = context.Product.Title;
|
||
}
|
||
if (attr.name == "作者" && attrValue == "无")
|
||
{
|
||
attrValue = new List<string>() { "赵老师", "钱老师", "孙老师", "李老师", "周老师", "吴老师", "郑老师", "王老师", "张老师", "孙老师", "刘老师" }.OrderBy(x => Guid.NewGuid()).FirstOrDefault();
|
||
attrValue = "无";
|
||
}
|
||
|
||
if (attrValue.IsNullOrEmpty() && attr.type == "integer_unit" && (propInfo.values.FirstOrDefault()?.value).IsNumber())
|
||
{
|
||
attrValue = propInfo.values.FirstOrDefault()?.value + " " + attr.value.Split(';').FirstOrDefault();
|
||
}
|
||
if (attrValue.IsNullOrEmpty() && attr.name == "包装")
|
||
{
|
||
if (propInfo.values.FirstOrDefault()?.value == "平装-胶订")
|
||
attrValue = "平装";
|
||
}
|
||
}
|
||
// 强制改为国产
|
||
{
|
||
if (attrValueLst.Contains("国产"))
|
||
attrValue = "国产";
|
||
else if (attr.name == "是否进口")
|
||
{
|
||
attrValue = "非进口";
|
||
if (attr.value == "是;否")
|
||
attrValue = "否";
|
||
}
|
||
else if (attr.name == "商品产地")
|
||
{
|
||
attrValue = "中国大陆";
|
||
}
|
||
else if (attr.name == "产地")
|
||
{
|
||
if (attr.type == "select_one")
|
||
{
|
||
//北京;天津;上海;重庆;河北石家庄;河北唐山;河北秦皇岛;河北邯郸;河北邢台;河北保定;河北张家口;河北承德;河北沧州;河北廊坊;河北衡水;山西太原;山西大同;山西阳泉;山西长治;山西晋城;山西朔州;山西晋中;山西运城;山西忻州;山西临汾;山西吕梁;内蒙古呼和浩特;内蒙古包头;内蒙古乌海;内蒙古赤峰;内蒙古通辽;内蒙古鄂尔多斯;内蒙古呼伦贝尔;内蒙古巴彦淖尔;内蒙古乌兰察布;内蒙古兴安;内蒙古锡林郭勒;内蒙古阿拉善;辽宁沈阳;辽宁大连;辽宁鞍山;辽宁抚顺;辽宁本溪;辽宁丹东;辽宁锦州;辽宁营口;辽宁阜新;辽宁辽阳;辽宁盘锦;辽宁铁岭;辽宁朝阳;辽宁葫芦岛;吉林长春;吉林吉林;吉林四平;吉林辽源;吉林通化;吉林白山;吉林松原;吉林白城;吉林延边;黑龙江哈尔滨;黑龙江齐齐哈尔;黑龙江鸡西;黑龙江鹤岗;黑龙江双鸭山;黑龙江大庆;黑龙江伊春;黑龙江佳木斯;黑龙江七台河;黑龙江牡丹江;黑龙江黑河;黑龙江绥化;黑龙江大兴安岭;江苏南京;江苏无锡;江苏徐州;江苏常州;江苏苏州;江苏南通;江苏连云港;江苏淮安;江苏盐城;江苏扬州;江苏镇江;江苏泰州;江苏宿迁;浙江杭州;浙江宁波;浙江温州;浙江嘉兴;浙江湖州;浙江绍兴;浙江金华;浙江衢州;浙江舟山;浙江台州;浙江丽水;安徽合肥;安徽芜湖;安徽蚌埠;安徽淮南;安徽马鞍山;安徽淮北;安徽铜陵;安徽安庆;安徽黄山;安徽滁州;安徽阜阳;安徽宿州;安徽六安;安徽亳州;安徽池州;安徽宣城;福建福州;福建厦门;福建莆田;福建三明;福建泉州;福建漳州;福建南平;福建龙岩;福建宁德;江西南昌;江西景德镇;江西萍乡;江西九江;江西新余;江西鹰潭;江西赣州;江西吉安;江西宜春;江西抚州;江西上饶;山东济南;山东青岛;山东淄博;山东枣庄;山东东营;山东烟台;山东潍坊;山东济宁;山东泰安;山东威海;山东日照;山东临沂;山东德州;山东聊城;山东滨州;山东菏泽;河南郑州;河南开封;河南洛阳;河南平顶山;河南安阳;河南鹤壁;河南新乡;河南焦作;河南濮阳;河南许昌;河南漯河;河南三门峡;河南南阳;河南商丘;河南信阳;河南周口;河南驻马店;河南济源;湖北武汉;湖北黄石;湖北十堰;湖北宜昌;湖北襄阳;湖北鄂州;湖北荆门;湖北孝感;湖北荆州;湖北黄冈;湖北咸宁;湖北随州;湖北恩施;湖北仙桃;湖北潜江;湖北天门;湖北神农架;湖南长沙;湖南株洲;湖南湘潭;湖南衡阳;湖南邵阳;湖南岳阳;湖南常德;湖南张家界;湖南益阳;湖南郴州;湖南永州;湖南怀化;湖南娄底;湖南湘西;广东广州;广东韶关;广东深圳;广东珠海;广东汕头;广东佛山;广东江门;广东湛江;广东茂名;广东肇庆;广东惠州;广东梅州;广东汕尾;广东河源;广东阳江;广东清远;广东东莞;广东中山;广东潮州;广东揭阳;广东云浮;广西南宁;广西柳州;广西桂林;广西梧州;广西北海;广西防城港;广西钦州;广西贵港;广西玉林;广西百色;广西贺州;广西河池;广西来宾;广西崇左;海南海口;海南三亚;海南三沙;海南儋州;海南五指山;海南琼海;海南文昌;海南万宁;海南东方;海南定安;海南屯昌;海南澄迈;海南临高;海南白沙;海南昌江;海南乐东;海南陵水;海南保亭;海南琼中;四川成都;四川自贡;四川攀枝花;四川泸州;四川德阳;四川绵阳;四川广元;四川遂宁;四川内江;四川乐山;四川南充;四川眉山;四川宜宾;四川广安;四川达州;四川雅安;四川巴中;四川资阳;四川阿坝;四川甘孜;四川凉山;贵州贵阳;贵州六盘水;贵州遵义;贵州安顺;贵州毕节;贵州铜仁;贵州黔西南;贵州黔东南;贵州黔南;云南昆明;云南曲靖;云南玉溪;云南保山;云南昭通;云南丽江;云南普洱;云南临沧;云南楚雄;云南红河;云南文山;云南西双版纳;云南大理;云南德宏;云南怒江;云南迪庆;西藏拉萨;西藏日喀则;西藏昌都;西藏林芝;西藏山南;西藏那曲;西藏阿里;陕西西安;陕西铜川;陕西宝鸡;陕西咸阳;陕西渭南;陕西延安;陕西汉中;陕西榆林;陕西安康;陕西商洛;甘肃兰州;甘肃嘉峪关;甘肃金昌;甘肃白银;甘肃天水;甘肃武威;甘肃张掖;甘肃平凉;甘肃酒泉;甘肃庆阳;甘肃定西;甘肃陇南;甘肃临夏;甘肃甘南;青海西宁;青海海东;青海海北;青海黄南;青海海南;青海果洛;青海玉树;青海海西;宁夏银川;宁夏石嘴山;宁夏吴忠;宁夏固原;宁夏中卫;新疆乌鲁木齐;新疆克拉玛依;新疆吐鲁番;新疆哈密;新疆昌吉;新疆博尔塔拉;新疆巴音郭楞;新疆阿克苏;新疆克孜勒苏;新疆喀什;新疆和田;新疆伊犁;新疆塔城;新疆阿勒泰;新疆石河子;新疆阿拉尔;新疆图木舒克;新疆五家渠;新疆北屯;新疆铁门关;新疆双河;新疆可克达拉;新疆昆玉;新疆胡杨河;新疆新星;新疆白杨
|
||
//北京;天津;上海;重庆;河北;山西;内蒙古;辽宁;吉林;黑龙江;江苏;浙江;安徽;福建;江西;山东;河南;湖北;湖南;广东;广西;海南;四川;贵州;云南;西藏;陕西;甘肃;青海;宁夏;新疆
|
||
var values = attr.value.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries).OrderBy(x => Guid.NewGuid()).ToList();
|
||
if (values.Contains("中国大陆"))
|
||
attrValue = "中国大陆";
|
||
else
|
||
{
|
||
var value = values.FirstOrDefault(v => context.Product.Title.ParseToString().Contains(v));
|
||
if (value == null)
|
||
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;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
attrValue = "中国大陆";
|
||
}
|
||
}
|
||
}
|
||
// 强制非收藏品
|
||
{
|
||
if (attrValueLst.Contains("是否具有拍卖/收藏价值"))
|
||
{
|
||
attrValue = "不具有";
|
||
}
|
||
if (attrValueLst.Contains("是否批量生产(孤品)"))
|
||
{
|
||
attrValue = "批量生产";
|
||
}
|
||
}
|
||
if (attrValue.IsNullOrEmpty() && attr.isRequired == true)
|
||
{
|
||
if (attrValueLst.Contains("其他"))
|
||
attrValue = "其他";
|
||
else if (attrValueLst.Contains("常规"))
|
||
attrValue = "常规";
|
||
else if (attrValueLst.Contains("通用"))
|
||
attrValue = "通用";
|
||
else if (attr.value.Contains("绒丝;羽毛;白鸭绒;白鹅绒;灰鸭绒;灰鹅绒;鸭毛片;鹅毛片"))
|
||
{
|
||
attrValue = "绒丝";
|
||
}
|
||
//else if (attrValueLst.Any(v => v.Contains("%")))
|
||
//{
|
||
// attrValue = attrValueLst.FirstOrDefault();
|
||
//}
|
||
else
|
||
attrValue = attrValueLst.Where(v => !"真丝、蚕丝、香云纱、羊绒、羊毛、羊羔绒、羊羔毛、羽绒、皮草".Contains(v)).OrderBy(x => Guid.NewGuid()).FirstOrDefault();
|
||
}
|
||
if (attrValue.IsNullOrEmpty())
|
||
{
|
||
if (attrValueLst.Contains("其他"))
|
||
attrValue = "其他";
|
||
else if (attrValueLst.Contains("通用"))
|
||
attrValue = "通用";
|
||
}
|
||
if (attrValue.IsNullOrEmpty() && attr.type == "string")
|
||
{
|
||
attrValue = propInfo.values.FirstOrDefault()?.value;
|
||
}
|
||
if (attr.type == "decimal4_unit" || attr.type == "integer_unit")
|
||
{
|
||
if (attr.value == "%")
|
||
attrValue = "1 %";
|
||
else if (attr.value == "g;kg")
|
||
attrValue = "50 g";
|
||
else if (attr.value == "g")
|
||
attrValue = "10 g";
|
||
else if (attr.value == "kg")
|
||
attrValue = "1 kg";
|
||
//else if (attr.value == "g;kg;ml;L")
|
||
// attrValue = "100 g";
|
||
else if (attr.value == "cm")
|
||
{
|
||
var propValue = propInfo.values.FirstOrDefault()?.value;
|
||
var match = BaseRegex.GetMatchRegexString(ref propValue, @"([\d]{1,4})cm");
|
||
if (!string.IsNullOrEmpty(match))
|
||
{
|
||
attrValue = match + " cm";
|
||
}
|
||
}
|
||
else if (attr.value == "mm")
|
||
{
|
||
var propValue = propInfo.values.FirstOrDefault()?.value;
|
||
var match = BaseRegex.GetMatchRegexString(ref propValue, @"([\d]{1,4})mm");
|
||
if (!string.IsNullOrEmpty(match))
|
||
{
|
||
attrValue = match + " mm";
|
||
}
|
||
}
|
||
else if (attr.value.Contains("岁以上") && attr.value.Contains("个月以上"))
|
||
{
|
||
attrValue = "7 岁以上";
|
||
if (propInfo.values.FirstOrDefault().value.Contains("岁以上") || propInfo.values.FirstOrDefault().value.Contains("个月以上"))
|
||
attrValue = propInfo.values.FirstOrDefault().value;
|
||
if (propInfo.values.FirstOrDefault().value.Contains("岁"))
|
||
{
|
||
var propValue = propInfo.values.FirstOrDefault().value;
|
||
var match = BaseRegex.GetMatchRegexString(ref propValue, @"([\d]{1,3})");
|
||
if (!string.IsNullOrEmpty(match))
|
||
{
|
||
attrValue = match + " 岁以上";
|
||
}
|
||
}
|
||
else if (propInfo.values.FirstOrDefault().value.Contains("月"))
|
||
{
|
||
var propValue = propInfo.values.FirstOrDefault().value;
|
||
var match = BaseRegex.GetMatchRegexString(ref propValue, @"([\d]{1,3})");
|
||
if (!string.IsNullOrEmpty(match))
|
||
{
|
||
attrValue = match + " 个月以上";
|
||
}
|
||
}
|
||
}
|
||
else if (attr.value == "个")
|
||
{
|
||
if ((propInfo.values.FirstOrDefault()?.value).ParseToString().EndsWith("个"))
|
||
{
|
||
attrValue = propInfo.values.FirstOrDefault()?.value;
|
||
if (attrValue.TrimEnd('个').ParseToInt() == 0)
|
||
attrValue = BaseRegex.GetMatchMaxRegexString(ref attrValue, "(\\d{1,6})") + (attrValue.Contains("只") ? " 只" : " 个");
|
||
if (attrValue.TrimEnd('个').ParseToInt() == 0)
|
||
attrValue = "1 个";
|
||
}
|
||
else
|
||
attrValue = "1 个";
|
||
}
|
||
else if (attr.value == "只;个")
|
||
{
|
||
if ((propInfo.values.FirstOrDefault()?.value).ParseToString().EndsWith("只") || (propInfo.values.FirstOrDefault()?.value).ParseToString().EndsWith("个"))
|
||
{
|
||
attrValue = propInfo.values.FirstOrDefault()?.value;
|
||
if (attrValue.TrimEnd('只', '个').ParseToInt() == 0)
|
||
attrValue = BaseRegex.GetMatchMaxRegexString(ref attrValue, "(\\d{1,6})") + (attrValue.Contains("只") ? " 只" : " 个");
|
||
if (attrValue.TrimEnd('只', '个').ParseToInt() == 0)
|
||
attrValue = "1 个";
|
||
}
|
||
else
|
||
attrValue = "1 个";
|
||
}
|
||
else if (attr.value == "ml")
|
||
{
|
||
if ((propInfo.values.FirstOrDefault()?.value).ParseToString().EndsWith(attr.value))
|
||
attrValue = propInfo.values.FirstOrDefault()?.value.TrimStart('-', ' ');
|
||
else
|
||
attrValue = "100 ml";
|
||
}
|
||
else if (attr.value == "L")
|
||
{
|
||
if ((propInfo.values.FirstOrDefault()?.value).ParseToString().EndsWith(attr.value))
|
||
{
|
||
attrValue = propInfo.values.FirstOrDefault()?.value;
|
||
if (attrValue.TrimEnd('L').ParseToInt() == 0)
|
||
attrValue = BaseRegex.GetMatchMaxRegexString(ref attrValue, "(\\d{1,6})") + " L";
|
||
if (attrValue.TrimEnd('L').ParseToInt() == 0)
|
||
attrValue = "1 L";
|
||
}
|
||
else
|
||
attrValue = "1 L";
|
||
}
|
||
else if (attr.value == "g;kg;ml;L")
|
||
{
|
||
var propInfoValue = (propInfo.values.FirstOrDefault()?.value).ParseToString();
|
||
if (propInfoValue.EndsWith("g") || propInfoValue.EndsWith("kg") || propInfoValue.EndsWith("ml") || propInfoValue.EndsWith("L"))
|
||
attrValue = propInfo.values.FirstOrDefault()?.value;
|
||
else
|
||
attrValue = "100 g";
|
||
}
|
||
else if (attr.value == "日;月;年")
|
||
{
|
||
var propInfoValue = (propInfo.values.FirstOrDefault()?.value).ParseToString();
|
||
if (propInfoValue.EndsWith("日") || propInfoValue.EndsWith("月") || propInfoValue.EndsWith("年"))
|
||
attrValue = propInfo.values.FirstOrDefault()?.value + propInfoValue.LastOrDefault();
|
||
else
|
||
attrValue = "30 日";
|
||
}
|
||
else if (attr.value.ParseToString().Length > 0 && !attr.value.ParseToString().Contains(";"))
|
||
{
|
||
if ((propInfo.values.FirstOrDefault()?.value).ParseToString().EndsWith(attr.value))
|
||
{
|
||
attrValue = propInfo.values.FirstOrDefault()?.value;
|
||
if (attrValue.Substring(0, attrValue.Length - attr.value.Length - 1).ParseToInt() == 0)
|
||
attrValue = BaseRegex.GetMatchMaxRegexString(ref attrValue, "(\\d{1,6})") + " " + attr.value;
|
||
if (attrValue.Substring(0, attrValue.Length - attr.value.Length - 1).ParseToInt() == 0)
|
||
attrValue = "1 " + attr.value;
|
||
}
|
||
else
|
||
attrValue = "1 " + attr.value;
|
||
}
|
||
else
|
||
{
|
||
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;
|
||
if (attrValue.Contains("磅") && attrValue.Replace("磅", "").ParseToDecimal() > 0)
|
||
{
|
||
if ((";" + attr.value + ";").Contains(";g;"))
|
||
attrValue = (attrValue.Replace("磅", "").ParseToDecimal() * 454).ParseToInt() + "g";
|
||
else if ((";" + attr.value + ";").Contains(";kg;"))
|
||
attrValue = (attrValue.Replace("磅", "").ParseToDecimal() * 0.454m).ParseToDecimal() + "kg";
|
||
}
|
||
}
|
||
else
|
||
{
|
||
attrValue = propInfo.values.FirstOrDefault()?.value.ParseToString();
|
||
var units = attr.value.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
|
||
foreach (var unit in units)
|
||
{
|
||
var val = attrValue.Replace(unit, "").Trim();
|
||
if (attr.type == "decimal4_unit" && val.ParseToDecimal() != 0m)
|
||
{
|
||
attrValue = val + " " + unit;
|
||
break;
|
||
}
|
||
if (attr.type == "integer_unit" && val.ParseToInt() != 0)
|
||
{
|
||
attrValue = val + " " + unit;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
if (string.IsNullOrEmpty(attrValue))
|
||
continue;
|
||
|
||
var wxPropParam = new wxPropParam();
|
||
context.Parameters.ProductParameter.product.info.param.Add(wxPropParam);
|
||
var wxCategoryParam1 = new categoryPropParam()
|
||
{
|
||
catType = 7,
|
||
name = attr.name,
|
||
catInfo = new catInfoParam() { inputType = attr.normalRelease.ruleType, isRequired = attr.isRequired == true ? 1 : 0, isCustomize = 0 }
|
||
};
|
||
var wxCategoryParam2 = new categoryPropParam()
|
||
{
|
||
catType = 7,
|
||
name = attrValue,
|
||
catInfo = new catInfoParam() { inputType = attr.normalRelease.ruleType, isRequired = attr.isRequired == true ? 1 : 0, isCustomize = 0 }
|
||
};
|
||
wxPropParam.categorys.Add(wxCategoryParam1);
|
||
wxPropParam.categorys.Add(wxCategoryParam2);
|
||
}
|
||
}
|
||
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 = context.Parameters.ProductParameter.product.info.param.FirstOrDefault(p => p.categorys.FirstOrDefault()?.name == "出版社名称").categorys.LastOrDefault()?.name;
|
||
}
|
||
}
|
||
|
||
foreach (var attr in context.Parameters.ProductAttr.attr)
|
||
{
|
||
if (attr.isRequired != true)
|
||
continue;
|
||
// 已填写内没有但是必填属性
|
||
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();
|
||
string attrValue = "";
|
||
if (attrValue.IsNullOrEmpty() && attr.isRequired == true)
|
||
{
|
||
if (attrValueLst.Contains("其他"))
|
||
attrValue = "其他";
|
||
else if (attrValueLst.Contains("常规"))
|
||
attrValue = "常规";
|
||
else if (attrValueLst.Contains("通用"))
|
||
attrValue = "通用";
|
||
else if (attrValueLst.Contains("国产"))
|
||
attrValue = "国产";
|
||
else if (attr.value.Contains("绒丝;羽毛;白鸭绒;白鹅绒;灰鸭绒;灰鹅绒;鸭毛片;鹅毛片"))
|
||
{
|
||
attrValue = "绒丝";
|
||
}
|
||
else if (attr.name == "是否进口")
|
||
{
|
||
attrValue = "非进口";
|
||
if (attr.value == "是;否")
|
||
attrValue = "否";
|
||
}
|
||
else if (attr.name == "商品产地")
|
||
{
|
||
attrValue = "中国大陆";
|
||
}
|
||
else if (attr.name == "产地")
|
||
{
|
||
if (attr.type == "select_one")
|
||
{
|
||
//北京;天津;上海;重庆;河北石家庄;河北唐山;河北秦皇岛;河北邯郸;河北邢台;河北保定;河北张家口;河北承德;河北沧州;河北廊坊;河北衡水;山西太原;山西大同;山西阳泉;山西长治;山西晋城;山西朔州;山西晋中;山西运城;山西忻州;山西临汾;山西吕梁;内蒙古呼和浩特;内蒙古包头;内蒙古乌海;内蒙古赤峰;内蒙古通辽;内蒙古鄂尔多斯;内蒙古呼伦贝尔;内蒙古巴彦淖尔;内蒙古乌兰察布;内蒙古兴安;内蒙古锡林郭勒;内蒙古阿拉善;辽宁沈阳;辽宁大连;辽宁鞍山;辽宁抚顺;辽宁本溪;辽宁丹东;辽宁锦州;辽宁营口;辽宁阜新;辽宁辽阳;辽宁盘锦;辽宁铁岭;辽宁朝阳;辽宁葫芦岛;吉林长春;吉林吉林;吉林四平;吉林辽源;吉林通化;吉林白山;吉林松原;吉林白城;吉林延边;黑龙江哈尔滨;黑龙江齐齐哈尔;黑龙江鸡西;黑龙江鹤岗;黑龙江双鸭山;黑龙江大庆;黑龙江伊春;黑龙江佳木斯;黑龙江七台河;黑龙江牡丹江;黑龙江黑河;黑龙江绥化;黑龙江大兴安岭;江苏南京;江苏无锡;江苏徐州;江苏常州;江苏苏州;江苏南通;江苏连云港;江苏淮安;江苏盐城;江苏扬州;江苏镇江;江苏泰州;江苏宿迁;浙江杭州;浙江宁波;浙江温州;浙江嘉兴;浙江湖州;浙江绍兴;浙江金华;浙江衢州;浙江舟山;浙江台州;浙江丽水;安徽合肥;安徽芜湖;安徽蚌埠;安徽淮南;安徽马鞍山;安徽淮北;安徽铜陵;安徽安庆;安徽黄山;安徽滁州;安徽阜阳;安徽宿州;安徽六安;安徽亳州;安徽池州;安徽宣城;福建福州;福建厦门;福建莆田;福建三明;福建泉州;福建漳州;福建南平;福建龙岩;福建宁德;江西南昌;江西景德镇;江西萍乡;江西九江;江西新余;江西鹰潭;江西赣州;江西吉安;江西宜春;江西抚州;江西上饶;山东济南;山东青岛;山东淄博;山东枣庄;山东东营;山东烟台;山东潍坊;山东济宁;山东泰安;山东威海;山东日照;山东临沂;山东德州;山东聊城;山东滨州;山东菏泽;河南郑州;河南开封;河南洛阳;河南平顶山;河南安阳;河南鹤壁;河南新乡;河南焦作;河南濮阳;河南许昌;河南漯河;河南三门峡;河南南阳;河南商丘;河南信阳;河南周口;河南驻马店;河南济源;湖北武汉;湖北黄石;湖北十堰;湖北宜昌;湖北襄阳;湖北鄂州;湖北荆门;湖北孝感;湖北荆州;湖北黄冈;湖北咸宁;湖北随州;湖北恩施;湖北仙桃;湖北潜江;湖北天门;湖北神农架;湖南长沙;湖南株洲;湖南湘潭;湖南衡阳;湖南邵阳;湖南岳阳;湖南常德;湖南张家界;湖南益阳;湖南郴州;湖南永州;湖南怀化;湖南娄底;湖南湘西;广东广州;广东韶关;广东深圳;广东珠海;广东汕头;广东佛山;广东江门;广东湛江;广东茂名;广东肇庆;广东惠州;广东梅州;广东汕尾;广东河源;广东阳江;广东清远;广东东莞;广东中山;广东潮州;广东揭阳;广东云浮;广西南宁;广西柳州;广西桂林;广西梧州;广西北海;广西防城港;广西钦州;广西贵港;广西玉林;广西百色;广西贺州;广西河池;广西来宾;广西崇左;海南海口;海南三亚;海南三沙;海南儋州;海南五指山;海南琼海;海南文昌;海南万宁;海南东方;海南定安;海南屯昌;海南澄迈;海南临高;海南白沙;海南昌江;海南乐东;海南陵水;海南保亭;海南琼中;四川成都;四川自贡;四川攀枝花;四川泸州;四川德阳;四川绵阳;四川广元;四川遂宁;四川内江;四川乐山;四川南充;四川眉山;四川宜宾;四川广安;四川达州;四川雅安;四川巴中;四川资阳;四川阿坝;四川甘孜;四川凉山;贵州贵阳;贵州六盘水;贵州遵义;贵州安顺;贵州毕节;贵州铜仁;贵州黔西南;贵州黔东南;贵州黔南;云南昆明;云南曲靖;云南玉溪;云南保山;云南昭通;云南丽江;云南普洱;云南临沧;云南楚雄;云南红河;云南文山;云南西双版纳;云南大理;云南德宏;云南怒江;云南迪庆;西藏拉萨;西藏日喀则;西藏昌都;西藏林芝;西藏山南;西藏那曲;西藏阿里;陕西西安;陕西铜川;陕西宝鸡;陕西咸阳;陕西渭南;陕西延安;陕西汉中;陕西榆林;陕西安康;陕西商洛;甘肃兰州;甘肃嘉峪关;甘肃金昌;甘肃白银;甘肃天水;甘肃武威;甘肃张掖;甘肃平凉;甘肃酒泉;甘肃庆阳;甘肃定西;甘肃陇南;甘肃临夏;甘肃甘南;青海西宁;青海海东;青海海北;青海黄南;青海海南;青海果洛;青海玉树;青海海西;宁夏银川;宁夏石嘴山;宁夏吴忠;宁夏固原;宁夏中卫;新疆乌鲁木齐;新疆克拉玛依;新疆吐鲁番;新疆哈密;新疆昌吉;新疆博尔塔拉;新疆巴音郭楞;新疆阿克苏;新疆克孜勒苏;新疆喀什;新疆和田;新疆伊犁;新疆塔城;新疆阿勒泰;新疆石河子;新疆阿拉尔;新疆图木舒克;新疆五家渠;新疆北屯;新疆铁门关;新疆双河;新疆可克达拉;新疆昆玉;新疆胡杨河;新疆新星;新疆白杨
|
||
//北京;天津;上海;重庆;河北;山西;内蒙古;辽宁;吉林;黑龙江;江苏;浙江;安徽;福建;江西;山东;河南;湖北;湖南;广东;广西;海南;四川;贵州;云南;西藏;陕西;甘肃;青海;宁夏;新疆
|
||
var values = attr.value.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries).OrderBy(x => Guid.NewGuid()).ToList();
|
||
if (values.Contains("中国大陆"))
|
||
attrValue = "中国大陆";
|
||
else
|
||
{
|
||
var value = values.FirstOrDefault(v => context.Product.Title.ParseToString().Contains(v));
|
||
if (value == null)
|
||
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;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
attrValue = "中国大陆";
|
||
}
|
||
}
|
||
else if (attr.name == "是否具有拍卖/收藏价值")
|
||
{
|
||
attrValue = "不具有";
|
||
}
|
||
else if (attr.name == "是否批量生产(孤品)")
|
||
{
|
||
attrValue = "批量生产";
|
||
}
|
||
//else if (attrValueLst.Any(v => v.Contains("%")))
|
||
//{
|
||
// attrValue = attrValueLst.FirstOrDefault();
|
||
//}
|
||
else if (!(attr.type == "decimal4_unit" || attr.type == "integer_unit"))
|
||
attrValue = attrValueLst.Where(v => !"真丝、蚕丝、香云纱、羊绒、羊毛、羊羔绒、羊羔毛、羽绒、皮草".Contains(v)).OrderBy(x => Guid.NewGuid()).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 = context.Product.Title;
|
||
if (attr.name == "是否为单一书号丛书")
|
||
attrValue = "是";
|
||
if (attr.name == "图书册数")
|
||
attrValue = "1 册";
|
||
if (attr.name == "出版社名称")
|
||
attrValue = new List<string>() { "技术出版社", "文化出版社", "美术出版社" }[Randomx.GetId(3)];
|
||
if (attr.name == "作者")
|
||
{
|
||
attrValue = new List<string>() { "赵老师", "钱老师", "孙老师", "李老师", "周老师", "吴老师", "郑老师", "王老师", "张老师", "孙老师", "刘老师" }.OrderBy(x => Guid.NewGuid()).FirstOrDefault();
|
||
attrValue = "无";
|
||
}
|
||
if (attr.name == "包装")
|
||
attrValue = "平装";
|
||
if (attr.name == "出版时间")
|
||
attrValue = DateTime.Now.AddMonths(0 - Randomx.GetId(3, 7)).ToString("yyyy-MM");
|
||
}
|
||
if (context.Parameters.ProductParameter.product.info.category.FirstOrDefault()?.name == "食品饮料" || context.Parameters.ProdInfo.detail.cats.FirstOrDefault() == "食品饮料")
|
||
{
|
||
if (attr.name == "食品名称")
|
||
attrValue = context.Product.Title;
|
||
if (attr.name == "生产企业名称")
|
||
attrValue = "见包装";
|
||
if (attr.name == "食品生产许可证编号")
|
||
{
|
||
attrValue = "SC10241162100670";
|
||
attrValue = "见包装";
|
||
}
|
||
if (attr.name == "产品标准号")
|
||
{
|
||
attrValue = "GB 2726";
|
||
attrValue = "见包装";
|
||
}
|
||
if (attr.name == "生产日期")
|
||
attrValue = DateTime.Now.Date.AddDays(-15).ToString("yyyy-MM-dd");
|
||
if (attr.name == "净含量")
|
||
attrValue = "见包装";
|
||
if (attr.name == "单件净含量")
|
||
{
|
||
attrValue = "见包装";
|
||
}
|
||
if (attr.name == "包装方式")
|
||
attrValue = "袋装";
|
||
if (attr.name == "配料表")
|
||
attrValue = "水";
|
||
if (attr.name == "联系方式")
|
||
attrValue = "无";
|
||
if (attr.name == "地址")
|
||
attrValue = "见包装";
|
||
if (attr.name == "贮存条件")
|
||
attrValue = "常温";
|
||
|
||
//if (attr.name == "保质期")
|
||
//{
|
||
// if (context.Parameters.IsDefaultBestBefore == false)
|
||
//throw new Exception("食品属性不含保质期,跳过上传");
|
||
// if (context.Parameters.DefaultBestBeforeDays < 15)
|
||
//throw new Exception("食品默认保质期设置小于15天,跳过上传");
|
||
// attrValue = context.Parameters.DefaultBestBeforeDays + " 天";
|
||
//}
|
||
}
|
||
|
||
if (attr.name == "保质期")
|
||
{
|
||
if (context.Parameters.IsDefaultBestBefore == false)
|
||
throw new Exception("属性不含保质期,跳过上传");
|
||
if (context.Parameters.DefaultBestBeforeDays < 3)
|
||
throw new Exception("默认保质期设置小于3天,跳过上传");
|
||
attrValue = context.Parameters.DefaultBestBeforeDays + " 天";
|
||
}
|
||
}
|
||
if (attrValue.IsNullOrEmpty() && attr.type == "string")
|
||
{
|
||
attrValue = "其他";
|
||
}
|
||
if ((attrValue.IsNullOrEmpty() || attrValue == "见包装" || attrValue == "%") && (attr.type == "decimal4_unit" || attr.type == "integer_unit"))
|
||
{
|
||
// 走系统推荐
|
||
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;
|
||
if (attrValue.Contains("磅") && attrValue.Replace("磅", "").ParseToDecimal() > 0)
|
||
{
|
||
if ((";" + attr.value + ";").Contains(";g;"))
|
||
attrValue = (attrValue.Replace("磅", "").ParseToDecimal() * 454).ParseToInt() + "g";
|
||
else if ((";" + attr.value + ";").Contains(";kg;"))
|
||
attrValue = (attrValue.Replace("磅", "").ParseToDecimal() * 0.454m).ParseToDecimal() + "kg";
|
||
}
|
||
}
|
||
else if (attr.value == "%")
|
||
attrValue = "1 %";
|
||
else if (attr.value == "g;kg")
|
||
attrValue = "50 g";
|
||
else if (attr.value == "g")
|
||
attrValue = "10 g";
|
||
else if (attr.value == "kg")
|
||
attrValue = "1 kg";
|
||
else if (attr.value == "g;kg;ml;L")
|
||
attrValue = "100 g";
|
||
else if (attr.value == "cm")
|
||
attrValue = "20 cm";
|
||
else if (attr.value == "mm")
|
||
attrValue = "20 mm";
|
||
else if (attr.value == "毫米(mm);厘米(cm);米(m)")
|
||
attrValue = "20 毫米(mm)";
|
||
else if (attr.value.Contains("岁以上") && attr.value.Contains("个月以上"))
|
||
attrValue = "7 岁以上";
|
||
else if (attr.value == "只;个")
|
||
attrValue = "1 个";
|
||
else if (attr.value == "个")
|
||
attrValue = "1 个";
|
||
else if (attr.value == "ml")
|
||
attrValue = "100 ml";
|
||
else if (attr.value == "L")
|
||
attrValue = "1 L";
|
||
else if (attr.value == "日;月;年")
|
||
attrValue = "30 日";
|
||
}
|
||
|
||
var wxPropParam = new wxPropParam();
|
||
context.Parameters.ProductParameter.product.info.param.Add(wxPropParam);
|
||
var wxCategoryParam1 = new categoryPropParam()
|
||
{
|
||
catType = 7,
|
||
name = attr.name,
|
||
catInfo = new catInfoParam() { inputType = attr.normalRelease.ruleType, isRequired = attr.isRequired == true ? 1 : 0, isCustomize = 0 }
|
||
};
|
||
var wxCategoryParam2 = new categoryPropParam()
|
||
{
|
||
catType = 7,
|
||
name = attrValue,
|
||
catInfo = new catInfoParam() { inputType = attr.normalRelease.ruleType, isRequired = attr.isRequired == true ? 1 : 0, isCustomize = 0 }
|
||
};
|
||
wxPropParam.categorys.Add(wxCategoryParam1);
|
||
wxPropParam.categorys.Add(wxCategoryParam2);
|
||
}
|
||
if (context.Parameters.ProductParameter.product.info.category.FirstOrDefault()?.name == "图书" || context.Parameters.ProdInfo.detail.cats.FirstOrDefault() == "书籍/杂志/报纸")
|
||
{
|
||
foreach (var param in context.Parameters.ProductParameter.product.info.param.ToList())
|
||
{
|
||
if (param.categorys.FirstOrDefault()?.name == "作者" && param.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;
|
||
}
|
||
}
|