diff --git a/shared/domain/activityField/popUpShopField.ts b/shared/domain/activityField/popUpShopField.ts index 823ae5d95..a8ad9c59f 100644 --- a/shared/domain/activityField/popUpShopField.ts +++ b/shared/domain/activityField/popUpShopField.ts @@ -4,7 +4,7 @@ import { ActivityModelType } from "../../db/Activity"; import { ActivityPopUpShopModelType, PopUpShopItem as ActivityPopUpShopItem } from "../../db/ActivityPopUpShop"; import { RewardInter } from "../../pubUtils/interface"; import { parseNumberList } from "../../pubUtils/util"; -import { stringToRewardInter } from "../../services/activity/giftPackageService"; +import { stringToRewardInter } from "../../pubUtils/util"; import { ActivityBase } from './activityField'; // 数据库格式 diff --git a/shared/pubUtils/util.ts b/shared/pubUtils/util.ts index 943c80d9f..c221dd410 100644 --- a/shared/pubUtils/util.ts +++ b/shared/pubUtils/util.ts @@ -12,6 +12,7 @@ import { findIndex } from 'underscore'; import { getTimeFunM } from './timeUtil'; import { Floor } from '../domain/activityField/gachaField'; import { WhiteListModel } from '../db/RegionWhiteList'; +import { RewardInter } from './interface'; const randomName = require("chinese-random-name"); const moment = require('moment'); const crypto = require('crypto'); @@ -772,4 +773,18 @@ export function getWarTypeName(warType: number) { total -= rand; } return { arr, remain: total } - } \ No newline at end of file + } + +//数据格式转换'id&数量|id&数量|' ->> Array 老资源格式 +export function stringToRewardInter(rewardStr: string): Array { + let result = new Array<{ id: number, count: number }>(); + if (!rewardStr) return result; + let decodeArr = decodeArrayListStr(rewardStr); + for (let [id, count] of decodeArr) { + if (isNaN(parseInt(id)) || isNaN(parseInt(count))) { + throw new Error('data table format wrong'); + } + result.push({ id: parseInt(id), count: parseInt(count) }); + } + return result +}