/** * 册 6《计费与对账出账》四页:FN-05 对账清单(14.1)、批次详情(14.2)、FN-08 账单明细与明细详情(14.3)。 * * 接线状态(2026-11-11 核实):bos.recon/* 与 bos.bill/* 未在 openapi.yaml 声明 ⇒ 网关 11001 未声明即拒绝。 * 撞 11001 ⇒ 契约占位分支(结构按 14 章落位、横幅标明待接线、数据区「后端未下发」); * ⛔ 用 settlement-demo/settlement-retries 本地台账冒充真接口(=绕过,本版起不再作为本页数据源)。 * 文案唯一真源 ../lib/copy-billing(逐字复制自册 6 契约 14 章/05 章 §5.1,⛔ 手打转述); * 「分成方式与取值」列走 ../lib/settle-text 单源(册 4 settle_text,⛔ 本册自造分成取值文案)。 * 禁项:⛔「按金额分成本期不计算」「未对账」「已打回」字样;⛔ 出账状态与批次状态混列;⛔ history.back()。 */ import { useEffect, useState, type FormEvent } from "react"; import { PageIntro } from "../components/PageIntro"; import { ArrowLeft, ArrowRight, Download, FileSpreadsheet, Search, X } from "lucide-react"; import { Link, useLocation, useNavigate, useParams, useSearchParams } from "react-router"; import { Button } from "../components/ui/button"; import { SearchInput } from "../components/ui/search-input"; import { FilterSelect } from "../components/ui/filter-select"; import { MonthFilter } from "../components/ui/month-filter"; import { ServerListPager } from "../components/ListPager"; import { OpsNotice, OpsStatus, OpsTableColumns, OpsTableEmpty, OpsTag, type OpsTone } from "../components/OperationsKit"; import { useDemoIdentity } from "../lib/demo-session"; import { entTeamGetList, operatorGetList, partnerGetList, reconExportDetail, reconExportList } from "../lib/api/bos"; import type { HolderType, ReconBatchStatus, ReconcileStatus, ReconDetailResult } from "../lib/api/types"; import type { StatusTone } from "../domain/statuses"; import { WORD_FETCH_FAILED } from "../lib/api/lockedCopy"; import { settleTextFromSnapshot } from "../lib/settle-text"; import { lastClosedMonth, submitReconRerun, useBillDetail, useBillList, useReconDetail, useReconList, useReconPeriods, } from "../lib/recon"; import { ACTION_FLAG_PENDING_NOTE, ALL_PERIODS_LABEL, BACK_TO_BILL_DETAIL, BACK_TO_BILL_LIST, BACK_TO_CORRECTIONS, BACK_TO_RECON_DETAIL, BACK_TO_RECON_LIST, BACKEND_NOT_WIRED, BASE_FLOOR_NOTE, BATCH_STATUS_TEXT, BILL_WIRING_NOTE, COST_UNCONFIGURED_NOTE, EXECUTOR_SYSTEM, EXPORT_EMPTY_NOTE, exportResultNote, HOLDER_TYPE_TEXT, MONTH_NO_BATCH_NOTE, PERIODS_UNAVAILABLE, periodProgressLine, PROGRESS_COLLAPSE, PROGRESS_EXPAND, RECON_WIRING_NOTE, RECONCILE_STATUS_TEXT, RERUN_DIALOG_TITLE, RERUN_NO_EMPTY_BATCH_NOTE, RERUN_SUBMIT, RERUN_VOID_NOTE, rerunMonthBoundNote, rerunScopeLine, S404_EMPTY_NOTE, STAT_CARDS, TICKET_GAP_LABEL, ticketGapText, TRIGGER_TYPE_TEXT, VOIDED_BY_PREFIX, ZERO_NOTE_TEXT, } from "../lib/copy-billing"; import "../styles/operations.css"; import "../styles/settlement-records.css"; /* ── 本地小工具 ─────────────────────────────────────────────────── */ /** 金额列以 `_cents`(分)下发;界面统一两位小数元。 */ const moneyFromCents = (cents: number): string => `¥${(cents / 100).toLocaleString("zh-CN", { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`; /** 三态格:null ⇒ 「取数失败」(KLT-S406 单格语义),⛔ 回落 0。 */ const moneyCell = (cents: number | null): string => (cents == null ? WORD_FETCH_FAILED : moneyFromCents(cents)); const reconcileTone: Record = { settled: "success", abnormal: "danger", unsettled: "neutral" }; const batchTone: Record = { pending: "neutral", executed: "success", failed: "danger", voided: "neutral" }; const holderTone: Record = { operator: "brand", partner: "info", ops_team: "warning" }; /** * 执行时间本地化:后端 `CAST(executed_at AS TEXT)` 下发 UTC 裸串(`2026-11-13 03:49:40.05+00`), * 直接入列既难读又与手册「执行时间」口径不符 ⇒ 按浏览器时区显示,原文留 `title` 可核。 */ function localTime(iso: string): string { const d = new Date(iso.includes("T") ? iso : iso.replace(" ", "T")); if (Number.isNaN(d.getTime())) return iso; const p = (n: number) => String(n).padStart(2, "0"); return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}`; } /** * 执行人可读化:优先绑定表用户名(`operator_username`);NULL ⇒「系统」(对账§14.2); * 只有裸 seoh 用户 ID 时标明是 ID,⛔ 把裸 ID 当人名直接渲染。 */ function executorText(e: { operator_user_id: string | null; operator_username?: string | null }): string { const name = e.operator_username?.trim(); if (name) return name; return e.operator_user_id ? `用户 ${e.operator_user_id}` : EXECUTOR_SYSTEM; } const batchPath = (holderId: string, batchNo: string) => `/settlement-batches/${encodeURIComponent(holderId)}/${encodeURIComponent(batchNo)}`; /** URL 搜索参数筛选(返回列表时保留条件;⛔ 路由级收敛另行处理)。 */ function useListFilters() { const [params, setParams] = useSearchParams(); const has = (key: string) => params.has(key); const get = (key: string) => params.get(key) ?? ""; const set = (key: string, value: string) => setParams((current) => { const next = new URLSearchParams(current); if (value) next.set(key, value); else next.delete(key); return next; }, { replace: true }); const reset = () => setParams({}, { replace: true }); return { has, get, set, reset }; } /** 失败原因行末红点(fail_reason 原文悬浮;⚠️ 不是 KLT-* 码,对账§7.1 末格)。 */ function FailDot({ reason }: { reason: string | null }) { if (!reason) return null; return ●; } /* ── 人工补跑对话框(14.1 动作矩阵:仅 admin;入参只三件) ────────── */ function RerunDialog({ onClose }: { onClose: () => void }) { const navigate = useNavigate(); const location = useLocation(); const [holderType, setHolderType] = useState("operator"); const [holders, setHolders] = useState<{ id: string; name: string }[] | null>(null); const [holdersError, setHoldersError] = useState(""); const [holderId, setHolderId] = useState(""); const [period, setPeriod] = useState(lastClosedMonth()); const [error, setError] = useState(""); const [busy, setBusy] = useState(false); // 分成方候选=第 1 册三类档案真源列表口(⛔ 本地台账);切换类型时重拉。 useEffect(() => { let alive = true; setHolders(null); setHoldersError(""); setHolderId(""); // ⚠️ bos 列表接口 `page` 以 0 为首页(同 `organization-demo.ts::pagedAll`)⇒ 传 1 会跳过首页, // dev 数据不足一页时候选恒空(补跑弹窗打不开)。 const load = holderType === "operator" ? operatorGetList({ page: 0, page_size: 100 }).then((r) => (r.items ?? []).map((o) => ({ id: o.operator_id, name: o.name }))) : holderType === "partner" ? partnerGetList({ page: 0, page_size: 100 }).then((r) => (r.items ?? []).map((p) => ({ id: p.partner_id, name: p.name }))) : entTeamGetList({ page: 0, page_size: 100 }).then((r) => (r.items ?? []).map((t) => ({ id: t.team_id, name: t.team_name }))); load .then((rows) => { if (!alive) return; setHolders(rows); setHolderId(rows[0]?.id ?? ""); }) .catch((e: unknown) => { if (alive) setHoldersError(e instanceof Error ? e.message : WORD_FETCH_FAILED); }); return () => { alive = false; }; }, [holderType]); function submit(event: FormEvent) { event.preventDefault(); if (!holderId || !period) { setError(!holderId ? "请选择分成方。" : "请选择自然月。"); return; } setBusy(true); setError(""); submitReconRerun({ holder_type: holderType, holder_id: holderId, period }) .then((res) => { onClose(); navigate(batchPath(holderId, res.batch_no), { state: location.state }); }) .catch((e: unknown) => { // 四道闸(60502→60503→60504→60506)/KLT-S407:文案直读后端 message(出路句由服务端带出)。 setError(e instanceof Error && e.message ? e.message : "补跑失败,请重试。"); setBusy(false); }); } // 弹窗须写明补跑对象(分成方名称+月份),⛔ 只回显 ID。 const holderName = holders?.find((h) => h.id === holderId)?.name ?? holderId; return (
event.stopPropagation()}>

{RERUN_DIALOG_TITLE}

{ setHolderType(event.target.value as HolderType); }}> {" "} {holders ? ( setHolderId(event.target.value)}> {holders.map((h) => )} {!holders.length && } ) : ( {holdersError || "加载中…"} )}{" "} {/* 月份上界=上一个已结束自然月(对账§8.3 只可对已结束月份补跑);期次必填 ⇒ ⛔「全部自然月」。 */}

{rerunScopeLine(holderName, period)}

{rerunMonthBoundNote(lastClosedMonth())}

{RERUN_NO_EMPTY_BATCH_NOTE}

{RERUN_VOID_NOTE}

{error &&

{error}

}
); } /* ── FN-05 对账清单(14.1) ─────────────────────────────────────── */ export function SettlementStatementListPage() { const identity = useDemoIdentity(); const location = useLocation(); const filters = useListFilters(); // 导出当前结果(B):admin/opsMain/opsSub(demo 角色无 opsSub);⛔ teamLead/partner/operator。 const canExportAll = !identity || identity.role === "admin" || identity.role === "regAdmin"; const isAdmin = !identity || identity.role === "admin"; const defaultMonth = lastClosedMonth(); // 自然月三态:参数缺席 ⇒ 默认预选 lastClosedMonth();显式 "all" ⇒ 全部自然月(空值项,⛔ 不得删除)。 const monthAll = filters.get("month") === "all"; const month = monthAll ? "" : filters.get("month") || defaultMonth; const type = filters.get("type"); const party = filters.get("party"); const reconcile = filters.get("reconcile"); const status = filters.get("status"); const trigger = filters.get("trigger"); const zero = filters.get("zero") === "1"; const q = filters.get("q"); const page = Number(filters.get("page") || "1") || 1; const setMonth = (value: string) => { filters.set("page", ""); filters.set("month", value === "" ? "all" : value === defaultMonth ? "" : value); }; const hasFilter = Boolean(monthAll || filters.get("month") || type || party || reconcile || status || trigger || zero || q); const periodsFetch = useReconPeriods(); // D-19:下拉选项=接口期次 ∪ 上一个已结束自然月(与人工补跑弹窗 `lastClosedMonth()` 同基准)。 // 仅有历史批、尚无「上月」批时,仍须能选上月(可能空表),⛔ 静默退到更早月造成「弹窗说 10 月、清单只到 9 月」。 const periods = (() => { const raw = periodsFetch.data?.periods ?? null; if (!raw) return null; if (raw.includes(defaultMonth)) return raw; return [defaultMonth, ...raw]; })(); // 仅当**用户显式选了**不在选项内的历史月(例如书签)才纠偏;默认预选月即使暂无批次也保留。 const [monthFallback, setMonthFallback] = useState(false); useEffect(() => { if (!periods?.length) return; if (monthAll) { setMonthFallback(false); return; } if (!filters.has("month")) { setMonthFallback(false); return; } if (periods.includes(month)) { setMonthFallback(false); return; } filters.set("month", periods[0]); setMonthFallback(true); // eslint-disable-next-line react-hooks/exhaustive-deps }, [periods, month, monthAll]); const list = useReconList({ period: month, holderType: type, holderKw: party, reconcileStatus: reconcile, batchStatus: status, trigger, includeZero: zero, keyword: q, page, }); const data = list.data; const wiring = list.fail?.kind === "wiring"; const s404 = list.fail?.kind === "s404"; const rows = data?.items ?? []; const total = data?.total ?? 0; const pageSize = 20; const [notice, setNotice] = useState(""); const [runOpen, setRunOpen] = useState(false); const [progressOpen, setProgressOpen] = useState(false); function exportAll() { // 筛选无结果 ⇒ 只提示、不导出、无错误码(14.1 动作矩阵)。 if (!rows.length) { setNotice(EXPORT_EMPTY_NOTE); return; } reconExportList({ period: month || undefined, holder_type: type || undefined, status: status || undefined }) .then((res) => setNotice(exportResultNote(res))) .catch((e: unknown) => setNotice(e instanceof Error && e.message ? e.message : WORD_FETCH_FAILED)); } return (

RECONCILIATION / 分成与对账

对账清单

每个账期出账后,按分成方核对批次状态和结算结果。
{isAdmin && }
{runOpen && setRunOpen(false)} />} {/* 接线占位横幅(klt-bos recon/* 未交付;交付后本分支自然失效) */} {wiring &&

{RECON_WIRING_NOTE}

} {periodsFetch.fail && !wiring &&

{PERIODS_UNAVAILABLE}

} {monthFallback && !rows.length &&

{MONTH_NO_BATCH_NOTE}

} {/* ② 三统计卡:与列表同一响应同一行集;S404 ⇒ 整体不渲染(不是显示 0);单格 null ⇒「取数失败」。 */} {!s404 && !wiring && data && (
{STAT_CARDS.map((card) => { const value = card.key === "base" ? data.stats.total_base_cents : card.key === "cost" ? data.stats.total_cost_cents : data.stats.total_share_cents; return (
{card.title} {moneyCell(value)} {card.subtitle}
); })}
)} {/* 契约占位分支:卡结构落位、值格显式标「后端未下发」(总则§16.9,⛔ 演示例数冒充)。 */} {wiring && (
{STAT_CARDS.map((card) => (
{card.title} {BACKEND_NOT_WIRED} {card.subtitle}
))}
)} {/* ③-1 期次出账进度(常驻;只随自然月变化,⛔ 随其余筛选变;后端未下发 ⇒ 不渲)。 */} {data?.progress && ( <>
{periodProgressLine(data.progress)}

{progressOpen && (
{data.progress.items.map((item) => ( ))}
分成方建档区域对账日本期应出账日期状态对账单号
{HOLDER_TYPE_TEXT[item.holder_type]} {item.holder_name} {item.region_label ?? "—"} {item.recon_day} 日 {item.expected_date} {item.status} {item.batch_no ?? "—"}
)} )} {/* ④ 批次清单 */}
{/* ③ 筛选条:自然月(periods 口)/分成方类型/分成方(可搜)/出账状态/批次状态/对账单号关键字/零明细开关/重置筛选。 */}
setMonth(event.target.value)}> {(periods ?? (month ? [month] : [])).map((p) => )} { filters.set("page", ""); filters.set("type", event.target.value); }}> {/* 出账状态与批次状态是两个独立下拉(⚠️ 合并=缺陷);出账状态⛔ 出现「待执行」「已作废」。 */} { filters.set("page", ""); filters.set("reconcile", event.target.value); }}> { filters.set("page", ""); filters.set("status", event.target.value); }}> {/* 触发方式(手册步序:批次状态之后、关键字之前):只两值,⛔ 第三值。 */} { filters.set("page", ""); filters.set("trigger", event.target.value); }}> {(["manual", "auto"] as const).map((key) => )} {hasFilter && } {canExportAll && }
{/* S404 触顶 ⇒ 不渲染三卡与列表(⚠️ 禁止静默截断)。 */} {s404 ? (

{S404_EMPTY_NOTE}

) : (
{rows.map((row) => ( ))} {!rows.length && ( {list.loading ? "加载中…" : wiring ? "对账接口待后端接线,批次数据暂不可读。" : "没有符合筛选条件的对账清单。"} )}
对账单号分成方自然月应出账日期触发方式明细条数总金额分成金额出账状态批次状态执行人操作
{row.batch_no} {HOLDER_TYPE_TEXT[row.holder_type]} {row.holder_name} {row.period} {row.recon_date} {TRIGGER_TYPE_TEXT[row.trigger_type]} {row.detail_count} 条 {moneyFromCents(row.base_cents)} {moneyFromCents(row.share_cents)} {RECONCILE_STATUS_TEXT[row.reconcile_status]} {BATCH_STATUS_TEXT[row.status]} {row.status === "failed" && } {executorText(row)} 详情
)} {!s404 && ( filters.set("page", String(next))} /> )}
{list.fail && !wiring && !s404 && (

{list.fail.message}

)} {notice && setNotice("")} />}
); } /* ── 批次详情(14.2) ───────────────────────────────────────────── */ export function SettlementStatementRecordPage() { const identity = useDemoIdentity(); const navigate = useNavigate(); const location = useLocation(); const { no } = useParams(); const state = (location.state ?? {}) as { from?: string; listSearch?: string }; // 返回恒回进来那一页(总则§16.11;⛔ history.back())。 const back = state.from === "/correction-notes" ? { to: "/correction-notes", label: BACK_TO_CORRECTIONS } : state.from?.startsWith("/settlement-bills/") ? { to: state.from, label: BACK_TO_BILL_DETAIL } : state.from === "/settlement-bills" ? { to: "/settlement-bills", label: BACK_TO_BILL_LIST } : { to: `/settlement-batches${state.listSearch ?? ""}`, label: BACK_TO_RECON_LIST }; const detail = useReconDetail(no ?? null); const d = detail.data; const wiring = detail.fail?.kind === "wiring"; const isAdmin = !identity || identity.role === "admin"; const [confirmRerun, setConfirmRerun] = useState(false); const [rerunError, setRerunError] = useState(""); const [busy, setBusy] = useState(false); const [notice, setNotice] = useState(""); function runRerun() { if (!d) return; setBusy(true); setRerunError(""); submitReconRerun({ holder_type: d.holder_type, holder_id: d.holder_id, period: d.period }) .then((res) => { setConfirmRerun(false); // 补跑成功 ⇒ 原批次作废、生成新批;直接落到新批详情(来路保留)。 navigate(batchPath(d.holder_id, res.batch_no), { state: location.state, replace: true }); }) .catch((e: unknown) => { // 四道闸(60502→60503→60504→60506)/KLT-S407:文案直读后端 message。 setRerunError(e instanceof Error && e.message ? e.message : "补跑失败,请重试。"); setBusy(false); }); } function exportDetail() { if (!d) return; reconExportDetail({ batch_id: d.batch_no }) .then((res) => setNotice(exportResultNote(res))) .catch((e: unknown) => setNotice(e instanceof Error && e.message ? e.message : WORD_FETCH_FAILED)); } return (
{back.label} {wiring &&

{RECON_WIRING_NOTE}

} {detail.fail && !wiring && (

{detail.fail.message}

)} {/* 契约占位分支:八字段头结构落位、值格「后端未下发」。 */} {(wiring || (!d && detail.loading)) && (
RECONCILIATION / {no}

批次详情

{detail.loading && !wiring ? "加载中…" : BACKEND_NOT_WIRED}

)} {d && { setRerunError(""); setConfirmRerun(true); }} onExport={exportDetail} onCorrect={() => navigate("/correction-notes", { state: { ref: d.batch_no } })} lineState={{ from: location.pathname }} />} {confirmRerun && d && (
!busy && setConfirmRerun(false)}>
event.stopPropagation()}>

{RERUN_DIALOG_TITLE}

{rerunScopeLine(d.holder_name, d.period)}

{/* failed 批补跑区追加句(§8.6 界面唯一落点之一)。 */} {d.status === "failed" &&

{RERUN_VOID_NOTE}

} {rerunError &&

{rerunError}

}
)} {notice && setNotice("")} />}
); } function BatchDetailBody({ d, isAdmin, onRerun, onExport, onCorrect, lineState }: { d: ReconDetailResult; isAdmin: boolean; onRerun: () => void; onExport: () => void; onCorrect: () => void; lineState: { from: string }; }) { // 动作可用性=服务端布尔位(与对账§5.5.4 同源常量;⚠️ 前端按角色自猜=第二套判据)。 // null ⇒ 后端未下发 ⇒ 禁用+「可操作性位后端未下发」说明。 const rerunEnabled = isAdmin && d.can_rerun === true; const exportEnabled = d.can_export === true; const correctEnabled = isAdmin && d.can_correct === true; const flagPending = d.can_rerun == null || d.can_export == null || d.can_correct == null; return ( <>
RECONCILIATION / {d.batch_no}

批次详情

{d.holder_name} {HOLDER_TYPE_TEXT[d.holder_type]} 自然月 {d.period} {TRIGGER_TYPE_TEXT[d.trigger_type]}触发 · {executorText(d)}执行

{BATCH_STATUS_TEXT[d.status]} {TRIGGER_TYPE_TEXT[d.trigger_type]}触发
明细条数{d.detail_count}本批有效行现算,作废行不计
总金额{moneyFromCents(d.base_cents)}本批有效行应收基数合计
分成金额{moneyFromCents(d.share_cents)}本批有效行分成金额合计
{TICKET_GAP_LABEL} {d.ticket_gap_failed ? WORD_FETCH_FAILED : d.ticket_gap_count == null ? BACKEND_NOT_WIRED : ticketGapText(d.ticket_gap_count)} {TICKET_GAP_LABEL}按工单台账现算(0 个缺口与取数失败是两回事)

执行结果

批次动作与执行说明。

{isAdmin && ( )} {isAdmin && ( )}
{flagPending &&

{ACTION_FLAG_PENDING_NOTE},动作暂不可用。

} {/* 失败原因只在 failed/voided 时渲染;voided 必带「由哪一次补跑作废」链接。 */} {(d.status === "failed" || d.status === "voided") && d.fail_reason && (

{d.fail_reason}

)} {d.status === "voided" && d.voided_by_batch_no && (

{VOIDED_BY_PREFIX} {d.voided_by_batch_no} 作废。

)} {/* 成本未配置提示一行(不发通知、不建提醒表;不说"异常")。 */} {d.cost_unconfigured.length > 0 && (

{COST_UNCONFIGURED_NOTE}:{d.cost_unconfigured.join("、")}

)}
01

本批账单明细

{d.holder_name} · {d.period} · {d.detail_count} 条

{d.items.map((line) => ( {/* zero_note 如实展示并解释为什么是 0(⛔ 隐藏 0 金额行)。 */} ))} {!d.items.length && 本批无明细行。}
客户订阅标识应收金额分成基数分成方式与取值本方分成金额恒 0 说明操作
{line.customer_name} {line.subscription_label} {moneyFromCents(line.receivable_cents)} {moneyFromCents(line.share_base_cents)} {settleTextFromSnapshot(line.share_mode, line.share_value)} {moneyFromCents(line.share_amount_cents)}{line.zero_note ? ZERO_NOTE_TEXT[line.zero_note] : "—"} 详情
02

执行与口径

批次八字段头与状态说明。

对账单号
{d.batch_no}
分成方
{d.holder_name} · {HOLDER_TYPE_TEXT[d.holder_type]}
自然月
{d.period}
应出账日期
{d.recon_date ?? "—"}
批次状态
{BATCH_STATUS_TEXT[d.status]}
执行人
{executorText(d)}
执行时间
{d.executed_at ? localTime(d.executed_at) : "—"}
触发方式
{TRIGGER_TYPE_TEXT[d.trigger_type]}

状态以批次当前记录为准。执行失败的批次由总运营补跑;账单差错通过出账更正登记。

); } /* ── FN-08 账单明细(14.3 列表) ─────────────────────────────────── */ export function SettlementBillListPage() { const filters = useListFilters(); const q = filters.get("q"); const type = filters.get("type"); const month = filters.get("month"); const page = Number(filters.get("page") || "1") || 1; const hasFilter = Boolean(q || type || month); const periodsFetch = useReconPeriods(); const periods = periodsFetch.data?.periods ?? null; const list = useBillList({ period: month, holderType: type, keyword: q, page }); const wiring = list.fail?.kind === "wiring"; const rows = list.data?.items ?? []; const total = list.data?.total ?? 0; const pageSize = 20; return (

BILLING LINES / 分成与对账

账单明细

对账有差异时,按客户和账期追到具体订阅,逐项核对应收、成本和分成。
{wiring &&

{BILL_WIRING_NOTE}

}
{ filters.set("page", ""); filters.set("type", event.target.value); }}> { filters.set("page", ""); filters.set("month", event.target.value); }}> {(periods ?? []).map((p) => )} {hasFilter && }
{rows.map((row) => ( ))} {!rows.length && ( {list.loading ? "加载中…" : wiring ? "账单明细接口待后端接线,数据暂不可读。" : "没有符合筛选条件的账单明细。"} )}
分成方自然月客户订阅计费天数分成基数本方分成金额对账单号操作
{HOLDER_TYPE_TEXT[row.holder_type]} {row.holder_name} {row.period} {row.customer_name} {row.subscription_label} {row.billing_days} 天 {moneyFromCents(row.share_base_cents)} {moneyFromCents(row.share_amount_cents)} {row.batch_no} 详情
filters.set("page", String(next))} />
{list.fail && !wiring && (

{list.fail.message}

)}
); } /* ── FN-08 明细详情(14.3 七段;字段按「钱是怎么来的」排序) ────────── */ export function SettlementBillRecordPage() { const { index } = useParams(); const location = useLocation(); const state = (location.state ?? {}) as { from?: string }; const back = state.from === "/correction-notes" ? { to: "/correction-notes", label: BACK_TO_CORRECTIONS } : state.from?.startsWith("/settlement-batches/") ? { to: state.from, label: BACK_TO_RECON_DETAIL } : { to: "/settlement-bills", label: BACK_TO_BILL_LIST }; const detail = useBillDetail(index ?? null); const d = detail.data; const wiring = detail.fail?.kind === "wiring"; return (
{back.label} {wiring &&

{BILL_WIRING_NOTE}

} {detail.fail && !wiring && (

{detail.fail.message}

)} {(wiring || (!d && detail.loading)) && (
BILLING LINE / {index}

明细详情

{detail.loading && !wiring ? "加载中…" : BACKEND_NOT_WIRED}

)} {d && ( <>
BILLING LINE / {d.bill_detail_id}

明细详情

{d.holder_name}{HOLDER_TYPE_TEXT[d.holder_type]}自然月 {d.period}{d.customer_name} · {d.subscription_label}

{/* ① 本期应收口径:pre_align_cents 与 receivable_cents 同屏(缺一=页面缺字段)。 */}
01

本期应收口径

尾月对齐前两值必须同屏。

尾月对齐前应收
{moneyFromCents(d.pre_align_cents)}
本期应收(对齐后)
{moneyFromCents(d.receivable_cents)}
{/* ② 计费区间与天数、是否不满月。 */}
02

计费依据

本期计费区间与天数。

计费区间
{d.bill_from} ~ {d.bill_to}
计费天数
{d.billing_days} 天
是否不满月
{d.partial_month ? "是" : "否"}
{/* ③ 成本快照逐条;configured=false ⇒ 标「未配置」。 */}
03

成本快照

冻结在本明细行上的成本逐条。

{d.costs.length ? (
{d.costs.map((cost, i) => ( ))}
成本项金额倍率折算计
{cost.item_name}{!cost.configured && 未配置} {cost.amount_cents == null ? "—" : moneyFromCents(cost.amount_cents)} {cost.multiplier ?? "—"} {cost.fold == null ? "—" : moneyFromCents(cost.fold)}
) : (

本行无成本快照。

)}
{/* ④ 分成基数;floor 到 0 ⇒ 显式标下限保护(floor 是静默的,不写=藏起一次配置错误)。 */}
04

实际出账口径

分成基数与下限保护。

分成基数
{moneyFromCents(d.share_base_cents)}
{d.base_floor_protected &&

{BASE_FLOOR_NOTE}

}
{/* ⑤ 分成方式与取值=当时冻结在明细行上的值(⛔ 读档案现值,I22);文案走册 4 settle_text 单源。 */}
05

分成方式与取值

当时冻结在明细行上的值。

分成方式与取值
{settleTextFromSnapshot(d.share_mode, d.share_value)}
{/* ⑥ 本方分成金额+恒 0 标注+所属对账单号。 */}
06

对账归属

本方分成金额与所属批次。

本方分成金额
{moneyFromCents(d.share_amount_cents)}{d.zero_note ? `(${ZERO_NOTE_TEXT[d.zero_note]})` : ""}
所属对账单号
{d.batch_no}
{/* 其他分成方面板:三类只读身份响应体不出现该字段(⛔ 值为空)。 */} {d.other_parties != null && d.other_parties.length > 0 && (
{d.other_parties.map((p, i) => ( ))}
其他分成方分成金额对账单号
{HOLDER_TYPE_TEXT[p.holder_type]} {p.holder_name} {moneyFromCents(p.share_amount_cents)} {p.batch_no ?? "—"}
)}
{/* ⑦ 逐账号在期天数;KLT-S406 ⇒ 该块「取数失败」(⛔ 回落「无开停记录」);未下发 ⇒「后端未下发」。 */}
07

逐账号在期天数

按订阅逐分账号统计。

{d.account_days_failed ? (

{WORD_FETCH_FAILED}

) : d.account_days == null ? (

{BACKEND_NOT_WIRED}

) : d.account_days.length ? (
{d.account_days.map((row, i) => ( ))}
分账号在期天数
{row.sub_account_label}{row.in_period_days} 天
) : (

本期无在期分账号。

)}
)}
); }