diff --git a/game-server/app/servers/guild/handler/auctionHandler.ts b/game-server/app/servers/guild/handler/auctionHandler.ts index 2d2e70319..03830bed5 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, checkAuctionStage, processDividendFormat, processSingleDividendFormat } from "../../../services/auctionService"; +import { auctionStage, calculateDividend, genAuction, sendUngotDividend, startGuildAuction, startWorldAuction, stopAuction, todayGuildBegin, getBasePrice, debugAuctionLots, officialAuctionLots, auctionBidStatus, getMaxPrice, guildBidStatus, getAuction, pushAuctionOver, pushAuctionUpdate, checkAuctionStage, processDividendFormat, processSingleDividendFormat, tomorrowGuildBegin, processLotsFormat, processSingleLotFormat } from "../../../services/auctionService"; import { addItems, getGoldObject, handleCost } from '../../../services/role/rewardService'; import { getSimpleRoleInfo } from '../../../services/roleService'; import { getRoleOnlineInfo } from '../../../services/redisService'; @@ -17,8 +17,6 @@ import { UserGuildModel } from '../../../db/UserGuild'; import { UserGuildApplyModel } from '../../../db/UserGuildApply'; import * as dicParam from '../../../pubUtils/dicParam'; import { gameData, getAuctionRewardByPoolId } from '../../../pubUtils/data'; -import { addRoleToGuildAuctionChannel, addRoleToWorldAuctionChannel, channelServer, groupRoomId, leaveGuildAuctionChannel } from '../../../services/chatService'; -import { RewardInter } from '../../../pubUtils/interface'; import { sendMailByContent } from '../../../services/mailService'; import { reportTAEvent } from '../../../services/sdkService'; import { sendMessageToGuildWithSuc, sendMessageToServerWithSuc } from '../../../services/pushService'; @@ -124,7 +122,7 @@ export class AuctionHandler { const dividend = await DividendModel.updateLot(code, gid, curPrice, incPrice, max); newDividend = await calculateDividend(dividend); } - let newLotResult = await treatSingleLotTime(newLot); + let newLotResult = processSingleLotFormat(newLot); await sendMessageToGuildWithSuc(guildCode, PUSH_ROUTE.DIVIDEND_UPDATE, { dividends: processDividendFormat([newDividend]) }) return resResult(STATUS.SUCCESS, { lot: newLotResult, dividend: processSingleDividendFormat(newDividend) }); } catch (e) { @@ -139,7 +137,7 @@ export class AuctionHandler { const { code } = msg; const lot = await LotModel.watchLot(code, roleId); if (!lot) return resResult(STATUS.WRONG_PARMS); - return resResult(STATUS.SUCCESS, { lot }); + return resResult(STATUS.SUCCESS, { lot: processSingleLotFormat(lot) }); } async unWatchLot(msg: { code: string }, session: BackendSession) { @@ -147,19 +145,20 @@ export class AuctionHandler { const { code } = msg; const lot = await LotModel.unWatchLot(code, roleId); if (!lot) return resResult(STATUS.WRONG_PARMS); - return resResult(STATUS.SUCCESS, { lot }); + return resResult(STATUS.SUCCESS, { lot: processSingleLotFormat(lot) }); } async checkDividend(msg: {}, session: BackendSession) { const begin = await todayGuildBegin(); + const tomorrowBegin = await tomorrowGuildBegin(); const guildCode = session.get('guildCode'); if(guildCode) { - const dividends = await DividendModel.findGuildDividendsByBegin(guildCode, begin); + const dividends = await DividendModel.findGuildDividendsByBegin(guildCode, [begin, tomorrowBegin]); return resResult(STATUS.SUCCESS, { dividends: processDividendFormat(dividends) }); } else { let roleId = session.get('roleId'); - const dividends = await DividendModel.findDividendByRoleAndBegin(roleId, begin); + const dividends = await DividendModel.findDividendByRoleAndBegin(roleId, [begin, tomorrowBegin]); return resResult(STATUS.SUCCESS, { dividends: processDividendFormat(dividends) }); } } @@ -186,7 +185,7 @@ export class AuctionHandler { const begin = await todayGuildBegin(); const lots = await LotModel.watchingLotsByBegin(serverId, roleId, begin); const stage = await auctionStage(); - let newLots = await treatLotsTime(lots); + let newLots = await processLotsFormat(lots); return resResult(STATUS.SUCCESS, { lots: stage === AUCTION_STAGE.END ? [] : newLots }); } diff --git a/game-server/app/services/auctionService.ts b/game-server/app/services/auctionService.ts index 9aad4da58..60b846c88 100644 --- a/game-server/app/services/auctionService.ts +++ b/game-server/app/services/auctionService.ts @@ -2,8 +2,8 @@ import { DividendModel } from './../db/Dividend'; import { LOT_CODE_LEN, AUCTION_STAGE, AUCTION_TIME, DIVIDEND_CODE_LEN, DIVIDEND_STATUS, LOT_STATUS, MAIL_TYPE, CURRENCY_BY_TYPE, CURRENCY_TYPE, ROLE_RECEIVE_STATUS, AUCTION_BID_STATUS, DEBUG_MAGIC_WORD, AUCTION_SOURCE, TA_EVENT, getAuctionSourceTypeName, PUSH_ROUTE, GUILD_JOB } from './../consts'; import { DividendRec, } from "../domain/dbGeneral"; import { genCode, getRandSingleEelm } from '../pubUtils/util'; -import { LotModel, LotParam, LotType } from '../db/Lot'; -import { getCurDay, getTimeFunD, getTimeFunM, nowSeconds } from '../pubUtils/timeUtil'; +import Lot, { LotModel, LotParam, LotType } from '../db/Lot'; +import { getCurDay, getSeconds, getTimeFunD, getTimeFunM, nowSeconds } from '../pubUtils/timeUtil'; import { gameData, getGoodById } from '../pubUtils/data'; import { DividendParam, DividendType } from '../db/Dividend'; import { sendMailByContent } from './mailService'; @@ -56,27 +56,7 @@ export async function officialAuctionLots(session: FrontendOrBackendSession, beg } - return await treatLotsTime(lots); -} - -export async function treatLotsTime(lots: LotType[]) { - let result: LotType[] = [] - for(let lot of lots) { - result.push(await treatSingleLotTime(lot)); - } - return result; -} - -export async function treatSingleLotTime(lot: LotType) { - if(isDebugTime()) { - let current = await getCurrentTime(); - if(Math.floor(current/1000) != nowSeconds()) { - lot.begin.setHours(20, 20, 0, 0); - lot.end.setHours(22, 0, 0, 0); - return {...lot, begin: lot.begin, end: lot.end} - } - } - return lot + return processLotsFormat(lots); } // 拍卖行开始时间 今天20:20 @@ -237,7 +217,7 @@ export async function genAuction(guildCode: string, sourceType: number, sourceCo }), }; const dividend = await DividendModel.createDividend(dividendData); - await sendMessageToGuildWithSuc(guildCode, PUSH_ROUTE.AUCTION_ADD, { lots }); + await sendMessageToGuildWithSuc(guildCode, PUSH_ROUTE.AUCTION_ADD, { lots: processLotsFormat(lots) }); await sendMessageToGuildWithSuc(guildCode, PUSH_ROUTE.DIVIDEND_ADD, { dividends: processDividendFormat([dividend]) }); return { lots, dividend }; } @@ -473,20 +453,21 @@ export async function sendUngotDividend(debug = false) { */ export async function getAuction(guildCode: string, session: FrontendOrBackendSession, magicWord?: string) { const begin = await todayGuildBegin(); + const tomorrowBegin = await tomorrowGuildBegin(); let lots = magicWord === DEBUG_MAGIC_WORD ? await debugAuctionLots(session, begin) : await officialAuctionLots(session, begin); let dividends: DividendType[] = []; if(guildCode) { - dividends = await DividendModel.findGuildDividendsByBegin(guildCode, begin); + dividends = await DividendModel.findGuildDividendsByBegin(guildCode, [begin, tomorrowBegin]); } return { lots, dividends: processDividendFormat(dividends) }; } export async function pushAuctionOver(lot: LotType) { if(lot.auctionStage == AUCTION_STAGE.GUILD) { - await sendMessageToGuildWithSuc(lot.guildCode, PUSH_ROUTE.AUCTION_OVER, { lot }); + await sendMessageToGuildWithSuc(lot.guildCode, PUSH_ROUTE.AUCTION_OVER, { lot: processSingleLotFormat(lot) }); } else if (lot.auctionStage == AUCTION_STAGE.WORLD) { - await sendMessageToServerWithSuc(lot.serverId, PUSH_ROUTE.AUCTION_OVER, { lot }); + await sendMessageToServerWithSuc(lot.serverId, PUSH_ROUTE.AUCTION_OVER, { lot: processSingleLotFormat(lot) }); } } @@ -503,7 +484,7 @@ export async function pushAuctionUpdate(lots: LotType[], dividends: DividendType } for(let [guildCode, lots] of lotsResult) { - await sendMessageToGuildWithSuc(guildCode, PUSH_ROUTE.AUCTION_UPDATE, { lots }); + await sendMessageToGuildWithSuc(guildCode, PUSH_ROUTE.AUCTION_UPDATE, { lots: processLotsFormat(lots) }); } } else { @@ -517,7 +498,7 @@ export async function pushAuctionUpdate(lots: LotType[], dividends: DividendType } for(let [serverId, lots] of lotsResult) { - await sendMessageToServerWithSuc(serverId, PUSH_ROUTE.AUCTION_UPDATE, { lots }); + await sendMessageToServerWithSuc(serverId, PUSH_ROUTE.AUCTION_UPDATE, { lots: processLotsFormat(lots) }); } } let dividendsResult = new Map(); @@ -549,9 +530,19 @@ export async function checkAuctionStage(auctionStage: number) { } export function processSingleDividendFormat(dividend: DividendType) { - return pick(dividend, ['serverId', 'guildCode', 'sourceType', 'sourceCode', 'code', 'totalPrice', 'dividends', 'status']) + let newDividend = { ...dividend, begin: getSeconds(dividend.begin)} + return pick(newDividend, ['serverId', 'guildCode', 'sourceType', 'sourceCode', 'code', 'totalPrice', 'dividends', 'status', 'begin']) } export function processDividendFormat(dividends: DividendType[]) { return dividends.map(processSingleDividendFormat); +} + +export function processSingleLotFormat(lot: LotType) { + let newLot = { ...lot, begin: getSeconds(lot.begin), end: getSeconds(lot.end)} + return pick(newLot, ['auctionStage', 'sourceType', 'sourceCode', 'serverId', 'guildCode', 'code', 'gid', 'count', 'prePrice', 'curPrice', 'curBuyer', 'maxPrice', 'bidRoles', 'watchingRoles', 'begin', 'end', 'status', 'sort']) +} + +export function processLotsFormat(lots: LotType[]) { + return lots.map(processSingleLotFormat); } \ No newline at end of file diff --git a/game-server/app/services/guildActivity/guildActivityService.ts b/game-server/app/services/guildActivity/guildActivityService.ts index 45debc4ab..fad86b937 100644 --- a/game-server/app/services/guildActivity/guildActivityService.ts +++ b/game-server/app/services/guildActivity/guildActivityService.ts @@ -305,6 +305,7 @@ export async function settleGuildActivityReward(aid: number) { let obj = getCityActivityObj(); let { cities } = obj.getAllCities(); for (let { serverId, cityId } of cities) { + console.log('######', serverId, cityId) await cityActivitySettleReward(cityId, serverId); } } else if (aid == GUILD_ACTIVITY_TYPE.RACE_ACTIVITY) { diff --git a/shared/db/Dividend.ts b/shared/db/Dividend.ts index ff8f643c3..0ee1fe6b4 100644 --- a/shared/db/Dividend.ts +++ b/shared/db/Dividend.ts @@ -46,18 +46,18 @@ export default class Dividend extends BaseModel { return result; } - public static async findWorldDividendsByBegin(serverId: number, begin: Date) { - const results = await DividendModel.find({ serverId, begin }).select('-_id -__v').lean(); + public static async findWorldDividendsByBegin(serverId: number, begins: Date[]) { + const results = await DividendModel.find({ serverId, begin: { $in: begins } }).select('-_id -__v').lean(); return results; } - public static async findGuildDividendsByBegin(guildCode: string, begin: Date) { - const results = await DividendModel.find({ guildCode, begin }).select('-_id -__v').lean(); + public static async findGuildDividendsByBegin(guildCode: string, begins: Date[]) { + const results = await DividendModel.find({ guildCode, begin: { $in: begins } }).select('-_id -__v').lean(); return results; } - public static async findDividendByRoleAndBegin(roleId: string, begin: Date) { - const results = await DividendModel.find({ 'dividends.roleId': roleId, begin }).select('-_id -__v').lean(); + public static async findDividendByRoleAndBegin(roleId: string, begins: Date[]) { + const results = await DividendModel.find({ 'dividends.roleId': roleId, begin: { $in: begins } }).select('-_id -__v').lean(); return results; } public static async findDividendsByBegin(begin: Date) {