From 5f9beb06648528443eeb993e27e87b9d5188f92c Mon Sep 17 00:00:00 2001 From: luying Date: Sat, 7 May 2022 11:28:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B4=BB=E5=8A=A8=EF=BC=9A=E5=BC=B9=E5=87=BA?= =?UTF-8?q?=E5=95=86=E5=BA=97=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shared/domain/activityField/popUpShopField.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/shared/domain/activityField/popUpShopField.ts b/shared/domain/activityField/popUpShopField.ts index f346fde44..565f88784 100644 --- a/shared/domain/activityField/popUpShopField.ts +++ b/shared/domain/activityField/popUpShopField.ts @@ -485,16 +485,29 @@ class PopUpShopShow { this[key] = baseData[key]; } + let itemsByCode = new Map(); for(let pkg of data.packages) { for(let item of pkg.items) { let { id, isPushing, hasBoughtCnt, buyCnt, hasPushCnt, pushCnt } = item; console.log('**** PopUpShopShow', { id, isPushing, hasBoughtCnt, buyCnt, hasPushCnt, pushCnt }) - if(item.isPushing && item.hasBoughtCnt < item.buyCnt) { + if(item.isPushing && item.code) { + if(!itemsByCode.has(item.code)) { + itemsByCode.set(item.code, []); + } + itemsByCode.get(item.code).push(item); + } + } + } + for(let [_, items] of itemsByCode) { + let hasItemsNotAllBought = items.filter(item => item.hasBoughtCnt < item.buyCnt).length > 0; + if(hasItemsNotAllBought) { + for(let item of items) { let obj = new PopUpShopItemShow(item); this.items.push({...obj}); } } } + } }