新增提取函数,实现通过套餐编号提取

This commit is contained in:
2026-05-23 13:50:52 +08:00
parent b436a6cade
commit 32e56b1a0f
4 changed files with 97 additions and 18 deletions

View File

@@ -24,7 +24,7 @@ import (
type channelBaiyinProvider struct{}
func (s *channelBaiyinProvider) CreateChannels(source netip.Addr, resourceId int32, authWhitelist bool, authPassword bool, count int, filter *EdgeFilter) ([]*m.Channel, error) {
func (s *channelBaiyinProvider) CreateChannels(source netip.Addr, resourceNo string, authWhitelist bool, authPassword bool, count int, filter *EdgeFilter) ([]*m.Channel, error) {
if filter == nil {
return nil, core.NewBizErr("缺少节点过滤条件")
}
@@ -34,9 +34,9 @@ func (s *channelBaiyinProvider) CreateChannels(source netip.Addr, resourceId int
channels := make([]*m.Channel, count)
// 资源锁,防止并发扣减失败导致的端口悬空问题
err := g.Redsync.WithLock(lockChannelCreateKey(resourceId), func() error {
err := g.Redsync.WithLock(lockChannelCreateKey(resourceNo), func() error {
// 检查并获取套餐与白名单
resource, whitelists, err := ensure(now, source, resourceId, authWhitelist, count)
resource, whitelists, err := ensure(now, source, resourceNo, authWhitelist, count)
if err != nil {
return err
}
@@ -65,7 +65,7 @@ func (s *channelBaiyinProvider) CreateChannels(source netip.Addr, resourceId int
// 通道数据
channels[i] = &m.Channel{
UserID: user.ID,
ResourceID: resourceId,
ResourceID: resource.ID,
BatchNo: batchNo,
ProxyID: proxy.ID,
Host: u.Else(proxy.Host, proxy.IP.String()),
@@ -181,7 +181,7 @@ func (s *channelBaiyinProvider) CreateChannels(source netip.Addr, resourceId int
// 保存提取记录
err = q.LogsUserUsage.Create(&m.LogsUserUsage{
UserID: user.ID,
ResourceID: resourceId,
ResourceID: resource.ID,
BatchNo: batchNo,
Count: int32(count),
ISP: u.X(filter.Isp.String()),
@@ -335,8 +335,8 @@ func (s *channelBaiyinProvider) ClearExpiredChannels(proxyId int32) (int, error)
return len(batchSet), nil
}
func lockChannelCreateKey(resourceId int32) string {
return fmt.Sprintf("platform:channel:create:%d", resourceId)
func lockChannelCreateKey(resourceNo string) string {
return fmt.Sprintf("platform:channel:create:%s", resourceNo)
}
func lockChannelRemoveKey(bid string) string {