Trường Số PRD/11 Dữ liệu và API
Trường Số · Yêu cầu sản phẩm · 09/2026

PRD 11 · Mô hình dữ liệu và API

Danh sách thực thể tổng hợp kèm quan hệ, bề mặt /v3 hiện có so với các endpoint mà từng mô-đun cần, quy ước API, và bộ công cụ di chuyển dữ liệu để nhập một trung tâm từ Excel: học viên, phụ huynh, lớp học, lượt ghi danh, số dư đầu kỳ và nhân sự.

Xuất xứ / Prompt / Giới hạn
Trạng thái
Dự thảo v1
Mô-đun phụ trách
Platform
Backend
staging /v3 · 182 endpoint · 504 schema
Giai đoạn
P1
Phụ thuộc vào
tất cả PRD mô-đun

Tài liệu do trợ lý AI soạn trong một phiên làm việc ngày 10/09/2026, theo yêu cầu gốc được trích nguyên văn ở trang mục lục; mục Thiết kế đề xuất được bổ sung ngày 16/09/2026. Đây là bản đề xuất để đội thảo luận, chưa phải quyết định của đội sản phẩm.

Nguồn

  • Nghiên cứu công khai về đối thủ cạnh tranh (PSE ONE, pse4.one), mã nguồn center-crm-frontend và đặc tả OpenAPI /v3 trên staging (182 endpoint), tính đến ngày 10/09/2026.
  • Nhãn existing / extend / new trong trang được xác định bằng cách đối chiếu với đặc tả /v3 trên staging tại thời điểm trên.
  • Số endpoint theo nhóm ở mục 3 (Crm 148, Teacher 73, Parent 5, Payment 1) đếm từ đặc tả staging ngày 10/09/2026.
  • Thứ tự nhập liệu ở mục 4 lấy theo cách đối thủ cạnh tranh hướng dẫn khách hàng của họ đưa dữ liệu vào phần mềm.

Giới hạn

  • Cần xác minh khi khảo sát trực tiếp trong ứng dụng, vì đăng nhập tự động vào sản phẩm tham chiếu chưa được cấp phép trong phiên soạn:
    • Mẫu nhập liệu của đối thủ theo từng thực thể (tên cột, trường bắt buộc) để tham chiếu lộ trình di chuyển dữ liệu cho các trung tâm chuyển đổi.
    • Định dạng xuất dữ liệu của họ, để xây dựng công cụ nhập liệu cho khách hàng chuyển đổi.
    • Định dạng mã (mã học viên, mã lớp, số phiếu thu).

Thiết kế đề xuất

PRD này không có màn hình riêng: nội dung là nền tảng dùng chung. Thiết kế của từng tính năng nằm ở mục "Thiết kế đề xuất" đầu mỗi PRD mô-đun (00 đến 10 và 13 đến 19).

1Quy ước API

2Danh mục thực thể

Nguồn gốc: existing = đã có trong API /v3; extend = đã có kèm trường mới; new = cần được tạo mới. Chỉ liệt kê trường chính; danh sách trường đầy đủ nằm trong từng PRD mô-đun.

