feat(v2): gateway 经 Picker 路由选账户 + retry 换号(ExcludeAccounts);替换首个 enabled

This commit is contained in:
wangjia
2026-07-10 14:02:33 +08:00
parent 381288e707
commit c06f6d3a3c
7 changed files with 109 additions and 17 deletions
+19
View File
@@ -0,0 +1,19 @@
package store
import (
"fmt"
"github.com/wangjia/pay/internal/model"
)
// AttemptAccountIDs returns the distinct account_ids already tried for an order on a
// channel (used by retry to switch to a not-yet-tried account via PickHint.ExcludeAccounts).
func (s *OrderStore) AttemptAccountIDs(outTradeNo, channel string) ([]string, error) {
var ids []string
if err := s.db.Model(&model.Attempt{}).
Where("out_trade_no = ? AND channel = ? AND account_id <> ''", outTradeNo, channel).
Distinct().Pluck("account_id", &ids).Error; err != nil {
return nil, fmt.Errorf("store.AttemptAccountIDs: %w", err)
}
return ids, nil
}