订单详情

This commit is contained in:
ray
2026-05-07 10:08:56 +08:00
parent c4e7f8dd58
commit 5355d8b7d2
3 changed files with 10 additions and 1 deletions

View File

@@ -22,6 +22,7 @@ ALIYUN_APS_DB_PASSWORD=
ALIYUN_APS_DB_NAME=
ALIYUN_APS_DB_CHARSET=utf8mb4
ALIYUN_APS_DB_CONNECTION_LIMIT=5
ALIYUN_APS_DB_CONNECT_TIMEOUT=20000
ALIYUN_APS_SMTP_HOST=smtp.163.com
ALIYUN_APS_SMTP_PORT=465
ALIYUN_APS_SMTP_SECURE=true

View File

@@ -58,6 +58,7 @@ export const config = {
database: process.env.ALIYUN_APS_DB_NAME || '',
charset: process.env.ALIYUN_APS_DB_CHARSET || 'utf8mb4',
connectionLimit: Math.max(1, Number.parseInt(process.env.ALIYUN_APS_DB_CONNECTION_LIMIT || '5', 10) || 5),
connectTimeout: Math.max(1000, Number.parseInt(process.env.ALIYUN_APS_DB_CONNECT_TIMEOUT || '20000', 10) || 20000),
},
};

View File

@@ -2,6 +2,7 @@ import mysql from 'mysql2/promise';
import { config } from './config.js';
let pool = null;
let customerMapCache = null;
const MESSAGE_TABLE_DDL = `
CREATE TABLE IF NOT EXISTS aliyun_aps_messages (
@@ -52,6 +53,7 @@ function getPool() {
database: config.db.database,
charset: config.db.charset,
connectionLimit: config.db.connectionLimit,
connectTimeout: config.db.connectTimeout,
waitForConnections: true,
});
return pool;
@@ -130,6 +132,9 @@ function safeDateTime(value) {
}
async function getCustomerMap() {
if (customerMapCache) {
return customerMapCache;
}
const [rows] = await getPool().query('SELECT account_id, login_name FROM aps_customer');
const map = new Map();
for (const row of rows) {
@@ -141,7 +146,8 @@ async function getCustomerMap() {
map.set(loginName, accountId);
map.set(loginName.replace(/\s+/g, ''), accountId);
}
return map;
customerMapCache = map;
return customerMapCache;
}
function resolveCustomerAccountId(customerMap, customerAccount) {
@@ -186,6 +192,7 @@ export async function closeDbPool() {
}
await pool.end();
pool = null;
customerMapCache = null;
}
export async function ensureMessagesTable() {