@jetthai/cuora 1.1.476-dev.1 → 1.1.476
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 +58 -68
- package/.husky/post-checkout +3 -3
- package/.husky/pre-push +1 -1
- package/.prettierignore +1 -2
- package/AGENTS.md +59 -69
- package/AI_PROMPT_SOURCE.md +59 -69
- package/CHANGELOG.md +5 -273
- package/CLAUDE.md +59 -69
- package/GEMINI.md +59 -69
- 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/activity_cash.js +0 -1
- 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 +28 -0
- 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,177 @@
|
|
|
1
|
+
import { assign, createMachine } from 'xstate'
|
|
2
|
+
import user from '../api/user.js'
|
|
3
|
+
|
|
4
|
+
export default function (request) {
|
|
5
|
+
return createMachine(
|
|
6
|
+
{
|
|
7
|
+
id: 'auth_otp_v2',
|
|
8
|
+
initial: 'idle',
|
|
9
|
+
context: {
|
|
10
|
+
strategy: null,
|
|
11
|
+
requestId: null,
|
|
12
|
+
ttl: null,
|
|
13
|
+
target: {},
|
|
14
|
+
acknowledgeTtl: null,
|
|
15
|
+
newPassword: null,
|
|
16
|
+
},
|
|
17
|
+
states: {
|
|
18
|
+
idle: {
|
|
19
|
+
on: {
|
|
20
|
+
SET_OTP_INITIALIZATION: {
|
|
21
|
+
target: 'otp',
|
|
22
|
+
actions: 'setOtpResult',
|
|
23
|
+
},
|
|
24
|
+
SEND_OTP_EMAIL: {
|
|
25
|
+
target: 'otpFetching',
|
|
26
|
+
actions: 'setStrategyEmail',
|
|
27
|
+
},
|
|
28
|
+
SEND_OTP_PHONE: {
|
|
29
|
+
target: 'otpFetching',
|
|
30
|
+
actions: 'setStrategyPhone',
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
otpFetching: {
|
|
35
|
+
invoke: {
|
|
36
|
+
src: 'sendOtp',
|
|
37
|
+
onDone: [
|
|
38
|
+
{
|
|
39
|
+
target: 'acknowledged',
|
|
40
|
+
cond: (context, event) => event.data.status === 'success-verified',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
target: 'otp',
|
|
44
|
+
actions: 'setOtpResult',
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
onError: {
|
|
48
|
+
target: 'idle',
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
otp: {
|
|
53
|
+
after: {
|
|
54
|
+
1000: [
|
|
55
|
+
{
|
|
56
|
+
target: 'otp',
|
|
57
|
+
actions: 'decreaseTtl',
|
|
58
|
+
cond: (context) => context.ttl > 0,
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
target: 'idle',
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
},
|
|
65
|
+
on: {
|
|
66
|
+
ACKNOWLEDGE: {
|
|
67
|
+
target: 'acknowledging',
|
|
68
|
+
},
|
|
69
|
+
BACK: {
|
|
70
|
+
target: 'idle',
|
|
71
|
+
},
|
|
72
|
+
RESET_OTP: {
|
|
73
|
+
target: 'otpResetting',
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
otpResetting: {
|
|
78
|
+
invoke: {
|
|
79
|
+
src: 'resetOtp',
|
|
80
|
+
onDone: {
|
|
81
|
+
target: 'otp',
|
|
82
|
+
actions: 'setOtpResult',
|
|
83
|
+
},
|
|
84
|
+
onError: {
|
|
85
|
+
target: 'otp',
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
acknowledging: {
|
|
90
|
+
invoke: {
|
|
91
|
+
src: 'acknowledge',
|
|
92
|
+
onDone: {
|
|
93
|
+
target: 'acknowledged',
|
|
94
|
+
actions: 'setAcknowledgeResult',
|
|
95
|
+
},
|
|
96
|
+
onError: [
|
|
97
|
+
{
|
|
98
|
+
target: 'idle',
|
|
99
|
+
cond: (context, event) => event.data.code === 'ERR_A108',
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
target: 'otp',
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
acknowledged: {
|
|
108
|
+
// after: {
|
|
109
|
+
// 1000: [
|
|
110
|
+
// {
|
|
111
|
+
// target: 'acknowledged',
|
|
112
|
+
// actions: 'decreaseAcknowledgeTtl',
|
|
113
|
+
// cond: (context) => context.acknowledgeTtl > 0,
|
|
114
|
+
// },
|
|
115
|
+
// {
|
|
116
|
+
// target: 'idle',
|
|
117
|
+
// },
|
|
118
|
+
// ],
|
|
119
|
+
// },
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
actions: {
|
|
125
|
+
setStrategyPhone: assign((context, event) => {
|
|
126
|
+
return {
|
|
127
|
+
strategy: 'phone',
|
|
128
|
+
}
|
|
129
|
+
}),
|
|
130
|
+
setStrategyEmail: assign((context, event) => {
|
|
131
|
+
return {
|
|
132
|
+
strategy: 'email',
|
|
133
|
+
}
|
|
134
|
+
}),
|
|
135
|
+
setOtpResult: assign((context, event) => {
|
|
136
|
+
const { requestId, ttl, target } = event.data
|
|
137
|
+
return {
|
|
138
|
+
requestId,
|
|
139
|
+
ttl,
|
|
140
|
+
target,
|
|
141
|
+
}
|
|
142
|
+
}),
|
|
143
|
+
decreaseTtl: assign((context, event) => {
|
|
144
|
+
return {
|
|
145
|
+
ttl: Math.max(context.ttl - 1, 0),
|
|
146
|
+
}
|
|
147
|
+
}),
|
|
148
|
+
setAcknowledgeResult: assign((context, event) => {
|
|
149
|
+
const { requestId, ttl, target } = event.data
|
|
150
|
+
return {
|
|
151
|
+
acknowledgeTtl: ttl,
|
|
152
|
+
}
|
|
153
|
+
}),
|
|
154
|
+
decreaseAcknowledgeTtl: assign((context, event) => {
|
|
155
|
+
return {
|
|
156
|
+
acknowledgeTtl: Math.max(context.acknowledgeTtl - 1, 0),
|
|
157
|
+
}
|
|
158
|
+
}),
|
|
159
|
+
},
|
|
160
|
+
services: {
|
|
161
|
+
sendOtp: async (context, event) => {
|
|
162
|
+
const { strategy } = context
|
|
163
|
+
return await request.send(user.verifyV2Initiate({ strategy }))
|
|
164
|
+
},
|
|
165
|
+
resetOtp: async (context, event) => {
|
|
166
|
+
const { requestId, target } = context
|
|
167
|
+
return await request.send(user.otpReset({ requestId, target }))
|
|
168
|
+
},
|
|
169
|
+
acknowledge: async (context, event) => {
|
|
170
|
+
const { requestId, target } = context
|
|
171
|
+
const code = event.data
|
|
172
|
+
return await request.send(user.otpAcknowledge({ requestId, target, code }))
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
}
|
|
176
|
+
)
|
|
177
|
+
}
|
|
@@ -48,29 +48,16 @@ export default function (request) {
|
|
|
48
48
|
{ target: 'notVerified', cond: 'isNotVerified' },
|
|
49
49
|
],
|
|
50
50
|
},
|
|
51
|
-
autoVerifying: {
|
|
52
|
-
invoke: {
|
|
53
|
-
src: 'fetchUserInfo',
|
|
54
|
-
onDone: {
|
|
55
|
-
target: 'checkingAutoVerification',
|
|
56
|
-
actions: 'setUserInfo',
|
|
57
|
-
},
|
|
58
|
-
onError: { target: 'fail' },
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
checkingAutoVerification: {
|
|
62
|
-
always: [{ target: 'verified', cond: 'isVerified' }, { target: 'fail' }],
|
|
63
|
-
},
|
|
64
51
|
notVerified: {
|
|
65
52
|
initial: 'checkingStatus',
|
|
66
53
|
states: {
|
|
67
54
|
checkingStatus: {
|
|
68
55
|
invoke: {
|
|
69
56
|
src: 'verify',
|
|
70
|
-
onDone:
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
57
|
+
onDone: {
|
|
58
|
+
target: 'otp',
|
|
59
|
+
actions: 'setVerificationData',
|
|
60
|
+
},
|
|
74
61
|
onError: {
|
|
75
62
|
target: 'errorChecking',
|
|
76
63
|
actions: 'setError',
|
|
@@ -99,20 +86,20 @@ export default function (request) {
|
|
|
99
86
|
sendingPhone: {
|
|
100
87
|
invoke: {
|
|
101
88
|
src: 'sendPhone',
|
|
102
|
-
onDone:
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
89
|
+
onDone: {
|
|
90
|
+
target: 'otp',
|
|
91
|
+
actions: 'setVerificationData',
|
|
92
|
+
},
|
|
106
93
|
onError: { target: 'phone' },
|
|
107
94
|
},
|
|
108
95
|
},
|
|
109
96
|
sendingEmail: {
|
|
110
97
|
invoke: {
|
|
111
98
|
src: 'sendEmail',
|
|
112
|
-
onDone:
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
99
|
+
onDone: {
|
|
100
|
+
target: 'otp',
|
|
101
|
+
actions: 'setVerificationData',
|
|
102
|
+
},
|
|
116
103
|
onError: { target: 'email' },
|
|
117
104
|
},
|
|
118
105
|
},
|
|
@@ -142,6 +129,9 @@ export default function (request) {
|
|
|
142
129
|
RESET_OTP: {
|
|
143
130
|
target: 'reset',
|
|
144
131
|
},
|
|
132
|
+
RESEND_PHONE: {
|
|
133
|
+
target: '#auth_otp.notVerified.phone',
|
|
134
|
+
},
|
|
145
135
|
},
|
|
146
136
|
},
|
|
147
137
|
acknowledging: {
|
|
@@ -226,11 +216,10 @@ export default function (request) {
|
|
|
226
216
|
}),
|
|
227
217
|
},
|
|
228
218
|
guards: {
|
|
229
|
-
doesNotNeedAcknowledge: (context, event) => event.data?.needAcknowledge === false,
|
|
230
219
|
isVerified: (context, event) => {
|
|
231
220
|
const { strategy, userInfo } = context
|
|
232
|
-
if (strategy === 'phone') return !!
|
|
233
|
-
if (strategy === 'email') return !!userInfo?.
|
|
221
|
+
if (strategy === 'phone') return !!userInfo?.phone_verification_status
|
|
222
|
+
if (strategy === 'email') return !!userInfo?.email_verification_status
|
|
234
223
|
return false
|
|
235
224
|
},
|
|
236
225
|
isNotVerified: (context, event) => {
|
|
@@ -242,11 +231,11 @@ export default function (request) {
|
|
|
242
231
|
},
|
|
243
232
|
isPhoneNotVerified: (context, event) => {
|
|
244
233
|
const { strategy, userInfo } = context
|
|
245
|
-
return strategy === 'phone' && !!userInfo && !
|
|
234
|
+
return strategy === 'phone' && !!userInfo && !userInfo.phone_verification_status && !userInfo.phone
|
|
246
235
|
},
|
|
247
236
|
isEmailNotVerified: (context, event) => {
|
|
248
237
|
const { strategy, userInfo } = context
|
|
249
|
-
return strategy === 'email' && !!userInfo && !userInfo.email
|
|
238
|
+
return strategy === 'email' && !!userInfo && !userInfo.email_verification_status && !userInfo.email
|
|
250
239
|
},
|
|
251
240
|
hasNoPhone: (context, event) => {
|
|
252
241
|
const { error } = context
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
// 棄用
|
|
2
|
+
import { assign, createMachine } from 'xstate'
|
|
3
|
+
import payment from '../api/payment.js'
|
|
4
|
+
|
|
5
|
+
export default function (request) {
|
|
6
|
+
const { appSecret } = request.config
|
|
7
|
+
|
|
8
|
+
return createMachine(
|
|
9
|
+
{
|
|
10
|
+
id: 'bank_binding_amb',
|
|
11
|
+
initial: 'fetching',
|
|
12
|
+
context: {
|
|
13
|
+
hasAnyAccount: false,
|
|
14
|
+
bankList: [],
|
|
15
|
+
bank: null,
|
|
16
|
+
// bonus: 0,
|
|
17
|
+
bankAccount: null,
|
|
18
|
+
firstNameTh: null,
|
|
19
|
+
lastNameTh: null,
|
|
20
|
+
firstNameEn: null,
|
|
21
|
+
lastNameEn: null,
|
|
22
|
+
},
|
|
23
|
+
states: {
|
|
24
|
+
fetching: {
|
|
25
|
+
invoke: {
|
|
26
|
+
src: 'fetchInitData',
|
|
27
|
+
onDone: {
|
|
28
|
+
target: 'idle',
|
|
29
|
+
actions: 'setBanks',
|
|
30
|
+
},
|
|
31
|
+
onError: {
|
|
32
|
+
target: 'idle',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
idle: {
|
|
37
|
+
on: {
|
|
38
|
+
SET_BANK_CODE: {
|
|
39
|
+
actions: assign((context, event) => {
|
|
40
|
+
return {
|
|
41
|
+
bank: event.data,
|
|
42
|
+
}
|
|
43
|
+
}),
|
|
44
|
+
},
|
|
45
|
+
SET_BANK_ACCOUNT: {
|
|
46
|
+
actions: assign((context, event) => {
|
|
47
|
+
return {
|
|
48
|
+
bankAccount: event.data,
|
|
49
|
+
}
|
|
50
|
+
}),
|
|
51
|
+
},
|
|
52
|
+
SET_FIRST_NAME_TH: {
|
|
53
|
+
actions: assign((context, event) => {
|
|
54
|
+
return {
|
|
55
|
+
firstNameTh: event.data,
|
|
56
|
+
}
|
|
57
|
+
}),
|
|
58
|
+
},
|
|
59
|
+
SET_LAST_NAME_TH: {
|
|
60
|
+
actions: assign((context, event) => {
|
|
61
|
+
return {
|
|
62
|
+
lastNameTh: event.data,
|
|
63
|
+
}
|
|
64
|
+
}),
|
|
65
|
+
},
|
|
66
|
+
SET_FIRST_NAME_EN: {
|
|
67
|
+
actions: assign((context, event) => {
|
|
68
|
+
return {
|
|
69
|
+
firstNameEn: event.data,
|
|
70
|
+
}
|
|
71
|
+
}),
|
|
72
|
+
},
|
|
73
|
+
SET_LAST_NAME_EN: {
|
|
74
|
+
actions: assign((context, event) => {
|
|
75
|
+
return {
|
|
76
|
+
lastNameEn: event.data,
|
|
77
|
+
}
|
|
78
|
+
}),
|
|
79
|
+
},
|
|
80
|
+
BIND_BANK: {
|
|
81
|
+
target: 'binding',
|
|
82
|
+
cond: 'isBindable',
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
binding: {
|
|
87
|
+
invoke: {
|
|
88
|
+
src: 'updatePaymentInfo',
|
|
89
|
+
onDone: {
|
|
90
|
+
target: 'bound',
|
|
91
|
+
},
|
|
92
|
+
onError: {
|
|
93
|
+
target: 'idle',
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
bound: {},
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
actions: {
|
|
102
|
+
setBanks: assign((context, event) => {
|
|
103
|
+
const { bankList = [], paymentInfo = {} } = event.data
|
|
104
|
+
const { bankInfo = [] } = paymentInfo
|
|
105
|
+
return {
|
|
106
|
+
hasAnyAccount: bankInfo.length > 0,
|
|
107
|
+
holderName: bankInfo[0]?.holderName,
|
|
108
|
+
bankList,
|
|
109
|
+
bank: bankList[0],
|
|
110
|
+
}
|
|
111
|
+
}),
|
|
112
|
+
},
|
|
113
|
+
guards: {
|
|
114
|
+
isBindable: (context, event) => {
|
|
115
|
+
const { bank, bankAccount, firstNameTh, lastNameTh, firstNameEn, lastNameEn } = context
|
|
116
|
+
|
|
117
|
+
return bank.bankCode && bankAccount && firstNameTh && lastNameTh && firstNameEn && lastNameEn
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
services: {
|
|
121
|
+
fetchInitData: async (context, event) => {
|
|
122
|
+
const [bankList, paymentInfo] = await Promise.all([
|
|
123
|
+
request.send(payment.getBindingBankList({ appSecret })),
|
|
124
|
+
request.send(payment.getPaymentInfo()),
|
|
125
|
+
])
|
|
126
|
+
return { bankList, paymentInfo }
|
|
127
|
+
},
|
|
128
|
+
updatePaymentInfo: async (context, event) => {
|
|
129
|
+
const { bonus, bank, bankAccount, firstNameTh, lastNameTh, firstNameEn, lastNameEn } = context
|
|
130
|
+
return await request.send(
|
|
131
|
+
payment.updatePaymentInfo({
|
|
132
|
+
paymentProvider: 'amb',
|
|
133
|
+
// bonus,
|
|
134
|
+
bankCode: bank.bankCode,
|
|
135
|
+
bankAccount,
|
|
136
|
+
firstNameTh,
|
|
137
|
+
lastNameTh,
|
|
138
|
+
firstNameEn,
|
|
139
|
+
lastNameEn,
|
|
140
|
+
})
|
|
141
|
+
)
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
}
|
|
145
|
+
)
|
|
146
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// 棄用
|
|
2
|
+
import { assign, createMachine, send } from 'xstate'
|
|
3
|
+
import payment from '../api/payment.js'
|
|
4
|
+
|
|
5
|
+
export default function (request) {
|
|
6
|
+
return createMachine(
|
|
7
|
+
{
|
|
8
|
+
id: 'bonus',
|
|
9
|
+
initial: 'loading',
|
|
10
|
+
context: {
|
|
11
|
+
bonus: null,
|
|
12
|
+
},
|
|
13
|
+
states: {
|
|
14
|
+
loading: {
|
|
15
|
+
invoke: {
|
|
16
|
+
src: 'fetchInitData',
|
|
17
|
+
onDone: {
|
|
18
|
+
target: 'idle',
|
|
19
|
+
actions: 'setBonus',
|
|
20
|
+
},
|
|
21
|
+
onError: {
|
|
22
|
+
target: 'idle',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
idle: {
|
|
27
|
+
on: {
|
|
28
|
+
TOGGLE: {
|
|
29
|
+
target: 'updating',
|
|
30
|
+
},
|
|
31
|
+
SWITCH_ON: {
|
|
32
|
+
actions: send((context, event) => ({ type: 'TOGGLE', data: 1 })),
|
|
33
|
+
cond: (context, event) => context.bonus !== 1,
|
|
34
|
+
},
|
|
35
|
+
SWITCH_OFF: {
|
|
36
|
+
actions: send((context, event) => ({ type: 'TOGGLE', data: 0 })),
|
|
37
|
+
cond: (context, event) => context.bonus !== 0,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
updating: {
|
|
42
|
+
invoke: {
|
|
43
|
+
src: 'toggleBonus',
|
|
44
|
+
onDone: {
|
|
45
|
+
target: 'idle',
|
|
46
|
+
actions: 'setBonus',
|
|
47
|
+
},
|
|
48
|
+
onError: {
|
|
49
|
+
target: 'idle',
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
actions: {
|
|
57
|
+
setBonus: assign((context, event) => {
|
|
58
|
+
return {
|
|
59
|
+
bonus: event.data,
|
|
60
|
+
}
|
|
61
|
+
}),
|
|
62
|
+
},
|
|
63
|
+
services: {
|
|
64
|
+
fetchInitData: async (context, event) => {
|
|
65
|
+
const { bonus } = await request.send(payment.getPaymentInfo())
|
|
66
|
+
return bonus
|
|
67
|
+
},
|
|
68
|
+
toggleBonus: async (context, event) => {
|
|
69
|
+
const bonus = context.bonus ? 0 : 1
|
|
70
|
+
await request.send(payment.setBonusSetting({ bonus }))
|
|
71
|
+
return bonus
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
}
|
|
75
|
+
)
|
|
76
|
+
}
|
package/src/machine/common.js
CHANGED
|
@@ -34,6 +34,8 @@ export default function (request) {
|
|
|
34
34
|
broadcastList: null,
|
|
35
35
|
mailBoxInfo: null,
|
|
36
36
|
promotions: [],
|
|
37
|
+
normalBroadcast: null,
|
|
38
|
+
sentNormalBroadcastList: [],
|
|
37
39
|
affiliateCode: null,
|
|
38
40
|
defaultAffiliateCode: null,
|
|
39
41
|
friendCode: null,
|
|
@@ -157,6 +159,39 @@ export default function (request) {
|
|
|
157
159
|
},
|
|
158
160
|
},
|
|
159
161
|
},
|
|
162
|
+
broadcast: {
|
|
163
|
+
initial: 'idle',
|
|
164
|
+
states: {
|
|
165
|
+
idle: {
|
|
166
|
+
on: {
|
|
167
|
+
START_BROADCAST: {
|
|
168
|
+
target: 'picking',
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
picking: {
|
|
173
|
+
after: {
|
|
174
|
+
5000: {
|
|
175
|
+
target: 'display',
|
|
176
|
+
actions: 'setBroadcast',
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
display: {
|
|
181
|
+
after: {
|
|
182
|
+
5000: {
|
|
183
|
+
target: 'picking',
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
on: {
|
|
189
|
+
RESET_BROADCAST: {
|
|
190
|
+
target: '.idle',
|
|
191
|
+
actions: 'resetBroadcast',
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
},
|
|
160
195
|
},
|
|
161
196
|
},
|
|
162
197
|
{
|
|
@@ -271,6 +306,26 @@ export default function (request) {
|
|
|
271
306
|
}
|
|
272
307
|
return { broadcastList, mailBoxInfo }
|
|
273
308
|
}),
|
|
309
|
+
setBroadcast: assign((context, event) => {
|
|
310
|
+
const { broadcastList, sentNormalBroadcastList, normalBroadcast } = context
|
|
311
|
+
let sentNormalList = sentNormalBroadcastList
|
|
312
|
+
if (normalBroadcast) {
|
|
313
|
+
sentNormalList = [...sentNormalBroadcastList, normalBroadcast]
|
|
314
|
+
}
|
|
315
|
+
const nextNormalBroadcast = broadcastList?.broadcasts?.find((broadcast) => {
|
|
316
|
+
return broadcast.type === '0' && !sentNormalList.some((item) => item.broadcast_id === broadcast.broadcast_id)
|
|
317
|
+
})
|
|
318
|
+
return {
|
|
319
|
+
normalBroadcast: nextNormalBroadcast,
|
|
320
|
+
sentNormalBroadcastList: sentNormalList,
|
|
321
|
+
}
|
|
322
|
+
}),
|
|
323
|
+
resetBroadcast: assign((context, event) => {
|
|
324
|
+
return {
|
|
325
|
+
normalBroadcast: null,
|
|
326
|
+
sentNormalBroadcastList: [],
|
|
327
|
+
}
|
|
328
|
+
}),
|
|
274
329
|
resetByEnterGame: assign((context, event) => {
|
|
275
330
|
return {
|
|
276
331
|
isPlaying: true,
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// 棄用
|
|
2
|
+
import { assign, createMachine } from 'xstate'
|
|
3
|
+
import payment from '../../api/payment.js'
|
|
4
|
+
|
|
5
|
+
export default function (request) {
|
|
6
|
+
return createMachine(
|
|
7
|
+
{
|
|
8
|
+
id: 'amb',
|
|
9
|
+
initial: 'loading',
|
|
10
|
+
context: {
|
|
11
|
+
bankList: [],
|
|
12
|
+
userAccount: {},
|
|
13
|
+
houseAccountName: null,
|
|
14
|
+
houseAccountNumber: null,
|
|
15
|
+
houseBankName: null,
|
|
16
|
+
method: 'amb',
|
|
17
|
+
},
|
|
18
|
+
states: {
|
|
19
|
+
loading: {
|
|
20
|
+
initial: 'checkingUserAccount',
|
|
21
|
+
states: {
|
|
22
|
+
checkingUserAccount: {
|
|
23
|
+
invoke: {
|
|
24
|
+
src: 'fetchPaymentInfo',
|
|
25
|
+
onDone: [
|
|
26
|
+
{
|
|
27
|
+
target: 'initializing',
|
|
28
|
+
actions: 'setUserAccount',
|
|
29
|
+
cond: 'hasUserAccount',
|
|
30
|
+
},
|
|
31
|
+
{ target: '#amb.accountUnbound' },
|
|
32
|
+
],
|
|
33
|
+
onError: {
|
|
34
|
+
target: '#amb.unavailable',
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
initializing: {
|
|
39
|
+
invoke: {
|
|
40
|
+
src: 'initialize',
|
|
41
|
+
onDone: { target: '#amb.finish', actions: 'setInitialization' },
|
|
42
|
+
onError: {
|
|
43
|
+
target: '#amb.unavailable',
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
finish: {},
|
|
50
|
+
accountUnbound: {},
|
|
51
|
+
unavailable: {},
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
actions: {
|
|
56
|
+
setUserAccount: assign((context, event) => {
|
|
57
|
+
return {
|
|
58
|
+
userAccount: event.data?.[0],
|
|
59
|
+
}
|
|
60
|
+
}),
|
|
61
|
+
setInitialization: assign((context, event) => {
|
|
62
|
+
const { houseAccount, bankList } = event.data
|
|
63
|
+
return {
|
|
64
|
+
houseAccountName: houseAccount.accountName,
|
|
65
|
+
houseAccountNumber: houseAccount.accountNumber,
|
|
66
|
+
houseBankName: houseAccount.bankName,
|
|
67
|
+
bankList: bankList?.data ? bankList.data : bankList,
|
|
68
|
+
}
|
|
69
|
+
}),
|
|
70
|
+
},
|
|
71
|
+
guards: {
|
|
72
|
+
hasUserAccount: (context, event) => {
|
|
73
|
+
return event.data?.[0]
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
services: {
|
|
77
|
+
fetchPaymentInfo: async (context, event) => {
|
|
78
|
+
const { bankInfo } = await request.send(payment.getPaymentInfo())
|
|
79
|
+
const filterArray = bankInfo?.filter((item) => item.bindingType !== 'CRYPTO' && item.bindingType !== 'EWALLET')
|
|
80
|
+
return filterArray || []
|
|
81
|
+
},
|
|
82
|
+
initialize: async (context, event) => {
|
|
83
|
+
const { method } = context
|
|
84
|
+
const [houseAccount, bankList] = await Promise.all([
|
|
85
|
+
request.send(payment.submitDepositTransaction({ method })),
|
|
86
|
+
request.send(payment.getBankList(method)),
|
|
87
|
+
])
|
|
88
|
+
return { houseAccount, bankList }
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
}
|
|
92
|
+
)
|
|
93
|
+
}
|