Files
minicrm/ai_instructions/AI_02_DATABASE_SCHEMA_UPGRADE.md
2026-05-01 04:33:00 +00:00

1.8 KiB

TASK: Nâng cấp Database Schema từ Dữ liệu Excel

Context: Đọc quy tắc tại AI_01_BUSINESS_LOGIC_AND_POLICIES.md

Hãy tạo các file Migration và cập nhật các Model tương ứng trong Laravel 13 cho các thực thể sau:

1. Bảng handovers (Module Bàn giao)

  • product_id (foreignId, constrained)
  • customer_id (foreignId, constrained - người nhận bàn giao)
  • handover_date (date - Ngày nhận BG)
  • status (string - Tình trạng BG: Chưa đủ điều kiện, Đủ ĐK, Đã BG trực tiếp...)
  • remark (text, nullable - Ghi chú hồ sơ BG)

2. Bảng contracts (Module Hợp đồng)

  • product_id (foreignId, constrained)
  • customer_id (foreignId, constrained)
  • type (string - Enum/Const: LEASE, BCC, SALE)
  • start_date (date, nullable - Ngày bắt đầu)
  • end_date (date, nullable - Ngày kết thúc/Thời hạn thanh lý)
  • status (string - Tình trạng HĐ: Active, Expired, Liquidated...)
  • printed_at (date, nullable - Ngày in HĐ)
  • signed_status (string - Tình trạng ký)

3. Bảng product_services (Dịch vụ phụ trợ / Tự doanh / Phí QL / Tri ân)

  • product_id (foreignId, constrained)
  • service_type (string - Enum/Const: MANAGEMENT_FEE, GRATITUDE, SELF_BUSINESS)
  • status (string - Tình trạng)
  • actual_collection_date (date, nullable - Thời hạn thu thực tế)
  • remark (text, nullable)

4. Cập nhật Bảng feedback (Cốt lõi)

  • Tạo migration bổ sung cột: table->foreignId('contract_id')->nullable()->constrained('contracts')->nullOnDelete();

Yêu cầu cho AI:

  • Khai báo đầy đủ các Relationships (hasMany, belongsTo) trong tất cả các Models.
  • Chuẩn bị sẵn các RelationManager cho Filament 5.6 để gắn vào ProductResource.