fix: complete October 22 workflow feedback and request failure recovery

This commit is contained in:
2026-10-22 23:06:00 +08:00
parent f701456de1
commit a16a85e14a
85 changed files with 1518 additions and 277 deletions
@@ -366,7 +366,7 @@ async function loadPricingEvidence(context) {
return { activeVersionIds: active.map((item) => id(item.id)).filter(Boolean), profiles }
}
async function ensureCustomerChargeRule(context, resource, profile) {
export async function ensureCustomerChargeRule(context, resource, profile) {
if (context.financeFixtureHooks?.ensureCustomerChargeRule) {
return context.financeFixtureHooks.ensureCustomerChargeRule(context, resource, profile)
}
@@ -389,6 +389,15 @@ async function ensureCustomerChargeRule(context, resource, profile) {
const applicable = rows(listed).filter((rule) => rule?.status === 'ACTIVE'
&& rule?.businessType === businessType && rule?.taxMode === 'TAX_EXCLUDED')
let desired = applicable.find((rule) => rule?.chargeMode === profile.chargeUnit)
if (context.options?.fixedCustomerId) {
const defaults = applicable.filter(rule => rule.defaultRule === true)
const selected = applicable.length === 1 ? applicable[0] : defaults.length === 1 ? defaults[0] : null
const valid = selected?.id && id(selected.customerId) === tenantId && selected.chargeMode === profile.chargeUnit
context.assert(MODULE, '固定客户复用现有有效默认计费方式', listResponse, Boolean(valid),
`customerId=${tenantId}, chargeMode=${profile.chargeUnit}`, OPTIONS)
if (!valid) throw new Error('固定客户缺少匹配且无歧义的计费规则,禁止自动创建或切换默认规则')
return selected
}
if (!desired) {
const effectiveFrom = new Date(Date.now() - 86_400_000).toISOString().slice(0, 19)
const body = {