From 38f9822d49f29de6fd76b350d63138bee0324191 Mon Sep 17 00:00:00 2001 From: zlwu <704541015@qq.com> Date: Fri, 9 Oct 2026 10:00:41 +0800 Subject: [PATCH] feat(backend): expose payment detail transferTime in protocol summary. Let protocol-audit list show first-pay times from transfer records. Co-authored-by: Cursor --- .../app/services/qc_work_order_fee_summary.py | 24 +++++++++++----- ..._protocol_payment_summary_transfer_time.py | 28 +++++++++++++++++++ web-admin/src/api/qc-work-order.ts | 1 + 3 files changed, 46 insertions(+), 7 deletions(-) create mode 100644 backend/tests/test_protocol_payment_summary_transfer_time.py diff --git a/backend/app/services/qc_work_order_fee_summary.py b/backend/app/services/qc_work_order_fee_summary.py index 2321501f..b7e517e8 100644 --- a/backend/app/services/qc_work_order_fee_summary.py +++ b/backend/app/services/qc_work_order_fee_summary.py @@ -16,9 +16,9 @@ from app.models.models import ( _PAY_MODE_LABELS = {"dj": "趸交", "fq": "分期", "djfq": "趸交+分期"} _PAY_STATUS_LABELS = { - "dfj": "待缴费", + "dfj": "已缴费", "jfqrz": "缴费确认中", - "yjf": "已缴费", + "yjf": "缴费成功", "tfqrz": "退费确认中", "ytf": "已退费", } @@ -64,12 +64,12 @@ def _protocol_status_hint(pay_mode: str, statuses: List[str]) -> str: if confirm: parts.append(f"{confirm} 期待确认") if pending: - parts.append(f"{pending} 期待缴费") + parts.append(f"{pending} 期已缴费") return " · ".join(parts) if len(parts) > 1 else parts[0] if confirm: - return f"{confirm} 期待确认" if confirm > 1 else "收款确认中" + return f"{confirm} 期待确认" if confirm > 1 else "缴费确认中" if pending: - return "待缴费" + return "已缴费" return "" @@ -89,9 +89,9 @@ def _protocol_overall_status( ): return {"overallPayStatus": "cleared", "overallPayStatusLabel": "已缴清", "overallPayStatusTagType": "success"} if "jfqrz" in statuses: - return {"overallPayStatus": "jfqrz", "overallPayStatusLabel": "收款确认中", "overallPayStatusTagType": "warning"} + return {"overallPayStatus": "jfqrz", "overallPayStatusLabel": "缴费确认中", "overallPayStatusTagType": "warning"} if "dfj" in statuses: - return {"overallPayStatus": "dfj", "overallPayStatusLabel": "待缴费", "overallPayStatusTagType": "info"} + return {"overallPayStatus": "dfj", "overallPayStatusLabel": "已缴费", "overallPayStatusTagType": "primary"} return {"overallPayStatus": "", "overallPayStatusLabel": "—", "overallPayStatusTagType": "info"} @@ -102,6 +102,15 @@ def _fmt_ymd(val: Any) -> str: return s +def _fmt_dt(v): + if v is None: + return "" + if isinstance(v, datetime): + return v.strftime("%Y-%m-%d %H:%M:%S") + s = str(v).strip() + return s + + def _payment_detail_row(d: BizProtocolPaymentDetail, pay_mode: str, idx: int) -> Dict[str, Any]: st = (d.pay_status or "").strip() inst_no = d.installment_no @@ -117,6 +126,7 @@ def _payment_detail_row(d: BizProtocolPaymentDetail, pay_mode: str, idx: int) -> "transferAmount": _dec(d.transfer_amount), "payStatus": st, "payStatusLabel": _PAY_STATUS_LABELS.get(st, st or "—"), + "transferTime": _fmt_dt(getattr(d, "transfer_time", None)), } diff --git a/backend/tests/test_protocol_payment_summary_transfer_time.py b/backend/tests/test_protocol_payment_summary_transfer_time.py new file mode 100644 index 00000000..fa032da6 --- /dev/null +++ b/backend/tests/test_protocol_payment_summary_transfer_time.py @@ -0,0 +1,28 @@ +"""payment summary detail includes transferTime""" +from datetime import datetime +from types import SimpleNamespace +import unittest + +from app.services.qc_work_order_fee_summary import build_protocol_payment_summary + + +class TestPaymentSummaryTransferTime(unittest.TestCase): + def test_detail_includes_transfer_time(self): + pay = SimpleNamespace(pay_mode="fq", contract_amount=10000) + detail = SimpleNamespace( + installment_no=1, + order_num=1, + create_time=datetime(2025, 9, 1, 10, 0, 0), + installment_due_date="20250901", + due_amount=5000, + transfer_amount=5000, + pay_status="yjf", + transfer_time=datetime(2025, 9, 15, 9, 20, 0), + ) + summary = build_protocol_payment_summary(pay, [detail]) + self.assertIsNotNone(summary) + self.assertEqual(summary["paymentDetails"][0]["transferTime"], "2025-09-15 09:20:00") + + +if __name__ == "__main__": + unittest.main() diff --git a/web-admin/src/api/qc-work-order.ts b/web-admin/src/api/qc-work-order.ts index 32950837..2e0a816a 100644 --- a/web-admin/src/api/qc-work-order.ts +++ b/web-admin/src/api/qc-work-order.ts @@ -25,6 +25,7 @@ export type QcProtocolPaymentDetailSummary = { transferAmount?: number | null payStatus?: string payStatusLabel?: string + transferTime?: string } export type QcProtocolSiblingSample = {