This commit is contained in:
Your Name committed 2026-09-14 11:46:07 +07:00
1 parent d5ea45a536
commit afd6904c48
20 files changed
+5435 -51

No files matched your search

+72
View File
@@ -790,3 +790,75 @@ model MarketplaceProduct {
@@index([totalRevenue])
}
// ── Marketplace Customers & CRM ───────────────────────────────────────────────
model MarketplaceCustomer {
id Int @id @default(autoincrement())
channel String // "tiktok" | "shopee" | "lazada"
shop String @default("hom-aroma")
identifier String // Unique identifier per channel (username or name+postcode)
displayName String // Display name on UI
location String? // District, Province
province String?
district String?
// Aggregated buyer stats
orderCount Int @default(0)
totalSpent Float @default(0)
avgIntervalDays Float @default(0)
firstOrderDate String?
lastOrderDate String?
predictedNextOrderDate String?
topProducts Json? // Stored as JSON array: string[]
// CRM Relationship
crm MarketplaceCustomerCrm?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@unique([channel, identifier])
@@index([channel])
@@index([totalSpent])
@@index([orderCount])
}
model MarketplaceCustomerCrm {
id Int @id @default(autoincrement())
customerId Int @unique
customer MarketplaceCustomer @relation(fields: [customerId], references: [id], onDelete: Cascade)
// Tracking status
status String @default("pending") // "pending" | "contacted" | "converted" | "unresponsive" | "do_not_disturb"
strategyType String @default("due_restock") // "due_restock" | "win_back" | "vip_reward" | "nurture"
// Campaign & contact details
promoCodeSent String? // e.g., "REPEAT10"
discountOffered String? // e.g., "ส่วนลด 10%"
lastContactedAt DateTime?
nextFollowUpDate DateTime?
notes String?
assignedTo String?
activities CustomerCrmActivity[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@index([status])
@@index([strategyType])
@@index([nextFollowUpDate])
}
model CustomerCrmActivity {
id Int @id @default(autoincrement())
crmId Int
crm MarketplaceCustomerCrm @relation(fields: [crmId], references: [id], onDelete: Cascade)
action String // "STATUS_CHANGE" | "SENT_PROMO" | "CALL_NOTE" | "CHAT_NOTE"
content String
author String?
createdAt DateTime @default(now())
@@index([crmId])
}