feat(finance): manage token plans and simplify recharge checkout
This commit is contained in:
@@ -29,6 +29,30 @@ def summary():
|
||||
db.close()
|
||||
|
||||
|
||||
@router.get("/plans")
|
||||
def token_plans():
|
||||
db = _session()
|
||||
try:
|
||||
return ApiResponse(data=finance_service.list_token_plans(db))
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
|
||||
@router.patch("/plans/{plan_id}")
|
||||
def update_token_plan(plan_id: str, body: dict = Body(...)):
|
||||
db = _session()
|
||||
try:
|
||||
finance_service.update_token_plan(
|
||||
db, plan_id, amount=int(body.get("amount") or 0), price=float(body.get("price") or 0),
|
||||
name=str(body.get("name") or ""), badge=str(body.get("badge") or ""), desc=str(body.get("desc") or ""),
|
||||
)
|
||||
return ApiResponse(message="充值套餐已更新")
|
||||
except (ValueError, FinanceServiceError) as exc:
|
||||
_raise(exc if isinstance(exc, FinanceServiceError) else FinanceServiceError("积分和价格格式不正确"))
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
|
||||
@router.get("/orders")
|
||||
def orders(
|
||||
page: int = Query(1, ge=1),
|
||||
|
||||
Reference in New Issue
Block a user