@jetthai/cuora 1.1.364-dev-5 → 1.1.364

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.
@@ -3,11 +3,13 @@ import ranking from '../api/ranking.js'
3
3
 
4
4
  export default function (request) {
5
5
  const cycleMapping = ['DAILY', 'WEEKLY', 'MONTHLY']
6
+ const limit = { DAILY: 56, WEEKLY: 8, MONTHLY: 2, ALL: 2 }
6
7
 
7
- function roundProcess(rounds) {
8
+ function roundProcess(rounds, cycles) {
8
9
  const roundArrays = rounds.map((round) => Array.from({ length: round }, (_, i) => i + 1))
9
10
  return roundArrays.reduce((acc, roundArray, index) => {
10
- acc[cycleMapping[index]] = roundArray.reverse()
11
+ const max = limit[cycles[index]] || rounds[index] // 若沒限制則取全部
12
+ acc[cycles[index]] = roundArray.reverse().slice(0, max)
11
13
  return acc
12
14
  }, {})
13
15
  }
@@ -24,6 +26,7 @@ export default function (request) {
24
26
  initial: 'idle',
25
27
  context: {
26
28
  auth: false,
29
+ site: '',
27
30
  activityNo: '',
28
31
  // api options 回傳的資料
29
32
  currentRound: [],
@@ -54,32 +57,43 @@ export default function (request) {
54
57
  },
55
58
  loading: {
56
59
  entry: 'setActivity',
57
- always: [{ target: 'getRankingOptions', cond: 'hasAuth' }, { target: 'getTournament' }],
60
+ always: [{ target: 'getRankingOptions' }],
58
61
  },
59
62
  setting: {
60
63
  entry: 'setOptions',
61
- always: [{ target: 'getRankingDetail' }],
64
+ always: [{ target: 'getRankingDetail', cond: 'hasAuth' }, { target: 'getTournament' }],
62
65
  },
63
- // 未登入時取得排名資料
64
- getTournament: {
66
+ // 取得排名選單資料
67
+ getRankingOptions: {
65
68
  invoke: {
66
- src: 'fetchTournament',
69
+ src: 'fetchRankingOptions',
67
70
  onDone: {
68
- target: 'idle',
69
- actions: 'setRanking',
71
+ target: 'decideNextAfterOptions',
72
+ actions: 'setRankingOptions',
70
73
  },
71
74
  onError: {
72
75
  target: 'idle',
73
76
  },
74
77
  },
75
78
  },
76
- // 登入後取得排名選單資料
77
- getRankingOptions: {
79
+ // 取得排名選單資料後的跳轉
80
+ decideNextAfterOptions: {
81
+ always: [
82
+ // 有登入且為冠軍: 先拿遊戲排行榜再拿排行榜資料
83
+ { target: 'getRankingGames', cond: 'canGetGameRanking' },
84
+ // 有登入但不為冠軍活動: 直接拿排行榜資料
85
+ { target: 'getRankingDetail', cond: 'hasAuth' },
86
+ // 未登入; 拿未登入的排行榜資料
87
+ { target: 'getTournament' },
88
+ ],
89
+ },
90
+ // 未登入時取得排名資料
91
+ getTournament: {
78
92
  invoke: {
79
- src: 'fetchRankingOptions',
93
+ src: 'fetchTournament',
80
94
  onDone: {
81
- target: 'getRankingGames',
82
- actions: 'setRankingOptions',
95
+ target: 'idle',
96
+ actions: 'setRanking',
83
97
  },
84
98
  onError: {
85
99
  target: 'idle',
@@ -117,6 +131,7 @@ export default function (request) {
117
131
  actions: {
118
132
  setActivity: assign((context, event) => {
119
133
  return {
134
+ site: event.data?.site,
120
135
  auth: !!request.getToken(),
121
136
  activityNo: event.data?.activityNo,
122
137
  }
@@ -138,14 +153,14 @@ export default function (request) {
138
153
  }
139
154
  }),
140
155
  setRankingOptions: assign((context, event) => {
156
+ const isChampion = event.data?.rule === 'CHAMPION'
141
157
  const cycle = event.data?.cycle
142
158
  const currentRound = event.data?.currentRound || []
143
159
  // 取得結算週期選單列表
144
- const cycleOptions = cycleMapping.slice(0, currentRound.length)
145
- // 取得每週期的歷史期數選單列表
146
- const roundOptions = roundProcess(currentRound)
147
- // 如果是月結算,則加入全部選項
148
- if (cycle === 'MONTHLY') {
160
+ const cycleOptions = isChampion ? cycleMapping.slice(0, currentRound.length) : [cycle]
161
+ const roundOptions = roundProcess(currentRound, cycleOptions)
162
+ // 如果是冠軍龍虎月結算,則加入全部選項
163
+ if (cycle === 'MONTHLY' && isChampion) {
149
164
  cycleOptions.push('ALL')
150
165
  roundOptions.ALL = roundOptions.MONTHLY
151
166
  }
@@ -153,7 +168,7 @@ export default function (request) {
153
168
  ...event.data,
154
169
  options: { cycle: cycleOptions, round: roundOptions },
155
170
  // 初始固定顯示 DAILY
156
- cycle: event.data?.rule !== 'NORMAL' ? 'DAILY' : cycle,
171
+ cycle: isChampion ? 'DAILY' : cycle,
157
172
  round: currentRound[0],
158
173
  }
159
174
  }),
@@ -174,11 +189,12 @@ export default function (request) {
174
189
  },
175
190
  guards: {
176
191
  hasAuth: (context) => context.auth,
192
+ canGetGameRanking: (context) => context.auth && context.rule === 'CHAMPION',
177
193
  },
178
194
  services: {
179
195
  fetchTournament: async (context) => {
180
- const { activityNo } = context
181
- const { data } = await request.send(ranking.getTournament({ activityNo }))
196
+ const { activityNo, cycle, round, site } = context
197
+ const { data } = await request.send(ranking.getTournament({ activityNo, cycle, round, site }))
182
198
  return data
183
199
  },
184
200
  fetchRankingOptions: async (context) => {
@@ -18,6 +18,7 @@ export default function (request) {
18
18
  rewardType: null,
19
19
  isPlaying: false,
20
20
  callback: () => {},
21
+ orderColumn: 'createTime',
21
22
  },
22
23
  states: {
23
24
  timer: {
@@ -37,7 +38,7 @@ export default function (request) {
37
38
  },
38
39
  pending: {
39
40
  after: {
40
- 20000: { target: 'loading', cond: 'isNotInGame' },
41
+ 20000: [{ target: 'loading', cond: 'isNotInGame' }, { target: 'pending' }],
41
42
  },
42
43
  },
43
44
  },
@@ -56,6 +57,10 @@ export default function (request) {
56
57
  target: 'fetching',
57
58
  actions: 'setRewardData',
58
59
  },
60
+ FETCH_OTHER_REWARD: {
61
+ target: 'fetchingOtherReward',
62
+ actions: 'setOrderColumn',
63
+ },
59
64
  RECEIVE_REWARD: {
60
65
  target: 'receiving',
61
66
  actions: ['setCallback', 'setRewardType'],
@@ -81,6 +86,18 @@ export default function (request) {
81
86
  },
82
87
  },
83
88
  },
89
+ fetchingOtherReward: {
90
+ invoke: {
91
+ src: 'fetchOtherRewardList',
92
+ onDone: {
93
+ target: 'idle',
94
+ actions: 'setOtherRewardList',
95
+ },
96
+ onError: {
97
+ target: 'idle',
98
+ },
99
+ },
100
+ },
84
101
  pending: {
85
102
  on: {
86
103
  RECEIVE_REWARD: {
@@ -136,6 +153,11 @@ export default function (request) {
136
153
  rewardList: event.data[2]?.data || [],
137
154
  }
138
155
  }),
156
+ setOtherRewardList: assign((context, event) => {
157
+ return {
158
+ otherRewardList: event.data[0]?.data,
159
+ }
160
+ }),
139
161
  setRewardData: assign((context, event) => {
140
162
  const { activityNo, receiveNo } = event.data
141
163
  return {
@@ -148,6 +170,11 @@ export default function (request) {
148
170
  callback: event.data?.callback || (() => {}),
149
171
  }
150
172
  }),
173
+ setOrderColumn: assign((context, event) => {
174
+ return {
175
+ orderColumn: event.data?.orderColumn || 'createTime',
176
+ }
177
+ }),
151
178
  setRewardType: assign((context, event) => {
152
179
  return {
153
180
  rewardType: event.data?.rewardType,
@@ -178,12 +205,27 @@ export default function (request) {
178
205
  },
179
206
  services: {
180
207
  fetchRewardList: async (context, event) => {
208
+ const orderColumn = context.orderColumn
181
209
  const getRewardAPI = request.send(activity.getRewardList({ count: 30, appSecret }))
182
210
  const getPointsRewardAPI = request.send(activity.getRewardList({ rewardType: 'POINTS', count: 30, appSecret }))
183
- const getOtherRewardAPI = request.send(activity.getRewardList({ rewardType: 'CASH,FREE,PRIZE', count: 30, appSecret }))
211
+ const getOtherRewardAPI = request.send(activity.getRewardList({ rewardType: 'CASH,FREE,PRIZE', count: 30, appSecret, orderColumn }))
184
212
  const [otherRewardList, pointsRewardList, rewardList] = await Promise.all([getOtherRewardAPI, getPointsRewardAPI, getRewardAPI])
185
213
  return [otherRewardList, pointsRewardList, rewardList]
186
214
  },
215
+ fetchOtherRewardList: async (context, event) => {
216
+ const orderColumn = context.orderColumn
217
+
218
+ const getOtherRewardAPI = request.send(
219
+ activity.getRewardList({
220
+ rewardType: 'CASH,FREE,PRIZE',
221
+ count: 30,
222
+ appSecret,
223
+ orderColumn,
224
+ })
225
+ )
226
+ const [otherRewardList] = await Promise.all([getOtherRewardAPI])
227
+ return [otherRewardList]
228
+ },
187
229
  fetchWithdrawRulePreview: async (context, event) => {
188
230
  const { receiveNo } = context
189
231
  const data = await request.send(payment.getWithdrawRulePreview({ applyType: 'activity', applyNo: receiveNo, amount: null }))
@@ -16,8 +16,8 @@ export default function (request) {
16
16
  activityNo: null,
17
17
  receiveNo: null,
18
18
  withdrawRule: {},
19
- isPlaying: false,
20
19
  callback: () => {},
20
+ orderColumn: 'createTime',
21
21
  },
22
22
  states: {
23
23
  timer: {
@@ -47,7 +47,7 @@ export default function (request) {
47
47
  },
48
48
  pending: {
49
49
  after: {
50
- 20000: [{ target: 'loading', cond: 'isNotInGame' }, { target: 'pending' }],
50
+ 20000: { target: 'loading' },
51
51
  },
52
52
  },
53
53
  },
@@ -66,6 +66,10 @@ export default function (request) {
66
66
  target: 'fetching',
67
67
  actions: 'setRewardData',
68
68
  },
69
+ FETCH_OTHER_REWARD: {
70
+ target: 'fetchingOtherReward',
71
+ actions: 'setOrderColumn',
72
+ },
69
73
  RECEIVE_REWARD: {
70
74
  target: 'receiving',
71
75
  actions: 'setCallback',
@@ -74,9 +78,6 @@ export default function (request) {
74
78
  target: 'allPointsReceiving',
75
79
  actions: 'setCallback',
76
80
  },
77
- SET_IS_PLAYING: {
78
- actions: 'setIsPlaying',
79
- },
80
81
  },
81
82
  },
82
83
  fetching: {
@@ -91,6 +92,18 @@ export default function (request) {
91
92
  },
92
93
  },
93
94
  },
95
+ fetchingOtherReward: {
96
+ invoke: {
97
+ src: 'fetchOtherRewardList',
98
+ onDone: {
99
+ target: 'idle',
100
+ actions: 'setOtherRewardList',
101
+ },
102
+ onError: {
103
+ target: 'idle',
104
+ },
105
+ },
106
+ },
94
107
  pending: {
95
108
  on: {
96
109
  RECEIVE_REWARD: {
@@ -147,11 +160,6 @@ export default function (request) {
147
160
  },
148
161
  },
149
162
  {
150
- guards: {
151
- isNotInGame: (context, event) => {
152
- return !context.isPlaying
153
- },
154
- },
155
163
  actions: {
156
164
  setAuth: assign((context, event) => {
157
165
  return { auth: !!event.data }
@@ -163,6 +171,11 @@ export default function (request) {
163
171
  rewardList: event.data[2]?.data || [],
164
172
  }
165
173
  }),
174
+ setOtherRewardList: assign((context, event) => {
175
+ return {
176
+ otherRewardList: event.data[0]?.data,
177
+ }
178
+ }),
166
179
  setRewardData: assign((context, event) => {
167
180
  const { activityNo, receiveNo } = event.data
168
181
  return {
@@ -175,6 +188,11 @@ export default function (request) {
175
188
  callback: event.data?.callback || (() => {}),
176
189
  }
177
190
  }),
191
+ setOrderColumn: assign((context, event) => {
192
+ return {
193
+ orderColumn: event.data?.orderColumn || 'createTime',
194
+ }
195
+ }),
178
196
  doCallback: (context, event) => {
179
197
  context.callback()
180
198
  },
@@ -183,15 +201,11 @@ export default function (request) {
183
201
  withdrawRule: event.data,
184
202
  }
185
203
  }),
186
- setIsPlaying: assign((context, event) => {
187
- return {
188
- isPlaying: event.data,
189
- }
190
- }),
191
204
  },
192
205
  services: {
193
206
  fetchRewardList: async (context, event) => {
194
207
  const getRewardAPI = request.send(activity.getRewardList({ count: 30, appSecret }))
208
+ const orderColumn = context.orderColumn
195
209
  const getPointsRewardAPI = request.send(
196
210
  activity.getRewardList({
197
211
  rewardType: 'POINTS',
@@ -204,11 +218,26 @@ export default function (request) {
204
218
  rewardType: 'CASH,FREE,PRIZE',
205
219
  count: 30,
206
220
  appSecret,
221
+ orderColumn,
207
222
  })
208
223
  )
209
224
  const [otherRewardList, pointsRewardList, rewardList] = await Promise.all([getOtherRewardAPI, getPointsRewardAPI, getRewardAPI])
210
225
  return [otherRewardList, pointsRewardList, rewardList]
211
226
  },
227
+ fetchOtherRewardList: async (context, event) => {
228
+ const orderColumn = context.orderColumn
229
+
230
+ const getOtherRewardAPI = request.send(
231
+ activity.getRewardList({
232
+ rewardType: 'CASH,FREE,PRIZE',
233
+ count: 30,
234
+ appSecret,
235
+ orderColumn,
236
+ })
237
+ )
238
+ const [otherRewardList] = await Promise.all([getOtherRewardAPI])
239
+ return [otherRewardList]
240
+ },
212
241
  fetchWithdrawRulePreview: async (context, event) => {
213
242
  const { receiveNo } = context
214
243
  const data = await request.send(
@@ -17,6 +17,9 @@ export default function () {
17
17
  idle: {},
18
18
  },
19
19
  on: {
20
+ DEFAULT_SETTING: {
21
+ actions: 'setSetting',
22
+ },
20
23
  MODIFY_SETTING: {
21
24
  actions: 'saveSetting',
22
25
  },
@@ -29,6 +32,10 @@ export default function () {
29
32
  const setting = JSON.parse(localStorage.getItem('setting')) || { sound: soundPlay, music: musicPlay }
30
33
  return { ...setting }
31
34
  }),
35
+ setSetting: assign((context, event) => {
36
+ const { sound, music, locale } = event.data
37
+ return { sound, music, locale }
38
+ }),
32
39
  saveSetting: assign((context, event) => {
33
40
  const { sound, music, locale } = event.data
34
41
  localStorage.setItem('setting', JSON.stringify({ sound, music, locale }))
@@ -147,7 +147,6 @@ export default function (request) {
147
147
  },
148
148
  SET_ATTACHMENT_TYPE: {
149
149
  actions: 'setAttachmentType',
150
- cond: 'isNewWalletMode',
151
150
  },
152
151
  POOL: {
153
152
  target: 'pooling',
@@ -323,7 +322,7 @@ export default function (request) {
323
322
  balance,
324
323
  siteConfig,
325
324
  userInfo,
326
- attachmentType: siteConfig.walletMode > 0 ? 'withdraw' : null,
325
+ attachmentType: 'withdraw',
327
326
  }
328
327
  }),
329
328
  updateWithdrawCondition: assign((context, event) => {
@@ -434,7 +433,6 @@ export default function (request) {
434
433
  isOtpRequired: (context, event) => {
435
434
  return event.data?.status === 'otp-verifying'
436
435
  },
437
- isNewWalletMode: (context, event) => context.siteConfig.walletMode > 0,
438
436
  },
439
437
  services: {
440
438
  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: siteConfig.walletMode > 0 ? 'withdraw' : null,
358
+ attachmentType: 'withdraw',
359
359
  }
360
360
  }),
361
361
  setMode: assign((context, event) => {
@@ -397,9 +397,8 @@ 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
401
400
  return {
402
- attachmentType: siteConfig.walletMode > 0 ? 'withdraw' : null,
401
+ attachmentType: 'withdraw',
403
402
  }
404
403
  }),
405
404
  setMode: assign((context, event) => {
@@ -580,7 +579,7 @@ export default function (request) {
580
579
  payment.submitWithdrawTransactionManual({
581
580
  method,
582
581
  amount,
583
- applyerBankCode: currentBank.bankCode,
582
+ applyerBankCode: currentBank.bankCode || currentBank.walletCode,
584
583
  applyerAccountNumber: currentBank.accountNumber,
585
584
  applyerIfscCode: currentBank.ifscCode,
586
585
  branch: branchTemp,
@@ -266,7 +266,7 @@ export default function (request, context) {
266
266
  payment.submitWithdrawTransactionVN({
267
267
  method: currentPayment.method,
268
268
  amount: selectedAmount,
269
- applyerBankCode: selectedUserBank.bankCode,
269
+ applyerBankCode: selectedUserBank.bankCode || selectedUserBank.walletCode,
270
270
  applyerAccountNumber: selectedUserBank.accountNumber,
271
271
  applyerIfscCode: selectedUserBank.ifscCode,
272
272
  branch: branchTemp,
@@ -193,7 +193,6 @@ export default function (request) {
193
193
  },
194
194
  SET_ATTACHMENT_TYPE: {
195
195
  actions: 'setAttachmentType',
196
- cond: 'isNewWalletMode',
197
196
  },
198
197
  SUBMIT: [
199
198
  {
@@ -359,7 +358,7 @@ export default function (request) {
359
358
  balance,
360
359
  siteConfig,
361
360
  userInfo,
362
- attachmentType: siteConfig.walletMode > 0 ? 'withdraw' : null,
361
+ attachmentType: 'withdraw',
363
362
  }
364
363
  }),
365
364
  updateWithdrawCondition: assign((context, event) => {
@@ -453,7 +452,6 @@ export default function (request) {
453
452
  isOtpRequired: (context, event) => {
454
453
  return event.data?.status === 'otp-verifying'
455
454
  },
456
- isNewWalletMode: (context, event) => context.siteConfig.walletMode > 0,
457
455
  isNotWithdrawMinDepositAmount: (context, event) => {
458
456
  const { withdrawCheck } = context
459
457
  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: siteConfig.walletMode > 0 ? 'withdraw' : null,
376
+ attachmentType: 'withdraw',
377
377
  }
378
378
  }),
379
379
  setMode: assign((context, event) => {