Files
pay/internal/store/attempt_accounts.go
T

20 lines
631 B
Go

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
}