拍卖行:处理分红格式
This commit is contained in:
@@ -1,10 +1,10 @@
|
|||||||
import { DividendModel } from './../../../db/Dividend';
|
import { DividendModel, DividendType } from './../../../db/Dividend';
|
||||||
import { Application, BackendSession, ChannelService, HandlerService, pinus, } from "pinus";
|
import { Application, BackendSession, ChannelService, HandlerService, pinus, } from "pinus";
|
||||||
import { AUCTION_STAGE, DEBUG_MAGIC_WORD, STATUS, CURRENCY_BY_TYPE, CURRENCY_TYPE, DATA_NAME, LOT_STATUS, CHANNEL_PREFIX, MAIL_TYPE, ITEM_CHANGE_REASON, TA_EVENT, ROLE_RECEIVE_STATUS, PUSH_ROUTE } from "../../../consts";
|
import { AUCTION_STAGE, DEBUG_MAGIC_WORD, STATUS, CURRENCY_BY_TYPE, CURRENCY_TYPE, DATA_NAME, LOT_STATUS, CHANNEL_PREFIX, MAIL_TYPE, ITEM_CHANGE_REASON, TA_EVENT, ROLE_RECEIVE_STATUS, PUSH_ROUTE } from "../../../consts";
|
||||||
import { LotModel } from "../../../db/Lot";
|
import { LotModel } from "../../../db/Lot";
|
||||||
import { ItemReward } from "../../../domain/dbGeneral";
|
import { ItemReward } from "../../../domain/dbGeneral";
|
||||||
import { genCode, resResult } from "../../../pubUtils/util";
|
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, pushAuctionUpdate, checkAuctionStage } from "../../../services/auctionService";
|
import { auctionStage, calculateDividend, genAuction, sendUngotDividend, startGuildAuction, startWorldAuction, stopAuction, todayGuildBegin, getBasePrice, debugAuctionLots, officialAuctionLots, auctionBidStatus, getMaxPrice, guildBidStatus, getAuction, pushAuctionOver, treatSingleLotTime, treatLotsTime, pushAuctionUpdate, checkAuctionStage, processDividendFormat, processSingleDividendFormat } from "../../../services/auctionService";
|
||||||
import { addItems, getGoldObject, handleCost } from '../../../services/role/rewardService';
|
import { addItems, getGoldObject, handleCost } from '../../../services/role/rewardService';
|
||||||
import { getSimpleRoleInfo } from '../../../services/roleService';
|
import { getSimpleRoleInfo } from '../../../services/roleService';
|
||||||
import { getRoleOnlineInfo } from '../../../services/redisService';
|
import { getRoleOnlineInfo } from '../../../services/redisService';
|
||||||
@@ -21,7 +21,7 @@ import { addRoleToGuildAuctionChannel, addRoleToWorldAuctionChannel, channelServ
|
|||||||
import { RewardInter } from '../../../pubUtils/interface';
|
import { RewardInter } from '../../../pubUtils/interface';
|
||||||
import { sendMailByContent } from '../../../services/mailService';
|
import { sendMailByContent } from '../../../services/mailService';
|
||||||
import { reportTAEvent } from '../../../services/sdkService';
|
import { reportTAEvent } from '../../../services/sdkService';
|
||||||
import { sendMessageToServerWithSuc } from '../../../services/pushService';
|
import { sendMessageToGuildWithSuc, sendMessageToServerWithSuc } from '../../../services/pushService';
|
||||||
|
|
||||||
export default function (app: Application) {
|
export default function (app: Application) {
|
||||||
new HandlerService(app, {});
|
new HandlerService(app, {});
|
||||||
@@ -119,13 +119,14 @@ export class AuctionHandler {
|
|||||||
res.releaseCallback();
|
res.releaseCallback();
|
||||||
|
|
||||||
const incPrice = curPrice - prePrice > 0? prePrice: 0;
|
const incPrice = curPrice - prePrice > 0? prePrice: 0;
|
||||||
let newDividend = null;
|
let newDividend: DividendType = null;
|
||||||
if (auctionStage === AUCTION_STAGE.GUILD) {
|
if (auctionStage === AUCTION_STAGE.GUILD) {
|
||||||
const dividend = await DividendModel.updateLot(code, gid, curPrice, incPrice, max);
|
const dividend = await DividendModel.updateLot(code, gid, curPrice, incPrice, max);
|
||||||
newDividend = await calculateDividend(dividend);
|
newDividend = await calculateDividend(dividend);
|
||||||
}
|
}
|
||||||
let newLotResult = await treatSingleLotTime(newLot);
|
let newLotResult = await treatSingleLotTime(newLot);
|
||||||
return resResult(STATUS.SUCCESS, { lot: newLotResult, dividend: newDividend });
|
await sendMessageToGuildWithSuc(guildCode, PUSH_ROUTE.DIVIDEND_UPDATE, { dividends: processDividendFormat([newDividend]) })
|
||||||
|
return resResult(STATUS.SUCCESS, { lot: newLotResult, dividend: processSingleDividendFormat(newDividend) });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('offer got err:', e);
|
console.log('offer got err:', e);
|
||||||
res.releaseCallback();
|
res.releaseCallback();
|
||||||
@@ -154,7 +155,7 @@ export class AuctionHandler {
|
|||||||
const guildCode = session.get('guildCode');
|
const guildCode = session.get('guildCode');
|
||||||
if (!guildCode) return resResult(STATUS.GUILD_NOT_FOUND);
|
if (!guildCode) return resResult(STATUS.GUILD_NOT_FOUND);
|
||||||
const dividends = await DividendModel.findGuildDividendsByBegin(guildCode, begin);
|
const dividends = await DividendModel.findGuildDividendsByBegin(guildCode, begin);
|
||||||
return resResult(STATUS.SUCCESS, { dividends });
|
return resResult(STATUS.SUCCESS, { dividends: processDividendFormat(dividends) });
|
||||||
}
|
}
|
||||||
|
|
||||||
async getDividend(msg: { code: string }, session: BackendSession) {
|
async getDividend(msg: { code: string }, session: BackendSession) {
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import { reportTAEvent } from './sdkService';
|
|||||||
import { getAllServers } from './redisService';
|
import { getAllServers } from './redisService';
|
||||||
import { sendMessageToGuildWithSuc, sendMessageToServer, sendMessageToServerWithSuc } from './pushService';
|
import { sendMessageToGuildWithSuc, sendMessageToServer, sendMessageToServerWithSuc } from './pushService';
|
||||||
import { isDebugTime } from '../pubUtils/sdkUtil';
|
import { isDebugTime } from '../pubUtils/sdkUtil';
|
||||||
|
import { pick } from 'underscore';
|
||||||
|
|
||||||
// ! 获取底价,假数据
|
// ! 获取底价,假数据
|
||||||
export function getBasePrice(gid: number, count: number) {
|
export function getBasePrice(gid: number, count: number) {
|
||||||
@@ -237,7 +238,7 @@ export async function genAuction(guildCode: string, sourceType: number, sourceCo
|
|||||||
};
|
};
|
||||||
const dividend = await DividendModel.createDividend(dividendData);
|
const dividend = await DividendModel.createDividend(dividendData);
|
||||||
await sendMessageToGuildWithSuc(guildCode, PUSH_ROUTE.AUCTION_ADD, { lots });
|
await sendMessageToGuildWithSuc(guildCode, PUSH_ROUTE.AUCTION_ADD, { lots });
|
||||||
await sendMessageToGuildWithSuc(guildCode, PUSH_ROUTE.DIVIDEND_ADD, { dividends: [dividend] });
|
await sendMessageToGuildWithSuc(guildCode, PUSH_ROUTE.DIVIDEND_ADD, { dividends: processDividendFormat([dividend]) });
|
||||||
return { lots, dividend };
|
return { lots, dividend };
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -477,7 +478,7 @@ export async function getAuction(guildCode: string, session: FrontendOrBackendSe
|
|||||||
if(guildCode) {
|
if(guildCode) {
|
||||||
dividends = await DividendModel.findGuildDividendsByBegin(guildCode, begin);
|
dividends = await DividendModel.findGuildDividendsByBegin(guildCode, begin);
|
||||||
}
|
}
|
||||||
return { lots, dividends };
|
return { lots, dividends: processDividendFormat(dividends) };
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function pushAuctionOver(lot: LotType) {
|
export async function pushAuctionOver(lot: LotType) {
|
||||||
@@ -526,7 +527,7 @@ export async function pushAuctionUpdate(lots: LotType[], dividends: DividendType
|
|||||||
dividendsResult.get(dividend.guildCode).push(dividend);
|
dividendsResult.get(dividend.guildCode).push(dividend);
|
||||||
}
|
}
|
||||||
for(let [guildCode, dividends] of dividendsResult) {
|
for(let [guildCode, dividends] of dividendsResult) {
|
||||||
await sendMessageToGuildWithSuc(guildCode, PUSH_ROUTE.DIVIDEND_UPDATE, { dividends })
|
await sendMessageToGuildWithSuc(guildCode, PUSH_ROUTE.DIVIDEND_UPDATE, { dividends: processDividendFormat(dividends) })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -544,4 +545,12 @@ export async function checkAuctionStage(auctionStage: number) {
|
|||||||
if(curTime > (await todayWorldEnd()).getTime() + 10 * 60 * 1000) return false
|
if(curTime > (await todayWorldEnd()).getTime() + 10 * 60 * 1000) return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
export function processSingleDividendFormat(dividend: DividendType) {
|
||||||
|
return pick(dividend, ['serverId', 'guildCode', 'sourceType', 'sourceCode', 'code', 'totalPrice', 'dividends'])
|
||||||
|
}
|
||||||
|
|
||||||
|
export function processDividendFormat(dividends: DividendType[]) {
|
||||||
|
return dividends.map(processSingleDividendFormat);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user