75 lines
2.1 KiB
Python
75 lines
2.1 KiB
Python
from __future__ import annotations
|
|
|
|
from datetime import datetime
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
from app.schemas.credit_subscription import CreditSubscriptionOut
|
|
|
|
|
|
class TeamSeatCreateRequest(BaseModel):
|
|
user_id: str = Field(..., min_length=1, max_length=32)
|
|
monthly_allocated_credits: float = Field(..., gt=0, le=999999999.99, multiple_of=0.01)
|
|
|
|
|
|
class TeamSeatUpdateRequest(BaseModel):
|
|
monthly_allocated_credits: float = Field(..., gt=0, le=999999999.99, multiple_of=0.01)
|
|
|
|
|
|
class TeamSeatOut(BaseModel):
|
|
id: str
|
|
team_id: str
|
|
subscription_id: str
|
|
user_id: str
|
|
username: str | None = None
|
|
monthly_allocated_credits: float
|
|
current_period_id: str | None = None
|
|
current_period_used_credits: float = 0
|
|
current_period_remaining_credits: float = 0
|
|
status: str
|
|
status_label: str
|
|
created_at: datetime
|
|
cancelled_at: datetime | None = None
|
|
|
|
|
|
class TeamSubscriptionManageOut(BaseModel):
|
|
subscription: CreditSubscriptionOut
|
|
current_period_id: str | None = None
|
|
current_period_start_at: datetime | None = None
|
|
current_period_expires_at: datetime | None = None
|
|
period_total_credits: float = 0
|
|
period_unspent_credits: float = 0
|
|
period_unallocated_credits: float = 0
|
|
seat_limit: int
|
|
active_seat_count: int
|
|
seats: list[TeamSeatOut] = Field(default_factory=list)
|
|
|
|
|
|
class TeamMemberUsageOut(BaseModel):
|
|
user_id: str
|
|
username: str | None = None
|
|
# 以下两个 ID 保留给内部关联/筛选,前端业务表格不直接展示。
|
|
subscription_id: str
|
|
subscription_no: str
|
|
subscription_period_id: str
|
|
subscription_name: str
|
|
tier_code: str
|
|
tier_label: str
|
|
tier_rank: int
|
|
billing_cycle: str
|
|
billing_cycle_label: str
|
|
period_sequence: int
|
|
period_label: str
|
|
period_start_at: datetime | None = None
|
|
period_expires_at: datetime | None = None
|
|
consumed_credits: float
|
|
|
|
|
|
class TeamManagerHistoryOut(BaseModel):
|
|
id: str
|
|
team_id: str
|
|
manager_user_id: str
|
|
manager_name: str | None = None
|
|
started_at: datetime
|
|
ended_at: datetime | None = None
|