活动:调整活动代码路径

This commit is contained in:
qiaoxin
2021-06-22 17:16:33 +08:00
parent 8fae4a22ab
commit 42748f4a62
58 changed files with 274 additions and 312 deletions
+34 -34
View File
@@ -19,7 +19,7 @@ import { getAllAssistCnt } from './comBattleService';
import { getDungeonData } from './dungeonService';
import { PvpSeasonResultModel } from '../db/PvpSeasonResult';
import { nowSeconds, getZeroPoint } from '../pubUtils/timeUtil';
import { getGachaList, getVisitedHeroList } from './gachaService';
import { getGachaList, getVisitedHeroList } from './activity/gachaService';
import { getSchoolList } from './roleService';
import { addRoleToGuildChannel } from './chatChannelService';
import { getMyGuildInfo, getGuildWithRefActive, getUserGuildWithRefActive, getWishPool } from './guildService';
@@ -38,42 +38,42 @@ import { PvpDefenseModel } from '../db/PvpDefense';
import { findPvpDefAllByRoleId } from './pvpService';
import { getDonation } from './donateService';
export async function pushData(role: RoleType, session: FrontendOrBackendSession, pushType: 'entry'|'refresh' = 'entry') {
try{
export async function pushData(role: RoleType, session: FrontendOrBackendSession, pushType: 'entry' | 'refresh' = 'entry') {
try {
const { roleId } = role;
const sid = session.get('sid');
pushEntryStart(roleId, sid);
// 军团
const guildData = await getGuildEntryData(role, sid, session);
let modules = ['shop', 'rank', 'mail', 'friend', 'daily', 'expedition', 'tower', 'comBattle', 'dungeon', 'pvp', 'gacha', 'school', 'task', 'chat', 'event', 'battle', 'guild'];
if(guildData.hasGuild) {
if (guildData.hasGuild) {
modules.push('auction', 'train', 'boss', 'wishPool', 'guildActivity', 'donate');
}
let notIncludeModule: string[] = [];
if(pushType == 'refresh') {
if (pushType == 'refresh') {
notIncludeModule = ['rank', 'mail', 'school', 'auction', 'train', 'chat', 'battle'];
}
for(let type of modules) {
if(notIncludeModule.indexOf(type) == -1) {
for (let type of modules) {
if (notIncludeModule.indexOf(type) == -1) {
let data = await getModuleData(type, { role, session }, guildData);
if(data) {
if (data) {
pushEntryData(type, roleId, sid, data);
}
}
}
pushEntryEnd(roleId, sid);
}catch(e) {
} catch (e) {
console.error(e.stack);
}
}
}
async function getModuleData(type: string, data: {role: RoleType, session: FrontendOrBackendSession}, guildData: { hasGuild: boolean, guild?: GuildType, userGuild?: UserGuildType, guildResult?: any} = { hasGuild: false }) {
async function getModuleData(type: string, data: { role: RoleType, session: FrontendOrBackendSession }, guildData: { hasGuild: boolean, guild?: GuildType, userGuild?: UserGuildType, guildResult?: any } = { hasGuild: false }) {
let { role, session } = data;
const { roleId, serverId, roleName, guildCode } = role;
let { hasGuild, guild, userGuild, guildResult } = guildData;
switch(type) {
switch (type) {
case 'shop': // 商店
return await getAllShopList(roleId);
case 'rank': // 排名
@@ -83,7 +83,7 @@ export async function pushData(role: RoleType, session: FrontendOrBackendSession
case 'friend': // 好友
const friendList = await getFriendList(role);
const applyList = await getApplyList(roleId);
return { friendList, applyList }
return { friendList, applyList }
case 'daily': // 每日
return await getDailyBattleList(role);
case 'expedition': // 远征
@@ -102,33 +102,33 @@ export async function pushData(role: RoleType, session: FrontendOrBackendSession
const gachalist = await getGachaList(roleId);
const visitList = await getVisitedHeroList(roleId);
return { gachalist, visitList }
case 'school':
case 'school':
return await getSchoolList(roleId);
case 'guild':
return await guildResult;
case 'auction':
return hasGuild? await getAuction(guildCode, session): null;
return hasGuild ? await getAuction(guildCode, session) : null;
case 'train':
if(hasGuild) {
if (hasGuild) {
let trainInstance = await getGuildTrainInstance(roleId, guild, userGuild);
let trainBoxRewards = await getTrainBoxRewardsResult(guildCode);
return { trainInstance, trainBoxRewards }
}
case 'boss':
if(hasGuild) {
case 'boss':
if (hasGuild) {
const bossInstance = await BossInstanceModel.findBossInstance(guild.code);
if(bossInstance) {
if (bossInstance) {
return await getBossInstanceInfo(bossInstance, roleId);
}
}
return null;
case 'wishPool':
return hasGuild? await getWishPool(userGuild): null;
return hasGuild ? await getWishPool(userGuild) : null;
case 'donate':
if(hasGuild) {
if (hasGuild) {
const { guildCode: code, donateCnt, receiveBoxs } = userGuild;
let { donateFund, reports, donationLv } = await getDonation(code, serverId);
return { receiveBoxs, donateFund, reports, donateCnt:donateCnt||0, donationLv};
return { receiveBoxs, donateFund, reports, donateCnt: donateCnt || 0, donationLv };
}
case 'task':
return await getCurTask(role.roleId, session);
@@ -142,15 +142,15 @@ export async function pushData(role: RoleType, session: FrontendOrBackendSession
return await getEvent(role.eventStatus, roleId, roleName);
case 'battle':
return await getBattleListOfMain(role);
case 'guildActivity':
case 'guildActivity':
return getAllGuildActivityStatus();
default:
return null;
}
}
}
function pushEntryData<T>(type: string, roleId: string, sid: string, param: T) {
function pushEntryData<T>(type: string, roleId: string, sid: string, param: T) {
let uids = [{ uid: roleId, sid }];
let data = { type };
data[type] = param;
@@ -177,7 +177,7 @@ async function getTowerEntryData(role: RoleType) {
const status = await getTowerStatus(role);
const hungUp = await getHungupRewards(roleId);
const tasks = await getTasks(role);
if(hungUp.status == -1) {
if (hungUp.status == -1) {
return { status, hungUp: {}, tasks }
} else {
return { status, hungUp: hungUp.data, tasks }
@@ -190,7 +190,7 @@ async function getTowerEntryData(role: RoleType) {
*/
async function getPvpEntryData(roleId: string) {
let pvpDefense = await PvpDefenseModel.findByRoleIdIncludeAll(roleId);
if(pvpDefense) {
if (pvpDefense) {
let { pvpDefense, } = await findPvpDefAllByRoleId(roleId);
let { challengeCnt, receivedBox, score, hisScore } = pvpDefense;
@@ -214,9 +214,9 @@ async function getGuildEntryData(role: RoleType, sid: string, session: FrontendO
let guild = await getGuildWithRefActive(userGuild.guildCode, role.serverId);
if (guild) {
addRoleToGuildChannel(role.roleId, sid, userGuild.guildCode);
let result = await getMyGuildInfo(role.roleId, sid, userGuild, guild, role.serverId, session);
return { hasGuild: true, guild, userGuild, guildResult: result};
return { hasGuild: true, guild, userGuild, guildResult: result };
}
}
}
@@ -230,12 +230,12 @@ export async function everydayRefresh() {
console.log(n)
let i = -1;
let interval = setInterval(() => {
if(++i < n) {
if (++i < n) {
let users = allOnlineUsers.slice(i * PUSH_BATCH, (i + 1) * PUSH_BATCH - 1);
for(let { roleId, sid } of users) {
for (let { roleId, sid } of users) {
pinus.app.channelService.pushMessageByUids('onRefreshTime', resResult(STATUS.SUCCESS, {
todayZeroPoint
} ), [{uid: roleId, sid: sid}]);
todayZeroPoint
}), [{ uid: roleId, sid: sid }]);
}
} else {
clearInterval(interval);