@jetthai/cuora 2.0.0-beta.0 → 2.0.0

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.
Files changed (201) hide show
  1. package/.claude/commands/sync-ai-prompts.md +93 -0
  2. package/.claude/settings.local.json +23 -0
  3. package/.github/copilot-instructions.md +405 -0
  4. package/.husky/post-checkout +32 -0
  5. package/.husky/pre-commit +1 -3
  6. package/.husky/pre-push +36 -0
  7. package/AGENTS.md +405 -0
  8. package/AI_PROMPT_SOURCE.md +403 -0
  9. package/CHANGELOG.md +274 -3
  10. package/CLAUDE.md +405 -0
  11. package/GEMINI.md +405 -0
  12. package/README.md +299 -15
  13. package/docs/kibana/crypto-way-deposit-amount-bug-analysis.md +1003 -0
  14. package/docs/kibana/play-providerId-error.md +202 -0
  15. package/docs/kibana/play-selectedWalletType.md +1 -0
  16. package/docs/kibana/play-selectedWalletType_2.md +1 -0
  17. package/docs/kibana/play-selectedWalletType_analysis.md +565 -0
  18. package/package.json +3 -3
  19. package/scripts/auto-version.js +68 -0
  20. package/scripts/auto-version.sh +33 -0
  21. package/scripts/branch-auto-npm-publish.js +29 -0
  22. package/scripts/check-version.sh +36 -0
  23. package/scripts/clean-tags.sh +84 -0
  24. package/src/api/account.js +0 -1
  25. package/src/api/activity.js +22 -37
  26. package/src/api/auth.js +5 -36
  27. package/src/api/common.js +5 -3
  28. package/src/api/game.js +0 -10
  29. package/src/api/payment.js +17 -55
  30. package/src/api/user.js +10 -16
  31. package/src/index.js +2 -2
  32. package/src/machine/activity/activity_cash.js +84 -36
  33. package/src/machine/activity/cash_rain_activity.js +0 -1
  34. package/src/machine/activity/continue_deposit_activity.js +0 -1
  35. package/src/machine/activity/deposit_activity.js +0 -1
  36. package/src/machine/activity/diamond_shop_activity_cash.js +0 -8
  37. package/src/machine/activity/fafafa_activity.js +0 -11
  38. package/src/machine/activity/friend_invite_friends_activity.js +8 -7
  39. package/src/machine/activity/index.js +0 -12
  40. package/src/machine/activity/instant_rebate_activity.js +0 -1
  41. package/src/machine/activity/jackpot.js +0 -1
  42. package/src/machine/activity/otp_verified_activity.js +0 -1
  43. package/src/machine/activity/ranking_activity.js +0 -1
  44. package/src/machine/activity/roulette_activity_v2.js +0 -1
  45. package/src/machine/activity/sign_in_activity.js +0 -1
  46. package/src/machine/activity/sign_in_monthly_activity.js +1 -2
  47. package/src/machine/activity/specify_bets_activity.js +0 -1
  48. package/src/machine/activity/specify_turnover_activity.js +0 -1
  49. package/src/machine/activity/time_bomb_activity.js +0 -1
  50. package/src/machine/activity/vip_card_activity.js +0 -1
  51. package/src/machine/auth.js +112 -112
  52. package/src/machine/auth_otp_v3.js +11 -8
  53. package/src/machine/bank_binding.js +2 -3
  54. package/src/machine/common.js +14 -98
  55. package/src/machine/deposit/crypto_bank_cash.js +20 -35
  56. package/src/machine/deposit/crypto_qrcode_cash.js +26 -64
  57. package/src/machine/deposit/crypto_way_cash.js +48 -37
  58. package/src/machine/deposit/direct_cash.js +8 -10
  59. package/src/machine/deposit/index.js +0 -28
  60. package/src/machine/deposit/loadcard_cash.js +14 -32
  61. package/src/machine/deposit/manual_cash.js +8 -11
  62. package/src/machine/deposit/qrcode_cash.js +15 -32
  63. package/src/machine/deposit/usdt_cash.js +1 -15
  64. package/src/machine/deposit/virtual_bank_cash.js +13 -12
  65. package/src/machine/error.js +7 -1
  66. package/src/machine/game_betslip.js +0 -1
  67. package/src/machine/game_favorite_v2.js +0 -1
  68. package/src/machine/game_info.js +1 -13
  69. package/src/machine/game_search_cash.js +0 -1
  70. package/src/machine/game_v2_1.js +39 -126
  71. package/src/machine/honor_board_cash.js +8 -11
  72. package/src/machine/inbox.js +43 -105
  73. package/src/machine/index.js +0 -32
  74. package/src/machine/leaderboard.js +8 -12
  75. package/src/machine/navbar.js +1 -3
  76. package/src/machine/ranking.js +45 -30
  77. package/src/machine/reward_cash.js +0 -40
  78. package/src/machine/roulette_v2.js +14 -11
  79. package/src/machine/setting.js +0 -1
  80. package/src/machine/side_cash.js +3 -3
  81. package/src/machine/user_info.js +0 -1
  82. package/src/machine/user_photo.js +0 -1
  83. package/src/machine/user_reset_password.js +0 -14
  84. package/src/machine/user_sign_up.js +46 -61
  85. package/src/machine/websocket.js +18 -62
  86. package/src/machine/withdraw/index.js +0 -6
  87. package/src/machine/withdraw/withdraw_manual_cash.js +59 -39
  88. package/src/request/config.js +2 -0
  89. package/src/request/request.js +49 -60
  90. package/src/util/amount.js +8 -0
  91. package/src/util/constant.js +0 -1
  92. package/src/util/err998SentryExtra.js +26 -0
  93. package/src/util/index.js +2 -4
  94. package/src/util/paramStore.js +139 -0
  95. package/src/util/storage.js +3 -4
  96. package/BREAKING_CHANGES.md +0 -9
  97. package/resetGitBranch.sh +0 -101
  98. package/src/lib/fingerprint_v3_11_12.js +0 -11433
  99. package/src/machine/activity/activity.js +0 -213
  100. package/src/machine/activity/diamond_shop_activity_fc.js +0 -197
  101. package/src/machine/activity/diamond_shop_activity_vn.js +0 -179
  102. package/src/machine/activity/invite_friends_activity.js +0 -115
  103. package/src/machine/activity/mini_game_activity.js +0 -69
  104. package/src/machine/activity/return_bonus_activity.js +0 -155
  105. package/src/machine/auth_otp_v2.js +0 -178
  106. package/src/machine/bank_binding_amb.js +0 -146
  107. package/src/machine/bonus.js +0 -76
  108. package/src/machine/deposit/amb.js +0 -93
  109. package/src/machine/deposit/crypto_bank.js +0 -340
  110. package/src/machine/deposit/crypto_qrcode.js +0 -158
  111. package/src/machine/deposit/crypto_way.js +0 -253
  112. package/src/machine/deposit/deposit_fc.js +0 -272
  113. package/src/machine/deposit/direct.js +0 -311
  114. package/src/machine/deposit/float.js +0 -375
  115. package/src/machine/deposit/krway.js +0 -152
  116. package/src/machine/deposit/loadcard_vn.js +0 -352
  117. package/src/machine/deposit/manual_vn.js +0 -459
  118. package/src/machine/deposit/qrcode_v2.js +0 -339
  119. package/src/machine/deposit/usdt.js +0 -163
  120. package/src/machine/deposit/virtual_bank_vn.js +0 -270
  121. package/src/machine/deposit/vpay.js +0 -374
  122. package/src/machine/game_hot_new.js +0 -80
  123. package/src/machine/game_replay.js +0 -47
  124. package/src/machine/game_search_v2.js +0 -402
  125. package/src/machine/honor_board.js +0 -133
  126. package/src/machine/merge.js +0 -58
  127. package/src/machine/payment_data.js +0 -87
  128. package/src/machine/promotions.js +0 -163
  129. package/src/machine/reward.js +0 -256
  130. package/src/machine/reward_fc.js +0 -99
  131. package/src/machine/side.js +0 -160
  132. package/src/machine/side_v2.js +0 -223
  133. package/src/machine/vip_table.js +0 -58
  134. package/src/machine/welcome.js +0 -111
  135. package/src/machine/withdraw/withdraw_crypto_cash.js +0 -328
  136. package/src/machine/withdraw/withdraw_krway.js +0 -223
  137. package/src/machine/withdraw/withdraw_manual.js +0 -541
  138. package/src/util/deviceToken.js +0 -60
  139. package/src/util/math.js +0 -4
  140. package/test/api.behavior.test.js +0 -69
  141. package/test/api.contract.test.js +0 -18
  142. package/test/config.test.js +0 -27
  143. package/test/deviceToken.test.js +0 -139
  144. package/test/helpers.coverage.test.js +0 -11
  145. package/test/helpers.js +0 -91
  146. package/test/index.exports.test.js +0 -14
  147. package/test/machine.activity.core.coverage.test.js +0 -337
  148. package/test/machine.activity.gap.coverage.test.js +0 -252
  149. package/test/machine.activity.more.coverage.test.js +0 -180
  150. package/test/machine.activity_plus_and_binding_amb.coverage.test.js +0 -201
  151. package/test/machine.activity_timer_bonus.coverage.test.js +0 -136
  152. package/test/machine.activity_welcome.low.coverage.test.js +0 -211
  153. package/test/machine.amb_rewardfc_websocket.more.coverage.test.js +0 -201
  154. package/test/machine.auth.coverage.test.js +0 -215
  155. package/test/machine.bank_binding.test.js +0 -143
  156. package/test/machine.binding_otp_krway.coverage.test.js +0 -223
  157. package/test/machine.contract.test.js +0 -50
  158. package/test/machine.crypto_bank.coverage.test.js +0 -270
  159. package/test/machine.crypto_way.coverage.test.js +0 -108
  160. package/test/machine.crypto_way_cash.coverage.test.js +0 -114
  161. package/test/machine.definition.test.js +0 -137
  162. package/test/machine.deposit.manual.coverage.test.js +0 -365
  163. package/test/machine.deposit_fc.coverage.test.js +0 -126
  164. package/test/machine.direct.coverage.test.js +0 -96
  165. package/test/machine.direct_cash.coverage.test.js +0 -108
  166. package/test/machine.error.coverage.test.js +0 -37
  167. package/test/machine.events.test.js +0 -126
  168. package/test/machine.favorite_jackpot.coverage.test.js +0 -82
  169. package/test/machine.float.coverage.test.js +0 -136
  170. package/test/machine.flow.test.js +0 -226
  171. package/test/machine.game_hot_new_vip_table.coverage.test.js +0 -105
  172. package/test/machine.game_search_cash.coverage.test.js +0 -155
  173. package/test/machine.game_search_v2.test.js +0 -199
  174. package/test/machine.game_user_profile.coverage.test.js +0 -100
  175. package/test/machine.honor_board.test.js +0 -133
  176. package/test/machine.inbox.common.coverage.test.js +0 -304
  177. package/test/machine.loadcard_cash.coverage.test.js +0 -101
  178. package/test/machine.loadcard_vn.coverage.test.js +0 -122
  179. package/test/machine.misc.coverage.test.js +0 -361
  180. package/test/machine.more2.coverage.test.js +0 -261
  181. package/test/machine.options.execution.test.js +0 -272
  182. package/test/machine.priority.coverage.test.js +0 -603
  183. package/test/machine.qrcode_cash.coverage.test.js +0 -107
  184. package/test/machine.qrcode_v2.coverage.test.js +0 -121
  185. package/test/machine.regression.test.js +0 -82
  186. package/test/machine.roulette_v2.test.js +0 -142
  187. package/test/machine.side_reward_reset.coverage.test.js +0 -220
  188. package/test/machine.targeted.coverage.test.js +0 -313
  189. package/test/machine.usdt.coverage.test.js +0 -95
  190. package/test/machine.usdt_cash.coverage.test.js +0 -73
  191. package/test/machine.vip_card_activity.test.js +0 -114
  192. package/test/machine.virtual_bank_cash.coverage.test.js +0 -105
  193. package/test/machine.virtual_bank_vn.coverage.test.js +0 -105
  194. package/test/machine.vpay.coverage.test.js +0 -142
  195. package/test/machine.withdraw_crypto_cash.coverage.test.js +0 -166
  196. package/test/machine.withdraw_krway.coverage.test.js +0 -123
  197. package/test/machine.withdraw_manual.coverage.test.js +0 -185
  198. package/test/machine.withdraw_manual_cash.coverage.test.js +0 -123
  199. package/test/request.test.js +0 -325
  200. package/test/util.storage.errors.test.js +0 -47
  201. package/test/util.test.js +0 -41
