feat(assoc): v4.0.1 合伙人关联码、分佣账单与 H5 用户管理
订单佣金只认关联用户;合伙人备注写入独立表;H5 增加用户管理与首页统计。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -339,9 +339,15 @@ enum UserSourceType {
|
||||
FRIEND_REFERRAL
|
||||
OFFLINE_EVENT
|
||||
PARTNER_PROXY
|
||||
PARTNER_ASSOC
|
||||
OTHER
|
||||
}
|
||||
|
||||
enum PartnerBillItemKind {
|
||||
ORDER
|
||||
REDEEM
|
||||
}
|
||||
|
||||
enum OrderType {
|
||||
NORMAL
|
||||
RESHIPMENT
|
||||
@@ -636,6 +642,7 @@ model CommonResource {
|
||||
|
||||
productCovers CommonProductItem[] @relation("ProductCover")
|
||||
promoQrcodes CommonPromoCode[] @relation("PromoQrcode")
|
||||
partnerAssocQrcodes PartnerAccount[] @relation("PartnerAssocQrcode")
|
||||
userAvatars User[] @relation("UserAvatar")
|
||||
storeCovers Store[] @relation("StoreCover")
|
||||
orderImages Order[] @relation("OrderProductImage")
|
||||
@@ -1195,6 +1202,8 @@ model PartnerAccount {
|
||||
bankBranch String? @map("bank_branch") @db.VarChar(128)
|
||||
weeklyStoreTarget Int? @default(20) @map("weekly_store_target")
|
||||
managedWarehouseId BigInt? @unique @map("managed_warehouse_id") @db.UnsignedBigInt
|
||||
assocQrcodeId String? @unique @map("assoc_qrcode_id") @db.VarChar(64)
|
||||
assocQrcodeResourceId BigInt? @map("assoc_qrcode_resource_id") @db.UnsignedBigInt
|
||||
/// 测试合伙人账号
|
||||
isTest Boolean @default(false) @map("is_test")
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
|
||||
@@ -1207,6 +1216,9 @@ model PartnerAccount {
|
||||
children PartnerAccount[] @relation("PartnerAccountHierarchy")
|
||||
stores Store[]
|
||||
bills PartnerBill[]
|
||||
assocUsers User[] @relation("UserPartnerAssoc")
|
||||
userNotes PartnerUserNote[]
|
||||
assocQrcodeResource CommonResource? @relation("PartnerAssocQrcode", fields: [assocQrcodeResourceId], references: [id], onDelete: SetNull)
|
||||
|
||||
@@index([cityId, scopeType])
|
||||
@@index([cityId, isPrimary])
|
||||
@@ -1217,6 +1229,23 @@ model PartnerAccount {
|
||||
@@map("partner_account")
|
||||
}
|
||||
|
||||
/// 主合伙人对关联用户的备注;与 HQ hqRemark 隔离,换绑不跟随
|
||||
model PartnerUserNote {
|
||||
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
||||
partnerAccountId BigInt @map("partner_account_id") @db.UnsignedBigInt
|
||||
userId BigInt @map("user_id") @db.UnsignedBigInt
|
||||
remark String @db.VarChar(128)
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
|
||||
updatedAt DateTime @updatedAt @map("updated_at") @db.DateTime(3)
|
||||
|
||||
partner PartnerAccount @relation(fields: [partnerAccountId], references: [id], onDelete: Cascade)
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([partnerAccountId, userId])
|
||||
@@index([userId])
|
||||
@@map("partner_user_note")
|
||||
}
|
||||
|
||||
model PartnerBill {
|
||||
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
||||
billNo String @unique @map("bill_no") @db.VarChar(32)
|
||||
@@ -1235,12 +1264,34 @@ model PartnerBill {
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
|
||||
|
||||
partnerAccount PartnerAccount @relation(fields: [partnerAccountId], references: [id], onDelete: Restrict)
|
||||
items PartnerBillItem[]
|
||||
|
||||
@@index([partnerAccountId, status])
|
||||
@@unique([partnerAccountId, periodStart])
|
||||
@@map("partner_bill")
|
||||
}
|
||||
|
||||
model PartnerBillItem {
|
||||
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
||||
partnerBillId BigInt @map("partner_bill_id") @db.UnsignedBigInt
|
||||
kind PartnerBillItemKind
|
||||
refId BigInt @map("ref_id") @db.UnsignedBigInt
|
||||
refNo String @map("ref_no") @db.VarChar(32)
|
||||
title String? @db.VarChar(128)
|
||||
extra String? @db.VarChar(128)
|
||||
baseAmount Decimal @map("base_amount") @db.Decimal(10, 2)
|
||||
rate Decimal @db.Decimal(5, 4)
|
||||
commission Decimal @db.Decimal(10, 2)
|
||||
occurredAt DateTime @map("occurred_at") @db.DateTime(3)
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
|
||||
|
||||
partnerBill PartnerBill @relation(fields: [partnerBillId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([kind, refId])
|
||||
@@index([partnerBillId])
|
||||
@@map("partner_bill_item")
|
||||
}
|
||||
|
||||
// ─── HQ ───────────────────────────────────────────────
|
||||
|
||||
model HqAccount {
|
||||
@@ -1322,6 +1373,8 @@ model User {
|
||||
sourceRefId BigInt? @map("source_ref_id") @db.UnsignedBigInt
|
||||
sourceLabel String? @map("source_label") @db.VarChar(128)
|
||||
referrerUserId BigInt? @map("referrer_user_id") @db.UnsignedBigInt
|
||||
assocPartnerAccountId BigInt? @map("assoc_partner_account_id") @db.UnsignedBigInt
|
||||
assocBoundAt DateTime? @map("assoc_bound_at") @db.DateTime(3)
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
|
||||
updatedAt DateTime @updatedAt @map("updated_at") @db.DateTime(3)
|
||||
|
||||
@@ -1329,6 +1382,8 @@ model User {
|
||||
mergedFrom User[] @relation("UserMerge")
|
||||
referrer User? @relation("UserReferrer", fields: [referrerUserId], references: [id], onDelete: SetNull)
|
||||
referrers User[] @relation("UserReferrer")
|
||||
assocPartner PartnerAccount? @relation("UserPartnerAssoc", fields: [assocPartnerAccountId], references: [id], onDelete: SetNull)
|
||||
partnerNotes PartnerUserNote[]
|
||||
avatar CommonResource? @relation("UserAvatar", fields: [avatarResourceId], references: [id], onDelete: SetNull)
|
||||
addresses UserAddress[]
|
||||
cityPreference UserCityPreference?
|
||||
@@ -1343,6 +1398,7 @@ model User {
|
||||
|
||||
@@index([sourceType, sourceRefId])
|
||||
@@index([referrerUserId])
|
||||
@@index([assocPartnerAccountId])
|
||||
@@index([mergedIntoUserId])
|
||||
@@index([wxOpenId])
|
||||
@@index([isTest])
|
||||
@@ -1877,6 +1933,9 @@ model StoreRating {
|
||||
storeId BigInt @map("store_id") @db.UnsignedBigInt
|
||||
serviceScore Int @map("service_score") @db.TinyInt
|
||||
envScore Int @map("env_score") @db.TinyInt
|
||||
comment String? @db.VarChar(200)
|
||||
tags Json?
|
||||
imageUrls Json? @map("image_urls")
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
|
||||
|
||||
redeemRecord RedeemRecord @relation(fields: [redeemRecordId], references: [id], onDelete: Cascade)
|
||||
|
||||
Reference in New Issue
Block a user