更新服务器信息为新的 IP 地址,调整相关文档和代码中的默认配置,确保部署和连接的一致性。同时,优化订单管理界面,增强商品信息的格式化逻辑,提升用户体验。
This commit is contained in:
@@ -60,26 +60,18 @@ export async function POST(req: NextRequest) {
|
||||
const userReferralCode = generateInviteCode(openid)
|
||||
const nickname = '用户' + openid.substr(-4)
|
||||
|
||||
// 处理推荐绑定
|
||||
let referredBy = null
|
||||
if (referralCode) {
|
||||
const referrers = await query('SELECT id FROM users WHERE referral_code = ?', [referralCode]) as any[]
|
||||
if (referrers.length > 0) {
|
||||
referredBy = referrers[0].id
|
||||
// 更新推荐人的推广数量
|
||||
await query('UPDATE users SET referral_count = referral_count + 1 WHERE id = ?', [referredBy])
|
||||
}
|
||||
}
|
||||
// 注意:推荐绑定逻辑已移至 /api/referral/bind,这里只创建用户
|
||||
// 如果有 referralCode,会在前端调用 /api/referral/bind 建立绑定关系
|
||||
|
||||
await query(`
|
||||
INSERT INTO users (
|
||||
id, open_id, session_key, nickname, avatar, referral_code, referred_by,
|
||||
id, open_id, session_key, nickname, avatar, referral_code,
|
||||
has_full_book, purchased_sections, earnings, pending_earnings, referral_count
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, FALSE, '[]', 0, 0, 0)
|
||||
) VALUES (?, ?, ?, ?, ?, ?, FALSE, '[]', 0, 0, 0)
|
||||
`, [
|
||||
userId, openid, session_key, nickname,
|
||||
'https://picsum.photos/200/200?random=' + openid.substr(-2),
|
||||
userReferralCode, referredBy
|
||||
userReferralCode
|
||||
])
|
||||
|
||||
// 获取新创建的用户
|
||||
@@ -115,7 +107,6 @@ export async function POST(req: NextRequest) {
|
||||
phone: user.phone,
|
||||
wechatId: user.wechat_id,
|
||||
referralCode: user.referral_code,
|
||||
referredBy: user.referred_by,
|
||||
hasFullBook: user.has_full_book || false,
|
||||
purchasedSections: typeof user.purchased_sections === 'string'
|
||||
? JSON.parse(user.purchased_sections || '[]')
|
||||
|
||||
Reference in New Issue
Block a user