Commit Graph
312 Commits
Author SHA1 Message Date
LizandroandClaude Sonnet 4.6 fb92ebfb1c Fix SQL string literals for PostgreSQL compatibility in AI logs query
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-14 19:21:39 +00:00
LizandroandClaude Sonnet 4.6 44297aa0bb Add AI usage logs for Gemini and Whisper
- Migration + AiUsageLog model with tokens, duration, time, cost fields
- GeminiIntentService and GeminiVisionService log every API call
  with input/output token counts from usageMetadata and response time
- TelegramBotService logs Whisper calls with audio duration (from Telegram)
  and calculates cost at $1/second
- Whisper voice duration now passed from TelegramWebhookController
- Free text in Telegram now tries Gemini intent detection before showing menu
- /chat/ia-logs: Livewire component with summary cards + filterable table
- Whisper connection test button in config panel
- "Logs IA" link added to Chat/Bot nav section

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-14 19:13:59 +00:00
LizandroandClaude Sonnet 4.6 f39f3d4045 Add Whisper voice transcription to Telegram bot
- handleVoice() downloads Telegram audio and transcribes via Whisper API
- transcribeAudio() calls Whisper with Basic Auth, handles json response
- TelegramWebhookController now routes message.voice and message.audio
- Whisper URL, token and toggle configurable from admin config panel
- Transcribed text echoed back to user then processed as normal text intent

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-14 19:00:57 +00:00
LizandroandClaude Sonnet 4.6 3f2bdc0d47 Add menu/salir commands to Telegram bot
- Any message matching salir/menu/volver/cancelar/inicio resets flow and shows main menu
- Register /menu /salir /cancelar as official bot commands via setMyCommands
- Commands are registered automatically when saving the webhook from admin panel

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-14 18:40:17 +00:00
LizandroandClaude Sonnet 4.6 50bbd159c6 Fix Telegram webhook registration: replace file_get_contents with Http client
file_get_contents fails on many hosts due to allow_url_fopen or SSL restrictions.
Http:: (Guzzle) is more reliable and shows a clearer error message on failure.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-14 18:26:39 +00:00
LizandroandClaude Sonnet 4.6 e43fe4043f Improve intent detection: keyword layer + better Gemini prompt
- Add detectarIntencionKeyword() with regex patterns in Colombian Spanish
  that runs before Gemini (instant, no API cost)
- Gemini is now only called for ambiguous text
- Improve Gemini prompt with real examples and informal Spanish
- Replace generic "no entendí" with actionable buttons

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-14 15:25:39 +00:00
LizandroandClaude Sonnet 4.6 a21675b12c Fix promotion listing: role-based filtering and correct pricing
- Filter promos by TarifaPromo.rol_id (same as services)
- Fix visible filter: use string 'true' not boolean
- Get price from Usuario_promo or TarifaPromo instead of Promociones.precio
- Get utilidad from TarifaPromo for correct margin tracking
- Applied same fixes to TelegramBotService promo flows

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-14 15:19:28 +00:00
LizandroandClaude Sonnet 4.6 b4624db056 fix: account lookup now uses real availability logic (servicio_id + pantallas)
- Replace tarifa_id+estado='ocupado' query with the same logic used in
  ShowServicios: filter by servicio_id, date range, historiales_count
- Full-account plans (pantallas == completa): look for estado='pendiente'
  accounts without assigned profiles
- Partial plans (screen sharing): look for estado='activo' accounts
  with remaining slots (historiales_count <= pantallas_servicio - pantallas)
- Wrap purchase in DB::transaction to avoid race conditions
- Remove incorrect cuenta->update(['estado' => 'ocupado']) — availability
  is now tracked via historial_cuentas count, not a flag
- Use effective price (Preferencial override) for saldo deduction

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-14 13:46:36 +00:00
LizandroandClaude Sonnet 4.6 26953c9dd5 feat: smart scroll — keep position when reading, badge for new messages
- Add pollMensajes() so wire:poll no longer force-scrolls to bottom
- MutationObserver detects new DOM nodes: auto-scrolls only if user
  is already at the bottom (within 80px threshold)
- Floating '↓ N mensaje nuevo' badge appears when new bot messages
  arrive while user is scrolled up; tap badge to jump to bottom
- scroll-chat event (emitted on button clicks/sends) still forces
  scroll since the user just took an action

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-14 13:36:31 +00:00
LizandroandClaude Sonnet 4.6 a5bac9cee7 feat: custom recharge amount in web chat and Telegram
- Web chat: 'Otro valor' button sets flujo=recarga.monto_custom,
  next text message is parsed as the amount (min $1.000)
- Telegram: '✏️ Otro valor' button sets step=await_amount,
  next message is parsed and routed to method selection
