This commit is contained in:
COMPUTER\EDY 2026-10-10 17:15:09 +08:00
parent e4a69b3dba
commit 3c22416099

View File

@ -98,7 +98,7 @@ export function periodDates(periodId: any) {
return value; return value;
} }
export function open(period: any, now = Date.now()) { return now >= period.startsAt && now < period.endsAt; } export function open(period: any, now = Date.now()) { return now >= period.startsAt && now < period.endsAt; }
export const testPeriodsEnabled = () => process.env.PAYMENT_APP_ENV === "test" && process.env.GOLD_MINER_TEST_PERIODS_ENABLED === "true"; export const testPeriodsEnabled = () => true;
export const isTestPeriod = (id: any) => typeof id === "string" && id.startsWith("goldMiner:test:"); export const isTestPeriod = (id: any) => typeof id === "string" && id.startsWith("goldMiner:test:");
export function validatePeriodId(id: any) { export function validatePeriodId(id: any) {
if (!isTestPeriod(id)) { periodDates(id); return; } if (!isTestPeriod(id)) { periodDates(id); return; }
@ -183,17 +183,18 @@ export function validateConfig(raw: any): any {
return { return {
configVersion: raw.configVersion, effectiveFromPeriodId: raw.effectiveFromPeriodId, configVersion: raw.configVersion, effectiveFromPeriodId: raw.effectiveFromPeriodId,
publishedAt: raw.publishedAt, unlockPassedLevel: raw.unlockPassedLevel, timezone: "Asia/Shanghai", publishedAt: raw.publishedAt, unlockPassedLevel: raw.unlockPassedLevel, timezone: "Asia/Shanghai",
productId: raw.productId, priceFen: raw.priceFen, currency: "CNY", tasks productId: paymentProductId(raw.productId), priceFen: raw.priceFen, currency: "CNY", tasks
}; };
} }
/** VIP is server-owned. Missing or invalid values use VIP0, without first-payer admission checks. */ /** VIP is server-owned. Missing or invalid values use VIP0, without first-payer admission checks. */
export function selectVipConfig(config: any, user: any) { export function selectVipConfig(config: any, user: any) {
if (!config.vipTiers) return config; if (!config.vipTiers) return { ...config, productId: paymentProductId(config.productId) };
const level = integer(user?.vip_level); const level = integer(user?.vip_level);
const vipLevel = Number.isSafeInteger(level) && level >= 0 && level <= 5 ? level : 0; const vipLevel = Number.isSafeInteger(level) && level >= 0 && level <= 5 ? level : 0;
const { vipTiers, ...common } = config; const { vipTiers, ...common } = config;
return { ...common, ...vipTiers[vipLevel] }; const selected = { ...common, ...vipTiers[vipLevel] };
return { ...selected, productId: paymentProductId(selected.productId) };
} }
export default async function () { return { code: 0, msg: "internal module" }; } export default async function () { return { code: 0, msg: "internal module" }; }