getCrmSettings($phone->business_id)); if (($assessment->cooperation_score ?? 0) >= 4 && ! empty($settings['auto_create_followup_on_interested'])) { $days = max(1, (int) ($settings['followup_days_after_interested'] ?? 3)); $crmUtil->addFollowUp([ 'contact_id' => $phone->lead_id, 'title' => __('crm::lang.telemarketing_followup_title', ['company' => $phone->company_name ?? $phone->mobile_number]), 'description' => $assessment->notes, 'start_datetime' => Carbon::now()->addDays($days)->format('Y-m-d H:i:s'), 'end_datetime' => Carbon::now()->addDays($days)->addHour()->format('Y-m-d H:i:s'), 'schedule_type' => 'call', 'status' => 'scheduled', 'followup_category_id' => null, 'user_id' => [$user->id], ], $user); } if ($assessment->partner_potential === 'high') { $this->notifySupervisors($phone->business_id, __('crm::lang.high_partner_potential_alert', [ 'company' => $phone->company_name ?? $phone->mobile_number, ])); } if ($assessment->sentiment === 'hostile') { $phone->update(['block_auto_recall' => true]); } if ($company && $company->profile_completion >= 80) { $offerService = new OfferMatchingService(); $offerService->matchForCompany($company, $assessment); } } public function afterNoAnswerStreak(CrmPhoneFollowUp $phone, int $streak = 3): void { if ($streak >= 3) { // Mark for SMS campaign follow-up $phone->update(['status' => 'no_answer']); } } protected function notifySupervisors(int $business_id, string $message): void { $supervisors = User::where('business_id', $business_id) ->whereHas('permissions', function ($q) { $q->where('name', 'crm.telemarketing.supervisor_dashboard'); }) ->get(); // Notification can be extended with a dedicated notification class foreach ($supervisors as $supervisor) { // placeholder for future notification } } }