增加项目,分层
This commit is contained in:
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user