拍卖:修改推送逻辑
This commit is contained in:
@@ -43,6 +43,7 @@ export class GuildRemote {
|
||||
private GUILD_TRAIN_RESET = 'onGuildTainReset'; // 试炼场重置
|
||||
private GUILD_BOSS_ENCOURAGE = 'onGuildBossEncourage'; // 鼓舞
|
||||
private AUCTION_UPDATE = 'onAuctionUpdate'; // 拍卖行更新
|
||||
private AUCTION_ADD = 'onAuctionAdd'; // 拍卖行增加
|
||||
|
||||
/**
|
||||
* 封装,军团相关channel名: 'guild'+guildCode
|
||||
@@ -322,4 +323,8 @@ export class GuildRemote {
|
||||
public async pushAuctionUpdate(guildCode: string, param: { lots: LotType[]; dividends: DividendType[] }) {
|
||||
this.pushMessage(guildCode, this.AUCTION_UPDATE, param);
|
||||
}
|
||||
|
||||
public async pushAuctionAdd(guildCode: string, param: { lots: LotType[]; dividends: DividendType[] }) {
|
||||
this.pushMessage(guildCode, this.AUCTION_ADD, param);
|
||||
}
|
||||
}
|
||||
@@ -221,8 +221,9 @@ export async function genAuction(guildCode: string, sourceType: number, sourceCo
|
||||
}),
|
||||
};
|
||||
const dividend = await DividendModel.createDividend(dividendData);
|
||||
await pushAuctionUpdate(lots, [dividend]);
|
||||
return { lots, dividend };
|
||||
let channelSid = await getGuildChannelSid(guildCode);
|
||||
pinus.app.rpc.chat.guildRemote.pushAuctionAdd.toServer(channelSid, guildCode, { lots, dividends: [dividend] });
|
||||
return { lots, dividend };
|
||||
}
|
||||
|
||||
function posDividend(totalPrice: number, roleRatio: number, totalRatio: number) {
|
||||
@@ -458,36 +459,43 @@ export async function pushAuctionOver(lot: LotType) {
|
||||
}
|
||||
|
||||
export async function pushAuctionUpdate(lots: LotType[], dividends: DividendType[]) {
|
||||
let lotsResult = new Map<string, LotType[]>(), dividendsResult = new Map<string, DividendType[]>();
|
||||
let serverLotsResult = new Map<number, LotType[]>();
|
||||
for(let lot of lots) {
|
||||
if (lot.auctionStage === AUCTION_STAGE.DEFAULT || lot.auctionStage === AUCTION_STAGE.GUILD) {
|
||||
const stage = await auctionStage();
|
||||
if(stage === AUCTION_STAGE.DEFAULT || stage === AUCTION_STAGE.GUILD) {
|
||||
let lotsResult = new Map<string, LotType[]>(), dividendsResult = new Map<string, DividendType[]>();
|
||||
|
||||
for(let lot of lots) {
|
||||
if(!lotsResult.has(lot.guildCode)) {
|
||||
lotsResult.set(lot.guildCode, []);
|
||||
}
|
||||
lotsResult.get(lot.guildCode).push(lot);
|
||||
} else if (lot.auctionStage === AUCTION_STAGE.WORLD || lot.auctionStage === AUCTION_STAGE.END ) {
|
||||
if(!serverLotsResult.has(lot.serverId)) {
|
||||
serverLotsResult.set(lot.serverId, []);
|
||||
}
|
||||
for(let dividend of dividends) {
|
||||
if(!dividendsResult.has(dividend.guildCode)) {
|
||||
dividendsResult.set(dividend.guildCode, []);
|
||||
}
|
||||
serverLotsResult.get(lot.serverId).push(lot);
|
||||
dividendsResult.get(dividend.guildCode).push(dividend);
|
||||
}
|
||||
}
|
||||
for(let dividend of dividends) {
|
||||
if(!dividendsResult.has(dividend.guildCode)) {
|
||||
dividendsResult.set(dividend.guildCode, []);
|
||||
|
||||
for(let [guildCode, lots] of lotsResult) {
|
||||
let dividends = dividendsResult.get(guildCode)||[];
|
||||
let channelSid = await getGuildChannelSid(guildCode);
|
||||
pinus.app.rpc.chat.guildRemote.pushAuctionUpdate.toServer(channelSid, guildCode, { lots, dividends });
|
||||
}
|
||||
|
||||
} else {
|
||||
let lotsResult = new Map<number, LotType[]>();
|
||||
for(let lot of lots) {
|
||||
|
||||
if(!lotsResult.has(lot.serverId)) {
|
||||
lotsResult.set(lot.serverId, []);
|
||||
}
|
||||
lotsResult.get(lot.serverId).push(lot);
|
||||
}
|
||||
dividendsResult.get(dividend.guildCode).push(dividend);
|
||||
}
|
||||
|
||||
for(let [guildCode, lots] of lotsResult) {
|
||||
let dividends = dividendsResult.get(guildCode)||[];
|
||||
let channelSid = await getGuildChannelSid(guildCode);
|
||||
pinus.app.rpc.chat.guildRemote.pushAuctionUpdate.toServer(channelSid, guildCode, { lots, dividends });
|
||||
for(let [serverId, lots] of lotsResult) {
|
||||
let channelSid = await getWorldAuctionChannelSid(serverId);
|
||||
pinus.app.rpc.chat.chatRemote.sendAuctionUpdate.toServer(channelSid, serverId, { lots });
|
||||
}
|
||||
}
|
||||
|
||||
for(let [serverId, lots] of serverLotsResult) {
|
||||
let channelSid = await getWorldAuctionChannelSid(serverId);
|
||||
pinus.app.rpc.chat.chatRemote.sendAuctionUpdate.toServer(channelSid, serverId, { lots });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user