feat: 完善 Rock 发货异常闭环与绑定判定
This commit is contained in:
@@ -31,6 +31,24 @@ const (
|
||||
// RockStatusAnomaly 表示「历史流转中出现过异常」的 Token,不改变其主状态。
|
||||
RockStatusAnomaly = "anomaly"
|
||||
|
||||
// Rock 发货异常事件。
|
||||
RockIncidentStatusOpen = "open"
|
||||
RockIncidentStatusResolved = "resolved"
|
||||
RockIncidentStatusIgnored = "ignored"
|
||||
|
||||
RockIncidentCategoryNoEntitlement = "no_entitlement"
|
||||
RockIncidentCategoryDuplicateItem = "duplicate_item"
|
||||
RockIncidentCategoryGiftExhausted = "gift_exhausted"
|
||||
RockIncidentCategoryTokenRedeemed = "token_already_redeemed"
|
||||
RockIncidentCategoryTokenNotRedeemable = "token_not_redeemable"
|
||||
RockIncidentCategoryTokenNotFound = "token_not_found"
|
||||
RockIncidentCategoryUpstreamTimeout = "upstream_timeout"
|
||||
RockIncidentCategoryRateLimited = "upstream_rate_limited"
|
||||
RockIncidentCategoryShipTimeout = "ship_timeout"
|
||||
RockIncidentCategoryBindMismatch = "bind_mismatch"
|
||||
RockIncidentCategoryOrderCancelled = "order_cancelled"
|
||||
RockIncidentCategoryOther = "other"
|
||||
|
||||
RockSKUBlackTshirt = "rock_black_tshirt"
|
||||
RockSKUBlueSportswear = "rock_blue_sportswear"
|
||||
|
||||
@@ -137,6 +155,13 @@ type RockToken struct {
|
||||
AnomalyReason string `gorm:"-" json:"anomaly_reason,omitempty"`
|
||||
AnomalyAt *time.Time `gorm:"-" json:"anomaly_at,omitempty"`
|
||||
AnomalyCount int `gorm:"-" json:"anomaly_count"`
|
||||
|
||||
// 当前开放异常,供列表筛选和人工处理入口使用。
|
||||
HasOpenIncident bool `gorm:"-" json:"has_open_incident"`
|
||||
IncidentCategory string `gorm:"-" json:"incident_category,omitempty"`
|
||||
IncidentMessage string `gorm:"-" json:"incident_message,omitempty"`
|
||||
IncidentAt *time.Time `gorm:"-" json:"incident_at,omitempty"`
|
||||
IncidentCount int64 `gorm:"-" json:"incident_count,omitempty"`
|
||||
}
|
||||
|
||||
func (RockToken) TableName() string {
|
||||
@@ -193,6 +218,34 @@ func (RockDeliveryLog) TableName() string {
|
||||
return "rock_delivery_logs"
|
||||
}
|
||||
|
||||
// RockDeliveryIncident 是需要人工处理的发货异常事件。
|
||||
// 原始报文仍保存在 rock_delivery_logs,本表只保存分类和处理状态。
|
||||
type RockDeliveryIncident struct {
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
TokenID uint `gorm:"not null;index:idx_rock_delivery_incidents_token" json:"token_id"`
|
||||
OrderNo string `gorm:"size:128;not null;default:'';index:idx_rock_delivery_incidents_order" json:"order_no"`
|
||||
UpstreamTokenID string `gorm:"size:64;not null;default:''" json:"upstream_token_id"`
|
||||
Category string `gorm:"size:40;not null;index:idx_rock_delivery_incidents_filter" json:"category"`
|
||||
Status string `gorm:"size:16;not null;default:'open';index:idx_rock_delivery_incidents_filter" json:"status"`
|
||||
BlockingRetry bool `gorm:"not null;default:true" json:"blocking_retry"`
|
||||
Message string `gorm:"type:text;not null;default:''" json:"message"`
|
||||
UpstreamHTTPStatus int `gorm:"not null;default:0" json:"upstream_http_status"`
|
||||
UpstreamResponse string `gorm:"type:text;not null;default:''" json:"upstream_response"`
|
||||
Occurrences int `gorm:"not null;default:1" json:"occurrences"`
|
||||
FirstSeenAt time.Time `json:"first_seen_at"`
|
||||
LastSeenAt time.Time `json:"last_seen_at"`
|
||||
ResolvedAt *time.Time `json:"resolved_at,omitempty"`
|
||||
ResolvedBy *uint `gorm:"index" json:"resolved_by,omitempty"`
|
||||
ResolutionAction string `gorm:"size:32;not null;default:''" json:"resolution_action"`
|
||||
ResolutionNote string `gorm:"type:text;not null;default:''" json:"resolution_note"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
func (RockDeliveryIncident) TableName() string {
|
||||
return "rock_delivery_incidents"
|
||||
}
|
||||
|
||||
// RockPurchaseLog 是一次采购尝试的主记录。
|
||||
// 每一次真正进入采购流程的尝试都会落一条,包含降级原因与各阶段汇总。
|
||||
type RockPurchaseLog struct {
|
||||
|
||||
Reference in New Issue
Block a user