x
This commit is contained in:
1 parent
abee5249ca
commit
2c8da0ae2a
24 files changed
+9413
-414
No files matched your search
@@ -112,6 +112,7 @@ model ProductVariant {
|
||||
productId Int
|
||||
product Product @relation(fields: [productId], references: [id])
|
||||
bomItems BomItem[]
|
||||
marketplaceProducts MarketplaceProduct[]
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@ -497,6 +498,12 @@ model TiktokOrder {
|
||||
shippingFee Float @default(0) // Shipping Fee After Discount
|
||||
originalShipping Float @default(0)
|
||||
taxes Float @default(0)
|
||||
// Settlement Financials
|
||||
commissionFee Float @default(0) // ค่าคอมมิชชั่น TikTok
|
||||
affiliateFee Float @default(0) // ค่าคอมมิชชั่นแอฟฟิลิเอต
|
||||
netSettlement Float @default(0) // ยอดเงินโอนจริงสุทธิ
|
||||
settledAt String? // วันที่โอนเงิน
|
||||
isSettled Boolean @default(false)
|
||||
// Geography
|
||||
province String?
|
||||
district String?
|
||||
@@ -509,9 +516,9 @@ model TiktokOrder {
|
||||
deliveredTime String?
|
||||
cancelledTime String?
|
||||
|
||||
items TiktokOrderItem[]
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
items TiktokOrderItem[]
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@index([shop])
|
||||
@@index([status])
|
||||
@@ -537,6 +544,44 @@ model TiktokOrderItem {
|
||||
weight Float @default(0)
|
||||
}
|
||||
|
||||
model TiktokSettlement {
|
||||
id Int @id @default(autoincrement())
|
||||
orderId String @unique // หมายเลขคำสั่งซื้อ/การปรับ
|
||||
shop String @default("hom-aroma")
|
||||
transactionType String? // ประเภทธุรกรรม (คำสั่งซื้อ / การปรับยอด)
|
||||
orderCreatedTime String? // เวลาที่สร้างคำสั่งซื้อ
|
||||
orderSettledTime String? // เวลาที่ชำระคำสั่งซื้อ / วันที่โอนเงิน
|
||||
currency String @default("THB")
|
||||
|
||||
// Financial breakdowns
|
||||
settlementAmount Float @default(0) // ยอดการชำระเงินทั้งหมด (Net Payout)
|
||||
grossRevenue Float @default(0) // รายได้ทั้งหมด
|
||||
subtotalAfterSellerDiscount Float @default(0) // ยอดรวมค่าสินค้าหลังหักส่วนลดจากผู้ขาย
|
||||
subtotalBeforeDiscount Float @default(0) // ยอดรวมค่าสินค้าก่อนหักส่วนลด
|
||||
sellerDiscount Float @default(0) // ส่วนลดจากร้านค้า
|
||||
refundAmount Float @default(0) // ยอดรวมเงินคืน
|
||||
|
||||
// Fees
|
||||
totalFee Float @default(0) // ค่าธรรมเนียมทั้งหมด
|
||||
orderFee Float @default(0) // ค่าธรรมเนียมคำสั่งซื้อ
|
||||
commissionFee Float @default(0) // ค่าคอมมิชชั่น TikTok Shop
|
||||
affiliateCommission Float @default(0) // ค่าคอมมิชชั่นแอฟฟิลิเอต
|
||||
affiliatePartnerFee Float @default(0) // ค่าคอมมิชชั่นของพาร์ทเนอร์แอฟฟิลิเอต
|
||||
growthSupportFee Float @default(0) // ค่าธรรมเนียมสนับสนุนการเติบโตของร้านค้า
|
||||
shippingFeeActual Float @default(0) // ค่าธรรมเนียมการจัดส่งจริง
|
||||
platformShippingDiscount Float @default(0) // ส่วนลดค่าธรรมเนียมการจัดส่งจากแพลตฟอร์ม
|
||||
|
||||
customerPayment Float @default(0) // การชำระเงินของลูกค้า
|
||||
rawData Json? // Full raw row data for audit
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@index([shop])
|
||||
@@index([orderSettledTime])
|
||||
@@index([orderId])
|
||||
}
|
||||
|
||||
// ── Lazada Orders ──────────────────────────────────────────────────────────────
|
||||
model LazadaOrder {
|
||||
id Int @id @default(autoincrement())
|
||||
@@ -715,3 +760,33 @@ model ContactMessage {
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
// ── Marketplace Products & SKU Mapping ──────────────────────────────────────────
|
||||
model MarketplaceProduct {
|
||||
id Int @id @default(autoincrement())
|
||||
channel String // "tiktok" | "shopee" | "lazada"
|
||||
shop String @default("hom-aroma")
|
||||
marketplaceSku String @default("") // sellerSku / skuRef / skuId
|
||||
productName String // Item name on marketplace
|
||||
variation String @default("") // Variation / flavor / size
|
||||
avgPrice Float @default(0)
|
||||
totalSoldQty Int @default(0)
|
||||
totalRevenue Float @default(0)
|
||||
firstSoldAt String?
|
||||
lastSoldAt String?
|
||||
|
||||
// Link to Master Core Catalog
|
||||
masterVariantId Int?
|
||||
masterVariant ProductVariant? @relation(fields: [masterVariantId], references: [id], onDelete: SetNull)
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@unique([channel, shop, productName, variation, marketplaceSku])
|
||||
@@index([channel])
|
||||
@@index([shop])
|
||||
@@index([marketplaceSku])
|
||||
@@index([masterVariantId])
|
||||
@@index([totalRevenue])
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user