feat(listings): 订单和账号详情展示可租时长与每日消耗

租客在订单列表和详情标题能看到每个号的租期、消耗。账号详情把这两项拆成独立格子。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
yml2213
2026-10-05 16:32:08 +08:00
co-authored by Cursor
parent c559287ee4
commit f2060c19cf
18 changed files with 393 additions and 71 deletions
@@ -218,6 +218,34 @@ export function getSnapshotHafCoinM(order: Order | null) {
return roundQuantity(readNumber(snapshot?.haf_coin_amount) / 1000000)
}
export function formatDailyLossText(dailyLossM: number) {
const rounded = Math.round(Number(dailyLossM || 0) * 10) / 10
if (rounded <= 0) return ''
const text = Number.isInteger(rounded) ? `${rounded}` : rounded.toFixed(1)
return `${text}M/天`
}
export function orderRentalTerms(order: Order | null) {
const dailyLossM = readNumber(readAssetSummary(order)?.daily_loss_m)
const coinM = getSnapshotHafCoinM(order)
if (dailyLossM <= 0 || coinM <= 0) return { rentalDays: 0, dailyLossText: '' }
return {
rentalDays: Math.max(1, Math.ceil(coinM / dailyLossM)),
dailyLossText: formatDailyLossText(dailyLossM),
}
}
export function orderListRentalTerms(
item?: { rental_days?: number; daily_loss_m?: number } | null
) {
const rentalDays = Math.ceil(readNumber(item?.rental_days))
const dailyLossText = formatDailyLossText(readNumber(item?.daily_loss_m))
return {
rentalDays: rentalDays > 0 ? rentalDays : 0,
dailyLossText,
}
}
export function orderEstimatedEndAt(order: Order | null) {
if (order?.estimated_end_at) return order.estimated_end_at
const rentedAt = order?.rented_at