优化结构

This commit is contained in:
Yvan
2026-08-23 00:38:33 +08:00
parent 64459574b2
commit 4e5071ee65
22 changed files with 301 additions and 127 deletions
+11 -5
View File
@@ -271,16 +271,22 @@ func recordPaymentTestError(ctx context.Context, data Provider, provider, tradeN
}
func (r *paymentRepo) testRow(ctx context.Context, provider string) (map[string]any, error) {
var row dataintegration.ConfigPO
if err := r.data.DB().WithContext(ctx).Where("kind = ? AND provider = ?", integrationbiz.IntegrationKindPayment, provider).First(&row).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
if r == nil || r.config == nil {
return nil, errors.New("支付配置仓储未接入")
}
config, err := r.config.ReadPaymentConfig(ctx, provider)
if err != nil {
if errors.Is(err, integrationbiz.ErrPaymentConfigNotFound) {
return nil, bizpayment.ErrPaymentProviderNotFound
}
return nil, err
}
if config == nil {
return nil, errors.New("支付配置为空")
}
values := map[string]any{}
if err := json.Unmarshal([]byte(row.Config), &values); err != nil {
return nil, fmt.Errorf("支付配置格式错误: %w", err)
if err := json.Unmarshal(config.Values, &values); err != nil || values == nil {
return nil, errors.New("支付配置格式错误")
}
return values, nil
}