Scale generation billing charges to 1-to-100 credits

This commit is contained in:
stringadmin
2026-06-08 16:03:49 +08:00
parent 0f94010104
commit 071a98bd96
3 changed files with 15 additions and 9 deletions
+6 -6
View File
@@ -136,8 +136,8 @@ function registerUserRoutes(router) {
CASE
WHEN billing_refunded = 1 THEN 0
WHEN cost_cents > 0 THEN cost_cents
WHEN status = 'completed' AND type = 'image' THEN 2000
WHEN status = 'completed' AND type = 'video' THEN 500
WHEN status = 'completed' AND type = 'image' THEN 200000
WHEN status = 'completed' AND type = 'video' THEN 50000
ELSE 0
END
), 0) AS used_cents
@@ -162,7 +162,7 @@ function registerUserRoutes(router) {
resolution = params.resolution || params.quality || params.ratio || null;
if (row.status === "completed") {
if (row.type === "image") {
estimatedCents = 2000;
estimatedCents = 200000;
} else if (row.type === "video") {
const dur = params.duration || 5;
const res = String(params.resolution || params.quality || "").toUpperCase();
@@ -172,7 +172,7 @@ function registerUserRoutes(router) {
else if (model.includes("wan2.7-i2v") || model.includes("wanxiang")) rate = res === "720P" ? 0.6 : 1;
else if (model.includes("animate-mix") || model.includes("s2v")) rate = res === "720P" ? 0.6 : 1;
else if (model.includes("kling")) rate = res === "720P" ? 0.6 : 0.8;
estimatedCents = Math.ceil(rate * dur * 100);
estimatedCents = Math.ceil(rate * dur * 10000);
}
}
} catch {
@@ -209,8 +209,8 @@ function registerUserRoutes(router) {
CASE
WHEN billing_refunded = 1 THEN 0
WHEN cost_cents > 0 THEN cost_cents
WHEN status = 'completed' AND type = 'image' THEN 2000
WHEN status = 'completed' AND type = 'video' THEN 500
WHEN status = 'completed' AND type = 'image' THEN 200000
WHEN status = 'completed' AND type = 'video' THEN 50000
ELSE 0
END
), 0) AS used_cents