etehadie removed
This commit is contained in:
@@ -11,7 +11,6 @@ use App\Models\Product;
|
|||||||
use App\Models\TransactionsAdmin;
|
use App\Models\TransactionsAdmin;
|
||||||
use App\Models\Withdraw;
|
use App\Models\Withdraw;
|
||||||
use App\Services\ConfigService;
|
use App\Services\ConfigService;
|
||||||
use App\Services\EtehadiePriceService;
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Hekmatinasser\Verta\Verta;
|
use Hekmatinasser\Verta\Verta;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -87,13 +86,14 @@ class DashboardController extends Controller
|
|||||||
|
|
||||||
$gramPrice = (int) ($tallaPrice->price ?? 0);
|
$gramPrice = (int) ($tallaPrice->price ?? 0);
|
||||||
$FPrices = [];
|
$FPrices = [];
|
||||||
if (app(ConfigService::class)->usesEtehadiePricing()) {
|
$mainProductId = app(ConfigService::class)->mainProductId();
|
||||||
$etehadie = app(EtehadiePriceService::class)->fetchMainGramPrice();
|
if ($mainProductId) {
|
||||||
if (($etehadie['price'] ?? 0) > 0) {
|
$mainProduct = Product::find($mainProductId);
|
||||||
$gramPrice = (int) round($etehadie['price'] / 10);
|
if ($mainProduct) {
|
||||||
|
$gramPrice = (int) ($mainProduct->price + ($mainProduct->price_profit ?? 0));
|
||||||
$FPrices[] = [
|
$FPrices[] = [
|
||||||
'id' => 'etehadie',
|
'id' => 'main_product',
|
||||||
'name' => 'اتحادیه',
|
'name' => $mainProduct->title ?? 'محصول اصلی',
|
||||||
'price' => $gramPrice,
|
'price' => $gramPrice,
|
||||||
'profit' => 0,
|
'profit' => 0,
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ class ProductController extends SuperController
|
|||||||
// }catch (\Exception $e){}
|
// }catch (\Exception $e){}
|
||||||
|
|
||||||
$config = app(ConfigService::class);
|
$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;
|
$hasExtremeKeys = Setting::whereIn('key', ['up_price', 'down_price'])->count() === 2;
|
||||||
$products = Product::with([])->whereNotNull('reading_method')->get();
|
$products = Product::with([])->whereNotNull('reading_method')->get();
|
||||||
foreach ($products as $product) {
|
foreach ($products as $product) {
|
||||||
|
|||||||
@@ -10,7 +10,10 @@ use Illuminate\Support\Facades\Artisan;
|
|||||||
class SettingsController extends Controller
|
class SettingsController extends Controller
|
||||||
{
|
{
|
||||||
public function index(){
|
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);
|
return response()->json($Setting);
|
||||||
}
|
}
|
||||||
public function edit(Request $request)
|
public function edit(Request $request)
|
||||||
@@ -19,23 +22,25 @@ class SettingsController extends Controller
|
|||||||
$setting = Setting::where('key', $request->key)->first();
|
$setting = Setting::where('key', $request->key)->first();
|
||||||
|
|
||||||
if ($setting) {
|
if ($setting) {
|
||||||
// Update the existing setting
|
|
||||||
$setting->value = $request->value;
|
$setting->value = $request->value;
|
||||||
$setting->description = $request->description;
|
$setting->description = $request->description;
|
||||||
$setting->is_active = $request->is_active;
|
$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();
|
$setting->save();
|
||||||
} else {
|
} else {
|
||||||
// Create a new setting
|
|
||||||
$setting = new Setting();
|
$setting = new Setting();
|
||||||
$setting->key = $request->key;
|
$setting->key = $request->key;
|
||||||
$setting->type = $request->type??$request->type??'';
|
$setting->title_fa = $request->title_fa ?? '';
|
||||||
$setting->title_fa = $request->title_fa??$setting->title_fa??'';
|
|
||||||
$setting->value = $request->value;
|
$setting->value = $request->value;
|
||||||
$setting->description = $request->description;
|
$setting->description = $request->description;
|
||||||
$setting->is_active = $request->is_active;
|
$setting->is_active = $request->is_active;
|
||||||
$setting->can_edit = 1;
|
$setting->can_edit = 1;
|
||||||
|
if (Setting::hasTypeColumn()) {
|
||||||
|
$setting->type = $request->type ?? '';
|
||||||
|
}
|
||||||
$setting->save();
|
$setting->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ class SingleOrderController extends Controller
|
|||||||
} else {
|
} else {
|
||||||
// Calculate total price and fee for non-product (gold) transaction
|
// Calculate total price and fee for non-product (gold) transaction
|
||||||
$data['total_price_original'] = $data['amount'] * ($data['price_original'] ?? 0);
|
$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;
|
$productId = $data['abshode_id'] ?? $data['product_id'] ?? $mainProductId;
|
||||||
$data['product'] = $productId ? Product::find($productId) : null;
|
$data['product'] = $productId ? Product::find($productId) : null;
|
||||||
if (!$data['product']) {
|
if (!$data['product']) {
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ use App\Models\Setting;
|
|||||||
use App\Models\ConfigStatic;
|
use App\Models\ConfigStatic;
|
||||||
use App\Models\Customer;
|
use App\Models\Customer;
|
||||||
use App\Services\MontzarService;
|
use App\Services\MontzarService;
|
||||||
use App\Services\EtehadiePriceService;
|
|
||||||
use App\Models\Price;
|
use App\Models\Price;
|
||||||
use App\Models\PriceCandle;
|
use App\Models\PriceCandle;
|
||||||
use App\Models\PriceTrigger;
|
use App\Models\PriceTrigger;
|
||||||
@@ -141,7 +140,6 @@ class ReportController extends Controller
|
|||||||
$closed = false;
|
$closed = false;
|
||||||
|
|
||||||
$montzar_price = 0;
|
$montzar_price = 0;
|
||||||
$etehadie_teh = 0;
|
|
||||||
$tgn = 0;
|
$tgn = 0;
|
||||||
$pr_price = 0;
|
$pr_price = 0;
|
||||||
|
|
||||||
@@ -167,7 +165,6 @@ class ReportController extends Controller
|
|||||||
'main_product' => 0,
|
'main_product' => 0,
|
||||||
'taban_gohar' => 0,
|
'taban_gohar' => 0,
|
||||||
'montzar' => 0,
|
'montzar' => 0,
|
||||||
'etehadie_teh' => 0,
|
|
||||||
'closed' => true,
|
'closed' => true,
|
||||||
'time' => now(),
|
'time' => now(),
|
||||||
]);
|
]);
|
||||||
@@ -227,18 +224,6 @@ class ReportController extends Controller
|
|||||||
$diff_buy = (float) $settingsMap->get('buy_fee', $difference);
|
$diff_buy = (float) $settingsMap->get('buy_fee', $difference);
|
||||||
$diff_sell = (float) $settingsMap->get('sell_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
|
| Montzar — فقط وقتی price_provider=montzar
|
||||||
@@ -322,17 +307,16 @@ class ReportController extends Controller
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Main Product
|
| Main Product — settings.main_product سپس const
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| عمومی است، پس از Cnt خوانده میشود.
|
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
if ($toBool($main_product_price) && !$closed) {
|
$main_product_id = $config->mainProductId();
|
||||||
$main_product_id = Cnt::where('key', 'main_product')->value('value');
|
if ($main_product_id && !$closed) {
|
||||||
$pr_product = $main_product_id ? Product::find($main_product_id) : null;
|
if ($priceProvider === 'main_product' || $toBool($main_product_price)) {
|
||||||
|
$pr_product = Product::find($main_product_id);
|
||||||
if ($pr_product) {
|
if ($pr_product) {
|
||||||
$pr_price = (float) $pr_product['price'] + (float) $pr_product['price_profit'];
|
$pr_price = (float) $pr_product['price'] + (float) $pr_product['price_profit'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -365,16 +349,13 @@ class ReportController extends Controller
|
|||||||
| انتخاب قیمت اصلی (همان price_provider)
|
| انتخاب قیمت اصلی (همان price_provider)
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
if ($priceProvider === 'etehadie' && $etehadie_teh > 0 && !$closed) {
|
if ($priceProvider === 'montzar' && ($montzar_price ?? 0) !== 0 && !$closed) {
|
||||||
$priceValue = (int) $etehadie_teh;
|
|
||||||
$priceSource = 'etehadie';
|
|
||||||
} 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) {
|
} elseif ($priceProvider === 'taban_gohar' && $toBool($taban_gohar_price) && ($tgn ?? 0) !== 0 && !$closed) {
|
||||||
$priceValue = $tgn;
|
$priceValue = $tgn;
|
||||||
$priceSource = 'taban_gohar';
|
$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;
|
$priceValue = $pr_price;
|
||||||
$priceSource = 'main_product';
|
$priceSource = 'main_product';
|
||||||
} else {
|
} else {
|
||||||
@@ -392,7 +373,6 @@ class ReportController extends Controller
|
|||||||
'main_product' => $pr_price ?? 0,
|
'main_product' => $pr_price ?? 0,
|
||||||
'taban_gohar' => $tgn ?? 0,
|
'taban_gohar' => $tgn ?? 0,
|
||||||
'montzar' => $montzar_price ?? 0,
|
'montzar' => $montzar_price ?? 0,
|
||||||
'etehadie_teh' => $etehadie_teh ?? 0,
|
|
||||||
'closed' => true,
|
'closed' => true,
|
||||||
'time' => now(),
|
'time' => now(),
|
||||||
]);
|
]);
|
||||||
@@ -409,7 +389,6 @@ class ReportController extends Controller
|
|||||||
'main_product' => $pr_price ?? 0,
|
'main_product' => $pr_price ?? 0,
|
||||||
'taban_gohar' => $tgn ?? 0,
|
'taban_gohar' => $tgn ?? 0,
|
||||||
'montzar' => $montzar_price ?? 0,
|
'montzar' => $montzar_price ?? 0,
|
||||||
'etehadie_teh' => $etehadie_teh ?? 0,
|
|
||||||
'closed' => true,
|
'closed' => true,
|
||||||
'time' => now(),
|
'time' => now(),
|
||||||
]);
|
]);
|
||||||
@@ -425,9 +404,6 @@ class ReportController extends Controller
|
|||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
$priceToStore = $priceValue;
|
$priceToStore = $priceValue;
|
||||||
if ($priceProvider === 'etehadie' && $etehadie_order_price > 0) {
|
|
||||||
$priceToStore = $etehadie_order_price;
|
|
||||||
}
|
|
||||||
|
|
||||||
$lastPrice = Price::latest()->first();
|
$lastPrice = Price::latest()->first();
|
||||||
|
|
||||||
@@ -502,11 +478,9 @@ class ReportController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
| گلد علی (etehadie): سفارش از Price::latest() میخواند؛
|
| main_product / گلد علی: سفارش از Price::latest() — نمایش buy/sell همان منبع.
|
||||||
| buy/sell/price_last هم از همان ردیف (مثل goldAliii قبل از مرج).
|
|
||||||
| etehadie_teh فقط در فیلد price / etehadie_teh میماند.
|
|
||||||
*/
|
*/
|
||||||
if ($priceProvider === 'etehadie' && !$closed) {
|
if ($priceProvider === 'main_product' && !$closed) {
|
||||||
$storedPrice = $lastPrice ?? Price::latest()->first();
|
$storedPrice = $lastPrice ?? Price::latest()->first();
|
||||||
if ($storedPrice && (float) $storedPrice->price > 0) {
|
if ($storedPrice && (float) $storedPrice->price > 0) {
|
||||||
$base = (float) $storedPrice->price;
|
$base = (float) $storedPrice->price;
|
||||||
@@ -528,7 +502,6 @@ class ReportController extends Controller
|
|||||||
'main_product' => $pr_price ?? 0,
|
'main_product' => $pr_price ?? 0,
|
||||||
'taban_gohar' => $tgn ?? 0,
|
'taban_gohar' => $tgn ?? 0,
|
||||||
'montzar' => $montzar_price ?? 0,
|
'montzar' => $montzar_price ?? 0,
|
||||||
'etehadie_teh' => $etehadie_teh ?? 0,
|
|
||||||
'closed' => false,
|
'closed' => false,
|
||||||
'time' => now(),
|
'time' => now(),
|
||||||
]);
|
]);
|
||||||
|
|||||||
+32
-1
@@ -6,19 +6,50 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
use Illuminate\Support\Facades\Hash;
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
use Rooyesh\Wallet\models\Transaction;
|
use Rooyesh\Wallet\models\Transaction;
|
||||||
use Tymon\JWTAuth\Contracts\JWTSubject;
|
use Tymon\JWTAuth\Contracts\JWTSubject;
|
||||||
|
|
||||||
class Setting extends Model
|
class Setting extends Model
|
||||||
{
|
{
|
||||||
use HasFactory,Selector;
|
use HasFactory,Selector;
|
||||||
|
|
||||||
|
private static ?bool $typeColumnExists = null;
|
||||||
|
|
||||||
|
public static function hasTypeColumn(): bool
|
||||||
|
{
|
||||||
|
if (static::$typeColumnExists !== null) {
|
||||||
|
return static::$typeColumnExists;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
static::$typeColumnExists = Schema::hasColumn((new static)->getTable(), 'type');
|
||||||
|
} catch (\Throwable) {
|
||||||
|
static::$typeColumnExists = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return static::$typeColumnExists;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @return array<int, string> */
|
||||||
|
public static function adminSelectColumns(): array
|
||||||
|
{
|
||||||
|
$cols = ['id', 'title_fa', 'key', 'value', 'description', 'is_active'];
|
||||||
|
if (static::hasTypeColumn()) {
|
||||||
|
$cols[] = 'type';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $cols;
|
||||||
|
}
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'key',
|
'key',
|
||||||
'title_fa',
|
'title_fa',
|
||||||
'is_active',
|
'is_active',
|
||||||
'description',
|
'description',
|
||||||
'value',
|
'value',
|
||||||
'value_json'
|
'value_json',
|
||||||
|
'type',
|
||||||
];
|
];
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
'value_json'=>'array',
|
'value_json'=>'array',
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Services;
|
namespace App\Services;
|
||||||
|
|
||||||
|
use App\Models\Cnt;
|
||||||
use App\Models\Setting;
|
use App\Models\Setting;
|
||||||
|
|
||||||
class ConfigService
|
class ConfigService
|
||||||
@@ -60,8 +61,7 @@ class ConfigService
|
|||||||
* اولویت:
|
* اولویت:
|
||||||
* 1) price_provider (یا price_primary_source قدیمی)
|
* 1) price_provider (یا price_primary_source قدیمی)
|
||||||
* 2) montzar_price=true → montzar (ابشده خانگی و پروژههای فعلی)
|
* 2) montzar_price=true → montzar (ابشده خانگی و پروژههای فعلی)
|
||||||
* 3) price_method پر و montzar خاموش → etehadie (گلد علی)
|
* 3) پیشفرض فایل: montzar
|
||||||
* 4) پیشفرض فایل: montzar
|
|
||||||
*/
|
*/
|
||||||
public function priceProvider(): string
|
public function priceProvider(): string
|
||||||
{
|
{
|
||||||
@@ -76,15 +76,29 @@ class ConfigService
|
|||||||
return 'montzar';
|
return 'montzar';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->getString('price_method') !== '') {
|
|
||||||
return 'etehadie';
|
|
||||||
}
|
|
||||||
|
|
||||||
$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';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* شناسه محصول آبشده پیشفرض: اول settings، بعد جدول const.
|
||||||
|
*/
|
||||||
|
public function mainProductId(): ?int
|
||||||
|
{
|
||||||
|
$fromSettings = $this->getString('main_product', '');
|
||||||
|
if ($fromSettings !== '' && is_numeric($fromSettings)) {
|
||||||
|
return (int) $fromSettings;
|
||||||
|
}
|
||||||
|
|
||||||
|
$fromConst = Cnt::where('key', 'main_product')->value('value');
|
||||||
|
if ($fromConst !== null && $fromConst !== '' && is_numeric($fromConst)) {
|
||||||
|
return (int) $fromConst;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/** @deprecated از priceProvider() استفاده کن */
|
/** @deprecated از priceProvider() استفاده کن */
|
||||||
public function pricePrimarySource(): string
|
public function pricePrimarySource(): string
|
||||||
{
|
{
|
||||||
@@ -103,6 +117,11 @@ class ConfigService
|
|||||||
return $this->priceProvider() === 'etehadie';
|
return $this->priceProvider() === 'etehadie';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function usesMainProductPricing(): bool
|
||||||
|
{
|
||||||
|
return $this->priceProvider() === 'main_product';
|
||||||
|
}
|
||||||
|
|
||||||
public function UpdateConfig($name, $value)
|
public function UpdateConfig($name, $value)
|
||||||
{
|
{
|
||||||
return Setting::updateOrCreate(
|
return Setting::updateOrCreate(
|
||||||
|
|||||||
@@ -8,7 +8,8 @@
|
|||||||
*
|
*
|
||||||
* سازگاری قدیمی (بدون price_provider):
|
* سازگاری قدیمی (بدون price_provider):
|
||||||
* montzar_price=true → montzar
|
* montzar_price=true → montzar
|
||||||
* price_method پر و montzar خاموش → etehadie
|
*
|
||||||
|
* main_product: شناسه محصول در settings (کلید main_product)، وگرنه const
|
||||||
*/
|
*/
|
||||||
return [
|
return [
|
||||||
'price_provider' => 'montzar',
|
'price_provider' => 'montzar',
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
-- گلد علی — حذف کلیدهای legacy که سرور Abshode_Khanegi (etehadie) دیگر نمیخواند
|
-- گلد علی — حذف کلیدهای legacy (لیمان/منتزر/اتحادیه)
|
||||||
-- قبل از اجرا: بکاپ. جدول const یا cnt بسته به اسکیمای شما.
|
-- قبل از اجرا: بکاپ. جدول const یا cnt بسته به اسکیمای شما.
|
||||||
|
|
||||||
START TRANSACTION;
|
START TRANSACTION;
|
||||||
|
|||||||
@@ -3,6 +3,16 @@
|
|||||||
|
|
||||||
START TRANSACTION;
|
START TRANSACTION;
|
||||||
|
|
||||||
|
-- قیمت: محصول اصلی (نه اتحادیه)
|
||||||
|
UPDATE `settings` SET `value` = 'main_product' WHERE `key` = 'price_provider';
|
||||||
|
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
|
||||||
|
SELECT 'price_provider', 'main_product', 'منبع قیمت', 1, 1, 'main_product برای گلد علی'
|
||||||
|
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'price_provider' LIMIT 1);
|
||||||
|
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
|
||||||
|
SELECT 'main_product', '13', 'شناسه محصول آبشده', 1, 1, 'اول settings، بعد const'
|
||||||
|
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'main_product' LIMIT 1);
|
||||||
|
UPDATE `settings` SET `value` = '13' WHERE `key` = 'main_product';
|
||||||
|
|
||||||
-- درگاه (اگر قبلاً نزدهاید)
|
-- درگاه (اگر قبلاً نزدهاید)
|
||||||
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 'payping_start_url', 'https://payment.goldaliii.com/payment/start', 'آدرس شروع درگاه', 1, 1, NULL
|
SELECT 'payping_start_url', 'https://payment.goldaliii.com/payment/start', 'آدرس شروع درگاه', 1, 1, NULL
|
||||||
@@ -84,4 +94,9 @@ WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'fee_service_charge_per
|
|||||||
UPDATE `settings` SET `value` = '0' WHERE `key` = 'fee_cash';
|
UPDATE `settings` SET `value` = '0' WHERE `key` = 'fee_cash';
|
||||||
UPDATE `settings` SET `value` = '0.02' WHERE `key` = 'fee_service_charge_percentage';
|
UPDATE `settings` SET `value` = '0.02' WHERE `key` = 'fee_service_charge_percentage';
|
||||||
|
|
||||||
|
-- ستون type (ادمین Abshode — اختیاری؛ کد بدون آن هم کار میکند)
|
||||||
|
-- اگر خطای Duplicate column name گرفتید، یعنی قبلاً اضافه شده — رد کنید.
|
||||||
|
ALTER TABLE `settings`
|
||||||
|
ADD COLUMN `type` VARCHAR(64) NULL DEFAULT NULL COMMENT 'نوع فیلد در پنل ادمین' AFTER `description`;
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|||||||
@@ -8,13 +8,17 @@
|
|||||||
START TRANSACTION;
|
START TRANSACTION;
|
||||||
|
|
||||||
-- -----------------------------------------------------------------------------
|
-- -----------------------------------------------------------------------------
|
||||||
-- ۱) قیمت — منبع اتحادیه (مثل goldAliii + price_method قبلی)
|
-- ۱) قیمت — محصول اصلی (نه اتحادیه)؛ main_product اول settings بعد const
|
||||||
-- -----------------------------------------------------------------------------
|
-- -----------------------------------------------------------------------------
|
||||||
UPDATE `settings` SET `value` = 'etehadie' WHERE `key` = 'price_provider';
|
UPDATE `settings` SET `value` = 'main_product' WHERE `key` = 'price_provider';
|
||||||
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 'price_provider', 'etehadie', 'منبع قیمت', 1, 1, 'montzar|etehadie|...'
|
SELECT 'price_provider', 'main_product', 'منبع قیمت', 1, 1, 'montzar|main_product|taban_gohar'
|
||||||
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);
|
||||||
-- price_method را عوض نکنید (همان estjt_... گلد علی)
|
|
||||||
|
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
|
||||||
|
SELECT 'main_product', '13', 'شناسه محصول آبشده پیشفرض', 1, 1, 'اولویت بر const'
|
||||||
|
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'main_product' LIMIT 1);
|
||||||
|
UPDATE `settings` SET `value` = '13' WHERE `key` = 'main_product';
|
||||||
|
|
||||||
-- نمایش buy/sell در /api/price/last (ریال — جدا از کارمزد سفارش)
|
-- نمایش buy/sell در /api/price/last (ریال — جدا از کارمزد سفارش)
|
||||||
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
|
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
|
||||||
@@ -95,10 +99,10 @@ UPDATE `settings` SET `value` = 'sDsB,gp1Q,GPH4,AMAX,TbQl,AAQl' WHERE `key` = 'p
|
|||||||
UPDATE `settings` SET `value` = 'true' WHERE `key` IN ('payping_round_toman', 'payping_strict_failed_withdraw');
|
UPDATE `settings` SET `value` = 'true' WHERE `key` IN ('payping_round_toman', 'payping_strict_failed_withdraw');
|
||||||
|
|
||||||
-- -----------------------------------------------------------------------------
|
-- -----------------------------------------------------------------------------
|
||||||
-- ۵) const — محصول آبشده پیشفرض (قبلاً abshode_id=13 در کد بود)
|
-- ۵) const — fallback اگر settings.main_product نبود
|
||||||
-- -----------------------------------------------------------------------------
|
-- -----------------------------------------------------------------------------
|
||||||
INSERT INTO `const` (`key`, `value`, `title_fa`)
|
INSERT INTO `const` (`key`, `value`, `title_fa`)
|
||||||
SELECT 'main_product', '13', 'محصول آبشده پیشفرض'
|
SELECT 'main_product', '13', 'محصول آبشده پیشفرض (fallback)'
|
||||||
WHERE NOT EXISTS (SELECT 1 FROM `const` WHERE `key` = 'main_product' LIMIT 1);
|
WHERE NOT EXISTS (SELECT 1 FROM `const` WHERE `key` = 'main_product' LIMIT 1);
|
||||||
UPDATE `const` SET `value` = '13' WHERE `key` = 'main_product';
|
UPDATE `const` SET `value` = '13' WHERE `key` = 'main_product';
|
||||||
|
|
||||||
@@ -123,6 +127,13 @@ WHERE NOT EXISTS (SELECT 1 FROM `const` WHERE `key` = 'first_customer_wallet_val
|
|||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
||||||
|
-- -----------------------------------------------------------------------------
|
||||||
|
-- ۵b) اسکیما — ستون type در settings (اختیاری؛ کد بدون آن هم کار میکند)
|
||||||
|
-- اگر Duplicate column name → قبلاً اضافه شده.
|
||||||
|
-- -----------------------------------------------------------------------------
|
||||||
|
-- ALTER TABLE `settings`
|
||||||
|
-- ADD COLUMN `type` VARCHAR(64) NULL DEFAULT NULL COMMENT 'نوع فیلد در پنل ادمین' AFTER `description`;
|
||||||
|
|
||||||
-- -----------------------------------------------------------------------------
|
-- -----------------------------------------------------------------------------
|
||||||
-- ۶) اختیاری — حذف کلیدهای legacy (بعد از تست)
|
-- ۶) اختیاری — حذف کلیدهای legacy (بعد از تست)
|
||||||
-- فایل جدا: goldali_cleanup_legacy_keys.sql
|
-- فایل جدا: goldali_cleanup_legacy_keys.sql
|
||||||
@@ -134,7 +145,7 @@ COMMIT;
|
|||||||
|
|
||||||
-- بررسی:
|
-- بررسی:
|
||||||
-- SELECT `key`, `value` FROM `settings` WHERE `key` IN (
|
-- SELECT `key`, `value` FROM `settings` WHERE `key` IN (
|
||||||
-- 'price_provider','price_method','fee_cash','fee_service_charge_percentage',
|
-- 'price_provider','main_product','fee_cash','fee_service_charge_percentage',
|
||||||
-- 'fee_single','payping_start_url','profit_gold_api_enabled'
|
-- 'fee_single','payping_start_url','profit_gold_api_enabled'
|
||||||
-- );
|
-- );
|
||||||
-- SELECT `key`, `value` FROM `const` WHERE `key` IN ('main_product','is_gateway_open');
|
-- SELECT `key`, `value` FROM `const` WHERE `key` IN ('main_product','is_gateway_open');
|
||||||
|
|||||||
@@ -56,9 +56,12 @@ UPDATE `const` SET `title_fa` = 'بنر بالای صفحه' WHERE `key` = 'head
|
|||||||
|
|
||||||
-- منبع قیمت: اتحادیه (تنها منبع فعال در کد مرجشده)
|
-- منبع قیمت: اتحادیه (تنها منبع فعال در کد مرجشده)
|
||||||
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 'price_provider', 'etehadie', 'منبع قیمت',
|
SELECT 'price_provider', 'main_product', 'منبع قیمت',
|
||||||
1, 1, 'فقط یکی: montzar | etehadie | taban_gohar | main_product'
|
1, 1, 'گلد علی: main_product — montzar | taban_gohar | 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`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
|
||||||
|
SELECT 'main_product', '13', 'شناسه محصول آبشده', 1, 1, 'اول settings، بعد const'
|
||||||
|
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'main_product' LIMIT 1);
|
||||||
|
|
||||||
-- کارمزد نمایش buy/sell در /api/price/last — کد fee_single میخواند (نه fee)
|
-- کارمزد نمایش buy/sell در /api/price/last — کد fee_single میخواند (نه fee)
|
||||||
-- مقدار 500000 = پیشفرض config/fee.php؛ اگر برای گلد علی عدد دیگری دارید بعداً در پنل عوض کنید
|
-- مقدار 500000 = پیشفرض config/fee.php؛ اگر برای گلد علی عدد دیگری دارید بعداً در پنل عوض کنید
|
||||||
@@ -95,9 +98,9 @@ WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'balance_report_exclude
|
|||||||
-- بخش ۳ — فقط چند UPDATE مطمئن (کلیدهای مربوط به کد جدید)
|
-- بخش ۳ — فقط چند UPDATE مطمئن (کلیدهای مربوط به کد جدید)
|
||||||
-- =============================================================================
|
-- =============================================================================
|
||||||
|
|
||||||
-- price_provider حتماً اتحادیه (ردیف بخش ۲ ساخته یا از قبل بوده)
|
UPDATE `settings` SET `value` = 'main_product', `title_fa` = COALESCE(NULLIF(TRIM(`title_fa`), ''), 'منبع قیمت')
|
||||||
UPDATE `settings` SET `value` = 'etehadie', `title_fa` = COALESCE(NULLIF(TRIM(`title_fa`), ''), 'منبع قیمت')
|
|
||||||
WHERE `key` = 'price_provider';
|
WHERE `key` = 'price_provider';
|
||||||
|
UPDATE `settings` SET `value` = '13' WHERE `key` = 'main_product';
|
||||||
UPDATE `settings` SET `value` = 'true' WHERE `key` = 'profit_gold_api_enabled';
|
UPDATE `settings` SET `value` = 'true' WHERE `key` = 'profit_gold_api_enabled';
|
||||||
UPDATE `settings` SET `is_active` = 1 WHERE `key` = 'open_register';
|
UPDATE `settings` SET `is_active` = 1 WHERE `key` = 'open_register';
|
||||||
UPDATE `settings` SET `value` = '12' WHERE `key` = 'balance_report_exclude_customer_id';
|
UPDATE `settings` SET `value` = '12' WHERE `key` = 'balance_report_exclude_customer_id';
|
||||||
|
|||||||
+1
-1
@@ -33,7 +33,7 @@ Route::middleware('auth:customer')->group(function () {
|
|||||||
//---------PriceTrigger
|
//---------PriceTrigger
|
||||||
Route::resource('price_triggers', PriceTriggerController::class);
|
Route::resource('price_triggers', PriceTriggerController::class);
|
||||||
$cfg = app(ConfigService::class);
|
$cfg = app(ConfigService::class);
|
||||||
if ($cfg->getBool('profit_gold_api_enabled', false) || $cfg->usesEtehadiePricing()) {
|
if ($cfg->getBool('profit_gold_api_enabled', false)) {
|
||||||
Route::get('profit_gold', [OrderController::class, 'profit_gold']);
|
Route::get('profit_gold', [OrderController::class, 'profit_gold']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user