feat(拍卖行): 只流3个拍品到世界拍卖行

https://bantugame.feishu.cn/wiki/wikcn1qfpNYNUnOvuKiyK69eqqg?lang=zh-CN&open_in_browser=true
This commit is contained in:
luying
2022-10-23 17:49:53 +08:00
parent ecba195051
commit 44787d68a5
8 changed files with 95 additions and 24 deletions

View File

@@ -37,6 +37,7 @@ export const LOT_STATUS = {
ING: 1, // 竞拍中
SOLD: 2, // 竞拍成功
MAX: 3, // 一口价
PASSIN: -1, // 流拍
}
export const ROLE_RECEIVE_STATUS = {
@@ -54,3 +55,5 @@ export const BID_REC_COUNT = 100;
export const GUILD_LOTS_REC_COUNT = 100;
export const DIVIDENDMAXRATIO = 0.1;
export const DIVIDENDPOSITIONMAXRATIO = 3;
export const LOTS_KEEP_TO_WORLD_CNT = 3; // 同一个物品id流到世界拍卖行的数量

View File

@@ -0,0 +1,28 @@
import BaseModel from './BaseModel';
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
/**
* 自增 ID
*/
@index({ sourceType: 1, time: 1, id: 1 })
export default class CounterLots extends BaseModel {
@prop({ required: true })
beginTime: Date;
@prop({ required: true })
id: number;
@prop({ required: true })
seq: number;
public static async getNewCounter(id: number, beginTime: Date, inc: number) {
let counter: CounterLotsType = await CounterLotsModel.findOneAndUpdate({ beginTime, id }, { $inc: { seq: inc } }, { new: true, upsert: true }).lean();
return counter?.seq;
}
}
export const CounterLotsModel = getModelForClass(CounterLots);
export interface CounterLotsType extends Pick<DocumentType<CounterLots>, keyof CounterLots>{};

View File

@@ -2,13 +2,14 @@ import { BidRec } from './../domain/dbGeneral';
import BaseModel from './BaseModel';
import { index, getModelForClass, prop, DocumentType, modelOptions } from '@typegoose/typegoose';
import { genCode } from '../pubUtils/util';
import { AUCTION_STAGE, BID_REC_COUNT, GUILD_LOTS_REC_COUNT, LOT_STATUS } from '../consts';
import { AUCTION_STAGE, BID_REC_COUNT, GUILD_LOTS_REC_COUNT, LOTS_KEEP_TO_WORLD_CNT, LOT_STATUS } from '../consts';
/**
* 竞拍物品表
**/
@modelOptions({ schemaOptions: { id: false } })
@index({ sort: 1 })
@index({ seq: 1 })
@index({ code: 1 })
@index({ guildCode: 1, begin: -1 })
@index({ serverId: 1, begin: -1, watchingRoles: 1 })
@@ -20,6 +21,8 @@ export default class Lot extends BaseModel {
@prop({ required: true, default: 0 })
sourceType: number; // 0初始值1演武2蛮夷入侵3诸侯混战4粮草先行
@prop({ required: true, default: '' })
seq: number; // 当日的这个物品的编号
@prop({ required: true, default: '' })
sourceCode: string; // 来源的唯一标识,如活动编号
@prop({ required: true, default: 0 })
serverId: number; // 区服编号
@@ -134,8 +137,9 @@ export default class Lot extends BaseModel {
return results;
}
public static async updateUnSoldLotsStageByBegin(begin: Date, auctionStage: number) {
await LotModel.updateMany({ begin, status: { $in: [LOT_STATUS.DEFAULT, LOT_STATUS.ING] } }, { auctionStage });
public static async keepUnSoldLotsToWorld(begin: Date) {
await LotModel.updateMany({ begin, status: { $in: [LOT_STATUS.DEFAULT, LOT_STATUS.ING] }, seq: { $gt: LOTS_KEEP_TO_WORLD_CNT } }, { status: LOT_STATUS.PASSIN });
await LotModel.updateMany({ begin, status: { $in: [LOT_STATUS.DEFAULT, LOT_STATUS.ING] }, seq: { $lte: LOTS_KEEP_TO_WORLD_CNT } }, { $set: { auctionStage: AUCTION_STAGE.WORLD } });
const results: LotType[] = await LotModel.find({ begin, status: { $in: [LOT_STATUS.DEFAULT, LOT_STATUS.ING] } }).select('-_id -__v').lean();
return results;
}
@@ -145,6 +149,11 @@ export default class Lot extends BaseModel {
await LotModel.updateMany({ begin, status: LOT_STATUS.ING }, { status: LOT_STATUS.SOLD, saveAuctionStage });
return results;
}
public static async setSeq(begin: Date, gid: number, count: number, seq: number) {
const results: LotType = await LotModel.findOneAndUpdate({ begin, gid, count, status: LOT_STATUS.DEFAULT }, { $set: { seq } }).sort({ seq: -1 }).select('-_id -__v').lean();
return results;
}
}
export const LotModel = getModelForClass(Lot);

View File

@@ -0,0 +1,8 @@
import { RewardInter } from '../../pubUtils/interface'
export interface AuctionRewardInter {
goods: RewardInter;
basePrice: number;
maxPrice: number;
sort: number;
}

View File

@@ -87,7 +87,6 @@ import { dicWhiteIp, loadWhiteIp } from './dictionary/DicWhiteIp';
import { dicGuildWishReward, loadGuildWishReward } from './dictionary/DicGuildWishReward';
import { dicApiById, dicApiByUrl, loadApi } from './dictionary/DicApi';
import { dicServerConst, loadServerConst } from './dictionary/DicServerConst';
import { pick } from "underscore";
const _ = require("underscore");
import { dicEquipById, dicEquipIdByJobClassAndEplace, loadEquip } from "./dictionary/DicEquip";
import { dicBlueprt, dicBlueprtByLv, dicJewel, loadJewel } from "./dictionary/DicJewel";
@@ -111,6 +110,7 @@ import { dicLadderMatch, loadLadderMatch } from "./dictionary/DicLadderMatch";
import { dicLadderDifficultRatio, loadLadderDifficultRatio } from "./dictionary/DicLadderDifficultRatio";
import { dicLadderRankReward, loadLadderRankReward } from "./dictionary/DicLadderRankReward";
import { dicGeneralGoods, loadGeneralGoods } from "./dictionary/DicGeneralGoods";
import { AuctionRewardInter } from "../domain/battleField/auction";
export const gameData = {
daily: dicDaily,
@@ -671,7 +671,7 @@ export function getGuildAuctionRewards(aid: number, rank: number, cityId: number
if(dic) {
return getAuctionRewardByPoolId(dic.rewards);
} else {
return []
return new Map();
}
}
@@ -682,13 +682,17 @@ export function getGuildAuctionBasicNum(aid: number, rank: number, cityId: numbe
export function getAuctionRewardByPoolId(poolId: number) {
let pools = gameData.auctionPool.get(poolId);
let rewards: { goods: RewardInter, basePrice: number, maxPrice: number, sort: number }[] = [];
let rewards: Map<number, AuctionRewardInter[]> = new Map();
for(let { count, basicPool } of pools) {
let { rewardBasicPool, basePrice, maxPrice, sort } = basicPool
for(let i = 0; i < count; i++) {
let result = getRandEelmWithWeight(rewardBasicPool);
if(result && result.dic) {
rewards.push({ goods: pick(result.dic, ['id', 'count']), basePrice, maxPrice, sort });
let { id, count } = result.dic;
if(!rewards.has(id)) {
rewards.set(id, []);
}
rewards.get(id).push({ goods: {id, count}, basePrice, maxPrice, sort });
}
}
}