更新.gitignore以排除部署配置文件,删除不再使用的一键部署脚本,优化小程序部署流程,增强文档说明。

This commit is contained in:
2026-01-31 17:39:21 +08:00
parent ceac5b73ff
commit 70497d3047
45 changed files with 9346 additions and 272 deletions

View File

@@ -1,9 +1,11 @@
/**
* 后台提现管理API
* 获取所有提现记录,处理提现审批
* 批准时如已配置微信转账则调用「商家转账到零钱」,否则仅更新为成功(需线下打款)
*/
import { NextResponse } from 'next/server'
import { query } from '@/lib/db'
import { createTransfer } from '@/lib/wechat-transfer'
// 获取所有提现记录
export async function GET(request: Request) {
@@ -112,24 +114,47 @@ export async function PUT(request: Request) {
}
if (action === 'approve') {
// 批准提现 - 更新状态为成功
const openid = withdrawal.wechat_openid || ''
const amountFen = Math.round(parseFloat(withdrawal.amount) * 100)
if (openid && amountFen > 0) {
const result = await createTransfer({
openid,
amountFen,
outDetailNo: id,
transferRemark: 'Soul创业派对-提现',
})
if (result.success) {
await query(`
UPDATE withdrawals
SET status = 'processing', transaction_id = ?
WHERE id = ?
`, [result.batchId || result.outBatchNo || '', id])
return NextResponse.json({
success: true,
message: '已发起微信转账,等待到账后自动更新状态',
batchId: result.batchId,
})
}
return NextResponse.json({
success: false,
error: result.errorMessage || '微信转账发起失败',
}, { status: 400 })
}
// 无 openid 或金额为 0仅标记为成功线下打款
await query(`
UPDATE withdrawals
SET status = 'success', processed_at = NOW(), transaction_id = ?
WHERE id = ?
`, [`manual_${Date.now()}`, id])
// 更新用户已提现金额
await query(`
UPDATE users
SET withdrawn_earnings = withdrawn_earnings + ?,
pending_earnings = pending_earnings - ?
WHERE id = ?
`, [withdrawal.amount, withdrawal.amount, withdrawal.user_id])
return NextResponse.json({
success: true,
message: '提现已批准'
message: '提现已批准(线下打款)',
})
} else if (action === 'reject') {