Thực thểNguồn gốcĐịnh danhQuan hệ chínhPRD
Center (tenant)extendcenter_id stringhas many School; Users; CRM config00, 10
School (branch) + branch_profileextendschool_id int64belongs to Center; has Students, Classes, Sessions, Tuition, Rooms, Cash accounts00, 10
SaleProfile (staff user) + user_branch_scopeextendsale_profile_id int64, user_idroles; branches; owns Leads; maps to Staff10
Role, Permission catalogextendrole id, codepermissions with scope10
Customer (lead) + prospect_learnersextenduuid, codestage, status, source, channel, tags, assignees, interactions, placement tests, learners link, trial bookings, conversions01
Pipeline, Stage, Status, Source, Channel, Tag, CustomField, Package (sales)existinguuidtenant catalogs01, 10
Interaction (call, meeting, task, note)existinguuidcustomer, actor01
PlacementTestextenduuidcustomer, learner link, FLYER report01
TrialBookingnewuuidcustomer, prospect, class, session01, 03
Conversionnewuuidcustomer → student, guardian, enrollment, tuition01
LearnerProfile (FLYER)existinglearner_profile_id int64StudentProfile; scores; reports02
Student (operational record)newuuid, codeschool; learner profile; guardians; enrollments; packages; balance; documents; notes; status history02
Guardian, student_guardian, Consentnewuuidstudents; portal sessions; messages02, 07
Courseextenduuidfee plans; classes03, 05
Levelnewcodecourses, classes, students, placement mapping03
Class + class_profileextendclass_id int64school; course; room; staff; sessions; enrollments; ClassSchedule (FLYER program)03
Room, Holidaynewuuidschool03
Sessionnewuuidclass; room; main and substitute staff; attendance sheet; timesheet lines; trial and make-up bookings03, 04, 06
Enrollmentnewuuidstudent; class; fee plan03
MakeupBooking, Excusenewuuidstudent; sessions03, 04
AttendanceSheet, AttendanceRecord (+history)newuuidsession; student; package consumption; messages04
FeePlannewuuidcourse; tuition lines; packages05
Tuition (invoice) + linesextenduuid, payment_codestudent; class; course; fee plan; payments; credit notes; e-invoice; group invoice05
Payment (TuitionTransaction)extenduuid, receipt_notuition; cash account; cashier; SePay id05
GroupInvoiceexistinguuidtuitions; classes05
SessionPackage, SessionConsumptionnewuuidstudent; tuition; attendance records05
CreditNote, Refund, Expense, ExpenseCategory, CashAccount, CashClose, UnmatchedTransaction, VoucherGroup, Voucher, VoucherUsenewuuidfinance05
SchoolBankAccount, SchoolCompanyexistinguuidschool05, 10
Staff, JobTitle, StaffContract, PayRule (+override), Timesheet (+lines, adjustments), EvaluationTemplate, Evaluation, StaffDocumentnewuuidwraps TeacherProfile and SaleProfile; sessions06
TeacherProfile, RollupTeacherexistingint64classes; KPIs06
MessageTemplate, Message, Announcement, ProgressReportBatch, ProgressReport, ParentRequest, ZaloOAConnection, PortalSessionnewuuidguardians; students; sources07
InventoryItem, Category, Document, Movementnewuuidschool; students; tuition lines08
agg_daily_school, report jobs, digest settingsnew09
Invitation, Integration, OnboardingChecklist, AuditLognewuuidcenter; actors10, 12
Notification, Mention, Discussion, CustomerFile, ViewConfig, ImportJob, TodayPlanexistingCRM support objects, reused by new modules where noted01, 09, 11

Sơ đồ quan hệ

CenterSchool (branch)Customer (lead)StudentEnrollmentClass GuardianTuition / PaymentAttendanceSession MessageSession packageTimesheetStaffRole / User has studentsconvertsenrollsingeneratesrosterconsumespaysbilledpayerreceivescreditsdeductsscoped by
Các quan hệ chính. Center sở hữu Schools và Users; một Student thuộc một School và liên kết với một learner FLYER; Sessions là đầu mối cho điểm danh, gói buổi và tính lương.

3Bề mặt API: hiện có so với cần bổ sung

Số endpoint hiện có theo nhóm: Crm 148, Teacher 73, Parent 5, Payment 1. Bảng dưới đây liệt kê những gì mỗi mô-đun tái sử dụng và số lượng endpoint mới mà mô-đun đó bổ sung (theo từng PRD mô-đun).

Mô-đunExisting reusedExtendedNewGhi chú
01 Tuyển sinhcustomers (60+), pipelines, stages, statuses, sources, channels, tags, custom fields, packages, interactions, quick actions, placement tests, imports, search, notifications, today plan, dashboardcustomers (prospect_learners), interactions filters, placement tests (suggested_level), pipelines (trial stage)do-not-call, transfer-school, trial-bookings (3), convertđóng các tham chiếu frontend đến những endpoint không theo đặc tả
02 Học viênschool-finance students, stats, tuitions, courses; parent reports; quick-search; learners searchnonestudents (7), guardians (3), consents, documents, notes, balance, anonymise, credentialsstudent bao lấy learner profile
03 Lớp họcteacher classes, class-schedules (FLYER program), coursescourses, classes listclasses (5), sessions (5), enrollments (2), roster, makeups, rooms, holidays, levels, timetable, icssessions được sinh thành các bản ghi cụ thể (materialised)
04 Điểm danhschool-configschool-config policyattendance (9), excuses, parent attendancechưa có entity nào có sẵn
05 Tài chínhtuitions (10), group invoices, bank accounts, company, link-token, payment QR, parent tuitionstuitions list/create/detail/pay/notify, group invoice create, parent tuitionsfee plans, void, approve, receipts, debt, payment plan, packages, credit notes, refunds, expenses, cashbook, cash accounts, unmatched, vouchers, e-invoice, finance report (about 25)tái sử dụng Tuition làm hoá đơn
06 Nhân sựschools, rollup-teachers, sale profiles, rolesnonestaff (6), contracts, pay rules, timesheets (7), evaluations, documentsP2
07 Phụ huynhtuition notify, class remind, exam notify, parent tuitions and reports, notification configschool-config notifications, parent tuitionstemplates, messages, announcements, progress reports, requests, zalo integration, parent auth and views, inbox, consents, webhook (about 20)tầng message bao lấy notify đã có sẵn
08 Khostudents, classes pickers, tuition createnoneitems, categories, stock, documents, issue, movements, materials, export (13)P2
09 Báo cáocrm dashboard (5), tuition stats, rollups, view configsnoneexecutive, home, reports/{key}, jobs, digestdữ liệu tổng hợp (aggregate)
10 Cài đặtroles, permissions catalog, sale profiles, centers, sources, channels, tags, custom fields, packages, pipelines, school-config, companypermissions catalog, roles permissions with scope, me/permissions, centers PATCH, school-configbranches, invitations, sale-profile branches, deactivate, catalogs (levels, rooms, job titles, expense categories, fee plans, holidays), audit logs, integrations, checklist, full exportthay thế các bản giả (mock)
11 Nhập liệuimports (customers)imports (entity types)import templates per entity, validate, commitxem phần dưới

