活动:首充支持礼包形式

This commit is contained in:
qiaoxin
2021-05-10 18:39:13 +08:00
parent 908b647e03
commit b268c85fa2
4 changed files with 21 additions and 6 deletions
@@ -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
}