修复支付取消与成功统计

This commit is contained in:
yml
2026-06-14 23:58:39 +08:00
parent 3ff8c1de88
commit a275a006eb
11 changed files with 412 additions and 7 deletions
@@ -0,0 +1,19 @@
-- +goose Up
-- 修复历史数据:订单已取消但支付流水仍停留在 created/paying 时,同步关闭支付流水。
UPDATE payment_orders p
JOIN rental_orders o ON o.id = p.order_id
SET p.status = 'closed',
p.raw_response = JSON_OBJECT(
'source', 'migration_cancelled_order',
'reason', '订单已取消,关闭历史未完成支付单'
),
p.updated_at = CURRENT_TIMESTAMP
WHERE p.biz_type = 'order_pay'
AND p.status IN ('created', 'paying')
AND o.status = 'cancelled';
-- +goose Down
-- 数据修复无法安全反推原状态,回滚时不重新打开已关闭支付流水。
SELECT 1;