fix some bugs

This commit is contained in:
2026-07-29 19:57:32 +03:30
parent 67c31c9bce
commit 381d28aae5
2 changed files with 30 additions and 2 deletions
+19 -2
View File
@@ -138,11 +138,28 @@ class ConfigService
foreach (['fee_service_charge_percentage', 'service_charge_percentage'] as $key) {
$raw = $this->getString($key, '');
if ($raw !== '') {
return (float) $raw;
return $this->normalizeServiceChargeRatio((float) $raw);
}
}
return (float) config('fee.service_charge_percentage', 0);
return $this->normalizeServiceChargeRatio((float) config('fee.service_charge_percentage', 0));
}
/**
* نسبت کارمزد (۰٫۰۱ = ۱٪). اگر ادمین «۱» به‌جای «۰٫۰۱» گذاشته باشد نرمال می‌شود.
*/
private function normalizeServiceChargeRatio(float $value): float
{
if ($value <= 0) {
return 0.0;
}
// مقدار ≥۱ یعنی درصد انسانی وارد شده (۱ → ۱٪)، نه نسبت
if ($value >= 1.0) {
return $value / 100.0;
}
return $value;
}
/**