v3.5.4版本提交
CI / verify (pull_request) Waiting to run

This commit is contained in:
2026-08-21 15:48:15 +08:00
parent 26334ed072
commit a01217539c
32 changed files with 2278 additions and 147 deletions
+101 -2
View File
@@ -164,6 +164,12 @@ enum ProductStatus {
OFF_SALE
}
/// SKU 销售单位:瓶 / 箱(起购与物流按瓶当量)
enum ProductSaleUnit {
BOTTLE
BOX
}
enum DetailTemplateStatus {
ACTIVE
DISABLED
@@ -791,10 +797,13 @@ model DevPlanTaskDispatch {
@@map("dev_plan_task_dispatch")
}
/// 商品 SPU(详情页实体);价格/码/履约等列为默认 SKU 冗余,供旧客户端拍平读取
model CommonProductItem {
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
skuCode String @unique @map("sku_code") @db.VarChar(32)
barcode69 String @unique @map("barcode_69") @db.VarChar(32)
/// 默认 SKU 冗余;唯一约束已下放到 common_product_sku
skuCode String @map("sku_code") @db.VarChar(32)
/// 默认 SKU 冗余;唯一约束已下放到 common_product_sku
barcode69 String @map("barcode_69") @db.VarChar(32)
name String @db.VarChar(128)
subtitle String? @db.VarChar(256)
aromaType AromaType @map("aroma_type")
@@ -818,11 +827,94 @@ model CommonProductItem {
coverResource CommonResource? @relation("ProductCover", fields: [coverResourceId], references: [id], onDelete: SetNull)
orders Order[]
visibilityPhones CommonProductVisibilityPhone[]
specAttrs CommonProductSpecAttr[]
skus CommonProductSku[]
@@index([skuCode])
@@index([barcode69])
@@index([status, aromaType])
@@map("common_product_item")
}
/// 销售规格轴(如「包装」)
model CommonProductSpecAttr {
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
productId BigInt @map("product_id") @db.UnsignedBigInt
name String @db.VarChar(32)
sortOrder Int @default(0) @map("sort_order")
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
updatedAt DateTime @updatedAt @map("updated_at") @db.DateTime(3)
product CommonProductItem @relation(fields: [productId], references: [id], onDelete: Cascade)
values CommonProductSpecValue[]
@@index([productId, sortOrder])
@@map("common_product_spec_attr")
}
/// 规格值(如「单瓶」「整箱6瓶」)
model CommonProductSpecValue {
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
attrId BigInt @map("attr_id") @db.UnsignedBigInt
name String @db.VarChar(64)
sortOrder Int @default(0) @map("sort_order")
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
updatedAt DateTime @updatedAt @map("updated_at") @db.DateTime(3)
attr CommonProductSpecAttr @relation(fields: [attrId], references: [id], onDelete: Cascade)
skuSpecs CommonProductSkuSpec[]
@@index([attrId, sortOrder])
@@map("common_product_spec_value")
}
/// 可售 SKU(规格组合)
model CommonProductSku {
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
productId BigInt @map("product_id") @db.UnsignedBigInt
skuCode String @unique @map("sku_code") @db.VarChar(32)
barcode69 String @unique @map("barcode_69") @db.VarChar(32)
/// 规格值 id 按 attr.sortOrder 拼接,无规格为 ""
specKey String @default("") @map("spec_key") @db.VarChar(128)
specText String @default("") @map("spec_text") @db.VarChar(128)
price Decimal @db.Decimal(10, 2)
benefitAmount Decimal? @map("benefit_amount") @db.Decimal(10, 2)
status ProductStatus @default(DRAFT)
allowOnSitePickup Boolean @default(false) @map("allow_on_site_pickup")
allowOnlinePurchase Boolean @default(true) @map("allow_online_purchase")
allowCrossCityDelivery Boolean @default(true) @map("allow_cross_city_delivery")
saleUnit ProductSaleUnit @default(BOTTLE) @map("sale_unit")
/// 每销售单位对应瓶数(瓶=1,箱默认=6)
bottlesPerUnit Int @default(1) @map("bottles_per_unit")
isDefault Boolean @default(false) @map("is_default")
sortOrder Int @default(0) @map("sort_order")
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
updatedAt DateTime @updatedAt @map("updated_at") @db.DateTime(3)
product CommonProductItem @relation(fields: [productId], references: [id], onDelete: Cascade)
skuSpecs CommonProductSkuSpec[]
orders Order[]
@@unique([productId, specKey])
@@index([productId, status])
@@index([productId, isDefault])
@@map("common_product_sku")
}
/// SKU ↔ 规格值
model CommonProductSkuSpec {
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
skuId BigInt @map("sku_id") @db.UnsignedBigInt
valueId BigInt @map("value_id") @db.UnsignedBigInt
sku CommonProductSku @relation(fields: [skuId], references: [id], onDelete: Cascade)
value CommonProductSpecValue @relation(fields: [valueId], references: [id], onDelete: Restrict)
@@unique([skuId, valueId])
@@index([valueId])
@@map("common_product_sku_spec")
}
/// Product visibility whitelist phones (match by bound phone)
model CommonProductVisibilityPhone {
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
@@ -1495,11 +1587,16 @@ model Order {
promoCodeId BigInt? @map("promo_code_id") @db.UnsignedBigInt
channelSource String? @map("channel_source") @db.VarChar(128)
productId BigInt @map("product_id") @db.UnsignedBigInt
/// v3.5.4 起可空;历史单无 sku 快照时仍用 product 冗余字段展示
skuId BigInt? @map("sku_id") @db.UnsignedBigInt
barcode69 String @map("barcode_69") @db.VarChar(32)
productName String @map("product_name") @db.VarChar(128)
productSpec String @map("product_spec") @db.VarChar(128)
imageResourceId BigInt? @map("image_resource_id") @db.UnsignedBigInt
/// 下单数量(销售单位:瓶或箱)
quantity Int
saleUnit ProductSaleUnit @default(BOTTLE) @map("sale_unit")
bottlesPerUnit Int @default(1) @map("bottles_per_unit")
listUnitPrice Decimal @map("list_unit_price") @db.Decimal(10, 2)
listAmount Decimal @map("list_amount") @db.Decimal(10, 2)
discountAmount Decimal @default(0) @map("discount_amount") @db.Decimal(10, 2)
@@ -1553,6 +1650,7 @@ model Order {
reshipments Order[] @relation("OrderReshipment")
promoCode CommonPromoCode? @relation(fields: [promoCodeId], references: [id], onDelete: SetNull)
product CommonProductItem @relation(fields: [productId], references: [id], onDelete: Restrict)
sku CommonProductSku? @relation(fields: [skuId], references: [id], onDelete: Restrict)
imageResource CommonResource? @relation("OrderProductImage", fields: [imageResourceId], references: [id], onDelete: SetNull)
delivery OrderDelivery?
benefitCoupon BenefitCoupon?
@@ -1561,6 +1659,7 @@ model Order {
@@index([userId, status])
@@index([cityId, createdAt])
@@index([productId])
@@index([skuId])
@@index([barcode69])
@@index([payExternalNo])
@@index([ipCity])