app-cloudep-trade-service/internal/repository/wallet_test.go

82 lines
2.1 KiB
Go
Raw Permalink Normal View History

2024-10-30 11:13:56 +00:00
package repository
import (
2024-10-31 04:05:22 +00:00
"app-cloudep-trade-service/internal/domain/wallet"
2024-10-30 11:13:56 +00:00
"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")
2024-10-31 04:05:22 +00:00
balances, err := wo.Balances(ctx, wallet.AllBalanceTypes)
2024-10-30 11:13:56 +00:00
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)
}
2024-10-31 04:05:22 +00:00
func TestBalanceUseCase(t *testing.T) {}