# -*- coding: utf-8 -*-
# /var/www/html/fluxo_vendas.py

import json
from utils_hibrido import registrar_log, enviar_whatsapp

def processar(conn, cursor, job, atendimento, configs, mensagem_bruta):
    atendimento_id = atendimento['id']
    numero = atendimento['cliente_numero']
    
    registrar_log('VENDAS', f"Atendimento {atendimento_id}")
    
    enviar_whatsapp(configs, numero, "Vou transferir você para o setor de Vendas. Por favor, aguarde.")
    
    cursor.execute("""
        UPDATE atendimentos
        SET status = 'fila', setor_id = 2, fluxo_atual = 'HUMANO', estado_atual = 'AGUARDANDO'
        WHERE id = %s
    """, (atendimento_id,))
    conn.commit()
