拍卖行:调整接口以便测试

This commit is contained in:
liangtongchuan
2021-03-23 10:43:12 +08:00
parent ecb4b87abc
commit 6eb1a1976f
2 changed files with 44 additions and 14 deletions
@@ -5,7 +5,7 @@ import { AUCTION_STAGE, DEBUG_MAGIC_WORD, STATUS, OFFER_RATIO, CURRENCY_BY_TYPE,
import { LotModel } from "../../../db/Lot";
import { ItemReward, LotRec } from "../../../domain/dbGeneral";
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 { getSimpleRoleInfo } from '../../../services/roleService';
import { getRoleOnlineInfo } from '../../../services/redisService';
@@ -21,18 +21,14 @@ export class AuctionHandler {
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 serverId = session.get('serverId');
if (!guildCode) return resResult(STATUS.GUILD_NOT_FOUND);
const begin = todayGuildBegin();
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);
}
let lots = magicWord === DEBUG_MAGIC_WORD ? await debugAuctionLots(session, begin) : await officialAuctionLots(session, begin);
const dividends = await DividendModel.findGuildDividendsByBegin(guildCode, begin);
return resResult(STATUS.SUCCESS, { lots, dividends });
}
@@ -57,8 +53,7 @@ export class AuctionHandler {
return resResult(STATUS.GUILD_LOT_NOT_FOUND);
}
const stage = auctionStage();
if (stage === AUCTION_STAGE.GUILD && lot.guildCode !== guildCode) {
if (lot.auctionStage === AUCTION_STAGE.GUILD && lot.guildCode !== guildCode) {
res.releaseCallback();
return resResult(STATUS.AUCTION_GUILD_MEMBER_ONLY);
}
@@ -96,7 +91,7 @@ export class AuctionHandler {
const incPrice = newPrice - (curBuyer ? curPrice : 0);
let newDividend = null;
if (stage === AUCTION_STAGE.GUILD) {
if (lot.auctionStage === AUCTION_STAGE.GUILD) {
const dividend = await DividendModel.updateLot(code, gid, newPrice, incPrice, max);
newDividend = await calculateDividend(dividend);
}
@@ -232,6 +227,10 @@ export class AuctionHandler {
// ! 测试接口
async debugScheduleStartGuild(msg: { magicWord: string }, session: BackendSession) {
const { magicWord } = msg;
if (magicWord !== DEBUG_MAGIC_WORD) {
return resResult(STATUS.TOKEN_ERR);
}
const result = await startGuildAuction();
if (result === true) {
return resResult(STATUS.SUCCESS);
@@ -241,6 +240,10 @@ export class AuctionHandler {
// ! 测试接口
async debugScheduleStartWorld(msg: { magicWord: string }, session: BackendSession) {
const { magicWord } = msg;
if (magicWord !== DEBUG_MAGIC_WORD) {
return resResult(STATUS.TOKEN_ERR);
}
const result = await startWorldAuction();
if (result === true) {
return resResult(STATUS.SUCCESS);
@@ -250,6 +253,10 @@ export class AuctionHandler {
// ! 测试接口
async debugScheduleStopAuction(msg: { magicWord: string }, session: BackendSession) {
const { magicWord } = msg;
if (magicWord !== DEBUG_MAGIC_WORD) {
return resResult(STATUS.TOKEN_ERR);
}
const result = await stopAuction();
if (result === true) {
return resResult(STATUS.SUCCESS);
@@ -259,6 +266,10 @@ export class AuctionHandler {
// ! 测试接口
async debugScheduleSendUngotDividend(msg: { magicWord: string }, session: BackendSession) {
const { magicWord } = msg;
if (magicWord !== DEBUG_MAGIC_WORD) {
return resResult(STATUS.TOKEN_ERR);
}
const result = await sendUngotDividend();
if (result === true) {
return resResult(STATUS.SUCCESS);