|
@@ -25,7 +25,7 @@ class AddAccount extends API {
|
|
|
...BaseStdResponse.ACCESS_DENIED
|
|
...BaseStdResponse.ACCESS_DENIED
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- let countSql = 'SELECT create_user FROM lepao_account WHERE student_num = ?'
|
|
|
|
|
|
|
+ let countSql = 'SELECT id, create_user FROM lepao_account WHERE student_num = ?'
|
|
|
let countRows = await db.query(countSql, [student_num])
|
|
let countRows = await db.query(countSql, [student_num])
|
|
|
|
|
|
|
|
if (!countRows)
|
|
if (!countRows)
|
|
@@ -33,7 +33,7 @@ class AddAccount extends API {
|
|
|
|
|
|
|
|
// 判断是否重复注册
|
|
// 判断是否重复注册
|
|
|
if (!id) {
|
|
if (!id) {
|
|
|
- if (countRows.length !== 0) {
|
|
|
|
|
|
|
+ if (countRows.length !== 0 && countRows[0].create_user != null) {
|
|
|
if (countRows[0].create_user !== uuid)
|
|
if (countRows[0].create_user !== uuid)
|
|
|
return res.json({ ...BaseStdResponse.ERR, msg: '该乐跑账号已被其他用户绑定,请联系客服解绑' })
|
|
return res.json({ ...BaseStdResponse.ERR, msg: '该乐跑账号已被其他用户绑定,请联系客服解绑' })
|
|
|
return res.json({ ...BaseStdResponse.ERR, msg: '该乐跑账号已添加' })
|
|
return res.json({ ...BaseStdResponse.ERR, msg: '该乐跑账号已添加' })
|
|
@@ -48,39 +48,22 @@ class AddAccount extends API {
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 判断用户是否用了会员权益
|
|
|
|
|
- // let userSql = 'SELECT vip FROM users WHERE uuid = ?'
|
|
|
|
|
- // let userData = await db.query(userSql, [uuid])
|
|
|
|
|
- // if (!userData || userData.length !== 1)
|
|
|
|
|
- // return res.json({ ...BaseStdResponse.ERR, msg: '添加乐跑账号失败!数据库错误' })
|
|
|
|
|
-
|
|
|
|
|
- // if (userData[0].vip !== 1) {
|
|
|
|
|
- // 限制账号个数
|
|
|
|
|
- // let numSql = 'SELECT COUNT(*) AS num FROM lepao_account WHERE create_user = ?'
|
|
|
|
|
- // let numRows = await db.query(numSql, [uuid])
|
|
|
|
|
- // if(!numRows)
|
|
|
|
|
- // return res.json({ ...BaseStdResponse.ERR, msg: '添加乐跑账号失败!数据库错误' })
|
|
|
|
|
- // if(numRows[0].num >= 6)
|
|
|
|
|
- // return res.json({...BaseStdResponse.NOTVIP, msg: '非VIP用户最多只能添加6个乐跑账号,请先开通VIP'})
|
|
|
|
|
-
|
|
|
|
|
- // if(min_distance != 2.00 || max_distance != 4.00)
|
|
|
|
|
- // return res.json({ ...BaseStdResponse.NOTVIP, msg: '仅VIP用户可设置跑步距离区间' })
|
|
|
|
|
-
|
|
|
|
|
- // 限制跑区
|
|
|
|
|
- // if (area != '')
|
|
|
|
|
- // return res.json({ ...BaseStdResponse.NOTVIP, msg: '仅VIP用户可指定跑区' })
|
|
|
|
|
- // }
|
|
|
|
|
-
|
|
|
|
|
const time = new Date().getTime()
|
|
const time = new Date().getTime()
|
|
|
|
|
|
|
|
let sql, r
|
|
let sql, r
|
|
|
|
|
|
|
|
if (!id) {
|
|
if (!id) {
|
|
|
- sql = 'INSERT INTO lepao_account (student_num, email, area, auto_time, auto_run, create_user, create_time, notes) VALUES (?, ?, ?, ?, ?, ?, ?, ?)'
|
|
|
|
|
- r = await db.query(sql, [student_num, email, area, auto_time, auto_run, uuid, time, notes ?? ''])
|
|
|
|
|
|
|
+ if (countRows.length !== 0) {
|
|
|
|
|
+ sql = 'UPDATE lepao_account SET create_user = ?, email = ?, area = ?, auto_time = ?, auto_run = ?, create_time = ?, notes = ? WHERE id = ?'
|
|
|
|
|
+ r = await db.query(sql, [uuid, email, area, auto_time, auto_run, time, notes ?? '', countRows[0].id])
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ sql = 'INSERT INTO lepao_account (student_num, email, area, auto_time, auto_run, create_user, create_time, notes) VALUES (?, ?, ?, ?, ?, ?, ?, ?)'
|
|
|
|
|
+ r = await db.query(sql, [student_num, email, area, auto_time, auto_run, uuid, time, notes ?? ''])
|
|
|
|
|
+ }
|
|
|
} else {
|
|
} else {
|
|
|
- sql = 'UPDATE lepao_account SET student_num = ?, email = ?, area = ?, auto_time = ?, auto_run = ?, update_time = ?, notes = ? WHERE id = ?'
|
|
|
|
|
- r = await db.query(sql, [student_num, email, area, auto_time, auto_run, time, notes ?? '', id])
|
|
|
|
|
|
|
+ sql = 'UPDATE lepao_account SET student_num = ?, email = ?, area = ?, auto_time = ?, auto_run = ?, notes = ? WHERE id = ?'
|
|
|
|
|
+ r = await db.query(sql, [student_num, email, area, auto_time, auto_run, notes ?? '', id])
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
try {
|