增加项目,分层

This commit is contained in:
chfei committed 2026-09-11 19:11:12 +08:00
1 parent 6e995a5bdb
commit 0a3e5af6a9
234 files changed
+26994 -1

No files matched your search

@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Store.Product.Models.Product.Image
{
/// <summary>
/// 商品详情图片
/// </summary>
public class ContentImage : ProductImage
{
//public override ImageType ImageType => ImageType.Content;
public ContentImage(string url) : base(url)
{
Gid = Guid.NewGuid().ToString();
}
public string Gid { get; }
}
}
@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Store.Product.Models.Product.Image
{
public class MainImage : ProductImage
{
public override ProductImageType ImageType => ProductImageType.Main;
public MainImage()
{
}
public MainImage(string url) : base(url)
{
}
}
}
@@ -0,0 +1,67 @@
using Newtonsoft.Json;
using Store.Management.Framework.Helpers;
using System.Drawing;
namespace Store.Product.Models.Product.Image
{
/// <summary>
/// 商品图片
/// </summary>
public class ProductImage
{
public ProductImage()
{
}
public ProductImage(string url)
{
ImgUrl = url;
}
//public ProductImage(string url, ImageType type)
//{
// ImgUrl = url;
// ImageType = type;
//}
/// <summary>
/// 图片类型
/// </summary>
public virtual ProductImageType ImageType { get; protected set; } = ProductImageType.None;
/// <summary>
/// 文件名
/// </summary>
public string FileName { get; set; }
/// <summary>
/// 图片源路径
/// </summary>
public string ImgUrl { get; set; }
private byte[] _imgbyte;
/// <summary>
/// 图片流
/// </summary>
[JsonIgnore]
public byte[] ImgByte
{
get
{
if (_imgbyte == null)
{
_imgbyte = ImageHelper.DownloadImage(ImgUrl);
}
return _imgbyte;
}
set
{
_imgbyte = value;
}
}
/// <summary>
/// 上传后图片路径
/// </summary>
public string UploadImgUrl { get; set; }
}
}
@@ -0,0 +1,13 @@
namespace Store.Product.Models.Product.Image
{
/// <summary>
/// 图片类型
/// </summary>
public enum ProductImageType
{
None,
Main,
Sku,
Content
}
}
@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Store.Product.Models.Product.Image
{
public class SkuImage : ProductImage
{
public override ProductImageType ImageType => ProductImageType.Sku;
public SkuImage()
{
}
public SkuImage(string url) : base(url)
{
}
}
}
@@ -0,0 +1,34 @@
using Store.Product.Models.Product.Image;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Store.Product.Models.Product
{
/// <summary>
/// 主图集合
/// </summary>
public class MainImageCollection : List<ProductImage>
{
/// <summary>
/// 随机排序
/// </summary>
public void RandomSort()
{
Random random = new Random();
List<ProductImage> newList = new List<ProductImage>();
foreach (ProductImage item in this.Take(4))
{
newList.Insert(random.Next(newList.Count + 1), item);
}
if (this.Count == 5)
{
newList.Add(this.Last());
}
this.Clear();
this.AddRange(newList);
}
}
}
+139
View File
@@ -0,0 +1,139 @@
using Store.Product.Models.Product.Sku;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Store.Product.Models.Product;
/// <summary>
/// 商品属性基类
/// </summary>
public class ProductBase
{
private string _gid = Guid.NewGuid().ToString();
/// <summary>
/// 唯一ID
/// </summary>
public string Gid
{
get
{
return _gid;
}
}
/// <summary>
/// 商品ID
/// </summary>
public long Id { get; set; }
/// <summary>
/// 标题
/// </summary>
public string Title { get; set; }
/// <summary>
/// 商铺名称
/// </summary>
public string ShopName { get; set; }
/// <summary>
/// 类目ID
/// </summary>
public int CategoryId { get; set; }
/// <summary>
/// 销售数量
/// </summary>
public int SaleCount { get; set; }
/// <summary>
/// 库存数量
/// </summary>
public int StockCount { get; set; }
/// <summary>
/// 价格
/// </summary>
public decimal Price { get; set; }
/// <summary>
/// 以前价格 | 划线价格
/// </summary>
public decimal BeforePrice { get; set; }
/// <summary>
/// 邮费
/// </summary>
public decimal ExpressPrice { get; set; }
/// <summary>
/// 折扣
/// </summary>
public decimal Discount { get; set; }
/// <summary>
/// 折扣价格
/// </summary>
public decimal DiscountPrice { get; set; }
/// <summary>
/// 在线价格
/// </summary>
public decimal OnlinePrice { get; set; }
/// <summary>
/// 市场价格
/// </summary>
public decimal MarketPrice { get; set; }
/// <summary>
/// 主图
/// </summary>
public string MainImage { get; set; }
/// <summary>
/// 品牌
/// </summary>
public string ShopBrand { get; set; }
/// <summary>
/// 是否是促销品
/// </summary>
public bool IsPromotion { get; set; }
/// <summary>
/// 省
/// </summary>
public string State { get; set; }
/// <summary>
/// 市
/// </summary>
public string City { get; set; }
/// <summary>
/// 内容
/// </summary>
public ProductContent Content { get; set; } = new ProductContent("");
/// <summary>
/// 来源地址
/// </summary>
public virtual string SourceUrl { get; set; }
/// <summary>
/// 商品主图视频Id
/// </summary>
public long VideoId { get; set; }
/// <summary>
/// 重量
/// </summary>
public int Weight { get; set; }
/// <summary>
/// 商品特性
/// </summary>
public ProductPropertys Propertys { get; set; } = new ProductPropertys();
/// <summary>
/// SKU 属性值
/// </summary>
public SkuPropertys SkuProperty { get; set; } = new SkuPropertys();
/// <summary>
/// Sku 属性映射
/// </summary>
public SkuMaps SkuMaps { get; set; } = new SkuMaps();
/// <summary>
/// 主图列表
/// </summary>
public MainImageCollection MainImages { get; set; } = new MainImageCollection();
}
@@ -0,0 +1,101 @@
using Store.Product.Models.Product.Image;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace Store.Product.Models.Product
{
/// <summary>
/// 商品详情
/// </summary>
public class ProductContent
{
/// <summary>
/// 备份数据
/// </summary>
private string _backcontent = "";
public ProductContent(string content)
{
_backcontent = content;
_content = content;
ConvertContent();
}
private string _content = "";
public override string ToString()
{
return GetContent();
}
/// <summary>
/// 详情图片集合
/// </summary>
public List<ContentImage> Images { get; } = new List<ContentImage>();
/// <summary>
/// 删除详情图片
/// </summary>
/// <param name="image"></param>
public void DelImage(ContentImage image)
{
var item = Images.FirstOrDefault(a => a.Gid == image.Gid);
if (item != null)
{
string value = GetImgTag(item);
_content.Replace(value, "");
Images.Remove(item);
}
}
private void ConvertContent()
{
Regex regImg = new Regex(@"<img\b[^>]*?\bsrc[\s]*=[\s]*[""']?[\s]*(?<imgUrl>[^""'>]*)[^>]*?/?[\s]*>");
if (regImg.IsMatch(_backcontent))
{
MatchCollection matchs = regImg.Matches(_backcontent);
int MatchMax = matchs.Count;
for (int i = MatchMax - 1; i >=0; i--)
{
Match item = matchs[i];
if (item.Success)
{
Group urlgroup = item.Groups["imgUrl"];
if (urlgroup.Success)
{
var cimg = new ContentImage(urlgroup.Value);
Images.Add(cimg);
_content = _content.Remove(item.Index, item.Length);
_content = _content.Insert(item.Index, GetImgTag(cimg));
}
}
}
}
}
private string GetContent()
{
var tempContent = _content;
foreach (var item in Images)
{
string value = GetImgTag(item);
string imgString = $"<img src=\"{item.UploadImgUrl}\" width=\"100%\" />";
tempContent = tempContent.Replace(value, imgString);
}
return tempContent;
}
/// <summary>
/// 图片标记
/// </summary>
/// <param name="img"></param>
/// <returns></returns>
private string GetImgTag(ContentImage img)
{
return "${" + img.Gid + "}";
}
}
}
@@ -0,0 +1,51 @@
using MAX.Core.Commons;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Store.Product.Models.Product
{
/// <summary>
/// 商品属性
/// </summary>
public partial class ProductPropertys : List<CommonKeyValue>
{
/// <summary>
/// 是否存在Key
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public bool ContainsKey(string key)
{
return Exists(a => a.Key == key);
}
/// <summary>
/// 添加数据
/// </summary>
/// <param name="Key"></param>
/// <param name="Value"></param>
public void Add(string Key, string Value)
{
if (!ContainsKey(Key))
{
Add(new CommonKeyValue() { Key = Key, Value = Value });
}
}
/// <summary>
/// 获取值
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public string GetValue(string key)
{
if (ContainsKey(key))
{
CommonKeyValue p = this.FirstOrDefault(a => a.Key == key);
return p.Value;
}
return "";
}
}
}
@@ -0,0 +1,18 @@
namespace Store.Product.Models.Product.Sku
{
/// <summary>
/// 属性值
/// </summary>
public class Property
{
/// <summary>
/// Id
/// </summary>
public string Id { get; set; }
/// <summary>
/// 标题
/// </summary>
public string Name { get; set; }
}
}
@@ -0,0 +1,56 @@
using System.Collections.Generic;
using System.Linq;
namespace Store.Product.Models.Product.Sku
{
/// <summary>
/// Sku Map Item
/// </summary>
public class SkuMapItem
{
/// <summary>
/// 库存数量
/// </summary>
public int StockCount { get; set; }
/// <summary>
/// 价格
/// </summary>
public decimal Price { get; set; }
/// <summary>
/// 划线价格
/// </summary>
public decimal MarketPrice { get; set; }
/// <summary>
/// SkuId
/// </summary>
public long SkuId { get; set; }
/// <summary>
/// Sku 属性值
/// </summary>
public List<SkuMapProperty> Properties { get; set; } = new List<SkuMapProperty>();
/// <summary>
/// Sku 属性标题集合
/// </summary>
public string SkuPropertyTitles
{
get
{
string title = string.Join("},{", Properties.Select(a => a.ToString()));
title = "{" + title + "}";
return title;
}
}
/// <summary>
/// Sku属性Keyu
/// </summary>
public string SalePropKey
{
get
{
return string.Join("_", Properties.Select(a => a.SalePropKey));
}
}
}
}
@@ -0,0 +1,26 @@
namespace Store.Product.Models.Product.Sku
{
/// <summary>
/// SkuMap 属性
/// </summary>
public class SkuMapProperty : Property
{
public SkuPropertyItem Item { get; set; }
public override string ToString()
{
return $"{Name}:{Item.Name}";
}
/// <summary>
/// 属性Key
/// </summary>
/// <returns></returns>
public string SalePropKey
{
get
{
return (Id + "-" + Item.Id).Replace("p-", "");
}
}
}
}
@@ -0,0 +1,40 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Linq;
namespace Store.Product.Models.Product.Sku
{
/// <summary>
/// Sku Map映射
/// </summary>
public class SkuMaps : List<SkuMapItem>
{
/// <summary>
/// 最低价位
/// </summary>
/// <returns></returns>
public SkuMapItem SkuLowItem
{
get
{
var price = this.Min(a => a.Price);
return this.FirstOrDefault(a => a.Price == price);
}
}
/// <summary>
/// 最高价位
/// </summary>
/// <returns></returns>
public SkuMapItem SkuHighItem
{
get
{
var price = this.Max(a => a.Price);
return this.FirstOrDefault(a => a.Price == price);
}
}
}
}
@@ -0,0 +1,12 @@
using System.Collections.Generic;
namespace Store.Product.Models.Product.Sku
{
/// <summary>
/// SKU 属性值
/// </summary>
public class SkuProperty : Property
{
public List<SkuPropertyItem> Values { get; set; } = new List<SkuPropertyItem>();
}
}
@@ -0,0 +1,16 @@
using Store.Product.Models.Product.Image;
namespace Store.Product.Models.Product.Sku
{
/// <summary>
/// Sku属性 values
/// </summary>
public class SkuPropertyItem : Property
{
/// <summary>
/// 库存
/// </summary>
public int StockCount { get; set; }
public ProductImage SkuImg { get; set; }
}
}
@@ -0,0 +1,105 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Store.Product.Models.Product.Sku
{
/// <summary>
/// Sku属性
/// </summary>
public class SkuPropertys : List<SkuProperty>
{
public SkuPropertys()
{
}
/// <summary>
/// 是否存在Key
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public bool ContainsKey(string Id)
{
return Exists(a => a.Id == Id);
}
/// <summary>
/// 添加Sku属性
/// </summary>
/// <param name="id"></param>
/// <param name="name"></param>
public void AddSkuProperty(string id, string name)
{
if (!ContainsKey(id))
{
this.Add(new SkuProperty
{
Id = id,
Name = name,
Values = new List<SkuPropertyItem>()
});
}
}
/// <summary>
/// 添加Sku属性 包含值
/// </summary>
/// <param name="id"></param>
/// <param name="propertyItem"></param>
public void AddSkuPropertyItem(string id, SkuPropertyItem propertyItem)
{
if (propertyItem != null)
{
var item = GetPropertyById(id);
if (!item.Values.Exists(a => a.Id == propertyItem.Id))
{
item.Values.Add(propertyItem);
}
}
}
//public void AddSkuProperty(string id, string name, SkuPropertyItem propertyItem)
//{
//}
/// <summary>
/// 获取Sku属性值
/// </summary>
/// <param name="name"></param>
/// <param name="itemname"></param>
/// <returns></returns>
public SkuMapProperty GetSkuMapProperty(string name, string itemname)
{
SkuProperty p = this.FirstOrDefault(a => a.Name == name);
if (p != null)
{
var item = p.Values.FirstOrDefault(a => a.Name == itemname);
return new SkuMapProperty()
{
Id = p.Id,
Name = p.Name,
Item = item
};
}
return null;
}
/// <summary>
/// 获取值
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public SkuProperty GetPropertyById(string Id)
{
if (ContainsKey(Id))
{
SkuProperty p = this.FirstOrDefault(a => a.Id == Id);
return p;
}
return null;
}
}
}
@@ -0,0 +1,89 @@
using System.IO;
namespace Store.Product.Models.PublishParameters.Image
{
/// <summary>
/// 上传图片参数
/// </summary>
public class ImageParameters
{
/// <summary>
/// 是否随机删除一张详情图
/// </summary>
public bool IsRandomDelDetailImg { get; set; }
/// <summary>
/// 是否随机主图
/// </summary>
public bool IsRandomMainImg { get; set; }
/// <summary>
/// 复制上家主图视频
/// </summary>
public bool IsUploadVideoByCopy { get; set; }
/// <summary>
/// 上传自己视频空间索引视频
/// </summary>
public SwitchParams<int> IsUploadVideoFromToIndex { get; set; }
/// <summary>
/// Logo水印
/// </summary>
public SwitchParams<System.Drawing.Image> IsLogoWaterMark { get; set; }
/// <summary>
/// 图片质量百分比
/// </summary>
public int PicQuality { get; set; }
/// <summary>
/// 商铺文字水印
/// </summary>
public bool IsShopNameWaterMark { get; set; }
/// <summary>
/// 是否随机属性图充当主图
/// </summary>
public bool IsRandomPropImgFillToMainImg { get; set; }
/// <summary>
/// 简单的电脑详情图
/// </summary>
public bool IsSimpleContentPc { get; set; }
/// <summary>
/// 是否删除主图 索引
/// </summary>
public SwitchParams<int> IsDelMainImgByIndex { get; set; } = new SwitchParams<int>();
/// <summary>
/// 是否删除详情图 索引 在之前
/// </summary>
public SwitchParams<int> IsDelDetailImgByFromToIndex { get; set; } = new SwitchParams<int>();
/// <summary>
/// 是否开启 详情图 最大上传
/// </summary>
public SwitchParams<int> IsOnlyUpDetailImgMaxCount { get; set; } = new SwitchParams<int>();
/// <summary>
/// 主图 白底最后一张
/// </summary>
public bool IsMainImgBackgroundWihiteLast { get; set; }
/// <summary>
/// 是否盗链
/// </summary>
public bool IsSteal { get; set; } = false;
/// <summary>
/// 是否保留前x张主图
/// </summary>
public SwitchParams<int> IsKeepMainImgNum { get; set; } = new SwitchParams<int>();
public ImageParameters()
{
IsLogoWaterMark = new SwitchParams<System.Drawing.Image>();
//string brandPath = Path.Combine(GlobalConfig.AppDirectory + "Brand\\brand.png");
//if(File.Exists(brandPath))
//{
// IsLogoWaterMark.Value = System.Drawing.Image.FromFile(brandPath);
//}
}
}
}
@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Store.Product.Models.PublishParameters.Price
{
/// <summary>
/// 计算操作符
/// </summary>
public enum ComputationType
{
/// <summary>
/// 加
/// </summary>
ADD,
/// <summary>
/// 减法
/// </summary>
SUB
}
}
@@ -0,0 +1,60 @@
using Store.Product.Models.Product.Sku;
using System.Linq;
namespace Store.Product.Models.PublishParameters.Price
{
/// <summary>
/// 高低价格配置
/// </summary>
public class HighLowPrice : PriceConfigBase
{
public override PriceStrategyType PriceType => PriceStrategyType.高低价格;
/// <summary>
/// 低价倍数
/// </summary>
public decimal LowMultiples { get; set; } = 1;
/// <summary>
/// 其他倍数
/// </summary>
public decimal OtherMultiples { get; set; } = 1;
/// <summary>
/// 计算价格
/// </summary>
/// <param name="oldPrice"></param>
/// <returns></returns>
public override decimal ComputedPrice(decimal oldPrice)
{
return oldPrice * OtherMultiples;
}
/// <summary>
/// 计算最低价
/// </summary>
/// <param name="oldPrice"></param>
/// <returns></returns>
public decimal ComputedLowPrice(decimal oldPrice)
{
return oldPrice * LowMultiples;
}
public override SkuMaps ComputedPrice(SkuMaps skuMaps)
{
decimal minPrice = skuMaps.Min(a => a.Price);
foreach (var item in skuMaps)
{
if (item.Price == minPrice)
{
ComputedLowPrice(item.Price);
}
else
{
item.Price = ComputedPrice(item.Price);
}
}
return skuMaps;
}
}
}
@@ -0,0 +1,67 @@
using Store.Product.Models.Product.Sku;
namespace Store.Product.Models.PublishParameters.Price
{
/// <summary>
/// 翻倍价格配置
/// </summary>
public class MultiplesPrice : PriceConfigBase
{
public override PriceStrategyType PriceType => PriceStrategyType.常规价格;
/// <summary>
/// 翻 x 倍
/// </summary>
public int Multiples { get; set; } = 1;
/// <summary>
/// 计算
/// </summary>
public ComputationType Computation { get; set; } = ComputationType.ADD;
/// <summary>
/// 基础加价
/// </summary>
public decimal AddPrice { get; set; }
public MultiplesPrice() { }
/// <summary>
/// 翻倍价格配置
/// </summary>
/// <param name="multiples">倍数</param>
/// <param name="addprice">加价</param>
public MultiplesPrice(int multiples, decimal addprice)
{
Multiples = multiples;
AddPrice = addprice;
}
/// <summary>
/// 计算价格
/// </summary>
/// <param name="oldPrice"></param>
/// <returns></returns>
public override decimal ComputedPrice(decimal oldPrice)
{
var newPrice = oldPrice;
newPrice = oldPrice * Multiples;
switch (Computation)
{
case ComputationType.ADD:
newPrice = newPrice + AddPrice;
break;
case ComputationType.SUB:
newPrice = newPrice - AddPrice;
break;
default:
break;
}
return newPrice;
}
public override SkuMaps ComputedPrice(SkuMaps skuMaps)
{
foreach (var item in skuMaps)
{
item.Price = ComputedPrice(item.Price);
}
return skuMaps;
}
}
}
@@ -0,0 +1,39 @@
using Store.Product.Models.Product.Sku;
namespace Store.Product.Models.PublishParameters.Price
{
/// <summary>
/// 价格配置
/// </summary>
public abstract class PriceConfigBase
{
/// <summary>
/// 价格类型
/// </summary>
public abstract PriceStrategyType PriceType { get; }
///// <summary>
///// 快递费是否增加到商品价格
///// </summary>
//public bool IsExpressAddPrice { get; set; } = false;
///// <summary>
///// 是否随机增加金额 0-1元
///// </summary>
//public bool IsRandomAddPrice { get; set; } = false;
/// <summary>
/// 计算价格
/// </summary>
/// <returns></returns>
public abstract decimal ComputedPrice(decimal oldPrice);
/// <summary>
/// 计算价格
/// </summary>
/// <returns></returns>
public abstract SkuMaps ComputedPrice(SkuMaps skuMaps);
}
}
@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Store.Product.Models.PublishParameters.Price
{
/// <summary>
///
/// </summary>
public class PriceStrategyFactory
{
public static PriceConfigBase GetPriceStrategy(PriceStrategyType strategyType)
{
PriceConfigBase priceConfig;
switch (strategyType)
{
case PriceStrategyType.常规价格:
priceConfig = new MultiplesPrice();
break;
case PriceStrategyType.高低价格:
priceConfig = new HighLowPrice();
break;
case PriceStrategyType.分段价格:
priceConfig = new SectionPrice();
break;
default:
priceConfig = null;
break;
}
return priceConfig;
}
}
}
@@ -0,0 +1,12 @@
namespace Store.Product.Models.PublishParameters.Price
{
/// <summary>
/// 价格策略类型
/// </summary>
public enum PriceStrategyType
{
常规价格 = 0,
高低价格 = 1,
分段价格 = 2
}
}
@@ -0,0 +1,72 @@
using Store.Product.Models.Product.Sku;
using System.Collections.Generic;
using System.Linq;
namespace Store.Product.Models.PublishParameters.Price
{
/// <summary>
/// 区间价格配置
/// </summary>
public class SectionPrice : PriceConfigBase
{
public override PriceStrategyType PriceType => PriceStrategyType.分段价格;
/// <summary>
/// 区间列表
/// </summary>
public List<SectionItemPrice> SectionList { get; set; } = new List<SectionItemPrice>();
/// <summary>
/// 计算价格
/// </summary>
/// <param name="oldPrice"></param>
/// <returns></returns>
public override decimal ComputedPrice(decimal oldPrice)
{
var newPrice = oldPrice;
if (SectionList != null && SectionList.Count > 0)
{
foreach (var item in SectionList)
{
if (item.BeginPrice < newPrice && newPrice < item.EndPrice)
{
newPrice = item.ComputedPrice(newPrice);
}
}
if (newPrice == oldPrice)
{
newPrice = SectionList.Last().ComputedPrice(newPrice);
}
}
return newPrice;
}
public override SkuMaps ComputedPrice(SkuMaps skuMaps)
{
foreach (var item in skuMaps)
{
item.Price = ComputedPrice(item.Price);
}
return skuMaps;
}
/// <summary>
/// 指定区间价格
/// </summary>
public class SectionItemPrice : MultiplesPrice
{
/// <summary>
/// 开始价格
/// </summary>
public decimal BeginPrice { get; set; } = 0;
/// <summary>
/// 结束价格
/// </summary>
public decimal EndPrice { get; set; } = 10000000;
}
}
}
@@ -0,0 +1,66 @@
using Newtonsoft.Json;
using Store.Product.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Store.Product.Models.PublishParameters
{
/// <summary>
/// 商品存储状态
/// </summary>
public class ProductStorage
{
/// <summary>
/// 立即上架
/// </summary>
public static ProductStorage OnSale
{
get
{
return new ProductStorage() { Status = ProductStorageStatus.立刻上架 };
}
}
/// <summary>
/// 放入仓库
/// </summary>
public static ProductStorage InStock
{
get
{
return new ProductStorage() { Status = ProductStorageStatus.放入仓库 };
}
}
/// <summary>
/// 定时上架
/// </summary>
/// <returns></returns>
public static ProductStorage TimedOnSale(DateTime time)
{
return new ProductStorage { Status = ProductStorageStatus.定时上架, ShelfTime = time };
}
public ProductStorage()
{
}
public ProductStorage(ProductStorageStatus status, DateTime? time = null)
{
Status = status;
if (Status == ProductStorageStatus.定时上架)
{
ShelfTime = time;
}
}
/// <summary>
/// 发布商品状态
/// </summary>
public ProductStorageStatus Status { get; set; } = ProductStorageStatus.立刻上架;
/// <summary>
/// 定时上架时间
/// </summary>
public DateTime? ShelfTime { get; set; }
}
}
@@ -0,0 +1,111 @@
using Store.Framework.Models;
using Store.Framework.Models.Product;
using Store.Product.Enums;
using Store.Product.Models.Product;
using Store.Product.Models.PublishParameters.Image;
using Store.Product.Models.PublishParameters.Price;
using Store.Product.Models.PublishParameters.Sku;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Store.Product.Models.PublishParameters;
public class PublishParameters
{
/// <summary>
/// 价格配置
/// </summary>
public PriceConfigBase PriceStrategy { get; set; }
/// <summary>
/// 图片上传参数
/// </summary>
public ImageParameters UpImageParams { get; set; } = new ImageParameters();
#region 重要参数
/// <summary>
/// Sku 上传参数
/// </summary>
public SkuParameters SkuParams { get; set; } = new SkuParameters();
/// <summary>1
/// 存储类型 上架Or仓库 Stock
/// </summary>
public ProductStorage StorageType { get; set; } = new ProductStorage();
/// <summary>
/// 店铺上传最大限制
/// </summary>
public int ShopUpMaxCount { get; set; }
/// <summary>
/// 过滤商品价格
/// </summary>
public SwitchParams<Tuple<int, int>> IsFilterPrice { get; set; } = new SwitchParams<Tuple<int, int>>(false, new Tuple<int, int>(0, int.MaxValue));
/// <summary>
/// 运费模板类型
/// </summary>
public FreightTemplateType FreightTemplateType { get; set; } = FreightTemplateType.Fixed;
///// <summary>
/// 运费模板
/// </summary>
//public FreightTemplateModel FreightTemplate { get; set; }
/// <summary>
/// 标题前缀
/// </summary>
public string TitlePrefix { get; set; }
#endregion
#region 其他参数
/// <summary>
/// 自定义删除标题关键字
/// </summary>
public bool IsRemoveCustomTitleKeywors { get; set; }
/// <summary>
/// 自定义过滤标题关键字
/// </summary>
public bool IsFilterCustomTitleKeywors { get; set; }
/// <summary>
/// 自定义类目
/// </summary>
public SwitchParams<CategoryModel> IsCustomCategory { get; set; } = new SwitchParams<CategoryModel>();
/// <summary>
/// 自定义描述
/// </summary>
public string CustomDescription { get; set; }
/// <summary>
/// 过滤非法标题
/// </summary>
public bool IsFilterIllegalTitle { get; set; }
/// <summary>
/// 过滤不包邮
/// </summary>
public bool IsFilterPackage { get; set; }
/// <summary>
/// 是否设置最低价库存
/// </summary>
public SwitchParams<int> IsSetLowPriceStock { get; set; } = new SwitchParams<int>();
/// <summary>
/// 是否使用代理
/// </summary>
public bool IsProxy { get; set; }
/// <summary>
/// 是否自动删除标题违规词语
/// </summary>
public bool IsRemoveIllegalTitle { get; set; }
#endregion
}
@@ -0,0 +1,28 @@
using Store.Product.Models.PublishParameters.Price;
namespace Store.Product.Models.PublishParameters.Sku
{
/// <summary>
/// 自定义Sku
/// </summary>
public class CustomSku
{
/// <summary>
/// 标题
/// </summary>
public string Title { get; set; }
/// <summary>
/// 翻倍
/// </summary>
public MultiplesPrice Multiples { get; set; }
/// <summary>
/// 图片地址
/// </summary>
public string ImagePath { get; set; }
/// <summary>
/// 库存
/// </summary>
public int StockCount { get; set; }
}
}
@@ -0,0 +1,27 @@
using Store.Product.Models.PublishParameters;
namespace Store.Product.Models.PublishParameters.Sku
{
/// <summary>
/// 上传Sku配置
/// </summary>
public class SkuParameters
{
/// <summary>
/// Sku名称随机增加特殊字符
/// </summary>
public bool IsSkuPropertyRandomChar { get; set; }
/// <summary>
/// 随机删除Sku
/// </summary>
public bool IsRandomDelSku { get; set; }
/// <summary>
/// 自定义Sku
/// </summary>
public SwitchParams<CustomSku> IsCustomSku { get; set; } = new SwitchParams<CustomSku>();
/// <summary>
/// 是否固定截取
/// </summary>
public bool IsSkuFixedSplit { get; set; }
}
}
@@ -0,0 +1,24 @@
namespace Store.Product.Models.PublishParameters
{
/// <summary>
/// 请求参数 是否开启 和值
/// </summary>
/// <typeparam name="T"></typeparam>
public class SwitchParams<T>
{
/// <summary>
/// 是否开启
/// </summary>
public bool IsOpened { get; set; } = false;
/// <summary>
/// 值
/// </summary>
public T Value { get; set; } = default;
public SwitchParams() { }
public SwitchParams(bool isopen, T value)
{
IsOpened = isopen;
Value = value;
}
}
}
@@ -0,0 +1,263 @@
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.Linq;
using Store.Framework.Extensions;
using System;
using System.Collections.Generic;
using System.Drawing;
namespace Store.Product.Models.PublishParameters.Wx;
/// <summary>
/// Store.Product 新的微信商品上传参数实体。
/// 说明:这里不修改 AllBase 中已有上传参数实体,当前作为迁移期承载对象复用其字段结构。
/// </summary>
public class WxProductUploadParam
{
public WxProductUploadSource Source { get; set; } = new();
public WXUploadProductInitParam InitParameter { get; set; } = new();
public WXUploadProductParam ProductParameter { get; set; } = new();
public WxProductPublishState State { get; set; } = new();
public WxProductUploadOptions Options { get; set; } = new();
public WxProductUploadRuntime Runtime { get; set; } = new();
/// <summary>步骤正常提前结束或最终成功时写入的返回 JSON。</summary>
public string Result { get; set; }
/// <summary>正常提前结束发布时置为 true,流水线不再执行后续步骤。</summary>
public bool IsCompleted { get; set; }
}
public class WxProductUploadSource
{
public ShopLoginInfo Shop { get; set; }
public KJDDBProduct DbProduct { get; set; }
public TemuDBProductSelect SelectProduct { get; set; }
public DateTime StartTime { get; set; } = DateTime.Now;
}
/// <summary>
/// 原 UploadProduct 方法中跨 #region 使用的可变状态。
/// TODO(迁移): 个别字段当前为 dynamic,需按 Store.Product 最终 DTO 改为明确类型。
/// </summary>
public class WxProductPublishState
{
public int CommissionRate { get; set; }
public int MinCommissionRate { get; set; }
public int MaxCommissionRate { get; set; }
public int CommissionRateChange { get; set; }
public int? FromCommissionRate { get; set; }
public WXGetEditProductInfoLite WxEditProdInfo { get; set; }
public JObject ProdJObject { get; set; } = new();
public bool IsChangeImgDic { get; set; }
public Dictionary<string, string> WxImgMapDic { get; set; } = new();
public PDDProductInfo ProdInfo { get; set; }
public int MainImgCount { get; set; }
public bool NeedAddRandomBlock { get; set; }
public bool WantAddRandomBlock { get; set; }
public WXShopTokenInfo Token { get; set; }
public string ProdTitle { get; set; }
public string ExtCode { get; set; }
public List<gallery_item> MainGalleries { get; set; } = new();
public List<long> AiCateIdLst { get; set; } = new();
public string GetCateRst { get; set; }
public JObject JCateRst { get; set; }
public long LeafCatId { get; set; }
public WxCatBoundInfo Bound { get; set; }
public int MaxBound { get; set; }
public int MinBound { get; set; }
public string SpBrandId { get; set; }
public string SpBrandName { get; set; }
public string ShippingTemplateJson { get; set; }
public int ShipPrice { get; set; }
public string ExpressRst { get; set; }
public List<gallery_item> DetailGalleries { get; set; } = new();
public WXUploadProductInfoRecommendParam RecommendParamRst { get; set; } = new();
public allAttrParam ProductAttr { get; set; }
public int MaxSkuSpecCnt { get; set; }
public int SkuIndex { get; set; }
public int Id { get; set; }
public long CatId { get; set; }
public long FCatId { get; set; }
public long ValueCatId { get; set; }
public Dictionary<string, long> DicSpecParentNameId { get; set; } = new();
public Dictionary<string, long> DicSpecParentNameCatId { get; set; } = new();
public Dictionary<string, long> DicSpecNameFCatId { get; set; } = new();
public Dictionary<string, long> DicSpecNameCatId { get; set; } = new();
public string UploadDraftRst { get; set; }
public string CommissionRstStr { get; set; }
public string DefaultAdultBrandId { get; set; }
public bool IsWxNotUseSoftwareDefaultAddressOnce { get; set; }
public List<WXShopTokenInfo> WxShopTokenInfoList { get; set; } = new();
public List<wx_qualification_image_info> QualificationImages { get; set; } = new();
public List<string> ForceFilterKeywords { get; set; } = new();
public List<dynamic> AddPriceRules { get; set; } = new();
public dynamic WxUploadRule { get; set; }
public string PddProductCates { get; set; }
public dynamic UploadDraftProductList { get; set; }
}
/// <summary>
/// UploadProduct 从窗体控件和配置读取的入参快照。
/// TODO(迁移): 后续可将这些字段逐步替换成 Store.Product 自己的发布规则模型。
/// </summary>
public class WxProductUploadOptions
{
public WxProductUploadFormState Form { get; set; } = new();
}
/// <summary>
/// 原方法依赖的窗体操作与通用上传能力适配入口。
/// </summary>
public class WxProductUploadRuntime
{
public object Host { get; set; }
public dynamic Cell { get; set; } = new WxUploadCellState();
public dynamic CancellationTokenSource { get; set; } = new WxUploadCancellationState();
public Func<string, string> GetAiImg { get; set; }
public Func<ShopLoginInfo, string, object, bool, string> UploadImgByUrl { get; set; }
public Func<ShopLoginInfo, Bitmap, object, string> UploadImgByBitmap { get; set; }
public GetImgBase64ForApiHandler GetImgBase64ForApi { get; set; }
public Action<string> SetStatus { get; set; }
public Action Cancel { get; set; }
public Action<string> ShowError { get; set; }
}
public delegate string GetImgBase64ForApiHandler(
out string errorMsg,
string imgUrl,
bool needAddRandomBlock,
bool wantAddRandomBlock,
int imgWidth = 0,
int imgHeight = 0,
bool wantAddRandomBorder = false);
public class WxUploadCellState
{
private object _value;
public object Value
{
get => _value;
set => _value = value;
}
}
public class WxUploadCancellationState
{
public Action CancelAction { get; set; }
public void Cancel()
{
CancelAction?.Invoke();
}
}
/// <summary>
/// 原窗体控件的状态代理,避免 Store.Product 直接引用 WinForms 控件类型。
/// </summary>
public class WxProductUploadFormState
{
public dynamic chkFissionGoodsName { get; set; } = new WxControlState();
public dynamic txtFissionTitle { get; set; } = new WxControlState();
public dynamic chkSkipUploaded { get; set; } = new WxControlState();
public dynamic chkCommission { get; set; } = new WxControlState();
public dynamic cmbCommissionAddOrReduce { get; set; } = new WxControlState();
public dynamic txtCommissionChangeValue { get; set; } = new WxControlState();
public dynamic txtMinUpCommission { get; set; } = new WxControlState();
public dynamic txtMaxUpCommission { get; set; } = new WxControlState();
public dynamic chkImgRandomBlock { get; set; } = new WxControlState();
public dynamic chkRandomMainImgOrder { get; set; } = new WxControlState();
public dynamic chkRandomDetailImgOrder { get; set; } = new WxControlState();
public dynamic chkFissionRandomPriceChange { get; set; } = new WxControlState();
public dynamic txtFissionRandomPriceChange { get; set; } = new WxControlState();
public dynamic chkHighestPriceSku { get; set; } = new WxControlState();
public dynamic chkLowestPriceSku { get; set; } = new WxControlState();
public dynamic chkSameSpecPriceUp { get; set; } = new WxControlState();
public dynamic chkSameSpecPriceDown { get; set; } = new WxControlState();
public dynamic txtMinPrice { get; set; } = new WxControlState();
public dynamic txtMaxPrice { get; set; } = new WxControlState();
public dynamic txtReplaceText { get; set; } = new WxControlState();
public dynamic chkSkipReplaceText { get; set; } = new WxControlState();
public dynamic chkRemoveSpecialChar { get; set; } = new WxControlState();
public dynamic chkUseWXComplateProd { get; set; } = new WxControlState();
public dynamic chkUseRecommand { get; set; } = new WxControlState();
public dynamic cmbSpBrandName { get; set; } = new WxControlState();
public dynamic txtFilterBoundMax { get; set; } = new WxControlState();
public dynamic txtFilterBoundMin { get; set; } = new WxControlState();
public dynamic txtMainBorderImgCount { get; set; } = new WxControlState();
public dynamic txtDetailBorderImgCount { get; set; } = new WxControlState();
public dynamic chkRandomImgBorder { get; set; } = new WxControlState();
public dynamic chkAiImage { get; set; } = new WxControlState();
public dynamic txtAiImgCount { get; set; } = new WxControlState();
public dynamic chkFreightInsurance { get; set; } = new WxControlState();
public dynamic chkUseShanghaiReturnOrderAddress { get; set; } = new WxControlState();
public dynamic chkPreSale { get; set; } = new WxControlState();
public dynamic chkDefaultBestBefore { get; set; } = new WxControlState();
public dynamic txtDefaultBestBefore { get; set; } = new WxControlState();
public dynamic chkTestNoAuditUpload { get; set; } = new WxControlState();
public dynamic chkUpDraft { get; set; } = new WxControlState();
public dynamic chkIsSubmitSuccess { get; set; } = new WxControlState();
public dynamic dgvShop { get; set; } = new WxControlState();
}
public class WxControlState
{
public bool Checked { get; set; }
public string Text { get; set; } = "";
public decimal Value { get; set; }
public object SelectedValue { get; set; }
public object SelectedItem { get; set; }
public int SelectedIndex { get; set; } = -1;
public dynamic Items { get; set; } = new List<object>();
public static WxControlState FromCheckBox(dynamic checkBox)
{
return new WxControlState
{
Checked = checkBox?.Checked == true,
Text = checkBox?.Text ?? ""
};
}
public static WxControlState FromTextBox(dynamic textBox)
{
return new WxControlState
{
Text = textBox?.Text ?? ""
};
}
public static WxControlState FromComboBox(dynamic comboBox)
{
if (comboBox == null)
{
return new WxControlState();
}
return new WxControlState
{
Text = comboBox.Text ?? "",
SelectedValue = comboBox.SelectedValue,
SelectedItem = comboBox.SelectedItem,
SelectedIndex = comboBox.SelectedIndex
};
}
public static WxControlState FromNumericUpDown(dynamic numericUpDown)
{
return new WxControlState
{
Value = numericUpDown?.Value ?? 0m,
Text = numericUpDown?.Text ?? ""
};
}
}