@jetthai/cuora 1.1.346-dev-6 → 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,53 +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-6](https://github.com/jetthai/cuora-module/compare/v1.1.346-dev-5...v1.1.346-dev-6) (2025-04-08)
6
-
7
- ### [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)
8
-
9
- ### [1.1.353](https://github.com/jetthai/cuora-module/compare/v1.1.352...v1.1.353) (2025-04-02)
10
-
11
- ### [1.1.352](https://github.com/jetthai/cuora-module/compare/v1.1.346-ranking-1...v1.1.352) (2025-04-02)
12
-
13
- ### [1.1.351](https://github.com/jetthai/cuora-module/compare/v1.1.350...v1.1.351) (2025-04-02)
14
-
15
- ### [1.1.350](https://github.com/jetthai/cuora-module/compare/v1.1.349...v1.1.350) (2025-03-31)
16
-
17
- ### [1.1.349](https://github.com/jetthai/cuora-module/compare/v1.1.348...v1.1.349) (2025-03-30)
18
-
19
- ### [1.1.348](https://github.com/jetthai/cuora-module/compare/v1.1.346-dev-3...v1.1.348) (2025-03-30)
20
-
21
- ### [1.1.347](https://github.com/jetthai/cuora-module/compare/v1.1.346-dev-2...v1.1.347) (2025-03-30)
22
-
23
- ### [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)
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.346-dev-4](https://github.com/jetthai/cuora-module/compare/v1.1.346-ranking-1...v1.1.346-dev-4) (2025-04-02)
40
-
41
- ### [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)
42
-
43
- ### [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)
44
-
45
- ### [1.1.346-dev-1](https://github.com/jetthai/cuora-module/compare/v1.1.346...v1.1.346-dev-1) (2025-03-28)
46
-
47
- ### [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)
48
-
49
- ### [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)
50
-
51
- ### [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)
52
6
 
53
7
  ### [1.1.346](https://github.com/jetthai/cuora-module/compare/v1.1.345...v1.1.346) (2025-03-27)
54
8
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.1.346-dev-6",
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) => {
@@ -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) => {
@@ -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
  },
@@ -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
  }
@@ -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)
@@ -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
- }