diff --git a/game-server/app/servers/battle/handler/auctionHandler.ts b/game-server/app/servers/battle/handler/auctionHandler.ts index 1ff090fa8..2f7ae8eda 100644 --- a/game-server/app/servers/battle/handler/auctionHandler.ts +++ b/game-server/app/servers/battle/handler/auctionHandler.ts @@ -31,7 +31,7 @@ export class AuctionHandler { const { magicWord } = msg; const guildCode = session.get('guildCode'); - if (!guildCode) return resResult(STATUS.GUILD_NOT_FOUND); + // if (!guildCode) return resResult(STATUS.GUILD_NOT_FOUND); let result = await getAuction(guildCode, session, magicWord); return resResult(STATUS.SUCCESS, result); diff --git a/game-server/app/services/auctionService.ts b/game-server/app/services/auctionService.ts index 5823c042e..bfd307464 100644 --- a/game-server/app/services/auctionService.ts +++ b/game-server/app/services/auctionService.ts @@ -53,31 +53,38 @@ export async function officialAuctionLots(session: FrontendOrBackendSession, beg } export function auctionBegin() { - return getTimeFunD().getAfterDayWithHour(0, AUCTION_TIME.GUILD_BEGIN_HOUR, AUCTION_TIME.GUILD_BEGIN_MIN); + let { hour, minute } = gameData.auctionTime.get(AUCTION_TIME.GUILD_OPEN); + return getTimeFunD().getAfterDayWithHour(0, hour, minute); } export function guildAuctionEnd() { - return getTimeFunD().getAfterDayWithHour(0, AUCTION_TIME.GUILD_END_HOUR, AUCTION_TIME.GUILD_END_MIN); + let { hour, minute } = gameData.auctionTime.get(AUCTION_TIME.GUILD_CLOSE); + return getTimeFunD().getAfterDayWithHour(0, hour, minute); } export function auctionEnd() { - return getTimeFunD().getAfterDayWithHour(0, AUCTION_TIME.WORLD_END_HOUR, AUCTION_TIME.WORLD_END_MIN); + let { hour, minute } = gameData.auctionTime.get(AUCTION_TIME.WORLD_CLOSE); + return getTimeFunD().getAfterDayWithHour(0, hour, minute); } export function todayGuildBegin() { - return getTimeFunD(getZeroPointD()).getAfterDayWithHour(0, AUCTION_TIME.GUILD_BEGIN_HOUR, AUCTION_TIME.GUILD_BEGIN_MIN); + let { hour, minute } = gameData.auctionTime.get(AUCTION_TIME.GUILD_OPEN); + return getTimeFunD(getZeroPointD()).getAfterDayWithHour(0, hour, minute); } export function yestodayGuildBegin() { - return getTimeFunD(getZeroPointD()).getAfterDayWithHour(-1, AUCTION_TIME.GUILD_BEGIN_HOUR, AUCTION_TIME.GUILD_BEGIN_MIN); + let { hour, minute } = gameData.auctionTime.get(AUCTION_TIME.GUILD_OPEN); + return getTimeFunD(getZeroPointD()).getAfterDayWithHour(-1, hour, minute); } export function todayWorldBegin() { - return getTimeFunD(getZeroPointD()).getAfterDayWithHour(0, AUCTION_TIME.WORLD_BEGIN_HOUR, AUCTION_TIME.WORLD_BEGIN_MIN); + let { hour, minute } = gameData.auctionTime.get(AUCTION_TIME.WORLD_OPEN); + return getTimeFunD(getZeroPointD()).getAfterDayWithHour(0, hour, minute); } export function todayWorldEnd() { - return getTimeFunD(getZeroPointD()).getAfterDayWithHour(0, AUCTION_TIME.WORLD_END_HOUR, AUCTION_TIME.WORLD_END_MIN); + let { hour, minute } = gameData.auctionTime.get(AUCTION_TIME.WORLD_CLOSE); + return getTimeFunD(getZeroPointD()).getAfterDayWithHour(0, hour, minute); } /** @@ -287,6 +294,9 @@ export async function getAuction(guildCode: string, session: FrontendOrBackendSe const begin = todayGuildBegin(); let lots = magicWord === DEBUG_MAGIC_WORD ? await debugAuctionLots(session, begin) : await officialAuctionLots(session, begin); - const dividends = await DividendModel.findGuildDividendsByBegin(guildCode, begin); + let dividends: DividendType[] = []; + if(guildCode) { + dividends = await DividendModel.findGuildDividendsByBegin(guildCode, begin); + } return { lots, dividends }; } \ No newline at end of file diff --git a/game-server/app/services/timeTaskService.ts b/game-server/app/services/timeTaskService.ts index 5a41112c5..a68a15985 100644 --- a/game-server/app/services/timeTaskService.ts +++ b/game-server/app/services/timeTaskService.ts @@ -4,11 +4,11 @@ import { PVPConfigModel } from '../db/SystemConfig'; import PvpDefenseType, { PvpDefenseModel } from '../db/PvpDefense'; import { PVP } from '../pubUtils/dicParam'; import { nowSeconds, getTimeFun } from '../pubUtils/timeUtil'; -import { getPvpGkWarIds, getPvpRankRewards, getPvpHeroRewards, getResultMaxRank, getTodayGuildActivity } from '../pubUtils/data'; +import { getPvpGkWarIds, getPvpRankRewards, getPvpHeroRewards, getResultMaxRank, getTodayGuildActivity, gameData } from '../pubUtils/data'; import { deepCopy, getRandSingleEelm } from '../pubUtils/util'; import { getLvByScore } from './pvpService'; import { getAllOnlineRoles, getAllServers, initSingleRank, delGuildActivityRank } from './redisService'; -import { MAIL_TYPE, REDIS_KEY, GUILD_ACTIVITY_STATUS, GUILD_ACTIVITY_TYPE, TASK_TYPE, TIME_OUTPUT_TYPE, REFRESH_TIME, SEND_NAME, SERVER_OPEN_TIME, COUNTER } from '../consts'; +import { MAIL_TYPE, REDIS_KEY, GUILD_ACTIVITY_STATUS, GUILD_ACTIVITY_TYPE, TASK_TYPE, TIME_OUTPUT_TYPE, REFRESH_TIME, SEND_NAME, SERVER_OPEN_TIME, COUNTER, AUCTION_TIME } from '../consts'; import { RoleModel } from '../db/Role'; import { pinus } from 'pinus'; import { indexOf } from 'underscore'; @@ -518,8 +518,12 @@ export async function raceActivitySeconds() { } function auctionSchedule() { - scheduleJob('startGuildAuction', '0 0 20 20 * ?', startGuildAuction); - scheduleJob('startWorldAuction', '0 0 20 30 * ?', startWorldAuction); - scheduleJob('stopAuction', '0 0 22 00 * ?', stopAuction); + let guildOpen = gameData.auctionTime.get(AUCTION_TIME.GUILD_OPEN); + let worldOpen = gameData.auctionTime.get(AUCTION_TIME.WORLD_OPEN); + let worldClose = gameData.auctionTime.get(AUCTION_TIME.WORLD_CLOSE); + + scheduleJob('startGuildAuction', `0 0 ${guildOpen.hour} ${guildOpen.minute} * ?`, startGuildAuction); + scheduleJob('startWorldAuction', `0 0 ${worldOpen.hour} ${worldOpen.minute} * ?`, startWorldAuction); + scheduleJob('stopAuction', `0 0 ${worldClose.hour} ${worldClose.minute} * ?`, stopAuction); scheduleJob('sendUngotDividendJob', '0 0 5 00 * ?', sendUngotDividendJob); } diff --git a/shared/consts/constModules/auctionConst.ts b/shared/consts/constModules/auctionConst.ts index 4f6066e1d..5ab4afbd1 100644 --- a/shared/consts/constModules/auctionConst.ts +++ b/shared/consts/constModules/auctionConst.ts @@ -16,17 +16,14 @@ export const AUCTION_SOURCE = { export const LOT_CODE_LEN = 8; export const DIVIDEND_CODE_LEN = 8; -// 世界拍卖开始时间需晚于军团拍卖结束时间 -export const AUCTION_TIME = { - GUILD_BEGIN_HOUR: 20, // 军团拍卖开始 - GUILD_BEGIN_MIN: 20, // 军团拍卖开始 - WORLD_BEGIN_HOUR: 20, // 世界拍卖开始 - WORLD_BEGIN_MIN: 30, // 世界拍卖开始 - GUILD_END_HOUR: 20, // 军团拍卖结束 - GUILD_END_MIN: 30, // 军团拍卖结束 - WORLD_END_HOUR: 22, // 世界拍卖结束 - WORLD_END_MIN: 0, // 世界拍卖结束 -}; +export enum AUCTION_TIME { + GUILD_PREVIEW = 1, // 军团拍卖预览时间(非开启时间) + GUILD_OPEN = 2, // 军团拍卖开启时间 + GUILD_CLOSE = 3, // 军团拍卖关闭时间 + WORLD_PREVIEW = 4, // 世界拍卖预览时间(非开启时间) + WORLD_OPEN = 5, // 世界拍卖开启时间 + WORLD_CLOSE = 6, // 世界拍卖结束时间 +} export const DIVIDEND_STATUS = { DEFAULT: 0, // 0:未开始 diff --git a/shared/pubUtils/data.ts b/shared/pubUtils/data.ts index f82a969d5..c153201fb 100644 --- a/shared/pubUtils/data.ts +++ b/shared/pubUtils/data.ts @@ -18,7 +18,7 @@ import { dicTowerTask, loadTowerTask } from "./dictionary/DicTowerTask"; import { dicWar, dicWarPvp, dicDailyWarByType, loadWar } from "./dictionary/DicWar"; import { dicWarJson, loadWarJson } from "./dictionary/DicWarJson"; import { dicXunbao, loadXunbao } from "./dictionary/DicXunbao"; -import { SPECIAL_ATTR } from "../consts"; +import { AUCTION_TIME, SPECIAL_ATTR } from "../consts"; import { dicFashions, loadFashions } from "./dictionary/DicFashions"; import { friendShips, friendShipHidAandIds, loadFriendShip } from "./dictionary/DicFriendShip"; import { maxFriendShipLv, dicFriendShipLevelMap, loadFriendShipLevel } from "./dictionary/DicFriendShipLevel"; @@ -235,7 +235,8 @@ export const gameData = { ceRatio: new Array<{type: number, val: number}>(), holiday: dicHoliday, expeditionSubAttr: dicExpeditionSubAttr, - auctionPool: dicAuctionPool + auctionPool: dicAuctionPool, + auctionTime: new Map() }; // 在此提供一些原先在gamedata中提供的方法,以便更方便获取gameData数据 @@ -799,6 +800,20 @@ function loadEquipAttributeRatio() { } } +function loadAuctionTime() { + gameData.auctionTime.set(AUCTION_TIME.GUILD_PREVIEW, splitTime(param.AUCTION.GUILD_AUCTION_PREVIEW_TIME)); + gameData.auctionTime.set(AUCTION_TIME.GUILD_OPEN, splitTime(param.AUCTION.GUILD_AUCTION_OPEN_TIME)); + gameData.auctionTime.set(AUCTION_TIME.GUILD_CLOSE, splitTime(param.AUCTION.GUILD_AUCTION_CLOSE_TIME)); + gameData.auctionTime.set(AUCTION_TIME.WORLD_PREVIEW, splitTime(param.AUCTION.WORLD_AUCTION_PREVIEW_TIME)); + gameData.auctionTime.set(AUCTION_TIME.WORLD_OPEN, splitTime(param.AUCTION.WORLD_AUCTION_OPEN_TIME)); + gameData.auctionTime.set(AUCTION_TIME.WORLD_CLOSE, splitTime(param.AUCTION.WORLD_AUCTION_CLOSE_TIME)); +} + +function splitTime(str: string) { + let arr = str.split(':'); + return { hour: parseInt(arr[0]), minute: parseInt(arr[1]), seconds: parseInt(arr[2]) } +} + // 初始加载 function initDatas() { parseDicParam(); @@ -815,6 +830,7 @@ function parseDicParam() { getHeroTransPiece(); parseComBtlLvRange(); getCeRatio(); + loadAuctionTime(); } // 加载json