mirror of
https://github.com/JetSprow/J-Board-Lite.git
synced 2026-05-01 09:14:11 +05:30
feat: polish internal value displays
This commit is contained in:
@@ -6,6 +6,7 @@ import { requireAuth } from "@/lib/require-auth";
|
||||
import { buildUnavailableMessage, getPlanAvailability } from "@/services/plan-availability";
|
||||
import { getPlanPurchasePrice, calculateCheckoutDiscounts } from "@/services/commerce";
|
||||
import { ensurePlanTrafficPoolCapacity } from "@/services/plan-traffic-pool";
|
||||
import { getSubscriptionTypeLabel } from "@/lib/domain-labels";
|
||||
|
||||
async function assertNoPendingOrder(userId: string) {
|
||||
const pendingOrder = await prisma.order.findFirst({
|
||||
@@ -33,7 +34,7 @@ async function getProxyPlanForCart(planId: string) {
|
||||
},
|
||||
});
|
||||
|
||||
if (plan.type !== "PROXY") throw new Error(`套餐类型不匹配:${plan.name} 是 ${plan.type},不能作为代理套餐加入购物车`);
|
||||
if (plan.type !== "PROXY") throw new Error(`套餐类型不匹配:${plan.name} 是${getSubscriptionTypeLabel(plan.type)},不能作为代理套餐加入购物车`);
|
||||
if (!plan.isActive) throw new Error(`套餐已下架:${plan.name} 当前不可购买`);
|
||||
return plan;
|
||||
}
|
||||
@@ -115,7 +116,7 @@ export async function addProxyPlanToCart(
|
||||
export async function addStreamingPlanToCart(planId: string) {
|
||||
const session = await requireAuth();
|
||||
const plan = await prisma.subscriptionPlan.findUniqueOrThrow({ where: { id: planId } });
|
||||
if (plan.type !== "STREAMING") throw new Error(`套餐类型不匹配:${plan.name} 是 ${plan.type},不能作为流媒体套餐加入购物车`);
|
||||
if (plan.type !== "STREAMING") throw new Error(`套餐类型不匹配:${plan.name} 是${getSubscriptionTypeLabel(plan.type)},不能作为流媒体套餐加入购物车`);
|
||||
if (!plan.isActive) throw new Error(`套餐已下架:${plan.name} 当前不可购买`);
|
||||
|
||||
const availability = await getPlanAvailability(plan, { userId: session.user.id });
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
getPlanTrafficPoolState,
|
||||
} from "@/services/plan-traffic-pool";
|
||||
import { getPlanPurchasePrice, roundMoney } from "@/services/commerce";
|
||||
import { getSubscriptionTypeLabel } from "@/lib/domain-labels";
|
||||
|
||||
async function assertNoPendingOrder(userId: string) {
|
||||
const pendingOrder = await prisma.order.findFirst({
|
||||
@@ -133,7 +134,7 @@ export async function purchaseProxy(
|
||||
},
|
||||
});
|
||||
|
||||
if (plan.type !== "PROXY") throw new Error(`套餐类型不匹配:${plan.name} 是 ${plan.type},不能作为代理套餐购买`);
|
||||
if (plan.type !== "PROXY") throw new Error(`套餐类型不匹配:${plan.name} 是${getSubscriptionTypeLabel(plan.type)},不能作为代理套餐购买`);
|
||||
if (!plan.isActive) throw new Error(`套餐已下架:${plan.name} 当前不可购买`);
|
||||
|
||||
const price = getPlanPurchasePrice(plan, trafficGb);
|
||||
@@ -213,7 +214,7 @@ export async function purchaseStreaming(planId: string): Promise<string> {
|
||||
where: { id: planId },
|
||||
});
|
||||
|
||||
if (plan.type !== "STREAMING") throw new Error(`套餐类型不匹配:${plan.name} 是 ${plan.type},不能作为流媒体套餐购买`);
|
||||
if (plan.type !== "STREAMING") throw new Error(`套餐类型不匹配:${plan.name} 是${getSubscriptionTypeLabel(plan.type)},不能作为流媒体套餐购买`);
|
||||
if (!plan.isActive) throw new Error(`套餐已下架:${plan.name} 当前不可购买`);
|
||||
|
||||
const availability = await getPlanAvailability(plan, { userId: session.user.id });
|
||||
|
||||
Reference in New Issue
Block a user