fix some bugs from fee
This commit is contained in:
@@ -101,38 +101,35 @@ class ConfigService
|
||||
return $fromDb !== '' ? $fromDb : (string) env('NODE_SHARED_SECRET', '');
|
||||
}
|
||||
|
||||
/** اختلاف خرید نمایش (/api/price/last) — fee_single / buy_fee */
|
||||
/** اختلاف خرید نمایش (/api/price/last) — فقط buy_fee (صفر یعنی بدون اختلاف) */
|
||||
public function displayBuyPriceDiffRial(): float
|
||||
{
|
||||
$feeSingle = (float) $this->get('fee_single', 0);
|
||||
$buyFee = (float) $this->get('buy_fee', $feeSingle);
|
||||
$raw = $this->getString('buy_fee', '');
|
||||
|
||||
return $buyFee > 0 ? $buyFee : $feeSingle;
|
||||
return $raw === '' ? 0.0 : (float) $raw;
|
||||
}
|
||||
|
||||
/** اختلاف فروش نمایش — fee_single / sell_fee */
|
||||
/** اختلاف فروش نمایش — فقط sell_fee (صفر یعنی بدون اختلاف) */
|
||||
public function displaySellPriceDiffRial(): float
|
||||
{
|
||||
$feeSingle = (float) $this->get('fee_single', 0);
|
||||
$sellFee = (float) $this->get('sell_fee', $feeSingle);
|
||||
$raw = $this->getString('sell_fee', '');
|
||||
|
||||
return $sellFee > 0 ? $sellFee : $feeSingle;
|
||||
return $raw === '' ? 0.0 : (float) $raw;
|
||||
}
|
||||
|
||||
/** اختلاف ریالی سفارش — fee_single، بعد fee_cash (legacy)، بعد config/fee.php */
|
||||
public function orderPriceDiffRial(): float
|
||||
/**
|
||||
* اختلاف ریالی سفارش — فقط buy_fee / sell_fee بر اساس جهت.
|
||||
* fee_single دیگر منبع نیست.
|
||||
*
|
||||
* @param int|null $direction 1=خرید، 2=فروش، null=خرید (برای سازگاری)
|
||||
*/
|
||||
public function orderPriceDiffRial(?int $direction = null): float
|
||||
{
|
||||
$feeSingle = $this->getString('fee_single', '');
|
||||
if ($feeSingle !== '') {
|
||||
return (float) $feeSingle;
|
||||
if ($direction === 2) {
|
||||
return $this->displaySellPriceDiffRial();
|
||||
}
|
||||
|
||||
$legacyCash = $this->getString('fee_cash', '');
|
||||
if ($legacyCash !== '') {
|
||||
return (float) $legacyCash;
|
||||
}
|
||||
|
||||
return (float) config('fee.single', 0);
|
||||
return $this->displayBuyPriceDiffRial();
|
||||
}
|
||||
|
||||
/** درصد کارمزد سفارش — fee_service_charge_percentage، service_charge_percentage، config/fee.php */
|
||||
@@ -172,7 +169,6 @@ class ConfigService
|
||||
): array {
|
||||
$diffBuy = (float) $this->displayBuyPriceDiffRial();
|
||||
$diffSell = (float) $this->displaySellPriceDiffRial();
|
||||
$feeSingle = (float) $this->get('fee_single', 0);
|
||||
|
||||
$openBuy = true;
|
||||
$openSell = true;
|
||||
@@ -191,16 +187,9 @@ class ConfigService
|
||||
return compact('sell', 'buy', 'priceLast');
|
||||
}
|
||||
|
||||
$sell = $openSell ? (int) ceil($priceValue - $feeSingle) : 0;
|
||||
$buy = $openBuy ? (int) ceil($priceValue + $feeSingle) : 0;
|
||||
$priceLast = (int) ceil($priceValue + $feeSingle);
|
||||
|
||||
$provider = $this->priceProvider();
|
||||
if (in_array($provider, ['main_product', 'zaarbox'], true)) {
|
||||
$sell = $openSell ? (int) ceil($priceValue - $diffSell) : 0;
|
||||
$buy = $openBuy ? (int) ceil($priceValue + $diffBuy) : 0;
|
||||
$priceLast = (int) ceil($priceValue + $diffBuy);
|
||||
}
|
||||
$sell = $openSell ? (int) ceil($priceValue - $diffSell) : 0;
|
||||
$buy = $openBuy ? (int) ceil($priceValue + $diffBuy) : 0;
|
||||
$priceLast = (int) ceil($priceValue + $diffBuy);
|
||||
|
||||
return compact('sell', 'buy', 'priceLast');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user