@jetthai/cuora 1.1.364-dev-5 → 1.1.364-dev-1

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.
Files changed (38) hide show
  1. package/CHANGELOG.md +25 -15
  2. package/package.json +1 -1
  3. package/resetGitBranch.sh +49 -0
  4. package/src/api/activity.js +2 -2
  5. package/src/api/game.js +14 -1
  6. package/src/api/payment.js +5 -0
  7. package/src/api/ranking.js +4 -3
  8. package/src/machine/activity/activity.js +7 -6
  9. package/src/machine/activity/vip_card_activity.js +17 -9
  10. package/src/machine/bank_binding.js +44 -10
  11. package/src/machine/common.js +3 -1
  12. package/src/machine/deposit/direct.js +2 -6
  13. package/src/machine/deposit/float.js +2 -2
  14. package/src/machine/deposit/loadcard_vn.js +10 -51
  15. package/src/machine/deposit/manual_vn.js +3 -23
  16. package/src/machine/deposit/qrcode_v2.js +6 -132
  17. package/src/machine/deposit/virtual_bank_vn.js +3 -31
  18. package/src/machine/deposit/vpay.js +2 -2
  19. package/src/machine/game_betslip.js +46 -0
  20. package/src/machine/game_search_cash.js +10 -2
  21. package/src/machine/game_search_v2.js +10 -2
  22. package/src/machine/game_v2_1.js +81 -12
  23. package/src/machine/inbox.js +13 -1
  24. package/src/machine/index.js +2 -0
  25. package/src/machine/promotions.js +4 -5
  26. package/src/machine/ranking.js +38 -22
  27. package/src/machine/reward.js +57 -5
  28. package/src/machine/reward_cash.js +56 -15
  29. package/src/machine/setting.js +7 -0
  30. package/src/machine/withdraw/index.js +0 -12
  31. package/src/machine/withdraw/withdraw_manual.js +3 -97
  32. package/src/machine/withdraw/withdraw_manual_cash.js +1 -1
  33. package/src/machine/withdraw/withdraw_amb.js +0 -373
  34. package/src/machine/withdraw/withdraw_crypto.js +0 -495
  35. package/src/machine/withdraw/withdraw_crypto2.js +0 -540
  36. package/src/machine/withdraw/withdraw_fc.js +0 -251
  37. package/src/machine/withdraw/withdraw_vn.js +0 -548
  38. package/src/machine/withdraw/withdraw_vn2.js +0 -563
