拍卖:数据库操作

This commit is contained in:
liangtongchuan
2021-03-17 11:29:26 +08:00
parent 2bb852135d
commit 023f7de8b9
5 changed files with 43 additions and 2 deletions
@@ -18,6 +18,10 @@ export class AuctionHandler {
}
async watchLot(msg: { code: string }, session: BackendSession) {
}
async checkDividend(msg: {}, session: BackendSession) {
}
+14 -1
View File
@@ -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;
}