@jetthai/cuora 1.1.126 → 1.1.128-dev-2

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 (71) hide show
  1. package/CHANGELOG.md +428 -0
  2. package/package.json +1 -1
  3. package/src/api/activity.js +28 -0
  4. package/src/api/auth.js +6 -0
  5. package/src/api/common.js +2 -1
  6. package/src/api/game.js +5 -4
  7. package/src/api/mailbox.js +9 -5
  8. package/src/api/payment.js +103 -8
  9. package/src/api/user.js +2 -0
  10. package/src/machine/activity/activity.js +56 -16
  11. package/src/machine/activity/activity_cash.js +78 -14
  12. package/src/machine/activity/cash_rain_activity.js +153 -0
  13. package/src/machine/activity/diamond_shop_activity_cash.js +57 -92
  14. package/src/machine/activity/diamond_shop_activity_vn.js +54 -89
  15. package/src/machine/activity/fafafa_activity.js +8 -1
  16. package/src/machine/activity/friend_invite_friends_activity.js +3 -1
  17. package/src/machine/activity/index.js +6 -0
  18. package/src/machine/activity/instant_rebate_activity.js +214 -0
  19. package/src/machine/activity/roulette_activity_v2.js +11 -2
  20. package/src/machine/activity/sign_in_activity.js +20 -13
  21. package/src/machine/activity/vip_card_activity.js +140 -0
  22. package/src/machine/auth.js +54 -5
  23. package/src/machine/bank_binding.js +112 -12
  24. package/src/machine/bank_binding_amb.js +6 -1
  25. package/src/machine/common.js +92 -24
  26. package/src/machine/deposit/amb.js +5 -3
  27. package/src/machine/deposit/crypto.js +14 -10
  28. package/src/machine/deposit/crypto_bank.js +317 -0
  29. package/src/machine/deposit/crypto_bank_cash.js +280 -0
  30. package/src/machine/deposit/crypto_button.js +9 -5
  31. package/src/machine/deposit/crypto_cash.js +2 -5
  32. package/src/machine/deposit/crypto_qrcode.js +147 -0
  33. package/src/machine/deposit/crypto_qrcode_cash.js +131 -0
  34. package/src/machine/deposit/crypto_way.js +220 -0
  35. package/src/machine/deposit/crypto_way_cash.js +242 -0
  36. package/src/machine/deposit/direct.js +2 -11
  37. package/src/machine/deposit/direct_cash.js +6 -26
  38. package/src/machine/deposit/float.js +5 -3
  39. package/src/machine/deposit/index.js +14 -0
  40. package/src/machine/deposit/krway.js +151 -0
  41. package/src/machine/deposit/loadcard_cash.js +6 -27
  42. package/src/machine/deposit/loadcard_vn.js +2 -10
  43. package/src/machine/deposit/manual_cash.js +89 -38
  44. package/src/machine/deposit/manual_vn.js +104 -48
  45. package/src/machine/deposit/qrcode_cash.js +12 -23
  46. package/src/machine/deposit/qrcode_v2.js +3 -8
  47. package/src/machine/deposit/usdt_cash.js +0 -2
  48. package/src/machine/deposit/vpay.js +5 -3
  49. package/src/machine/game_info.js +57 -0
  50. package/src/machine/game_search_cash.js +390 -0
  51. package/src/machine/game_search_v2.js +4 -4
  52. package/src/machine/game_v2_1.js +131 -7
  53. package/src/machine/honor_board_cash.js +63 -0
  54. package/src/machine/inbox.js +259 -34
  55. package/src/machine/index.js +8 -2
  56. package/src/machine/leaderboard.js +31 -8
  57. package/src/machine/reward_cash.js +1 -1
  58. package/src/machine/side_v2.js +1 -1
  59. package/src/machine/user_photo.js +65 -0
  60. package/src/machine/user_sign_up.js +71 -7
  61. package/src/machine/withdraw/index.js +6 -0
  62. package/src/machine/withdraw/withdraw_crypto.js +1 -66
  63. package/src/machine/withdraw/withdraw_crypto2.js +540 -0
  64. package/src/machine/withdraw/withdraw_krway.js +207 -0
  65. package/src/machine/withdraw/withdraw_manual.js +595 -0
  66. package/src/machine/withdraw/withdraw_manual_cash.js +44 -14
  67. package/src/machine/withdraw/withdraw_vn.js +42 -7
  68. package/src/machine/withdraw/withdraw_vn2.js +64 -37
  69. package/src/util/constant.js +18 -0
  70. package/src/util/deviceToken.js +2 -2
  71. package/src/machine/game_search.js +0 -244
