diff --git a/game-server/app/servers/battle/handler/auctionHandler.ts b/game-server/app/servers/battle/handler/auctionHandler.ts index 7ce13a5ee..ffe0a9a9a 100644 --- a/game-server/app/servers/battle/handler/auctionHandler.ts +++ b/game-server/app/servers/battle/handler/auctionHandler.ts @@ -18,6 +18,10 @@ export class AuctionHandler { } + async watchLot(msg: { code: string }, session: BackendSession) { + + } + async checkDividend(msg: {}, session: BackendSession) { } diff --git a/game-server/app/services/auctionService.ts b/game-server/app/services/auctionService.ts index f89da4bd4..91c4ea4ea 100644 --- a/game-server/app/services/auctionService.ts +++ b/game-server/app/services/auctionService.ts @@ -1,4 +1,7 @@ +import { LOT_CODE_LEN, AUCTION_STAGE, AUCTION_SOURCE } from './../consts'; import { ItemReward } from "../domain/dbGeneral"; +import { genCode } from '../pubUtils/util'; +import { LotModel, LotParam } from '../db/Lot'; /** * @description 生成拍卖数据 @@ -10,7 +13,17 @@ import { ItemReward } from "../domain/dbGeneral"; * @param {ItemReward[]} rewards */ export async function genAuction(guildCode: string, sourceType: number, sourceCode: string, serverId: number, rewards: ItemReward[]) { - + const lots: LotParam[] = rewards.map(reward => { + const { id, count } = reward; + const code = genCode(LOT_CODE_LEN); + return { + auctionStage: AUCTION_STAGE.DEFAULT, sourceType, + sourceCode, serverId, guildCode, code, gid: id, count + // maxPrice, begin, end + } + }); + const result = await LotModel.createRecs(lots); + return result; } diff --git a/shared/consts/constModules/auctionConst.ts b/shared/consts/constModules/auctionConst.ts new file mode 100644 index 000000000..e0ff9ee49 --- /dev/null +++ b/shared/consts/constModules/auctionConst.ts @@ -0,0 +1,16 @@ +export const AUCTION_STAGE = { + DEFAULT: 0, + GUILD: 1, + WORLD: 2, + END: 3, +}; + +export const AUCTION_SOURCE = { + DEFAULT: 0, + BOSS: 1, // 演武 + GATE: 2, // 蛮夷入侵 + CITY: 3, // 诸侯混战 + RACE: 4, // 粮草先行 +}; + +export const LOT_CODE_LEN = 8; \ No newline at end of file diff --git a/shared/consts/index.ts b/shared/consts/index.ts index 8ab622c87..8c2c5143c 100644 --- a/shared/consts/index.ts +++ b/shared/consts/index.ts @@ -8,5 +8,6 @@ export * from './constModules/guildConst'; export * from './constModules/selectConst'; export * from './constModules/chatConst'; export * from './constModules/httpConst'; +export * from './constModules/auctionConst'; export * from './statusCode'; export * from './dataName'; \ No newline at end of file diff --git a/shared/db/Lot.ts b/shared/db/Lot.ts index ebe45c49f..c7e49d43f 100644 --- a/shared/db/Lot.ts +++ b/shared/db/Lot.ts @@ -13,7 +13,7 @@ export default class Lot extends BaseModel { @prop({ required: true, default: 0 }) auctionStage: number; // 0:初始添加,1:军团拍卖,2:世界拍卖,3:拍卖结束 @prop({ required: true, default: 0 }) - type: number; // 0:初始值,1:演武;2:蛮夷入侵;3:诸侯混战;4:粮草先行 + sourceType: number; // 0:初始值,1:演武;2:蛮夷入侵;3:诸侯混战;4:粮草先行 @prop({ required: true, default: '' }) sourceCode: string; // 来源的唯一标识,如活动编号 @prop({ required: true, default: 0 }) @@ -24,6 +24,8 @@ export default class Lot extends BaseModel { code: string; // 竞拍物品唯一标识 @prop({ required: true, default: 0 }) gid: number; // 物品 id + @prop({ required: true, default: 1 }) + count: number; // 物品数量 @prop({ required: true, default: 0 }) curPrice: number; // 当前出价 @prop({ required: true, default: '' }) @@ -44,6 +46,11 @@ export default class Lot extends BaseModel { return result; } + public static async createRecs(datas: LotParam[]) { + const result: LotType[] = await LotModel.insertMany(datas); + return result; + } + public static async findLot(code: string) { const result = await LotModel.findOne({ code }).select('-_id -__v').lean(); return result;