Log des achats

This commit is contained in:
Claire DELBOS 2017-02-28 14:26:31 +01:00
parent fc52e79c7d
commit e7551303b8
3 changed files with 60 additions and 18 deletions

View File

@ -1,8 +1,9 @@
<?php
return array(
'Credit' => 'Credit',
'infoCredit' => 'InfoCredit',
// 'addCredit' => 'AddCredit',
// 'subCredit' => 'SubCredit',
// 'updateCredit' => 'UpdateCredit',
);
'GetCredit' => 'GetCredit',
'infoCredit' => 'infoCredit',
'PayCredit' => 'PayCredit',
'AddCredit' => 'AddCredit',
'SubCredit' => 'SubCredit',
'UpdateCredit' => 'UpdateCredit',
);

View File

@ -34,10 +34,11 @@ class Credit extends Scores_Ws_Server
$this->wsLog('credit', $idUser);
return $credit;
}
/**
* Retourne la totalite des infos de crédit à un utilisateur
* @return infoCredit
*/
*/
public function infoCredit()
{
$info=new infoCredit();
@ -71,6 +72,38 @@ class Credit extends Scores_Ws_Server
return $info;
}
/**
* Mettre à jour la table Credit_paid
* @param string ligneCredit
* @return PayCredit
*/
public function payCredit($ligneCredit='toto')
{
$PayCreditResult=new PayCredit();
$this->authenticate();
$PayCreditResult->ligneCredit=$ligneCredit;
$PayCreditResult->message='';
$ir=(array)json_decode($ligneCredit);
if(empty($ir) || !isset($ir['idCmd'])){
$PayCreditResult->message='Bad data format';
$PayCreditResult->result=false;
return $PayCreditResult;
}
$sql = "SELECT transaction FROM sdv1.credit__paid c
WHERE c.idCmd=:idCmd";
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('idCmd', $ir['idCmd']);
$stmt->execute();
if ($stmt->rowCount() > 0) {
$r = $this->conn->update('sdv1.credit__paid', $ir,'idCmd='.$ir['idCmd=']);
}else{
$r = $this->conn->insert('sdv1.credit__paid', $ir);
}
$PayCreditResult->result=true;
$this->wsLog('payCredit', $idUser);
return $PayCreditResult;
}
/**
* Ajoute des crédits supplémentaires à un utilisateur
* @param $nbCredit

View File

@ -3,6 +3,7 @@ class GetCredit
{
}
class infoCredit{
/**
* Etat actuel du compte
@ -20,19 +21,26 @@ class infoCredit{
*/
public $used;
}
class balance{
/**
* Date de creation
* @var date
*/
public $created;
/**
* Balance des credits
* @var int
*/
public $balance;
class PayCredit
{
/**
* Success or failed
* @var boolean
*/
public $result;
/**
* Message
* @var string
*/
public $message;
/**
* Params sent
* @var string
*/
public $ligneCredit;
}
class AddCredit
{