@@ -0,0 +1,207 @@
1
+ import { assign, createMachine } from 'xstate'
2
+ import findLastIndex from 'lodash/findLastIndex.js'
3
+ import payment from '../../api/payment.js'
4
+ import user from '../../api/user.js'
5
+
6
+ export default function (request) {
7
+ const { appSecret } = request.config
8
+ return createMachine(
9
+ {
10
+ id: 'withdraw_krway',
11
+ initial: 'loading',
12
+ context: {
13
+ userInfo: {},
14
+ paymentDetail: {},
15
+ minimum: 0,
16
+ maximum: 0,
17
+ options: [],
18
+ amount: 0,
19
+ bankInfo: [],
20
+ bank: null,
21
+ enableWithdraw: false,
22
+ applyId: '',
23
+ balance: 0,
24
+ realAmount: 0,
25
+ charge: 0,
26
+ withdrawCheck: null,
27
+ },
28
+ states: {
29
+ loading: {
30
+ invoke: {
31
+ src: 'fetchPaymentDetail',
32
+ onDone: {
33
+ target: 'fetching',
34
+ actions: 'setPaymentData',
35
+ },
36
+ onError: {
37
+ target: 'fail',
38
+ },
39
+ },
40
+ },
41
+ fetching: {
42
+ invoke: {
43
+ src: 'fetchWithdrawRules',
44
+ onDone: {
45
+ target: 'checking',
46
+ actions: 'updateWithdrawCondition',
47
+ },
48
+ onError: {
49
+ target: 'fail',
50
+ },
51
+ },
52
+ },
53
+ checking: {
54
+ always: [{ target: 'inProcessing', cond: 'haveProcessing' }, { target: 'withdrawCheck' }],
55
+ },
56
+ withdrawCheck: {
57
+ invoke: {
58
+ src: 'withdrawCheck',
59
+ onDone: [
60
+ {
61
+ target: 'notWithdrawMinDepositAmount',
62
+ cond: 'isNotWithdrawMinDepositAmount',
63
+ actions: assign((context, event) => {
64
+ return {
65
+ withdrawCheck: event.data,
66
+ }
67
+ }),
68
+ },
69
+ {
70
+ target: 'notWithdrawable',
71
+ cond: 'isNotWithdrawable',
72
+ },
73
+ {
74
+ target: 'withdrawable',
75
+ },
76
+ ],
77
+ onError: {
78
+ target: '#withdraw_krway.fail',
79
+ },
80
+ },
81
+ },
82
+ notWithdrawMinDepositAmount: {},
83
+ inProcessing: {},
84
+ notWithdrawable: {},
85
+ withdrawable: {
86
+ on: {
87
+ ADD_AMOUNT: {
88
+ actions: 'addAmount',
89
+ },
90
+ SET_AMOUNT: {
91
+ actions: 'setAmount',
92
+ },
93
+ CLEAR_AMOUNT: {
94
+ actions: 'clearAmount',
95
+ },
96
+ SUBMIT: {
97
+ target: 'submitting',
98
+ cond: 'isSubmittable',
99
+ },
100
+ },
101
+ },
102
+ submitting: {
103
+ invoke: {
104
+ src: 'submitWithdraw',
105
+ onDone: {
106
+ target: 'submitted',
107
+ actions: 'setResult',
108
+ },
109
+ onError: {
110
+ target: 'withdrawable',
111
+ },
112
+ },
113
+ },
114
+ submitted: {
115
+ invoke: {
116
+ src: 'fetchPaymentDetail',
117
+ onDone: {
118
+ target: 'inProcessing',
119
+ actions: 'setPaymentData',
120
+ },
121
+ onError: {
122
+ target: 'fail',
123
+ },
124
+ },
125
+ },
126
+ fail: {},
127
+ },
128
+ },
129
+ {
130
+ actions: {
131
+ setPaymentData: assign((context, event) => {
132
+ const { paymentDetail, bankInfo } = event.data
133
+ const { minimum, maximum, optional } = paymentDetail?.[0] || {}
134
+ return { paymentDetail, bank: bankInfo[0], minimum, maximum, options: optional }
135
+ }),
136
+ updateWithdrawCondition: assign((context, event) => {
137
+ const { enableWithdraw, balance } = event.data
138
+ return {
139
+ balance,
140
+ enableWithdraw,
141
+ }
142
+ }),
143
+ addAmount: assign((context, event) => {
144
+ return {
145
+ amount: parseFloat(`${context.amount || 0}`) + parseFloat(`${event.data}`),
146
+ }
147
+ }),
148
+ setAmount: assign((context, event) => {
149
+ return { amount: parseFloat(`${event.data}`) }
150
+ }),
151
+ clearAmount: assign((context, event) => {
152
+ return { amount: null }
153
+ }),
154
+ setResult: assign((context, event) => {
155
+ const { applyId, balance, realAmount, charge } = event.data
156
+ return { applyId, balance, realAmount, charge }
157
+ }),
158
+ },
159
+ guards: {
160
+ haveProcessing: (context, event) => {
161
+ return (context.paymentDetail?.[0]?.processing || []).length > 0
162
+ },
163
+ isSubmittable: (context, event) => {
164
+ const { amount } = context
165
+ return parseFloat(`${amount}`) > 0
166
+ },
167
+ isNotWithdrawable: (context, event) => {
168
+ const { balance, enableWithdraw, paymentDetail } = context
169
+ const minWithdrawAmount = paymentDetail[0]?.minimum || 0
170
+ return !enableWithdraw || balance < minWithdrawAmount
171
+ },
172
+ isNotWithdrawMinDepositAmount: (context, event) => {
173
+ return !event.data?.enableWithdraw
174
+ },
175
+ },
176
+ services: {
177
+ fetchPaymentDetail: async (context, event) => {
178
+ const [paymentDetail = [], { bankInfo }] = await Promise.all([
179
+ request.send(payment.getPaymentDetail({ transferType: 'WITHDRAW' })),
180
+ request.send(payment.getPaymentInfo()),
181
+ ])
182
+ return { paymentDetail, bankInfo }
183
+ },
184
+ fetchWithdrawRules: async (context, event) => {
185
+ return await request.send(payment.getDoubleWalletWithdrawRule({ walletType: 'CASH' }))
186
+ },
187
+ submitWithdraw: async (context, event) => {
188
+ const { paymentDetail, amount, bank } = context
189
+ const { method } = paymentDetail[0]
190
+ return await request.send(
191
+ payment.submitWithdrawTransactionVN({
192
+ method,
193
+ amount,
194
+ applyerBankCode: bank.bankCode,
195
+ applyerAccountNumber: bank.accountNumber,
196
+ branch: bank.branch,
197
+ holderName: bank.holderName,
198
+ })
199
+ )
200
+ },
201
+ withdrawCheck: async (context, event) => {
202
+ return await request.send(payment.withdrawCheck())
203
+ },
204
+ },
205
+ }
206
+ )
207
+ }