活动:任务接口添加serverId接口
This commit is contained in:
@@ -88,7 +88,7 @@ export enum ORDER_STATE {
|
||||
}
|
||||
|
||||
//服务器开服时间
|
||||
export const SERVER_OPEN_TIME = '2021-02-11T20:03:16.637+08:00';
|
||||
export const SERVER_OPEN_TIME = '2021-05-19T20:03:16.637+08:00';
|
||||
//玩家等级大于等于15级才能开启vip签到
|
||||
export const SIGNIN_VIP_OPEN_LIMIT = 15;
|
||||
|
||||
|
||||
+21
-21
@@ -23,39 +23,39 @@ export default class Activity extends BaseModel {
|
||||
data: string; // 活动表中的数据
|
||||
|
||||
//根据活动类型查询开启的活动数据
|
||||
public static async findOpenActivityByType(type: number, date: Date, lean = true) {
|
||||
let result: ActivityModelType[] = await ActivityModel.find({ type, beginTime: { $lte: date }, endTime: { $gte: date } }).lean(lean);
|
||||
public static async findOpenActivityByType(serverId: number, type: number, date: Date, lean = true) {
|
||||
let result: ActivityModelType[] = await ActivityModel.find({ serverId, type, beginTime: { $lte: date }, endTime: { $gte: date } }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//根据活动类型查询活动数据
|
||||
public static async findActivityByType(type: number, lean = true) {
|
||||
let result: ActivityModelType[] = await ActivityModel.find({ type }).lean(lean);
|
||||
public static async findActivityByType(serverId: number, type: number, lean = true) {
|
||||
let result: ActivityModelType[] = await ActivityModel.find({ serverId, type }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//根据活动id查询活动数据
|
||||
public static async findActivity(activityId: number, lean = true) {
|
||||
let result: ActivityModelType = await ActivityModel.findOne({ activityId }).lean(lean);
|
||||
public static async findActivity(serverId: number, activityId: number, lean = true) {
|
||||
let result: ActivityModelType = await ActivityModel.findOne({ serverId, activityId }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//新增活动
|
||||
public static async addActivity(aids: number[], serverId: number, beginTime: Date, endTime: Date, type: number, data: string, lean = true) {
|
||||
let result: ActivityModelType[] = [];
|
||||
for(let activityId of aids) {
|
||||
if(!activityId) activityId = await CounterModel.getNewCounter(COUNTER.ACTIVITY);
|
||||
for (let activityId of aids) {
|
||||
if (!activityId) activityId = await CounterModel.getNewCounter(COUNTER.ACTIVITY);
|
||||
let update = { type, data }
|
||||
if(serverId != undefined) {
|
||||
if (serverId != undefined) {
|
||||
update["serverId"] = serverId;
|
||||
}
|
||||
if(beginTime != undefined) {
|
||||
if (beginTime != undefined) {
|
||||
update["beginTime"] = beginTime;
|
||||
}
|
||||
if(endTime != undefined) {
|
||||
if (endTime != undefined) {
|
||||
update["endTime"] = endTime;
|
||||
}
|
||||
let rec: ActivityModelType = await ActivityModel.findOneAndUpdate({ activityId }, {$set: update},
|
||||
let rec: ActivityModelType = await ActivityModel.findOneAndUpdate({ activityId }, { $set: update },
|
||||
{ new: true, upsert: true }).lean(lean);
|
||||
result.push(rec);
|
||||
}
|
||||
@@ -71,24 +71,24 @@ export default class Activity extends BaseModel {
|
||||
//查询
|
||||
public static async findByCondition(page: number, pageSize: number, type: number = 0, serverId: number = 0, current: boolean = false, activityId: number = 0) {
|
||||
let searchObj = {};
|
||||
if(type != 0) searchObj['type'] = type;
|
||||
if(serverId != 0) searchObj['serverId'] = { $in: [0, serverId] };
|
||||
if(activityId != 0) searchObj['activityId'] = activityId;
|
||||
if(current) {
|
||||
if (type != 0) searchObj['type'] = type;
|
||||
if (serverId != 0) searchObj['serverId'] = { $in: [0, serverId] };
|
||||
if (activityId != 0) searchObj['activityId'] = activityId;
|
||||
if (current) {
|
||||
searchObj['beginTime'] = { $lte: new Date };
|
||||
searchObj['endTime'] = { $gte: new Date };
|
||||
}
|
||||
const result: ActivityModelType[] = await ActivityModel.find(searchObj, { _id: 0 }).limit(pageSize).skip((page - 1) * pageSize).sort({updatedAt: -1}).lean();
|
||||
const result: ActivityModelType[] = await ActivityModel.find(searchObj, { _id: 0 }).limit(pageSize).skip((page - 1) * pageSize).sort({ updatedAt: -1 }).lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
// 获得活动数量
|
||||
public static async countByCondition(type: number = 0, serverId: number = 0, current: boolean = false, activityId: number = 0) {
|
||||
let searchObj = {};
|
||||
if(type != 0) searchObj['type'] = type;
|
||||
if(serverId != 0) searchObj['serverId'] = { $in: [0, serverId] };
|
||||
if(activityId != 0) searchObj['activityId'] = activityId;
|
||||
if(current) {
|
||||
if (type != 0) searchObj['type'] = type;
|
||||
if (serverId != 0) searchObj['serverId'] = { $in: [0, serverId] };
|
||||
if (activityId != 0) searchObj['activityId'] = activityId;
|
||||
if (current) {
|
||||
searchObj['beginTime'] = { $lte: new Date };
|
||||
searchObj['endTime'] = { $gte: new Date };
|
||||
}
|
||||
|
||||
@@ -246,8 +246,8 @@ export async function createHeroes(roleId: string, roleName: string, serverId: n
|
||||
let dicHero = gameData.hero.get(heroInfo.hid);
|
||||
let { quality, initialStars: star, jobid: job, name: hName, initialSkin } = dicHero;
|
||||
|
||||
let info = { roleId, roleName, serverId, quality, star, job, hName, skins: [{id: initialSkin, enable: true}] };
|
||||
let curHero = await HeroModel.createHero(Object.assign(info, heroInfo));
|
||||
let info = { roleId, roleName, serverId, quality, star, job, hName, skins: [{ id: initialSkin, enable: true }] };
|
||||
let curHero = await HeroModel.createHero(Object.assign(info, heroInfo));
|
||||
let calHeroResult = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.INIT, roleId, curHero, {}); calHeroResults.push(calHeroResult);
|
||||
let calAllHeroResult = await reCalAllHeroCe(HERO_SYSTEM_TYPE.ADD_SKIN, roleId, {}, skinIds); calAllHeroResults.push(calAllHeroResult);
|
||||
heroes.push(calHeroResult.hero);
|
||||
@@ -268,7 +268,7 @@ export async function createHeroes(roleId: string, roleName: string, serverId: n
|
||||
let m4 = await checkTaskWithHeroes(roleId, TASK_TYPE.HERO_LV, heroes, funcs);
|
||||
let taskPushMessage = m1.concat(m2, m3, m4);
|
||||
//成长任务
|
||||
await accomplishTask(roleId, TASK_TYPE.HERO_NUM, heroNum)
|
||||
await accomplishTask(serverId, roleId, TASK_TYPE.HERO_NUM, heroNum)
|
||||
return { role, figureInfo, heroes, calHeroResults, calAllHeroResults, taskPushMessage }
|
||||
}
|
||||
|
||||
|
||||
@@ -20,18 +20,18 @@ import { ActivityThirtyDaysModel, ActivityThirtyDaysModelType } from '../db/Acti
|
||||
|
||||
|
||||
|
||||
export async function checkTaskWithRoles(taskType: number, roles: RoleType[], funcs?: number[]) {
|
||||
export async function checkTaskWithRoles(serverId: number, taskType: number, roles: RoleType[], funcs?: number[]) {
|
||||
let pushMessage = new Array<TaskListReturn>();
|
||||
for (let role of roles) {
|
||||
if (role) {
|
||||
let singlePush = await checkTaskWithRole(role.roleId, taskType, role, funcs);
|
||||
let singlePush = await checkTaskWithRole(serverId, role.roleId, taskType, role, funcs);
|
||||
pushMessage.concat(singlePush);
|
||||
}
|
||||
}
|
||||
return pushMessage
|
||||
}
|
||||
|
||||
export async function checkTaskWithRole(roleId: string, taskType: number, role: RoleType, funcs?: number[]) {
|
||||
export async function checkTaskWithRole(serverId: number, roleId: string, taskType: number, role: RoleType, funcs?: number[]) {
|
||||
let pushMessage = new Array<TaskListReturn>();
|
||||
|
||||
if (taskType == TASK_TYPE.LOGIN_SUM) {
|
||||
@@ -39,7 +39,7 @@ export async function checkTaskWithRole(roleId: string, taskType: number, role:
|
||||
if (today > role.loginTime) {
|
||||
pushMessage = await checkTask(roleId, taskType, 1, true, {}, funcs);
|
||||
//成长任务-累计登录游戏天数
|
||||
await accomplishTask(roleId, taskType, 1)
|
||||
await accomplishTask(serverId, roleId, taskType, 1)
|
||||
}
|
||||
}
|
||||
else if (taskType == TASK_TYPE.LOGIN_SERIES) {
|
||||
@@ -481,9 +481,9 @@ function checkRecResult(rec: UserTaskRecType, id: number) {
|
||||
* @param {number} parma 参数
|
||||
*
|
||||
*/
|
||||
export async function accomplishTask(roleId: string, taskType: TASK_TYPE, count: number, parma?: any) {
|
||||
//成长活动统计
|
||||
let allActivity: ActivityModelType[] = await ActivityModel.findOpenActivityByType(ACTIVITY_TYPE.TASK_GROWTH, new Date());
|
||||
export async function accomplishTask(serverId: number, roleId: string, taskType: TASK_TYPE, count: number, parma?: any) {
|
||||
//七天乐-成长活动统计
|
||||
let allActivity: ActivityModelType[] = await ActivityModel.findOpenActivityByType(serverId, ACTIVITY_TYPE.TASK_GROWTH, new Date());
|
||||
for (let activity of allActivity) {
|
||||
let growthActivity = new GrowthData(activity);
|
||||
let taskArray = growthActivity.findTaskByType(taskType);
|
||||
@@ -500,7 +500,7 @@ export async function accomplishTask(roleId: string, taskType: TASK_TYPE, count:
|
||||
}
|
||||
|
||||
//今日挑战统计
|
||||
allActivity = await ActivityModel.findOpenActivityByType(ACTIVITY_TYPE.TASK_DAILY_CHALLENGES, new Date());
|
||||
allActivity = await ActivityModel.findOpenActivityByType(serverId, ACTIVITY_TYPE.TASK_DAILY_CHALLENGES, new Date());
|
||||
for (let activity of allActivity) {
|
||||
let growthActivity = new DailyChallengesData(activity);
|
||||
let taskArray = growthActivity.findTaskByType(taskType, growthActivity.today());
|
||||
@@ -531,7 +531,7 @@ export async function accomplishTask(roleId: string, taskType: TASK_TYPE, count:
|
||||
taskType === TASK_TYPE.EQUIP_QUALITY
|
||||
|
||||
) {
|
||||
allActivity = await ActivityModel.findOpenActivityByType(ACTIVITY_TYPE.THIRTY_DAYS, new Date());
|
||||
allActivity = await ActivityModel.findOpenActivityByType(serverId, ACTIVITY_TYPE.THIRTY_DAYS, new Date());
|
||||
for (let activity of allActivity) {
|
||||
let thirtyDaysActivity = new ThirtyDaysData(activity);
|
||||
let playerRecords: ActivityThirtyDaysModelType[] = await ActivityThirtyDaysModel.findData(activity.serverId, activity.activityId, roleId);
|
||||
|
||||
Reference in New Issue
Block a user