新增订单推荐人和邀请码功能,优化支付流程中的订单插入逻辑,确保订单记录准确。更新小程序支付请求,支持传递邀请码以便于分销归属和对账。同时,调整数据库结构以支持新字段,提升系统的稳定性和用户体验。
This commit is contained in:
307
prisma/schema.prisma
Normal file
307
prisma/schema.prisma
Normal file
@@ -0,0 +1,307 @@
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
output = "../lib/generated/prisma"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "mysql"
|
||||
}
|
||||
|
||||
/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments
|
||||
model chapters {
|
||||
id String @id @db.VarChar(20)
|
||||
part_id String @db.VarChar(20)
|
||||
part_title String @db.VarChar(100)
|
||||
chapter_id String @db.VarChar(20)
|
||||
chapter_title String @db.VarChar(200)
|
||||
section_title String @db.VarChar(200)
|
||||
content String @db.LongText
|
||||
word_count Int? @default(0)
|
||||
is_free Boolean? @default(false)
|
||||
price Decimal? @default(1.00) @db.Decimal(10, 2)
|
||||
sort_order Int? @default(0)
|
||||
status chapters_status? @default(published)
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @default(now()) @db.Timestamp(0)
|
||||
|
||||
@@index([chapter_id], map: "idx_chapter_id")
|
||||
@@index([part_id], map: "idx_part_id")
|
||||
@@index([sort_order], map: "idx_sort_order")
|
||||
@@index([status], map: "idx_status")
|
||||
}
|
||||
|
||||
/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments
|
||||
model ckb_sync_logs {
|
||||
id String @id @db.VarChar(50)
|
||||
user_id String @db.VarChar(100)
|
||||
phone String @db.VarChar(20)
|
||||
action String @db.VarChar(50)
|
||||
status String @db.VarChar(20)
|
||||
request_data Json?
|
||||
response_data Json?
|
||||
error_msg String? @db.Text
|
||||
created_at DateTime? @default(now()) @db.DateTime(0)
|
||||
|
||||
@@index([created_at], map: "idx_created_at")
|
||||
@@index([phone], map: "idx_phone")
|
||||
@@index([user_id], map: "idx_user_id")
|
||||
}
|
||||
|
||||
model match_records {
|
||||
id String @id @db.VarChar(50)
|
||||
user_id String @db.VarChar(50)
|
||||
match_type match_records_match_type
|
||||
phone String? @db.VarChar(20)
|
||||
wechat_id String? @db.VarChar(100)
|
||||
matched_user_id String? @db.VarChar(50)
|
||||
match_score Int?
|
||||
status match_records_status? @default(pending)
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
users users @relation(fields: [user_id], references: [id], onUpdate: Restrict, map: "match_records_ibfk_1")
|
||||
|
||||
@@index([match_type], map: "idx_match_type")
|
||||
@@index([status], map: "idx_status")
|
||||
@@index([user_id], map: "idx_user_id")
|
||||
}
|
||||
|
||||
model orders {
|
||||
id String @id @db.VarChar(50)
|
||||
order_sn String @unique(map: "order_sn") @db.VarChar(50)
|
||||
user_id String @db.VarChar(50)
|
||||
open_id String @db.VarChar(100)
|
||||
product_type orders_product_type
|
||||
product_id String? @db.VarChar(50)
|
||||
amount Decimal @db.Decimal(10, 2)
|
||||
description String? @db.VarChar(200)
|
||||
status orders_status? @default(created)
|
||||
transaction_id String? @db.VarChar(100)
|
||||
pay_time DateTime? @db.Timestamp(0)
|
||||
referral_code String? @db.VarChar(255)
|
||||
referrer_id String? @db.VarChar(255)
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @default(now()) @db.Timestamp(0)
|
||||
users users @relation(fields: [user_id], references: [id], onUpdate: Restrict, map: "orders_ibfk_1")
|
||||
referral_bindings referral_bindings[]
|
||||
|
||||
@@index([order_sn], map: "idx_order_sn")
|
||||
@@index([status], map: "idx_status")
|
||||
@@index([user_id], map: "idx_user_id")
|
||||
}
|
||||
|
||||
/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments
|
||||
model reading_progress {
|
||||
id Int @id @default(autoincrement())
|
||||
user_id String @db.VarChar(50)
|
||||
section_id String @db.VarChar(20)
|
||||
progress Int? @default(0)
|
||||
duration Int? @default(0)
|
||||
status reading_progress_status? @default(reading)
|
||||
completed_at DateTime? @db.DateTime(0)
|
||||
first_open_at DateTime @db.DateTime(0)
|
||||
last_open_at DateTime @db.DateTime(0)
|
||||
created_at DateTime? @default(now()) @db.DateTime(0)
|
||||
updated_at DateTime? @default(now()) @db.DateTime(0)
|
||||
|
||||
@@unique([user_id, section_id], map: "idx_user_section")
|
||||
@@index([completed_at], map: "idx_completed")
|
||||
@@index([last_open_at], map: "idx_last_open")
|
||||
@@index([user_id, status], map: "idx_user_status")
|
||||
}
|
||||
|
||||
/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments
|
||||
model referral_bindings {
|
||||
id String @id @db.VarChar(50)
|
||||
referrer_id String @db.VarChar(50)
|
||||
referee_id String @db.VarChar(50)
|
||||
referral_code String @db.VarChar(20)
|
||||
status referral_bindings_status? @default(active)
|
||||
binding_date DateTime @default(now()) @db.Timestamp(0)
|
||||
expiry_date DateTime @default(dbgenerated("'0000-00-00 00:00:00'")) @db.Timestamp(0)
|
||||
conversion_date DateTime? @db.Timestamp(0)
|
||||
commission_amount Decimal? @default(0.00) @db.Decimal(10, 2)
|
||||
order_id String? @db.VarChar(50)
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @default(now()) @db.Timestamp(0)
|
||||
last_purchase_date DateTime? @db.DateTime(0)
|
||||
purchase_count Int? @default(0)
|
||||
total_commission Decimal? @default(0.00) @db.Decimal(10, 2)
|
||||
users_referral_bindings_referrer_idTousers users @relation("referral_bindings_referrer_idTousers", fields: [referrer_id], references: [id], onUpdate: Restrict, map: "referral_bindings_ibfk_1")
|
||||
users_referral_bindings_referee_idTousers users @relation("referral_bindings_referee_idTousers", fields: [referee_id], references: [id], onUpdate: Restrict, map: "referral_bindings_ibfk_2")
|
||||
orders orders? @relation(fields: [order_id], references: [id], onDelete: Restrict, onUpdate: Restrict, map: "referral_bindings_ibfk_3")
|
||||
|
||||
@@unique([referrer_id, referee_id], map: "unique_referrer_referee")
|
||||
@@index([expiry_date], map: "idx_expiry_date")
|
||||
@@index([expiry_date, purchase_count, status], map: "idx_expiry_purchase")
|
||||
@@index([referee_id], map: "idx_referee_id")
|
||||
@@index([referee_id, status], map: "idx_referee_status")
|
||||
@@index([referrer_id], map: "idx_referrer_id")
|
||||
@@index([status], map: "idx_status")
|
||||
@@index([order_id], map: "order_id")
|
||||
}
|
||||
|
||||
/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments
|
||||
model referral_visits {
|
||||
id Int @id @default(autoincrement())
|
||||
referrer_id String @db.VarChar(50)
|
||||
visitor_id String? @db.VarChar(50)
|
||||
visitor_openid String? @db.VarChar(100)
|
||||
source String? @default("miniprogram") @db.VarChar(50)
|
||||
page String? @db.VarChar(200)
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
|
||||
@@index([created_at], map: "idx_created_at")
|
||||
@@index([referrer_id], map: "idx_referrer_id")
|
||||
@@index([visitor_id], map: "idx_visitor_id")
|
||||
}
|
||||
|
||||
model system_config {
|
||||
id Int @id @default(autoincrement())
|
||||
config_key String @unique(map: "config_key") @db.VarChar(100)
|
||||
config_value Json
|
||||
description String? @db.VarChar(200)
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @default(now()) @db.Timestamp(0)
|
||||
|
||||
@@index([config_key], map: "idx_config_key")
|
||||
}
|
||||
|
||||
/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments
|
||||
model user_tag_definitions {
|
||||
id Int @id @default(autoincrement())
|
||||
name String @unique(map: "name") @db.VarChar(50)
|
||||
category String @db.VarChar(50)
|
||||
color String? @default("#38bdac") @db.VarChar(20)
|
||||
description String? @db.VarChar(200)
|
||||
is_active Boolean? @default(true)
|
||||
created_at DateTime? @default(now()) @db.DateTime(0)
|
||||
|
||||
@@index([category], map: "idx_category")
|
||||
}
|
||||
|
||||
/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments
|
||||
model user_tracks {
|
||||
id String @id @db.VarChar(50)
|
||||
user_id String @db.VarChar(100)
|
||||
action String @db.VarChar(50)
|
||||
chapter_id String? @db.VarChar(100)
|
||||
target String? @db.VarChar(200)
|
||||
extra_data Json?
|
||||
created_at DateTime? @default(now()) @db.DateTime(0)
|
||||
|
||||
@@index([action], map: "idx_action")
|
||||
@@index([created_at], map: "idx_created_at")
|
||||
@@index([user_id], map: "idx_user_id")
|
||||
}
|
||||
|
||||
/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments
|
||||
model users {
|
||||
id String @id @db.VarChar(50)
|
||||
open_id String? @unique(map: "open_id") @db.VarChar(100)
|
||||
nickname String? @db.VarChar(100)
|
||||
avatar String? @db.VarChar(500)
|
||||
phone String? @db.VarChar(20)
|
||||
wechat_id String? @db.VarChar(100)
|
||||
referral_code String? @unique(map: "referral_code") @db.VarChar(20)
|
||||
purchased_sections Json?
|
||||
has_full_book Boolean? @default(false)
|
||||
earnings Decimal? @default(0.00) @db.Decimal(10, 2)
|
||||
pending_earnings Decimal? @default(0.00) @db.Decimal(10, 2)
|
||||
referral_count Int? @default(0)
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @default(now()) @db.Timestamp(0)
|
||||
password String? @db.VarChar(100)
|
||||
session_key String? @db.VarChar(100)
|
||||
referred_by String? @db.VarChar(50)
|
||||
is_admin Boolean? @default(false)
|
||||
match_count_today Int? @default(0)
|
||||
last_match_date DateTime? @db.Date
|
||||
withdrawn_earnings Decimal? @default(0.00) @db.Decimal(10, 2)
|
||||
ckb_user_id String? @db.VarChar(100)
|
||||
ckb_synced_at DateTime? @db.DateTime(0)
|
||||
ckb_tags Json?
|
||||
tags Json?
|
||||
source_tags Json?
|
||||
merged_tags Json?
|
||||
source String? @db.VarChar(50)
|
||||
created_by String? @db.VarChar(100)
|
||||
matched_by String? @db.VarChar(100)
|
||||
match_records match_records[]
|
||||
orders orders[]
|
||||
referral_bindings_referral_bindings_referrer_idTousers referral_bindings[] @relation("referral_bindings_referrer_idTousers")
|
||||
referral_bindings_referral_bindings_referee_idTousers referral_bindings[] @relation("referral_bindings_referee_idTousers")
|
||||
|
||||
@@index([open_id], map: "idx_open_id")
|
||||
@@index([phone], map: "idx_phone")
|
||||
@@index([referral_code], map: "idx_referral_code")
|
||||
@@index([referred_by], map: "idx_referred_by")
|
||||
}
|
||||
|
||||
model withdrawals {
|
||||
id String @id @db.VarChar(50)
|
||||
user_id String @db.VarChar(50)
|
||||
amount Decimal @db.Decimal(10, 2)
|
||||
status withdrawals_status? @default(pending)
|
||||
wechat_openid String? @db.VarChar(100)
|
||||
wechat_id String? @db.VarChar(100) // 用户微信号,用于后台列表展示与核对
|
||||
transaction_id String? @db.VarChar(100)
|
||||
error_message String? @db.VarChar(500)
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
processed_at DateTime? @db.Timestamp(0)
|
||||
|
||||
@@index([status], map: "idx_status")
|
||||
@@index([user_id], map: "idx_user_id")
|
||||
}
|
||||
|
||||
enum match_records_match_type {
|
||||
partner
|
||||
investor
|
||||
mentor
|
||||
team
|
||||
}
|
||||
|
||||
enum withdrawals_status {
|
||||
pending
|
||||
processing
|
||||
success
|
||||
failed
|
||||
}
|
||||
|
||||
enum orders_product_type {
|
||||
section
|
||||
fullbook
|
||||
match
|
||||
}
|
||||
|
||||
enum referral_bindings_status {
|
||||
active
|
||||
converted
|
||||
expired
|
||||
cancelled
|
||||
}
|
||||
|
||||
enum reading_progress_status {
|
||||
reading
|
||||
completed
|
||||
abandoned
|
||||
}
|
||||
|
||||
enum match_records_status {
|
||||
pending
|
||||
matched
|
||||
contacted
|
||||
}
|
||||
|
||||
enum orders_status {
|
||||
created
|
||||
pending
|
||||
paid
|
||||
cancelled
|
||||
refunded
|
||||
expired
|
||||
}
|
||||
|
||||
enum chapters_status {
|
||||
draft
|
||||
published
|
||||
archived
|
||||
}
|
||||
Reference in New Issue
Block a user