拍卖行:出价、关注接口和测试用例
This commit is contained in:
@@ -18,13 +18,13 @@ export const DIVIDEND_CODE_LEN = 8;
|
||||
|
||||
// 世界拍卖开始时间需晚于军团拍卖结束时间
|
||||
export const AUCTION_TIME = {
|
||||
GUILD_BEGIN_HOUR: 8, // 军团拍卖开始
|
||||
GUILD_BEGIN_HOUR: 20, // 军团拍卖开始
|
||||
GUILD_BEGIN_MIN: 20, // 军团拍卖开始
|
||||
WORLD_BEGIN_HOUR: 8, // 世界拍卖开始
|
||||
WORLD_BEGIN_HOUR: 20, // 世界拍卖开始
|
||||
WORLD_BEGIN_MIN: 30, // 世界拍卖开始
|
||||
GUILD_END_HOUR: 8, // 军团拍卖结束
|
||||
GUILD_END_HOUR: 20, // 军团拍卖结束
|
||||
GUILD_END_MIN: 30, // 军团拍卖结束
|
||||
WORLD_END_HOUR: 10, // 世界拍卖结束
|
||||
WORLD_END_HOUR: 22, // 世界拍卖结束
|
||||
WORLD_END_MIN: 0, // 世界拍卖结束
|
||||
};
|
||||
|
||||
@@ -35,4 +35,10 @@ export const DIVIDEND_STATUS = {
|
||||
SENT: 3, // 3:已发放
|
||||
};
|
||||
|
||||
export const LOT_STATUS = {
|
||||
DEFAULT: 0, // 未开始
|
||||
ING: 1, // 竞拍中
|
||||
SOLD: 2, // 已拍出
|
||||
}
|
||||
|
||||
export const OFFER_RATIO = 1.1;
|
||||
|
||||
@@ -9,4 +9,5 @@ export enum DATA_NAME {
|
||||
REFRESH_ACTIVE = 'GuildRefActive',
|
||||
WEEKLY_GUILD_SUM = 'WeeklyGuildSum', // 每周结算活跃和奖励
|
||||
GAMEMAIL = 'Mail',
|
||||
AUCTION_LOT = 'LotCode',
|
||||
}
|
||||
|
||||
+23
-4
@@ -34,10 +34,14 @@ export default class Lot extends BaseModel {
|
||||
maxPrice: number; // 一口价,最高价格
|
||||
@prop({ required: true, type: BidRec, default: [] })
|
||||
bidRoles: BidRec[];
|
||||
@prop({ required: true, type: String, default: [] })
|
||||
watchingRoles: string[];
|
||||
@prop({ required: true })
|
||||
begin: Date; // 竞拍开始时间
|
||||
@prop({ required: true })
|
||||
end: Date; // 竞拍结束时间
|
||||
@prop({ required: true, default: 0 })
|
||||
status: number; // 拍品状态,0:无人竞拍;1:竞拍中;2:已拍
|
||||
|
||||
public static async createRec(data: LotParam) {
|
||||
const code = genCode(8);
|
||||
@@ -56,13 +60,18 @@ export default class Lot extends BaseModel {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async findGuildLotsByBegin(guildCode: string, time: Date) {
|
||||
const results = await LotModel.find({ guildCode, begin: { $eq: time } }).select('-_id -__v').lean();
|
||||
public static async findGuildLotsByBegin(guildCode: string, begin: Date) {
|
||||
const results = await LotModel.find({ guildCode, begin }).select('-_id -__v').lean();
|
||||
return results;
|
||||
}
|
||||
|
||||
public static async findWorldLotsByBegin(serverId: number, time: Date) {
|
||||
const results = await LotModel.find({ serverId, begin: { $eq: time } }).select('-_id -__v').lean();
|
||||
public static async findWorldLotsByBegin(serverId: number, begin: Date) {
|
||||
const results = await LotModel.find({ serverId, begin }).select('-_id -__v').lean();
|
||||
return results;
|
||||
}
|
||||
|
||||
public static async findWatchingLotsByBegin(roleId: string, serverId: number, begin: Date) {
|
||||
const results = await LotModel.find({ serverId, begin, watchingRoles: roleId }, { new: true }).select('-_id -__v').lean();
|
||||
return results;
|
||||
}
|
||||
|
||||
@@ -71,6 +80,16 @@ export default class Lot extends BaseModel {
|
||||
const result: LotType = await LotModel.findOneAndUpdate({ code }, { ...data }, { new: true }).select('-_id -__v').lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async watchLot(code: string, roleId: string) {
|
||||
const result: LotType = await LotModel.findOneAndUpdate({ code }, { $addToSet: { watchingRoles: roleId } }, { new: true }).select('-_id -__v').lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async unWatchLot(code: string, roleId: string) {
|
||||
const result: LotType = await LotModel.findOneAndUpdate({ code }, { $pull: { watchingRoles: roleId } }, { new: true }).select('-_id -__v').lean();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
export const LotModel = getModelForClass(Lot);
|
||||
|
||||
@@ -156,10 +156,10 @@ export function formatTime(d: Date, type: number) {
|
||||
* @param {number} [s=0] 给定秒
|
||||
* @returns {Date}
|
||||
*/
|
||||
export function getNextTime(date: Date, h: number, m = 0, s = 0): Date {
|
||||
export function getNextTime(date: Date, h: number, m = 0, s = 0, ms = 0): Date {
|
||||
const milliseconds = date.getTime();
|
||||
const timeToday = new Date(milliseconds).setHours(h, m, s);
|
||||
return timeToday > milliseconds ? new Date(timeToday) : new Date(timeToday + PER_DAY * PER_SECOND);
|
||||
const timeToday = new Date(milliseconds).setHours(h, m, s, ms);
|
||||
return timeToday < milliseconds ? new Date(timeToday) : new Date(timeToday + PER_DAY * PER_SECOND);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user