拍卖行:增加测试接口和用例
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { AUCTION_BID_STATUS } from './../../../consts/constModules/auctionConst';
|
||||
import { AUCTION_BID_STATUS, DIVIDEND_STATUS } from './../../../consts/constModules/auctionConst';
|
||||
import { DividendModel } from './../../../db/Dividend';
|
||||
import { Application, BackendSession, ChannelService } from "pinus";
|
||||
import { AUCTION_STAGE, DEBUG_MAGIC_WORD, STATUS, OFFER_RATIO, CURRENCY_BY_TYPE, CURRENCY_TYPE, DATA_NAME, LOT_STATUS } from "../../../consts";
|
||||
@@ -78,7 +78,7 @@ export class AuctionHandler {
|
||||
const { sid: buyerSid } = await getRoleOnlineInfo(buyerName);
|
||||
await addItems(curBuyer, buyerName, buyerSid, [{ id: CURRENCY_BY_TYPE.get(CURRENCY_TYPE.GOLD), count: curPrice }]);
|
||||
}
|
||||
// TODO 元宝返还纪录
|
||||
|
||||
if (maxFlag) {
|
||||
newPrice = maxPrice;
|
||||
await addItems(roleId, roleName, sid, [{ id: gid, count }]);
|
||||
@@ -159,20 +159,30 @@ export class AuctionHandler {
|
||||
}
|
||||
|
||||
// ! 测试接口
|
||||
async debugSetDividendReady(msg: { magicWord: string, sourceType: number}, session: BackendSession) {
|
||||
const { magicWord, sourceType } = msg;
|
||||
async debugSetDividendStatus(msg: { magicWord: string, sourceType: number, status: number }, session: BackendSession) {
|
||||
const { magicWord, sourceType, status } = msg;
|
||||
if (magicWord !== DEBUG_MAGIC_WORD) {
|
||||
return resResult(STATUS.TOKEN_ERR);
|
||||
}
|
||||
|
||||
const guildCode: string = session.get('guildCode');
|
||||
if (!guildCode) return resResult(STATUS.GUILD_NOT_FOUND)
|
||||
const dividend = await DividendModel.updateDividendReady(guildCode, sourceType);
|
||||
const dividend = await DividendModel.updateDividendStatus(guildCode, sourceType, status);
|
||||
return resResult(STATUS.SUCCESS, { dividend });
|
||||
}
|
||||
|
||||
// ! 测试接口
|
||||
async debugAddLots(msg: { magicWord: string, sourceType: number, sourceCode: string, rewards: ItemReward[]}, session: BackendSession) {
|
||||
async debugSetLotStage(msg: { magicWord: string, code: string, auctionStage: number }, session: BackendSession) {
|
||||
const { magicWord, code, auctionStage } = msg;
|
||||
if (magicWord !== DEBUG_MAGIC_WORD) {
|
||||
return resResult(STATUS.TOKEN_ERR);
|
||||
}
|
||||
const lot = await LotModel.updateLotStage(code, auctionStage);
|
||||
return resResult(STATUS.SUCCESS, { lot });
|
||||
}
|
||||
|
||||
// ! 测试接口
|
||||
async debugAddLots(msg: { magicWord: string, sourceType: number, sourceCode: string, rewards: ItemReward[] }, session: BackendSession) {
|
||||
const { magicWord, sourceType, sourceCode, rewards } = msg;
|
||||
if (magicWord !== DEBUG_MAGIC_WORD) {
|
||||
return resResult(STATUS.TOKEN_ERR);
|
||||
|
||||
@@ -3,7 +3,7 @@ import 'mocha';
|
||||
import { PinusWSClient } from 'pinus-robot-plugin';
|
||||
import { expect } from 'chai';
|
||||
import { checkSuccessResponse } from './CheckPatten';
|
||||
import { DEBUG_MAGIC_WORD, AUCTION_SOURCE, CURRENCY_BY_TYPE, CURRENCY_TYPE } from '../app/consts';
|
||||
import { DEBUG_MAGIC_WORD, AUCTION_SOURCE, CURRENCY_BY_TYPE, CURRENCY_TYPE, AUCTION_STAGE, DIVIDEND_STATUS } from '../app/consts';
|
||||
import { LOT_STATUS } from '../../shared/consts';
|
||||
|
||||
const GOOD_ID_TIEJIAN = 1;
|
||||
@@ -198,7 +198,7 @@ describe('拍卖行测试', function() {
|
||||
expect(info.id).to.be.equal(CURRENCY_BY_TYPE.get(CURRENCY_TYPE.GOLD));
|
||||
}
|
||||
});
|
||||
pinusClient.request('battle.auctionHandler.debugSetDividendReady', { magicWord: DEBUG_MAGIC_WORD, sourceType: AUCTION_SOURCE.GATE }, (res) => {
|
||||
pinusClient.request('battle.auctionHandler.debugSetDividendStatus', { magicWord: DEBUG_MAGIC_WORD, sourceType: AUCTION_SOURCE.GATE, status: DIVIDEND_STATUS.ING }, (res) => {
|
||||
checkSuccessResponse(res);
|
||||
checkDividend(res.data.dividend);
|
||||
pinusClient.request('battle.auctionHandler.getDividend', { sourceType: AUCTION_SOURCE.GATE }, (res) => {
|
||||
@@ -241,7 +241,27 @@ describe('拍卖行测试', function() {
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('更新拍品阶段的测试接口', function(done) {
|
||||
pinusClient.request('battle.auctionHandler.getAuction', {}, (res) => {
|
||||
checkSuccessResponse(res);
|
||||
expect(res.data.lots).to.be.an('array');
|
||||
checkLots(res.data.lots);
|
||||
expect(res.data.dividends).to.be.an('array');
|
||||
checkDividends(res.data.dividends);
|
||||
if (res.data.lots.length === 0) {
|
||||
console.warn('没有可更新阶段的拍品');
|
||||
done();
|
||||
return;
|
||||
}
|
||||
const code = res.data.lots[0].code;
|
||||
pinusClient.request('battle.auctionHandler.debugSetLotStage', { code, magicWord: DEBUG_MAGIC_WORD, auctionStage: AUCTION_STAGE.GUILD }, (res) => {
|
||||
checkSuccessResponse(res);
|
||||
checkLot(res.data.lot);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('查看我的拍卖纪录', function(done) {
|
||||
|
||||
@@ -67,7 +67,7 @@ export default class Dividend extends BaseModel {
|
||||
}
|
||||
|
||||
public static async findReadyDividend(guildCode: string, sourceType: number) {
|
||||
const result: DividendType = await DividendModel.findOne({ guildCode, sourceType, status: DIVIDEND_STATUS.END }).select('-_id -__v').lean();
|
||||
const result: DividendType = await DividendModel.findOne({ guildCode, sourceType, status: DIVIDEND_STATUS.ING }).select('-_id -__v').lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -76,8 +76,8 @@ export default class Dividend extends BaseModel {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async updateDividendReady(guildCode: string, sourceType: number) {
|
||||
const result: DividendType = await DividendModel.findOneAndUpdate({ guildCode, sourceType }, { status: DIVIDEND_STATUS.END }, { new: true }).select('-_id -__v').lean();
|
||||
public static async updateDividendStatus(guildCode: string, sourceType: number, status: number) {
|
||||
const result: DividendType = await DividendModel.findOneAndUpdate({ guildCode, sourceType }, { status }, { new: true }).select('-_id -__v').lean();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,6 +102,11 @@ export default class Lot extends BaseModel {
|
||||
const results: LotType[] = await LotModel.find({ serverId, 'bidRoles.roleId': roleId }).select('-_id -__v').limit(count).lean();
|
||||
return results;
|
||||
}
|
||||
|
||||
public static async updateLotStage(code: string, auctionStage: number) {
|
||||
const result: LotType = await LotModel.findOneAndUpdate({ code }, { auctionStage }).select('-_id -__v').lean();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
export const LotModel = getModelForClass(Lot);
|
||||
|
||||
Reference in New Issue
Block a user