fix: 修正 HasValidByCarrier 有效套餐定义,仅 status=Active 才算有效
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m43s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m43s
修复Bug:原代码将 Pending(0) 也算作有效套餐,导致待生效套餐的卡 不会被触发停机指令。现改为仅生效中(Active)才算有效套餐。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -172,17 +172,12 @@ func (s *PackageUsageStore) ResetDataUsage(ctx context.Context, id uint, lastRes
|
||||
}).Error
|
||||
}
|
||||
|
||||
// HasValidByCarrier 检查载体是否有有效套餐(status IN 待生效/生效中)
|
||||
// 修复Bug1:通过 carrierType 动态切换 device_id / iot_card_id 查询
|
||||
// HasValidByCarrier 检查载体是否有有效套餐(仅 status = 生效中)
|
||||
// carrierType: "iot_card" 或 "device"
|
||||
func (s *PackageUsageStore) HasValidByCarrier(ctx context.Context, carrierType string, carrierID uint) (bool, error) {
|
||||
var count int64
|
||||
validStatuses := []int{
|
||||
constants.PackageUsageStatusPending, // 待生效
|
||||
constants.PackageUsageStatusActive, // 生效中
|
||||
}
|
||||
query := s.db.WithContext(ctx).Model(&model.PackageUsage{}).
|
||||
Where("status IN ?", validStatuses)
|
||||
Where("status = ?", constants.PackageUsageStatusActive)
|
||||
if carrierType == "device" {
|
||||
query = query.Where("device_id = ?", carrierID)
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user