@jetthai/cuora 1.1.361-dev-11 → 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 -9
- package/package.json +1 -1
- package/src/api/activity.js +2 -2
- package/src/api/game.js +0 -12
- 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/inbox.js +1 -9
- package/src/machine/index.js +0 -2
- package/src/machine/reward.js +5 -15
- package/src/machine/reward_cash.js +2 -14
- 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/machine/game_betslip.js +0 -46
- package/src/util/sessionStorage.js +0 -28
|
@@ -0,0 +1,563 @@
|
|
|
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_vn2',
|
|
11
|
+
initial: 'loading',
|
|
12
|
+
context: {
|
|
13
|
+
mode: null,
|
|
14
|
+
siteConfig: null,
|
|
15
|
+
balance: null,
|
|
16
|
+
charge: null,
|
|
17
|
+
realAmount: null,
|
|
18
|
+
applyId: null,
|
|
19
|
+
methods: [],
|
|
20
|
+
paymentDetail: [],
|
|
21
|
+
bankInfo: [],
|
|
22
|
+
bankList: [],
|
|
23
|
+
currentWithdrawLimit: null,
|
|
24
|
+
targetWithdrawLimit: null,
|
|
25
|
+
attachmentType: null, // null | 'withdraw' | 'pool'
|
|
26
|
+
enableWithdrawAmount: 0,
|
|
27
|
+
enableWithdraw: false,
|
|
28
|
+
withdrawRules: [],
|
|
29
|
+
withdrawRule: {},
|
|
30
|
+
withdrawCheck: {},
|
|
31
|
+
|
|
32
|
+
amount: null,
|
|
33
|
+
bank: null,
|
|
34
|
+
branch: null,
|
|
35
|
+
holderName: null,
|
|
36
|
+
|
|
37
|
+
// otp
|
|
38
|
+
requestId: null,
|
|
39
|
+
status: null,
|
|
40
|
+
target: null,
|
|
41
|
+
ttl: null,
|
|
42
|
+
},
|
|
43
|
+
states: {
|
|
44
|
+
loading: {
|
|
45
|
+
invoke: {
|
|
46
|
+
src: 'fetchInitData',
|
|
47
|
+
onDone: {
|
|
48
|
+
target: 'pending',
|
|
49
|
+
actions: ['setInitData', 'preset'],
|
|
50
|
+
},
|
|
51
|
+
onError: {
|
|
52
|
+
target: 'fail',
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
pending: {
|
|
57
|
+
on: {
|
|
58
|
+
SET_MODE: {
|
|
59
|
+
target: 'fetching',
|
|
60
|
+
actions: 'setMode',
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
fetching: {
|
|
65
|
+
invoke: {
|
|
66
|
+
src: 'fetchWithdrawRules',
|
|
67
|
+
onDone: {
|
|
68
|
+
target: 'mode',
|
|
69
|
+
actions: 'updateWithdrawCondition',
|
|
70
|
+
},
|
|
71
|
+
onError: {
|
|
72
|
+
target: '#withdraw_vn2.fail',
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
mode: {
|
|
77
|
+
always: [{ target: 'activity', cond: 'isActivity' }, { target: 'cash' }],
|
|
78
|
+
},
|
|
79
|
+
activity: {
|
|
80
|
+
initial: 'checking',
|
|
81
|
+
states: {
|
|
82
|
+
checking: {
|
|
83
|
+
always: [{ target: 'convertible', cond: 'isConvertible' }, { target: 'notConvertible' }],
|
|
84
|
+
},
|
|
85
|
+
notConvertible: {
|
|
86
|
+
on: {
|
|
87
|
+
GIVE_UP: {
|
|
88
|
+
target: 'fetchWithdrawRule',
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
fetchWithdrawRule: {
|
|
93
|
+
invoke: {
|
|
94
|
+
src: 'fetchWithdrawRulePreview',
|
|
95
|
+
onDone: {
|
|
96
|
+
target: 'giveUp',
|
|
97
|
+
actions: 'setWithdrawRulePreview',
|
|
98
|
+
},
|
|
99
|
+
onError: {
|
|
100
|
+
target: 'notConvertible',
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
giveUp: {
|
|
105
|
+
on: {
|
|
106
|
+
CONFIRM: {
|
|
107
|
+
target: 'givingUp',
|
|
108
|
+
},
|
|
109
|
+
BACK: {
|
|
110
|
+
target: 'notConvertible',
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
givingUp: {
|
|
115
|
+
invoke: {
|
|
116
|
+
src: 'giveUp',
|
|
117
|
+
onDone: {
|
|
118
|
+
target: 'gaveUp',
|
|
119
|
+
},
|
|
120
|
+
onError: {
|
|
121
|
+
target: 'convertible',
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
gaveUp: {},
|
|
126
|
+
convertible: {
|
|
127
|
+
on: {
|
|
128
|
+
SUBMIT: {
|
|
129
|
+
target: 'converting',
|
|
130
|
+
actions: 'setAttachmentType',
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
converting: {
|
|
135
|
+
invoke: {
|
|
136
|
+
src: 'convertFreeCredit',
|
|
137
|
+
onDone: [
|
|
138
|
+
{
|
|
139
|
+
target: '#withdraw_vn2.otp',
|
|
140
|
+
actions: 'setOtp',
|
|
141
|
+
cond: 'isOtpRequired',
|
|
142
|
+
},
|
|
143
|
+
{ target: 'converted' },
|
|
144
|
+
],
|
|
145
|
+
onError: {
|
|
146
|
+
target: 'convertible',
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
converted: {
|
|
151
|
+
always: [
|
|
152
|
+
{ target: '#withdraw_vn2.cash.unbound', cond: 'isBankNotBound' },
|
|
153
|
+
{ target: '#withdraw_vn2.cash.withdrawable', cond: 'hasAttachmentType' },
|
|
154
|
+
],
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
cash: {
|
|
159
|
+
initial: 'checking',
|
|
160
|
+
states: {
|
|
161
|
+
checking: {
|
|
162
|
+
always: [
|
|
163
|
+
{ target: 'inProcessing', cond: 'haveProcessing' },
|
|
164
|
+
{ target: 'unbound', cond: 'isBankNotBound' },
|
|
165
|
+
{ target: 'withdrawCheck' },
|
|
166
|
+
],
|
|
167
|
+
},
|
|
168
|
+
withdrawCheck: {
|
|
169
|
+
invoke: {
|
|
170
|
+
src: 'withdrawCheck',
|
|
171
|
+
onDone: [
|
|
172
|
+
{
|
|
173
|
+
target: 'checkingWithdrawStatus',
|
|
174
|
+
actions: assign((context, event) => {
|
|
175
|
+
return {
|
|
176
|
+
withdrawCheck: event.data,
|
|
177
|
+
}
|
|
178
|
+
}),
|
|
179
|
+
},
|
|
180
|
+
],
|
|
181
|
+
onError: {
|
|
182
|
+
target: '#withdraw_vn2.fail',
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
checkingWithdrawStatus: {
|
|
187
|
+
always: [
|
|
188
|
+
// 提款最低存款金額
|
|
189
|
+
{ target: 'notWithdrawMinDepositAmount', cond: 'isNotWithdrawMinDepositAmount' },
|
|
190
|
+
// 提款冷卻時間
|
|
191
|
+
{ target: 'passWithdrawCooldownTime', cond: 'isPassWithdrawCooldownTime' },
|
|
192
|
+
// 提款服務時間
|
|
193
|
+
{ target: 'withdrawServiceTime', cond: 'isNotWIthdrawServiceTime' },
|
|
194
|
+
{ target: 'notWithdrawable', cond: 'isNotWithdrawable' },
|
|
195
|
+
{ target: 'withdrawable' },
|
|
196
|
+
],
|
|
197
|
+
},
|
|
198
|
+
notWithdrawMinDepositAmount: {},
|
|
199
|
+
passWithdrawCooldownTime: {},
|
|
200
|
+
withdrawServiceTime: {},
|
|
201
|
+
notWithdrawable: {},
|
|
202
|
+
unbound: {
|
|
203
|
+
// to bank_binding.js
|
|
204
|
+
},
|
|
205
|
+
inProcessing: {},
|
|
206
|
+
withdrawable: {
|
|
207
|
+
on: {
|
|
208
|
+
SET_CURRENT_BANK: {
|
|
209
|
+
actions: assign((context, event) => {
|
|
210
|
+
return {
|
|
211
|
+
bank: event.data,
|
|
212
|
+
}
|
|
213
|
+
}),
|
|
214
|
+
},
|
|
215
|
+
SET_AMOUNT: {
|
|
216
|
+
actions: assign((context, event) => {
|
|
217
|
+
return {
|
|
218
|
+
amount: event.data,
|
|
219
|
+
}
|
|
220
|
+
}),
|
|
221
|
+
},
|
|
222
|
+
SET_ATTACHMENT_TYPE: {
|
|
223
|
+
actions: 'setAttachmentType',
|
|
224
|
+
},
|
|
225
|
+
SUBMIT: [
|
|
226
|
+
{
|
|
227
|
+
target: 'pooling',
|
|
228
|
+
cond: (context, event) => {
|
|
229
|
+
const { amount, attachmentType } = context
|
|
230
|
+
return attachmentType === 'pool' && amount > 0
|
|
231
|
+
},
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
target: 'submitting',
|
|
235
|
+
cond: 'isSubmittable',
|
|
236
|
+
},
|
|
237
|
+
],
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
submitting: {
|
|
241
|
+
invoke: {
|
|
242
|
+
src: 'submitWithdraw',
|
|
243
|
+
onDone: [
|
|
244
|
+
{
|
|
245
|
+
target: '#withdraw_vn2.otp',
|
|
246
|
+
actions: 'setOtp',
|
|
247
|
+
cond: 'isOtpRequired',
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
target: 'submitted',
|
|
251
|
+
},
|
|
252
|
+
],
|
|
253
|
+
onError: {
|
|
254
|
+
target: 'withdrawable',
|
|
255
|
+
},
|
|
256
|
+
},
|
|
257
|
+
},
|
|
258
|
+
submitted: {
|
|
259
|
+
entry: assign((context, event) => {
|
|
260
|
+
const { applyId, balance, realAmount, charge } = event.data
|
|
261
|
+
return { applyId, balance, realAmount, charge }
|
|
262
|
+
}),
|
|
263
|
+
invoke: {
|
|
264
|
+
src: 'fetchPaymentData',
|
|
265
|
+
onDone: {
|
|
266
|
+
target: 'inProcessing',
|
|
267
|
+
actions: 'setPaymentData',
|
|
268
|
+
},
|
|
269
|
+
onError: {
|
|
270
|
+
target: '#withdraw_vn2.fail',
|
|
271
|
+
},
|
|
272
|
+
},
|
|
273
|
+
},
|
|
274
|
+
pooling: {
|
|
275
|
+
invoke: {
|
|
276
|
+
src: 'pool',
|
|
277
|
+
onDone: { target: 'pooled' },
|
|
278
|
+
onError: {
|
|
279
|
+
target: 'withdrawable',
|
|
280
|
+
},
|
|
281
|
+
},
|
|
282
|
+
},
|
|
283
|
+
pooled: {},
|
|
284
|
+
},
|
|
285
|
+
},
|
|
286
|
+
otp: {
|
|
287
|
+
type: 'parallel',
|
|
288
|
+
states: {
|
|
289
|
+
countdown: {
|
|
290
|
+
after: {
|
|
291
|
+
1000: {
|
|
292
|
+
target: 'countdown',
|
|
293
|
+
actions: 'decreaseTtl',
|
|
294
|
+
cond: (context) => context.ttl > 0,
|
|
295
|
+
},
|
|
296
|
+
},
|
|
297
|
+
},
|
|
298
|
+
verification: {
|
|
299
|
+
initial: 'idle',
|
|
300
|
+
states: {
|
|
301
|
+
idle: {
|
|
302
|
+
on: {
|
|
303
|
+
ACKNOWLEDGE: {
|
|
304
|
+
target: 'acknowledging',
|
|
305
|
+
},
|
|
306
|
+
RESET_OTP: {
|
|
307
|
+
target: 'reset',
|
|
308
|
+
},
|
|
309
|
+
BACK: [
|
|
310
|
+
{
|
|
311
|
+
target: '#withdraw_vn2.activity.convertible',
|
|
312
|
+
cond: 'isActivity',
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
target: '#withdraw_vn2.cash.withdrawable',
|
|
316
|
+
},
|
|
317
|
+
],
|
|
318
|
+
},
|
|
319
|
+
},
|
|
320
|
+
acknowledging: {
|
|
321
|
+
invoke: {
|
|
322
|
+
src: 'acknowledge',
|
|
323
|
+
onDone: [
|
|
324
|
+
{
|
|
325
|
+
target: '#withdraw_vn2.activity.converted',
|
|
326
|
+
cond: 'isActivity',
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
target: '#withdraw_vn2.cash.submitted',
|
|
330
|
+
},
|
|
331
|
+
],
|
|
332
|
+
onError: {
|
|
333
|
+
target: 'idle',
|
|
334
|
+
},
|
|
335
|
+
},
|
|
336
|
+
},
|
|
337
|
+
reset: {
|
|
338
|
+
invoke: {
|
|
339
|
+
src: 'resetOtp',
|
|
340
|
+
onDone: {
|
|
341
|
+
target: 'idle',
|
|
342
|
+
actions: 'setVerificationData',
|
|
343
|
+
},
|
|
344
|
+
onError: { target: 'idle' },
|
|
345
|
+
},
|
|
346
|
+
},
|
|
347
|
+
},
|
|
348
|
+
},
|
|
349
|
+
},
|
|
350
|
+
},
|
|
351
|
+
fail: {},
|
|
352
|
+
},
|
|
353
|
+
on: {
|
|
354
|
+
REFRESH: {
|
|
355
|
+
target: 'loading',
|
|
356
|
+
},
|
|
357
|
+
},
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
actions: {
|
|
361
|
+
setInitData: assign((context, event) => {
|
|
362
|
+
const { paymentDetail, bankInfo, bonus, bankList } = event.data
|
|
363
|
+
return {
|
|
364
|
+
paymentDetail,
|
|
365
|
+
bankInfo,
|
|
366
|
+
bank: bankInfo[0],
|
|
367
|
+
bonus,
|
|
368
|
+
bankList,
|
|
369
|
+
}
|
|
370
|
+
}),
|
|
371
|
+
preset: assign((context, event) => {
|
|
372
|
+
const { siteConfig } = context
|
|
373
|
+
const methods = siteConfig?.paymentMethods?.withdraw || []
|
|
374
|
+
return {
|
|
375
|
+
methods,
|
|
376
|
+
attachmentType: 'withdraw',
|
|
377
|
+
}
|
|
378
|
+
}),
|
|
379
|
+
setMode: assign((context, event) => {
|
|
380
|
+
return {
|
|
381
|
+
mode: event.data,
|
|
382
|
+
}
|
|
383
|
+
}),
|
|
384
|
+
updateWithdrawCondition: assign((context, event) => {
|
|
385
|
+
const { enableWithdraw, enableWithdrawAmount, currentWithdrawLimit, targetWithdrawLimit, balance } = event.data
|
|
386
|
+
const withdrawRules = event.data?.rules || []
|
|
387
|
+
const rules = withdrawRules.filter((rule) => rule.maxWithdrawAmount > 0)
|
|
388
|
+
const lastMatchedIndex = findLastIndex(rules, (rule) => balance >= rule.greaterEqualThen)
|
|
389
|
+
|
|
390
|
+
let maxWithdrawAmount = 0
|
|
391
|
+
|
|
392
|
+
if (lastMatchedIndex > -1) {
|
|
393
|
+
rules[lastMatchedIndex].match = true
|
|
394
|
+
maxWithdrawAmount = rules[lastMatchedIndex].maxWithdrawAmount
|
|
395
|
+
} else if (rules.length > 0) {
|
|
396
|
+
maxWithdrawAmount = rules[0].maxWithdrawAmount
|
|
397
|
+
} else {
|
|
398
|
+
maxWithdrawAmount = balance
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
return {
|
|
402
|
+
balance,
|
|
403
|
+
currentWithdrawLimit,
|
|
404
|
+
targetWithdrawLimit,
|
|
405
|
+
maxWithdrawAmount,
|
|
406
|
+
enableWithdrawAmount: +enableWithdrawAmount,
|
|
407
|
+
enableWithdraw,
|
|
408
|
+
withdrawRules,
|
|
409
|
+
}
|
|
410
|
+
}),
|
|
411
|
+
setWithdrawRulePreview: assign((context, event) => {
|
|
412
|
+
return {
|
|
413
|
+
withdrawRule: event.data,
|
|
414
|
+
}
|
|
415
|
+
}),
|
|
416
|
+
setPaymentData: assign((context, event) => {
|
|
417
|
+
const { bankInfo, bonus, paymentDetail } = event.data
|
|
418
|
+
return {
|
|
419
|
+
bankInfo,
|
|
420
|
+
bonus,
|
|
421
|
+
paymentDetail,
|
|
422
|
+
}
|
|
423
|
+
}),
|
|
424
|
+
setOtp: assign((context, event) => {
|
|
425
|
+
const { requestId, status, target, ttl } = event.data
|
|
426
|
+
return {
|
|
427
|
+
requestId,
|
|
428
|
+
status,
|
|
429
|
+
target,
|
|
430
|
+
ttl,
|
|
431
|
+
}
|
|
432
|
+
}),
|
|
433
|
+
decreaseTtl: assign((context, evnet) => {
|
|
434
|
+
const second = context.ttl
|
|
435
|
+
return {
|
|
436
|
+
ttl: Math.max(second - 1, 0),
|
|
437
|
+
}
|
|
438
|
+
}),
|
|
439
|
+
setVerificationData: assign((context, event) => {
|
|
440
|
+
const { requestId, ttl, target } = event.data
|
|
441
|
+
return {
|
|
442
|
+
requestId,
|
|
443
|
+
ttl,
|
|
444
|
+
target,
|
|
445
|
+
}
|
|
446
|
+
}),
|
|
447
|
+
setAttachmentType: assign((context, event) => {
|
|
448
|
+
return {
|
|
449
|
+
attachmentType: event.data,
|
|
450
|
+
}
|
|
451
|
+
}),
|
|
452
|
+
},
|
|
453
|
+
guards: {
|
|
454
|
+
isActivity: (context, event) => {
|
|
455
|
+
return context.mode === 'ACTIVITY'
|
|
456
|
+
},
|
|
457
|
+
hasAttachmentType: (context, event) => {
|
|
458
|
+
return ['withdraw', 'pool'].includes(context.attachmentType)
|
|
459
|
+
},
|
|
460
|
+
haveProcessing: (context, event) => {
|
|
461
|
+
return (context.paymentDetail?.[0]?.processing || []).length > 0
|
|
462
|
+
},
|
|
463
|
+
isBankNotBound: (context, event) => {
|
|
464
|
+
return !context.bankInfo?.length
|
|
465
|
+
},
|
|
466
|
+
isSubmittable: (context, event) => {
|
|
467
|
+
const { bank, amount } = context
|
|
468
|
+
return bank && amount > 0
|
|
469
|
+
},
|
|
470
|
+
isConvertible: (context, event) => {
|
|
471
|
+
const { balance, enableWithdraw } = context
|
|
472
|
+
return balance > 0 && enableWithdraw
|
|
473
|
+
},
|
|
474
|
+
isNotWithdrawable: (context, event) => {
|
|
475
|
+
const { balance, enableWithdraw, paymentDetail } = context
|
|
476
|
+
const minWithdrawAmount = paymentDetail[0]?.minimum || 0
|
|
477
|
+
return !enableWithdraw || balance < minWithdrawAmount
|
|
478
|
+
},
|
|
479
|
+
isOtpRequired: (context, event) => {
|
|
480
|
+
return event.data?.status === 'otp-verifying'
|
|
481
|
+
},
|
|
482
|
+
isNotWithdrawMinDepositAmount: (context, event) => {
|
|
483
|
+
const { withdrawCheck } = context
|
|
484
|
+
return !withdrawCheck?.passDepositeLimit
|
|
485
|
+
},
|
|
486
|
+
isPassWithdrawCooldownTime: (context, event) => {
|
|
487
|
+
const { withdrawCheck } = context
|
|
488
|
+
return !withdrawCheck?.passWithdrawCooldownTime
|
|
489
|
+
},
|
|
490
|
+
isNotWIthdrawServiceTime: (context, event) => {
|
|
491
|
+
const { withdrawCheck } = context
|
|
492
|
+
return !withdrawCheck?.withdrawInServiceTime
|
|
493
|
+
},
|
|
494
|
+
},
|
|
495
|
+
services: {
|
|
496
|
+
fetchInitData: async (context, event) => {
|
|
497
|
+
const [paymentDetail = [], { bonus, bankInfo }] = await Promise.all([
|
|
498
|
+
request.send(payment.getPaymentDetail({ transferType: 'WITHDRAW' })),
|
|
499
|
+
request.send(payment.getPaymentInfo()),
|
|
500
|
+
])
|
|
501
|
+
const bankList = await request.send(payment.getWithdrawBankList())
|
|
502
|
+
const newBankInfo = bankInfo
|
|
503
|
+
.map((item) => {
|
|
504
|
+
const matchedBank = bankList.find((bank) => bank.bankCode === item.bankCode)
|
|
505
|
+
return matchedBank ? { ...item, ...matchedBank } : null
|
|
506
|
+
})
|
|
507
|
+
.filter(Boolean)
|
|
508
|
+
return { paymentDetail, bonus, bankInfo: newBankInfo, bankList }
|
|
509
|
+
},
|
|
510
|
+
fetchPaymentData: async (context, event) => {
|
|
511
|
+
const paymentDetail = await request.send(payment.getPaymentDetail({ transferType: 'WITHDRAW' }))
|
|
512
|
+
const { bonus, bankInfo } = await request.send(payment.getPaymentInfo())
|
|
513
|
+
return { bonus, bankInfo, paymentDetail }
|
|
514
|
+
},
|
|
515
|
+
fetchWithdrawRules: async (context, event) => {
|
|
516
|
+
const { mode } = context
|
|
517
|
+
return await request.send(payment.getDoubleWalletWithdrawRule({ walletType: mode }))
|
|
518
|
+
},
|
|
519
|
+
fetchWithdrawRulePreview: async (context, event) => {
|
|
520
|
+
const data = await request.send(payment.getWithdrawRulePreview({ applyType: 'giveup' }))
|
|
521
|
+
return data
|
|
522
|
+
},
|
|
523
|
+
submitWithdraw: async (context, event) => {
|
|
524
|
+
const { bank, amount } = context
|
|
525
|
+
const { method } = context.paymentDetail[0]
|
|
526
|
+
const branchTemp = ['GCASH', 'PAYM', 'PIX'].includes(bank.bankCode) ? '' : bank.branch
|
|
527
|
+
return await request.send(
|
|
528
|
+
payment.submitWithdrawTransactionVN({
|
|
529
|
+
method,
|
|
530
|
+
amount,
|
|
531
|
+
applyerBankCode: bank.bankCode,
|
|
532
|
+
applyerAccountNumber: bank.accountNumber,
|
|
533
|
+
branch: branchTemp,
|
|
534
|
+
holderName: bank.holderName,
|
|
535
|
+
})
|
|
536
|
+
)
|
|
537
|
+
},
|
|
538
|
+
convertFreeCredit: async (context, event) => {
|
|
539
|
+
return await request.send(payment.convertFreeCredit({ exchangeType: 1 }))
|
|
540
|
+
},
|
|
541
|
+
resetOtp: async (context, event) => {
|
|
542
|
+
const { requestId, target } = context
|
|
543
|
+
return await request.send(user.otpReset({ requestId, target }))
|
|
544
|
+
},
|
|
545
|
+
acknowledge: async (context, event) => {
|
|
546
|
+
const { requestId, target } = context
|
|
547
|
+
const code = event.data
|
|
548
|
+
return await request.send(user.otpAcknowledge({ requestId, target, code }))
|
|
549
|
+
},
|
|
550
|
+
pool: async (context, event) => {
|
|
551
|
+
const { amount } = context
|
|
552
|
+
return await request.send(payment.restore({ amount }))
|
|
553
|
+
},
|
|
554
|
+
giveUp: async (context, event) => {
|
|
555
|
+
return await request.send(payment.giveUp())
|
|
556
|
+
},
|
|
557
|
+
withdrawCheck: async (context, event) => {
|
|
558
|
+
return await request.send(payment.withdrawCheck())
|
|
559
|
+
},
|
|
560
|
+
},
|
|
561
|
+
}
|
|
562
|
+
)
|
|
563
|
+
}
|
package/src/request/request.js
CHANGED
|
@@ -2,6 +2,80 @@ import pickBy from 'lodash/pickBy.js'
|
|
|
2
2
|
import storage from '../util/storage.js'
|
|
3
3
|
|
|
4
4
|
// const pickBy = require('lodash/pickBy')
|
|
5
|
+
const supportVersion2List = [
|
|
6
|
+
'game/play',
|
|
7
|
+
'game/gameReplay',
|
|
8
|
+
'game/logout',
|
|
9
|
+
'game/list/v3/root',
|
|
10
|
+
'game/list/v3/category',
|
|
11
|
+
'game/list/v3/addition',
|
|
12
|
+
'game/list/v3/categoryByRange',
|
|
13
|
+
'game/list/v3/additionByRange',
|
|
14
|
+
'game/list/v3/myFavorite',
|
|
15
|
+
'game/list/v3/addMyFavorite',
|
|
16
|
+
'game/list/v3/removeMyFavorite',
|
|
17
|
+
'login',
|
|
18
|
+
'callback/:strategy',
|
|
19
|
+
'guestLogin',
|
|
20
|
+
'appLogin',
|
|
21
|
+
'logout',
|
|
22
|
+
'self',
|
|
23
|
+
'register',
|
|
24
|
+
'settings/password',
|
|
25
|
+
'verify',
|
|
26
|
+
'reset',
|
|
27
|
+
'acknowledge',
|
|
28
|
+
'friends',
|
|
29
|
+
'friends/home',
|
|
30
|
+
'friends/reward-list',
|
|
31
|
+
'recovery',
|
|
32
|
+
'recovery/abandon',
|
|
33
|
+
'recovery/acknowledge',
|
|
34
|
+
'checkDt',
|
|
35
|
+
'updateDt',
|
|
36
|
+
'checkAC',
|
|
37
|
+
'checkAccount',
|
|
38
|
+
'getAllAvatar',
|
|
39
|
+
'updateUserAvatar',
|
|
40
|
+
'getConfig',
|
|
41
|
+
'getQuickLayout',
|
|
42
|
+
'getNavbarSetting',
|
|
43
|
+
'getAffiliateCode',
|
|
44
|
+
'get-site-config',
|
|
45
|
+
'friends/dashboard',
|
|
46
|
+
'friends/dashboard/list',
|
|
47
|
+
'mailbox/sendMessage',
|
|
48
|
+
'mailbox/getMessageList',
|
|
49
|
+
'mailbox/getMessage',
|
|
50
|
+
'mailbox/updateMessage',
|
|
51
|
+
'mailbox/getMessageTypes',
|
|
52
|
+
]
|
|
53
|
+
|
|
54
|
+
const version2ListName = {
|
|
55
|
+
'game/gameReplay': 'game/game-replay',
|
|
56
|
+
'game/list/v3/categoryByRange': 'game/list/v3/category-by-range',
|
|
57
|
+
'game/list/v3/additionByRange': 'game/list/v3/addition-by-range',
|
|
58
|
+
'game/list/v3/myFavorite': 'game/list/v3/my-favorite',
|
|
59
|
+
'game/list/v3/addMyFavorite': 'game/list/v3/add-my-favorite',
|
|
60
|
+
'game/list/v3/removeMyFavorite': 'game/list/v3/remove-my-favorite',
|
|
61
|
+
guestLogin: 'guest-login',
|
|
62
|
+
appLogin: 'app-login',
|
|
63
|
+
checkDt: 'check-dt',
|
|
64
|
+
updateDt: 'update-dt',
|
|
65
|
+
checkAC: 'check-ac',
|
|
66
|
+
checkAccount: 'check-account',
|
|
67
|
+
getAllAvatar: 'get-all-avatar',
|
|
68
|
+
updateUserAvatar: 'update-user-avatar',
|
|
69
|
+
getConfig: 'get-config',
|
|
70
|
+
getQuickLayout: 'get-quick-layout',
|
|
71
|
+
getNavbarSetting: 'get-navbar-setting',
|
|
72
|
+
getAffiliateCode: 'get-affiliate-code',
|
|
73
|
+
'mailbox/sendMessage': 'mailbox/send-message',
|
|
74
|
+
'mailbox/getMessageList': 'mailbox/get-message-list',
|
|
75
|
+
'mailbox/getMessage': 'mailbox/get-message',
|
|
76
|
+
'mailbox/updateMessage': 'mailbox/update-message',
|
|
77
|
+
'mailbox/getMessageTypes': 'mailbox/get-message-types',
|
|
78
|
+
}
|
|
5
79
|
|
|
6
80
|
function isValid(value) {
|
|
7
81
|
return value !== undefined && value !== null
|
|
@@ -24,7 +98,8 @@ export default class Request {
|
|
|
24
98
|
axiosConfig.headers['X-TH1GAMES-VERSION'] = this.config.version
|
|
25
99
|
axiosConfig.headers['X-TH1GAMES-PLATFORM'] = this.config.platform
|
|
26
100
|
if (this.getToken()) {
|
|
27
|
-
|
|
101
|
+
// 為了支援V2版本的API接口新增Bearer來進行身份驗證
|
|
102
|
+
axiosConfig.headers.Authorization = `Bearer ${this.getToken()}`
|
|
28
103
|
}
|
|
29
104
|
return axiosConfig
|
|
30
105
|
})
|
|
@@ -85,11 +160,21 @@ export default class Request {
|
|
|
85
160
|
|
|
86
161
|
_createConfig(req, cancelToken) {
|
|
87
162
|
const { method, url, params, isPublic, isFormData, headers } = req
|
|
163
|
+
let fullURL = this.config.fullURL
|
|
164
|
+
let urlName = url
|
|
165
|
+
// 有些API會將參數(/?)直接帶在URL上,所以要將參數排除
|
|
166
|
+
if (supportVersion2List.includes(url.split('?')[0])) {
|
|
167
|
+
fullURL = fullURL.replace('/v1/', '/v2/')
|
|
168
|
+
urlName = version2ListName[url] || url
|
|
169
|
+
console.log('*[DEV_ONLY]支援V2API-原本路徑:', url)
|
|
170
|
+
console.log('*[DEV_ONLY]支援V2API-調整路徑:', fullURL, urlName)
|
|
171
|
+
}
|
|
172
|
+
|
|
88
173
|
if (isFormData) {
|
|
89
174
|
return {
|
|
90
|
-
baseURL:
|
|
175
|
+
baseURL: fullURL,
|
|
91
176
|
method,
|
|
92
|
-
url,
|
|
177
|
+
url: urlName,
|
|
93
178
|
cancelToken,
|
|
94
179
|
isPublic,
|
|
95
180
|
headers: { 'Content-Type': 'multipart/form-data' },
|
|
@@ -97,9 +182,9 @@ export default class Request {
|
|
|
97
182
|
}
|
|
98
183
|
} else {
|
|
99
184
|
return {
|
|
100
|
-
baseURL:
|
|
185
|
+
baseURL: fullURL,
|
|
101
186
|
method,
|
|
102
|
-
url,
|
|
187
|
+
url: urlName,
|
|
103
188
|
cancelToken,
|
|
104
189
|
isPublic,
|
|
105
190
|
headers,
|