diff --git a/app/Http/Controllers/Admin/CustomerController.php b/app/Http/Controllers/Admin/CustomerController.php index c293e62..2496d80 100644 --- a/app/Http/Controllers/Admin/CustomerController.php +++ b/app/Http/Controllers/Admin/CustomerController.php @@ -167,7 +167,7 @@ class CustomerController extends SuperController $customer = Customer::findOrFail($customerId); return response()->json( - $assetSummaryService->buildForCustomer((int) $customer->id, (int) $customer->type) + $assetSummaryService->buildForCustomer((int) $customer->id, (int) $customer->type, true) ); } diff --git a/app/Http/Controllers/Admin/WalletController.php b/app/Http/Controllers/Admin/WalletController.php index 15384e7..b445f3a 100644 --- a/app/Http/Controllers/Admin/WalletController.php +++ b/app/Http/Controllers/Admin/WalletController.php @@ -234,7 +234,7 @@ class WalletController extends Controller return response()->json(true); } - /** گزینه‌های شارژ کیف پول — نقدی + محصولات فعال */ + /** گزینه‌های شارژ کیف پول — نقدی + همهٔ محصولات (فعال و غیرفعال) */ public function chargeTargets() { $configService = app(ConfigService::class); @@ -247,14 +247,15 @@ class WalletController extends Controller 'kind' => 'money', 'label' => 'نقدی (ریال)', 'unit' => 'ریال', + 'active' => true, ], ]; $products = Product::query() - ->where('active', 1) + ->orderByDesc('active') ->orderBy('metal_id') ->orderBy('id') - ->get(['id', 'title', 'unit', 'metal_id', 'group_type', 'trade_by_quantity', 'amount', 'direct_price']); + ->get(['id', 'title', 'unit', 'metal_id', 'group_type', 'trade_by_quantity', 'amount', 'direct_price', 'active']); foreach ($products as $product) { $usesMainWallet = in_array((int) $product->id, $mainWalletProductIds, true); @@ -262,6 +263,9 @@ class WalletController extends Controller if ($usesMainWallet) { $label .= ' (کیف اصلی)'; } + if (!(bool) $product->active) { + $label .= ' (غیرفعال)'; + } $targets[] = [ 'key' => 'product:' . $product->id, @@ -273,6 +277,7 @@ class WalletController extends Controller 'uses_main_wallet' => $usesMainWallet, 'trade_by_quantity' => (bool) $product->trade_by_quantity, 'group_type' => (string) ($product->group_type ?? ''), + 'active' => (bool) $product->active, ]; } diff --git a/app/Services/AssetSummaryService.php b/app/Services/AssetSummaryService.php index 41e3cba..829b090 100644 --- a/app/Services/AssetSummaryService.php +++ b/app/Services/AssetSummaryService.php @@ -24,12 +24,13 @@ class AssetSummaryService ) { } - public function buildForCustomer(int $customerId, int $ownerType): array + public function buildForCustomer(int $customerId, int $ownerType, bool $includeInactiveProducts = false): array { - $catalog = Product::query() - ->where('active', 1) - ->with('file') - ->get(); + $catalogQuery = Product::query()->with('file'); + if (!$includeInactiveProducts) { + $catalogQuery->where('active', 1); + } + $catalog = $catalogQuery->get(); $userWallets = Wallet::query() ->with(['product.file'])