@jetthai/cuora 1.1.488 → 2.0.0-beta.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/BREAKING_CHANGES.md +9 -0
- package/CHANGELOG.md +3 -316
- package/README.md +15 -299
- package/package.json +5 -5
- package/resetGitBranch.sh +101 -0
- package/src/api/account.js +1 -0
- package/src/api/activity.js +39 -24
- package/src/api/auth.js +36 -5
- package/src/api/common.js +3 -5
- package/src/api/game.js +10 -0
- package/src/api/payment.js +55 -17
- package/src/api/user.js +16 -10
- package/src/index.js +2 -2
- package/src/lib/fingerprint_v3_11_12.js +11433 -0
- package/src/machine/activity/activity.js +213 -0
- package/src/machine/activity/activity_cash.js +36 -84
- package/src/machine/activity/cash_rain_activity.js +1 -0
- package/src/machine/activity/continue_deposit_activity.js +1 -0
- package/src/machine/activity/deposit_activity.js +1 -0
- package/src/machine/activity/diamond_shop_activity_cash.js +8 -0
- package/src/machine/activity/diamond_shop_activity_fc.js +197 -0
- package/src/machine/activity/diamond_shop_activity_vn.js +179 -0
- package/src/machine/activity/fafafa_activity.js +11 -0
- package/src/machine/activity/friend_invite_friends_activity.js +7 -8
- package/src/machine/activity/index.js +12 -0
- package/src/machine/activity/instant_rebate_activity.js +1 -0
- package/src/machine/activity/invite_friends_activity.js +115 -0
- package/src/machine/activity/jackpot.js +1 -0
- package/src/machine/activity/mini_game_activity.js +69 -0
- package/src/machine/activity/otp_verified_activity.js +1 -0
- package/src/machine/activity/ranking_activity.js +1 -0
- package/src/machine/activity/return_bonus_activity.js +155 -0
- package/src/machine/activity/roulette_activity_v2.js +1 -0
- package/src/machine/activity/sign_in_activity.js +1 -0
- package/src/machine/activity/sign_in_monthly_activity.js +2 -1
- package/src/machine/activity/specify_bets_activity.js +1 -0
- package/src/machine/activity/specify_turnover_activity.js +1 -0
- package/src/machine/activity/time_bomb_activity.js +1 -0
- package/src/machine/activity/vip_card_activity.js +1 -0
- package/src/machine/auth.js +112 -149
- package/src/machine/auth_otp_v2.js +178 -0
- package/src/machine/auth_otp_v3.js +22 -64
- package/src/machine/bank_binding.js +3 -2
- package/src/machine/bank_binding_amb.js +146 -0
- package/src/machine/bonus.js +76 -0
- package/src/machine/common.js +98 -14
- package/src/machine/deposit/amb.js +93 -0
- package/src/machine/deposit/crypto_bank.js +340 -0
- package/src/machine/deposit/crypto_bank_cash.js +35 -20
- package/src/machine/deposit/crypto_qrcode.js +158 -0
- package/src/machine/deposit/crypto_qrcode_cash.js +64 -26
- package/src/machine/deposit/crypto_way.js +253 -0
- package/src/machine/deposit/crypto_way_cash.js +37 -48
- package/src/machine/deposit/deposit_fc.js +272 -0
- package/src/machine/deposit/direct.js +311 -0
- package/src/machine/deposit/direct_cash.js +10 -8
- package/src/machine/deposit/float.js +375 -0
- package/src/machine/deposit/index.js +28 -0
- package/src/machine/deposit/krway.js +152 -0
- package/src/machine/deposit/loadcard_cash.js +32 -14
- package/src/machine/deposit/loadcard_vn.js +352 -0
- package/src/machine/deposit/manual_cash.js +11 -8
- package/src/machine/deposit/manual_vn.js +459 -0
- package/src/machine/deposit/qrcode_cash.js +32 -15
- package/src/machine/deposit/qrcode_v2.js +339 -0
- package/src/machine/deposit/usdt.js +163 -0
- package/src/machine/deposit/usdt_cash.js +15 -1
- package/src/machine/deposit/virtual_bank_cash.js +12 -13
- package/src/machine/deposit/virtual_bank_vn.js +270 -0
- package/src/machine/deposit/vpay.js +374 -0
- package/src/machine/error.js +1 -7
- package/src/machine/game_betslip.js +1 -0
- package/src/machine/game_favorite_v2.js +1 -0
- package/src/machine/game_hot_new.js +80 -0
- package/src/machine/game_info.js +13 -1
- package/src/machine/game_replay.js +47 -0
- package/src/machine/game_search_cash.js +1 -0
- package/src/machine/game_search_v2.js +402 -0
- package/src/machine/game_v2_1.js +126 -39
- package/src/machine/honor_board.js +133 -0
- package/src/machine/honor_board_cash.js +28 -22
- package/src/machine/inbox.js +105 -43
- package/src/machine/index.js +32 -0
- package/src/machine/leaderboard.js +12 -8
- package/src/machine/merge.js +58 -0
- package/src/machine/navbar.js +3 -1
- package/src/machine/payment_data.js +87 -0
- package/src/machine/promotions.js +163 -0
- package/src/machine/ranking.js +30 -45
- package/src/machine/reward.js +256 -0
- package/src/machine/reward_cash.js +42 -2
- package/src/machine/reward_fc.js +99 -0
- package/src/machine/roulette_v2.js +11 -14
- package/src/machine/setting.js +1 -0
- package/src/machine/side.js +160 -0
- package/src/machine/side_cash.js +3 -3
- package/src/machine/side_v2.js +223 -0
- package/src/machine/user_info.js +1 -0
- package/src/machine/user_photo.js +1 -0
- package/src/machine/user_reset_password.js +14 -0
- package/src/machine/user_sign_up.js +61 -46
- package/src/machine/vip_table.js +58 -0
- package/src/machine/websocket.js +349 -374
- package/src/machine/welcome.js +111 -0
- package/src/machine/withdraw/index.js +6 -0
- package/src/machine/withdraw/withdraw_crypto_cash.js +328 -0
- package/src/machine/withdraw/withdraw_krway.js +223 -0
- package/src/machine/withdraw/withdraw_manual.js +541 -0
- package/src/machine/withdraw/withdraw_manual_cash.js +39 -59
- package/src/request/config.js +0 -2
- package/src/request/request.js +60 -124
- package/src/util/constant.js +2 -6
- package/src/util/deviceToken.js +60 -0
- package/src/util/index.js +4 -2
- package/src/util/math.js +4 -0
- package/src/util/storage.js +4 -3
- package/test/api.behavior.test.js +69 -0
- package/test/api.contract.test.js +18 -0
- package/test/config.test.js +27 -0
- package/test/deviceToken.test.js +139 -0
- package/test/helpers.coverage.test.js +11 -0
- package/test/helpers.js +91 -0
- package/test/index.exports.test.js +14 -0
- package/test/machine.activity.core.coverage.test.js +337 -0
- package/test/machine.activity.gap.coverage.test.js +252 -0
- package/test/machine.activity.more.coverage.test.js +180 -0
- package/test/machine.activity_plus_and_binding_amb.coverage.test.js +201 -0
- package/test/machine.activity_timer_bonus.coverage.test.js +136 -0
- package/test/machine.activity_welcome.low.coverage.test.js +211 -0
- package/test/machine.amb_rewardfc_websocket.more.coverage.test.js +201 -0
- package/test/machine.auth.coverage.test.js +215 -0
- package/test/machine.bank_binding.test.js +143 -0
- package/test/machine.binding_otp_krway.coverage.test.js +223 -0
- package/test/machine.contract.test.js +50 -0
- package/test/machine.crypto_bank.coverage.test.js +270 -0
- package/test/machine.crypto_way.coverage.test.js +108 -0
- package/test/machine.crypto_way_cash.coverage.test.js +114 -0
- package/test/machine.definition.test.js +137 -0
- package/test/machine.deposit.manual.coverage.test.js +365 -0
- package/test/machine.deposit_fc.coverage.test.js +126 -0
- package/test/machine.direct.coverage.test.js +96 -0
- package/test/machine.direct_cash.coverage.test.js +108 -0
- package/test/machine.error.coverage.test.js +37 -0
- package/test/machine.events.test.js +126 -0
- package/test/machine.favorite_jackpot.coverage.test.js +82 -0
- package/test/machine.float.coverage.test.js +136 -0
- package/test/machine.flow.test.js +226 -0
- package/test/machine.game_hot_new_vip_table.coverage.test.js +105 -0
- package/test/machine.game_search_cash.coverage.test.js +155 -0
- package/test/machine.game_search_v2.test.js +199 -0
- package/test/machine.game_user_profile.coverage.test.js +100 -0
- package/test/machine.honor_board.test.js +133 -0
- package/test/machine.inbox.common.coverage.test.js +304 -0
- package/test/machine.loadcard_cash.coverage.test.js +101 -0
- package/test/machine.loadcard_vn.coverage.test.js +122 -0
- package/test/machine.misc.coverage.test.js +361 -0
- package/test/machine.more2.coverage.test.js +261 -0
- package/test/machine.options.execution.test.js +272 -0
- package/test/machine.priority.coverage.test.js +603 -0
- package/test/machine.qrcode_cash.coverage.test.js +107 -0
- package/test/machine.qrcode_v2.coverage.test.js +121 -0
- package/test/machine.regression.test.js +82 -0
- package/test/machine.roulette_v2.test.js +142 -0
- package/test/machine.side_reward_reset.coverage.test.js +220 -0
- package/test/machine.targeted.coverage.test.js +313 -0
- package/test/machine.usdt.coverage.test.js +95 -0
- package/test/machine.usdt_cash.coverage.test.js +73 -0
- package/test/machine.vip_card_activity.test.js +114 -0
- package/test/machine.virtual_bank_cash.coverage.test.js +105 -0
- package/test/machine.virtual_bank_vn.coverage.test.js +105 -0
- package/test/machine.vpay.coverage.test.js +142 -0
- package/test/machine.withdraw_crypto_cash.coverage.test.js +166 -0
- package/test/machine.withdraw_krway.coverage.test.js +123 -0
- package/test/machine.withdraw_manual.coverage.test.js +185 -0
- package/test/machine.withdraw_manual_cash.coverage.test.js +123 -0
- package/test/request.test.js +325 -0
- package/test/util.storage.errors.test.js +47 -0
- package/test/util.test.js +41 -0
- package/.claude/commands/sync-ai-prompts.md +0 -93
- package/.claude/settings.local.json +0 -23
- package/.github/copilot-instructions.md +0 -448
- package/.husky/post-checkout +0 -32
- package/.husky/pre-push +0 -36
- package/AGENTS.md +0 -448
- package/AI_PROMPT_SOURCE.md +0 -446
- package/CLAUDE.md +0 -448
- package/GEMINI.md +0 -448
- 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/scripts/auto-version.js +0 -68
- package/scripts/auto-version.sh +0 -33
- package/scripts/branch-auto-npm-publish.js +0 -29
- package/scripts/check-version.sh +0 -36
- package/scripts/clean-tags.sh +0 -84
- 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/test/auth_otp_v3.test.js +0 -323
- package/tests/websocket.test.mjs +0 -779
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
import { assign, createMachine } from 'xstate'
|
|
2
|
+
import payment from '../../api/payment.js'
|
|
3
|
+
import common from '../../api/common.js'
|
|
4
|
+
|
|
5
|
+
export default function (request) {
|
|
6
|
+
const { appSecret } = request.config
|
|
7
|
+
return createMachine(
|
|
8
|
+
{
|
|
9
|
+
id: 'float',
|
|
10
|
+
predictableActionArguments: true,
|
|
11
|
+
initial: 'loading',
|
|
12
|
+
context: {
|
|
13
|
+
method: 'amb_float',
|
|
14
|
+
userAccount: {},
|
|
15
|
+
siteConfig: null,
|
|
16
|
+
amount: 0,
|
|
17
|
+
|
|
18
|
+
bankList: [],
|
|
19
|
+
options: [],
|
|
20
|
+
minimum: 0,
|
|
21
|
+
maximum: 0,
|
|
22
|
+
|
|
23
|
+
calculation: null,
|
|
24
|
+
|
|
25
|
+
houseAccountName: null,
|
|
26
|
+
houseAccountNumber: null,
|
|
27
|
+
houseBankName: null,
|
|
28
|
+
calculatedAmount: 0,
|
|
29
|
+
|
|
30
|
+
grandTotalEnable: 1,
|
|
31
|
+
ttl: 120,
|
|
32
|
+
|
|
33
|
+
promotion: null,
|
|
34
|
+
bonusPreviewData: [],
|
|
35
|
+
},
|
|
36
|
+
states: {
|
|
37
|
+
loading: {
|
|
38
|
+
initial: 'checkingUserAccount',
|
|
39
|
+
states: {
|
|
40
|
+
checkingUserAccount: {
|
|
41
|
+
invoke: {
|
|
42
|
+
src: 'fetchPaymentInfo',
|
|
43
|
+
onDone: [
|
|
44
|
+
{
|
|
45
|
+
target: 'initializing',
|
|
46
|
+
actions: 'setUserAccount',
|
|
47
|
+
cond: 'hasUserAccount',
|
|
48
|
+
},
|
|
49
|
+
{ target: '#float.accountUnbound' },
|
|
50
|
+
],
|
|
51
|
+
onError: {
|
|
52
|
+
target: '#float.unavailable',
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
initializing: {
|
|
57
|
+
invoke: {
|
|
58
|
+
src: 'initialize',
|
|
59
|
+
onDone: {
|
|
60
|
+
target: '#float.loaded',
|
|
61
|
+
actions: 'setInitialization',
|
|
62
|
+
},
|
|
63
|
+
onError: {
|
|
64
|
+
target: '#float.unavailable',
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
checking: {
|
|
71
|
+
always: [
|
|
72
|
+
{
|
|
73
|
+
target: 'fetching',
|
|
74
|
+
cond: (context, event) => {
|
|
75
|
+
const { siteConfig = {}, promotion = {} } = context
|
|
76
|
+
const { bonusPreviewEnable } = siteConfig
|
|
77
|
+
return bonusPreviewEnable && promotion.activityNo != 'none'
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
{ target: 'loaded' },
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
fetching: {
|
|
84
|
+
invoke: {
|
|
85
|
+
src: 'fetchBonusPreview',
|
|
86
|
+
onDone: {
|
|
87
|
+
target: 'loaded',
|
|
88
|
+
actions: 'setBonusPreview',
|
|
89
|
+
},
|
|
90
|
+
onError: {
|
|
91
|
+
target: 'loaded',
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
loaded: {
|
|
96
|
+
on: {
|
|
97
|
+
SELECT_AMOUNT: [
|
|
98
|
+
{
|
|
99
|
+
target: 'debouncing',
|
|
100
|
+
actions: 'addAmount',
|
|
101
|
+
cond: 'isGrandTotalEnable',
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
target: 'debouncing',
|
|
105
|
+
actions: 'setAmount',
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
KEY_IN: {
|
|
109
|
+
target: 'calculating',
|
|
110
|
+
actions: 'setAmount',
|
|
111
|
+
},
|
|
112
|
+
CLEAR_CALCULATION: {
|
|
113
|
+
target: 'debouncing',
|
|
114
|
+
actions: 'clearCalculation',
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
debouncing: {
|
|
119
|
+
on: {
|
|
120
|
+
SELECT_AMOUNT: [
|
|
121
|
+
{
|
|
122
|
+
target: 'debouncing',
|
|
123
|
+
actions: 'addAmount',
|
|
124
|
+
cond: 'isGrandTotalEnable',
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
target: 'debouncing',
|
|
128
|
+
actions: 'setAmount',
|
|
129
|
+
},
|
|
130
|
+
],
|
|
131
|
+
KEY_IN: {
|
|
132
|
+
target: 'debouncing',
|
|
133
|
+
actions: 'setAmount',
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
after: {
|
|
137
|
+
1000: {
|
|
138
|
+
target: 'calculating',
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
calculable: {
|
|
143
|
+
entry: 'clearCalculation',
|
|
144
|
+
on: {
|
|
145
|
+
SELECT_AMOUNT: [
|
|
146
|
+
{
|
|
147
|
+
target: 'debouncing',
|
|
148
|
+
actions: 'addAmount',
|
|
149
|
+
cond: 'isGrandTotalEnable',
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
target: 'debouncing',
|
|
153
|
+
actions: 'setAmount',
|
|
154
|
+
},
|
|
155
|
+
],
|
|
156
|
+
KEY_IN: {
|
|
157
|
+
target: 'debouncing',
|
|
158
|
+
actions: 'setAmount',
|
|
159
|
+
},
|
|
160
|
+
CLEAR_CALCULATION: {
|
|
161
|
+
target: 'debouncing',
|
|
162
|
+
actions: 'clearCalculation',
|
|
163
|
+
},
|
|
164
|
+
CLEAR: {
|
|
165
|
+
actions: 'setAmount',
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
calculating: {
|
|
170
|
+
invoke: {
|
|
171
|
+
src: 'fetchCalculation',
|
|
172
|
+
onDone: {
|
|
173
|
+
target: 'calculated',
|
|
174
|
+
actions: 'setCalculation',
|
|
175
|
+
},
|
|
176
|
+
onError: {
|
|
177
|
+
target: 'calculable',
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
calculated: {
|
|
182
|
+
on: {
|
|
183
|
+
SELECT_AMOUNT: [
|
|
184
|
+
{
|
|
185
|
+
target: 'debouncing',
|
|
186
|
+
actions: 'addAmount',
|
|
187
|
+
cond: 'isGrandTotalEnable',
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
target: 'debouncing',
|
|
191
|
+
actions: 'setAmount',
|
|
192
|
+
},
|
|
193
|
+
],
|
|
194
|
+
KEY_IN: {
|
|
195
|
+
target: 'debouncing',
|
|
196
|
+
actions: 'setAmount',
|
|
197
|
+
},
|
|
198
|
+
CONFIRM: {
|
|
199
|
+
target: 'submitting',
|
|
200
|
+
},
|
|
201
|
+
CLEAR: {
|
|
202
|
+
actions: 'setAmount',
|
|
203
|
+
},
|
|
204
|
+
CLEAR_CALCULATION: {
|
|
205
|
+
target: 'debouncing',
|
|
206
|
+
actions: 'clearCalculation',
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
submitting: {
|
|
211
|
+
invoke: {
|
|
212
|
+
src: 'submitDeposit',
|
|
213
|
+
onDone: {
|
|
214
|
+
target: 'countdown',
|
|
215
|
+
actions: 'setHouseBank',
|
|
216
|
+
},
|
|
217
|
+
onError: {
|
|
218
|
+
target: 'calculated',
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
countdown: {
|
|
223
|
+
after: {
|
|
224
|
+
1000: [
|
|
225
|
+
{
|
|
226
|
+
target: 'countdown',
|
|
227
|
+
actions: 'decreaseTtl',
|
|
228
|
+
cond: (context) => context.ttl > 0,
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
target: 'loaded',
|
|
232
|
+
},
|
|
233
|
+
],
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
accountUnbound: {},
|
|
237
|
+
unavailable: {},
|
|
238
|
+
},
|
|
239
|
+
on: {
|
|
240
|
+
SET_PROMOTION: {
|
|
241
|
+
actions: 'setPromotion',
|
|
242
|
+
},
|
|
243
|
+
},
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
actions: {
|
|
247
|
+
setUserAccount: assign((context, event) => {
|
|
248
|
+
return {
|
|
249
|
+
userAccount: event.data?.[0],
|
|
250
|
+
}
|
|
251
|
+
}),
|
|
252
|
+
setPromotion: assign((context, event) => {
|
|
253
|
+
const promotion = event.data
|
|
254
|
+
return {
|
|
255
|
+
promotion,
|
|
256
|
+
}
|
|
257
|
+
}),
|
|
258
|
+
setBonusPreview: assign((context, event) => {
|
|
259
|
+
return {
|
|
260
|
+
bonusPreviewData: event.data,
|
|
261
|
+
}
|
|
262
|
+
}),
|
|
263
|
+
setHouseBank: assign((context, event) => {
|
|
264
|
+
const { accountName, accountNumber, bankName, amount } = event.data
|
|
265
|
+
return {
|
|
266
|
+
houseAccountName: accountName,
|
|
267
|
+
houseAccountNumber: accountNumber,
|
|
268
|
+
houseBankName: bankName,
|
|
269
|
+
calculatedAmount: amount,
|
|
270
|
+
}
|
|
271
|
+
}),
|
|
272
|
+
setInitialization: assign((context, event) => {
|
|
273
|
+
const { siteConfig, housePayment, bankList } = event.data
|
|
274
|
+
const { optional, minimum, maximum, grandTotalEnable } = housePayment
|
|
275
|
+
return {
|
|
276
|
+
siteConfig,
|
|
277
|
+
options: optional,
|
|
278
|
+
minimum,
|
|
279
|
+
maximum,
|
|
280
|
+
bankList: bankList?.data ? bankList.data : bankList,
|
|
281
|
+
grandTotalEnable,
|
|
282
|
+
}
|
|
283
|
+
}),
|
|
284
|
+
addAmount: assign((context, event) => {
|
|
285
|
+
const { amount, maximum } = context
|
|
286
|
+
return {
|
|
287
|
+
amount: Math.min(amount + event.data, maximum),
|
|
288
|
+
}
|
|
289
|
+
}),
|
|
290
|
+
setAmount: assign((context, event) => {
|
|
291
|
+
return {
|
|
292
|
+
amount: event.data,
|
|
293
|
+
}
|
|
294
|
+
}),
|
|
295
|
+
setCalculation: assign((context, event) => {
|
|
296
|
+
// V2接口轉換中回傳的資料結構不同
|
|
297
|
+
const { data } = event.data
|
|
298
|
+
if (data) {
|
|
299
|
+
return {
|
|
300
|
+
calculation: data,
|
|
301
|
+
}
|
|
302
|
+
} else {
|
|
303
|
+
return {
|
|
304
|
+
calculation: event.data,
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}),
|
|
308
|
+
clearCalculation: assign((context, event) => {
|
|
309
|
+
return {
|
|
310
|
+
calculation: null,
|
|
311
|
+
}
|
|
312
|
+
}),
|
|
313
|
+
decreaseTtl: assign((context, evnet) => {
|
|
314
|
+
const ms = context.ttl
|
|
315
|
+
return {
|
|
316
|
+
ttl: Math.max(ms - 1, 0),
|
|
317
|
+
}
|
|
318
|
+
}),
|
|
319
|
+
},
|
|
320
|
+
guards: {
|
|
321
|
+
hasUserAccount: (context, event) => {
|
|
322
|
+
return event.data?.[0]
|
|
323
|
+
},
|
|
324
|
+
isGrandTotalEnable: (context, event) => {
|
|
325
|
+
return context.grandTotalEnable === 1
|
|
326
|
+
},
|
|
327
|
+
},
|
|
328
|
+
services: {
|
|
329
|
+
fetchPaymentInfo: async (context, event) => {
|
|
330
|
+
const { bankInfo } = await request.send(payment.getPaymentInfo())
|
|
331
|
+
const filterArray = bankInfo?.filter((item) => item.bindingType !== 'CRYPTO' && item.bindingType !== 'EWALLET')
|
|
332
|
+
return filterArray || []
|
|
333
|
+
},
|
|
334
|
+
initialize: async (context, event) => {
|
|
335
|
+
const [{ config }, payments, bankList] = await Promise.all([
|
|
336
|
+
request.send(common.getConfig({ appSecret })),
|
|
337
|
+
request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' })),
|
|
338
|
+
request.send(payment.getBankList('amb')),
|
|
339
|
+
])
|
|
340
|
+
const siteConfig = JSON.parse(window.atob(config))
|
|
341
|
+
return { siteConfig, housePayment: payments.find((payment) => payment.method === context.method), bankList }
|
|
342
|
+
},
|
|
343
|
+
fetchBonusPreview: async (context, event) => {
|
|
344
|
+
const { method, promotion } = context
|
|
345
|
+
return await request.send(
|
|
346
|
+
payment.getBonusPreview({
|
|
347
|
+
method,
|
|
348
|
+
promotionsNo: promotion?.activityNo,
|
|
349
|
+
})
|
|
350
|
+
)
|
|
351
|
+
},
|
|
352
|
+
submitDeposit: async (context, event) => {
|
|
353
|
+
const { method, amount, promotion } = context
|
|
354
|
+
return await request.send(
|
|
355
|
+
payment.submitDepositTransaction({
|
|
356
|
+
method,
|
|
357
|
+
amount,
|
|
358
|
+
promotionsNo: promotion?.activityNo,
|
|
359
|
+
})
|
|
360
|
+
)
|
|
361
|
+
},
|
|
362
|
+
fetchCalculation: async (context, event) => {
|
|
363
|
+
const { method, amount, promotion } = context
|
|
364
|
+
return await request.send(
|
|
365
|
+
payment.getDepositExpectedResult({
|
|
366
|
+
method,
|
|
367
|
+
amount: Number(amount),
|
|
368
|
+
promotionsNo: promotion?.activityNo,
|
|
369
|
+
})
|
|
370
|
+
)
|
|
371
|
+
},
|
|
372
|
+
},
|
|
373
|
+
}
|
|
374
|
+
)
|
|
375
|
+
}
|
|
@@ -1,21 +1,49 @@
|
|
|
1
|
+
import manual_vn from './manual_vn.js'
|
|
2
|
+
import loadcard_vn from './loadcard_vn.js'
|
|
3
|
+
import qrcode_v2 from './qrcode_v2.js'
|
|
4
|
+
import deposit_fc from './deposit_fc.js'
|
|
5
|
+
import direct from './direct.js'
|
|
6
|
+
import amb from './amb.js'
|
|
7
|
+
import float from './float.js'
|
|
8
|
+
import vpay from './vpay.js'
|
|
9
|
+
import krway from './krway.js'
|
|
10
|
+
import usdt from './usdt.js'
|
|
1
11
|
import manual_cash from './manual_cash.js'
|
|
2
12
|
import qrcode_cash from './qrcode_cash.js'
|
|
3
13
|
import usdt_cash from './usdt_cash.js'
|
|
4
14
|
import direct_cash from './direct_cash.js'
|
|
5
15
|
import loadcard_cash from './loadcard_cash.js'
|
|
16
|
+
import crypto_bank from './crypto_bank.js'
|
|
17
|
+
import crypto_qrcode from './crypto_qrcode.js'
|
|
18
|
+
import crypto_way from './crypto_way.js'
|
|
6
19
|
import crypto_bank_cash from './crypto_bank_cash.js'
|
|
7
20
|
import crypto_qrcode_cash from './crypto_qrcode_cash.js'
|
|
8
21
|
import crypto_way_cash from './crypto_way_cash.js'
|
|
22
|
+
import virtual_bank_vn from './virtual_bank_vn.js'
|
|
9
23
|
import virtual_bank_cash from './virtual_bank_cash.js'
|
|
10
24
|
|
|
11
25
|
export default {
|
|
26
|
+
manual_vn,
|
|
27
|
+
loadcard_vn,
|
|
28
|
+
qrcode_v2,
|
|
29
|
+
deposit_fc,
|
|
30
|
+
direct,
|
|
31
|
+
amb,
|
|
32
|
+
float,
|
|
33
|
+
vpay,
|
|
34
|
+
usdt,
|
|
35
|
+
krway,
|
|
12
36
|
manual_cash,
|
|
13
37
|
qrcode_cash,
|
|
14
38
|
usdt_cash,
|
|
15
39
|
direct_cash,
|
|
16
40
|
loadcard_cash,
|
|
41
|
+
crypto_bank,
|
|
42
|
+
crypto_qrcode,
|
|
43
|
+
crypto_way,
|
|
17
44
|
crypto_bank_cash,
|
|
18
45
|
crypto_qrcode_cash,
|
|
19
46
|
crypto_way_cash,
|
|
47
|
+
virtual_bank_vn,
|
|
20
48
|
virtual_bank_cash,
|
|
21
49
|
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { assign, createMachine } from 'xstate'
|
|
2
|
+
import payment from '../../api/payment.js'
|
|
3
|
+
import mailbox from '../../api/mailbox.js'
|
|
4
|
+
|
|
5
|
+
export default function (request) {
|
|
6
|
+
return createMachine(
|
|
7
|
+
{
|
|
8
|
+
id: 'krway',
|
|
9
|
+
predictableActionArguments: true,
|
|
10
|
+
initial: 'loading',
|
|
11
|
+
context: {
|
|
12
|
+
currentCategory: 'krway',
|
|
13
|
+
paymentDetail: [],
|
|
14
|
+
currentPayment: null,
|
|
15
|
+
options: [],
|
|
16
|
+
amount: null,
|
|
17
|
+
processing: null,
|
|
18
|
+
},
|
|
19
|
+
states: {
|
|
20
|
+
loading: {
|
|
21
|
+
invoke: {
|
|
22
|
+
src: 'fetchPaymentDetail',
|
|
23
|
+
onDone: {
|
|
24
|
+
target: 'checking',
|
|
25
|
+
actions: 'setPaymentDetail',
|
|
26
|
+
},
|
|
27
|
+
onError: {
|
|
28
|
+
target: 'fail',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
checking: {
|
|
33
|
+
always: [
|
|
34
|
+
{
|
|
35
|
+
target: 'processing',
|
|
36
|
+
cond: 'isProcessing',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
target: 'idle',
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
processing: {},
|
|
44
|
+
idle: {},
|
|
45
|
+
inquiring: {
|
|
46
|
+
invoke: {
|
|
47
|
+
src: 'accountInquiry',
|
|
48
|
+
onDone: {
|
|
49
|
+
target: 'inquired',
|
|
50
|
+
},
|
|
51
|
+
onError: {
|
|
52
|
+
target: 'idle',
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
inquired: {
|
|
57
|
+
after: {
|
|
58
|
+
0: {
|
|
59
|
+
target: 'idle',
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
submitting: {
|
|
64
|
+
invoke: {
|
|
65
|
+
src: 'submitDeposit',
|
|
66
|
+
onDone: {
|
|
67
|
+
target: 'submitted',
|
|
68
|
+
actions: 'setProcessing',
|
|
69
|
+
},
|
|
70
|
+
onError: {
|
|
71
|
+
target: 'fail',
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
submitted: {},
|
|
76
|
+
fail: {},
|
|
77
|
+
},
|
|
78
|
+
on: {
|
|
79
|
+
INQUIRY_ACCOUNT: {
|
|
80
|
+
target: 'inquiring',
|
|
81
|
+
},
|
|
82
|
+
ADD_AMOUNT: {
|
|
83
|
+
actions: 'addAmount',
|
|
84
|
+
},
|
|
85
|
+
SET_AMOUNT: {
|
|
86
|
+
actions: 'setAmount',
|
|
87
|
+
},
|
|
88
|
+
CLEAR_AMOUNT: {
|
|
89
|
+
actions: 'clearAmount',
|
|
90
|
+
},
|
|
91
|
+
SUBMIT: {
|
|
92
|
+
target: 'submitting',
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
actions: {
|
|
98
|
+
setPaymentDetail: assign((context, event) => {
|
|
99
|
+
const paymentDetail = event.data
|
|
100
|
+
const payments = paymentDetail.filter((item) => item.category === context.currentCategory)
|
|
101
|
+
const currentPayment = payments[0]
|
|
102
|
+
const options = currentPayment.optional || []
|
|
103
|
+
|
|
104
|
+
return {
|
|
105
|
+
currentPayment,
|
|
106
|
+
options,
|
|
107
|
+
processing: currentPayment.processing?.[0],
|
|
108
|
+
}
|
|
109
|
+
}),
|
|
110
|
+
addAmount: assign((context, event) => {
|
|
111
|
+
return {
|
|
112
|
+
amount: parseFloat(`${context.amount || 0}`) + parseFloat(`${event.data}`),
|
|
113
|
+
}
|
|
114
|
+
}),
|
|
115
|
+
setAmount: assign((context, event) => {
|
|
116
|
+
return { amount: parseFloat(`${event.data}`) }
|
|
117
|
+
}),
|
|
118
|
+
clearAmount: assign((context, event) => {
|
|
119
|
+
return { amount: null }
|
|
120
|
+
}),
|
|
121
|
+
setProcessing: assign((context, event) => {
|
|
122
|
+
return {
|
|
123
|
+
processing: event.data,
|
|
124
|
+
}
|
|
125
|
+
}),
|
|
126
|
+
},
|
|
127
|
+
guards: {
|
|
128
|
+
isProcessing: (context, event) => {
|
|
129
|
+
return context.processing
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
services: {
|
|
133
|
+
fetchPaymentDetail: async (context, event) => {
|
|
134
|
+
return await request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' }))
|
|
135
|
+
},
|
|
136
|
+
accountInquiry: async (context, event) => {
|
|
137
|
+
const { from, title, content } = event.data
|
|
138
|
+
return await request.send(mailbox.sendMessage({ type: 'CUSTOMER', category: 'DEPOSIT', from, to: 'SYSTEM', title, content }))
|
|
139
|
+
},
|
|
140
|
+
submitDeposit: async (context, event) => {
|
|
141
|
+
const { currentPayment, amount } = context
|
|
142
|
+
return await request.send(
|
|
143
|
+
payment.submitDepositTransaction({
|
|
144
|
+
method: currentPayment.method,
|
|
145
|
+
amount,
|
|
146
|
+
})
|
|
147
|
+
)
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
}
|
|
151
|
+
)
|
|
152
|
+
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { assign, createMachine } from 'xstate'
|
|
2
2
|
import payment from '../../api/payment.js'
|
|
3
|
-
import {
|
|
3
|
+
import { max } from '../../util/index.js'
|
|
4
4
|
|
|
5
5
|
export default function (request, context) {
|
|
6
6
|
const { paymentDetail = [], promotion, selectedAmount } = context || {}
|
|
7
7
|
return createMachine(
|
|
8
8
|
{
|
|
9
9
|
id: 'qrcode_cash',
|
|
10
|
+
predictableActionArguments: true,
|
|
10
11
|
initial: 'loading',
|
|
11
12
|
context: {
|
|
12
13
|
currentCategory: 'loadcard',
|
|
@@ -34,7 +35,22 @@ export default function (request, context) {
|
|
|
34
35
|
debouncing: {
|
|
35
36
|
entry: 'clearCalculation',
|
|
36
37
|
after: {
|
|
37
|
-
1000: [
|
|
38
|
+
1000: [
|
|
39
|
+
{
|
|
40
|
+
target: 'calculating',
|
|
41
|
+
cond: (context, event) => {
|
|
42
|
+
const { selectedLoadcard, selectedAmount } = context
|
|
43
|
+
if (selectedLoadcard && selectedAmount) {
|
|
44
|
+
return selectedLoadcard.minimum <= selectedAmount && selectedAmount <= selectedLoadcard.maximum
|
|
45
|
+
} else {
|
|
46
|
+
return false
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
target: 'loaded',
|
|
52
|
+
},
|
|
53
|
+
],
|
|
38
54
|
},
|
|
39
55
|
},
|
|
40
56
|
calculating: {
|
|
@@ -81,7 +97,6 @@ export default function (request, context) {
|
|
|
81
97
|
target: '.debouncing',
|
|
82
98
|
actions: 'setPromotion',
|
|
83
99
|
internal: false,
|
|
84
|
-
cond: 'isPromotionChanged',
|
|
85
100
|
},
|
|
86
101
|
SELECT_LOADCARD: {
|
|
87
102
|
target: '.debouncing',
|
|
@@ -98,7 +113,7 @@ export default function (request, context) {
|
|
|
98
113
|
{
|
|
99
114
|
actions: {
|
|
100
115
|
setInitData: assign((context, event) => {
|
|
101
|
-
const { paymentDetail } = context
|
|
116
|
+
const { paymentDetail, selectedAmount, promotion } = context
|
|
102
117
|
const loadcards = paymentDetail.filter((element) => element.category === context.currentCategory && element.transferType === 'deposit')
|
|
103
118
|
const selectedLoadcard = loadcards[0]
|
|
104
119
|
return {
|
|
@@ -106,22 +121,30 @@ export default function (request, context) {
|
|
|
106
121
|
loadcards,
|
|
107
122
|
selectedLoadcard,
|
|
108
123
|
options: selectedLoadcard?.optional,
|
|
124
|
+
selectedAmount: max(promotion?.minimumAmount, selectedLoadcard?.minimum, selectedAmount, 0),
|
|
109
125
|
}
|
|
110
126
|
}),
|
|
111
127
|
setPromotion: assign((context, event) => {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
128
|
+
const { selectedAmount } = context
|
|
129
|
+
const promotion = event.data
|
|
130
|
+
const loadcards = context.loadcards
|
|
131
|
+
const selectedLoadcard = loadcards[0]
|
|
115
132
|
return {
|
|
116
|
-
promotion
|
|
133
|
+
promotion,
|
|
134
|
+
loadcards,
|
|
135
|
+
selectedLoadcard,
|
|
136
|
+
options: selectedLoadcard?.optional,
|
|
137
|
+
selectedAmount: max(promotion.minimumAmount, selectedLoadcard?.minimum, selectedAmount, 0),
|
|
117
138
|
calculation: null,
|
|
118
139
|
}
|
|
119
140
|
}),
|
|
120
141
|
setLoadcard: assign((context, event) => {
|
|
142
|
+
const { promotion, selectedAmount } = context
|
|
121
143
|
const selectedLoadcard = event.data
|
|
122
144
|
return {
|
|
123
145
|
selectedLoadcard,
|
|
124
146
|
options: selectedLoadcard.optional,
|
|
147
|
+
selectedAmount: max(promotion.minimumAmount, selectedAmount, 0),
|
|
125
148
|
calculation: null,
|
|
126
149
|
}
|
|
127
150
|
}),
|
|
@@ -162,12 +185,7 @@ export default function (request, context) {
|
|
|
162
185
|
}
|
|
163
186
|
}),
|
|
164
187
|
},
|
|
165
|
-
guards: {
|
|
166
|
-
isPromotionChanged: (context, event) => {
|
|
167
|
-
return event.data?.promotionsNo !== context.promotion?.promotionsNo
|
|
168
|
-
},
|
|
169
|
-
isCalculable: ({ selectedLoadcard, selectedAmount }) => isAmountInRange(selectedAmount, selectedLoadcard),
|
|
170
|
-
},
|
|
188
|
+
guards: {},
|
|
171
189
|
services: {
|
|
172
190
|
fetchCalculation: async (context, event) => {
|
|
173
191
|
const { selectedLoadcard, selectedAmount, promotion } = context
|