拍卖:优化

This commit is contained in:
luying
2021-10-27 16:39:55 +08:00
parent b03802136b
commit 0dde8fd09a
9 changed files with 146 additions and 68 deletions

View File

@@ -8,6 +8,7 @@ import { BID_REC_COUNT, GUILD_LOTS_REC_COUNT, LOT_STATUS } from '../consts';
* 竞拍物品表
**/
@modelOptions({ schemaOptions: { id: false } })
@index({ sort: 1 })
@index({ code: 1 })
@index({ guildCode: 1, begin: -1 })
@index({ serverId: 1, begin: -1, watchingRoles: 1 })
@@ -44,6 +45,8 @@ export default class Lot extends BaseModel {
end: Date; // 竞拍结束时间
@prop({ required: true, default: 0 })
status: number; // 拍品状态0无人竞拍1竞拍中2已竞拍3一口价
@prop({ required: true, default: 0 })
sort: number; // 排序
public static async createRec(data: LotParam) {
const code = genCode(8);
@@ -63,27 +66,27 @@ export default class Lot extends BaseModel {
}
public static async findLots(codes: string[]) {
const result = await LotModel.find({ code: {$in: codes} }).select('-_id -__v').lean();
const result = await LotModel.find({ code: {$in: codes} }).sort({ sort: 1 }).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();
const results = await LotModel.find({ guildCode, begin }).sort({ sort: 1 }).select('-_id -__v').lean();
return results;
}
public static async findWorldLotsByBegin(serverId: number, begin: Date) {
const results = await LotModel.find({ serverId, begin }).select('-_id -__v').lean();
const results = await LotModel.find({ serverId, begin }).sort({ sort: 1 }).select('-_id -__v').lean();
return results;
}
public static async findWatchingLotsByBegin(roleId: string, serverId: number, begin: Date) {
const results = await LotModel.find({ serverId, begin, watchingRoles: roleId }, { new: true }).select('-_id -__v').lean();
const results = await LotModel.find({ serverId, begin, watchingRoles: roleId }, { new: true }).sort({ sort: 1 }).select('-_id -__v').lean();
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();
const results = await LotModel.find({ guildCode }).sort({ _id: -1 }).limit(count).sort({ sort: 1 }).select('-_id -__v').lean();
return results;
}
@@ -104,12 +107,12 @@ export default class Lot extends BaseModel {
}
public static async watchingLotsByBegin(serverId: number, roleId: string, begin: Date) {
const results: LotType[] = await LotModel.find({ serverId, begin, watchingRoles: roleId }).select('-_id -__v').lean();
const results: LotType[] = await LotModel.find({ serverId, begin, watchingRoles: roleId }).sort({ sort: 1 }).select('-_id -__v').lean();
return results;
}
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').sort({ _id: -1 }).limit(count).lean();
const results: LotType[] = await LotModel.find({ serverId, 'bidRoles.roleId': roleId }).sort({ sort: 1 }).select('-_id -__v').sort({ _id: -1 }).limit(count).lean();
return results;
}
@@ -129,7 +132,8 @@ export default class Lot extends BaseModel {
}
public static async setLotSoldByBegin(begin: Date) {
const results = await LotModel.updateMany({ begin, status: LOT_STATUS.ING }, { status: LOT_STATUS.SOLD }).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 });
return results;
}
}

View File

@@ -597,13 +597,13 @@ export function getGuildAuctionRewards(aid: number, rank: number) {
export function getAuctionRewardByPoolId(poolId: number) {
let pools = gameData.auctionPool.get(poolId);
let rewards: { goods: RewardInter, basePrice: number, maxPrice: number }[] = [];
let rewards: { goods: RewardInter, basePrice: number, maxPrice: number, sort: number }[] = [];
for(let { count, basicPool } of pools) {
let { rewardBasicPool, basePrice, maxPrice } = basicPool
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 });
rewards.push({ goods: pick(result.dic, ['id', 'count']), basePrice, maxPrice, sort });
}
}
}

