refactor: migrate amount fields to decimal and implement location service restriction for unsupported regions
This commit is contained in:
@@ -147,12 +147,23 @@ try {
|
||||
if ($driverRaw) {
|
||||
$encryptedFields = ['first_name', 'last_name', 'gender', 'phone', 'car_plate', 'token'];
|
||||
foreach ($driverRaw as $key => $value) {
|
||||
$driverInfo[$key] = (in_array($key, $encryptedFields) && !empty($value))
|
||||
? $encryptionHelper->decryptData($value)
|
||||
: $value;
|
||||
if (in_array($key, $encryptedFields, true) && !empty($value)) {
|
||||
$decrypted = false;
|
||||
try {
|
||||
$decrypted = $encryptionHelper->decryptData($value);
|
||||
} catch (\Throwable $e) {
|
||||
$decrypted = false;
|
||||
}
|
||||
$driverInfo[$key] = ($decrypted !== false && $decrypted !== null && $decrypted !== '') ? $decrypted : $value;
|
||||
} else {
|
||||
$driverInfo[$key] = $value;
|
||||
}
|
||||
}
|
||||
$driverInfo['driverName'] = trim(($driverInfo['first_name'] ?? '') . ' ' . ($driverInfo['last_name'] ?? ''));
|
||||
$driverInfo['ratingDriver'] = $driverInfo['ratingDriver'] ?: "5.0";
|
||||
if (empty($driverInfo['driverName']) && !empty($driverInfo['phone'])) {
|
||||
$driverInfo['driverName'] = $driverInfo['phone'];
|
||||
}
|
||||
$driverInfo['ratingDriver'] = !empty($driverInfo['ratingDriver']) ? (string)$driverInfo['ratingDriver'] : "5.0";
|
||||
$ratingValue = (float) $driverInfo['ratingDriver'];
|
||||
$ratingCount = (int) ($driverInfo['ratingCount'] ?? 0);
|
||||
$completedRides = (int) ($driverInfo['completedRides'] ?? 0);
|
||||
@@ -163,6 +174,19 @@ try {
|
||||
} else {
|
||||
$driverInfo['driverTier'] = 'Verified driver';
|
||||
}
|
||||
|
||||
if (isset($redisLocation) && $redisLocation) {
|
||||
try {
|
||||
$driverLoc = $redisLocation->hGetAll("driver:location:$driverId");
|
||||
if (!empty($driverLoc)) {
|
||||
$driverInfo['lat'] = (float)($driverLoc['lat'] ?? 0);
|
||||
$driverInfo['lng'] = (float)($driverLoc['lng'] ?? 0);
|
||||
$driverInfo['heading'] = (float)($driverLoc['heading'] ?? 0);
|
||||
}
|
||||
} catch (Exception $eLoc) {
|
||||
// Ignore location fetch error
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════
|
||||
|
||||
Reference in New Issue
Block a user