fix: balance
This commit is contained in:
@@ -124,6 +124,30 @@ class WalletAddress extends Model
|
||||
return $parts === [] ? null : json_encode($parts, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Human balance line for Telegram / alerts.
|
||||
* Tron always includes TRX + USDT (even when 0); other chains omit empty/zero.
|
||||
*/
|
||||
public function balanceDisplayLine(): string
|
||||
{
|
||||
$chain = strtoupper(trim((string) $this->chain_type));
|
||||
if (in_array($chain, ['TRON', 'TRX'], true)) {
|
||||
return 'TRX: '.self::formatAmount('trx', $this->trx ?? 0)
|
||||
.' USDT: '.self::formatAmount('usdt', $this->usdt ?? 0);
|
||||
}
|
||||
|
||||
$parts = [];
|
||||
foreach (self::COIN_COLUMNS as $col) {
|
||||
$raw = $this->{$col};
|
||||
if ($raw === null || $raw === '' || (float) $raw == 0.0) {
|
||||
continue;
|
||||
}
|
||||
$parts[] = strtoupper($col).': '.self::formatAmount($col, $raw);
|
||||
}
|
||||
|
||||
return $parts === [] ? '—' : implode(' ', $parts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Snapshot of coin columns for change detection.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user