购买套餐添加count_min字段
This commit is contained in:
@@ -7,11 +7,13 @@ export type PurchaseSkuItem = {
|
||||
live: string
|
||||
expire: string
|
||||
price: string
|
||||
count_min: number
|
||||
}
|
||||
|
||||
export type PurchaseSkuData = {
|
||||
items: PurchaseSkuItem[]
|
||||
priceMap: Map<string, string>
|
||||
countMinMap: Map<string, number>
|
||||
modeList: PurchaseMode[]
|
||||
liveList: string[]
|
||||
expireList: string[]
|
||||
@@ -24,6 +26,7 @@ export function parsePurchaseSkuList(kind: PurchaseKind, skuList: ProductItem['s
|
||||
|
||||
const items: PurchaseSkuItem[] = []
|
||||
const priceMap = new Map<string, string>()
|
||||
const countMinMap = new Map<string, number>()
|
||||
const modeSet = new Set<PurchaseMode>()
|
||||
const liveSet = new Set<number>()
|
||||
const expireSet = new Set<number>()
|
||||
@@ -45,6 +48,8 @@ export function parsePurchaseSkuList(kind: PurchaseKind, skuList: ProductItem['s
|
||||
live: liveValue,
|
||||
expire: expireValue,
|
||||
})
|
||||
const countMin = typeof sku.count_min === 'number' ? sku.count_min : Number(sku.count_min) || 0
|
||||
countMinMap.set(code, countMin)
|
||||
|
||||
items.push({
|
||||
code,
|
||||
@@ -52,6 +57,7 @@ export function parsePurchaseSkuList(kind: PurchaseKind, skuList: ProductItem['s
|
||||
live: liveValue,
|
||||
expire: expireValue,
|
||||
price: sku.price,
|
||||
count_min: countMin,
|
||||
})
|
||||
priceMap.set(code, sku.price)
|
||||
modeSet.add(mode)
|
||||
@@ -75,6 +81,7 @@ export function parsePurchaseSkuList(kind: PurchaseKind, skuList: ProductItem['s
|
||||
return {
|
||||
items,
|
||||
priceMap,
|
||||
countMinMap,
|
||||
modeList: (['2', '1'] as const).filter(mode => modeSet.has(mode)),
|
||||
liveList: sortNumericValues(liveSet),
|
||||
expireList: sortNumericValues(expireSet),
|
||||
@@ -163,3 +170,11 @@ export function formatPurchaseLiveLabel(live: string, kind: PurchaseKind) {
|
||||
|
||||
return `${minutes} 分钟`
|
||||
}
|
||||
|
||||
export function getPurchaseSkuCountMin(
|
||||
skuData: PurchaseSkuData,
|
||||
props: {mode: PurchaseMode, live: string, expire: string},
|
||||
): number {
|
||||
const key = getPurchaseSkuKey(props)
|
||||
return skuData.countMinMap.get(key) ?? 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user