@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
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { assign, createMachine } from 'xstate'
|
|
2
|
+
import api from '../api/payment.js'
|
|
3
|
+
export default function (request) {
|
|
4
|
+
return createMachine(
|
|
5
|
+
{
|
|
6
|
+
id: 'merge',
|
|
7
|
+
initial: 'idle',
|
|
8
|
+
context: {
|
|
9
|
+
userInfo: null,
|
|
10
|
+
},
|
|
11
|
+
states: {
|
|
12
|
+
idle: {
|
|
13
|
+
always: [{ target: 'mergeable', cond: 'isMergeable' }],
|
|
14
|
+
},
|
|
15
|
+
mergeable: {
|
|
16
|
+
on: {
|
|
17
|
+
MERGE: {
|
|
18
|
+
target: 'merging',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
merging: {
|
|
23
|
+
invoke: {
|
|
24
|
+
src: 'mergeWallet',
|
|
25
|
+
onDone: { target: 'idle' },
|
|
26
|
+
onError: { target: 'idle' },
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
on: {
|
|
31
|
+
SET_USER_INFO: {
|
|
32
|
+
actions: 'setUserInfo',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
actions: {
|
|
38
|
+
setUserInfo: assign((context, event) => {
|
|
39
|
+
return {
|
|
40
|
+
userInfo: event.data,
|
|
41
|
+
}
|
|
42
|
+
}),
|
|
43
|
+
},
|
|
44
|
+
guards: {
|
|
45
|
+
isMergeable: (context, event) => {
|
|
46
|
+
const { retain, balance, withdraw_policy } = context.userInfo || {}
|
|
47
|
+
return retain > 0 && (parseFloat(balance) <= 5 || withdraw_policy === 'FREE')
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
services: {
|
|
51
|
+
mergeWallet: async (context, event) => {
|
|
52
|
+
return await request.send(api.mergeWallet())
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
}
|
|
56
|
+
)
|
|
57
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { assign, createMachine } from 'xstate'
|
|
2
|
+
import payment from '../api/payment.js'
|
|
3
|
+
|
|
4
|
+
export default function (request) {
|
|
5
|
+
return createMachine(
|
|
6
|
+
{
|
|
7
|
+
id: 'payment_data',
|
|
8
|
+
initial: 'idle',
|
|
9
|
+
context: {
|
|
10
|
+
transactionList: [],
|
|
11
|
+
spotMarketTime: null,
|
|
12
|
+
spotMarketList: [],
|
|
13
|
+
},
|
|
14
|
+
states: {
|
|
15
|
+
idle: {},
|
|
16
|
+
fetchingTransactionList: {
|
|
17
|
+
invoke: {
|
|
18
|
+
src: 'fetchTransactionList',
|
|
19
|
+
onDone: {
|
|
20
|
+
target: 'idle',
|
|
21
|
+
actions: 'setTransactionList',
|
|
22
|
+
},
|
|
23
|
+
onError: {
|
|
24
|
+
target: 'idle',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
fetchingSpotMarket: {
|
|
29
|
+
invoke: {
|
|
30
|
+
src: 'fetchSpotMarket',
|
|
31
|
+
onDone: {
|
|
32
|
+
target: 'idle',
|
|
33
|
+
actions: 'setSpotMarket',
|
|
34
|
+
},
|
|
35
|
+
onError: {
|
|
36
|
+
target: 'idle',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
on: {
|
|
42
|
+
GET_TRANSACTION_LIST: {
|
|
43
|
+
target: 'fetchingTransactionList',
|
|
44
|
+
},
|
|
45
|
+
GET_SPOT_MARKET: {
|
|
46
|
+
target: 'fetchingSpotMarket',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
actions: {
|
|
52
|
+
setTransactionList: assign((context, event) => {
|
|
53
|
+
const statusMap = {
|
|
54
|
+
2: 'pending',
|
|
55
|
+
3: 'success',
|
|
56
|
+
4: 'reject',
|
|
57
|
+
8: 'expired',
|
|
58
|
+
}
|
|
59
|
+
const transactionList = event.data.map((item) => {
|
|
60
|
+
item.statusName = statusMap[item.status]
|
|
61
|
+
return item
|
|
62
|
+
})
|
|
63
|
+
return {
|
|
64
|
+
transactionList,
|
|
65
|
+
}
|
|
66
|
+
}),
|
|
67
|
+
setSpotMarket: assign((context, event) => {
|
|
68
|
+
const { timestamp, data } = event.data
|
|
69
|
+
return {
|
|
70
|
+
spotMarketTime: timestamp,
|
|
71
|
+
spotMarketList: data.slice(0, 100),
|
|
72
|
+
}
|
|
73
|
+
}),
|
|
74
|
+
},
|
|
75
|
+
services: {
|
|
76
|
+
fetchTransactionList: async (context, event) => {
|
|
77
|
+
const returnDays = event.data
|
|
78
|
+
return await request.send(payment.getPaymentHistory(returnDays))
|
|
79
|
+
},
|
|
80
|
+
fetchSpotMarket: async (context, event) => {
|
|
81
|
+
return await request.send(payment.getSpotMarket())
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
}
|
|
85
|
+
)
|
|
86
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { assign, createMachine } from 'xstate'
|
|
2
|
+
import payment from '../api/payment.js'
|
|
3
|
+
|
|
4
|
+
export default function (request) {
|
|
5
|
+
return createMachine(
|
|
6
|
+
{
|
|
7
|
+
id: 'promotions',
|
|
8
|
+
initial: 'loading',
|
|
9
|
+
context: {
|
|
10
|
+
userInfo: {},
|
|
11
|
+
siteConfig: {},
|
|
12
|
+
withdrawRule: {},
|
|
13
|
+
promotionsList: [],
|
|
14
|
+
selectedPromo: {},
|
|
15
|
+
amount: null,
|
|
16
|
+
callback: () => {},
|
|
17
|
+
},
|
|
18
|
+
states: {
|
|
19
|
+
loading: {
|
|
20
|
+
invoke: {
|
|
21
|
+
src: 'fetchPromotionsList',
|
|
22
|
+
onDone: {
|
|
23
|
+
target: 'loaded',
|
|
24
|
+
actions: 'setPromotionsList',
|
|
25
|
+
},
|
|
26
|
+
onError: {
|
|
27
|
+
target: 'fail',
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
loaded: {
|
|
32
|
+
on: {
|
|
33
|
+
SELECT_PROMO: {
|
|
34
|
+
actions: ['reset', 'setSelectedPromo'],
|
|
35
|
+
},
|
|
36
|
+
SET_AMOUNT: {
|
|
37
|
+
actions: 'setAmount',
|
|
38
|
+
},
|
|
39
|
+
JOIN: {
|
|
40
|
+
target: 'fetching',
|
|
41
|
+
cond: 'isValidAmount',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
fetching: {
|
|
46
|
+
invoke: {
|
|
47
|
+
src: 'fetchWithdrawRulePreview',
|
|
48
|
+
onDone: {
|
|
49
|
+
target: 'pending',
|
|
50
|
+
actions: 'setWithdrawRulePreview',
|
|
51
|
+
},
|
|
52
|
+
onError: {
|
|
53
|
+
target: 'loaded',
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
pending: {
|
|
58
|
+
on: {
|
|
59
|
+
CONFIRM: {
|
|
60
|
+
target: 'applying',
|
|
61
|
+
actions: 'setCallback',
|
|
62
|
+
},
|
|
63
|
+
BACK: {
|
|
64
|
+
target: 'loaded',
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
applying: {
|
|
69
|
+
invoke: {
|
|
70
|
+
src: 'applyPromotion',
|
|
71
|
+
onDone: {
|
|
72
|
+
target: 'applied',
|
|
73
|
+
},
|
|
74
|
+
onError: {
|
|
75
|
+
target: 'loaded',
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
applied: {
|
|
80
|
+
entry: 'doCallback',
|
|
81
|
+
},
|
|
82
|
+
fail: {},
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
actions: {
|
|
87
|
+
setPromotionsList: assign((context, event) => {
|
|
88
|
+
const promotionsList = JSON.parse(JSON.stringify(event.data))
|
|
89
|
+
const { userInfo, siteConfig } = context
|
|
90
|
+
const { withdraw_rule, balance, bank_amount } = userInfo
|
|
91
|
+
const { currencyConversionLimit } = siteConfig
|
|
92
|
+
const balanceAvailable = parseFloat(bank_amount) < parseFloat(`${currencyConversionLimit}`)
|
|
93
|
+
const isFreeLimitRule = withdraw_rule.includes('FREE_LIMIT')
|
|
94
|
+
const includesDefaultRule = withdraw_rule === 'DEFAULT' || withdraw_rule.includes('FREE_DEFAULT')
|
|
95
|
+
|
|
96
|
+
if (!balanceAvailable && includesDefaultRule) {
|
|
97
|
+
promotionsList.map((item) => {
|
|
98
|
+
item.attendEnable = !item.withdrawRule.includes('FREE_LIMIT')
|
|
99
|
+
return item
|
|
100
|
+
})
|
|
101
|
+
} else if (!balanceAvailable && isFreeLimitRule) {
|
|
102
|
+
promotionsList.map((item) => {
|
|
103
|
+
item.attendEnable = false
|
|
104
|
+
return item
|
|
105
|
+
})
|
|
106
|
+
} else {
|
|
107
|
+
promotionsList.map((item) => {
|
|
108
|
+
item.attendEnable = true
|
|
109
|
+
return item
|
|
110
|
+
})
|
|
111
|
+
}
|
|
112
|
+
return {
|
|
113
|
+
promotionsList,
|
|
114
|
+
selectedPromo: promotionsList[0],
|
|
115
|
+
}
|
|
116
|
+
}),
|
|
117
|
+
setSelectedPromo: assign((context, event) => {
|
|
118
|
+
return {
|
|
119
|
+
selectedPromo: event.data,
|
|
120
|
+
}
|
|
121
|
+
}),
|
|
122
|
+
setAmount: assign((context, event) => {
|
|
123
|
+
return {
|
|
124
|
+
amount: event.data,
|
|
125
|
+
}
|
|
126
|
+
}),
|
|
127
|
+
setWithdrawRulePreview: assign((context, event) => {
|
|
128
|
+
return {
|
|
129
|
+
withdrawRule: event.data,
|
|
130
|
+
}
|
|
131
|
+
}),
|
|
132
|
+
setCallback: assign((context, event) => {
|
|
133
|
+
return {
|
|
134
|
+
callback: event.data?.callback || (() => {}),
|
|
135
|
+
}
|
|
136
|
+
}),
|
|
137
|
+
doCallback: (context, event) => {
|
|
138
|
+
context.callback()
|
|
139
|
+
},
|
|
140
|
+
reset: assign((context, event) => {
|
|
141
|
+
return {
|
|
142
|
+
amount: null,
|
|
143
|
+
}
|
|
144
|
+
}),
|
|
145
|
+
},
|
|
146
|
+
guards: {
|
|
147
|
+
isValidAmount: (context, event) => {
|
|
148
|
+
const { selectedPromo, amount } = context
|
|
149
|
+
return selectedPromo.minimumAmount <= amount
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
services: {
|
|
153
|
+
fetchPromotionsList: async (context, event) => {
|
|
154
|
+
return await request.send(payment.getPromotionsList())
|
|
155
|
+
},
|
|
156
|
+
fetchWithdrawRulePreview: async (context, event) => {
|
|
157
|
+
const { selectedPromo, amount } = context
|
|
158
|
+
const data = await request.send(
|
|
159
|
+
payment.getWithdrawRulePreview({ applyType: 'promotions', applyNo: selectedPromo.promotionsNo, amount: parseFloat(amount) })
|
|
160
|
+
)
|
|
161
|
+
return data
|
|
162
|
+
},
|
|
163
|
+
applyPromotion: async (context, event) => {
|
|
164
|
+
const { selectedPromo, amount } = context
|
|
165
|
+
return await request.send(payment.applyPromotions({ promotionsNo: selectedPromo.promotionsNo, amount: parseFloat(amount) }))
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
}
|
|
169
|
+
)
|
|
170
|
+
}
|
package/src/machine/ranking.js
CHANGED
|
@@ -1,28 +1,19 @@
|
|
|
1
1
|
import { createMachine, assign } from 'xstate'
|
|
2
2
|
import ranking from '../api/ranking.js'
|
|
3
3
|
|
|
4
|
-
const ROUND_LIMIT = { DAILY: 56, WEEKLY: 8, MONTHLY: 2, ALL: 2 }
|
|
5
|
-
const ONE_DAY_MS = 24 * 60 * 60 * 1000
|
|
6
|
-
|
|
7
|
-
// 後端每個 cycle 只回傳「當前回合」一筆,前台依當前回合往前回填歷史回合
|
|
8
|
-
// 回合長度 = 當期長度(endDate - beginDate)+ 1 天,回合之間連續無間隔
|
|
9
|
-
function expandPeriodOption(option, cycle) {
|
|
10
|
-
if (!option) return []
|
|
11
|
-
const { round, beginDate, endDate } = option
|
|
12
|
-
// 回合長度取整到整數天,避免後端 endDate 帶當日 23:59:59 等時間造成歷史回合逐期偏移
|
|
13
|
-
const step = Math.floor((endDate - beginDate) / ONE_DAY_MS + 1) * ONE_DAY_MS
|
|
14
|
-
const count = Math.min(ROUND_LIMIT[cycle] || round, round)
|
|
15
|
-
// 降冪排列,當前回合在最前
|
|
16
|
-
return Array.from({ length: count }, (_, i) => ({
|
|
17
|
-
round: round - i,
|
|
18
|
-
beginDate: beginDate - i * step,
|
|
19
|
-
endDate: endDate - i * step,
|
|
20
|
-
}))
|
|
21
|
-
}
|
|
22
|
-
|
|
23
4
|
export default function (request) {
|
|
24
5
|
const { appSecret } = request.config
|
|
25
6
|
const cycleMapping = ['DAILY', 'WEEKLY', 'MONTHLY']
|
|
7
|
+
const limit = { DAILY: 56, WEEKLY: 8, MONTHLY: 2, ALL: 2 }
|
|
8
|
+
|
|
9
|
+
function roundProcess(rounds, cycles) {
|
|
10
|
+
const roundArrays = rounds.map((round) => Array.from({ length: round }, (_, i) => i + 1))
|
|
11
|
+
return roundArrays.reduce((acc, roundArray, index) => {
|
|
12
|
+
const max = limit[cycles[index]] || rounds[index] // 若沒限制則取全部
|
|
13
|
+
acc[cycles[index]] = roundArray.reverse().slice(0, max)
|
|
14
|
+
return acc
|
|
15
|
+
}, {})
|
|
16
|
+
}
|
|
26
17
|
|
|
27
18
|
function transGameData(item) {
|
|
28
19
|
if (!item) return {}
|
|
@@ -39,6 +30,7 @@ export default function (request) {
|
|
|
39
30
|
site: '',
|
|
40
31
|
activityNo: '',
|
|
41
32
|
// api options 回傳的資料
|
|
33
|
+
currentRound: [],
|
|
42
34
|
cycle: '',
|
|
43
35
|
round: 0,
|
|
44
36
|
rule: '',
|
|
@@ -50,7 +42,7 @@ export default function (request) {
|
|
|
50
42
|
gameRanking: [],
|
|
51
43
|
topRanking: [],
|
|
52
44
|
settleStatus: false,
|
|
53
|
-
// 前端這邊用的選單資料 { cycle
|
|
45
|
+
// 前端這邊用的選單資料 { cycle, round }
|
|
54
46
|
options: {},
|
|
55
47
|
},
|
|
56
48
|
states: {
|
|
@@ -164,41 +156,31 @@ export default function (request) {
|
|
|
164
156
|
setRankingOptions: assign((context, event) => {
|
|
165
157
|
const isChampion = event.data?.rule === 'CHAMPION'
|
|
166
158
|
const cycle = event.data?.cycle
|
|
167
|
-
const
|
|
168
|
-
//
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
return acc
|
|
172
|
-
}, {})
|
|
173
|
-
// 依照 cycleMapping 順序取出有資料的 cycle
|
|
174
|
-
const cycleOptions = isChampion ? cycleMapping.filter((c) => optionByCycle[c]) : [cycle]
|
|
175
|
-
// 將每個 cycle 的當前回合往前回填為完整回合列表 { [cycle]: [{ round, beginDate, endDate }] }
|
|
176
|
-
const roundOptions = cycleOptions.reduce((acc, c) => {
|
|
177
|
-
acc[c] = expandPeriodOption(optionByCycle[c], c)
|
|
178
|
-
return acc
|
|
179
|
-
}, {})
|
|
159
|
+
const currentRound = event.data?.currentRound || []
|
|
160
|
+
// 取得結算週期選單列表
|
|
161
|
+
const cycleOptions = isChampion ? cycleMapping.slice(0, currentRound.length) : [cycle]
|
|
162
|
+
const roundOptions = roundProcess(currentRound, cycleOptions)
|
|
180
163
|
// 如果是冠軍龍虎月結算,則加入全部選項
|
|
181
164
|
if (cycle === 'MONTHLY' && isChampion) {
|
|
182
165
|
cycleOptions.push('ALL')
|
|
183
|
-
roundOptions.ALL =
|
|
166
|
+
roundOptions.ALL = roundOptions.MONTHLY
|
|
184
167
|
}
|
|
185
|
-
// 初始 cycle 與 round
|
|
186
|
-
const initialCycle = isChampion ? 'DAILY' : cycle
|
|
187
|
-
const initialRound = roundOptions[initialCycle]?.[0]?.round
|
|
188
168
|
return {
|
|
189
169
|
...event.data,
|
|
190
170
|
options: { cycle: cycleOptions, round: roundOptions },
|
|
191
|
-
|
|
192
|
-
|
|
171
|
+
// 初始固定顯示 DAILY
|
|
172
|
+
cycle: isChampion ? 'DAILY' : cycle,
|
|
173
|
+
round: currentRound[0],
|
|
193
174
|
}
|
|
194
175
|
}),
|
|
195
176
|
setOptions: assign((context, event) => {
|
|
196
|
-
const { cycle, round
|
|
177
|
+
const { cycle, round } = context
|
|
197
178
|
// 處理變更 cycle,如果沒有輸入或沒有變更就不更新
|
|
198
179
|
if (event.data?.cycle && cycle !== event.data?.cycle) {
|
|
199
|
-
const
|
|
200
|
-
const
|
|
201
|
-
|
|
180
|
+
const { currentRound } = context
|
|
181
|
+
const cycleForRound = event.data?.cycle === 'ALL' ? 'MONTHLY' : event.data?.cycle
|
|
182
|
+
const cycleIndex = cycleMapping.indexOf(cycleForRound)
|
|
183
|
+
return { cycle: event.data?.cycle, round: currentRound[cycleIndex] }
|
|
202
184
|
}
|
|
203
185
|
if (event.data?.round && round !== event.data?.round) {
|
|
204
186
|
return { round: event.data?.round }
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { createMachine, assign, send } from 'xstate'
|
|
2
|
+
import activity from '../api/activity.js'
|
|
3
|
+
import payment from '../api/payment.js'
|
|
4
|
+
|
|
5
|
+
export default function (request, context) {
|
|
6
|
+
const { appSecret } = request.config
|
|
7
|
+
return createMachine(
|
|
8
|
+
{
|
|
9
|
+
id: 'reward',
|
|
10
|
+
type: 'parallel',
|
|
11
|
+
context: {
|
|
12
|
+
otherRewardList: [],
|
|
13
|
+
pointsRewardList: [],
|
|
14
|
+
rewardList: [],
|
|
15
|
+
activityNo: null,
|
|
16
|
+
receiveNo: null,
|
|
17
|
+
withdrawRule: {},
|
|
18
|
+
rewardType: null,
|
|
19
|
+
isPlaying: false,
|
|
20
|
+
callback: () => {},
|
|
21
|
+
orderColumn: 'createTime',
|
|
22
|
+
lang: context?.locale,
|
|
23
|
+
},
|
|
24
|
+
states: {
|
|
25
|
+
timer: {
|
|
26
|
+
initial: 'loading',
|
|
27
|
+
states: {
|
|
28
|
+
loading: {
|
|
29
|
+
invoke: {
|
|
30
|
+
src: 'fetchRewardList',
|
|
31
|
+
onDone: {
|
|
32
|
+
target: 'pending',
|
|
33
|
+
actions: 'setRewardList',
|
|
34
|
+
},
|
|
35
|
+
onError: {
|
|
36
|
+
target: 'pending',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
pending: {
|
|
41
|
+
after: {
|
|
42
|
+
20000: [{ target: 'loading', cond: 'isNotInGame' }, { target: 'pending' }],
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
on: {
|
|
47
|
+
REFRESH: {
|
|
48
|
+
target: '.loading',
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
reward: {
|
|
53
|
+
initial: 'idle',
|
|
54
|
+
states: {
|
|
55
|
+
idle: {
|
|
56
|
+
on: {
|
|
57
|
+
FETCH_WITHDRAW_RULE: {
|
|
58
|
+
target: 'fetching',
|
|
59
|
+
actions: 'setRewardData',
|
|
60
|
+
},
|
|
61
|
+
FETCH_OTHER_REWARD: {
|
|
62
|
+
target: 'fetchingOtherReward',
|
|
63
|
+
actions: 'setOrderColumn',
|
|
64
|
+
},
|
|
65
|
+
RECEIVE_REWARD: {
|
|
66
|
+
target: 'receiving',
|
|
67
|
+
actions: ['setCallback', 'setRewardType'],
|
|
68
|
+
},
|
|
69
|
+
RECEIVE_ALL_POINTS: {
|
|
70
|
+
target: 'allPointsReceiving',
|
|
71
|
+
actions: 'setCallback',
|
|
72
|
+
},
|
|
73
|
+
SET_IS_PLAYING: {
|
|
74
|
+
actions: 'setIsPlaying',
|
|
75
|
+
},
|
|
76
|
+
SET_LANG: {
|
|
77
|
+
actions: 'setLang',
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
fetching: {
|
|
82
|
+
invoke: {
|
|
83
|
+
src: 'fetchWithdrawRulePreview',
|
|
84
|
+
onDone: {
|
|
85
|
+
target: 'pending',
|
|
86
|
+
actions: 'setWithdrawRulePreview',
|
|
87
|
+
},
|
|
88
|
+
onError: {
|
|
89
|
+
target: 'idle',
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
fetchingOtherReward: {
|
|
94
|
+
invoke: {
|
|
95
|
+
src: 'fetchOtherRewardList',
|
|
96
|
+
onDone: {
|
|
97
|
+
target: 'idle',
|
|
98
|
+
actions: 'setOtherRewardList',
|
|
99
|
+
},
|
|
100
|
+
onError: {
|
|
101
|
+
target: 'idle',
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
pending: {
|
|
106
|
+
on: {
|
|
107
|
+
RECEIVE_REWARD: {
|
|
108
|
+
target: 'receiving',
|
|
109
|
+
actions: 'setCallback',
|
|
110
|
+
},
|
|
111
|
+
BACK: {
|
|
112
|
+
target: 'idle',
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
receiving: {
|
|
117
|
+
invoke: {
|
|
118
|
+
src: 'receiveReward',
|
|
119
|
+
onDone: [
|
|
120
|
+
{ target: 'received', cond: 'isPrize', actions: send({ type: 'REFRESH' }) },
|
|
121
|
+
{ target: 'received', actions: [send({ type: 'REFRESH' }), 'doCallback'] },
|
|
122
|
+
],
|
|
123
|
+
onError: {
|
|
124
|
+
target: 'idle',
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
received: {
|
|
129
|
+
after: {
|
|
130
|
+
0: {
|
|
131
|
+
target: 'idle',
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
allPointsReceiving: {
|
|
136
|
+
invoke: {
|
|
137
|
+
src: 'receiveAllPoints',
|
|
138
|
+
onDone: {
|
|
139
|
+
target: 'idle',
|
|
140
|
+
actions: [send({ type: 'REFRESH' }), 'doCallback'],
|
|
141
|
+
},
|
|
142
|
+
onError: {
|
|
143
|
+
target: 'idle',
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
actions: {
|
|
153
|
+
setRewardList: assign((context, event) => {
|
|
154
|
+
return {
|
|
155
|
+
otherRewardList: event.data[0]?.data || [],
|
|
156
|
+
pointsRewardList: event.data[1]?.data || [],
|
|
157
|
+
rewardList: event.data[2]?.data || [],
|
|
158
|
+
}
|
|
159
|
+
}),
|
|
160
|
+
setOtherRewardList: assign((context, event) => {
|
|
161
|
+
return {
|
|
162
|
+
otherRewardList: event.data[0]?.data,
|
|
163
|
+
}
|
|
164
|
+
}),
|
|
165
|
+
setRewardData: assign((context, event) => {
|
|
166
|
+
const { activityNo, receiveNo } = event.data
|
|
167
|
+
return {
|
|
168
|
+
activityNo,
|
|
169
|
+
receiveNo,
|
|
170
|
+
}
|
|
171
|
+
}),
|
|
172
|
+
setCallback: assign((context, event) => {
|
|
173
|
+
return {
|
|
174
|
+
callback: event.data?.callback || (() => {}),
|
|
175
|
+
}
|
|
176
|
+
}),
|
|
177
|
+
setOrderColumn: assign((context, event) => {
|
|
178
|
+
return {
|
|
179
|
+
orderColumn: event.data?.orderColumn || 'createTime',
|
|
180
|
+
}
|
|
181
|
+
}),
|
|
182
|
+
setRewardType: assign((context, event) => {
|
|
183
|
+
return {
|
|
184
|
+
rewardType: event.data?.rewardType,
|
|
185
|
+
}
|
|
186
|
+
}),
|
|
187
|
+
doCallback: (context, event) => {
|
|
188
|
+
context.callback()
|
|
189
|
+
},
|
|
190
|
+
setWithdrawRulePreview: assign((context, event) => {
|
|
191
|
+
return {
|
|
192
|
+
withdrawRule: event.data,
|
|
193
|
+
}
|
|
194
|
+
}),
|
|
195
|
+
setIsPlaying: assign((context, event) => {
|
|
196
|
+
return {
|
|
197
|
+
isPlaying: event.data,
|
|
198
|
+
}
|
|
199
|
+
}),
|
|
200
|
+
setLang: assign((context, event) => {
|
|
201
|
+
const lang = event.data.locale || context.lang || 'en-US'
|
|
202
|
+
return { lang }
|
|
203
|
+
}),
|
|
204
|
+
},
|
|
205
|
+
guards: {
|
|
206
|
+
isPrize: (context, event) => {
|
|
207
|
+
const { rewardType } = context
|
|
208
|
+
return rewardType === 'PRIZE'
|
|
209
|
+
},
|
|
210
|
+
isNotInGame: (context, event) => {
|
|
211
|
+
return !context.isPlaying
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
services: {
|
|
215
|
+
fetchRewardList: async (context, event) => {
|
|
216
|
+
const lang = context.lang
|
|
217
|
+
const orderColumn = context.orderColumn
|
|
218
|
+
const getRewardAPI = request.send(activity.getRewardList({ count: 30, appSecret, lang }))
|
|
219
|
+
const getPointsRewardAPI = request.send(activity.getRewardList({ rewardType: 'POINTS', count: 30, appSecret, lang }))
|
|
220
|
+
const getOtherRewardAPI = request.send(activity.getRewardList({ rewardType: 'CASH,FREE,PRIZE', count: 30, appSecret, orderColumn, lang }))
|
|
221
|
+
const [otherRewardList, pointsRewardList, rewardList] = await Promise.all([getOtherRewardAPI, getPointsRewardAPI, getRewardAPI])
|
|
222
|
+
return [otherRewardList, pointsRewardList, rewardList]
|
|
223
|
+
},
|
|
224
|
+
fetchOtherRewardList: async (context, event) => {
|
|
225
|
+
const orderColumn = context.orderColumn
|
|
226
|
+
const lang = context.lang
|
|
227
|
+
const getOtherRewardAPI = request.send(
|
|
228
|
+
activity.getRewardList({
|
|
229
|
+
rewardType: 'CASH,FREE,PRIZE',
|
|
230
|
+
count: 30,
|
|
231
|
+
appSecret,
|
|
232
|
+
orderColumn,
|
|
233
|
+
lang,
|
|
234
|
+
})
|
|
235
|
+
)
|
|
236
|
+
const [otherRewardList] = await Promise.all([getOtherRewardAPI])
|
|
237
|
+
return [otherRewardList]
|
|
238
|
+
},
|
|
239
|
+
fetchWithdrawRulePreview: async (context, event) => {
|
|
240
|
+
const { receiveNo } = context
|
|
241
|
+
const data = await request.send(payment.getWithdrawRulePreview({ applyType: 'activity', applyNo: receiveNo, amount: null }))
|
|
242
|
+
return data
|
|
243
|
+
},
|
|
244
|
+
receiveReward: async (context, event) => {
|
|
245
|
+
const { activityNo, receiveNo, attended } = event.data
|
|
246
|
+
const validateReceiveNo = Number(receiveNo) > 0 ? Number(receiveNo) : undefined
|
|
247
|
+
return await request.send(activity.getReward({ activityNo, receiveNo: validateReceiveNo, appSecret, attended }))
|
|
248
|
+
},
|
|
249
|
+
receiveAllPoints: async (context, event) => {
|
|
250
|
+
return await request.send(activity.collect({ collectType: 'collectPoints', appSecret }))
|
|
251
|
+
},
|
|
252
|
+
},
|
|
253
|
+
}
|
|
254
|
+
)
|
|
255
|
+
}
|