MAJ des méthodes pour le batch graydon
This commit is contained in:
parent
8f010c9f25
commit
fda2c77a52
@ -1,151 +1,191 @@
|
|||||||
|
#!/usr/bin/php -q
|
||||||
<?php
|
<?php
|
||||||
|
$version = '0.2';
|
||||||
|
$argc = $_SERVER['argc'];
|
||||||
|
$argv = $_SERVER['argv'];
|
||||||
|
|
||||||
|
//par défault, on active tout
|
||||||
|
if($argc == 1){
|
||||||
|
$checkCommandes = TRUE;
|
||||||
|
$matchidentifiers = TRUE;
|
||||||
|
$matchmethods = TRUE;
|
||||||
|
$checkCommandes = FALSE;
|
||||||
|
}else{
|
||||||
|
foreach($argv as $value){
|
||||||
|
switch($value){
|
||||||
|
case 'availability':
|
||||||
|
$availability = FALSE;
|
||||||
|
break;
|
||||||
|
case 'matchidentifiers':
|
||||||
|
$matchidentifiers = FALSE;
|
||||||
|
break;
|
||||||
|
case 'matchmethods':
|
||||||
|
$matchmethods = FALSE;
|
||||||
|
break;
|
||||||
|
case 'commandes':
|
||||||
|
$checkCommandes = FALSE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
print $argv[0]." version : ".$version."\n\n";
|
||||||
|
print "Lancer le script ".$argv[0]." sans paramètres permet de charger toutes les méthodes graydon et vérifier les commandes\n\n";
|
||||||
|
print "Les services disponibles sont :\n";
|
||||||
|
print "\t-Disponibilité des pays graydon (availability).\n";
|
||||||
|
print "\t-Types d'identifiant disponible par pays (matchidentifiers).\n";
|
||||||
|
print "\t-Méthodes de recherche (matchmethods).\n";
|
||||||
|
print "\t-Vérification des commandes (commandes).\n";
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
require_once '../config/prepend.php';
|
require_once '../config/prepend.php';
|
||||||
//Inclure la base de données
|
//Inclure la base de données
|
||||||
require_once 'dbbootstrap.php';
|
require_once 'dbbootstrap.php';
|
||||||
//Inclure la config graydon
|
//Inclure la config graydon
|
||||||
require_once 'graydon/graydonws.php';
|
require_once 'graydon/graydonws.php';
|
||||||
|
|
||||||
//Country Availability
|
setDbConn('graydon');
|
||||||
$request = new StdClass();
|
|
||||||
$request->Authentication_Parameters = $authentication;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
$result = $graydon->getCountryAvailability($request);
|
|
||||||
//Enregistrement de l'action dans les logs
|
|
||||||
$transactionIdentifier = $result->Service_Log->TransactionIdentifier;
|
|
||||||
$sessionID = $result->Service_Log->SessionID;
|
|
||||||
graydonRequeteLog('batch', 'batch', 'getCompanyMatchIdentifiers', $transactionIdentifier, $sessionID);
|
|
||||||
foreach($result->CountryAvailablity->CountryAndProduct as $item){
|
|
||||||
//Enregistrement pour chaque pays de la disponibilité des services
|
|
||||||
$countryavailability = new Countryavailability();
|
|
||||||
$countryavailability->country = $item->Country;
|
|
||||||
$count = count($item->Products->Product);
|
|
||||||
if ($count>1){
|
|
||||||
$availability = $item->Products->Product;
|
|
||||||
}elseif($count==1){
|
|
||||||
$availability[] = $item->Products->Product;
|
|
||||||
}
|
|
||||||
$countryavailability->availability = serialize($availability);
|
|
||||||
$countryavailability->replace();
|
|
||||||
}
|
|
||||||
}catch( SoapFault $fault ){
|
|
||||||
|
|
||||||
}
|
if($availability == TRUE){
|
||||||
|
//Country Availability
|
||||||
//matchidentifiers
|
$request = new StdClass();
|
||||||
$request = new StdClass();
|
$request->Authentication_Parameters = $authentication;
|
||||||
$request->Authentication_Parameters = $authentication;
|
try
|
||||||
try
|
{
|
||||||
{
|
$result = $graydon->getCountryAvailability($request);
|
||||||
$result = $graydon->getCompanyMatchIdentifiers($request);
|
//Enregistrement de l'action dans les logs
|
||||||
//Enregistrement de l'action dans les logs
|
$transactionIdentifier = $result->Service_Log->TransactionIdentifier;
|
||||||
$transactionIdentifier = $result->Service_Log->TransactionIdentifier;
|
$sessionID = $result->Service_Log->SessionID;
|
||||||
$sessionID = $result->Service_Log->SessionID;
|
foreach($result->CountryAvailablity->CountryAndProduct as $item){
|
||||||
graydonRequeteLog('batch', 'batch', 'getCompanyMatchIdentifiers', $transactionIdentifier, $sessionID);
|
$availability = array();
|
||||||
|
$count = count($item->Products->Product);
|
||||||
foreach($result->CompanyMatchIdentifiers->CompanyMatchIdentifier as $item){
|
if ($count>1){
|
||||||
$count = count($item->CompanyIdentifier);
|
$availability = $item->Products->Product;
|
||||||
if ($count>1){
|
}elseif($count==1){
|
||||||
$tabIdentifiers = $item->CompanyIdentifier;
|
$availability[] = $item->Products->Product;
|
||||||
}elseif($count==1){
|
|
||||||
$tabIdentifiers[] = $item->CompanyIdentifier;
|
|
||||||
}
|
|
||||||
//Stockage du résultat de la méthode en cache
|
|
||||||
$matchidentifiers = new Matchidentifiers();
|
|
||||||
$matchidentifiers->country = $item->Country;
|
|
||||||
$matchidentifiers->identifiers = serialize($tabIdentifiers);
|
|
||||||
$matchidentifiers->replace();
|
|
||||||
}
|
|
||||||
}catch( SoapFault $fault ){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//matchmethods
|
|
||||||
$request = new StdClass();
|
|
||||||
$request->Authentication_Parameters = $authentication;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
$result = $graydon->getCompanyMatchMethods($request);
|
|
||||||
$transactionIdentifier = $result->Service_Log->TransactionIdentifier;
|
|
||||||
$sessionID = $result->Service_Log->SessionID;
|
|
||||||
graydonRequeteLog('batch', 'batch', 'getCompanyMatchMethods', $transactionIdentifier, $sessionID);
|
|
||||||
|
|
||||||
foreach($result->CompanyMatchMethods->CompanyMatchMethod as $item){
|
|
||||||
$count = count($item->MatchMethods->MatchMethod);
|
|
||||||
//Stockage du résultat de la méthode en cache
|
|
||||||
$matchmethods = new Matchmethods();
|
|
||||||
$matchmethods->country = $item->Country;
|
|
||||||
if ($count>1){
|
|
||||||
$methods = $item->MatchMethods->MatchMethod;
|
|
||||||
}elseif($count==1){
|
|
||||||
$methods[] = $item->MatchMethods->MatchMethod;
|
|
||||||
}
|
|
||||||
$matchmethods->methods = serialize($methods);
|
|
||||||
$matchmethods->replace();
|
|
||||||
}
|
|
||||||
|
|
||||||
}catch( SoapFault $fault ){
|
|
||||||
$code = $fault->detail->GraydonCompanyData_Fault->FaultReturnCode;
|
|
||||||
$text = $fault->detail->GraydonCompanyData_Fault->FaultMessage;
|
|
||||||
$firephp->log($text,'texterror');
|
|
||||||
require_once 'graydon/error.php';
|
|
||||||
if(graydon_error($code, $text)!=FALSE){
|
|
||||||
if($code=='CWS0112'){
|
|
||||||
//Stockage du résultat de la méthode en cache
|
|
||||||
$matchmethods = new Matchmethods();
|
|
||||||
$matchmethods->country = $pays;
|
|
||||||
$matchmethods->methods = serialize('false');
|
|
||||||
$matchmethods->replace();
|
|
||||||
}
|
}
|
||||||
}else{
|
//Enregistrement pour chaque pays de la disponibilité des services
|
||||||
graydon_processSoapFault($graydon,$fault,'');
|
$countryavailability = new Countryavailability();
|
||||||
|
$countryavailability->country = $item->Country;
|
||||||
|
$countryavailability->availability = serialize($availability);
|
||||||
|
$countryavailability->replace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}catch( SoapFault $fault ){}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Vérification des commandes
|
if($matchidentifiers == TRUE){
|
||||||
$q = Doctrine_Query::create()
|
//matchidentifiers
|
||||||
->select('*')
|
$request = new StdClass();
|
||||||
->from('Commandes');
|
$request->Authentication_Parameters = $authentication;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$result = $graydon->getCompanyMatchIdentifiers($request);
|
||||||
|
//Enregistrement de l'action dans les logs
|
||||||
|
$transactionIdentifier = $result->Service_Log->TransactionIdentifier;
|
||||||
|
$sessionID = $result->Service_Log->SessionID;
|
||||||
|
|
||||||
$tabCommandes = $q->Execute();
|
foreach($result->CompanyMatchIdentifiers->CompanyMatchIdentifier as $item){
|
||||||
|
$tabIdentifiers = array();
|
||||||
|
$count = count($item->CompanyIdentifier);
|
||||||
|
if ($count>1){
|
||||||
|
$tabIdentifiers = $item->CompanyIdentifier;
|
||||||
|
}elseif($count==1){
|
||||||
|
$tabIdentifiers[] = $item->CompanyIdentifier;
|
||||||
|
}
|
||||||
|
//Stockage du résultat de la méthode en cache
|
||||||
|
$matchidentifiers = new Matchidentifiers();
|
||||||
|
$matchidentifiers->country = $item->Country;
|
||||||
|
$matchidentifiers->identifiers = serialize($tabIdentifiers);
|
||||||
|
$matchidentifiers->replace();
|
||||||
|
}
|
||||||
|
}catch( SoapFault $fault ){}
|
||||||
|
}
|
||||||
|
|
||||||
//Pour chaque commande ('Completed','Assigned','InError','Initialised','Delivered','Notified','ReCompleted')
|
if($matchmethods == TRUE){
|
||||||
foreach($tabCommandes as $commande){
|
//matchmethods
|
||||||
|
$request = new StdClass();
|
||||||
|
$request->Authentication_Parameters = $authentication;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$result = $graydon->getCompanyMatchMethods($request);
|
||||||
|
$transactionIdentifier = $result->Service_Log->TransactionIdentifier;
|
||||||
|
$sessionID = $result->Service_Log->SessionID;
|
||||||
|
|
||||||
//Si servicespeed = immediate alors on ne gère pas
|
foreach($result->CompanyMatchMethods->CompanyMatchMethod as $item){
|
||||||
if($commande->servicespeed != 'Immediate'){
|
$methods = array();
|
||||||
switch($commande->orderstate){
|
$count = count($item->MatchMethods->MatchMethod);
|
||||||
case 'Delivered': //Délivré, on a été la chercher
|
if ($count>1){
|
||||||
//On ne fait rien
|
$methods = $item->MatchMethods->MatchMethod;
|
||||||
break;
|
}elseif($count==1){
|
||||||
|
$methods[] = $item->MatchMethods->MatchMethod;
|
||||||
|
}
|
||||||
|
//Stockage du résultat de la méthode en cache
|
||||||
|
$matchmethods = new Matchmethods();
|
||||||
|
$matchmethods->country = $item->Country;
|
||||||
|
$matchmethods->methods = serialize($methods);
|
||||||
|
$matchmethods->replace();
|
||||||
|
}
|
||||||
|
|
||||||
case 'Completed': //Commande prête à télécharger
|
}catch( SoapFault $fault ){
|
||||||
|
$code = $fault->detail->GraydonCompanyData_Fault->FaultReturnCode;
|
||||||
|
$text = $fault->detail->GraydonCompanyData_Fault->FaultMessage;
|
||||||
|
$firephp->log($text,'texterror');
|
||||||
|
require_once 'graydon/error.php';
|
||||||
|
if(graydon_error($code, $text)!=FALSE){
|
||||||
|
if($code=='CWS0112'){
|
||||||
|
//Stockage du résultat de la méthode en cache
|
||||||
|
$matchmethods = new Matchmethods();
|
||||||
|
$matchmethods->country = $pays;
|
||||||
|
$matchmethods->methods = serialize('false');
|
||||||
|
$matchmethods->replace();
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
graydon_processSoapFault($graydon,$fault,'');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
if($checkCommandes == TRUE){
|
||||||
|
//Vérification des commandes
|
||||||
|
$q = Doctrine_Query::create()
|
||||||
|
->select('*')
|
||||||
|
->from('Commandes');
|
||||||
|
$tabCommandes = $q->Execute();
|
||||||
|
//Pour chaque commande ('Completed','Assigned','InError','Initialised','Delivered','Notified','ReCompleted')
|
||||||
|
foreach($tabCommandes as $commande){
|
||||||
|
//Si servicespeed = immediate alors on ne gère pas
|
||||||
|
if($commande->servicespeed != 'Immediate'){
|
||||||
|
switch($commande->orderstate){
|
||||||
|
case 'Delivered': //Délivré, on a été la chercher
|
||||||
|
//On ne fait rien
|
||||||
|
break;
|
||||||
|
case 'Completed': //Commande prête à télécharger
|
||||||
|
|
||||||
case 'InError': //Problème dans la commande
|
break;
|
||||||
|
|
||||||
break;
|
case 'InError': //Problème dans la commande
|
||||||
|
|
||||||
case 'Notified':
|
break;
|
||||||
|
|
||||||
break;
|
case 'Notified':
|
||||||
|
|
||||||
case 'Initialised': //Commande prise en compte
|
break;
|
||||||
case 'Assigned': //Assigné chez graydon
|
|
||||||
case ''; // Pas d'état, commande pas encore vérifier
|
|
||||||
case 'default':
|
|
||||||
|
|
||||||
|
case 'Initialised': //Commande prise en compte
|
||||||
|
case 'Assigned': //Assigné chez graydon
|
||||||
|
case '': // Pas d'état, commande pas encore vérifier
|
||||||
|
case 'default':
|
||||||
|
$q = Doctrine_Query::create()
|
||||||
|
->update('Commandes')
|
||||||
|
->set('orderstate', $orderstate)
|
||||||
|
->where('reference = ?', array($commande->reference));
|
||||||
|
|
||||||
$q = Doctrine_Query::create()
|
$q->execute();
|
||||||
->update('Commandes')
|
|
||||||
->set('orderstate', $orderstate)
|
|
||||||
->where('reference = ?', array($commande->reference));
|
|
||||||
|
|
||||||
$q->execute();
|
break;
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user