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
+5 -2
View File
@@ -19,6 +19,9 @@ const ENTERPRISE_VIDEO_ALLOWED_MODELS = new Set([
"pixverse-c1-i2v",
]);
const CREDITS_PER_CNY = 100;
const CREDIT_UNITS_PER_CREDIT = 100;
function normalizeModel(value) {
return String(value || "").trim().toLowerCase();
}
@@ -102,7 +105,7 @@ function getEnterpriseVideoCreditRate(input) {
function calculateEnterpriseVideoCredits(input) {
const duration = normalizeEnterpriseVideoDuration(input.durationSeconds || input.duration);
return Number((getEnterpriseVideoCreditRate(input) * duration).toFixed(2));
return Number((getEnterpriseVideoCreditRate(input) * duration * CREDITS_PER_CNY).toFixed(2));
}
function calculateEnterpriseVideoCost(input) {
@@ -113,7 +116,7 @@ function calculateEnterpriseVideoCost(input) {
resolution,
durationSeconds,
});
const rateCentsPerSecond = Math.round(rateCreditsPerSecond * 100);
const rateCentsPerSecond = Math.round(rateCreditsPerSecond * CREDITS_PER_CNY * CREDIT_UNITS_PER_CREDIT);
return {
resolution,
durationSeconds,