修复:收到订单后按订单级触发自动核销

This commit is contained in:
yml2213
2026-11-08 21:29:51 +08:00
parent d76e8265f8
commit 996054a5c5
13 changed files with 683 additions and 8 deletions
@@ -0,0 +1,24 @@
-- 150_voucher_consume_order_received_scope.sql
--
-- “收到订单后”核销改为订单级触发:
-- 1. 不再依赖履约渠道、订单项状态或待处理原因;
-- 2. 订单级任务以 order:<订单ID> 去重;
-- 3. channel=order_received 仅用于任务来源审计和后台筛选。
ALTER TABLE voucher_consume_jobs
DROP CONSTRAINT IF EXISTS voucher_consume_jobs_channel_check;
ALTER TABLE voucher_consume_jobs
ADD CONSTRAINT voucher_consume_jobs_channel_check
CHECK (channel IN (
'order_received',
'affiliate_dash',
'work_order',
'manual',
'third_party_voucher',
'on_account',
'unmatched'
));
COMMENT ON COLUMN voucher_consume_jobs.channel IS
'触发核销时的策略来源;order_received 表示与履约渠道无关的订单级收单触发';