@jetthai/cuora 1.1.66-sabai-6 → 1.1.67
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/CHANGELOG.md +6 -12
- package/dist/bundle.mjs +5524 -11512
- package/package.json +4 -4
- package/src/api/payment.js +2 -0
- package/src/lib/fingerprint.js +5779 -0
- package/src/machine/activity/activity.js +1 -1
- package/src/machine/deposit/crypto.js +36 -19
- package/src/machine/deposit/crypto_button.js +103 -126
- package/src/machine/deposit/direct.js +69 -7
- package/src/machine/deposit/float.js +94 -27
- package/src/machine/deposit/loadcard_vn.js +114 -146
- package/src/machine/deposit/manual_vn.js +39 -7
- package/src/machine/deposit/qrcode_v2.js +155 -171
- package/src/machine/deposit/vpay.js +89 -26
- package/src/machine/game_favorite_v2.js +14 -23
- package/src/machine/game_v2_1.js +20 -34
- package/src/machine/promotions.js +1 -1
- package/src/machine/side_v2.js +11 -26
- package/src/util/deviceToken.js +6 -9
- package/src/lib/fingerprint_v3_11_5.js +0 -11896
|
@@ -85,7 +85,7 @@ export default function (request) {
|
|
|
85
85
|
setActivityList: assign((context, event) => {
|
|
86
86
|
const noRedActivity = [2, 4, 13, 20, 90, 91, 92]
|
|
87
87
|
const { uidSite } = context
|
|
88
|
-
let list = event.data
|
|
88
|
+
let list = JSON.parse(JSON.stringify(event.data))
|
|
89
89
|
list.forEach((activity) => {
|
|
90
90
|
const storageUnread = localStorage.getItem(`unread_${activity.activityNo}_${uidSite}`)
|
|
91
91
|
if (noRedActivity.includes(activity.activityType)) {
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { assign, createMachine } from 'xstate'
|
|
2
2
|
import padStart from 'lodash/padStart.js'
|
|
3
3
|
import payment from '@jetthai/cuora/src/api/payment.js'
|
|
4
|
-
|
|
5
|
-
// const padStart = require('lodash/padStart')
|
|
4
|
+
import common from '../../api/common.js'
|
|
6
5
|
|
|
7
6
|
export default function (request) {
|
|
7
|
+
const { appSecret } = request.config
|
|
8
8
|
return createMachine(
|
|
9
9
|
{
|
|
10
10
|
id: 'crypto',
|
|
11
11
|
initial: 'loading',
|
|
12
12
|
context: {
|
|
13
|
+
siteConfig: null,
|
|
13
14
|
paymentDetails: [],
|
|
14
15
|
|
|
15
16
|
channels: [],
|
|
@@ -26,14 +27,17 @@ export default function (request) {
|
|
|
26
27
|
|
|
27
28
|
calculation: null,
|
|
28
29
|
result: null,
|
|
30
|
+
|
|
31
|
+
// use for wallet mode 4
|
|
32
|
+
promotion: null,
|
|
29
33
|
},
|
|
30
34
|
states: {
|
|
31
35
|
loading: {
|
|
32
36
|
invoke: {
|
|
33
|
-
src: '
|
|
37
|
+
src: 'fetchInitData',
|
|
34
38
|
onDone: {
|
|
35
39
|
target: 'idle',
|
|
36
|
-
actions: '
|
|
40
|
+
actions: 'setInitData',
|
|
37
41
|
},
|
|
38
42
|
onError: {
|
|
39
43
|
target: '#crypto.fail',
|
|
@@ -50,13 +54,6 @@ export default function (request) {
|
|
|
50
54
|
},
|
|
51
55
|
},
|
|
52
56
|
},
|
|
53
|
-
// calculable: {
|
|
54
|
-
// on: {
|
|
55
|
-
// CALCULATE: {
|
|
56
|
-
// target: 'calculating',
|
|
57
|
-
// },
|
|
58
|
-
// },
|
|
59
|
-
// },
|
|
60
57
|
calculating: {
|
|
61
58
|
invoke: {
|
|
62
59
|
src: 'fetchCalculation',
|
|
@@ -70,6 +67,20 @@ export default function (request) {
|
|
|
70
67
|
},
|
|
71
68
|
},
|
|
72
69
|
calculated: {
|
|
70
|
+
on: {
|
|
71
|
+
SUBMIT: [
|
|
72
|
+
{
|
|
73
|
+
target: 'pending',
|
|
74
|
+
cond: 'isDoubleWalletMode',
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
target: 'submitting',
|
|
78
|
+
cond: 'isSubmittable',
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
pending: {
|
|
73
84
|
on: {
|
|
74
85
|
SUBMIT: {
|
|
75
86
|
target: 'submitting',
|
|
@@ -112,10 +123,6 @@ export default function (request) {
|
|
|
112
123
|
target: '.idle',
|
|
113
124
|
actions: ['setAmount', 'clearCalculation'],
|
|
114
125
|
},
|
|
115
|
-
// CLEAR_CALCULATION: {
|
|
116
|
-
// target: '.idle',
|
|
117
|
-
// actions: 'clearCalculation',
|
|
118
|
-
// },
|
|
119
126
|
CALCULATE: {
|
|
120
127
|
target: '.debouncing',
|
|
121
128
|
actions: 'clearCalculation',
|
|
@@ -124,8 +131,9 @@ export default function (request) {
|
|
|
124
131
|
},
|
|
125
132
|
{
|
|
126
133
|
actions: {
|
|
127
|
-
|
|
128
|
-
const
|
|
134
|
+
setInitData: assign((context, event) => {
|
|
135
|
+
const { siteConfig, paymentDetail } = event.data
|
|
136
|
+
const cryptos = paymentDetail.map?.((crypto) => ({ ...crypto, label: crypto.channel, value: crypto.method, icon: crypto.channel })) || []
|
|
129
137
|
const currentPayment = cryptos.find((element) => element.category === context.currentCategory)
|
|
130
138
|
const channels = cryptos.map((item, i) => ({ ...item, label: `Channel ${padStart(String(i + 1), 2, '0')}`, icon: 'channel' }))
|
|
131
139
|
const defaultNetworks =
|
|
@@ -137,6 +145,7 @@ export default function (request) {
|
|
|
137
145
|
}
|
|
138
146
|
}) || []
|
|
139
147
|
return {
|
|
148
|
+
siteConfig,
|
|
140
149
|
channels,
|
|
141
150
|
cryptos,
|
|
142
151
|
networks: defaultNetworks,
|
|
@@ -221,6 +230,9 @@ export default function (request) {
|
|
|
221
230
|
}),
|
|
222
231
|
},
|
|
223
232
|
guards: {
|
|
233
|
+
isDoubleWalletMode: (context, event) => {
|
|
234
|
+
return context.siteConfig?.walletMode === '4'
|
|
235
|
+
},
|
|
224
236
|
isCalculable: (context, event) => {
|
|
225
237
|
const {
|
|
226
238
|
selectedCrypto,
|
|
@@ -236,8 +248,13 @@ export default function (request) {
|
|
|
236
248
|
},
|
|
237
249
|
},
|
|
238
250
|
services: {
|
|
239
|
-
|
|
240
|
-
|
|
251
|
+
fetchInitData: async (context, event) => {
|
|
252
|
+
const [{ config }, paymentDetail = []] = await Promise.all([
|
|
253
|
+
request.send(common.getConfig({ appSecret })),
|
|
254
|
+
request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' })),
|
|
255
|
+
])
|
|
256
|
+
const siteConfig = JSON.parse(window.atob(config))
|
|
257
|
+
return { siteConfig, paymentDetail }
|
|
241
258
|
},
|
|
242
259
|
fetchCalculation: async (context, event) => {
|
|
243
260
|
const { selectedCrypto, amount } = context
|
|
@@ -30,14 +30,18 @@ export default function (request) {
|
|
|
30
30
|
result: null,
|
|
31
31
|
|
|
32
32
|
grandTotalEnable: 1,
|
|
33
|
+
|
|
34
|
+
// use for wallet mode 4
|
|
35
|
+
promotion: null,
|
|
36
|
+
bonusPreviewData: [],
|
|
33
37
|
},
|
|
34
38
|
states: {
|
|
35
39
|
loading: {
|
|
36
40
|
invoke: {
|
|
37
41
|
src: 'fetchInitData',
|
|
38
42
|
onDone: {
|
|
39
|
-
target: '
|
|
40
|
-
actions:
|
|
43
|
+
target: 'loaded',
|
|
44
|
+
actions: 'setInitData',
|
|
41
45
|
},
|
|
42
46
|
onError: {
|
|
43
47
|
target: 'fail',
|
|
@@ -45,116 +49,31 @@ export default function (request) {
|
|
|
45
49
|
},
|
|
46
50
|
},
|
|
47
51
|
checking: {
|
|
48
|
-
always: [
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
on: {
|
|
56
|
-
SET_CHANNEL: {
|
|
57
|
-
actions: 'setChannel',
|
|
58
|
-
},
|
|
59
|
-
SET_CRYPTO: {
|
|
60
|
-
actions: 'setCrypto',
|
|
61
|
-
},
|
|
62
|
-
SET_NETWORK: {
|
|
63
|
-
actions: 'setNetwork',
|
|
64
|
-
},
|
|
65
|
-
SET_ADDRESS: {
|
|
66
|
-
actions: 'setAddress',
|
|
67
|
-
},
|
|
68
|
-
CONFIRM: {
|
|
69
|
-
target: 'selecting',
|
|
70
|
-
cond: 'isConfirmable',
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
selecting: {
|
|
75
|
-
entry: 'reset',
|
|
76
|
-
on: {
|
|
77
|
-
SELECT_AMOUNT: [
|
|
78
|
-
{
|
|
79
|
-
actions: 'addAmount',
|
|
80
|
-
cond: (context, event) => context.grandTotalEnable === 1,
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
actions: 'setAmount',
|
|
84
|
-
},
|
|
85
|
-
],
|
|
86
|
-
KEY_IN: {
|
|
87
|
-
actions: 'setAmount',
|
|
88
|
-
},
|
|
89
|
-
SUBMIT: {
|
|
90
|
-
target: 'debouncing',
|
|
91
|
-
},
|
|
92
|
-
BACK: {
|
|
93
|
-
target: 'loaded',
|
|
94
|
-
},
|
|
95
|
-
CLEAR_ALL: {
|
|
96
|
-
actions: 'reset',
|
|
97
|
-
},
|
|
52
|
+
always: [
|
|
53
|
+
{
|
|
54
|
+
target: 'fetching',
|
|
55
|
+
cond: (context, event) => {
|
|
56
|
+
const { siteConfig = {}, promotion = {} } = context
|
|
57
|
+
const { walletMode = '', bonusPreviewEnable = '0' } = siteConfig
|
|
58
|
+
return walletMode === '4' && bonusPreviewEnable === '1' && promotion.activityNo != 'none'
|
|
98
59
|
},
|
|
99
60
|
},
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
target: 'debouncing',
|
|
110
|
-
actions: 'setAmount',
|
|
111
|
-
},
|
|
112
|
-
],
|
|
113
|
-
KEY_IN: {
|
|
114
|
-
target: 'debouncing',
|
|
115
|
-
actions: 'setAmount',
|
|
116
|
-
},
|
|
117
|
-
BACK: {
|
|
118
|
-
target: 'loaded',
|
|
119
|
-
},
|
|
120
|
-
CLEAR_ALL: {
|
|
121
|
-
actions: 'reset',
|
|
122
|
-
},
|
|
123
|
-
},
|
|
124
|
-
after: {
|
|
125
|
-
1000: {
|
|
126
|
-
target: 'calculating',
|
|
127
|
-
},
|
|
128
|
-
},
|
|
129
|
-
},
|
|
130
|
-
calculating: {
|
|
131
|
-
invoke: {
|
|
132
|
-
src: 'fetchCalculation',
|
|
133
|
-
onDone: {
|
|
134
|
-
target: 'submitting',
|
|
135
|
-
actions: 'setCalculation',
|
|
136
|
-
},
|
|
137
|
-
onError: {
|
|
138
|
-
target: 'selecting',
|
|
139
|
-
actions: 'reset',
|
|
140
|
-
},
|
|
141
|
-
},
|
|
61
|
+
{ target: 'loaded' },
|
|
62
|
+
],
|
|
63
|
+
},
|
|
64
|
+
fetching: {
|
|
65
|
+
invoke: {
|
|
66
|
+
src: 'fetchBonusPreview',
|
|
67
|
+
onDone: {
|
|
68
|
+
target: 'loaded',
|
|
69
|
+
actions: 'setBonusPreview',
|
|
142
70
|
},
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
src: 'submitDeposit',
|
|
146
|
-
onDone: {
|
|
147
|
-
target: '#crypro_button.submitted',
|
|
148
|
-
actions: 'setResult',
|
|
149
|
-
},
|
|
150
|
-
onError: {
|
|
151
|
-
target: 'selecting',
|
|
152
|
-
},
|
|
153
|
-
},
|
|
71
|
+
onError: {
|
|
72
|
+
target: 'loaded',
|
|
154
73
|
},
|
|
155
74
|
},
|
|
156
75
|
},
|
|
157
|
-
|
|
76
|
+
loaded: {
|
|
158
77
|
on: {
|
|
159
78
|
SET_CHANNEL: {
|
|
160
79
|
actions: 'setChannel',
|
|
@@ -181,20 +100,45 @@ export default function (request) {
|
|
|
181
100
|
SELECT_AMOUNT: [
|
|
182
101
|
{
|
|
183
102
|
target: 'debouncing',
|
|
103
|
+
actions: 'setAmount',
|
|
104
|
+
cond: 'isDoubleWalletMode',
|
|
105
|
+
},
|
|
106
|
+
{
|
|
184
107
|
actions: 'addAmount',
|
|
185
|
-
cond: (context, event) => context.grandTotalEnable === 1,
|
|
108
|
+
cond: (context, event) => context.siteConfig?.walletMode === '2' && context.grandTotalEnable === 1,
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
actions: 'setAmount',
|
|
112
|
+
cond: (context, event) => context.siteConfig?.walletMode === '2',
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
target: 'debouncing',
|
|
116
|
+
actions: 'addAmount',
|
|
117
|
+
cond: 'isGrandTotalEnable',
|
|
186
118
|
},
|
|
187
119
|
{
|
|
188
120
|
target: 'debouncing',
|
|
189
121
|
actions: 'setAmount',
|
|
190
122
|
},
|
|
191
123
|
],
|
|
192
|
-
KEY_IN:
|
|
124
|
+
KEY_IN: [
|
|
125
|
+
{
|
|
126
|
+
actions: 'setAmount',
|
|
127
|
+
cond: 'isFreeWalletMode',
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
target: 'debouncing',
|
|
131
|
+
actions: 'setAmount',
|
|
132
|
+
},
|
|
133
|
+
],
|
|
134
|
+
SUBMIT: {
|
|
193
135
|
target: 'debouncing',
|
|
194
|
-
actions: 'setAmount',
|
|
195
136
|
},
|
|
196
137
|
BACK: {
|
|
197
|
-
target: '
|
|
138
|
+
target: 'loaded',
|
|
139
|
+
},
|
|
140
|
+
CLEAR_ALL: {
|
|
141
|
+
actions: 'reset',
|
|
198
142
|
},
|
|
199
143
|
},
|
|
200
144
|
},
|
|
@@ -204,7 +148,7 @@ export default function (request) {
|
|
|
204
148
|
{
|
|
205
149
|
target: 'debouncing',
|
|
206
150
|
actions: 'addAmount',
|
|
207
|
-
cond:
|
|
151
|
+
cond: 'isGrandTotalEnable',
|
|
208
152
|
},
|
|
209
153
|
{
|
|
210
154
|
target: 'debouncing',
|
|
@@ -225,10 +169,17 @@ export default function (request) {
|
|
|
225
169
|
calculating: {
|
|
226
170
|
invoke: {
|
|
227
171
|
src: 'fetchCalculation',
|
|
228
|
-
onDone:
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
172
|
+
onDone: [
|
|
173
|
+
{
|
|
174
|
+
target: 'submitting',
|
|
175
|
+
actions: 'setCalculation',
|
|
176
|
+
cond: 'isFreeWalletMode',
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
target: 'calculated',
|
|
180
|
+
actions: 'setCalculation',
|
|
181
|
+
},
|
|
182
|
+
],
|
|
232
183
|
onError: {
|
|
233
184
|
target: 'selecting',
|
|
234
185
|
actions: 'reset',
|
|
@@ -241,7 +192,7 @@ export default function (request) {
|
|
|
241
192
|
{
|
|
242
193
|
target: 'debouncing',
|
|
243
194
|
actions: 'addAmount',
|
|
244
|
-
cond:
|
|
195
|
+
cond: 'isGrandTotalEnable',
|
|
245
196
|
},
|
|
246
197
|
{
|
|
247
198
|
target: 'debouncing',
|
|
@@ -280,6 +231,11 @@ export default function (request) {
|
|
|
280
231
|
},
|
|
281
232
|
submitted: {},
|
|
282
233
|
},
|
|
234
|
+
on: {
|
|
235
|
+
SET_PROMOTION: {
|
|
236
|
+
actions: 'setPromotion',
|
|
237
|
+
},
|
|
238
|
+
},
|
|
283
239
|
},
|
|
284
240
|
{
|
|
285
241
|
actions: {
|
|
@@ -290,7 +246,7 @@ export default function (request) {
|
|
|
290
246
|
}
|
|
291
247
|
}),
|
|
292
248
|
setInitData: assign((context, event) => {
|
|
293
|
-
const { paymentDetail } = event.data
|
|
249
|
+
const { siteConfig, paymentDetail } = event.data
|
|
294
250
|
const cryptos = paymentDetail?.map?.((crypto) => ({ ...crypto, label: crypto.channel, value: crypto.method, icon: crypto.channel })) || []
|
|
295
251
|
const currentPayment = cryptos.find((element) => element.category === context.currentCategory)
|
|
296
252
|
const channels = cryptos.map((item, i) => ({ ...item, label: `Channel ${padStart(String(i + 1), 2, '0')}`, icon: 'channel' }))
|
|
@@ -304,6 +260,7 @@ export default function (request) {
|
|
|
304
260
|
}) || []
|
|
305
261
|
const options = cryptos[0].optional
|
|
306
262
|
return {
|
|
263
|
+
siteConfig,
|
|
307
264
|
channels,
|
|
308
265
|
cryptos,
|
|
309
266
|
networks: defaultNetworks,
|
|
@@ -315,12 +272,6 @@ export default function (request) {
|
|
|
315
272
|
options,
|
|
316
273
|
}
|
|
317
274
|
}),
|
|
318
|
-
preset: assign((context, event) => {
|
|
319
|
-
const { siteConfig } = event.data
|
|
320
|
-
return {
|
|
321
|
-
siteConfig,
|
|
322
|
-
}
|
|
323
|
-
}),
|
|
324
275
|
setChannel: assign((context, event) => {
|
|
325
276
|
const { cryptos } = context
|
|
326
277
|
const selectedCrypto = cryptos.find((crypto) => crypto.method === event.data.value)
|
|
@@ -372,6 +323,11 @@ export default function (request) {
|
|
|
372
323
|
setNetwork: assign((context, event) => {
|
|
373
324
|
return { selectedNetwork: event.data }
|
|
374
325
|
}),
|
|
326
|
+
setBonusPreview: assign((context, event) => {
|
|
327
|
+
return {
|
|
328
|
+
bonusPreviewData: event.data.bonus,
|
|
329
|
+
}
|
|
330
|
+
}),
|
|
375
331
|
addAmount: assign((context, event) => {
|
|
376
332
|
return { selectedAmount: (context.selectedAmount || 0) + event.data }
|
|
377
333
|
}),
|
|
@@ -398,11 +354,23 @@ export default function (request) {
|
|
|
398
354
|
result: event.data,
|
|
399
355
|
}
|
|
400
356
|
}),
|
|
357
|
+
setPromotion: assign((context, event) => {
|
|
358
|
+
const promotion = event.data
|
|
359
|
+
return {
|
|
360
|
+
promotion,
|
|
361
|
+
}
|
|
362
|
+
}),
|
|
401
363
|
},
|
|
402
364
|
guards: {
|
|
403
|
-
|
|
365
|
+
isFreeWalletMode: (context, event) => {
|
|
404
366
|
return context.siteConfig?.walletMode === '2'
|
|
405
367
|
},
|
|
368
|
+
isDoubleWalletMode: (context, event) => {
|
|
369
|
+
return context.siteConfig?.walletMode === '4'
|
|
370
|
+
},
|
|
371
|
+
isGrandTotalEnable: (context, event) => {
|
|
372
|
+
return context.grandTotalEnable === 1
|
|
373
|
+
},
|
|
406
374
|
isConfirmable: (context, event) => {
|
|
407
375
|
const { selectedCrypto, selectedNetwork } = context
|
|
408
376
|
return selectedCrypto && selectedNetwork
|
|
@@ -421,18 +389,26 @@ export default function (request) {
|
|
|
421
389
|
const siteConfig = JSON.parse(window.atob(config))
|
|
422
390
|
return { siteConfig, paymentDetail }
|
|
423
391
|
},
|
|
392
|
+
fetchBonusPreview: async (context, event) => {
|
|
393
|
+
const { selectedCrypto, promotion } = context
|
|
394
|
+
return await request.send({
|
|
395
|
+
paymentMethod: selectedCrypto.method,
|
|
396
|
+
promotionsNo: promotion?.activityNo,
|
|
397
|
+
})
|
|
398
|
+
},
|
|
424
399
|
fetchCalculation: async (context, event) => {
|
|
425
|
-
const { selectedCrypto, selectedAmount } = context
|
|
400
|
+
const { selectedCrypto, selectedAmount, promotion } = context
|
|
426
401
|
return await request.send(
|
|
427
402
|
payment.getDepositExpectedResult({
|
|
428
403
|
method: selectedCrypto.method,
|
|
429
404
|
amount: selectedAmount,
|
|
430
405
|
cryptoCurrency: selectedCrypto.channel,
|
|
406
|
+
promotionsNo: promotion?.activityNo,
|
|
431
407
|
})
|
|
432
408
|
)
|
|
433
409
|
},
|
|
434
410
|
submitDeposit: async (context, event) => {
|
|
435
|
-
const { selectedCrypto, selectedNetwork, calculation, sourceAddress } = context
|
|
411
|
+
const { selectedCrypto, selectedNetwork, calculation, sourceAddress, promotion } = context
|
|
436
412
|
return await request.send(
|
|
437
413
|
payment.submitDepositTransactionCrypto({
|
|
438
414
|
method: selectedCrypto.method,
|
|
@@ -440,6 +416,7 @@ export default function (request) {
|
|
|
440
416
|
cryptoCurrency: selectedCrypto.channel,
|
|
441
417
|
cryptoNetwork: selectedNetwork.value,
|
|
442
418
|
sourceAddress: sourceAddress,
|
|
419
|
+
promotionsNo: promotion?.activityNo,
|
|
443
420
|
})
|
|
444
421
|
)
|
|
445
422
|
},
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { assign, createMachine } from 'xstate'
|
|
2
2
|
import payment from '../../api/payment.js'
|
|
3
|
+
import common from '../../api/common.js'
|
|
3
4
|
|
|
4
5
|
export default function (request) {
|
|
6
|
+
const { appSecret } = request.config
|
|
5
7
|
return createMachine(
|
|
6
8
|
{
|
|
7
9
|
id: 'direct',
|
|
8
10
|
initial: 'loading',
|
|
9
11
|
context: {
|
|
10
|
-
|
|
12
|
+
siteConfig: null,
|
|
13
|
+
paymentDetail: [],
|
|
11
14
|
directs: [],
|
|
12
15
|
currentDirect: null,
|
|
13
16
|
banks: [],
|
|
@@ -53,6 +56,10 @@ export default function (request) {
|
|
|
53
56
|
},
|
|
54
57
|
promotion: {
|
|
55
58
|
always: [
|
|
59
|
+
{
|
|
60
|
+
target: 'loaded',
|
|
61
|
+
cond: 'isDoubleWalletMode',
|
|
62
|
+
},
|
|
56
63
|
{
|
|
57
64
|
target: 'calculating',
|
|
58
65
|
actions: 'setPromotionDefaultAmount',
|
|
@@ -79,15 +86,61 @@ export default function (request) {
|
|
|
79
86
|
actions: 'clearCalculation',
|
|
80
87
|
},
|
|
81
88
|
CALCULATE: {
|
|
82
|
-
target: '
|
|
83
|
-
cond: 'isCalculable',
|
|
89
|
+
target: 'debouncing',
|
|
84
90
|
},
|
|
91
|
+
SUBMIT: [
|
|
92
|
+
{
|
|
93
|
+
target: 'pending',
|
|
94
|
+
cond: (context, event) => context.siteConfig?.walletMode === '4' && !!context.calculation,
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
target: 'submitting',
|
|
98
|
+
cond: 'isSubmittable',
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
pending: {
|
|
104
|
+
on: {
|
|
85
105
|
SUBMIT: {
|
|
86
106
|
target: 'submitting',
|
|
87
107
|
cond: 'isSubmittable',
|
|
88
108
|
},
|
|
89
109
|
},
|
|
90
110
|
},
|
|
111
|
+
debouncing: {
|
|
112
|
+
on: {
|
|
113
|
+
SELECT_DIRECT: {
|
|
114
|
+
actions: ['setDirect', 'reset'],
|
|
115
|
+
target: 'loading.fetching',
|
|
116
|
+
},
|
|
117
|
+
SELECT_BANK: {
|
|
118
|
+
actions: 'setSelectedBank',
|
|
119
|
+
},
|
|
120
|
+
SET_AMOUNT: {
|
|
121
|
+
actions: ['setAmount', 'clearCalculation'],
|
|
122
|
+
},
|
|
123
|
+
CLEAR_CALCULATION: {
|
|
124
|
+
actions: 'clearCalculation',
|
|
125
|
+
},
|
|
126
|
+
CALCULATE: {
|
|
127
|
+
target: 'debouncing',
|
|
128
|
+
},
|
|
129
|
+
SUBMIT: [
|
|
130
|
+
{
|
|
131
|
+
target: 'pending',
|
|
132
|
+
cond: (context, event) => context.siteConfig?.walletMode === '4' && !!context.calculation,
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
target: 'submitting',
|
|
136
|
+
cond: 'isSubmittable',
|
|
137
|
+
},
|
|
138
|
+
],
|
|
139
|
+
},
|
|
140
|
+
after: {
|
|
141
|
+
1000: [{ target: 'calculating', cond: 'isCalculable' }, { target: 'loaded' }],
|
|
142
|
+
},
|
|
143
|
+
},
|
|
91
144
|
calculating: {
|
|
92
145
|
invoke: {
|
|
93
146
|
src: 'fetchCalculation',
|
|
@@ -132,11 +185,12 @@ export default function (request) {
|
|
|
132
185
|
}
|
|
133
186
|
}),
|
|
134
187
|
setInitData: assign((context, event) => {
|
|
135
|
-
const
|
|
136
|
-
const directs =
|
|
188
|
+
const { siteConfig, paymentDetail } = event.data
|
|
189
|
+
const directs = paymentDetail.filter((element) => element.category === context.currentCategory)
|
|
137
190
|
|
|
138
191
|
return {
|
|
139
|
-
|
|
192
|
+
siteConfig,
|
|
193
|
+
paymentDetail,
|
|
140
194
|
directs,
|
|
141
195
|
currentDirect: directs[0],
|
|
142
196
|
currentMethod: directs[0]?.method,
|
|
@@ -193,6 +247,9 @@ export default function (request) {
|
|
|
193
247
|
}),
|
|
194
248
|
},
|
|
195
249
|
guards: {
|
|
250
|
+
isDoubleWalletMode: (context, event) => {
|
|
251
|
+
return context.siteConfig?.walletMode === '4'
|
|
252
|
+
},
|
|
196
253
|
isCalculable: (context, event) => {
|
|
197
254
|
const {
|
|
198
255
|
amount,
|
|
@@ -211,7 +268,12 @@ export default function (request) {
|
|
|
211
268
|
},
|
|
212
269
|
services: {
|
|
213
270
|
fetchInitData: async (context, event) => {
|
|
214
|
-
|
|
271
|
+
const [{ config }, paymentDetail = []] = await Promise.all([
|
|
272
|
+
request.send(common.getConfig({ appSecret })),
|
|
273
|
+
request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' })),
|
|
274
|
+
])
|
|
275
|
+
const siteConfig = JSON.parse(window.atob(config))
|
|
276
|
+
return { siteConfig, paymentDetail }
|
|
215
277
|
},
|
|
216
278
|
fetchBanksList: async (context, event) => {
|
|
217
279
|
const { currentDirect } = context
|