using SqlSugar; namespace AssetManager.Data; /// /// 交易流水表 /// [SugarTable("transactions")] public class Transaction { /// /// 主键 /// [SugarColumn(IsPrimaryKey = true, IsIdentity = false)] public string? Id { get; set; } /// /// 所属组合ID /// [SugarColumn(ColumnName = "portfolio_id", IndexGroupNameList = new string[] { "idx_portfolio_id" })] public string? PortfolioId { get; set; } /// /// 交易类型 (buy/sell) /// [SugarColumn(ColumnName = "type", Length = 20)] public string? Type { get; set; } /// /// 标的代码 /// [SugarColumn(ColumnName = "stock_code", Length = 50)] public string? StockCode { get; set; } /// /// 资产类型 (Stock/Crypto) /// [SugarColumn(ColumnName = "asset_type", Length = 20)] public string? AssetType { get; set; } /// /// 交易标题 (如: 定期定投) /// [SugarColumn(ColumnName = "title", Length = 200)] public string? Title { get; set; } /// /// 交易数量 /// [SugarColumn(ColumnName = "amount", ColumnDataType = "decimal(18,8)")] public decimal Amount { get; set; } /// /// 成交价格 /// [SugarColumn(ColumnName = "price", ColumnDataType = "decimal(18,4)")] public decimal Price { get; set; } /// /// 交易总金额(原始币种) /// [SugarColumn(ColumnName = "total_amount", ColumnDataType = "decimal(18,4)")] public decimal TotalAmount { get; set; } /// /// 交易币种 /// [SugarColumn(ColumnName = "currency", Length = 10)] public string? Currency { get; set; } /// /// 交易时汇率(原始币种 -> 组合本位币) /// 用于精确计算历史净值,避免汇率变化影响 /// [SugarColumn(ColumnName = "exchange_rate", ColumnDataType = "decimal(18,6)", IsNullable = true)] public decimal? ExchangeRate { get; set; } /// /// 交易总金额(组合本位币) /// = TotalAmount * ExchangeRate,用于精确计算 /// [SugarColumn(ColumnName = "total_amount_base", ColumnDataType = "decimal(18,4)", IsNullable = true)] public decimal? TotalAmountBase { get; set; } /// /// 交易状态 (processing/completed) /// [SugarColumn(ColumnName = "status", Length = 50)] public string? Status { get; set; } /// /// 交易备注 /// [SugarColumn(ColumnName = "remark", Length = 500, IsNullable = true)] public string? Remark { get; set; } /// /// 交易发生时间 /// [SugarColumn(ColumnName = "transaction_time")] public DateTime TransactionTime { get; set; } /// /// 记录创建时间 /// [SugarColumn(ColumnName = "created_at")] public DateTime CreatedAt { get; set; } }