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

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
+2 -2
View File
@@ -321,7 +321,7 @@ export async function startWorldAuction() {
try { try {
console.log('schedule startWorldAuction called:', new Date()); console.log('schedule startWorldAuction called:', new Date());
const begin = await todayGuildBegin(); const begin = await todayGuildBegin();
let lots = await LotModel.setLotSoldByBegin(begin); // 正在竞拍的拍品 let lots = await LotModel.setLotSoldByBegin(begin, AUCTION_STAGE.GUILD); // 正在竞拍的拍品
await sendLotsRewardToMlail(lots); await sendLotsRewardToMlail(lots);
lots = await LotModel.updateUnSoldLotsStageByBegin(begin, AUCTION_STAGE.WORLD); lots = await LotModel.updateUnSoldLotsStageByBegin(begin, AUCTION_STAGE.WORLD);
let dividends = await DividendModel.updateDividendsStatus(begin, DIVIDEND_STATUS.END); let dividends = await DividendModel.updateDividendsStatus(begin, DIVIDEND_STATUS.END);
@@ -344,7 +344,7 @@ export async function stopAuction() {
try { try {
console.log('schedule stopAuction called:', new Date()); console.log('schedule stopAuction called:', new Date());
const begin = await todayGuildBegin(); const begin = await todayGuildBegin();
let lots = await LotModel.setLotSoldByBegin(begin); // 正在竞拍的拍品 let lots = await LotModel.setLotSoldByBegin(begin, AUCTION_STAGE.WORLD); // 正在竞拍的拍品
await sendLotsRewardToMlail(lots); await sendLotsRewardToMlail(lots);
lots = await LotModel.updateLotsStageByBegin(begin, AUCTION_STAGE.END); lots = await LotModel.updateLotsStageByBegin(begin, AUCTION_STAGE.END);
+11 -6
View File
@@ -2,7 +2,7 @@ import { BidRec } from './../domain/dbGeneral';
import BaseModel from './BaseModel'; import BaseModel from './BaseModel';
import { index, getModelForClass, prop, DocumentType, modelOptions } from '@typegoose/typegoose'; import { index, getModelForClass, prop, DocumentType, modelOptions } from '@typegoose/typegoose';
import { genCode } from '../pubUtils/util'; 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 }) @prop({ required: true, default: 0 })
auctionStage: number; // 0:初始添加,1:军团拍卖,2:世界拍卖,3:拍卖结束 auctionStage: number; // 0:初始添加,1:军团拍卖,2:世界拍卖,3:拍卖结束
@prop({ required: true, default: 0 }) @prop({ required: true, default: 0 })
saveAuctionStage: number; // 0:初始添加,1:军团拍卖,2:世界拍卖,3:拍卖结束
@prop({ required: true, default: 0 })
sourceType: number; // 0:初始值,1:演武;2:蛮夷入侵;3:诸侯混战;4:粮草先行 sourceType: number; // 0:初始值,1:演武;2:蛮夷入侵;3:诸侯混战;4:粮草先行
@prop({ required: true, default: '' }) @prop({ required: true, default: '' })
sourceCode: string; // 来源的唯一标识,如活动编号 sourceCode: string; // 来源的唯一标识,如活动编号
@@ -73,12 +75,12 @@ export default class Lot extends BaseModel {
} }
public static async findGuildLotsByBegin(guildCode: string, begin: Date) { 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; return results;
} }
public static async findWorldLotsByBegin(serverId: number, begin: Date) { 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; return results;
} }
@@ -94,6 +96,9 @@ export default class Lot extends BaseModel {
public static async updateLot(data: LotParam) { public static async updateLot(data: LotParam) {
const code = data.code!; 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(); const result: LotType = await LotModel.findOneAndUpdate({ code }, { ...data }, { new: true }).select('-_id -__v').lean();
return result; return result;
} }
@@ -125,7 +130,7 @@ export default class Lot extends BaseModel {
public static async updateLotsStageByBegin(begin: Date, auctionStage: number) { public static async updateLotsStageByBegin(begin: Date, auctionStage: number) {
await LotModel.updateMany({ begin }, { auctionStage }); 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; return results;
} }
@@ -135,9 +140,9 @@ export default class Lot extends BaseModel {
return results; 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(); 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; return results;
} }
} }