using SqlSugar;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Auditing;
using Yi.Framework.Stock.Domain.Shared;
namespace Yi.Framework.Stock.Domain.Entities
{
///
/// 股票交易记录实体
///
///
/// 用于记录用户买入或卖出股票的交易历史
///
[SugarTable("Stock_Transaction")]
public class StockTransactionEntity : Entity, IAuditedObject
{
///
/// 用户ID
///
/// 进行交易的用户
public Guid UserId { get; set; }
///
/// 股票ID
///
/// 交易的股票
public Guid StockId { get; set; }
///
/// 股票代码
///
/// 冗余字段,方便查询
public string StockCode { get; set; } = string.Empty;
///
/// 股票名称
///
/// 冗余字段,方便查询
public string StockName { get; set; } = string.Empty;
///
/// 交易类型
///
public TransactionTypeEnum TransactionType { get; set; }
///
/// 交易价格
///
/// 股票的单价
public decimal Price { get; set; }
///
/// 交易数量
///
/// 买入或卖出的股票数量
public int Quantity { get; set; }
///
/// 交易总额
///
/// 价格 × 数量
public decimal TotalAmount { get; set; }
///
/// 交易费用
///
/// 手续费、佣金等
public decimal Fee { get; set; }
///
/// 创建时间
///
/// 交易发生时间
public DateTime CreationTime { get; set; }
///
/// 创建者ID
///
public Guid? CreatorId { get; set; }
///
/// 最后修改时间
///
public DateTime? LastModificationTime { get; set; }
///
/// 最后修改者ID
///
public Guid? LastModifierId { get; set; }
///
/// 备注
///
public string Remark { get; set; } = string.Empty;
public StockTransactionEntity() { }
public StockTransactionEntity(
Guid userId,
Guid stockId,
string stockCode,
string stockName,
TransactionTypeEnum transactionType,
decimal price,
int quantity,
decimal fee = 0)
{
Id = Guid.NewGuid();
UserId = userId;
StockId = stockId;
StockCode = stockCode;
StockName = stockName;
TransactionType = transactionType;
Price = price;
Quantity = quantity;
TotalAmount = price * quantity;
Fee = fee;
CreationTime = DateTime.Now;
}
}
}