重构:统一财务派生数据真源与重建

This commit is contained in:
yml2213
2026-11-08 19:44:27 +08:00
parent bae9a5ae5e
commit f8cbb645fe
14 changed files with 1011 additions and 541 deletions
@@ -44,12 +44,12 @@ async function main() {
}>(
`
SELECT
COUNT(*) FILTER (WHERE fulfillment_status = 'assigned')::int AS assigned,
COUNT(*) FILTER (WHERE fulfillment_status = 'pending')::int AS pending,
COUNT(*) FILTER (WHERE fulfillment_status = 'archived')::int AS archived,
COUNT(*) FILTER (WHERE status = 'assigned')::int AS assigned,
COUNT(*) FILTER (WHERE status = 'pending')::int AS pending,
COUNT(*) FILTER (WHERE status = 'archived')::int AS archived,
(SELECT COUNT(*)::int FROM sales_daily_facts) AS facts,
(SELECT COUNT(*)::int FROM cost_snapshots WHERE superseded_at IS NULL) AS snapshots
FROM order_items
FROM fulfillments
`,
)