@jetthai/cuora 1.1.361-dev-10 → 1.1.361-v2api-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.
- package/CHANGELOG.md +9 -7
- package/package.json +1 -1
- package/src/api/payment.js +0 -4
- package/src/machine/bank_binding.js +10 -44
- package/src/machine/common.js +2 -3
- package/src/machine/game_v2_1.js +0 -4
- package/src/machine/withdraw/index.js +12 -0
- package/src/machine/withdraw/withdraw_amb.js +373 -0
- package/src/machine/withdraw/withdraw_crypto.js +493 -0
- package/src/machine/withdraw/withdraw_crypto2.js +540 -0
- package/src/machine/withdraw/withdraw_fc.js +251 -0
- package/src/machine/withdraw/withdraw_manual.js +95 -2
- package/src/machine/withdraw/withdraw_manual_cash.js +1 -1
- package/src/machine/withdraw/withdraw_vn.js +546 -0
- package/src/machine/withdraw/withdraw_vn2.js +563 -0
- package/src/request/request.js +90 -5
- package/src/util/sessionStorage.js +0 -28
package/CHANGELOG.md
CHANGED
|
@@ -2,26 +2,28 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
-
### [1.1.361-
|
|
6
|
-
|
|
7
|
-
### [1.1.361-dev-2](https://github.com/jetthai/cuora-module/compare/v1.1.361-dev...v1.1.361-dev-2) (2025-06-20)
|
|
8
|
-
|
|
9
|
-
### [1.1.361-dev-1](https://github.com/jetthai/cuora-module/compare/v1.1.361-dev...v1.1.361-dev-1) (2025-06-20)
|
|
10
|
-
|
|
11
|
-
### [1.1.361-dev](https://github.com/jetthai/cuora-module/compare/v1.1.361...v1.1.361-dev) (2025-06-20)
|
|
5
|
+
### [1.1.361-v2api-1](https://github.com/jetthai/cuora-module/compare/v1.1.361...v1.1.361-v2api-1) (2025-06-05)
|
|
12
6
|
|
|
13
7
|
### [1.1.361](https://github.com/jetthai/cuora-module/compare/v1.1.360...v1.1.361) (2025-06-03)
|
|
14
8
|
|
|
15
9
|
### [1.1.360](https://github.com/jetthai/cuora-module/compare/v1.1.359...v1.1.360) (2025-06-03)
|
|
16
10
|
|
|
11
|
+
### [1.1.358-apiv2-2](https://github.com/jetthai/cuora-module/compare/v1.1.359...v1.1.358-apiv2-2) (2025-05-27)
|
|
12
|
+
|
|
17
13
|
### [1.1.359](https://github.com/jetthai/cuora-module/compare/v1.1.358...v1.1.359) (2025-05-23)
|
|
18
14
|
|
|
15
|
+
### [1.1.358-apiv2-1](https://github.com/jetthai/cuora-module/compare/v1.1.358...v1.1.358-apiv2-1) (2025-05-09)
|
|
16
|
+
|
|
19
17
|
### [1.1.358](https://github.com/jetthai/cuora-module/compare/v1.1.357...v1.1.358) (2025-05-09)
|
|
20
18
|
|
|
21
19
|
### [1.1.357](https://github.com/jetthai/cuora-module/compare/v1.1.356...v1.1.357) (2025-05-06)
|
|
22
20
|
|
|
23
21
|
### [1.1.356](https://github.com/jetthai/cuora-module/compare/v1.1.355...v1.1.356) (2025-04-29)
|
|
24
22
|
|
|
23
|
+
### [1.1.355-apiv2-2](https://github.com/jetthai/cuora-module/compare/v1.1.355-apiv2-1...v1.1.355-apiv2-2) (2025-05-07)
|
|
24
|
+
|
|
25
|
+
### [1.1.355-apiv2-1](https://github.com/jetthai/cuora-module/compare/v1.1.355...v1.1.355-apiv2-1) (2025-05-05)
|
|
26
|
+
|
|
25
27
|
### [1.1.355](https://github.com/jetthai/cuora-module/compare/v1.1.353-data-1...v1.1.355) (2025-04-22)
|
|
26
28
|
|
|
27
29
|
### [1.1.354](https://github.com/jetthai/cuora-module/compare/v1.1.353...v1.1.354) (2025-04-14)
|
package/package.json
CHANGED
package/src/api/payment.js
CHANGED
|
@@ -19,8 +19,6 @@ export default {
|
|
|
19
19
|
lastNameTh,
|
|
20
20
|
firstNameEn,
|
|
21
21
|
lastNameEn,
|
|
22
|
-
firstNameLocale,
|
|
23
|
-
lastNameLocale,
|
|
24
22
|
bonus,
|
|
25
23
|
paymentProvider,
|
|
26
24
|
pixType,
|
|
@@ -43,8 +41,6 @@ export default {
|
|
|
43
41
|
lastNameTh,
|
|
44
42
|
firstNameEn,
|
|
45
43
|
lastNameEn,
|
|
46
|
-
firstNameLocale,
|
|
47
|
-
lastNameLocale,
|
|
48
44
|
bonus,
|
|
49
45
|
paymentProvider,
|
|
50
46
|
pixType,
|
|
@@ -27,8 +27,6 @@ export default function (request) {
|
|
|
27
27
|
branchCode: null,
|
|
28
28
|
accountNumber: null,
|
|
29
29
|
holderName: null,
|
|
30
|
-
lastNameLocale: null,
|
|
31
|
-
firstNameLocale: null,
|
|
32
30
|
pixType: null,
|
|
33
31
|
},
|
|
34
32
|
states: {
|
|
@@ -116,20 +114,6 @@ export default function (request) {
|
|
|
116
114
|
}
|
|
117
115
|
}),
|
|
118
116
|
},
|
|
119
|
-
SET_FIRST_NAME: {
|
|
120
|
-
actions: assign((context, event) => {
|
|
121
|
-
return {
|
|
122
|
-
firstNameLocale: event.data,
|
|
123
|
-
}
|
|
124
|
-
}),
|
|
125
|
-
},
|
|
126
|
-
SET_LAST_NAME: {
|
|
127
|
-
actions: assign((context, event) => {
|
|
128
|
-
return {
|
|
129
|
-
lastNameLocale: event.data,
|
|
130
|
-
}
|
|
131
|
-
}),
|
|
132
|
-
},
|
|
133
117
|
SET_PIX_TYPE: {
|
|
134
118
|
actions: assign((context, event) => {
|
|
135
119
|
return {
|
|
@@ -172,8 +156,6 @@ export default function (request) {
|
|
|
172
156
|
return {
|
|
173
157
|
hasAnyAccount: bankInfo.length > 0,
|
|
174
158
|
holderName: bankInfo[0]?.holderName,
|
|
175
|
-
firstNameLocale: bankInfo[0]?.firstNameLocale || null,
|
|
176
|
-
lastNameLocale: bankInfo[0]?.lastNameLocale || null,
|
|
177
159
|
paymentList,
|
|
178
160
|
bank: null, // 不預選銀行,玩家可能不知道這裡可以選 by Gordan
|
|
179
161
|
}
|
|
@@ -185,21 +167,21 @@ export default function (request) {
|
|
|
185
167
|
|
|
186
168
|
if (bindingType === 'CRYPTO') {
|
|
187
169
|
// 虛擬貨幣
|
|
188
|
-
const { crypto, network, cryptoAddress, holderName
|
|
189
|
-
return crypto && network && cryptoAddress &&
|
|
170
|
+
const { crypto, network, cryptoAddress, holderName } = context
|
|
171
|
+
return crypto && network && cryptoAddress && holderName
|
|
190
172
|
} else if (bindingType === 'EWALLET') {
|
|
191
173
|
// 電子錢包
|
|
192
|
-
const { walletCode, accountNumber, holderName
|
|
193
|
-
return walletCode?.bankCode && accountNumber &&
|
|
174
|
+
const { walletCode, accountNumber, holderName } = context
|
|
175
|
+
return walletCode?.bankCode && accountNumber && holderName
|
|
194
176
|
} else {
|
|
195
177
|
// 一般銀行
|
|
196
178
|
if (currency === 'INR') {
|
|
197
179
|
// 如果是印度幣別
|
|
198
|
-
const { bank, ifscCode, accountNumber, branch, holderName
|
|
199
|
-
return bank.bankCode && ifscCode && accountNumber && branch &&
|
|
180
|
+
const { bank, ifscCode, accountNumber, branch, holderName } = context
|
|
181
|
+
return bank.bankCode && ifscCode && accountNumber && branch && holderName
|
|
200
182
|
} else {
|
|
201
|
-
const { bank, accountNumber, branch, holderName
|
|
202
|
-
return bank.bankCode && accountNumber && branch &&
|
|
183
|
+
const { bank, accountNumber, branch, holderName } = context
|
|
184
|
+
return bank.bankCode && accountNumber && branch && holderName
|
|
203
185
|
}
|
|
204
186
|
}
|
|
205
187
|
},
|
|
@@ -213,22 +195,8 @@ export default function (request) {
|
|
|
213
195
|
return { paymentList, paymentInfo }
|
|
214
196
|
},
|
|
215
197
|
updatePaymentInfo: async (context, event) => {
|
|
216
|
-
const {
|
|
217
|
-
|
|
218
|
-
bank,
|
|
219
|
-
ifscCode,
|
|
220
|
-
crypto,
|
|
221
|
-
network,
|
|
222
|
-
cryptoAddress,
|
|
223
|
-
walletCode,
|
|
224
|
-
branch,
|
|
225
|
-
branchCode,
|
|
226
|
-
accountNumber,
|
|
227
|
-
holderName,
|
|
228
|
-
firstNameLocale,
|
|
229
|
-
lastNameLocale,
|
|
230
|
-
pixType,
|
|
231
|
-
} = context
|
|
198
|
+
const { bindingType, bank, ifscCode, crypto, network, cryptoAddress, walletCode, branch, branchCode, accountNumber, holderName, pixType } =
|
|
199
|
+
context
|
|
232
200
|
return await request.send(
|
|
233
201
|
payment.updatePaymentInfo({
|
|
234
202
|
bindingType,
|
|
@@ -242,8 +210,6 @@ export default function (request) {
|
|
|
242
210
|
branchCode,
|
|
243
211
|
bankAccount: accountNumber,
|
|
244
212
|
holderName,
|
|
245
|
-
firstNameLocale,
|
|
246
|
-
lastNameLocale,
|
|
247
213
|
pixType,
|
|
248
214
|
})
|
|
249
215
|
)
|
package/src/machine/common.js
CHANGED
|
@@ -3,7 +3,6 @@ import { assign, createMachine } from 'xstate'
|
|
|
3
3
|
import pickBy from 'lodash/pickBy.js'
|
|
4
4
|
import api from '../api/common.js'
|
|
5
5
|
import storage from '../util/storage.js'
|
|
6
|
-
import sessionStorage from '../util/sessionStorage.js'
|
|
7
6
|
|
|
8
7
|
export default function (request) {
|
|
9
8
|
const { appSecret, defaultChannel, defaultSubchannel } = request.config
|
|
@@ -259,7 +258,7 @@ export default function (request) {
|
|
|
259
258
|
const channel = urlParams.get('channel') || storage.get('channel') || defaultChannel || 'official'
|
|
260
259
|
const subchannel = urlParams.get('subchannel') || storage.get('subchannel') || defaultSubchannel || 'pwa'
|
|
261
260
|
const affiliateCode = urlParams.get('ac') || urlParams.get('referralCode') || storage.get('ac') || storage.get('referralCode')
|
|
262
|
-
const friendCode = urlParams.get('fc') || urlParams.get('affiliate') ||
|
|
261
|
+
const friendCode = urlParams.get('fc') || urlParams.get('affiliate') || storage.get('fc') || storage.get('affiliate')
|
|
263
262
|
|
|
264
263
|
storage.set('channel', channel, {
|
|
265
264
|
path: '/',
|
|
@@ -273,7 +272,7 @@ export default function (request) {
|
|
|
273
272
|
path: '/',
|
|
274
273
|
maxAge: 60 * 60 * 24 * 7,
|
|
275
274
|
})
|
|
276
|
-
|
|
275
|
+
storage.set('fc', friendCode, {
|
|
277
276
|
path: '/',
|
|
278
277
|
maxAge: 60 * 60 * 24 * 7,
|
|
279
278
|
})
|
package/src/machine/game_v2_1.js
CHANGED
|
@@ -229,10 +229,6 @@ export default function (request) {
|
|
|
229
229
|
ENTER_GAME_PAUSE: {
|
|
230
230
|
actions: ['setIsPlaying', 'resetContent', 'resetSHA'],
|
|
231
231
|
},
|
|
232
|
-
ENTER_GAME: {
|
|
233
|
-
target: 'connecting',
|
|
234
|
-
actions: ['setGameInfo', 'setLang', 'setwalletType'],
|
|
235
|
-
},
|
|
236
232
|
},
|
|
237
233
|
},
|
|
238
234
|
playingDemo: {
|
|
@@ -1,10 +1,22 @@
|
|
|
1
|
+
import withdraw_fc from './withdraw_fc.js'
|
|
2
|
+
import withdraw_vn from './withdraw_vn.js'
|
|
3
|
+
import withdraw_vn2 from './withdraw_vn2.js'
|
|
1
4
|
import withdraw_manual from './withdraw_manual.js'
|
|
5
|
+
import withdraw_crypto from './withdraw_crypto.js'
|
|
6
|
+
import withdraw_crypto2 from './withdraw_crypto2.js'
|
|
7
|
+
import withdraw_amb from './withdraw_amb.js'
|
|
2
8
|
import withdraw_krway from './withdraw_krway.js'
|
|
3
9
|
import withdraw_crypto_cash from './withdraw_crypto_cash.js'
|
|
4
10
|
import withdraw_manual_cash from './withdraw_manual_cash.js'
|
|
5
11
|
|
|
6
12
|
export default {
|
|
13
|
+
withdraw_fc,
|
|
14
|
+
withdraw_vn,
|
|
15
|
+
withdraw_vn2,
|
|
7
16
|
withdraw_manual,
|
|
17
|
+
withdraw_crypto,
|
|
18
|
+
withdraw_crypto2,
|
|
19
|
+
withdraw_amb,
|
|
8
20
|
withdraw_krway,
|
|
9
21
|
withdraw_crypto_cash,
|
|
10
22
|
withdraw_manual_cash,
|
|
@@ -0,0 +1,373 @@
|
|
|
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_amb',
|
|
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
|
+
|
|
27
|
+
amount: null,
|
|
28
|
+
|
|
29
|
+
// otp
|
|
30
|
+
requestId: null,
|
|
31
|
+
status: null,
|
|
32
|
+
target: null,
|
|
33
|
+
ttl: null,
|
|
34
|
+
},
|
|
35
|
+
states: {
|
|
36
|
+
loading: {
|
|
37
|
+
invoke: {
|
|
38
|
+
src: 'fetchInitData',
|
|
39
|
+
onDone: {
|
|
40
|
+
target: 'mode',
|
|
41
|
+
actions: ['setInitData', 'preset'],
|
|
42
|
+
},
|
|
43
|
+
onError: {
|
|
44
|
+
target: 'fail',
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
mode: {
|
|
49
|
+
always: [{ target: 'free', cond: 'isFree' }, { target: 'cash' }],
|
|
50
|
+
},
|
|
51
|
+
free: {
|
|
52
|
+
initial: 'checking',
|
|
53
|
+
states: {
|
|
54
|
+
// loading: {
|
|
55
|
+
// invoke: {
|
|
56
|
+
// src: 'fetchWithdrawRules',
|
|
57
|
+
// onDone: {
|
|
58
|
+
// target: 'checking',
|
|
59
|
+
// actions: 'updateWithdrawCondition',
|
|
60
|
+
// },
|
|
61
|
+
// onError: {
|
|
62
|
+
// target: 'notConvertible',
|
|
63
|
+
// },
|
|
64
|
+
// },
|
|
65
|
+
// },
|
|
66
|
+
checking: {
|
|
67
|
+
always: [{ target: 'convertible', cond: 'isConvertible' }, { target: 'notConvertible' }],
|
|
68
|
+
},
|
|
69
|
+
notConvertible: {},
|
|
70
|
+
convertible: {
|
|
71
|
+
on: {
|
|
72
|
+
SUBMIT: {
|
|
73
|
+
target: 'converting',
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
converting: {
|
|
78
|
+
invoke: {
|
|
79
|
+
src: 'submitWithdrawFree',
|
|
80
|
+
onDone: [
|
|
81
|
+
{
|
|
82
|
+
target: '#withdraw_amb.otp',
|
|
83
|
+
actions: 'setOtp',
|
|
84
|
+
cond: 'isOtpRequired',
|
|
85
|
+
},
|
|
86
|
+
{ target: 'converted' },
|
|
87
|
+
],
|
|
88
|
+
onError: {
|
|
89
|
+
target: 'convertible',
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
converted: {},
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
cash: {
|
|
97
|
+
initial: 'checking',
|
|
98
|
+
states: {
|
|
99
|
+
checking: {
|
|
100
|
+
always: [
|
|
101
|
+
{ target: 'notWithdrawable', cond: 'isNotWithdrawable' },
|
|
102
|
+
{ target: 'unbound', cond: 'isBankNotBound' },
|
|
103
|
+
{ target: 'withdrawable' },
|
|
104
|
+
],
|
|
105
|
+
},
|
|
106
|
+
notWithdrawable: {},
|
|
107
|
+
unbound: {
|
|
108
|
+
// to bank_binding.js
|
|
109
|
+
},
|
|
110
|
+
withdrawable: {
|
|
111
|
+
entry: 'setMaximumWithdrawAmount',
|
|
112
|
+
on: {
|
|
113
|
+
SUBMIT: {
|
|
114
|
+
target: 'submitting',
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
submitting: {
|
|
119
|
+
invoke: {
|
|
120
|
+
src: 'submitWithdraw',
|
|
121
|
+
onDone: [
|
|
122
|
+
{
|
|
123
|
+
target: '#withdraw_amb.otp',
|
|
124
|
+
actions: 'setOtp',
|
|
125
|
+
cond: 'isOtpRequired',
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
target: 'submitted',
|
|
129
|
+
},
|
|
130
|
+
],
|
|
131
|
+
onError: {
|
|
132
|
+
target: 'withdrawable',
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
submitted: {
|
|
137
|
+
entry: assign((context, event) => {
|
|
138
|
+
const { applyId, balance, realAmount, charge } = event.data
|
|
139
|
+
return { applyId, balance, realAmount, charge }
|
|
140
|
+
}),
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
otp: {
|
|
145
|
+
type: 'parallel',
|
|
146
|
+
states: {
|
|
147
|
+
countdown: {
|
|
148
|
+
after: {
|
|
149
|
+
1000: {
|
|
150
|
+
target: 'countdown',
|
|
151
|
+
actions: 'decreaseTtl',
|
|
152
|
+
cond: (context) => context.ttl > 0,
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
verification: {
|
|
157
|
+
initial: 'idle',
|
|
158
|
+
states: {
|
|
159
|
+
idle: {
|
|
160
|
+
on: {
|
|
161
|
+
ACKNOWLEDGE: {
|
|
162
|
+
target: 'acknowledging',
|
|
163
|
+
},
|
|
164
|
+
RESET_OTP: {
|
|
165
|
+
target: 'reset',
|
|
166
|
+
},
|
|
167
|
+
BACK: [
|
|
168
|
+
{
|
|
169
|
+
target: '#withdraw_amb.free.convertible',
|
|
170
|
+
cond: 'isFree',
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
target: '#withdraw_amb.cash.withdrawable',
|
|
174
|
+
},
|
|
175
|
+
],
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
acknowledging: {
|
|
179
|
+
invoke: {
|
|
180
|
+
src: 'acknowledge',
|
|
181
|
+
onDone: [
|
|
182
|
+
{
|
|
183
|
+
target: '#withdraw_amb.free.converted',
|
|
184
|
+
cond: 'isFree',
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
target: '#withdraw_amb.cash.submitted',
|
|
188
|
+
},
|
|
189
|
+
],
|
|
190
|
+
onError: {
|
|
191
|
+
target: 'idle',
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
reset: {
|
|
196
|
+
invoke: {
|
|
197
|
+
src: 'resetOtp',
|
|
198
|
+
onDone: {
|
|
199
|
+
target: 'idle',
|
|
200
|
+
actions: 'setVerificationData',
|
|
201
|
+
},
|
|
202
|
+
onError: { target: 'idle' },
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
fail: {},
|
|
210
|
+
},
|
|
211
|
+
on: {
|
|
212
|
+
REFRESH: {
|
|
213
|
+
target: 'loading',
|
|
214
|
+
},
|
|
215
|
+
},
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
actions: {
|
|
219
|
+
setInitData: assign((context, event) => {
|
|
220
|
+
return {
|
|
221
|
+
paymentDetail: event.data.paymentDetail,
|
|
222
|
+
bankInfo: event.data.bankInfo,
|
|
223
|
+
bonus: event.data.bonus,
|
|
224
|
+
bankList: event.data.bankList,
|
|
225
|
+
}
|
|
226
|
+
}),
|
|
227
|
+
setPaymentData: assign((context, event) => {
|
|
228
|
+
return {
|
|
229
|
+
bankInfo: event.data.bankInfo,
|
|
230
|
+
bonus: event.data.bonus,
|
|
231
|
+
paymentDetail: event.data.paymentDetail,
|
|
232
|
+
}
|
|
233
|
+
}),
|
|
234
|
+
preset: assign((context, event) => {
|
|
235
|
+
const { userInfo, siteConfig } = event.data
|
|
236
|
+
const { withdraw_limit, target_withdraw_limit } = userInfo || {}
|
|
237
|
+
const balance = parseFloat(userInfo?.balance)
|
|
238
|
+
const methods = siteConfig?.paymentMethods?.withdraw || []
|
|
239
|
+
return {
|
|
240
|
+
withdrawLimit: Math.abs(withdraw_limit),
|
|
241
|
+
targetWithdrawLimit: Math.abs(target_withdraw_limit),
|
|
242
|
+
methods,
|
|
243
|
+
balance,
|
|
244
|
+
siteConfig,
|
|
245
|
+
userInfo,
|
|
246
|
+
}
|
|
247
|
+
}),
|
|
248
|
+
updateWithdrawCondition: assign((context, event) => {
|
|
249
|
+
const rules = event.data.rules.filter((rule) => rule.maxWithdrawAmount > 0)
|
|
250
|
+
|
|
251
|
+
const { balance, withdrawLimit } = context
|
|
252
|
+
const lastMatchedIndex = findLastIndex(rules, (rule) => balance >= rule.greaterEqualThen)
|
|
253
|
+
|
|
254
|
+
let maxWithdrawAmount = 0,
|
|
255
|
+
availableWithdrawAmount = 0
|
|
256
|
+
|
|
257
|
+
if (lastMatchedIndex > -1) {
|
|
258
|
+
rules[lastMatchedIndex].match = true
|
|
259
|
+
maxWithdrawAmount = rules[lastMatchedIndex].maxWithdrawAmount
|
|
260
|
+
|
|
261
|
+
if (withdrawLimit === 0) {
|
|
262
|
+
availableWithdrawAmount = Math.min(balance, maxWithdrawAmount)
|
|
263
|
+
}
|
|
264
|
+
} else if (rules.length > 0) {
|
|
265
|
+
maxWithdrawAmount = rules[0].maxWithdrawAmount
|
|
266
|
+
} else {
|
|
267
|
+
maxWithdrawAmount = balance
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
return {
|
|
271
|
+
maxWithdrawAmount,
|
|
272
|
+
availableWithdrawAmount,
|
|
273
|
+
}
|
|
274
|
+
}),
|
|
275
|
+
setOtp: assign((context, event) => {
|
|
276
|
+
const { requestId, status, target, ttl } = event.data
|
|
277
|
+
return {
|
|
278
|
+
requestId,
|
|
279
|
+
status,
|
|
280
|
+
target,
|
|
281
|
+
ttl,
|
|
282
|
+
}
|
|
283
|
+
}),
|
|
284
|
+
decreaseTtl: assign((context, evnet) => {
|
|
285
|
+
const second = context.ttl
|
|
286
|
+
return {
|
|
287
|
+
ttl: Math.max(second - 1, 0),
|
|
288
|
+
}
|
|
289
|
+
}),
|
|
290
|
+
setVerificationData: assign((context, event) => {
|
|
291
|
+
const { requestId, ttl, target } = event.data
|
|
292
|
+
return {
|
|
293
|
+
requestId,
|
|
294
|
+
ttl,
|
|
295
|
+
target,
|
|
296
|
+
}
|
|
297
|
+
}),
|
|
298
|
+
setMaximumWithdrawAmount: assign((context, event) => {
|
|
299
|
+
const { balance, paymentDetail } = context
|
|
300
|
+
return {
|
|
301
|
+
amount: Math.min(balance, paymentDetail[0]?.maximum || 0),
|
|
302
|
+
}
|
|
303
|
+
}),
|
|
304
|
+
},
|
|
305
|
+
guards: {
|
|
306
|
+
isFree: (context, event) => {
|
|
307
|
+
return context.userInfo?.withdraw_rule !== 'DEFAULT'
|
|
308
|
+
},
|
|
309
|
+
isWithdrawDisable: (context, event) => {
|
|
310
|
+
const { siteConfig } = context
|
|
311
|
+
const methods = siteConfig?.paymentMethods?.withdraw || []
|
|
312
|
+
return methods.length === 0
|
|
313
|
+
},
|
|
314
|
+
isBankNotBound: (context, event) => {
|
|
315
|
+
return !context.bankInfo?.length
|
|
316
|
+
},
|
|
317
|
+
isConvertible: (context, event) => {
|
|
318
|
+
const { balance, withdrawLimit } = context
|
|
319
|
+
return balance > 0 && withdrawLimit === 0
|
|
320
|
+
},
|
|
321
|
+
isNotWithdrawable: (context, event) => {
|
|
322
|
+
const { balance, withdrawLimit, paymentDetail } = context
|
|
323
|
+
const minWithdrawAmount = paymentDetail[0]?.minimum || 0
|
|
324
|
+
return withdrawLimit !== 0 || balance < minWithdrawAmount
|
|
325
|
+
},
|
|
326
|
+
isOtpRequired: (context, event) => {
|
|
327
|
+
return event.data?.status === 'otp-verifying'
|
|
328
|
+
},
|
|
329
|
+
},
|
|
330
|
+
services: {
|
|
331
|
+
fetchInitData: async (context, event) => {
|
|
332
|
+
const [{ config }, userInfo, paymentDetail = [], { bonus, bankInfo }] = await Promise.all([
|
|
333
|
+
request.send(common.getConfig({ appSecret })),
|
|
334
|
+
request.send(user.getUserInfo()),
|
|
335
|
+
request.send(payment.getPaymentDetail({ transferType: 'WITHDRAW' })),
|
|
336
|
+
request.send(payment.getPaymentInfo()),
|
|
337
|
+
])
|
|
338
|
+
const siteConfig = JSON.parse(window.atob(config))
|
|
339
|
+
const method = paymentDetail.find((payment) => payment.category === 'amb').method
|
|
340
|
+
const bankList = await request.send(payment.getBankList(method))
|
|
341
|
+
const newBankInfo = bankInfo.map((item) => {
|
|
342
|
+
return { ...item, ...bankList.find((bank) => bank.bankCode === item.bankCode) }
|
|
343
|
+
})
|
|
344
|
+
return { siteConfig, userInfo, paymentDetail, bonus, bankInfo: newBankInfo, bankList }
|
|
345
|
+
},
|
|
346
|
+
fetchPaymentData: async (context, event) => {
|
|
347
|
+
const paymentDetail = await request.send(payment.getPaymentDetail({ transferType: 'WITHDRAW' }))
|
|
348
|
+
const { bonus, bankInfo } = await request.send(payment.getPaymentInfo())
|
|
349
|
+
return { bonus, bankInfo, paymentDetail }
|
|
350
|
+
},
|
|
351
|
+
fetchWithdrawRules: async (context, event) => {
|
|
352
|
+
return await request.send(payment.getCurrentWithdrawRule())
|
|
353
|
+
},
|
|
354
|
+
submitWithdraw: async (context, event) => {
|
|
355
|
+
const { method } = context.paymentDetail[0]
|
|
356
|
+
return await request.send(payment.submitWithdrawTransactionAmb({ method }))
|
|
357
|
+
},
|
|
358
|
+
submitWithdrawFree: async (context, event) => {
|
|
359
|
+
return await request.send(payment.convertFreeCredit({ exchangeType: 1 }))
|
|
360
|
+
},
|
|
361
|
+
resetOtp: async (context, event) => {
|
|
362
|
+
const { requestId, target } = context
|
|
363
|
+
return await request.send(user.otpReset({ requestId, target }))
|
|
364
|
+
},
|
|
365
|
+
acknowledge: async (context, event) => {
|
|
366
|
+
const { requestId, target } = context
|
|
367
|
+
const code = event.data
|
|
368
|
+
return await request.send(user.otpAcknowledge({ requestId, target, code }))
|
|
369
|
+
},
|
|
370
|
+
},
|
|
371
|
+
}
|
|
372
|
+
)
|
|
373
|
+
}
|