拍卖:修改超越牌价推送

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
@@ -260,7 +260,7 @@ export class ChatRemote {
* @param guildCode * @param guildCode
*/ */
public async sendGuildAuction(guildCode: string, lot: LotType) { 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); let channel = this.channelService.getChannel(roomId, false);
if(!channel) return false; if(!channel) return false;
@@ -269,7 +269,7 @@ export class ChatRemote {
} }
public async sendWorldAuction(serverId: number, lot: LotType) { 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); let channel = this.channelService.getChannel(roomId, false);
if(!channel) return false; if(!channel) return false;
@@ -44,6 +44,8 @@ export class GuildRemote {
private GUILD_BOSS_ENCOURAGE = 'onGuildBossEncourage'; // 鼓舞 private GUILD_BOSS_ENCOURAGE = 'onGuildBossEncourage'; // 鼓舞
private AUCTION_UPDATE = 'onAuctionUpdate'; // 拍卖行更新 private AUCTION_UPDATE = 'onAuctionUpdate'; // 拍卖行更新
private AUCTION_ADD = 'onAuctionAdd'; // 拍卖行增加 private AUCTION_ADD = 'onAuctionAdd'; // 拍卖行增加
private DIVIDEND_UPDATE = 'onDividendsUpdate'; // 拍卖行更新
private DIVIDEND_ADD = 'onDividendsAdd';
/** /**
* 封装,军团相关channel名: 'guild'+guildCode * 封装,军团相关channel名: 'guild'+guildCode
@@ -321,10 +323,12 @@ export class GuildRemote {
} }
public async pushAuctionUpdate(guildCode: string, param: { lots: LotType[]; dividends: DividendType[] }) { 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[] }) { 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 });
} }
} }
@@ -37,34 +37,16 @@ export class AuctionHandler {
const { magicWord } = msg; const { magicWord } = msg;
const guildCode = session.get('guildCode'); 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); let result = await getAuction(guildCode, session, magicWord);
return resResult(STATUS.SUCCESS, result); return resResult(STATUS.SUCCESS, result);
} }
async leaveAuction(msg: {}, session: BackendSession) { 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); return resResult(STATUS.SUCCESS);
} }
async offer(msg: { code: string, max: boolean }, session: BackendSession) { async offer(msg: { code: string, max: boolean }, session: BackendSession) {
const { code, max } = msg; const { code, max } = msg;
const roleId = session.get('roleId'); const roleId = session.get('roleId');
+17 -13
View File
@@ -223,7 +223,7 @@ export async function genAuction(guildCode: string, sourceType: number, sourceCo
const dividend = await DividendModel.createDividend(dividendData); const dividend = await DividendModel.createDividend(dividendData);
let channelSid = await getGuildChannelSid(guildCode); let channelSid = await getGuildChannelSid(guildCode);
pinus.app.rpc.chat.guildRemote.pushAuctionAdd.toServer(channelSid, guildCode, { lots, dividends: [dividend] }); 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) { function posDividend(totalPrice: number, roleRatio: number, totalRatio: number) {
@@ -340,7 +340,6 @@ export async function stopAuction() {
let lots = await LotModel.setLotSoldByBegin(begin); // 正在竞拍的拍品 let lots = await LotModel.setLotSoldByBegin(begin); // 正在竞拍的拍品
await sendLotsRewardToMlail(lots); await sendLotsRewardToMlail(lots);
lots = await LotModel.updateLotsStageByBegin(begin, AUCTION_STAGE.END); lots = await LotModel.updateLotsStageByBegin(begin, AUCTION_STAGE.END);
let dividends = await DividendModel.findDividendsByBegin(begin);
if(dicParam.SERVER_DEBUG_MODE.CURRENT_TIME == 1) { if(dicParam.SERVER_DEBUG_MODE.CURRENT_TIME == 1) {
let day = getCurDay(); let day = getCurDay();
@@ -348,7 +347,7 @@ export async function stopAuction() {
pinus.app.rpc.guild.guildActivityRemote.setCurrentTime.broadcast(time); pinus.app.rpc.guild.guildActivityRemote.setCurrentTime.broadcast(time);
await pushCurrentTime(time); await pushCurrentTime(time);
} }
await pushAuctionUpdate(lots, dividends); await pushAuctionUpdate(lots, []);
return true; return true;
} catch (e) { } catch (e) {
console.error('stopAuction err: ', e); console.error('stopAuction err: ', e);
@@ -450,7 +449,7 @@ export async function getAuction(guildCode: string, session: FrontendOrBackendSe
export async function pushAuctionOver(lot: LotType) { export async function pushAuctionOver(lot: LotType) {
if(lot.auctionStage == AUCTION_STAGE.GUILD) { 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); pinus.app.rpc.chat.chatRemote.sendGuildAuction.toServer(chatSid, lot.guildCode, lot);
} else if (lot.auctionStage == AUCTION_STAGE.WORLD) { } else if (lot.auctionStage == AUCTION_STAGE.WORLD) {
let chatSid = await getWorldAuctionChannelSid(lot.serverId); let chatSid = await getWorldAuctionChannelSid(lot.serverId);
@@ -461,7 +460,7 @@ export async function pushAuctionOver(lot: LotType) {
export async function pushAuctionUpdate(lots: LotType[], dividends: DividendType[]) { export async function pushAuctionUpdate(lots: LotType[], dividends: DividendType[]) {
const stage = await auctionStage(); const stage = await auctionStage();
if(stage === AUCTION_STAGE.DEFAULT || stage === AUCTION_STAGE.GUILD) { 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) { for(let lot of lots) {
if(!lotsResult.has(lot.guildCode)) { if(!lotsResult.has(lot.guildCode)) {
@@ -469,17 +468,10 @@ export async function pushAuctionUpdate(lots: LotType[], dividends: DividendType
} }
lotsResult.get(lot.guildCode).push(lot); 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) { for(let [guildCode, lots] of lotsResult) {
let dividends = dividendsResult.get(guildCode)||[];
let channelSid = await getGuildChannelSid(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 { } else {
@@ -497,5 +489,17 @@ export async function pushAuctionUpdate(lots: LotType[], dividends: DividendType
pinus.app.rpc.chat.chatRemote.sendAuctionUpdate.toServer(channelSid, serverId, { lots }); 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 });
}
} }