80 lines
2.0 KiB
Go
80 lines
2.0 KiB
Go
|
package repository
|
||
|
|
||
|
import (
|
||
|
"app-cloudep-trade-service/internal/domain"
|
||
|
"app-cloudep-trade-service/internal/model"
|
||
|
"context"
|
||
|
"fmt"
|
||
|
"testing"
|
||
|
|
||
|
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||
|
)
|
||
|
|
||
|
func TestByMe(t *testing.T) {
|
||
|
sqlConn := sqlx.NewSqlConn("mysql",
|
||
|
"root:yytt@tcp(127.0.0.1:3306)/digimon_wallet?parseTime=true&interpolateParams=false")
|
||
|
|
||
|
WalletRepo := NewWalletRepository(WalletRepositoryParam{
|
||
|
model.NewWalletModel(sqlConn),
|
||
|
sqlConn,
|
||
|
})
|
||
|
|
||
|
ctx := context.Background()
|
||
|
|
||
|
wo := WalletRepo.GetUserWalletOperator("OOOOOOOK", "USD")
|
||
|
balances, err := wo.Balances(ctx, domain.AllWalletType)
|
||
|
if err != nil {
|
||
|
return
|
||
|
}
|
||
|
|
||
|
fmt.Println(balances)
|
||
|
|
||
|
// create, err := WalletRepo.Create(ctx, "OOOOOOOK", "USD", "Digimon")
|
||
|
// if err != nil {
|
||
|
// return
|
||
|
// }
|
||
|
|
||
|
// fmt.Println(create)
|
||
|
|
||
|
// balances, err := WalletRepo.Balances(ctx, repository.BalanceReq{
|
||
|
// UID: []string{"OOOOOOOK"},
|
||
|
// Currency: []string{"USD"},
|
||
|
// // Kind: make([]domain.WalletType, 0),
|
||
|
// })
|
||
|
// if err != nil {
|
||
|
// fmt.Println(err)
|
||
|
// return
|
||
|
// }
|
||
|
|
||
|
// err := WalletRepo.Transaction(ctx, func(tx sqlx.Session) error {
|
||
|
// wm := model.NewWalletJournalModel(sqlConn)
|
||
|
// _, err := wm.InsertWithSession(ctx, tx, &model.WalletJournal{
|
||
|
// Id: 1,
|
||
|
// TransactionId: 10001,
|
||
|
// OrderId: "ORD123456789",
|
||
|
// Brand: "BrandX",
|
||
|
// Uid: "user123",
|
||
|
// WalletType: 1, // 1=可用
|
||
|
// Currency: "USD",
|
||
|
// TransactionAmount: 500.00,
|
||
|
// PostTransactionBalance: 1500.00,
|
||
|
// BusinessType: 2, // 假設 2 表示特定業務類型
|
||
|
// Status: 1, // 假設 1 表示成功狀態
|
||
|
// DueTime: 1698289200000, // T+N 執行時間
|
||
|
// CreatedAt: 1698192800000, // 創建時間 (Unix 時間戳,毫秒)
|
||
|
// })
|
||
|
//
|
||
|
// if err != nil {
|
||
|
// return err
|
||
|
// }
|
||
|
//
|
||
|
// return nil
|
||
|
// })
|
||
|
//
|
||
|
// if err != nil {
|
||
|
// return
|
||
|
// }
|
||
|
|
||
|
// fmt.Println(balances)
|
||
|
}
|