etehadie removed
This commit is contained in:
@@ -11,7 +11,6 @@ use App\Models\Product;
|
||||
use App\Models\TransactionsAdmin;
|
||||
use App\Models\Withdraw;
|
||||
use App\Services\ConfigService;
|
||||
use App\Services\EtehadiePriceService;
|
||||
use Carbon\Carbon;
|
||||
use Hekmatinasser\Verta\Verta;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -87,13 +86,14 @@ class DashboardController extends Controller
|
||||
|
||||
$gramPrice = (int) ($tallaPrice->price ?? 0);
|
||||
$FPrices = [];
|
||||
if (app(ConfigService::class)->usesEtehadiePricing()) {
|
||||
$etehadie = app(EtehadiePriceService::class)->fetchMainGramPrice();
|
||||
if (($etehadie['price'] ?? 0) > 0) {
|
||||
$gramPrice = (int) round($etehadie['price'] / 10);
|
||||
$mainProductId = app(ConfigService::class)->mainProductId();
|
||||
if ($mainProductId) {
|
||||
$mainProduct = Product::find($mainProductId);
|
||||
if ($mainProduct) {
|
||||
$gramPrice = (int) ($mainProduct->price + ($mainProduct->price_profit ?? 0));
|
||||
$FPrices[] = [
|
||||
'id' => 'etehadie',
|
||||
'name' => 'اتحادیه',
|
||||
'id' => 'main_product',
|
||||
'name' => $mainProduct->title ?? 'محصول اصلی',
|
||||
'price' => $gramPrice,
|
||||
'profit' => 0,
|
||||
];
|
||||
|
||||
@@ -170,7 +170,7 @@ class ProductController extends SuperController
|
||||
// }catch (\Exception $e){}
|
||||
|
||||
$config = app(ConfigService::class);
|
||||
$mainProductId = Cnt::where('key', 'main_product')->value('value');
|
||||
$mainProductId = app(ConfigService::class)->mainProductId();
|
||||
$hasExtremeKeys = Setting::whereIn('key', ['up_price', 'down_price'])->count() === 2;
|
||||
$products = Product::with([])->whereNotNull('reading_method')->get();
|
||||
foreach ($products as $product) {
|
||||
|
||||
@@ -10,7 +10,10 @@ use Illuminate\Support\Facades\Artisan;
|
||||
class SettingsController extends Controller
|
||||
{
|
||||
public function index(){
|
||||
$Setting = Setting::where('can_edit',1)->select('id','title_fa', 'key','value','description','is_active','type')->get();
|
||||
$Setting = Setting::where('can_edit', 1)
|
||||
->select(Setting::adminSelectColumns())
|
||||
->get();
|
||||
|
||||
return response()->json($Setting);
|
||||
}
|
||||
public function edit(Request $request)
|
||||
@@ -19,23 +22,25 @@ class SettingsController extends Controller
|
||||
$setting = Setting::where('key', $request->key)->first();
|
||||
|
||||
if ($setting) {
|
||||
// Update the existing setting
|
||||
$setting->value = $request->value;
|
||||
$setting->description = $request->description;
|
||||
$setting->is_active = $request->is_active;
|
||||
$setting->type = $request->type??'';
|
||||
$setting->title_fa = $request->title_fa??'';
|
||||
$setting->title_fa = $request->title_fa ?? '';
|
||||
if (Setting::hasTypeColumn()) {
|
||||
$setting->type = $request->type ?? '';
|
||||
}
|
||||
$setting->save();
|
||||
} else {
|
||||
// Create a new setting
|
||||
$setting = new Setting();
|
||||
$setting->key = $request->key;
|
||||
$setting->type = $request->type??$request->type??'';
|
||||
$setting->title_fa = $request->title_fa??$setting->title_fa??'';
|
||||
$setting->title_fa = $request->title_fa ?? '';
|
||||
$setting->value = $request->value;
|
||||
$setting->description = $request->description;
|
||||
$setting->is_active = $request->is_active;
|
||||
$setting->can_edit = 1;
|
||||
if (Setting::hasTypeColumn()) {
|
||||
$setting->type = $request->type ?? '';
|
||||
}
|
||||
$setting->save();
|
||||
}
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@ class SingleOrderController extends Controller
|
||||
} else {
|
||||
// Calculate total price and fee for non-product (gold) transaction
|
||||
$data['total_price_original'] = $data['amount'] * ($data['price_original'] ?? 0);
|
||||
$mainProductId = Cnt::where('key', 'main_product')->value('value');
|
||||
$mainProductId = app(\App\Services\ConfigService::class)->mainProductId();
|
||||
$productId = $data['abshode_id'] ?? $data['product_id'] ?? $mainProductId;
|
||||
$data['product'] = $productId ? Product::find($productId) : null;
|
||||
if (!$data['product']) {
|
||||
|
||||
@@ -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(),
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user