Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
musica_listas_backend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Cristian Mauricio Diaz Canales
musica_listas_backend
Commits
91518fbc
Commit
91518fbc
authored
May 07, 2019
by
Cristian Mauricio Diaz Canales
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Notificaciones wappush
parent
bb8ed495
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
189 additions
and
0 deletions
+189
-0
config/routes.yaml
config/routes.yaml
+6
-0
src/Utilities/EntelWapush.php
src/Utilities/EntelWapush.php
+4
-0
src/WsBundle/Controller/wsReceptorWapPush.php
src/WsBundle/Controller/wsReceptorWapPush.php
+179
-0
No files found.
config/routes.yaml
View file @
91518fbc
...
...
@@ -105,6 +105,12 @@ ws_enviarWapPush:
requirements
:
suscripcionId
:
\d+
tipo
:
\d+
ws_notificacion_wapush
:
path
:
app/ws/notificacion/wappush
controller
:
App\WsBundle\Controller\wsReceptorWapPush::notificacionWapPush
methods
:
[
GET
,
POST
]
ws_notificacion_reagendamiento
:
path
:
app/ws/notificacion/reagendamiento
controller
:
App\WsBundle\Controller\wsReceptorVPW::notificacionesReagendamiento
...
...
src/Utilities/EntelWapush.php
View file @
91518fbc
...
...
@@ -106,6 +106,8 @@ class EntelWapush {
$detalleWappush
->
setSusId
(
$suscripcion
);
$detalleWappush
->
setEwdMsisdn
(
$aux_msisdn
);
$detalleWappush
->
setEwdEstado
(
PluEntelWapushMasiveDetalle
::
ESTADO_OK_PREENVIO
);
$detalleWappush
->
setCreatedAt
(
new
\DateTime
());
$detalleWappush
->
setUpdatedAt
(
new
\DateTime
());
$em
->
persist
(
$detalleWappush
);
$em
->
flush
();
}
...
...
@@ -204,6 +206,8 @@ class EntelWapush {
$detalleWappush
->
setSusId
(
$suscripcion
);
$detalleWappush
->
setEwdMsisdn
(
$aux_msisdn
);
$detalleWappush
->
setEwdEstado
(
PluEntelWapushMasiveDetalle
::
ESTADO_OK_PREENVIO
);
$detalleWappush
->
setCreatedAt
(
new
\DateTime
());
$detalleWappush
->
setUpdatedAt
(
new
\DateTime
());
$em
->
persist
(
$detalleWappush
);
$em
->
flush
();
}
...
...
src/WsBundle/Controller/wsReceptorWapPush.php
0 → 100644
View file @
91518fbc
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
namespace
App\WsBundle\Controller
;
use
Symfony\Bundle\FrameworkBundle\Controller\AbstractController
;
use
Symfony\Component\HttpFoundation\Response
;
use
Symfony\Component\HttpFoundation\Request
;
use
Doctrine\ORM\EntityManagerInterface
;
use
App\Utilities\Utiles
;
use
App\Utilities\EntelWapush
;
use
App\Entity\PluEntelWapushMasive
;
use
App\Entity\PluEntelWapushMasiveDetalle
;
use
App\Entity\PluTipoWapush
;
use
App\Entity\PluSuscripcion
;
use
App\Entity\PluRegistroTxSuscripcion
;
use
App\Entity\PluRegistroTxDesinscripcion
;
use
App\Entity\PluRegistroTxCobro
;
/**
* Description of wsReceptorVPW
*
* @author Ing 04
*/
class
wsReceptorWapPush
extends
AbstractController
{
public
function
notificacionWapPush
(
Request
$request
)
:
Response
{
$log
=
Utiles
::
setLog
(
'WsBundle\Controller\wsReceptorWapPush::notificacionWapPush'
,
'ws/notificacionWapPush'
);
$tiempo_inicio
=
microtime
(
true
);
$em
=
$this
->
getDoctrine
()
->
getManager
(
'default'
);
$log
->
debug
(
'entrando...'
);
//Parametros de entrada
$xmlIN
=
$request
->
getContent
();
//Variables de Retorno
$status
=
200
;
$descripcion
=
'OK'
;
$response
=
new
Response
();
try
{
//Leer parametros
$log
->
debug
(
'Validando parametros de entrada...'
);
$parametros
=
$this
->
procesarXmlEntrada
(
$xmlIN
);
if
(
$parametros
[
'code'
]
==
''
||
!
is_numeric
(
$parametros
[
'transid'
])){
$logError
=
Utiles
::
setLog
(
'WsBundle\Controller\wsReceptorWapPush::notificacionWapPush'
,
'error/notificacionWapPush'
);
$logError
->
err
(
'Parametros invalidos... parametros:'
.
print_r
(
$xmlIN
,
true
));
$log
->
err
(
'Parametros invalidos... parametros:'
.
print_r
(
$parametros
,
true
));
throw
new
HttpException
(
Response
::
HTTP_BAD_REQUEST
,
"Parametros invalidos"
);
}
$log
->
debug
(
'Buscando registro PluEntelWapPush en base a transId=ewaId='
.
$parametros
[
'transid'
]);
$entelWapPush
=
$em
->
getRepository
(
PluEntelWapushMasive
::
class
)
->
findBy
(
array
(
"ewaCode"
=>
$parametros
[
'code'
],
"ewaEstado"
=>
PluEntelWapushMasive
::
ESTADO_OK_ENVIO
,
"ewaId"
=>
$parametros
[
'transId'
]));
if
(
$entelWapPush
==
null
){
$log
->
err
(
'Transaccion no exite en DB'
);
$logError
=
Utiles
::
setLog
(
'WsBundle\Controller\entel::notificacionWapPush'
,
'error/notificacionWapPush'
);
$logError
->
err
(
'Transaccion no exite en DB. xml:'
.
$xmlIN
);
throw
new
HttpException
(
Response
::
HTTP_BAD_REQUEST
,
"Parametros invalidos"
);
}
$ewaId
=
$entelWapPush
->
getEwaId
();
$entelWapPush
->
setEwaXmlNotificacion
(
$xmlIN
);
if
(
$parametros
[
'failurereason'
]
!=
''
){
$log
->
err
(
'Failurereason en notificacion! Se actualizan todos los detalle a estado error.'
);
$entelWapPush
->
setEwaEstado
(
PluEntelWapushmasive
::
ESTADO_NO_OK
);
//NOOK
$nbUpdatedRows
=
$em
->
getRepository
(
PluEntelWapushMasive
::
class
)
->
findBy
(
array
(
"ewaId"
=>
$ewaId
,
"ewdEstado"
=>
PluEntelWapushMasiveDetalle
::
ESTADO_OK_PREENVIO
));
$contador
=
0
;
foreach
(
$nbUpdatedRows
as
$index
=>
$nbUpdatedRow
)
:
$nbUpdatedRow
->
setEwdEstado
(
PluEntelWapushMasiveDetalle
::
ESTADO_NO_OK
);
//marcandola como error
$em
->
persist
(
$nbUpdatedRow
);
$contador
++
;
endforeach
;
$em
->
flush
();
$log
->
debug
(
'cantidad de registros actualizados:'
.
$contador
);
}
else
{
$entelWapPush
->
setEwaDispatched
(
$parametros
[
'dispatched'
]);
$entelWapPush
->
setEwaMobilerequested
(
$parametros
[
'mobilesrequested'
]);
$entelWapPush
->
setEwaMobilesonlist
(
$parametros
[
'mobilesonlist'
]);
$entelWapPush
->
setEwaEstado
(
PluEntelWapushMasive
::
ESTADO_OK_NOTIFICACION
);
//OK
$log
->
debug
(
'Actualizar todos msisdn con error...'
);
foreach
(
$parametros
[
'msisdns'
]
as
$array_msisdn
)
:
$entelWapPushDetalle
=
$em
->
getRepository
(
PluEntelWapushMasiveDetalle
::
class
)
->
findOneBy
(
array
(
"ewaId"
=>
$ewaId
,
"ewdMsisdn"
=>
$array_msisdn
[
'msisdn'
],
"ewdEstado"
=>
PluEntelWapushMasiveDetalle
::
ESTADO_OK_PREENVIO
));
if
(
$entelWapPushDetalle
){
$entelWapPushDetalle
->
setEwdEstado
(
PluEntelWapushMasiveDetalle
::
ESTADO_NO_OK
);
//error
$entelWapPushDetalle
->
setEwdResult
(
$array_msisdn
[
'result'
]);
$em
->
persist
(
$entelWapPushDetalle
);
$em
->
flush
();
}
endforeach
;
$log
->
debug
(
'Actualizar todos msisdn sin error...'
);
$nbUpdatedRows
=
$em
->
getRepository
(
PluEntelWapushMasive
::
class
)
->
findBy
(
array
(
"ewaId"
=>
$ewaId
,
"ewdEstado"
=>
PluEntelWapushMasiveDetalle
::
ESTADO_OK_PREENVIO
));
$contador
=
0
;
foreach
(
$nbUpdatedRows
as
$index
=>
$nbUpdatedRow
)
:
$nbUpdatedRow
->
setEwdEstado
(
PluEntelWapushMasiveDetalle
::
ESTADO_OK_ENVIO
);
//marcandola como error
$em
->
persist
(
$nbUpdatedRow
);
$contador
++
;
endforeach
;
$em
->
flush
();
$log
->
debug
(
'cantidad de registros actualizados:'
.
$contador
);
}
$em
->
persist
(
$entelWapPush
);
$em
->
flush
();
}
catch
(
HttpException
$e
){
$status
=
$e
->
getStatusCode
();
$descripcion
=
$e
->
getMessage
();
}
$response
->
setStatusCode
(
$status
,
$descripcion
);
$tiempo_fin
=
microtime
(
true
);
$log
->
debug
(
"Peticion Finalizada. status:"
.
$status
.
' | tiempo:'
.
round
(
$tiempo_fin
-
$tiempo_inicio
,
4
));
return
$response
;
}
private
function
procesarXmlEntrada
(
$xmlIN
)
{
$log
=
Utiles
::
setLog
(
"WsBundle\Controller\wsReceptorWapPush::procesarXmlEntrada"
,
'ws/notificacionWapPush'
);
$parametros
=
null
;
try
{
//Leer parametros
$log
->
debug
(
'obteniendo parametros desde xml entrada... xmlIN:'
.
$xmlIN
);
$xml
=
@
simplexml_load_string
(
$xmlIN
);
if
(
!
is_object
(
$xml
)){
$log
->
err
(
'Error al instanciar objeto xml. xmlIN:'
.
$xmlIN
);
}
else
{
$xml_parametros
=
$xml
->
xpath
(
'//mpushrequest'
);
if
(
$xml_parametros
!=
null
){
$parametros
=
array
();
$parametros
[
'code'
]
=
trim
((
string
)
$xml_parametros
[
0
]
->
attributes
()
->
code
);
$parametros
[
'transid'
]
=
trim
((
string
)
$xml_parametros
[
0
]
->
attributes
()
->
transid
);
$parametros
[
'mobilesonlist'
]
=
trim
((
string
)
$xml_parametros
[
0
]
->
attributes
()
->
mobilesonlist
);
$parametros
[
'mobilesrequested'
]
=
trim
((
string
)
$xml_parametros
[
0
]
->
attributes
()
->
mobilesrequested
);
$parametros
[
'dispatched'
]
=
trim
((
string
)
$xml_parametros
[
0
]
->
attributes
()
->
dispatched
);
$parametros
[
'failurereason'
]
=
trim
((
string
)
$xml_parametros
[
0
]
->
attributes
()
->
failurereason
);
$xml_msisdn
=
$xml
->
xpath
(
'//msisdn'
);
$arrayMsisdn
=
array
();
if
(
$xml_msisdn
!=
null
){
foreach
(
$xml_msisdn
as
$msisdn
){
$aux_msisdn
=
trim
((
string
)
$msisdn
);
$aux_result
=
trim
((
string
)
$msisdn
->
attributes
()
->
result
);
if
(
$aux_msisdn
!=
''
&&
$aux_result
!=
''
)
$arrayMsisdn
[]
=
array
(
'msisdn'
=>
$aux_msisdn
,
'result'
=>
$aux_result
);
}
}
$parametros
[
'msisdns'
]
=
$arrayMsisdn
;
}
}
}
catch
(
\Exception
$e
){
$log
->
debug
(
'error al leer parametros... Exception::'
.
$e
);
}
return
$parametros
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment