Files
sub2apipay/src/app/api/limits/route.ts

28 lines
1012 B
TypeScript
Raw Normal View History

import { NextResponse } from 'next/server';
import { queryMethodLimits } from '@/lib/order/limits';
import { initPaymentProviders, paymentRegistry } from '@/lib/payment';
2026-03-10 11:52:37 +08:00
import { getNextBizDayStartUTC } from '@/lib/time/biz-day';
/**
* GET /api/limits
* 使
*
* Response:
* {
* methods: {
* alipay: { dailyLimit: 10000, used: 3500, remaining: 6500, available: true },
* wxpay: { dailyLimit: 10000, used: 10000, remaining: 0, available: false },
* stripe: { dailyLimit: 0, used: 500, remaining: null, available: true }
* },
2026-03-10 11:52:37 +08:00
* resetAt: "2026-03-02T16:00:00.000Z" // 业务时区Asia/Shanghai次日零点对应的 UTC 时间
* }
*/
export async function GET() {
initPaymentProviders();
const types = paymentRegistry.getSupportedTypes();
const methods = await queryMethodLimits(types);
2026-03-10 11:52:37 +08:00
const resetAt = getNextBizDayStartUTC();
return NextResponse.json({ methods, resetAt });
}