交易流水对账明细导出完成

This commit is contained in:
2026-06-25 16:53:04 +08:00
parent 8aafd7de32
commit 30db7d3bf5
34 changed files with 2491 additions and 327 deletions
+11 -3
View File
@@ -1,6 +1,4 @@
from datetime import datetime
from sqlalchemy import DateTime, ForeignKey, Integer, String
from sqlalchemy import ForeignKey, Index, Integer, String
from sqlalchemy.orm import Mapped, mapped_column
from app.models.base import Base, TimestampMixin
@@ -8,6 +6,10 @@ from app.models.base import Base, TimestampMixin
class TokenUsage(Base, TimestampMixin):
__tablename__ = "token_usage"
__table_args__ = (
Index("ix_token_usage_owner", "owner_type", "owner_id"),
Index("ix_token_usage_biz_key", "biz_key"),
)
id: Mapped[str] = mapped_column(String(32), primary_key=True)
model_config_id: Mapped[str | None] = mapped_column(
@@ -19,3 +21,9 @@ class TokenUsage(Base, TimestampMixin):
input_tokens: Mapped[int] = mapped_column(Integer, default=0)
output_tokens: Mapped[int] = mapped_column(Integer, default=0)
total_tokens: Mapped[int] = mapped_column(Integer, default=0)
owner_type: Mapped[str | None] = mapped_column(String(64), nullable=True, index=True)
owner_id: Mapped[str | None] = mapped_column(String(64), nullable=True, index=True)
biz_key: Mapped[str | None] = mapped_column(String(160), nullable=True, index=True)
source_module: Mapped[str | None] = mapped_column(String(64), nullable=True, index=True)
source_step_code: Mapped[str | None] = mapped_column(String(64), nullable=True, index=True)