拍卖:修改超越牌价推送

This commit is contained in:
luying
2021-11-24 18:08:01 +08:00
parent f7d51164b6
commit ccc80291b3
4 changed files with 26 additions and 36 deletions

View File

@@ -260,7 +260,7 @@ export class ChatRemote {
* @param guildCode
*/
public async sendGuildAuction(guildCode: string, lot: LotType) {
let roomId = groupRoomId(CHANNEL_PREFIX.GUILD_AUCTION, guildCode);
let roomId = groupRoomId(CHANNEL_PREFIX.GUILD, guildCode);
let channel = this.channelService.getChannel(roomId, false);
if(!channel) return false;
@@ -269,7 +269,7 @@ export class ChatRemote {
}
public async sendWorldAuction(serverId: number, lot: LotType) {
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD_AUCTION, serverId);
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD, serverId);
let channel = this.channelService.getChannel(roomId, false);
if(!channel) return false;

View File

@@ -44,6 +44,8 @@ export class GuildRemote {
private GUILD_BOSS_ENCOURAGE = 'onGuildBossEncourage'; // 鼓舞
private AUCTION_UPDATE = 'onAuctionUpdate'; // 拍卖行更新
private AUCTION_ADD = 'onAuctionAdd'; // 拍卖行增加
private DIVIDEND_UPDATE = 'onDividendsUpdate'; // 拍卖行更新
private DIVIDEND_ADD = 'onDividendsAdd';
/**
* 封装军团相关channel名: 'guild'+guildCode
@@ -321,10 +323,12 @@ export class GuildRemote {
}
public async pushAuctionUpdate(guildCode: string, param: { lots: LotType[]; dividends: DividendType[] }) {
this.pushMessage(guildCode, this.AUCTION_UPDATE, param);
if(param.lots) this.pushMessage(guildCode, this.AUCTION_UPDATE, { lots: param.lots });
if(param.dividends) this.pushMessage(guildCode, this.DIVIDEND_UPDATE, { dividends: param.dividends });
}
public async pushAuctionAdd(guildCode: string, param: { lots: LotType[]; dividends: DividendType[] }) {
this.pushMessage(guildCode, this.AUCTION_ADD, param);
if(param.lots) this.pushMessage(guildCode, this.AUCTION_ADD, { lots: param.lots });
if(param.dividends) this.pushMessage(guildCode, this.DIVIDEND_ADD, { dividends: param.dividends });
}
}

View File

@@ -37,34 +37,16 @@ export class AuctionHandler {
const { magicWord } = msg;
const guildCode = session.get('guildCode');
const serverId = session.get('serverId');
const roleId = session.get('roleId');
const sid = session.get('sid');
if(guildCode) {
await addRoleToGuildAuctionChannel(roleId, sid, guildCode);
}
await addRoleToWorldAuctionChannel(roleId, sid, serverId);
let result = await getAuction(guildCode, session, magicWord);
return resResult(STATUS.SUCCESS, result);
}
async leaveAuction(msg: {}, session: BackendSession) {
const guildCode = session.get('guildCode');
const serverId = session.get('serverId');
const roleId = session.get('roleId');
const sid = session.get('sid');
if(guildCode) {
await leaveGuildAuctionChannel(roleId, sid, guildCode);
}
await leaveGuildAuctionChannel(roleId, sid, serverId);
return resResult(STATUS.SUCCESS);
}
async offer(msg: { code: string, max: boolean }, session: BackendSession) {
const { code, max } = msg;
const roleId = session.get('roleId');

View File

@@ -223,7 +223,7 @@ export async function genAuction(guildCode: string, sourceType: number, sourceCo
const dividend = await DividendModel.createDividend(dividendData);
let channelSid = await getGuildChannelSid(guildCode);
pinus.app.rpc.chat.guildRemote.pushAuctionAdd.toServer(channelSid, guildCode, { lots, dividends: [dividend] });
return { lots, dividend };
return { lots, dividend };
}
function posDividend(totalPrice: number, roleRatio: number, totalRatio: number) {
@@ -340,7 +340,6 @@ export async function stopAuction() {
let lots = await LotModel.setLotSoldByBegin(begin); // 正在竞拍的拍品
await sendLotsRewardToMlail(lots);
lots = await LotModel.updateLotsStageByBegin(begin, AUCTION_STAGE.END);
let dividends = await DividendModel.findDividendsByBegin(begin);
if(dicParam.SERVER_DEBUG_MODE.CURRENT_TIME == 1) {
let day = getCurDay();
@@ -348,7 +347,7 @@ export async function stopAuction() {
pinus.app.rpc.guild.guildActivityRemote.setCurrentTime.broadcast(time);
await pushCurrentTime(time);
}
await pushAuctionUpdate(lots, dividends);
await pushAuctionUpdate(lots, []);
return true;
} catch (e) {
console.error('stopAuction err: ', e);
@@ -450,7 +449,7 @@ export async function getAuction(guildCode: string, session: FrontendOrBackendSe
export async function pushAuctionOver(lot: LotType) {
if(lot.auctionStage == AUCTION_STAGE.GUILD) {
let chatSid = await getGuildAuctionChannelSid(lot.guildCode);
let chatSid = await getGuildChannelSid(lot.guildCode);
pinus.app.rpc.chat.chatRemote.sendGuildAuction.toServer(chatSid, lot.guildCode, lot);
} else if (lot.auctionStage == AUCTION_STAGE.WORLD) {
let chatSid = await getWorldAuctionChannelSid(lot.serverId);
@@ -461,7 +460,7 @@ export async function pushAuctionOver(lot: LotType) {
export async function pushAuctionUpdate(lots: LotType[], dividends: DividendType[]) {
const stage = await auctionStage();
if(stage === AUCTION_STAGE.DEFAULT || stage === AUCTION_STAGE.GUILD) {
let lotsResult = new Map<string, LotType[]>(), dividendsResult = new Map<string, DividendType[]>();
let lotsResult = new Map<string, LotType[]>();
for(let lot of lots) {
if(!lotsResult.has(lot.guildCode)) {
@@ -469,17 +468,10 @@ export async function pushAuctionUpdate(lots: LotType[], dividends: DividendType
}
lotsResult.get(lot.guildCode).push(lot);
}
for(let dividend of dividends) {
if(!dividendsResult.has(dividend.guildCode)) {
dividendsResult.set(dividend.guildCode, []);
}
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 });
pinus.app.rpc.chat.guildRemote.pushAuctionUpdate.toServer(channelSid, guildCode, { lots });
}
} else {
@@ -497,5 +489,17 @@ export async function pushAuctionUpdate(lots: LotType[], dividends: DividendType
pinus.app.rpc.chat.chatRemote.sendAuctionUpdate.toServer(channelSid, serverId, { lots });
}
}
let dividendsResult = new Map<string, DividendType[]>();
for(let dividend of dividends) {
if(!dividendsResult.has(dividend.guildCode)) {
dividendsResult.set(dividend.guildCode, []);
}
dividendsResult.get(dividend.guildCode).push(dividend);
}
for(let [guildCode, dividends] of dividendsResult) {
let channelSid = await getGuildChannelSid(guildCode);
pinus.app.rpc.chat.guildRemote.pushAuctionUpdate.toServer(channelSid, guildCode, { dividends });
}
}