fix bug
This commit is contained in:
@@ -260,6 +260,7 @@ class AssetSummaryService
|
||||
'unit_weight' => $this->productUnitWeightLabel($catalogProduct),
|
||||
'show_in_assets' => $this->shouldShowInAssets($catalogProduct),
|
||||
'is_melted' => true,
|
||||
'is_main_wallet' => true,
|
||||
'file' => $this->filePayload($catalogProduct),
|
||||
];
|
||||
}
|
||||
@@ -267,6 +268,57 @@ class AssetSummaryService
|
||||
return $cards;
|
||||
}
|
||||
|
||||
/**
|
||||
* کارت موجودی یک محصول از assets-summary — منبع واحد با صفحهٔ اصلی و کیف پول.
|
||||
*/
|
||||
public function productInventoryCard(int $customerId, int $ownerType, int $productId): ?array
|
||||
{
|
||||
$summary = $this->buildForCustomer($customerId, $ownerType);
|
||||
|
||||
foreach ($summary['inventory_cards'] as $card) {
|
||||
if ((int) ($card['product_id'] ?? 0) === $productId) {
|
||||
return $card;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/** موجودی نمایشی محصول — همسان با inventory_cards */
|
||||
public function productDisplayQuantity(int $customerId, int $ownerType, int $productId): float
|
||||
{
|
||||
$card = $this->productInventoryCard($customerId, $ownerType, $productId);
|
||||
if ($card !== null) {
|
||||
return (float) ($card['quantity'] ?? 0);
|
||||
}
|
||||
|
||||
$wallet = Wallet::query()
|
||||
->where('owner', $customerId)
|
||||
->where('owner_type', $ownerType)
|
||||
->where('product_id', $productId)
|
||||
->whereNull('fund_id')
|
||||
->first();
|
||||
|
||||
return (float) ($wallet->gold ?? 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* کیف مؤثر برای برداشت/تحویل فیزیکی — null یعنی کیف اصلی.
|
||||
*/
|
||||
public function effectiveProductWalletIdForCustomer(int $customerId, int $ownerType, int $productId): ?int
|
||||
{
|
||||
if ($this->configService->isMainWalletProduct($productId)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$card = $this->productInventoryCard($customerId, $ownerType, $productId);
|
||||
if ($card !== null && !empty($card['is_main_wallet'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $productId;
|
||||
}
|
||||
|
||||
private function resolveMainWallet(Collection $userWallets): ?Wallet
|
||||
{
|
||||
return $userWallets->first(
|
||||
|
||||
Reference in New Issue
Block a user