拍卖行:推送
This commit is contained in:
@@ -12,7 +12,7 @@ import { participants } from './guildActivityService';
|
||||
import { Member } from '../domain/battleField/guildActivity';
|
||||
import * as dicParam from '../pubUtils/dicParam';
|
||||
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) {
|
||||
@@ -221,6 +221,7 @@ export async function genAuction(guildCode: string, sourceType: number, sourceCo
|
||||
}),
|
||||
};
|
||||
const dividend = await DividendModel.createDividend(dividendData);
|
||||
await pushAuctionUpdate(lots, [dividend]);
|
||||
return { lots, dividend };
|
||||
}
|
||||
|
||||
@@ -276,8 +277,8 @@ export async function startGuildAuction() {
|
||||
try {
|
||||
console.log('schedule startGuildAuction called:', new Date());
|
||||
const begin = await todayGuildBegin();
|
||||
await LotModel.updateLotsStageByBegin(begin, AUCTION_STAGE.GUILD);
|
||||
await DividendModel.updateDividendsStatus(begin, DIVIDEND_STATUS.ING);
|
||||
let lots = await LotModel.updateLotsStageByBegin(begin, AUCTION_STAGE.GUILD);
|
||||
let dividends = await DividendModel.updateDividendsStatus(begin, DIVIDEND_STATUS.ING);
|
||||
|
||||
if(dicParam.SERVER_DEBUG_MODE.CURRENT_TIME == 1) {
|
||||
let day = getCurDay();
|
||||
@@ -286,6 +287,8 @@ export async function startGuildAuction() {
|
||||
await pushCurrentTime(time);
|
||||
}
|
||||
|
||||
await pushAuctionUpdate(lots, dividends);
|
||||
|
||||
return true;
|
||||
} catch (e) {
|
||||
console.error('startGuildAuction err: ', e);
|
||||
@@ -312,8 +315,8 @@ export async function startWorldAuction() {
|
||||
const begin = await todayGuildBegin();
|
||||
let lots = await LotModel.setLotSoldByBegin(begin); // 正在竞拍的拍品
|
||||
await sendLotsRewardToMlail(lots);
|
||||
await LotModel.updateUnSoldLotsStageByBegin(begin, AUCTION_STAGE.WORLD);
|
||||
await DividendModel.updateDividendsStatus(begin, DIVIDEND_STATUS.END);
|
||||
lots = await LotModel.updateUnSoldLotsStageByBegin(begin, AUCTION_STAGE.WORLD);
|
||||
let dividends = await DividendModel.updateDividendsStatus(begin, DIVIDEND_STATUS.END);
|
||||
|
||||
if(dicParam.SERVER_DEBUG_MODE.CURRENT_TIME == 1) {
|
||||
let day = getCurDay();
|
||||
@@ -321,6 +324,7 @@ export async function startWorldAuction() {
|
||||
pinus.app.rpc.guild.guildActivityRemote.setCurrentTime.broadcast(time);
|
||||
await pushCurrentTime(time);
|
||||
}
|
||||
await pushAuctionUpdate(lots, dividends);
|
||||
return true;
|
||||
} catch (e) {
|
||||
console.error('startWorldAuction err: ', e);
|
||||
@@ -334,7 +338,8 @@ export async function stopAuction() {
|
||||
const begin = await todayGuildBegin();
|
||||
let lots = await LotModel.setLotSoldByBegin(begin); // 正在竞拍的拍品
|
||||
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) {
|
||||
let day = getCurDay();
|
||||
@@ -342,6 +347,7 @@ export async function stopAuction() {
|
||||
pinus.app.rpc.guild.guildActivityRemote.setCurrentTime.broadcast(time);
|
||||
await pushCurrentTime(time);
|
||||
}
|
||||
await pushAuctionUpdate(lots, dividends);
|
||||
return true;
|
||||
} catch (e) {
|
||||
console.error('stopAuction err: ', e);
|
||||
@@ -449,4 +455,39 @@ export async function pushAuctionOver(lot: LotType) {
|
||||
let chatSid = await getWorldAuctionChannelSid(lot.serverId);
|
||||
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 == '') notice = ' ';
|
||||
let body = new CheckGuild37Params(guildCode, serverId, 2, notice);
|
||||
let result = await request37Post(SDK_37_ADDR.CHECK_UNION, body, SDK_37_CONST.CHAT_KEY);
|
||||
if(result == STATUS.REQUEST_TIME_OUT.code) { // 超时
|
||||
|
||||
Reference in New Issue
Block a user