feat: add gamification endpoints for driver behavior

This commit is contained in:
Hamza-Ayed
2026-05-08 06:06:33 +03:00
parent 975527f1d0
commit 5928695212
5 changed files with 181 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
<?php
require_once __DIR__ . '/../../connect.php';
$driver_id = filterRequest("driver_id");
// Driver invites count
$sqlDriver = "SELECT COUNT(*) as total FROM invites WHERE driverId = :driver_id AND isInstall = 1";
$stmtD = $con->prepare($sqlDriver);
$stmtD->bindParam(':driver_id', $driver_id, PDO::PARAM_INT);
$stmtD->execute();
$driverCount = $stmtD->fetchColumn();
// Passenger invites count
$sqlPass = "SELECT COUNT(*) as total FROM invitesToPassengers WHERE driverId = :driver_id AND isInstall = 1";
$stmtP = $con->prepare($sqlPass);
$stmtP->bindParam(':driver_id', $driver_id, PDO::PARAM_INT);
$stmtP->execute();
$passengerCount = $stmtP->fetchColumn();
// Rewards calculation (100 pts per driver, 50 pts per passenger)
$totalRewards = ($driverCount * 100) + ($passengerCount * 50);
jsonSuccess([
[
"driverInvites" => (int)$driverCount,
"passengerInvites" => (int)$passengerCount,
"totalRewards" => $totalRewards
]
]);
?>