feat(admin): rebuild the payment center overview with ECharts analytics

- Overview page: realtime today vs. same time yesterday, 6 KPI cards with
  period-over-period deltas, trend (paid / net / refund curves + order count
  line), category curves, payment method donut, top 10 paid content,
  conversion / close / refund rates, todos and shortcuts
- Date presets, custom range and category filter via
  GET aksrt/v1/admin/pay-overview (manage_options + wp_rest nonce)
- Metrics: paid amount by paid date including later-refunded orders, refunds
  by refund date, net = paid - refund; CNY only, points and recharge excluded,
  foreign-currency orders listed separately; integer cents internally
- Daily records cached per month in transients (today/yesterday live),
  invalidated on order status change and on purge
- ECharts 6.1.0 subset bundled to assets/js/runtime/libs/echarts-pay.min.js
  (npm run build:pay-charts), loaded only on the overview page
- Split payment-attempt methods out of OrderRepositoryCore into
  OrderRepositoryAttempts; remove dead get_stats(), cash_decimal(),
  Order::get_stats() and the old .aksrt-native-links styles

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
kate522andClaude Fable 5 committed 2026-11-01 00:22:44 +08:00
1 parent d98f8d7975
commit 9805a371d8
19 files changed
+2203 -405

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
/**
* 打包支付中心概览用的 ECharts 子集。
*
* cd assets/admin && npm run build:pay-charts
*
* echarts 是 assets/admin 的 devDependency;产物入库,部署时无需安装 node 依赖。
*/
import { createRequire } from 'node:module';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
const adminDir = path.join(repoRoot, 'assets/admin');
const require = createRequire(path.join(adminDir, 'package.json'));
const { build } = require('esbuild');
const outfile = path.join(repoRoot, 'assets/js/runtime/libs/echarts-pay.min.js');
await build({
entryPoints: [path.join(repoRoot, 'tools/echarts-pay-overview.entry.mjs')],
outfile,
bundle: true,
format: 'iife',
minify: true,
target: ['es2018'],
legalComments: 'inline',
nodePaths: [path.join(adminDir, 'node_modules')],
logLevel: 'info',
});
+32
View File
@@ -0,0 +1,32 @@
/**
* 支付中心概览专用的 ECharts 按需入口(由 tools/build-pay-charts.mjs 打包)。
*
* 只注册概览页用到的图表与组件,打包为 IIFE 并挂到 window.echarts。
* 产物:assets/js/runtime/libs/echarts-pay.min.js(入库,后台只在 aksrt_pay 页入队)。
*/
import * as echarts from 'echarts/core';
import { LineChart, BarChart, PieChart } from 'echarts/charts';
import {
GridComponent,
TooltipComponent,
LegendComponent,
DataZoomComponent,
AxisPointerComponent,
AriaComponent,
} from 'echarts/components';
import { SVGRenderer } from 'echarts/renderers';
echarts.use([
LineChart,
BarChart,
PieChart,
GridComponent,
TooltipComponent,
LegendComponent,
DataZoomComponent,
AxisPointerComponent,
AriaComponent,
SVGRenderer,
]);
window.echarts = echarts;