拍卖行:价格修改

This commit is contained in:
luying
2021-09-24 11:38:41 +08:00
parent f3c73ade66
commit 1384074736
8 changed files with 98 additions and 56 deletions

View File

@@ -1,4 +1,4 @@
import { readFileAndParse } from '../util'
import { parseNumberList, readFileAndParse } from '../util'
import { FILENAME } from '../../consts'
import { decodeArrayListStr } from '../../pubUtils/util';
@@ -11,6 +11,8 @@ export interface AuctionBasicPool {
export interface DicAuctionBasicPool {
readonly id: number; // 唯一id
readonly rewardBasicPool: AuctionBasicPool[];
readonly basePrice: number;
readonly maxPrice: number;
}
export interface DicAuctionReward {
@@ -23,17 +25,20 @@ export interface DicAuctionReward {
interface DicAuctionPool {
readonly id: number; // basicPool的id
readonly count: number; // 份数
readonly basicPool: AuctionBasicPool[]; // 随机池
readonly basicPool: DicAuctionBasicPool; // 随机池
}
export const dicAuctionPool = new Map<number, DicAuctionPool[]>(); // poolId => DicAuctionPool
export function loadAuctionReward() {
dicAuctionPool.clear();
let basicPoolMap = new Map<number, AuctionBasicPool[]>(); // id => AuctionBasicPool
let basicPoolMap = new Map<number, DicAuctionBasicPool>(); // id => AuctionBasicPool
let arr = readFileAndParse(FILENAME.DIC_AUCTION_BASIC_POOL);
arr.forEach(o => {
let rewardBasicPool = parseRewardBasicPool(o.rewardBasicPool);
basicPoolMap.set(o.id, rewardBasicPool);
console.log(o)
o.rewardBasicPool = parseRewardBasicPool(o.rewardBasicPool);
o.basePrice = parsePrice(o.basePrice);
o.maxPrice = parsePrice(o.maxPrice);
basicPoolMap.set(o.id, o);
});
arr = undefined;
let arr2 = readFileAndParse(FILENAME.DIC_AUCTION_REWARD);
@@ -60,6 +65,14 @@ function parseRewardBasicPool(str: string) {
return result
}
function parsePrice(str: string) {
let arr = str.split('&');
if(arr.length != 2) return 0;
let price = parseInt(arr[1]);
if(isNaN(price)) throw new Error('price format wrong');
return price;
}
function parseRewardId(str: string) {
let result = new Array<{id: number, count: number}>();
if (!str) return result;