Files
sub2apipay/prisma/schema.prisma
erio 5be0616e78 feat: 支付手续费功能
- 支持提供商级别和渠道级别手续费率配置(FEE_RATE_PROVIDER_* / FEE_RATE_*)
- 用户多付手续费,到账金额不变(充值 ¥100 + 1.6% = 实付 ¥101.60)
- 前端显示手续费明细和实付金额
- 退款时按实付金额退款,余额扣减到账金额
2026-03-03 22:00:44 +08:00

78 lines
2.2 KiB
Plaintext

generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
}
model Order {
id String @id @default(cuid())
userId Int @map("user_id")
userEmail String? @map("user_email")
userName String? @map("user_name")
userNotes String? @map("user_notes")
amount Decimal @db.Decimal(10, 2)
payAmount Decimal? @db.Decimal(10, 2) @map("pay_amount")
feeRate Decimal? @db.Decimal(5, 2) @map("fee_rate")
rechargeCode String @unique @map("recharge_code")
status OrderStatus @default(PENDING)
paymentType String @map("payment_type")
paymentTradeNo String? @map("payment_trade_no")
payUrl String? @map("pay_url")
qrCode String? @map("qr_code")
qrCodeImg String? @map("qr_code_img")
refundAmount Decimal? @db.Decimal(10, 2) @map("refund_amount")
refundReason String? @map("refund_reason")
refundAt DateTime? @map("refund_at")
forceRefund Boolean @default(false) @map("force_refund")
expiresAt DateTime @map("expires_at")
paidAt DateTime? @map("paid_at")
completedAt DateTime? @map("completed_at")
failedAt DateTime? @map("failed_at")
failedReason String? @map("failed_reason")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
clientIp String? @map("client_ip")
srcHost String? @map("src_host")
srcUrl String? @map("src_url")
auditLogs AuditLog[]
@@index([userId])
@@index([status])
@@index([expiresAt])
@@index([createdAt])
@@map("orders")
}
enum OrderStatus {
PENDING
PAID
RECHARGING
COMPLETED
EXPIRED
CANCELLED
FAILED
REFUNDING
REFUNDED
REFUND_FAILED
}
model AuditLog {
id String @id @default(cuid())
orderId String @map("order_id")
order Order @relation(fields: [orderId], references: [id])
action String
detail String? @db.Text
operator String?
createdAt DateTime @default(now()) @map("created_at")
@@index([orderId])
@@index([createdAt])
@@map("audit_logs")
}