拍卖行:调整接口以便测试
This commit is contained in:
@@ -5,7 +5,7 @@ import { AUCTION_STAGE, DEBUG_MAGIC_WORD, STATUS, OFFER_RATIO, CURRENCY_BY_TYPE,
|
|||||||
import { LotModel } from "../../../db/Lot";
|
import { LotModel } from "../../../db/Lot";
|
||||||
import { ItemReward, LotRec } from "../../../domain/dbGeneral";
|
import { ItemReward, LotRec } from "../../../domain/dbGeneral";
|
||||||
import { resResult } from "../../../pubUtils/util";
|
import { resResult } from "../../../pubUtils/util";
|
||||||
import { auctionStage, calculateDividend, genAuction, sendUngotDividend, startGuildAuction, startWorldAuction, stopAuction, todayGuildBegin, getBasePrice } from "../../../services/auctionService";
|
import { auctionStage, calculateDividend, genAuction, sendUngotDividend, startGuildAuction, startWorldAuction, stopAuction, todayGuildBegin, getBasePrice, debugAuctionLots, officialAuctionLots } from "../../../services/auctionService";
|
||||||
import { addItems, handleCost } from '../../../services/rewardService';
|
import { addItems, handleCost } from '../../../services/rewardService';
|
||||||
import { getSimpleRoleInfo } from '../../../services/roleService';
|
import { getSimpleRoleInfo } from '../../../services/roleService';
|
||||||
import { getRoleOnlineInfo } from '../../../services/redisService';
|
import { getRoleOnlineInfo } from '../../../services/redisService';
|
||||||
@@ -21,18 +21,14 @@ export class AuctionHandler {
|
|||||||
this.channelService = app.get('channelService');
|
this.channelService = app.get('channelService');
|
||||||
}
|
}
|
||||||
|
|
||||||
async getAuction(msg: {}, session: BackendSession) {
|
async getAuction(msg: { magicWord: string }, session: BackendSession) {
|
||||||
|
const { magicWord } = msg;
|
||||||
|
|
||||||
const guildCode = session.get('guildCode');
|
const guildCode = session.get('guildCode');
|
||||||
const serverId = session.get('serverId');
|
|
||||||
if (!guildCode) return resResult(STATUS.GUILD_NOT_FOUND);
|
if (!guildCode) return resResult(STATUS.GUILD_NOT_FOUND);
|
||||||
const begin = todayGuildBegin();
|
const begin = todayGuildBegin();
|
||||||
const stage = auctionStage();
|
let lots = magicWord === DEBUG_MAGIC_WORD ? await debugAuctionLots(session, begin) : await officialAuctionLots(session, begin);
|
||||||
let lots = [];
|
|
||||||
if (stage === AUCTION_STAGE.DEFAULT || stage === AUCTION_STAGE.GUILD) {
|
|
||||||
lots = await LotModel.findGuildLotsByBegin(guildCode, begin);
|
|
||||||
} else if (stage === AUCTION_STAGE.WORLD) {
|
|
||||||
lots = await LotModel.findWorldLotsByBegin(serverId, begin);
|
|
||||||
}
|
|
||||||
const dividends = await DividendModel.findGuildDividendsByBegin(guildCode, begin);
|
const dividends = await DividendModel.findGuildDividendsByBegin(guildCode, begin);
|
||||||
return resResult(STATUS.SUCCESS, { lots, dividends });
|
return resResult(STATUS.SUCCESS, { lots, dividends });
|
||||||
}
|
}
|
||||||
@@ -57,8 +53,7 @@ export class AuctionHandler {
|
|||||||
return resResult(STATUS.GUILD_LOT_NOT_FOUND);
|
return resResult(STATUS.GUILD_LOT_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
const stage = auctionStage();
|
if (lot.auctionStage === AUCTION_STAGE.GUILD && lot.guildCode !== guildCode) {
|
||||||
if (stage === AUCTION_STAGE.GUILD && lot.guildCode !== guildCode) {
|
|
||||||
res.releaseCallback();
|
res.releaseCallback();
|
||||||
return resResult(STATUS.AUCTION_GUILD_MEMBER_ONLY);
|
return resResult(STATUS.AUCTION_GUILD_MEMBER_ONLY);
|
||||||
}
|
}
|
||||||
@@ -96,7 +91,7 @@ export class AuctionHandler {
|
|||||||
|
|
||||||
const incPrice = newPrice - (curBuyer ? curPrice : 0);
|
const incPrice = newPrice - (curBuyer ? curPrice : 0);
|
||||||
let newDividend = null;
|
let newDividend = null;
|
||||||
if (stage === AUCTION_STAGE.GUILD) {
|
if (lot.auctionStage === AUCTION_STAGE.GUILD) {
|
||||||
const dividend = await DividendModel.updateLot(code, gid, newPrice, incPrice, max);
|
const dividend = await DividendModel.updateLot(code, gid, newPrice, incPrice, max);
|
||||||
newDividend = await calculateDividend(dividend);
|
newDividend = await calculateDividend(dividend);
|
||||||
}
|
}
|
||||||
@@ -232,6 +227,10 @@ export class AuctionHandler {
|
|||||||
|
|
||||||
// ! 测试接口
|
// ! 测试接口
|
||||||
async debugScheduleStartGuild(msg: { magicWord: string }, session: BackendSession) {
|
async debugScheduleStartGuild(msg: { magicWord: string }, session: BackendSession) {
|
||||||
|
const { magicWord } = msg;
|
||||||
|
if (magicWord !== DEBUG_MAGIC_WORD) {
|
||||||
|
return resResult(STATUS.TOKEN_ERR);
|
||||||
|
}
|
||||||
const result = await startGuildAuction();
|
const result = await startGuildAuction();
|
||||||
if (result === true) {
|
if (result === true) {
|
||||||
return resResult(STATUS.SUCCESS);
|
return resResult(STATUS.SUCCESS);
|
||||||
@@ -241,6 +240,10 @@ export class AuctionHandler {
|
|||||||
|
|
||||||
// ! 测试接口
|
// ! 测试接口
|
||||||
async debugScheduleStartWorld(msg: { magicWord: string }, session: BackendSession) {
|
async debugScheduleStartWorld(msg: { magicWord: string }, session: BackendSession) {
|
||||||
|
const { magicWord } = msg;
|
||||||
|
if (magicWord !== DEBUG_MAGIC_WORD) {
|
||||||
|
return resResult(STATUS.TOKEN_ERR);
|
||||||
|
}
|
||||||
const result = await startWorldAuction();
|
const result = await startWorldAuction();
|
||||||
if (result === true) {
|
if (result === true) {
|
||||||
return resResult(STATUS.SUCCESS);
|
return resResult(STATUS.SUCCESS);
|
||||||
@@ -250,6 +253,10 @@ export class AuctionHandler {
|
|||||||
|
|
||||||
// ! 测试接口
|
// ! 测试接口
|
||||||
async debugScheduleStopAuction(msg: { magicWord: string }, session: BackendSession) {
|
async debugScheduleStopAuction(msg: { magicWord: string }, session: BackendSession) {
|
||||||
|
const { magicWord } = msg;
|
||||||
|
if (magicWord !== DEBUG_MAGIC_WORD) {
|
||||||
|
return resResult(STATUS.TOKEN_ERR);
|
||||||
|
}
|
||||||
const result = await stopAuction();
|
const result = await stopAuction();
|
||||||
if (result === true) {
|
if (result === true) {
|
||||||
return resResult(STATUS.SUCCESS);
|
return resResult(STATUS.SUCCESS);
|
||||||
@@ -259,6 +266,10 @@ export class AuctionHandler {
|
|||||||
|
|
||||||
// ! 测试接口
|
// ! 测试接口
|
||||||
async debugScheduleSendUngotDividend(msg: { magicWord: string }, session: BackendSession) {
|
async debugScheduleSendUngotDividend(msg: { magicWord: string }, session: BackendSession) {
|
||||||
|
const { magicWord } = msg;
|
||||||
|
if (magicWord !== DEBUG_MAGIC_WORD) {
|
||||||
|
return resResult(STATUS.TOKEN_ERR);
|
||||||
|
}
|
||||||
const result = await sendUngotDividend();
|
const result = await sendUngotDividend();
|
||||||
if (result === true) {
|
if (result === true) {
|
||||||
return resResult(STATUS.SUCCESS);
|
return resResult(STATUS.SUCCESS);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import { gameData, getGoodById } from '../pubUtils/data';
|
|||||||
import { DividendParam, DividendType } from '../db/Dividend';
|
import { DividendParam, DividendType } from '../db/Dividend';
|
||||||
import { pushMail } from '../pubUtils/interface';
|
import { pushMail } from '../pubUtils/interface';
|
||||||
import { getMailContent } from './mailService';
|
import { getMailContent } from './mailService';
|
||||||
import { pinus } from 'pinus';
|
import { pinus, BackendSession } from 'pinus';
|
||||||
import { participants } from './guildActivityService';
|
import { participants } from './guildActivityService';
|
||||||
import { Member } from '../domain/battleField/guildActivity';
|
import { Member } from '../domain/battleField/guildActivity';
|
||||||
|
|
||||||
@@ -33,6 +33,25 @@ export function auctionStage() {
|
|||||||
if (curTime > todayWorldEnd().getTime()) return AUCTION_STAGE.END;
|
if (curTime > todayWorldEnd().getTime()) return AUCTION_STAGE.END;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function debugAuctionLots(session: BackendSession, begin: Date) {
|
||||||
|
const serverId = session.get('serverId');
|
||||||
|
const lots = await LotModel.findWorldLotsByBegin(serverId, begin);
|
||||||
|
return lots;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function officialAuctionLots(session: BackendSession, begin: Date) {
|
||||||
|
const serverId = session.get('serverId');
|
||||||
|
const guildCode = session.get('guildCode');
|
||||||
|
const stage = auctionStage();
|
||||||
|
let lots = [];
|
||||||
|
if (stage === AUCTION_STAGE.DEFAULT || stage === AUCTION_STAGE.GUILD) {
|
||||||
|
lots = await LotModel.findGuildLotsByBegin(guildCode, begin);
|
||||||
|
} else if (stage === AUCTION_STAGE.WORLD) {
|
||||||
|
lots = await LotModel.findWorldLotsByBegin(serverId, begin);
|
||||||
|
}
|
||||||
|
return lots;
|
||||||
|
}
|
||||||
|
|
||||||
export function auctionBegin() {
|
export function auctionBegin() {
|
||||||
return getNextTime(new Date(), AUCTION_TIME.GUILD_BEGIN_HOUR, AUCTION_TIME.GUILD_BEGIN_MIN);
|
return getNextTime(new Date(), AUCTION_TIME.GUILD_BEGIN_HOUR, AUCTION_TIME.GUILD_BEGIN_MIN);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user