Files
minicrm/PROGRESS.md
phuongtc 887765bbd7 feat: AfterSales CRM - SOP compliant real-estate customer care system
- Departments + cross-department transfer workflow
- Role-based closing (staff→resolved, manager→closed) with proof_of_resolution
- Private file storage with collection system + temporary signed URLs
- Dashboard: resolved tickets table, stats, handler performance bar chart
- Spatie RBAC (admin/manager/staff)
- Notifications: TicketTransferred, TicketClosed (database + mail)
- Pest tests: 8 tests, 21 assertions
- Docker production-ready (Dockerfile + compose + entrypoint)
2026-04-27 05:29:48 +00:00

4.4 KiB

AfterSales CRM - Tiến độ

Trạng thái: Hoàn thành SOP — 8 giai đoạn + bug fix + polish

Đã test: Tất cả routes HTTP 200, Pest 7/7 tests pass ✓ Tham chiếu: SOP_des.md — Bản đặc tả hệ thống After-Sale CRM

Công nghệ

  • Laravel 13.6.0 + Filament 5.6.1 + SQLite
  • PHP 8.3
  • Spatie laravel-permission (RBAC)
  • Pest PHP (testing)

Tài khoản test

Role Email Password
admin admin@minicrm.local password
manager manager@minicrm.local password
staff staff@minicrm.local password

ĐÃ HOÀN THÀNH

Giai đoạn 1: Mở rộng CSDL

  • Bảng departments (id, name, manager_id → users)
  • Bổ sung feedback: current_department_id, is_escalated
  • Bảng ticket_transfer_logs (feedback_id, from/to department, sender, reason)
  • Nâng cấp feedback_attachments: uuid, disk, collection
  • Cài Spatie laravel-permission

Giai đoạn 2: Services & Logic

  • FileService: upload, validation (jpg/png/pdf/mp4/mov ≤20MB), collection query, temporary URL
  • TransferService: transfer department + reason required + notification
  • ClosingService: role-gated close + proof_of_resolution check
  • Policies cập nhật dùng Spatie hasRole()
  • Custom Rule RequireProofOfResolution

Giai đoạn 3: Notifications

  • TicketTransferred (Database + Mail)
  • TicketClosed (Database + Mail)

Giai đoạn 4: Filament UI

  • TransferDepartment Action trên Edit Feedback (modal: department + reason + attachment)
  • CloseTicket Action (visible: admin/manager, status ≠ closed, requires confirmation)
  • InteractionsRelationManager: role-aware status options (staff: no "closed"), department field
  • FeedbackForm: current_department_id, is_escalated, attachment_collection

Giai đoạn 5: Dashboard Widgets

  • ResolvedTicketsWidget: bảng ticket resolved chờ đóng (manager lọc theo phòng quản lý)
  • AvgProcessingTimeWidget: 4 stats (resolved count, avg time, pending, escalated)

Giai đoạn 6: Testing

  • Pest cài đặt + 5 test scenarios
  • ClosingPermissionTest: 3 tests (staff 403, no evidence 422, with evidence OK)
  • TransferFlowTest: 2 tests (success + missing reason)

Giai đoạn 7: Seeder

  • 4 departments (CSKH, Kỹ thuật, Kế toán, Pháp lý)
  • 1 ticket_transfer_log mẫu
  • 3 feedback_attachments (2 proof_of_resolution, 1 customer_evidence)

Giai đoạn 8: Polish

  • AGENTS.md cập nhật đầy đủ

Bug Fix

  • Dashboard widget lọc Manager dùng Department::where('manager_id') thay vì auth()->id()
  • Migration default disk privatelocal
  • File upload trong Interaction/Create/Edit dùng lưu thẳng FeedbackAttachment, không tạo UploadedFile giả

PM (Improvements)

  • FeedbackTable: thêm cột Department, Escalated icon, Department filter
  • EditFeedback: validation proof_of_resolution khi đổi status sang closed từ form

PASS 3 — Hoàn thiện SOP

  • HandlerPerformanceWidget: biểu đồ bar chart thời gian xử lý trung bình theo từng nhân viên
  • Department_Head: Manager chỉ đóng được ticket phòng mình quản lý (kèm test)
  • Temporary URL tích hợp vào UI: nút "View Attachments" trong Interaction History với download link
  • Cho phép upload attachment trong status_change interaction
  • Docker sẵn sàng production: Dockerfile, docker-compose, entrypoint
  • Migration notifications table

Database Schema (final)

products              customers            customer_product (pivot)
feedback_channels     feedback             feedback_interactions
feedback_attachments  feedback_tags        feedback_feedback_tag (pivot)
users                 departments          ticket_transfer_logs
permissions           roles                model_has_roles (spatie)
notifications         sessions             cache

Docker Deployment

cp .env.example .env
# Edit .env: set APP_URL, optional: switch to MySQL
docker compose up -d --build
# Open http://localhost:8080/admin

Local Dev

cd /home/phuongtc/vibecode/minicrm
php artisan migrate:fresh --seed
php artisan serve
# Mở http://localhost:8000/admin
php artisan test  # 8 tests, 21 assertions

Hướng dẫn cho AI Agent khác

Xem AGENTS.md - chứa đầy đủ cấu trúc thư mục, schema, namespace patterns, workflow, RBAC.