✨ feat(拍卖行): 只流3个拍品到世界拍卖行
https://bantugame.feishu.cn/wiki/wikcn1qfpNYNUnOvuKiyK69eqqg?lang=zh-CN&open_in_browser=true
This commit is contained in:
@@ -17,6 +17,8 @@ import { getAllServers } from './redisService';
|
||||
import { sendMessageToGuildWithSuc, sendMessageToServer, sendMessageToServerWithSuc } from './pushService';
|
||||
import { isDebugTime } from '../pubUtils/sdkUtil';
|
||||
import { pick } from 'underscore';
|
||||
import { AuctionRewardInter } from '../domain/battleField/auction';
|
||||
import { CounterLotsModel } from '../db/CounterAuction';
|
||||
|
||||
// ! 获取底价,假数据
|
||||
export function getBasePrice(gid: number, count: number) {
|
||||
@@ -179,7 +181,7 @@ export async function getBossAuctionEnd() {
|
||||
* @param {number} serverId
|
||||
* @param {ItemReward[]} rewards
|
||||
*/
|
||||
export async function genAuction(guildCode: string, sourceType: number, sourceCode: string, serverId: number, rewards: { goods: RewardInter, basePrice: number, maxPrice: number, sort: number}[]) {
|
||||
export async function genAuction(guildCode: string, sourceType: number, sourceCode: string, serverId: number, rewards: Map<number, AuctionRewardInter[]>) {
|
||||
let begin = await auctionBegin();
|
||||
let end = await auctionEnd();
|
||||
if(sourceType == AUCTION_SOURCE.BOSS) { // 军团boss本
|
||||
@@ -187,15 +189,20 @@ export async function genAuction(guildCode: string, sourceType: number, sourceCo
|
||||
end = await getBossAuctionEnd();
|
||||
}
|
||||
const guildEnd = await guildAuctionEnd();
|
||||
const lotsData: LotParam[] = rewards.map(({ goods, basePrice, maxPrice, sort }) => {
|
||||
const { id, count } = goods;
|
||||
const code = genCode(LOT_CODE_LEN);
|
||||
return {
|
||||
auctionStage: AUCTION_STAGE.DEFAULT, sourceType,
|
||||
sourceCode, serverId, guildCode, code, gid: id, count, begin, end, status: LOT_STATUS.DEFAULT,
|
||||
maxPrice, curPrice: basePrice, prePrice: 0, sort, bidRoles: [], watchingRoles: []
|
||||
const lotsData: LotParam[] = [];
|
||||
for(let [id, items] of rewards) {
|
||||
let seq = await CounterLotsModel.getNewCounter(id, begin, items.length);
|
||||
for(let i = 0; i < items.length; i++) {
|
||||
let { goods: {id, count}, maxPrice, basePrice, sort } = items[i];
|
||||
let code = genCode(LOT_CODE_LEN);
|
||||
lotsData.push({
|
||||
seq: seq - i,
|
||||
auctionStage: AUCTION_STAGE.DEFAULT, sourceType,
|
||||
sourceCode, serverId, guildCode, code, gid: id, count, begin, end, status: LOT_STATUS.DEFAULT,
|
||||
maxPrice, curPrice: basePrice, prePrice: 0, sort, bidRoles: [], watchingRoles: []
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
const lots = await LotModel.createRecs(lotsData);
|
||||
const dividendCode = genCode(DIVIDEND_CODE_LEN);
|
||||
const participantsData = await participants(guildCode, sourceType, sourceCode);
|
||||
@@ -223,6 +230,16 @@ export async function genAuction(guildCode: string, sourceType: number, sourceCo
|
||||
return { lots, dividend };
|
||||
}
|
||||
|
||||
export function getRewardToDbFromMap(map: Map<number, AuctionRewardInter[]>) {
|
||||
let rewards: { id: number, count: number }[] = [];
|
||||
for(let [_, arr] of map) {
|
||||
for(let { goods } of arr) {
|
||||
rewards.push(goods)
|
||||
}
|
||||
}
|
||||
return rewards
|
||||
}
|
||||
|
||||
function posDividend(totalPrice: number, roleRatio: number, totalRatio: number) {
|
||||
const dividend = Math.floor(totalPrice * roleRatio / totalRatio);
|
||||
const maxDividend = Math.floor(totalPrice * dicParam.GUILD_AUCTION.DIVIDEND_MAXRATIO);
|
||||
@@ -323,12 +340,12 @@ export async function startWorldAuction() {
|
||||
const begin = await todayGuildBegin();
|
||||
let lots = await LotModel.setLotSoldByBegin(begin, AUCTION_STAGE.GUILD); // 正在竞拍的拍品
|
||||
await sendLotsRewardToMlail(lots);
|
||||
lots = await LotModel.updateUnSoldLotsStageByBegin(begin, AUCTION_STAGE.WORLD);
|
||||
lots = await LotModel.keepUnSoldLotsToWorld(begin);
|
||||
let dividends = await DividendModel.updateDividendsStatus(begin, DIVIDEND_STATUS.END);
|
||||
|
||||
if(isDebugTime()) {
|
||||
let day = getCurDay();
|
||||
let time = <number>getTimeFunM().getTimeWithWeek(day, 20, 40, 0);
|
||||
let time = <number>getTimeFunM().getTimeWithWeek(day, 20, 30, 0);
|
||||
pinus.app.rpc.guild.guildActivityRemote.setCurrentTime.broadcast(time);
|
||||
await pushCurrentTime(time);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user