====== Liste et description des requêtes SQL les plus utilisés pour la Fidélité ======
Le but de cette documentation est de lister puis de commenter les différentes requêtes SQL qui sont les plus utilisés pour la fidélité.\\
__**NB :**__ //Ci-dessous, la légende sur les différents statut fidélité (statut_fidelite) depuis Cynod//
- **NP** -> Non pris en compte
- **AP** -> A prendre en compte
- **PE** -> Pris en compte
- **AA** -> A annuler
- **AN** -> Annulé
-- Les opérations non remontées pour une carte donnée (CYNOD)
select c.*, h.motif, h.date_traitement_fidelite,h.ind_fidelite, h.numero_fidelite,h.montant_paye,
h.date_transaction,h.statut,h.numero_carte_fidelite,h.statut_fidelite, h.montant_transaction, h.total_point_fidelite, h.deleted, h.numero_operation from operation h, carte c where
h.carte_emettrice_id = c.id
and h.deleted=false
and c.num_carte="5812340101021233"
and h.statut_fidelite ="AP"
and h.statut='VA'
and h.statut_confirmation="CF"
UNION ALL
select c.*, h.motif, h.date_traitement_fidelite,h.ind_fidelite, h.numero_fidelite,h.montant_paye, h.date_transaction,h.statut,h.numero_carte_fidelite,h.statut_fidelite, h.montant_transaction, h.total_point_fidelite, h.deleted, h.numero_operation from historique_operation h, carte c where
h.carte_emettrice_id = c.id
and h.deleted=false
and c.num_carte="5812340101021233"
and h.statut_fidelite ="AP"
and h.statut='VA'
and h.statut_confirmation="CF";
-- Mise à jour opération simple vers la Fidélité (CYNOD)
update operation
inner join carte on operation.carte_emettrice_id = carte.id
set statut_fidelite="AP", numero_carte_fidelite = "5812340100014890"
where carte.num_carte="5812340100014890" and
operation.statut_fidelite ="AP" and operation.statut='VA'
and operation.statut_confirmation="CF";
-- Mise à zéro des compteurs points des clients Fidélia (FIDELIA)
Update
campagne_participant
SET
nombre_total_point = 0,
version = version + 1,
user_updated = "support_sensoft",
last_updated = NOW
WHERE
nombre_total_point > 0
and campagne_id = 2
and is_deleted = FALSE;
-- Vérification des opérations effectuées avec le bagde - Exemple 1 (FIDELIA)
select nombre_total_point,numero_carte,numero_code_bar,numero_fidelite,telephone,prenom,nom from
campagne_participant where numero_fidelite="3366710213" and numero_code_bar="10017440";
-- Vérification des opérations effectuées avec le bagde - Exemple 2 (FIDELIA)
select pc.date_collecte,pc.nombre_point,pc.reference_externe,pc.numero_transaction_externe,pc.valeur_achat,
cp.telephone,cp.numero_code_bar,cp.nom,cp.prenom
from point_collecte pc, campagne_participant cp
where pc.campagne_participant_id=cp.id
and cp.numero_fidelite="3366710213"
and cp.numero_code_bar="10017440"
and cp.telephone="+221776176210"
order by pc.date_collecte desc;
-- Vérification des points fidélité avec bagde (FIDELIA)
select sum(pc.nombre_point)
from point_collecte pc, campagne_participant cp
where pc.campagne_participant_id=cp.id
and cp.numero_fidelite="3366710213"
and cp.numero_code_bar="10017440"
order by pc.date_collecte desc;
-- Vérification de l'ensemble des points collecté avec un compte badge (FIDELIA)
select pc.date_collecte,pc.nombre_point,pc.reference_externe,pc.numero_transaction_externe,pc.valeur_achat,
cp.telephone,cp.numero_code_bar,cp.nom,cp.prenom
from point_collecte pc, campagne_participant cp
where pc.campagne_participant_id=cp.id
and cp.numero_fidelite="3366710213"
and cp.numero_code_bar="10017440"
and cp.telephone="+221776176210"
order by pc.date_collecte desc;