Add new rules for fraud
This commit is contained in:
parent
8ca1d602ce
commit
02848500ce
@ -169,7 +169,7 @@ class FraudCore
|
||||
$count_orders = Db::getInstance()->getRow('
|
||||
SELECT COUNT(*) AS `total`
|
||||
FROM `ps_orders`
|
||||
WHERE `id_customer` = '.(int) $this->customer->id.'
|
||||
WHERE `id_customer` = '.(int)$this->customer->id.'
|
||||
AND `date_add` >= DATE_SUB(NOW(), INTERVAL 7 DAY)
|
||||
');
|
||||
if($count_orders['total'] + 1 > 3) {
|
||||
@ -178,40 +178,47 @@ class FraudCore
|
||||
}
|
||||
|
||||
// Products and Total Paid
|
||||
$count_products = Db::getInstance()->getRow('
|
||||
SELECT COUNT(*) AS `total`
|
||||
FROM `ps_cart_product`
|
||||
WHERE `id_cart` = '.(int) $this->cart->id.'
|
||||
');
|
||||
$count_total_paid = $this->cart->getOrderTotal();
|
||||
|
||||
if($count_products['total'] > 7 && $count_total_paid > 250) {
|
||||
$this->fraud_score += 100;
|
||||
$this->fraud_report[] = 'Plus de 7 produits dans le panier et total de plus de 250€ (+100)';
|
||||
if ($count_total_paid > 250) {
|
||||
$count_products = Db::getInstance()->getRow('
|
||||
SELECT COUNT(*) AS `total`
|
||||
FROM `ps_cart_product`
|
||||
WHERE `id_cart` = '.(int)$this->cart->id.'
|
||||
');
|
||||
if ($count_products['total'] > 7) {
|
||||
$this->fraud_score += 100;
|
||||
$this->fraud_report[] = 'Plus de 7 produits dans le panier et total de plus de 250€ (+100)';
|
||||
}
|
||||
}
|
||||
|
||||
// Orders delivered and valid
|
||||
$count_delivered = Db::getInstance()->getValue('
|
||||
SELECT COUNT(*)
|
||||
FROM `'._DB_PREFIX_.'orders`
|
||||
WHERE `id_customer` = '.(int) $this->customer->id.'
|
||||
WHERE `id_customer` = '.(int)$this->customer->id.'
|
||||
AND `valid` = 1 AND `delivery_date` != 0
|
||||
');
|
||||
if ($count_delivered) {
|
||||
|
||||
if ($count_delivered > 10) {
|
||||
$this->fraud_score -= 100;
|
||||
$this->fraud_report[] = 'Compte avec plus de 10 commandes valides expédiées (-100)';
|
||||
}
|
||||
|
||||
// Old Orders
|
||||
$count_oldorders = Db::getInstance()->getValue('
|
||||
SELECT COUNT(*)
|
||||
FROM `'._DB_PREFIX_.'orders`
|
||||
WHERE `id_customer` = '.(int) $this->customer->id.'
|
||||
AND `valid` = 1
|
||||
AND `date_add` < DATE_SUB(NOW(), INTERVAL 30 DAY)
|
||||
');
|
||||
if($count_oldorders > 3) {
|
||||
$this->fraud_score -= 50;
|
||||
$this->fraud_report[] = 'Compte avec plus de 3 commandes valides de plus de 30 jours (-50)';
|
||||
elseif ($count_delivered > 5) {
|
||||
$this->fraud_score -= 50;
|
||||
$this->fraud_report[] = 'Compte avec plus de 5 commandes valides expédiées (-50)';
|
||||
}
|
||||
else {
|
||||
// Old Orders
|
||||
$count_oldorders = Db::getInstance()->getValue('
|
||||
SELECT COUNT(*)
|
||||
FROM `'._DB_PREFIX_.'orders`
|
||||
WHERE `id_customer` = '.(int)$this->customer->id.'
|
||||
AND `valid` = 1
|
||||
AND `date_add` < DATE_SUB(NOW(), INTERVAL 30 DAY)
|
||||
');
|
||||
if($count_oldorders > 3) {
|
||||
$this->fraud_score -= 50;
|
||||
$this->fraud_report[] = 'Compte avec plus de 3 commandes valides de plus de 30 jours (-50)';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user