拍卖行:获取军团拍卖记录;修改分红机制

This commit is contained in:
liangtongchuan
2021-03-20 01:09:09 +08:00
parent 7df19fd510
commit a9d06173ac
7 changed files with 108 additions and 15 deletions
+3 -1
View File
@@ -38,7 +38,8 @@ export const DIVIDEND_STATUS = {
export const LOT_STATUS = {
DEFAULT: 0, // 未开始
ING: 1, // 竞拍中
SOLD: 2, // 已拍出
SOLD: 2, // 竞拍成功
MAX: 3, // 一口价
}
export const ROLE_RECEIVE_STATUS = {
@@ -54,6 +55,7 @@ export const AUCTION_BID_STATUS = {
export const OFFER_RATIO = 1.1;
export const BID_REC_COUNT = 100;
export const GUILD_LOTS_REC_COUNT = 100;
export const DIVIDENDWEEKENDRATE = 0.2;
export const DIVIDENDMAXRATIO = 0.1;
export const DIVIDENDPOSITIONMAXRATIO = 3;
+7 -2
View File
@@ -61,13 +61,18 @@ export default class Dividend extends BaseModel {
return results;
}
public static async findDividendsByGuild(guildCode: string, count: number) {
const results = await DividendModel.find({ guildCode }).limit(count).sort({ _id: -1 }).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;
}
public static async updateLot(lotCode: string, gid: number, price: number, incPrice: number) {
const result = await DividendModel.findOneAndUpdate({ 'lots.code': lotCode }, { 'lots.$.gid': gid, 'lots.$.price': price, $inc: { totalPrice: incPrice} }, { new: true }).select('-_id -__v').lean();
public static async updateLot(lotCode: string, gid: number, price: number, incPrice: number, max: boolean) {
const result = await DividendModel.findOneAndUpdate({ 'lots.code': lotCode }, { 'lots.$.gid': gid, 'lots.$.price': price, 'lots.$.time': new Date(), 'lots.$.max': max, $inc: { totalPrice: incPrice} }, { new: true }).select('-_id -__v').lean();
return result;
}
+18 -3
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 } from '../consts';
import { BID_REC_COUNT, GUILD_LOTS_REC_COUNT, LOT_STATUS } from '../consts';
/**
* 竞拍物品表
@@ -43,7 +43,7 @@ export default class Lot extends BaseModel {
@prop({ required: true })
end: Date; // 竞拍结束时间
@prop({ required: true, default: 0 })
status: number; // 拍品状态,0:无人竞拍;1:竞拍中;2:已
status: number; // 拍品状态,0:无人竞拍;1:竞拍中;2:已竞拍;3:一口价
public static async createRec(data: LotParam) {
const code = genCode(8);
@@ -62,6 +62,11 @@ export default class Lot extends BaseModel {
return result;
}
public static async findLots(codes: string[]) {
const result = await LotModel.find({ code: {$in: codes} }).select('-_id -__v').lean();
return result;
}
public static async findGuildLotsByBegin(guildCode: string, begin: Date) {
const results = await LotModel.find({ guildCode, begin }).select('-_id -__v').lean();
return results;
@@ -77,6 +82,11 @@ export default class Lot extends BaseModel {
return results;
}
public static async recentGuildLots(guildCode: string, count = GUILD_LOTS_REC_COUNT ) {
const results = await LotModel.find({ guildCode }).sort({ _id: -1 }).limit(count).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();
@@ -99,7 +109,7 @@ export default class Lot extends BaseModel {
}
public static async recentBidLots(serverId: number, roleId: string, count = BID_REC_COUNT) {
const results: LotType[] = await LotModel.find({ serverId, 'bidRoles.roleId': roleId }).select('-_id -__v').limit(count).lean();
const results: LotType[] = await LotModel.find({ serverId, 'bidRoles.roleId': roleId }).select('-_id -__v').sort({ _id: -1 }).limit(count).lean();
return results;
}
@@ -112,6 +122,11 @@ export default class Lot extends BaseModel {
const results = await LotModel.updateMany({ begin }, { auctionStage }).select('-_id -__v').lean();
return results;
}
public static async setLotSoldByBegin(begin: Date) {
const results = await LotModel.updateMany({ begin, status: LOT_STATUS.ING }, { status: LOT_STATUS.SOLD }).select('-_id -__v').lean();
return results;
}
}
export const LotModel = getModelForClass(Lot);
+6
View File
@@ -254,7 +254,13 @@ export class LotRec {
@prop({ required: true, default: 0 })
gid: number; // 物品 id
@prop({ required: true, default: 0 })
count: number; // 物品数量
@prop({ required: true, default: 0 })
price: number; // 物品成交价
@prop({ required: true, default: null })
time: Date; // 出价时间
@prop({ required: true, default: 0 })
max: boolean; // 出价时间
}
/**