This commit is contained in:
2026-07-02 01:26:26 +03:30
parent 24edbf3ff3
commit 17e50de53e
7 changed files with 21 additions and 21 deletions
@@ -81,7 +81,7 @@ class SingleOrderController extends Controller
$data['all_price'] = $latestPrice;
$data['price'] = $basePrice;
$data['price_id'] = $latestPrice?->id;
$data['difference'] = $config->orderSpreadRial();
$data['difference'] = $config->orderPriceDiffRial();
$data['service_charge_percentage'] = $config->orderServiceChargePercentage();
$fee_free = Setting::where('key', 'fee_free')->where('is_active', true)->value('value');
@@ -122,7 +122,7 @@ class SingleOrderController extends Controller
if ($data['direction'] == 1) {
$data['service_charge_percentage'] = isset($data['fee_free']) && $data['fee_free'] === true ? 0 : ($data['product']['percent_fee_buy']) * $data['number'];
$data['difference'] = $data['fee'] = $this->resolveCashSpread($config, $data['product'], 1);
$data['difference'] = $data['fee'] = $this->resolveCashPriceDiff($config, $data['product'], 1);
$data['total_fee'] = $data['number'] * $data['fee'];
$data['price_original'] = $data['product']['price'] + $data['product']['price_profit'];
$data['total_price_original'] = $data['product']['amount'] * ($data['price_original'] ?? 0);
@@ -140,7 +140,7 @@ class SingleOrderController extends Controller
} // Check if the user wants to sell
else if ($data['direction'] == 2) {
$data['service_charge_percentage'] = isset($data['fee_free']) && $data['fee_free'] === true ? 0 : ($data['product']['percent_fee_sell']) * $data['number'];
$data['difference'] = $data['fee'] = $this->resolveCashSpread($config, $data['product'], 2);
$data['difference'] = $data['fee'] = $this->resolveCashPriceDiff($config, $data['product'], 2);
$data['total_fee'] = $data['number'] * $data['fee'];
$data['price_original'] = $data['product']['price'] + $data['product']['price_profit'];
$data['total_price_original'] = $data['product']['amount'] * ($data['price_original'] ?? 0);
@@ -166,10 +166,10 @@ class SingleOrderController extends Controller
}
$config->assertProductTradingOpen($data['product']);
if ($data['direction'] == 1) {
$data['difference'] = $this->resolveCashSpread($config, $data['product'], 1);
$data['difference'] = $this->resolveCashPriceDiff($config, $data['product'], 1);
$data['service_charge_percentage'] = $data['product']['percent_fee_buy'];
} elseif ($data['direction'] == 2) {
$data['difference'] = $this->resolveCashSpread($config, $data['product'], 2);
$data['difference'] = $this->resolveCashPriceDiff($config, $data['product'], 2);
$data['service_charge_percentage'] = $data['product']['percent_fee_sell'];
}
$data['total_fee'] = $data['amount'] * $data['difference'];
@@ -963,15 +963,15 @@ class SingleOrderController extends Controller
* گلد علی / zaarbox / main_product: اختلاف سفارش = buy_fee/sell_fee نمایش (مثل /api/price/last).
* montzar و بقیه: همان cash_fee_buy/sell محصول (رفتار قبلی ابشده‌خانگی).
*/
private function resolveCashSpread(ConfigService $config, Product $product, int $direction): float
private function resolveCashPriceDiff(ConfigService $config, Product $product, int $direction): float
{
$provider = $config->priceProvider();
$alignWithDisplay = in_array($provider, ['zaarbox', 'main_product'], true);
if ($alignWithDisplay) {
$display = $direction === 1
? $config->displayBuySpreadRial()
: $config->displaySellSpreadRial();
? $config->displayBuyPriceDiffRial()
: $config->displaySellPriceDiffRial();
if ($display > 0) {
return $display;
@@ -93,8 +93,8 @@ class ReportController extends Controller
protected function buildUpDownPrices(): array
{
$config = app(ConfigService::class);
$diffBuy = $config->displayBuySpreadRial();
$diffSell = $config->displaySellSpreadRial();
$diffBuy = $config->displayBuyPriceDiffRial();
$diffSell = $config->displaySellPriceDiffRial();
$extremes = $config->resolvedDailyBaseExtremes();
$up = $extremes['up'];
+5 -5
View File
@@ -93,7 +93,7 @@ class ConfigService
}
/** اختلاف خرید نمایش (/api/price/last) — fee_single / buy_fee */
public function displayBuySpreadRial(): float
public function displayBuyPriceDiffRial(): float
{
$feeSingle = (float) $this->get('fee_single', 0);
$buyFee = (float) $this->get('buy_fee', $feeSingle);
@@ -102,7 +102,7 @@ class ConfigService
}
/** اختلاف فروش نمایش — fee_single / sell_fee */
public function displaySellSpreadRial(): float
public function displaySellPriceDiffRial(): float
{
$feeSingle = (float) $this->get('fee_single', 0);
$sellFee = (float) $this->get('sell_fee', $feeSingle);
@@ -111,7 +111,7 @@ class ConfigService
}
/** اختلاف ریالی سفارش — fee_single، بعد fee_cash (legacy)، بعد config/fee.php */
public function orderSpreadRial(): float
public function orderPriceDiffRial(): float
{
$feeSingle = $this->getString('fee_single', '');
if ($feeSingle !== '') {
@@ -161,8 +161,8 @@ class ConfigService
?string $priceSource = null,
array $montzarFlags = []
): array {
$diffBuy = (float) $this->displayBuySpreadRial();
$diffSell = (float) $this->displaySellSpreadRial();
$diffBuy = (float) $this->displayBuyPriceDiffRial();
$diffSell = (float) $this->displaySellPriceDiffRial();
$feeSingle = (float) $this->get('fee_single', 0);
$openBuy = true;
+2 -2
View File
@@ -131,8 +131,8 @@ class LivePriceCacheService
$payload['up'] = $config->resolvedDailyBaseExtremes()['up'] > 0
? [
'sell' => max(0, (int) ceil($config->resolvedDailyBaseExtremes()['down'] - $config->displaySellSpreadRial())),
'buy' => (int) ceil($config->resolvedDailyBaseExtremes()['up'] + $config->displayBuySpreadRial()),
'sell' => max(0, (int) ceil($config->resolvedDailyBaseExtremes()['down'] - $config->displaySellPriceDiffRial())),
'buy' => (int) ceil($config->resolvedDailyBaseExtremes()['up'] + $config->displayBuyPriceDiffRial()),
]
: ['sell' => $payload['sell'] ?? 0, 'buy' => $payload['buy'] ?? 0];
$payload['last_historical'] = $display->resolveHistoricalBasePrice();
+2 -2
View File
@@ -465,8 +465,8 @@ class ProductDisplayPriceService
}
}
$diffBuy = (int) $config->displayBuySpreadRial();
$diffSell = (int) $config->displaySellSpreadRial();
$diffBuy = (int) $config->displayBuyPriceDiffRial();
$diffSell = (int) $config->displaySellPriceDiffRial();
$payload = [
'price' => $price,