fix some bugs

This commit is contained in:
2026-07-18 15:04:08 +03:30
parent 4c7e4fdfde
commit eedde65be6
4 changed files with 94 additions and 29 deletions
+37 -7
View File
@@ -51,10 +51,28 @@ class AssetSummaryService
$metalsWithProductWallet = $this->metalIdsWithProductWallet($userWallets, $catalogById, $mainWalletProductIds, $mainWallet);
$inventoryCards = array_merge(
$this->buildMeltedInventoryCards($catalog, $catalogById, $mainWallet, $metalIds, $metalsWithProductWallet, $mainWalletProductIds, $userWallets),
$this->buildMeltedInventoryCards(
$catalog,
$catalogById,
$mainWallet,
$metalIds,
$metalsWithProductWallet,
$mainWalletProductIds,
$userWallets,
$customerId
),
$this->buildInventoryCards($userWallets, $catalogById, $mainWalletProductIds, $mainWallet),
);
$metalTotals = $this->buildMetalTotals($userWallets, $mainWallet, $metalIds, $weightUnit, $catalogById, $metalsWithProductWallet, $mainWalletProductIds);
$metalTotals = $this->buildMetalTotals(
$userWallets,
$mainWallet,
$metalIds,
$weightUnit,
$catalogById,
$metalsWithProductWallet,
$mainWalletProductIds,
$customerId
);
$cashWallet = $this->walletBalanceService->mainWalletCash($userWallets);
$assetsRialValue = $this->sumAssetsRialValue(
$metalTotals,
@@ -199,11 +217,14 @@ class AssetSummaryService
array $metalIds,
array $metalsWithProductWallet = [],
array $mainWalletProductIds = [],
Collection $userWallets
Collection $userWallets,
int $customerId = 0
): array {
$cards = [];
$mainWalletGrams = Controller::weightToGrams(
$this->effectiveMainWalletGold($userWallets, $mainWallet, $mainWalletProductIds)
$customerId > 0
? $this->walletBalanceService->effectiveMainWalletGold($customerId)
: $this->effectiveMainWalletGold($userWallets, $mainWallet, $mainWalletProductIds)
);
$assignedMetalIds = [];
$mainProductId = $this->configService->mainProductId();
@@ -215,7 +236,9 @@ class AssetSummaryService
return [];
}
$mainWalletWeight = $this->effectiveMainWalletGold($userWallets, $mainWallet, $mainWalletProductIds);
$mainWalletWeight = $customerId > 0
? $this->walletBalanceService->effectiveMainWalletGold($customerId)
: $this->effectiveMainWalletGold($userWallets, $mainWallet, $mainWalletProductIds);
if ($mainWalletWeight <= 0) {
return [];
}
@@ -298,6 +321,10 @@ class AssetSummaryService
/** موجودی نمایشی محصول — همسان با inventory_cards */
public function productDisplayQuantity(int $customerId, int $ownerType, int $productId): float
{
if ($this->configService->isMainWalletProduct($productId)) {
return $this->walletBalanceService->effectiveMainWalletGold($customerId);
}
$card = $this->productInventoryCard($customerId, $ownerType, $productId);
if ($card !== null) {
return (float) ($card['quantity'] ?? 0);
@@ -581,14 +608,17 @@ class AssetSummaryService
string $weightUnit,
Collection $catalogById,
array $metalsWithProductWallet = [],
array $mainWalletProductIds = []
array $mainWalletProductIds = [],
int $customerId = 0
): array {
if ($metalIds === []) {
return [];
}
$mainWalletGrams = Controller::weightToGrams(
$this->effectiveMainWalletGold($userWallets, $mainWallet, $mainWalletProductIds)
$customerId > 0
? $this->walletBalanceService->effectiveMainWalletGold($customerId)
: $this->effectiveMainWalletGold($userWallets, $mainWallet, $mainWalletProductIds)
);
$totals = [];