@jetthai/cuora 1.1.346-dev-7 → 1.1.346-qa

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 CHANGED
@@ -2,69 +2,7 @@
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.346-dev-7](https://github.com/jetthai/cuora-module/compare/v1.1.346-wallet-1...v1.1.346-dev-7) (2025-04-11)
6
-
7
- ### [1.1.346-dev-6](https://github.com/jetthai/cuora-module/compare/v1.1.346-dev-5...v1.1.346-dev-6) (2025-04-08)
8
-
9
- ### [1.1.346-dev-5](https://github.com/jetthai/cuora-module/compare/v1.1.346-dev-4...v1.1.346-dev-5) (2025-04-08)
10
-
11
- ### [1.1.346-dev-4](https://github.com/jetthai/cuora-module/compare/v1.1.353...v1.1.346-dev-4) (2025-04-02)
12
-
13
- ### [1.1.346-ranking-1](https://github.com/jetthai/cuora-module/compare/v1.1.351...v1.1.346-ranking-1) (2025-04-02)
14
-
15
- ### [1.1.346-dev-3](https://github.com/jetthai/cuora-module/compare/v1.1.347...v1.1.346-dev-3) (2025-03-30)
16
-
17
- ### [1.1.346-dev-2](https://github.com/jetthai/cuora-module/compare/v1.1.346-dev-1...v1.1.346-dev-2) (2025-03-28)
18
-
19
- ### [1.1.346-dev-1](https://github.com/jetthai/cuora-module/compare/v1.1.346...v1.1.346-dev-1) (2025-03-28)
20
-
21
- ### [1.1.346-dev-6](https://github.com/jetthai/cuora-module/compare/v1.1.346-dev-5...v1.1.346-dev-6) (2025-04-08)
22
-
23
- ### [1.1.346-dev-5](https://github.com/jetthai/cuora-module/compare/v1.1.346-dev-4...v1.1.346-dev-5) (2025-04-08)
24
-
25
- ### [1.1.353](https://github.com/jetthai/cuora-module/compare/v1.1.352...v1.1.353) (2025-04-02)
26
-
27
- ### [1.1.352](https://github.com/jetthai/cuora-module/compare/v1.1.346-ranking-1...v1.1.352) (2025-04-02)
28
-
29
- ### [1.1.351](https://github.com/jetthai/cuora-module/compare/v1.1.350...v1.1.351) (2025-04-02)
30
-
31
- ### [1.1.350](https://github.com/jetthai/cuora-module/compare/v1.1.349...v1.1.350) (2025-03-31)
32
-
33
- ### [1.1.349](https://github.com/jetthai/cuora-module/compare/v1.1.348...v1.1.349) (2025-03-30)
34
-
35
- ### [1.1.348](https://github.com/jetthai/cuora-module/compare/v1.1.346-dev-3...v1.1.348) (2025-03-30)
36
-
37
- ### [1.1.347](https://github.com/jetthai/cuora-module/compare/v1.1.346-dev-2...v1.1.347) (2025-03-30)
38
-
39
- ### [1.1.364-dev-5](https://github.com/jetthai/cuora-module/compare/v1.1.346-dev-4...v1.1.364-dev-5) (2025-04-08)
40
-
41
- ### [1.1.353](https://github.com/jetthai/cuora-module/compare/v1.1.352...v1.1.353) (2025-04-02)
42
-
43
- ### [1.1.352](https://github.com/jetthai/cuora-module/compare/v1.1.346-ranking-1...v1.1.352) (2025-04-02)
44
-
45
- ### [1.1.351](https://github.com/jetthai/cuora-module/compare/v1.1.350...v1.1.351) (2025-04-02)
46
-
47
- ### [1.1.350](https://github.com/jetthai/cuora-module/compare/v1.1.349...v1.1.350) (2025-03-31)
48
-
49
- ### [1.1.349](https://github.com/jetthai/cuora-module/compare/v1.1.348...v1.1.349) (2025-03-30)
50
-
51
- ### [1.1.348](https://github.com/jetthai/cuora-module/compare/v1.1.346-dev-3...v1.1.348) (2025-03-30)
52
-
53
- ### [1.1.347](https://github.com/jetthai/cuora-module/compare/v1.1.346-dev-2...v1.1.347) (2025-03-30)
54
-
55
- ### [1.1.346-dev-4](https://github.com/jetthai/cuora-module/compare/v1.1.346-ranking-1...v1.1.346-dev-4) (2025-04-02)
56
-
57
- ### [1.1.346-dev-3](https://github.com/jetthai/cuora-module/compare/v1.1.346-dev-2...v1.1.346-dev-3) (2025-03-30)
58
-
59
- ### [1.1.346-dev-2](https://github.com/jetthai/cuora-module/compare/v1.1.346-dev-1...v1.1.346-dev-2) (2025-03-28)
60
-
61
- ### [1.1.346-dev-1](https://github.com/jetthai/cuora-module/compare/v1.1.346...v1.1.346-dev-1) (2025-03-28)
62
-
63
- ### [1.1.346-dev-3](https://github.com/jetthai/cuora-module/compare/v1.1.346-dev-2...v1.1.346-dev-3) (2025-03-30)
64
-
65
- ### [1.1.346-dev-2](https://github.com/jetthai/cuora-module/compare/v1.1.346-dev-1...v1.1.346-dev-2) (2025-03-28)
66
-
67
- ### [1.1.346-dev-1](https://github.com/jetthai/cuora-module/compare/v1.1.346...v1.1.346-dev-1) (2025-03-28)
5
+ ### [1.1.346-qa](https://github.com/jetthai/cuora-module/compare/v1.1.346...v1.1.346-qa) (2025-03-30)
68
6
 
69
7
  ### [1.1.346](https://github.com/jetthai/cuora-module/compare/v1.1.345...v1.1.346) (2025-03-27)
70
8
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.1.346-dev-7",
3
+ "version": "1.1.346-qa",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
@@ -107,9 +107,4 @@ 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
- }),
115
110
  }
