diff --git a/game-server/app/servers/guild/handler/auctionHandler.ts b/game-server/app/servers/guild/handler/auctionHandler.ts index c985acdd4..421837ec9 100644 --- a/game-server/app/servers/guild/handler/auctionHandler.ts +++ b/game-server/app/servers/guild/handler/auctionHandler.ts @@ -1,10 +1,10 @@ -import { DividendModel } from './../../../db/Dividend'; +import { DividendModel, DividendType } from './../../../db/Dividend'; import { Application, BackendSession, ChannelService, HandlerService, pinus, } from "pinus"; import { AUCTION_STAGE, DEBUG_MAGIC_WORD, STATUS, CURRENCY_BY_TYPE, CURRENCY_TYPE, DATA_NAME, LOT_STATUS, CHANNEL_PREFIX, MAIL_TYPE, ITEM_CHANGE_REASON, TA_EVENT, ROLE_RECEIVE_STATUS, PUSH_ROUTE } from "../../../consts"; 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 } from "../../../services/auctionService"; +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 { addItems, getGoldObject, handleCost } from '../../../services/role/rewardService'; import { getSimpleRoleInfo } from '../../../services/roleService'; import { getRoleOnlineInfo } from '../../../services/redisService'; @@ -21,7 +21,7 @@ import { addRoleToGuildAuctionChannel, addRoleToWorldAuctionChannel, channelServ import { RewardInter } from '../../../pubUtils/interface'; import { sendMailByContent } from '../../../services/mailService'; import { reportTAEvent } from '../../../services/sdkService'; -import { sendMessageToServerWithSuc } from '../../../services/pushService'; +import { sendMessageToGuildWithSuc, sendMessageToServerWithSuc } from '../../../services/pushService'; export default function (app: Application) { new HandlerService(app, {}); @@ -119,13 +119,14 @@ export class AuctionHandler { res.releaseCallback(); const incPrice = curPrice - prePrice > 0? prePrice: 0; - let newDividend = null; + let newDividend: DividendType = null; if (auctionStage === AUCTION_STAGE.GUILD) { const dividend = await DividendModel.updateLot(code, gid, curPrice, incPrice, max); newDividend = await calculateDividend(dividend); } let newLotResult = await treatSingleLotTime(newLot); - return resResult(STATUS.SUCCESS, { lot: newLotResult, dividend: newDividend }); + await sendMessageToGuildWithSuc(guildCode, PUSH_ROUTE.DIVIDEND_UPDATE, { dividends: processDividendFormat([newDividend]) }) + return resResult(STATUS.SUCCESS, { lot: newLotResult, dividend: processSingleDividendFormat(newDividend) }); } catch (e) { console.log('offer got err:', e); res.releaseCallback(); @@ -154,7 +155,7 @@ export class AuctionHandler { 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 }); + return resResult(STATUS.SUCCESS, { dividends: processDividendFormat(dividends) }); } async getDividend(msg: { code: string }, session: BackendSession) { diff --git a/game-server/app/services/auctionService.ts b/game-server/app/services/auctionService.ts index ba8e9346d..f5e800885 100644 --- a/game-server/app/services/auctionService.ts +++ b/game-server/app/services/auctionService.ts @@ -16,6 +16,7 @@ import { reportTAEvent } from './sdkService'; import { getAllServers } from './redisService'; import { sendMessageToGuildWithSuc, sendMessageToServer, sendMessageToServerWithSuc } from './pushService'; import { isDebugTime } from '../pubUtils/sdkUtil'; +import { pick } from 'underscore'; // ! 获取底价,假数据 export function getBasePrice(gid: number, count: number) { @@ -237,7 +238,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.DIVIDEND_ADD, { dividends: [dividend] }); + await sendMessageToGuildWithSuc(guildCode, PUSH_ROUTE.DIVIDEND_ADD, { dividends: processDividendFormat([dividend]) }); return { lots, dividend }; } @@ -477,7 +478,7 @@ export async function getAuction(guildCode: string, session: FrontendOrBackendSe if(guildCode) { dividends = await DividendModel.findGuildDividendsByBegin(guildCode, begin); } - return { lots, dividends }; + return { lots, dividends: processDividendFormat(dividends) }; } export async function pushAuctionOver(lot: LotType) { @@ -526,7 +527,7 @@ export async function pushAuctionUpdate(lots: LotType[], dividends: DividendType dividendsResult.get(dividend.guildCode).push(dividend); } for(let [guildCode, dividends] of dividendsResult) { - await sendMessageToGuildWithSuc(guildCode, PUSH_ROUTE.DIVIDEND_UPDATE, { dividends }) + await sendMessageToGuildWithSuc(guildCode, PUSH_ROUTE.DIVIDEND_UPDATE, { dividends: processDividendFormat(dividends) }) } @@ -544,4 +545,12 @@ export async function checkAuctionStage(auctionStage: number) { if(curTime > (await todayWorldEnd()).getTime() + 10 * 60 * 1000) return false } return true +} + +export function processSingleDividendFormat(dividend: DividendType) { + return pick(dividend, ['serverId', 'guildCode', 'sourceType', 'sourceCode', 'code', 'totalPrice', 'dividends']) +} + +export function processDividendFormat(dividends: DividendType[]) { + return dividends.map(processSingleDividendFormat); } \ No newline at end of file