fix: 卡或绑定设备关闭轮询时不再自动停复机
关闭轮询的卡/设备已导入其他卡管,去掉套餐到期、退款场景对暂停轮询卡的停机放行, 任何场景都不停机也不复机(单卡判断与设备下逐卡停机同步收口)。 场景判断函数更名为 StopResumeSceneIgnoresNetworkStatus,只保留不看库里开停状态的语义。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -28,8 +28,8 @@ type stopResumeDecision struct {
|
||||
DeviceID uint // 设备维度动作的设备;0 表示单卡
|
||||
}
|
||||
|
||||
// decideCard 统一判断函数:暂停轮询(按场景) → 停机条件 → 复机条件。
|
||||
// 暂停轮询的卡只在套餐失效类场景(套餐到期、退款)下放行无套餐停机,其余自动停复机一律不做;
|
||||
// decideCard 统一判断函数:暂停轮询 → 停机条件 → 复机条件。
|
||||
// 卡或绑定设备暂停轮询(已交由其他卡管)时任何场景都不停机也不复机;
|
||||
// 套餐失效类场景不看库里的开停状态,资产无可用主套餐即停机。
|
||||
// 设备维度原因(无套餐、流量耗尽)与绑定设备的复机返回 DeviceID,由调用方按设备处理。通道阈值锁由复机执行方判断。
|
||||
func (s *StopResumeService) decideCard(ctx context.Context, card *model.IotCard, scenes []string) (stopResumeDecision, error) {
|
||||
@@ -37,11 +37,10 @@ func (s *StopResumeService) decideCard(ctx context.Context, card *model.IotCard,
|
||||
if err != nil {
|
||||
return stopResumeDecision{}, err
|
||||
}
|
||||
allowSuspendedStop := constants.StopResumeSceneAllowsSuspendedStop(scenes)
|
||||
if suspended && !allowSuspendedStop {
|
||||
if suspended {
|
||||
return stopResumeDecision{}, nil
|
||||
}
|
||||
if allowSuspendedStop {
|
||||
if constants.StopResumeSceneIgnoresNetworkStatus(scenes) {
|
||||
// 套餐失效类场景(套餐到期、退款):不看库里的开停状态,资产无可用主套餐即停机。
|
||||
// 停复机成功后上游状态有延迟,库里的开停状态可能是旧值;上游已停时调用按已是目标状态结束。
|
||||
reasons, err := s.checkStopReasons(ctx, card)
|
||||
@@ -55,9 +54,6 @@ func (s *StopResumeService) decideCard(ctx context.Context, card *model.IotCard,
|
||||
}
|
||||
return decision, nil
|
||||
}
|
||||
if suspended {
|
||||
return stopResumeDecision{}, nil
|
||||
}
|
||||
}
|
||||
switch card.NetworkStatus {
|
||||
case constants.NetworkStatusOnline:
|
||||
@@ -66,22 +62,12 @@ func (s *StopResumeService) decideCard(ctx context.Context, card *model.IotCard,
|
||||
return stopResumeDecision{}, err
|
||||
}
|
||||
primary := reasons[0]
|
||||
if suspended {
|
||||
// 暂停轮询:只有套餐失效(无可用主套餐)才停机。
|
||||
if !containsStopReason(reasons, constants.StopReasonNoPackage) {
|
||||
return stopResumeDecision{}, nil
|
||||
}
|
||||
primary = constants.StopReasonNoPackage
|
||||
}
|
||||
decision := stopResumeDecision{Action: constants.StopResumeActionStop, Reason: primary, Reasons: reasons}
|
||||
if !card.IsStandalone && isDeviceScopeReason(primary) {
|
||||
decision.DeviceID = s.boundDeviceID(ctx, card)
|
||||
}
|
||||
return decision, nil
|
||||
case constants.NetworkStatusOffline:
|
||||
if suspended {
|
||||
return stopResumeDecision{}, nil
|
||||
}
|
||||
// 不看停机原因,是否复机只由本系统规则决定。
|
||||
resume, err := s.shouldResume(ctx, card)
|
||||
if err != nil || !resume {
|
||||
|
||||
Reference in New Issue
Block a user