@jetthai/cuora 1.1.85-cash → 1.1.86
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 +1 -1
- package/CHANGELOG.md +1 -23
- package/dist/bundle.mjs +4382 -3170
- package/package.json +1 -1
- package/src/machine/activity/deposit_activity.js +2 -2
- package/src/machine/activity/fafafa_activity.js +11 -35
- package/src/machine/activity/index.js +0 -2
- package/src/machine/activity/ranking_activity.js +2 -31
- package/src/machine/activity/specify_bets_activity.js +3 -44
- package/src/machine/activity/specify_turnover_activity.js +3 -44
- package/src/machine/common.js +1 -10
- package/src/machine/deposit/index.js +0 -2
- package/src/machine/game.js +285 -0
- package/src/machine/game_favorite.js +123 -0
- package/src/machine/game_favorite_v2.js +2 -6
- package/src/machine/game_v2.js +381 -0
- package/src/machine/game_v2_1.js +9 -35
- package/src/machine/index.js +8 -2
- package/src/machine/user_info.js +2 -8
- package/src/machine/{withdraw/withdraw_activity.js → withdraw_vn2.js} +168 -62
- package/src/request/request.js +5 -9
- package/src/util/index.js +1 -2
- package/src/machine/activity/diamond_shop_activity_cash.js +0 -215
- package/src/machine/deposit/qrcode_v_cash.js +0 -280
- package/src/machine/reward_cash.js +0 -220
- package/src/util/math.js +0 -4
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { assign, createMachine } from 'xstate'
|
|
2
2
|
import findLastIndex from 'lodash/findLastIndex.js'
|
|
3
|
-
import payment from '
|
|
4
|
-
import
|
|
5
|
-
import user from '../../api/user.js'
|
|
3
|
+
import payment from '../api/payment.js'
|
|
4
|
+
import user from '../api/user.js'
|
|
6
5
|
|
|
7
6
|
export default function (request) {
|
|
8
7
|
const { appSecret } = request.config
|
|
9
8
|
return createMachine(
|
|
10
9
|
{
|
|
11
|
-
id: '
|
|
10
|
+
id: 'withdraw_vn2',
|
|
12
11
|
initial: 'loading',
|
|
13
12
|
context: {
|
|
13
|
+
mode: null,
|
|
14
14
|
siteConfig: null,
|
|
15
15
|
userInfo: null,
|
|
16
16
|
balance: null,
|
|
@@ -21,10 +21,9 @@ export default function (request) {
|
|
|
21
21
|
paymentDetail: [],
|
|
22
22
|
bankInfo: [],
|
|
23
23
|
bankList: [],
|
|
24
|
-
|
|
24
|
+
currentWithdrawLimit: null,
|
|
25
25
|
targetWithdrawLimit: null,
|
|
26
26
|
attachmentType: null, // null | 'withdraw' | 'pool'
|
|
27
|
-
maximumWithdrawAmount: 0,
|
|
28
27
|
enableWithdrawAmount: 0,
|
|
29
28
|
enableWithdraw: false,
|
|
30
29
|
withdrawRules: [],
|
|
@@ -46,15 +45,38 @@ export default function (request) {
|
|
|
46
45
|
invoke: {
|
|
47
46
|
src: 'fetchInitData',
|
|
48
47
|
onDone: {
|
|
49
|
-
target: '
|
|
50
|
-
actions: ['setInitData', 'preset'
|
|
48
|
+
target: 'pending',
|
|
49
|
+
actions: ['setInitData', 'preset'],
|
|
51
50
|
},
|
|
52
51
|
onError: {
|
|
53
52
|
target: 'fail',
|
|
54
53
|
},
|
|
55
54
|
},
|
|
56
55
|
},
|
|
57
|
-
|
|
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: {
|
|
58
80
|
initial: 'checking',
|
|
59
81
|
states: {
|
|
60
82
|
checking: {
|
|
@@ -92,7 +114,7 @@ export default function (request) {
|
|
|
92
114
|
src: 'convertFreeCredit',
|
|
93
115
|
onDone: [
|
|
94
116
|
{
|
|
95
|
-
target: '#
|
|
117
|
+
target: '#withdraw_vn2.otp',
|
|
96
118
|
actions: 'setOtp',
|
|
97
119
|
cond: 'isOtpRequired',
|
|
98
120
|
},
|
|
@@ -103,7 +125,109 @@ export default function (request) {
|
|
|
103
125
|
},
|
|
104
126
|
},
|
|
105
127
|
},
|
|
106
|
-
converted: {
|
|
128
|
+
converted: {
|
|
129
|
+
always: [
|
|
130
|
+
{ target: '#withdraw_vn2.cash.unbound', cond: 'isBankNotBound' },
|
|
131
|
+
{ target: '#withdraw_vn2.cash.withdrawable', cond: 'hasAttachmentType' },
|
|
132
|
+
],
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
cash: {
|
|
137
|
+
initial: 'checking',
|
|
138
|
+
states: {
|
|
139
|
+
checking: {
|
|
140
|
+
always: [
|
|
141
|
+
{ target: 'inProcessing', cond: 'haveProcessing' },
|
|
142
|
+
{ target: 'notWithdrawable', cond: 'isNotWithdrawable' },
|
|
143
|
+
{ target: 'unbound', cond: 'isBankNotBound' },
|
|
144
|
+
{ target: 'withdrawable' },
|
|
145
|
+
],
|
|
146
|
+
},
|
|
147
|
+
notWithdrawable: {},
|
|
148
|
+
unbound: {
|
|
149
|
+
// to bank_binding.js
|
|
150
|
+
},
|
|
151
|
+
inProcessing: {},
|
|
152
|
+
withdrawable: {
|
|
153
|
+
on: {
|
|
154
|
+
SET_CURRENT_BANK: {
|
|
155
|
+
actions: assign((context, event) => {
|
|
156
|
+
return {
|
|
157
|
+
bank: event.data,
|
|
158
|
+
}
|
|
159
|
+
}),
|
|
160
|
+
},
|
|
161
|
+
SET_AMOUNT: {
|
|
162
|
+
actions: assign((context, event) => {
|
|
163
|
+
return {
|
|
164
|
+
amount: event.data,
|
|
165
|
+
}
|
|
166
|
+
}),
|
|
167
|
+
},
|
|
168
|
+
SET_ATTACHMENT_TYPE: {
|
|
169
|
+
actions: 'setAttachmentType',
|
|
170
|
+
cond: 'isNewWalletMode',
|
|
171
|
+
},
|
|
172
|
+
SUBMIT: [
|
|
173
|
+
{
|
|
174
|
+
target: 'pooling',
|
|
175
|
+
cond: (context, event) => {
|
|
176
|
+
const { amount, attachmentType } = context
|
|
177
|
+
return attachmentType === 'pool' && amount > 0
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
target: 'submitting',
|
|
182
|
+
cond: 'isSubmittable',
|
|
183
|
+
},
|
|
184
|
+
],
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
submitting: {
|
|
188
|
+
invoke: {
|
|
189
|
+
src: 'submitWithdraw',
|
|
190
|
+
onDone: [
|
|
191
|
+
{
|
|
192
|
+
target: '#withdraw_vn2.otp',
|
|
193
|
+
actions: 'setOtp',
|
|
194
|
+
cond: 'isOtpRequired',
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
target: 'submitted',
|
|
198
|
+
},
|
|
199
|
+
],
|
|
200
|
+
onError: {
|
|
201
|
+
target: 'withdrawable',
|
|
202
|
+
},
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
submitted: {
|
|
206
|
+
entry: assign((context, event) => {
|
|
207
|
+
const { applyId, balance, realAmount, charge } = event.data
|
|
208
|
+
return { applyId, balance, realAmount, charge }
|
|
209
|
+
}),
|
|
210
|
+
invoke: {
|
|
211
|
+
src: 'fetchPaymentData',
|
|
212
|
+
onDone: {
|
|
213
|
+
target: 'inProcessing',
|
|
214
|
+
actions: 'setPaymentData',
|
|
215
|
+
},
|
|
216
|
+
onError: {
|
|
217
|
+
target: '#withdraw_vn2.fail',
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
|
+
pooling: {
|
|
222
|
+
invoke: {
|
|
223
|
+
src: 'pool',
|
|
224
|
+
onDone: { target: 'pooled' },
|
|
225
|
+
onError: {
|
|
226
|
+
target: 'withdrawable',
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
pooled: {},
|
|
107
231
|
},
|
|
108
232
|
},
|
|
109
233
|
otp: {
|
|
@@ -131,11 +255,11 @@ export default function (request) {
|
|
|
131
255
|
},
|
|
132
256
|
BACK: [
|
|
133
257
|
{
|
|
134
|
-
target: '#
|
|
135
|
-
cond: '
|
|
258
|
+
target: '#withdraw_vn2.activity.convertible',
|
|
259
|
+
cond: 'isActivity',
|
|
136
260
|
},
|
|
137
261
|
{
|
|
138
|
-
target: '#
|
|
262
|
+
target: '#withdraw_vn2.cash.withdrawable',
|
|
139
263
|
},
|
|
140
264
|
],
|
|
141
265
|
},
|
|
@@ -145,11 +269,11 @@ export default function (request) {
|
|
|
145
269
|
src: 'acknowledge',
|
|
146
270
|
onDone: [
|
|
147
271
|
{
|
|
148
|
-
target: '#
|
|
149
|
-
cond: '
|
|
272
|
+
target: '#withdraw_vn2.activity.converted',
|
|
273
|
+
cond: 'isActivity',
|
|
150
274
|
},
|
|
151
275
|
{
|
|
152
|
-
target: '#
|
|
276
|
+
target: '#withdraw_vn2.cash.submitted',
|
|
153
277
|
},
|
|
154
278
|
],
|
|
155
279
|
onError: {
|
|
@@ -173,6 +297,11 @@ export default function (request) {
|
|
|
173
297
|
},
|
|
174
298
|
fail: {},
|
|
175
299
|
},
|
|
300
|
+
on: {
|
|
301
|
+
REFRESH: {
|
|
302
|
+
target: 'loading',
|
|
303
|
+
},
|
|
304
|
+
},
|
|
176
305
|
},
|
|
177
306
|
{
|
|
178
307
|
actions: {
|
|
@@ -193,28 +322,18 @@ export default function (request) {
|
|
|
193
322
|
}
|
|
194
323
|
}),
|
|
195
324
|
preset: assign((context, event) => {
|
|
196
|
-
const {
|
|
197
|
-
const { withdraw_limit, target_withdraw_limit } = userInfo || {}
|
|
198
|
-
const balance = parseFloat(userInfo?.balance)
|
|
325
|
+
const { siteConfig } = context
|
|
199
326
|
const methods = siteConfig?.paymentMethods?.withdraw || []
|
|
200
327
|
return {
|
|
201
|
-
withdrawLimit: Math.abs(withdraw_limit),
|
|
202
|
-
targetWithdrawLimit: Math.abs(target_withdraw_limit),
|
|
203
328
|
methods,
|
|
204
|
-
balance,
|
|
205
329
|
siteConfig,
|
|
206
|
-
userInfo,
|
|
207
330
|
attachmentType: siteConfig.walletMode > 0 ? 'withdraw' : null,
|
|
208
331
|
}
|
|
209
332
|
}),
|
|
210
333
|
updateWithdrawCondition: assign((context, event) => {
|
|
211
|
-
const {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
const withdrawRules = event.data?.withdrawRule?.rules || []
|
|
334
|
+
const { enableWithdraw, enableWithdrawAmount, currentWithdrawLimit, targetWithdrawLimit, balance } = event.data
|
|
335
|
+
const withdrawRules = event.data?.rules || []
|
|
215
336
|
const rules = withdrawRules.filter((rule) => rule.maxWithdrawAmount > 0)
|
|
216
|
-
|
|
217
|
-
const { balance } = context
|
|
218
337
|
const lastMatchedIndex = findLastIndex(rules, (rule) => balance >= rule.greaterEqualThen)
|
|
219
338
|
|
|
220
339
|
let maxWithdrawAmount = 0
|
|
@@ -229,12 +348,20 @@ export default function (request) {
|
|
|
229
348
|
}
|
|
230
349
|
|
|
231
350
|
return {
|
|
351
|
+
balance,
|
|
352
|
+
currentWithdrawLimit,
|
|
353
|
+
targetWithdrawLimit,
|
|
232
354
|
maxWithdrawAmount,
|
|
233
355
|
enableWithdrawAmount: +enableWithdrawAmount,
|
|
234
356
|
enableWithdraw,
|
|
235
357
|
withdrawRules,
|
|
236
358
|
}
|
|
237
359
|
}),
|
|
360
|
+
setMode: assign((context, event) => {
|
|
361
|
+
return {
|
|
362
|
+
mode: event.data,
|
|
363
|
+
}
|
|
364
|
+
}),
|
|
238
365
|
setOtp: assign((context, event) => {
|
|
239
366
|
const { requestId, status, target, ttl } = event.data
|
|
240
367
|
return {
|
|
@@ -265,8 +392,8 @@ export default function (request) {
|
|
|
265
392
|
}),
|
|
266
393
|
},
|
|
267
394
|
guards: {
|
|
268
|
-
|
|
269
|
-
return context.
|
|
395
|
+
isActivity: (context, event) => {
|
|
396
|
+
return context.mode === 'ACTIVITY'
|
|
270
397
|
},
|
|
271
398
|
hasAttachmentType: (context, event) => {
|
|
272
399
|
return ['withdraw', 'pool'].includes(context.attachmentType)
|
|
@@ -274,11 +401,6 @@ export default function (request) {
|
|
|
274
401
|
haveProcessing: (context, event) => {
|
|
275
402
|
return (context.paymentDetail?.[0]?.processing || []).length > 0
|
|
276
403
|
},
|
|
277
|
-
isWithdrawDisable: (context, event) => {
|
|
278
|
-
const { siteConfig } = context
|
|
279
|
-
const methods = siteConfig?.paymentMethods?.withdraw || []
|
|
280
|
-
return methods.length === 0
|
|
281
|
-
},
|
|
282
404
|
isBankNotBound: (context, event) => {
|
|
283
405
|
return !context.bankInfo?.length
|
|
284
406
|
},
|
|
@@ -302,39 +424,30 @@ export default function (request) {
|
|
|
302
424
|
},
|
|
303
425
|
services: {
|
|
304
426
|
fetchInitData: async (context, event) => {
|
|
305
|
-
const [
|
|
306
|
-
request.send(common.getConfig({ appSecret })),
|
|
307
|
-
request.send(user.getUserInfo()),
|
|
427
|
+
const [paymentDetail = [], { bonus, bankInfo }] = await Promise.all([
|
|
308
428
|
request.send(payment.getPaymentDetail({ transferType: 'WITHDRAW' })),
|
|
309
429
|
request.send(payment.getPaymentInfo()),
|
|
310
|
-
request.send(payment.getCurrentWithdrawRule()),
|
|
311
430
|
])
|
|
312
|
-
const siteConfig = JSON.parse(window.atob(config))
|
|
313
431
|
const method = paymentDetail.find((payment) => payment.category === 'manual').method
|
|
314
432
|
const bankList = await request.send(payment.getBankList(method))
|
|
315
433
|
const newBankInfo = bankInfo.map((item) => {
|
|
316
434
|
return { ...item, ...bankList.find((bank) => bank.bankCode === item.bankCode) }
|
|
317
435
|
})
|
|
318
|
-
return {
|
|
436
|
+
return { paymentDetail, bonus, bankInfo: newBankInfo, bankList }
|
|
319
437
|
},
|
|
320
438
|
fetchPaymentData: async (context, event) => {
|
|
321
439
|
const paymentDetail = await request.send(payment.getPaymentDetail({ transferType: 'WITHDRAW' }))
|
|
322
440
|
const { bonus, bankInfo } = await request.send(payment.getPaymentInfo())
|
|
323
441
|
return { bonus, bankInfo, paymentDetail }
|
|
324
442
|
},
|
|
325
|
-
updatePaymentInfo: async (context, event) => {
|
|
326
|
-
const { bank, branch, accountNumber, holderName } = context
|
|
327
|
-
return await request.send(
|
|
328
|
-
payment.updatePaymentInfo({
|
|
329
|
-
bankCode: bank.bankCode,
|
|
330
|
-
branch,
|
|
331
|
-
bankAccount: accountNumber,
|
|
332
|
-
holderName,
|
|
333
|
-
})
|
|
334
|
-
)
|
|
335
|
-
},
|
|
336
443
|
fetchWithdrawRules: async (context, event) => {
|
|
337
|
-
|
|
444
|
+
const { siteConfig = {}, mode } = context
|
|
445
|
+
const { walletMode = null } = siteConfig
|
|
446
|
+
if (walletMode === '4') {
|
|
447
|
+
return await request.send(payment.getDoubleWalletWithdrawRule({ walletType: mode }))
|
|
448
|
+
} else {
|
|
449
|
+
return await request.send(payment.getCurrentWithdrawRule())
|
|
450
|
+
}
|
|
338
451
|
},
|
|
339
452
|
submitWithdraw: async (context, event) => {
|
|
340
453
|
const { bank, amount } = context
|
|
@@ -370,13 +483,6 @@ export default function (request) {
|
|
|
370
483
|
giveUp: async (context, event) => {
|
|
371
484
|
return await request.send(payment.giveUp())
|
|
372
485
|
},
|
|
373
|
-
getActivityWalletStatus: async (context, event) => {
|
|
374
|
-
return await request.send(payment.getDoubleWalletWithdrawRule({ walletType: 'ACTIVITY' }))
|
|
375
|
-
|
|
376
|
-
// 轉換條件: currentWithdrawLimit === 0
|
|
377
|
-
// -> settle
|
|
378
|
-
//
|
|
379
|
-
},
|
|
380
486
|
},
|
|
381
487
|
}
|
|
382
488
|
)
|
package/src/request/request.js
CHANGED
|
@@ -22,8 +22,8 @@ export default class Request {
|
|
|
22
22
|
this.axios.interceptors.request.use((axiosConfig) => {
|
|
23
23
|
axiosConfig.headers['X-TH1GAMES-VERSION'] = this.config.version
|
|
24
24
|
axiosConfig.headers['X-TH1GAMES-PLATFORM'] = this.config.platform
|
|
25
|
-
if (this.
|
|
26
|
-
axiosConfig.headers.Authorization = this.
|
|
25
|
+
if (storage.get(this.key)) {
|
|
26
|
+
axiosConfig.headers.Authorization = storage.get(this.key)
|
|
27
27
|
}
|
|
28
28
|
return axiosConfig
|
|
29
29
|
})
|
|
@@ -51,7 +51,7 @@ export default class Request {
|
|
|
51
51
|
async send(req, customToken) {
|
|
52
52
|
try {
|
|
53
53
|
const cancelToken = customToken || this.source.token
|
|
54
|
-
this._checkToken(req)
|
|
54
|
+
this._checkToken(req, storage.get(this.key))
|
|
55
55
|
const requestConfig = this._createConfig(req, cancelToken)
|
|
56
56
|
const { data } = await this.axios.request(requestConfig)
|
|
57
57
|
return data
|
|
@@ -97,14 +97,10 @@ export default class Request {
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
_checkToken(req) {
|
|
101
|
-
if (!req.isPublic && !
|
|
100
|
+
_checkToken(req, token) {
|
|
101
|
+
if (!req.isPublic && !token) {
|
|
102
102
|
console.error(req)
|
|
103
103
|
throw { code: 'ERR_A103', url: req.url }
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
|
-
|
|
107
|
-
getToken() {
|
|
108
|
-
return storage.get(this.key)
|
|
109
|
-
}
|
|
110
106
|
}
|
package/src/util/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { getDeviceToken } from './deviceToken.js'
|
|
2
2
|
import storage from './storage.js'
|
|
3
3
|
import * as constant from './constant.js'
|
|
4
|
-
import { max } from './math.js'
|
|
5
4
|
|
|
6
5
|
export default { getDeviceToken }
|
|
7
|
-
export { constant, storage
|
|
6
|
+
export { constant, storage }
|
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
import { assign, createMachine } from 'xstate'
|
|
2
|
-
import api from '../../api/activity.js'
|
|
3
|
-
|
|
4
|
-
export default function (request) {
|
|
5
|
-
const { appSecret } = request.config
|
|
6
|
-
return createMachine(
|
|
7
|
-
{
|
|
8
|
-
id: 'diamond_shop_activity',
|
|
9
|
-
context: {
|
|
10
|
-
activityNo: null,
|
|
11
|
-
activityDetail: null,
|
|
12
|
-
awards: [],
|
|
13
|
-
exchangeList: [],
|
|
14
|
-
exchangeAward: 0,
|
|
15
|
-
exchangePoint: 0,
|
|
16
|
-
remainingPoints: 0,
|
|
17
|
-
receiveRewards: [],
|
|
18
|
-
unclaimedRewardList: [],
|
|
19
|
-
},
|
|
20
|
-
initial: 'fetching',
|
|
21
|
-
states: {
|
|
22
|
-
fetching: {
|
|
23
|
-
invoke: {
|
|
24
|
-
src: 'fetchActivityList',
|
|
25
|
-
onDone: {
|
|
26
|
-
target: 'checking',
|
|
27
|
-
actions: 'setDiamondShopActivities',
|
|
28
|
-
},
|
|
29
|
-
onError: {
|
|
30
|
-
target: 'idle',
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
idle: {},
|
|
35
|
-
checking: {
|
|
36
|
-
always: [{ target: 'loading', cond: 'hasActivityNo' }],
|
|
37
|
-
},
|
|
38
|
-
loading: {
|
|
39
|
-
invoke: {
|
|
40
|
-
src: 'fetchActivityDetail',
|
|
41
|
-
onDone: {
|
|
42
|
-
target: 'loaded',
|
|
43
|
-
actions: ['setActivityDetail', 'setAwardList', 'setUnclaimedReward'],
|
|
44
|
-
},
|
|
45
|
-
onError: {
|
|
46
|
-
target: 'idle',
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
loaded: {
|
|
51
|
-
on: {
|
|
52
|
-
EXCHANGE: {
|
|
53
|
-
target: 'exchanging',
|
|
54
|
-
},
|
|
55
|
-
SELECT: {
|
|
56
|
-
actions: ['selectProduct', 'count'],
|
|
57
|
-
},
|
|
58
|
-
// ADD_TO_CART: {
|
|
59
|
-
// actions: ['addProduct', 'count'],
|
|
60
|
-
// },
|
|
61
|
-
// CLEAR_CART: {
|
|
62
|
-
// actions: ['clearCart', 'count'],
|
|
63
|
-
// },
|
|
64
|
-
// COLLECT: {
|
|
65
|
-
// target: 'collecting',
|
|
66
|
-
// cond: 'hasUnclaimedReward',
|
|
67
|
-
// },
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
exchanging: {
|
|
71
|
-
invoke: {
|
|
72
|
-
src: 'exchange',
|
|
73
|
-
onDone: {
|
|
74
|
-
target: 'collecting',
|
|
75
|
-
actions: ['setExchangedData', 'setUnclaimedReward'],
|
|
76
|
-
},
|
|
77
|
-
onError: {
|
|
78
|
-
target: 'loaded',
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
collecting: {
|
|
83
|
-
invoke: {
|
|
84
|
-
src: 'collect',
|
|
85
|
-
onDone: {
|
|
86
|
-
target: 'collected',
|
|
87
|
-
actions: 'clearExchangedData',
|
|
88
|
-
},
|
|
89
|
-
onError: {
|
|
90
|
-
target: 'collected',
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
collected: {
|
|
95
|
-
after: {
|
|
96
|
-
0: {
|
|
97
|
-
target: 'loaded',
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
},
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
actions: {
|
|
105
|
-
setActivityNo: assign((context, event) => {
|
|
106
|
-
return {
|
|
107
|
-
activityNo: event.data,
|
|
108
|
-
}
|
|
109
|
-
}),
|
|
110
|
-
setDiamondShopActivities: assign((context, event) => {
|
|
111
|
-
const rankActivities = event.data.filter((item) => item.activityType === 91)
|
|
112
|
-
return {
|
|
113
|
-
rankActivities,
|
|
114
|
-
activityNo: rankActivities?.[0]?.activityNo,
|
|
115
|
-
}
|
|
116
|
-
}),
|
|
117
|
-
setActivityDetail: assign((context, event) => {
|
|
118
|
-
return {
|
|
119
|
-
activityDetail: event.data,
|
|
120
|
-
}
|
|
121
|
-
}),
|
|
122
|
-
setAwardList: assign((context, event) => {
|
|
123
|
-
return {
|
|
124
|
-
awardList: event.data?.awards || [],
|
|
125
|
-
}
|
|
126
|
-
}),
|
|
127
|
-
setExchangedData: assign((context, event) => {
|
|
128
|
-
return {
|
|
129
|
-
remainingPoints: event.data?.data?.points,
|
|
130
|
-
receiveRewards: event.data?.date?.receiveRewards,
|
|
131
|
-
}
|
|
132
|
-
}),
|
|
133
|
-
setUnclaimedReward: assign((context, event) => {
|
|
134
|
-
return {
|
|
135
|
-
unclaimedRewardList: event.data?.unclaimedReward || event.data?.data?.unclaimedReward || [],
|
|
136
|
-
}
|
|
137
|
-
}),
|
|
138
|
-
clearExchangedData: assign((context, event) => {
|
|
139
|
-
return {
|
|
140
|
-
remainingPoints: null,
|
|
141
|
-
receiveRewards: [],
|
|
142
|
-
unclaimedRewardList: [],
|
|
143
|
-
}
|
|
144
|
-
}),
|
|
145
|
-
selectProduct: assign((context, event) => {
|
|
146
|
-
return {
|
|
147
|
-
exchangeList: [event.data],
|
|
148
|
-
}
|
|
149
|
-
}),
|
|
150
|
-
addProduct: assign((context, event) => {
|
|
151
|
-
return {
|
|
152
|
-
exchangeList: [...context.exchangeList, event.data],
|
|
153
|
-
}
|
|
154
|
-
}),
|
|
155
|
-
clearCart: assign((context, event) => {
|
|
156
|
-
return {
|
|
157
|
-
exchangeList: [],
|
|
158
|
-
}
|
|
159
|
-
}),
|
|
160
|
-
count: assign((context, event) => {
|
|
161
|
-
const { exchangeList } = context
|
|
162
|
-
const { exchangeAward, exchangePoint } = exchangeList.reduce(
|
|
163
|
-
({ exchangeAward, exchangePoint }, item) => {
|
|
164
|
-
return {
|
|
165
|
-
exchangeAward: exchangeAward + item.award,
|
|
166
|
-
exchangePoint: exchangePoint + item.points,
|
|
167
|
-
}
|
|
168
|
-
},
|
|
169
|
-
{ exchangeAward: 0, exchangePoint: 0 }
|
|
170
|
-
)
|
|
171
|
-
return {
|
|
172
|
-
exchangeAward,
|
|
173
|
-
exchangePoint,
|
|
174
|
-
}
|
|
175
|
-
}),
|
|
176
|
-
},
|
|
177
|
-
guards: {
|
|
178
|
-
hasUnclaimedReward: (context, event) => {
|
|
179
|
-
return context.unclaimedRewardList.length > 0
|
|
180
|
-
},
|
|
181
|
-
isExchangeable: (context, event) => {
|
|
182
|
-
const { exchangeList } = context
|
|
183
|
-
return exchangeList.length > 0
|
|
184
|
-
},
|
|
185
|
-
hasActivityNo: (context, event) => {
|
|
186
|
-
return !!context.activityNo
|
|
187
|
-
},
|
|
188
|
-
},
|
|
189
|
-
services: {
|
|
190
|
-
fetchActivityList: async (context, event) => {
|
|
191
|
-
const { data } = await request.send(api.getActivityList({ appSecret }))
|
|
192
|
-
return data
|
|
193
|
-
},
|
|
194
|
-
fetchActivityDetail: async (context, event) => {
|
|
195
|
-
const { activityNo } = context
|
|
196
|
-
const { data } = await request.send(api.getActivityDetail({ activityNo, appSecret }))
|
|
197
|
-
return data
|
|
198
|
-
},
|
|
199
|
-
exchange: async (context, event) => {
|
|
200
|
-
const { activityNo } = context
|
|
201
|
-
return await request.send(
|
|
202
|
-
api.exchange({
|
|
203
|
-
exchangeType: 1,
|
|
204
|
-
activityNo,
|
|
205
|
-
exchangeAward: event.data,
|
|
206
|
-
})
|
|
207
|
-
)
|
|
208
|
-
},
|
|
209
|
-
collect: async (context, event) => {
|
|
210
|
-
return await request.send(api.collect({ appSecret }))
|
|
211
|
-
},
|
|
212
|
-
},
|
|
213
|
-
}
|
|
214
|
-
)
|
|
215
|
-
}
|