feat: 金额上限校验、订阅详情展示优化、支付商品名称区分
- 硬编码 MAX_AMOUNT=99999999.99,所有金额输入(API+前端)统一校验上限
- 管理后台订阅列表改为卡片布局,Sub2API 分组信息嵌套只读展示(平台/倍率/限额/模型)
- 用户端套餐卡片和确认页展示平台、倍率、用量限制
- 订阅订单支付商品名改为 "Sub2API 订阅 {分组名}",余额充值保持原格式
This commit is contained in:
@@ -27,8 +27,11 @@ export async function PUT(request: NextRequest, { params }: { params: Promise<{
|
||||
}
|
||||
}
|
||||
|
||||
if (body.price !== undefined && (typeof body.price !== 'number' || body.price <= 0)) {
|
||||
return NextResponse.json({ error: 'price 必须是正数' }, { status: 400 });
|
||||
if (body.price !== undefined && (typeof body.price !== 'number' || body.price <= 0 || body.price > 99999999.99)) {
|
||||
return NextResponse.json({ error: 'price 必须是 0.01 ~ 99999999.99 之间的数值' }, { status: 400 });
|
||||
}
|
||||
if (body.original_price !== undefined && body.original_price !== null && (typeof body.original_price !== 'number' || body.original_price <= 0 || body.original_price > 99999999.99)) {
|
||||
return NextResponse.json({ error: 'original_price 必须是 0.01 ~ 99999999.99 之间的数值' }, { status: 400 });
|
||||
}
|
||||
if (body.validity_days !== undefined && (!Number.isInteger(body.validity_days) || body.validity_days <= 0)) {
|
||||
return NextResponse.json({ error: 'validity_days 必须是正整数' }, { status: 400 });
|
||||
|
||||
@@ -16,8 +16,9 @@ export async function GET(request: NextRequest) {
|
||||
plans.map(async (plan) => {
|
||||
let groupExists = false;
|
||||
let groupName: string | null = null;
|
||||
let group: Awaited<ReturnType<typeof getGroup>> | null = null;
|
||||
try {
|
||||
const group = await getGroup(plan.groupId);
|
||||
group = await getGroup(plan.groupId);
|
||||
groupExists = group !== null;
|
||||
groupName = group?.name ?? null;
|
||||
} catch {
|
||||
@@ -37,6 +38,12 @@ export async function GET(request: NextRequest) {
|
||||
sortOrder: plan.sortOrder,
|
||||
enabled: plan.forSale,
|
||||
groupExists,
|
||||
groupPlatform: group?.platform ?? null,
|
||||
groupRateMultiplier: group?.rate_multiplier ?? null,
|
||||
groupDailyLimit: group?.daily_limit_usd ?? null,
|
||||
groupWeeklyLimit: group?.weekly_limit_usd ?? null,
|
||||
groupMonthlyLimit: group?.monthly_limit_usd ?? null,
|
||||
groupModelScopes: group?.supported_model_scopes ?? null,
|
||||
createdAt: plan.createdAt,
|
||||
updatedAt: plan.updatedAt,
|
||||
};
|
||||
@@ -61,8 +68,11 @@ export async function POST(request: NextRequest) {
|
||||
return NextResponse.json({ error: '缺少必填字段: group_id, name, price' }, { status: 400 });
|
||||
}
|
||||
|
||||
if (typeof price !== 'number' || price <= 0) {
|
||||
return NextResponse.json({ error: 'price 必须是正数' }, { status: 400 });
|
||||
if (typeof price !== 'number' || price <= 0 || price > 99999999.99) {
|
||||
return NextResponse.json({ error: 'price 必须是 0.01 ~ 99999999.99 之间的数值' }, { status: 400 });
|
||||
}
|
||||
if (original_price !== undefined && original_price !== null && (typeof original_price !== 'number' || original_price <= 0 || original_price > 99999999.99)) {
|
||||
return NextResponse.json({ error: 'original_price 必须是 0.01 ~ 99999999.99 之间的数值' }, { status: 400 });
|
||||
}
|
||||
if (validity_days !== undefined && (!Number.isInteger(validity_days) || validity_days <= 0)) {
|
||||
return NextResponse.json({ error: 'validity_days 必须是正整数' }, { status: 400 });
|
||||
|
||||
Reference in New Issue
Block a user