fix some bugs
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user