feat(billing): 完成异步结算与请求执行闭环
统一任务成功、Attempt 与结算 Outbox 的事务边界,增加多实例安全结算、人工复核、请求幂等与执行租约。钱包决策使用九位精确金额,并通过审计保护约束保留流水事实;同时补充管理接口、指标与 PostgreSQL 集成测试。
This commit is contained in:
@@ -37,19 +37,14 @@ func (s *Service) Estimate(ctx context.Context, kind string, model string, body
|
||||
return EstimateResult{}, err
|
||||
}
|
||||
estimates := make([]candidateEstimate, 0, len(candidates))
|
||||
var pricingErr error
|
||||
for _, candidate := range candidates {
|
||||
candidateBody := preprocessRequest(kind, cloneMap(body), candidate)
|
||||
estimate, candidateErr := s.estimateCandidateV2(ctx, user, kind, candidateBody, candidate)
|
||||
if candidateErr != nil {
|
||||
pricingErr = candidateErr
|
||||
continue
|
||||
return EstimateResult{}, candidateErr
|
||||
}
|
||||
estimates = append(estimates, estimate)
|
||||
}
|
||||
if len(estimates) == 0 && pricingErr != nil {
|
||||
return EstimateResult{}, pricingErr
|
||||
}
|
||||
return buildEstimateResult(estimates, pricingRequestFingerprint(kind, model, body))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user