Files
jizhi/backend/MiaoJiZhang.Domain/Entities/Ledger.cs
T

100 lines
3.7 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using MiaoJiZhang.Domain.Enums;
namespace MiaoJiZhang.Domain.Entities;
/// <summary>账本(支持多账本/共享账本)</summary>
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<Transaction> Transactions { get; set; } = [];
public List<Budget> Budgets { get; set; } = [];
}
/// <summary>分类(系统默认分类 UserId 为 null;用户自定义分类挂 UserId</summary>
public class Category
{
public long Id { get; set; }
/// <summary>null = 系统默认分类(后台可管理)</summary>
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; }
}
/// <summary>账单</summary>
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 TransferDirection? TransferDirection { get; set; }
public string? Counterparty { get; set; }
public DateTime OccurredAt { get; set; }
// ---- AI 来源追溯(决策:可核对、可撤销) ----
public TransactionSource Source { get; set; } = TransactionSource.Manual;
/// <summary>AI 记账时用户的原话(追溯用)</summary>
public string? SourceText { get; set; }
/// <summary>关联的聊天消息 Id(追溯用)</summary>
public long? SourceChatMessageId { get; set; }
public string? ClientRequestId { get; set; }
public string? Provider { get; set; }
public string? ProviderTransactionId { get; set; }
public string? RecognitionOccurrenceId { get; set; }
public string? EvidenceFingerprint { get; set; }
public string? RecognitionConfidence { get; set; }
// ---- 软删除(决策:直接入账 + 可撤销) ----
public bool IsDeleted { get; set; }
public DateTime? DeletedAt { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime UpdatedAt { get; set; }
}
/// <summary>预算(CategoryId 为 null 表示总预算)</summary>
public class Budget
{
public long Id { get; set; }
public long LedgerId { get; set; }
public Ledger Ledger { get; set; } = null!;
public long UserId { get; set; }
/// <summary>null = 月度总预算</summary>
public long? CategoryId { get; set; }
/// <summary>格式 yyyyMM0 表示长期生效模板</summary>
public int Period { get; set; }
public decimal Amount { get; set; }
}
/// <summary>AI 聊天消息</summary>
public class ChatMessage
{
public long Id { get; set; }
public long UserId { get; set; }
public ChatRole Role { get; set; }
public ChatMessageType Type { get; set; }
/// <summary>文本内容 / 表情包 key / 卡片 JSON</summary>
public string Content { get; set; } = null!;
/// <summary>该消息产生的账单 IdBillCard 类型)</summary>
public long? TransactionId { get; set; }
public DateTime CreatedAt { get; set; }
}