任务:修复任务很多问题

This commit is contained in:
luying
2022-04-29 18:13:02 +08:00
parent c063b2d135
commit b4deba6cb0
4 changed files with 15 additions and 9 deletions

View File

@@ -59,11 +59,20 @@ export default class UserTaskRec extends BaseModel {
return rec;
}
public static async recordTaskRec(roleId: string, type: number, taskType: number, group: string, records?: string[]) {
let condition = this.getRefreshCondition(type);
let rec: UserTaskRecType = await UserTaskRecModel.findOneAndUpdate({ roleId, group, taskType, ...condition }, { $setOnInsert: { code: genCode(8), received: [] }, $set: { records: records||[] } }, { new: true, upsert: true }).lean();
return rec;
}
public static async setOrIncTask(roleId: string, type: number, taskType: number, group: string, param: UpdateTaskParam) {
if(param.set) {
return await this.setTaskRec(roleId, type, taskType, group, param.set, param.records);
} else if (param.inc) {
return await this.incTaskRec(roleId, type, taskType, group, param.inc, param.records);
} else if (param.records) {
return await this.recordTaskRec(roleId, type, taskType, group, param.records);
}
}