修复:溢出流量应优先记到主套餐而非加油包
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m47s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m47s
主套餐和加油包同时 Depleted 时,recordOverflowToDepletedPackage 原先取 id 最大的套餐,可能取到加油包,语义不对。 改为优先查 master_usage_id IS NULL(主套餐),找不到时 再回退取任意 Depleted 套餐。
This commit is contained in:
@@ -470,9 +470,14 @@ func (s *UsageService) recordOverflowToDepletedPackage(ctx context.Context, tx *
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 优先选主套餐(master_usage_id IS NULL),主套餐不存在时再退而求其次取加油包
|
||||||
var pkg model.PackageUsage
|
var pkg model.PackageUsage
|
||||||
if err := query.Order("id DESC").First(&pkg).Error; err != nil {
|
err := query.Where("master_usage_id IS NULL").Order("id DESC").First(&pkg).Error
|
||||||
// 找不到 Depleted 套餐,静默忽略
|
if err == gorm.ErrRecordNotFound {
|
||||||
|
err = query.Order("id DESC").First(&pkg).Error
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
// 找不到任何 Depleted 套餐,静默忽略
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user