活动:寻宝骑兵活动添加推送任务

This commit is contained in:
qiaoxin
2021-06-08 21:29:09 +08:00
parent 63845d09c7
commit f64bd7bdd2
4 changed files with 102 additions and 0 deletions

View File

@@ -22,6 +22,9 @@ import { ActivityGrowthFundModel, ActivityGrowthFundModelType } from '../db/Acti
import { ActivityBuyRecordsModel } from '../db/ActivityBuyRecords';
import { PopUpShopData } from '../domain/activityField/popUpShopField';
import { ActivityPopUpShopModel } from '../db/ActivityPopUpShop';
import { ServerTempModel, ServerTempModelType } from '../db/ServerTemp';
import { TreasureHuntData } from '../domain/activityField/treasureHuntField';
import { ActivityTreasureHuntTaskModel, ActivityTreasureHuntTaskModelType } from '../db/ActivityTreasureHuntTask';
import { ActivityPopUpShopRecordModel, ActivityPopUpShopRecordModelType } from '../db/ActivityPopUpShopRecord';
import { SevenDaysData } from '../domain/activityField/sevenDaysField';
import moment = require("moment");
@@ -642,6 +645,44 @@ export async function accomplishTask(serverId: number, roleId: string, taskType:
}
}
//寻宝骑兵活动任务
let tempData: ServerTempModelType = await ServerTempModel.findData(serverId);
if (tempData) {
let huntActivityId = tempData.huntActivityId;
let huntBeginTime = tempData.huntBeginTime;
let huntEndTime = tempData.huntEndTime;
let huntRoundIndex = tempData.huntRoundIndex;
let activity = await ActivityModel.findActivity(tempData.huntActivityId);
let playerData = new TreasureHuntData(activity);
playerData.beginTime = moment(huntBeginTime).valueOf();
playerData.endTime = moment(huntEndTime).valueOf();
playerData.roundIndex = huntRoundIndex;
let taskArray = playerData.tasks.findItemByTaskType(taskType);
for (let task of taskArray) {
let taskRecord: ActivityTreasureHuntTaskModelType = await ActivityTreasureHuntTaskModel.findDataByCellIndex(serverId, activity.activityId, roleId, huntRoundIndex, task.cellIndex);
if (!taskRecord || !taskRecord.isPush) {
let recordData = taskRecord && taskRecord.data ? JSON.parse(taskRecord.data) : null
let { addCount, record } = isComplete(roleId, task.taskType, task.taskParam, count, parma, recordData);
if (addCount) {
let playerRecord = await ActivityTreasureHuntTaskModel.addTreasureHuntTaskCount(serverId, activity.activityId, roleId, huntRoundIndex, task.cellIndex, addCount);
//推送
if (task.condition <= playerRecord.totalCount) {//已经完成
playerRecord = await ActivityTreasureHuntTaskModel.pushMessage(serverId, activity.activityId, roleId, huntRoundIndex, task.cellIndex);
task.totalCount = playerRecord.totalCount;
pushMessage = pushMessage.concat(Object.assign(task, { activityId: activity.activityId }));
} else {//没有完成
task.totalCount = playerRecord.totalCount;
pushMessage = pushMessage.concat(Object.assign(task, { activityId: activity.activityId }));
}
}
if (record) {
await ActivityTreasureHuntTaskModel.addTreasureHuntTaskRecord(serverId, activity.activityId, roleId, huntRoundIndex, task.cellIndex, JSON.stringify(record));
}
}
}
}
//30天任务统计
if (taskType === TASK_TYPE.HERO_QUALITY_STAR_UP ||
taskType === TASK_TYPE.HERO_QUALITY_TO_QUALITY_COUNT ||