feat: 完善履约路由、订单服务与自动核销

This commit is contained in:
yml2213
2026-11-05 14:59:58 +08:00
parent 517d763f17
commit 1df88cc639
54 changed files with 3166 additions and 318 deletions
@@ -728,7 +728,7 @@ async function loadTemplateProductBootstrapData(range: { fromDate: string; toDat
COUNT(DISTINCT oi.id)::int AS item_count
FROM order_items oi
JOIN orders o ON o.id = oi.order_id
JOIN work_orders wo ON wo.order_item_id = oi.id
JOIN work_orders wo ON wo.order_item_id = oi.id AND wo.status <> 'cancelled'
JOIN work_product_rules r ON r.id = wo.product_rule_id AND r.enabled = TRUE
WHERE wo.product_rule_id IS NOT NULL
AND (COALESCE(o.paid_at, o.created_at) AT TIME ZONE 'Asia/Shanghai')::date