feat:采购日志
This commit is contained in:
@@ -100,3 +100,56 @@ type RockToken struct {
|
||||
func (RockToken) TableName() string {
|
||||
return "rock_tokens"
|
||||
}
|
||||
|
||||
// RockPurchaseLog 是一次采购尝试的主记录。
|
||||
// 每一次真正进入采购流程的尝试都会落一条,包含降级原因与各阶段汇总。
|
||||
type RockPurchaseLog struct {
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
TriggerType string `gorm:"size:16;not null;default:'auto';index:idx_rock_purchase_logs_trigger_status" json:"trigger_type"` // auto / manual
|
||||
Status string `gorm:"size:16;not null;default:'running'" json:"status"` // running / success / partial / failed / skipped
|
||||
RequestedCount int `gorm:"not null;default:0" json:"requested_count"`
|
||||
PlannedCount int `gorm:"not null;default:0" json:"planned_count"`
|
||||
ClaimedCount int `gorm:"not null;default:0" json:"claimed_count"`
|
||||
ImportedCount int `gorm:"not null;default:0" json:"imported_count"`
|
||||
UpstreamAvailable int `gorm:"not null;default:0" json:"upstream_available"`
|
||||
PointsBefore float64 `gorm:"type:numeric(12,2);not null;default:0" json:"points_before"`
|
||||
UnitCost float64 `gorm:"type:numeric(12,2);not null;default:0" json:"unit_cost"`
|
||||
MaxByPoints int `gorm:"not null;default:0" json:"max_by_points"`
|
||||
MaxByStock int `gorm:"not null;default:0" json:"max_by_stock"`
|
||||
LimitReason string `gorm:"size:32;not null;default:''" json:"limit_reason"` // points / upstream_stock / points_and_stock
|
||||
PointsSource string `gorm:"size:16;not null;default:''" json:"points_source"` // live / snapshot
|
||||
Stage string `gorm:"size:32;not null;default:''" json:"stage"`
|
||||
ErrorMessage string `gorm:"type:text;not null;default:''" json:"error_message"`
|
||||
PackageID *int64 `json:"package_id,omitempty"`
|
||||
ShareCode string `gorm:"size:64;not null;default:''" json:"share_code"`
|
||||
DurationMs int `gorm:"not null;default:0" json:"duration_ms"`
|
||||
StartedAt time.Time `json:"started_at"`
|
||||
FinishedAt *time.Time `json:"finished_at,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
func (RockPurchaseLog) TableName() string {
|
||||
return "rock_purchase_logs"
|
||||
}
|
||||
|
||||
// RockPurchaseStage 记录一次采购中单个上游调用的原始请求与响应。
|
||||
// ResponseBody 保存上游返回的原始 JSON 原文;超过 512KB 时截断并置 Truncated。
|
||||
type RockPurchaseStage struct {
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
LogID uint `gorm:"not null;index:idx_rock_purchase_stages_log_id" json:"log_id"`
|
||||
Seq int `gorm:"not null;default:0" json:"seq"`
|
||||
Stage string `gorm:"size:32;not null" json:"stage"`
|
||||
Method string `gorm:"size:8;not null;default:''" json:"method"`
|
||||
URL string `gorm:"type:text;not null;default:''" json:"url"`
|
||||
RequestBody string `gorm:"type:text;not null;default:''" json:"request_body"`
|
||||
HTTPStatus int `gorm:"not null;default:0" json:"http_status"`
|
||||
ResponseBody string `gorm:"type:text;not null;default:''" json:"response_body"`
|
||||
Truncated bool `gorm:"not null;default:false" json:"truncated"`
|
||||
DurationMs int `gorm:"not null;default:0" json:"duration_ms"`
|
||||
ErrorMessage string `gorm:"type:text;not null;default:''" json:"error_message"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
func (RockPurchaseStage) TableName() string {
|
||||
return "rock_purchase_stages"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user