etehadie removed

This commit is contained in:
2026-06-04 14:19:54 +03:30
parent a643ba58b7
commit f9c5ca109d
13 changed files with 134 additions and 76 deletions
+12 -39
View File
@@ -10,7 +10,6 @@ use App\Models\Setting;
use App\Models\ConfigStatic;
use App\Models\Customer;
use App\Services\MontzarService;
use App\Services\EtehadiePriceService;
use App\Models\Price;
use App\Models\PriceCandle;
use App\Models\PriceTrigger;
@@ -141,7 +140,6 @@ class ReportController extends Controller
$closed = false;
$montzar_price = 0;
$etehadie_teh = 0;
$tgn = 0;
$pr_price = 0;
@@ -167,7 +165,6 @@ class ReportController extends Controller
'main_product' => 0,
'taban_gohar' => 0,
'montzar' => 0,
'etehadie_teh' => 0,
'closed' => true,
'time' => now(),
]);
@@ -227,18 +224,6 @@ class ReportController extends Controller
$diff_buy = (float) $settingsMap->get('buy_fee', $difference);
$diff_sell = (float) $settingsMap->get('sell_fee', $difference);
/*
|--------------------------------------------------------------------------
| اتحادیه (گلد علی / refPricer) — فقط وقتی price_provider=etehadie
|--------------------------------------------------------------------------
*/
$etehadie_order_price = 0;
if ($priceProvider === 'etehadie' && !$closed) {
$etehadie = app(EtehadiePriceService::class)->fetchMainGramPrice();
$etehadie_teh = (int) ($etehadie['price'] ?? 0);
$etehadie_order_price = (int) ($etehadie['order_price'] ?? 0);
}
/*
|--------------------------------------------------------------------------
| Montzar — فقط وقتی price_provider=montzar
@@ -322,17 +307,16 @@ class ReportController extends Controller
/*
|--------------------------------------------------------------------------
| Main Product
|--------------------------------------------------------------------------
| عمومی است، پس از Cnt خوانده می‌شود.
| Main Product — settings.main_product سپس const
|--------------------------------------------------------------------------
*/
if ($toBool($main_product_price) && !$closed) {
$main_product_id = Cnt::where('key', 'main_product')->value('value');
$pr_product = $main_product_id ? Product::find($main_product_id) : null;
if ($pr_product) {
$pr_price = (float) $pr_product['price'] + (float) $pr_product['price_profit'];
$main_product_id = $config->mainProductId();
if ($main_product_id && !$closed) {
if ($priceProvider === 'main_product' || $toBool($main_product_price)) {
$pr_product = Product::find($main_product_id);
if ($pr_product) {
$pr_price = (float) $pr_product['price'] + (float) $pr_product['price_profit'];
}
}
}
@@ -365,16 +349,13 @@ class ReportController extends Controller
| انتخاب قیمت اصلی (همان price_provider)
|--------------------------------------------------------------------------
*/
if ($priceProvider === 'etehadie' && $etehadie_teh > 0 && !$closed) {
$priceValue = (int) $etehadie_teh;
$priceSource = 'etehadie';
} elseif ($priceProvider === 'montzar' && ($montzar_price ?? 0) !== 0 && !$closed) {
if ($priceProvider === 'montzar' && ($montzar_price ?? 0) !== 0 && !$closed) {
$priceValue = (int) $montzar_price;
$priceSource = 'montzar';
} elseif ($priceProvider === 'taban_gohar' && $toBool($taban_gohar_price) && ($tgn ?? 0) !== 0 && !$closed) {
$priceValue = $tgn;
$priceSource = 'taban_gohar';
} elseif ($priceProvider === 'main_product' && $toBool($main_product_price) && ($pr_price ?? 0) !== 0 && !$closed) {
} elseif ($priceProvider === 'main_product' && ($pr_price ?? 0) !== 0 && !$closed) {
$priceValue = $pr_price;
$priceSource = 'main_product';
} else {
@@ -392,7 +373,6 @@ class ReportController extends Controller
'main_product' => $pr_price ?? 0,
'taban_gohar' => $tgn ?? 0,
'montzar' => $montzar_price ?? 0,
'etehadie_teh' => $etehadie_teh ?? 0,
'closed' => true,
'time' => now(),
]);
@@ -409,7 +389,6 @@ class ReportController extends Controller
'main_product' => $pr_price ?? 0,
'taban_gohar' => $tgn ?? 0,
'montzar' => $montzar_price ?? 0,
'etehadie_teh' => $etehadie_teh ?? 0,
'closed' => true,
'time' => now(),
]);
@@ -425,9 +404,6 @@ class ReportController extends Controller
|--------------------------------------------------------------------------
*/
$priceToStore = $priceValue;
if ($priceProvider === 'etehadie' && $etehadie_order_price > 0) {
$priceToStore = $etehadie_order_price;
}
$lastPrice = Price::latest()->first();
@@ -502,11 +478,9 @@ class ReportController extends Controller
}
/*
| گلد علی (etehadie): سفارش از Price::latest() می‌خواند؛
| buy/sell/price_last هم از همان ردیف (مثل goldAliii قبل از مرج).
| etehadie_teh فقط در فیلد price / etehadie_teh می‌ماند.
| main_product / گلد علی: سفارش از Price::latest() — نمایش buy/sell همان منبع.
*/
if ($priceProvider === 'etehadie' && !$closed) {
if ($priceProvider === 'main_product' && !$closed) {
$storedPrice = $lastPrice ?? Price::latest()->first();
if ($storedPrice && (float) $storedPrice->price > 0) {
$base = (float) $storedPrice->price;
@@ -528,7 +502,6 @@ class ReportController extends Controller
'main_product' => $pr_price ?? 0,
'taban_gohar' => $tgn ?? 0,
'montzar' => $montzar_price ?? 0,
'etehadie_teh' => $etehadie_teh ?? 0,
'closed' => false,
'time' => now(),
]);