- 新增 assets:fusion.css(样板全量 token/组件/动效)、fusion.js(主题/抽屉/弹层/开关/按住确认/计算器引擎/三态全选/toast)、日夜 Logo - pageHeader/pageFooter 重写为样板侧栏骨架:固定侧栏导航、底部账户区、日间/夜间 token 切换、导入弹层、详情抽屉容器 - 新增工作台(风险入口卡+今日待办+快捷入口)、任务中心(四组分段+行内处理)、档案库目录管理三栏视图 - 档案列表恢复样板分段标签/KPI 卡/筛选条/批量条/行点击抽屉 - 档案详情页 + 右侧抽屉(概要/还款计划/附件三标签)按样板实现,保留全部真实绑定 - 新建/编辑档案改造为五步向导(字段与联动 JS 全量保留) - 登录页左右布局、用户管理、个人设置、删除审批、统计查询四口径页签、便捷查询、两个计算器全部按样板重构 - 页面 view 抽取至 app/views/pages/,index.php 保留全部业务逻辑与路由 - 业务功能零删减:表单字段、权限、审批闭环、导入导出、计算口径均不变 Co-authored-by: multica-agent <github@multica.ai>
114 lines
6.7 KiB
PHP
114 lines
6.7 KiB
PHP
<?php
|
||
requireLogin();
|
||
$exportFormat = (string)($_GET['format'] ?? '');
|
||
$rowsAll = $pdo->query('SELECT * FROM archives ORDER BY id DESC')->fetchAll();
|
||
$financeAll = loadFinanceConfigs();
|
||
$planAll = loadRepaymentPlans();
|
||
$quickStats = qqBuildPayableInterestData($rowsAll, $financeAll, $planAll);
|
||
$instRows = $quickStats['instRows'];
|
||
$planRows = $quickStats['planRows'];
|
||
$planTotal = (float)($quickStats['planTotal'] ?? 0);
|
||
|
||
if ($exportFormat === 'xlsx' && class_exists('\PhpOffice\PhpSpreadsheet\Spreadsheet') && class_exists('\PhpOffice\PhpSpreadsheet\Writer\Xlsx')) {
|
||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||
$sheet1 = $spreadsheet->getActiveSheet();
|
||
$sheet1->setTitle('机构利息汇总');
|
||
$sheet1->fromArray(['机构', '笔数(履行+逾期)', '当前应付利息', '结息日', '结息日应付利息'], null, 'A1');
|
||
$sheet1->fromArray(array_map(fn($x) => [$x['loan_institution'], $x['loan_count'], amount((float)$x['current_interest']), (string)($x['settlement_date'] ?? ''), amount((float)$x['settlement_interest'])], $instRows), null, 'A2');
|
||
foreach (range('A', 'E') as $col) { $sheet1->getColumnDimension($col)->setWidth(24); }
|
||
|
||
$sheet2 = $spreadsheet->createSheet();
|
||
$sheet2->setTitle('当月还款计划');
|
||
$sheet2->fromArray(['机构', '档案名称', '借款主体', '到期日', '金额', '状态'], null, 'A1');
|
||
$sheet2->fromArray(array_map(fn($x) => [$x['loan_institution'], $x['archive_name'], $x['borrower'], $x['due_date'], amount((float)$x['amount']), $x['status']], $planRows), null, 'A2');
|
||
$sheet2->setCellValue('A' . (count($planRows) + 3), '合计');
|
||
$sheet2->setCellValue('E' . (count($planRows) + 3), amount($planTotal));
|
||
foreach (range('A', 'F') as $col) { $sheet2->getColumnDimension($col)->setWidth(22); }
|
||
|
||
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
||
header('Content-Disposition: attachment; filename="' . rawurlencode('应付本息查询_' . date('Y-m-d') . '.xlsx') . '"');
|
||
(new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet))->save('php://output');
|
||
exit;
|
||
}
|
||
/* 视觉层辅助在 index.php 尾部(本组页面 require 点之后)定义,这里做呈现级兜底 */
|
||
if (!function_exists('fmtMoney')) {
|
||
function fmtMoney(?float $v): string
|
||
{
|
||
return $v === null ? '—' : number_format($v, 2, '.', ',');
|
||
}
|
||
}
|
||
pageHeader($me); ?>
|
||
<div class="page-head">
|
||
<div>
|
||
<h1 class="page-title">统计查询</h1>
|
||
<div class="page-sub">便捷统计 · 四个口径</div>
|
||
</div>
|
||
</div>
|
||
<div class="seg" role="tablist" aria-label="统计口径" style="margin-bottom:20px;">
|
||
<a role="tab" href="index.php?action=query_totals">总金额</a>
|
||
<a role="tab" href="index.php?action=query_payable_interest" data-active>应付本息</a>
|
||
<a role="tab" href="index.php?action=query_external_guarantee">对外担保</a>
|
||
<a role="tab" href="index.php?action=repayment_history">历史还款</a>
|
||
</div>
|
||
<div class="filter-bar" style="margin-top:0;">
|
||
<span class="filter-note">当月计划 <?= count($planRows) ?> 笔 · 合计 <?= e(fmtMoney($planTotal)) ?> 元</span>
|
||
<span class="filter-spacer"></span>
|
||
<a class="btn btn--plain" href="index.php?action=query_payable_interest&format=xlsx">导出 xlsx</a>
|
||
</div>
|
||
<div class="section-title" style="margin-top:0;">机构应付利息统计</div>
|
||
<div class="table-card">
|
||
<table>
|
||
<thead><tr><th>贷款机构</th><th class="cell-right">在保笔数</th><th class="cell-right">当前应付利息</th><th>结息日</th><th class="cell-right" title="本结息周期整段应计,非自今日至结息日">结息日应付利息</th></tr></thead>
|
||
<tbody>
|
||
<?php
|
||
$sumCur = 0.0;
|
||
$sumSettle = 0.0;
|
||
foreach ($instRows as $i => $r):
|
||
$sumCur += (float)$r['current_interest'];
|
||
$sumSettle += (float)$r['settlement_interest'];
|
||
?>
|
||
<tr class="stagger-in" style="animation-delay:<?= min($i, 8) * 45 ?>ms; cursor:default;">
|
||
<td><?= e((string)$r['loan_institution']) ?></td>
|
||
<td class="cell-right num"><?= (int)$r['loan_count'] ?></td>
|
||
<td class="cell-right num" style="color:var(--gold); font-weight:650;"><?= e(fmtMoney((float)$r['current_interest'])) ?></td>
|
||
<td class="num"><?= (string)($r['settlement_date'] ?? '') !== '' ? e((string)$r['settlement_date']) : '—' ?></td>
|
||
<td class="cell-right num"><?= e(fmtMoney((float)$r['settlement_interest'])) ?></td>
|
||
</tr>
|
||
<?php endforeach; ?>
|
||
<?php if ($instRows): ?>
|
||
<tr style="cursor:default;">
|
||
<td><strong>合计</strong></td>
|
||
<td class="cell-right num"><strong><?= array_sum(array_map(fn($x) => (int)$x['loan_count'], $instRows)) ?></strong></td>
|
||
<td class="cell-right num" style="color:var(--gold); font-weight:650;"><strong><?= e(fmtMoney($sumCur)) ?></strong></td>
|
||
<td>—</td>
|
||
<td class="cell-right num"><strong><?= e(fmtMoney($sumSettle)) ?></strong></td>
|
||
</tr>
|
||
<?php endif; ?>
|
||
</tbody>
|
||
</table>
|
||
<?php if (!$instRows): ?>
|
||
<div style="padding:16px;"><div class="empty">暂无履行中或逾期中的银行贷款</div></div>
|
||
<?php endif; ?>
|
||
</div>
|
||
<div class="section-title">当月还款计划(<?= e(date('Y-m')) ?>)<span class="nav-badge num"><?= count($planRows) ?></span></div>
|
||
<?php if ($planRows): ?>
|
||
<div class="timeline">
|
||
<?php foreach ($planRows as $r):
|
||
$pst = (string)$r['status'];
|
||
$tl = $pst === 'overdue' ? 'over' : ($pst === 'paid' ? 'paid' : 'due');
|
||
$pillCls = ['pending' => 'due', 'overdue' => 'over', 'delayed' => 'done', 'paid' => 'ok'][$pst] ?? 'due';
|
||
$pillTxt = ['pending' => '未还', 'overdue' => '逾期', 'delayed' => '已延期', 'paid' => '已还款'][$pst] ?? '未还';
|
||
?>
|
||
<div class="plan-row" data-tl="<?= $tl ?>">
|
||
<span class="plan-kind"><?= e((string)$r['archive_name']) ?></span>
|
||
<span class="plan-date num"><?= e((string)$r['due_date']) ?> · <?= e((string)$r['loan_institution']) ?></span>
|
||
<span class="pill pill--<?= $pillCls ?>"><?= e($pillTxt) ?></span>
|
||
<span class="plan-amt num"><?= e(fmtMoney((float)$r['amount'])) ?></span>
|
||
</div>
|
||
<?php endforeach; ?>
|
||
</div>
|
||
<?php else: ?>
|
||
<div class="empty">当月无还款计划</div>
|
||
<?php endif; ?>
|
||
<?php pageFooter(); exit;
|