feat: 卡实名时间以上游 archiveTime 为准并记录实名时间历史,新增二次实名批次
Some checks failed
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Has been cancelled

This commit is contained in:
邹进
2026-11-08 19:12:46 +09:00
parent 94f86ab217
commit 4967f4df43
32 changed files with 1885 additions and 47 deletions

View File

@@ -0,0 +1,67 @@
package model
import (
"time"
"gorm.io/datatypes"
)
// IotCardRealname 是卡的当前实名记录(每卡一行)。
// 实名状态 real_name_status 仍在 tb_iot_card;这里只记录实名时间及来源、二次实名状态。
type IotCardRealname struct {
ID uint `gorm:"column:id;primaryKey" json:"id"`
CardID uint `gorm:"column:card_id;not null" json:"card_id"`
RealnameAt *time.Time `gorm:"column:realname_at" json:"realname_at,omitempty"`
RealnameAtSource string `gorm:"column:realname_at_source;type:varchar(20);not null;default:''" json:"realname_at_source"`
UpstreamRealnameAt *time.Time `gorm:"column:upstream_realname_at" json:"upstream_realname_at,omitempty"`
FirstObservedAt *time.Time `gorm:"column:first_observed_at" json:"first_observed_at,omitempty"`
ResetStatus string `gorm:"column:reset_status;type:varchar(20);not null;default:'none'" json:"reset_status"`
ResetAt *time.Time `gorm:"column:reset_at" json:"reset_at,omitempty"`
ResetBaselineAt *time.Time `gorm:"column:reset_baseline_at" json:"reset_baseline_at,omitempty"`
ResetBatchID *uint `gorm:"column:reset_batch_id" json:"reset_batch_id,omitempty"`
CreatedAt time.Time `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP" json:"created_at"`
UpdatedAt time.Time `gorm:"column:updated_at;not null;default:CURRENT_TIMESTAMP" json:"updated_at"`
}
// TableName 指定表名。
func (IotCardRealname) TableName() string { return "tb_iot_card_realname" }
// IotCardRealnameHistory 是卡实名时间变化历史(只追加)。
type IotCardRealnameHistory struct {
ID uint `gorm:"column:id;primaryKey" json:"id"`
CardID uint `gorm:"column:card_id;not null" json:"card_id"`
ICCID string `gorm:"column:iccid;type:varchar(20);not null;default:''" json:"iccid"`
BeforeAt *time.Time `gorm:"column:before_at" json:"before_at,omitempty"`
AfterAt *time.Time `gorm:"column:after_at" json:"after_at,omitempty"`
AfterSource string `gorm:"column:after_source;type:varchar(20);not null;default:''" json:"after_source"`
ChangeType string `gorm:"column:change_type;type:varchar(30);not null" json:"change_type"`
ObservationSource string `gorm:"column:observation_source;type:varchar(30);not null;default:''" json:"observation_source"`
ResetBatchID *uint `gorm:"column:reset_batch_id" json:"reset_batch_id,omitempty"`
OperatorID uint `gorm:"column:operator_id;not null;default:0" json:"operator_id"`
ObservedAt time.Time `gorm:"column:observed_at;not null" json:"observed_at"`
CreatedAt time.Time `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP" json:"created_at"`
}
// TableName 指定表名。
func (IotCardRealnameHistory) TableName() string { return "tb_iot_card_realname_history" }
// IotCardRealnameResetBatch 是二次实名导入批次。
type IotCardRealnameResetBatch struct {
ID uint `gorm:"column:id;primaryKey" json:"id"`
BatchNo string `gorm:"column:batch_no;type:varchar(40);not null" json:"batch_no"`
ImportFileKey string `gorm:"column:import_file_key;type:varchar(500);not null;default:''" json:"import_file_key"`
Reason string `gorm:"column:reason;type:varchar(500);not null;default:''" json:"reason"`
TotalCount int `gorm:"column:total_count;not null;default:0" json:"total_count"`
SucceededCount int `gorm:"column:succeeded_count;not null;default:0" json:"succeeded_count"`
SkippedCount int `gorm:"column:skipped_count;not null;default:0" json:"skipped_count"`
RevertedCount int `gorm:"column:reverted_count;not null;default:0" json:"reverted_count"`
CompletedCount int `gorm:"column:completed_count;not null;default:0" json:"completed_count"`
Items datatypes.JSON `gorm:"column:items;type:jsonb;not null;default:'[]'" json:"items"`
OperatorID uint `gorm:"column:operator_id;not null;default:0" json:"operator_id"`
OperatorName string `gorm:"column:operator_name;type:varchar(100);not null;default:''" json:"operator_name"`
CreatedAt time.Time `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP" json:"created_at"`
UpdatedAt time.Time `gorm:"column:updated_at;not null;default:CURRENT_TIMESTAMP" json:"updated_at"`
}
// TableName 指定表名。
func (IotCardRealnameResetBatch) TableName() string { return "tb_iot_card_realname_reset_batch" }