From 73d25238704dc83f3cd6907824e2fdedd406e385 Mon Sep 17 00:00:00 2001 From: liangtongchuan Date: Thu, 18 Mar 2021 14:17:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8B=8D=E5=8D=96=E8=A1=8C=EF=BC=9A=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=8B=8D=E5=8D=96=E9=98=B6=E6=AE=B5=E5=88=A4=E6=96=AD?= =?UTF-8?q?=EF=BC=8C=E5=AE=9E=E7=8E=B0=E6=9F=A5=E7=9C=8B=E5=88=86=E7=BA=A2?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../servers/battle/handler/auctionHandler.ts | 16 +++++++++---- game-server/app/services/auctionService.ts | 23 +++++++++++++------ 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/game-server/app/servers/battle/handler/auctionHandler.ts b/game-server/app/servers/battle/handler/auctionHandler.ts index 432b4ad2f..b5e8481fa 100644 --- a/game-server/app/servers/battle/handler/auctionHandler.ts +++ b/game-server/app/servers/battle/handler/auctionHandler.ts @@ -4,7 +4,7 @@ import { AUCTION_STAGE, DEBUG_MAGIC_WORD, STATUS, OFFER_RATIO, CURRENCY_BY_TYPE, import { LotModel } from "../../../db/Lot"; import { ItemReward } from "../../../domain/dbGeneral"; import { resResult } from "../../../pubUtils/util"; -import { auctionBegin, auctionStage, genAuction } from "../../../services/auctionService"; +import { auctionBegin, auctionStage, calculateDividend, genAuction, todayGuildBegin } from "../../../services/auctionService"; import { addItems, handleCost } from '../../../services/rewardService'; import { getSimpleRoleInfo } from '../../../services/roleService'; import { getRoleOnlineInfo } from '../../../services/redisService'; @@ -23,7 +23,7 @@ export class AuctionHandler { const guildCode = session.get('guildCode'); const serverId = session.get('serverId'); if (!guildCode) return resResult(STATUS.GUILD_NOT_FOUND); - const begin = auctionBegin(); + const begin = todayGuildBegin(); const stage = auctionStage(); let lots = []; if (stage === AUCTION_STAGE.DEFAULT || stage === AUCTION_STAGE.GUILD) { @@ -65,7 +65,9 @@ export class AuctionHandler { const incPrice = newPrice - (curBuyer ? curPrice : 0); const dividend = await DividendModel.updateLot(code, gid, newPrice, incPrice); - return resResult(STATUS.SUCCESS, { lot: newLot, dividend }); + const newDividend = await calculateDividend(dividend); + // TODO 加关注 + return resResult(STATUS.SUCCESS, { lot: newLot, dividend: newDividend }); } async watchLot(msg: { code: string }, session: BackendSession) { @@ -73,10 +75,14 @@ export class AuctionHandler { } async checkDividend(msg: {}, session: BackendSession) { - return resResult(STATUS.SUCCESS); + const begin = todayGuildBegin(); + const guildCode = session.get('guildCode'); + if (!guildCode) return resResult(STATUS.GUILD_NOT_FOUND); + const dividends = await DividendModel.findGuildDividendsByBegin(guildCode, begin); + return resResult(STATUS.SUCCESS, { dividends }); } - async getDividend(msg: {}, session: BackendSession) { + async getDividend(msg: { sourceType: number }, session: BackendSession) { return resResult(STATUS.SUCCESS); } diff --git a/game-server/app/services/auctionService.ts b/game-server/app/services/auctionService.ts index 047f81bca..ca0c6bc0c 100644 --- a/game-server/app/services/auctionService.ts +++ b/game-server/app/services/auctionService.ts @@ -21,13 +21,10 @@ function getMaxPrice(gid: number, count: number) { export function auctionStage() { const curTime = new Date().getTime(); - const todayGuildBegin = getNextTime(getTodayZeroDate(), AUCTION_TIME.GUILD_BEGIN_HOUR, AUCTION_TIME.GUILD_BEGIN_MIN).getTime(); - const todayWorldBegin = getNextTime(getTodayZeroDate(), AUCTION_TIME.WORLD_BEGIN_HOUR, AUCTION_TIME.WORLD_BEGIN_MIN).getTime(); - const todayWorldEnd = getNextTime(getTodayZeroDate(), AUCTION_TIME.WORLD_END_HOUR, AUCTION_TIME.WORLD_END_MIN).getTime(); - if (curTime < todayGuildBegin) return AUCTION_STAGE.DEFAULT; - if (curTime < todayWorldBegin && curTime > todayGuildBegin) return AUCTION_STAGE.GUILD; - if (curTime > todayWorldBegin && curTime < todayWorldEnd) return AUCTION_STAGE.WORLD; - if (curTime > todayWorldEnd) return AUCTION_STAGE.END; + if (curTime < todayGuildBegin().getTime()) return AUCTION_STAGE.DEFAULT; + if (curTime < todayWorldBegin().getTime() && curTime > todayGuildBegin().getTime()) return AUCTION_STAGE.GUILD; + if (curTime > todayWorldBegin().getTime() && curTime < todayWorldEnd().getTime()) return AUCTION_STAGE.WORLD; + if (curTime > todayWorldEnd().getTime()) return AUCTION_STAGE.END; } export function auctionBegin() { @@ -38,6 +35,18 @@ export function auctionEnd() { return getNextTime(new Date(), AUCTION_TIME.WORLD_END_HOUR, AUCTION_TIME.WORLD_END_MIN); } +export function todayGuildBegin() { + return getNextTime(getTodayZeroDate(), AUCTION_TIME.GUILD_BEGIN_HOUR, AUCTION_TIME.GUILD_BEGIN_MIN); +} + +export function todayWorldBegin() { + return getNextTime(getTodayZeroDate(), AUCTION_TIME.WORLD_BEGIN_HOUR, AUCTION_TIME.WORLD_BEGIN_MIN); +} + +export function todayWorldEnd() { + return getNextTime(getTodayZeroDate(), AUCTION_TIME.WORLD_END_HOUR, AUCTION_TIME.WORLD_END_MIN); +} + /** * @description 生成拍卖数据 * @export