View File

@@ -13,6 +13,7 @@ export interface DicAuctionBasicPool {
readonly rewardBasicPool: AuctionBasicPool[];
readonly basePrice: number;
readonly maxPrice: number;
readonly sort: number; // 排序
}
export interface DicAuctionReward {

View File

@@ -6,7 +6,8 @@
"totalCount": 8,
"itid": 25,
"basePrice": "31002&800",
"maxPrice": "31002&1500"
"maxPrice": "31002&1500",
"sort": 3
},
{
"id": 2,
@@ -15,7 +16,8 @@
"totalCount": 22,
"itid": 25,
"basePrice": "31002&1500",
"maxPrice": "31002&3000"
"maxPrice": "31002&3000",
"sort": 2
},
{
"id": 3,
@@ -24,7 +26,8 @@
"totalCount": 31,
"itid": 25,
"basePrice": "31002&3000",
"maxPrice": "31002&5000"
"maxPrice": "31002&5000",
"sort": 1
},
{
"id": 4,
@@ -33,7 +36,8 @@
"totalCount": 6,
"itid": 40,
"basePrice": "31002&800",
"maxPrice": "31002&1500"
"maxPrice": "31002&1500",
"sort": 5
},
{
"id": 5,
@@ -42,7 +46,8 @@
"totalCount": 6,
"itid": 40,
"basePrice": "31002&400",
"maxPrice": "31002&800"
"maxPrice": "31002&800",
"sort": 4
},
{
"id": 6,
@@ -51,7 +56,8 @@
"totalCount": 6,
"itid": 40,
"basePrice": "31002&300",
"maxPrice": "31002&600"
"maxPrice": "31002&600",
"sort": 7
},
{
"id": 7,
@@ -60,7 +66,8 @@
"totalCount": 6,
"itid": 40,
"basePrice": "31002&150",
"maxPrice": "31002&200"
"maxPrice": "31002&200",
"sort": 6
},
{
"id": 8,
@@ -69,7 +76,8 @@
"totalCount": 6,
"itid": 28,
"basePrice": "31002&2000",
"maxPrice": "31002&4000"
"maxPrice": "31002&4000",
"sort": 8
},
{
"id": 9,
@@ -78,7 +86,8 @@
"totalCount": 6,
"itid": 28,
"basePrice": "31002&1000",
"maxPrice": "31002&2000"
"maxPrice": "31002&2000",
"sort": 9
},
{
"id": 10,
@@ -87,7 +96,8 @@
"totalCount": 42,
"itid": 41,
"basePrice": "31002&5000",
"maxPrice": "31002&7000"
"maxPrice": "31002&7000",
"sort": 10
},
{
"id": 11,
@@ -96,7 +106,8 @@
"totalCount": 42,
"itid": 41,
"basePrice": "31002&3000",
"maxPrice": "31002&6000"
"maxPrice": "31002&6000",
"sort": 11
},
{
"id": 12,
@@ -105,7 +116,8 @@
"totalCount": 1,
"itid": 38,
"basePrice": "31002&800",
"maxPrice": "31002&1600"
"maxPrice": "31002&1600",
"sort": 12
},
{
"id": 13,
@@ -114,7 +126,8 @@
"totalCount": 1,
"itid": 38,
"basePrice": "31002&800",
"maxPrice": "31002&1600"
"maxPrice": "31002&1600",
"sort": 13
},
{
"id": 14,
@@ -123,7 +136,8 @@
"totalCount": 7,
"itid": 38,
"basePrice": "31002&800",
"maxPrice": "31002&1600"
"maxPrice": "31002&1600",
"sort": 14
},
{
"id": 15,
@@ -132,7 +146,8 @@
"totalCount": 6,
"itid": 38,
"basePrice": "31002&800",
"maxPrice": "31002&1600"
"maxPrice": "31002&1600",
"sort": 15
},
{
"id": 16,
@@ -141,6 +156,7 @@
"totalCount": 5,
"itid": 38,
"basePrice": "31002&800",
"maxPrice": "31002&1600"
"maxPrice": "31002&1600",
"sort": 16
}
]

