Files
apskel-pos-backend/internal/models/wallet_move.go
T

45 lines
1.5 KiB
Go
Raw Normal View History

package models
import (
"time"
"github.com/google/uuid"
)
// WalletExchangePreview is GET /customer/wallet/exchange/preview
// (docs/prd-point-coin.md F4): the rate, and what exchanging Coins would give.
type WalletExchangePreview struct {
// The rate: CoinAmount EnakCoin exchange into PointAmount EnakPoint.
CoinAmount int64 `json:"coin_amount"`
PointAmount int64 `json:"point_amount"`
CoinBalance int64 `json:"coin_balance"`
Coins int64 `json:"coins"`
Points int64 `json:"points"`
// Whether Coins can be exchanged now, and why not when it cannot.
Valid bool `json:"valid"`
Reason string `json:"reason,omitempty"`
}
// WalletMovedLot is part of what an exchange or a transfer delivered, with the
// expiry it carried over from the lot it came from (K9).
type WalletMovedLot struct {
Amount int64 `json:"amount"`
// Nil when it never expires.
ExpiresAt *time.Time `json:"expires_at"`
}
// WalletExchangeResult is POST /customer/wallet/exchange.
type WalletExchangeResult struct {
GroupID uuid.UUID `json:"group_id"`
Coins int64 `json:"coins"`
Points int64 `json:"points"`
CoinAmount int64 `json:"coin_amount"`
PointAmount int64 `json:"point_amount"`
// The EnakPoint received, split by expiry.
Lots []WalletMovedLot `json:"lots"`
CoinBalance int64 `json:"coin_balance"`
PointBalance int64 `json:"point_balance"`
// True when this was a retry of an exchange already made; nothing moved again.
Replayed bool `json:"replayed"`
}