using MiaoJiZhang.Domain.Enums; namespace MiaoJiZhang.Domain.Entities; /// 账本(支持多账本/共享账本) public class Ledger { public long Id { get; set; } public long OwnerId { get; set; } public User Owner { get; set; } = null!; public string Name { get; set; } = null!; public string IconKey { get; set; } = "wallet"; public bool IsDefault { get; set; } public DateTime CreatedAt { get; set; } public List Transactions { get; set; } = []; public List Budgets { get; set; } = []; } /// 分类(系统默认分类 UserId 为 null;用户自定义分类挂 UserId) public class Category { public long Id { get; set; } /// null = 系统默认分类(后台可管理) public long? UserId { get; set; } public TransactionType Type { get; set; } public string Name { get; set; } = null!; public string IconKey { get; set; } = "tag"; public string ColorKey { get; set; } = "mint"; public int SortOrder { get; set; } public bool IsDeleted { get; set; } } /// 账单 public class Transaction { public long Id { get; set; } public long LedgerId { get; set; } public Ledger Ledger { get; set; } = null!; public long UserId { get; set; } public long CategoryId { get; set; } public Category Category { get; set; } = null!; public TransactionType Type { get; set; } public decimal Amount { get; set; } public string? Note { get; set; } public string? PaymentMethod { get; set; } public DateTime OccurredAt { get; set; } // ---- AI 来源追溯(决策:可核对、可撤销) ---- public TransactionSource Source { get; set; } = TransactionSource.Manual; /// AI 记账时用户的原话(追溯用) public string? SourceText { get; set; } /// 关联的聊天消息 Id(追溯用) public long? SourceChatMessageId { get; set; } public string? ClientRequestId { get; set; } // ---- 软删除(决策:直接入账 + 可撤销) ---- public bool IsDeleted { get; set; } public DateTime? DeletedAt { get; set; } public DateTime CreatedAt { get; set; } public DateTime UpdatedAt { get; set; } } /// 预算(CategoryId 为 null 表示总预算) public class Budget { public long Id { get; set; } public long LedgerId { get; set; } public Ledger Ledger { get; set; } = null!; public long UserId { get; set; } /// null = 月度总预算 public long? CategoryId { get; set; } /// 格式 yyyyMM;0 表示长期生效模板 public int Period { get; set; } public decimal Amount { get; set; } } /// AI 聊天消息 public class ChatMessage { public long Id { get; set; } public long UserId { get; set; } public ChatRole Role { get; set; } public ChatMessageType Type { get; set; } /// 文本内容 / 表情包 key / 卡片 JSON public string Content { get; set; } = null!; /// 该消息产生的账单 Id(BillCard 类型) public long? TransactionId { get; set; } public DateTime CreatedAt { get; set; } }