package model import "time" // CardFlowDay 卡日流量快照:每卡每天一条本月自然月累计。 // // MonthUsedMB 按通道上游流量重置日换算为自然月累计,同一天只增不减;SettledMB 是当天已结算的增量合计 // (发出的增量、无生效套餐时丢弃的增量、切换时视为老算法已结算的部分)。由观测链路原子写入,永久保留。 type CardFlowDay struct { ID uint `gorm:"column:id;primaryKey" json:"id"` IotCardID uint `gorm:"column:iot_card_id;type:bigint;not null;uniqueIndex:uk_card_flow_day_card_date" json:"iot_card_id"` FlowDate time.Time `gorm:"column:flow_date;type:date;not null;uniqueIndex:uk_card_flow_day_card_date" json:"flow_date"` MonthUsedMB float64 `gorm:"column:month_used_mb;type:numeric(14,3);not null;default:0" json:"month_used_mb"` VendorUsedMB float64 `gorm:"column:vendor_used_mb;type:numeric(14,3);not null;default:0" json:"vendor_used_mb"` SettledMB float64 `gorm:"column:settled_mb;type:numeric(14,3);not null;default:0" json:"settled_mb"` StaleGuarded bool `gorm:"column:stale_guarded;not null;default:false" json:"stale_guarded"` ObsCount int `gorm:"column:obs_count;not null;default:0" json:"obs_count"` CreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at"` UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"` } // TableName 指定表名 func (CardFlowDay) TableName() string { return "tb_card_flow_day" } // CardFlowSwitch 卡流量计量切换水位:卡第一次走新算法时写入,退回老算法时由维护者删除。 type CardFlowSwitch struct { ID uint `gorm:"column:id;primaryKey" json:"id"` IotCardID uint `gorm:"column:iot_card_id;type:bigint;not null;uniqueIndex:uk_card_flow_switch_card" json:"iot_card_id"` SwitchedAt time.Time `gorm:"column:switched_at;type:timestamptz;not null" json:"switched_at"` MonthUsedMB float64 `gorm:"column:month_used_mb;type:numeric(14,3);not null;default:0" json:"month_used_mb"` VendorUsedMB float64 `gorm:"column:vendor_used_mb;type:numeric(14,3);not null;default:0" json:"vendor_used_mb"` OldBaselineMB float64 `gorm:"column:old_baseline_mb;type:numeric(14,3);not null;default:0" json:"old_baseline_mb"` OldMonthUsageMB float64 `gorm:"column:old_month_usage_mb;type:numeric(14,3);not null;default:0" json:"old_month_usage_mb"` OldReadingAccepted bool `gorm:"column:old_reading_accepted;not null;default:false" json:"old_reading_accepted"` OldIncrementMB float64 `gorm:"column:old_increment_mb;type:numeric(14,3);not null;default:0" json:"old_increment_mb"` CreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at"` } // TableName 指定表名 func (CardFlowSwitch) TableName() string { return "tb_card_flow_switch" }