Browse Source

✨ feat: 乐跑记录增加uuid

Pchen. 7 months ago
parent
commit
485394b88d
2 changed files with 7 additions and 7 deletions
  1. 2 2
      apis/Lepao/Record/GetLepaoRecords.js
  2. 5 5
      lib/Lepao/Lepao.js

+ 2 - 2
apis/Lepao/Record/GetLepaoRecords.js

@@ -58,7 +58,7 @@ class GetLepaoRecords extends API {
                 ON 
                 ON 
                     r.lepao_account = a.student_num
                     r.lepao_account = a.student_num
                 WHERE 
                 WHERE 
-                    a.create_user = ?
+                    l.create_user = ? OR a.create_user = ?
             `
             `
 
 
         let countSql = `
         let countSql = `
@@ -96,7 +96,7 @@ class GetLepaoRecords extends API {
             ORDER BY id DESC
             ORDER BY id DESC
             LIMIT ? OFFSET ?;
             LIMIT ? OFFSET ?;
         `
         `
-         params.push(String(pagesize), String(offset))
+        params.push(String(pagesize), String(offset))
 
 
         let rows = await db.query(sql, params)
         let rows = await db.query(sql, params)
         let countResult = await db.query(countSql, countParams)
         let countResult = await db.query(countSql, countParams)

+ 5 - 5
lib/Lepao/Lepao.js

@@ -179,7 +179,7 @@ class Lepao {
                     throw new Error(data?.info || '未知错误,请尝试重新登录')
                     throw new Error(data?.info || '未知错误,请尝试重新登录')
                 }
                 }
 
 
-                await this.addRecord(account, data.data, path_id)
+                await this.addRecord(uuid, account, data.data, path_id)
 
 
                 // 获取剩余跑步次数
                 // 获取剩余跑步次数
                 const recordData = await this.getRecord(uid, token, school_id, account)
                 const recordData = await this.getRecord(uid, token, school_id, account)
@@ -213,12 +213,12 @@ class Lepao {
         }
         }
     }
     }
 
 
-    async addRecord(account, result, path_id) {
+    async addRecord(uuid, account, result, path_id) {
         try {
         try {
             const time = Date.now()
             const time = Date.now()
             this.logger.info(`${account}添加乐跑记录,path_id=${path_id}`)
             this.logger.info(`${account}添加乐跑记录,path_id=${path_id}`)
-            const sql = 'INSERT INTO lepao_record (time, lepao_account, result, path_id) VALUES (?, ?, ?, ?)'
-            await db.query(sql, [time, account, result, path_id])
+            const sql = 'INSERT INTO lepao_record (uuid, time, lepao_account, result, path_id) VALUES (?, ?, ?, ?, ?)'
+            await db.query(sql, [uuid, time, account, result, path_id])
             this.logger.info(`${account}添加乐跑记录成功`)
             this.logger.info(`${account}添加乐跑记录成功`)
         } catch (error) {
         } catch (error) {
             this.logger.error(`添加乐跑记录失败: ${error.stack || error.message}`)
             this.logger.error(`添加乐跑记录失败: ${error.stack || error.message}`)
@@ -274,7 +274,7 @@ class Lepao {
             const data = {
             const data = {
                 name: rows[0].name,
                 name: rows[0].name,
                 account,
                 account,
-                reason
+                reason: reason === 'Request failed with status code 503' ? 'RunForge系统维护中,请稍后再试' : reason
             }
             }
 
 
             await EmailTemplate.lepaoFail(rows[0].email, data)
             await EmailTemplate.lepaoFail(rows[0].email, data)