拍卖行:添加实时推送
This commit is contained in:
@@ -11,6 +11,7 @@ import { GeneralRankParam } from '../../../domain/rank';
|
||||
import { getAllGuildActivityStatus } from '../../../services/guildActivityService';
|
||||
import { MailParam } from '../../../domain/roleField/mail';
|
||||
import { RankFirstType } from '../../../db/RankFirst';
|
||||
import { LotType } from '../../../db/Lot';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
@@ -252,4 +253,26 @@ export class ChatRemote {
|
||||
channel.pushMessage('onPushCurrentTime', resResult(STATUS.SUCCESS, { time }));
|
||||
return { result: true, serverId };
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 实时推送军团拍卖出价
|
||||
* @param guildCode
|
||||
*/
|
||||
public async sendGuildAuction(guildCode: string, lot: LotType) {
|
||||
let roomId = groupRoomId(CHANNEL_PREFIX.GUILD_AUCTION, guildCode);
|
||||
let channel = this.channelService.getChannel(roomId, false);
|
||||
if(!channel) return false;
|
||||
|
||||
channel.pushMessage('onAuctionOver', resResult(STATUS.SUCCESS, { lot }));
|
||||
return true;
|
||||
}
|
||||
|
||||
public async sendWorldAuction(serverId: number, lot: LotType) {
|
||||
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD_AUCTION, serverId);
|
||||
let channel = this.channelService.getChannel(roomId, false);
|
||||
if(!channel) return false;
|
||||
|
||||
channel.pushMessage('onAuctionOver', resResult(STATUS.SUCCESS, { lot }));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import { SkinModel } from '../../../db/Skin';
|
||||
import { nowSeconds, getZeroPoint } from '../../../pubUtils/timeUtil';
|
||||
import { rmRoleFromQueue, roleLeave, getRoleOnlineInfo, roleLogin } from '../../../services/redisService';
|
||||
|
||||
import { addRoleToGuildChannel, addRoleToSysChannel, addRoleToWorldChannel, leaveGuildChannel, leaveSysChannel, leaveWorldChannel, recentGuildMsgs, recentPrivateChatInfos, recentSysMsgs, recentWorldMsgs } from '../../../services/chatService';
|
||||
import { addRoleToGuildChannel, addRoleToSysChannel, addRoleToWorldChannel, leaveGuildAuctionChannel, leaveGuildChannel, leaveSysChannel, leaveWorldAuctionChannel, leaveWorldChannel, recentGuildMsgs, recentPrivateChatInfos, recentSysMsgs, recentWorldMsgs } from '../../../services/chatService';
|
||||
import { reportOneOnline, savePlayTime } from '../../../services/authenticateService';
|
||||
import { Rank } from '../../../services/rankService';
|
||||
import { checkTaskWithRole, } from '../../../services/taskService';
|
||||
@@ -205,6 +205,8 @@ export class EntryHandler {
|
||||
await leaveSysChannel(roleId, sid, serverId);
|
||||
await leaveWorldChannel(roleId, sid, serverId);
|
||||
await leaveGuildChannel(roleId, sid, guildCode);
|
||||
await leaveGuildAuctionChannel(roleId, sid, guildCode);
|
||||
await leaveWorldAuctionChannel(roleId, sid, serverId);
|
||||
RoleModel.updateRoleInfo(roleId, { quitTime: nowSeconds() });
|
||||
if(teamCode) { // 如果有寻宝中的队伍,那么等于战败
|
||||
setComBtlOnUserLeave(roleId, teamCode)
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { DividendModel } 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 } from "../../../consts";
|
||||
import { AUCTION_STAGE, DEBUG_MAGIC_WORD, STATUS, CURRENCY_BY_TYPE, CURRENCY_TYPE, DATA_NAME, LOT_STATUS, CHANNEL_PREFIX, MAIL_TYPE } from "../../../consts";
|
||||
import { LotModel } from "../../../db/Lot";
|
||||
import { ItemReward } from "../../../domain/dbGeneral";
|
||||
import { resResult } from "../../../pubUtils/util";
|
||||
import { auctionStage, calculateDividend, genAuction, sendUngotDividend, startGuildAuction, startWorldAuction, stopAuction, todayGuildBegin, getBasePrice, debugAuctionLots, officialAuctionLots, auctionBidStatus, getMaxPrice, guildBidStatus, getAuction } from "../../../services/auctionService";
|
||||
import { auctionStage, calculateDividend, genAuction, sendUngotDividend, startGuildAuction, startWorldAuction, stopAuction, todayGuildBegin, getBasePrice, debugAuctionLots, officialAuctionLots, auctionBidStatus, getMaxPrice, guildBidStatus, getAuction, pushAuctionOver } from "../../../services/auctionService";
|
||||
import { addItems, handleCost } from '../../../services/rewardService';
|
||||
import { getSimpleRoleInfo } from '../../../services/roleService';
|
||||
import { getRoleOnlineInfo } from '../../../services/redisService';
|
||||
@@ -17,7 +17,10 @@ import { UserGuildModel } from '../../../db/UserGuild';
|
||||
import { UserGuildApplyModel } from '../../../db/UserGuildApply';
|
||||
import * as dicParam from '../../../pubUtils/dicParam';
|
||||
import { getAuctionRewardByPoolId } from '../../../pubUtils/data';
|
||||
import { channelServer, groupRoomId } from '../../../services/chatService';
|
||||
import { addRoleToGuildAuctionChannel, addRoleToWorldAuctionChannel, channelServer, groupRoomId, leaveGuildAuctionChannel } from '../../../services/chatService';
|
||||
import { RewardInter } from '../../../pubUtils/interface';
|
||||
import { sendMailByContent } from '../../../services/mailService';
|
||||
import { getGoldObject } from '../../../pubUtils/itemUtils';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
@@ -34,16 +37,37 @@ export class AuctionHandler {
|
||||
const { magicWord } = msg;
|
||||
|
||||
const guildCode = session.get('guildCode');
|
||||
// if (!guildCode) return resResult(STATUS.GUILD_NOT_FOUND);
|
||||
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');
|
||||
const roleName = session.get('roleName');
|
||||
const sid = session.get('sid');
|
||||
const serverId = session.get('serverId');
|
||||
const guildCode = session.get('guildCode');
|
||||
@@ -83,20 +107,16 @@ export class AuctionHandler {
|
||||
}
|
||||
|
||||
if (curBuyer) {
|
||||
const { roleName: buyerName } = await getSimpleRoleInfo(curBuyer);
|
||||
const { isOnline, sid: buyerSid } = await getRoleOnlineInfo(curBuyer);
|
||||
await addItems(curBuyer, buyerName, buyerSid, [{ id: CURRENCY_BY_TYPE.get(CURRENCY_TYPE.GOLD), count: curPrice }]);
|
||||
if (isOnline) {
|
||||
this.channelService.pushMessageByUids('onAuctionOver', resResult(STATUS.SUCCESS, { code }), [{ uid: curBuyer, sid: buyerSid }]);
|
||||
}
|
||||
await sendMailByContent(MAIL_TYPE.AUCTION_OVER, curBuyer, { goods: [getGoldObject(curPrice)] });
|
||||
}
|
||||
|
||||
if (maxFlag) {
|
||||
newPrice = maxPrice;
|
||||
await addItems(roleId, roleName, sid, [{ id: gid, count }]);
|
||||
await sendMailByContent(MAIL_TYPE.AUTION_REWARD, roleId, { goods: [{ id: gid, count }] });
|
||||
}
|
||||
bidRoles.push({ roleId, price: newPrice, time: new Date() });
|
||||
const newLot = await LotModel.updateLot({ code, curBuyer: roleId, curPrice: newPrice, bidRoles, status: max ? LOT_STATUS.MAX : (maxFlag ? LOT_STATUS.SOLD : LOT_STATUS.ING), watchingRoles: Array.from(new Set([...watchingRoles, roleId])) });
|
||||
await pushAuctionOver(newLot); // 推送竞价超过标志
|
||||
res.releaseCallback();
|
||||
|
||||
const incPrice = newPrice - (curBuyer ? curPrice : 0);
|
||||
|
||||
Reference in New Issue
Block a user