package/src/api/index.js CHANGED
@@ -6,6 +6,5 @@ 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'
10
9
 
11
- export default { activity, auth, common, game, mailbox, payment, user, form, ranking }
10
+ export default { activity, auth, common, game, mailbox, payment, user, form }
@@ -150,8 +150,12 @@ 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))
153
155
  return {
154
156
  isPlaying: true,
157
+ activityList: keepActivities,
158
+ promotionList: [],
155
159
  }
156
160
  }),
157
161
  leaveGame: assign((context, event) => {
@@ -182,7 +186,8 @@ export default function (request) {
182
186
  services: {
183
187
  fetchList: async (context, event) => {
184
188
  const hasToken = request.getToken()
185
- const apiCallable = hasToken
189
+ const isDoubleWallet = context.siteConfig?.walletMode === '4'
190
+ const apiCallable = hasToken && isDoubleWallet
186
191
  const [{ data }, promotionList] = await Promise.all([
187
192
  hasToken ? request.send(activity.getActivityList({ appSecret })) : request.send(activity.getAllActivityList({ appSecret })),
188
193
  apiCallable && !context.isPlaying ? request.send(payment.getPromotionsList()) : [],
@@ -123,8 +123,12 @@ 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))
126
128
  return {
127
129
  isPlaying: true,
130
+ activityList: keepActivities,
131
+ promotionList: [],
128
132
  }
129
133
  }),
130
134
  leaveGame: assign((context, event) => {
@@ -11,19 +11,17 @@ export default function (request) {
11
11
  activityDetail: null,
12
12
  conditions: null,
13
13
  rebateType: null,
14
- nextCycleCardCurrentReachLevel: null,
15
- nextCycleCardNextReachLevel: null,
16
- lastCycleCard: null,
14
+ currentReachLevel: null,
15
+ nextReachLevel: null,
16
+ lastPeriod: null,
17
17
  nextDepositLimit: null,
18
18
  nextTurnoverLimit: null,
19
- accumulateTotalDeposit: null,
20
- accumulateTotalValidTurnover: null,
19
+ currentTotalDeposit: null,
20
+ currentTotalTurnover: null,
21
21
  retainAmount: '0',
22
- yesterdayRewardsAmount: '0',
22
+ yesterdayReward: '0',
23
23
  calculateWalletMode: '1',
24
24
  duration: 0,
25
- isAccumulationPeriod: false, // 當前是否為累積期
26
- isAwardPeriod: false, // 當前是否為領獎期
27
25
  },
28
26
  initial: 'idle',
29
27
  states: {
@@ -47,17 +45,6 @@ export default function (request) {
47
45
  },
48
46
  },
49
47
  },
50
- sentAward: {
51
- invoke: {
52
- src: 'sentAward',
53
- onDone: {
54
- target: 'loading',
55
- },
56
- onError: {
57
- target: 'loaded',
58
- },
59
- },
60
- },
61
48
  loaded: {
62
49
  entry: 'setDuration',
63
50
  after: {
@@ -74,9 +61,6 @@ export default function (request) {
74
61
  STOP: {
75
62
  target: '.idle',
76
63
  },
77
- SENT_AWARD: {
78
- target: '.sentAward',
79
- },
80
64
  },
81
65
  },
82
66
  {
@@ -95,68 +79,50 @@ export default function (request) {
95
79
  const {
96
80
  rebateType,
97
81
  conditions = [],
98
- nextCycleCardCurrentReachLevel = {},
99
- nextCycleCardNextReachLevel = {},
100
- lastCycleCard = {},
101
- accumulateTotalDeposit = '0',
102
- accumulateTotalValidTurnover = '0',
82
+ currentReachLevel = {},
83
+ nextReachLevel = {},
84
+ lastPeriod = {},
85
+ currentTotalDeposit = '0',
86
+ currentTotalTurnover = '0',
103
87
  retainAmount = '0',
104
- yesterdayRewardsAmount = '0',
88
+ yesterdayReward = '0',
105
89
  calculateWalletMode = '0',
106
- accumulateStartTime,
107
- accumulateEndTime,
108
- lastCycleCardStartTime,
109
- lastCycleCardEndTime,
110
90
  } = context.activityDetail || {}
111
91
 
112
92
  let nextDepositLimit = '0'
113
93
  let nextTurnoverLimit = '0'
114
94
  let currentTurnover = '0'
115
95
  let currentDeposit = '0'
116
- const maxReachLevel = conditions?.[conditions?.length - 1]
117
96
  // 若已達到最高等級,所有數值皆以最高等級顯示
118
- if (maxReachLevel && nextCycleCardCurrentReachLevel?.title === maxReachLevel.title) {
119
- currentDeposit = maxReachLevel.depositLimit
120
- currentTurnover = maxReachLevel.turnoverLimit
121
- nextDepositLimit = maxReachLevel.depositLimit
122
- nextTurnoverLimit = maxReachLevel.turnoverLimit
97
+ if (currentReachLevel?.title === conditions?.[conditions?.length - 1]?.title) {
98
+ currentDeposit = conditions[conditions.length - 1].depositLimit
99
+ currentTurnover = conditions[conditions.length - 1].turnoverLimit
100
+ nextDepositLimit = conditions[conditions.length - 1].depositLimit
101
+ nextTurnoverLimit = conditions[conditions.length - 1].turnoverLimit
123
102
  } else {
124
- currentDeposit = accumulateTotalDeposit
125
- currentTurnover = accumulateTotalValidTurnover
126
- nextDepositLimit = nextCycleCardNextReachLevel?.depositLimit
127
- nextTurnoverLimit = nextCycleCardNextReachLevel?.turnoverLimit
103
+ currentDeposit = currentTotalDeposit
104
+ currentTurnover = currentTotalTurnover
105
+ nextDepositLimit = nextReachLevel?.depositLimit
106
+ nextTurnoverLimit = nextReachLevel?.turnoverLimit
128
107
  }
129
- // 計算當前是否為累積期及領獎期
130
- const currentTime = new Date().getTime() / 1000
131
- const isAccumulationPeriod = currentTime >= accumulateStartTime && currentTime <= accumulateEndTime
132
- const isAwardPeriod = currentTime >= lastCycleCardStartTime && currentTime <= lastCycleCardEndTime
133
108
 
134
109
  return {
135
110
  rebateType,
136
111
  conditions,
137
- nextCycleCardCurrentReachLevel,
138
- nextCycleCardNextReachLevel,
139
- lastCycleCard,
112
+ currentReachLevel,
113
+ nextReachLevel,
114
+ lastPeriod,
140
115
  nextDepositLimit,
141
116
  nextTurnoverLimit,
142
- accumulateTotalDeposit: currentDeposit,
143
- accumulateTotalValidTurnover: currentTurnover,
117
+ currentTotalDeposit: currentDeposit,
118
+ currentTotalTurnover: currentTurnover,
144
119
  retainAmount,
145
- yesterdayRewardsAmount,
120
+ yesterdayReward,
146
121
  calculateWalletMode,
147
- isAccumulationPeriod,
148
- isAwardPeriod,
149
122
  }
150
123
  }),
151
124
  setDuration: assign((context, event) => {
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
- }
125
+ const { currentEndTime } = context?.activityDetail
160
126
  return {
161
127
  duration: Math.max(parseInt(currentEndTime) - new Date().getTime() / 1000, 0),
162
128
  }
@@ -168,11 +134,6 @@ export default function (request) {
168
134
  const { data } = await request.send(api.getActivityDetail({ activityNo, appSecret }))
169
135
  return data
170
136
  },
171
- sentAward: async (context, event) => {
172
- const { activityNo } = context
173
- const { data } = await request.send(api.sentAward({ activityNo, appSecret }))
174
- return data
175
- },
176
137
  },
177
138
  }
178
139
  )
@@ -292,12 +292,8 @@ export default function (request) {
292
292
  return { announcementList: { data } }
293
293
  }),
294
294
  setFeeds: assign((context, event) => {
295
- const { announcementList, broadcastList, mailBoxInfo, siteConfig } = event.data
295
+ const { announcementList, broadcastList, mailBoxInfo } = 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
- }
301
297
  return { broadcastList, mailBoxInfo, promotions }
302
298
  }),
303
299
  setBroadcast: assign((context, event) => {
@@ -58,6 +58,7 @@ export default function (request) {
58
58
  always: [
59
59
  {
60
60
  target: 'loaded',
61
+ cond: 'isDoubleWalletMode',
61
62
  },
62
63
  {
63
64
  target: 'calculating',
@@ -90,7 +91,7 @@ export default function (request) {
90
91
  SUBMIT: [
91
92
  {
92
93
  target: 'pending',
93
- cond: (context, event) => !!context.calculation,
94
+ cond: (context, event) => context.siteConfig?.walletMode === '4' && !!context.calculation,
94
95
  },
95
96
  {
96
97
  target: 'submitting',
@@ -128,7 +129,7 @@ export default function (request) {
128
129
  SUBMIT: [
129
130
  {
130
131
  target: 'pending',
131
- cond: (context, event) => !!context.calculation,
132
+ cond: (context, event) => context.siteConfig?.walletMode === '4' && !!context.calculation,
132
133
  },
133
134
  {
134
135
  target: 'submitting',
@@ -246,6 +247,9 @@ export default function (request) {
246
247
  }),
247
248
  },
248
249
  guards: {
250
+ isDoubleWalletMode: (context, event) => {
251
+ return context.siteConfig?.walletMode === '4'
252
+ },
249
253
  isCalculable: (context, event) => {
250
254
  const {
251
255
  amount,
@@ -72,8 +72,8 @@ export default function (request) {
72
72
  target: 'fetching',
73
73
  cond: (context, event) => {
74
74
  const { siteConfig = {}, promotion = {} } = context
75
- const { bonusPreviewEnable } = siteConfig
76
- return bonusPreviewEnable && promotion.activityNo != 'none'
75
+ const { walletMode = '', bonusPreviewEnable } = siteConfig
76
+ return walletMode === '4' && bonusPreviewEnable && promotion.activityNo != 'none'
77
77
  },
78
78
  },
79
79
  { target: 'loaded' },
@@ -49,8 +49,8 @@ export default function (request) {
49
49
  target: 'fetching',
50
50
  cond: (context, event) => {
51
51
  const { siteConfig = {}, promotion = {}, selectedCard } = context
52
- const { bonusPreviewEnable } = siteConfig
53
- return !!selectedCard && bonusPreviewEnable && promotion.activityNo != 'none'
52
+ const { walletMode = '', bonusPreviewEnable } = siteConfig
53
+ return !!selectedCard && walletMode === '4' && bonusPreviewEnable && promotion.activityNo != 'none'
54
54
  },
55
55
  },
56
56
  { target: 'loaded' },
@@ -78,8 +78,8 @@ export default function (request) {
78
78
  actions: 'setCard',
79
79
  cond: (context, event) => {
80
80
  const { siteConfig = {}, promotion = {} } = context
81
- const { bonusPreviewEnable } = siteConfig
82
- return bonusPreviewEnable && promotion.activityNo != 'none'
81
+ const { walletMode = '', bonusPreviewEnable } = siteConfig
82
+ return walletMode === '4' && bonusPreviewEnable && promotion.activityNo != 'none'
83
83
  },
84
84
  },
85
85
  {
@@ -87,6 +87,11 @@ export default function (request) {
87
87
  },
88
88
  ],
89
89
  SELECT_AMOUNT: [
90
+ {
91
+ target: 'pending',
92
+ actions: 'setAmount',
93
+ cond: 'isFreeWalletMode',
94
+ },
90
95
  {
91
96
  target: 'debouncing',
92
97
  actions: 'setAmount',
@@ -94,6 +99,19 @@ export default function (request) {
94
99
  ],
95
100
  },
96
101
  },
102
+ pending: {
103
+ on: {
104
+ SELECT_AMOUNT: {
105
+ actions: 'setAmount',
106
+ },
107
+ CONFIRM: {
108
+ target: 'debouncing',
109
+ },
110
+ BACK: {
111
+ target: 'loaded',
112
+ },
113
+ },
114
+ },
97
115
  debouncing: {
98
116
  on: {
99
117
  SELECT_AMOUNT: {
@@ -114,6 +132,19 @@ export default function (request) {
114
132
  invoke: {
115
133
  src: 'fetchCalculation',
116
134
  onDone: [
135
+ {
136
+ target: 'submitting',
137
+ actions: 'setCalculation',
138
+ cond: (context, event) => {
139
+ const { siteConfig = {}, selectedCard = {} } = context
140
+ return siteConfig.walletMode === '2' && selectedCard.jumpLinkEnable === 1
141
+ },
142
+ },
143
+ {
144
+ target: 'cardInfo',
145
+ actions: 'setCalculation',
146
+ cond: 'isFreeWalletMode',
147
+ },
117
148
  {
118
149
  target: 'calculated',
119
150
  actions: 'setCalculation',
@@ -127,10 +158,17 @@ export default function (request) {
127
158
  calculable: {
128
159
  entry: 'clearCalculation',
129
160
  on: {
130
- SELECT_AMOUNT: {
131
- target: 'debouncing',
132
- actions: 'setAmount',
133
- },
161
+ SELECT_AMOUNT: [
162
+ {
163
+ target: 'pending',
164
+ actions: 'setAmount',
165
+ cond: 'isFreeWalletMode',
166
+ },
167
+ {
168
+ target: 'debouncing',
169
+ actions: 'setAmount',
170
+ },
171
+ ],
134
172
  BACK: {
135
173
  target: 'loaded',
136
174
  },
@@ -178,8 +216,8 @@ export default function (request) {
178
216
  actions: 'setCard',
179
217
  cond: (context, event) => {
180
218
  const { siteConfig = {}, promotion = {} } = context
181
- const { bonusPreviewEnable } = siteConfig
182
- return bonusPreviewEnable && promotion.activityNo != 'none'
219
+ const { walletMode = '', bonusPreviewEnable } = siteConfig
220
+ return walletMode === '4' && bonusPreviewEnable && promotion.activityNo != 'none'
183
221
  },
184
222
  },
185
223
  {
@@ -287,6 +325,9 @@ export default function (request) {
287
325
  }),
288
326
  },
289
327
  guards: {
328
+ isFreeWalletMode: (context, event) => {
329
+ return context.siteConfig?.walletMode === '2'
330
+ },
290
331
  isSubmittable: (context, event) => {
291
332
  const { cardNumber, serialNumber } = context
292
333
  return cardNumber && serialNumber
@@ -75,8 +75,24 @@ export default function (request) {
75
75
  },
76
76
  },
77
77
  step1: {
78
- initial: 'idle',
78
+ initial: 'promotion',
79
79
  states: {
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
+ },
80
96
  idle: {},
81
97
  calculating: {
82
98
  invoke: {
@@ -121,10 +137,11 @@ export default function (request) {
121
137
  {
122
138
  target: 'pending',
123
139
  cond: (context, event) => {
124
- const { calculation, promotion } = context
140
+ const { siteConfig = {}, calculation, promotion } = context
141
+ const { walletMode } = siteConfig
125
142
  const { promotionsNo, activityNo } = promotion
126
143
  const isNoBonus = promotionsNo === 'none' || activityNo === 'none'
127
- return !!calculation && !isNoBonus
144
+ return walletMode === '4' && !!calculation && !isNoBonus
128
145
  },
129
146
  },
130
147
  {
@@ -368,6 +385,9 @@ export default function (request) {
368
385
  }),
369
386
  },
370
387
  guards: {
388
+ isDoubleWalletMode: (context, event) => {
389
+ return context.siteConfig?.walletMode === '4'
390
+ },
371
391
  isCalculable: (context, event) => {
372
392
  const {
373
393
  amount,
@@ -49,8 +49,16 @@ export default function (request) {
49
49
  target: 'fetching',
50
50
  cond: (context, event) => {
51
51
  const { siteConfig = {}, promotion = {}, selectedQrcode } = context
52
- const { bonusPreviewEnable } = siteConfig
53
- return !!selectedQrcode && bonusPreviewEnable && promotion.activityNo != 'none'
52
+ const { walletMode = '', bonusPreviewEnable } = siteConfig
53
+ return !!selectedQrcode && walletMode === '4' && bonusPreviewEnable && promotion.activityNo != 'none'
54
+ },
55
+ },
56
+ {
57
+ target: 'debouncing',
58
+ actions: 'setPromotionDefaultAmount',
59
+ cond: (context, event) => {
60
+ const { siteConfig = {}, promotion = {} } = context
61
+ return siteConfig.walletMode === '3' && !!promotion?.minimumAmount
54
62
  },
55
63
  },
56
64
  { target: 'loaded' },
@@ -78,21 +86,51 @@ export default function (request) {
78
86
  actions: 'setQrcode',
79
87
  cond: (context, event) => {
80
88
  const { siteConfig = {}, promotion = {} } = context
81
- const { bonusPreviewEnable } = siteConfig
82
- return bonusPreviewEnable && promotion.activityNo != 'none'
89
+ const { walletMode = '', bonusPreviewEnable } = siteConfig
90
+ return walletMode === '4' && bonusPreviewEnable && promotion.activityNo != 'none'
83
91
  },
84
92
  },
93
+ {
94
+ target: 'debouncing',
95
+ actions: ['setQrcode', 'setPromotionDefaultAmount'],
96
+ cond: (context, event) => context.siteConfig?.walletMode === '3' && context.promotion?.minimumAmount,
97
+ },
85
98
  {
86
99
  actions: 'setQrcode',
87
100
  },
88
101
  ],
89
102
  SELECT_AMOUNT: [
103
+ {
104
+ target: 'debouncing',
105
+ actions: 'setAmount',
106
+ cond: 'isDoubleWalletMode',
107
+ },
108
+ {
109
+ target: 'pending',
110
+ actions: 'addAmount',
111
+ cond: (context, event) => context.siteConfig?.walletMode === '2' && context.grandTotalEnable === 1,
112
+ },
113
+ {
114
+ target: 'pending',
115
+ actions: 'setAmount',
116
+ cond: 'isFreeWalletMode',
117
+ },
118
+ {
119
+ target: 'debouncing',
120
+ actions: 'addAmount',
121
+ cond: 'isGrandTotalEnable',
122
+ },
90
123
  {
91
124
  target: 'debouncing',
92
125
  actions: 'setAmount',
93
126
  },
94
127
  ],
95
128
  KEY_IN: [
129
+ {
130
+ target: 'pending',
131
+ actions: 'setAmount',
132
+ cond: 'isFreeWalletMode',
133
+ },
96
134
  {
97
135
  target: 'calculating',
98
136
  actions: 'setAmount',
@@ -100,9 +138,51 @@ export default function (request) {
100
138
  ],
101
139
  },
102
140
  },
141
+ pending: {
142
+ on: {
143
+ SELECT_AMOUNT: [
144
+ {
145
+ actions: 'addAmount',
146
+ cond: 'isGrandTotalEnable',
147
+ },
148
+ {
149
+ actions: 'setAmount',
150
+ },
151
+ ],
152
+ KEY_IN: {
153
+ actions: 'setAmount',
154
+ },
155
+ CONFIRM: {
156
+ target: 'calculating',
157
+ },
158
+ BACK: {
159
+ target: 'loaded',
160
+ },
161
+ },
162
+ },
103
163
  debouncing: {
104
164
  on: {
105
165
  SELECT_AMOUNT: [
166
+ {
167
+ target: 'debouncing',
168
+ actions: 'setAmount',
169
+ cond: 'isDoubleWalletMode',
170
+ },
171
+ {
172
+ target: 'debouncing',
173
+ actions: 'addAmount',
174
+ cond: (context, event) => context.siteConfig?.walletMode === '2' && context.grandTotalEnable === 1,
175
+ },
176
+ {
177
+ target: 'debouncing',
178
+ actions: 'setAmount',
179
+ cond: 'isFreeWalletMode',
180
+ },
181
+ {
182
+ target: 'debouncing',
183
+ actions: 'addAmount',
184
+ cond: 'isGrandTotalEnable',
185
+ },
106
186
  {
107
187
  target: 'debouncing',
108
188
  actions: 'setAmount',
@@ -122,6 +202,26 @@ export default function (request) {
122
202
  entry: 'clearCalculation',
123
203
  on: {
124
204
  SELECT_AMOUNT: [
205
+ {
206
+ target: 'debouncing',
207
+ actions: 'setAmount',
208
+ cond: 'isDoubleWalletMode',
209
+ },
210
+ {
211
+ target: 'pending',
212
+ actions: 'addAmount',
213
+ cond: (context, event) => context.siteConfig?.walletMode === '2' && context.grandTotalEnable === 1,
214
+ },
215
+ {
216
+ target: 'pending',
217
+ actions: 'setAmount',
218
+ cond: 'isFreeWalletMode',
219
+ },
220
+ {
221
+ target: 'debouncing',
222
+ actions: 'addAmount',
223
+ cond: 'isGrandTotalEnable',
224
+ },
125
225
  {
126
226
  target: 'debouncing',
127
227
  actions: 'setAmount',
@@ -140,6 +240,11 @@ export default function (request) {
140
240
  invoke: {
141
241
  src: 'fetchCalculation',
142
242
  onDone: [
243
+ {
244
+ target: 'submitting',
245
+ actions: 'setCalculation',
246
+ cond: 'isFreeWalletMode',
247
+ },
143
248
  {
144
249
  target: 'calculated',
145
250
  actions: 'setCalculation',
@@ -153,6 +258,16 @@ export default function (request) {
153
258
  calculated: {
154
259
  on: {
155
260
  SELECT_AMOUNT: [
261
+ {
262
+ target: 'pending',
263
+ actions: 'addAmount',
264
+ cond: (context, event) => context.siteConfig?.walletMode === '2' && context.grandTotalEnable === 1,
265
+ },
266
+ {
267
+ target: 'pending',
268
+ actions: 'setAmount',
269
+ cond: 'isFreeWalletMode',
270
+ },
156
271
  {
157
272
  target: 'debouncing',
158
273
  actions: 'addAmount',
@@ -199,8 +314,8 @@ export default function (request) {
199
314
  actions: 'setQrcode',
200
315
  cond: (context, event) => {
201
316
  const { siteConfig = {}, promotion = {} } = context
202
- const { bonusPreviewEnable } = siteConfig
203
- return bonusPreviewEnable && promotion.activityNo != 'none'
317
+ const { walletMode = '', bonusPreviewEnable } = siteConfig
318
+ return walletMode === '4' && bonusPreviewEnable && promotion.activityNo != 'none'
204
319
  },
205
320
  },
206
321
  {
@@ -280,8 +395,19 @@ export default function (request) {
280
395
  promotion,
281
396
  }
282
397
  }),
398
+ setPromotionDefaultAmount: assign((context, event) => {
399
+ return {
400
+ selectedAmount: context.promotion.minimumAmount,
401
+ }
402
+ }),
283
403
  },
284
404
  guards: {
405
+ isDoubleWalletMode: (context, event) => {
406
+ return context.siteConfig?.walletMode === '4'
407
+ },
408
+ isFreeWalletMode: (context, event) => {
409
+ return context.siteConfig?.walletMode === '2'
410
+ },
285
411
  isGrandTotalEnable: (context, event) => {
286
412
  return context.grandTotalEnable === 1
287
413
  },
@@ -45,8 +45,24 @@ export default function (request) {
45
45
  },
46
46
  },
47
47
  step1: {
48
- initial: 'idle',
48
+ initial: 'promotion',
49
49
  states: {
50
+ promotion: {
51
+ always: [
52
+ {
53
+ target: 'idle',
54
+ cond: 'isDoubleWalletMode',
55
+ },
56
+ {
57
+ target: 'calculating',
58
+ actions: 'setPromotionDefaultAmount',
59
+ cond: 'hasMinPromotionDeposit',
60
+ },
61
+ {
62
+ target: 'idle',
63
+ },
64
+ ],
65
+ },
50
66
  idle: {},
51
67
  calculating: {
52
68
  invoke: {
@@ -88,10 +104,11 @@ export default function (request) {
88
104
  {
89
105
  target: 'pending',
90
106
  cond: (context, event) => {
91
- const { calculation, promotion } = context
107
+ const { siteConfig = {}, calculation, promotion } = context
108
+ const { walletMode } = siteConfig
92
109
  const { promotionsNo, activityNo } = promotion
93
110
  const isNoBonus = promotionsNo === 'none' || activityNo === 'none'
94
- return !!calculation && !isNoBonus
111
+ return walletMode === '4' && !!calculation && !isNoBonus
95
112
  },
96
113
  },
97
114
  {
@@ -214,8 +231,16 @@ export default function (request) {
214
231
  promotion: event.data,
215
232
  }
216
233
  }),
234
+ setPromotionDefaultAmount: assign((context, event) => {
235
+ return {
236
+ amount: context.promotion.minimumAmount,
237
+ }
238
+ }),
217
239
  },
218
240
  guards: {
241
+ isDoubleWalletMode: (context, event) => {
242
+ return context.siteConfig?.walletMode === '4'
243
+ },
219
244
  isCalculable: (context, event) => {
220
245
  const {
221
246
  amount,
@@ -229,6 +254,9 @@ export default function (request) {
229
254
  isProcessing: (context, event) => {
230
255
  return context.processing
231
256
  },
257
+ hasMinPromotionDeposit: (context, event) => {
258
+ return context.promotion?.minimumAmount
259
+ },
232
260
  },
233
261
  services: {
234
262
  fetchPaymentDetail: async (context, event) => {
@@ -74,8 +74,8 @@ export default function (request) {
74
74
  target: 'fetching',
75
75
  cond: (context, event) => {
76
76
  const { siteConfig = {}, promotion = {} } = context
77
- const { bonusPreviewEnable } = siteConfig
78
- return bonusPreviewEnable && promotion.activityNo != 'none'
77
+ const { walletMode = '', bonusPreviewEnable } = siteConfig
78
+ return walletMode === '4' && bonusPreviewEnable && promotion.activityNo != 'none'
79
79
  },
80
80
  },
81
81
  { target: 'loaded' },
@@ -40,7 +40,7 @@ export default function (request) {
40
40
  gameCode: null,
41
41
  name: null,
42
42
  },
43
- walletType: null,
43
+ walletMode: null,
44
44
  lang: 'en_US',
45
45
  isMobile: new UAParser().getResult().device.type,
46
46
  gameURL: null,
@@ -81,7 +81,7 @@ export default function (request) {
81
81
  },
82
82
  ENTER_GAME: {
83
83
  target: 'connecting',
84
- actions: ['setGameInfo', 'setLang', 'setwalletType'],
84
+ actions: ['setGameInfo', 'setLang', 'setWalletMode'],
85
85
  },
86
86
  MENU_ENTER_GAME: {
87
87
  target: 'connecting',
@@ -246,10 +246,6 @@ export default function (request) {
246
246
  LEAVE_GAME_REFRESH: {
247
247
  actions: 'setIsPlaying',
248
248
  },
249
- LOAD: {
250
- target: 'routing',
251
- actions: 'setLoadable',
252
- },
253
249
  },
254
250
  },
255
251
  },
@@ -411,8 +407,8 @@ export default function (request) {
411
407
  const { providerId, gameId, gameTypeId, mappingId, portrait, gameCode, name } = context.switchGame
412
408
  return { game: { providerId, gameId, gameTypeId, mappingId, portrait: portrait ? 1 : 0, gameCode, name } }
413
409
  }),
414
- setwalletType: assign((context, event) => {
415
- return { walletType: event.data.walletType }
410
+ setWalletMode: assign((context, event) => {
411
+ return { walletMode: event.data.walletMode }
416
412
  }),
417
413
  setLang: assign((context, event) => {
418
414
  const lang = event.data.locale.replace('-', '_')
@@ -550,7 +546,7 @@ export default function (request) {
550
546
  },
551
547
  connectGame: async (context, event) => {
552
548
  const returnProviders = ['RSG', 'KP', 'EPICWIN', 'AMBSLOT', 'SEXY_VENUS', 'SEXY_SEXYBCRT', 'PG', 'NPG']
553
- const { lang, isMobile, walletType } = context
549
+ const { lang, isMobile, walletMode } = context
554
550
  const { providerId, gameId, gameTypeId, mappingId } = context.game
555
551
  const params = {
556
552
  provider_id: providerId,
@@ -560,7 +556,7 @@ export default function (request) {
560
556
  is_demo: false,
561
557
  is_mobile: isMobile === 'mobile' ? 'y' : null,
562
558
  lang,
563
- selected_wallet_type: walletType,
559
+ selected_wallet_type: walletMode,
564
560
  return_url: returnProviders.includes(providerId) ? `${window.location.origin}${context.base}return` : window.location.href, // For providers to return.
565
561
  }
566
562
  const { type, redirect_url, gameToken, gameHtml, wallet_type } = await request.send(api.playGame(params))
@@ -39,7 +39,6 @@ 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'
43
42
 
44
43
  export default {
45
44
  ...activity,
@@ -83,5 +82,4 @@ export default {
83
82
  navbar,
84
83
  ...withdraw,
85
84
  websocket,
86
- ranking,
87
85
  }
@@ -7,6 +7,7 @@ export default function (request) {
7
7
  id: 'promotions',
8
8
  initial: 'loading',
9
9
  context: {
10
+ noBonus: {},
10
11
  userInfo: {},
11
12
  siteConfig: {},
12
13
  withdrawRule: {},
@@ -86,10 +87,10 @@ export default function (request) {
86
87
  actions: {
87
88
  setPromotionsList: assign((context, event) => {
88
89
  const promotionsList = JSON.parse(JSON.stringify(event.data))
89
- const { userInfo, siteConfig } = context
90
+ const { noBonus, userInfo, siteConfig } = context
90
91
  const { withdraw_rule, balance, bank_amount } = userInfo
91
- const { currencyConversionLimit } = siteConfig
92
- const balanceAvailable = parseFloat(bank_amount) < parseFloat(`${currencyConversionLimit}`)
92
+ const { currencyConversionLimit, walletMode } = siteConfig
93
+ const balanceAvailable = parseFloat(`${walletMode === '4' ? bank_amount : balance}`) < parseFloat(`${currencyConversionLimit}`)
93
94
  const isFreeLimitRule = withdraw_rule.includes('FREE_LIMIT')
94
95
  const includesDefaultRule = withdraw_rule === 'DEFAULT' || withdraw_rule.includes('FREE_DEFAULT')
95
96
 
@@ -111,7 +112,7 @@ export default function (request) {
111
112
  }
112
113
  return {
113
114
  promotionsList,
114
- selectedPromo: promotionsList[0],
115
+ selectedPromo: siteConfig?.walletMode === '4' ? promotionsList[0] : noBonus,
115
116
  }
116
117
  }),
117
118
  setSelectedPromo: assign((context, event) => {
@@ -17,9 +17,6 @@ export default function () {
17
17
  idle: {},
18
18
  },
19
19
  on: {
20
- DEFAULT_SETTING: {
21
- actions: 'setSetting',
22
- },
23
20
  MODIFY_SETTING: {
24
21
  actions: 'saveSetting',
25
22
  },
@@ -32,13 +29,7 @@ export default function () {
32
29
  const setting = JSON.parse(localStorage.getItem('setting')) || { sound: soundPlay, music: musicPlay }
33
30
  return { ...setting }
34
31
  }),
35
- setSetting: assign((context, event) => {
36
- console.log('*[DEV_ONLY]預設SETTING')
37
- const { sound, music, locale } = event.data
38
- return { sound, music, locale }
39
- }),
40
32
  saveSetting: assign((context, event) => {
41
- console.log('*[DEV_ONLY]修改SETTING')
42
33
  const { sound, music, locale } = event.data
43
34
  localStorage.setItem('setting', JSON.stringify({ sound, music, locale }))
44
35
  return { sound, music, locale }
@@ -278,18 +278,6 @@ 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
-
293
281
  // 監聽 payment-info 事件
294
282
  clientSocket.on('payment-info', (data) => {
295
283
  console.log('[socket][payment-info]:', data)
@@ -147,6 +147,7 @@ export default function (request) {
147
147
  },
148
148
  SET_ATTACHMENT_TYPE: {
149
149
  actions: 'setAttachmentType',
150
+ cond: 'isNewWalletMode',
150
151
  },
151
152
  POOL: {
152
153
  target: 'pooling',
@@ -322,7 +323,7 @@ export default function (request) {
322
323
  balance,
323
324
  siteConfig,
324
325
  userInfo,
325
- attachmentType: 'withdraw',
326
+ attachmentType: siteConfig.walletMode > 0 ? 'withdraw' : null,
326
327
  }
327
328
  }),
328
329
  updateWithdrawCondition: assign((context, event) => {
@@ -433,6 +434,7 @@ export default function (request) {
433
434
  isOtpRequired: (context, event) => {
434
435
  return event.data?.status === 'otp-verifying'
435
436
  },
437
+ isNewWalletMode: (context, event) => context.siteConfig.walletMode > 0,
436
438
  },
437
439
  services: {
438
440
  fetchInitData: async (context, event) => {
@@ -355,7 +355,7 @@ export default function (request) {
355
355
  const methods = siteConfig?.paymentMethods?.withdraw || []
356
356
  return {
357
357
  methods,
358
- attachmentType: 'withdraw',
358
+ attachmentType: siteConfig.walletMode > 0 ? 'withdraw' : null,
359
359
  }
360
360
  }),
361
361
  setMode: assign((context, event) => {
@@ -397,8 +397,9 @@ export default function (request) {
397
397
  return { bindingPaymentList, bindingPaymentInfo, boundBanks: combinedData, currentBank: combinedData[0] }
398
398
  }),
399
399
  preset: assign((context, event) => {
400
+ const { siteConfig } = context
400
401
  return {
401
- attachmentType: 'withdraw',
402
+ attachmentType: siteConfig.walletMode > 0 ? 'withdraw' : null,
402
403
  }
403
404
  }),
404
405
  setMode: assign((context, event) => {
@@ -193,6 +193,7 @@ export default function (request) {
193
193
  },
194
194
  SET_ATTACHMENT_TYPE: {
195
195
  actions: 'setAttachmentType',
196
+ cond: 'isNewWalletMode',
196
197
  },
197
198
  SUBMIT: [
198
199
  {
@@ -358,7 +359,7 @@ export default function (request) {
358
359
  balance,
359
360
  siteConfig,
360
361
  userInfo,
361
- attachmentType: 'withdraw',
362
+ attachmentType: siteConfig.walletMode > 0 ? 'withdraw' : null,
362
363
  }
363
364
  }),
364
365
  updateWithdrawCondition: assign((context, event) => {
@@ -452,6 +453,7 @@ export default function (request) {
452
453
  isOtpRequired: (context, event) => {
453
454
  return event.data?.status === 'otp-verifying'
454
455
  },
456
+ isNewWalletMode: (context, event) => context.siteConfig.walletMode > 0,
455
457
  isNotWithdrawMinDepositAmount: (context, event) => {
456
458
  const { withdrawCheck } = context
457
459
  return !withdrawCheck?.passDepositeLimit
@@ -373,7 +373,7 @@ export default function (request) {
373
373
  const methods = siteConfig?.paymentMethods?.withdraw || []
374
374
  return {
375
375
  methods,
376
- attachmentType: 'withdraw',
376
+ attachmentType: siteConfig.walletMode > 0 ? 'withdraw' : null,
377
377
  }
378
378
  }),
379
379
  setMode: assign((context, event) => {
@@ -1,26 +0,0 @@
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
- }
@@ -1,202 +0,0 @@
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
- }