拍卖:数据库操作
This commit is contained in:
@@ -18,6 +18,10 @@ export class AuctionHandler {
|
||||
|
||||
}
|
||||
|
||||
async watchLot(msg: { code: string }, session: BackendSession) {
|
||||
|
||||
}
|
||||
|
||||
async checkDividend(msg: {}, session: BackendSession) {
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user