@jetthai/cuora 1.1.468-dev.1 → 1.1.468
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/.claude/commands/sync-ai-prompts.md +1 -88
- package/.claude/settings.local.json +1 -3
- package/.github/copilot-instructions.md +57 -64
- package/.husky/post-checkout +3 -3
- package/.husky/pre-push +1 -1
- package/.prettierignore +1 -2
- package/AGENTS.md +57 -64
- package/AI_PROMPT_SOURCE.md +57 -64
- package/CHANGELOG.md +2 -184
- package/CLAUDE.md +57 -64
- package/GEMINI.md +57 -64
- package/README.md +12 -11
- package/package.json +1 -1
- package/scripts/auto-version.js +0 -1
- package/scripts/branch-auto-npm-publish.js +2 -9
- package/src/api/account.js +1 -0
- package/src/api/activity.js +37 -0
- package/src/api/auth.js +31 -0
- package/src/api/game.js +10 -0
- package/src/api/payment.js +52 -0
- package/src/api/user.js +22 -4
- package/src/index.js +2 -2
- package/src/machine/activity/activity.js +209 -0
- package/src/machine/activity/activity_cash.js +15 -23
- 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/auth.js +69 -37
- package/src/machine/auth_otp_v2.js +177 -0
- package/src/machine/auth_otp_v3.js +3 -0
- package/src/machine/bank_binding_amb.js +146 -0
- package/src/machine/bonus.js +76 -0
- package/src/machine/common.js +55 -0
- package/src/machine/deposit/amb.js +93 -0
- package/src/machine/deposit/crypto_bank.js +330 -0
- package/src/machine/deposit/crypto_qrcode.js +148 -0
- package/src/machine/deposit/crypto_way.js +252 -0
- package/src/machine/deposit/deposit_fc.js +272 -0
- package/src/machine/deposit/direct.js +310 -0
- package/src/machine/deposit/float.js +375 -0
- package/src/machine/deposit/index.js +28 -0
- package/src/machine/deposit/krway.js +151 -0
- package/src/machine/deposit/loadcard_vn.js +351 -0
- package/src/machine/deposit/manual_cash.js +8 -0
- package/src/machine/deposit/manual_vn.js +458 -0
- package/src/machine/deposit/qrcode_v2.js +338 -0
- package/src/machine/deposit/usdt.js +144 -0
- package/src/machine/deposit/virtual_bank_vn.js +269 -0
- package/src/machine/deposit/vpay.js +368 -0
- package/src/machine/game_hot_new.js +79 -0
- package/src/machine/game_info.js +12 -1
- package/src/machine/game_replay.js +46 -0
- package/src/machine/game_search_v2.js +401 -0
- package/src/machine/game_v2_1.js +89 -1
- package/src/machine/honor_board.js +132 -0
- package/src/machine/inbox.js +12 -0
- package/src/machine/index.js +32 -0
- 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/reward.js +255 -0
- package/src/machine/reward_cash.js +39 -0
- package/src/machine/reward_fc.js +98 -0
- package/src/machine/side.js +154 -0
- package/src/machine/side_v2.js +211 -0
- package/src/machine/user_reset_password.js +13 -0
- package/src/machine/user_sign_up.js +1 -6
- package/src/machine/vip_table.js +57 -0
- package/src/machine/websocket.js +4 -0
- 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 +223 -0
- package/src/machine/withdraw/withdraw_manual.js +536 -0
- package/src/request/request.js +28 -0
- package/src/util/constant.js +1 -0
- package/src/util/index.js +4 -1
- package/src/util/math.js +4 -0
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
import { assign, createMachine } from 'xstate'
|
|
2
|
+
import payment from '../../api/payment.js'
|
|
3
|
+
import user from '../../api/user.js'
|
|
4
|
+
import api from '../../api/payment.js'
|
|
5
|
+
|
|
6
|
+
export default function (request, context) {
|
|
7
|
+
const { paymentDetail = [] } = context || {}
|
|
8
|
+
return createMachine(
|
|
9
|
+
{
|
|
10
|
+
id: 'withdraw_crypto_cash',
|
|
11
|
+
initial: 'loading',
|
|
12
|
+
context: {
|
|
13
|
+
paymentDetail,
|
|
14
|
+
withdrawRule: null,
|
|
15
|
+
selectedCrypto: null,
|
|
16
|
+
networks: [],
|
|
17
|
+
selectedNetwork: null,
|
|
18
|
+
address: '',
|
|
19
|
+
selectedAmount: null,
|
|
20
|
+
calculation: null,
|
|
21
|
+
processing: null,
|
|
22
|
+
|
|
23
|
+
// otp
|
|
24
|
+
requestId: null,
|
|
25
|
+
status: null,
|
|
26
|
+
target: null,
|
|
27
|
+
ttl: null,
|
|
28
|
+
},
|
|
29
|
+
states: {
|
|
30
|
+
loading: {
|
|
31
|
+
invoke: {
|
|
32
|
+
src: 'fetchInitData',
|
|
33
|
+
onDone: {
|
|
34
|
+
target: 'checking',
|
|
35
|
+
actions: 'setInitData',
|
|
36
|
+
},
|
|
37
|
+
onError: {
|
|
38
|
+
target: 'loaded',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
checking: {
|
|
43
|
+
always: [{ target: 'submitted', cond: 'isProcessing' }, { target: 'loaded' }],
|
|
44
|
+
},
|
|
45
|
+
loaded: {},
|
|
46
|
+
debouncing: {
|
|
47
|
+
after: {
|
|
48
|
+
1000: [
|
|
49
|
+
{
|
|
50
|
+
target: 'calculating',
|
|
51
|
+
cond: 'isCalculable',
|
|
52
|
+
},
|
|
53
|
+
{ target: 'loaded' },
|
|
54
|
+
],
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
calculating: {
|
|
58
|
+
entry: 'resetCharge',
|
|
59
|
+
invoke: {
|
|
60
|
+
src: 'fetchCalculation',
|
|
61
|
+
onDone: {
|
|
62
|
+
target: 'calculated',
|
|
63
|
+
actions: 'setCalculation',
|
|
64
|
+
},
|
|
65
|
+
onError: {
|
|
66
|
+
target: 'calculated',
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
calculated: {
|
|
71
|
+
on: {
|
|
72
|
+
SUBMIT: [
|
|
73
|
+
{
|
|
74
|
+
target: 'submitting',
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
submitting: {
|
|
80
|
+
invoke: {
|
|
81
|
+
src: 'submitWithdraw',
|
|
82
|
+
onDone: [
|
|
83
|
+
{
|
|
84
|
+
target: 'otp',
|
|
85
|
+
actions: 'setOtp',
|
|
86
|
+
cond: 'isOtpRequired',
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
target: 'submitted',
|
|
90
|
+
actions: 'setProcessing',
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
onError: {
|
|
94
|
+
target: 'loaded',
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
submitted: {},
|
|
99
|
+
otp: {
|
|
100
|
+
type: 'parallel',
|
|
101
|
+
states: {
|
|
102
|
+
countdown: {
|
|
103
|
+
after: {
|
|
104
|
+
1000: {
|
|
105
|
+
target: 'countdown',
|
|
106
|
+
actions: 'decreaseTtl',
|
|
107
|
+
cond: (context) => context.ttl > 0,
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
verification: {
|
|
112
|
+
initial: 'idle',
|
|
113
|
+
states: {
|
|
114
|
+
idle: {
|
|
115
|
+
on: {
|
|
116
|
+
ACKNOWLEDGE: {
|
|
117
|
+
target: 'acknowledging',
|
|
118
|
+
},
|
|
119
|
+
RESET_OTP: {
|
|
120
|
+
target: 'reset',
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
acknowledging: {
|
|
125
|
+
invoke: {
|
|
126
|
+
src: 'acknowledge',
|
|
127
|
+
onDone: [
|
|
128
|
+
{
|
|
129
|
+
target: '#withdraw_crypto_cash.submitted',
|
|
130
|
+
},
|
|
131
|
+
],
|
|
132
|
+
onError: {
|
|
133
|
+
target: '#withdraw_crypto_cash.calculated',
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
reset: {
|
|
138
|
+
invoke: {
|
|
139
|
+
src: 'resetOtp',
|
|
140
|
+
onDone: {
|
|
141
|
+
target: 'idle',
|
|
142
|
+
actions: 'setVerificationData',
|
|
143
|
+
},
|
|
144
|
+
onError: { target: 'idle' },
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
on: {
|
|
153
|
+
SET_NETWORK: {
|
|
154
|
+
target: 'debouncing',
|
|
155
|
+
actions: 'setNetwork',
|
|
156
|
+
internal: false,
|
|
157
|
+
},
|
|
158
|
+
SET_ADDRESS: {
|
|
159
|
+
actions: 'setAddress',
|
|
160
|
+
internal: false,
|
|
161
|
+
},
|
|
162
|
+
SET_AMOUNT: {
|
|
163
|
+
target: 'debouncing',
|
|
164
|
+
actions: 'setAmount',
|
|
165
|
+
internal: false,
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
actions: {
|
|
171
|
+
setInitData: assign((context, event) => {
|
|
172
|
+
const { withdrawRule, processing } = event.data
|
|
173
|
+
const { paymentDetail } = context
|
|
174
|
+
const selectedCrypto = paymentDetail.find((item) => item.transferType === 'withdraw' && item.category === 'crypto')
|
|
175
|
+
const networks = (selectedCrypto?.networkName || []).map((value, i) => {
|
|
176
|
+
return {
|
|
177
|
+
label: selectedCrypto.networkOptional?.[i],
|
|
178
|
+
value,
|
|
179
|
+
icon: value,
|
|
180
|
+
}
|
|
181
|
+
})
|
|
182
|
+
|
|
183
|
+
return {
|
|
184
|
+
withdrawRule,
|
|
185
|
+
selectedCrypto,
|
|
186
|
+
networks,
|
|
187
|
+
selectedNetwork: networks[0],
|
|
188
|
+
processing,
|
|
189
|
+
}
|
|
190
|
+
}),
|
|
191
|
+
setNetwork: assign((context, event) => {
|
|
192
|
+
return {
|
|
193
|
+
selectedNetwork: event.data,
|
|
194
|
+
}
|
|
195
|
+
}),
|
|
196
|
+
setAddress: assign((context, event) => {
|
|
197
|
+
return {
|
|
198
|
+
address: event.data,
|
|
199
|
+
}
|
|
200
|
+
}),
|
|
201
|
+
setAmount: assign((context, event) => {
|
|
202
|
+
return {
|
|
203
|
+
selectedAmount: event.data,
|
|
204
|
+
}
|
|
205
|
+
}),
|
|
206
|
+
setCalculation: assign((context, event) => {
|
|
207
|
+
// V2接口轉換中回傳的資料結構不同
|
|
208
|
+
const { data } = event.data
|
|
209
|
+
if (data) {
|
|
210
|
+
return {
|
|
211
|
+
calculation: data,
|
|
212
|
+
}
|
|
213
|
+
} else {
|
|
214
|
+
return {
|
|
215
|
+
calculation: event.data,
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}),
|
|
219
|
+
resetCharge: assign((context, event) => {
|
|
220
|
+
return {
|
|
221
|
+
charge: null,
|
|
222
|
+
}
|
|
223
|
+
}),
|
|
224
|
+
setTransaction: assign((context, event) => {
|
|
225
|
+
const { realAmount } = event.data
|
|
226
|
+
return {
|
|
227
|
+
realAmount,
|
|
228
|
+
}
|
|
229
|
+
}),
|
|
230
|
+
setOtp: assign((context, event) => {
|
|
231
|
+
const { requestId, status, target, ttl } = event.data
|
|
232
|
+
return {
|
|
233
|
+
requestId,
|
|
234
|
+
status,
|
|
235
|
+
target,
|
|
236
|
+
ttl,
|
|
237
|
+
}
|
|
238
|
+
}),
|
|
239
|
+
decreaseTtl: assign((context, evnet) => {
|
|
240
|
+
const second = context.ttl
|
|
241
|
+
return {
|
|
242
|
+
ttl: Math.max(second - 1, 0),
|
|
243
|
+
}
|
|
244
|
+
}),
|
|
245
|
+
setVerificationData: assign((context, event) => {
|
|
246
|
+
const { requestId, ttl, target } = event.data
|
|
247
|
+
return {
|
|
248
|
+
requestId,
|
|
249
|
+
ttl,
|
|
250
|
+
target,
|
|
251
|
+
}
|
|
252
|
+
}),
|
|
253
|
+
setAttachmentType: assign((context, event) => {
|
|
254
|
+
return {
|
|
255
|
+
attachmentType: event.data,
|
|
256
|
+
}
|
|
257
|
+
}),
|
|
258
|
+
setProcessing: assign((context, event) => {
|
|
259
|
+
return {
|
|
260
|
+
processing: event.data,
|
|
261
|
+
}
|
|
262
|
+
}),
|
|
263
|
+
},
|
|
264
|
+
guards: {
|
|
265
|
+
isProcessing: (context, event) => {
|
|
266
|
+
return context.processing
|
|
267
|
+
},
|
|
268
|
+
isCalculable: (context, event) => {
|
|
269
|
+
const { withdrawRule, selectedCrypto, selectedNetwork, selectedAmount } = context
|
|
270
|
+
const maximum = Math.min(withdrawRule.balance, selectedCrypto.maximum)
|
|
271
|
+
return selectedNetwork && selectedAmount && selectedCrypto.minimum <= selectedAmount && selectedAmount <= maximum
|
|
272
|
+
},
|
|
273
|
+
isOtpRequired: (context, event) => {
|
|
274
|
+
return event.data?.status === 'otp-verifying'
|
|
275
|
+
},
|
|
276
|
+
},
|
|
277
|
+
services: {
|
|
278
|
+
fetchInitData: async (context, event) => {
|
|
279
|
+
const [withdrawRule, orders] = await Promise.all([
|
|
280
|
+
request.send(payment.getDoubleWalletWithdrawRule({ walletType: 'CASH' })),
|
|
281
|
+
request.send(payment.getPendingOrder({ transferType: 'WITHDRAW' })),
|
|
282
|
+
])
|
|
283
|
+
|
|
284
|
+
return {
|
|
285
|
+
withdrawRule,
|
|
286
|
+
processing: orders[0],
|
|
287
|
+
}
|
|
288
|
+
},
|
|
289
|
+
fetchWithdrawRule: async (context, event) => {
|
|
290
|
+
return await request.send(payment.getDoubleWalletWithdrawRule({ walletType: 'CASH' }))
|
|
291
|
+
},
|
|
292
|
+
submitWithdraw: async (context, event) => {
|
|
293
|
+
const { selectedCrypto, selectedNetwork, address, selectedAmount } = context
|
|
294
|
+
return await request.send(
|
|
295
|
+
api.submitWithdrawTransactionCrypto({
|
|
296
|
+
method: selectedCrypto.method,
|
|
297
|
+
amount: selectedAmount,
|
|
298
|
+
cryptoCurrency: selectedCrypto.channel,
|
|
299
|
+
cryptoNetwork: selectedNetwork.value,
|
|
300
|
+
targetAddress: address,
|
|
301
|
+
})
|
|
302
|
+
)
|
|
303
|
+
},
|
|
304
|
+
fetchCalculation: async (context, event) => {
|
|
305
|
+
const { selectedCrypto, selectedNetwork, selectedAmount } = context
|
|
306
|
+
const method = selectedCrypto.method
|
|
307
|
+
return await request.send(
|
|
308
|
+
api.getWithdrawExpectedResult({
|
|
309
|
+
method,
|
|
310
|
+
amount: selectedAmount,
|
|
311
|
+
cryptoNetwork: selectedNetwork.value,
|
|
312
|
+
})
|
|
313
|
+
)
|
|
314
|
+
},
|
|
315
|
+
resetOtp: async (context, event) => {
|
|
316
|
+
const { requestId, target } = context
|
|
317
|
+
return await request.send(user.otpReset({ requestId, target }))
|
|
318
|
+
},
|
|
319
|
+
acknowledge: async (context, event) => {
|
|
320
|
+
const { requestId, target } = context
|
|
321
|
+
const code = event.data
|
|
322
|
+
return await request.send(user.otpAcknowledge({ requestId, target, code }))
|
|
323
|
+
},
|
|
324
|
+
},
|
|
325
|
+
}
|
|
326
|
+
)
|
|
327
|
+
}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
// 棄用
|
|
2
|
+
import { assign, createMachine } from 'xstate'
|
|
3
|
+
import findLastIndex from 'lodash/findLastIndex.js'
|
|
4
|
+
import payment from '../../api/payment.js'
|
|
5
|
+
import user from '../../api/user.js'
|
|
6
|
+
|
|
7
|
+
export default function (request) {
|
|
8
|
+
const { appSecret } = request.config
|
|
9
|
+
return createMachine(
|
|
10
|
+
{
|
|
11
|
+
id: 'withdraw_krway',
|
|
12
|
+
initial: 'loading',
|
|
13
|
+
context: {
|
|
14
|
+
userInfo: {},
|
|
15
|
+
paymentDetail: {},
|
|
16
|
+
minimum: 0,
|
|
17
|
+
maximum: 0,
|
|
18
|
+
options: [],
|
|
19
|
+
amount: 0,
|
|
20
|
+
bankInfo: [],
|
|
21
|
+
bank: null,
|
|
22
|
+
enableWithdraw: false,
|
|
23
|
+
applyId: '',
|
|
24
|
+
balance: 0,
|
|
25
|
+
realAmount: 0,
|
|
26
|
+
charge: 0,
|
|
27
|
+
withdrawCheck: null,
|
|
28
|
+
},
|
|
29
|
+
states: {
|
|
30
|
+
loading: {
|
|
31
|
+
invoke: {
|
|
32
|
+
src: 'fetchPaymentDetail',
|
|
33
|
+
onDone: {
|
|
34
|
+
target: 'fetching',
|
|
35
|
+
actions: 'setPaymentData',
|
|
36
|
+
},
|
|
37
|
+
onError: {
|
|
38
|
+
target: 'fail',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
fetching: {
|
|
43
|
+
invoke: {
|
|
44
|
+
src: 'fetchWithdrawRules',
|
|
45
|
+
onDone: {
|
|
46
|
+
target: 'checking',
|
|
47
|
+
actions: 'updateWithdrawCondition',
|
|
48
|
+
},
|
|
49
|
+
onError: {
|
|
50
|
+
target: 'fail',
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
checking: {
|
|
55
|
+
always: [{ target: 'inProcessing', cond: 'haveProcessing' }, { target: 'withdrawCheck' }],
|
|
56
|
+
},
|
|
57
|
+
withdrawCheck: {
|
|
58
|
+
invoke: {
|
|
59
|
+
src: 'withdrawCheck',
|
|
60
|
+
onDone: [
|
|
61
|
+
{
|
|
62
|
+
target: 'checkingWithdrawStatus',
|
|
63
|
+
actions: assign((context, event) => {
|
|
64
|
+
return {
|
|
65
|
+
withdrawCheck: event.data,
|
|
66
|
+
}
|
|
67
|
+
}),
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
onError: {
|
|
71
|
+
target: '#withdraw_krway.fail',
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
checkingWithdrawStatus: {
|
|
76
|
+
always: [
|
|
77
|
+
// 提款最低存款金額
|
|
78
|
+
{ target: 'notWithdrawMinDepositAmount', cond: 'isNotWithdrawMinDepositAmount' },
|
|
79
|
+
// 提款冷卻時間
|
|
80
|
+
{ target: 'passWithdrawCooldownTime', cond: 'isPassWithdrawCooldownTime' },
|
|
81
|
+
// 提款服務時間
|
|
82
|
+
{ target: 'withdrawServiceTime', cond: 'isNotWIthdrawServiceTime' },
|
|
83
|
+
{ target: 'notWithdrawable', cond: 'isNotWithdrawable' },
|
|
84
|
+
{ target: 'withdrawable' },
|
|
85
|
+
],
|
|
86
|
+
},
|
|
87
|
+
notWithdrawMinDepositAmount: {},
|
|
88
|
+
passWithdrawCooldownTime: {},
|
|
89
|
+
inProcessing: {},
|
|
90
|
+
withdrawServiceTime: {},
|
|
91
|
+
notWithdrawable: {},
|
|
92
|
+
withdrawable: {
|
|
93
|
+
on: {
|
|
94
|
+
ADD_AMOUNT: {
|
|
95
|
+
actions: 'addAmount',
|
|
96
|
+
},
|
|
97
|
+
SET_AMOUNT: {
|
|
98
|
+
actions: 'setAmount',
|
|
99
|
+
},
|
|
100
|
+
CLEAR_AMOUNT: {
|
|
101
|
+
actions: 'clearAmount',
|
|
102
|
+
},
|
|
103
|
+
SUBMIT: {
|
|
104
|
+
target: 'submitting',
|
|
105
|
+
cond: 'isSubmittable',
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
submitting: {
|
|
110
|
+
invoke: {
|
|
111
|
+
src: 'submitWithdraw',
|
|
112
|
+
onDone: {
|
|
113
|
+
target: 'submitted',
|
|
114
|
+
actions: 'setResult',
|
|
115
|
+
},
|
|
116
|
+
onError: {
|
|
117
|
+
target: 'withdrawable',
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
submitted: {
|
|
122
|
+
invoke: {
|
|
123
|
+
src: 'fetchPaymentDetail',
|
|
124
|
+
onDone: {
|
|
125
|
+
target: 'inProcessing',
|
|
126
|
+
actions: 'setPaymentData',
|
|
127
|
+
},
|
|
128
|
+
onError: {
|
|
129
|
+
target: 'fail',
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
fail: {},
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
actions: {
|
|
138
|
+
setPaymentData: assign((context, event) => {
|
|
139
|
+
const { paymentDetail, bankInfo } = event.data
|
|
140
|
+
const { minimum, maximum, optional } = paymentDetail?.[0] || {}
|
|
141
|
+
return { paymentDetail, bank: bankInfo[0], minimum, maximum, options: optional }
|
|
142
|
+
}),
|
|
143
|
+
updateWithdrawCondition: assign((context, event) => {
|
|
144
|
+
const { enableWithdraw, balance } = event.data
|
|
145
|
+
return {
|
|
146
|
+
balance,
|
|
147
|
+
enableWithdraw,
|
|
148
|
+
}
|
|
149
|
+
}),
|
|
150
|
+
addAmount: assign((context, event) => {
|
|
151
|
+
return {
|
|
152
|
+
amount: parseFloat(`${context.amount || 0}`) + parseFloat(`${event.data}`),
|
|
153
|
+
}
|
|
154
|
+
}),
|
|
155
|
+
setAmount: assign((context, event) => {
|
|
156
|
+
return { amount: parseFloat(`${event.data}`) }
|
|
157
|
+
}),
|
|
158
|
+
clearAmount: assign((context, event) => {
|
|
159
|
+
return { amount: null }
|
|
160
|
+
}),
|
|
161
|
+
setResult: assign((context, event) => {
|
|
162
|
+
const { applyId, balance, realAmount, charge } = event.data
|
|
163
|
+
return { applyId, balance, realAmount, charge }
|
|
164
|
+
}),
|
|
165
|
+
},
|
|
166
|
+
guards: {
|
|
167
|
+
haveProcessing: (context, event) => {
|
|
168
|
+
return (context.paymentDetail?.[0]?.processing || []).length > 0
|
|
169
|
+
},
|
|
170
|
+
isSubmittable: (context, event) => {
|
|
171
|
+
const { amount } = context
|
|
172
|
+
return parseFloat(`${amount}`) > 0
|
|
173
|
+
},
|
|
174
|
+
isNotWithdrawable: (context, event) => {
|
|
175
|
+
const { balance, enableWithdraw, paymentDetail } = context
|
|
176
|
+
const minWithdrawAmount = paymentDetail[0]?.minimum || 0
|
|
177
|
+
return !enableWithdraw || balance < minWithdrawAmount
|
|
178
|
+
},
|
|
179
|
+
isNotWithdrawMinDepositAmount: (context, event) => {
|
|
180
|
+
const { withdrawCheck } = context
|
|
181
|
+
return !withdrawCheck?.passDepositeLimit
|
|
182
|
+
},
|
|
183
|
+
isPassWithdrawCooldownTime: (context, event) => {
|
|
184
|
+
const { withdrawCheck } = context
|
|
185
|
+
return !withdrawCheck?.passWithdrawCooldownTime
|
|
186
|
+
},
|
|
187
|
+
isNotWIthdrawServiceTime: (context, event) => {
|
|
188
|
+
const { withdrawCheck } = context
|
|
189
|
+
return !withdrawCheck?.withdrawInServiceTime
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
services: {
|
|
193
|
+
fetchPaymentDetail: async (context, event) => {
|
|
194
|
+
const [paymentDetail = [], { bankInfo }] = await Promise.all([
|
|
195
|
+
request.send(payment.getPaymentDetail({ transferType: 'WITHDRAW' })),
|
|
196
|
+
request.send(payment.getPaymentInfo()),
|
|
197
|
+
])
|
|
198
|
+
return { paymentDetail, bankInfo }
|
|
199
|
+
},
|
|
200
|
+
fetchWithdrawRules: async (context, event) => {
|
|
201
|
+
return await request.send(payment.getDoubleWalletWithdrawRule({ walletType: 'CASH' }))
|
|
202
|
+
},
|
|
203
|
+
submitWithdraw: async (context, event) => {
|
|
204
|
+
const { paymentDetail, amount, bank } = context
|
|
205
|
+
const { method } = paymentDetail[0]
|
|
206
|
+
return await request.send(
|
|
207
|
+
payment.submitWithdrawTransactionVN({
|
|
208
|
+
method,
|
|
209
|
+
amount,
|
|
210
|
+
applyerBankCode: bank.bankCode,
|
|
211
|
+
applyerAccountNumber: bank.accountNumber,
|
|
212
|
+
branch: bank.branch,
|
|
213
|
+
holderName: bank.holderName,
|
|
214
|
+
})
|
|
215
|
+
)
|
|
216
|
+
},
|
|
217
|
+
withdrawCheck: async (context, event) => {
|
|
218
|
+
return await request.send(payment.withdrawCheck())
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
|
+
}
|
|
222
|
+
)
|
|
223
|
+
}
|