fix(contract): 合同付款预警bug修复

This commit is contained in:
sophie committed 2026-09-23 14:34:08 +08:00
1 parent 5330e08281
commit 161666c0e7
26 files changed
+1599 -117

No files matched your search

@@ -1,7 +1,7 @@
/**
* 合同付款预警 API 类型与请求封装。
* 依赖:统一 requestJson;后端 /api/contract-payment。
* 逻辑:台账/合同详情查询、汇总卡统计、待发送摘要、每日扫描入队、周五汇总入队及批次附件下载。
* 逻辑:台账/合同详情查询、汇总卡统计、待发送摘要、每日扫描入队、周五汇总入队、批次附件下载、失败原因及后台任务状态。
*/
import { requestBlob, requestJson } from '@/shared/api/client';
@@ -28,7 +28,8 @@ export interface LedgerSummary {
active: number;
due_this_month: number;
}
export interface AlertBatch { id: number; batch_no: string; week_key: string; status: string; summary?: { total?: number; stages?: Record<string, number> }; excel_file_name?: string | null; excel_file_size?: number | null; sent_at?: string | null; }
export interface AlertBatchFailureReason { code: string; detail?: string | null; }
export interface AlertBatch { id: number; batch_no: string; week_key: string; status: string; summary?: { total?: number; stages?: Record<string, number> }; excel_file_name?: string | null; excel_file_size?: number | null; sent_at?: string | null; created_at?: string | null; failure_reasons?: AlertBatchFailureReason[]; }
export interface AlertSummary { pending_count: number; next_send_at?: string | null; timezone?: string | null; }
/**
@@ -37,7 +38,7 @@ export interface AlertSummary { pending_count: number; next_send_at?: string | n
* @param params.keyword - 模糊检索词,可为空。
* @param params.parse_status - 解析状态精确筛选。
* @param params.reviewOnly - 为 true 时只查 needs_review。
* @param params.focus - 汇总卡口径:即将到期 / 逾期未付 / 进行中 / 本月应付。
* @param params.focus - 汇总卡口径:即将到期 / 逾期未付 / 未到期 / 本月应付。
* @returns 分页后的合同列表。
*/
export const listContractPaymentContracts = (params?: { keyword?: string; parse_status?: string; reviewOnly?: boolean; focus?: LedgerFocus; page?: number; pageSize?: number }) => {
@@ -55,7 +56,16 @@ export const enqueueContractPaymentSync = (force = false) => requestJson<{ job_i
/** 提交存量合同批量重解析,直接使用已归档附件刷新历史解析结果。 */
export const enqueueContractPaymentReparse = () => requestJson<{ job_id: string }>('/api/contract-payment/sync', { method: 'POST', body: JSON.stringify({ reparse_existing: true }) });
export const enqueueContractPaymentAlertScan = () => requestJson<{ job_id: string }>('/api/contract-payment/alerts/run', { method: 'POST' });
export const enqueueContractPaymentWeeklyAlert = () => requestJson<{ job_id: string }>('/api/contract-payment/alerts/weekly-run', { method: 'POST' });
export const enqueueContractPaymentWeeklyAlert = () => requestJson<{ job_id: number }>('/api/contract-payment/alerts/weekly-run', { method: 'POST' });
export interface ContractPaymentJobResult { batches?: number; sent?: number; failed?: number; alerts?: number; }
export interface ContractPaymentJob { id: number; status: string; message?: string | null; result?: ContractPaymentJobResult | null; }
/**
* 查询当前管理员刚提交的合同付款后台任务。
* 核心逻辑:发送预警只是入队,页面需轮询本接口直到 success / failed,再刷新周汇总列表。
* @param jobId - 入队接口返回的任务主键。
* @returns 任务状态与发送计数。
*/
export const getContractPaymentJob = (jobId: number) => requestJson<ContractPaymentJob>(`/api/contract-payment/jobs/${jobId}`);
/** 查询本周待发送笔数和下一次周五汇总发送时间。 */
export const getContractPaymentAlertSummary = () => requestJson<AlertSummary>('/api/contract-payment/alerts/summary');
/**