拍卖行:推送
This commit is contained in:
@@ -277,6 +277,15 @@ export class ChatRemote {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async sendAuctionUpdate(serverId: number, params: { lots: LotType[] }) {
|
||||||
|
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD, serverId);
|
||||||
|
let channel = this.channelService.getChannel(roomId, false);
|
||||||
|
if(!channel) return false;
|
||||||
|
|
||||||
|
channel.pushMessage('onAuctionUpdate', resResult(STATUS.SUCCESS, params));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public async checkFilterWords(word: string) {
|
public async checkFilterWords(word: string) {
|
||||||
return await _checkFilterWords(word);
|
return await _checkFilterWords(word);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import { leaveGuildChannel, groupRoomId } from '../../../services/chatService';
|
|||||||
import { GuildRankParams, WoodenHorse, Event } from '../../../domain/battleField/guildActivity';
|
import { GuildRankParams, WoodenHorse, Event } from '../../../domain/battleField/guildActivity';
|
||||||
import { MailParam } from '../../../domain/roleField/mail';
|
import { MailParam } from '../../../domain/roleField/mail';
|
||||||
import { pick } from 'underscore';
|
import { pick } from 'underscore';
|
||||||
|
import { LotType } from '../../../db/Lot';
|
||||||
|
import { DividendType } from '../../../db/Dividend';
|
||||||
|
|
||||||
export default function (app: Application) {
|
export default function (app: Application) {
|
||||||
new HandlerService(app, {});
|
new HandlerService(app, {});
|
||||||
@@ -40,6 +42,7 @@ export class GuildRemote {
|
|||||||
private GUILD_POP_UP_ACTIVITY = 'onActivityUpdate'; /// 向军团成员发送弹窗礼包
|
private GUILD_POP_UP_ACTIVITY = 'onActivityUpdate'; /// 向军团成员发送弹窗礼包
|
||||||
private GUILD_TRAIN_RESET = 'onGuildTainReset'; // 试炼场重置
|
private GUILD_TRAIN_RESET = 'onGuildTainReset'; // 试炼场重置
|
||||||
private GUILD_BOSS_ENCOURAGE = 'onGuildBossEncourage'; // 鼓舞
|
private GUILD_BOSS_ENCOURAGE = 'onGuildBossEncourage'; // 鼓舞
|
||||||
|
private AUCTION_UPDATE = 'onAuctionUpdate'; // 拍卖行更新
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 封装,军团相关channel名: 'guild'+guildCode
|
* 封装,军团相关channel名: 'guild'+guildCode
|
||||||
@@ -315,4 +318,8 @@ export class GuildRemote {
|
|||||||
public async pushEncourage(guildCode: string, param: {encourageCnt: number; encourageMax: number; myEncourageCnt: number;}) {
|
public async pushEncourage(guildCode: string, param: {encourageCnt: number; encourageMax: number; myEncourageCnt: number;}) {
|
||||||
this.pushMessage(guildCode, this.GUILD_BOSS_ENCOURAGE, param);
|
this.pushMessage(guildCode, this.GUILD_BOSS_ENCOURAGE, param);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async pushAuctionUpdate(guildCode: string, param: { lots: LotType[]; dividends: DividendType[] }) {
|
||||||
|
this.pushMessage(guildCode, this.AUCTION_UPDATE, param);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -12,7 +12,7 @@ import { participants } from './guildActivityService';
|
|||||||
import { Member } from '../domain/battleField/guildActivity';
|
import { Member } from '../domain/battleField/guildActivity';
|
||||||
import * as dicParam from '../pubUtils/dicParam';
|
import * as dicParam from '../pubUtils/dicParam';
|
||||||
import { RewardInter } from '../pubUtils/interface';
|
import { RewardInter } from '../pubUtils/interface';
|
||||||
import { getGuildAuctionChannelSid, getWorldAuctionChannelSid, pushCurrentTime } from './chatService';
|
import { getGuildAuctionChannelSid, getGuildChannelSid, getWorldAuctionChannelSid, pushCurrentTime } from './chatService';
|
||||||
|
|
||||||
// ! 获取底价,假数据
|
// ! 获取底价,假数据
|
||||||
export function getBasePrice(gid: number, count: number) {
|
export function getBasePrice(gid: number, count: number) {
|
||||||
@@ -221,6 +221,7 @@ export async function genAuction(guildCode: string, sourceType: number, sourceCo
|
|||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
const dividend = await DividendModel.createDividend(dividendData);
|
const dividend = await DividendModel.createDividend(dividendData);
|
||||||
|
await pushAuctionUpdate(lots, [dividend]);
|
||||||
return { lots, dividend };
|
return { lots, dividend };
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,8 +277,8 @@ export async function startGuildAuction() {
|
|||||||
try {
|
try {
|
||||||
console.log('schedule startGuildAuction called:', new Date());
|
console.log('schedule startGuildAuction called:', new Date());
|
||||||
const begin = await todayGuildBegin();
|
const begin = await todayGuildBegin();
|
||||||
await LotModel.updateLotsStageByBegin(begin, AUCTION_STAGE.GUILD);
|
let lots = await LotModel.updateLotsStageByBegin(begin, AUCTION_STAGE.GUILD);
|
||||||
await DividendModel.updateDividendsStatus(begin, DIVIDEND_STATUS.ING);
|
let dividends = await DividendModel.updateDividendsStatus(begin, DIVIDEND_STATUS.ING);
|
||||||
|
|
||||||
if(dicParam.SERVER_DEBUG_MODE.CURRENT_TIME == 1) {
|
if(dicParam.SERVER_DEBUG_MODE.CURRENT_TIME == 1) {
|
||||||
let day = getCurDay();
|
let day = getCurDay();
|
||||||
@@ -286,6 +287,8 @@ export async function startGuildAuction() {
|
|||||||
await pushCurrentTime(time);
|
await pushCurrentTime(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await pushAuctionUpdate(lots, dividends);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('startGuildAuction err: ', e);
|
console.error('startGuildAuction err: ', e);
|
||||||
@@ -312,8 +315,8 @@ export async function startWorldAuction() {
|
|||||||
const begin = await todayGuildBegin();
|
const begin = await todayGuildBegin();
|
||||||
let lots = await LotModel.setLotSoldByBegin(begin); // 正在竞拍的拍品
|
let lots = await LotModel.setLotSoldByBegin(begin); // 正在竞拍的拍品
|
||||||
await sendLotsRewardToMlail(lots);
|
await sendLotsRewardToMlail(lots);
|
||||||
await LotModel.updateUnSoldLotsStageByBegin(begin, AUCTION_STAGE.WORLD);
|
lots = await LotModel.updateUnSoldLotsStageByBegin(begin, AUCTION_STAGE.WORLD);
|
||||||
await DividendModel.updateDividendsStatus(begin, DIVIDEND_STATUS.END);
|
let dividends = await DividendModel.updateDividendsStatus(begin, DIVIDEND_STATUS.END);
|
||||||
|
|
||||||
if(dicParam.SERVER_DEBUG_MODE.CURRENT_TIME == 1) {
|
if(dicParam.SERVER_DEBUG_MODE.CURRENT_TIME == 1) {
|
||||||
let day = getCurDay();
|
let day = getCurDay();
|
||||||
@@ -321,6 +324,7 @@ export async function startWorldAuction() {
|
|||||||
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);
|
||||||
return true;
|
return true;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('startWorldAuction err: ', e);
|
console.error('startWorldAuction err: ', e);
|
||||||
@@ -334,7 +338,8 @@ export async function stopAuction() {
|
|||||||
const begin = await todayGuildBegin();
|
const begin = await todayGuildBegin();
|
||||||
let lots = await LotModel.setLotSoldByBegin(begin); // 正在竞拍的拍品
|
let lots = await LotModel.setLotSoldByBegin(begin); // 正在竞拍的拍品
|
||||||
await sendLotsRewardToMlail(lots);
|
await sendLotsRewardToMlail(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();
|
||||||
@@ -342,6 +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);
|
||||||
return true;
|
return true;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('stopAuction err: ', e);
|
console.error('stopAuction err: ', e);
|
||||||
@@ -449,4 +455,39 @@ export async function pushAuctionOver(lot: LotType) {
|
|||||||
let chatSid = await getWorldAuctionChannelSid(lot.serverId);
|
let chatSid = await getWorldAuctionChannelSid(lot.serverId);
|
||||||
pinus.app.rpc.chat.chatRemote.sendWorldAuction.toServer(chatSid, lot.serverId, lot);
|
pinus.app.rpc.chat.chatRemote.sendWorldAuction.toServer(chatSid, lot.serverId, lot);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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) {
|
||||||
|
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, []);
|
||||||
|
}
|
||||||
|
serverLotsResult.get(lot.serverId).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 });
|
||||||
|
}
|
||||||
|
|
||||||
|
for(let [serverId, lots] of serverLotsResult) {
|
||||||
|
let channelSid = await getWorldAuctionChannelSid(serverId);
|
||||||
|
pinus.app.rpc.chat.chatRemote.sendAuctionUpdate.toServer(channelSid, serverId, { lots });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -85,6 +85,7 @@ export async function checkGuildName(guildCode: string, serverId: number, name:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(notice != undefined) {
|
if(notice != undefined) {
|
||||||
|
if(notice == '') notice = ' ';
|
||||||
let body = new CheckGuild37Params(guildCode, serverId, 2, notice);
|
let body = new CheckGuild37Params(guildCode, serverId, 2, notice);
|
||||||
let result = await request37Post(SDK_37_ADDR.CHECK_UNION, body, SDK_37_CONST.CHAT_KEY);
|
let result = await request37Post(SDK_37_ADDR.CHECK_UNION, body, SDK_37_CONST.CHAT_KEY);
|
||||||
if(result == STATUS.REQUEST_TIME_OUT.code) { // 超时
|
if(result == STATUS.REQUEST_TIME_OUT.code) { // 超时
|
||||||
|
|||||||
+1
-1
@@ -38,7 +38,7 @@ export default class Api extends BaseModel {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export let ApiModel: ReturnModelType<typeof Api, {}>;
|
export let ApiModel: ReturnModelType<typeof Api, {}> = getModelForClass(Api);
|
||||||
export function loadApiModel(connect: mongoose.Connection) {
|
export function loadApiModel(connect: mongoose.Connection) {
|
||||||
ApiModel = getModelForClass(Api, {
|
ApiModel = getModelForClass(Api, {
|
||||||
existingConnection: connect
|
existingConnection: connect
|
||||||
|
|||||||
@@ -93,6 +93,8 @@ export default class Dividend extends BaseModel {
|
|||||||
|
|
||||||
public static async updateDividendsStatus(begin: Date, status: number) {
|
public static async updateDividendsStatus(begin: Date, status: number) {
|
||||||
await DividendModel.updateMany({ begin }, { status });
|
await DividendModel.updateMany({ begin }, { status });
|
||||||
|
const result: DividendType[] = await DividendModel.find({ begin }).select('-_id -__v').lean();
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ export default class GMGroup extends BaseModel {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export let GMGroupModel: ReturnModelType<typeof GMGroup, {}>;
|
export let GMGroupModel: ReturnModelType<typeof GMGroup, {}> = getModelForClass(GMGroup);
|
||||||
export function loadGMGroupModel(connect: mongoose.Connection) {
|
export function loadGMGroupModel(connect: mongoose.Connection) {
|
||||||
GMGroupModel = getModelForClass(GMGroup, {
|
GMGroupModel = getModelForClass(GMGroup, {
|
||||||
existingConnection: connect
|
existingConnection: connect
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ export default class GMRecord extends BaseModel {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export let GMRecordModel: ReturnModelType<typeof GMRecord, {}>;
|
export let GMRecordModel: ReturnModelType<typeof GMRecord, {}> = getModelForClass(GMRecord);
|
||||||
export function loadGMRecordModel(connect: mongoose.Connection) {
|
export function loadGMRecordModel(connect: mongoose.Connection) {
|
||||||
GMRecordModel = getModelForClass(GMRecord, {
|
GMRecordModel = getModelForClass(GMRecord, {
|
||||||
existingConnection: connect
|
existingConnection: connect
|
||||||
|
|||||||
+1
-1
@@ -85,7 +85,7 @@ export default class GMUser extends BaseModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export let GMUserModel: ReturnModelType<typeof GMUser, {}>;
|
export let GMUserModel: ReturnModelType<typeof GMUser, {}> = getModelForClass(GMUser);
|
||||||
export function loadGMUserModel(connect: mongoose.Connection) {
|
export function loadGMUserModel(connect: mongoose.Connection) {
|
||||||
GMUserModel = getModelForClass(GMUser, {
|
GMUserModel = getModelForClass(GMUser, {
|
||||||
existingConnection: connect
|
existingConnection: connect
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export default class GMUserGroup extends BaseModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export let GMUserGroupModel: ReturnModelType<typeof GMUserGroup, {}>;
|
export let GMUserGroupModel: ReturnModelType<typeof GMUserGroup, {}> = getModelForClass(GMUserGroup);
|
||||||
export function loadGMUserGroupModel(connect: mongoose.Connection) {
|
export function loadGMUserGroupModel(connect: mongoose.Connection) {
|
||||||
GMUserGroupModel = getModelForClass(GMUserGroup, {
|
GMUserGroupModel = getModelForClass(GMUserGroup, {
|
||||||
existingConnection: connect
|
existingConnection: connect
|
||||||
|
|||||||
+4
-2
@@ -122,12 +122,14 @@ export default class Lot extends BaseModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static async updateLotsStageByBegin(begin: Date, auctionStage: number) {
|
public static async updateLotsStageByBegin(begin: Date, auctionStage: number) {
|
||||||
const results = await LotModel.updateMany({ begin }, { auctionStage }).select('-_id -__v').lean();
|
await LotModel.updateMany({ begin }, { auctionStage });
|
||||||
|
const results: LotType[] = await LotModel.find({ begin }).select('-_id -__v').lean();
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async updateUnSoldLotsStageByBegin(begin: Date, auctionStage: number) {
|
public static async updateUnSoldLotsStageByBegin(begin: Date, auctionStage: number) {
|
||||||
const results = await LotModel.updateMany({ begin, status: { $in: [LOT_STATUS.DEFAULT, LOT_STATUS.ING] } }, { auctionStage }).select('-_id -__v').lean();
|
await LotModel.updateMany({ begin, status: { $in: [LOT_STATUS.DEFAULT, LOT_STATUS.ING] } }, { auctionStage });
|
||||||
|
const results: LotType[] = await LotModel.find({ begin, status: { $in: [LOT_STATUS.DEFAULT, LOT_STATUS.ING] } }).select('-_id -__v').lean();
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user