活动:添加任务统计

This commit is contained in:
qiaoxin
2021-05-29 15:49:09 +08:00
parent 6aaaa391f2
commit 1c8e06cefc
4 changed files with 21 additions and 7 deletions

View File

@@ -302,6 +302,7 @@ export class PvpHandler {
await checkTaskInPvpEnd(roleId, sid, funcs, isSuccess, heroScores);
if (isSuccess) {
await checkActivityTask(serverId, sid, funcs, roleId, TASK_TYPE.PVP_WIN, 1)
await checkActivityTask(serverId, sid, funcs, roleId, TASK_TYPE.PVP_WIN_SERIES, 1)
}

View File

@@ -69,8 +69,8 @@ export default class Activity_Growth extends BaseModel {
}
//查询第几天某个的活动数据
public static async findDataByCellIndex(serverId: number, activityId: number, roleId: string, dayIndex: number, cellIndex: number, lean = true) {
let result: ActivityGrowthModelType[] = await ActivityGrowthModel.find({ serverId, roleId, activityId, dayIndex, cellIndex }).lean(lean);
public static async findDataByCellIndex(serverId: number, activityId: number, roleId: string, dayIndex: number, cellIndex: number, type: number,) {
let result: ActivityGrowthModelType = await ActivityGrowthModel.findOne({ serverId, roleId, activityId, dayIndex, cellIndex, type }).lean(true);
return result;
}

View File

@@ -67,8 +67,8 @@ export default class Activity_Thirty_Days extends BaseModel {
}
//查询第*页的某个的活动数据
public static async findDataByCellIndex(serverId: number, activityId: number, roleId: string, pageIndex: number, cellIndex: number, lean = true) {
let result: ActivityThirtyDaysModelType[] = await ActivityThirtyDaysModel.find({ serverId, roleId, activityId, pageIndex, cellIndex }).lean(lean);
public static async findDataByCellIndex(serverId: number, activityId: number, roleId: string, pageIndex: number, cellIndex: number, type: number,) {
let result: ActivityThirtyDaysModelType = await ActivityThirtyDaysModel.findOne({ serverId, roleId, activityId, pageIndex, cellIndex, type }).lean(true);
return result;
}

View File

@@ -486,6 +486,7 @@ function checkRecResult(rec: UserTaskRecType, id: number) {
*
*/
export async function accomplishTask(serverId: number, roleId: string, taskType: TASK_TYPE, count: number, parma?: any) {
console.log('accomplishTask', roleId, taskType, count, JSON.stringify(parma))
let pushMessage = [];
let { activityGroupId } = await ServerlistModel.findByServerId(serverId);
//七天乐-成长活动统计
@@ -494,7 +495,7 @@ export async function accomplishTask(serverId: number, roleId: string, taskType:
let growthActivity = new GrowthData(activity);
let taskArray = growthActivity.findTaskByType(taskType);
for (let task of taskArray) {
let taskRecord = await ActivityDailyChallengesModel.findDataByCellIndex(serverId, growthActivity.activityId, roleId, task.dayIndex, task.cellIndex, task.taskType)
let taskRecord = await ActivityGrowthModel.findDataByCellIndex(serverId, growthActivity.activityId, roleId, task.dayIndex, task.cellIndex, task.taskType)
let recordData = taskRecord && taskRecord.data ? JSON.parse(taskRecord.data) : null;
let { addCount, record } = isComplete(roleId, task.taskType, task.taskParam, count, parma, recordData);
if (addCount) {
@@ -553,7 +554,7 @@ export async function accomplishTask(serverId: number, roleId: string, taskType:
thirtyDaysActivity.setPlayerRecords(playerRecords);
let taskArray = thirtyDaysActivity.findUncompleteTaskByType(taskType);
for (let task of taskArray) {
let taskRecord = await ActivityDailyChallengesModel.findDataByCellIndex(serverId, thirtyDaysActivity.activityId, roleId, task.dayIndex, task.cellIndex, task.taskType)
let taskRecord = await ActivityThirtyDaysModel.findDataByCellIndex(serverId, thirtyDaysActivity.activityId, roleId, task.dayIndex, task.cellIndex, task.taskType)
let recordData = taskRecord && taskRecord.data ? JSON.parse(taskRecord.data) : null
let { addCount, record } = isComplete(roleId, task.taskType, task.taskParam, count, parma, recordData);
if (addCount) {
@@ -751,10 +752,18 @@ export function isComplete(roleId: string, taskType: TASK_TYPE, taskParam: strin
}
} else {
record[hid] = count;
if (count >= param[1]) {
addCount = count;
break;
}
}
} else {
record = {};
record[hid] = count;
if (count >= param[1]) {
addCount = count;
break;
}
}
break;
}
@@ -780,7 +789,11 @@ export function isComplete(roleId: string, taskType: TASK_TYPE, taskParam: strin
addCount = count;
break;
}
case TASK_TYPE.PVP_WIN:
{
addCount = count;
break;
}
default:
addCount = 0;
break;