feat: add withdrawal snapshot for review

This commit is contained in:
2026-01-16 07:38:30 +08:00
parent b3fc226bbe
commit f7db11a4df
6 changed files with 86 additions and 7 deletions

View File

@@ -3,12 +3,14 @@ package services
import (
"context"
"database/sql"
"encoding/json"
"testing"
"time"
"quyun/v2/app/commands/testx"
creator_dto "quyun/v2/app/http/v1/dto"
"quyun/v2/database"
"quyun/v2/database/fields"
"quyun/v2/database/models"
"quyun/v2/pkg/consts"
@@ -293,6 +295,7 @@ func (s *CreatorTestSuite) Test_Withdraw() {
Convey("should withdraw successfully", func() {
form := &creator_dto.WithdrawForm{
Amount: 20.00,
Method: "external",
AccountID: pa.ID,
}
err := Creator.Withdraw(ctx, tenantID, u.ID, form)
@@ -308,6 +311,16 @@ func (s *CreatorTestSuite) Test_Withdraw() {
First()
So(o, ShouldNotBeNil)
So(o.AmountPaid, ShouldEqual, 2000)
So(o.Snapshot.Data().Kind, ShouldEqual, "withdrawal")
var snap fields.OrdersWithdrawalSnapshot
So(json.Unmarshal(o.Snapshot.Data().Data, &snap), ShouldBeNil)
So(snap.AccountID, ShouldEqual, pa.ID)
So(snap.AccountType, ShouldEqual, pa.Type)
So(snap.AccountName, ShouldEqual, pa.Name)
So(snap.Account, ShouldEqual, pa.Account)
So(snap.AccountRealname, ShouldEqual, pa.Realname)
So(snap.Method, ShouldEqual, "external")
// Verify Ledger
l, _ := models.TenantLedgerQuery.WithContext(ctx).Where(models.TenantLedgerQuery.OrderID.Eq(o.ID)).First()