@jetthai/cuora 1.1.477-dev.1 → 1.1.478
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/.claude/commands/sync-ai-prompts.md +1 -88
- package/.claude/settings.local.json +1 -3
- package/.github/copilot-instructions.md +57 -64
- package/.husky/post-checkout +3 -3
- package/.husky/pre-push +1 -1
- package/.prettierignore +1 -2
- package/AGENTS.md +58 -65
- package/AI_PROMPT_SOURCE.md +58 -65
- package/CHANGELOG.md +6 -318
- package/CLAUDE.md +58 -65
- package/GEMINI.md +58 -65
- package/README.md +12 -11
- package/package.json +1 -1
- package/scripts/auto-version.js +0 -1
- package/scripts/branch-auto-npm-publish.js +2 -9
- package/src/api/account.js +1 -0
- package/src/api/activity.js +37 -0
- package/src/api/auth.js +31 -0
- package/src/api/game.js +10 -0
- package/src/api/payment.js +52 -1
- package/src/api/user.js +16 -0
- package/src/index.js +2 -2
- package/src/machine/activity/activity.js +209 -0
- package/src/machine/activity/diamond_shop_activity_cash.js +1 -0
- package/src/machine/activity/diamond_shop_activity_fc.js +196 -0
- package/src/machine/activity/diamond_shop_activity_vn.js +178 -0
- package/src/machine/activity/fafafa_activity.js +10 -0
- package/src/machine/activity/index.js +12 -0
- package/src/machine/activity/invite_friends_activity.js +114 -0
- package/src/machine/activity/mini_game_activity.js +68 -0
- package/src/machine/activity/return_bonus_activity.js +153 -0
- package/src/machine/auth.js +59 -37
- package/src/machine/auth_otp_v2.js +177 -0
- package/src/machine/auth_otp_v3.js +19 -30
- package/src/machine/bank_binding_amb.js +146 -0
- package/src/machine/bonus.js +76 -0
- package/src/machine/common.js +55 -0
- package/src/machine/deposit/amb.js +93 -0
- package/src/machine/deposit/crypto_bank.js +330 -0
- package/src/machine/deposit/crypto_qrcode.js +148 -0
- package/src/machine/deposit/crypto_way.js +252 -0
- package/src/machine/deposit/deposit_fc.js +272 -0
- package/src/machine/deposit/direct.js +310 -0
- package/src/machine/deposit/float.js +375 -0
- package/src/machine/deposit/index.js +28 -0
- package/src/machine/deposit/krway.js +151 -0
- package/src/machine/deposit/loadcard_vn.js +351 -0
- package/src/machine/deposit/manual_cash.js +8 -0
- package/src/machine/deposit/manual_vn.js +458 -0
- package/src/machine/deposit/qrcode_v2.js +338 -0
- package/src/machine/deposit/usdt.js +144 -0
- package/src/machine/deposit/virtual_bank_vn.js +269 -0
- package/src/machine/deposit/vpay.js +368 -0
- package/src/machine/game_hot_new.js +79 -0
- package/src/machine/game_info.js +12 -1
- package/src/machine/game_replay.js +46 -0
- package/src/machine/game_search_v2.js +401 -0
- package/src/machine/game_v2_1.js +89 -1
- package/src/machine/honor_board.js +132 -0
- package/src/machine/honor_board_cash.js +18 -15
- package/src/machine/inbox.js +12 -0
- package/src/machine/index.js +32 -0
- package/src/machine/merge.js +57 -0
- package/src/machine/payment_data.js +86 -0
- package/src/machine/promotions.js +170 -0
- package/src/machine/reward.js +255 -0
- package/src/machine/reward_cash.js +39 -0
- package/src/machine/reward_fc.js +98 -0
- package/src/machine/side.js +154 -0
- package/src/machine/side_v2.js +211 -0
- package/src/machine/user_reset_password.js +13 -0
- package/src/machine/user_sign_up.js +0 -3
- package/src/machine/vip_table.js +57 -0
- package/src/machine/websocket.js +4 -0
- package/src/machine/welcome.js +110 -0
- package/src/machine/withdraw/index.js +6 -0
- package/src/machine/withdraw/withdraw_crypto_cash.js +327 -0
- package/src/machine/withdraw/withdraw_krway.js +223 -0
- package/src/machine/withdraw/withdraw_manual.js +536 -0
- package/src/request/request.js +29 -4
- package/src/util/constant.js +1 -0
- package/src/util/index.js +4 -1
- package/src/util/math.js +4 -0
- package/test/auth_otp_v3.test.js +0 -192
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { assign, createMachine } from 'xstate'
|
|
2
|
+
import activity from '../api/activity.js'
|
|
3
|
+
|
|
4
|
+
export default function (request) {
|
|
5
|
+
const { appSecret } = request.config
|
|
6
|
+
return createMachine(
|
|
7
|
+
{
|
|
8
|
+
id: 'honor_board',
|
|
9
|
+
type: 'parallel',
|
|
10
|
+
context: {
|
|
11
|
+
tick: 6000,
|
|
12
|
+
isPlaying: false,
|
|
13
|
+
},
|
|
14
|
+
states: {
|
|
15
|
+
feed: {
|
|
16
|
+
initial: 'updating',
|
|
17
|
+
states: {
|
|
18
|
+
updating: {
|
|
19
|
+
invoke: {
|
|
20
|
+
src: 'fetchHonorBoardList',
|
|
21
|
+
onDone: {
|
|
22
|
+
target: 'waiting',
|
|
23
|
+
actions: 'setBroadcastList',
|
|
24
|
+
},
|
|
25
|
+
onError: {
|
|
26
|
+
target: 'waiting',
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
waiting: {
|
|
31
|
+
after: {
|
|
32
|
+
TIMEOUT: {
|
|
33
|
+
target: 'updating',
|
|
34
|
+
cond: 'isNotInGame',
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
broadcast: {
|
|
41
|
+
initial: 'idle',
|
|
42
|
+
states: {
|
|
43
|
+
idle: {
|
|
44
|
+
on: {
|
|
45
|
+
START_BROADCAST: {
|
|
46
|
+
target: 'picking',
|
|
47
|
+
actions: 'leaveGame',
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
picking: {
|
|
52
|
+
after: {
|
|
53
|
+
5000: {
|
|
54
|
+
target: 'display',
|
|
55
|
+
actions: 'setBroadcast',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
display: {
|
|
60
|
+
after: {
|
|
61
|
+
5000: {
|
|
62
|
+
target: 'picking',
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
on: {
|
|
68
|
+
RESET_BROADCAST: {
|
|
69
|
+
target: '.idle',
|
|
70
|
+
actions: 'resetBroadcast',
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
delays: {
|
|
78
|
+
TIMEOUT: (context, event) => {
|
|
79
|
+
return context.tick * 10
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
actions: {
|
|
83
|
+
setBroadcastList: assign((context, event) => {
|
|
84
|
+
const broadcastList = (event.data || []).map((item) => item.data).flat()
|
|
85
|
+
const sortBroadcastList = broadcastList.sort((a, b) => {
|
|
86
|
+
if (!a.time) return -1
|
|
87
|
+
if (!b.time) return 1
|
|
88
|
+
return a.time - b.time
|
|
89
|
+
})
|
|
90
|
+
return { broadcastList: sortBroadcastList }
|
|
91
|
+
}),
|
|
92
|
+
setBroadcast: assign((context, event) => {
|
|
93
|
+
const { broadcastList = [], sentNormalBroadcastList = [], normalBroadcast = [] } = context
|
|
94
|
+
let sentNormalList = sentNormalBroadcastList
|
|
95
|
+
if (normalBroadcast) {
|
|
96
|
+
sentNormalList = [...sentNormalBroadcastList, normalBroadcast]
|
|
97
|
+
}
|
|
98
|
+
const nextNormalBroadcast = broadcastList?.find((broadcast) => {
|
|
99
|
+
return !sentNormalList.some((item) => item.broadcastId === broadcast.broadcastId)
|
|
100
|
+
})
|
|
101
|
+
return {
|
|
102
|
+
normalBroadcast: nextNormalBroadcast,
|
|
103
|
+
sentNormalBroadcastList: sentNormalList,
|
|
104
|
+
}
|
|
105
|
+
}),
|
|
106
|
+
resetBroadcast: assign((context, event) => {
|
|
107
|
+
return {
|
|
108
|
+
isPlaying: true,
|
|
109
|
+
normalBroadcast: null,
|
|
110
|
+
sentNormalBroadcastList: [],
|
|
111
|
+
}
|
|
112
|
+
}),
|
|
113
|
+
leaveGame: assign((context, event) => {
|
|
114
|
+
return {
|
|
115
|
+
isPlaying: false,
|
|
116
|
+
}
|
|
117
|
+
}),
|
|
118
|
+
},
|
|
119
|
+
guards: {
|
|
120
|
+
isNotInGame: (context, event) => {
|
|
121
|
+
return !context.isPlaying
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
services: {
|
|
125
|
+
fetchHonorBoardList: async (context, event) => {
|
|
126
|
+
const { data } = await request.send(activity.getHonorBroadcast({ isPwa: true, appSecret }))
|
|
127
|
+
return data
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
}
|
|
131
|
+
)
|
|
132
|
+
}
|
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
import { createMachine, assign } from 'xstate'
|
|
2
2
|
import activity from '../api/activity.js'
|
|
3
3
|
|
|
4
|
-
const TAB_KEY_BY_TYPE = {
|
|
5
|
-
CASH_RAIN: 'cashRain',
|
|
6
|
-
DEPOSIT: 'deposit',
|
|
7
|
-
FREE_ROULETTE_SPIN: 'roulette',
|
|
8
|
-
JACKPOT: 'jackpot',
|
|
9
|
-
WIN_SCORE: 'bigWin',
|
|
10
|
-
WIN_MULTIPLIER: 'maxBet',
|
|
11
|
-
WITHDRAW: 'withdraw',
|
|
12
|
-
LATEST_BET: 'latestBet',
|
|
13
|
-
}
|
|
14
|
-
|
|
15
4
|
export default function (request) {
|
|
16
5
|
const { appSecret } = request.config
|
|
17
6
|
return createMachine(
|
|
@@ -28,7 +17,6 @@ export default function (request) {
|
|
|
28
17
|
bigWin: {},
|
|
29
18
|
maxBet: {},
|
|
30
19
|
withdraw: {},
|
|
31
|
-
latestBet: {},
|
|
32
20
|
},
|
|
33
21
|
states: {
|
|
34
22
|
fetching: {
|
|
@@ -56,8 +44,24 @@ export default function (request) {
|
|
|
56
44
|
actions: {
|
|
57
45
|
setHonorBoardList: assign((context, event) => {
|
|
58
46
|
return {
|
|
59
|
-
|
|
60
|
-
|
|
47
|
+
tabs: (event.data || []).map((list) => {
|
|
48
|
+
switch (list.type) {
|
|
49
|
+
case 'CASH_RAIN':
|
|
50
|
+
return 'cashRain'
|
|
51
|
+
case 'DEPOSIT':
|
|
52
|
+
return 'deposit'
|
|
53
|
+
case 'FREE_ROULETTE_SPIN':
|
|
54
|
+
return 'roulette'
|
|
55
|
+
case 'JACKPOT':
|
|
56
|
+
return 'jackpot'
|
|
57
|
+
case 'WIN_SCORE':
|
|
58
|
+
return 'bigWin'
|
|
59
|
+
case 'WIN_MULTIPLIER':
|
|
60
|
+
return 'maxBet'
|
|
61
|
+
case 'WITHDRAW':
|
|
62
|
+
return 'withdraw'
|
|
63
|
+
}
|
|
64
|
+
}),
|
|
61
65
|
cashRain: (event.data || []).find((item) => item.type === 'CASH_RAIN') || {},
|
|
62
66
|
deposit: (event.data || []).find((item) => item.type === 'DEPOSIT') || {},
|
|
63
67
|
roulette: (event.data || []).find((item) => item.type === 'FREE_ROULETTE_SPIN') || {},
|
|
@@ -65,7 +69,6 @@ export default function (request) {
|
|
|
65
69
|
bigWin: (event.data || []).find((item) => item.type === 'WIN_SCORE') || {},
|
|
66
70
|
maxBet: (event.data || []).find((item) => item.type === 'WIN_MULTIPLIER') || {},
|
|
67
71
|
withdraw: (event.data || []).find((item) => item.type === 'WITHDRAW') || {},
|
|
68
|
-
latestBet: (event.data || []).find((item) => item.type === 'LATEST_BET') || {},
|
|
69
72
|
}
|
|
70
73
|
}),
|
|
71
74
|
},
|
package/src/machine/inbox.js
CHANGED
|
@@ -223,6 +223,10 @@ export default function (request) {
|
|
|
223
223
|
PRESET_TAB: {
|
|
224
224
|
actions: ['setCurrentTab', 'hideMessage'],
|
|
225
225
|
},
|
|
226
|
+
RESET: {
|
|
227
|
+
target: '.loading',
|
|
228
|
+
actions: 'reset',
|
|
229
|
+
},
|
|
226
230
|
INQUIRY_ACCOUNT: {
|
|
227
231
|
target: '.inquiring',
|
|
228
232
|
actions: 'resetPage',
|
|
@@ -279,6 +283,14 @@ export default function (request) {
|
|
|
279
283
|
const lang = event.data.locale || context.lang || 'en-US'
|
|
280
284
|
return { lang }
|
|
281
285
|
}),
|
|
286
|
+
reset: assign((context, event) => {
|
|
287
|
+
return {
|
|
288
|
+
currentTab: null,
|
|
289
|
+
inbox: {},
|
|
290
|
+
messageDetail: null,
|
|
291
|
+
currentMessage: null,
|
|
292
|
+
}
|
|
293
|
+
}),
|
|
282
294
|
resetPage: assign((context, event) => {
|
|
283
295
|
const { inbox, currentTab } = JSON.parse(JSON.stringify(context))
|
|
284
296
|
inbox[currentTab].page = -1
|
package/src/machine/index.js
CHANGED
|
@@ -1,26 +1,42 @@
|
|
|
1
1
|
import activity from './activity/index.js'
|
|
2
2
|
import auth from './auth.js'
|
|
3
|
+
import welcome from './welcome.js'
|
|
3
4
|
import common from './common.js'
|
|
4
5
|
import error from './error.js'
|
|
5
6
|
import game_v2_1 from './game_v2_1.js'
|
|
6
7
|
import game_favorite_v2 from './game_favorite_v2.js'
|
|
7
8
|
import game_search_cash from './game_search_cash.js'
|
|
9
|
+
import game_search_v2 from './game_search_v2.js'
|
|
10
|
+
import game_hot_new from './game_hot_new.js'
|
|
8
11
|
import game_info from './game_info.js'
|
|
12
|
+
import game_replay from './game_replay.js'
|
|
9
13
|
import game_betslip from './game_betslip.js'
|
|
10
14
|
import inbox from './inbox.js'
|
|
15
|
+
import merge from './merge.js'
|
|
16
|
+
import payment_data from './payment_data.js'
|
|
17
|
+
import reward_fc from './reward_fc.js'
|
|
18
|
+
import reward from './reward.js'
|
|
11
19
|
import reward_cash from './reward_cash.js'
|
|
12
20
|
import setting from './setting.js'
|
|
21
|
+
import side from './side.js'
|
|
22
|
+
import side_v2 from './side_v2.js'
|
|
13
23
|
import side_cash from './side_cash.js'
|
|
14
24
|
import user_info from './user_info.js'
|
|
15
25
|
import user_sign_up from './user_sign_up.js'
|
|
16
26
|
import user_reset_password from './user_reset_password.js'
|
|
17
27
|
import bank_binding from './bank_binding.js'
|
|
28
|
+
import bank_binding_amb from './bank_binding_amb.js'
|
|
18
29
|
import withdraw from './withdraw/index.js'
|
|
19
30
|
import deposit from './deposit/index.js'
|
|
31
|
+
import bonus from './bonus.js'
|
|
20
32
|
import leaderboard from './leaderboard.js'
|
|
33
|
+
import auth_otp_v2 from './auth_otp_v2.js'
|
|
21
34
|
import auth_otp_v3 from './auth_otp_v3.js'
|
|
35
|
+
import vip_table from './vip_table.js'
|
|
36
|
+
import promotions from './promotions.js'
|
|
22
37
|
import roulette_v2 from './roulette_v2.js'
|
|
23
38
|
import honor_board_cash from './honor_board_cash.js'
|
|
39
|
+
import honor_board from './honor_board.js'
|
|
24
40
|
import user_photo from './user_photo.js'
|
|
25
41
|
import navbar from './navbar.js'
|
|
26
42
|
import websocket from './websocket.js'
|
|
@@ -29,26 +45,42 @@ import ranking from './ranking.js'
|
|
|
29
45
|
export default {
|
|
30
46
|
...activity,
|
|
31
47
|
auth,
|
|
48
|
+
welcome,
|
|
32
49
|
common,
|
|
33
50
|
error,
|
|
34
51
|
game_favorite_v2,
|
|
35
52
|
game_search_cash,
|
|
53
|
+
game_search_v2,
|
|
54
|
+
game_hot_new,
|
|
36
55
|
game_info,
|
|
56
|
+
game_replay,
|
|
37
57
|
game_betslip,
|
|
38
58
|
inbox,
|
|
59
|
+
merge,
|
|
60
|
+
payment_data,
|
|
61
|
+
reward,
|
|
39
62
|
reward_cash,
|
|
63
|
+
reward_fc,
|
|
40
64
|
setting,
|
|
65
|
+
side,
|
|
66
|
+
side_v2,
|
|
41
67
|
side_cash,
|
|
42
68
|
game_v2_1,
|
|
43
69
|
user_info,
|
|
44
70
|
user_sign_up,
|
|
45
71
|
user_reset_password,
|
|
46
72
|
bank_binding,
|
|
73
|
+
bank_binding_amb,
|
|
47
74
|
...deposit,
|
|
75
|
+
bonus,
|
|
48
76
|
leaderboard,
|
|
77
|
+
auth_otp_v2,
|
|
49
78
|
auth_otp_v3,
|
|
79
|
+
vip_table,
|
|
80
|
+
promotions,
|
|
50
81
|
roulette_v2,
|
|
51
82
|
honor_board_cash,
|
|
83
|
+
honor_board,
|
|
52
84
|
user_photo,
|
|
53
85
|
navbar,
|
|
54
86
|
...withdraw,
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { assign, createMachine } from 'xstate'
|
|
2
|
+
import api from '../api/payment.js'
|
|
3
|
+
export default function (request) {
|
|
4
|
+
return createMachine(
|
|
5
|
+
{
|
|
6
|
+
id: 'merge',
|
|
7
|
+
initial: 'idle',
|
|
8
|
+
context: {
|
|
9
|
+
userInfo: null,
|
|
10
|
+
},
|
|
11
|
+
states: {
|
|
12
|
+
idle: {
|
|
13
|
+
always: [{ target: 'mergeable', cond: 'isMergeable' }],
|
|
14
|
+
},
|
|
15
|
+
mergeable: {
|
|
16
|
+
on: {
|
|
17
|
+
MERGE: {
|
|
18
|
+
target: 'merging',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
merging: {
|
|
23
|
+
invoke: {
|
|
24
|
+
src: 'mergeWallet',
|
|
25
|
+
onDone: { target: 'idle' },
|
|
26
|
+
onError: { target: 'idle' },
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
on: {
|
|
31
|
+
SET_USER_INFO: {
|
|
32
|
+
actions: 'setUserInfo',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
actions: {
|
|
38
|
+
setUserInfo: assign((context, event) => {
|
|
39
|
+
return {
|
|
40
|
+
userInfo: event.data,
|
|
41
|
+
}
|
|
42
|
+
}),
|
|
43
|
+
},
|
|
44
|
+
guards: {
|
|
45
|
+
isMergeable: (context, event) => {
|
|
46
|
+
const { retain, balance, withdraw_policy } = context.userInfo || {}
|
|
47
|
+
return retain > 0 && (parseFloat(balance) <= 5 || withdraw_policy === 'FREE')
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
services: {
|
|
51
|
+
mergeWallet: async (context, event) => {
|
|
52
|
+
return await request.send(api.mergeWallet())
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
}
|
|
56
|
+
)
|
|
57
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { assign, createMachine } from 'xstate'
|
|
2
|
+
import payment from '../api/payment.js'
|
|
3
|
+
|
|
4
|
+
export default function (request) {
|
|
5
|
+
return createMachine(
|
|
6
|
+
{
|
|
7
|
+
id: 'payment_data',
|
|
8
|
+
initial: 'idle',
|
|
9
|
+
context: {
|
|
10
|
+
transactionList: [],
|
|
11
|
+
spotMarketTime: null,
|
|
12
|
+
spotMarketList: [],
|
|
13
|
+
},
|
|
14
|
+
states: {
|
|
15
|
+
idle: {},
|
|
16
|
+
fetchingTransactionList: {
|
|
17
|
+
invoke: {
|
|
18
|
+
src: 'fetchTransactionList',
|
|
19
|
+
onDone: {
|
|
20
|
+
target: 'idle',
|
|
21
|
+
actions: 'setTransactionList',
|
|
22
|
+
},
|
|
23
|
+
onError: {
|
|
24
|
+
target: 'idle',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
fetchingSpotMarket: {
|
|
29
|
+
invoke: {
|
|
30
|
+
src: 'fetchSpotMarket',
|
|
31
|
+
onDone: {
|
|
32
|
+
target: 'idle',
|
|
33
|
+
actions: 'setSpotMarket',
|
|
34
|
+
},
|
|
35
|
+
onError: {
|
|
36
|
+
target: 'idle',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
on: {
|
|
42
|
+
GET_TRANSACTION_LIST: {
|
|
43
|
+
target: 'fetchingTransactionList',
|
|
44
|
+
},
|
|
45
|
+
GET_SPOT_MARKET: {
|
|
46
|
+
target: 'fetchingSpotMarket',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
actions: {
|
|
52
|
+
setTransactionList: assign((context, event) => {
|
|
53
|
+
const statusMap = {
|
|
54
|
+
2: 'pending',
|
|
55
|
+
3: 'success',
|
|
56
|
+
4: 'reject',
|
|
57
|
+
8: 'expired',
|
|
58
|
+
}
|
|
59
|
+
const transactionList = event.data.map((item) => {
|
|
60
|
+
item.statusName = statusMap[item.status]
|
|
61
|
+
return item
|
|
62
|
+
})
|
|
63
|
+
return {
|
|
64
|
+
transactionList,
|
|
65
|
+
}
|
|
66
|
+
}),
|
|
67
|
+
setSpotMarket: assign((context, event) => {
|
|
68
|
+
const { timestamp, data } = event.data
|
|
69
|
+
return {
|
|
70
|
+
spotMarketTime: timestamp,
|
|
71
|
+
spotMarketList: data.slice(0, 100),
|
|
72
|
+
}
|
|
73
|
+
}),
|
|
74
|
+
},
|
|
75
|
+
services: {
|
|
76
|
+
fetchTransactionList: async (context, event) => {
|
|
77
|
+
const returnDays = event.data
|
|
78
|
+
return await request.send(payment.getPaymentHistory(returnDays))
|
|
79
|
+
},
|
|
80
|
+
fetchSpotMarket: async (context, event) => {
|
|
81
|
+
return await request.send(payment.getSpotMarket())
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
}
|
|
85
|
+
)
|
|
86
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { assign, createMachine } from 'xstate'
|
|
2
|
+
import payment from '../api/payment.js'
|
|
3
|
+
|
|
4
|
+
export default function (request) {
|
|
5
|
+
return createMachine(
|
|
6
|
+
{
|
|
7
|
+
id: 'promotions',
|
|
8
|
+
initial: 'loading',
|
|
9
|
+
context: {
|
|
10
|
+
userInfo: {},
|
|
11
|
+
siteConfig: {},
|
|
12
|
+
withdrawRule: {},
|
|
13
|
+
promotionsList: [],
|
|
14
|
+
selectedPromo: {},
|
|
15
|
+
amount: null,
|
|
16
|
+
callback: () => {},
|
|
17
|
+
},
|
|
18
|
+
states: {
|
|
19
|
+
loading: {
|
|
20
|
+
invoke: {
|
|
21
|
+
src: 'fetchPromotionsList',
|
|
22
|
+
onDone: {
|
|
23
|
+
target: 'loaded',
|
|
24
|
+
actions: 'setPromotionsList',
|
|
25
|
+
},
|
|
26
|
+
onError: {
|
|
27
|
+
target: 'fail',
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
loaded: {
|
|
32
|
+
on: {
|
|
33
|
+
SELECT_PROMO: {
|
|
34
|
+
actions: ['reset', 'setSelectedPromo'],
|
|
35
|
+
},
|
|
36
|
+
SET_AMOUNT: {
|
|
37
|
+
actions: 'setAmount',
|
|
38
|
+
},
|
|
39
|
+
JOIN: {
|
|
40
|
+
target: 'fetching',
|
|
41
|
+
cond: 'isValidAmount',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
fetching: {
|
|
46
|
+
invoke: {
|
|
47
|
+
src: 'fetchWithdrawRulePreview',
|
|
48
|
+
onDone: {
|
|
49
|
+
target: 'pending',
|
|
50
|
+
actions: 'setWithdrawRulePreview',
|
|
51
|
+
},
|
|
52
|
+
onError: {
|
|
53
|
+
target: 'loaded',
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
pending: {
|
|
58
|
+
on: {
|
|
59
|
+
CONFIRM: {
|
|
60
|
+
target: 'applying',
|
|
61
|
+
actions: 'setCallback',
|
|
62
|
+
},
|
|
63
|
+
BACK: {
|
|
64
|
+
target: 'loaded',
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
applying: {
|
|
69
|
+
invoke: {
|
|
70
|
+
src: 'applyPromotion',
|
|
71
|
+
onDone: {
|
|
72
|
+
target: 'applied',
|
|
73
|
+
},
|
|
74
|
+
onError: {
|
|
75
|
+
target: 'loaded',
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
applied: {
|
|
80
|
+
entry: 'doCallback',
|
|
81
|
+
},
|
|
82
|
+
fail: {},
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
actions: {
|
|
87
|
+
setPromotionsList: assign((context, event) => {
|
|
88
|
+
const promotionsList = JSON.parse(JSON.stringify(event.data))
|
|
89
|
+
const { userInfo, siteConfig } = context
|
|
90
|
+
const { withdraw_rule, balance, bank_amount } = userInfo
|
|
91
|
+
const { currencyConversionLimit } = siteConfig
|
|
92
|
+
const balanceAvailable = parseFloat(bank_amount) < parseFloat(`${currencyConversionLimit}`)
|
|
93
|
+
const isFreeLimitRule = withdraw_rule.includes('FREE_LIMIT')
|
|
94
|
+
const includesDefaultRule = withdraw_rule === 'DEFAULT' || withdraw_rule.includes('FREE_DEFAULT')
|
|
95
|
+
|
|
96
|
+
if (!balanceAvailable && includesDefaultRule) {
|
|
97
|
+
promotionsList.map((item) => {
|
|
98
|
+
item.attendEnable = !item.withdrawRule.includes('FREE_LIMIT')
|
|
99
|
+
return item
|
|
100
|
+
})
|
|
101
|
+
} else if (!balanceAvailable && isFreeLimitRule) {
|
|
102
|
+
promotionsList.map((item) => {
|
|
103
|
+
item.attendEnable = false
|
|
104
|
+
return item
|
|
105
|
+
})
|
|
106
|
+
} else {
|
|
107
|
+
promotionsList.map((item) => {
|
|
108
|
+
item.attendEnable = true
|
|
109
|
+
return item
|
|
110
|
+
})
|
|
111
|
+
}
|
|
112
|
+
return {
|
|
113
|
+
promotionsList,
|
|
114
|
+
selectedPromo: promotionsList[0],
|
|
115
|
+
}
|
|
116
|
+
}),
|
|
117
|
+
setSelectedPromo: assign((context, event) => {
|
|
118
|
+
return {
|
|
119
|
+
selectedPromo: event.data,
|
|
120
|
+
}
|
|
121
|
+
}),
|
|
122
|
+
setAmount: assign((context, event) => {
|
|
123
|
+
return {
|
|
124
|
+
amount: event.data,
|
|
125
|
+
}
|
|
126
|
+
}),
|
|
127
|
+
setWithdrawRulePreview: assign((context, event) => {
|
|
128
|
+
return {
|
|
129
|
+
withdrawRule: event.data,
|
|
130
|
+
}
|
|
131
|
+
}),
|
|
132
|
+
setCallback: assign((context, event) => {
|
|
133
|
+
return {
|
|
134
|
+
callback: event.data?.callback || (() => {}),
|
|
135
|
+
}
|
|
136
|
+
}),
|
|
137
|
+
doCallback: (context, event) => {
|
|
138
|
+
context.callback()
|
|
139
|
+
},
|
|
140
|
+
reset: assign((context, event) => {
|
|
141
|
+
return {
|
|
142
|
+
amount: null,
|
|
143
|
+
}
|
|
144
|
+
}),
|
|
145
|
+
},
|
|
146
|
+
guards: {
|
|
147
|
+
isValidAmount: (context, event) => {
|
|
148
|
+
const { selectedPromo, amount } = context
|
|
149
|
+
return selectedPromo.minimumAmount <= amount
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
services: {
|
|
153
|
+
fetchPromotionsList: async (context, event) => {
|
|
154
|
+
return await request.send(payment.getPromotionsList())
|
|
155
|
+
},
|
|
156
|
+
fetchWithdrawRulePreview: async (context, event) => {
|
|
157
|
+
const { selectedPromo, amount } = context
|
|
158
|
+
const data = await request.send(
|
|
159
|
+
payment.getWithdrawRulePreview({ applyType: 'promotions', applyNo: selectedPromo.promotionsNo, amount: parseFloat(amount) })
|
|
160
|
+
)
|
|
161
|
+
return data
|
|
162
|
+
},
|
|
163
|
+
applyPromotion: async (context, event) => {
|
|
164
|
+
const { selectedPromo, amount } = context
|
|
165
|
+
return await request.send(payment.applyPromotions({ promotionsNo: selectedPromo.promotionsNo, amount: parseFloat(amount) }))
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
}
|
|
169
|
+
)
|
|
170
|
+
}
|