Multi-currency

This commit is contained in:
2025-03-23 17:58:12 +08:00
parent 90f451cf5a
commit 468cd655f8
9 changed files with 206 additions and 118 deletions

View File

@@ -24,4 +24,5 @@ type Order struct {
Transaction *Transaction `json:"transaction"`
TransactionID *uint `json:"transaction_id"`
ClientID *uint `json:"client_id"`
Currency string `json:"currency"`
}

View File

@@ -10,12 +10,13 @@ import (
type Transaction struct {
cruda.BaseModel
Remark string `json:"remark"` // The usage of this transaction
Amount decimal.Decimal `json:"amount" type:"decimal(30,2);"`
Payer *Wallet `json:"payer" foreignKey:"PayerID"` // Who give the money
Payee *Wallet `json:"payee" foreignKey:"PayeeID"` // Who get the money
PayerID *uint `json:"payer_id"` // Leave this field as nil means pay from the system
PayeeID *uint `json:"payee_id"` // Leave this field as nil means pay to the system
Remark string `json:"remark"` // The usage of this transaction
Amount decimal.Decimal `json:"amount" type:"decimal(30,2);"`
Currency string `json:"currency" gorm:"default:'normal'"`
Payer *Wallet `json:"payer" foreignKey:"PayerID"` // Who give the money
Payee *Wallet `json:"payee" foreignKey:"PayeeID"` // Who get the money
PayerID *uint `json:"payer_id"` // Leave this field as nil means pay from the system
PayeeID *uint `json:"payee_id"` // Leave this field as nil means pay to the system
}
func (v *Transaction) ToTransactionInfo() *proto.TransactionInfo {

View File

@@ -9,9 +9,10 @@ import (
type Wallet struct {
cruda.BaseModel
Balance decimal.Decimal `json:"balance" sql:"type:decimal(30,2);"`
Password string `json:"password"`
AccountID uint `json:"account_id"`
Balance decimal.Decimal `json:"balance" sql:"type:decimal(30,2);"`
GoldenBalance decimal.Decimal `json:"golden_balance" sql:"type:decimal(30,2);"`
Password string `json:"password"`
AccountID uint `json:"account_id"`
}
func (v *Wallet) ToWalletInfo() *proto.WalletInfo {