更新提现和订单管理逻辑,新增用户佣金信息展示,优化提现审批流程以防止超额提现风险。同时,调整提现页面显示用户佣金详情,提升用户体验。重构API以支持新字段,确保数据一致性和准确性。
This commit is contained in:
13
lib/db.ts
13
lib/db.ts
@@ -63,7 +63,10 @@ export async function query(sql: string, params?: any[]) {
|
||||
}
|
||||
try {
|
||||
const [results] = await connection.execute(sql, params)
|
||||
return results
|
||||
// 确保调用方拿到的始终是数组,避免 undefined.length 报错
|
||||
if (Array.isArray(results)) return results
|
||||
if (results != null) return [results]
|
||||
return []
|
||||
} catch (error) {
|
||||
if (isConnectionError(error)) {
|
||||
if (!connectionErrorLogged) {
|
||||
@@ -333,10 +336,10 @@ export async function getConfig(key: string) {
|
||||
const results = await query(
|
||||
'SELECT config_value FROM system_config WHERE config_key = ?',
|
||||
[key]
|
||||
) as any[]
|
||||
|
||||
if (results.length > 0) {
|
||||
return results[0].config_value
|
||||
)
|
||||
const rows = Array.isArray(results) ? results : (results != null ? [results] : [])
|
||||
if (rows != null && rows.length > 0) {
|
||||
return (rows[0] as any)?.config_value ?? null
|
||||
}
|
||||
return null
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user