feat: 停复机新规则转正,删除总开关与旧口径
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 9m35s

- 删除总开关 stop_resume.unified_rule_enabled(配置、加载、部署工作流与 docker-compose.prod.yml 环境变量)
- 复机不看停机原因:删除只对轮询停因复机的旧分支与 ListByDeviceIDAndPollingStopReasons;设备复机取全部停机卡
- 实名门槛只按卡所属通道实名管控判断,删除行业卡与卡/设备实名策略放行;暂停轮询的卡不自动停复机无条件生效
- 通道阈值新周期解锁后的复机条件固定为新规则复机条件
- 资产自动续费复机同步新规则:不看停因、暂停轮询不复机、设备取全部停机卡、复机成功清除停因
- 实名轮询不再按行业卡跳过;所属运营商账户未开启实名管控时跳过查询,但卡未实名且所在资产有等待实名激活的套餐时照常查询,避免囤货套餐无法激活
This commit is contained in:
邹进
2026-10-25 18:13:51 +09:00
parent 457abaabd7
commit f49baff7c2
15 changed files with 155 additions and 159 deletions

View File

@@ -7,7 +7,6 @@ import (
"gorm.io/gorm"
"github.com/break/junhong_cmp_fiber/internal/model"
"github.com/break/junhong_cmp_fiber/pkg/config"
"github.com/break/junhong_cmp_fiber/pkg/constants"
"github.com/break/junhong_cmp_fiber/pkg/errors"
)
@@ -15,25 +14,12 @@ import (
// realnameControlEnabled 是通道实名管控开启时的取值。
const realnameControlEnabled = 1
// unifiedStopResumeEnabled 判定停复机新规则总开关是否开启。
//
// 开启后:复机不看停机原因;实名按卡所属通道的实名管控判断(不区分行业卡、不看卡/设备实名策略);
// 卡或所在设备暂停轮询时不自动停复机。关闭时全部停复机路径与原有行为一致。
func unifiedStopResumeEnabled() bool {
cfg := config.Get()
return cfg != nil && cfg.StopResume.UnifiedRuleEnabled
}
// 停复机规则(已转正为唯一口径):复机不看停机原因;实名按卡所属通道的实名管控判断
// (不区分行业卡、不看卡或设备实名策略);卡或所在设备暂停轮询时不自动停复机。
// autoResumableStopReason 判定该停因的停机卡能否进入自动复机判断:总开关开启时不看停因,
// 关闭时只处理轮询系统引起的停机。
func autoResumableStopReason(reason string) bool {
return unifiedStopResumeEnabled() || isPollingStopReason(reason)
}
// autoControlSuspended 判定总开关开启时该卡是否因暂停轮询而不自动停复机:卡自身或其有效绑定设备暂停轮询。
// 总开关关闭时恒为 false。
// autoControlSuspended 判定该卡是否因暂停轮询而不自动停复机:卡自身或其有效绑定设备暂停轮询。
func (s *StopResumeService) autoControlSuspended(ctx context.Context, card *model.IotCard) (bool, error) {
if !unifiedStopResumeEnabled() || card == nil {
if card == nil {
return false, nil
}
if !card.EnablePolling {
@@ -69,8 +55,9 @@ func (s *StopResumeService) channelRealnameControlled(ctx context.Context, card
return values[0] == realnameControlEnabled, nil
}
// unifiedRealnameOK 是总开关开启后的实名门槛:通道未开启实名管控即满足;开启时只看卡是否已实名。
func (s *StopResumeService) unifiedRealnameOK(ctx context.Context, card *model.IotCard) (bool, error) {
// isRealnameOK 是停复机的实名门槛:通道未开启实名管控即满足;开启时只看卡是否已实名。
// 查询通道失败时返回错误,调用方本次不对该卡发起停复机。
func (s *StopResumeService) isRealnameOK(ctx context.Context, card *model.IotCard) (bool, error) {
controlled, err := s.channelRealnameControlled(ctx, card)
if err != nil {
return false, err