97 lines
2.1 KiB
Plaintext
97 lines
2.1 KiB
Plaintext
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
}
|
|
|
|
model User {
|
|
id String @id @default(cuid())
|
|
mobile String @unique
|
|
nickname String?
|
|
avatarUrl String?
|
|
points Int @default(0)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
carts CartItem[]
|
|
orders Order[]
|
|
}
|
|
|
|
model Product {
|
|
id String @id @default(cuid())
|
|
name String
|
|
description String?
|
|
detail String?
|
|
price Decimal @db.Decimal(10, 2)
|
|
imageUrl String?
|
|
category String?
|
|
tag String?
|
|
stock Int @default(0)
|
|
enabled Boolean @default(true)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
carts CartItem[]
|
|
orderItems OrderItem[]
|
|
}
|
|
|
|
model CartItem {
|
|
id String @id @default(cuid())
|
|
userId String
|
|
productId String
|
|
skuText String?
|
|
quantity Int @default(1)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
product Product @relation(fields: [productId], references: [id], onDelete: Cascade)
|
|
|
|
@@unique([userId, productId, skuText])
|
|
}
|
|
|
|
model Order {
|
|
id String @id @default(cuid())
|
|
orderNo String @unique
|
|
userId String
|
|
status OrderStatus @default(PENDING_PAYMENT)
|
|
totalAmount Decimal @db.Decimal(10, 2)
|
|
payType PayType?
|
|
paidAt DateTime?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
items OrderItem[]
|
|
}
|
|
|
|
model OrderItem {
|
|
id String @id @default(cuid())
|
|
orderId String
|
|
productId String
|
|
name String
|
|
imageUrl String?
|
|
skuText String?
|
|
price Decimal @db.Decimal(10, 2)
|
|
quantity Int
|
|
|
|
order Order @relation(fields: [orderId], references: [id], onDelete: Cascade)
|
|
product Product @relation(fields: [productId], references: [id])
|
|
}
|
|
|
|
enum OrderStatus {
|
|
PENDING_PAYMENT
|
|
PAID
|
|
SHIPPED
|
|
COMPLETED
|
|
CANCELLED
|
|
}
|
|
|
|
enum PayType {
|
|
POINTS
|
|
WECHAT
|
|
ALIPAY
|
|
}
|