拍卖行:获取数据接口和出价接口部分功能
This commit is contained in:
+13
-2
@@ -8,7 +8,8 @@ import { genCode } from '../pubUtils/util';
|
||||
**/
|
||||
@modelOptions({ schemaOptions: { id: false } })
|
||||
@index({ code: 1 })
|
||||
@index({ guildCode: 1 })
|
||||
@index({ begin: -1, guildCode: 1 })
|
||||
@index({ begin: -1, serverId: 1})
|
||||
export default class Dividend extends BaseModel {
|
||||
@prop({ required: true, default: 0 })
|
||||
serverId: number; // 区服编号
|
||||
@@ -29,7 +30,7 @@ export default class Dividend extends BaseModel {
|
||||
@prop({ required: true, default: 0 })
|
||||
status: number; // 0:未开始;1:进行中;2:已结束;3:已发放
|
||||
@prop({ required: true })
|
||||
end: Date;
|
||||
begin: Date;
|
||||
|
||||
public static async createDividend(data: DividendParam) {
|
||||
const code = genCode(8);
|
||||
@@ -43,6 +44,16 @@ export default class Dividend extends BaseModel {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async findWorldDividendsByBegin(serverId: number, begin: Date) {
|
||||
const results = await DividendModel.find({ serverId, begin }).select('-_id -__v').lean();
|
||||
return results;
|
||||
}
|
||||
|
||||
public static async findGuildDividendsByBegin(guildCode: string, begin: Date) {
|
||||
const results = await DividendModel.find({ guildCode, begin }).select('-_id -__v').lean();
|
||||
return results;
|
||||
}
|
||||
|
||||
public static async updateDividend(code: string, update: DividendParam) {
|
||||
const result = await DividendModel.findOneAndUpdate({ code }, { ...update }, { new: true }).select('-_id -__v').lean();
|
||||
return result;
|
||||
|
||||
+14
-3
@@ -8,7 +8,7 @@ import { genCode } from '../pubUtils/util';
|
||||
**/
|
||||
@modelOptions({ schemaOptions: { id: false } })
|
||||
@index({ code: 1 })
|
||||
@index({ guildCode: 1, createdAt: -1 })
|
||||
@index({ guildCode: 1, begin: -1 })
|
||||
export default class Lot extends BaseModel {
|
||||
@prop({ required: true, default: 0 })
|
||||
auctionStage: number; // 0:初始添加,1:军团拍卖,2:世界拍卖,3:拍卖结束
|
||||
@@ -56,10 +56,21 @@ export default class Lot extends BaseModel {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async findGuildLotsByTime(guildCode: string, sourceType: number, time: Date) {
|
||||
const results = await LotModel.find({ guildCode, sourceType, createdAt: { $gte: time } }).select('-_id -__v').lean();
|
||||
public static async findGuildLotsByBegin(guildCode: string, time: Date) {
|
||||
const results = await LotModel.find({ guildCode, begin: { $eq: time } }).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();
|
||||
return results;
|
||||
}
|
||||
|
||||
public static async updateLot(data: LotParam) {
|
||||
const code = data.code!;
|
||||
const result: LotType = await LotModel.findOneAndUpdate({ code }, { ...data }, { new: true }).select('-_id -__v').lean();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
export const LotModel = getModelForClass(Lot);
|
||||
|
||||
Reference in New Issue
Block a user