diff --git a/game-server/app/servers/battle/handler/auctionHandler.ts b/game-server/app/servers/battle/handler/auctionHandler.ts index 720be23a4..7e17cde0c 100644 --- a/game-server/app/servers/battle/handler/auctionHandler.ts +++ b/game-server/app/servers/battle/handler/auctionHandler.ts @@ -5,7 +5,7 @@ import { AUCTION_STAGE, DEBUG_MAGIC_WORD, STATUS, OFFER_RATIO, CURRENCY_BY_TYPE, import { LotModel } from "../../../db/Lot"; import { ItemReward, LotRec } from "../../../domain/dbGeneral"; import { resResult } from "../../../pubUtils/util"; -import { auctionStage, calculateDividend, genAuction, sendUngotDividend, startGuildAuction, startWorldAuction, stopAuction, todayGuildBegin, getBasePrice } from "../../../services/auctionService"; +import { auctionStage, calculateDividend, genAuction, sendUngotDividend, startGuildAuction, startWorldAuction, stopAuction, todayGuildBegin, getBasePrice, debugAuctionLots, officialAuctionLots } from "../../../services/auctionService"; import { addItems, handleCost } from '../../../services/rewardService'; import { getSimpleRoleInfo } from '../../../services/roleService'; import { getRoleOnlineInfo } from '../../../services/redisService'; @@ -21,18 +21,14 @@ export class AuctionHandler { this.channelService = app.get('channelService'); } - async getAuction(msg: {}, session: BackendSession) { + async getAuction(msg: { magicWord: string }, session: BackendSession) { + const { magicWord } = msg; + const guildCode = session.get('guildCode'); - const serverId = session.get('serverId'); if (!guildCode) return resResult(STATUS.GUILD_NOT_FOUND); const begin = todayGuildBegin(); - const stage = auctionStage(); - let lots = []; - if (stage === AUCTION_STAGE.DEFAULT || stage === AUCTION_STAGE.GUILD) { - lots = await LotModel.findGuildLotsByBegin(guildCode, begin); - } else if (stage === AUCTION_STAGE.WORLD) { - lots = await LotModel.findWorldLotsByBegin(serverId, begin); - } + let lots = magicWord === DEBUG_MAGIC_WORD ? await debugAuctionLots(session, begin) : await officialAuctionLots(session, begin); + const dividends = await DividendModel.findGuildDividendsByBegin(guildCode, begin); return resResult(STATUS.SUCCESS, { lots, dividends }); } @@ -57,8 +53,7 @@ export class AuctionHandler { return resResult(STATUS.GUILD_LOT_NOT_FOUND); } - const stage = auctionStage(); - if (stage === AUCTION_STAGE.GUILD && lot.guildCode !== guildCode) { + if (lot.auctionStage === AUCTION_STAGE.GUILD && lot.guildCode !== guildCode) { res.releaseCallback(); return resResult(STATUS.AUCTION_GUILD_MEMBER_ONLY); } @@ -96,7 +91,7 @@ export class AuctionHandler { const incPrice = newPrice - (curBuyer ? curPrice : 0); let newDividend = null; - if (stage === AUCTION_STAGE.GUILD) { + if (lot.auctionStage === AUCTION_STAGE.GUILD) { const dividend = await DividendModel.updateLot(code, gid, newPrice, incPrice, max); newDividend = await calculateDividend(dividend); } @@ -232,6 +227,10 @@ export class AuctionHandler { // ! 测试接口 async debugScheduleStartGuild(msg: { magicWord: string }, session: BackendSession) { + const { magicWord } = msg; + if (magicWord !== DEBUG_MAGIC_WORD) { + return resResult(STATUS.TOKEN_ERR); + } const result = await startGuildAuction(); if (result === true) { return resResult(STATUS.SUCCESS); @@ -241,6 +240,10 @@ export class AuctionHandler { // ! 测试接口 async debugScheduleStartWorld(msg: { magicWord: string }, session: BackendSession) { + const { magicWord } = msg; + if (magicWord !== DEBUG_MAGIC_WORD) { + return resResult(STATUS.TOKEN_ERR); + } const result = await startWorldAuction(); if (result === true) { return resResult(STATUS.SUCCESS); @@ -250,6 +253,10 @@ export class AuctionHandler { // ! 测试接口 async debugScheduleStopAuction(msg: { magicWord: string }, session: BackendSession) { + const { magicWord } = msg; + if (magicWord !== DEBUG_MAGIC_WORD) { + return resResult(STATUS.TOKEN_ERR); + } const result = await stopAuction(); if (result === true) { return resResult(STATUS.SUCCESS); @@ -259,6 +266,10 @@ export class AuctionHandler { // ! 测试接口 async debugScheduleSendUngotDividend(msg: { magicWord: string }, session: BackendSession) { + const { magicWord } = msg; + if (magicWord !== DEBUG_MAGIC_WORD) { + return resResult(STATUS.TOKEN_ERR); + } const result = await sendUngotDividend(); if (result === true) { return resResult(STATUS.SUCCESS); diff --git a/game-server/app/services/auctionService.ts b/game-server/app/services/auctionService.ts index c227b4ce4..c247880e8 100644 --- a/game-server/app/services/auctionService.ts +++ b/game-server/app/services/auctionService.ts @@ -9,7 +9,7 @@ import { gameData, getGoodById } from '../pubUtils/data'; import { DividendParam, DividendType } from '../db/Dividend'; import { pushMail } from '../pubUtils/interface'; import { getMailContent } from './mailService'; -import { pinus } from 'pinus'; +import { pinus, BackendSession } from 'pinus'; import { participants } from './guildActivityService'; import { Member } from '../domain/battleField/guildActivity'; @@ -33,6 +33,25 @@ export function auctionStage() { if (curTime > todayWorldEnd().getTime()) return AUCTION_STAGE.END; } +export async function debugAuctionLots(session: BackendSession, begin: Date) { + const serverId = session.get('serverId'); + const lots = await LotModel.findWorldLotsByBegin(serverId, begin); + return lots; +} + +export async function officialAuctionLots(session: BackendSession, begin: Date) { + const serverId = session.get('serverId'); + const guildCode = session.get('guildCode'); + const stage = auctionStage(); + let lots = []; + if (stage === AUCTION_STAGE.DEFAULT || stage === AUCTION_STAGE.GUILD) { + lots = await LotModel.findGuildLotsByBegin(guildCode, begin); + } else if (stage === AUCTION_STAGE.WORLD) { + lots = await LotModel.findWorldLotsByBegin(serverId, begin); + } + return lots; +} + export function auctionBegin() { return getNextTime(new Date(), AUCTION_TIME.GUILD_BEGIN_HOUR, AUCTION_TIME.GUILD_BEGIN_MIN); }