67a1ed6430
CI/CD Pipeline / Check if frontend-only change (push) Has been skipped
CI/CD Pipeline / Check push changed paths (push) Successful in 2s
CI/CD Pipeline / PR Build API Image (push) Has been skipped
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (push) Successful in 2s
CI/CD Pipeline / PR Build Web Image (push) Has been skipped
CI/CD Pipeline / PR Build Worker Image (push) Has been skipped
CI/CD Pipeline / Frontend Lint (push) Has been skipped
CI/CD Pipeline / Build Staging Web Image (push) Has been skipped
CI/CD Pipeline / Build Staging API Image (push) Successful in 37s
CI/CD Pipeline / Build Staging Worker Image (push) Successful in 38s
CI/CD Pipeline / Retag skipped Staging API Image (push) Has been skipped
CI/CD Pipeline / Retag skipped Staging Worker Image (push) Has been skipped
CI/CD Pipeline / Retag skipped Staging Web Image (push) Successful in 20s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Successful in 43s
CI/CD Pipeline / Validate - Python (mypy + alembic) (push) Successful in 3m3s
CI/CD Pipeline / Integration Tests (push) Successful in 3m7s
CI/CD Pipeline / Staging E2E Tests (push) Successful in 1m40s
CI/CD Pipeline / Validate - Style (push) Successful in 3m52s
CI/CD Pipeline / Frontend Unit Tests (push) Successful in 4m17s
CI/CD Pipeline / ACR Image Cleanup (push) Successful in 3m6s
CI/CD Pipeline / Validate - Security (push) Successful in 7m14s
CI/CD Pipeline / Unit Tests (push) Successful in 9m33s
CI/CD Pipeline / Build Production API Image (push) Has been skipped
CI/CD Pipeline / Build Production Web Image (push) Has been skipped
CI/CD Pipeline / Build Production Worker Image (push) Has been skipped
CI/CD Pipeline / CI Gate (push) Has been skipped
CI/CD Pipeline / Deploy Production (push) Has been skipped
CI/CD Pipeline / Production Browser E2E (push) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (push) Successful in 35m54s
CI/CD Pipeline / Canary Release to Production (push) Has been skipped
Co-authored-by: xiaoxia <dev@xiaoxiajianji.com> Co-committed-by: xiaoxia <dev@xiaoxiajianji.com>
113 lines
2.3 KiB
Python
113 lines
2.3 KiB
Python
"""Subscription schemas for API request/response models."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Optional
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
# ============ Enums / Types ============
|
|
# 会员体系(#1951/#1955 实装):
|
|
# free — 免费用户
|
|
# monthly — 月卡
|
|
# quarterly — 季卡
|
|
# yearly — 年卡
|
|
# 已废弃档位:standard / pro / enterprise(保留常量名便于识别旧字段,但不在 API 中暴露)
|
|
|
|
|
|
class MembershipType(str):
|
|
"""会员类型(与 packages.domain.points_rules.MEMBERSHIP_PRICES 一致)"""
|
|
|
|
FREE = "free"
|
|
MONTHLY = "monthly"
|
|
QUARTERLY = "quarterly"
|
|
YEARLY = "yearly"
|
|
|
|
|
|
class SubscriptionStatus(str):
|
|
"""订阅状态"""
|
|
|
|
ACTIVE = "active"
|
|
EXPIRED = "expired"
|
|
CANCELLED = "cancelled"
|
|
TRIAL = "trial"
|
|
|
|
|
|
class BillingStatus(str):
|
|
"""账单状态"""
|
|
|
|
PAID = "paid"
|
|
PENDING = "pending"
|
|
FAILED = "failed"
|
|
REFUNDED = "refunded"
|
|
|
|
|
|
class BillingCycle(str):
|
|
"""计费周期"""
|
|
|
|
MONTHLY = "monthly"
|
|
QUARTERLY = "quarterly"
|
|
YEARLY = "yearly"
|
|
|
|
|
|
# ============ Response Schemas ============
|
|
|
|
|
|
class SubscriptionInfo(BaseModel):
|
|
"""当前订阅信息"""
|
|
|
|
id: str
|
|
plan_id: str
|
|
plan_name: str
|
|
status: str
|
|
billing_cycle: str
|
|
current_period_start: str
|
|
current_period_end: str
|
|
amount: float
|
|
auto_renew: bool
|
|
created_at: str
|
|
|
|
|
|
class BillingRecord(BaseModel):
|
|
"""账单记录"""
|
|
|
|
id: str
|
|
plan_name: str
|
|
amount: float
|
|
billing_cycle: str
|
|
status: str
|
|
payment_method: str
|
|
created_at: str
|
|
invoice_url: Optional[str] = None
|
|
|
|
|
|
class ChangePlanResponse(BaseModel):
|
|
"""升级/降级响应"""
|
|
|
|
success: bool
|
|
message: str
|
|
new_subscription: Optional[SubscriptionInfo] = None
|
|
|
|
|
|
class SimpleResponse(BaseModel):
|
|
"""简单响应(用于取消订阅、切换自动续费等)"""
|
|
|
|
success: bool
|
|
message: str
|
|
|
|
|
|
# ============ Request Schemas ============
|
|
|
|
|
|
class ChangePlanRequest(BaseModel):
|
|
"""升级/降级请求"""
|
|
|
|
target_plan_id: str = Field(..., description="目标会员类型: monthly/quarterly/yearly")
|
|
billing_cycle: str = Field(..., description="计费周期: monthly/quarterly/yearly")
|
|
|
|
|
|
class ToggleAutoRenewRequest(BaseModel):
|
|
"""切换自动续费请求"""
|
|
|
|
enabled: bool = Field(..., description="是否开启自动续费")
|