@jetthai/cuora 1.1.488-dev.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.husky/pre-commit +3 -1
- package/.prettierignore +1 -2
- package/CHANGELOG.md +0 -746
- package/README.md +15 -299
- package/package.json +3 -6
- package/resetGitBranch.sh +101 -0
- package/src/api/activity.js +39 -24
- package/src/api/auth.js +35 -4
- package/src/api/common.js +1 -8
- package/src/api/game.js +10 -0
- package/src/api/index.js +1 -3
- package/src/api/payment.js +55 -18
- package/src/api/user.js +16 -11
- package/src/index.js +2 -2
- package/src/lib/fingerprint_v3_11_12.js +11433 -0
- package/src/machine/activity/activity.js +209 -0
- package/src/machine/activity/activity_cash.js +18 -71
- package/src/machine/activity/diamond_shop_activity_cash.js +1 -0
- package/src/machine/activity/diamond_shop_activity_fc.js +196 -0
- package/src/machine/activity/diamond_shop_activity_vn.js +178 -0
- package/src/machine/activity/fafafa_activity.js +10 -0
- package/src/machine/activity/index.js +12 -0
- package/src/machine/activity/invite_friends_activity.js +114 -0
- package/src/machine/activity/mini_game_activity.js +68 -0
- package/src/machine/activity/return_bonus_activity.js +153 -0
- package/src/machine/activity/roulette_activity_v2.js +0 -5
- package/src/machine/auth.js +140 -192
- package/src/machine/auth_otp_v2.js +177 -0
- package/src/machine/auth_otp_v3.js +32 -111
- package/src/machine/bank_binding.js +2 -2
- package/src/machine/bank_binding_amb.js +145 -0
- package/src/machine/bonus.js +75 -0
- package/src/machine/common.js +91 -27
- package/src/machine/deposit/amb.js +92 -0
- package/src/machine/deposit/crypto_bank.js +325 -0
- package/src/machine/deposit/crypto_bank_cash.js +8 -19
- package/src/machine/deposit/crypto_qrcode.js +148 -0
- package/src/machine/deposit/crypto_qrcode_cash.js +41 -26
- package/src/machine/deposit/crypto_way.js +247 -0
- package/src/machine/deposit/crypto_way_cash.js +32 -52
- package/src/machine/deposit/deposit_fc.js +271 -0
- package/src/machine/deposit/direct.js +310 -0
- package/src/machine/deposit/direct_cash.js +9 -8
- package/src/machine/deposit/float.js +374 -0
- package/src/machine/deposit/index.js +28 -0
- package/src/machine/deposit/krway.js +151 -0
- package/src/machine/deposit/loadcard_cash.js +31 -14
- package/src/machine/deposit/loadcard_vn.js +351 -0
- package/src/machine/deposit/manual_cash.js +10 -8
- package/src/machine/deposit/manual_vn.js +458 -0
- package/src/machine/deposit/qrcode_cash.js +30 -14
- package/src/machine/deposit/qrcode_v2.js +338 -0
- package/src/machine/deposit/usdt.js +144 -0
- package/src/machine/deposit/virtual_bank_cash.js +2 -5
- package/src/machine/deposit/virtual_bank_vn.js +269 -0
- package/src/machine/deposit/vpay.js +367 -0
- package/src/machine/error.js +0 -7
- package/src/machine/game_hot_new.js +79 -0
- package/src/machine/game_info.js +12 -5
- package/src/machine/game_replay.js +46 -0
- package/src/machine/game_search_v2.js +401 -0
- package/src/machine/game_v2_1.js +88 -58
- package/src/machine/honor_board.js +132 -0
- package/src/machine/honor_board_cash.js +18 -15
- package/src/machine/inbox.js +12 -0
- package/src/machine/index.js +32 -0
- package/src/machine/leaderboard.js +11 -8
- package/src/machine/merge.js +57 -0
- package/src/machine/payment_data.js +86 -0
- package/src/machine/promotions.js +170 -0
- package/src/machine/ranking.js +25 -43
- package/src/machine/reward.js +255 -0
- package/src/machine/reward_cash.js +41 -2
- package/src/machine/reward_fc.js +98 -0
- package/src/machine/roulette_v2.js +25 -20
- package/src/machine/side.js +154 -0
- package/src/machine/side_cash.js +2 -3
- package/src/machine/side_v2.js +209 -0
- package/src/machine/user_reset_password.js +15 -4
- package/src/machine/user_sign_up.js +60 -49
- package/src/machine/vip_table.js +57 -0
- package/src/machine/websocket.js +325 -378
- package/src/machine/welcome.js +110 -0
- package/src/machine/withdraw/index.js +6 -0
- package/src/machine/withdraw/withdraw_crypto_cash.js +327 -0
- package/src/machine/withdraw/withdraw_krway.js +222 -0
- package/src/machine/withdraw/withdraw_manual.js +533 -0
- package/src/machine/withdraw/withdraw_manual_cash.js +43 -74
- package/src/request/config.js +0 -2
- package/src/request/request.js +64 -231
- package/src/util/constant.js +2 -12
- package/src/util/deviceToken.js +59 -0
- package/src/util/index.js +4 -2
- package/src/util/math.js +4 -0
- package/.claude/commands/sync-ai-prompts.md +0 -180
- package/.claude/settings.local.json +0 -25
- package/.github/copilot-instructions.md +0 -459
- package/.husky/post-checkout +0 -32
- package/.husky/pre-push +0 -36
- package/AGENTS.md +0 -459
- package/AI_PROMPT_SOURCE.md +0 -457
- package/CLAUDE.md +0 -459
- package/GEMINI.md +0 -459
- package/docs/kibana/crypto-way-deposit-amount-bug-analysis.md +0 -1003
- package/docs/kibana/play-providerId-error.md +0 -202
- package/docs/kibana/play-selectedWalletType.md +0 -1
- package/docs/kibana/play-selectedWalletType_2.md +0 -1
- package/docs/kibana/play-selectedWalletType_analysis.md +0 -565
- package/docs/my-claude/feat-sharon-JT-1790247240-socket/branch-transfer.md +0 -14
- package/docs/my-claude/feat-sharon-JT-1790247240-socket/cash-module-preparation.json +0 -40
- package/docs/my-claude/feat-sharon-JT-1790247240-socket/cash-module-verification.md +0 -41
- package/docs/my-claude/feat-sharon-JT-1790247240-socket/implementation-ledger.md +0 -87
- package/docs/my-claude/feat-sharon-JT-1790247240-socket/module-report.md +0 -73
- package/docs/my-claude/feat-sharon-JT-1790247240-socket/plan.md +0 -309
- package/docs/my-claude/feat-sharon-JT-1790247240-socket/test-cases.md +0 -245
- package/docs/my-claude/feat-sharon-JT-1791180540-onesignal/transfer.md +0 -9
- package/e2e/feature-map.md +0 -19
- package/prepare-for-pr/JT-1776243420.md +0 -85
- package/prepare-for-pr/TI-16026/STATE.md +0 -18
- package/prepare-for-pr/TI-16026/after-prepare-authorization.md +0 -3
- package/prepare-for-pr/TI-16026/analysis.md +0 -38
- package/prepare-for-pr/TI-16026/answer-analyze-01.md +0 -1
- package/prepare-for-pr/TI-16026/answer-commit-01.md +0 -2
- package/prepare-for-pr/TI-16026/answer-commit-02.md +0 -1
- package/prepare-for-pr/TI-16026/bundle.json +0 -18
- package/prepare-for-pr/TI-16026/checklist.md +0 -196
- package/prepare-for-pr/TI-16026/checklist.unit-test-original.md +0 -39
- package/prepare-for-pr/TI-16026/claude-after-model +0 -1
- package/prepare-for-pr/TI-16026/claude-commit-session +0 -1
- package/prepare-for-pr/TI-16026/claude-harvest-session +0 -1
- package/prepare-for-pr/TI-16026/claude-hops/01-analyze.err +0 -1
- package/prepare-for-pr/TI-16026/claude-hops/01-analyze.out +0 -2
- package/prepare-for-pr/TI-16026/claude-hops/02-analyze.err +0 -1
- package/prepare-for-pr/TI-16026/claude-hops/02-analyze.out +0 -4
- package/prepare-for-pr/TI-16026/claude-hops/03-dev.err +0 -1
- package/prepare-for-pr/TI-16026/claude-hops/03-dev.out +0 -4
- package/prepare-for-pr/TI-16026/claude-hops/04-dev.err +0 -1
- package/prepare-for-pr/TI-16026/claude-hops/04-dev.out +0 -4
- package/prepare-for-pr/TI-16026/claude-hops/05-dev.err +0 -1
- package/prepare-for-pr/TI-16026/claude-hops/05-dev.out +0 -3
- package/prepare-for-pr/TI-16026/claude-hops/06-after.err +0 -1
- package/prepare-for-pr/TI-16026/claude-hops/06-after.out +0 -2
- package/prepare-for-pr/TI-16026/claude-hops/07-commit.err +0 -1
- package/prepare-for-pr/TI-16026/claude-hops/07-commit.out +0 -2
- package/prepare-for-pr/TI-16026/claude-hops/08-commit.err +0 -1
- package/prepare-for-pr/TI-16026/claude-hops/08-commit.out +0 -2
- package/prepare-for-pr/TI-16026/claude-hops/09-commit.err +0 -1
- package/prepare-for-pr/TI-16026/claude-hops/09-commit.out +0 -8
- package/prepare-for-pr/TI-16026/claude-hops/10-harvest.err +0 -1
- package/prepare-for-pr/TI-16026/claude-hops/10-harvest.out +0 -3
- package/prepare-for-pr/TI-16026/claude-hops/11-harvest.err +0 -1
- package/prepare-for-pr/TI-16026/claude-hops/11-harvest.out +0 -3
- package/prepare-for-pr/TI-16026/commit-note.md +0 -5
- package/prepare-for-pr/TI-16026/evidence-index.json +0 -215
- package/prepare-for-pr/TI-16026/feature-map.before.md +0 -61
- package/prepare-for-pr/TI-16026/harvest-redaction.json +0 -34
- package/prepare-for-pr/TI-16026/harvest-redaction.out +0 -37
- package/prepare-for-pr/TI-16026/harvest.md +0 -46
- package/prepare-for-pr/TI-16026/lessons.md +0 -5
- package/prepare-for-pr/TI-16026/note-harvest-redaction.md +0 -1
- package/prepare-for-pr/TI-16026/open-questions.md +0 -6
- package/prepare-for-pr/TI-16026/publish.md +0 -32
- package/prepare-for-pr/TI-16026/review-convergence-response.md +0 -3
- package/prepare-for-pr/TI-16026/review-input/scope.md +0 -18
- package/prepare-for-pr/TI-16026/review-log.md +0 -57
- package/prepare-for-pr/TI-16026/review-notes.md +0 -97
- package/prepare-for-pr/TI-16026/review-response-r1.md +0 -7
- package/prepare-for-pr/TI-16026/self-test-report.md +0 -67
- package/prepare-for-pr/TI-16026/spec-proposal.md +0 -34
- package/prepare-for-pr/TI-16026/spec-snapshot.md +0 -291
- package/prepare-for-pr/TI-16026/state-log.md +0 -57
- package/prepare-for-pr/TI-16026/user-messages/01.md +0 -12
- package/prepare-for-pr/TI-16026/user-messages/02.md +0 -20
- package/prepare-for-pr/TI-16026/user-messages/03.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/04.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/05.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/06.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/07.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/08.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/09.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/10.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/11.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/12.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/13.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/14.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/15.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/16.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/17.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/18.md +0 -10
- package/prepare-for-pr/TI-16026/user-messages/19.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/20.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/21.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/22.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/23.md +0 -8
- package/prepare-for-pr/TI-16026/user-messages/24.md +0 -24
- package/prepare-for-pr/TI-16026/user-question.md +0 -24
- package/prepare-for-pr/TI-16026/verify/metrics-check.json +0 -13
- package/prepare-for-pr/TI-16026/verify/redaction.json +0 -38
- package/prepare-for-pr/TI-16026/verify/row-closure.json +0 -45
- package/prepare-for-pr/TI-16026/verify/s04-ws-capture.md +0 -23
- package/prepare-for-pr/TI-16026/verify-after.md +0 -23
- package/prepare-for-pr/TI-16026/verify.json +0 -80
- package/prepare-for-pr/TI-16026.md +0 -408
- package/scripts/auto-version.js +0 -69
- package/scripts/auto-version.sh +0 -33
- package/scripts/branch-auto-npm-publish.js +0 -36
- package/scripts/check-version.sh +0 -36
- package/scripts/clean-tags.sh +0 -84
- package/src/api/account.js +0 -7
- package/src/api/otp.js +0 -5
- package/src/util/amount.js +0 -8
- package/src/util/err998SentryExtra.js +0 -26
- package/src/util/paramStore.js +0 -139
- package/src/util/socketPolicy.js +0 -57
- package/src/util/tokenStore.js +0 -44
- package/test/auth_otp_v3.test.js +0 -323
- package/test/auth_self_timeout.test.js +0 -171
- package/test/request_self.test.js +0 -288
- package/test/withdraw_manual_cash.test.js +0 -149
- package/tests/session.test.mjs +0 -177
- package/tests/websocket.test.mjs +0 -779
|
@@ -63,6 +63,10 @@ export default function (request, context) {
|
|
|
63
63
|
states: {
|
|
64
64
|
idle: {
|
|
65
65
|
on: {
|
|
66
|
+
FETCH_WITHDRAW_RULE: {
|
|
67
|
+
target: 'fetching',
|
|
68
|
+
actions: 'setRewardData',
|
|
69
|
+
},
|
|
66
70
|
FETCH_OTHER_REWARD: {
|
|
67
71
|
target: 'fetchingOtherReward',
|
|
68
72
|
actions: 'setOrderColumn',
|
|
@@ -80,6 +84,18 @@ export default function (request, context) {
|
|
|
80
84
|
},
|
|
81
85
|
},
|
|
82
86
|
},
|
|
87
|
+
fetching: {
|
|
88
|
+
invoke: {
|
|
89
|
+
src: 'fetchWithdrawRulePreview',
|
|
90
|
+
onDone: {
|
|
91
|
+
target: 'pending',
|
|
92
|
+
actions: 'setWithdrawRulePreview',
|
|
93
|
+
},
|
|
94
|
+
onError: {
|
|
95
|
+
target: 'idle',
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
},
|
|
83
99
|
fetchingOtherReward: {
|
|
84
100
|
invoke: {
|
|
85
101
|
src: 'fetchOtherRewardList',
|
|
@@ -164,6 +180,13 @@ export default function (request, context) {
|
|
|
164
180
|
otherRewardList: event.data[0]?.data,
|
|
165
181
|
}
|
|
166
182
|
}),
|
|
183
|
+
setRewardData: assign((context, event) => {
|
|
184
|
+
const { activityNo, receiveNo } = event.data
|
|
185
|
+
return {
|
|
186
|
+
activityNo,
|
|
187
|
+
receiveNo,
|
|
188
|
+
}
|
|
189
|
+
}),
|
|
167
190
|
setCallback: assign((context, event) => {
|
|
168
191
|
return {
|
|
169
192
|
callback: event.data?.callback || (() => {}),
|
|
@@ -177,6 +200,11 @@ export default function (request, context) {
|
|
|
177
200
|
doCallback: (context, event) => {
|
|
178
201
|
context.callback()
|
|
179
202
|
},
|
|
203
|
+
setWithdrawRulePreview: assign((context, event) => {
|
|
204
|
+
return {
|
|
205
|
+
withdrawRule: event.data,
|
|
206
|
+
}
|
|
207
|
+
}),
|
|
180
208
|
setLang: assign((context, event) => {
|
|
181
209
|
const lang = event.data.locale || context.lang || 'en-US'
|
|
182
210
|
return { lang }
|
|
@@ -197,7 +225,7 @@ export default function (request, context) {
|
|
|
197
225
|
)
|
|
198
226
|
const getOtherRewardAPI = request.send(
|
|
199
227
|
activity.getRewardList({
|
|
200
|
-
rewardType: 'CASH,FREE,PRIZE
|
|
228
|
+
rewardType: 'CASH,FREE,PRIZE',
|
|
201
229
|
count: 30,
|
|
202
230
|
appSecret,
|
|
203
231
|
orderColumn,
|
|
@@ -212,7 +240,7 @@ export default function (request, context) {
|
|
|
212
240
|
const lang = context.lang
|
|
213
241
|
const getOtherRewardAPI = request.send(
|
|
214
242
|
activity.getRewardList({
|
|
215
|
-
rewardType: 'CASH,FREE,PRIZE
|
|
243
|
+
rewardType: 'CASH,FREE,PRIZE',
|
|
216
244
|
count: 30,
|
|
217
245
|
appSecret,
|
|
218
246
|
orderColumn,
|
|
@@ -222,6 +250,17 @@ export default function (request, context) {
|
|
|
222
250
|
const [otherRewardList] = await Promise.all([getOtherRewardAPI])
|
|
223
251
|
return [otherRewardList]
|
|
224
252
|
},
|
|
253
|
+
fetchWithdrawRulePreview: async (context, event) => {
|
|
254
|
+
const { receiveNo } = context
|
|
255
|
+
const data = await request.send(
|
|
256
|
+
payment.getWithdrawRulePreview({
|
|
257
|
+
applyType: 'activity',
|
|
258
|
+
applyNo: receiveNo,
|
|
259
|
+
amount: null,
|
|
260
|
+
})
|
|
261
|
+
)
|
|
262
|
+
return data
|
|
263
|
+
},
|
|
225
264
|
receiveReward: async (context, event) => {
|
|
226
265
|
const { activityNo, receiveNo, attended } = event.data
|
|
227
266
|
// Number("")-> 0 / Number(" ") -> 0 需要收到實際的數字才傳給後端
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { createMachine, assign, send } from 'xstate'
|
|
2
|
+
import activity from '../api/activity.js'
|
|
3
|
+
|
|
4
|
+
export default function (request) {
|
|
5
|
+
const { appSecret } = request.config
|
|
6
|
+
return createMachine(
|
|
7
|
+
{
|
|
8
|
+
id: 'reward',
|
|
9
|
+
type: 'parallel',
|
|
10
|
+
context: {
|
|
11
|
+
rewardList: [],
|
|
12
|
+
callback: () => {},
|
|
13
|
+
},
|
|
14
|
+
states: {
|
|
15
|
+
timer: {
|
|
16
|
+
initial: 'loading',
|
|
17
|
+
states: {
|
|
18
|
+
loading: {
|
|
19
|
+
invoke: {
|
|
20
|
+
src: 'fetchRewardList',
|
|
21
|
+
onDone: {
|
|
22
|
+
target: 'pending',
|
|
23
|
+
actions: 'setRewardList',
|
|
24
|
+
},
|
|
25
|
+
onError: {
|
|
26
|
+
target: 'pending',
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
pending: {
|
|
31
|
+
after: {
|
|
32
|
+
20000: { target: 'loading' },
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
on: {
|
|
37
|
+
REFRESH: {
|
|
38
|
+
target: '.loading',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
reward: {
|
|
43
|
+
initial: 'idle',
|
|
44
|
+
states: {
|
|
45
|
+
idle: {
|
|
46
|
+
on: {
|
|
47
|
+
RECEIVE_REWARD: {
|
|
48
|
+
target: 'receiving',
|
|
49
|
+
actions: 'setCallback',
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
receiving: {
|
|
54
|
+
invoke: {
|
|
55
|
+
src: 'receiveReward',
|
|
56
|
+
onDone: {
|
|
57
|
+
target: 'idle',
|
|
58
|
+
actions: [send({ type: 'REFRESH' }), 'doCallback'],
|
|
59
|
+
},
|
|
60
|
+
onError: {
|
|
61
|
+
target: 'idle',
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
actions: {
|
|
71
|
+
setRewardList: assign((context, event) => {
|
|
72
|
+
return {
|
|
73
|
+
rewardList: event.data || [],
|
|
74
|
+
}
|
|
75
|
+
}),
|
|
76
|
+
setCallback: assign((context, event) => {
|
|
77
|
+
return {
|
|
78
|
+
callback: event.data?.callback || (() => {}),
|
|
79
|
+
}
|
|
80
|
+
}),
|
|
81
|
+
doCallback: (context, event) => {
|
|
82
|
+
context.callback()
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
services: {
|
|
86
|
+
fetchRewardList: async (context, event) => {
|
|
87
|
+
const { data } = await request.send(activity.getRewardList({ count: 30, appSecret }))
|
|
88
|
+
return data
|
|
89
|
+
},
|
|
90
|
+
receiveReward: async (context, event) => {
|
|
91
|
+
const { activityNo, receiveNo, attended } = event.data
|
|
92
|
+
const validateReceiveNo = Number(receiveNo) > 0 ? Number(receiveNo) : undefined
|
|
93
|
+
return await request.send(activity.getReward({ activityNo, receiveNo: validateReceiveNo, appSecret, attended }))
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
}
|
|
97
|
+
)
|
|
98
|
+
}
|
|
@@ -24,7 +24,6 @@ export default function (request) {
|
|
|
24
24
|
spinResult: {},
|
|
25
25
|
rouletteV2ExchangeAward: [],
|
|
26
26
|
calculatedNewSpinRewards: [],
|
|
27
|
-
isSpinOutOfStock: false,
|
|
28
27
|
awardedCashAmount: 0,
|
|
29
28
|
awardedFreeAmount: 0,
|
|
30
29
|
awardedPointsAmount: 0,
|
|
@@ -210,26 +209,36 @@ export default function (request) {
|
|
|
210
209
|
}),
|
|
211
210
|
setSpinResult: assign((context, event) => {
|
|
212
211
|
const { unCollectRewards = [], newSpinRewards = [], spinLeft = 0 } = JSON.parse(JSON.stringify(event.data || {}))
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
212
|
+
const calculatedNewSpinRewards = newSpinRewards
|
|
213
|
+
.map((item) => {
|
|
214
|
+
item.count = 1
|
|
215
|
+
return item
|
|
216
|
+
})
|
|
217
|
+
.reduce((arr, spin) => {
|
|
218
|
+
let newIndex = 0
|
|
219
|
+
let alreadyHave = false
|
|
220
|
+
if (arr.length > 0) {
|
|
221
|
+
alreadyHave = arr.find((item, index) => {
|
|
222
|
+
if (item.rewardType === spin.rewardType && item.reward === spin.reward) {
|
|
223
|
+
newIndex = index
|
|
224
|
+
return true
|
|
225
|
+
} else {
|
|
226
|
+
return false
|
|
227
|
+
}
|
|
228
|
+
})
|
|
229
|
+
}
|
|
230
|
+
if (alreadyHave) {
|
|
231
|
+
arr[newIndex].count++
|
|
232
|
+
} else {
|
|
233
|
+
arr.push(spin)
|
|
234
|
+
}
|
|
235
|
+
return arr
|
|
236
|
+
}, [])
|
|
226
237
|
|
|
227
238
|
return {
|
|
228
239
|
spinResult: event.data,
|
|
229
240
|
unCollectRewards,
|
|
230
241
|
calculatedNewSpinRewards,
|
|
231
|
-
// 本次抽獎含缺貨項目(單次 Spin 缺貨或 Spin All 部分/全部缺貨),前台以此決定是否改顯示通用缺貨提示
|
|
232
|
-
isSpinOutOfStock: newSpinRewards.some(isOutOfStock),
|
|
233
242
|
spinLeft,
|
|
234
243
|
}
|
|
235
244
|
}),
|
|
@@ -249,10 +258,6 @@ export default function (request) {
|
|
|
249
258
|
services: {
|
|
250
259
|
fetchActivityDetail: async (context, event) => {
|
|
251
260
|
const { activityNo, activityDetail = {} } = context
|
|
252
|
-
// 當活動資料已存在時避免重複呼叫 api
|
|
253
|
-
if (Object.keys(activityDetail).length > 0) {
|
|
254
|
-
return activityDetail
|
|
255
|
-
}
|
|
256
261
|
const { data } = await request.send(api.getActivityDetail({ activityNo, appSecret }))
|
|
257
262
|
return data.activityNo ? data : activityDetail
|
|
258
263
|
},
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { assign, createMachine } from 'xstate'
|
|
2
|
+
import api from '../api/game.js'
|
|
3
|
+
|
|
4
|
+
export default function (request) {
|
|
5
|
+
return createMachine(
|
|
6
|
+
{
|
|
7
|
+
id: 'side',
|
|
8
|
+
initial: 'preparing',
|
|
9
|
+
context: {
|
|
10
|
+
menu: {},
|
|
11
|
+
room: null,
|
|
12
|
+
roomHistory: [],
|
|
13
|
+
},
|
|
14
|
+
states: {
|
|
15
|
+
preparing: {
|
|
16
|
+
invoke: {
|
|
17
|
+
src: 'getRoomItems',
|
|
18
|
+
onDone: {
|
|
19
|
+
target: 'room',
|
|
20
|
+
actions: 'makeMenu',
|
|
21
|
+
},
|
|
22
|
+
onError: {
|
|
23
|
+
target: 'room',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
room: {
|
|
28
|
+
initial: 'home',
|
|
29
|
+
states: {
|
|
30
|
+
home: {
|
|
31
|
+
entry: createSideAction('home'),
|
|
32
|
+
},
|
|
33
|
+
favorite: {
|
|
34
|
+
entry: createSideAction('favorite'),
|
|
35
|
+
},
|
|
36
|
+
hot: {
|
|
37
|
+
entry: createSideAction('hot'),
|
|
38
|
+
},
|
|
39
|
+
new: {
|
|
40
|
+
entry: createSideAction('new'),
|
|
41
|
+
},
|
|
42
|
+
slot: {
|
|
43
|
+
entry: createSideAction('slot'),
|
|
44
|
+
},
|
|
45
|
+
fish: {
|
|
46
|
+
entry: createSideAction('fish'),
|
|
47
|
+
},
|
|
48
|
+
arcade: {
|
|
49
|
+
entry: createSideAction('arcade'),
|
|
50
|
+
},
|
|
51
|
+
table: {
|
|
52
|
+
entry: createSideAction('table'),
|
|
53
|
+
},
|
|
54
|
+
search: {},
|
|
55
|
+
history: {
|
|
56
|
+
type: 'history',
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
feature: {
|
|
61
|
+
on: {
|
|
62
|
+
RETURN: { target: 'room.history' },
|
|
63
|
+
CLICK_HOT: { target: 'room.hot', actions: 'resetRoomHistory' },
|
|
64
|
+
CLICK_NEW: { target: 'room.new', actions: 'resetRoomHistory' },
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
category: {
|
|
68
|
+
on: {
|
|
69
|
+
RETURN: { target: 'room.history' },
|
|
70
|
+
CLICK_SLOT: { target: 'room.slot', actions: 'resetRoomHistory' },
|
|
71
|
+
CLICK_FISH: { target: 'room.fish', actions: 'resetRoomHistory' },
|
|
72
|
+
CLICK_ARCADE: { target: 'room.arcade', actions: 'resetRoomHistory' },
|
|
73
|
+
CLICK_TABLE: { target: 'room.table', actions: 'resetRoomHistory' },
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
on: {
|
|
78
|
+
CLICK_HOME: { target: 'room.home', actions: 'resetRoomHistory' },
|
|
79
|
+
CLICK_FAVORITE: { target: 'room.favorite', actions: 'resetRoomHistory' },
|
|
80
|
+
CLICK_FEATURE: { target: 'feature' },
|
|
81
|
+
CLICK_CATEGORY: { target: 'category' },
|
|
82
|
+
CLICK_SEARCH: { target: 'room.search' },
|
|
83
|
+
FORWARD_ROOM: { actions: 'forwardRoom' },
|
|
84
|
+
BACKWARD_ROOM: { actions: 'backwardRoom' },
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
actions: {
|
|
89
|
+
makeMenu: assign((context, event) => {
|
|
90
|
+
const { list = [] } = event.data
|
|
91
|
+
const map = {
|
|
92
|
+
home: ['SYSTEM_PERSONAL', 'SYSTEM_INDEX_LIST'],
|
|
93
|
+
favorite: 'SYSTEM_MY_FAVORITE',
|
|
94
|
+
hot: 'SYSTEM_TOP_GAME',
|
|
95
|
+
new: 'SYSTEM_NEW_GAME',
|
|
96
|
+
slot: 'SYSTEM_BIG_CATEGORY_SLOT',
|
|
97
|
+
fish: 'SYSTEM_BIG_CATEGORY_FISHING',
|
|
98
|
+
arcade: 'SYSTEM_BIG_CATEGORY_ARCADE',
|
|
99
|
+
table: 'SYSTEM_BIG_CATEGORY_TABLECARD',
|
|
100
|
+
}
|
|
101
|
+
const menu = {}
|
|
102
|
+
Object.keys(map).forEach((key) => {
|
|
103
|
+
if (Array.isArray(map[key])) {
|
|
104
|
+
// 若是陣列則依順序決定館別內容
|
|
105
|
+
map[key].some((val) => {
|
|
106
|
+
const category = list.find((item) => item.category === val)
|
|
107
|
+
if (category) {
|
|
108
|
+
menu[key] = category
|
|
109
|
+
return true
|
|
110
|
+
} else {
|
|
111
|
+
return false
|
|
112
|
+
}
|
|
113
|
+
})
|
|
114
|
+
} else {
|
|
115
|
+
menu[key] = list.find((item) => item.category === map[key])
|
|
116
|
+
}
|
|
117
|
+
})
|
|
118
|
+
return { menu }
|
|
119
|
+
}),
|
|
120
|
+
forwardRoom: assign((context, event) => {
|
|
121
|
+
return {
|
|
122
|
+
room: event.data,
|
|
123
|
+
roomHistory: [...context.roomHistory, context.room],
|
|
124
|
+
}
|
|
125
|
+
}),
|
|
126
|
+
backwardRoom: assign((context, event) => {
|
|
127
|
+
const { roomHistory } = context
|
|
128
|
+
return {
|
|
129
|
+
room: roomHistory.slice(-1)[0],
|
|
130
|
+
roomHistory: roomHistory.slice(0, -1),
|
|
131
|
+
}
|
|
132
|
+
}),
|
|
133
|
+
resetRoomHistory: assign((context, event) => {
|
|
134
|
+
return {
|
|
135
|
+
roomHistory: [],
|
|
136
|
+
}
|
|
137
|
+
}),
|
|
138
|
+
},
|
|
139
|
+
services: {
|
|
140
|
+
getRoomItems: async (context, event) => {
|
|
141
|
+
return await request.send(api.getGameCategory({ id: context.room?.id }))
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
}
|
|
145
|
+
)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function createSideAction(name) {
|
|
149
|
+
return assign((context, event) => {
|
|
150
|
+
if (!context.roomHistory.some((item) => item.id === context.menu[name].id)) {
|
|
151
|
+
return { room: context.menu[name] }
|
|
152
|
+
}
|
|
153
|
+
})
|
|
154
|
+
}
|
package/src/machine/side_cash.js
CHANGED
|
@@ -66,13 +66,12 @@ export default function (request) {
|
|
|
66
66
|
actions: {
|
|
67
67
|
setMenu: assign((context, event) => {
|
|
68
68
|
const menu = event.data
|
|
69
|
-
if (!Array.isArray(menu?.data)) return
|
|
70
69
|
addLevelProperty(menu.data, 0)
|
|
71
70
|
return { menu }
|
|
72
71
|
}),
|
|
73
72
|
updateMenu: assign((context, event) => {
|
|
74
73
|
const menu = event.data
|
|
75
|
-
if (menu
|
|
74
|
+
if (menu.data.length) {
|
|
76
75
|
addLevelProperty(menu.data, 0)
|
|
77
76
|
return { menu, defaultMenuItemStack: getDefaultItem(menu.data[0]) }
|
|
78
77
|
}
|
|
@@ -83,7 +82,7 @@ export default function (request) {
|
|
|
83
82
|
return await request.send(game.getListRoot({ appSecret }))
|
|
84
83
|
},
|
|
85
84
|
fetchUpdateMenu: async (context, event) => {
|
|
86
|
-
return await request.send(game.getListRoot({ timestamp: context.menu
|
|
85
|
+
return await request.send(game.getListRoot({ timestamp: context.menu.timestamp, appSecret }))
|
|
87
86
|
},
|
|
88
87
|
},
|
|
89
88
|
}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { assign, createMachine } from 'xstate'
|
|
2
|
+
import game from '../api/game.js'
|
|
3
|
+
|
|
4
|
+
export default function (request) {
|
|
5
|
+
const { appSecret } = request.config
|
|
6
|
+
return createMachine(
|
|
7
|
+
{
|
|
8
|
+
id: 'side',
|
|
9
|
+
initial: 'init',
|
|
10
|
+
context: {
|
|
11
|
+
menu: null,
|
|
12
|
+
menuItemStack: [],
|
|
13
|
+
previousMenuItemStack: [],
|
|
14
|
+
historyStack: [],
|
|
15
|
+
defaultMenuItemStack: [],
|
|
16
|
+
},
|
|
17
|
+
states: {
|
|
18
|
+
init: {
|
|
19
|
+
on: {
|
|
20
|
+
START_MENU: {
|
|
21
|
+
target: 'loading',
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
loading: {
|
|
26
|
+
invoke: {
|
|
27
|
+
src: 'getMenu',
|
|
28
|
+
onDone: {
|
|
29
|
+
target: 'idle',
|
|
30
|
+
actions: ['setMenu', 'setDefaultMenuItemStack'],
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
idle: {
|
|
35
|
+
initial: 'pending',
|
|
36
|
+
states: {
|
|
37
|
+
pending: {
|
|
38
|
+
after: {
|
|
39
|
+
20000: [
|
|
40
|
+
{
|
|
41
|
+
target: 'updating',
|
|
42
|
+
cond: 'isInMenu',
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
target: 'pending',
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
updating: {
|
|
51
|
+
invoke: {
|
|
52
|
+
src: 'fetchUpdateMenu',
|
|
53
|
+
onDone: {
|
|
54
|
+
target: 'pending',
|
|
55
|
+
actions: 'updateMenu',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
on: {
|
|
61
|
+
SELECT: {
|
|
62
|
+
actions: 'setMenuItemStack',
|
|
63
|
+
},
|
|
64
|
+
CANCEL: {
|
|
65
|
+
actions: 'restoreMenuItemStack',
|
|
66
|
+
},
|
|
67
|
+
PUSH: {
|
|
68
|
+
actions: 'pushHistoryStack',
|
|
69
|
+
},
|
|
70
|
+
POP: {
|
|
71
|
+
actions: 'popHistoryStack',
|
|
72
|
+
},
|
|
73
|
+
RESET: {
|
|
74
|
+
actions: ['resetMenuItemStack', 'resetHistoryStack'],
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
actions: {
|
|
82
|
+
setMenu: assign((context, event) => {
|
|
83
|
+
const menu = event.data
|
|
84
|
+
addLevelProperty(menu.data, 0)
|
|
85
|
+
return { menu }
|
|
86
|
+
}),
|
|
87
|
+
setDefaultMenuItemStack: assign((context, event) => {
|
|
88
|
+
const menu = event.data
|
|
89
|
+
if (menu.data.length > 0) {
|
|
90
|
+
const menuItemStack = getDefaultItem(menu.data[0])
|
|
91
|
+
return { menuItemStack, defaultMenuItemStack: menuItemStack }
|
|
92
|
+
}
|
|
93
|
+
}),
|
|
94
|
+
setMenuItemStack: assign((context, event) => {
|
|
95
|
+
const { menuItemStack } = context
|
|
96
|
+
const inputItem = event.data
|
|
97
|
+
const isTopItem = inputItem.level === 0
|
|
98
|
+
const hasSubMenu = inputItem.sub?.length
|
|
99
|
+
|
|
100
|
+
if (isTopItem) {
|
|
101
|
+
if (hasSubMenu) {
|
|
102
|
+
return {
|
|
103
|
+
previousMenuItemStack: menuItemStack,
|
|
104
|
+
menuItemStack: [event.data],
|
|
105
|
+
}
|
|
106
|
+
} else {
|
|
107
|
+
return {
|
|
108
|
+
previousMenuItemStack: [],
|
|
109
|
+
menuItemStack: [event.data],
|
|
110
|
+
historyStack: [],
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
} else {
|
|
114
|
+
const slicedStack = menuItemStack.slice(0, inputItem.level)
|
|
115
|
+
return {
|
|
116
|
+
menuItemStack: [...slicedStack, event.data],
|
|
117
|
+
historyStack: [],
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}),
|
|
121
|
+
restoreMenuItemStack: assign((context, event) => {
|
|
122
|
+
const { previousMenuItemStack } = context
|
|
123
|
+
return {
|
|
124
|
+
previousMenuItemStack: [],
|
|
125
|
+
menuItemStack: previousMenuItemStack,
|
|
126
|
+
}
|
|
127
|
+
}),
|
|
128
|
+
updateMenu: assign((context, event) => {
|
|
129
|
+
const menu = event.data
|
|
130
|
+
if (menu.data.length) {
|
|
131
|
+
addLevelProperty(menu.data, 0)
|
|
132
|
+
return { menu, defaultMenuItemStack: getDefaultItem(menu.data[0]) }
|
|
133
|
+
}
|
|
134
|
+
}),
|
|
135
|
+
pushHistoryStack: assign((context, event) => {
|
|
136
|
+
const { menuItemStack, historyStack } = context
|
|
137
|
+
return {
|
|
138
|
+
historyStack: [...historyStack, event.data],
|
|
139
|
+
}
|
|
140
|
+
}),
|
|
141
|
+
popHistoryStack: assign((context, event) => {
|
|
142
|
+
const { historyStack } = context
|
|
143
|
+
return {
|
|
144
|
+
historyStack: historyStack.slice(0, -1),
|
|
145
|
+
}
|
|
146
|
+
}),
|
|
147
|
+
resetMenuItemStack: assign((context, event) => {
|
|
148
|
+
const { defaultMenuItemStack } = context
|
|
149
|
+
return { menuItemStack: defaultMenuItemStack }
|
|
150
|
+
}),
|
|
151
|
+
resetHistoryStack: assign((context, event) => {
|
|
152
|
+
return { historyStack: [] }
|
|
153
|
+
}),
|
|
154
|
+
},
|
|
155
|
+
guards: {
|
|
156
|
+
isInMenu: (context, event) => {
|
|
157
|
+
const { menuItemStack, menu } = context
|
|
158
|
+
const menuItem = menuItemStack.slice(-1)[0]
|
|
159
|
+
return isItemInMenu(menuItem, menu.data)
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
services: {
|
|
163
|
+
getMenu: async (context, event) => {
|
|
164
|
+
return await request.send(game.getListRoot({ appSecret }))
|
|
165
|
+
},
|
|
166
|
+
fetchUpdateMenu: async (context, event) => {
|
|
167
|
+
return await request.send(game.getListRoot({ timestamp: context.menu.timestamp, appSecret }))
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
}
|
|
171
|
+
)
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function isItemInMenu(targetItem, menuList) {
|
|
175
|
+
return menuList.reduce((result, currentItem) => {
|
|
176
|
+
if (result) {
|
|
177
|
+
return true
|
|
178
|
+
} else {
|
|
179
|
+
if (currentItem?.categoryId === targetItem?.categoryId) {
|
|
180
|
+
return true
|
|
181
|
+
} else if (currentItem?.sub?.length) {
|
|
182
|
+
return isItemInMenu(targetItem, currentItem.sub)
|
|
183
|
+
} else {
|
|
184
|
+
return false
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}, false)
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function getDefaultItem(node) {
|
|
191
|
+
if (node.sub?.length > 0) {
|
|
192
|
+
const stack = getDefaultItem(node.sub[0])
|
|
193
|
+
return [node, ...stack]
|
|
194
|
+
} else {
|
|
195
|
+
return [node]
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function addLevelProperty(list, level) {
|
|
200
|
+
const nextLevel = level + 1
|
|
201
|
+
for (let i = 0; i < list.length; i++) {
|
|
202
|
+
list[i].level = level
|
|
203
|
+
|
|
204
|
+
// avoid games in list
|
|
205
|
+
if (!list[i].isGame) {
|
|
206
|
+
addLevelProperty(list[i].sub, nextLevel)
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
@@ -28,6 +28,10 @@ export default function (request) {
|
|
|
28
28
|
target: 'otpFetching',
|
|
29
29
|
actions: 'setOtpParamsEmail',
|
|
30
30
|
},
|
|
31
|
+
SEND_OTP_LOCAL: {
|
|
32
|
+
target: 'otpFetching',
|
|
33
|
+
actions: 'setOtpParamsLocal',
|
|
34
|
+
},
|
|
31
35
|
SEND_OTP_PHONE: {
|
|
32
36
|
target: 'otpFetching',
|
|
33
37
|
actions: 'setOtpParamsPhone',
|
|
@@ -153,6 +157,15 @@ export default function (request) {
|
|
|
153
157
|
},
|
|
154
158
|
}
|
|
155
159
|
}),
|
|
160
|
+
setOtpParamsLocal: assign((context, event) => {
|
|
161
|
+
const { username } = event.data
|
|
162
|
+
return {
|
|
163
|
+
otpParams: {
|
|
164
|
+
provider: 'local',
|
|
165
|
+
username,
|
|
166
|
+
},
|
|
167
|
+
}
|
|
168
|
+
}),
|
|
156
169
|
setOtpParamsEmail: assign((context, event) => {
|
|
157
170
|
const { email } = event.data
|
|
158
171
|
return {
|
|
@@ -171,9 +184,8 @@ export default function (request) {
|
|
|
171
184
|
}
|
|
172
185
|
}),
|
|
173
186
|
decreaseTtl: assign((context, event) => {
|
|
174
|
-
const ms = context.ttl
|
|
175
187
|
return {
|
|
176
|
-
ttl: Math.max(
|
|
188
|
+
ttl: Math.max(context.ttl - 1, 0),
|
|
177
189
|
}
|
|
178
190
|
}),
|
|
179
191
|
setAcknowledgeResult: assign((context, event) => {
|
|
@@ -183,9 +195,8 @@ export default function (request) {
|
|
|
183
195
|
}
|
|
184
196
|
}),
|
|
185
197
|
decreaseAcknowledgeTtl: assign((context, event) => {
|
|
186
|
-
const ms = context.acknowledgeTtl
|
|
187
198
|
return {
|
|
188
|
-
acknowledgeTtl: Math.max(
|
|
199
|
+
acknowledgeTtl: Math.max(context.acknowledgeTtl - 1, 0),
|
|
189
200
|
}
|
|
190
201
|
}),
|
|
191
202
|
setNewPassword: assign((context, event) => {
|