@@ -1,548 +0,0 @@
1
- import { assign, createMachine } from 'xstate'
2
- import findLastIndex from 'lodash/findLastIndex.js'
3
- import payment from '../../api/payment.js'
4
- import common from '../../api/common.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_vn',
12
- initial: 'loading',
13
- context: {
14
- siteConfig: null,
15
- userInfo: null,
16
- balance: null,
17
- charge: null,
18
- realAmount: null,
19
- applyId: null,
20
- methods: [],
21
- paymentDetail: [],
22
- bankInfo: [],
23
- bankList: [],
24
- withdrawLimit: null,
25
- targetWithdrawLimit: null,
26
- attachmentType: null, // null | 'withdraw' | 'pool'
27
- maximumWithdrawAmount: 0,
28
- enableWithdrawAmount: 0,
29
- enableWithdraw: false,
30
- withdrawRules: [],
31
- withdrawCheck: null,
32
-
33
- amount: null,
34
- bank: null,
35
- branch: null,
36
- accountNumber: null,
37
- holderName: null,
38
-
39
- // otp
40
- requestId: null,
41
- status: null,
42
- target: null,
43
- ttl: null,
44
- },
45
- states: {
46
- loading: {
47
- invoke: {
48
- src: 'fetchInitData',
49
- onDone: {
50
- target: 'mode',
51
- actions: ['setInitData', 'preset', 'updateWithdrawCondition'],
52
- },
53
- onError: {
54
- target: 'fail',
55
- },
56
- },
57
- },
58
- mode: {
59
- always: [{ target: 'free', cond: 'isFree' }, { target: 'cash' }],
60
- },
61
- free: {
62
- initial: 'checking',
63
- states: {
64
- // loading: {
65
- // invoke: {
66
- // src: 'fetchWithdrawRules',
67
- // onDone: {
68
- // target: 'checking',
69
- // actions: 'updateWithdrawCondition',
70
- // },
71
- // onError: {
72
- // target: 'notConvertible',
73
- // },
74
- // },
75
- // },
76
- checking: {
77
- always: [{ target: 'convertible', cond: 'isConvertible' }, { target: 'notConvertible' }],
78
- },
79
- notConvertible: {
80
- on: {
81
- GIVE_UP: {
82
- target: 'givingUp',
83
- },
84
- },
85
- },
86
- givingUp: {
87
- invoke: {
88
- src: 'giveUp',
89
- onDone: {
90
- target: 'gaveUp',
91
- },
92
- onError: {
93
- target: 'convertible',
94
- },
95
- },
96
- },
97
- gaveUp: {},
98
- convertible: {
99
- on: {
100
- SUBMIT: {
101
- target: 'converting',
102
- actions: 'setAttachmentType',
103
- },
104
- },
105
- },
106
- converting: {
107
- invoke: {
108
- src: 'convertFreeCredit',
109
- onDone: [
110
- // {
111
- // target: '#withdraw_vn.otp',
112
- // actions: 'setOtp',
113
- // cond: 'isOtpRequired',
114
- // },
115
- { target: 'converted' },
116
- ],
117
- onError: {
118
- target: 'convertible',
119
- },
120
- },
121
- },
122
- converted: {
123
- // always: [
124
- // { target: '#withdraw_vn.cash.unbound', cond: 'isBankNotBound' },
125
- // { target: '#withdraw_vn.cash.withdrawable', cond: 'hasAttachmentType' },
126
- // ],
127
- },
128
- },
129
- },
130
- cash: {
131
- initial: 'checking',
132
- states: {
133
- checking: {
134
- always: [
135
- { target: 'inProcessing', cond: 'haveProcessing' },
136
- { target: 'unbound', cond: 'isBankNotBound' },
137
- { target: 'withdrawCheck' },
138
- ],
139
- },
140
- withdrawCheck: {
141
- invoke: {
142
- src: 'withdrawCheck',
143
- onDone: [
144
- {
145
- target: 'checkingWithdrawStatus',
146
- actions: assign((context, event) => {
147
- return {
148
- withdrawCheck: event.data,
149
- }
150
- }),
151
- },
152
- ],
153
- onError: {
154
- target: '#withdraw_vn.fail',
155
- },
156
- },
157
- },
158
- checkingWithdrawStatus: {
159
- always: [
160
- // 提款最低存款金額
161
- { target: 'notWithdrawMinDepositAmount', cond: 'isNotWithdrawMinDepositAmount' },
162
- // 提款冷卻時間
163
- { target: 'passWithdrawCooldownTime', cond: 'isPassWithdrawCooldownTime' },
164
- // 提款服務時間
165
- { target: 'withdrawServiceTime', cond: 'isNotWIthdrawServiceTime' },
166
- { target: 'notWithdrawable', cond: 'isNotWithdrawable' },
167
- { target: 'withdrawable' },
168
- ],
169
- },
170
- notWithdrawMinDepositAmount: {},
171
- passWithdrawCooldownTime: {},
172
- withdrawServiceTime: {},
173
- notWithdrawable: {},
174
- unbound: {
175
- // to bank_binding.js
176
- },
177
- inProcessing: {},
178
- withdrawable: {
179
- on: {
180
- SET_CURRENT_BANK: {
181
- actions: assign((context, event) => {
182
- return {
183
- bank: event.data,
184
- }
185
- }),
186
- },
187
- SET_AMOUNT: {
188
- actions: assign((context, event) => {
189
- return {
190
- amount: event.data,
191
- }
192
- }),
193
- },
194
- SET_ATTACHMENT_TYPE: {
195
- actions: 'setAttachmentType',
196
- cond: 'isNewWalletMode',
197
- },
198
- SUBMIT: [
199
- {
200
- target: 'pooling',
201
- cond: (context, event) => {
202
- const { amount, attachmentType } = context
203
- return attachmentType === 'pool' && amount > 0
204
- },
205
- },
206
- {
207
- target: 'submitting',
208
- cond: 'isSubmittable',
209
- },
210
- ],
211
- },
212
- },
213
- submitting: {
214
- invoke: {
215
- src: 'submitWithdraw',
216
- onDone: [
217
- {
218
- target: '#withdraw_vn.otp',
219
- actions: 'setOtp',
220
- cond: 'isOtpRequired',
221
- },
222
- {
223
- target: 'submitted',
224
- },
225
- ],
226
- onError: {
227
- target: 'withdrawable',
228
- },
229
- },
230
- },
231
- submitted: {
232
- entry: assign((context, event) => {
233
- const { applyId, balance, realAmount, charge } = event.data
234
- return { applyId, balance, realAmount, charge }
235
- }),
236
- invoke: {
237
- src: 'fetchPaymentData',
238
- onDone: {
239
- target: 'inProcessing',
240
- actions: 'setPaymentData',
241
- },
242
- onError: {
243
- target: '#withdraw_vn.fail',
244
- },
245
- },
246
- },
247
- pooling: {
248
- invoke: {
249
- src: 'pool',
250
- onDone: { target: 'pooled' },
251
- onError: {
252
- target: 'withdrawable',
253
- },
254
- },
255
- },
256
- pooled: {},
257
- },
258
- },
259
- otp: {
260
- type: 'parallel',
261
- states: {
262
- countdown: {
263
- after: {
264
- 1000: {
265
- target: 'countdown',
266
- actions: 'decreaseTtl',
267
- cond: (context) => context.ttl > 0,
268
- },
269
- },
270
- },
271
- verification: {
272
- initial: 'idle',
273
- states: {
274
- idle: {
275
- on: {
276
- ACKNOWLEDGE: {
277
- target: 'acknowledging',
278
- },
279
- RESET_OTP: {
280
- target: 'reset',
281
- },
282
- BACK: [
283
- {
284
- target: '#withdraw_vn.free.convertible',
285
- cond: 'isFree',
286
- },
287
- {
288
- target: '#withdraw_vn.cash.withdrawable',
289
- },
290
- ],
291
- },
292
- },
293
- acknowledging: {
294
- invoke: {
295
- src: 'acknowledge',
296
- onDone: [
297
- {
298
- target: '#withdraw_vn.free.converted',
299
- cond: 'isFree',
300
- },
301
- {
302
- target: '#withdraw_vn.cash.submitted',
303
- },
304
- ],
305
- onError: {
306
- target: 'idle',
307
- },
308
- },
309
- },
310
- reset: {
311
- invoke: {
312
- src: 'resetOtp',
313
- onDone: {
314
- target: 'idle',
315
- actions: 'setVerificationData',
316
- },
317
- onError: { target: 'idle' },
318
- },
319
- },
320
- },
321
- },
322
- },
323
- },
324
- fail: {},
325
- },
326
- on: {
327
- REFRESH: {
328
- target: 'loading',
329
- },
330
- },
331
- },
332
- {
333
- actions: {
334
- setInitData: assign((context, event) => {
335
- return {
336
- paymentDetail: event.data.paymentDetail,
337
- bankInfo: event.data.bankInfo,
338
- bank: event.data.bankInfo[0],
339
- bonus: event.data.bonus,
340
- bankList: event.data.bankList,
341
- }
342
- }),
343
- setPaymentData: assign((context, event) => {
344
- return {
345
- bankInfo: event.data.bankInfo,
346
- bonus: event.data.bonus,
347
- paymentDetail: event.data.paymentDetail,
348
- }
349
- }),
350
- preset: assign((context, event) => {
351
- const { userInfo, siteConfig } = event.data
352
- const { withdraw_limit, target_withdraw_limit } = userInfo || {}
353
- const balance = parseFloat(userInfo?.balance)
354
- const methods = siteConfig?.paymentMethods?.withdraw || []
355
- return {
356
- withdrawLimit: Math.abs(withdraw_limit),
357
- targetWithdrawLimit: Math.abs(target_withdraw_limit),
358
- methods,
359
- balance,
360
- siteConfig,
361
- userInfo,
362
- attachmentType: siteConfig.walletMode > 0 ? 'withdraw' : null,
363
- }
364
- }),
365
- updateWithdrawCondition: assign((context, event) => {
366
- const { differAmountLimit, enableWithdraw, enableWithdrawAmount, maxWithdrawStatus, maximumWithdrawAmount, minimumWithdrawAmount } =
367
- event.data?.withdrawRule
368
-
369
- const withdrawRules = event.data?.withdrawRule?.rules || []
370
- const rules = withdrawRules.filter((rule) => rule.maxWithdrawAmount > 0)
371
-
372
- const { balance } = context
373
- const lastMatchedIndex = findLastIndex(rules, (rule) => balance >= rule.greaterEqualThen)
374
-
375
- let maxWithdrawAmount = 0
376
-
377
- if (lastMatchedIndex > -1) {
378
- rules[lastMatchedIndex].match = true
379
- maxWithdrawAmount = rules[lastMatchedIndex].maxWithdrawAmount
380
- } else if (rules.length > 0) {
381
- maxWithdrawAmount = rules[0].maxWithdrawAmount
382
- } else {
383
- maxWithdrawAmount = balance
384
- }
385
-
386
- return {
387
- maxWithdrawAmount,
388
- enableWithdrawAmount: +enableWithdrawAmount,
389
- enableWithdraw,
390
- withdrawRules,
391
- }
392
- }),
393
- setOtp: assign((context, event) => {
394
- const { requestId, status, target, ttl } = event.data
395
- return {
396
- requestId,
397
- status,
398
- target,
399
- ttl,
400
- }
401
- }),
402
- decreaseTtl: assign((context, evnet) => {
403
- const second = context.ttl
404
- return {
405
- ttl: Math.max(second - 1, 0),
406
- }
407
- }),
408
- setVerificationData: assign((context, event) => {
409
- const { requestId, ttl, target } = event.data
410
- return {
411
- requestId,
412
- ttl,
413
- target,
414
- }
415
- }),
416
- setAttachmentType: assign((context, event) => {
417
- return {
418
- attachmentType: event.data,
419
- }
420
- }),
421
- },
422
- guards: {
423
- isFree: (context, event) => {
424
- return context.userInfo?.withdraw_rule !== 'DEFAULT'
425
- },
426
- hasAttachmentType: (context, event) => {
427
- return ['withdraw', 'pool'].includes(context.attachmentType)
428
- },
429
- haveProcessing: (context, event) => {
430
- return (context.paymentDetail?.[0]?.processing || []).length > 0
431
- },
432
- isWithdrawDisable: (context, event) => {
433
- const { siteConfig } = context
434
- const methods = siteConfig?.paymentMethods?.withdraw || []
435
- return methods.length === 0
436
- },
437
- isBankNotBound: (context, event) => {
438
- return !context.bankInfo?.length
439
- },
440
- isSubmittable: (context, event) => {
441
- const { bank, amount } = context
442
- return bank && amount > 0
443
- },
444
- isConvertible: (context, event) => {
445
- const { balance, enableWithdraw } = context
446
- return balance > 0 && enableWithdraw
447
- },
448
- isNotWithdrawable: (context, event) => {
449
- const { balance, enableWithdraw, paymentDetail } = context
450
- const minWithdrawAmount = paymentDetail[0]?.minimum || 0
451
- return !enableWithdraw || balance < minWithdrawAmount
452
- },
453
- isOtpRequired: (context, event) => {
454
- return event.data?.status === 'otp-verifying'
455
- },
456
- isNewWalletMode: (context, event) => context.siteConfig.walletMode > 0,
457
- isNotWithdrawMinDepositAmount: (context, event) => {
458
- const { withdrawCheck } = context
459
- return !withdrawCheck?.passDepositeLimit
460
- },
461
- isPassWithdrawCooldownTime: (context, event) => {
462
- const { withdrawCheck } = context
463
- return !withdrawCheck?.passWithdrawCooldownTime
464
- },
465
- isNotWIthdrawServiceTime: (context, event) => {
466
- const { withdrawCheck } = context
467
- return !withdrawCheck?.withdrawInServiceTime
468
- },
469
- },
470
- services: {
471
- fetchInitData: async (context, event) => {
472
- const [{ config }, userInfo, paymentDetail = [], { bonus, bankInfo }, withdrawRule] = await Promise.all([
473
- request.send(common.getConfig({ appSecret })),
474
- request.send(user.getUserInfo()),
475
- request.send(payment.getPaymentDetail({ transferType: 'WITHDRAW' })),
476
- request.send(payment.getPaymentInfo()),
477
- request.send(payment.getCurrentWithdrawRule()),
478
- ])
479
- const siteConfig = JSON.parse(window.atob(config))
480
- const bankList = await request.send(payment.getWithdrawBankList())
481
- const newBankInfo = bankInfo
482
- .map((item) => {
483
- const matchedBank = bankList.find((bank) => bank.bankCode === item.bankCode)
484
- return matchedBank ? { ...item, ...matchedBank } : null
485
- })
486
- .filter(Boolean)
487
- return { siteConfig, userInfo, paymentDetail, bonus, bankInfo: newBankInfo, bankList, withdrawRule }
488
- },
489
- fetchPaymentData: async (context, event) => {
490
- const paymentDetail = await request.send(payment.getPaymentDetail({ transferType: 'WITHDRAW' }))
491
- const { bonus, bankInfo } = await request.send(payment.getPaymentInfo())
492
- return { bonus, bankInfo, paymentDetail }
493
- },
494
- updatePaymentInfo: async (context, event) => {
495
- const { bank, branch, accountNumber, holderName } = context
496
- return await request.send(
497
- payment.updatePaymentInfo({
498
- bankCode: bank.bankCode,
499
- branch,
500
- bankAccount: accountNumber,
501
- holderName,
502
- })
503
- )
504
- },
505
- fetchWithdrawRules: async (context, event) => {
506
- return await request.send(payment.getCurrentWithdrawRule())
507
- },
508
- submitWithdraw: async (context, event) => {
509
- const { bank, amount } = context
510
- const { method } = context.paymentDetail[0]
511
- const branchTemp = ['GCASH', 'PAYM', 'PIX'].includes(bank.bankCode) ? '' : bank.branch
512
- return await request.send(
513
- payment.submitWithdrawTransactionVN({
514
- method,
515
- amount,
516
- applyerBankCode: bank.bankCode,
517
- applyerAccountNumber: bank.accountNumber,
518
- branch: branchTemp,
519
- holderName: bank.holderName,
520
- })
521
- )
522
- },
523
- convertFreeCredit: async (context, event) => {
524
- return await request.send(payment.convertFreeCredit({ exchangeType: 1 }))
525
- },
526
- resetOtp: async (context, event) => {
527
- const { requestId, target } = context
528
- return await request.send(user.otpReset({ requestId, target }))
529
- },
530
- acknowledge: async (context, event) => {
531
- const { requestId, target } = context
532
- const code = event.data
533
- return await request.send(user.otpAcknowledge({ requestId, target, code }))
534
- },
535
- pool: async (context, event) => {
536
- const { amount } = context
537
- return await request.send(payment.restore({ amount }))
538
- },
539
- giveUp: async (context, event) => {
540
- return await request.send(payment.giveUp())
541
- },
542
- withdrawCheck: async (context, event) => {
543
- return await request.send(payment.withdrawCheck())
544
- },
545
- },
546
- }
547
- )
548
- }