Files
Mycontent/soul-api/scripts/backfill-vip-orders-insert.sql
卡若 6aa0d27da1 feat: 阅读页与章节预览 API;管理端内容页;book/h5_read;脚本与文档
- miniprogram: read 页与 member-detail/my;SOP 文档
- soul-api: chapter_preview、book/h5_read 调整;VIP 订单回填 SQL
- soul-admin: ContentPage、dist
- scripts: pull_from_baota;content_upload、gitignore、对话规则

Made-with: Cursor
2026-03-27 17:19:21 +08:00

45 lines
1.1 KiB
SQL
Raw 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.

-- 插入:为符合条件的超级个体用户各补一条 vip ¥1980 已付订单(仅无 vip 已付记录者)
-- 执行前请先跑 backfill-vip-orders-preview.sql并备份 orders 表
INSERT INTO orders (
id,
order_sn,
user_id,
open_id,
product_type,
product_id,
amount,
description,
status,
payment_method,
transaction_id,
pay_time,
created_at,
updated_at
)
SELECT
CONCAT('BFV', MD5(CONCAT(u.id, ':vip1980:backfill'))),
CONCAT('BFV', MD5(CONCAT(u.id, ':vip1980:backfill'))),
u.id,
COALESCE(u.open_id, ''),
'vip',
'vip_annual',
1980.00,
'卡若创业派对VIP年度会员365天【数据补录与超级个体权益对齐】',
'paid',
'manual',
'MANUAL_BACKFILL_VIP',
COALESCE(u.vip_activated_at, u.updated_at, u.created_at, NOW()),
NOW(),
NOW()
FROM users u
WHERE u.deleted_at IS NULL
AND COALESCE(u.is_vip, 0) = 1
AND (u.vip_expire_date IS NULL OR u.vip_expire_date > NOW())
AND NOT EXISTS (
SELECT 1 FROM orders o
WHERE o.user_id = u.id
AND o.product_type = 'vip'
AND o.status IN ('paid', 'completed', 'success')
);