new check for kashkol
This commit is contained in:
@@ -138,7 +138,6 @@ class ReportController extends Controller
|
|||||||
|
|
||||||
$montzar_price = 0;
|
$montzar_price = 0;
|
||||||
$zaarbox_price = 0;
|
$zaarbox_price = 0;
|
||||||
$tgn = 0;
|
|
||||||
$pr_price = 0;
|
$pr_price = 0;
|
||||||
|
|
||||||
$open_buy = true;
|
$open_buy = true;
|
||||||
@@ -207,7 +206,6 @@ class ReportController extends Controller
|
|||||||
*/
|
*/
|
||||||
$settings = Setting::whereIn('key', [
|
$settings = Setting::whereIn('key', [
|
||||||
'fee_single',
|
'fee_single',
|
||||||
'tabanGohar_price',
|
|
||||||
'main_product_price',
|
'main_product_price',
|
||||||
'buy_fee',
|
'buy_fee',
|
||||||
'sell_fee',
|
'sell_fee',
|
||||||
@@ -215,7 +213,6 @@ class ReportController extends Controller
|
|||||||
|
|
||||||
$settingsMap = $settings->pluck('value', 'key');
|
$settingsMap = $settings->pluck('value', 'key');
|
||||||
$show_last_price = $config->getBool('show_last_price', false);
|
$show_last_price = $config->getBool('show_last_price', false);
|
||||||
$taban_gohar_price = $settingsMap->get('tabanGohar_price');
|
|
||||||
$main_product_price = $settingsMap->get('main_product_price');
|
$main_product_price = $settingsMap->get('main_product_price');
|
||||||
|
|
||||||
$difference = (float) $settingsMap->get('fee_single', 0);
|
$difference = (float) $settingsMap->get('fee_single', 0);
|
||||||
@@ -341,30 +338,6 @@ class ReportController extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| Taban Gohar
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
if ($toBool($taban_gohar_price) && !$closed) {
|
|
||||||
try {
|
|
||||||
$taban_gohar = Http::withOptions([
|
|
||||||
'curl' => [
|
|
||||||
CURLOPT_IPRESOLVE => CURL_IPRESOLVE_V4,
|
|
||||||
CURLOPT_TCP_FASTOPEN => 1,
|
|
||||||
],
|
|
||||||
])
|
|
||||||
->withoutVerifying()
|
|
||||||
->timeout(2)
|
|
||||||
->get('https://tabangohar.com/GheymatKhan/prices_in_table.html')
|
|
||||||
->json();
|
|
||||||
|
|
||||||
$tgn = (int) $taban_gohar['c'] * 10;
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
$tgn = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| انتخاب قیمت اصلی (همان price_provider)
|
| انتخاب قیمت اصلی (همان price_provider)
|
||||||
@@ -376,9 +349,6 @@ class ReportController extends Controller
|
|||||||
} elseif ($priceProvider === 'montzar' && ($montzar_price ?? 0) !== 0 && !$closed) {
|
} elseif ($priceProvider === 'montzar' && ($montzar_price ?? 0) !== 0 && !$closed) {
|
||||||
$priceValue = (int) $montzar_price;
|
$priceValue = (int) $montzar_price;
|
||||||
$priceSource = 'montzar';
|
$priceSource = 'montzar';
|
||||||
} elseif ($priceProvider === 'taban_gohar' && $toBool($taban_gohar_price) && ($tgn ?? 0) !== 0 && !$closed) {
|
|
||||||
$priceValue = $tgn;
|
|
||||||
$priceSource = 'taban_gohar';
|
|
||||||
} elseif ($priceProvider === 'main_product' && ($pr_price ?? 0) !== 0 && !$closed) {
|
} elseif ($priceProvider === 'main_product' && ($pr_price ?? 0) !== 0 && !$closed) {
|
||||||
$priceValue = $pr_price;
|
$priceValue = $pr_price;
|
||||||
$priceSource = 'main_product';
|
$priceSource = 'main_product';
|
||||||
@@ -395,7 +365,7 @@ class ReportController extends Controller
|
|||||||
'price_last' => 0,
|
'price_last' => 0,
|
||||||
'price' => 0,
|
'price' => 0,
|
||||||
'main_product' => $pr_price ?? 0,
|
'main_product' => $pr_price ?? 0,
|
||||||
'taban_gohar' => $tgn ?? 0,
|
'taban_gohar' => 0,
|
||||||
'montzar' => $montzar_price ?? 0,
|
'montzar' => $montzar_price ?? 0,
|
||||||
'zaarbox' => $zaarbox_price ?? 0,
|
'zaarbox' => $zaarbox_price ?? 0,
|
||||||
'closed' => true,
|
'closed' => true,
|
||||||
@@ -413,7 +383,7 @@ class ReportController extends Controller
|
|||||||
'price_last' => 0,
|
'price_last' => 0,
|
||||||
'price' => 0,
|
'price' => 0,
|
||||||
'main_product' => $pr_price ?? 0,
|
'main_product' => $pr_price ?? 0,
|
||||||
'taban_gohar' => $tgn ?? 0,
|
'taban_gohar' => 0,
|
||||||
'montzar' => $montzar_price ?? 0,
|
'montzar' => $montzar_price ?? 0,
|
||||||
'zaarbox' => $zaarbox_price ?? 0,
|
'zaarbox' => $zaarbox_price ?? 0,
|
||||||
'closed' => true,
|
'closed' => true,
|
||||||
@@ -525,7 +495,7 @@ class ReportController extends Controller
|
|||||||
'price_last' => $priceLast,
|
'price_last' => $priceLast,
|
||||||
'price' => $priceValue,
|
'price' => $priceValue,
|
||||||
'main_product' => $pr_price ?? 0,
|
'main_product' => $pr_price ?? 0,
|
||||||
'taban_gohar' => $tgn ?? 0,
|
'taban_gohar' => 0,
|
||||||
'montzar' => $montzar_price ?? 0,
|
'montzar' => $montzar_price ?? 0,
|
||||||
'zaarbox' => $zaarbox_price ?? 0,
|
'zaarbox' => $zaarbox_price ?? 0,
|
||||||
'closed' => false,
|
'closed' => false,
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use App\Models\Setting;
|
|||||||
|
|
||||||
class ConfigService
|
class ConfigService
|
||||||
{
|
{
|
||||||
public const PRICE_PROVIDERS = ['montzar', 'taban_gohar', 'main_product', 'zaarbox'];
|
public const PRICE_PROVIDERS = ['montzar', 'main_product', 'zaarbox'];
|
||||||
|
|
||||||
public function Config($name)
|
public function Config($name)
|
||||||
{
|
{
|
||||||
@@ -99,12 +99,13 @@ class ConfigService
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* تنها منبع فعال قیمت — montzar | taban_gohar | main_product | zaarbox
|
* تنها منبع فعال قیمت — montzar | main_product | zaarbox
|
||||||
*
|
*
|
||||||
* اولویت:
|
* اولویت:
|
||||||
* 1) price_provider (یا price_primary_source قدیمی)
|
* 1) price_provider (یا price_primary_source قدیمی) — فقط مقادیر معتبر
|
||||||
* 2) montzar_price=true → montzar (ابشده خانگی و پروژههای فعلی)
|
* 2) montzar_price=true → montzar (ابشده خانگی و پروژههای فعلی)
|
||||||
* 3) پیشفرض فایل: montzar
|
* 3) main_product_price=true → main_product (legacy)
|
||||||
|
* 4) پیشفرض فایل: montzar
|
||||||
*/
|
*/
|
||||||
public function priceProvider(): string
|
public function priceProvider(): string
|
||||||
{
|
{
|
||||||
@@ -119,6 +120,10 @@ class ConfigService
|
|||||||
return 'montzar';
|
return 'montzar';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->getBool('main_product_price', false)) {
|
||||||
|
return 'main_product';
|
||||||
|
}
|
||||||
|
|
||||||
$default = strtolower((string) config('price_providers.price_provider', 'montzar'));
|
$default = strtolower((string) config('price_providers.price_provider', 'montzar'));
|
||||||
|
|
||||||
return in_array($default, self::PRICE_PROVIDERS, true) ? $default : 'montzar';
|
return in_array($default, self::PRICE_PROVIDERS, true) ? $default : 'montzar';
|
||||||
|
|||||||
@@ -274,8 +274,6 @@ class ProductDisplayPriceService
|
|||||||
if ($main) {
|
if ($main) {
|
||||||
$price = (int) (($main->price ?? 0) + ($main->price_profit ?? 0));
|
$price = (int) (($main->price ?? 0) + ($main->price_profit ?? 0));
|
||||||
}
|
}
|
||||||
} elseif ($provider === 'taban_gohar') {
|
|
||||||
$price = $config->getInt('taban_gohar_live_price', 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($price <= 0 && $config->getBool('show_last_price', false)) {
|
if ($price <= 0 && $config->getBool('show_last_price', false)) {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
* پیشفرض وقتی کلید در جدول settings نیست.
|
* پیشفرض وقتی کلید در جدول settings نیست.
|
||||||
*
|
*
|
||||||
* منبع قیمت: یک کلید → price_provider
|
* منبع قیمت: یک کلید → price_provider
|
||||||
* montzar | taban_gohar | main_product | zaarbox
|
* montzar | main_product | zaarbox
|
||||||
*
|
*
|
||||||
* سازگاری قدیمی (بدون price_provider):
|
* سازگاری قدیمی (بدون price_provider):
|
||||||
* montzar_price=true → montzar
|
* montzar_price=true → montzar
|
||||||
|
|||||||
@@ -93,10 +93,6 @@ INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `de
|
|||||||
SELECT 'chart_id', '', 'UUID نمودار Zaarbox', 1, 1, 'خالی = ca3800a0-1f57-3528-b963-178f9168e04f'
|
SELECT 'chart_id', '', 'UUID نمودار Zaarbox', 1, 1, 'خالی = ca3800a0-1f57-3528-b963-178f9168e04f'
|
||||||
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'chart_id' LIMIT 1);
|
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'chart_id' LIMIT 1);
|
||||||
|
|
||||||
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
|
|
||||||
SELECT 'etehadie_api_url', 'https://price.zaarbox.ir/api/free', 'آدرس API اتحادیه (پشتیبان)', 1, 1, NULL
|
|
||||||
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'etehadie_api_url' LIMIT 1);
|
|
||||||
|
|
||||||
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
|
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
|
||||||
SELECT 'show_last_price', 'true', 'نمایش آخرین قیمت DB اگر API قطع شد', 1, 1, NULL
|
SELECT 'show_last_price', 'true', 'نمایش آخرین قیمت DB اگر API قطع شد', 1, 1, NULL
|
||||||
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'show_last_price' LIMIT 1);
|
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'show_last_price' LIMIT 1);
|
||||||
@@ -105,10 +101,6 @@ INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `de
|
|||||||
SELECT 'main_product_price', 'false', 'قیمت از محصول (legacy)', 1, 1, 'از price_provider استفاده کنید'
|
SELECT 'main_product_price', 'false', 'قیمت از محصول (legacy)', 1, 1, 'از price_provider استفاده کنید'
|
||||||
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'main_product_price' LIMIT 1);
|
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'main_product_price' LIMIT 1);
|
||||||
|
|
||||||
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
|
|
||||||
SELECT 'tabanGohar_price', 'false', 'قیمت تابان گوهر', 1, 1, NULL
|
|
||||||
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'tabanGohar_price' LIMIT 1);
|
|
||||||
|
|
||||||
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
|
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
|
||||||
SELECT 'montzar_price', 'false', 'قیمت از همکار (montzar)', 1, 1, 'معمولاً false وقتی price_provider=zaarbox'
|
SELECT 'montzar_price', 'false', 'قیمت از همکار (montzar)', 1, 1, 'معمولاً false وقتی price_provider=zaarbox'
|
||||||
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'montzar_price' LIMIT 1);
|
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'montzar_price' LIMIT 1);
|
||||||
@@ -325,7 +317,7 @@ WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'payping_gateway_item'
|
|||||||
-- =============================================================================
|
-- =============================================================================
|
||||||
|
|
||||||
UPDATE `settings` SET `title_fa` = COALESCE(NULLIF(TRIM(`title_fa`), ''), 'منبع قیمت'), `can_edit` = 1,
|
UPDATE `settings` SET `title_fa` = COALESCE(NULLIF(TRIM(`title_fa`), ''), 'منبع قیمت'), `can_edit` = 1,
|
||||||
`description` = 'zaarbox | main_product | montzar | etehadie | taban_gohar'
|
`description` = 'منبع فعال قیمت|montzar,zaarbox,main_product'
|
||||||
WHERE `key` = 'price_provider';
|
WHERE `key` = 'price_provider';
|
||||||
|
|
||||||
UPDATE `settings` SET `title_fa` = COALESCE(NULLIF(TRIM(`title_fa`), ''), 'محصول / UUID تابلو'), `can_edit` = 1
|
UPDATE `settings` SET `title_fa` = COALESCE(NULLIF(TRIM(`title_fa`), ''), 'محصول / UUID تابلو'), `can_edit` = 1
|
||||||
@@ -419,7 +411,7 @@ WHERE `key` = 'main_product';
|
|||||||
UPDATE `settings` SET `type` = 'longtext' WHERE `key` IN ('text_rule', 'text_about');
|
UPDATE `settings` SET `type` = 'longtext' WHERE `key` IN ('text_rule', 'text_about');
|
||||||
|
|
||||||
-- select (+ گزینهها در description)
|
-- select (+ گزینهها در description)
|
||||||
UPDATE `settings` SET `type` = 'select', `description` = 'montzar,zaarbox,main_product,etehadie,taban_gohar' WHERE `key` = 'price_provider';
|
UPDATE `settings` SET `type` = 'select', `description` = 'منبع فعال قیمت|montzar,zaarbox,main_product' WHERE `key` = 'price_provider';
|
||||||
UPDATE `settings` SET `type` = 'select', `description` = 'required = اجباری؛ خالی = اختیاری|required,', `can_edit` = 1 WHERE `key` = 'referral_id';
|
UPDATE `settings` SET `type` = 'select', `description` = 'required = اجباری؛ خالی = اختیاری|required,', `can_edit` = 1 WHERE `key` = 'referral_id';
|
||||||
UPDATE `settings` SET `type` = 'select', `description` = 'sepal,' WHERE `key` = 'payping_gateway_name';
|
UPDATE `settings` SET `type` = 'select', `description` = 'sepal,' WHERE `key` = 'payping_gateway_name';
|
||||||
UPDATE `settings` SET `type` = 'select', `description` = 'bale,telegram,whatsapp,rubika,eitaa,soroush' WHERE `key` = 'support_messenger';
|
UPDATE `settings` SET `type` = 'select', `description` = 'bale,telegram,whatsapp,rubika,eitaa,soroush' WHERE `key` = 'support_messenger';
|
||||||
@@ -427,7 +419,7 @@ UPDATE `settings` SET `type` = 'select', `description` = 'bale,telegram,whatsapp
|
|||||||
-- switch
|
-- switch
|
||||||
UPDATE `settings` SET `type` = 'switch' WHERE `key` IN (
|
UPDATE `settings` SET `type` = 'switch' WHERE `key` IN (
|
||||||
'jibit_verification', 'register_jibit_verify', 'open_register', 'auto_active_customer',
|
'jibit_verification', 'register_jibit_verify', 'open_register', 'auto_active_customer',
|
||||||
'close_price', 'montzar_price', 'main_product_price', 'tabanGohar_price', 'show_last_price',
|
'close_price', 'montzar_price', 'main_product_price', 'show_last_price',
|
||||||
'send_to_tahesab', 'profit_gold_api_enabled', 'payping_round_toman', 'payping_strict_failed_withdraw',
|
'send_to_tahesab', 'profit_gold_api_enabled', 'payping_round_toman', 'payping_strict_failed_withdraw',
|
||||||
'has_page_earn_money', 'has_page_fund', 'has_page_permission', 'has_page_price_trigger',
|
'has_page_earn_money', 'has_page_fund', 'has_page_permission', 'has_page_price_trigger',
|
||||||
'has_page_physical_gold', 'has_chat', 'charge_notif', 'group_sms', 'display_montzar',
|
'has_page_physical_gold', 'has_chat', 'charge_notif', 'group_sms', 'display_montzar',
|
||||||
@@ -469,7 +461,7 @@ UPDATE `settings` SET `type` = 'text' WHERE `type` IS NULL OR TRIM(`type`) = '';
|
|||||||
-- کلیدهای modular اضافی (INSERT اگر نبود)
|
-- کلیدهای modular اضافی (INSERT اگر نبود)
|
||||||
-- ---------------------------------------------------------------------------
|
-- ---------------------------------------------------------------------------
|
||||||
INSERT INTO `settings` (`key`, `title_fa`, `value`, `can_edit`, `is_exist`, `is_active`, `type`, `description`)
|
INSERT INTO `settings` (`key`, `title_fa`, `value`, `can_edit`, `is_exist`, `is_active`, `type`, `description`)
|
||||||
SELECT 'price_provider', 'منبع قیمت', 'montzar', 1, 0, 1, 'select', 'منبع فعال قیمت|montzar,zaarbox,main_product,taban_gohar,etehadie'
|
SELECT 'price_provider', 'منبع قیمت', 'montzar', 1, 0, 1, 'select', 'منبع فعال قیمت|montzar,zaarbox,main_product'
|
||||||
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'price_provider' LIMIT 1);
|
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'price_provider' LIMIT 1);
|
||||||
|
|
||||||
INSERT INTO `settings` (`key`, `title_fa`, `value`, `can_edit`, `is_exist`, `is_active`, `type`)
|
INSERT INTO `settings` (`key`, `title_fa`, `value`, `can_edit`, `is_exist`, `is_active`, `type`)
|
||||||
@@ -551,7 +543,8 @@ WHERE NOT EXISTS (SELECT 1 FROM `const` WHERE `key` = 'liman' LIMIT 1);
|
|||||||
DELETE FROM `settings` WHERE `key` IN (
|
DELETE FROM `settings` WHERE `key` IN (
|
||||||
'test', 'test2', 'test22', 'test3', 'test33', 'longtest', 'longtest2',
|
'test', 'test2', 'test22', 'test3', 'test33', 'longtest', 'longtest2',
|
||||||
'is_requaire_referral', 'send_to_goldir', 'goldir_price', 'liman_token',
|
'is_requaire_referral', 'send_to_goldir', 'goldir_price', 'liman_token',
|
||||||
'melted_product_id', 'display_montzar'
|
'melted_product_id', 'display_montzar', 'tabanGohar_price', 'etehadie_api_url',
|
||||||
|
'price_method', 'price_primary_source'
|
||||||
);
|
);
|
||||||
|
|
||||||
DELETE FROM `const` WHERE `key` = 'log' OR `key` LIKE 'goldir%';
|
DELETE FROM `const` WHERE `key` = 'log' OR `key` LIKE 'goldir%';
|
||||||
@@ -563,9 +556,12 @@ UPDATE `settings` SET `description` = NULL
|
|||||||
WHERE LOWER(TRIM(COALESCE(`description`, ''))) IN ('true', 'false', '0', '1', 'yes', 'no', 'in server')
|
WHERE LOWER(TRIM(COALESCE(`description`, ''))) IN ('true', 'false', '0', '1', 'yes', 'no', 'in server')
|
||||||
OR TRIM(COALESCE(`description`, '')) LIKE 'count of%';
|
OR TRIM(COALESCE(`description`, '')) LIKE 'count of%';
|
||||||
|
|
||||||
UPDATE `settings` SET `description` = 'منبع فعال قیمت|montzar,zaarbox,main_product,taban_gohar,etehadie'
|
UPDATE `settings` SET `description` = 'منبع فعال قیمت|montzar,zaarbox,main_product'
|
||||||
WHERE `key` = 'price_provider';
|
WHERE `key` = 'price_provider';
|
||||||
|
|
||||||
|
UPDATE `settings` SET `value` = 'montzar'
|
||||||
|
WHERE `key` = 'price_provider' AND LOWER(TRIM(`value`)) IN ('taban_gohar', 'etehadie');
|
||||||
|
|
||||||
UPDATE `settings` SET `description` = 'required = اجباری|required,', `title_fa` = 'کد معرف', `type` = 'select'
|
UPDATE `settings` SET `description` = 'required = اجباری|required,', `title_fa` = 'کد معرف', `type` = 'select'
|
||||||
WHERE `key` = 'referral_id';
|
WHERE `key` = 'referral_id';
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
-- حذف تابانگوهر و منابع قیمت legacy — برای همه پروژهها (ابشده خانگی، گلد علی، قطره، کشکول)
|
||||||
|
-- قبل از اجرا: بکاپ DB
|
||||||
|
|
||||||
|
START TRANSACTION;
|
||||||
|
|
||||||
|
DELETE FROM `settings` WHERE `key` IN (
|
||||||
|
'tabanGohar_price',
|
||||||
|
'etehadie_api_url',
|
||||||
|
'price_method',
|
||||||
|
'price_primary_source'
|
||||||
|
);
|
||||||
|
|
||||||
|
UPDATE `settings`
|
||||||
|
SET
|
||||||
|
`value` = CASE
|
||||||
|
WHEN LOWER(TRIM(`value`)) IN ('taban_gohar', 'etehadie') THEN 'montzar'
|
||||||
|
ELSE `value`
|
||||||
|
END,
|
||||||
|
`description` = 'منبع فعال قیمت|montzar,zaarbox,main_product',
|
||||||
|
`type` = 'select'
|
||||||
|
WHERE `key` = 'price_provider';
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
Reference in New Issue
Block a user