7b62c2f8b4
## H5 底部导航修复 (Bug #10) - 精简 App.vue,移除重复 tabbar,仅保留全局样式 - uni-page 设置 height: calc(100% - 50px) + overflow-y: auto - 内容区域精确停在底部导航上方,独立滚动不再叠加 - 恢复 custom-tab-bar 组件 ## 项目进度文档 - PROGRESS.md 更新至 10 个 Bug 修复 - 新增 H5 底部导航修复记录 - 新增历史变更条目
58 lines
1.5 KiB
Python
58 lines
1.5 KiB
Python
from fastapi import APIRouter, Depends, HTTPException
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
from typing import Annotated
|
|
from pydantic import BaseModel
|
|
from app.database import get_db
|
|
from app.services.payment import PaymentService
|
|
from app.api.v1.deps import get_current_user_id
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
class CreateOrderRequest(BaseModel):
|
|
plan: str
|
|
|
|
|
|
class PaymentCallbackRequest(BaseModel):
|
|
payment_id: str
|
|
success: bool
|
|
|
|
|
|
@router.get("/plans")
|
|
async def get_plans():
|
|
svc = PaymentService(None)
|
|
return await svc.get_plans()
|
|
|
|
|
|
@router.get("/subscription")
|
|
async def get_subscription(
|
|
user_id: str = Depends(get_current_user_id),
|
|
db: Annotated[AsyncSession, Depends(get_db)] = None,
|
|
):
|
|
svc = PaymentService(db)
|
|
return await svc.get_current_subscription(user_id)
|
|
|
|
|
|
@router.post("/create-order")
|
|
async def create_order(
|
|
data: CreateOrderRequest,
|
|
user_id: str = Depends(get_current_user_id),
|
|
db: Annotated[AsyncSession, Depends(get_db)] = None,
|
|
):
|
|
svc = PaymentService(db)
|
|
try:
|
|
return await svc.create_order(user_id, data.plan)
|
|
except ValueError as e:
|
|
raise HTTPException(status_code=400, detail=str(e))
|
|
|
|
|
|
@router.post("/callback")
|
|
async def payment_callback(
|
|
data: PaymentCallbackRequest,
|
|
db: Annotated[AsyncSession, Depends(get_db)] = None,
|
|
):
|
|
svc = PaymentService(db)
|
|
success = await svc.handle_payment_callback(data.payment_id, data.success)
|
|
if not success:
|
|
raise HTTPException(status_code=404, detail="Order not found")
|
|
return {"status": "ok"} |