feat(billing): record subscription-covered token usage in usage records
Memind CI / Test, build, and release guards (pull_request) Successful in 4m8s

Write h5_usage_records when plan quota fully covers a session bill so
WeChat and H5 consumption stays visible in admin usage history.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
john
2026-08-06 18:51:11 +08:00
parent 7c18c998bd
commit 6b586e0951
4 changed files with 145 additions and 6 deletions
+6
View File
@@ -194,6 +194,12 @@ export async function migrateSchema(pool) {
`ALTER TABLE h5_usage_records ADD UNIQUE KEY uniq_h5_usage_request_id (request_id)`,
);
}
if (!(await columnExists(pool, 'h5_usage_records', 'billing_source'))) {
await pool.query(
`ALTER TABLE h5_usage_records
ADD COLUMN billing_source VARCHAR(16) NOT NULL DEFAULT 'wallet' AFTER balance_after_cents`,
);
}
const assetForeignKeys = [
{