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
+56
View File
@@ -42,6 +42,7 @@ type Repository interface {
CurrentSiteConfig(context.Context, int64) (json.RawMessage, error)
AccountSecurity(context.Context, int64, int64) (*store.AccountSecurity, error)
PaymentAccounts(context.Context, int64, int64) ([]store.PaymentAccount, error)
PaymentAccountDetails(context.Context, int64, int64) ([]store.PaymentAccount, error)
CreatePaymentAccount(context.Context, store.PaymentAccountCreation) (*store.PaymentAccount, error)
PaymentAccountForWithdrawal(context.Context, int64, int64, int64) (*store.PaymentAccount, error)
ActiveWithdrawalChannel(context.Context, int64, []int) (*store.WithdrawalChannel, error)
@@ -92,6 +93,19 @@ type PaymentAccount struct {
UpdatedAt string `json:"updated_at,omitempty"`
}
type PaymentAccountDetail struct {
ID int64 `json:"id"`
BankName string `json:"bank_name"`
HolderName string `json:"holder_name"`
IdentityNo string `json:"identity_no"`
AccountNo string `json:"account_no"`
DigitalRMBCode string `json:"digital_rmb_code"`
WechatQRURL string `json:"wechat_qr_url"`
AlipayQRURL string `json:"alipay_qr_url"`
VerifyStatus string `json:"verify_status"`
IsDefault bool `json:"is_default"`
}
type QuoteInput struct {
PaymentAccountID int64 `json:"payment_account_id"`
Amount int64 `json:"amount"`
@@ -282,6 +296,48 @@ func (s *Service) PaymentAccounts(ctx context.Context, tenantID, memberID int64)
return items, nil
}
func (s *Service) PaymentAccountDetails(ctx context.Context, tenantID, memberID int64) ([]PaymentAccountDetail, error) {
if !s.ready || s.repository == nil {
return nil, ErrUnavailable
}
rows, err := s.repository.PaymentAccountDetails(ctx, tenantID, memberID)
if err != nil {
return nil, err
}
items := make([]PaymentAccountDetail, 0, len(rows))
for _, row := range rows {
holderName, err := s.decrypt(row.HolderCipher)
if err != nil {
return nil, store.ErrPaymentAccountInvalid
}
accountNo, err := s.decrypt(row.AccountNoCipher)
if err != nil {
return nil, store.ErrPaymentAccountInvalid
}
identityNo := ""
if row.IdentityNoCipher != "" {
identityNo, err = s.decrypt(row.IdentityNoCipher)
if err != nil {
return nil, store.ErrPaymentAccountInvalid
}
}
digitalRMBCode := ""
if row.DigitalRMBCodeCipher != "" {
digitalRMBCode, err = s.decrypt(row.DigitalRMBCodeCipher)
if err != nil {
return nil, store.ErrPaymentAccountInvalid
}
}
items = append(items, PaymentAccountDetail{
ID: row.ID, BankName: row.BankName, HolderName: holderName,
IdentityNo: identityNo, AccountNo: accountNo, DigitalRMBCode: digitalRMBCode,
WechatQRURL: row.WechatQRURL, AlipayQRURL: row.AlipayQRURL,
VerifyStatus: verifyStatusName(row.VerifyStatus), IsDefault: row.IsDefault == 1,
})
}
return items, nil
}
func (s *Service) CreatePaymentAccount(ctx context.Context, tenantID, memberID int64, input PaymentAccountInput) (*PaymentAccount, error) {
if !s.ready {
return nil, ErrUnavailable