deep-risk/backend/app/models/settlement.py
2025-12-14 20:08:27 +08:00

99 lines
3.1 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 datetime import date, datetime
from typing import Optional, TYPE_CHECKING
from sqlalchemy import (
Column,
Date,
DateTime,
Integer,
String,
Text,
Float,
)
from sqlalchemy.orm import Mapped, mapped_column
from app.models.base import BaseModel
if TYPE_CHECKING:
from .streamer import StreamerInfo, McnAgency
class Settlement(BaseModel):
"""
佣金结算单表
"""
__tablename__ = "settlement"
settlement_id: Mapped[str] = mapped_column(
String(50), unique=True, nullable=False, comment="结算单ID"
)
settlement_no: Mapped[str] = mapped_column(
String(100), nullable=False, comment="结算单号"
)
streamer_id: Mapped[str] = mapped_column(
String(50), nullable=False, comment="主播ID"
)
streamer_name: Mapped[str] = mapped_column(
String(100), nullable=False, comment="主播姓名"
)
streamer_entity_type: Mapped[str] = mapped_column(
String(20), nullable=False, comment="主播主体类型"
)
settlement_period: Mapped[str] = mapped_column(
String(20), nullable=False, comment="结算周期YYYY-MM"
)
settlement_start_date: Mapped[date] = mapped_column(
Date, nullable=False, comment="结算开始日期"
)
settlement_end_date: Mapped[date] = mapped_column(
Date, nullable=False, comment="结算结束日期"
)
order_count: Mapped[int] = mapped_column(
nullable=False, comment="订单数量"
)
total_sales: Mapped[float] = mapped_column(
nullable=False, comment="总销售额"
)
total_commission: Mapped[float] = mapped_column(
nullable=False, comment="总佣金"
)
platform_service_fee: Mapped[float] = mapped_column(
nullable=False, comment="平台服务费"
)
actual_settlement_amount: Mapped[float] = mapped_column(
nullable=False, comment="实际结算金额"
)
tax_withholding: Mapped[float] = mapped_column(
default=0, comment="代扣代缴税费"
)
payment_method: Mapped[str] = mapped_column(
String(50),
nullable=False,
comment="付款方式bank_transfer-银行转账alipay-支付宝wechat-微信",
)
payment_account_no: Mapped[str] = mapped_column(
String(50), nullable=False, comment="付款账号"
)
payment_account_name: Mapped[str] = mapped_column(
String(100), nullable=False, comment="付款账户名"
)
payment_time: Mapped[Optional[datetime]] = mapped_column(
DateTime(timezone=True), nullable=True, comment="付款时间"
)
payment_status: Mapped[str] = mapped_column(
String(20),
nullable=False,
comment="付款状态pending-待付款processing-处理中paid-已付款failed-付款失败",
)
settlement_status: Mapped[str] = mapped_column(
String(20),
nullable=False,
comment="结算状态pending-待结算settled-已结算partial-部分结算",
)
remark: Mapped[Optional[str]] = mapped_column(
Text, nullable=True, comment="备注"
)