added charge for all products

This commit is contained in:
2026-07-11 17:59:50 +03:30
parent 47a2f8e6bf
commit 0d78bcb750
3 changed files with 15 additions and 9 deletions
@@ -167,7 +167,7 @@ class CustomerController extends SuperController
$customer = Customer::findOrFail($customerId); $customer = Customer::findOrFail($customerId);
return response()->json( return response()->json(
$assetSummaryService->buildForCustomer((int) $customer->id, (int) $customer->type) $assetSummaryService->buildForCustomer((int) $customer->id, (int) $customer->type, true)
); );
} }
@@ -234,7 +234,7 @@ class WalletController extends Controller
return response()->json(true); return response()->json(true);
} }
/** گزینه‌های شارژ کیف پول — نقدی + محصولات فعال */ /** گزینه‌های شارژ کیف پول — نقدی + همهٔ محصولات (فعال و غیرفعال) */
public function chargeTargets() public function chargeTargets()
{ {
$configService = app(ConfigService::class); $configService = app(ConfigService::class);
@@ -247,14 +247,15 @@ class WalletController extends Controller
'kind' => 'money', 'kind' => 'money',
'label' => 'نقدی (ریال)', 'label' => 'نقدی (ریال)',
'unit' => 'ریال', 'unit' => 'ریال',
'active' => true,
], ],
]; ];
$products = Product::query() $products = Product::query()
->where('active', 1) ->orderByDesc('active')
->orderBy('metal_id') ->orderBy('metal_id')
->orderBy('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) { foreach ($products as $product) {
$usesMainWallet = in_array((int) $product->id, $mainWalletProductIds, true); $usesMainWallet = in_array((int) $product->id, $mainWalletProductIds, true);
@@ -262,6 +263,9 @@ class WalletController extends Controller
if ($usesMainWallet) { if ($usesMainWallet) {
$label .= ' (کیف اصلی)'; $label .= ' (کیف اصلی)';
} }
if (!(bool) $product->active) {
$label .= ' (غیرفعال)';
}
$targets[] = [ $targets[] = [
'key' => 'product:' . $product->id, 'key' => 'product:' . $product->id,
@@ -273,6 +277,7 @@ class WalletController extends Controller
'uses_main_wallet' => $usesMainWallet, 'uses_main_wallet' => $usesMainWallet,
'trade_by_quantity' => (bool) $product->trade_by_quantity, 'trade_by_quantity' => (bool) $product->trade_by_quantity,
'group_type' => (string) ($product->group_type ?? ''), 'group_type' => (string) ($product->group_type ?? ''),
'active' => (bool) $product->active,
]; ];
} }
+6 -5
View File
@@ -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() $catalogQuery = Product::query()->with('file');
->where('active', 1) if (!$includeInactiveProducts) {
->with('file') $catalogQuery->where('active', 1);
->get(); }
$catalog = $catalogQuery->get();
$userWallets = Wallet::query() $userWallets = Wallet::query()
->with(['product.file']) ->with(['product.file'])