feat(通道流量阈值): AUG26-011 运营商通道流量阈值达量停机与周期复机
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 12m59s

This commit is contained in:
2026-09-16 15:54:49 +08:00
parent 41722760b1
commit 59b3df868a
36 changed files with 2431 additions and 93 deletions

View File

@@ -0,0 +1,38 @@
package model
import (
"time"
"gorm.io/gorm"
)
// CarrierTrafficThresholdLock 是「卡在某运营商计费周期内已触发通道流量阈值停机」的持久化事实。
//
// 一行表达一个 (carrier_id, card_id, period_start) 组合,由部分唯一索引保证至多一条:
// Status 表达整行生命周期locked 进行中 / unlocked 已跨期解锁StopStatus 与 ResumeStatus
// 分别表达停机与复机两个子任务StopSubmittedAt/ResumeSubmittedAt 是提交认领字段,
// 由消费者以「字段为 NULL」条件更新取得至多一次的外部调用权AnomalyFlag 与 FailureReason
// 承载查询窗口超期等需人工核对的结果。周期起点按触发时该运营商的 data_reset_day 计算,
// 换运营商后旧周期锁保留、新周期按新运营商的重置日另建一行。
type CarrierTrafficThresholdLock struct {
gorm.Model
CarrierID uint `gorm:"column:carrier_id;type:bigint;not null" json:"carrier_id"`
CardID uint `gorm:"column:card_id;type:bigint;not null" json:"card_id"`
PeriodStart time.Time `gorm:"column:period_start;type:timestamptz;not null" json:"period_start"`
Status string `gorm:"column:status;type:varchar(16);not null;default:'locked'" json:"status"`
StopStatus string `gorm:"column:stop_status;type:varchar(16);not null;default:'pending'" json:"stop_status"`
ResumeStatus string `gorm:"column:resume_status;type:varchar(16);not null;default:'pending'" json:"resume_status"`
StopSubmittedAt *time.Time `gorm:"column:stop_submitted_at;type:timestamptz" json:"stop_submitted_at,omitempty"`
ResumeSubmittedAt *time.Time `gorm:"column:resume_submitted_at;type:timestamptz" json:"resume_submitted_at,omitempty"`
StopIntegrationID string `gorm:"column:stop_integration_id;type:varchar(64);not null;default:''" json:"stop_integration_id"`
// ResumeIntegrationID 记录复机 Gateway 调用的 Integration Log 标识,便于人工核对。
ResumeIntegrationID string `gorm:"column:resume_integration_id;type:varchar(64);not null;default:''" json:"resume_integration_id"`
// AnomalyFlag 为 1 表示查询窗口超期或失败无法自动确认,必须退出自动扫描转人工核对。
AnomalyFlag int `gorm:"column:anomaly_flag;type:smallint;not null;default:0" json:"anomaly_flag"`
FailureReason string `gorm:"column:failure_reason;type:varchar(500);not null;default:''" json:"failure_reason"`
}
// TableName 指定运营商通道流量阈值周期锁表名。
func (CarrierTrafficThresholdLock) TableName() string {
return "tb_carrier_traffic_threshold_lock"
}