Danh sách đầy đủ các endpoint kèm cấu trúc request và response nằm trong phần API của từng PRD. Đội backend nên sinh các bổ sung OpenAPI trước để đội frontend tiếp tục quy trình sinh hook tự động.

4Di chuyển dữ liệu và nhập từ Excel

Hầu hết các trung tâm đến với dữ liệu là các sheet Excel hoặc file xuất từ một hệ thống khác. Wizard nhập liệu hiện có xử lý lead với mẫu file, xem trước, chiến lược khử trùng (bỏ qua, gộp, ghi đè), phân bổ round-robin và một báo cáo lỗi. Cùng một mẫu job này được mở rộng sang các thực thể của school, theo một thứ tự cố định (nhân sự, lớp học, học viên, khoá học, học phí, số buổi còn lại, điểm danh).

Thứ tự nhập liệu và mẫu file

BướcThực thểCột trong mẫu (tiêu đề tiếng Việt · key)Bắt buộcKhoá khử trùngKiểm tra dữ liệu
1Nhân sựHọ tên · full_name; Mã NV · code; Chức danh · job_title; Loại hình · employment_type; Chi nhánh · branch_code; SĐT · phone; Email · email; Ngày bắt đầu · start_date; Là giáo viên · is_teacher; Tạo tài khoản · create_account; Vai trò · role_codefull_name, phone, branch_codephonechi nhánh tồn tại; vai trò tồn tại
2Khoá học và gói học phíTên khoá · course_name; Trình độ · level; Số buổi · lessons; Thời lượng (phút) · duration; Tên gói · plan_name; Loại gói · plan_type; Giá · price; Số buổi gói · sessions; Hạn (tháng) · validity_monthscourse_name, plan_name, plan_type, pricecourse_name + plan_nameplan_type theo enum
3Phòng họcChi nhánh · branch_code; Phòng · name; Sức chứa · capacitybranch_code, namebranch + name
4Lớp họcMã lớp · code; Tên lớp · name; Chi nhánh · branch_code; Khoá · course_name; Trình độ · level; GV chính · teacher_phone; Phòng · room; Lịch · pattern ("T3 18:00-19:30; T5 18:00-19:30"); Khai giảng · start_date; Kết thúc · end_date; Sĩ số · capacitycode, name, branch_code, pattern, start_datecodegiáo viên tồn tại; phòng học tồn tại; pattern phân tích được; sessions được sinh từ max(start_date, ngày nhập liệu) trở về sau, các session trước đó được nhập với trạng thái đã học nhưng chưa có điểm danh trừ khi bước 8 cung cấp dữ liệu điểm danh
5Học viên và phụ huynhMã HV · code; Họ tên · display_name; Ngày sinh · birthday; Giới tính · gender; Chi nhánh · branch_code; Trạng thái · status; Trình độ · level; Trường · school_name; Địa chỉ · address; PH1 họ tên · g1_name; PH1 SĐT · g1_phone; PH1 quan hệ · g1_relationship; PH1 email · g1_email; PH1 Zalo đồng ý · g1_zalo; PH2 ... · g2_*; Tài khoản FLYER · flyer_username; Ghi chú · notedisplay_name, birthday, branch_code, g1_phone (unless age ≥ 18)code, else display_name + birthday + g1_phonestatus theo enum; learner được tạo mới hoặc liên kết theo username; guardian được gộp theo số điện thoại
6Lượt ghi danhMã HV · student_code; Mã lớp · class_code; Ngày bắt đầu · start_date; Ngày kết thúc · end_date; Gói · plan_namestudent_code, class_code, start_datestudent + class + startcảnh báo sĩ số (không chặn khi nhập liệu)
7Số dư đầu kỳMã HV · student_code; Gói · plan_name; Buổi còn lại · sessions_remaining; Hết hạn · expires_on; Còn nợ · debt_amount; Hạn nợ · debt_due; Ghi chú · notestudent_code and at least one of sessions_remaining, debt_amountstudent + plantạo một package với sessions_total = sessions_remaining và một tuition "Số dư đầu kỳ" cho khoản nợ, cả hai đều được gắn cờ is_opening
8Lịch sử điểm danh (tuỳ chọn)Mã lớp · class_code; Ngày · date; Mã HV · student_code; Trạng thái · status (Có mặt/Muộn/Vắng/Có phép)allclass + date + studentsession phải tồn tại cho (class, date); tạo attendance sheet được đánh dấu bởi "Import"
9Tồn kho đầu kỳ (P2)Chi nhánh; Mã hàng; Tên; Danh mục; Đơn vị; Giá bán; Giá vốn; Tồncode, name, branchcodechứng từ nhập kho "Số dư đầu kỳ"