79
shared/resource/jsons/dic_zyz_gk_pvp.json Executable file → Normal file
View File

@@ -5,53 +5,82 @@
"bg_img_id": 107,
"warType": 9,
"gk_name": "地图1",
"mapseid": "50101&50201&50202",
"victoryInfoInUI": "5回合内杀死2个敌军",
"loseInfoInUI": "5回合内未杀死2个敌军",
"pvpVictoryCondition": "111&5&2&",
"turnLimted": 10
"turnLimted": 10,
"needPrepare": 1,
"selectView": 1
},
{
"war_id": 4502,
"dispatchJsonId": 4502,
"bg_img_id": 542,
"bg_img_id": 107,
"warType": 9,
"gk_name": "地图2",
"victoryInfoInUI": "我军死亡武将不超过2人",
"loseInfoInUI": "我军阵亡武将超出2人",
"pvpVictoryCondition": "102&2&",
"turnLimted": 10
"gk_name": "地图1",
"mapseid": "50101&50201&50202",
"victoryInfoInUI": "5回合内杀死2个敌军",
"loseInfoInUI": "5回合内未杀死2个敌军",
"pvpVictoryCondition": "111&5&2&",
"turnLimted": 10,
"needPrepare": 1,
"selectView": 0
},
{
"war_id": 4503,
"dispatchJsonId": 4503,
"bg_img_id": 543,
"bg_img_id": 542,
"warType": 9,
"gk_name": "地图3",
"victoryInfoInUI": "我军全员生存",
"loseInfoInUI": "我军有武将阵亡",
"pvpVictoryCondition": "102&0&",
"turnLimted": 10
"gk_name": "地图2",
"mapseid": "50306&50307&50401",
"victoryInfoInUI": "我军死亡武将不超过2人",
"loseInfoInUI": "我军阵亡武将超出2人",
"pvpVictoryCondition": "102&2&",
"turnLimted": 10,
"needPrepare": 1,
"selectView": 1
},
{
"war_id": 4504,
"dispatchJsonId": 4504,
"bg_img_id": 501,
"bg_img_id": 542,
"warType": 9,
"gk_name": "地图4",
"victoryInfoInUI": "10回合内获得胜利",
"loseInfoInUI": "10回合内未能击杀全部敌军",
"pvpVictoryCondition": "106&10&",
"turnLimted": 10
"gk_name": "地图2",
"mapseid": "50306&50307&50401",
"victoryInfoInUI": "我军死亡武将不超过2人",
"loseInfoInUI": "我军阵亡武将超出2人",
"pvpVictoryCondition": "102&2&",
"turnLimted": 10,
"needPrepare": 1,
"selectView": 0
},
{
"war_id": 4505,
"dispatchJsonId": 4505,
"bg_img_id": 1003,
"bg_img_id": 543,
"warType": 9,
"gk_name": "地图5",
"victoryInfoInUI": "同一名武将击杀3名敌军",
"loseInfoInUI": "未有同一名武将击杀3名敌军",
"pvpVictoryCondition": "400&3&",
"turnLimted": 10
"gk_name": "地图3",
"mapseid": "50205&50206&50207",
"victoryInfoInUI": "我军全员生存",
"loseInfoInUI": "我军有武将阵亡",
"pvpVictoryCondition": "102&0&",
"turnLimted": 10,
"needPrepare": 1,
"selectView": 1
},
{
"war_id": 4506,
"dispatchJsonId": 4505,
"bg_img_id": 543,
"warType": 9,
"gk_name": "地图3",
"mapseid": "50205&50206&50207",
"victoryInfoInUI": "我军全员生存",
"loseInfoInUI": "我军有武将阵亡",
"pvpVictoryCondition": "102&0&",
"turnLimted": 10,
"needPrepare": 1,
"selectView": 0
}
]