218 lines
6.8 KiB
Plaintext
218 lines
6.8 KiB
Plaintext
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "mysql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
model User {
|
|
id Int @id @default(autoincrement())
|
|
mobile String @unique
|
|
nickname String?
|
|
avatarUrl String?
|
|
points Int @default(0)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
carts CartItem[]
|
|
orders Order[]
|
|
}
|
|
|
|
model SupplierProduct {
|
|
id Int @id @default(autoincrement())
|
|
sku String @unique
|
|
number Int @default(0)
|
|
price Decimal @db.Decimal(10, 2)
|
|
name String
|
|
taxRate Decimal @default(0.13) @db.Decimal(5, 4)
|
|
picInfo Json?
|
|
description String?
|
|
detail String?
|
|
originPrice Decimal? @db.Decimal(10, 2)
|
|
imageUrl String?
|
|
categoryId String?
|
|
category String?
|
|
tag String?
|
|
sales String?
|
|
stock Int @default(0)
|
|
sortOrder Int @default(0)
|
|
enabled Boolean @default(true)
|
|
deleted Int @default(0)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
carts CartItem[]
|
|
orderItems OrderItem[]
|
|
|
|
@@map("supplier_product")
|
|
}
|
|
|
|
model SupplierInfo {
|
|
id Int @id @default(autoincrement())
|
|
supplierIdentification String @unique
|
|
supplierId String @unique
|
|
supplierName String
|
|
clientId String
|
|
clientSecret String
|
|
createTime DateTime @default(now())
|
|
updateTime DateTime @updatedAt
|
|
creator String?
|
|
updator String?
|
|
version Int @default(0)
|
|
deleted Int @default(0)
|
|
|
|
@@map("supplier_info")
|
|
}
|
|
|
|
model CartItem {
|
|
id Int @id @default(autoincrement())
|
|
userId Int
|
|
productId Int
|
|
skuText String?
|
|
quantity Int @default(1)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
product SupplierProduct @relation(fields: [productId], references: [id], onDelete: Cascade)
|
|
|
|
@@unique([userId, productId, skuText])
|
|
}
|
|
|
|
model Order {
|
|
id Int @id @default(autoincrement())
|
|
orderNo String @unique
|
|
userId Int
|
|
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 Int @id @default(autoincrement())
|
|
orderId Int
|
|
productId Int
|
|
name String
|
|
imageUrl String?
|
|
skuText String?
|
|
price Decimal @db.Decimal(10, 2)
|
|
quantity Int
|
|
|
|
order Order @relation(fields: [orderId], references: [id], onDelete: Cascade)
|
|
product SupplierProduct @relation(fields: [productId], references: [id])
|
|
}
|
|
|
|
model SupplierOrderMain {
|
|
id Int @id @default(autoincrement())
|
|
orderId String @unique
|
|
orderNumberId String?
|
|
supplierId String
|
|
userId String?
|
|
aplName String?
|
|
createTime DateTime?
|
|
updateTime DateTime?
|
|
deliveryTime DateTime?
|
|
orderFinishTime DateTime?
|
|
completeTime DateTime?
|
|
deliveryStatus String?
|
|
freightCost Decimal @default(0) @db.Decimal(10, 2)
|
|
wPayOrAPayFreightCost Decimal @default(0) @db.Decimal(10, 2)
|
|
refund Decimal @default(0) @db.Decimal(10, 2)
|
|
wPayOrAPayRefund Decimal @default(0) @db.Decimal(10, 2)
|
|
logisticsOrderId String?
|
|
crrgBsnNm String?
|
|
orderState Int @default(0)
|
|
totalPrice Decimal @default(0) @db.Decimal(10, 2)
|
|
wPayOrAPay Decimal @default(0) @db.Decimal(10, 2)
|
|
pointsPrice Decimal @default(0) @db.Decimal(10, 2)
|
|
invoiceCode String?
|
|
createAt DateTime @default(now())
|
|
updateAt DateTime @updatedAt
|
|
deleted Int @default(0)
|
|
|
|
subOrders SupplierOrderSub[]
|
|
|
|
@@map("supplier_order_main")
|
|
}
|
|
|
|
model SupplierOrderSub {
|
|
id Int @id @default(autoincrement())
|
|
orderId String @unique
|
|
orderNumberId String?
|
|
mainOrderId String
|
|
supplierId String
|
|
token String?
|
|
userId String?
|
|
aplName String?
|
|
createTime DateTime?
|
|
updateTime DateTime?
|
|
deliveryTime DateTime?
|
|
orderFinishTime DateTime?
|
|
completeTime DateTime?
|
|
deliveryStatus String?
|
|
freightCost Decimal @default(0) @db.Decimal(10, 2)
|
|
wPayOrAPayFreightCost Decimal @default(0) @db.Decimal(10, 2)
|
|
refund Decimal @default(0) @db.Decimal(10, 2)
|
|
wPayOrAPayRefund Decimal @default(0) @db.Decimal(10, 2)
|
|
logisticsOrderId String?
|
|
crrgBsnNm String?
|
|
orderState Int @default(0)
|
|
totalPrice Decimal @default(0) @db.Decimal(10, 2)
|
|
wPayOrAPay Decimal @default(0) @db.Decimal(10, 2)
|
|
pointsPrice Decimal @default(0) @db.Decimal(10, 2)
|
|
invoiceCode String?
|
|
createAt DateTime @default(now())
|
|
updateAt DateTime @updatedAt
|
|
deleted Int @default(0)
|
|
|
|
mainOrder SupplierOrderMain @relation(fields: [mainOrderId], references: [orderId], onDelete: Cascade)
|
|
products SupplierOrderProduct[]
|
|
|
|
@@index([mainOrderId])
|
|
@@map("supplier_order_sub")
|
|
}
|
|
|
|
model SupplierOrderProduct {
|
|
id Int @id @default(autoincrement())
|
|
subOrderId String
|
|
sku String
|
|
number Int
|
|
price Decimal @db.Decimal(10, 2)
|
|
name String
|
|
taxRate Decimal @default(0.13) @db.Decimal(5, 4)
|
|
productImgUrl String?
|
|
fileId String?
|
|
filePath String?
|
|
picInfo Json?
|
|
createAt DateTime @default(now())
|
|
updateAt DateTime @updatedAt
|
|
deleted Int @default(0)
|
|
|
|
subOrder SupplierOrderSub @relation(fields: [subOrderId], references: [orderId], onDelete: Cascade)
|
|
|
|
@@index([subOrderId])
|
|
@@map("supplier_order_product")
|
|
}
|
|
|
|
enum OrderStatus {
|
|
PENDING_PAYMENT
|
|
PAID
|
|
SHIPPED
|
|
COMPLETED
|
|
CANCELLED
|
|
}
|
|
|
|
enum PayType {
|
|
POINTS
|
|
WECHAT
|
|
ALIPAY
|
|
}
|