36 lines
1.1 KiB
SQL
36 lines
1.1 KiB
SQL
-- +goose Up
|
|
-- 财务仪表盘按时间窗口聚合支付、退款和结算数据。
|
|
-- 支付索引避免退款统计扫描全部历史状态;结算与结账索引避免日报聚合回表。
|
|
ALTER TABLE payment_orders
|
|
ADD KEY idx_payment_orders_dashboard_created (created_at, biz_type, status, order_id, amount_cent),
|
|
ADD KEY idx_payment_orders_dashboard_order (order_id, biz_type, status, amount_cent);
|
|
|
|
ALTER TABLE rental_orders
|
|
ADD KEY idx_rental_orders_dashboard_settled (
|
|
settled_at,
|
|
id,
|
|
settlement_mode,
|
|
offline_settlement_status,
|
|
offline_settlement_amount_cent,
|
|
refund_status
|
|
);
|
|
|
|
ALTER TABLE order_checkouts
|
|
ADD KEY idx_order_checkouts_dashboard_accepted (
|
|
status,
|
|
order_id,
|
|
platform_fee_cent,
|
|
owner_income_amount_cent
|
|
);
|
|
|
|
-- +goose Down
|
|
ALTER TABLE order_checkouts
|
|
DROP KEY idx_order_checkouts_dashboard_accepted;
|
|
|
|
ALTER TABLE rental_orders
|
|
DROP KEY idx_rental_orders_dashboard_settled;
|
|
|
|
ALTER TABLE payment_orders
|
|
DROP KEY idx_payment_orders_dashboard_order,
|
|
DROP KEY idx_payment_orders_dashboard_created;
|