| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010 |
- /**
- * 册 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<ReconcileStatus, StatusTone> = { settled: "success", abnormal: "danger", unsettled: "neutral" };
- const batchTone: Record<ReconBatchStatus, StatusTone> = { pending: "neutral", executed: "success", failed: "danger", voided: "neutral" };
- const holderTone: Record<HolderType, OpsTone> = { 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 <span style={{ color: "var(--destructive)", cursor: "help" }} title={reason}> ●</span>;
- }
- /* ── 人工补跑对话框(14.1 动作矩阵:仅 admin;入参只三件) ────────── */
- function RerunDialog({ onClose }: { onClose: () => void }) {
- const navigate = useNavigate();
- const location = useLocation();
- const [holderType, setHolderType] = useState<HolderType>("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 (
- <div className="ops-confirm-backdrop" role="presentation" onMouseDown={onClose}>
- <div className="ops-confirm" role="dialog" aria-modal="true" aria-labelledby="rerun-dialog-title" onMouseDown={(event) => event.stopPropagation()}>
- <h2 id="rerun-dialog-title">{RERUN_DIALOG_TITLE}</h2>
- <form onSubmit={submit}>
- <p style={{ margin: "12px 0" }}>
- <FilterSelect icon="type" aria-label="分成方类型" value={holderType} onChange={(event) => { setHolderType(event.target.value as HolderType); }}>
- <option value="operator">{HOLDER_TYPE_TEXT.operator}</option>
- <option value="partner">{HOLDER_TYPE_TEXT.partner}</option>
- <option value="ops_team">{HOLDER_TYPE_TEXT.ops_team}</option>
- </FilterSelect>{" "}
- {holders ? (
- <FilterSelect icon="operator" aria-label="分成方" value={holderId} onChange={(event) => setHolderId(event.target.value)}>
- {holders.map((h) => <option key={h.id} value={h.id}>{h.name}</option>)}
- {!holders.length && <option value="">(无可选分成方)</option>}
- </FilterSelect>
- ) : (
- <span>{holdersError || "加载中…"}</span>
- )}{" "}
- {/* 月份上界=上一个已结束自然月(对账§8.3 只可对已结束月份补跑);期次必填 ⇒ ⛔「全部自然月」。 */}
- <MonthFilter value={period} onChange={setPeriod} maxMonth={lastClosedMonth()} allowAll={false} />
- </p>
- <p>{rerunScopeLine(holderName, period)}</p>
- <p>{rerunMonthBoundNote(lastClosedMonth())}</p>
- <p>{RERUN_NO_EMPTY_BATCH_NOTE}</p>
- <p>{RERUN_VOID_NOTE}</p>
- {error && <p className="ops-form-error" role="alert">{error}</p>}
- <div>
- <Button variant="outline" type="button" onClick={onClose} disabled={busy}>取消</Button>
- <Button type="submit" disabled={busy || !holders?.length}>{busy ? "提交中…" : RERUN_SUBMIT}</Button>
- </div>
- </form>
- </div>
- </div>
- );
- }
- /* ── 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 (
- <section className="ops-page reconcile-index page-fill page-fill-window">
- <header className="reconcile-page-heading">
- <div>
- <p className="ops-eyebrow"><span /> RECONCILIATION / 分成与对账</p>
- <h1>对账清单</h1>
- <PageIntro>每个账期出账后,按分成方核对批次状态和结算结果。</PageIntro>
- </div>
- <div className="statement-heading-actions">
- {isAdmin && <Button onClick={() => setRunOpen(true)}>人工补跑</Button>}
- </div>
- </header>
- {runOpen && <RerunDialog onClose={() => setRunOpen(false)} />}
- {/* 接线占位横幅(klt-bos recon/* 未交付;交付后本分支自然失效) */}
- {wiring && <p className="ops-import-note" role="status">{RECON_WIRING_NOTE}</p>}
- {periodsFetch.fail && !wiring && <p className="ops-import-note" role="status">{PERIODS_UNAVAILABLE}</p>}
- {monthFallback && !rows.length && <p className="ops-import-note" role="status">{MONTH_NO_BATCH_NOTE}</p>}
- {/* ② 三统计卡:与列表同一响应同一行集;S404 ⇒ 整体不渲染(不是显示 0);单格 null ⇒「取数失败」。 */}
- {!s404 && !wiring && data && (
- <div className="reconcile-totals" aria-label="当前筛选结果统计">
- {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 (
- <div key={card.key}>
- <span>{card.title}</span>
- <strong>{moneyCell(value)}</strong>
- <small>{card.subtitle}</small>
- </div>
- );
- })}
- </div>
- )}
- {/* 契约占位分支:卡结构落位、值格显式标「后端未下发」(总则§16.9,⛔ 演示例数冒充)。 */}
- {wiring && (
- <div className="reconcile-totals" aria-label="当前筛选结果统计">
- {STAT_CARDS.map((card) => (
- <div key={card.key}>
- <span>{card.title}</span>
- <strong>{BACKEND_NOT_WIRED}</strong>
- <small>{card.subtitle}</small>
- </div>
- ))}
- </div>
- )}
- {/* ③-1 期次出账进度(常驻;只随自然月变化,⛔ 随其余筛选变;后端未下发 ⇒ 不渲)。 */}
- {data?.progress && (
- <>
- <div className="ops-detail-callout" role="status">
- <strong>{periodProgressLine(data.progress)}</strong>
- <p>
- <button type="button" className="ops-table-action" onClick={() => setProgressOpen((v) => !v)}>
- {progressOpen ? PROGRESS_COLLAPSE : PROGRESS_EXPAND} <ArrowRight size={13} />
- </button>
- </p>
- </div>
- {progressOpen && (
- <div className="ops-table-wrap">
- <table className="ops-table">
- <thead><tr><th>分成方</th><th>建档区域</th><th>对账日</th><th>本期应出账日期</th><th>状态</th><th>对账单号</th></tr></thead>
- <tbody>
- {data.progress.items.map((item) => (
- <tr key={`${item.holder_type}-${item.holder_id}`}>
- <td><OpsTag tone={holderTone[item.holder_type]}>{HOLDER_TYPE_TEXT[item.holder_type]}</OpsTag> {item.holder_name}</td>
- <td>{item.region_label ?? "—"}</td>
- <td>{item.recon_day} 日</td>
- <td>{item.expected_date}</td>
- <td>{item.status}</td>
- <td className="ops-mono">{item.batch_no ?? "—"}</td>
- </tr>
- ))}
- </tbody>
- </table>
- </div>
- )}
- </>
- )}
- {/* ④ 批次清单 */}
- <div className="reconcile-ledger list-shell-fill">
- {/* ③ 筛选条:自然月(periods 口)/分成方类型/分成方(可搜)/出账状态/批次状态/对账单号关键字/零明细开关/重置筛选。 */}
- <div className="reconcile-filters">
- <label className="ops-search">
- <Search size={17} />
- <SearchInput aria-label="搜索对账单号" placeholder="搜索对账单号" value={q}
- onCommit={(value) => { filters.set("page", ""); filters.set("q", value); }} />
- {q && <button type="button" aria-label="清空搜索" onClick={() => filters.set("q", "")}><X size={15} /></button>}
- </label>
- <FilterSelect icon="month" aria-label="自然月" value={monthAll ? "" : month} onChange={(event) => setMonth(event.target.value)}>
- <option value="">{ALL_PERIODS_LABEL}</option>
- {(periods ?? (month ? [month] : [])).map((p) => <option key={p} value={p}>{p}</option>)}
- </FilterSelect>
- <FilterSelect icon="type" aria-label="分成方类型" value={type} onChange={(event) => { filters.set("page", ""); filters.set("type", event.target.value); }}>
- <option value="">全部类型</option>
- <option value="operator">{HOLDER_TYPE_TEXT.operator}</option>
- <option value="partner">{HOLDER_TYPE_TEXT.partner}</option>
- <option value="ops_team">{HOLDER_TYPE_TEXT.ops_team}</option>
- </FilterSelect>
- <label className="ops-search">
- <Search size={17} />
- <SearchInput aria-label="搜索分成方" placeholder="搜索分成方" value={party}
- onCommit={(value) => { filters.set("page", ""); filters.set("party", value); }} />
- </label>
- {/* 出账状态与批次状态是两个独立下拉(⚠️ 合并=缺陷);出账状态⛔ 出现「待执行」「已作废」。 */}
- <FilterSelect icon="status" aria-label="出账状态" value={reconcile} onChange={(event) => { filters.set("page", ""); filters.set("reconcile", event.target.value); }}>
- <option value="">全部出账状态</option>
- <option value="settled">{RECONCILE_STATUS_TEXT.settled}</option>
- <option value="abnormal">{RECONCILE_STATUS_TEXT.abnormal}</option>
- <option value="unsettled">{RECONCILE_STATUS_TEXT.unsettled}</option>
- </FilterSelect>
- <FilterSelect icon="action" aria-label="批次状态" value={status} onChange={(event) => { filters.set("page", ""); filters.set("status", event.target.value); }}>
- <option value="">全部批次状态</option>
- <option value="pending">{BATCH_STATUS_TEXT.pending}</option>
- <option value="executed">{BATCH_STATUS_TEXT.executed}</option>
- <option value="failed">{BATCH_STATUS_TEXT.failed}</option>
- <option value="voided">{BATCH_STATUS_TEXT.voided}</option>
- </FilterSelect>
- {/* 触发方式(手册步序:批次状态之后、关键字之前):只两值,⛔ 第三值。 */}
- <FilterSelect icon="action" aria-label="触发方式" value={trigger} onChange={(event) => { filters.set("page", ""); filters.set("trigger", event.target.value); }}>
- <option value="">全部触发方式</option>
- {(["manual", "auto"] as const).map((key) => <option key={key} value={key}>{TRIGGER_TYPE_TEXT[key]}</option>)}
- </FilterSelect>
- <Button variant={zero ? "default" : "outline"} size="sm" aria-pressed={zero}
- onClick={() => { filters.set("page", ""); filters.set("zero", zero ? "" : "1"); }}>零明细批次</Button>
- {hasFilter && <Button variant="ghost" size="sm" onClick={() => { filters.reset(); setMonthFallback(false); }}>重置筛选</Button>}
- {canExportAll && <Button variant="outline" size="sm" onClick={exportAll}><Download size={16} />导出当前结果</Button>}
- </div>
- {/* S404 触顶 ⇒ 不渲染三卡与列表(⚠️ 禁止静默截断)。 */}
- {s404 ? (
- <p className="ops-import-note" role="alert">{S404_EMPTY_NOTE}</p>
- ) : (
- <div className="ops-table-wrap">
- <table className="ops-table reconcile-table">
- <OpsTableColumns widths={[150, 190, 90, 100, 90, 80, 110, 110, 96, 96, 90, 76]} />
- <thead>
- <tr><th>对账单号</th><th>分成方</th><th>自然月</th><th>应出账日期</th><th>触发方式</th><th>明细条数</th><th>总金额</th><th>分成金额</th><th>出账状态</th><th>批次状态</th><th>执行人</th><th>操作</th></tr>
- </thead>
- <tbody>
- {rows.map((row) => (
- <tr key={row.batch_no}>
- <td>
- <Link className="reconcile-row-link" title={row.batch_no} to={batchPath(row.holder_id, row.batch_no)}
- state={{ from: "/settlement-batches", listSearch: location.search }}>
- {row.batch_no}<ArrowRight size={14} />
- </Link>
- </td>
- <td><OpsTag tone={holderTone[row.holder_type]}>{HOLDER_TYPE_TEXT[row.holder_type]}</OpsTag> <strong title={row.holder_name}>{row.holder_name}</strong></td>
- <td><span className="ops-mono">{row.period}</span></td>
- <td>{row.recon_date}</td>
- <td><OpsTag tone={row.trigger_type === "manual" ? "warning" : "neutral"}>{TRIGGER_TYPE_TEXT[row.trigger_type]}</OpsTag></td>
- <td>{row.detail_count} 条</td>
- <td><span className="ops-money">{moneyFromCents(row.base_cents)}</span></td>
- <td><strong className="reconcile-money">{moneyFromCents(row.share_cents)}</strong></td>
- <td><OpsStatus tone={reconcileTone[row.reconcile_status]}>{RECONCILE_STATUS_TEXT[row.reconcile_status]}</OpsStatus></td>
- <td>
- <OpsStatus tone={batchTone[row.status]}>{BATCH_STATUS_TEXT[row.status]}</OpsStatus>
- {row.status === "failed" && <FailDot reason={row.fail_reason} />}
- </td>
- <td title={row.operator_user_id ?? undefined}>{executorText(row)}</td>
- <td>
- <Link className="ops-table-action" to={batchPath(row.holder_id, row.batch_no)}
- state={{ from: "/settlement-batches", listSearch: location.search }}>详情</Link>
- </td>
- </tr>
- ))}
- {!rows.length && (
- <OpsTableEmpty colSpan={12}>
- {list.loading ? "加载中…" : wiring ? "对账接口待后端接线,批次数据暂不可读。" : "没有符合筛选条件的对账清单。"}
- </OpsTableEmpty>
- )}
- </tbody>
- </table>
- </div>
- )}
- {!s404 && (
- <ServerListPager
- total={total}
- page={page}
- pageSize={pageSize}
- onPageChange={(next) => filters.set("page", String(next))}
- />
- )}
- </div>
- {list.fail && !wiring && !s404 && (
- <p className="ops-form-error" role="alert">{list.fail.message} <Button variant="ghost" size="sm" onClick={list.reload}>重试</Button></p>
- )}
- {notice && <OpsNotice message={notice} onClose={() => setNotice("")} />}
- </section>
- );
- }
- /* ── 批次详情(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 (
- <article className="ops-page reconcile-record">
- <Link className="ops-back-link" to={back.to}><ArrowLeft size={16} />{back.label}</Link>
- {wiring && <p className="ops-import-note" role="status">{RECON_WIRING_NOTE}</p>}
- {detail.fail && !wiring && (
- <p className="ops-form-error" role="alert">{detail.fail.message} <Button variant="ghost" size="sm" onClick={detail.reload}>重试</Button></p>
- )}
- {/* 契约占位分支:八字段头结构落位、值格「后端未下发」。 */}
- {(wiring || (!d && detail.loading)) && (
- <header className="reconcile-record-hero">
- <div className="reconcile-record-symbol"><FileSpreadsheet size={27} /></div>
- <div>
- <span className="reconcile-record-eyebrow">RECONCILIATION / {no}</span>
- <h1>批次详情</h1>
- <p>{detail.loading && !wiring ? "加载中…" : BACKEND_NOT_WIRED}</p>
- </div>
- </header>
- )}
- {d && <BatchDetailBody
- d={d}
- isAdmin={isAdmin}
- onRerun={() => { setRerunError(""); setConfirmRerun(true); }}
- onExport={exportDetail}
- onCorrect={() => navigate("/correction-notes", { state: { ref: d.batch_no } })}
- lineState={{ from: location.pathname }}
- />}
- {confirmRerun && d && (
- <div className="ops-confirm-backdrop" role="presentation" onMouseDown={() => !busy && setConfirmRerun(false)}>
- <div className="ops-confirm" role="alertdialog" aria-modal="true" aria-labelledby="rerun-confirm-title" onMouseDown={(event) => event.stopPropagation()}>
- <h2 id="rerun-confirm-title">{RERUN_DIALOG_TITLE}</h2>
- <p>{rerunScopeLine(d.holder_name, d.period)}</p>
- {/* failed 批补跑区追加句(§8.6 界面唯一落点之一)。 */}
- {d.status === "failed" && <p>{RERUN_VOID_NOTE}</p>}
- {rerunError && <p className="ops-form-error" role="alert">{rerunError}</p>}
- <div>
- <Button variant="outline" onClick={() => setConfirmRerun(false)} disabled={busy}>取消</Button>
- <Button onClick={runRerun} disabled={busy}>{busy ? "提交中…" : RERUN_SUBMIT}</Button>
- </div>
- </div>
- </div>
- )}
- {notice && <OpsNotice message={notice} onClose={() => setNotice("")} />}
- </article>
- );
- }
- 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 (
- <>
- <header className="reconcile-record-hero">
- <div className="reconcile-record-symbol"><FileSpreadsheet size={27} /></div>
- <div>
- <span className="reconcile-record-eyebrow">RECONCILIATION / {d.batch_no}</span>
- <h1>批次详情</h1>
- <p>
- <strong>{d.holder_name}</strong>
- <span>{HOLDER_TYPE_TEXT[d.holder_type]}</span>
- <span>自然月 {d.period}</span>
- <span>{TRIGGER_TYPE_TEXT[d.trigger_type]}触发 · {executorText(d)}执行</span>
- </p>
- <div className="reconcile-hero-pills">
- <OpsStatus tone={batchTone[d.status]}>{BATCH_STATUS_TEXT[d.status]}</OpsStatus>
- <OpsTag tone={d.trigger_type === "manual" ? "warning" : "neutral"}>{TRIGGER_TYPE_TEXT[d.trigger_type]}触发</OpsTag>
- </div>
- </div>
- </header>
- <div className="reconcile-record-stats">
- <div><span>明细条数</span><strong>{d.detail_count}</strong><small>本批有效行现算,作废行不计</small></div>
- <div><span>总金额</span><strong>{moneyFromCents(d.base_cents)}</strong><small>本批有效行应收基数合计</small></div>
- <div><span>分成金额</span><strong>{moneyFromCents(d.share_cents)}</strong><small>本批有效行分成金额合计</small></div>
- <div>
- <span>{TICKET_GAP_LABEL}</span>
- <strong>{d.ticket_gap_failed ? WORD_FETCH_FAILED : d.ticket_gap_count == null ? BACKEND_NOT_WIRED : ticketGapText(d.ticket_gap_count)}</strong>
- <small>{TICKET_GAP_LABEL}按工单台账现算(0 个缺口与取数失败是两回事)</small>
- </div>
- </div>
- <section className="reconcile-record-section">
- <div className="reconcile-record-section-head">
- <div><h2>执行结果</h2><p>批次动作与执行说明。</p></div>
- <div style={{ display: "flex", gap: 8 }}>
- {isAdmin && (
- <Button variant="outline" onClick={onRerun} disabled={!rerunEnabled} title={d.can_rerun == null ? ACTION_FLAG_PENDING_NOTE : undefined}>人工补跑</Button>
- )}
- <Button variant="outline" onClick={onExport} disabled={!exportEnabled} title={d.can_export == null ? ACTION_FLAG_PENDING_NOTE : undefined}>
- <Download size={15} />导出本批账单明细
- </Button>
- {isAdmin && (
- <Button variant="outline" onClick={onCorrect} disabled={!correctEnabled} title={d.can_correct == null ? ACTION_FLAG_PENDING_NOTE : undefined}>登记更正</Button>
- )}
- </div>
- </div>
- {flagPending && <p className="reconcile-footnote">{ACTION_FLAG_PENDING_NOTE},动作暂不可用。</p>}
- {/* 失败原因只在 failed/voided 时渲染;voided 必带「由哪一次补跑作废」链接。 */}
- {(d.status === "failed" || d.status === "voided") && d.fail_reason && (
- <p className="ops-form-error" role="alert">{d.fail_reason}</p>
- )}
- {d.status === "voided" && d.voided_by_batch_no && (
- <p className="reconcile-footnote">
- {VOIDED_BY_PREFIX}
- <Link className="ops-table-action" to={batchPath(d.holder_id, d.voided_by_batch_no)}>{d.voided_by_batch_no} <ArrowRight size={14} /></Link>
- 作废。
- </p>
- )}
- {/* 成本未配置提示一行(不发通知、不建提醒表;不说"异常")。 */}
- {d.cost_unconfigured.length > 0 && (
- <p className="reconcile-footnote">{COST_UNCONFIGURED_NOTE}:{d.cost_unconfigured.join("、")}</p>
- )}
- </section>
- <section className="reconcile-record-section">
- <div className="reconcile-record-section-head">
- <span>01</span>
- <div><h2>本批账单明细</h2><p>{d.holder_name} · {d.period} · {d.detail_count} 条</p></div>
- </div>
- <div className="ops-table-wrap">
- <table className="ops-table" style={{ minWidth: 980 }}>
- <thead><tr><th>客户</th><th>订阅标识</th><th>应收金额</th><th>分成基数</th><th>分成方式与取值</th><th>本方分成金额</th><th>恒 0 说明</th><th>操作</th></tr></thead>
- <tbody>
- {d.items.map((line) => (
- <tr key={line.bill_detail_id}>
- <td><strong>{line.customer_name}</strong></td>
- <td>{line.subscription_label}</td>
- <td><span className="ops-money">{moneyFromCents(line.receivable_cents)}</span></td>
- <td><span className="ops-money">{moneyFromCents(line.share_base_cents)}</span></td>
- <td>{settleTextFromSnapshot(line.share_mode, line.share_value)}</td>
- <td><strong className="reconcile-money">{moneyFromCents(line.share_amount_cents)}</strong></td>
- {/* zero_note 如实展示并解释为什么是 0(⛔ 隐藏 0 金额行)。 */}
- <td>{line.zero_note ? ZERO_NOTE_TEXT[line.zero_note] : "—"}</td>
- <td>
- <Link className="ops-table-action" to={`/settlement-bills/${encodeURIComponent(line.bill_detail_id)}`} state={lineState}>
- 详情
- </Link>
- </td>
- </tr>
- ))}
- {!d.items.length && <OpsTableEmpty colSpan={8}>本批无明细行。</OpsTableEmpty>}
- </tbody>
- </table>
- </div>
- </section>
- <section className="reconcile-record-section">
- <div className="reconcile-record-section-head"><span>02</span><div><h2>执行与口径</h2><p>批次八字段头与状态说明。</p></div></div>
- <dl className="reconcile-record-facts">
- <div><dt>对账单号</dt><dd>{d.batch_no}</dd></div>
- <div><dt>分成方</dt><dd>{d.holder_name} · {HOLDER_TYPE_TEXT[d.holder_type]}</dd></div>
- <div><dt>自然月</dt><dd>{d.period}</dd></div>
- <div><dt>应出账日期</dt><dd title="该分成方该自然月的应出账日期=自然月次月的对账日;「每月 N 日」的对账日口径见「出账配置」">{d.recon_date ?? "—"}</dd></div>
- <div><dt>批次状态</dt><dd>{BATCH_STATUS_TEXT[d.status]}</dd></div>
- <div><dt>执行人</dt><dd title={d.operator_user_id ?? undefined}>{executorText(d)}</dd></div>
- <div><dt>执行时间</dt><dd title={d.executed_at ?? undefined}>{d.executed_at ? localTime(d.executed_at) : "—"}</dd></div>
- <div><dt>触发方式</dt><dd>{TRIGGER_TYPE_TEXT[d.trigger_type]}</dd></div>
- </dl>
- <p className="reconcile-footnote">状态以批次当前记录为准。执行失败的批次由总运营补跑;账单差错通过出账更正登记。</p>
- </section>
- </>
- );
- }
- /* ── 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 (
- <section className="ops-page bill-index page-fill page-fill-window">
- <header className="reconcile-page-heading">
- <div>
- <p className="ops-eyebrow"><span /> BILLING LINES / 分成与对账</p>
- <h1>账单明细</h1>
- <PageIntro>对账有差异时,按客户和账期追到具体订阅,逐项核对应收、成本和分成。</PageIntro>
- </div>
- </header>
- {wiring && <p className="ops-import-note" role="status">{BILL_WIRING_NOTE}</p>}
- <div className="reconcile-ledger list-shell-fill">
- <div className="reconcile-filters">
- <label className="ops-search">
- <Search size={17} />
- <SearchInput aria-label="搜索账单明细" placeholder="搜索分成方、客户、订阅或单号" value={q}
- onCommit={(value) => { filters.set("page", ""); filters.set("q", value); }} />
- {q && <button type="button" aria-label="清空搜索" onClick={() => filters.set("q", "")}><X size={15} /></button>}
- </label>
- <FilterSelect icon="type" aria-label="分成方类型" value={type} onChange={(event) => { filters.set("page", ""); filters.set("type", event.target.value); }}>
- <option value="">全部类型</option>
- <option value="operator">{HOLDER_TYPE_TEXT.operator}</option>
- <option value="partner">{HOLDER_TYPE_TEXT.partner}</option>
- <option value="ops_team">{HOLDER_TYPE_TEXT.ops_team}</option>
- </FilterSelect>
- <FilterSelect icon="month" aria-label="自然月" value={month} onChange={(event) => { filters.set("page", ""); filters.set("month", event.target.value); }}>
- <option value="">{ALL_PERIODS_LABEL}</option>
- {(periods ?? []).map((p) => <option key={p} value={p}>{p}</option>)}
- </FilterSelect>
- {hasFilter && <Button variant="ghost" size="sm" onClick={filters.reset}>重置筛选</Button>}
- </div>
- <div className="ops-table-wrap">
- <table className="ops-table">
- <OpsTableColumns widths={[180, 90, 170, 200, 90, 120, 130, 160, 76]} />
- <thead><tr><th>分成方</th><th>自然月</th><th>客户</th><th>订阅</th><th>计费天数</th><th>分成基数</th><th>本方分成金额</th><th>对账单号</th><th>操作</th></tr></thead>
- <tbody>
- {rows.map((row) => (
- <tr key={row.bill_detail_id}>
- <td><OpsTag tone={holderTone[row.holder_type]}>{HOLDER_TYPE_TEXT[row.holder_type]}</OpsTag> <strong>{row.holder_name}</strong></td>
- <td><span className="ops-mono">{row.period}</span></td>
- <td>{row.customer_name}</td>
- <td>{row.subscription_label}</td>
- <td>{row.billing_days} 天</td>
- <td><span className="ops-money">{moneyFromCents(row.share_base_cents)}</span></td>
- <td><strong className="reconcile-money">{moneyFromCents(row.share_amount_cents)}</strong></td>
- <td>
- <Link className="reconcile-row-link" title={row.batch_no} to={batchPath(row.holder_id, row.batch_no)} state={{ from: "/settlement-bills" }}>
- {row.batch_no}<ArrowRight size={14} />
- </Link>
- </td>
- <td>
- <Link className="ops-table-action" to={`/settlement-bills/${encodeURIComponent(row.bill_detail_id)}`} state={{ from: "/settlement-bills" }}>
- 详情
- </Link>
- </td>
- </tr>
- ))}
- {!rows.length && (
- <OpsTableEmpty colSpan={9}>
- {list.loading ? "加载中…" : wiring ? "账单明细接口待后端接线,数据暂不可读。" : "没有符合筛选条件的账单明细。"}
- </OpsTableEmpty>
- )}
- </tbody>
- </table>
- </div>
- <ServerListPager
- total={total}
- page={page}
- pageSize={pageSize}
- onPageChange={(next) => filters.set("page", String(next))}
- />
- </div>
- {list.fail && !wiring && (
- <p className="ops-form-error" role="alert">{list.fail.message} <Button variant="ghost" size="sm" onClick={list.reload}>重试</Button></p>
- )}
- </section>
- );
- }
- /* ── 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 (
- <article className="ops-page reconcile-record">
- <Link className="ops-back-link" to={back.to}><ArrowLeft size={16} />{back.label}</Link>
- {wiring && <p className="ops-import-note" role="status">{BILL_WIRING_NOTE}</p>}
- {detail.fail && !wiring && (
- <p className="ops-form-error" role="alert">{detail.fail.message} <Button variant="ghost" size="sm" onClick={detail.reload}>重试</Button></p>
- )}
- {(wiring || (!d && detail.loading)) && (
- <header className="reconcile-record-hero">
- <div className="reconcile-record-symbol"><FileSpreadsheet size={27} /></div>
- <div>
- <span className="reconcile-record-eyebrow">BILLING LINE / {index}</span>
- <h1>明细详情</h1>
- <p>{detail.loading && !wiring ? "加载中…" : BACKEND_NOT_WIRED}</p>
- </div>
- </header>
- )}
- {d && (
- <>
- <header className="reconcile-record-hero">
- <div className="reconcile-record-symbol"><FileSpreadsheet size={27} /></div>
- <div>
- <span className="reconcile-record-eyebrow">BILLING LINE / {d.bill_detail_id}</span>
- <h1>明细详情</h1>
- <p><strong>{d.holder_name}</strong><span>{HOLDER_TYPE_TEXT[d.holder_type]}</span><span>自然月 {d.period}</span><span>{d.customer_name} · {d.subscription_label}</span></p>
- </div>
- </header>
- {/* ① 本期应收口径:pre_align_cents 与 receivable_cents 同屏(缺一=页面缺字段)。 */}
- <section className="reconcile-record-section">
- <div className="reconcile-record-section-head"><span>01</span><div><h2>本期应收口径</h2><p>尾月对齐前两值必须同屏。</p></div></div>
- <dl className="reconcile-record-facts">
- <div><dt>尾月对齐前应收</dt><dd>{moneyFromCents(d.pre_align_cents)}</dd></div>
- <div><dt>本期应收(对齐后)</dt><dd>{moneyFromCents(d.receivable_cents)}</dd></div>
- </dl>
- </section>
- {/* ② 计费区间与天数、是否不满月。 */}
- <section className="reconcile-record-section">
- <div className="reconcile-record-section-head"><span>02</span><div><h2>计费依据</h2><p>本期计费区间与天数。</p></div></div>
- <dl className="reconcile-record-facts">
- <div><dt>计费区间</dt><dd>{d.bill_from} ~ {d.bill_to}</dd></div>
- <div><dt>计费天数</dt><dd>{d.billing_days} 天</dd></div>
- <div><dt>是否不满月</dt><dd>{d.partial_month ? "是" : "否"}</dd></div>
- </dl>
- </section>
- {/* ③ 成本快照逐条;configured=false ⇒ 标「未配置」。 */}
- <section className="reconcile-record-section">
- <div className="reconcile-record-section-head"><span>03</span><div><h2>成本快照</h2><p>冻结在本明细行上的成本逐条。</p></div></div>
- {d.costs.length ? (
- <div className="ops-table-wrap">
- <table className="ops-table">
- <thead><tr><th>成本项</th><th>金额</th><th>倍率</th><th>折算计</th></tr></thead>
- <tbody>
- {d.costs.map((cost, i) => (
- <tr key={`${cost.item_name}-${i}`}>
- <td>{cost.item_name}{!cost.configured && <OpsTag tone="warning">未配置</OpsTag>}</td>
- <td><span className="ops-money">{cost.amount_cents == null ? "—" : moneyFromCents(cost.amount_cents)}</span></td>
- <td>{cost.multiplier ?? "—"}</td>
- <td>{cost.fold == null ? "—" : moneyFromCents(cost.fold)}</td>
- </tr>
- ))}
- </tbody>
- </table>
- </div>
- ) : (
- <p className="reconcile-empty-line">本行无成本快照。</p>
- )}
- </section>
- {/* ④ 分成基数;floor 到 0 ⇒ 显式标下限保护(floor 是静默的,不写=藏起一次配置错误)。 */}
- <section className="reconcile-record-section">
- <div className="reconcile-record-section-head"><span>04</span><div><h2>实际出账口径</h2><p>分成基数与下限保护。</p></div></div>
- <dl className="reconcile-record-facts">
- <div><dt>分成基数</dt><dd>{moneyFromCents(d.share_base_cents)}</dd></div>
- </dl>
- {d.base_floor_protected && <p className="reconcile-footnote">{BASE_FLOOR_NOTE}</p>}
- </section>
- {/* ⑤ 分成方式与取值=当时冻结在明细行上的值(⛔ 读档案现值,I22);文案走册 4 settle_text 单源。 */}
- <section className="reconcile-record-section">
- <div className="reconcile-record-section-head"><span>05</span><div><h2>分成方式与取值</h2><p>当时冻结在明细行上的值。</p></div></div>
- <dl className="reconcile-record-facts">
- <div><dt>分成方式与取值</dt><dd>{settleTextFromSnapshot(d.share_mode, d.share_value)}</dd></div>
- </dl>
- </section>
- {/* ⑥ 本方分成金额+恒 0 标注+所属对账单号。 */}
- <section className="reconcile-record-section">
- <div className="reconcile-record-section-head"><span>06</span><div><h2>对账归属</h2><p>本方分成金额与所属批次。</p></div></div>
- <dl className="reconcile-record-facts">
- <div><dt>本方分成金额</dt><dd>{moneyFromCents(d.share_amount_cents)}{d.zero_note ? `(${ZERO_NOTE_TEXT[d.zero_note]})` : ""}</dd></div>
- <div>
- <dt>所属对账单号</dt>
- <dd>
- <Link className="ops-table-action" to={batchPath(d.holder_id, d.batch_no)} state={{ from: location.pathname }}>
- {d.batch_no} <ArrowRight size={14} />
- </Link>
- </dd>
- </div>
- </dl>
- {/* 其他分成方面板:三类只读身份响应体不出现该字段(⛔ 值为空)。 */}
- {d.other_parties != null && d.other_parties.length > 0 && (
- <div className="ops-table-wrap" style={{ marginTop: 12 }}>
- <table className="ops-table">
- <thead><tr><th>其他分成方</th><th>分成金额</th><th>对账单号</th></tr></thead>
- <tbody>
- {d.other_parties.map((p, i) => (
- <tr key={`${p.holder_type}-${p.holder_name}-${i}`}>
- <td><OpsTag tone={holderTone[p.holder_type]}>{HOLDER_TYPE_TEXT[p.holder_type]}</OpsTag> {p.holder_name}</td>
- <td><span className="ops-money">{moneyFromCents(p.share_amount_cents)}</span></td>
- <td className="ops-mono">{p.batch_no ?? "—"}</td>
- </tr>
- ))}
- </tbody>
- </table>
- </div>
- )}
- </section>
- {/* ⑦ 逐账号在期天数;KLT-S406 ⇒ 该块「取数失败」(⛔ 回落「无开停记录」);未下发 ⇒「后端未下发」。 */}
- <section className="reconcile-record-section">
- <div className="reconcile-record-section-head"><span>07</span><div><h2>逐账号在期天数</h2><p>按订阅逐分账号统计。</p></div></div>
- {d.account_days_failed ? (
- <p className="ops-form-error" role="alert">{WORD_FETCH_FAILED}</p>
- ) : d.account_days == null ? (
- <p className="reconcile-footnote">{BACKEND_NOT_WIRED}</p>
- ) : d.account_days.length ? (
- <div className="ops-table-wrap">
- <table className="ops-table">
- <thead><tr><th>分账号</th><th>在期天数</th></tr></thead>
- <tbody>
- {d.account_days.map((row, i) => (
- <tr key={`${row.sub_account_label}-${i}`}><td>{row.sub_account_label}</td><td>{row.in_period_days} 天</td></tr>
- ))}
- </tbody>
- </table>
- </div>
- ) : (
- <p className="reconcile-empty-line">本期无在期分账号。</p>
- )}
- </section>
- </>
- )}
- </article>
- );
- }
|