拍卖行:世界拍卖行不显示已售出拍品

This commit is contained in:
luying
2022-09-08 18:21:24 +08:00
parent 19382fc011
commit 864e557c11
2 changed files with 13 additions and 8 deletions
+11 -6
View File
@@ -2,7 +2,7 @@ import { BidRec } from './../domain/dbGeneral';
import BaseModel from './BaseModel';
import { index, getModelForClass, prop, DocumentType, modelOptions } from '@typegoose/typegoose';
import { genCode } from '../pubUtils/util';
import { BID_REC_COUNT, GUILD_LOTS_REC_COUNT, LOT_STATUS } from '../consts';
import { AUCTION_BID_STATUS, AUCTION_STAGE, BID_REC_COUNT, GUILD_LOTS_REC_COUNT, LOT_STATUS } from '../consts';
/**
* 竞拍物品表
@@ -16,6 +16,8 @@ export default class Lot extends BaseModel {
@prop({ required: true, default: 0 })
auctionStage: number; // 0:初始添加,1:军团拍卖,2:世界拍卖,3:拍卖结束
@prop({ required: true, default: 0 })
saveAuctionStage: number; // 0:初始添加,1:军团拍卖,2:世界拍卖,3:拍卖结束
@prop({ required: true, default: 0 })
sourceType: number; // 0:初始值,1:演武;2:蛮夷入侵;3:诸侯混战;4:粮草先行
@prop({ required: true, default: '' })
sourceCode: string; // 来源的唯一标识,如活动编号
@@ -73,12 +75,12 @@ export default class Lot extends BaseModel {
}
public static async findGuildLotsByBegin(guildCode: string, begin: Date) {
const results = await LotModel.find({ guildCode, begin }).sort({ sort: 1 }).select('-_id -__v').lean();
const results = await LotModel.find({ guildCode, begin, auctionStage: AUCTION_STAGE.GUILD }).sort({ sort: 1 }).select('-_id -__v').lean();
return results;
}
public static async findWorldLotsByBegin(serverId: number, begin: Date) {
const results = await LotModel.find({ serverId, begin }).sort({ sort: 1 }).select('-_id -__v').lean();
const results = await LotModel.find({ serverId, begin, auctionStage: AUCTION_STAGE.WORLD }).sort({ sort: 1 }).select('-_id -__v').lean();
return results;
}
@@ -94,6 +96,9 @@ export default class Lot extends BaseModel {
public static async updateLot(data: LotParam) {
const code = data.code!;
if(data.status == LOT_STATUS.SOLD|| data.status == LOT_STATUS.MAX) {
data.saveAuctionStage = data.auctionStage;
}
const result: LotType = await LotModel.findOneAndUpdate({ code }, { ...data }, { new: true }).select('-_id -__v').lean();
return result;
}
@@ -125,7 +130,7 @@ export default class Lot extends BaseModel {
public static async updateLotsStageByBegin(begin: Date, auctionStage: number) {
await LotModel.updateMany({ begin }, { auctionStage });
const results: LotType[] = await LotModel.find({ begin }).select('-_id -__v -createdAt -updatedAt').lean();
const results: LotType[] = await LotModel.find({ begin, auctionStage }).select('-_id -__v -createdAt -updatedAt').lean();
return results;
}
@@ -135,9 +140,9 @@ export default class Lot extends BaseModel {
return results;
}
public static async setLotSoldByBegin(begin: Date) {
public static async setLotSoldByBegin(begin: Date, saveAuctionStage: number) {
const results: LotType[] = await LotModel.find({ begin, status: LOT_STATUS.ING }).sort({ sort: 1 }).select('-_id -__v').lean();
await LotModel.updateMany({ begin, status: LOT_STATUS.ING }, { status: LOT_STATUS.SOLD });
await LotModel.updateMany({ begin, status: LOT_STATUS.ING }, { status: LOT_STATUS.SOLD, saveAuctionStage });
return results;
}
}