diff --git a/game-server/app/servers/guild/handler/auctionHandler.ts b/game-server/app/servers/guild/handler/auctionHandler.ts index 8662cb58d..db3dcbb03 100644 --- a/game-server/app/servers/guild/handler/auctionHandler.ts +++ b/game-server/app/servers/guild/handler/auctionHandler.ts @@ -4,7 +4,7 @@ import { AUCTION_STAGE, DEBUG_MAGIC_WORD, STATUS, CURRENCY_BY_TYPE, CURRENCY_TYP import { LotModel } from "../../../db/Lot"; import { ItemReward } from "../../../domain/dbGeneral"; import { genCode, resResult } from "../../../pubUtils/util"; -import { auctionStage, calculateDividend, genAuction, sendUngotDividend, startGuildAuction, startWorldAuction, stopAuction, todayGuildBegin, getBasePrice, debugAuctionLots, officialAuctionLots, auctionBidStatus, getMaxPrice, guildBidStatus, getAuction, pushAuctionOver, treatSingleLotTime, treatLotsTime, pushAuctionUpdate } from "../../../services/auctionService"; +import { auctionStage, calculateDividend, genAuction, sendUngotDividend, startGuildAuction, startWorldAuction, stopAuction, todayGuildBegin, getBasePrice, debugAuctionLots, officialAuctionLots, auctionBidStatus, getMaxPrice, guildBidStatus, getAuction, pushAuctionOver, treatSingleLotTime, treatLotsTime, pushAuctionUpdate, checkAuctionStage } from "../../../services/auctionService"; import { addItems, getGoldObject, handleCost } from '../../../services/role/rewardService'; import { getSimpleRoleInfo } from '../../../services/roleService'; import { getRoleOnlineInfo } from '../../../services/redisService'; @@ -48,17 +48,17 @@ export class AuctionHandler { } - async offer(msg: { code: string, max: boolean }, session: BackendSession) { - const { code, max } = msg; + async offer(msg: { code: string, max: boolean, auctionStage: number }, session: BackendSession) { + const { code, max, auctionStage } = msg; const roleId = session.get('roleId'); const sid = session.get('sid'); const serverId = session.get('serverId'); const guildCode = session.get('guildCode'); const ip = session.get('ip'); - let res: any = await lockData(serverId, DATA_NAME.AUCTION_LOT, code);// 加锁 + let res: any = await lockData(serverId, DATA_NAME.AUCTION_LOT, '');// 加锁 try { - if (!res) { + if (!!res.err) { return resResult(STATUS.REDLOCK_ERR); } @@ -68,11 +68,16 @@ export class AuctionHandler { return resResult(STATUS.GUILD_LOT_NOT_FOUND); } - if (lot.auctionStage === AUCTION_STAGE.GUILD && lot.guildCode !== guildCode) { + if (auctionStage === AUCTION_STAGE.GUILD && lot.guildCode !== guildCode) { res.releaseCallback(); return resResult(STATUS.AUCTION_GUILD_MEMBER_ONLY); } + if(!checkAuctionStage(auctionStage)) { + res.releaseCallback(); + return resResult(STATUS.AUCITON_STAGE_ERR); + } + let { curBuyer, curPrice, prePrice, maxPrice, gid, count, bidRoles, watchingRoles } = lot; if (curBuyer === roleId && !max) { res.releaseCallback(); @@ -109,13 +114,13 @@ export class AuctionHandler { reportTAEvent(roleId, TA_EVENT.AUCTION_ITEM_GET, { item_name: dicGoods?.name, item_count: count, deel_price: newPrice }, ip); } bidRoles.push({ roleId, price: newPrice, time: new Date() }); - const newLot = await LotModel.updateLot({ code, curBuyer: roleId, curPrice: newPrice, prePrice: curPrice, bidRoles, status: max ? LOT_STATUS.MAX : (maxFlag ? LOT_STATUS.SOLD : LOT_STATUS.ING), watchingRoles: Array.from(new Set([...watchingRoles, roleId])) }); + const newLot = await LotModel.updateLot({ code, curBuyer: roleId, curPrice: newPrice, auctionStage, prePrice: curPrice, bidRoles, status: max ? LOT_STATUS.MAX : (maxFlag ? LOT_STATUS.SOLD : LOT_STATUS.ING), watchingRoles: Array.from(new Set([...watchingRoles, roleId])) }); await pushAuctionOver(newLot); // 推送竞价超过标志 res.releaseCallback(); const incPrice = curPrice - prePrice > 0? prePrice: 0; let newDividend = null; - if (lot.auctionStage === AUCTION_STAGE.GUILD) { + if (auctionStage === AUCTION_STAGE.GUILD) { const dividend = await DividendModel.updateLot(code, gid, curPrice, incPrice, max); newDividend = await calculateDividend(dividend); } diff --git a/game-server/app/services/auctionService.ts b/game-server/app/services/auctionService.ts index 6122a6195..9181103e5 100644 --- a/game-server/app/services/auctionService.ts +++ b/game-server/app/services/auctionService.ts @@ -530,4 +530,18 @@ export async function pushAuctionUpdate(lots: LotType[], dividends: DividendType } +} + +export async function checkAuctionStage(auctionStage: number) { + const curTime = await getCurrentTimeWithSetDay(); + if(auctionStage != AUCTION_STAGE.GUILD && auctionStage != AUCTION_STAGE.WORLD) return false; + if(auctionStage == AUCTION_STAGE.GUILD) { + if(curTime < (await todayGuildBegin()).getTime() - 10 * 60 * 100) return false; + if(curTime > (await todayWorldBegin()).getTime() + 10 * 60 * 1000) return false + } + if(auctionStage == AUCTION_STAGE.WORLD) { + if(curTime < (await todayWorldBegin()).getTime() - 10 * 60 * 100) return false; + if(curTime > (await todayWorldEnd()).getTime() + 10 * 60 * 1000) return false + } + return true } \ No newline at end of file diff --git a/game-server/app/services/timeTaskService.ts b/game-server/app/services/timeTaskService.ts index 0827c6503..471de8ba7 100644 --- a/game-server/app/services/timeTaskService.ts +++ b/game-server/app/services/timeTaskService.ts @@ -376,7 +376,7 @@ let startWorldAuctionJobId: Job; let stopAuctionJobId: Job; let sendUngotDividendJobId: Job; -export function auctionSchedule() { +export async function auctionSchedule() { clearAuctionSchedule(); let guildOpen = gameData.auctionTime.get(AUCTION_TIME.GUILD_OPEN); let worldOpen = gameData.auctionTime.get(AUCTION_TIME.WORLD_OPEN); diff --git a/shared/consts/statusCode.ts b/shared/consts/statusCode.ts index 05ade9e82..3ab6b7bae 100644 --- a/shared/consts/statusCode.ts +++ b/shared/consts/statusCode.ts @@ -238,6 +238,7 @@ export const STATUS = { DIVIDEND_NOT_READY: { code: 21003, simStr: '还不可以领取分红' }, DIVIDEND_GUILD_PLAYER_ONLY: { code: 21004, simStr: '需要参加军团活动才能领取' }, AUCTION_GUILD_MEMBER_ONLY: { code: 21005, simStr: '不是军团的成员无法出价' }, + AUCITON_STAGE_ERR: { code: 21006, simStr: '拍卖超时,请刷新客户端重新进入' }, // 军团活动 21100-21199 GUILD_ACTIVITY_NOT_OPEN: { code: 21100, simStr: '活动未开放' },