活动:首充支持礼包形式
This commit is contained in:
@@ -3,7 +3,7 @@ import { resResult } from '../../../pubUtils/util';
|
||||
import { FIRST_GIFT_STATE, STATUS } from '../../../consts';
|
||||
import { firstGiftActivity, getPlayerFirstGiftData } from '../../../services/firstGiftService';
|
||||
import { RoleModel } from '../../../db/Role';
|
||||
import { useGiftPackage } from '../../../services/giftPackageService';
|
||||
import { addReward, stringToRewardParam, useGiftPackage } from '../../../services/giftPackageService';
|
||||
import { ActivityFirstGiftModel } from '../../../db/ActivityFirstGift';
|
||||
|
||||
export default function (app: Application) {
|
||||
@@ -69,8 +69,8 @@ export class firstGiftHandler {
|
||||
return resResult(STATUS.ACTIVITY_REWARDED);
|
||||
}
|
||||
|
||||
let giftID = item.gift;
|
||||
let result = await useGiftPackage(roleId, roleName, sid, serverId, funcs, giftID, []);
|
||||
let rewardArray = stringToRewardParam(item.reward)
|
||||
let result = await addReward(roleId, roleName, sid, serverId, funcs, rewardArray);
|
||||
|
||||
await ActivityFirstGiftModel.addRecord(activityId, roleId, index);
|
||||
return resResult(STATUS.SUCCESS, Object.assign(result, {}));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { STATUS, ACTIVITY_RESOURCES_TYPE } from '../../../consts';
|
||||
import { STATUS } from '../../../consts';
|
||||
import { getPlayerGrowthFundData, growthFundActivity } from '../../../services/growthFundService';
|
||||
import { GrowthFundItem } from '../../../domain/activityField/growthFundField';
|
||||
import { addItems, createHeroes } from '../../../services/rewardService';
|
||||
|
||||
@@ -5,6 +5,7 @@ import { RewardParam } from '../domain/activityField/rewardField';
|
||||
import { CreateHeroParam } from '../domain/roleField/hero';
|
||||
import { DicGiftPackage } from '../pubUtils/dictionary/DicGiftPackage';
|
||||
import { RewardInter } from '../pubUtils/interface';
|
||||
import { decodeArrayListStr } from '../pubUtils/util';
|
||||
|
||||
|
||||
|
||||
@@ -113,4 +114,18 @@ function randomSelectedData(count: number) {
|
||||
let arr = [];
|
||||
|
||||
return arr;
|
||||
}
|
||||
|
||||
//数据格式转换'类型&id&数量|类型&id&数量|' ->> Array<RewardParam>
|
||||
export function stringToRewardParam(rewardStr: string): Array<RewardParam> {
|
||||
let result = new Array<{ type: number, id: number, count: number }>();
|
||||
if (!rewardStr) return result;
|
||||
let decodeArr = decodeArrayListStr(rewardStr);
|
||||
for (let [type, id, count] of decodeArr) {
|
||||
if (isNaN(parseInt(type)) || isNaN(parseInt(id)) || isNaN(parseInt(count))) {
|
||||
throw new Error('data table format wrong');
|
||||
}
|
||||
result.push({ type: parseInt(type), id: parseInt(id), count: parseInt(count) });
|
||||
}
|
||||
return result
|
||||
}
|
||||
@@ -8,14 +8,14 @@ import { ActivityBase } from './activityField';
|
||||
export class FirstGiftItem {
|
||||
index: number; // 第几天,从1开始
|
||||
name: string; //名称
|
||||
gift: number; //礼包id
|
||||
reward: string; //奖励
|
||||
|
||||
isReceive: boolean = false; //是否领取过奖励
|
||||
|
||||
constructor(data: any) {
|
||||
this.name = data.name;
|
||||
this.index = data.index;
|
||||
this.gift = data.gift;
|
||||
this.reward = data.reward;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user