Cách hoạt động của wizard

  1. Chọn thực thể; tải mẫu file (xlsx có dòng tiêu đề, dòng ví dụ, và một sheet ẩn chứa các giá trị hợp lệ cho enum và mã chi nhánh); tải lên file xlsx hoặc csv.
  2. Ánh xạ cột: tự động ánh xạ theo tiêu đề, ánh xạ lại thủ công, các cột chưa ánh xạ được liệt kê; trường tuỳ chỉnh được hỗ trợ cho học viên như đối với lead.
  3. Xem trước kiểm tra dữ liệu: lỗi và cảnh báo theo từng dòng kèm số lượng; tải file lỗi; công tắc "Bỏ qua dòng lỗi".
  4. Chiến lược khử trùng theo từng thực thể (bỏ qua, gộp, ghi đè) như hiện tại; đối với học viên, gộp sẽ cập nhật các trường hồ sơ còn để trống và thêm phụ huynh.
  5. Commit chạy dưới dạng một job (ImportJob đã có sẵn kèm entity_type mới); tiến độ, số dòng thành công và thất bại; trang chi tiết có tab thành công và thất bại (tái sử dụng trang đã có sẵn); có thể huỷ khi đang chờ xử lý.
  6. Rollback: một lượt nhập liệu có thể được hoàn tác trong 24 giờ nếu không có bản ghi nào được tạo bị sửa sau đó (xoá các dòng đã tạo, giữ lại các dòng đã gộp kèm ghi chú trong nhật ký).

Quy tắc chất lượng dữ liệu

API

MethodPathRequest / responseStatus
GET/POST/v3/crm/imports; GET /{id}; POST /{id}/cancel; GET /{id}/errors, /error-reportthêm entity_type enum(customers, staff, courses, rooms, classes, students, enrollments, balances, attendance, inventory) và mappingextend
GET/v3/school/imports/templates/{entity_type}.xlsxtemplate kèm các giá trị hợp lệ cho tenantnew
POST/v3/school/imports/validate{entity_type, rows[], mapping, dedupe_strategy} → {valid, errors[], warnings[], duplicates[]} (không ghi dữ liệu)new
POST/v3/school/imports/{id}/rollbacknew
POST/v3/crm/imports/bulk-customerskhông thay đổi đối với leadexisting

5Thời hạn lưu trữ dữ liệu và định danh

Dữ liệuThời hạn lưu trữĐịnh dạng mã
Leadẩn danh hoá sau 24 tháng không có hoạt động nếu chưa ở trạng thái Thành côngmã customer như hiện tại
Học viên, phụ huynhcòn hoạt động + 5 năm, sau đó ẩn danh hoá theo yêu cầu hoặc sau 5 năm không hoạt độngHV-000123 theo từng tenant
Điểm danh5 nămsession uuid
Chứng từ tài chính10 nămPT-<branch>-YYYYMM-####, PC-..., HĐ = payment_code
Tin nhắn12 tháng đối với nội dung đã hiển thị, 5 năm đối với metadatauuid
Nhật ký hệ thống5 nămuuid, request_id

Trường Số (truongso.net) · Nội bộ FLYER