@@ -1,42 +1,26 @@
1
1
  import activity from './activity/index.js'
2
2
  import auth from './auth.js'
3
- import welcome from './welcome.js'
4
3
  import common from './common.js'
5
4
  import error from './error.js'
6
5
  import game_v2_1 from './game_v2_1.js'
7
6
  import game_favorite_v2 from './game_favorite_v2.js'
8
7
  import game_search_cash from './game_search_cash.js'
9
- import game_search_v2 from './game_search_v2.js'
10
- import game_hot_new from './game_hot_new.js'
11
8
  import game_info from './game_info.js'
12
- import game_replay from './game_replay.js'
13
9
  import game_betslip from './game_betslip.js'
14
10
  import inbox from './inbox.js'
15
- import merge from './merge.js'
16
- import payment_data from './payment_data.js'
17
- import reward_fc from './reward_fc.js'
18
- import reward from './reward.js'
19
11
  import reward_cash from './reward_cash.js'
20
12
  import setting from './setting.js'
21
- import side from './side.js'
22
- import side_v2 from './side_v2.js'
23
13
  import side_cash from './side_cash.js'
24
14
  import user_info from './user_info.js'
25
15
  import user_sign_up from './user_sign_up.js'
26
16
  import user_reset_password from './user_reset_password.js'
