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

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

View File

@@ -321,7 +321,7 @@ export async function startWorldAuction() {
try {
console.log('schedule startWorldAuction called:', new Date());
const begin = await todayGuildBegin();
let lots = await LotModel.setLotSoldByBegin(begin); // 正在竞拍的拍品
let lots = await LotModel.setLotSoldByBegin(begin, AUCTION_STAGE.GUILD); // 正在竞拍的拍品
await sendLotsRewardToMlail(lots);
lots = await LotModel.updateUnSoldLotsStageByBegin(begin, AUCTION_STAGE.WORLD);
let dividends = await DividendModel.updateDividendsStatus(begin, DIVIDEND_STATUS.END);
@@ -344,7 +344,7 @@ export async function stopAuction() {
try {
console.log('schedule stopAuction called:', new Date());
const begin = await todayGuildBegin();
let lots = await LotModel.setLotSoldByBegin(begin); // 正在竞拍的拍品
let lots = await LotModel.setLotSoldByBegin(begin, AUCTION_STAGE.WORLD); // 正在竞拍的拍品
await sendLotsRewardToMlail(lots);
lots = await LotModel.updateLotsStageByBegin(begin, AUCTION_STAGE.END);

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;
}
}