任务:修改taskType
This commit is contained in:
@@ -37,44 +37,25 @@ export default class Activity_Daily_Challenges extends BaseModel {
|
||||
}
|
||||
|
||||
// 更新任务
|
||||
public static async checkAndUpdateTask(serverId: number, activityId: number, roleId: string, dayIndex: number, cellIndex: number, param: UpdateTaskParam) {
|
||||
let canSet = true;
|
||||
if(param.record || param.max || param.min) {
|
||||
let rec = await this.findDataByCellIndex(serverId, activityId, roleId, dayIndex, cellIndex);
|
||||
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, dayIndex, cellIndex, param);
|
||||
}
|
||||
}
|
||||
|
||||
public static async setOrIncTask(serverId: number, activityId: number, roleId: string, dayIndex: number, cellIndex: number, param: UpdateTaskParam) {
|
||||
if(param.set) {
|
||||
return await this.setTaskCount(serverId, activityId, roleId, dayIndex, cellIndex, param.set, param.record);
|
||||
return await this.setTaskCount(serverId, activityId, roleId, dayIndex, cellIndex, param.set, param.records);
|
||||
} else if (param.inc) {
|
||||
return await this.addTaskCount(serverId, activityId, roleId, dayIndex, cellIndex, param.inc, param.record);
|
||||
return await this.addTaskCount(serverId, activityId, roleId, dayIndex, cellIndex, param.inc, param.records);
|
||||
}
|
||||
}
|
||||
|
||||
//根据活动统计完成任务次数
|
||||
public static async setTaskCount(serverId: number, activityId: number, roleId: string, dayIndex: number, cellIndex: number, count: number, record?: string) {
|
||||
public static async setTaskCount(serverId: number, activityId: number, roleId: string, dayIndex: number, cellIndex: number, count: number, records?: string[]) {
|
||||
let result: ActivityDailyChallengesModelType = await ActivityDailyChallengesModel.findOneAndUpdate({ serverId, roleId, activityId, dayIndex, cellIndex },
|
||||
{ $set: { totalCount: count }, $addToSet: { records: record||''} }, { upsert: true, new: true }).lean();
|
||||
{ $set: { totalCount: count, records } }, { upsert: true, new: true }).lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
//根据活动统计完成任务次数
|
||||
public static async addTaskCount(serverId: number, activityId: number, roleId: string, dayIndex: number, cellIndex: number, addCount: number, record?: string) {
|
||||
public static async addTaskCount(serverId: number, activityId: number, roleId: string, dayIndex: number, cellIndex: number, addCount: number, records?: string[]) {
|
||||
let result: ActivityDailyChallengesModelType = await ActivityDailyChallengesModel.findOneAndUpdate({ serverId, roleId, activityId, dayIndex, cellIndex },
|
||||
{ $inc: { totalCount: addCount }, $addToSet: { records: record||''} }, { upsert: true, new: true }).lean();
|
||||
{ $inc: { totalCount: addCount }, $set: { records: records||[]} }, { upsert: true, new: true }).lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,45 +36,25 @@ export default class Activity_Growth extends BaseModel {
|
||||
return result;
|
||||
}
|
||||
|
||||
// 更新任务
|
||||
public static async checkAndUpdateTask(serverId: number, activityId: number, roleId: string, dayIndex: number, cellIndex: number, param: UpdateTaskParam) {
|
||||
let canSet = true;
|
||||
if(param.record || param.max || param.min) {
|
||||
let rec = await this.findDataByCellIndex(serverId, activityId, roleId, dayIndex, cellIndex);
|
||||
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, dayIndex, cellIndex, param);
|
||||
}
|
||||
}
|
||||
|
||||
public static async setOrIncTask(serverId: number, activityId: number, roleId: string, dayIndex: number, cellIndex: number, param: UpdateTaskParam) {
|
||||
if(param.set) {
|
||||
return await this.setTaskCount(serverId, activityId, roleId, dayIndex, cellIndex, param.set, param.record);
|
||||
return await this.setTaskCount(serverId, activityId, roleId, dayIndex, cellIndex, param.set, param.records);
|
||||
} else if (param.inc) {
|
||||
return await this.addTaskCount(serverId, activityId, roleId, dayIndex, cellIndex, param.inc, param.record);
|
||||
return await this.addTaskCount(serverId, activityId, roleId, dayIndex, cellIndex, param.inc, param.records);
|
||||
}
|
||||
}
|
||||
|
||||
//根据活动统计完成任务次数
|
||||
public static async setTaskCount(serverId: number, activityId: number, roleId: string, dayIndex: number, cellIndex: number, count: number, record?: string) {
|
||||
public static async setTaskCount(serverId: number, activityId: number, roleId: string, dayIndex: number, cellIndex: number, count: number, records?: string[]) {
|
||||
let result: ActivityGrowthModelType = await ActivityGrowthModel.findOneAndUpdate({ serverId, roleId, activityId, dayIndex, cellIndex },
|
||||
{ $set: { totalCount: count }, $addToSet: { 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, dayIndex: number, cellIndex: number, addCount: number, record?: string) {
|
||||
public static async addTaskCount(serverId: number, activityId: number, roleId: string, dayIndex: number, cellIndex: number, addCount: number, records?: string[]) {
|
||||
let result: ActivityGrowthModelType = await ActivityGrowthModel.findOneAndUpdate({ serverId, roleId, activityId, dayIndex, cellIndex },
|
||||
{ $inc: { totalCount: addCount }, $addToSet: { records: record||'' } }, { upsert: true, new: true }).lean();
|
||||
{ $inc: { totalCount: addCount }, $set: { records: records||[] } }, { upsert: true, new: true }).lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -66,30 +66,11 @@ export default class Activity_Thirty_Days extends BaseModel {
|
||||
|
||||
|
||||
// 更新任务
|
||||
public static async checkAndUpdateTask(serverId: number, activityId: number, roleId: string, pageIndex: number, cellIndex: number, tab: number, param: UpdateTaskParam) {
|
||||
let canSet = true;
|
||||
if(param.record || param.max || param.min) {
|
||||
let rec = await this.findDataByCellIndex(serverId, activityId, roleId, pageIndex, cellIndex, tab);
|
||||
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, pageIndex, cellIndex, tab, param);
|
||||
}
|
||||
}
|
||||
|
||||
public static async setOrIncTask(serverId: number, activityId: number, roleId: string, pageIndex: number, cellIndex: number, tab: number, param: UpdateTaskParam) {
|
||||
if(param.set) {
|
||||
return await this.setTaskCount(serverId, activityId, roleId, pageIndex, cellIndex, tab, param.set, param.record);
|
||||
return await this.setTaskCount(serverId, activityId, roleId, pageIndex, cellIndex, tab, param.set, param.records);
|
||||
} else if (param.inc) {
|
||||
return await this.addTaskCount(serverId, activityId, roleId, pageIndex, cellIndex, tab, param.inc, param.record);
|
||||
return await this.addTaskCount(serverId, activityId, roleId, pageIndex, cellIndex, tab, param.inc, param.records);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,16 +83,16 @@ export default class Activity_Thirty_Days extends BaseModel {
|
||||
}
|
||||
|
||||
//根据活动统计完成任务次数
|
||||
public static async addTaskCount(serverId: number, activityId: number, roleId: string, pageIndex: number, cellIndex: number, tab: number, count: number, record?: string) {
|
||||
public static async addTaskCount(serverId: number, activityId: number, roleId: string, pageIndex: number, cellIndex: number, tab: number, count: number, records?: string[]) {
|
||||
let result: ActivityThirtyDaysModelType = await ActivityThirtyDaysModel.findOneAndUpdate({ serverId, roleId, activityId, pageIndex, cellIndex, tab },
|
||||
{ $inc: { totalCount: count }, $addToSet: { records: record||'' } }, { upsert: true, new: true }).lean();
|
||||
{ $inc: { totalCount: count }, $set: { records: records||[] } }, { upsert: true, new: true }).lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
//根据活动统计完成任务次数
|
||||
public static async setTaskCount(serverId: number, activityId: number, roleId: string, pageIndex: number, cellIndex: number, tab: number, count: number, record?: string) {
|
||||
public static async setTaskCount(serverId: number, activityId: number, roleId: string, pageIndex: number, cellIndex: number, tab: number, count: number, records?: string[]) {
|
||||
let result: ActivityThirtyDaysModelType = await ActivityThirtyDaysModel.findOneAndUpdate({ serverId, roleId, activityId, pageIndex, cellIndex, tab },
|
||||
{ $set: { totalCount: count }, $addToSet: { records: record||'' } }, { upsert: true, new: true }).lean();
|
||||
{ $set: { totalCount: count, records: records||[] } }, { upsert: true, new: true }).lean();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,44 +29,25 @@ export default class Activity_Treasure_Hunt_Task extends ActivityGrowth {
|
||||
}
|
||||
|
||||
// 更新任务
|
||||
public static async checkAndUpdateTask(serverId: number, activityId: number, roleId: string, roundIndex: number, cellIndex: number, param: UpdateTaskParam) {
|
||||
let canSet = true;
|
||||
if(param.record || param.max || param.min) {
|
||||
let rec = await this.findDataByCellIndex(serverId, activityId, roleId, roundIndex, cellIndex);
|
||||
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, cellIndex, param);
|
||||
}
|
||||
}
|
||||
|
||||
public static async setOrIncTask(serverId: number, activityId: number, roleId: string, roundIndex: number, cellIndex: number, param: UpdateTaskParam) {
|
||||
if(param.set) {
|
||||
return await this.setTaskCount(serverId, activityId, roleId, roundIndex, cellIndex, param.set, param.record);
|
||||
return await this.setTaskCount(serverId, activityId, roleId, roundIndex, cellIndex, param.set, param.records);
|
||||
} else if (param.inc) {
|
||||
return await this.addTaskCount(serverId, activityId, roleId, roundIndex, cellIndex, param.inc, param.record);
|
||||
return await this.addTaskCount(serverId, activityId, roleId, roundIndex, cellIndex, param.inc, param.records);
|
||||
}
|
||||
}
|
||||
|
||||
//根据活动统计完成任务次数
|
||||
public static async setTaskCount(serverId: number, activityId: number, roleId: string, roundIndex: number, cellIndex: number, count: number, record?: string) {
|
||||
public static async setTaskCount(serverId: number, activityId: number, roleId: string, roundIndex: number, cellIndex: number, count: number, records?: string[]) {
|
||||
let result: ActivityTreasureHuntTaskModelType = await ActivityTreasureHuntTaskModel.findOneAndUpdate({ serverId, roleId, activityId, roundIndex, cellIndex },
|
||||
{ $set: { totalCount: count }, $addToSet: { 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, cellIndex: number, count: number, record?: string) {
|
||||
public static async addTaskCount(serverId: number, activityId: number, roleId: string, roundIndex: number, cellIndex: number, count: number, records?: string[]) {
|
||||
let result: ActivityTreasureHuntTaskModelType = await ActivityTreasureHuntTaskModel.findOneAndUpdate({ serverId, roleId, activityId, roundIndex, cellIndex },
|
||||
{ $inc: { totalCount: count }, $addToSet: { records: record||'' } }, { upsert: true, new: true }).lean();
|
||||
{ $inc: { totalCount: count }, $set: { records: records||[] } }, { upsert: true, new: true }).lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,51 +47,23 @@ export default class UserTaskRec extends BaseModel {
|
||||
}
|
||||
}
|
||||
|
||||
public static async setTaskRec(roleId: string, type: number, taskType: number, group: string, count: number, record?: string) {
|
||||
public static async setTaskRec(roleId: string, type: number, taskType: number, group: string, count: number, records?: string[]) {
|
||||
let condition = this.getRefreshCondition(type);
|
||||
let rec: UserTaskRecType = await UserTaskRecModel.findOneAndUpdate({ roleId, group, taskType, ...condition }, { $setOnInsert: { code: genCode(8), received: [] }, $set: { count }, $addToSet: { records: record||'' } }, { new: true, upsert: true }).lean();
|
||||
let rec: UserTaskRecType = await UserTaskRecModel.findOneAndUpdate({ roleId, group, taskType, ...condition }, { $setOnInsert: { code: genCode(8), received: [] }, $set: { count, records: records||[] } }, { new: true, upsert: true }).lean();
|
||||
return rec;
|
||||
}
|
||||
|
||||
public static async incTaskRec(roleId: string, type: number, taskType: number, group: string, count: number, record?: string) {
|
||||
public static async incTaskRec(roleId: string, type: number, taskType: number, group: string, count: number, records?: string[]) {
|
||||
let condition = this.getRefreshCondition(type);
|
||||
let rec: UserTaskRecType = await UserTaskRecModel.findOneAndUpdate({ roleId, group, taskType, ...condition }, { $setOnInsert: { code: genCode(8), received: [] }, $inc: { count }, $addToSet: { records: record||'' } }, { new: true, upsert: true }).lean();
|
||||
let rec: UserTaskRecType = await UserTaskRecModel.findOneAndUpdate({ roleId, group, taskType, ...condition }, { $setOnInsert: { code: genCode(8), received: [] }, $inc: { count }, $set: { records: records||[] } }, { new: true, upsert: true }).lean();
|
||||
return rec;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查是否可以更新任务并更新
|
||||
* @param roleId 玩家id
|
||||
* @param type 任务大类型,日常、成就、每日
|
||||
* @param taskType 任务类型
|
||||
* @param group 活动组
|
||||
* @param param 更新参数
|
||||
* @returns
|
||||
*/
|
||||
public static async checkAndUpdateTask(roleId: string, type: TASK_FUN_TYPE, taskType: number, group: string, param: UpdateTaskParam) {
|
||||
let canSet = true;
|
||||
if(param.record || param.max || param.min) {
|
||||
let rec = await this.findByRoleAndGroup(roleId, type, taskType, group);
|
||||
if(rec) {
|
||||
if(param.record && rec.records.indexOf(param.record) != -1) {
|
||||
canSet = false;
|
||||
} else if (param.max && rec.count >= param.max) {
|
||||
canSet = false;
|
||||
} else if (param.min && rec.count <= param.min) {
|
||||
canSet = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(canSet) {
|
||||
return await this.setOrIncTask(roleId, type, taskType, group, param);
|
||||
}
|
||||
}
|
||||
|
||||
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.record);
|
||||
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.record);
|
||||
return await this.incTaskRec(roleId, type, taskType, group, param.inc, param.records);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user