拍卖行:价格修改
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { DividendModel } from './../../../db/Dividend';
|
||||
import { Application, BackendSession, ChannelService, HandlerService, } from "pinus";
|
||||
import { AUCTION_STAGE, DEBUG_MAGIC_WORD, STATUS, OFFER_RATIO, CURRENCY_BY_TYPE, CURRENCY_TYPE, DATA_NAME, LOT_STATUS } from "../../../consts";
|
||||
import { AUCTION_STAGE, DEBUG_MAGIC_WORD, STATUS, CURRENCY_BY_TYPE, CURRENCY_TYPE, DATA_NAME, LOT_STATUS } from "../../../consts";
|
||||
import { LotModel } from "../../../db/Lot";
|
||||
import { ItemReward } from "../../../domain/dbGeneral";
|
||||
import { resResult } from "../../../pubUtils/util";
|
||||
@@ -15,6 +15,8 @@ import { openGuildRefine } from '../../../services/guildRefineService';
|
||||
import { unlockTrain } from '../../../services/guildTrainService';
|
||||
import { UserGuildModel } from '../../../db/UserGuild';
|
||||
import { UserGuildApplyModel } from '../../../db/UserGuildApply';
|
||||
import * as dicParam from '../../../pubUtils/dicParam';
|
||||
import { getAuctionRewardByPoolId } from '../../../pubUtils/data';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
@@ -67,7 +69,7 @@ export class AuctionHandler {
|
||||
res.releaseCallback();
|
||||
return resResult(STATUS.LOT_OFFER_SERIAL);
|
||||
}
|
||||
let newPrice = Math.floor(curPrice * OFFER_RATIO);
|
||||
let newPrice = Math.floor(curPrice * dicParam.GUILD_AUCTION.AUCTION_PRICE_RISE);
|
||||
let maxFlag = max;
|
||||
if (newPrice >= maxPrice) {
|
||||
newPrice = maxPrice;
|
||||
@@ -214,8 +216,8 @@ export class AuctionHandler {
|
||||
}
|
||||
|
||||
// ! 测试接口
|
||||
async debugAddLots(msg: { magicWord: string, sourceType: number, sourceCode: string, rewards: ItemReward[] }, session: BackendSession) {
|
||||
const { magicWord, sourceType, sourceCode, rewards } = msg;
|
||||
async debugAddLots(msg: { magicWord: string, sourceType: number, sourceCode: string, poolId: number }, session: BackendSession) {
|
||||
const { magicWord, sourceType, sourceCode, poolId } = msg;
|
||||
if (magicWord !== DEBUG_MAGIC_WORD) {
|
||||
return resResult(STATUS.TOKEN_ERR);
|
||||
}
|
||||
@@ -242,6 +244,8 @@ export class AuctionHandler {
|
||||
await UserGuildApplyModel.deleteApply(roleId); // 删除玩家所有对其他公会的申请
|
||||
}
|
||||
|
||||
let rewards = getAuctionRewardByPoolId(poolId);
|
||||
if(!rewards) return resResult(STATUS.WRONG_PARMS);
|
||||
const result = await genAuction(guildCode, sourceType, sourceCode, serverId, rewards);
|
||||
if (!result) {
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import { MailModel, MailType } from './../db/Mail';
|
||||
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, STATUS, DIVIDENDWEEKENDRATE, DIVIDENDMAXRATIO, DIVIDENDPOSITIONMAXRATIO, ROLE_RECEIVE_STATUS, AUCTION_BID_STATUS, DEBUG_MAGIC_WORD, AUCTION_SOURCE } 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 } from './../consts';
|
||||
import { DividendRec, ItemReward } from "../domain/dbGeneral";
|
||||
import { genCode, resResult } from '../pubUtils/util';
|
||||
import { genCode } from '../pubUtils/util';
|
||||
import { LotModel, LotParam } from '../db/Lot';
|
||||
import { getZeroPointD, getTimeFunD } from '../pubUtils/timeUtil';
|
||||
import { getTimeFunD } from '../pubUtils/timeUtil';
|
||||
import { gameData, getGoodById } from '../pubUtils/data';
|
||||
import { DividendParam, DividendType } from '../db/Dividend';
|
||||
import { pushMail } from '../pubUtils/interface';
|
||||
import { sendMailByContent } from './mailService';
|
||||
import { pinus, BackendSession, FrontendOrBackendSession } from 'pinus';
|
||||
import { FrontendOrBackendSession } from 'pinus';
|
||||
import { participants } from './guildActivityService';
|
||||
import { Member } from '../domain/battleField/guildActivity';
|
||||
import * as dicParam from '../pubUtils/dicParam';
|
||||
import { RewardInter } from '../pubUtils/interface';
|
||||
|
||||
// ! 获取底价,假数据
|
||||
export function getBasePrice(gid: number, count: number) {
|
||||
@@ -142,7 +142,7 @@ export function getBossAuctionEnd() {
|
||||
* @param {number} serverId
|
||||
* @param {ItemReward[]} rewards
|
||||
*/
|
||||
export async function genAuction(guildCode: string, sourceType: number, sourceCode: string, serverId: number, rewards: ItemReward[]) {
|
||||
export async function genAuction(guildCode: string, sourceType: number, sourceCode: string, serverId: number, rewards: { goods: RewardInter, basePrice: number, maxPrice: number}[]) {
|
||||
let begin = auctionBegin();
|
||||
let end = auctionEnd();
|
||||
if(sourceType == AUCTION_SOURCE.BOSS) { // 军团boss本
|
||||
@@ -150,13 +150,13 @@ export async function genAuction(guildCode: string, sourceType: number, sourceCo
|
||||
end = getBossAuctionEnd();
|
||||
}
|
||||
const guildEnd = guildAuctionEnd();
|
||||
const lotsData: LotParam[] = rewards.map(reward => {
|
||||
const { id, count } = reward;
|
||||
const lotsData: LotParam[] = rewards.map(({ goods, basePrice, maxPrice }) => {
|
||||
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: getMaxPrice(id, count), curPrice: getBasePrice(id, count),
|
||||
maxPrice, curPrice: basePrice,
|
||||
}
|
||||
});
|
||||
const lots = await LotModel.createRecs(lotsData);
|
||||
@@ -179,7 +179,7 @@ function posDividend(totalPrice: number, roleRatio: number, totalRatio: number)
|
||||
|
||||
function weekendDividend(posNum: number, date: Date) {
|
||||
const day = date.getDay();
|
||||
return (day === 0 || day === 6) ? Math.floor(posNum * DIVIDENDWEEKENDRATE) : 0;
|
||||
return (day === 0 || day === 6) ? Math.floor(posNum * dicParam.GUILD_AUCTION.DIVIDEND_WEEKEND_RATE) : 0;
|
||||
}
|
||||
|
||||
function dividendRate(data: Member) {
|
||||
@@ -197,7 +197,7 @@ export async function calculateDividend(dividend: DividendType) {
|
||||
if (!dividend) return null;
|
||||
const { code, guildCode, sourceType, sourceCode, lots, totalPrice, status, begin } = dividend;
|
||||
if (status === DIVIDEND_STATUS.SENT) return dividend;
|
||||
const calcuTotalPrice = lots.reduce((acc, lot) => { return acc + lot.price }, 0);
|
||||
const calcuTotalPrice = lots.reduce((acc, lot) => { return acc + lot.price }, 0) * dicParam.GUILD_AUCTION.DIVIDEND_RATE;
|
||||
if (calcuTotalPrice !== totalPrice) {
|
||||
await DividendModel.updateDividend(code, { totalPrice: calcuTotalPrice });
|
||||
// 更新 totalPrice
|
||||
|
||||
@@ -393,7 +393,7 @@ export async function gateActivitySettleReward(guildCode: string, serverId: numb
|
||||
rank, score: guildScore, remainGateHp: gateHp,
|
||||
members, memberCnt: members.length,
|
||||
auctionType: AUCTION_SOURCE.GATE,
|
||||
rewards
|
||||
rewards: rewards.map(cur => cur.goods)
|
||||
});
|
||||
// 结算功勋等奖励
|
||||
let dic = gameData.guildActivity.get(GUILD_ACTIVITY_TYPE.GATE_ACTIVITY);
|
||||
@@ -455,7 +455,7 @@ export async function cityActivitySettleReward(cityId: number, serverId: number)
|
||||
memberCnt: members.length, members,
|
||||
isSuccess, isCompleted: true,
|
||||
rank: guildRank, damage: num, remainGateHp: gateHp,
|
||||
rewards,
|
||||
rewards: rewards.map(cur => cur.goods),
|
||||
auctionType: AUCTION_SOURCE.CITY,
|
||||
});
|
||||
|
||||
@@ -690,7 +690,7 @@ export async function raceActivitySettleReward(guildCode: string, woodenHorse: W
|
||||
let rec = await GuildActivityRecordModel.updateInfo(guildCode, {
|
||||
memberCnt: members.length, members,
|
||||
isSuccess, isCompleted: true, rank: myGuildRank,
|
||||
rewards,
|
||||
rewards: rewards.map(cur => cur.goods),
|
||||
woodenHorse,
|
||||
});
|
||||
if (rec) {
|
||||
|
||||
Reference in New Issue
Block a user