任务:修改taskType

This commit is contained in:
陆莹
2022-03-18 20:50:11 +08:00
parent 37d2e6cfa7
commit 1c3d1c209c
24 changed files with 821 additions and 2102 deletions

View File

@@ -40,45 +40,26 @@ export default class Activity_Refresh_Task extends BaseModel {
// 更新任务
public static async checkAndUpdateTask(serverId: number, activityId: number, roleId: string, roundIndex: number, pageIndex: number, id: number, param: UpdateTaskParam) {
let canSet = true;
if(param.record || param.max || param.min) {
let rec = await this.findDataById(serverId, activityId, roleId, roundIndex, pageIndex, id);
if(rec) {
if(param.record && rec.records.indexOf(param.record) != -1) {
canSet = false;
} else if (param.max && rec.totalCount >= param.max) {
canSet = false;
} else if (param.min && rec.totalCount <= param.min) {
canSet = false;
}
}
}
if(canSet) {
return await this.setOrIncTask(serverId, activityId, roleId, roundIndex, pageIndex, id, param);
}
}
public static async setOrIncTask(serverId: number, activityId: number, roleId: string, roundIndex: number, pageIndex: number, id: number, param: UpdateTaskParam) {
if(param.set) {
return await this.setTaskCount(serverId, activityId, roleId, roundIndex, pageIndex, id, param.set, param.record);
return await this.setTaskCount(serverId, activityId, roleId, roundIndex, pageIndex, id, param.set, param.records);
} else if (param.inc) {
return await this.addTaskCount(serverId, activityId, roleId, roundIndex, pageIndex, id, param.inc, param.record);
return await this.addTaskCount(serverId, activityId, roleId, roundIndex, pageIndex, id, param.inc, param.records);
}
}
//根据活动统计完成任务次数
public static async setTaskCount(serverId: number, activityId: number, roleId: string, roundIndex: number, pageIndex: number, id: number, count: number, record?: string) {
public static async setTaskCount(serverId: number, activityId: number, roleId: string, roundIndex: number, pageIndex: number, id: number, count: number, records?: string[]) {
let result: ActivityRefreshTaskModelType = await ActivityRefreshTaskModel.findOneAndUpdate({ serverId, roleId, activityId, roundIndex, pageIndex, id },
{ $set: { totalCount: count }, $setOnInsert: { records: record||'' } }, { upsert: true, new: true }).lean();
{ $set: { totalCount: count, records: records||[] }}, { upsert: true, new: true }).lean();
return result;
}
//根据活动统计完成任务次数
public static async addTaskCount(serverId: number, activityId: number, roleId: string, roundIndex: number, pageIndex: number, id: number, count: number, record?: string) {
public static async addTaskCount(serverId: number, activityId: number, roleId: string, roundIndex: number, pageIndex: number, id: number, count: number, records?: string[]) {
let result: ActivityRefreshTaskModelType = await ActivityRefreshTaskModel.findOneAndUpdate({ serverId, roleId, activityId, roundIndex, pageIndex, id },
{ $inc: { totalCount: count }, $setOnInsert: { records: record||'' } }, { upsert: true, new: true }).lean();
{ $inc: { totalCount: count }, $set: { records: records||[] } }, { upsert: true, new: true }).lean();
return result;
}