Appearance
Hệ thống Affiliate (CTV/KOL/KOC)
Thông tin nhanh
- 7 bảng chính: affiliates, aff_campaigns, aff_links, aff_clicks, aff_referrals, aff_commissions, aff_payouts
- ORG-level: org_affiliates, org_payout_batches, org_payout_items (029)
- Attribution: Last-touch model (028)
- Portal: aff.salehay.com — dashboard, referrals, earnings, links, profile
Xem thêm: Database · Kiến trúc
Mô hình Affiliate
SaleHay sử dụng mô hình CTV (Cộng Tác Viên) giới thiệu khách hàng — CTV giới thiệu doanh nghiệp dịch vụ đăng ký SaleHay và nhận hoa hồng.
Loại affiliate
| Type | Mô tả |
|---|---|
ctv | Cộng tác viên thông thường |
kol | Key Opinion Leader — influencer |
koc | Key Opinion Consumer — người dùng chia sẻ |
staff | Nhân viên nội bộ giới thiệu |
Luồng Commission
Commission types
| Type | Trigger | Ví dụ |
|---|---|---|
signup_fee | Org đăng ký gói trả phí | 500.000đ / org |
booking_fee | Booking từ content CTV | 50.000đ / booking |
recurring | Recurring monthly | 5% revenue × N tháng |
bonus | Thưởng thủ công | Tuỳ campaign |
Attribution Model (Last-Touch)
Migration 028_affiliate_attribution.sql triển khai last-touch attribution:
- Cookie tracking: CTV link set cookie
_sh_refvớireferral_code+ expiry 30 ngày - Signup capture: Registration flow đọc cookie → ghi vào
aff_referrals.affiliate_id - Org creation: Khi user tạo org → link affiliate referral với org
ORG-level Affiliate Management (029)
Ngoài platform-level affiliate, mỗi Organization cũng có thể quản lý CTV riêng:
| Bảng | Chức năng |
|---|---|
org_affiliates | CTV theo org (nhân viên giới thiệu khách) |
org_payout_batches | Đợt thanh toán (draft → confirmed → completed) |
org_payout_items | Chi tiết từng khoản thanh toán trong batch |
Schema chính
Bảng affiliates
| Column | Type | Mô tả |
|---|---|---|
| id | UUID PK | |
| user_id | UUID FK → users | Tài khoản người dùng |
| type | VARCHAR | ctv, kol, koc, staff |
| referral_code | VARCHAR UK | Mã giới thiệu duy nhất |
| status | VARCHAR | pending, active, suspended, inactive |
| bank_name, bank_account, bank_holder | VARCHAR | Thông tin ngân hàng |
| momo_phone | VARCHAR | Số MoMo |
| total_referrals, total_gmv, total_earned, total_paid | Numeric | Stats cache |
Bảng aff_campaigns
| Column | Type | Mô tả |
|---|---|---|
| id | UUID PK | |
| name | VARCHAR | Tên chương trình |
| signup_commission_type | VARCHAR | flat hoặc percentage |
| signup_commission_value | DECIMAL | Giá trị hoa hồng |
| booking_fee | DECIMAL | Phí per booking |
| recurring_enabled | BOOLEAN | Có recurring không |
| recurring_percentage, recurring_months | Numeric | Chi tiết recurring |
| start_date, end_date | DATE | Thời gian chiến dịch |
Affiliate Portal (aff.salehay.com)
Giao diện dành cho CTV quản lý hoạt động giới thiệu:
| Trang | Chức năng |
|---|---|
| Dashboard | Tổng quan: referrals, earnings, click stats |
| Referrals | Danh sách org đã giới thiệu + trạng thái |
| Earnings | Lịch sử commission + payout |
| Links | Tạo và quản lý referral links |
| Profile | Thông tin cá nhân, ngân hàng, CCCD |
Xem thêm: SOP Affiliate Onboarding