fix report

This commit is contained in:
2026-06-24 01:17:34 +03:30
parent f44cb7263b
commit 7a18d76ad9
5 changed files with 256 additions and 34 deletions
+29
View File
@@ -215,6 +215,35 @@ class ConfigService
return in_array($productId, $this->mainWalletProductIds(), true);
}
/** اولین محصول فعال از `main_wallet_products` — نماینده کیف اصلی */
public function mainWalletRepresentativeProduct(): ?Product
{
foreach ($this->mainWalletProductIds() as $productId) {
$product = Product::query()->where('active', 1)->find($productId);
if ($product) {
return $product;
}
}
foreach ($this->mainWalletProductIds() as $productId) {
$product = Product::query()->find($productId);
if ($product) {
return $product;
}
}
return null;
}
/** metal_id محصول نماینده کیف اصلی — پیش‌فرض ۱ (طلا) */
public function mainWalletMetalId(): int
{
$product = $this->mainWalletRepresentativeProduct();
$metalId = $product ? (int) ($product->metal_id ?? 0) : 0;
return $metalId > 0 ? $metalId : 1;
}
/**
* شناسه محصول آبشده: اول settings، بعد const.
* مقدار settings می‌تواند id عددی (مثل 13) یا reading_method (مثل estjt_...) باشد.