deliveryman-api/app/models/settlement.py
2025-03-13 09:28:58 +08:00

39 lines
1.3 KiB
Python
Raw Permalink 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.

from sqlalchemy import Column, Integer, String, DateTime, JSON, Date, ForeignKey
from sqlalchemy.sql import func
from pydantic import BaseModel, Field
from typing import Optional, Dict, Any
from datetime import date, datetime
from .database import Base
from .community import CommunityDB
class SettlementHistoryDB(Base):
"""结算历史记录表"""
__tablename__ = "settlement_history"
id = Column(Integer, primary_key=True, autoincrement=True)
settle_date = Column(Date, nullable=False, index=True, comment="结算日期")
community_id = Column(Integer, ForeignKey("communities.id"), nullable=False, index=True, comment="小区ID")
community_name = Column(String(100), nullable=False, comment="小区名称")
settle_details = Column(JSON, nullable=False, comment="结算详情JSON格式")
create_time = Column(DateTime(timezone=True), server_default=func.now(), comment="创建时间")
class Config:
orm_mode = True
# Pydantic 模型
class SettlementHistoryCreate(BaseModel):
settle_date: date
community_id: int
community_name: str
settle_details: Dict[str, Any]
class SettlementHistoryInfo(BaseModel):
id: int
settle_date: date
community_id: int
community_name: str
settle_details: Dict[str, Any]
create_time: datetime
class Config:
from_attributes = True