|
|
@@ -150,6 +150,17 @@ class Worker {
|
|
|
|
|
|
async syncRunCount(req, ctx) {
|
|
|
try {
|
|
|
+ const sid = req?.student_id || req?.account
|
|
|
+ if (
|
|
|
+ req?.uid == null ||
|
|
|
+ req?.token == null ||
|
|
|
+ String(req.token).trim() === '' ||
|
|
|
+ req?.school_id == null ||
|
|
|
+ !sid
|
|
|
+ ) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
const recordData = await this.handlers['lepao.getRecord'](req, ctx)
|
|
|
const data = recordData?.data
|
|
|
if (!data) return
|
|
|
@@ -361,6 +372,13 @@ class Worker {
|
|
|
|
|
|
userData = await this.handlers['lepao.getUserData'](req, ctx)
|
|
|
|
|
|
+ // 立刻合并账号凭证,保证后续任意 throw 时 finally 里 syncRunCount 不会用空 token 调 getRecord
|
|
|
+ req = {
|
|
|
+ ...req,
|
|
|
+ ...userData,
|
|
|
+ student_id: req.account
|
|
|
+ }
|
|
|
+
|
|
|
// 进入乐跑进程后写入进行中缓存
|
|
|
const progressKey = `lepaoProgress:${req.account}`
|
|
|
const inProgress = await Redis.get(progressKey)
|
|
|
@@ -383,9 +401,7 @@ class Worker {
|
|
|
|
|
|
req = {
|
|
|
...req,
|
|
|
- ...userData,
|
|
|
- run_end_time,
|
|
|
- student_id: req.account
|
|
|
+ run_end_time
|
|
|
}
|
|
|
|
|
|
// 1.5️⃣ 乐跑开始前扣减次数(失败会返还,且有幂等保护)
|