fix some bugs
This commit is contained in:
@@ -596,6 +596,12 @@ class SingleOrderController extends Controller
|
|||||||
// سمت کسر کارمزد برای گزارش تفکیکشده در داشبورد
|
// سمت کسر کارمزد برای گزارش تفکیکشده در داشبورد
|
||||||
$data['fee_asset'] = $rialLocked ? 'gold' : 'rial';
|
$data['fee_asset'] = $rialLocked ? 'gold' : 'rial';
|
||||||
|
|
||||||
|
if (!$rialLocked && (float) $data['total_price'] < 0) {
|
||||||
|
throw new UnprocessableEntityHttpException(
|
||||||
|
'مبلغ دریافتی فروش پس از کارمزد منفی شد. درصد کارمزد سفارش را بررسی کنید (باید اعشاری باشد؛ مثلاً ۰٫۰۱ برای ۱٪).'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$grossTotal = $data['amount'] * $data['price'];
|
$grossTotal = $data['amount'] * $data['price'];
|
||||||
$this->enforceProductOrderLimits($data, (float) $grossTotal);
|
$this->enforceProductOrderLimits($data, (float) $grossTotal);
|
||||||
|
|
||||||
@@ -675,6 +681,11 @@ class SingleOrderController extends Controller
|
|||||||
$data['total_price'] = $data['amount'] * $data['price'] - $data['service_charge_price'];
|
$data['total_price'] = $data['amount'] * $data['price'] - $data['service_charge_price'];
|
||||||
$data['payment_amount'] = $data['total_price'];
|
$data['payment_amount'] = $data['total_price'];
|
||||||
$data['fee_asset'] = 'rial';
|
$data['fee_asset'] = 'rial';
|
||||||
|
if ($data['total_price'] < 0) {
|
||||||
|
throw new UnprocessableEntityHttpException(
|
||||||
|
'مبلغ دریافتی فروش پس از کارمزد منفی شد. درصد کارمزد سفارش را بررسی کنید (باید اعشاری باشد؛ مثلاً ۰٫۰۱ برای ۱٪).'
|
||||||
|
);
|
||||||
|
}
|
||||||
$grossTotal = (float) ($data['amount'] * $data['price']);
|
$grossTotal = (float) ($data['amount'] * $data['price']);
|
||||||
$this->enforceProductOrderLimits($data, $grossTotal);
|
$this->enforceProductOrderLimits($data, $grossTotal);
|
||||||
$wallet_interface_product = $this->productWalletInterface((int) $data["product_id"]);
|
$wallet_interface_product = $this->productWalletInterface((int) $data["product_id"]);
|
||||||
|
|||||||
@@ -138,11 +138,28 @@ class ConfigService
|
|||||||
foreach (['fee_service_charge_percentage', 'service_charge_percentage'] as $key) {
|
foreach (['fee_service_charge_percentage', 'service_charge_percentage'] as $key) {
|
||||||
$raw = $this->getString($key, '');
|
$raw = $this->getString($key, '');
|
||||||
if ($raw !== '') {
|
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