拍卖行:初步实现添加拍品的测试接口
This commit is contained in:
@@ -53,11 +53,11 @@ export class AuctionHandler {
|
|||||||
const serverId: number = session.get('serverId');
|
const serverId: number = session.get('serverId');
|
||||||
if (!guildCode) return resResult(STATUS.GUILD_NOT_FOUND)
|
if (!guildCode) return resResult(STATUS.GUILD_NOT_FOUND)
|
||||||
|
|
||||||
const result = await genAuction(guildCode, sourceType, sourceCode, serverId, rewards);
|
const lots = await genAuction(guildCode, sourceType, sourceCode, serverId, rewards);
|
||||||
if (!result) {
|
if (!lots) {
|
||||||
return resResult(STATUS.WRONG_PARMS);
|
return resResult(STATUS.WRONG_PARMS);
|
||||||
}
|
}
|
||||||
|
|
||||||
return resResult(STATUS.SUCCESS, { result });
|
return resResult(STATUS.SUCCESS, { lots });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,21 @@
|
|||||||
import { LOT_CODE_LEN, AUCTION_STAGE, AUCTION_SOURCE, AUCTION_TIME } from './../consts';
|
import { LOT_CODE_LEN, AUCTION_STAGE, AUCTION_TIME } from './../consts';
|
||||||
import { ItemReward } from "../domain/dbGeneral";
|
import { ItemReward } from "../domain/dbGeneral";
|
||||||
import { genCode } from '../pubUtils/util';
|
import { genCode } from '../pubUtils/util';
|
||||||
import { LotModel, LotParam } from '../db/Lot';
|
import { LotModel, LotParam } from '../db/Lot';
|
||||||
import { getNextTime } from '../pubUtils/timeUtil';
|
import { getNextTime } from '../pubUtils/timeUtil';
|
||||||
|
import { getGoodById } from '../pubUtils/data';
|
||||||
|
|
||||||
|
// ! 获取底价,假数据
|
||||||
|
function getBasePrice(gid: number, count: number) {
|
||||||
|
const good = getGoodById(gid);
|
||||||
|
return (good ? good.quality * 100 : 100) * count;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ! 获取一口价,假数据
|
||||||
|
function getMaxPrice(gid: number, count: number) {
|
||||||
|
const good = getGoodById(gid);
|
||||||
|
return (good ? good.quality * 200 : 200) * count;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 生成拍卖数据
|
* @description 生成拍卖数据
|
||||||
@@ -22,7 +35,7 @@ export async function genAuction(guildCode: string, sourceType: number, sourceCo
|
|||||||
return {
|
return {
|
||||||
auctionStage: AUCTION_STAGE.DEFAULT, sourceType,
|
auctionStage: AUCTION_STAGE.DEFAULT, sourceType,
|
||||||
sourceCode, serverId, guildCode, code, gid: id, count, begin, end,
|
sourceCode, serverId, guildCode, code, gid: id, count, begin, end,
|
||||||
maxPrice: 100, curPrice: 10, // ! 此行为临时数据
|
maxPrice: getMaxPrice(id, count), curPrice: getBasePrice(id, count),
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const result = await LotModel.createRecs(lots);
|
const result = await LotModel.createRecs(lots);
|
||||||
@@ -30,6 +43,7 @@ export async function genAuction(guildCode: string, sourceType: number, sourceCo
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* ! 目前返回假数据
|
||||||
* @description 获取活动参加者
|
* @description 获取活动参加者
|
||||||
* @export
|
* @export
|
||||||
* @param {string} guildCode
|
* @param {string} guildCode
|
||||||
@@ -37,5 +51,11 @@ export async function genAuction(guildCode: string, sourceType: number, sourceCo
|
|||||||
* @param {string} sourceCode
|
* @param {string} sourceCode
|
||||||
*/
|
*/
|
||||||
export async function participants(guildCode: string, sourceType: number, sourceCode: string) {
|
export async function participants(guildCode: string, sourceType: number, sourceCode: string) {
|
||||||
|
return [{
|
||||||
|
roleId: 'rM8NZtlfzD',
|
||||||
|
position: 1,
|
||||||
|
}, {
|
||||||
|
roleId: 'EjX79SEddK',
|
||||||
|
position: 2,
|
||||||
|
}];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,25 @@
|
|||||||
import { AUCTION_SOURCE } from './../app/consts/constModules/auctionConst';
|
|
||||||
import { DEFAULT_MSG_PER_PAGE, MSG_TYPE, ON_PRIVATE_MSG_ROUTE, ON_GROUP_MSG_ROUTE, CHANNEL_PREFIX, DEBUG_MAGIC_WORD, STATUS, HERO_GROW_MAX, ABI_STAGE } from './../app/consts';
|
|
||||||
import { Client } from './Client';
|
import { Client } from './Client';
|
||||||
import 'mocha';
|
import 'mocha';
|
||||||
import { PinusWSClient } from 'pinus-robot-plugin';
|
import { PinusWSClient } from 'pinus-robot-plugin';
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import { checkSuccessResponse } from './CheckPatten';
|
import { checkSuccessResponse } from './CheckPatten';
|
||||||
|
import { DEBUG_MAGIC_WORD, AUCTION_SOURCE } from '../app/consts';
|
||||||
|
|
||||||
|
function checkLot(lot) {
|
||||||
|
expect(lot.auctionStage).to.be.a('number');
|
||||||
|
expect(lot.sourceType).to.be.a('number');
|
||||||
|
expect(lot.sourceCode).to.be.a('string');
|
||||||
|
expect(lot.serverId).to.be.a('number');
|
||||||
|
expect(lot.guildCode).to.be.a('string');
|
||||||
|
expect(lot.code).to.be.a('string');
|
||||||
|
expect(lot.gid).to.be.a('number');
|
||||||
|
expect(lot.count).to.be.a('number');
|
||||||
|
expect(lot.maxPrice).to.be.a('number');
|
||||||
|
expect(lot.curPrice).to.be.a('number');
|
||||||
|
expect(lot.bidRoles).to.be.a('array');
|
||||||
|
expect(Date.parse(lot.begin)).to.be.a('number');
|
||||||
|
expect(Date.parse(lot.end)).to.be.a('number');
|
||||||
|
}
|
||||||
|
|
||||||
describe('拍卖行测试', function() {
|
describe('拍卖行测试', function() {
|
||||||
let pinusClient: PinusWSClient;
|
let pinusClient: PinusWSClient;
|
||||||
@@ -40,6 +55,10 @@ describe('拍卖行测试', function() {
|
|||||||
const sourceCode = Math.random().toString(36).slice(-8);
|
const sourceCode = Math.random().toString(36).slice(-8);
|
||||||
pinusClient.request('battle.auctionHandler.debugAddLots', { magicWord: DEBUG_MAGIC_WORD, sourceType: AUCTION_SOURCE.GATE, sourceCode, rewards: [{ id: 1, count: 1 }, { id: 2, count: 2 }] }, (res) => {
|
pinusClient.request('battle.auctionHandler.debugAddLots', { magicWord: DEBUG_MAGIC_WORD, sourceType: AUCTION_SOURCE.GATE, sourceCode, rewards: [{ id: 1, count: 1 }, { id: 2, count: 2 }] }, (res) => {
|
||||||
checkSuccessResponse(res);
|
checkSuccessResponse(res);
|
||||||
|
expect(res.data.lots).to.be.an('array');
|
||||||
|
for (let lot of res.data.lots) {
|
||||||
|
checkLot(lot);
|
||||||
|
}
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ function checkTime(date: Date, h: number, m: number, s: number) {
|
|||||||
expect(date.getSeconds()).to.be.equal(s);
|
expect(date.getSeconds()).to.be.equal(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('测试时间相关工具方法', function () {
|
describe('测试时间工具方法', function () {
|
||||||
it('获取某个时间后的某点,返回当天', function () {
|
it('获取某个时间后的某点,返回当天', function () {
|
||||||
const baseDate = new Date();
|
const baseDate = new Date();
|
||||||
const newHour = 9, newMin = 9, newSec = 9;
|
const newHour = 9, newMin = 9, newSec = 9;
|
||||||
|
|||||||
Reference in New Issue
Block a user