This commit is contained in:
2026-06-14 22:00:21 +03:30
parent 0c4cbd7c12
commit b021acde56
7 changed files with 119 additions and 15 deletions
@@ -42,6 +42,8 @@ class SingleOrderController extends Controller
return filter_var($value, FILTER_VALIDATE_BOOLEAN);
};
$config->assertTradingOpen();
if ($config->usesMontzarPricing()) {
$montzar_closed = $toBool($config->Config('montzar_closed'));
$montzar_buy = !$toBool($config->Config('montzar_open_buy')) && (int) $data['direction'] === 1;
@@ -52,10 +54,6 @@ class SingleOrderController extends Controller
}
}
if ($toBool($config->Config('close_price'))) {
$config->assertTradingOpen();
}
// throw new UnprocessableEntityHttpException('به دلیل نوسانات سفارشات بسته میباشد.');
$transactionType = $data['direction'] == 1 ? "خرید" : "فروش";
$customer = Customer::find(auth('customer')->id() ?? ($data['customer_id'] ?? null));
@@ -76,6 +74,9 @@ class SingleOrderController extends Controller
$latestPrice = Price::latest()->first();
if (!$latestPrice || $latestPrice->price == 0) {
if ($config->isOutsideTradingHours()) {
throw new UnprocessableEntityHttpException($config->tradingClosedMessage());
}
throw new UnprocessableEntityHttpException('عدم ارائه سرویس.');
}
$data['all_price'] = $latestPrice;
@@ -120,6 +121,8 @@ class SingleOrderController extends Controller
// Check if the user wants to transact with a product or non-product (gold)
if (isset($data['product_id']) and $data['product'] = Product::find($data['product_id'])) {
$config->assertProductTradingOpen($data['product']);
// Check if the user wants to buy
if ($data['direction'] == 1) {
@@ -166,6 +169,7 @@ class SingleOrderController extends Controller
if (!$data['product']) {
throw new UnprocessableEntityHttpException('محصول آبشده یافت نشد.');
}
$config->assertProductTradingOpen($data['product']);
if ($data['direction'] == 1) {
$data['difference'] = $this->resolveCashSpread($config, $data['product'], 1);
$data['service_charge_percentage'] = $data['product']['percent_fee_buy'];