fix: 修复匹配详情提示及公积金可选路径问题
修复匹配详情中“用户自填未经核验”等来源说明,清理未参与项的橙色注意提示,修正贷款统计口径文案;补充公积金完整可选路径提取逻辑,确保明确无额外时长要求的公积金分支可正确识别并通过。
This commit is contained in:
@@ -2,6 +2,7 @@ import { revisionParams } from './records.uts'
|
||||
import { requestJson } from '@/services/api.uts'
|
||||
import { API_BASE_URL } from '@/services/config.uts'
|
||||
import { yuanToWan } from '@/services/money.uts'
|
||||
import { provinceOptions } from '@/services/cities.uts'
|
||||
|
||||
export type ProductMaterial = { name: string, note: string, required: boolean, objects: string }
|
||||
export type ProductView = { logo: string, materialList: ProductMaterial[], consultPhone: string, repayment: string, channel: string, approval: string, id: string, version: number, name: string, bank: string, type: string, demo: boolean, amount: string, rate: string, term: string, objects: string, regions: string, valid: string, materials: string, source: string, sourceRef: string, checkedOn: string, conditions: string[] }
|
||||
@@ -12,16 +13,23 @@ export type MatchPage = { assessmentId: string, revisionId: string, resultVersio
|
||||
|
||||
function text(data: UTSJSONObject, key: string): string { return data.getString(key) ?? '' }
|
||||
export function validRecordId(value: string): boolean { return /^[1-9][0-9]{0,9}$/.test(value) }
|
||||
export function eligibilityLabel(value: string): string { return value == 'eligible' ? '符合已知条件' : (value == 'ineligible' ? '条件不符' : '待确认') }
|
||||
export function eligibilityLabel(value: string): string { return value == 'eligible' ? '符合已知条件' : (value == 'ineligible' ? '条件不符' : '待核实') }
|
||||
export function hasProductValue(value: string): boolean { return value.trim().length > 0 && !['未提供', '待核实', '—'].includes(value.trim()) }
|
||||
export function matchPercentage(state: string, score: number | null): string { return state == 'eligible' && score != null ? score.toString() + '%' : '' }
|
||||
const fieldNames: UTSJSONObject = { requestedAmountYuan: '融资金额', requestedTermMonths: '融资期限', applicantType: '申请主体', purposeCode: '资金用途', cityCode: '所在城市', monthlyIncome: '月收入', annualRevenue: '年营收', operatingMonths: '经营月数', totalDebtBalance: '贷款余额', monthlyLoanPayment: '每月还款额', creditLoanCount: '贷款笔数', creditCardCount: '信用卡数量', creditCardTotalLimit: '信用卡总额度', creditCardUsedLimit: '信用卡已用额度', socialSecurity: '社保情况', housingFund: '公积金情况', house: '房产情况', car: '车辆情况', establishedMonths: '企业成立月数', annualInvoiceAmount: '年开票金额', taxPaymentMonths: '连续纳税月数', taxpayerGrade: '纳税等级', enterpriseCreditStatus: '企业信用状态', annualRevenueGrowthPercent: '年营收增长率', debtRatioPercent: '负债率', cashFlowStability: '经营流水稳定性', industryCategory: '行业类别' }
|
||||
export function matchPercentage(state: string, score: number | null): string { return ['eligible','unknown','ineligible'].includes(state) && score != null ? score.toString() + '%' : '' }
|
||||
const fieldNames: UTSJSONObject = { age: '年龄', occupation: '职业类型', employer: '单位名称', requestedAmountYuan: '融资金额', requestedTermMonths: '融资期限', applicantType: '申请主体', purposeCode: '资金用途', cityCode: '所在城市', provinceCode: '所在省份', monthlyIncome: '月收入', annualRevenue: '年营收', operatingMonths: '经营月数', totalDebtBalance: '贷款余额', monthlyLoanPayment: '每月还款额', creditLoanCount: '贷款笔数', creditCardCount: '信用卡数量', creditCardTotalLimit: '信用卡总额度', creditCardUsedLimit: '信用卡已用额度', socialSecurity: '社保情况', housingFund: '公积金情况', house: '房产情况', car: '车辆情况', establishedMonths: '企业成立月数', annualInvoiceAmount: '年开票金额', taxPaymentMonths: '连续纳税月数', taxpayerGrade: '纳税等级', enterpriseCreditStatus: '企业信用状态', annualRevenueGrowthPercent: '年营收增长率', debtRatioPercent: '负债率', cashFlowStability: '经营流水稳定性', industryCategory: '行业类别' }
|
||||
const labels: UTSJSONObject = { personal: '个人', enterprise: '企业', daily_consumption: '日常消费', education: '教育进修', home_improvement: '家居装修', personal_business: '个体经营周转', working_capital: '经营周转', inventory_purchase: '采购备货', equipment_purchase: '设备购置', business_expansion: '经营扩展', other: '其他用途', none: '无', under_six_months: '不足六个月', six_months_plus: '六个月及以上', yes: '有', no: '无', normal: '正常', abnormal: '异常', stable: '稳定', unstable: '不稳定', manufacturing: '制造业', trade: '贸易', services: '服务业', construction: '建筑业', agriculture: '农业', finance: '金融业', real_estate: '房地产业', '440300': '深圳市', '440100': '广州市', '110100': '北京市', '310100': '上海市', '330100': '杭州市' }
|
||||
const moneyFields = ['requestedAmountYuan','monthlyIncome','annualRevenue','totalDebtBalance','monthlyLoanPayment','creditCardTotalLimit','creditCardUsedLimit','annualInvoiceAmount']
|
||||
const advisoryReasonCodes = ['AI_CONDITION_NOT_ASSESSED', 'PROFILE_DETAIL_NOT_ASSESSED']
|
||||
|
||||
function displayReasonText(value: string): string {
|
||||
return value.replace(/((?:根据自填资料判断|资料尚需核验|用户自填[,、]未经核验|自填信息未经核验|产品快照))/g, '').replace(/自填信息未经核验;本页面不承诺额度、放款或获批。/g, '结果仅供参考,不代表审批结果。').trim()
|
||||
}
|
||||
|
||||
function valueText(value: any | null, field: string): string {
|
||||
if (value == null) return '未提供'
|
||||
const raw = value.toString()
|
||||
if (field == 'provinceCode') return provinceOptions.find((item): boolean => item.code == raw)?.name ?? '待核实'
|
||||
if (field == 'age') return raw + ' 岁'
|
||||
if (moneyFields.includes(field)) return yuanToWan(raw) + ' 万元'
|
||||
if (field == 'requestedTermMonths' || field == 'operatingMonths' || field == 'establishedMonths' || field == 'taxPaymentMonths') return raw + ' 个月'
|
||||
if (field == 'debtRatioPercent' || field == 'annualRevenueGrowthPercent') return raw + '%'
|
||||
@@ -81,24 +89,37 @@ function matchView(data: UTSJSONObject): MatchView {
|
||||
const evidence = data['evidence'] as UTSJSONObject[]
|
||||
const ai = data['aiExplanation'] as UTSJSONObject
|
||||
const explanations = (ai['reasonExplanations'] as UTSJSONObject[] | null) ?? []
|
||||
const reasons = (key: string): MatchReason[] => (data[key] as UTSJSONObject[]).map((r: UTSJSONObject): MatchReason => {
|
||||
const hiddenAdvisory = (reason: UTSJSONObject): boolean => {
|
||||
const code = text(reason, 'code')
|
||||
if (!advisoryReasonCodes.includes(code)) return false
|
||||
const refs = (reason['evidenceRefs'] as string[] | null) ?? []
|
||||
return refs.length > 0 && refs.every((ref: string): boolean => {
|
||||
const item = evidence.find((entry: UTSJSONObject): boolean => text(entry, 'evidenceId') == ref)
|
||||
if (item == null || text(item, 'reasonCode') != code || text(item, 'outcome') != 'unknown') return false
|
||||
const source = text(item, 'source')
|
||||
return code == 'AI_CONDITION_NOT_ASSESSED' ? source == 'ai_self_reported' : ['self_reported', 'product_snapshot'].includes(source)
|
||||
})
|
||||
}
|
||||
// 仅隐藏证据一致的未参与判断提示;异常记录与原始快照保持可追溯。
|
||||
const reasons = (key: string): MatchReason[] => (data[key] as UTSJSONObject[]).filter((r: UTSJSONObject): boolean => key != 'cautions' || !hiddenAdvisory(r)).map((r: UTSJSONObject): MatchReason => {
|
||||
const reasonFields: string[] = []
|
||||
const reasonText = ['AI_CONDITION_PASS', 'AI_CONDITION_FAIL'].includes(text(r, 'code')) ? text(r, 'text').replace('(根据自填资料判断)', '') : text(r, 'text')
|
||||
const lines = (r['evidenceRefs'] as string[]).map((ref: string): string => {
|
||||
const reasonText = displayReasonText(text(r, 'text'))
|
||||
const lines = ((r['evidenceRefs'] as string[] | null) ?? []).map((ref: string): string => {
|
||||
const e = evidence.find((item: UTSJSONObject): boolean => text(item, 'evidenceId') == ref)
|
||||
if (e == null) return '证据暂不可读取'
|
||||
const fields = e['fieldRefs'] as string[]; const field = fields.length > 0 ? fields[0] : ''
|
||||
fields.forEach((name: string) => { if (!reasonFields.includes(name)) reasonFields.push(name) })
|
||||
if (text(e, 'source') == 'ai_self_reported') {
|
||||
if (e['actual'] != null && fieldNames.getString(field) != null) return fieldNames.getString(field)! + ':' + valueText(e['actual'], field)
|
||||
const names = fields.map((name: string): string => fieldNames.getString(name) ?? '').filter((name: string): boolean => name.length > 0)
|
||||
if (e['actual'] != null && (field == 'age' || fieldNames.getString(field) != null)) return (field == 'age' ? '年龄' : fieldNames.getString(field)!) + ':' + valueText(e['actual'], field)
|
||||
const names = fields.map((name: string): string => name == 'age' ? '年龄' : (fieldNames.getString(name) ?? '')).filter((name: string): boolean => name.length > 0)
|
||||
return names.length > 0 ? '关联资料:' + names.join('、') : reasonText
|
||||
}
|
||||
const source = text(e, 'source') == 'verified' ? '外部核验' : (text(e, 'source') == 'product_snapshot' ? '产品快照' : (text(e, 'source') == 'self_reported' ? '用户自填,未经核验' : '来源未知'))
|
||||
return (fieldNames.getString(field) ?? field) + ':' + valueText(e['actual'], field) + ' · ' + source
|
||||
const source = text(e, 'source')
|
||||
const sourceNote = ['self_reported', 'product_snapshot'].includes(source) ? '' : ' · ' + (source == 'verified' ? '外部核验' : '来源未知')
|
||||
return (fieldNames.getString(field) ?? field) + ':' + valueText(e['actual'], field) + sourceNote
|
||||
})
|
||||
const explanation = explanations.find((item: UTSJSONObject): boolean => text(item, 'reasonId') == text(r, 'reasonId'))
|
||||
return { id: text(r, 'reasonId'), text: reasonText, evidence: lines, fields: reasonFields, explanation: text(ai, 'status') == 'completed' && explanation != null ? text(explanation, 'text') : '' }
|
||||
return { id: text(r, 'reasonId'), text: reasonText, evidence: lines, fields: reasonFields, explanation: text(ai, 'status') == 'completed' && explanation != null ? displayReasonText(text(explanation, 'text')) : '' }
|
||||
})
|
||||
const availability = text(data, 'currentAvailability')
|
||||
const score = data.getNumber('score')
|
||||
@@ -108,7 +129,7 @@ function matchView(data: UTSJSONObject): MatchView {
|
||||
return { score, id: text(data, 'productId'), state: text(data, 'eligibility'), stateLabel: missingData ? '资料不足' : eligibilityLabel(text(data, 'eligibility')), availability,
|
||||
availabilityLabel: availability == 'available' ? '当前产品可查看' : (availability == 'unavailable' ? '当前产品已下架' : '当前产品状态暂无法确认'),
|
||||
product: productView(data['productSnapshot'] as UTSJSONObject, false), positive: reasons('positiveReasons'), blocking: reasons('blockingReasons'), cautions: reasons('cautions'),
|
||||
aiText: text(ai, 'status') == 'completed' ? text(ai, 'text') : (text(ai, 'status') == 'failed' ? 'AI解释暂不可用,已保留全部规则依据。' : '当前展示规则依据,尚未生成单产品AI解释。'),
|
||||
aiText: text(ai, 'status') == 'completed' ? displayReasonText(text(ai, 'text')) : (text(ai, 'status') == 'failed' ? 'AI解释暂不可用,已保留全部规则依据。' : '当前展示规则依据,尚未生成单产品AI解释。'),
|
||||
aiStatus: text(ai, 'status'), aiCanRetry: ai.getBoolean('canRetry') ?? false, aiCanRequest: data.getBoolean('canRequestExplanation') ?? false, aiGeneratedAt: text(ai, 'generatedAt') }
|
||||
}
|
||||
export async function requestProductExplanation(id: string, productId: string, requestId: string, revisionId: string = ''): Promise<MatchView> {
|
||||
@@ -116,6 +137,7 @@ export async function requestProductExplanation(id: string, productId: string, r
|
||||
return detailRecord(data, id, productId, revisionId).item
|
||||
}
|
||||
export async function fetchMatchPage(id: string, group: string, cursor: string, revisionId: string = ''): Promise<MatchPage> {
|
||||
if (!['all','eligible','unknown','ineligible'].includes(group)) throw new Error('匹配分组无效,请重新选择。')
|
||||
const data = await requestJson('/assessments/' + encodeURIComponent(id) + '/matches', 'GET', { ...revisionParams(revisionId), eligibility: group, limit: '3', cursor })
|
||||
const matching = data['matching'] as UTSJSONObject; const status = text(matching, 'status')
|
||||
const resolvedRevision = text(data, 'revisionId'); const version = data.getNumber('resultVersion') ?? 0
|
||||
@@ -123,7 +145,7 @@ export async function fetchMatchPage(id: string, group: string, cursor: string,
|
||||
const items = (data['items'] as UTSJSONObject[]).map((v: UTSJSONObject): MatchView => matchView(v))
|
||||
const hasMore = data.getBoolean('hasMore') ?? false; const nextCursor = text(data, 'nextCursor')
|
||||
const ids: string[] = []
|
||||
items.forEach((item: MatchView) => { if (item.state != group || ids.includes(item.id)) throw new Error('匹配分组或产品编号不一致,请重新加载。'); ids.push(item.id) })
|
||||
items.forEach((item: MatchView) => { if ((group != 'all' && item.state != group) || ids.includes(item.id)) throw new Error('匹配分组或产品编号不一致,请重新加载。'); ids.push(item.id) })
|
||||
if (!['completed','unavailable'].includes(status) || items.length > 3 || (hasMore && (items.length == 0 || nextCursor.length == 0)) || (!hasMore && nextCursor.length > 0) || (status == 'unavailable' && (items.length > 0 || hasMore))) throw new Error('匹配分页状态不完整,请重新加载。')
|
||||
if (status == 'completed') {
|
||||
if (text(matching, 'catalogSnapshotId').length == 0 || text(matching, 'ruleVersion').length == 0 || text(matching, 'orderingPolicyVersion').length == 0) throw new Error('匹配快照版本不完整,请重新加载。')
|
||||
@@ -132,7 +154,7 @@ export async function fetchMatchPage(id: string, group: string, cursor: string,
|
||||
}
|
||||
const reason = text(matching, 'reasonCode')
|
||||
const count = (key: string): string => { const v = matching.getNumber(key); return v == null ? '—' : v.toString() }
|
||||
const message = status == 'completed' ? (text(matching, 'orderingPolicyVersion') == 'product-score-descending-v1' ? '按本次条件匹配度排序,匹配度不代表获批概率。' : '按本次评估时的产品条件判断,展示顺序不代表优劣。') : (reason == 'LEGACY_INPUT' ? '旧版报告未执行产品匹配,可重新评估获取新的结果。' : (reason == 'MATCH_RULES_UNPUBLISHED' ? '本次评估尚未启用产品匹配规则。' : '本次评估没有可用产品目录,未执行产品匹配。'))
|
||||
const message = status == 'completed' ? (group == 'all' ? '优先展示符合条件的产品,其次为待核实、条件不符的产品。' : (text(matching, 'orderingPolicyVersion') == 'product-score-descending-v1' ? '按本次条件匹配度排序,匹配度不代表获批概率。' : '按本次评估时的产品条件判断,展示顺序不代表优劣。')) : (reason == 'LEGACY_INPUT' ? '旧版报告未执行产品匹配,可重新评估获取新的结果。' : (reason == 'MATCH_RULES_UNPUBLISHED' ? '本次评估尚未启用产品匹配规则。' : '本次评估没有可用产品目录,未执行产品匹配。'))
|
||||
return { assessmentId: id, revisionId: resolvedRevision, resultVersion: version, snapshotId: text(matching, 'catalogSnapshotId'), ruleVersion: text(matching, 'ruleVersion'), orderingVersion: text(matching, 'orderingPolicyVersion'), status, message, eligible: count('candidateCount'), ineligible: count('ineligibleCount'), unknown: count('unknownCount'), items, hasMore, cursor: nextCursor }
|
||||
}
|
||||
export async function fetchMatchDetail(id: string, productId: string, revisionId: string = ''): Promise<MatchView> {
|
||||
|
||||
Reference in New Issue
Block a user