455 lines
28 KiB
PHP
455 lines
28 KiB
PHP
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use App\Enums\ContractStatus;
|
|
use App\Enums\ContractType;
|
|
use App\Enums\HandoverStatus;
|
|
use App\Enums\ServiceType;
|
|
use App\Models\Contract;
|
|
use App\Models\Customer;
|
|
use App\Models\CustomerProduct;
|
|
use App\Models\Department;
|
|
use App\Models\Feedback;
|
|
use App\Models\FeedbackAttachment;
|
|
use App\Models\FeedbackChannel;
|
|
use App\Models\FeedbackInteraction;
|
|
use App\Models\FeedbackTag;
|
|
use App\Models\Handover;
|
|
use App\Models\Product;
|
|
use App\Models\ProductService;
|
|
use App\Models\TicketTransferLog;
|
|
use App\Models\User;
|
|
use Illuminate\Database\Seeder;
|
|
use Illuminate\Support\Facades\Storage;
|
|
use Illuminate\Support\Str;
|
|
use Spatie\Permission\Models\Role;
|
|
|
|
class AfterSalesSeeder extends Seeder
|
|
{
|
|
public function run(): void
|
|
{
|
|
// ============================================================
|
|
// 1. ROLES & PERMISSIONS
|
|
// ============================================================
|
|
Role::create(['name' => 'admin']);
|
|
Role::create(['name' => 'manager']);
|
|
Role::create(['name' => 'staff']);
|
|
|
|
$this->call(PermissionSeeder::class);
|
|
|
|
// ============================================================
|
|
// 2. USERS (5 users)
|
|
// ============================================================
|
|
$admin = User::create([
|
|
'name' => 'Nguyễn Quản Trị',
|
|
'email' => 'admin@minicrm.local',
|
|
'password' => bcrypt('password'),
|
|
'role' => 'admin',
|
|
]);
|
|
$admin->assignRole('admin');
|
|
|
|
$managerCskh = User::create([
|
|
'name' => 'Trần Minh Manager',
|
|
'email' => 'manager@minicrm.local',
|
|
'password' => bcrypt('password'),
|
|
'role' => 'manager',
|
|
]);
|
|
$managerCskh->assignRole('manager');
|
|
|
|
$managerKt = User::create([
|
|
'name' => 'Lê Văn Kỹ Thuật',
|
|
'email' => 'manager.kt@minicrm.local',
|
|
'password' => bcrypt('password'),
|
|
'role' => 'manager',
|
|
]);
|
|
$managerKt->assignRole('manager');
|
|
|
|
$staffA = User::create([
|
|
'name' => 'Phạm Thị Nhân Viên',
|
|
'email' => 'staff@minicrm.local',
|
|
'password' => bcrypt('password'),
|
|
'role' => 'staff',
|
|
]);
|
|
$staffA->assignRole('staff');
|
|
|
|
$staffB = User::create([
|
|
'name' => 'Hoàng Văn Phụ',
|
|
'email' => 'staff.b@minicrm.local',
|
|
'password' => bcrypt('password'),
|
|
'role' => 'staff',
|
|
]);
|
|
$staffB->assignRole('staff');
|
|
|
|
// ============================================================
|
|
// 3. DEPARTMENTS (4 departments)
|
|
// ============================================================
|
|
$deptCskh = Department::create(['name' => 'Phòng Chăm sóc Khách hàng', 'manager_id' => $managerCskh->id]);
|
|
$deptKt = Department::create(['name' => 'Phòng Kỹ thuật', 'manager_id' => $managerKt->id]);
|
|
$deptKtoan = Department::create(['name' => 'Phòng Kế toán', 'manager_id' => null]);
|
|
$deptPhaply = Department::create(['name' => 'Phòng Pháp lý', 'manager_id' => null]);
|
|
|
|
// ============================================================
|
|
// 4. FEEDBACK CHANNELS (5 channels)
|
|
// ============================================================
|
|
$chEmail = FeedbackChannel::create(['name' => 'Email', 'slug' => 'email', 'icon' => 'heroicon-o-envelope', 'color' => '#3b82f6']);
|
|
$chZalo = FeedbackChannel::create(['name' => 'Zalo', 'slug' => 'zalo', 'icon' => 'heroicon-o-chat-bubble-left', 'color' => '#10b981']);
|
|
$chPhone = FeedbackChannel::create(['name' => 'Điện thoại', 'slug' => 'phone', 'icon' => 'heroicon-o-phone', 'color' => '#f59e0b']);
|
|
$chWalkin = FeedbackChannel::create(['name' => 'Trực tiếp', 'slug' => 'walk-in', 'icon' => 'heroicon-o-user', 'color' => '#ec4899']);
|
|
$chApp = FeedbackChannel::create(['name' => 'Ứng dụng', 'slug' => 'app', 'icon' => 'heroicon-o-device-phone-mobile', 'color' => '#8b5cf6']);
|
|
|
|
// ============================================================
|
|
// 5. PRODUCTS (6 products)
|
|
// ============================================================
|
|
$p1 = Product::create(['name' => 'Sunrise Apartment A101', 'description' => 'Căn hộ 3PN, tầng 10, view sông, nội thất cao cấp', 'status' => 'active']);
|
|
$p2 = Product::create(['name' => 'Sunrise Apartment A202', 'description' => 'Căn hộ 2PN, tầng 20, view thành phố', 'status' => 'active']);
|
|
$p3 = Product::create(['name' => 'Green Valley Villa V05', 'description' => 'Biệt thự đơn lập, hồ bơi riêng, sân vườn 200m²', 'status' => 'active']);
|
|
$p4 = Product::create(['name' => 'Ocean Tower Office O12', 'description' => 'Văn phòng hạng A, tầng 12, trung tâm Q1', 'status' => 'sold_out']);
|
|
$p5 = Product::create(['name' => 'Park Hill Townhouse T08', 'description' => 'Nhà phố liền kề, 4PN, gần công viên', 'status' => 'active']);
|
|
$p6 = Product::create(['name' => 'Sunrise Apartment B305', 'description' => 'Căn hộ Studio, tầng 3, phù hợp đầu tư cho thuê', 'status' => 'inactive']);
|
|
|
|
// ============================================================
|
|
// 6. CUSTOMERS (6 customers)
|
|
// ============================================================
|
|
$c1 = Customer::create(['name' => 'Nguyễn Văn An', 'email' => 'nguyenvanan@gmail.com', 'phone' => '0909123456', 'address' => 'Quận 1, TP.HCM', 'status' => 'active']);
|
|
$c2 = Customer::create(['name' => 'Trần Thị Bình', 'email' => 'tranthibinh@gmail.com', 'phone' => '0918234567', 'address' => 'Quận 7, TP.HCM', 'status' => 'active']);
|
|
$c3 = Customer::create(['name' => 'Lê Hoàng Dũng', 'email' => 'lehoangdung@gmail.com', 'phone' => '0927345678', 'address' => 'Quận 2, TP.HCM', 'status' => 'active']);
|
|
$c4 = Customer::create(['name' => 'Phạm Minh Châu', 'email' => 'phamminhchau@gmail.com', 'phone' => '0936456789', 'address' => 'Bình Thạnh, TP.HCM', 'status' => 'active']);
|
|
$c5 = Customer::create(['name' => 'Hoàng Thị Mai', 'email' => 'hoangthimai@gmail.com', 'phone' => '0945567890', 'address' => 'Quận 9, TP.HCM', 'status' => 'active']);
|
|
$c6 = Customer::create(['name' => 'Đỗ Văn Phúc', 'email' => 'dovanphuc@gmail.com', 'phone' => '0954678901', 'address' => 'Thủ Đức, TP.HCM', 'status' => 'inactive']);
|
|
|
|
// ============================================================
|
|
// 7. CUSTOMER-PRODUCT pivots
|
|
// ============================================================
|
|
$c1->products()->attach($p1->id, ['purchase_date' => '2024-01-15']);
|
|
$c1->products()->attach($p2->id, ['purchase_date' => '2024-06-01']);
|
|
$c2->products()->attach($p1->id, ['purchase_date' => '2024-03-20']);
|
|
$c3->products()->attach($p3->id, ['purchase_date' => '2024-09-10']);
|
|
$c4->products()->attach($p2->id, ['purchase_date' => '2025-01-05']);
|
|
$c4->products()->attach($p5->id, ['purchase_date' => '2025-02-15']);
|
|
$c5->products()->attach($p5->id, ['purchase_date' => '2024-11-01']);
|
|
$c6->products()->attach($p6->id, ['purchase_date' => '2023-06-15']);
|
|
|
|
// ============================================================
|
|
// 8. CONTRACTS (6 contracts)
|
|
// ============================================================
|
|
$contract1 = Contract::create([
|
|
'product_id' => $p1->id, 'customer_id' => $c1->id,
|
|
'type' => ContractType::SALE->value,
|
|
'start_date' => '2024-01-15', 'end_date' => null,
|
|
'status' => ContractStatus::ACTIVE->value,
|
|
'signed_status' => 'Đã ký',
|
|
]);
|
|
$contract2 = Contract::create([
|
|
'product_id' => $p2->id, 'customer_id' => $c1->id,
|
|
'type' => ContractType::LEASE->value,
|
|
'start_date' => '2024-06-01', 'end_date' => '2026-06-01',
|
|
'status' => ContractStatus::ACTIVE->value,
|
|
'signed_status' => 'Đã ký',
|
|
]);
|
|
$contract3 = Contract::create([
|
|
'product_id' => $p1->id, 'customer_id' => $c2->id,
|
|
'type' => ContractType::SALE->value,
|
|
'start_date' => '2024-03-20', 'end_date' => null,
|
|
'status' => ContractStatus::ACTIVE->value,
|
|
'signed_status' => 'Đã ký',
|
|
]);
|
|
$contract4 = Contract::create([
|
|
'product_id' => $p3->id, 'customer_id' => $c3->id,
|
|
'type' => ContractType::BCC->value,
|
|
'start_date' => '2024-09-10', 'end_date' => '2029-09-10',
|
|
'status' => ContractStatus::ACTIVE->value,
|
|
'signed_status' => 'Đang chờ ký',
|
|
]);
|
|
$contract5 = Contract::create([
|
|
'product_id' => $p2->id, 'customer_id' => $c4->id,
|
|
'type' => ContractType::LEASE->value,
|
|
'start_date' => '2025-01-05', 'end_date' => '2026-01-05',
|
|
'status' => ContractStatus::EXPIRED->value,
|
|
'signed_status' => 'Đã ký',
|
|
]);
|
|
$contract6 = Contract::create([
|
|
'product_id' => $p5->id, 'customer_id' => $c5->id,
|
|
'type' => ContractType::SALE->value,
|
|
'start_date' => '2024-11-01', 'end_date' => null,
|
|
'status' => ContractStatus::ACTIVE->value,
|
|
'signed_status' => 'Đã ký',
|
|
]);
|
|
|
|
// ============================================================
|
|
// 9. HANDOVERS (6 handovers)
|
|
// ============================================================
|
|
Handover::create(['product_id' => $p1->id, 'customer_id' => $c1->id, 'handover_date' => '2024-02-15', 'status' => HandoverStatus::HANDED_OVER->value, 'remark' => 'Đã bàn giao đầy đủ chìa khóa, thẻ từ và sổ bảo hành.']);
|
|
Handover::create(['product_id' => $p1->id, 'customer_id' => $c2->id, 'handover_date' => '2024-04-20', 'status' => HandoverStatus::HANDED_OVER->value, 'remark' => 'Đã bàn giao, khách yêu cầu kiểm tra lại hệ thống nước nóng.']);
|
|
Handover::create(['product_id' => $p2->id, 'customer_id' => $c1->id, 'handover_date' => null, 'status' => HandoverStatus::READY->value, 'remark' => 'Căn hộ đã hoàn thiện, chờ khách xác nhận lịch bàn giao.']);
|
|
Handover::create(['product_id' => $p3->id, 'customer_id' => $c3->id, 'handover_date' => '2024-10-01', 'status' => HandoverStatus::SCHEDULED->value, 'remark' => 'Đã hẹn lịch 10h sáng ngày 01/10/2024.']);
|
|
Handover::create(['product_id' => $p5->id, 'customer_id' => $c4->id, 'handover_date' => null, 'status' => HandoverStatus::NOT_READY->value, 'remark' => 'Đang hoàn thiện nội thất, dự kiến đủ điều kiện sau 2 tuần.']);
|
|
Handover::create(['product_id' => $p5->id, 'customer_id' => $c5->id, 'handover_date' => '2025-01-15', 'status' => HandoverStatus::HANDED_OVER->value, 'remark' => 'Bàn giao thành công, khách hài lòng với chất lượng.']);
|
|
|
|
// ============================================================
|
|
// 10. PRODUCT SERVICES (6 services)
|
|
// ============================================================
|
|
ProductService::create(['product_id' => $p1->id, 'service_type' => ServiceType::MANAGEMENT_FEE->value, 'status' => 'active', 'actual_collection_date' => '2024-03-01', 'remark' => 'Phí quản lý hàng tháng 5.000.000 VND/căn.']);
|
|
ProductService::create(['product_id' => $p1->id, 'service_type' => ServiceType::GRATITUDE->value, 'status' => 'completed', 'actual_collection_date' => '2024-06-15', 'remark' => 'Quà tri ân khách hàng nhân dịp khai trương tiện ích mới.']);
|
|
ProductService::create(['product_id' => $p2->id, 'service_type' => ServiceType::MANAGEMENT_FEE->value, 'status' => 'pending', 'actual_collection_date' => null, 'remark' => 'Chưa thu phí quản lý quý 1/2025.']);
|
|
ProductService::create(['product_id' => $p3->id, 'service_type' => ServiceType::SELF_BUSINESS->value, 'status' => 'active', 'actual_collection_date' => '2024-10-01', 'remark' => 'Dịch vụ cho thuê hồ bơi và BBQ khu Villa.']);
|
|
ProductService::create(['product_id' => $p5->id, 'service_type' => ServiceType::GRATITUDE->value, 'status' => 'cancelled', 'actual_collection_date' => null, 'remark' => 'KH từ chối nhận quà, chuyển sang đợt sau.']);
|
|
ProductService::create(['product_id' => $p5->id, 'service_type' => ServiceType::MANAGEMENT_FEE->value, 'status' => 'active', 'actual_collection_date' => '2025-02-01', 'remark' => 'Phí quản lý hàng tháng 3.500.000 VND/căn.']);
|
|
|
|
// ============================================================
|
|
// 11. FEEDBACK TAGS (6 tags)
|
|
// ============================================================
|
|
$tagLeaking = FeedbackTag::create(['name' => 'Rò rỉ', 'slug' => 'leaking', 'color' => '#3b82f6']);
|
|
$tagElectrical = FeedbackTag::create(['name' => 'Điện nước', 'slug' => 'electrical', 'color' => '#f59e0b']);
|
|
$tagWarranty = FeedbackTag::create(['name' => 'Bảo hành', 'slug' => 'warranty', 'color' => '#10b981']);
|
|
$tagMaintenance = FeedbackTag::create(['name' => 'Bảo trì', 'slug' => 'maintenance', 'color' => '#8b5cf6']);
|
|
$tagComplaint = FeedbackTag::create(['name' => 'Phàn nàn', 'slug' => 'complaint', 'color' => '#ef4444']);
|
|
$tagSuggestion = FeedbackTag::create(['name' => 'Đề xuất', 'slug' => 'suggestion', 'color' => '#06b6d4']);
|
|
|
|
// ============================================================
|
|
// 12. FEEDBACKS (8 feedbacks - various statuses)
|
|
// ============================================================
|
|
|
|
// Feedback 1: Pending - Trần rò rỉ
|
|
$cp1 = CustomerProduct::where('customer_id', $c1->id)->where('product_id', $p1->id)->first();
|
|
$fb1 = Feedback::create([
|
|
'customer_id' => $c1->id, 'customer_product_id' => $cp1->id, 'contract_id' => $contract1->id,
|
|
'feedback_channel_id' => $chEmail->id, 'assigned_to' => $staffA->id,
|
|
'current_department_id' => $deptCskh->id,
|
|
'title' => 'Trần nhà bị rò rỉ nước mưa',
|
|
'content' => 'Sau trận mưa lớn ngày 25/04, trần phòng khách xuất hiện vết nước và nhỏ giọt. Đề nghị kiểm tra và sửa chữa khẩn cấp.',
|
|
'status' => 'pending',
|
|
]);
|
|
|
|
// Feedback 2: Processing - Nâng cấp chỗ đậu xe
|
|
$cp2 = CustomerProduct::where('customer_id', $c1->id)->where('product_id', $p2->id)->first();
|
|
$fb2 = Feedback::create([
|
|
'customer_id' => $c1->id, 'customer_product_id' => $cp2->id, 'contract_id' => $contract2->id,
|
|
'feedback_channel_id' => $chPhone->id, 'assigned_to' => $managerCskh->id,
|
|
'current_department_id' => $deptCskh->id,
|
|
'title' => 'Yêu cầu nâng cấp chỗ đậu xe',
|
|
'content' => 'Tôi muốn nâng cấp từ 1 chỗ đậu xe lên 2 chỗ. Vui lòng tư vấn giá cả và thủ tục.',
|
|
'status' => 'processing',
|
|
]);
|
|
|
|
// Feedback 3: Resolved - Điều hòa hỏng
|
|
$cp3 = CustomerProduct::where('customer_id', $c2->id)->where('product_id', $p1->id)->first();
|
|
$fb3 = Feedback::create([
|
|
'customer_id' => $c2->id, 'customer_product_id' => $cp3->id, 'contract_id' => $contract3->id,
|
|
'feedback_channel_id' => $chZalo->id, 'assigned_to' => $staffA->id,
|
|
'current_department_id' => $deptKt->id, 'is_escalated' => false,
|
|
'title' => 'Điều hòa phòng ngủ chính không mát',
|
|
'content' => 'Điều hòa Panasonic Inverter 1.5HP trong phòng ngủ chính phát ra tiếng ồn lớn và không làm mát hiệu quả. Đã vệ sinh lưới lọc nhưng không cải thiện.',
|
|
'status' => 'resolved',
|
|
]);
|
|
|
|
// Feedback 4: Pending - Góp ý cải thiện dịch vụ
|
|
$fb4 = Feedback::create([
|
|
'customer_id' => $c3->id, 'customer_product_id' => null, 'contract_id' => null,
|
|
'feedback_channel_id' => $chApp->id, 'assigned_to' => null,
|
|
'current_department_id' => $deptCskh->id,
|
|
'title' => 'Đề xuất cải thiện dịch vụ vệ sinh',
|
|
'content' => 'Tôi đề xuất tăng tần suất thu gom rác lên 2 lần/ngày (hiện tại 1 lần). Khu vực hành lang tầng 3 thường xuyên có mùi khó chịu vào buổi chiều.',
|
|
'status' => 'pending',
|
|
]);
|
|
|
|
// Feedback 5: Closed - Bản lề tủ bếp
|
|
$cp5 = CustomerProduct::where('customer_id', $c4->id)->where('product_id', $p2->id)->first();
|
|
$fb5 = Feedback::create([
|
|
'customer_id' => $c4->id, 'customer_product_id' => $cp5->id, 'contract_id' => $contract5->id,
|
|
'feedback_channel_id' => $chEmail->id, 'assigned_to' => $staffB->id,
|
|
'current_department_id' => $deptKt->id,
|
|
'title' => 'Bản lề tủ bếp bị gãy',
|
|
'content' => 'Bản lề cánh tủ bếp trên bị gãy, không đóng được. Còn trong thời gian bảo hành, đề nghị thay thế.',
|
|
'status' => 'closed',
|
|
]);
|
|
|
|
// Feedback 6: Processing - Ổ cắm điện hư
|
|
$cp6 = CustomerProduct::where('customer_id', $c5->id)->where('product_id', $p5->id)->first();
|
|
$fb6 = Feedback::create([
|
|
'customer_id' => $c5->id, 'customer_product_id' => $cp6->id, 'contract_id' => $contract6->id,
|
|
'feedback_channel_id' => $chPhone->id, 'assigned_to' => $staffA->id,
|
|
'current_department_id' => $deptKt->id, 'is_escalated' => true,
|
|
'title' => 'Ổ c插座 điện phòng bếp bị hư, có mùi khét',
|
|
'content' => 'Ổ cắm điện cạnh bồn rửa chén bị hư, phát ra mùi khét khi cắm thiết bị. Đây là vấn đề an toàn, cần xử lý gấp.',
|
|
'status' => 'processing',
|
|
]);
|
|
|
|
// Feedback 7: Resolved - Hợp đồng thuê
|
|
$fb7 = Feedback::create([
|
|
'customer_id' => $c4->id, 'customer_product_id' => null, 'contract_id' => $contract5->id,
|
|
'feedback_channel_id' => $chWalkin->id, 'assigned_to' => $staffB->id,
|
|
'current_department_id' => $deptPhaply->id,
|
|
'title' => 'Hỏi về gia hạn hợp đồng thuê',
|
|
'content' => 'Hợp đồng thuê căn hộ A202 sẽ hết hạn vào 01/2026. Tôi muốn gia hạn thêm 2 năm, vui lòng tư vấn thủ tục và giá thuê mới.',
|
|
'status' => 'resolved',
|
|
]);
|
|
|
|
// Feedback 8: Pending - Phàn nàn về tiếng ồn
|
|
$fb8 = Feedback::create([
|
|
'customer_id' => $c2->id, 'customer_product_id' => $cp3->id, 'contract_id' => $contract3->id,
|
|
'feedback_channel_id' => $chZalo->id, 'assigned_to' => $staffB->id,
|
|
'current_department_id' => $deptCskh->id,
|
|
'title' => 'Phàn nàn về tiếng ồn từ tầng trên',
|
|
'content' => 'Căn hộ tầng trên thường xuyên gây tiếng ồn sau 22h, ảnh hưởng đến giấc ngủ gia đình tôi. Đã phản ánh 2 lần nhưng chưa được giải quyết.',
|
|
'status' => 'pending',
|
|
]);
|
|
|
|
// ============================================================
|
|
// 13. TAG ATTACHMENTS
|
|
// ============================================================
|
|
$fb1->tags()->attach([$tagLeaking->id, $tagMaintenance->id]);
|
|
$fb2->tags()->attach([$tagSuggestion->id]);
|
|
$fb3->tags()->attach([$tagElectrical->id, $tagWarranty->id]);
|
|
$fb4->tags()->attach([$tagSuggestion->id]);
|
|
$fb5->tags()->attach([$tagWarranty->id, $tagMaintenance->id]);
|
|
$fb6->tags()->attach([$tagElectrical->id, $tagComplaint->id]);
|
|
$fb7->tags()->attach([$tagSuggestion->id]);
|
|
$fb8->tags()->attach([$tagComplaint->id]);
|
|
|
|
// ============================================================
|
|
// 14. FEEDBACK INTERACTIONS (12 interactions)
|
|
// ============================================================
|
|
|
|
// FB1: Tạo mới + ghi chú
|
|
FeedbackInteraction::create([
|
|
'feedback_id' => $fb1->id, 'user_id' => $admin->id, 'type' => 'note',
|
|
'content' => 'Tiếp nhận phản ánh qua Email. Giao cho nhân viên Phạm Thị xử lý.',
|
|
'changes' => ['status' => ['old' => null, 'new' => 'pending']],
|
|
]);
|
|
FeedbackInteraction::create([
|
|
'feedback_id' => $fb1->id, 'user_id' => $staffA->id, 'type' => 'note',
|
|
'content' => 'Đã liên hệ khách hàng qua điện thoại. Lên lịch kiểm tra vào thứ Ba tuần sau.',
|
|
]);
|
|
|
|
// FB2: Phân công
|
|
FeedbackInteraction::create([
|
|
'feedback_id' => $fb2->id, 'user_id' => $managerCskh->id, 'type' => 'note',
|
|
'content' => 'Đã gửi báo giá nâng cấp chỗ đậu xe qua email. Chờ khách xác nhận.',
|
|
]);
|
|
|
|
// FB3: Xử lý xong
|
|
FeedbackInteraction::create([
|
|
'feedback_id' => $fb3->id, 'user_id' => $staffA->id, 'type' => 'status_change',
|
|
'content' => 'Kỹ thuật viên đã kiểm tra và thay thế block điều hòa ngày 10/06. Khách hàng xác nhận hoạt động bình thường.',
|
|
'changes' => ['status' => ['old' => 'processing', 'new' => 'resolved']],
|
|
]);
|
|
|
|
// FB5: Đóng phiếu
|
|
FeedbackInteraction::create([
|
|
'feedback_id' => $fb5->id, 'user_id' => $staffB->id, 'type' => 'status_change',
|
|
'content' => 'Đã thay thế bản lề mới ngày 01/03. Tất cả tủ bếp hoạt động bình thường.',
|
|
'changes' => ['status' => ['old' => 'processing', 'new' => 'closed']],
|
|
]);
|
|
|
|
// FB6: Đang xử lý + ghi chú khẩn cấp
|
|
FeedbackInteraction::create([
|
|
'feedback_id' => $fb6->id, 'user_id' => $staffA->id, 'type' => 'note',
|
|
'content' => 'Đã cử kỹ thuật viên khẩn cấp đến kiểm tra. Yêu cầu khách không sử dụng ổ cắm cho đến khi sửa xong.',
|
|
]);
|
|
FeedbackInteraction::create([
|
|
'feedback_id' => $fb6->id, 'user_id' => $staffA->id, 'type' => 'status_change',
|
|
'content' => 'Kỹ thuật viên đã kiểm tra, phát hiện dây điện bị hở. Đang chờ vật tư thay thế.',
|
|
'changes' => ['status' => ['old' => 'pending', 'new' => 'processing']],
|
|
]);
|
|
|
|
// FB7: Phân công + chuyển phòng ban
|
|
FeedbackInteraction::create([
|
|
'feedback_id' => $fb7->id, 'user_id' => $managerCskh->id, 'type' => 'assignment',
|
|
'content' => 'Chuyển yêu cầu gia hạn hợp đồng sang Phòng Pháp lý.',
|
|
'changes' => ['assignment' => ['old' => 'Chưa phân công', 'new' => 'Hoàng Văn Phụ']],
|
|
]);
|
|
FeedbackInteraction::create([
|
|
'feedback_id' => $fb7->id, 'user_id' => $staffB->id, 'type' => 'status_change',
|
|
'content' => 'Đã soạn thảo phụ lục hợp đồng gia hạn. Đang chờ khách hàng ký.',
|
|
'changes' => ['status' => ['old' => 'processing', 'new' => 'resolved']],
|
|
]);
|
|
|
|
// FB8: Ghi chú
|
|
FeedbackInteraction::create([
|
|
'feedback_id' => $fb8->id, 'user_id' => $staffB->id, 'type' => 'note',
|
|
'content' => 'Đã liên hệ ban quản lý tòa nhà để xác minh thông tin. BQL cho biết sẽ nhắc nhở cư dân tầng trên.',
|
|
]);
|
|
|
|
// ============================================================
|
|
// 15. TICKET TRANSFER LOGS (2 transfers)
|
|
// ============================================================
|
|
TicketTransferLog::create([
|
|
'feedback_id' => $fb3->id,
|
|
'from_department_id' => $deptCskh->id,
|
|
'to_department_id' => $deptKt->id,
|
|
'sender_id' => $managerCskh->id,
|
|
'reason' => 'Vấn đề kỹ thuật về điều hòa, cần Phòng Kỹ thuật kiểm tra và xử lý.',
|
|
]);
|
|
TicketTransferLog::create([
|
|
'feedback_id' => $fb7->id,
|
|
'from_department_id' => $deptCskh->id,
|
|
'to_department_id' => $deptPhaply->id,
|
|
'sender_id' => $managerCskh->id,
|
|
'reason' => 'Yêu cầu gia hạn hợp đồng thuộc thẩm quyền Phòng Pháp lý.',
|
|
]);
|
|
|
|
// ============================================================
|
|
// 16. FEEDBACK ATTACHMENTS (6 attachments - public disk)
|
|
// ============================================================
|
|
$disk = Storage::disk('public');
|
|
|
|
// Tạo file mẫu trên public disk
|
|
$disk->put('feedback-attachments/bao-cao-kiem-tra-dieu-hoa.pdf', '%PDF-1.4 Mẫu báo cáo kiểm tra điều hòa - Demo');
|
|
$disk->put('feedback-attachments/anh-tran-ro-ri.jpg', str_repeat('x', 1000)); // dummy image
|
|
$disk->put('feedback-attachments/anh-ban-le-hong.png', str_repeat('y', 1200)); // dummy image
|
|
$disk->put('feedback-attachments/bao-gia-nang-cap.pdf', '%PDF-1.4 Báo giá nâng cấp chỗ đậu xe - Demo');
|
|
$disk->put('feedback-attachments/phu-luc-hop-dong.pdf', '%PDF-1.4 Phụ lục hợp đồng gia hạn - Demo');
|
|
$disk->put('feedback-attachments/anh-o-cam-hu.jpg', str_repeat('z', 800)); // dummy image
|
|
|
|
FeedbackAttachment::create([
|
|
'uuid' => (string) Str::uuid(),
|
|
'feedback_id' => $fb3->id, 'user_id' => $staffA->id,
|
|
'name' => 'bao-cao-kiem-tra-dieu-hoa.pdf',
|
|
'path' => 'feedback-attachments/bao-cao-kiem-tra-dieu-hoa.pdf',
|
|
'disk' => 'public', 'collection' => 'proof_of_resolution',
|
|
'mime_type' => 'application/pdf', 'size' => $disk->size('feedback-attachments/bao-cao-kiem-tra-dieu-hoa.pdf'),
|
|
]);
|
|
FeedbackAttachment::create([
|
|
'uuid' => (string) Str::uuid(),
|
|
'feedback_id' => $fb1->id, 'user_id' => $staffA->id,
|
|
'name' => 'anh-tran-ro-ri.jpg',
|
|
'path' => 'feedback-attachments/anh-tran-ro-ri.jpg',
|
|
'disk' => 'public', 'collection' => 'customer_evidence',
|
|
'mime_type' => 'image/jpeg', 'size' => $disk->size('feedback-attachments/anh-tran-ro-ri.jpg'),
|
|
]);
|
|
FeedbackAttachment::create([
|
|
'uuid' => (string) Str::uuid(),
|
|
'feedback_id' => $fb5->id, 'user_id' => $staffB->id,
|
|
'name' => 'anh-ban-le-hong.png',
|
|
'path' => 'feedback-attachments/anh-ban-le-hong.png',
|
|
'disk' => 'public', 'collection' => 'proof_of_resolution',
|
|
'mime_type' => 'image/png', 'size' => $disk->size('feedback-attachments/anh-ban-le-hong.png'),
|
|
]);
|
|
FeedbackAttachment::create([
|
|
'uuid' => (string) Str::uuid(),
|
|
'feedback_id' => $fb2->id, 'user_id' => $managerCskh->id,
|
|
'name' => 'bao-gia-nang-cap.pdf',
|
|
'path' => 'feedback-attachments/bao-gia-nang-cap.pdf',
|
|
'disk' => 'public', 'collection' => 'general',
|
|
'mime_type' => 'application/pdf', 'size' => $disk->size('feedback-attachments/bao-gia-nang-cap.pdf'),
|
|
]);
|
|
FeedbackAttachment::create([
|
|
'uuid' => (string) Str::uuid(),
|
|
'feedback_id' => $fb7->id, 'user_id' => $staffB->id,
|
|
'name' => 'phu-luc-hop-dong.pdf',
|
|
'path' => 'feedback-attachments/phu-luc-hop-dong.pdf',
|
|
'disk' => 'public', 'collection' => 'proof_of_resolution',
|
|
'mime_type' => 'application/pdf', 'size' => $disk->size('feedback-attachments/phu-luc-hop-dong.pdf'),
|
|
]);
|
|
FeedbackAttachment::create([
|
|
'uuid' => (string) Str::uuid(),
|
|
'feedback_id' => $fb6->id, 'user_id' => $staffA->id,
|
|
'name' => 'anh-o-cam-hu.jpg',
|
|
'path' => 'feedback-attachments/anh-o-cam-hu.jpg',
|
|
'disk' => 'public', 'collection' => 'customer_evidence',
|
|
'mime_type' => 'image/jpeg', 'size' => $disk->size('feedback-attachments/anh-o-cam-hu.jpg'),
|
|
]);
|
|
}
|
|
}
|