added charge for all products
This commit is contained in:
@@ -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)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -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'])
|
||||
|
||||
Reference in New Issue
Block a user