release: prepare 0629001 portal updates

This commit is contained in:
john
2026-06-29 22:20:04 +08:00
parent 18ea4f82fd
commit a40e340a41
84 changed files with 17516 additions and 2475 deletions
+27 -4
View File
@@ -11,7 +11,7 @@ export const PLAN_CATALOG = {
free: {
name: '免费版',
priceCents: 0,
periodTokens: 150_000,
periodTokens: 450_000,
periodImages: 10,
modelTier: 'basic',
overageRate: 1.00,
@@ -20,7 +20,7 @@ export const PLAN_CATALOG = {
lite: {
name: '轻量版',
priceCents: 990,
periodTokens: 1_200_000,
periodTokens: 3_600_000,
periodImages: 50,
modelTier: 'basic',
overageRate: 0.50,
@@ -29,7 +29,7 @@ export const PLAN_CATALOG = {
standard: {
name: '标准版',
priceCents: 2900,
periodTokens: 4_500_000,
periodTokens: 13_500_000,
periodImages: 200,
modelTier: 'standard',
overageRate: 0.70,
@@ -46,6 +46,12 @@ export const PLAN_CATALOG = {
},
};
const PLAN_TOKEN_ALLOWANCE_MIGRATIONS = [
['free', 150_000, PLAN_CATALOG.free.periodTokens],
['lite', 1_200_000, PLAN_CATALOG.lite.periodTokens],
['standard', 4_500_000, PLAN_CATALOG.standard.periodTokens],
];
export function getPlanDef(planType) {
return PLAN_CATALOG[planType] ?? null;
}
@@ -458,7 +464,7 @@ export function createSubscriptionService(pool, { getPlanAsync = null } = {}) {
for (const row of rows) {
const sub = mapSubRow(row);
const plan = getPlanDef(sub.planType);
const plan = await resolvePlan(sub.planType);
if (!plan || plan.priceCents === 0) continue;
const balance = Number(row.balance_cents ?? 0);
@@ -649,6 +655,23 @@ export async function ensurePlanCatalogSchema(pool) {
);
}
}
const now = Date.now();
for (const [planType, previousTokens, nextTokens] of PLAN_TOKEN_ALLOWANCE_MIGRATIONS) {
if (nextTokens <= previousTokens) continue;
await pool.query(
`UPDATE h5_plan_catalog
SET period_tokens = ?, updated_at = ?
WHERE plan_type = ? AND period_tokens = ?`,
[nextTokens, now, planType, previousTokens],
);
await pool.query(
`UPDATE h5_subscriptions
SET period_tokens_limit = ?, updated_at = ?
WHERE status = 'active' AND plan_type = ? AND period_tokens_limit = ?`,
[nextTokens, now, planType, previousTokens],
);
}
}
export function createPlanCatalogService(pool) {