更新支付和推荐系统逻辑,新增根据推荐配置计算支付金额的功能,确保用户享受优惠。调整绑定推荐关系的有效期读取方式,支持从配置中获取。优化提现流程,增加最低提现金额的配置读取,提升系统灵活性和用户体验。同时,更新管理界面中的支付设置链接,确保一致性。
This commit is contained in:
@@ -12,8 +12,8 @@
|
||||
import { NextRequest, NextResponse } from 'next/server'
|
||||
import { query, getConfig } from '@/lib/db'
|
||||
|
||||
// 绑定有效期(天)
|
||||
const BINDING_DAYS = 30
|
||||
// 绑定有效期(天)- 默认值,优先从配置读取
|
||||
const DEFAULT_BINDING_DAYS = 30
|
||||
|
||||
/**
|
||||
* POST - 绑定推荐关系(支持抢夺机制)
|
||||
@@ -32,6 +32,17 @@ export async function POST(request: NextRequest) {
|
||||
}, { status: 400 })
|
||||
}
|
||||
|
||||
// 获取绑定天数配置
|
||||
let bindingDays = DEFAULT_BINDING_DAYS
|
||||
try {
|
||||
const config = await getConfig('referral_config')
|
||||
if (config?.bindingDays) {
|
||||
bindingDays = Number(config.bindingDays)
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('[Referral Bind] 读取配置失败,使用默认值', DEFAULT_BINDING_DAYS)
|
||||
}
|
||||
|
||||
// 查找推荐人
|
||||
const referrers = await query(
|
||||
'SELECT id, nickname, referral_code FROM users WHERE referral_code = ?',
|
||||
@@ -111,9 +122,9 @@ export async function POST(request: NextRequest) {
|
||||
}
|
||||
}
|
||||
|
||||
// 计算新的过期时间(30天)
|
||||
// 计算新的过期时间(从配置读取天数)
|
||||
const expiryDate = new Date()
|
||||
expiryDate.setDate(expiryDate.getDate() + BINDING_DAYS)
|
||||
expiryDate.setDate(expiryDate.getDate() + bindingDays)
|
||||
|
||||
// 创建或更新绑定记录
|
||||
const bindingId = 'bind_' + Date.now().toString(36) + Math.random().toString(36).substr(2, 6)
|
||||
|
||||
Reference in New Issue
Block a user