feat(listings): 订单和账号详情展示可租时长与每日消耗
租客在订单列表和详情标题能看到每个号的租期、消耗。账号详情把这两项拆成独立格子。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -124,6 +124,20 @@ func orderEstimatedEndAt(order model.RentalOrder) *time.Time {
|
||||
return &endAt
|
||||
}
|
||||
|
||||
// orderListingTerms 用下单快照里的哈夫币和日损耗估算租期,和首页「可租 / 消耗」同一口径。
|
||||
func orderListingTerms(snapshot datatypes.JSON) (days int, dailyLossM float64) {
|
||||
dailyLossM = readOrderSnapshotAssetNumber(snapshot, "daily_loss_m")
|
||||
coinM := readOrderSnapshotCoinM(snapshot)
|
||||
if dailyLossM <= 0 || coinM <= 0 {
|
||||
return 0, 0
|
||||
}
|
||||
days = int(math.Ceil(coinM / dailyLossM))
|
||||
if days < 1 {
|
||||
days = 1
|
||||
}
|
||||
return days, roundQuantity(dailyLossM)
|
||||
}
|
||||
|
||||
func estimateOrderDurationHours(snapshot datatypes.JSON) int {
|
||||
hafCoinM := readOrderSnapshotCoinM(snapshot)
|
||||
if hafCoinM <= 0 {
|
||||
|
||||
Reference in New Issue
Block a user