更新支付和推荐系统逻辑,新增根据推荐配置计算支付金额的功能,确保用户享受优惠。调整绑定推荐关系的有效期读取方式,支持从配置中获取。优化提现流程,增加最低提现金额的配置读取,提升系统灵活性和用户体验。同时,更新管理界面中的支付设置链接,确保一致性。
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
import { NextRequest, NextResponse } from 'next/server'
|
||||
import { query } from '@/lib/db'
|
||||
import { query, getConfig } from '@/lib/db'
|
||||
|
||||
// 确保提现表存在
|
||||
async function ensureWithdrawalsTable() {
|
||||
@@ -41,6 +41,25 @@ export async function POST(request: NextRequest) {
|
||||
return NextResponse.json({ success: false, message: '提现金额无效' }, { status: 400 })
|
||||
}
|
||||
|
||||
// 读取最低提现门槛
|
||||
let minWithdrawAmount = 10 // 默认值
|
||||
try {
|
||||
const config = await getConfig('referral_config')
|
||||
if (config?.minWithdrawAmount) {
|
||||
minWithdrawAmount = Number(config.minWithdrawAmount)
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('[Withdraw] 读取配置失败,使用默认值 10 元')
|
||||
}
|
||||
|
||||
// 检查最低提现门槛
|
||||
if (amount < minWithdrawAmount) {
|
||||
return NextResponse.json({
|
||||
success: false,
|
||||
message: `最低提现金额为 ¥${minWithdrawAmount},当前 ¥${amount}`
|
||||
}, { status: 400 })
|
||||
}
|
||||
|
||||
// 确保表存在
|
||||
await ensureWithdrawalsTable()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user