拍卖行:获取军团拍卖记录;修改分红机制
This commit is contained in:
@@ -3,9 +3,9 @@ import { DividendModel } from './../../../db/Dividend';
|
||||
import { Application, BackendSession, ChannelService } from "pinus";
|
||||
import { AUCTION_STAGE, DEBUG_MAGIC_WORD, STATUS, OFFER_RATIO, CURRENCY_BY_TYPE, CURRENCY_TYPE, DATA_NAME, LOT_STATUS } from "../../../consts";
|
||||
import { LotModel } from "../../../db/Lot";
|
||||
import { ItemReward } from "../../../domain/dbGeneral";
|
||||
import { ItemReward, LotRec } from "../../../domain/dbGeneral";
|
||||
import { resResult } from "../../../pubUtils/util";
|
||||
import { auctionStage, calculateDividend, genAuction, sendUngotDividend, startGuildAuction, startWorldAuction, stopAuction, todayGuildBegin } from "../../../services/auctionService";
|
||||
import { auctionStage, calculateDividend, genAuction, sendUngotDividend, startGuildAuction, startWorldAuction, stopAuction, todayGuildBegin, getBasePrice } from "../../../services/auctionService";
|
||||
import { addItems, handleCost } from '../../../services/rewardService';
|
||||
import { getSimpleRoleInfo } from '../../../services/roleService';
|
||||
import { getRoleOnlineInfo } from '../../../services/redisService';
|
||||
@@ -51,7 +51,7 @@ export class AuctionHandler {
|
||||
}
|
||||
|
||||
const lot = await LotModel.findLot(code);
|
||||
if (!lot || lot.status === LOT_STATUS.SOLD) {
|
||||
if (!lot || lot.status === LOT_STATUS.SOLD || lot.status === LOT_STATUS.MAX) {
|
||||
res.releaseCallback();
|
||||
return resResult(STATUS.GUILD_LOT_NOT_FOUND);
|
||||
}
|
||||
@@ -84,12 +84,15 @@ export class AuctionHandler {
|
||||
await addItems(roleId, roleName, sid, [{ id: gid, count }]);
|
||||
}
|
||||
bidRoles.push({ roleId, price: newPrice, time: new Date() });
|
||||
const newLot = await LotModel.updateLot({ code, curBuyer: roleId, curPrice: newPrice, bidRoles, status: maxFlag ? LOT_STATUS.SOLD : LOT_STATUS.ING, watchingRoles: Array.from(new Set([...watchingRoles, roleId])) });
|
||||
const newLot = await LotModel.updateLot({ code, curBuyer: roleId, curPrice: newPrice, bidRoles, status: max ? LOT_STATUS.MAX : (maxFlag ? LOT_STATUS.SOLD : LOT_STATUS.ING), watchingRoles: Array.from(new Set([...watchingRoles, roleId])) });
|
||||
res.releaseCallback();
|
||||
|
||||
const incPrice = newPrice - (curBuyer ? curPrice : 0);
|
||||
const dividend = await DividendModel.updateLot(code, gid, newPrice, incPrice);
|
||||
const newDividend = await calculateDividend(dividend);
|
||||
let newDividend = null;
|
||||
if (auctionStage() === AUCTION_STAGE.GUILD) {
|
||||
const dividend = await DividendModel.updateLot(code, gid, newPrice, incPrice, max);
|
||||
newDividend = await calculateDividend(dividend);
|
||||
}
|
||||
return resResult(STATUS.SUCCESS, { lot: newLot, dividend: newDividend });
|
||||
} catch (e) {
|
||||
console.log('offer got err:', e);
|
||||
@@ -159,6 +162,25 @@ export class AuctionHandler {
|
||||
return resResult(STATUS.SUCCESS, { bidRecs });
|
||||
}
|
||||
|
||||
async guildLotRecs(msg: { count: number }, session: BackendSession) {
|
||||
const guildCode = session.get('guildCode');
|
||||
const dividends = await DividendModel.findDividendsByGuild(guildCode, msg.count);
|
||||
let lotsData: LotRec[] = [];
|
||||
dividends.forEach(dividend => {
|
||||
const lots = dividend.lots.map(lot => {
|
||||
return { ...lot, sourceType: dividend.sourceType };
|
||||
})
|
||||
lotsData = [...lotsData, ...lots];
|
||||
});
|
||||
const lotRecs = lotsData.map(lot => {
|
||||
const price = lot.price === 0 ? getBasePrice(lot.gid, lot.count) : lot.price;
|
||||
const sold = lot.price !== 0;
|
||||
return { ...lot, price, sold };
|
||||
});
|
||||
|
||||
return resResult(STATUS.SUCCESS, { lotRecs });
|
||||
}
|
||||
|
||||
// ! 测试接口
|
||||
async debugSetDividendStatus(msg: { magicWord: string, sourceType: number, status: number }, session: BackendSession) {
|
||||
const { magicWord, sourceType, status } = msg;
|
||||
|
||||
Reference in New Issue
Block a user