99 lines
3.1 KiB
Python
99 lines
3.1 KiB
Python
"""
|
||
佣金结算单模型
|
||
"""
|
||
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="备注"
|
||
)
|