Files
junhong_cmp_fiber/internal/application/cardobservation/business_event.go
break 5c4d17e9fc
Some checks failed
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Has been cancelled
收口七月卡状态回调与系列授权兼容契约
完成运营商实名回调、业务事件观测序列与受控配置装配,同时恢复 UR43 已交付的 packages[].remove 字段及旧响应兼容,统一更新 OpenSpec、OpenAPI 和交付文档。

Constraint: 七月测试环境里程碑不新增或运行自动化测试

Rejected: 以必填 operation_type 替换 packages[].remove | 会破坏已交付前端契约

Confidence: high

Scope-risk: broad

Directive: 后续修改系列套餐管理接口必须保持 packages[].remove 和 ShopSeriesGrantResponse 兼容

Tested: go run ./cmd/gendocs;go build -buildvcs=false ./...;openspec validate complete-july-iteration-test-release --strict;git diff --check

Not-tested: 按本 Change 约定未运行 go test,真实运营商与 Gateway 联调延期
2026-07-24 19:59:24 +08:00

42 lines
1.4 KiB
Go

package cardobservation
import (
"context"
"time"
"gorm.io/gorm"
)
type suppressSeriesTriggerKey struct{}
// SuppressSeriesTriggerContext 标记观测结果驱动的业务评估,避免形成反向触发环。
func SuppressSeriesTriggerContext(ctx context.Context) context.Context {
return context.WithValue(ctx, suppressSeriesTriggerKey{}, true)
}
// IsSeriesTriggerSuppressed 判断当前业务调用是否来自观测结果消费。
func IsSeriesTriggerSuppressed(ctx context.Context) bool {
value, _ := ctx.Value(suppressSeriesTriggerKey{}).(bool)
return value
}
// SeriesRequestedEvent 是业务成功边界可靠请求观测序列的事实。
type SeriesRequestedEvent struct {
EventID string `json:"event_id"`
Scene string `json:"scene"`
ResourceType string `json:"resource_type"`
ResourceID uint `json:"resource_id"`
ResourceIDs []uint `json:"resource_ids,omitempty"`
SyncTypes []string `json:"sync_types"`
ExpectedValue string `json:"expected_value,omitempty"`
Source string `json:"source"`
OccurredAt time.Time `json:"occurred_at"`
RequestID string `json:"request_id,omitempty"`
CorrelationID string `json:"correlation_id,omitempty"`
}
// SeriesEventWriter 在原业务事务中追加观测序列请求事件。
type SeriesEventWriter interface {
AppendSeriesRequested(ctx context.Context, tx *gorm.DB, event SeriesRequestedEvent) error
}