- Preset amounts in Telegram now show 2 per row for compactness

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-14 12:57:36 +00:00
LizandroandClaude Sonnet 4.6 2fc2aba8a3 feat: Telegram transactional flows + role pricing + services slider
- New TelegramBotService: full OTP auth, registration, main menu with
  inline keyboards, buy plans, buy promos, recharge (MP + Bre-B),
  credentials, history, profile, agent transfer, photo receipt analysis
- TelegramWebhookController: now handles text, callback_query and photo
- Role-based pricing: tarifas filtered by user rol_id in both web chat
  and Telegram; Preferencial price overrides base tarifa valor
- Services and promos now render as horizontal scroll slider
  (cards_slider tipo_ui) instead of stacked individual cards

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-14 04:36:03 +00:00
LizandroandClaude Sonnet 4.6 65c569b333 fix(chat): usuarios creados desde el chat reciben rol 'cliente'
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-14 01:47:41 +00:00
LizandroandClaude Sonnet 4.6 a9d8253800 fix(chat): menú no se repite + responsive corregido
- abrirChat(): mueve cargarMensajes() al final (después de crear mensajes en DB)
- abrirChat(): siempre agrega saludo+menú al autenticarse (no hay duplicación
  porque mount() no llama a abrirChat())
- mount(): solo restaura estado desde sesión, sin agregar mensajes nuevos
- public-chat.blade.php: root div recupera flex flex-col (flex-1 en hijos funciona)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-14 01:32:29 +00:00
LizandroandClaude Sonnet 4.6 d27bd1c0d7 fix(chat): sesión persistente entre recargas + responsive móvil/desktop
- mount(): restaura userId y convId desde sesión Laravel al recargar página
- abrirChat(): guarda chat_user_id y chat_conv_id en sesión
- cerrarSesion(): limpia la sesión correctamente
- Desktop: chat centrado como frame (420px, bordes redondeados, sombra)
- Móvil: pantalla completa sin restricción de ancho
- teclado virtual: ajuste de altura solo en móvil

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-14 01:22:23 +00:00
LizandroandClaude Sonnet 4.6 4ddfdaeecc fix(chat): renombrar transferencia bancaria a Bre-B y clave a llave
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-14 01:18:09 +00:00
LizandroandClaude Sonnet 4.6 9b76f63aa0 feat(chat): recarga con transferencia bancaria, fix OTP y mejoras UI
- Fix: autocomplete="off" en campo OTP (evita que el correo aparezca ahí)
- Recarga: nuevo paso elegir método (MercadoPago o Transferencia bancaria)
- Transferencia: muestra card con banco/clave/titular/monto y aviso de comprobante
- Validación automática al enviar foto del comprobante (flujo existente)
- Config admin: nuevos campos banco/clave/titular para transferencia
- UI: card de banco con estilo diferenciado (azul), aviso destacado en ámbar

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-14 01:16:51 +00:00
LizandroandClaude Sonnet 4.6 9d0940873d feat(chat): botón cerrar sesión en el header del chat
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-14 01:08:46 +00:00
LizandroandClaude Sonnet 4.6 5f06c27869 feat(chat): pedir cédula y celular al crear cuenta desde el chat
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-14 01:06:05 +00:00
LizandroandClaude Sonnet 4.6 a693ce2527 feat(chat): identificación por correo con registro automático
- Reemplaza campo teléfono por correo electrónico en el inicio del chat
- Si el correo existe: envía OTP y abre el chat
- Si no existe: ofrece crear cuenta automáticamente (pide nombre)
- Si rechaza registro: vuelve al formulario inicial
- Cuenta nueva se crea con contraseña aleatoria

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-14 01:03:24 +00:00
LizandroandClaude Sonnet 4.6 536377363c feat: web chat con IA, validación de pagos y OTP por correo
- Chat público en /chat con flujos de compra, recarga y credenciales
- Verificación de identidad por código OTP enviado al correo registrado
- Botones enriquecidos: cards, links, credenciales, validación de comprobante
- Gemini IA para detección de intención en texto libre
- Gemini Vision para extraer datos de foto de comprobante
- Validador de pagos cruzando IA con correos IMAP (Bancolombia)
- MercadoPago como pasarela de pago (reemplaza Wompi en el chat)
- Migraciones: payload en chat_messages, user_id en chat_contacts
- Config admin: API key Gemini, toggles IA y validación de foto

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-14 00:09:31 +00:00
Lizandro Guarnizo a56a69dccb up 2026-06-18 13:04:07 -05:00
Lizandro Guarnizo ebd72870be Update ReversarCompra.php 2026-06-18 12:59:00 -05:00
Lizandro Guarnizo 9066229e3a up 2026-06-18 12:56:20 -05:00
Lizandro Guarnizo 0282645c08 nuevo formulario 2026-06-18 11:06:49 -05:00
Lizandro Guarnizo 155450b676 Update ShowUsuarios.php 2026-06-05 10:17:07 -05:00
Lizandro Guarnizo ca0636f81c up 2026-06-05 10:12:46 -05:00
Lizandro Guarnizo 67732fbde5 up 2026-05-12 19:50:28 -05:00
Lizandro Guarnizo f61e8005fc chatbot nuevo 2026-04-30 21:32:32 -05:00
Lizandro Guarnizo 0e5ff957eb up 2026-04-25 15:04:50 -05:00
Lizandro Guarnizo 2228818c85 up 2026-04-25 14:54:19 -05:00
Lizandro Guarnizo bbf34d08d0 correo 2026-04-25 14:47:20 -05:00
Lizandro Guarnizo 148fa6b9f9 up 2026-04-24 21:40:10 -05:00
Lizandro Guarnizo 877a0d393a up 2026-04-21 18:32:01 -05:00
Lizandro Guarnizo e6f749e059 ip 2026-04-21 18:27:16 -05:00
Lizandro Guarnizo bca737531b up 2026-04-21 18:14:04 -05:00
Lizandro Guarnizo 9108a584cf up 2026-04-18 20:07:42 -05:00
Lizandro Guarnizo d11423c379 up 2026-04-18 14:13:24 -05:00
Lizandro Guarnizo 03207775af up 2026-04-18 14:08:14 -05:00
Juan Felipe Duarte 36bf56b622 Normalize email input for registration and login
Trim and lowercase email before storing or attempting login to avoid mismatches from case or surrounding whitespace. Updated RegisteredUserController@store to save 'email' => strtolower(trim($request->email)) and LoginRequest@authenticate to call Auth::attempt with the normalized email input.
2026-03-02 08:43:12 -05:00
Juan Felipe Duarte 4a44dbc1c1 Implement device and IP tracking for users
Added Device and UserIp models and migrations to store device fingerprints and user IPs with expiration. Updated ShowSavingIp Livewire component and view to capture and persist both IP and device fingerprint. Introduced a scheduled command to clean expired user IPs and registered it in the console kernel. Removed the old migration for storing IPs directly on the users table.
2025-10-25 09:18:56 -05:00
Juan Felipe Duarte a558e393f2 Add rank management feature with CRUD and UI
Introduces a new rank management system including the Rank model, migrations for the ranks table and user IP address, Livewire components for managing and displaying ranks, and related Blade views. Updates navigation and routes to include the new 'Gestión Rangos' section, and enhances the ShareCodeComponent with user data. Also adds a reusable input field component for forms.
2025-10-23 20:28:47 -05:00
Juan Felipe Duarte aa67099449 Add Livewire component to display and save user IP
Introduces ShowSavingIp Livewire component to fetch, display, and save the authenticated user's IP address. Integrates the component into the navigation layout and comments out the unused /ip-test route.
2025-10-18 14:10:11 -05:00
lizandrogd 227b129613 up 2025-10-18 10:43:02 -05:00
Juan Felipe Duarte 4276f1da4e Refactor IP display logic in ShowIpTest component
Simplifies the Livewire component by removing public and local IP properties and related listeners. Updates the Blade view to fetch and display the user's public IP using ipify API, removing previous local IP detection logic.
2025-10-18 10:28:30 -05:00
Juan Felipe Duarte 013061c1d6 Show public and local IP addresses in Livewire view
Added properties and event listener to ShowIpTest component to display both public IP (from Laravel) and local IP (from JavaScript). Updated Blade view to show both IPs and included a script to detect local IP using WebRTC and dispatch it to Livewire.
2025-10-17 16:24:46 -05:00
Juan Felipe Duarte 5ea64cac17 Add IP test page with Livewire component
Introduces a new route and controller method for '/ip-test', rendering a new view that includes a Livewire component to display the user's IP address. Updates navigation layout for improved profile display. Adds related Blade and Livewire files.
2025-10-17 14:50:13 -05:00
Juan Felipe Duarte 0e2a7e9a20 Copy tarifas and promos on user registration
When a new user registers with a referral code, their tarifas and promos are now copied from the referring user. Also refactored Usuario_promo and Usuario_tarifa models to use fillable attributes and improved method formatting. Added Swiper CSS/JS to app layout.
2025-10-16 14:46:17 -05:00
Juan Felipe Duarte 8c50434f31 Restrict price validation to non-super users
Updated price validation logic in ShowTarifas and ShowUsuarios to allow users with the 'super' role to set prices below the base value. Other users will continue to receive an error if the price is less than the base value.
2025-10-16 11:49:20 -05:00
Juan Felipe Duarte 5c04a95792 update codigo referido funcionamiento login, register y dashboard 2025-10-15 16:43:43 -05:00
lizandrogd 75bffed0bb Update ShowPromociones.php 2025-09-03 18:31:49 -05:00