Stabilisation du cache extranet

This commit is contained in:
Claire DELBOS 2017-03-17 17:23:53 +01:00
parent 12dcdf4f57
commit a6352a7c97
8 changed files with 166 additions and 30 deletions

View File

@ -39,7 +39,7 @@ class Metier_Credit_Decrement extends Scores_Ws_Server
$canUseResult->typecredit=$this->rateType;
return $canUseResult;
}
public function setUsed($idLog,$user){
public function setUsed($idLog,$user,$siret='0'){
if(!isset($this->rateType)){
$this->getRateType($user,$idLog);
}
@ -48,8 +48,10 @@ class Metier_Credit_Decrement extends Scores_Ws_Server
'idLog' => $idLog,
'login' => $user->login,
'consumption' => $this->logCost,
'siret' => $siret,
'created' => Date('Y-m-d H:i:s'),
);
$this->logger->info(implode("##",$declog));
$res=$this->conn->insert('sdv1.credit__consumption',$declog);
switch($this->rateType){
case 1:
@ -60,7 +62,7 @@ class Metier_Credit_Decrement extends Scores_Ws_Server
break;
}
//$newbalance=
$this->logger->info(var_export($res,true));
$this->logger->info(implode("##",$declog));
return true;
return $this->logCost.'--->'.$this->rateType;
}
@ -115,7 +117,7 @@ class Metier_Credit_Decrement extends Scores_Ws_Server
$ratedLog = $stmt->fetch(\PDO::FETCH_OBJ);
$this->rateType=$ratedLog->rateType;
$this->logCost=$ratedLog->cost;
$this->logger->info(__LINE__ . 'getRateType OK');
$this->logger->info(__LINE__ . 'getRateType OK'.$idLog.'-'.$user->idClient);
}else{
$this->rateType=0;
$this->logCost=0;
@ -144,7 +146,6 @@ class Metier_Credit_Decrement extends Scores_Ws_Server
WHERE idUser = :idUser group by idUser" ;
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('idUser', $user->id);
$this->logger->info($user->serviceCode);
$stmt->execute();
if ($stmt->rowCount() == 1) {
$ratedLog = $stmt->fetch(\PDO::FETCH_OBJ);
@ -159,7 +160,6 @@ class Metier_Credit_Decrement extends Scores_Ws_Server
WHERE idClient = :idClient and idLog= :idLog group by idClient,idLog" ;
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('idUser', $user->id);
$this->logger->info($user->serviceCode);
$stmt->execute();
if ($stmt->rowCount() == 1) {
$ratedLog = $stmt->fetch(\PDO::FETCH_OBJ);

View File

@ -0,0 +1,107 @@
<?php
/**
* PDO Connection with Doctrine
* @var \Doctrine\DBAL\Connection
*/
class Metier_Credit_Information extends Scores_Ws_Server
{
/**
* PDO Connection with Doctrine
* @var \Doctrine\DBAL\Connection
*/
protected $conn;
/**
* Libelle des fonctions ws sous credit
* @var array
*/
public $libelles=array(
'getIdentite' => 'Fiche d\'identité',
'getIdentiteProcol' => 'Fiche procédure collective',
'getListeEtablissements' => 'Liste des établissements',
'getLiens' => 'Liens inter-entreprises',
'getGroupeInfos' => 'Informations Groupe',
'getListeEvenements' => 'Modifications Insee',
'getDirigeants' => 'Liste ou Historique des dirigeants',
'getSynthese' => 'Synthèse financière',
'getBilan' => 'Bilan Compte de résultat',
'getRatios' => 'Ratios financiers',
'getFlux' => 'Flux de trésorerie',
'getListeBilans' => 'Liasse fiscale',
'getInfosBourse' => 'Bourse et Cotations',
'getBanques' => 'Relations bancaires',
'getSubventionList' => 'Subventions',
'getAnnoncesLegales' => 'Annonces légales',
'getAnnoncesBalo' => 'Annonces BALO',
'getAnnoncesBoamp' => 'Annonces BOAMP',
'getListeCompetences' => 'Rubrique de Compétences territoriales',
'getAnnoncesAsso' => 'Annonces JO Associations',
'getListeConventions' => 'Conventions collectives',
'getMarques' => 'Marques déposées',
'getIndiScore' => 'Indiscore',
'getIndiScore2' => 'Rapport de synthèse',
'getRapport' => 'Rapport complet',
'getValo' => 'Valorisation',
);
/**
* tranches autorisées pour les crédits
* @var array
*/
private $tranches=array(
'1' => array(
'200' => array('montant' => 2000,'montantht' => 1667, 'tva' => 333, ),
'500' => array('montant' => 5000,'montantht' => 4167, 'tva' => 833, ),
'1000' => array('montant' => 10000,'montantht' => 8333, 'tva' => 1667, ),
),
'195' => array(
'200' => array('montant' => 2000,'montantht' => 1667, 'tva' => 333, ),
'500' => array('montant' => 5000,'montantht' => 4167, 'tva' => 833, ),
'1000' => array('montant' => 10000,'montantht' => 8333, 'tva' => 1667, ),
),
);
public function __construct($db = null)
{
// Set Database
if ($this->conn === null) {
$this->conn = Zend_Registry::get('doctrine');
} else {
$this->conn = $conn;
}
if (Zend_Registry::isRegistered('logger')) {
$this->logger = Zend_Registry::get('logger');
}
}
/**
* Recuperation des informations necessaires a la facturation
* @param string $idCmd
*/
public function getInfosFacture($idCmd){
$sql='select c.*, u.idClient, u.siret
from sdv1.credit__paid c inner join utilisateurs u on c.idUser=u.id
where idCmd= :idCmd;';
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('idCmd', $idCmd);
$stmt->execute();
if ($stmt->rowCount() == 1) {
$infos['commande']=$stmt->fetch(PDO::FETCH_ASSOC);
}
$siren=$infos['commande']['siret'];
try {
$stmt = $this->conn->prepare('SELECT * FROM insee.identite WHERE SIREN=:siren and nic="00072"');
$stmt->bindValue('siren', $siren);
$stmt->execute();
$infos['societe']=$stmt->fetch(\PDO::FETCH_ASSOC);
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
return $infos;
}
}

View File

@ -385,15 +385,15 @@ class Scores_Ws_Server
$this->conn->insert('sdv1.logs', $dataInsert);
} catch (\Doctrine\DBAL\DBALException $e) {
}
$this->decLog($this->idLog);
$this->decLog($this->idLog,$siret);
}
protected function decLog($idLog=null){
protected function decLog($idLog=null,$siret='0'){
if($this->idMainLog=='getRapport' && $this->idLog!=$this->idMainLog){
return true;
}
$this->idLog=$idLog;
$crdt=new Metier_Credit_Decrement();
$ok=$crdt->setUsed($this->idLog,$this->User);
$ok=$crdt->setUsed($this->idLog,$this->User,$siret);
return $ok;
}
/**
@ -486,7 +486,7 @@ class Scores_Ws_Server
){
$this->idMainLog=$idLog;
}
if(empty($idLog)){$idLog=$this->getIdLog();}
//if(empty($idLog)){$idLog=$this->getIdLog();}
//@todo:retirer la securite apres verif
if(!empty($idLog)){
$this->idLog=$idLog;

View File

@ -84,8 +84,9 @@ class Credit extends Scores_Ws_Server
$stmt->bindValue('idClient', $this->User->idClient);
$stmt->execute();
$info->used=$stmt->fetchAll(\PDO::FETCH_ASSOC);
$this->wsLog(__FUNCTION__,$idUser,'0');
$crdt=new Metier_Credit_Information();
$info->libelle=$crdt->libelles;
//$this->wsLog(__FUNCTION__,$idUser,'0');
return $info;
}
@ -183,11 +184,14 @@ class Credit extends Scores_Ws_Server
$UseCreditResult->idLog=$idLog;
$this->authenticate();
$idUser = $this->User->id;
$this->logger->info('idUser : '.$this->User->id.'idLog : '.$idLog);
//$this->permission($this->libdroits);
$this->decLog($idLog);
$crdt=new Metier_Credit_Decrement();
$ok=$crdt->canUse($idLog,$this->User);
if(!$ok->result){
$UseCreditResult->result=false;
}else{
$ok=$crdt->setUsed($idLog,$this->User,'extranet');
$UseCreditResult->result=true;
}
return $UseCreditResult;
}

View File

@ -20,7 +20,12 @@ class InfoCredit{
* @var array
*/
public $used;
}
/**
* Les libelles des codes fonction
* @var array
*/
public $libelle;
}
class PayCredit
{

View File

@ -13,7 +13,12 @@ class Entreprise extends Scores_Ws_Server
public function getIdentite($siret, $id = 0)
{
$this->authenticate();
$this->permission('identite', __FUNCTION__);
if(isset($this->freeservice) && $this->freeservice){
$idLog='freeservice';
}else{
$idLog= __FUNCTION__ ;
}
$this->permission('identite', $idLog);
//Initialisation
if (empty($id)) { $id = 0; }
@ -660,7 +665,12 @@ class Entreprise extends Scores_Ws_Server
public function getLiens($siren, $actifsUniquement = true)
{
$this->authenticate();
$this->permission('liens',__FUNCTION__);
if(isset($this->freeservice) && $this->freeservice){
$idLog='freeservice';
}else{
$idLog= __FUNCTION__ ;
}
$this->permission('liens',$idLog);
// Initialisation
if (empty($actifsUniquement)) { $actifsUniquement = true; }
@ -807,7 +817,12 @@ class Entreprise extends Scores_Ws_Server
public function getDirigeants( $siren , $histo = false)
{
$this->authenticate();
$this->permission('dirigeants',__FUNCTION__);
if(isset($this->freeservice) && $this->freeservice){
$idLog='freeservice';
}else{
$idLog= __FUNCTION__ ;
}
$this->permission('dirigeants',$idLog);
//Initialisation
if (empty($histo)) { $histo = false; }
@ -864,7 +879,12 @@ class Entreprise extends Scores_Ws_Server
public function getAnnonces($siren, $filtre = 1, $idAnn = '', $position = 0, $nbRep = 100)
{
$this->authenticate();
$this->permission('annonces',__FUNCTION__);
if(isset($this->freeservice) && $this->freeservice){
$idLog='freeservice';
}else{
$idLog= __FUNCTION__ ;
}
$this->permission('annonces',$idLog);
//Initialisation
if (empty($filtre)) { $filtre = 1; }
@ -3779,7 +3799,7 @@ class Entreprise extends Scores_Ws_Server
if ($perm === false) {
$this->sendError('0902');
}
$this->freeservice=true;
$accesDist=true;
$nivComment=2;
if ($niveau==1){
@ -3798,6 +3818,7 @@ class Entreprise extends Scores_Ws_Server
$result->Ratios = $this->getRatios($siren, $page="rapport$niveau");
$result->Annonces = $this->getAnnonces($siren, $filtre, $idAnn);
}
$this->freeservice=false;
return $result;
}

View File

@ -2499,7 +2499,7 @@ class Entreprise extends Scores_Ws_Server
{
$this->authenticate();
$this->permission('VALORISATION',__FUNCTION__);
$this->checkCredit(__FUNCTION__);
//Initialisation
$accesPartenaire = true;
if (APPLICATION_ENV == 'development') {
@ -4858,7 +4858,6 @@ class Entreprise extends Scores_Ws_Server
public function getRapport($siren, $niveau=3, $id=0, $plus=false, $ref='', $encours=0, $email='')
{
$this->authenticate();
$this->checkCredit(__FUNCTION__.'cd');
if (empty($niveau)) $niveau = 3;
if (empty($id)) $id = 0;
$result = new Rapport();
@ -4881,7 +4880,7 @@ class Entreprise extends Scores_Ws_Server
if ($perm === false) {
$this->sendError('0902');
}
$this->checkCredit(__FUNCTION__);
$accesDist=true;
$nivComment=2;
if ($niveau==1){

View File

@ -2102,7 +2102,7 @@ class Interne extends Scores_Ws_Server
public function getGroupeInfos($siren)
{
$this->authenticate();
$this->checkCredit(__FUNCTION__);
if ( strlen($siren)!=9 || intval($siren)<100 ){
$this->logger->warning( "Siren $siren incorrect");
$this->sendError('1010');