@jetthai/cuora 1.0.204 → 1.0.302-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.
- package/.husky/pre-commit +4 -0
- package/.prettierignore +1 -0
- package/CHANGELOG.md +848 -0
- package/README.md +6 -0
- package/package.json +6 -9
- package/src/api/activity.js +43 -2
- package/src/api/auth.js +22 -7
- package/src/api/common.js +3 -1
- package/src/api/game.js +20 -7
- package/src/api/mailbox.js +9 -5
- package/src/api/payment.js +167 -19
- package/src/api/user.js +7 -0
- package/src/lib/fingerprint.js +9779 -0
- package/src/machine/activity/activity.js +111 -26
- package/src/machine/activity/activity_cash.js +159 -0
- package/src/machine/activity/cash_rain_activity.js +153 -0
- package/src/machine/activity/continue_deposit_activity.js +11 -2
- package/src/machine/activity/deposit_activity.js +13 -4
- package/src/machine/activity/diamond_shop_activity_cash.js +179 -0
- package/src/machine/activity/diamond_shop_activity_vn.js +54 -89
- package/src/machine/activity/fafafa_activity.js +34 -19
- package/src/machine/activity/{affiliate_invite_friends_activity.js → friend_invite_friends_activity.js} +72 -45
- package/src/machine/activity/index.js +22 -4
- package/src/machine/activity/instant_rebate_activity.js +217 -0
- package/src/machine/activity/invite_friends_activity.js +14 -14
- package/src/machine/activity/jackpot.js +74 -0
- package/src/machine/activity/otp_verified_activity.js +74 -0
- package/src/machine/activity/ranking_activity.js +11 -2
- package/src/machine/activity/roulette_activity_v2.js +90 -0
- package/src/machine/activity/sign_in_activity.js +21 -14
- package/src/machine/activity/sign_in_monthly_activity.js +65 -0
- package/src/machine/activity/specify_bets_activity.js +25 -3
- package/src/machine/activity/specify_turnover_activity.js +25 -3
- package/src/machine/activity/time_bomb_activity.js +11 -2
- package/src/machine/activity/vip_card_activity.js +140 -0
- package/src/machine/auth.js +141 -27
- package/src/machine/auth_otp_v2.js +10 -4
- package/src/machine/auth_otp_v3.js +11 -3
- package/src/machine/bank_binding.js +112 -12
- package/src/machine/bank_binding_amb.js +145 -0
- package/src/machine/common.js +113 -25
- package/src/machine/deposit/amb.js +92 -0
- package/src/machine/deposit/crypto.js +50 -29
- package/src/machine/deposit/crypto_bank.js +317 -0
- package/src/machine/deposit/crypto_bank_cash.js +287 -0
- package/src/machine/deposit/crypto_button.js +174 -39
- package/src/machine/deposit/crypto_cash.js +255 -0
- package/src/machine/deposit/crypto_qrcode.js +148 -0
- package/src/machine/deposit/crypto_qrcode_cash.js +131 -0
- package/src/machine/deposit/crypto_way.js +239 -0
- package/src/machine/deposit/crypto_way_cash.js +256 -0
- package/src/machine/deposit/deposit_fc.js +8 -5
- package/src/machine/deposit/direct.js +111 -16
- package/src/machine/deposit/direct_cash.js +217 -0
- package/src/machine/deposit/float.js +366 -0
- package/src/machine/deposit/index.js +43 -2
- package/src/machine/deposit/krway.js +151 -0
- package/src/machine/deposit/loadcard_cash.js +207 -0
- package/src/machine/deposit/loadcard_vn.js +191 -43
- package/src/machine/deposit/manual_cash.js +356 -0
- package/src/machine/deposit/manual_vn.js +182 -60
- package/src/machine/deposit/qrcode_cash.js +217 -0
- package/src/machine/deposit/qrcode_v2.js +285 -52
- package/src/machine/deposit/usdt.js +144 -0
- package/src/machine/deposit/usdt_cash.js +138 -0
- package/src/machine/deposit/vpay.js +359 -0
- package/src/machine/game_favorite_v2.js +70 -28
- package/src/machine/game_info.js +57 -0
- package/src/machine/game_search_cash.js +390 -0
- package/src/machine/game_search_v2.js +64 -24
- package/src/machine/game_v2_1.js +662 -0
- package/src/machine/honor_board_cash.js +63 -0
- package/src/machine/inbox.js +259 -34
- package/src/machine/index.js +24 -17
- package/src/machine/leaderboard.js +31 -8
- package/src/machine/navbar.js +57 -0
- package/src/machine/promotions.js +171 -0
- package/src/machine/reward.js +74 -7
- package/src/machine/reward_cash.js +219 -0
- package/src/machine/roulette_v2.js +276 -0
- package/src/machine/setting.js +5 -2
- package/src/machine/side_cash.js +110 -0
- package/src/machine/side_v2.js +33 -28
- package/src/machine/user_photo.js +65 -0
- package/src/machine/user_sign_up.js +117 -17
- package/src/machine/withdraw/index.js +23 -0
- package/src/machine/{withdraw_vn.js → withdraw/withdraw_amb.js} +146 -78
- package/src/machine/{withdraw_crypto.js → withdraw/withdraw_crypto.js} +220 -69
- package/src/machine/withdraw/withdraw_crypto2.js +540 -0
- package/src/machine/withdraw/withdraw_crypto_cash.js +319 -0
- package/src/machine/{withdraw_fc.js → withdraw/withdraw_fc.js} +2 -2
- package/src/machine/withdraw/withdraw_krway.js +207 -0
- package/src/machine/withdraw/withdraw_manual.js +595 -0
- package/src/machine/withdraw/withdraw_manual_cash.js +303 -0
- package/src/machine/withdraw/withdraw_vn.js +533 -0
- package/src/machine/withdraw/withdraw_vn2.js +548 -0
- package/src/request/request.js +10 -5
- package/src/util/constant.js +19 -1
- package/src/util/deviceToken.js +18 -8
- package/src/util/index.js +2 -1
- package/src/util/math.js +4 -0
- package/src/util/storage.js +22 -22
- package/dist/bundle.mjs +0 -18462
- package/rollup.config.js +0 -16
- package/src/machine/auth_otp.js +0 -201
- package/src/machine/deposit/qrcode_vn.js +0 -206
- package/src/machine/game.js +0 -285
- package/src/machine/game_favorite.js +0 -123
- package/src/machine/game_search.js +0 -244
- package/src/machine/game_v2.js +0 -356
|
@@ -2,22 +2,28 @@ import { assign, createMachine } from 'xstate'
|
|
|
2
2
|
import payment from '../../api/payment.js'
|
|
3
3
|
|
|
4
4
|
export default function (request) {
|
|
5
|
+
const { appSecret } = request.config
|
|
6
|
+
|
|
5
7
|
return createMachine(
|
|
6
8
|
{
|
|
7
9
|
id: 'manual',
|
|
8
10
|
initial: 'loading',
|
|
9
11
|
context: {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
siteConfig: null,
|
|
13
|
+
paymentDetail: [],
|
|
14
|
+
allBankList: [],
|
|
12
15
|
houseBanks: [],
|
|
13
16
|
playerBanks: [],
|
|
14
|
-
banks: [],
|
|
15
17
|
|
|
16
18
|
amount: null,
|
|
17
19
|
selectedHouseBank: null,
|
|
18
20
|
selectedUserBank: null,
|
|
19
21
|
userAccountNumber: null,
|
|
22
|
+
userIfscCode: null,
|
|
20
23
|
userAccountName: null,
|
|
24
|
+
userAccountBranchName: null,
|
|
25
|
+
userAccountBranchCode: null,
|
|
26
|
+
transactionId: null,
|
|
21
27
|
depositTime: null,
|
|
22
28
|
receipt: null,
|
|
23
29
|
|
|
@@ -28,6 +34,9 @@ export default function (request) {
|
|
|
28
34
|
|
|
29
35
|
calculation: null,
|
|
30
36
|
processing: null,
|
|
37
|
+
|
|
38
|
+
// use for wallet mode 3
|
|
39
|
+
promotion: null,
|
|
31
40
|
},
|
|
32
41
|
states: {
|
|
33
42
|
loading: {
|
|
@@ -35,7 +44,7 @@ export default function (request) {
|
|
|
35
44
|
states: {
|
|
36
45
|
init1: {
|
|
37
46
|
invoke: {
|
|
38
|
-
src: '
|
|
47
|
+
src: 'fetchPaymentDetail',
|
|
39
48
|
onDone: {
|
|
40
49
|
target: 'init2',
|
|
41
50
|
actions: 'setInitData',
|
|
@@ -53,7 +62,7 @@ export default function (request) {
|
|
|
53
62
|
},
|
|
54
63
|
],
|
|
55
64
|
invoke: {
|
|
56
|
-
src: '
|
|
65
|
+
src: 'fetchBanks',
|
|
57
66
|
onDone: {
|
|
58
67
|
target: '#manual.step1',
|
|
59
68
|
actions: 'setBanks',
|
|
@@ -66,9 +75,25 @@ export default function (request) {
|
|
|
66
75
|
},
|
|
67
76
|
},
|
|
68
77
|
step1: {
|
|
69
|
-
initial: '
|
|
78
|
+
initial: 'promotion',
|
|
70
79
|
states: {
|
|
71
|
-
|
|
80
|
+
promotion: {
|
|
81
|
+
always: [
|
|
82
|
+
{
|
|
83
|
+
target: 'idle',
|
|
84
|
+
cond: 'isDoubleWalletMode',
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
target: 'calculating',
|
|
88
|
+
actions: 'setPromotionDefaultAmount',
|
|
89
|
+
cond: 'hasMinPromotionDeposit',
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
target: 'idle',
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
},
|
|
96
|
+
idle: {},
|
|
72
97
|
calculating: {
|
|
73
98
|
invoke: {
|
|
74
99
|
src: 'fetchCalculation',
|
|
@@ -83,10 +108,7 @@ export default function (request) {
|
|
|
83
108
|
},
|
|
84
109
|
debouncing: {
|
|
85
110
|
after: {
|
|
86
|
-
1000: [
|
|
87
|
-
{ target: 'calculating', cond: 'isCalculable'},
|
|
88
|
-
{ target: 'idle'},
|
|
89
|
-
]
|
|
111
|
+
1000: [{ target: 'calculating', cond: 'isCalculable' }, { target: 'idle' }],
|
|
90
112
|
},
|
|
91
113
|
},
|
|
92
114
|
},
|
|
@@ -105,15 +127,39 @@ export default function (request) {
|
|
|
105
127
|
actions: 'clearCalculation',
|
|
106
128
|
},
|
|
107
129
|
TRANSACT: {
|
|
108
|
-
target: '
|
|
130
|
+
target: 'checking',
|
|
109
131
|
cond: 'isCalculated',
|
|
110
132
|
},
|
|
111
133
|
},
|
|
112
134
|
},
|
|
135
|
+
checking: {
|
|
136
|
+
always: [
|
|
137
|
+
{
|
|
138
|
+
target: 'pending',
|
|
139
|
+
cond: (context, event) => {
|
|
140
|
+
const { siteConfig = {}, calculation, promotion } = context
|
|
141
|
+
const { walletMode } = siteConfig
|
|
142
|
+
const { promotionsNo, activityNo } = promotion
|
|
143
|
+
const isNoBonus = promotionsNo === 'none' || activityNo === 'none'
|
|
144
|
+
return walletMode === '4' && !!calculation && !isNoBonus
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
target: '#manual.step2',
|
|
149
|
+
},
|
|
150
|
+
],
|
|
151
|
+
},
|
|
152
|
+
pending: {
|
|
153
|
+
on: {
|
|
154
|
+
CONFIRM: {
|
|
155
|
+
target: '#manual.step2',
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
},
|
|
113
159
|
step2: {
|
|
114
160
|
initial: 'idle',
|
|
115
161
|
states: {
|
|
116
|
-
idle: {
|
|
162
|
+
idle: {},
|
|
117
163
|
calculating: {
|
|
118
164
|
invoke: {
|
|
119
165
|
src: 'fetchCalculation',
|
|
@@ -128,10 +174,7 @@ export default function (request) {
|
|
|
128
174
|
},
|
|
129
175
|
debouncing: {
|
|
130
176
|
after: {
|
|
131
|
-
1000: [
|
|
132
|
-
{ target: 'calculating', cond: 'isCalculable'},
|
|
133
|
-
{ target: 'idle'},
|
|
134
|
-
]
|
|
177
|
+
1000: [{ target: 'calculating', cond: 'isCalculable' }, { target: 'idle' }],
|
|
135
178
|
},
|
|
136
179
|
},
|
|
137
180
|
submitting: {
|
|
@@ -152,7 +195,7 @@ export default function (request) {
|
|
|
152
195
|
actions: ['setAmount', 'clearCalculation'],
|
|
153
196
|
},
|
|
154
197
|
CALCULATE: {
|
|
155
|
-
|
|
198
|
+
target: '.debouncing',
|
|
156
199
|
},
|
|
157
200
|
SELECT_HOUSE_BANK: {
|
|
158
201
|
actions: 'setHouseBank',
|
|
@@ -160,9 +203,21 @@ export default function (request) {
|
|
|
160
203
|
SELECT_USER_BANK: {
|
|
161
204
|
actions: 'setUserBank',
|
|
162
205
|
},
|
|
206
|
+
INPUT_USER_ACCOUNT_BRANCH_NAME: {
|
|
207
|
+
actions: 'setUserAccountBranchName',
|
|
208
|
+
},
|
|
209
|
+
INPUT_USER_ACCOUNT_BRANCH_CODE: {
|
|
210
|
+
actions: 'setUserAccountBranchCode',
|
|
211
|
+
},
|
|
163
212
|
INPUT_USER_ACCOUNT_NUMBER: {
|
|
164
213
|
actions: 'setUserAccountNumber',
|
|
165
214
|
},
|
|
215
|
+
INPUT_USER_IFSC_CODE: {
|
|
216
|
+
actions: 'setUserIfscCode',
|
|
217
|
+
},
|
|
218
|
+
INPUT_TRANSACTION_ID: {
|
|
219
|
+
actions: 'setTransactionId',
|
|
220
|
+
},
|
|
166
221
|
INPUT_USER_ACCOUNT_NAME: {
|
|
167
222
|
actions: 'setUserAccountName',
|
|
168
223
|
},
|
|
@@ -178,7 +233,6 @@ export default function (request) {
|
|
|
178
233
|
},
|
|
179
234
|
SUBMIT: {
|
|
180
235
|
target: '.submitting',
|
|
181
|
-
cond: 'isSubmittable',
|
|
182
236
|
},
|
|
183
237
|
},
|
|
184
238
|
},
|
|
@@ -186,52 +240,61 @@ export default function (request) {
|
|
|
186
240
|
submitted: {},
|
|
187
241
|
fail: {},
|
|
188
242
|
},
|
|
243
|
+
on: {
|
|
244
|
+
SET_PROMOTION: {
|
|
245
|
+
actions: 'setPromotion',
|
|
246
|
+
},
|
|
247
|
+
},
|
|
189
248
|
},
|
|
190
249
|
{
|
|
191
250
|
actions: {
|
|
192
251
|
setInitData: assign((context, event) => {
|
|
193
|
-
const
|
|
194
|
-
const
|
|
195
|
-
const
|
|
196
|
-
const houseBanks =
|
|
252
|
+
const paymentDetail = event.data || []
|
|
253
|
+
const currentPayment = paymentDetail.find((element) => element.category === context.currentCategory)
|
|
254
|
+
const { method, banks = [], processing } = currentPayment || {}
|
|
255
|
+
const houseBanks = banks.map((item) => {
|
|
197
256
|
item.bankCode = item.bankName
|
|
198
257
|
return item
|
|
199
258
|
})
|
|
259
|
+
|
|
200
260
|
return {
|
|
201
|
-
|
|
261
|
+
paymentDetail,
|
|
202
262
|
currentPayment,
|
|
203
|
-
method
|
|
263
|
+
method,
|
|
204
264
|
houseBanks,
|
|
205
265
|
selectedHouseBank: houseBanks[0],
|
|
206
|
-
|
|
207
|
-
processing: currentPayment.processing?.[0],
|
|
266
|
+
processing: processing?.[0],
|
|
208
267
|
}
|
|
209
268
|
}),
|
|
210
269
|
setBanks: assign((context, event) => {
|
|
211
|
-
const
|
|
212
|
-
const
|
|
270
|
+
const { bindingPaymentInfo = {}, bindingPaymentList = {} } = event.data || {}
|
|
271
|
+
const userBankLsit = bindingPaymentInfo.bankList || []
|
|
272
|
+
const allBankList = bindingPaymentList.bankList || []
|
|
273
|
+
const { currentPayment, houseBanks, selectedHouseBank } = context
|
|
274
|
+
const { banks = [] } = currentPayment
|
|
213
275
|
|
|
214
|
-
const
|
|
276
|
+
const formettedPlayerBanks = userBankLsit.map((bank) => {
|
|
215
277
|
bank.shortName = `${bank.bankCode} ${bank.accountNumber.slice(-5)}`
|
|
216
|
-
bank.imageUrl =
|
|
278
|
+
bank.imageUrl = allBankList.find((item) => item.bankCode === bank.bankCode)?.imageUrl
|
|
217
279
|
return bank
|
|
218
280
|
})
|
|
219
|
-
|
|
220
|
-
const userBanks = [...formattedPlayerBanks, ...banks]
|
|
281
|
+
const playerBanks = [...formettedPlayerBanks, ...allBankList]
|
|
221
282
|
|
|
222
283
|
const newHouseBanks = houseBanks.map((houseBank) => {
|
|
223
|
-
return { ...houseBank, ...
|
|
284
|
+
return { ...houseBank, ...allBankList.find((bank) => houseBank.bankName === bank.bankCode) }
|
|
224
285
|
})
|
|
225
|
-
|
|
226
|
-
const newSelectedHouseBank = { ...selectedHouseBank, ...banks.find((bank) => selectedHouseBank.bankName === bank.bankCode) }
|
|
286
|
+
const newSelectedHouseBank = { ...selectedHouseBank, ...allBankList.find((bank) => selectedHouseBank.bankName === bank.bankCode) }
|
|
227
287
|
|
|
228
288
|
return {
|
|
229
|
-
|
|
289
|
+
playerBanks,
|
|
230
290
|
houseBanks: newHouseBanks,
|
|
231
291
|
selectedHouseBank: newSelectedHouseBank,
|
|
232
|
-
selectedUserBank:
|
|
233
|
-
userAccountNumber:
|
|
234
|
-
|
|
292
|
+
selectedUserBank: playerBanks[0],
|
|
293
|
+
userAccountNumber: playerBanks[0].accountNumber,
|
|
294
|
+
userIfscCode: playerBanks[0].ifscCode,
|
|
295
|
+
userAccountName: playerBanks[0].holderName,
|
|
296
|
+
userAccountBranchName: playerBanks[0].branch,
|
|
297
|
+
userAccountBranchCode: playerBanks[0].branchCode,
|
|
235
298
|
}
|
|
236
299
|
}),
|
|
237
300
|
setHouseBank: assign((context, event) => {
|
|
@@ -260,11 +323,24 @@ export default function (request) {
|
|
|
260
323
|
}
|
|
261
324
|
}),
|
|
262
325
|
setUserBank: assign((context, event) => {
|
|
263
|
-
const { accountNumber, holderName } = event.data
|
|
326
|
+
const { accountNumber, ifscCode, holderName, branch, branchCode } = event.data
|
|
264
327
|
return {
|
|
265
328
|
selectedUserBank: event.data,
|
|
266
329
|
userAccountNumber: accountNumber,
|
|
330
|
+
userIfscCode: ifscCode,
|
|
267
331
|
userAccountName: holderName,
|
|
332
|
+
userAccountBranchName: branch,
|
|
333
|
+
userAccountBranchCode: branchCode,
|
|
334
|
+
}
|
|
335
|
+
}),
|
|
336
|
+
setUserAccountBranchName: assign((context, event) => {
|
|
337
|
+
return {
|
|
338
|
+
userAccountBranchName: event.data,
|
|
339
|
+
}
|
|
340
|
+
}),
|
|
341
|
+
setUserAccountBranchCode: assign((context, event) => {
|
|
342
|
+
return {
|
|
343
|
+
userAccountBranchCode: event.data,
|
|
268
344
|
}
|
|
269
345
|
}),
|
|
270
346
|
setUserAccountNumber: assign((context, event) => {
|
|
@@ -272,6 +348,16 @@ export default function (request) {
|
|
|
272
348
|
userAccountNumber: event.data,
|
|
273
349
|
}
|
|
274
350
|
}),
|
|
351
|
+
setUserIfscCode: assign((context, event) => {
|
|
352
|
+
return {
|
|
353
|
+
userIfscCode: event.data,
|
|
354
|
+
}
|
|
355
|
+
}),
|
|
356
|
+
setTransactionId: assign((context, event) => {
|
|
357
|
+
return {
|
|
358
|
+
transactionId: event.data,
|
|
359
|
+
}
|
|
360
|
+
}),
|
|
275
361
|
setUserAccountName: assign((context, event) => {
|
|
276
362
|
return {
|
|
277
363
|
userAccountName: event.data,
|
|
@@ -287,8 +373,21 @@ export default function (request) {
|
|
|
287
373
|
receipt: event.data,
|
|
288
374
|
}
|
|
289
375
|
}),
|
|
376
|
+
setPromotion: assign((context, event) => {
|
|
377
|
+
return {
|
|
378
|
+
promotion: event.data,
|
|
379
|
+
}
|
|
380
|
+
}),
|
|
381
|
+
setPromotionDefaultAmount: assign((context, event) => {
|
|
382
|
+
return {
|
|
383
|
+
amount: context.promotion.minimumAmount,
|
|
384
|
+
}
|
|
385
|
+
}),
|
|
290
386
|
},
|
|
291
387
|
guards: {
|
|
388
|
+
isDoubleWalletMode: (context, event) => {
|
|
389
|
+
return context.siteConfig?.walletMode === '4'
|
|
390
|
+
},
|
|
292
391
|
isCalculable: (context, event) => {
|
|
293
392
|
const {
|
|
294
393
|
amount,
|
|
@@ -299,46 +398,69 @@ export default function (request) {
|
|
|
299
398
|
isCalculated: (context, event) => {
|
|
300
399
|
return context.calculation
|
|
301
400
|
},
|
|
302
|
-
isSubmittable: (context, event) => {
|
|
303
|
-
const { amount, userAccountNumber, userAccountName, depositTime, receipt } = context
|
|
304
|
-
return amount && userAccountNumber && userAccountName && depositTime && receipt
|
|
305
|
-
},
|
|
306
401
|
isProcessing: (context, event) => {
|
|
307
402
|
return context.processing
|
|
308
403
|
},
|
|
404
|
+
hasMinPromotionDeposit: (context, event) => {
|
|
405
|
+
return context.promotion?.minimumAmount
|
|
406
|
+
},
|
|
309
407
|
},
|
|
310
408
|
services: {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
request.send(payment.getPaymentInfo()),
|
|
314
|
-
request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' })),
|
|
315
|
-
])
|
|
316
|
-
return {
|
|
317
|
-
paymentInfo,
|
|
318
|
-
paymentDetails,
|
|
319
|
-
}
|
|
409
|
+
fetchPaymentDetail: async (context, event) => {
|
|
410
|
+
return await request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' }))
|
|
320
411
|
},
|
|
321
|
-
|
|
322
|
-
const
|
|
323
|
-
|
|
412
|
+
fetchBanks: async (context, event) => {
|
|
413
|
+
const [bindingPaymentInfo, bindingPaymentList] = await Promise.all([
|
|
414
|
+
request.send(payment.getBindingPaymentInfo({ appSecret })),
|
|
415
|
+
request.send(payment.getBindingPaymentList({ appSecret })),
|
|
416
|
+
])
|
|
417
|
+
|
|
418
|
+
return { bindingPaymentInfo, bindingPaymentList }
|
|
324
419
|
},
|
|
325
420
|
fetchCalculation: async (context, event) => {
|
|
326
|
-
const { method, amount } = context
|
|
327
|
-
return await request.send(
|
|
421
|
+
const { method, amount, promotion } = context
|
|
422
|
+
return await request.send(
|
|
423
|
+
payment.getDepositExpectedResult({
|
|
424
|
+
method,
|
|
425
|
+
amount,
|
|
426
|
+
promotionsNo: promotion?.activityNo,
|
|
427
|
+
})
|
|
428
|
+
)
|
|
328
429
|
},
|
|
329
430
|
submitDeposit: async (context, event) => {
|
|
330
|
-
const {
|
|
431
|
+
const {
|
|
432
|
+
method,
|
|
433
|
+
amount,
|
|
434
|
+
selectedHouseBank,
|
|
435
|
+
selectedUserBank,
|
|
436
|
+
userAccountNumber,
|
|
437
|
+
userIfscCode,
|
|
438
|
+
userAccountName,
|
|
439
|
+
userAccountBranchName,
|
|
440
|
+
userAccountBranchCode,
|
|
441
|
+
transactionId,
|
|
442
|
+
depositTime,
|
|
443
|
+
receipt,
|
|
444
|
+
promotion,
|
|
445
|
+
} = context
|
|
331
446
|
return await request.send(
|
|
332
447
|
payment.submitDepositTransactionBank({
|
|
333
448
|
method,
|
|
334
449
|
amount,
|
|
335
450
|
targetBankCode: selectedHouseBank.bankName,
|
|
336
451
|
targetAccountNumber: selectedHouseBank.accountNumber,
|
|
452
|
+
targetIfscCode: selectedHouseBank.ifscCode,
|
|
453
|
+
targetUpi: selectedHouseBank.upi,
|
|
337
454
|
applyerBankCode: selectedUserBank.bankCode,
|
|
338
455
|
applyerAccountNumber: userAccountNumber,
|
|
456
|
+
applyerIfscCode: userIfscCode,
|
|
339
457
|
applyerHolderName: userAccountName,
|
|
458
|
+
applyerBranch: userAccountBranchName,
|
|
459
|
+
applyerBranchCode: userAccountBranchCode,
|
|
460
|
+
transactionId,
|
|
340
461
|
depositTime,
|
|
341
462
|
receipt,
|
|
463
|
+
promotionsNo: promotion?.activityNo,
|
|
342
464
|
})
|
|
343
465
|
)
|
|
344
466
|
},
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { assign, createMachine } from 'xstate'
|
|
2
|
+
import payment from '../../api/payment.js'
|
|
3
|
+
import { max } from '../../util'
|
|
4
|
+
|
|
5
|
+
export default function (request, context) {
|
|
6
|
+
const { paymentDetail = [], promotion, selectedAmount } = context || {}
|
|
7
|
+
return createMachine(
|
|
8
|
+
{
|
|
9
|
+
id: 'qrcode_cash',
|
|
10
|
+
initial: 'loading',
|
|
11
|
+
context: {
|
|
12
|
+
paymentDetail,
|
|
13
|
+
promotion,
|
|
14
|
+
selectedAmount,
|
|
15
|
+
|
|
16
|
+
qrcodes: null,
|
|
17
|
+
options: null,
|
|
18
|
+
|
|
19
|
+
selectedQrcode: null,
|
|
20
|
+
|
|
21
|
+
calculation: null,
|
|
22
|
+
|
|
23
|
+
currentCategory: 'qrcode',
|
|
24
|
+
|
|
25
|
+
result: null,
|
|
26
|
+
|
|
27
|
+
bonusPreviewData: [],
|
|
28
|
+
},
|
|
29
|
+
states: {
|
|
30
|
+
loading: {
|
|
31
|
+
always: [
|
|
32
|
+
{
|
|
33
|
+
target: 'debouncing',
|
|
34
|
+
actions: 'setInitData',
|
|
35
|
+
cond: 'hasQrcodeMethods',
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
loaded: {
|
|
40
|
+
after: {
|
|
41
|
+
0: {
|
|
42
|
+
target: 'calculated',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
debouncing: {
|
|
47
|
+
entry: 'clearCalculation',
|
|
48
|
+
after: {
|
|
49
|
+
1000: [
|
|
50
|
+
{
|
|
51
|
+
target: 'calculating',
|
|
52
|
+
cond: (context, event) => {
|
|
53
|
+
const { selectedQrcode, selectedAmount } = context
|
|
54
|
+
if (selectedQrcode && selectedAmount) {
|
|
55
|
+
return selectedQrcode.minimum <= selectedAmount && selectedAmount <= selectedQrcode.maximum
|
|
56
|
+
} else {
|
|
57
|
+
return false
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
target: 'loaded',
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
calculating: {
|
|
68
|
+
invoke: {
|
|
69
|
+
src: 'fetchCalculation',
|
|
70
|
+
onDone: {
|
|
71
|
+
target: 'calculated',
|
|
72
|
+
actions: 'setCalculation',
|
|
73
|
+
},
|
|
74
|
+
onError: {
|
|
75
|
+
target: 'calculated',
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
calculated: {
|
|
80
|
+
on: {
|
|
81
|
+
SUBMIT: {
|
|
82
|
+
target: 'submitting',
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
submitting: {
|
|
87
|
+
invoke: {
|
|
88
|
+
src: 'submitDeposit',
|
|
89
|
+
onDone: {
|
|
90
|
+
target: 'submitted',
|
|
91
|
+
actions: 'setResult',
|
|
92
|
+
},
|
|
93
|
+
onError: {
|
|
94
|
+
target: 'loaded',
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
submitted: {},
|
|
99
|
+
},
|
|
100
|
+
on: {
|
|
101
|
+
SET_PROMOTION: {
|
|
102
|
+
target: '.debouncing',
|
|
103
|
+
actions: 'setPromotion',
|
|
104
|
+
internal: false,
|
|
105
|
+
},
|
|
106
|
+
SELECT_QRCODE: {
|
|
107
|
+
target: '.debouncing',
|
|
108
|
+
actions: 'setQrcode',
|
|
109
|
+
internal: false,
|
|
110
|
+
},
|
|
111
|
+
SELECT_AMOUNT: {
|
|
112
|
+
target: '.debouncing',
|
|
113
|
+
actions: 'setAmount',
|
|
114
|
+
internal: false,
|
|
115
|
+
},
|
|
116
|
+
INPUT_AMOUNT: {
|
|
117
|
+
target: '.debouncing',
|
|
118
|
+
actions: 'inputAmount',
|
|
119
|
+
internal: false,
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
actions: {
|
|
125
|
+
setInitData: assign((context, event) => {
|
|
126
|
+
const { paymentDetail, selectedAmount, promotion } = context
|
|
127
|
+
const qrcodes = paymentDetail.filter((element) => element.category === context.currentCategory && element.transferType === 'deposit')
|
|
128
|
+
const selectedQrcode = qrcodes[0]
|
|
129
|
+
return {
|
|
130
|
+
paymentDetail,
|
|
131
|
+
qrcodes,
|
|
132
|
+
selectedQrcode,
|
|
133
|
+
options: selectedQrcode?.optional,
|
|
134
|
+
selectedAmount: max(promotion?.minimumAmount, selectedQrcode?.minimum, selectedAmount, 0),
|
|
135
|
+
}
|
|
136
|
+
}),
|
|
137
|
+
setPromotion: assign((context, event) => {
|
|
138
|
+
const { selectedAmount } = context
|
|
139
|
+
const promotion = event.data
|
|
140
|
+
const qrcodes = context.qrcodes
|
|
141
|
+
const selectedQrcode = qrcodes[0]
|
|
142
|
+
return {
|
|
143
|
+
promotion,
|
|
144
|
+
qrcodes,
|
|
145
|
+
selectedQrcode,
|
|
146
|
+
options: selectedQrcode?.optional,
|
|
147
|
+
selectedAmount: max(promotion.minimumAmount, selectedQrcode?.minimum, selectedAmount, 0),
|
|
148
|
+
calculation: null,
|
|
149
|
+
}
|
|
150
|
+
}),
|
|
151
|
+
setQrcode: assign((context, event) => {
|
|
152
|
+
const { promotion, selectedAmount } = context
|
|
153
|
+
const selectedQrcode = event.data
|
|
154
|
+
return {
|
|
155
|
+
selectedQrcode,
|
|
156
|
+
options: selectedQrcode.optional,
|
|
157
|
+
selectedAmount: max(promotion.minimumAmount, selectedAmount, 0),
|
|
158
|
+
calculation: null,
|
|
159
|
+
}
|
|
160
|
+
}),
|
|
161
|
+
setAmount: assign((context, event) => {
|
|
162
|
+
// 現金網可自由填額度,grandTotalEnable 欄位感覺不再需要?
|
|
163
|
+
if (context.selectedQrcode?.grandTotalEnable === 1) {
|
|
164
|
+
return { selectedAmount: parseFloat(context.selectedAmount || 0) + parseFloat(event.data) }
|
|
165
|
+
} else {
|
|
166
|
+
return { selectedAmount: event.data }
|
|
167
|
+
}
|
|
168
|
+
}),
|
|
169
|
+
inputAmount: assign((context, event) => {
|
|
170
|
+
return { selectedAmount: event.data }
|
|
171
|
+
}),
|
|
172
|
+
setCalculation: assign((context, event) => {
|
|
173
|
+
return {
|
|
174
|
+
calculation: event.data,
|
|
175
|
+
}
|
|
176
|
+
}),
|
|
177
|
+
clearCalculation: assign((context, event) => {
|
|
178
|
+
return {
|
|
179
|
+
calculation: null,
|
|
180
|
+
}
|
|
181
|
+
}),
|
|
182
|
+
setResult: assign((context, event) => {
|
|
183
|
+
return {
|
|
184
|
+
result: event.data,
|
|
185
|
+
}
|
|
186
|
+
}),
|
|
187
|
+
},
|
|
188
|
+
guards: {
|
|
189
|
+
hasQrcodeMethods: (context, event) => {
|
|
190
|
+
return context.paymentDetail?.filter((element) => element.category === context.currentCategory).length > 0
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
services: {
|
|
194
|
+
fetchCalculation: async (context, event) => {
|
|
195
|
+
const { selectedQrcode, selectedAmount, promotion } = context
|
|
196
|
+
return await request.send(
|
|
197
|
+
payment.getDepositExpectedResult({
|
|
198
|
+
method: selectedQrcode.method,
|
|
199
|
+
amount: selectedAmount,
|
|
200
|
+
promotionsNo: promotion?.promotionsNo,
|
|
201
|
+
})
|
|
202
|
+
)
|
|
203
|
+
},
|
|
204
|
+
submitDeposit: async (context, event) => {
|
|
205
|
+
const { selectedQrcode, selectedAmount, promotion } = context
|
|
206
|
+
return await request.send(
|
|
207
|
+
payment.submitDepositTransaction({
|
|
208
|
+
method: selectedQrcode.method,
|
|
209
|
+
amount: selectedAmount,
|
|
210
|
+
promotionsNo: promotion?.promotionsNo,
|
|
211
|
+
})
|
|
212
|
+
)
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
}
|
|
216
|
+
)
|
|
217
|
+
}
|