fixed price
This commit is contained in:
@@ -25,6 +25,7 @@ use App\Models\Setting;
|
||||
use App\Models\Cnt;
|
||||
use App\Services\MontzarService;
|
||||
use App\Services\ConfigService;
|
||||
use App\Services\ProductDisplayPriceService;
|
||||
use App\Services\WalletBroadcastService;
|
||||
|
||||
|
||||
@@ -43,21 +44,9 @@ class SingleOrderController extends Controller
|
||||
}
|
||||
$config = app(ConfigService::class);
|
||||
|
||||
$toBool = function ($value) {
|
||||
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;
|
||||
$montzar_sell = !$toBool($config->Config('montzar_open_sell')) && (int) $data['direction'] === 2;
|
||||
|
||||
if ($montzar_closed || $montzar_buy || $montzar_sell) {
|
||||
throw new UnprocessableEntityHttpException('عدم ارائه سرویس.');
|
||||
}
|
||||
}
|
||||
$config->assertMontzarOrderAllowed((int) ($data['direction'] ?? 0));
|
||||
|
||||
// throw new UnprocessableEntityHttpException('به دلیل نوسانات سفارشات بسته میباشد.');
|
||||
$transactionType = $data['direction'] == 1 ? "خرید" : "فروش";
|
||||
@@ -76,17 +65,23 @@ class SingleOrderController extends Controller
|
||||
|
||||
if (auth('customer')->id()) {
|
||||
$data['customer_id'] = auth('customer')->id();
|
||||
$latestPrice = Price::latest()->first();
|
||||
|
||||
if (!$latestPrice || $latestPrice->price == 0) {
|
||||
$orderProductId = (int) ($data['abshode_id'] ?? $data['product_id'] ?? $config->mainProductId() ?? 0);
|
||||
$orderProduct = $orderProductId > 0 ? Product::find($orderProductId) : null;
|
||||
|
||||
$basePrice = app(ProductDisplayPriceService::class)->resolveOrderBasePrice($orderProduct);
|
||||
|
||||
if ($basePrice <= 0) {
|
||||
if ($config->isOutsideTradingHours()) {
|
||||
throw new UnprocessableEntityHttpException($config->tradingClosedMessage());
|
||||
}
|
||||
throw new UnprocessableEntityHttpException('عدم ارائه سرویس.');
|
||||
}
|
||||
|
||||
$latestPrice = Price::latest()->first();
|
||||
$data['all_price'] = $latestPrice;
|
||||
$data['price'] = $latestPrice->price;
|
||||
$data['price_id'] = $latestPrice->id;
|
||||
$data['price'] = $basePrice;
|
||||
$data['price_id'] = $latestPrice?->id;
|
||||
$feeCash = Setting::where('key', 'fee_cash')->first();
|
||||
$feeServiceCharge = Setting::where('key', 'fee_service_charge_percentage')->first();
|
||||
if (!$feeCash || !$feeServiceCharge) {
|
||||
|
||||
@@ -318,7 +318,10 @@ class ReportController extends Controller
|
||||
'montzar_response' => $montzar ?? null,
|
||||
]);
|
||||
|
||||
$config->UpdateConfig('montzar_closed', 'true');
|
||||
$config->applyMontzarSyncFailure();
|
||||
if (!$config->getBool('montzar_closed', true)) {
|
||||
$montzar_price = $config->getInt('montzar_live_price', 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -542,7 +545,7 @@ class ReportController extends Controller
|
||||
$config->UpdateConfig('montzar_closed', $montzar === 0 ? 'true' : 'false');
|
||||
} catch (\Throwable $e) {
|
||||
$montzar = 0;
|
||||
$config->UpdateConfig('montzar_closed', 'true');
|
||||
$config->applyMontzarSyncFailure();
|
||||
\Log::error('STORE MONZAR PRICE ERROR', ['message' => $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user