更新服务器信息为新的 IP 地址,调整相关文档和代码中的默认配置,确保部署和连接的一致性。同时,优化订单管理界面,增强商品信息的格式化逻辑,提升用户体验。
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
* 用户绑定关系API
|
||||
* 获取指定用户的所有绑定用户列表
|
||||
*
|
||||
* 优先从referral_bindings表查询,同时兼容users表的referred_by字段
|
||||
* 从 referral_bindings 表查询(已弃用 users.referred_by)
|
||||
*/
|
||||
import { NextResponse } from 'next/server'
|
||||
import { query } from '@/lib/db'
|
||||
@@ -59,25 +59,8 @@ export async function GET(request: Request) {
|
||||
referrals = bindingsReferrals
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('[Referrals] referral_bindings表查询失败,使用users表')
|
||||
}
|
||||
|
||||
// 2. 如果referral_bindings表没有数据,再从users表查询
|
||||
if (referrals.length === 0 && code) {
|
||||
referrals = await query(`
|
||||
SELECT
|
||||
id, nickname, avatar, phone, open_id,
|
||||
has_full_book, purchased_sections,
|
||||
created_at, updated_at,
|
||||
NULL as binding_status,
|
||||
NULL as binding_date,
|
||||
NULL as expiry_date,
|
||||
NULL as days_remaining,
|
||||
NULL as commission_amount
|
||||
FROM users
|
||||
WHERE referred_by = ?
|
||||
ORDER BY created_at DESC
|
||||
`, [code]) as any[]
|
||||
console.log('[Referrals] referral_bindings表查询失败:', e)
|
||||
// 注意:已弃用 users.referred_by,只使用 referral_bindings
|
||||
}
|
||||
|
||||
// 统计信息
|
||||
|
||||
@@ -128,13 +128,13 @@ export async function POST(request: NextRequest) {
|
||||
const userId = generateUserId()
|
||||
const referralCode = generateReferralCode(openId || phone || userId)
|
||||
|
||||
// 创建用户
|
||||
// 创建用户(注意:不再使用 referred_by 字段)
|
||||
await query(`
|
||||
INSERT INTO users (
|
||||
id, open_id, phone, nickname, password, wechat_id, avatar,
|
||||
referral_code, referred_by, has_full_book, is_admin,
|
||||
referral_code, has_full_book, is_admin,
|
||||
earnings, pending_earnings, referral_count
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, FALSE, ?, 0, 0, 0)
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, FALSE, ?, 0, 0, 0)
|
||||
`, [
|
||||
userId,
|
||||
openId || null,
|
||||
@@ -144,7 +144,6 @@ export async function POST(request: NextRequest) {
|
||||
wechatId || null,
|
||||
avatar || null,
|
||||
referralCode,
|
||||
referredBy || null,
|
||||
is_admin || false
|
||||
])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user