若干更新迭代
This commit is contained in:
1 parent
deb9cc5bcf
commit
4ac786aafb
64 files changed
+3251
-291
No files matched your search
@@ -3,8 +3,9 @@ import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { DEFAULT_BILLING_PRICE_RULES, ensureDefaultBillingPriceRules } from "@/lib/server/billing-catalog";
|
||||
import { quoteGenerationCharge } from "@/lib/server/billing-service";
|
||||
import { quoteGenerationCharge, settleMinimaxGenerationCharge } from "@/lib/server/billing-service";
|
||||
import { createBillingPriceRule, getBillingPriceRule, updateBillingPriceTierMultiplier } from "@/lib/server/billing-store";
|
||||
import { createGenerationJob } from "@/lib/server/data-store";
|
||||
|
||||
let runtimeDir = "";
|
||||
|
||||
@@ -44,6 +45,50 @@ describe("default billing catalog refresh", () => {
|
||||
expect(tiers?.find((tier) => tier.value === "2K")?.markupMultiplier).toBe(1.2);
|
||||
});
|
||||
|
||||
it("quotes MiniMax nine references and keeps Wan 3.0 resolution pricing independent", async () => {
|
||||
const context = { source: "platform" as const, accountId: "user-1", displayName: "测试用户", organizationId: "org-1" };
|
||||
const minimax = await quoteGenerationCharge({
|
||||
provider: "minimax", capability: "video.generate", reqKey: "MiniMax-H3",
|
||||
requestPayload: {
|
||||
settings: { duration: 5, resolution: "2K" },
|
||||
materials: Array.from({ length: 9 }, (_, index) => ({ type: "image", url: `https://cdn.test/${index}.png` }))
|
||||
},
|
||||
usageContext: context
|
||||
});
|
||||
expect(minimax).toMatchObject({ amountFen: 576, reservedAmountFen: 576, settlementStatus: "pending" });
|
||||
expect(minimax?.parameters).toMatchObject({ inputImageCount: 9, inputImagePriceFen: 80 });
|
||||
|
||||
const wan3 = await quoteGenerationCharge({
|
||||
provider: "bailian", capability: "video.generate", reqKey: "wan3.0-video",
|
||||
requestPayload: { settings: { duration: 5, resolution: "1080P" } }, usageContext: context
|
||||
});
|
||||
expect(wan3).toMatchObject({
|
||||
priceRuleId: "base-bailian-wan30-video-1080p", amountFen: 720,
|
||||
reservedAmountFen: 720, settlementStatus: "pending"
|
||||
});
|
||||
});
|
||||
|
||||
it("retains quoted MiniMax image fees only when provider omits image usage", async () => {
|
||||
const materials = Array.from({ length: 9 }, (_, index) => ({ type: "image", url: `https://cdn.test/${index}.png` }));
|
||||
const makeJob = () => createGenerationJob({
|
||||
ownerId: "user-1", capability: "video.generate", provider: "minimax", reqKey: "MiniMax-H3", status: "succeeded",
|
||||
inputAssetIds: [], inputUrls: [], outputAssetIds: [], requestPayload: { materials },
|
||||
usageContext: { source: "platform", accountId: "user-1", displayName: "管理员", role: "super_admin" },
|
||||
billing: {
|
||||
priceRuleId: "base-minimax-h3-2k", provider: "minimax", capability: "video.generate", reqKey: "MiniMax-H3",
|
||||
unit: "video_second", quantity: 5, standardUnitPriceFen: 80, markupMultiplier: 1.2,
|
||||
amountFen: 576, reservedAmountFen: 576, currency: "CNY", status: "not_charged", quotaExempt: true,
|
||||
settlementStatus: "pending", parameters: { resolution: "2k", inputImageCount: 9 }
|
||||
}
|
||||
});
|
||||
|
||||
const missing = await settleMinimaxGenerationCharge(await makeJob(), { outputSeconds: 5, inputSeconds: 0 });
|
||||
expect(missing?.billing).toMatchObject({ amountFen: 576, settlementStatus: "settled", providerUsage: { inputImageCount: 9 } });
|
||||
|
||||
const explicitZero = await settleMinimaxGenerationCharge(await makeJob(), { outputSeconds: 5, inputSeconds: 0, inputImageCount: 0 });
|
||||
expect(explicitZero?.billing).toMatchObject({ amountFen: 480, settlementStatus: "settled", providerUsage: { inputImageCount: 0 } });
|
||||
});
|
||||
|
||||
it("takes current default definitions while retaining valid matching tier markups", async () => {
|
||||
const candidate = DEFAULT_BILLING_PRICE_RULES.find((rule) => rule.id === "base-seedream-5-0-pro")!;
|
||||
const size = candidate.parameterDimensions!.find((dimension) => dimension.key === "size")!;
|
||||
|
||||
Reference in new issue
Block a user