拍卖行:修改拍卖阶段判断,实现查看分红接口

This commit is contained in:
liangtongchuan
2021-03-18 14:17:00 +08:00
parent 9a463afd0d
commit 73d2523870
2 changed files with 27 additions and 12 deletions

View File

@@ -4,7 +4,7 @@ import { AUCTION_STAGE, DEBUG_MAGIC_WORD, STATUS, OFFER_RATIO, CURRENCY_BY_TYPE,
import { LotModel } from "../../../db/Lot";
import { ItemReward } from "../../../domain/dbGeneral";
import { resResult } from "../../../pubUtils/util";
import { auctionBegin, auctionStage, genAuction } from "../../../services/auctionService";
import { auctionBegin, auctionStage, calculateDividend, genAuction, todayGuildBegin } from "../../../services/auctionService";
import { addItems, handleCost } from '../../../services/rewardService';
import { getSimpleRoleInfo } from '../../../services/roleService';
import { getRoleOnlineInfo } from '../../../services/redisService';
@@ -23,7 +23,7 @@ export class AuctionHandler {
const guildCode = session.get('guildCode');
const serverId = session.get('serverId');
if (!guildCode) return resResult(STATUS.GUILD_NOT_FOUND);
const begin = auctionBegin();
const begin = todayGuildBegin();
const stage = auctionStage();
let lots = [];
if (stage === AUCTION_STAGE.DEFAULT || stage === AUCTION_STAGE.GUILD) {
@@ -65,7 +65,9 @@ export class AuctionHandler {
const incPrice = newPrice - (curBuyer ? curPrice : 0);
const dividend = await DividendModel.updateLot(code, gid, newPrice, incPrice);
return resResult(STATUS.SUCCESS, { lot: newLot, dividend });
const newDividend = await calculateDividend(dividend);
// TODO 加关注
return resResult(STATUS.SUCCESS, { lot: newLot, dividend: newDividend });
}
async watchLot(msg: { code: string }, session: BackendSession) {
@@ -73,10 +75,14 @@ export class AuctionHandler {
}
async checkDividend(msg: {}, session: BackendSession) {
return resResult(STATUS.SUCCESS);
const begin = todayGuildBegin();
const guildCode = session.get('guildCode');
if (!guildCode) return resResult(STATUS.GUILD_NOT_FOUND);
const dividends = await DividendModel.findGuildDividendsByBegin(guildCode, begin);
return resResult(STATUS.SUCCESS, { dividends });
}
async getDividend(msg: {}, session: BackendSession) {
async getDividend(msg: { sourceType: number }, session: BackendSession) {
return resResult(STATUS.SUCCESS);
}

View File

@@ -21,13 +21,10 @@ function getMaxPrice(gid: number, count: number) {
export function auctionStage() {
const curTime = new Date().getTime();
const todayGuildBegin = getNextTime(getTodayZeroDate(), AUCTION_TIME.GUILD_BEGIN_HOUR, AUCTION_TIME.GUILD_BEGIN_MIN).getTime();
const todayWorldBegin = getNextTime(getTodayZeroDate(), AUCTION_TIME.WORLD_BEGIN_HOUR, AUCTION_TIME.WORLD_BEGIN_MIN).getTime();
const todayWorldEnd = getNextTime(getTodayZeroDate(), AUCTION_TIME.WORLD_END_HOUR, AUCTION_TIME.WORLD_END_MIN).getTime();
if (curTime < todayGuildBegin) return AUCTION_STAGE.DEFAULT;
if (curTime < todayWorldBegin && curTime > todayGuildBegin) return AUCTION_STAGE.GUILD;
if (curTime > todayWorldBegin && curTime < todayWorldEnd) return AUCTION_STAGE.WORLD;
if (curTime > todayWorldEnd) return AUCTION_STAGE.END;
if (curTime < todayGuildBegin().getTime()) return AUCTION_STAGE.DEFAULT;
if (curTime < todayWorldBegin().getTime() && curTime > todayGuildBegin().getTime()) return AUCTION_STAGE.GUILD;
if (curTime > todayWorldBegin().getTime() && curTime < todayWorldEnd().getTime()) return AUCTION_STAGE.WORLD;
if (curTime > todayWorldEnd().getTime()) return AUCTION_STAGE.END;
}
export function auctionBegin() {
@@ -38,6 +35,18 @@ export function auctionEnd() {
return getNextTime(new Date(), AUCTION_TIME.WORLD_END_HOUR, AUCTION_TIME.WORLD_END_MIN);
}
export function todayGuildBegin() {
return getNextTime(getTodayZeroDate(), AUCTION_TIME.GUILD_BEGIN_HOUR, AUCTION_TIME.GUILD_BEGIN_MIN);
}
export function todayWorldBegin() {
return getNextTime(getTodayZeroDate(), AUCTION_TIME.WORLD_BEGIN_HOUR, AUCTION_TIME.WORLD_BEGIN_MIN);
}
export function todayWorldEnd() {
return getNextTime(getTodayZeroDate(), AUCTION_TIME.WORLD_END_HOUR, AUCTION_TIME.WORLD_END_MIN);
}
/**
* @description 生成拍卖数据
* @export