增加项目,分层

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,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;
}
}
}