|
@@ -56,13 +56,13 @@ class Lepao {
|
|
|
const reqData = { uid, token, school_id, student_id }
|
|
const reqData = { uid, token, school_id, student_id }
|
|
|
const recordUrl = this.runpy + '/get_record'
|
|
const recordUrl = this.runpy + '/get_record'
|
|
|
const recordRes = await axios.post(recordUrl, reqData)
|
|
const recordRes = await axios.post(recordUrl, reqData)
|
|
|
- const { recordData } = recordRes
|
|
|
|
|
- if (!recordData || recordData.status !== 1 || !recordData.data) {
|
|
|
|
|
|
|
+ const { data } = recordRes
|
|
|
|
|
+ if (!data || data.status !== 1 || !data.data) {
|
|
|
this.logger.info('获取剩余跑步次数失败!')
|
|
this.logger.info('获取剩余跑步次数失败!')
|
|
|
- console.log(recordData)
|
|
|
|
|
|
|
+ console.log(data)
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- return recordRes.data
|
|
|
|
|
|
|
+ return data
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
this.logger.error('获取跑步次数失败!')
|
|
this.logger.error('获取跑步次数失败!')
|
|
|
console.log(error.stack)
|
|
console.log(error.stack)
|
|
@@ -156,27 +156,23 @@ class Lepao {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
await this.addRecord(account, data.data)
|
|
await this.addRecord(account, data.data)
|
|
|
|
|
+
|
|
|
|
|
+ // 获取剩余跑步次数
|
|
|
|
|
+ const recordData = await this.getRecord(uid, token, school_id, account)
|
|
|
|
|
+
|
|
|
|
|
+ let term_num = recordData.term_num || 0
|
|
|
|
|
+ let total_num = recordData.total_num || 0
|
|
|
if (data.data.record_failed_reason === '') {
|
|
if (data.data.record_failed_reason === '') {
|
|
|
- // 获取剩余跑步次数
|
|
|
|
|
- const recordData = await this.getRecord(uid, token, school_id, account)
|
|
|
|
|
-
|
|
|
|
|
- // await this.sendSuccessEmail(account, data.data)
|
|
|
|
|
- let term_num = 0, total_num = 0
|
|
|
|
|
- if (recordData) {
|
|
|
|
|
- term_num = recordData.term_num
|
|
|
|
|
- total_num = recordData.total_num
|
|
|
|
|
- if (!recordRows || recordRows.affectedRows !== 1)
|
|
|
|
|
- this.logger.info('更新乐跑次数失败!')
|
|
|
|
|
- }
|
|
|
|
|
await this.sendSuccessEmail(account, data.data, term_num, total_num)
|
|
await this.sendSuccessEmail(account, data.data, term_num, total_num)
|
|
|
-
|
|
|
|
|
- let recordSql = 'UPDATE lepao_accounts SET term_num = ?, total_num = ? WHERE student_num = ?'
|
|
|
|
|
- let recordRows = await db.query(recordSql, [term_num, total_num, account])
|
|
|
|
|
} else {
|
|
} else {
|
|
|
await this.sendFailEmail(account, data.data.record_failed_reason)
|
|
await this.sendFailEmail(account, data.data.record_failed_reason)
|
|
|
await this.lepaoFail(uuid)
|
|
await this.lepaoFail(uuid)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ let recordSql = 'UPDATE lepao_account SET term_num = ?, total_num = ? WHERE student_num = ?'
|
|
|
|
|
+ let recordRows = await db.query(recordSql, [term_num, total_num, account])
|
|
|
|
|
+ if (!recordRows || recordRows.affectedRows !== 1)
|
|
|
|
|
+ this.logger.info('更新乐跑次数失败!')
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
await this.lepaoFail(uuid)
|
|
await this.lepaoFail(uuid)
|
|
|
throw error
|
|
throw error
|