Files
as-daycard-openapi/db/schedule-timeout-task.sql
zhaogd 30198c7191 初始化天卡开放平台后端项目
包含完整功能模块:
- 设备激活(直销激活码模式 + 代销免激活码模式)
- 微信支付 + 天卡订单
- 天卡池管理 + 异步橘视厅SDK激活
- 第三方合作伙伴接口(代销模式)
  - 签名鉴权(appKey/appSecret + nonce防重放)
  - 天卡消耗(事务 + 幂等 + 并发控制)
  - 媒资接口(三级授权过滤)
  - 审计日志
- 定价策略(3层:门店 > 渠道 > 平台)
- 分账(微信分账 + 分润规则)
- Docker部署(含Redis容器)
2026-07-26 12:34:13 +08:00

22 lines
1.1 KiB
SQL
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- ===========================================================
-- schedule-timeout-task.sql
-- 修复:天卡订单超时取消任务未被调度,导致 RESERVED 卡永不释放
-- 1) 注册 dayCardOrderTimeoutTask 到 schedule_job(每 2 分钟)
-- 2) 清理当前卡死的 RESERVED 卡与对应过期 PENDING 订单
-- 注:新增调度任务需重启后端才会被 Quartz 加载生效
-- ===========================================================
-- 1. 注册超时取消任务(status=0 正常运行)
INSERT INTO schedule_job (bean_name, params, cron_expression, status, remark, create_time)
VALUES ('dayCardOrderTimeoutTask', '', '0 */2 * * * ?', 0, '天卡订单超时取消-释放预占卡', NOW());
-- 2. 释放卡死的 RESERVED 卡 -> UNUSED
UPDATE day_card_pool
SET status = 'UNUSED', order_no = NULL, device_id = NULL, updated_at = NOW()
WHERE status = 'RESERVED' AND delete_flag = 'UNDEL';
-- 3. 取消过期未支付订单 PENDING -> CANCELLED
UPDATE day_card_order
SET status = 'CANCELLED', cancel_time = NOW(), updated_at = NOW()
WHERE status = 'PENDING' AND delete_flag = 'UNDEL' AND expire_time < NOW();