This commit is contained in:
eric
2026-03-27 19:07:24 -05:00
parent 759875ec36
commit 3eb0334114
8 changed files with 49 additions and 31 deletions

View File

@@ -84,7 +84,7 @@ async function checkVipFromPayjsapi(
userId
)}`;
console.log("[check-by-user] payjsapi request user_id=%s url=%s", userId, url);
const checkTimeout = Number(process.env.PAYJSAPI_CHECK_TIMEOUT) || 15000;
const checkTimeout = Number(process.env.PAYJSAPI_CHECK_TIMEOUT) || 15_000;
const retries = Math.max(0, Number(process.env.PAYJSAPI_CHECK_RETRIES) || 1);
const res = await fetchPayjsVipWithRetry(url, checkTimeout, retries);
if (!res) {
@@ -166,7 +166,7 @@ export async function POST(request: NextRequest) {
let linkedUserId: string | undefined;
let vipFromSite = false;
let vipFromPayments = false;
let vipSource = vip ? "payjsapi" : "none";
let vipSource = "none";
try {
const adminToken = await getAdminToken().catch((error) => {
@@ -206,7 +206,7 @@ export async function POST(request: NextRequest) {
);
}
// PB 未命中再请求 payjsapi,避免每次都先走远端网络
// 同机 PB 命中则不再打 payjsapi;仅未命中时再走 payjs(与线上极致路径一致)
if (!vip) {
payjsResult = await checkVipFromPayjsapi(request, userId);
if (payjsResult?.vip) {