fix: 完善动态错误指引与发票日期校验(09-05-error-explainability-payment-readiness)
这个提交包含在:
@@ -77,6 +77,30 @@ export function mapApiErrorMessage(
|
||||
return mapApiErrorMessage(code, { ...details, reasonCode: undefined, items: "invoice_item_guard_failed" });
|
||||
}
|
||||
if (code === "VALID_001" && details?.reasonCode !== undefined) {
|
||||
if (details.reasonCode === "invoice_pool.ocr_fields_missing") {
|
||||
const missingFields = readStringList(details.missingFields).filter((field) =>
|
||||
["invoiceCode", "invoiceNumber", "invoiceDate", "totalAmount", "sellerName"].includes(field));
|
||||
if (missingFields.length) {
|
||||
return mapApiErrorMessage(code, { ocr: "missing_required_fields", missingFields });
|
||||
}
|
||||
}
|
||||
if (details.reasonCode === "workflow.remind_cooldown") {
|
||||
const nextAllowedAt = details.nextAllowedAt;
|
||||
if (typeof nextAllowedAt === "string"
|
||||
&& /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/.test(nextAllowedAt)
|
||||
&& Number.isFinite(new Date(nextAllowedAt).getTime())) {
|
||||
return mapApiErrorMessage(code, { workflow: "remind_too_frequent", nextAllowedAt });
|
||||
}
|
||||
}
|
||||
if (details.reasonCode === "auth.password_policy_failed") {
|
||||
const password = readStringList(details.password).filter((rule) => [
|
||||
"密码长度必须 ≥ 12", "密码必须包含小写字母", "密码必须包含大写字母",
|
||||
"密码必须包含数字", "密码过于常见/弱",
|
||||
].includes(rule));
|
||||
if (password.length) {
|
||||
return mapApiErrorMessage(code, { password });
|
||||
}
|
||||
}
|
||||
return resolveErrorReasonMessage(details.reasonCode) ?? UNKNOWN_VALIDATION_MESSAGE;
|
||||
}
|
||||
if (code === "AUTH_001") {
|
||||
|
||||
在新工单中引用
屏蔽一个用户