活动:活动开关添加成长基金的数据
This commit is contained in:
@@ -5,6 +5,8 @@ import { getPlayerGrowthFundData, growthFundActivity } from '../../../services/g
|
||||
import { GrowthFundItem } from '../../../domain/activityField/growthFundField';
|
||||
import { addItems, createHeroes } from '../../../services/rewardService';
|
||||
import { ActivityGrowthFundModel } from '../../../db/ActivityGrowthFund';
|
||||
import { addReward, stringToRewardParam } from '../../../services/giftPackageService';
|
||||
import { RewardParam } from '../../../domain/activityField/rewardField';
|
||||
|
||||
|
||||
export default function (app: Application) {
|
||||
@@ -19,16 +21,16 @@ export class GrowthFundHandler {
|
||||
|
||||
/**
|
||||
* @description 获取成长基金活动数据
|
||||
* @param {{ type: number}} msg
|
||||
* @param {{ activityId: number}} msg
|
||||
* @param {BackendSession} session
|
||||
* @memberof GrowthFundHandler
|
||||
*/
|
||||
async getGrowthFundActivity(msg: { type: number }, session: BackendSession) {
|
||||
const { type } = msg;
|
||||
async getGrowthFundActivity(msg: { activityId: number }, session: BackendSession) {
|
||||
const { activityId } = msg;
|
||||
const roleId = session.get('roleId');
|
||||
const serverId = session.get('serverId');
|
||||
|
||||
let playerData = await growthFundActivity(type, serverId, roleId);
|
||||
let playerData = await getPlayerGrowthFundData(activityId, serverId, roleId);
|
||||
|
||||
if (!playerData) return resResult(STATUS.ACTIVITY_GROWTH_FUND_END);
|
||||
|
||||
@@ -67,18 +69,17 @@ export class GrowthFundHandler {
|
||||
return resResult(STATUS.ACTIVITY_REWARDED);
|
||||
}
|
||||
|
||||
await ActivityGrowthFundModel.addRecord(activityId, roleId, pageIndex, cellIndex);
|
||||
let reward = growthFundItemData.goodReward();
|
||||
let goods = await addItems(roleId, roleName, sid, reward);
|
||||
let heroReward = growthFundItemData.heroReward();
|
||||
let addHeros = [];
|
||||
if (heroReward.length > 0) {
|
||||
let heroResult = await createHeroes(roleId, roleName, sid, serverId, funcs, heroReward);
|
||||
goods = goods.concat(heroResult.goods)
|
||||
addHeros = addHeros.concat(heroResult.heroes);
|
||||
}
|
||||
growthFundItemData.isReceive = true;
|
||||
|
||||
return resResult(STATUS.SUCCESS, { goods, addHeros });
|
||||
await ActivityGrowthFundModel.addRecord(activityId, roleId, pageIndex, cellIndex);
|
||||
|
||||
let rewardParamArr: Array<RewardParam> = stringToRewardParam(growthFundItemData.reward);
|
||||
let result = await addReward(roleId, roleName, sid, serverId, funcs, rewardParamArr)
|
||||
|
||||
return resResult(STATUS.SUCCESS, Object.assign(result, {
|
||||
param: { activityId, pageIndex, cellIndex },
|
||||
item: growthFundItemData
|
||||
}));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user