@@ -0,0 +1,73 @@
|
||||
import { config } from 'dotenv';
|
||||
import { resolve } from 'path';
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
|
||||
config({ path: resolve('.env'), override: true });
|
||||
|
||||
function mockPayEnabled() {
|
||||
return process.env.MOCK_PAY !== 'false';
|
||||
}
|
||||
|
||||
function wechatPayEnabled() {
|
||||
const e = process.env;
|
||||
const appId = e.WX_MINI_APP_ID?.trim() || e.WX_APP_ID?.trim();
|
||||
return (
|
||||
!mockPayEnabled() &&
|
||||
!!(
|
||||
appId &&
|
||||
e.WX_MCH_ID?.trim() &&
|
||||
e.WX_MCH_SERIAL_NO?.trim() &&
|
||||
e.WX_MCH_PRIVATE_KEY?.trim() &&
|
||||
e.WX_API_V3_KEY?.trim()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
console.log('=== .env only ===');
|
||||
console.log('MOCK_PAY:', process.env.MOCK_PAY);
|
||||
console.log('mockPayEnabled:', mockPayEnabled());
|
||||
|
||||
const rows = await prisma.systemConfig.findMany({
|
||||
where: { configKey: { in: ['MOCK_PAY', 'MOCK_SMS', 'MOCK_WECHAT', 'WX_MCH_ID'] } },
|
||||
});
|
||||
console.log('\n=== system_config (DB) ===');
|
||||
for (const r of rows) {
|
||||
console.log(`${r.configKey} = ${r.configKey.includes('KEY') ? '(redacted)' : r.value}`);
|
||||
process.env[r.configKey] = r.value;
|
||||
}
|
||||
|
||||
console.log('\n=== After DB overlay (API startup) ===');
|
||||
console.log('MOCK_PAY:', process.env.MOCK_PAY);
|
||||
console.log('mockPayEnabled:', mockPayEnabled());
|
||||
console.log('wechatPayEnabled:', wechatPayEnabled());
|
||||
|
||||
const orders = await prisma.order.findMany({
|
||||
where: { orderType: 'PROXY' },
|
||||
orderBy: { id: 'desc' },
|
||||
take: 5,
|
||||
select: {
|
||||
id: true,
|
||||
orderNo: true,
|
||||
status: true,
|
||||
payStatus: true,
|
||||
payExternalNo: true,
|
||||
channelSource: true,
|
||||
createdAt: true,
|
||||
},
|
||||
});
|
||||
console.log('\n=== Recent PROXY orders ===');
|
||||
for (const o of orders) {
|
||||
console.log({
|
||||
id: o.id.toString(),
|
||||
orderNo: o.orderNo,
|
||||
status: o.status,
|
||||
payStatus: o.payStatus,
|
||||
payExternalNo: o.payExternalNo,
|
||||
channelSource: o.channelSource,
|
||||
createdAt: o.createdAt.toISOString(),
|
||||
});
|
||||
}
|
||||
|
||||
await prisma.$disconnect();
|
||||
Reference in New Issue
Block a user