Version 2.0

This commit is contained in:
2026-05-12 09:23:05 +00:00
parent f2bc048219
commit f1b68e5e78
34 changed files with 564 additions and 283 deletions

View File

@@ -114,6 +114,7 @@ minicrm/
│ │ ├── ImportCskh.php # app:import-cskh
│ │ └── ExportBackup.php # app:export-backup
│ ├── Enums/
│ │ ├── ContractCategory.php # V2: ownership/business
│ │ ├── ContractType.php
│ │ ├── ContractStatus.php
│ │ ├── HandoverStatus.php
@@ -123,11 +124,10 @@ minicrm/
│ │ └── Middleware/HandleUploadErrors.php
│ ├── Models/
│ │ ├── ActivityLog.php # NEW: Audit trail model
│ │ ├── Contract.php
│ │ ├── Customer.php
│ │ ├── CustomerProduct.php
│ │ ├── Contract.php # V2: +category, +representative_*
│ │ ├── Customer.php # V2: ownedProducts() qua contracts
│ │ ├── Department.php
│ │ ├── Feedback.php
│ │ ├── Feedback.php # V2: bỏ customer_product_id
│ │ ├── FeedbackAttachment.php
│ │ ├── FeedbackChannel.php
│ │ ├── FeedbackInteraction.php
@@ -136,7 +136,7 @@ minicrm/
│ │ ├── Product.php
│ │ ├── ProductService.php
│ │ ├── TicketTransferLog.php
│ │ └── User.php # HasRoles (Spatie), isAdmin(), isManager()
│ │ └── User.php
│ ├── Policies/
│ │ ├── ActivityLogPolicy.php # NEW
│ │ ├── ContractPolicy.php
@@ -192,7 +192,26 @@ minicrm/
| metadata | json nullable | Extra data |
| created_at | timestamp | |
### departments
### contracts (V2: category + representative)
| Column | Type | Notes |
|--------|------|-------|
| id | bigint PK | |
| product_id | fk -> products | cascadeOnDelete |
| customer_id | fk -> customers | cascadeOnDelete |
| category | string | **(V2)** ownership \| business |
| type | string | **(V2)** deposit, purchase, transfer, rental, self_business, bcc |
| start_date, end_date | date nullable | |
| status | string | active, expired, liquidated |
| printed_at | date nullable | |
| signed_status | string nullable | |
| representative_name | string nullable | **(V2)** |
| representative_phone | string nullable | **(V2)** |
| representative_email | string nullable | **(V2)** |
| created_at, updated_at | timestamp | |
> **V2 Constraint:** Mỗi product chỉ có tối đa 1 contract active mỗi category. Validation ở cả Model level (`booted::saving`) và UI.
### departments (NEW)
| Column | Type | Notes |
|--------|------|-------|
| id | bigint PK | |
@@ -216,8 +235,7 @@ minicrm/
|--------|------|-------|
| id | bigint PK | |
| customer_id | fk -> customers | cascadeOnDelete |
| customer_product_id | fk -> customer_product nullable | null = general feedback |
| contract_id | fk -> contracts nullable | **(NEW)** Snapshot contract |
| contract_id | fk -> contracts nullable | **(V2)** Snapshot contract (thay thế customer_product_id) |
| feedback_channel_id | fk -> feedback_channels | |
| assigned_to | fk -> users nullable | Current handler |
| current_department_id | fk -> departments nullable | Current department |
@@ -244,7 +262,7 @@ minicrm/
| created_at, updated_at | timestamp | |
### Other tables
feedback_interactions, feedback_tags, feedback_feedback_tag, products, customers, customer_product, feedback_channels, users, contracts, handovers, product_services, roles, permissions, model_has_roles (Spatie), notifications, sessions, cache
feedback_interactions, feedback_tags, feedback_feedback_tag, products, customers, feedback_channels, users, contracts, handovers, product_services, roles, permissions, model_has_roles (Spatie), notifications, sessions, cache
## Workflow