fix: preserve legacy payment account display

This commit is contained in:
richjohnrambo
2026-10-16 10:14:41 +08:00
parent ecf1a89313
commit 443622cd3c
4 changed files with 54 additions and 23 deletions
+25 -22
View File
@@ -104,6 +104,7 @@ type PaymentAccountDetail struct {
AlipayQRURL string `json:"alipay_qr_url"`
VerifyStatus string `json:"verify_status"`
IsDefault bool `json:"is_default"`
Masked bool `json:"masked"`
}
type QuoteInput struct {
@@ -297,7 +298,7 @@ func (s *Service) PaymentAccounts(ctx context.Context, tenantID, memberID int64)
}
func (s *Service) PaymentAccountDetails(ctx context.Context, tenantID, memberID int64) ([]PaymentAccountDetail, error) {
if !s.ready || s.repository == nil {
if s.repository == nil {
return nil, ErrUnavailable
}
rows, err := s.repository.PaymentAccountDetails(ctx, tenantID, memberID)
@@ -306,33 +307,35 @@ func (s *Service) PaymentAccountDetails(ctx context.Context, tenantID, memberID
}
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
holderName, accountNo := row.HolderMask, row.AccountNoMask
identityNo, digitalRMBCode := row.IdentityNoMask, row.DigitalRMBCodeMask
masked := true
if s.ready {
decryptedHolder, holderErr := s.decrypt(row.HolderCipher)
decryptedAccount, accountErr := s.decrypt(row.AccountNoCipher)
if holderErr == nil && accountErr == nil {
holderName, accountNo, masked = decryptedHolder, decryptedAccount, false
if row.IdentityNoCipher != "" {
if value, decryptErr := s.decrypt(row.IdentityNoCipher); decryptErr == nil {
identityNo = value
} else {
masked = true
}
}
if row.DigitalRMBCodeCipher != "" {
if value, decryptErr := s.decrypt(row.DigitalRMBCodeCipher); decryptErr == nil {
digitalRMBCode = value
} else {
masked = true
}
}
}
}
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,
VerifyStatus: verifyStatusName(row.VerifyStatus), IsDefault: row.IsDefault == 1, Masked: masked,
})
}
return items, nil