added merge wallet

This commit is contained in:
2026-06-10 16:57:31 +03:30
parent bb94f7a5ba
commit 285767fcd3
5 changed files with 202 additions and 10 deletions
+32
View File
@@ -116,6 +116,38 @@ class ConfigService
return in_array($default, self::PRICE_PROVIDERS, true) ? $default : 'montzar';
}
/**
* محصولات متصل به کیف اصلی — setting `main_wallet_products`.
* مقدار: idها با کاما (مثل «13,25») یا آرایه JSON (مثل «[13,25]»).
* موجودی این محصولات = gold کیف اصلی (دارایی جدا ندارند).
* فقط opt-in: اگر ست نباشد آرایه خالی برمی‌گردد و رفتار قبلی حفظ می‌شود.
*/
public function mainWalletProductIds(): array
{
$raw = trim($this->getString('main_wallet_products', ''));
if ($raw === '') {
return [];
}
$decoded = json_decode($raw, true);
$parts = is_array($decoded) ? $decoded : explode(',', $raw);
$ids = [];
foreach ($parts as $part) {
$id = (int) trim((string) $part);
if ($id > 0) {
$ids[] = $id;
}
}
return array_values(array_unique($ids));
}
public function isMainWalletProduct(int $productId): bool
{
return in_array($productId, $this->mainWalletProductIds(), true);
}
/**
* شناسه محصول آبشده: اول settings، بعد const.
* مقدار settings می‌تواند id عددی (مثل 13) یا reading_method (مثل estjt_...) باشد.