27
17
  import bank_binding from './bank_binding.js'
28
- import bank_binding_amb from './bank_binding_amb.js'
29
18
  import withdraw from './withdraw/index.js'
30
19
  import deposit from './deposit/index.js'
31
- import bonus from './bonus.js'
32
20
  import leaderboard from './leaderboard.js'
33
- import auth_otp_v2 from './auth_otp_v2.js'
34
21
  import auth_otp_v3 from './auth_otp_v3.js'
35
- import vip_table from './vip_table.js'
36
- import promotions from './promotions.js'
37
22
  import roulette_v2 from './roulette_v2.js'
38
23
  import honor_board_cash from './honor_board_cash.js'
39
- import honor_board from './honor_board.js'
40
24
  import user_photo from './user_photo.js'
41
25
  import navbar from './navbar.js'
42
26
  import websocket from './websocket.js'
@@ -45,42 +29,26 @@ import ranking from './ranking.js'
45
29
  export default {
46
30
  ...activity,
47
31
  auth,
48
- welcome,
49
32
  common,
50
33
  error,
51
34
  game_favorite_v2,
52
35
  game_search_cash,
53
- game_search_v2,
54
- game_hot_new,
55
36
  game_info,
56
- game_replay,
57
37
  game_betslip,
58
38
  inbox,
59
- merge,
60
- payment_data,
61
- reward,
62
39
  reward_cash,
63
- reward_fc,
64
40
  setting,
65
- side,
66
- side_v2,
67
41
  side_cash,
68
42
  game_v2_1,
69
43
  user_info,
70
44
  user_sign_up,
71
45
  user_reset_password,
72
46
  bank_binding,
73
- bank_binding_amb,
74
47
  ...deposit,
75
- bonus,
76
48
  leaderboard,
77
- auth_otp_v2,
78
49
  auth_otp_v3,
79
- vip_table,
80
- promotions,
81
50
  roulette_v2,
82
51
  honor_board_cash,
83
- honor_board,
84
52
  user_photo,
85
53
  navbar,
86
54
  ...withdraw,
@@ -6,7 +6,6 @@ export default function (request) {
6
6
  return createMachine(
7
7
  {
8
8
  id: 'leaderboard',
9
- predictableActionArguments: true,
10
9
  context: {
11
10
  rankActivities: null,
12
11
  activityNo: null,
@@ -38,12 +37,13 @@ export default function (request) {
38
37
  checking: {
39
38
  always: [
40
39
  { target: 'idle', actions: 'setActivityDetail', cond: 'isExist' },
41
- { target: 'loading', cond: 'hasActivityNo' },
40
+ { target: 'loading', cond: 'hasActivityNoAndToken' },
41
+ { target: 'idle' },
42
42
  ],
43
43
  },
44
44
  loading: {
45
45
  invoke: {
46
- src: 'fetchPublicActivityDetail',
46
+ src: 'fetchActivityDetail',
47
47
  onDone: {
48
48
  target: 'idle',
49
49
  actions: ['setActivityMap', 'setActivityDetail'],
@@ -101,8 +101,9 @@ export default function (request) {
101
101
  const { activityMap, activityNo } = context
102
102
  return activityMap[activityNo]
103
103
  },
104
- hasActivityNo: (context, event) => {
105
- return !!context.activityNo
104
+ hasActivityNoAndToken: (context, event) => {
105
+ const hasToken = request.getToken()
106
+ return !!context.activityNo && hasToken
106
107
  },
107
108
  },
108
109
  services: {
@@ -117,15 +118,10 @@ export default function (request) {
117
118
  const { data } = await request.send(hasToken ? api.getActivityList({ appSecret }) : api.getAllActivityList({ appSecret }))
118
119
  return data
119
120
  },
120
- fetchPublicActivityDetail: async (context, event) => {
121
- const hasToken = request.getToken()
121
+ fetchActivityDetail: async (context, event) => {
122
122
  const { activityNo } = context
123
123
  let result = {}
124
- if (hasToken) {
125
- result = await request.send(api.getActivityDetail({ activityNo, appSecret }))
126
- } else {
127
- result = await request.send(api.getTournamentDetail({ activityNo, appSecret }))
128
- }
124
+ result = await request.send(api.getActivityDetail({ activityNo, appSecret }))
129
125
  return result.data
130
126
  },
131
127
  },
@@ -7,7 +7,6 @@ export default function (request) {
7
7
  return createMachine(
8
8
  {
9
9
  id: 'navbar',
10
- predictableActionArguments: true,
11
10
  initial: 'fetching',
12
11
  context: {
13
12
  navbar: [],
@@ -73,10 +72,9 @@ export default function (request) {
73
72
  combindGames: assign((context, event) => {
74
73
  const gameInfo = event.data?.data || []
75
74
  const { navbar = [] } = context
76
- const gameInfoMap = new Map(gameInfo.map((game) => [game.gameCode, game]))
77
75
  const combindNavBar = navbar.map((item) => {
78
76
  if (item.type.toLowerCase() === 'game') {
79
- const currentGame = gameInfoMap.get(item.gameCode)
77
+ const currentGame = gameInfo.find((game) => game.gameCode === item.gameCode)
80
78
  return {
81
79
  ...item,
82
80
  ...currentGame,
@@ -1,39 +1,44 @@
1
1
  import { createMachine, assign } from 'xstate'
2
2
  import ranking from '../api/ranking.js'
3
3
 
4
+ const ROUND_LIMIT = { DAILY: 56, WEEKLY: 8, MONTHLY: 2, ALL: 2 }
5
+ const ONE_DAY_MS = 24 * 60 * 60 * 1000
6
+
7
+ // 後端每個 cycle 只回傳「當前回合」一筆,前台依當前回合往前回填歷史回合
8
+ // 回合長度 = 當期長度(endDate - beginDate)+ 1 天,回合之間連續無間隔
9
+ function expandPeriodOption(option, cycle) {
10
+ if (!option) return []
11
+ const { round, beginDate, endDate } = option
12
+ // 回合長度取整到整數天,避免後端 endDate 帶當日 23:59:59 等時間造成歷史回合逐期偏移
13
+ const step = Math.floor((endDate - beginDate) / ONE_DAY_MS + 1) * ONE_DAY_MS
14
+ const count = Math.min(ROUND_LIMIT[cycle] || round, round)
15
+ // 降冪排列,當前回合在最前
16
+ return Array.from({ length: count }, (_, i) => ({
17
+ round: round - i,
18
+ beginDate: beginDate - i * step,
19
+ endDate: endDate - i * step,
20
+ }))
21
+ }
22
+
4
23
  export default function (request) {
5
24
  const { appSecret } = request.config
6
25
  const cycleMapping = ['DAILY', 'WEEKLY', 'MONTHLY']
7
- const limit = { DAILY: 56, WEEKLY: 8, MONTHLY: 2, ALL: 2 }
8
-
9
- function roundProcess(rounds, cycles) {
10
- const roundArrays = rounds.map((round) => Array.from({ length: round }, (_, i) => i + 1))
11
- return roundArrays.reduce((acc, roundArray, index) => {
12
- const max = limit[cycles[index]] || rounds[index] // 若沒限制則取全部
13
- acc[cycles[index]] = roundArray.reverse().slice(0, max)
14
- return acc
15
- }, {})
16
- }
17
26
 
18
27
  function transGameData(item) {
19
28
  if (!item) return {}
20
- return {
21
- ...item,
22
- providerId: item.provider,
23
- }
29
+ item.providerId = item.provider
30
+ return item
24
31
  }
25
32
 
26
33
  return createMachine(
27
34
  {
28
35
  id: 'ranking',
29
- predictableActionArguments: true,
30
36
  initial: 'idle',
31
37
  context: {
32
38
  auth: false,
33
39
  site: '',
34
40
  activityNo: '',
35
41
  // api options 回傳的資料
36
- currentRound: [],
37
42
  cycle: '',
38
43
  round: 0,
39
44
  rule: '',
@@ -45,7 +50,7 @@ export default function (request) {
45
50
  gameRanking: [],
46
51
  topRanking: [],
47
52
  settleStatus: false,
48
- // 前端這邊用的選單資料 { cycle, round }
53
+ // 前端這邊用的選單資料 { cycle: [string], round: { [cycle]: [{ round, beginDate, endDate }] } }
49
54
  options: {},
50
55
  },
51
56
  states: {
@@ -159,31 +164,41 @@ export default function (request) {
159
164
  setRankingOptions: assign((context, event) => {
160
165
  const isChampion = event.data?.rule === 'CHAMPION'
161
166
  const cycle = event.data?.cycle
162
- const currentRound = event.data?.currentRound || []
163
- // 取得結算週期選單列表
164
- const cycleOptions = isChampion ? cycleMapping.slice(0, currentRound.length) : [cycle]
165
- const roundOptions = roundProcess(currentRound, cycleOptions)
167
+ const periodOptions = event.data?.periodOptions || []
168
+ // 每個 cycle 對應一筆「當前回合」
169
+ const optionByCycle = periodOptions.reduce((acc, option) => {
170
+ acc[option.cycle] = option
171
+ return acc
172
+ }, {})
173
+ // 依照 cycleMapping 順序取出有資料的 cycle
174
+ const cycleOptions = isChampion ? cycleMapping.filter((c) => optionByCycle[c]) : [cycle]
175
+ // 將每個 cycle 的當前回合往前回填為完整回合列表 { [cycle]: [{ round, beginDate, endDate }] }
176
+ const roundOptions = cycleOptions.reduce((acc, c) => {
177
+ acc[c] = expandPeriodOption(optionByCycle[c], c)
178
+ return acc
179
+ }, {})
166
180
  // 如果是冠軍龍虎月結算,則加入全部選項
167
181
  if (cycle === 'MONTHLY' && isChampion) {
168
182
  cycleOptions.push('ALL')
169
- roundOptions.ALL = roundOptions.MONTHLY
183
+ roundOptions.ALL = expandPeriodOption(optionByCycle.MONTHLY, 'ALL')
170
184
  }
185
+ // 初始 cycle 與 round
186
+ const initialCycle = isChampion ? 'DAILY' : cycle
187
+ const initialRound = roundOptions[initialCycle]?.[0]?.round
171
188
  return {
172
189
  ...event.data,
173
190
  options: { cycle: cycleOptions, round: roundOptions },
174
- // 初始固定顯示 DAILY
175
- cycle: isChampion ? 'DAILY' : cycle,
176
- round: currentRound[0],
191
+ cycle: initialCycle,
192
+ round: initialRound,
177
193
  }
178
194
  }),
179
195
  setOptions: assign((context, event) => {
180
- const { cycle, round } = context
196
+ const { cycle, round, options } = context
181
197
  // 處理變更 cycle,如果沒有輸入或沒有變更就不更新
182
198
  if (event.data?.cycle && cycle !== event.data?.cycle) {
183
- const { currentRound } = context
184
- const cycleForRound = event.data?.cycle === 'ALL' ? 'MONTHLY' : event.data?.cycle
185
- const cycleIndex = cycleMapping.indexOf(cycleForRound)
186
- return { cycle: event.data?.cycle, round: currentRound[cycleIndex] }
199
+ const newCycle = event.data?.cycle
200
+ const newRound = options?.round?.[newCycle]?.[0]?.round
201
+ return { cycle: newCycle, round: newRound }
187
202
  }
188
203
  if (event.data?.round && round !== event.data?.round) {
189
204
  return { round: event.data?.round }
@@ -7,7 +7,6 @@ export default function (request, context) {
7
7
  return createMachine(
8
8
  {
9
9
  id: 'reward_cash',
10
- predictableActionArguments: true,
11
10
  type: 'parallel',
12
11
  context: {
13
12
  auth: false,
@@ -64,10 +63,6 @@ export default function (request, context) {
64
63
  states: {
65
64
  idle: {
66
65
  on: {
67
- FETCH_WITHDRAW_RULE: {
68
- target: 'fetching',
69
- actions: 'setRewardData',
70
- },
71
66
  FETCH_OTHER_REWARD: {
72
67
  target: 'fetchingOtherReward',
73
68
  actions: 'setOrderColumn',
@@ -85,18 +80,6 @@ export default function (request, context) {
85
80
  },
86
81
  },
87
82
  },
88
- fetching: {
89
- invoke: {
90
- src: 'fetchWithdrawRulePreview',
91
- onDone: {
92
- target: 'pending',
93
- actions: 'setWithdrawRulePreview',
94
- },
95
- onError: {
96
- target: 'idle',
97
- },
98
- },
99
- },
100
83
  fetchingOtherReward: {
101
84
  invoke: {
102
85
  src: 'fetchOtherRewardList',
@@ -181,13 +164,6 @@ export default function (request, context) {
181
164
  otherRewardList: event.data[0]?.data,
182
165
  }
183
166
  }),
184
- setRewardData: assign((context, event) => {
185
- const { activityNo, receiveNo } = event.data
186
- return {
187
- activityNo,
188
- receiveNo,
189
- }
190
- }),
191
167
  setCallback: assign((context, event) => {
192
168
  return {
193
169
  callback: event.data?.callback || (() => {}),
@@ -201,11 +177,6 @@ export default function (request, context) {
201
177
  doCallback: (context, event) => {
202
178
  context.callback()
203
179
  },
204
- setWithdrawRulePreview: assign((context, event) => {
205
- return {
206
- withdrawRule: event.data,
207
- }
208
- }),
209
180
  setLang: assign((context, event) => {
210
181
  const lang = event.data.locale || context.lang || 'en-US'
211
182
  return { lang }
@@ -251,17 +222,6 @@ export default function (request, context) {
251
222
  const [otherRewardList] = await Promise.all([getOtherRewardAPI])
252
223
  return [otherRewardList]
253
224
  },
254
- fetchWithdrawRulePreview: async (context, event) => {
255
- const { receiveNo } = context
256
- const data = await request.send(
257
- payment.getWithdrawRulePreview({
258
- applyType: 'activity',
259
- applyNo: receiveNo,
260
- amount: null,
261
- })
262
- )
263
- return data
264
- },
265
225
  receiveReward: async (context, event) => {
266
226
  const { activityNo, receiveNo, attended } = event.data
267
227
  // Number("")-> 0 / Number(" ") -> 0 需要收到實際的數字才傳給後端
@@ -6,7 +6,6 @@ export default function (request) {
6
6
  return createMachine(
7
7
  {
8
8
  id: 'roulette_v2',
9
- predictableActionArguments: true,
10
9
  context: {
11
10
  tick: 2000,
12
11
  activityNo: null,
@@ -25,6 +24,7 @@ export default function (request) {
25
24
  spinResult: {},
26
25
  rouletteV2ExchangeAward: [],
27
26
  calculatedNewSpinRewards: [],
27
+ isSpinOutOfStock: false,
28
28
  awardedCashAmount: 0,
29
29
  awardedFreeAmount: 0,
30
30
  awardedPointsAmount: 0,
@@ -209,24 +209,27 @@ export default function (request) {
209
209
  }
210
210
  }),
211
211
  setSpinResult: assign((context, event) => {
212
- const { unCollectRewards = [], newSpinRewards = [], spinLeft = 0 } = event.data || {}
213
- const rewardCountMap = new Map()
214
- for (let i = 0; i < newSpinRewards.length; i++) {
215
- const spin = newSpinRewards[i]
216
- const key = `${spin.rewardType}:${spin.reward}`
217
- const existing = rewardCountMap.get(key)
212
+ const { unCollectRewards = [], newSpinRewards = [], spinLeft = 0 } = JSON.parse(JSON.stringify(event.data || {}))
213
+ // JT-1780311660:newSpinRewards[].outOfStock === true 代表抽中已無庫存的實體獎,後端不派獎、不進 unCollectRewards,
214
+ // 跑馬燈也不展示;只有嚴格 true 才算缺貨(null / undefined 為非實體獎或舊後端)。合併計數沿用 rewardType + reward 相同才合併
215
+ const isOutOfStock = (spin) => spin?.outOfStock === true
216
+ const calculatedNewSpinRewards = newSpinRewards.reduce((arr, spin) => {
217
+ if (!spin || isOutOfStock(spin)) return arr
218
+ const existing = arr.find((item) => item.rewardType === spin.rewardType && item.reward === spin.reward)
218
219
  if (existing) {
219
- existing.count += 1
220
+ existing.count++
220
221
  } else {
221
- rewardCountMap.set(key, { ...spin, count: 1 })
222
+ arr.push({ ...spin, count: 1 })
222
223
  }
223
- }
224
- const calculatedNewSpinRewards = [...rewardCountMap.values()]
224
+ return arr
225
+ }, [])
225
226
 
226
227
  return {
227
228
  spinResult: event.data,
228
229
  unCollectRewards,
229
230
  calculatedNewSpinRewards,
231
+ // 本次抽獎含缺貨項目(單次 Spin 缺貨或 Spin All 部分/全部缺貨),前台以此決定是否改顯示通用缺貨提示
232
+ isSpinOutOfStock: newSpinRewards.some(isOutOfStock),
230
233
  spinLeft,
231
234
  }
232
235
  }),
@@ -4,7 +4,6 @@ export default function () {
4
4
  return createMachine(
5
5
  {
6
6
  id: 'setting',
7
- predictableActionArguments: true,
8
7
  initial: 'idle',
9
8
  context: {
10
9
  musicPlay: true,
@@ -6,7 +6,6 @@ export default function (request) {
6
6
  return createMachine(
7
7
  {
8
8
  id: 'side',
9
- predictableActionArguments: true,
10
9
  initial: 'inactive',
11
10
  context: {
12
11
  menu: null,
@@ -67,12 +66,13 @@ export default function (request) {
67
66
  actions: {
68
67
  setMenu: assign((context, event) => {
69
68
  const menu = event.data
69
+ if (!Array.isArray(menu?.data)) return
70
70
  addLevelProperty(menu.data, 0)
71
71
  return { menu }
72
72
  }),
73
73
  updateMenu: assign((context, event) => {
74
74
  const menu = event.data
75
- if (menu.data.length) {
75
+ if (menu?.data?.length) {
76
76
  addLevelProperty(menu.data, 0)
77
77
  return { menu, defaultMenuItemStack: getDefaultItem(menu.data[0]) }
78
78
  }
@@ -83,7 +83,7 @@ export default function (request) {
83
83
  return await request.send(game.getListRoot({ appSecret }))
84
84
  },
85
85
  fetchUpdateMenu: async (context, event) => {
86
- return await request.send(game.getListRoot({ timestamp: context.menu.timestamp, appSecret }))
86
+ return await request.send(game.getListRoot({ timestamp: context.menu?.timestamp, appSecret }))
87
87
  },
88
88
  },
89
89
  }
@@ -5,7 +5,6 @@ export default function (request) {
5
5
  return createMachine(
6
6
  {
7
7
  id: 'user_info',
8
- predictableActionArguments: true,
9
8
  initial: 'fetching',
10
9
  context: {
11
10
  userInfo: {},
@@ -5,7 +5,6 @@ export default function (request) {
5
5
  return createMachine(
6
6
  {
7
7
  id: 'user_photo',
8
- predictableActionArguments: true,
9
8
  initial: 'fetching',
10
9
  context: {
11
10
  userPhotoList: {},
@@ -6,7 +6,6 @@ export default function (request) {
6
6
  return createMachine(
7
7
  {
8
8
  id: 'user_reset_password',
9
- predictableActionArguments: true,
10
9
  initial: 'idle',
11
10
  context: {
12
11
  otpParams: {
@@ -29,10 +28,6 @@ export default function (request) {
29
28
  target: 'otpFetching',
30
29
  actions: 'setOtpParamsEmail',
31
30
  },
32
- SEND_OTP_LOCAL: {
33
- target: 'otpFetching',
34
- actions: 'setOtpParamsLocal',
35
- },
36
31
  SEND_OTP_PHONE: {
37
32
  target: 'otpFetching',
38
33
  actions: 'setOtpParamsPhone',
@@ -158,15 +153,6 @@ export default function (request) {
158
153
  },
159
154
  }
160
155
  }),
161
- setOtpParamsLocal: assign((context, event) => {
162
- const { username } = event.data
163
- return {
164
- otpParams: {
165
- provider: 'local',
166
- username,
167
- },
168
- }
169
- }),
170
156
  setOtpParamsEmail: assign((context, event) => {
171
157
  const { email } = event.data
172
158
  return {