拍卖行:分红时间问题修改
This commit is contained in:
@@ -2,8 +2,8 @@ import { DividendModel } from './../db/Dividend';
|
||||
import { LOT_CODE_LEN, AUCTION_STAGE, AUCTION_TIME, DIVIDEND_CODE_LEN, DIVIDEND_STATUS, LOT_STATUS, MAIL_TYPE, CURRENCY_BY_TYPE, CURRENCY_TYPE, ROLE_RECEIVE_STATUS, AUCTION_BID_STATUS, DEBUG_MAGIC_WORD, AUCTION_SOURCE, TA_EVENT, getAuctionSourceTypeName, PUSH_ROUTE, GUILD_JOB } from './../consts';
|
||||
import { DividendRec, } from "../domain/dbGeneral";
|
||||
import { genCode, getRandSingleEelm } from '../pubUtils/util';
|
||||
import { LotModel, LotParam, LotType } from '../db/Lot';
|
||||
import { getCurDay, getTimeFunD, getTimeFunM, nowSeconds } from '../pubUtils/timeUtil';
|
||||
import Lot, { LotModel, LotParam, LotType } from '../db/Lot';
|
||||
import { getCurDay, getSeconds, getTimeFunD, getTimeFunM, nowSeconds } from '../pubUtils/timeUtil';
|
||||
import { gameData, getGoodById } from '../pubUtils/data';
|
||||
import { DividendParam, DividendType } from '../db/Dividend';
|
||||
import { sendMailByContent } from './mailService';
|
||||
@@ -56,27 +56,7 @@ export async function officialAuctionLots(session: FrontendOrBackendSession, beg
|
||||
}
|
||||
|
||||
|
||||
return await treatLotsTime(lots);
|
||||
}
|
||||
|
||||
export async function treatLotsTime(lots: LotType[]) {
|
||||
let result: LotType[] = []
|
||||
for(let lot of lots) {
|
||||
result.push(await treatSingleLotTime(lot));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export async function treatSingleLotTime(lot: LotType) {
|
||||
if(isDebugTime()) {
|
||||
let current = await getCurrentTime();
|
||||
if(Math.floor(current/1000) != nowSeconds()) {
|
||||
lot.begin.setHours(20, 20, 0, 0);
|
||||
lot.end.setHours(22, 0, 0, 0);
|
||||
return {...lot, begin: lot.begin, end: lot.end}
|
||||
}
|
||||
}
|
||||
return lot
|
||||
return processLotsFormat(lots);
|
||||
}
|
||||
|
||||
// 拍卖行开始时间 今天20:20
|
||||
@@ -237,7 +217,7 @@ export async function genAuction(guildCode: string, sourceType: number, sourceCo
|
||||
}),
|
||||
};
|
||||
const dividend = await DividendModel.createDividend(dividendData);
|
||||
await sendMessageToGuildWithSuc(guildCode, PUSH_ROUTE.AUCTION_ADD, { lots });
|
||||
await sendMessageToGuildWithSuc(guildCode, PUSH_ROUTE.AUCTION_ADD, { lots: processLotsFormat(lots) });
|
||||
await sendMessageToGuildWithSuc(guildCode, PUSH_ROUTE.DIVIDEND_ADD, { dividends: processDividendFormat([dividend]) });
|
||||
return { lots, dividend };
|
||||
}
|
||||
@@ -473,20 +453,21 @@ export async function sendUngotDividend(debug = false) {
|
||||
*/
|
||||
export async function getAuction(guildCode: string, session: FrontendOrBackendSession, magicWord?: string) {
|
||||
const begin = await todayGuildBegin();
|
||||
const tomorrowBegin = await tomorrowGuildBegin();
|
||||
let lots = magicWord === DEBUG_MAGIC_WORD ? await debugAuctionLots(session, begin) : await officialAuctionLots(session, begin);
|
||||
|
||||
let dividends: DividendType[] = [];
|
||||
if(guildCode) {
|
||||
dividends = await DividendModel.findGuildDividendsByBegin(guildCode, begin);
|
||||
dividends = await DividendModel.findGuildDividendsByBegin(guildCode, [begin, tomorrowBegin]);
|
||||
}
|
||||
return { lots, dividends: processDividendFormat(dividends) };
|
||||
}
|
||||
|
||||
export async function pushAuctionOver(lot: LotType) {
|
||||
if(lot.auctionStage == AUCTION_STAGE.GUILD) {
|
||||
await sendMessageToGuildWithSuc(lot.guildCode, PUSH_ROUTE.AUCTION_OVER, { lot });
|
||||
await sendMessageToGuildWithSuc(lot.guildCode, PUSH_ROUTE.AUCTION_OVER, { lot: processSingleLotFormat(lot) });
|
||||
} else if (lot.auctionStage == AUCTION_STAGE.WORLD) {
|
||||
await sendMessageToServerWithSuc(lot.serverId, PUSH_ROUTE.AUCTION_OVER, { lot });
|
||||
await sendMessageToServerWithSuc(lot.serverId, PUSH_ROUTE.AUCTION_OVER, { lot: processSingleLotFormat(lot) });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -503,7 +484,7 @@ export async function pushAuctionUpdate(lots: LotType[], dividends: DividendType
|
||||
}
|
||||
|
||||
for(let [guildCode, lots] of lotsResult) {
|
||||
await sendMessageToGuildWithSuc(guildCode, PUSH_ROUTE.AUCTION_UPDATE, { lots });
|
||||
await sendMessageToGuildWithSuc(guildCode, PUSH_ROUTE.AUCTION_UPDATE, { lots: processLotsFormat(lots) });
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -517,7 +498,7 @@ export async function pushAuctionUpdate(lots: LotType[], dividends: DividendType
|
||||
}
|
||||
|
||||
for(let [serverId, lots] of lotsResult) {
|
||||
await sendMessageToServerWithSuc(serverId, PUSH_ROUTE.AUCTION_UPDATE, { lots });
|
||||
await sendMessageToServerWithSuc(serverId, PUSH_ROUTE.AUCTION_UPDATE, { lots: processLotsFormat(lots) });
|
||||
}
|
||||
}
|
||||
let dividendsResult = new Map<string, DividendType[]>();
|
||||
@@ -549,9 +530,19 @@ export async function checkAuctionStage(auctionStage: number) {
|
||||
}
|
||||
|
||||
export function processSingleDividendFormat(dividend: DividendType) {
|
||||
return pick(dividend, ['serverId', 'guildCode', 'sourceType', 'sourceCode', 'code', 'totalPrice', 'dividends', 'status'])
|
||||
let newDividend = { ...dividend, begin: getSeconds(dividend.begin)}
|
||||
return pick(newDividend, ['serverId', 'guildCode', 'sourceType', 'sourceCode', 'code', 'totalPrice', 'dividends', 'status', 'begin'])
|
||||
}
|
||||
|
||||
export function processDividendFormat(dividends: DividendType[]) {
|
||||
return dividends.map(processSingleDividendFormat);
|
||||
}
|
||||
|
||||
export function processSingleLotFormat(lot: LotType) {
|
||||
let newLot = { ...lot, begin: getSeconds(lot.begin), end: getSeconds(lot.end)}
|
||||
return pick(newLot, ['auctionStage', 'sourceType', 'sourceCode', 'serverId', 'guildCode', 'code', 'gid', 'count', 'prePrice', 'curPrice', 'curBuyer', 'maxPrice', 'bidRoles', 'watchingRoles', 'begin', 'end', 'status', 'sort'])
|
||||
}
|
||||
|
||||
export function processLotsFormat(lots: LotType[]) {
|
||||
return lots.map(processSingleLotFormat);
|
||||
}
|
||||
@@ -305,6 +305,7 @@ export async function settleGuildActivityReward(aid: number) {
|
||||
let obj = getCityActivityObj();
|
||||
let { cities } = obj.getAllCities();
|
||||
for (let { serverId, cityId } of cities) {
|
||||
console.log('######', serverId, cityId)
|
||||
await cityActivitySettleReward(cityId, serverId);
|
||||
}
|
||||
} else if (aid == GUILD_ACTIVITY_TYPE.RACE_ACTIVITY) {
|
||||
|
||||
Reference in New Issue
Block a user