release: prepare 0629001 portal updates
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user