feat(api): GET /v1/user/balance 查询用户余额

users 表新增 credits_used(累计消耗积分):扣费累加、失败退款回减(refundIfNeeded / 维护清扫改走 RefundCredits),充值/CDK/签到发放不计入。接口返回 {object,balance,used,total},Bearer API Key 鉴权,与其他 v1 接口同一 CORS 与错误格式。站内接口文档与 README 补充端点说明。
This commit is contained in:
GlossSeaDress
2026-08-10 14:59:48 +08:00
parent 2c47344ed9
commit f94a7ace5f
9 changed files with 79 additions and 6 deletions
+1
View File
@@ -15,6 +15,7 @@ type User struct {
Role string `gorm:"size:32;index;not null"`
Status string `gorm:"size:32;index;not null"`
Credits float64 `gorm:"not null;default:0"`
CreditsUsed float64 `gorm:"not null;default:0"` // 累计已消耗额度:扣费时加、退款时减,充值/发放不计入
Notes string `gorm:"type:text"`
ConcurrencyGroupID string `gorm:"size:32;index"`
AnnouncementSeen string `gorm:"size:32"` // version hash of the last announcement this user dismissed