Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
階段 27-3|權益發放 & 冪等
目標
集中管理「發獎」與「冪等處理」。
orderId/purchaseToken只處理一次規格
EntitlementManager(純前端、本地持久化)Future<void> grant({required String skuId, String? orderId})bool hasGrantedOrder(String orderId)entitlement_$skuId = trueorderId → grantedorderId為null(Mock 恢復、或非 Android 平台),以skuId為冪等鍵(僅 non-consumable 可接受){ "orders": { "GPA.XXXX": { "skuId": "card_click_2x_30m", "grantedAt": 1737xxxx } }, "entitlements": { "card_click_perm": true, "card_idle_perm": true } }store.card_click_perm:購買成功時,每次點擊或獲得迷因點數額外 +50%store.card_idle_perm:購買成功時,idlePerSec 累積額外 +20%store.card_click_2x_30m:購買成功時,點擊收益乘以 2,並開始 30 分鐘倒數(重複購買延長 30 分鐘)store.card_idle_2x_1h:購買成功時,idlePerSec 乘以 2,並開始 1 小時倒數(重複購買延長 1 小時)store.card_offline_perm_6h:購買成功時,離線獎勵永久 +6 小時(由 6h → 12h)store.card_offline_once_6h:購買成功時,離線獎勵暫時 +6 小時,並開始 24 小時倒數(重複購買延長 24 小時)store.card_cap_perm:購買成功時,每日點擊上限永久 +50%(200 → 300)store.ticket_pet_single:購買成功時,寵物抽獎券 +1store.ticket_pet_10plus1:購買成功時,寵物抽獎券 +11store.pack_daily:立即獲得迷因點數 +300、寵物抽獎券 +2,並啟動 idle 2x(30 分鐘,重複購買延長 30 分鐘)store.pack_monthly:立即獲得迷因點數 +3000、寵物抽獎券 +22,並啟動 idle 2x(24 小時,重複購買延長 24 小時)store.pack_7n_starter:立即獲得迷因點數 +1000、寵物抽獎券 +11,並啟動 idle 2x(24 小時)store.pack_30n_starter:立即獲得迷因點數 +5000、寵物抽獎券 +33,並啟動 idle 2x(120 小時)驗收實例化需求
grant(skuId='store.card_click_perm', orderId='A')entitlements.card_click_perm=true(不重複觸發副作用)grant(skuId='store.card_click_2x_30m', orderId='B')呼叫兩次orders.B僅一筆grant(skuId='store.card_idle_perm', orderId=null)grant(skuId='store.card_click_perm')10 * 1.5 = 15 點grant(skuId='store.card_idle_perm')5 * 1.2 = 6 點grant(skuId='store.card_click_2x_30m')10 * 2 = 20 點,並建立一個 30 分鐘的倒數計時grant(skuId='store.card_idle_2x_1h')5 * 2 = 10 點,並建立一個 1 小時的倒數計時grant(skuId='store.card_offline_perm_6h')12 小時grant(skuId='store.card_offline_once_6h')12 小時,並建立一個 24 小時的倒數計時grant(skuId='store.card_cap_perm')* Then:每日上限應為
200 * 1.5 = 300 點grant(skuId='store.ticket_pet_single')* Then:抽獎券數量 = 1
grant(skuId='store.ticket_pet_10plus1')* Then:抽獎券數量 = 11
grant(skuId='store.pack_daily')grant(skuId='store.pack_monthly')grant(skuId='store.pack_7n_starter')grant(skuId='store.pack_30n_starter')