@jetthai/cuora 1.1.352 → 1.1.353-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/CHANGELOG.md +4 -0
- package/package.json +1 -1
- package/src/api/activity.js +5 -0
- package/src/api/index.js +2 -1
- package/src/api/ranking.js +26 -0
- package/src/machine/activity/activity.js +0 -4
- package/src/machine/activity/activity_cash.js +0 -4
- package/src/machine/activity/vip_card_activity.js +67 -28
- package/src/machine/common.js +5 -1
- package/src/machine/game_search_cash.js +9 -1
- package/src/machine/game_search_v2.js +9 -1
- package/src/machine/index.js +2 -0
- package/src/machine/ranking.js +202 -0
- package/src/machine/websocket.js +12 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [1.1.353-dev-1](https://github.com/jetthai/cuora-module/compare/v1.1.353...v1.1.353-dev-1) (2025-04-11)
|
|
6
|
+
|
|
7
|
+
### [1.1.353](https://github.com/jetthai/cuora-module/compare/v1.1.352...v1.1.353) (2025-04-02)
|
|
8
|
+
|
|
5
9
|
### [1.1.352](https://github.com/jetthai/cuora-module/compare/v1.1.351...v1.1.352) (2025-04-02)
|
|
6
10
|
|
|
7
11
|
### [1.1.351](https://github.com/jetthai/cuora-module/compare/v1.1.350...v1.1.351) (2025-04-02)
|
package/package.json
CHANGED
package/src/api/activity.js
CHANGED
|
@@ -107,4 +107,9 @@ export default {
|
|
|
107
107
|
method: 'post',
|
|
108
108
|
params: { startDate, endDate, appSecret },
|
|
109
109
|
}),
|
|
110
|
+
loseRebateHistory: ({ startDate, endDate, appSecret }) => ({
|
|
111
|
+
url: 'activities/lose-rebate/history',
|
|
112
|
+
method: 'post',
|
|
113
|
+
params: { startDate, endDate, appSecret },
|
|
114
|
+
}),
|
|
110
115
|
}
|
package/src/api/index.js
CHANGED
|
@@ -6,5 +6,6 @@ import mailbox from './mailbox.js'
|
|
|
6
6
|
import payment from './payment.js'
|
|
7
7
|
import user from './user.js'
|
|
8
8
|
import form from './form.js'
|
|
9
|
+
import ranking from './ranking.js'
|
|
9
10
|
|
|
10
|
-
export default { activity, auth, common, game, mailbox, payment, user, form }
|
|
11
|
+
export default { activity, auth, common, game, mailbox, payment, user, form, ranking }
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
// 未登入排名資料
|
|
3
|
+
getTournament: ({ activityNo }) => ({
|
|
4
|
+
url: 'tournament/detail',
|
|
5
|
+
method: 'get',
|
|
6
|
+
params: { activityNo },
|
|
7
|
+
isPublic: true,
|
|
8
|
+
}),
|
|
9
|
+
// 登入後排名預設期數資料
|
|
10
|
+
getRankingOptions: ({ activityNo }) => ({
|
|
11
|
+
url: 'ranking/detail/option',
|
|
12
|
+
method: 'get',
|
|
13
|
+
params: { activityNo },
|
|
14
|
+
}),
|
|
15
|
+
// 登入後排名資料
|
|
16
|
+
getRankingDetail: ({ activityNo, cycle, round }) => ({
|
|
17
|
+
url: 'ranking/detail',
|
|
18
|
+
method: 'post',
|
|
19
|
+
params: { activityNo, cycle, round },
|
|
20
|
+
}),
|
|
21
|
+
getRankingGames: ({ activityNo }) => ({
|
|
22
|
+
url: 'hot-game/ranking',
|
|
23
|
+
method: 'get',
|
|
24
|
+
params: { activityNo },
|
|
25
|
+
}),
|
|
26
|
+
}
|
|
@@ -150,12 +150,8 @@ export default function (request) {
|
|
|
150
150
|
}
|
|
151
151
|
}),
|
|
152
152
|
resetActivities: assign((context, event) => {
|
|
153
|
-
const { activityList = [], specifyActivities = [] } = context
|
|
154
|
-
const keepActivities = activityList.filter((activity) => specifyActivities.includes(activity.activityType))
|
|
155
153
|
return {
|
|
156
154
|
isPlaying: true,
|
|
157
|
-
activityList: keepActivities,
|
|
158
|
-
promotionList: [],
|
|
159
155
|
}
|
|
160
156
|
}),
|
|
161
157
|
leaveGame: assign((context, event) => {
|
|
@@ -123,12 +123,8 @@ export default function (request) {
|
|
|
123
123
|
}
|
|
124
124
|
}),
|
|
125
125
|
resetActivities: assign((context, event) => {
|
|
126
|
-
const { activityList = [], detailNeededActivityTypes = [] } = context
|
|
127
|
-
const keepActivities = activityList.filter((activity) => detailNeededActivityTypes.includes(activity.activityType))
|
|
128
126
|
return {
|
|
129
127
|
isPlaying: true,
|
|
130
|
-
activityList: keepActivities,
|
|
131
|
-
promotionList: [],
|
|
132
128
|
}
|
|
133
129
|
}),
|
|
134
130
|
leaveGame: assign((context, event) => {
|
|
@@ -11,17 +11,19 @@ export default function (request) {
|
|
|
11
11
|
activityDetail: null,
|
|
12
12
|
conditions: null,
|
|
13
13
|
rebateType: null,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
nextCycleCardCurrentReachLevel: null,
|
|
15
|
+
nextCycleCardNextReachLevel: null,
|
|
16
|
+
lastCycleCard: null,
|
|
17
17
|
nextDepositLimit: null,
|
|
18
18
|
nextTurnoverLimit: null,
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
accumulateTotalDeposit: null,
|
|
20
|
+
accumulateTotalValidTurnover: null,
|
|
21
21
|
retainAmount: '0',
|
|
22
|
-
|
|
22
|
+
yesterdayRewardsAmount: '0',
|
|
23
23
|
calculateWalletMode: '1',
|
|
24
24
|
duration: 0,
|
|
25
|
+
isAccumulationPeriod: false, // 當前是否為累積期
|
|
26
|
+
isAwardPeriod: false, // 當前是否為領獎期
|
|
25
27
|
},
|
|
26
28
|
initial: 'idle',
|
|
27
29
|
states: {
|
|
@@ -45,6 +47,17 @@ export default function (request) {
|
|
|
45
47
|
},
|
|
46
48
|
},
|
|
47
49
|
},
|
|
50
|
+
sentAward: {
|
|
51
|
+
invoke: {
|
|
52
|
+
src: 'sentAward',
|
|
53
|
+
onDone: {
|
|
54
|
+
target: 'loading',
|
|
55
|
+
},
|
|
56
|
+
onError: {
|
|
57
|
+
target: 'loaded',
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
},
|
|
48
61
|
loaded: {
|
|
49
62
|
entry: 'setDuration',
|
|
50
63
|
after: {
|
|
@@ -61,6 +74,9 @@ export default function (request) {
|
|
|
61
74
|
STOP: {
|
|
62
75
|
target: '.idle',
|
|
63
76
|
},
|
|
77
|
+
SENT_AWARD: {
|
|
78
|
+
target: '.sentAward',
|
|
79
|
+
},
|
|
64
80
|
},
|
|
65
81
|
},
|
|
66
82
|
{
|
|
@@ -79,50 +95,68 @@ export default function (request) {
|
|
|
79
95
|
const {
|
|
80
96
|
rebateType,
|
|
81
97
|
conditions = [],
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
98
|
+
nextCycleCardCurrentReachLevel = {},
|
|
99
|
+
nextCycleCardNextReachLevel = {},
|
|
100
|
+
lastCycleCard = {},
|
|
101
|
+
accumulateTotalDeposit = '0',
|
|
102
|
+
accumulateTotalValidTurnover = '0',
|
|
87
103
|
retainAmount = '0',
|
|
88
|
-
|
|
104
|
+
yesterdayRewardsAmount = '0',
|
|
89
105
|
calculateWalletMode = '0',
|
|
106
|
+
accumulateStartTime,
|
|
107
|
+
accumulateEndTime,
|
|
108
|
+
lastCycleCardStartTime,
|
|
109
|
+
lastCycleCardEndTime,
|
|
90
110
|
} = context.activityDetail || {}
|
|
91
111
|
|
|
92
112
|
let nextDepositLimit = '0'
|
|
93
113
|
let nextTurnoverLimit = '0'
|
|
94
114
|
let currentTurnover = '0'
|
|
95
115
|
let currentDeposit = '0'
|
|
116
|
+
const maxReachLevel = conditions?.[conditions?.length - 1]
|
|
96
117
|
// 若已達到最高等級,所有數值皆以最高等級顯示
|
|
97
|
-
if (
|
|
98
|
-
currentDeposit =
|
|
99
|
-
currentTurnover =
|
|
100
|
-
nextDepositLimit =
|
|
101
|
-
nextTurnoverLimit =
|
|
118
|
+
if (maxReachLevel && nextCycleCardCurrentReachLevel?.title === maxReachLevel.title) {
|
|
119
|
+
currentDeposit = maxReachLevel.depositLimit
|
|
120
|
+
currentTurnover = maxReachLevel.turnoverLimit
|
|
121
|
+
nextDepositLimit = maxReachLevel.depositLimit
|
|
122
|
+
nextTurnoverLimit = maxReachLevel.turnoverLimit
|
|
102
123
|
} else {
|
|
103
|
-
currentDeposit =
|
|
104
|
-
currentTurnover =
|
|
105
|
-
nextDepositLimit =
|
|
106
|
-
nextTurnoverLimit =
|
|
124
|
+
currentDeposit = accumulateTotalDeposit
|
|
125
|
+
currentTurnover = accumulateTotalValidTurnover
|
|
126
|
+
nextDepositLimit = nextCycleCardNextReachLevel?.depositLimit
|
|
127
|
+
nextTurnoverLimit = nextCycleCardNextReachLevel?.turnoverLimit
|
|
107
128
|
}
|
|
129
|
+
// 計算當前是否為累積期及領獎期
|
|
130
|
+
const currentTime = new Date().getTime() / 1000
|
|
131
|
+
const isAccumulationPeriod = currentTime >= accumulateStartTime && currentTime <= accumulateEndTime
|
|
132
|
+
const isAwardPeriod = currentTime >= lastCycleCardStartTime && currentTime <= lastCycleCardEndTime
|
|
108
133
|
|
|
109
134
|
return {
|
|
110
135
|
rebateType,
|
|
111
136
|
conditions,
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
137
|
+
nextCycleCardCurrentReachLevel,
|
|
138
|
+
nextCycleCardNextReachLevel,
|
|
139
|
+
lastCycleCard,
|
|
115
140
|
nextDepositLimit,
|
|
116
141
|
nextTurnoverLimit,
|
|
117
|
-
|
|
118
|
-
|
|
142
|
+
accumulateTotalDeposit: currentDeposit,
|
|
143
|
+
accumulateTotalValidTurnover: currentTurnover,
|
|
119
144
|
retainAmount,
|
|
120
|
-
|
|
145
|
+
yesterdayRewardsAmount,
|
|
121
146
|
calculateWalletMode,
|
|
147
|
+
isAccumulationPeriod,
|
|
148
|
+
isAwardPeriod,
|
|
122
149
|
}
|
|
123
150
|
}),
|
|
124
151
|
setDuration: assign((context, event) => {
|
|
125
|
-
const {
|
|
152
|
+
const { rewardPeriodSameAsAccumulationPeriod, accumulateEndTime, lastCycleCardEndTime } = context?.activityDetail
|
|
153
|
+
const { isAwardPeriod } = context
|
|
154
|
+
// 若為累積期,則倒數時間以累積期結束時間計算
|
|
155
|
+
let currentEndTime = accumulateEndTime
|
|
156
|
+
// 若為領獎期,則倒數時間以領獎期結束時間計算
|
|
157
|
+
if (!rewardPeriodSameAsAccumulationPeriod && isAwardPeriod) {
|
|
158
|
+
currentEndTime = lastCycleCardEndTime
|
|
159
|
+
}
|
|
126
160
|
return {
|
|
127
161
|
duration: Math.max(parseInt(currentEndTime) - new Date().getTime() / 1000, 0),
|
|
128
162
|
}
|
|
@@ -134,6 +168,11 @@ export default function (request) {
|
|
|
134
168
|
const { data } = await request.send(api.getActivityDetail({ activityNo, appSecret }))
|
|
135
169
|
return data
|
|
136
170
|
},
|
|
171
|
+
sentAward: async (context, event) => {
|
|
172
|
+
const { activityNo } = context
|
|
173
|
+
const { data } = await request.send(api.sentAward({ activityNo, appSecret }))
|
|
174
|
+
return data
|
|
175
|
+
},
|
|
137
176
|
},
|
|
138
177
|
}
|
|
139
178
|
)
|
package/src/machine/common.js
CHANGED
|
@@ -292,8 +292,12 @@ export default function (request) {
|
|
|
292
292
|
return { announcementList: { data } }
|
|
293
293
|
}),
|
|
294
294
|
setFeeds: assign((context, event) => {
|
|
295
|
-
const { announcementList, broadcastList, mailBoxInfo } = event.data
|
|
295
|
+
const { announcementList, broadcastList, mailBoxInfo, siteConfig } = event.data
|
|
296
296
|
const promotions = announcementList?.announcements?.filter?.((item) => item.category === 3) || []
|
|
297
|
+
const customerMessageEnable = siteConfig?.csChat?.some((item) => item.enable && item.name === 'customermessage')
|
|
298
|
+
if (!customerMessageEnable) {
|
|
299
|
+
mailBoxInfo.rows -= mailBoxInfo.detailRows?.CUSTOMER || 0
|
|
300
|
+
}
|
|
297
301
|
return { broadcastList, mailBoxInfo, promotions }
|
|
298
302
|
}),
|
|
299
303
|
setBroadcast: assign((context, event) => {
|
|
@@ -5,7 +5,7 @@ export default function (request) {
|
|
|
5
5
|
return createMachine(
|
|
6
6
|
{
|
|
7
7
|
id: 'game_search_cash',
|
|
8
|
-
initial: '
|
|
8
|
+
initial: 'init',
|
|
9
9
|
context: {
|
|
10
10
|
initialized: false,
|
|
11
11
|
keyword: '',
|
|
@@ -32,6 +32,14 @@ export default function (request) {
|
|
|
32
32
|
isRecentlySearch: null,
|
|
33
33
|
},
|
|
34
34
|
states: {
|
|
35
|
+
init: {
|
|
36
|
+
on: {
|
|
37
|
+
INIT: {
|
|
38
|
+
target: 'preset',
|
|
39
|
+
actions: ['setLang'],
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
35
43
|
preset: {
|
|
36
44
|
exit: 'setInitialized',
|
|
37
45
|
invoke: {
|
|
@@ -5,7 +5,7 @@ export default function (request) {
|
|
|
5
5
|
return createMachine(
|
|
6
6
|
{
|
|
7
7
|
id: 'game_search_v2',
|
|
8
|
-
initial: '
|
|
8
|
+
initial: 'init',
|
|
9
9
|
context: {
|
|
10
10
|
keyword: '',
|
|
11
11
|
tagId: null,
|
|
@@ -28,6 +28,14 @@ export default function (request) {
|
|
|
28
28
|
lang: 'en-US',
|
|
29
29
|
},
|
|
30
30
|
states: {
|
|
31
|
+
init: {
|
|
32
|
+
on: {
|
|
33
|
+
INIT: {
|
|
34
|
+
target: 'preset',
|
|
35
|
+
actions: ['setLang'],
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
},
|
|
31
39
|
preset: {
|
|
32
40
|
invoke: {
|
|
33
41
|
src: 'fetchTags',
|
package/src/machine/index.js
CHANGED
|
@@ -39,6 +39,7 @@ import honor_board from './honor_board.js'
|
|
|
39
39
|
import user_photo from './user_photo.js'
|
|
40
40
|
import navbar from './navbar.js'
|
|
41
41
|
import websocket from './websocket.js'
|
|
42
|
+
import ranking from './ranking.js'
|
|
42
43
|
|
|
43
44
|
export default {
|
|
44
45
|
...activity,
|
|
@@ -82,4 +83,5 @@ export default {
|
|
|
82
83
|
navbar,
|
|
83
84
|
...withdraw,
|
|
84
85
|
websocket,
|
|
86
|
+
ranking,
|
|
85
87
|
}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { createMachine, assign } from 'xstate'
|
|
2
|
+
import ranking from '../api/ranking.js'
|
|
3
|
+
|
|
4
|
+
export default function (request) {
|
|
5
|
+
const cycleMapping = ['DAILY', 'WEEKLY', 'MONTHLY']
|
|
6
|
+
|
|
7
|
+
function roundProcess(rounds) {
|
|
8
|
+
const roundArrays = rounds.map((round) => Array.from({ length: round }, (_, i) => i + 1))
|
|
9
|
+
return roundArrays.reduce((acc, roundArray, index) => {
|
|
10
|
+
acc[cycleMapping[index]] = roundArray.reverse()
|
|
11
|
+
return acc
|
|
12
|
+
}, {})
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function transGameData(item) {
|
|
16
|
+
if (!item) return {}
|
|
17
|
+
item.providerId = item.provider
|
|
18
|
+
return item
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return createMachine(
|
|
22
|
+
{
|
|
23
|
+
id: 'ranking',
|
|
24
|
+
initial: 'idle',
|
|
25
|
+
context: {
|
|
26
|
+
auth: false,
|
|
27
|
+
activityNo: '',
|
|
28
|
+
// api options 回傳的資料
|
|
29
|
+
currentRound: [],
|
|
30
|
+
cycle: '',
|
|
31
|
+
round: 0,
|
|
32
|
+
rule: '',
|
|
33
|
+
// api detail 資料
|
|
34
|
+
description: '',
|
|
35
|
+
descriptionUrl: [],
|
|
36
|
+
// api detail 排名資料
|
|
37
|
+
playerRanking: {},
|
|
38
|
+
gameRanking: [],
|
|
39
|
+
topRanking: [],
|
|
40
|
+
settleStatus: false,
|
|
41
|
+
// 前端這邊用的選單資料 { cycle, round }
|
|
42
|
+
options: {},
|
|
43
|
+
},
|
|
44
|
+
states: {
|
|
45
|
+
idle: {
|
|
46
|
+
on: {
|
|
47
|
+
SET_ACTIVITY: {
|
|
48
|
+
target: 'loading',
|
|
49
|
+
},
|
|
50
|
+
SET_OPTIONS: {
|
|
51
|
+
target: 'setting',
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
loading: {
|
|
56
|
+
entry: 'setActivity',
|
|
57
|
+
always: [{ target: 'getRankingOptions', cond: 'hasAuth' }, { target: 'getTournament' }],
|
|
58
|
+
},
|
|
59
|
+
setting: {
|
|
60
|
+
entry: 'setOptions',
|
|
61
|
+
always: [{ target: 'getRankingDetail' }],
|
|
62
|
+
},
|
|
63
|
+
// 未登入時取得排名資料
|
|
64
|
+
getTournament: {
|
|
65
|
+
invoke: {
|
|
66
|
+
src: 'fetchTournament',
|
|
67
|
+
onDone: {
|
|
68
|
+
target: 'idle',
|
|
69
|
+
actions: 'setRanking',
|
|
70
|
+
},
|
|
71
|
+
onError: {
|
|
72
|
+
target: 'idle',
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
// 登入後取得排名選單資料
|
|
77
|
+
getRankingOptions: {
|
|
78
|
+
invoke: {
|
|
79
|
+
src: 'fetchRankingOptions',
|
|
80
|
+
onDone: {
|
|
81
|
+
target: 'getRankingGames',
|
|
82
|
+
actions: 'setRankingOptions',
|
|
83
|
+
},
|
|
84
|
+
onError: {
|
|
85
|
+
target: 'idle',
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
// 登入後取得排名資料
|
|
90
|
+
getRankingDetail: {
|
|
91
|
+
invoke: {
|
|
92
|
+
src: 'fetchRankingDetail',
|
|
93
|
+
onDone: {
|
|
94
|
+
target: 'idle',
|
|
95
|
+
actions: 'setRanking',
|
|
96
|
+
},
|
|
97
|
+
onError: {
|
|
98
|
+
target: 'idle',
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
getRankingGames: {
|
|
103
|
+
invoke: {
|
|
104
|
+
src: 'fetchRankingGames',
|
|
105
|
+
onDone: {
|
|
106
|
+
target: 'getRankingDetail',
|
|
107
|
+
actions: 'setRankingGames',
|
|
108
|
+
},
|
|
109
|
+
onError: {
|
|
110
|
+
target: 'idle',
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
actions: {
|
|
118
|
+
setActivity: assign((context, event) => {
|
|
119
|
+
return {
|
|
120
|
+
auth: !!request.getToken(),
|
|
121
|
+
activityNo: event.data?.activityNo,
|
|
122
|
+
}
|
|
123
|
+
}),
|
|
124
|
+
setRanking: assign((context, event) => {
|
|
125
|
+
const topRanking = event.data?.topRanking?.map((rank) => transGameData(rank)) || []
|
|
126
|
+
return {
|
|
127
|
+
description: event.data?.description,
|
|
128
|
+
descriptionUrl: event.data?.descriptionUrl,
|
|
129
|
+
topRanking: topRanking,
|
|
130
|
+
playerRanking: transGameData(event.data?.playerRanking) || {},
|
|
131
|
+
settleStatus: !!topRanking[0]?.settleStatus,
|
|
132
|
+
}
|
|
133
|
+
}),
|
|
134
|
+
setRankingGames: assign((context, event) => {
|
|
135
|
+
const gameRanking = event.data?.map((rank) => transGameData(rank))
|
|
136
|
+
return {
|
|
137
|
+
gameRanking: gameRanking || [],
|
|
138
|
+
}
|
|
139
|
+
}),
|
|
140
|
+
setRankingOptions: assign((context, event) => {
|
|
141
|
+
const cycle = event.data?.cycle
|
|
142
|
+
const currentRound = event.data?.currentRound || []
|
|
143
|
+
// 取得結算週期選單列表
|
|
144
|
+
const cycleOptions = cycleMapping.slice(0, currentRound.length)
|
|
145
|
+
// 取得每週期的歷史期數選單列表
|
|
146
|
+
const roundOptions = roundProcess(currentRound)
|
|
147
|
+
// 如果是月結算,則加入全部選項
|
|
148
|
+
if (cycle === 'MONTHLY') {
|
|
149
|
+
cycleOptions.push('ALL')
|
|
150
|
+
roundOptions.ALL = roundOptions.MONTHLY
|
|
151
|
+
}
|
|
152
|
+
return {
|
|
153
|
+
...event.data,
|
|
154
|
+
options: { cycle: cycleOptions, round: roundOptions },
|
|
155
|
+
// 初始固定顯示 DAILY
|
|
156
|
+
cycle: event.data?.rule !== 'NORMAL' ? 'DAILY' : cycle,
|
|
157
|
+
round: currentRound[0],
|
|
158
|
+
}
|
|
159
|
+
}),
|
|
160
|
+
setOptions: assign((context, event) => {
|
|
161
|
+
const { cycle, round } = context
|
|
162
|
+
// 處理變更 cycle,如果沒有輸入或沒有變更就不更新
|
|
163
|
+
if (event.data?.cycle && cycle !== event.data?.cycle) {
|
|
164
|
+
const { currentRound } = context
|
|
165
|
+
const cycleForRound = event.data?.cycle === 'ALL' ? 'MONTHLY' : event.data?.cycle
|
|
166
|
+
const cycleIndex = cycleMapping.indexOf(cycleForRound)
|
|
167
|
+
return { cycle: event.data?.cycle, round: currentRound[cycleIndex] }
|
|
168
|
+
}
|
|
169
|
+
if (event.data?.round && round !== event.data?.round) {
|
|
170
|
+
return { round: event.data?.round }
|
|
171
|
+
}
|
|
172
|
+
return {}
|
|
173
|
+
}),
|
|
174
|
+
},
|
|
175
|
+
guards: {
|
|
176
|
+
hasAuth: (context) => context.auth,
|
|
177
|
+
},
|
|
178
|
+
services: {
|
|
179
|
+
fetchTournament: async (context) => {
|
|
180
|
+
const { activityNo } = context
|
|
181
|
+
const { data } = await request.send(ranking.getTournament({ activityNo }))
|
|
182
|
+
return data
|
|
183
|
+
},
|
|
184
|
+
fetchRankingOptions: async (context) => {
|
|
185
|
+
const { activityNo } = context
|
|
186
|
+
const { data } = await request.send(ranking.getRankingOptions({ activityNo }))
|
|
187
|
+
return data
|
|
188
|
+
},
|
|
189
|
+
fetchRankingDetail: async (context, event) => {
|
|
190
|
+
const { activityNo, cycle, round } = context
|
|
191
|
+
const { data } = await request.send(ranking.getRankingDetail({ activityNo, cycle, round }))
|
|
192
|
+
return data
|
|
193
|
+
},
|
|
194
|
+
fetchRankingGames: async (context) => {
|
|
195
|
+
const { activityNo } = context
|
|
196
|
+
const { data } = await request.send(ranking.getRankingGames({ activityNo }))
|
|
197
|
+
return data
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
}
|
|
201
|
+
)
|
|
202
|
+
}
|
package/src/machine/websocket.js
CHANGED
|
@@ -278,6 +278,18 @@ export default function (request) {
|
|
|
278
278
|
callback({ type: 'PUSH_ANALYTICS', data })
|
|
279
279
|
})
|
|
280
280
|
|
|
281
|
+
// 監聽 activity-reward-info 事件
|
|
282
|
+
clientSocket.on('activity-reward-info', (data) => {
|
|
283
|
+
console.log('[socket][activity-reward-info]:', data)
|
|
284
|
+
callback({ type: 'ACTIVITY_INFO', data })
|
|
285
|
+
})
|
|
286
|
+
|
|
287
|
+
// 監聽 message-notice-info 事件
|
|
288
|
+
clientSocket.on('message-notice-info', (data) => {
|
|
289
|
+
console.log('[socket][message-notice-info]:', data)
|
|
290
|
+
callback({ type: 'ACTIVITY_INFO', data })
|
|
291
|
+
})
|
|
292
|
+
|
|
281
293
|
// 監聽 payment-info 事件
|
|
282
294
|
clientSocket.on('payment-info', (data) => {
|
|
283
295
|
console.log('[socket][payment-info]:', data)
|