Skip to content

Commit

Permalink
Ajout du nouveau service MYACCOUNT
Browse files Browse the repository at this point in the history
  • Loading branch information
mattgu74 committed Oct 2, 2013
1 parent 8c0772a commit 4f0bd59
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 2 deletions.
39 changes: 39 additions & 0 deletions src/Payutc/Bom/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,45 @@ public function setMsgPerso($msgPerso, $funID) {
MsgPerso::setMsgPerso($msgPerso, $this->idUser, $funID);
}

/**
* Fonction pour récupérer l'historique de l'utilisateur
*
* @return array
*/
public function getHistorique() {
$conn = Dbal::conn();
$query = $conn->executeQuery('
SELECT pur.pur_date AS date, pur.pur_price AS amount, "PURCHASE" AS
type, obj.obj_name as name, fun.fun_name as fun, NULL as firstname, NULL as lastname
FROM t_purchase_pur pur, t_object_obj obj, t_fundation_fun fun, t_application_app app
WHERE
pur.usr_id_buyer = ?
AND pur.obj_id = obj.obj_id
AND pur.fun_id = fun.fun_id
UNION
SELECT rec.rec_date AS date, rec.rec_credit AS amount, "RECHARGE" AS
type, NULL as name, NULL as fun, NULL as firstname, NULL as lastname
FROM t_recharge_rec rec
WHERE
rec.usr_id_buyer = ?
UNION
SELECT virin.vir_date AS date, virin.vir_amount AS amount, "VIRIN" AS
type, virin.vir_message as name, NULL as fun, usrfrom.usr_firstname as firstname, usrfrom.usr_lastname as lastname
FROM t_virement_vir virin, ts_user_usr usrfrom
WHERE
virin.usr_id_to = ?
AND virin.usr_id_from = usrfrom.usr_id
UNION
SELECT virout.vir_date AS date, virout.vir_amount AS amount, "VIROUT" AS
type, virout.vir_message as name, NULL as fun, usrto.usr_firstname as firstname, usrto.usr_lastname as lastname
FROM t_virement_vir virout, ts_user_usr usrto
WHERE
virout.usr_id_from = ?
AND virout.usr_id_to = usrto.usr_id
ORDER BY `date` DESC', array($this->getId(), $this->getId(), $this->getId(), $this->getId()));
return $query->fetchAll();
}

/**
* Fonction pour se bloquer soi même (en cas de perte/vol par exemple)
*
Expand Down
3 changes: 2 additions & 1 deletion src/Payutc/Mapping/Services.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ class Services {
'BLOCKED',
'GESARTICLE',
'PAYLINE',
'RELOAD'
'RELOAD',
'MYACCOUNT'
);

public static function get($name) {
Expand Down
8 changes: 7 additions & 1 deletion src/Payutc/Service/ADMINRIGHT.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,13 @@ public function getServices() {
), array(
"service" => "RELOAD",
"name" => "Rechargement",
"desc" => "Permettre le rechargement des utilisateurs",
"desc" => "Permet le rechargement des utilisateurs",
"user" => false,
"app" => false
), array(
"service" => "MYACCOUNT",
"name" => "Gestion de mon compte",
"desc" => "Permet de consulter un historique, et de bloquer/débloquer sa carte",
"user" => false,
"app" => false
)
Expand Down
73 changes: 73 additions & 0 deletions src/Payutc/Service/MYACCOUNT.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php

namespace Payutc\Service;

/**
* MYACCOUNT.php
*
* Ce service permet la gestion du compte d'un utilisateur
* (Visualisation de l'historique, Blocage/Déblocage de sa carte)
*/

class MYACCOUNT extends \ServiceBase {

public function __construct() {
parent::__construct();
}

/**
* Recupere l'historique d'un utilisateur (+ son solde pour éviter une requete a casper)
* @return array historique de l'utilisateur (+ son solde)
*/
public function historique() {
// On a une appli qui a les droits ?
$this->checkRight(false, true, true, null);
// On a un user ?
if(!$this->user()) {
throw new \Payutc\Exception\CheckRightException("Vous devez connecter un utilisateur ! (method loginCas)");
}

// Verification de rechargement en cours (utile surout quand les notifications ne marchent pas (genre en dev))
$pl = new \Payutc\Bom\Payline($this->application()->getId(), $this->service_name);
$pl->checkUser($this->user());

return array(
"historique" => $this->user()->getHistorique(),
"credit" => $this->user()->getCredit());
}

/**
* Definit le blocage de la carte de l'utilisateur (par lui même, en cas de perte par exemple)
* @param int (0/1)
*/
public function setSelfBlock($blocage) {
// On a une appli qui a les droits ?
$this->checkRight(false, true, true, null);
// On a un user ?
if(!$this->user()) {
throw new \Payutc\Exception\CheckRightException("Vous devez connecter un utilisateur ! (method loginCas)");
}

$this->user()->setSelfBlock($blocage);

return $this->isBlockedMe();
}

/**
* Self-blocked ?
*
* @return isBlocked ?
*/
public function isBlockedMe() {
// On a une appli qui a les droits ?
$this->checkRight(false, true, true, null);
// On a un user ?
if(!$this->user()) {
throw new \Payutc\Exception\CheckRightException("Vous devez connecter un utilisateur ! (method loginCas)");
}

return $this->user()->isBlockedMe();
}


}

0 comments on commit 4f0bd59

Please sign in to comment.