72 lines
2.5 KiB
Go
72 lines
2.5 KiB
Go
package models
|
|||
|
|
|
||
|
|
import (
|
||
|
|
"time"
|
||
|
|
|
||
|
|
"github.com/google/uuid"
|
||
|
|
)
|
||
|
|
|
||
|
|
// CustomerWalletTransaction is one ledger row as the customer app shows it
|
||
|
|
// (docs/prd-point-coin.md F6).
|
||
|
|
type CustomerWalletTransaction struct {
|
||
|
|
ID uuid.UUID `json:"id"`
|
||
|
|
Currency string `json:"currency"`
|
||
|
|
Type string `json:"type"`
|
||
|
|
// Signed: positive added to the balance, negative taken from it.
|
||
|
|
Amount int64 `json:"amount"`
|
||
|
|
BalanceAfter int64 `json:"balance_after"`
|
||
|
|
Description string `json:"description"`
|
||
|
|
// Where the value came from, set on additions.
|
||
|
|
Source *CustomerWalletTransactionRef `json:"source,omitempty"`
|
||
|
|
// Where the value went, set on deductions.
|
||
|
|
Destination *CustomerWalletTransactionRef `json:"destination,omitempty"`
|
||
|
|
OutletID *uuid.UUID `json:"outlet_id,omitempty"`
|
||
|
|
ReversesTransactionID *uuid.UUID `json:"reverses_transaction_id,omitempty"`
|
||
|
|
// Shared by the two rows of an exchange or a transfer.
|
||
|
|
GroupID *uuid.UUID `json:"group_id,omitempty"`
|
||
|
|
// Additions only: the earliest expiry among the lots it created, nil when none of
|
||
|
|
// them expire, and the lots themselves.
|
||
|
|
ExpiresAt *time.Time `json:"expires_at,omitempty"`
|
||
|
|
Lots []CustomerWalletLot `json:"lots,omitempty"`
|
||
|
|
CreatedAt time.Time `json:"created_at"`
|
||
|
|
}
|
||
|
|
|
||
|
|
// CustomerWalletTransactionRef points at what a ledger row came from or went to, as
|
||
|
|
// listed in §8.1: ORDER, PAYMENT, WALLET_TX, GAME_PLAY, LOT, USER and so on.
|
||
|
|
type CustomerWalletTransactionRef struct {
|
||
|
|
Type string `json:"type"`
|
||
|
|
ID uuid.UUID `json:"id"`
|
||
|
|
}
|
||
|
|
|
||
|
|
type CustomerWalletLot struct {
|
||
|
|
Amount int64 `json:"amount"`
|
||
|
|
Remaining int64 `json:"remaining"`
|
||
|
|
ExpiresAt *time.Time `json:"expires_at"`
|
||
|
|
}
|
||
|
|
|
||
|
|
// CustomerWalletExpiring is how much expires on one day.
|
||
|
|
type CustomerWalletExpiring struct {
|
||
|
|
Amount int64 `json:"amount"`
|
||
|
|
// YYYY-MM-DD, Asia/Jakarta.
|
||
|
|
Date string `json:"date"`
|
||
|
|
}
|
||
|
|
|
||
|
|
// CustomerWalletNearestExpiring is the next day each currency loses balance, nil when
|
||
|
|
// nothing is due to expire.
|
||
|
|
type CustomerWalletNearestExpiring struct {
|
||
|
|
Point *CustomerWalletExpiring `json:"point"`
|
||
|
|
Coin *CustomerWalletExpiring `json:"coin"`
|
||
|
|
}
|
||
|
|
|
||
|
|
// ListCustomerWalletTransactionsQuery is GET /customer/wallet/transactions.
|
||
|
|
type ListCustomerWalletTransactionsQuery struct {
|
||
|
|
Page int `form:"page"`
|
||
|
|
Limit int `form:"limit"`
|
||
|
|
Currency string `form:"currency"`
|
||
|
|
// One type, or several separated by commas.
|
||
|
|
Type string `form:"type"`
|
||
|
|
// Inclusive calendar dates, YYYY-MM-DD, Asia/Jakarta.
|
||
|
|
From string `form:"from"`
|
||
|
|
To string `form:"to"`
|
||
|
|
}
|