Command normalizacion y avance envio de correo a usuario

parent 429891f5
...@@ -170,6 +170,23 @@ ...@@ -170,6 +170,23 @@
<parameter name="Engine" value="InnoDB"/> <parameter name="Engine" value="InnoDB"/>
</vendor> </vendor>
</table> </table>
<table name="mcafee_ultimo_proceso_normalizacion" phpName="McafeeUltimoProcesoNormalizacion" idMethod="native">
<column name="mun_id" phpName="MunId" type="INTEGER" primaryKey="true" autoIncrement="true" required="true"/>
<column name="ultimo_umc_id" phpName="UltimoUmcId" type="INTEGER" required="false"/>
<column name="mun_cantidad_procesados" phpName="MunCantidadProcesados" type="INTEGER" required="false"/>
<column name="mun_cantidad_pendientes" phpName="MunCantidadPendientes" type="INTEGER" required="false"/>
<column name="created_at" phpName="CreatedAt" type="TIMESTAMP" required="false"/>
<column name="updated_at" phpName="UpdatedAt" type="TIMESTAMP" required="false"/>
<foreign-key foreignTable="usuario_mcafee" name="fk_ultimo_umc_id_normla" onDelete="RESTRICT" onUpdate="RESTRICT">
<reference local="ultimo_umc_id" foreign="umc_id"/>
</foreign-key>
<index name="fk_ultimo_umc_id_normla_idx">
<index-column name="ultimo_umc_id"/>
</index>
<vendor type="mysql">
<parameter name="Engine" value="InnoDB"/>
</vendor>
</table>
<table name="notificacion_email" phpName="NotificacionEmail" idMethod="native"> <table name="notificacion_email" phpName="NotificacionEmail" idMethod="native">
<column name="nem_id" phpName="NemId" type="INTEGER" primaryKey="true" autoIncrement="true" required="true"/> <column name="nem_id" phpName="NemId" type="INTEGER" primaryKey="true" autoIncrement="true" required="true"/>
<column name="eem_id" phpName="EemId" type="INTEGER" required="false"/> <column name="eem_id" phpName="EemId" type="INTEGER" required="false"/>
...@@ -265,6 +282,7 @@ ...@@ -265,6 +282,7 @@
<column name="umc_permite_email" phpName="UmcPermiteEmail" type="BOOLEAN" size="1" required="false" defaultValue="true"/> <column name="umc_permite_email" phpName="UmcPermiteEmail" type="BOOLEAN" size="1" required="false" defaultValue="true"/>
<column name="umc_fecha_desuscripcion_email" phpName="UmcFechaDesuscripcionEmail" type="TIMESTAMP" required="false"/> <column name="umc_fecha_desuscripcion_email" phpName="UmcFechaDesuscripcionEmail" type="TIMESTAMP" required="false"/>
<column name="umc_movil" phpName="UmcMovil" type="VARCHAR" size="200" required="false"/> <column name="umc_movil" phpName="UmcMovil" type="VARCHAR" size="200" required="false"/>
<column name="umc_fijo" phpName="UmcFijo" type="VARCHAR" size="200" required="false"/>
<column name="umc_customer_id" phpName="UmcCustomerId" type="VARCHAR" size="250" required="false"/> <column name="umc_customer_id" phpName="UmcCustomerId" type="VARCHAR" size="250" required="false"/>
<column name="umc_eliminado" phpName="UmcEliminado" type="BOOLEAN" size="1" required="false"/> <column name="umc_eliminado" phpName="UmcEliminado" type="BOOLEAN" size="1" required="false"/>
<column name="created_at" phpName="CreatedAt" type="TIMESTAMP" required="false"/> <column name="created_at" phpName="CreatedAt" type="TIMESTAMP" required="false"/>
......
<?php
namespace AppBundle\Model;
use AppBundle\Model\om\BaseMcafeeUltimoProcesoNormalizacion;
class McafeeUltimoProcesoNormalizacion extends BaseMcafeeUltimoProcesoNormalizacion
{
}
<?php
namespace AppBundle\Model;
use AppBundle\Model\om\BaseMcafeeUltimoProcesoNormalizacionPeer;
class McafeeUltimoProcesoNormalizacionPeer extends BaseMcafeeUltimoProcesoNormalizacionPeer
{
}
<?php
namespace AppBundle\Model;
use AppBundle\Model\om\BaseMcafeeUltimoProcesoNormalizacionQuery;
class McafeeUltimoProcesoNormalizacionQuery extends BaseMcafeeUltimoProcesoNormalizacionQuery
{
}
<?php
namespace AppBundle\Model\map;
use \RelationMap;
use \TableMap;
/**
* This class defines the structure of the 'mcafee_ultimo_proceso_normalizacion' table.
*
*
*
* This map class is used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
* @package propel.generator.src.AppBundle.Model.map
*/
class McafeeUltimoProcesoNormalizacionTableMap extends TableMap
{
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'src.AppBundle.Model.map.McafeeUltimoProcesoNormalizacionTableMap';
/**
* Initialize the table attributes, columns and validators
* Relations are not initialized by this method since they are lazy loaded
*
* @return void
* @throws PropelException
*/
public function initialize()
{
// attributes
$this->setName('mcafee_ultimo_proceso_normalizacion');
$this->setPhpName('McafeeUltimoProcesoNormalizacion');
$this->setClassname('AppBundle\\Model\\McafeeUltimoProcesoNormalizacion');
$this->setPackage('src.AppBundle.Model');
$this->setUseIdGenerator(true);
// columns
$this->addPrimaryKey('mun_id', 'MunId', 'INTEGER', true, null, null);
$this->addForeignKey('ultimo_umc_id', 'UltimoUmcId', 'INTEGER', 'usuario_mcafee', 'umc_id', false, null, null);
$this->addColumn('mun_cantidad_procesados', 'MunCantidadProcesados', 'INTEGER', false, null, null);
$this->addColumn('mun_cantidad_pendientes', 'MunCantidadPendientes', 'INTEGER', false, null, null);
$this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null);
$this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null);
// validators
} // initialize()
/**
* Build the RelationMap objects for this table relationships
*/
public function buildRelations()
{
$this->addRelation('UsuarioMcafee', 'AppBundle\\Model\\UsuarioMcafee', RelationMap::MANY_TO_ONE, array('ultimo_umc_id' => 'umc_id', ), null, null);
} // buildRelations()
/**
*
* Gets the list of behaviors registered for this table
*
* @return array Associative array (name => parameters) of behaviors
*/
public function getBehaviors()
{
return array(
'timestampable' => array (
'create_column' => 'created_at',
'update_column' => 'updated_at',
'disable_updated_at' => 'false',
),
);
} // getBehaviors()
} // McafeeUltimoProcesoNormalizacionTableMap
...@@ -58,6 +58,7 @@ class UsuarioMcafeeTableMap extends TableMap ...@@ -58,6 +58,7 @@ class UsuarioMcafeeTableMap extends TableMap
$this->addColumn('umc_permite_email', 'UmcPermiteEmail', 'BOOLEAN', false, 1, true); $this->addColumn('umc_permite_email', 'UmcPermiteEmail', 'BOOLEAN', false, 1, true);
$this->addColumn('umc_fecha_desuscripcion_email', 'UmcFechaDesuscripcionEmail', 'TIMESTAMP', false, null, null); $this->addColumn('umc_fecha_desuscripcion_email', 'UmcFechaDesuscripcionEmail', 'TIMESTAMP', false, null, null);
$this->addColumn('umc_movil', 'UmcMovil', 'VARCHAR', false, 200, null); $this->addColumn('umc_movil', 'UmcMovil', 'VARCHAR', false, 200, null);
$this->addColumn('umc_fijo', 'UmcFijo', 'VARCHAR', false, 200, null);
$this->addColumn('umc_customer_id', 'UmcCustomerId', 'VARCHAR', false, 250, null); $this->addColumn('umc_customer_id', 'UmcCustomerId', 'VARCHAR', false, 250, null);
$this->addColumn('umc_eliminado', 'UmcEliminado', 'BOOLEAN', false, 1, null); $this->addColumn('umc_eliminado', 'UmcEliminado', 'BOOLEAN', false, 1, null);
$this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null);
...@@ -73,6 +74,7 @@ class UsuarioMcafeeTableMap extends TableMap ...@@ -73,6 +74,7 @@ class UsuarioMcafeeTableMap extends TableMap
$this->addRelation('EnvioEmail', 'AppBundle\\Model\\EnvioEmail', RelationMap::ONE_TO_MANY, array('umc_id' => 'umc_id', ), null, null, 'EnvioEmails'); $this->addRelation('EnvioEmail', 'AppBundle\\Model\\EnvioEmail', RelationMap::ONE_TO_MANY, array('umc_id' => 'umc_id', ), null, null, 'EnvioEmails');
$this->addRelation('McafeeTransaccion', 'AppBundle\\Model\\McafeeTransaccion', RelationMap::ONE_TO_MANY, array('umc_id' => 'umc_id', ), null, null, 'McafeeTransaccions'); $this->addRelation('McafeeTransaccion', 'AppBundle\\Model\\McafeeTransaccion', RelationMap::ONE_TO_MANY, array('umc_id' => 'umc_id', ), null, null, 'McafeeTransaccions');
$this->addRelation('McafeeTransaccionPendiente', 'AppBundle\\Model\\McafeeTransaccionPendiente', RelationMap::ONE_TO_MANY, array('umc_id' => 'umc_id', ), null, null, 'McafeeTransaccionPendientes'); $this->addRelation('McafeeTransaccionPendiente', 'AppBundle\\Model\\McafeeTransaccionPendiente', RelationMap::ONE_TO_MANY, array('umc_id' => 'umc_id', ), null, null, 'McafeeTransaccionPendientes');
$this->addRelation('McafeeUltimoProcesoNormalizacion', 'AppBundle\\Model\\McafeeUltimoProcesoNormalizacion', RelationMap::ONE_TO_MANY, array('umc_id' => 'ultimo_umc_id', ), null, null, 'McafeeUltimoProcesoNormalizacions');
$this->addRelation('Tracking', 'AppBundle\\Model\\Tracking', RelationMap::ONE_TO_MANY, array('umc_id' => 'umc_id', ), null, null, 'Trackings'); $this->addRelation('Tracking', 'AppBundle\\Model\\Tracking', RelationMap::ONE_TO_MANY, array('umc_id' => 'umc_id', ), null, null, 'Trackings');
} // buildRelations() } // buildRelations()
......
...@@ -152,6 +152,22 @@ ...@@ -152,6 +152,22 @@
<parameter name="Engine" value="InnoDB"/> <parameter name="Engine" value="InnoDB"/>
</vendor> </vendor>
</table> </table>
<table name="mcafee_ultimo_proceso_normalizacion" phpName="McafeeUltimoProcesoNormalizacion" idMethod="native">
<column name="mun_id" phpName="MunId" type="INTEGER" primaryKey="true" autoIncrement="true" required="true"/>
<column name="ultimo_umc_id" phpName="UltimoUmcId" type="INTEGER" required="false"/>
<column name="mun_cantidad_procesados" phpName="MunCantidadProcesados" type="INTEGER" required="false"/>
<column name="mun_cantidad_pendientes" phpName="MunCantidadPendientes" type="INTEGER" required="false"/>
<behavior name="timestampable" />
<foreign-key foreignTable="usuario_mcafee" name="fk_ultimo_umc_id_normla" onDelete="RESTRICT" onUpdate="RESTRICT">
<reference local="ultimo_umc_id" foreign="umc_id"/>
</foreign-key>
<index name="fk_ultimo_umc_id_normla_idx">
<index-column name="ultimo_umc_id"/>
</index>
<vendor type="mysql">
<parameter name="Engine" value="InnoDB"/>
</vendor>
</table>
<table name="notificacion_email" phpName="NotificacionEmail" idMethod="native"> <table name="notificacion_email" phpName="NotificacionEmail" idMethod="native">
<column name="nem_id" phpName="NemId" type="INTEGER" primaryKey="true" autoIncrement="true" required="true"/> <column name="nem_id" phpName="NemId" type="INTEGER" primaryKey="true" autoIncrement="true" required="true"/>
<column name="eem_id" phpName="EemId" type="INTEGER" required="false"/> <column name="eem_id" phpName="EemId" type="INTEGER" required="false"/>
...@@ -244,6 +260,7 @@ ...@@ -244,6 +260,7 @@
<column name="umc_permite_email" phpName="UmcPermiteEmail" type="BOOLEAN" size="1" required="false" defaultValue="true"/> <column name="umc_permite_email" phpName="UmcPermiteEmail" type="BOOLEAN" size="1" required="false" defaultValue="true"/>
<column name="umc_fecha_desuscripcion_email" phpName="UmcFechaDesuscripcionEmail" type="TIMESTAMP" required="false"/> <column name="umc_fecha_desuscripcion_email" phpName="UmcFechaDesuscripcionEmail" type="TIMESTAMP" required="false"/>
<column name="umc_movil" phpName="UmcMovil" type="VARCHAR" size="200" required="false"/> <column name="umc_movil" phpName="UmcMovil" type="VARCHAR" size="200" required="false"/>
<column name="umc_fijo" phpName="UmcFijo" type="VARCHAR" size="200" required="false"/>
<column name="umc_customer_id" phpName="UmcCustomerId" type="VARCHAR" size="250" required="false"/> <column name="umc_customer_id" phpName="UmcCustomerId" type="VARCHAR" size="250" required="false"/>
<column name="umc_eliminado" phpName="UmcEliminado" type="BOOLEAN" size="1" required="false"/> <column name="umc_eliminado" phpName="UmcEliminado" type="BOOLEAN" size="1" required="false"/>
......
<?php
namespace BackendBundle\Command;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use AppBundle\Model\UsuarioMcafee;
use AppBundle\Model\UsuarioMcafeeQuery;
use AppBundle\Model\UsuariosMcafeeMovistarMigrar;
use AppBundle\Model\UsuariosMcafeeMovistarMigrarQuery;
use AppBundle\Model\McafeeUltimoProcesoNormalizacion;
use AppBundle\Model\McafeeUltimoProcesoNormalizacionQuery;
use AppBundle\Lib\Utiles;
class McafeeNormalizacionUsuariosMigracionCommand extends ContainerAwareCommand
{
protected function configure()
{
$this
->setName('mcafee:normalizacion-usuarios-migracion')
->setDescription('comando que sirve para normalizar errores generados en la migracion.')
;
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$output->writeln("COMANDO INICIADO.");
$log = Utiles::setLog('command::NormalizacionUsuariosMigracion', 'ws/wsNormalizarUsuariosMcAfee');
$ultimoUsuarioProcesado = null;
$cantidadProcesados = 0;
$cantidadPendientes = 0;
$usuariosMax = Utiles::getParametroConfiguracion("numero_usuarios_normalizar");
$log->debug("obteniendo ultimo indice procesado normalizacion...");
$ultimoIndiceUsuarioProcesado = McafeeUltimoProcesoNormalizacionQuery::create()//arreglar es ultimo indice procesado
->orderByMunId("DESC")
->findOne();
if ($ultimoIndiceUsuarioProcesado == null){
$condicion = "usuarios_mcafee.umc_id > 0";
//else $condicion = "usuarios_mcafee_movistar_migrar.id > ".$ultimoIndiceUsuarioProcesado->getUltimoUmcId();
}else $condicion = "usuarios_mcafee.umc_id >= 0 and usuarios_mcafee.umc_id > ".$ultimoIndiceUsuarioProcesado->getUltimoUmcId();
$log->debug("condicion a analizar ".$condicion);
$log->debug("obteniendo usuarios candidatos a migrar...");
$usuariosANormalizar = UsuarioMcafeeQuery::create()
->where($condicion)
->limit($usuariosMax)
->find();
foreach($usuariosANormalizar as $index=>$usuario):
$log->debug("usuario mcafee a normalizar : ".$usuario->getUmcId());
$strAencriptar = $usuario->getUmcMcafeeCcid()."|".$usuario->getUmcMcafeeEmail();
$log->debug("buscando usuario en tabla usuario movistar migrar por correo mcafee : ".$usuario->getUmcMcafeeEmail());
$usuarioTablaMigracion = UsuariosMcafeeMovistarMigrarQuery::create()
->filterByEmailAddress($usuario->getUmcMcafeeEmail())
->findOne();
if($usuarioTablaMigracion->getFonoContactoMovil1() != 0){
$telMovil = $usuarioTablaMigracion->getFonoContactoMovil1();
}else {
$telMovil = $usuarioTablaMigracion->getFonoContactoMovil2();
}
$usuario->setUmcMovil($telMovil);
$usuario->setUmcFijo($usuarioTablaMigracion->getAreaTel());
$usuario->setUmcParametroEncriptado(Utiles::base64url_encode($strAencriptar));
$usuario->save();
$log->debug("Ultimo usuario procesado : ".$usuario->getUmcId());
$log->debug("descansando el proceso un segundo...");
$cantidadProcesados++;
$ultimoUsuarioProcesado = $usuario;
sleep(1000);
endforeach;
//GENERANDO REGISTRO DE PROCESO
$registroProceso = new McafeeUltimoProcesoNormalizacion();
$registroProceso->setUsuarioMcafee($ultimoUsuarioProcesado);
$registroProceso->setMunCantidadProcesados($cantidadProcesados);
$registroProceso->setMunCantidadPendientes($cantidadPendientes);
$registroProceso->setCreatedAt(new \DateTime());
$registroProceso->setUpdatedAt(new \DateTime());
$registroProceso->save();
$log->debug("Ultimo usuario procesado : ".$ultimoUsuarioProcesado->getUmcId()." | cantidad procesados : $cantidadProcesados | cantidad pendientes : $cantidadPendientes");
$output->writeln('COMANDO FINALIZADO.');
}
}
...@@ -115,36 +115,37 @@ class ResearchController extends Controller { ...@@ -115,36 +115,37 @@ class ResearchController extends Controller {
if ($usuarioMcafee) { if ($usuarioMcafee) {
if ($usuarioMcafee->getUmcPermiteEmail() == false) { if ($usuarioMcafee->getUmcPermiteEmail() == false) {
$log->warn('usuario ya realizo descarga... umcId:' . $usuarioMcafee->getUmcId()); $log->warn('usuario ya realizo descarga... umcId:' . $usuarioMcafee->getUmcId());
$tNoPermiteEmail++;
$tNoProcesado++;
$terminarEnvio = true; $terminarEnvio = true;
$log->debug("eusuario ya realizo descarga...");
$json->setStatusCode(JsonResponse::HTTP_BAD_REQUEST, 'usuario ya realizo descarga...');
$json->setData(array('errors' => 'usuario ya realizo descarga.'));
return $json;
} }
if ($terminarEnvio == false && $usuarioMcafee->isTrakingDescarga() == true) { if ($terminarEnvio == false && $usuarioMcafee->isTrakingDescarga() == true) {
$log->warn('usuario ya realizo descarga... umcId:' . $usuarioMcafee->getUmcId()); $log->warn('usuario ya realizo descarga... umcId:' . $usuarioMcafee->getUmcId());
$tYaDescargo++;
$tNoProcesado++;
$terminarEnvio = true; $terminarEnvio = true;
$json->setStatusCode(JsonResponse::HTTP_BAD_REQUEST, 'usuario ya realizo descarga...');
$json->setData(array('errors' => 'usuario ya realizo descarga.'));
return $json;
} }
if ($terminarEnvio == false && $usuarioMcafee->isEmailMovistarCorrecto() == false) { if ($terminarEnvio == false && $usuarioMcafee->isEmailMovistarCorrecto() == false) {
$log->warn('usuario sin correo... umcId:' . $usuarioMcafee->getUmcId()); $log->warn('usuario sin correo... umcId:' . $usuarioMcafee->getUmcId());
$tSinEmail++;
$tNoProcesado++;
$terminarEnvio = true; $terminarEnvio = true;
$json->setStatusCode(JsonResponse::HTTP_BAD_REQUEST, 'usuario sin correo...');
$json->setData(array('errors' => 'usuario sin correo.'));
return $json;
} }
$tProcesado++;
$tPermiteEmail++;
$asunto = Utiles::getParametroConfiguracion("titulo_correo_licencia"); $asunto = Utiles::getParametroConfiguracion("titulo_correo_licencia");
$fromNombreEmail = Utiles::getParametroConfiguracion("from_correo_licencia"); $fromNombreEmail = Utiles::getParametroConfiguracion("from_correo_licencia");
$fromEmail = Utiles::getParametroConfiguracion("alias_correo_licencia"); $fromEmail = Utiles::getParametroConfiguracion("alias_correo_licencia");
$email = $usuarioMcafee->getUmcMovistarEmail(); $email = $usuarioMcafee->getUmcMovistarEmail();
$log->debug($cont . " email:" . $email . " | umcId:" . $usuarioMcafee->getUmcId() . " | campana:" . $campana); $log->debug(" email:" . $email . " | umcId:" . $usuarioMcafee->getUmcId());
$envioEmail = EnvioEmail::enviarEmailV2($urlDescarga, $urlDesuscripcion, $email, $usuarioMcafee, $emailing, $campana, $asunto, $fromEmail, $fromNombreEmail, EnvioEmail::TIPO_MASIVO, null, $log, $this->getContainer()); $envioEmail = EnvioEmail::enviarEmailV2($urlDescarga, $urlDesuscripcion, $email, $usuarioMcafee, null, 0, $asunto, $fromEmail, $fromNombreEmail, EnvioEmail::TIPO_UNITARIO, null, $log, $this->getContainer());
$log->debug('enviando E-mail...'); $log->debug('enviando E-mail...');
if ($envioEmail) { if ($envioEmail) {
...@@ -154,7 +155,10 @@ class ResearchController extends Controller { ...@@ -154,7 +155,10 @@ class ResearchController extends Controller {
$json->setData("OK"); $json->setData("OK");
return $json; return $json;
} else { } else {
$log->debug("el usuario no existe...");
$json->setStatusCode(JsonResponse::HTTP_BAD_REQUEST, 'Ocurrio un error al tratar de enviar el mail...');
$json->setData(array('errors' => 'Ocurrio un error al tratar de enviar el mail.'));
return $json;
} }
} else { } else {
$log->debug("el usuario no existe..."); $log->debug("el usuario no existe...");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment