套餐白名单检查逻辑 & 检查订单金额

This commit is contained in:
2026-04-21 16:32:07 +08:00
parent 982cbb4cab
commit 6e14ea65d0
7 changed files with 32 additions and 17 deletions

View File

@@ -83,10 +83,11 @@ func findResource(resourceId int32, now time.Time) (*ResourceView, error) {
return nil, ErrResourceNotExist
}
var info = &ResourceView{
Id: resource.ID,
User: *resource.User,
Active: resource.Active,
Type: resource.Type,
Id: resource.ID,
User: *resource.User,
Active: resource.Active,
Type: resource.Type,
CheckIP: resource.CheckIP,
}
switch resource.Type {
@@ -142,6 +143,7 @@ type ResourceView struct {
Daily int32
LastAt *time.Time
Today int // 今日用量
CheckIP bool
}
// 检查用户是否可提取
@@ -178,7 +180,7 @@ func ensure(now time.Time, source netip.Addr, resourceId int32, count int) (*Res
pass = true
}
}
if !pass {
if resource.CheckIP && !pass {
return nil, nil, core.NewBizErr(fmt.Sprintf("IP 地址 %s 不在白名单内", source.String()))
}