拍卖行:修改分红逻辑

This commit is contained in:
luying
2022-05-07 09:45:13 +08:00
parent a161fbd239
commit 7347e6bd1f
3 changed files with 17 additions and 11 deletions
@@ -4,7 +4,7 @@ import { AUCTION_STAGE, DEBUG_MAGIC_WORD, STATUS, CURRENCY_BY_TYPE, CURRENCY_TYP
import { LotModel } from "../../../db/Lot";
import { ItemReward } from "../../../domain/dbGeneral";
import { genCode, resResult } from "../../../pubUtils/util";
import { auctionStage, calculateDividend, genAuction, sendUngotDividend, startGuildAuction, startWorldAuction, stopAuction, todayGuildBegin, getBasePrice, debugAuctionLots, officialAuctionLots, auctionBidStatus, getMaxPrice, guildBidStatus, getAuction, pushAuctionOver, treatSingleLotTime, treatLotsTime } from "../../../services/auctionService";
import { auctionStage, calculateDividend, genAuction, sendUngotDividend, startGuildAuction, startWorldAuction, stopAuction, todayGuildBegin, getBasePrice, debugAuctionLots, officialAuctionLots, auctionBidStatus, getMaxPrice, guildBidStatus, getAuction, pushAuctionOver, treatSingleLotTime, treatLotsTime, pushAuctionUpdate } from "../../../services/auctionService";
import { addItems, getGoldObject, handleCost } from '../../../services/role/rewardService';
import { getSimpleRoleInfo } from '../../../services/roleService';
import { getRoleOnlineInfo } from '../../../services/redisService';
@@ -113,10 +113,10 @@ export class AuctionHandler {
await pushAuctionOver(newLot); // 推送竞价超过标志
res.releaseCallback();
const incPrice = newPrice - (curBuyer ? curPrice : 0);
const incPrice = curPrice - prePrice > 0? prePrice: 0;
let newDividend = null;
if (lot.auctionStage === AUCTION_STAGE.GUILD) {
const dividend = await DividendModel.updateLot(code, gid, newPrice, incPrice, max);
const dividend = await DividendModel.updateLot(code, gid, curPrice, incPrice, max);
newDividend = await calculateDividend(dividend);
}
let newLotResult = await treatSingleLotTime(newLot);
+8 -3
View File
@@ -1,5 +1,5 @@
import { DividendModel } from './../db/Dividend';
import { LOT_CODE_LEN, AUCTION_STAGE, AUCTION_TIME, DIVIDEND_CODE_LEN, DIVIDEND_STATUS, LOT_STATUS, MAIL_TYPE, CURRENCY_BY_TYPE, CURRENCY_TYPE, DIVIDENDMAXRATIO, DIVIDENDPOSITIONMAXRATIO, ROLE_RECEIVE_STATUS, AUCTION_BID_STATUS, DEBUG_MAGIC_WORD, AUCTION_SOURCE, TA_EVENT, getAuctionSourceTypeName, PUSH_ROUTE } from './../consts';
import { LOT_CODE_LEN, AUCTION_STAGE, AUCTION_TIME, DIVIDEND_CODE_LEN, DIVIDEND_STATUS, LOT_STATUS, MAIL_TYPE, CURRENCY_BY_TYPE, CURRENCY_TYPE, DIVIDENDMAXRATIO, DIVIDENDPOSITIONMAXRATIO, ROLE_RECEIVE_STATUS, AUCTION_BID_STATUS, DEBUG_MAGIC_WORD, AUCTION_SOURCE, TA_EVENT, getAuctionSourceTypeName, PUSH_ROUTE, GUILD_JOB } from './../consts';
import { DividendRec, ItemReward } from "../domain/dbGeneral";
import { genCode, getRandSingleEelm } from '../pubUtils/util';
import { LotModel, LotParam, LotType } from '../db/Lot';
@@ -242,8 +242,12 @@ export async function genAuction(guildCode: string, sourceType: number, sourceCo
function posDividend(totalPrice: number, roleRatio: number, totalRatio: number) {
const dividend = Math.floor(totalPrice * roleRatio / totalRatio);
const maxDividend = Math.floor(totalPrice * DIVIDENDMAXRATIO);
return dividend <= maxDividend ? dividend : Math.floor(maxDividend * roleRatio / DIVIDENDPOSITIONMAXRATIO);
const maxDividend = Math.floor(totalPrice * dicParam.GUILD_AUCTION.DIVIDEND_MAXRATIO);
return dividend <= maxDividend ? dividend : Math.floor(maxDividend * roleRatio / getMaxPosRatio());
}
function getMaxPosRatio() {
return gameData.guildPosition.get(GUILD_JOB.DAJIANGJUN).sellRatio;
}
function weekendDividend(posNum: number, date: Date) {
@@ -275,6 +279,7 @@ export async function calculateDividend(dividend: DividendType) {
const totalRatio = totalDividendRatio(participantsData);
const dividends: DividendRec[] = participantsData.map(data => {
const { roleId } = data;
console.log('### calculateDividend', calcuTotalPrice, dividendRate(data), totalRatio)
const posNum = posDividend(calcuTotalPrice, dividendRate(data), totalRatio);
const weekendNum = weekendDividend(posNum, begin);
return {