feat: 渠道展示、订阅套餐、系统配置全功能
- 新增 Channel / SubscriptionPlan / SystemConfig 三个数据模型 - Order 模型扩展支持订阅订单(order_type, plan_id, subscription_group_id) - Sub2API client 新增分组查询、订阅分配/续期、用户订阅查询 - 订单服务支持订阅履约流程(CAS 锁 + 分组消失安全处理) - 管理后台:渠道管理、订阅套餐管理、系统配置、Sub2API 分组同步 - 用户页面:双 Tab UI(按量付费/包月订阅)、渠道卡片、充值弹窗、订阅确认 - PaymentForm 支持 fixedAmount 固定金额模式 - 订单状态 API 返回 failedReason 用于订阅异常展示 - 数据库迁移脚本
This commit is contained in:
@@ -40,6 +40,13 @@ model Order {
|
||||
srcHost String? @map("src_host")
|
||||
srcUrl String? @map("src_url")
|
||||
|
||||
// ── 订单类型 & 订阅相关 ──
|
||||
orderType String @default("balance") @map("order_type")
|
||||
planId String? @map("plan_id")
|
||||
plan SubscriptionPlan? @relation(fields: [planId], references: [id])
|
||||
subscriptionGroupId Int? @map("subscription_group_id")
|
||||
subscriptionDays Int? @map("subscription_days")
|
||||
|
||||
auditLogs AuditLog[]
|
||||
|
||||
@@index([userId])
|
||||
@@ -48,6 +55,7 @@ model Order {
|
||||
@@index([createdAt])
|
||||
@@index([paidAt])
|
||||
@@index([paymentType, paidAt])
|
||||
@@index([orderType])
|
||||
@@map("orders")
|
||||
}
|
||||
|
||||
@@ -77,3 +85,55 @@ model AuditLog {
|
||||
@@index([createdAt])
|
||||
@@map("audit_logs")
|
||||
}
|
||||
|
||||
// ── 渠道展示配置 ──
|
||||
model Channel {
|
||||
id String @id @default(cuid())
|
||||
groupId Int @unique @map("group_id")
|
||||
name String
|
||||
platform String @default("claude")
|
||||
rateMultiplier Decimal @db.Decimal(10, 4) @map("rate_multiplier")
|
||||
description String? @db.Text
|
||||
models String? @db.Text
|
||||
features String? @db.Text
|
||||
sortOrder Int @default(0) @map("sort_order")
|
||||
enabled Boolean @default(true)
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
@@index([sortOrder])
|
||||
@@map("channels")
|
||||
}
|
||||
|
||||
// ── 订阅套餐配置 ──
|
||||
model SubscriptionPlan {
|
||||
id String @id @default(cuid())
|
||||
groupId Int @unique @map("group_id")
|
||||
name String
|
||||
description String? @db.Text
|
||||
price Decimal @db.Decimal(10, 2)
|
||||
originalPrice Decimal? @db.Decimal(10, 2) @map("original_price")
|
||||
validityDays Int @default(30) @map("validity_days")
|
||||
features String? @db.Text
|
||||
forSale Boolean @default(false) @map("for_sale")
|
||||
sortOrder Int @default(0) @map("sort_order")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
orders Order[]
|
||||
|
||||
@@index([forSale, sortOrder])
|
||||
@@map("subscription_plans")
|
||||
}
|
||||
|
||||
// ── 系统配置 ──
|
||||
model SystemConfig {
|
||||
key String @id
|
||||
value String @db.Text
|
||||
group String @default("general")
|
||||
label String?
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
@@index([group])
|
||||
@@map("system_configs")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user