product
This commit is contained in:
		
							
								
								
									
										99
									
								
								modules/admin/src/KonSoft.Admin.Domain/Entities/Product.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										99
									
								
								modules/admin/src/KonSoft.Admin.Domain/Entities/Product.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,99 @@
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.ComponentModel.DataAnnotations.Schema;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using Volo.Abp.Domain.Entities.Auditing;
 | 
			
		||||
 | 
			
		||||
namespace KonSoft.Admin.Entities
 | 
			
		||||
{
 | 
			
		||||
    public class Product(Guid id, string name, string code, decimal price, string description, string type, Guid? parentId, string status = "在售", int order = 0) : FullAuditedAggregateRoot<Guid>(id)
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 分类名称
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Name { get; private set; } = name;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 商品编码
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Code { get; private set; } = code;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 商品价格
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public decimal Price { get; private set; } = price;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 商品描述
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Description { get; private set; } = description;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 分类类型(大类或小类)
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Type { get; private set; } = type;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 父分类ID
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Guid? ParentId { get; private set; } = parentId;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 商品状态(在售/下架等)
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Status { get; private set; } = status;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 排序字段
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public int Order { get; private set; } = order;
 | 
			
		||||
 | 
			
		||||
        [NotMapped]
 | 
			
		||||
        public List<Product> Children { get; set; } = new();
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 修改商品信息
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void Update(string name, string code, decimal price, string description, int order)
 | 
			
		||||
        {
 | 
			
		||||
            Name = name;
 | 
			
		||||
            Code = code;
 | 
			
		||||
            Price = price;
 | 
			
		||||
            Description = description;
 | 
			
		||||
            Order = order;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 修改商品分类
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void ChangeCategory(string type, Guid? parentId)
 | 
			
		||||
        {
 | 
			
		||||
            Type = type;
 | 
			
		||||
            ParentId = parentId;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 上架商品
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void PutOnSale()
 | 
			
		||||
        {
 | 
			
		||||
            Status = "在售";
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 下架商品
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void TakeOffSale()
 | 
			
		||||
        {
 | 
			
		||||
            Status = "下架";
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 修改价格
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void ChangePrice(decimal newPrice)
 | 
			
		||||
        {
 | 
			
		||||
            Price = newPrice;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user