feat: show own withdrawal account details and enable avatar upload

This commit is contained in:
richjohnrambo
2026-10-16 00:19:11 +08:00
parent 07c654b6d4
commit ecf1a89313
8 changed files with 355 additions and 36 deletions
+29
View File
@@ -15,6 +15,7 @@ import (
type fakeRepository struct {
config json.RawMessage
account *store.PaymentAccount
details []store.PaymentAccount
channel *store.WithdrawalChannel
wallet *store.WithdrawalWallet
orders []store.WithdrawalOrder
@@ -43,6 +44,9 @@ func (f *fakeRepository) AccountSecurity(context.Context, int64, int64) (*store.
func (f *fakeRepository) PaymentAccounts(context.Context, int64, int64) ([]store.PaymentAccount, error) {
return nil, nil
}
func (f *fakeRepository) PaymentAccountDetails(context.Context, int64, int64) ([]store.PaymentAccount, error) {
return f.details, nil
}
func (f *fakeRepository) CreatePaymentAccount(context.Context, store.PaymentAccountCreation) (*store.PaymentAccount, error) {
return nil, errors.New("not implemented")
}
@@ -139,6 +143,31 @@ func TestNormalizePaymentAccountAllowsEmptyDigitalRMBCode(t *testing.T) {
}
}
func TestPaymentAccountDetailsReturnsOriginalFields(t *testing.T) {
repository := &fakeRepository{}
service := New(repository, &redis.Client{}, config.AuthConfig{
FinanceMasterKey: "test-finance-master-key-with-at-least-32-characters",
})
holder, _ := service.encrypt("张三")
identity, _ := service.encrypt("11010119900101123X")
account, _ := service.encrypt("6222000000001234")
digital, _ := service.encrypt("123456")
repository.details = []store.PaymentAccount{{
ID: 7, BankName: "中国工商银行", HolderCipher: holder, IdentityNoCipher: identity,
AccountNoCipher: account, DigitalRMBCodeCipher: digital,
WechatQRURL: "/wechat.png", AlipayQRURL: "/alipay.png", VerifyStatus: 2,
}}
items, err := service.PaymentAccountDetails(context.Background(), 1, 2)
if err != nil {
t.Fatal(err)
}
if len(items) != 1 || items[0].HolderName != "张三" || items[0].IdentityNo != "11010119900101123X" ||
items[0].AccountNo != "6222000000001234" || items[0].DigitalRMBCode != "123456" ||
items[0].WechatQRURL != "/wechat.png" || items[0].AlipayQRURL != "/alipay.png" {
t.Fatalf("unexpected account details: %#v", items)
}
}
func TestCreatePaymentAccountDoesNotStoreEmptyDigitalRMBCode(t *testing.T) {
repository := &paymentAccountRepository{}
service := New(repository, &redis.Client{}, config.AuthConfig{