@jetthai/cuora 2.0.0-beta.1 → 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 -113
  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 -112
  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 +18 -28
  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 +2 -13
  70. package/src/machine/game_v2_1.js +42 -166
  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 -463
  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 -91
  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 -144
  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 -195
  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 -148
  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 -629
  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,311 +0,0 @@
1
- import { assign, createMachine } from 'xstate'
2
- import payment from '../../api/payment.js'
3
- import common from '../../api/common.js'
4
-
5
- export default function (request) {
6
- const { appSecret } = request.config
7
- return createMachine(
8
- {
9
- id: 'direct',
10
- predictableActionArguments: true,
11
- initial: 'loading',
12
- context: {
13
- siteConfig: null,
14
- paymentDetail: [],
15
- directs: [],
16
- currentDirect: null,
17
- banks: [],
18
- selectedBank: null,
19
- calculation: null,
20
- currentCategory: 'direct',
21
- currentMethod: null,
22
- amount: null,
23
- result: null,
24
-
25
- // use for wallet mode 3
26
- promotion: null,
27
- },
28
- states: {
29
- loading: {
30
- initial: 'init',
31
- states: {
32
- init: {
33
- invoke: {
34
- src: 'fetchInitData',
35
- onDone: {
36
- target: 'fetching',
37
- actions: 'setInitData',
38
- },
39
- onError: {
40
- target: '#direct.fail',
41
- },
42
- },
43
- },
44
- fetching: {
45
- invoke: {
46
- src: 'fetchBanksList',
47
- onDone: {
48
- target: '#direct.promotion',
49
- actions: 'setBanks',
50
- },
51
- onError: {
52
- target: '#direct.fail',
53
- },
54
- },
55
- },
56
- },
57
- },
58
- promotion: {
59
- always: [
60
- {
61
- target: 'loaded',
62
- },
63
- {
64
- target: 'calculating',
65
- actions: 'setPromotionDefaultAmount',
66
- cond: 'hasMinPromotionDeposit',
67
- },
68
- {
69
- target: 'loaded',
70
- },
71
- ],
72
- },
73
- loaded: {
74
- on: {
75
- SELECT_DIRECT: {
76
- actions: ['setDirect', 'reset'],
77
- target: 'loading.fetching',
78
- },
79
- SELECT_BANK: {
80
- actions: 'setSelectedBank',
81
- },
82
- SET_AMOUNT: {
83
- actions: ['setAmount', 'clearCalculation'],
84
- },
85
- CLEAR_CALCULATION: {
86
- actions: 'clearCalculation',
87
- },
88
- CALCULATE: {
89
- target: 'debouncing',
90
- },
91
- SUBMIT: [
92
- {
93
- target: 'pending',
94
- cond: (context, event) => !!context.calculation,
95
- },
96
- {
97
- target: 'submitting',
98
- cond: 'isSubmittable',
99
- },
100
- ],
101
- },
102
- },
103
- pending: {
104
- on: {
105
- SUBMIT: {
106
- target: 'submitting',
107
- cond: 'isSubmittable',
108
- },
109
- },
110
- },
111
- debouncing: {
112
- on: {
113
- SELECT_DIRECT: {
114
- actions: ['setDirect', 'reset'],
115
- target: 'loading.fetching',
116
- },
117
- SELECT_BANK: {
118
- actions: 'setSelectedBank',
119
- },
120
- SET_AMOUNT: {
121
- actions: ['setAmount', 'clearCalculation'],
122
- },
123
- CLEAR_CALCULATION: {
124
- actions: 'clearCalculation',
125
- },
126
- CALCULATE: {
127
- target: 'debouncing',
128
- },
129
- SUBMIT: [
130
- {
131
- target: 'pending',
132
- cond: (context, event) => !!context.calculation,
133
- },
134
- {
135
- target: 'submitting',
136
- cond: 'isSubmittable',
137
- },
138
- ],
139
- },
140
- after: {
141
- 1000: [{ target: 'calculating', cond: 'isCalculable' }, { target: 'loaded' }],
142
- },
143
- },
144
- calculating: {
145
- invoke: {
146
- src: 'fetchCalculation',
147
- onDone: {
148
- target: 'loaded',
149
- actions: 'setCalculation',
150
- },
151
- onError: {
152
- target: 'loaded',
153
- },
154
- },
155
- },
156
- submitting: {
157
- invoke: {
158
- src: 'submitDeposit',
159
- onDone: {
160
- target: 'submitted',
161
- actions: 'setResult',
162
- },
163
- onError: {
164
- target: 'loaded',
165
- },
166
- },
167
- },
168
- submitted: {},
169
- fail: {},
170
- },
171
- on: {
172
- SET_PROMOTION: {
173
- actions: 'setPromotion',
174
- },
175
- },
176
- },
177
- {
178
- actions: {
179
- reset: assign((context, event) => {
180
- const { banks } = context
181
- return {
182
- amount: null,
183
- selectedBank: banks[0],
184
- calculation: null,
185
- result: null,
186
- }
187
- }),
188
- setInitData: assign((context, event) => {
189
- const { siteConfig, paymentDetail } = event.data
190
- const directs = paymentDetail.filter((element) => element.category === context.currentCategory)
191
- const currentDirect = directs[0]
192
- return {
193
- siteConfig,
194
- paymentDetail,
195
- directs,
196
- currentDirect,
197
- currentMethod: currentDirect?.method,
198
- }
199
- }),
200
- setBanks: assign((context, event) => {
201
- const banks = event.data?.data ? event.data.data : event.data
202
- return {
203
- banks,
204
- selectedBank: banks[0],
205
- }
206
- }),
207
- setDirect: assign((context, event) => {
208
- return {
209
- currentDirect: event.data,
210
- currentMethod: event.data.method,
211
- }
212
- }),
213
- setSelectedBank: assign((context, event) => {
214
- return {
215
- selectedBank: event.data,
216
- }
217
- }),
218
- setAmount: assign((context, event) => {
219
- return {
220
- amount: event.data,
221
- }
222
- }),
223
- setCalculation: assign((context, event) => {
224
- // V2接口轉換中回傳的資料結構不同
225
- const { data } = event.data
226
- if (data) {
227
- return {
228
- calculation: data,
229
- }
230
- } else {
231
- return {
232
- calculation: event.data,
233
- }
234
- }
235
- }),
236
- clearCalculation: assign((context, event) => {
237
- return {
238
- calculation: null,
239
- }
240
- }),
241
- setResult: assign((context, event) => {
242
- return {
243
- result: event.data,
244
- }
245
- }),
246
- setPromotion: assign((context, event) => {
247
- return {
248
- promotion: event.data,
249
- }
250
- }),
251
- setPromotionDefaultAmount: assign((context, event) => {
252
- return {
253
- amount: context.promotion.minimumAmount,
254
- }
255
- }),
256
- },
257
- guards: {
258
- isCalculable: (context, event) => {
259
- const {
260
- amount,
261
- currentDirect: { maximum, minimum },
262
- } = context
263
- return amount && minimum <= +amount && +amount <= maximum
264
- },
265
- isSubmittable: (context, event) => {
266
- const { amount, currentMethod, selectedBank } = context
267
- return amount && currentMethod && selectedBank?.bankCode
268
- },
269
- hasMinPromotionDeposit: (context, event) => {
270
- return context.promotion?.minimumAmount
271
- },
272
- },
273
- services: {
274
- fetchInitData: async (context, event) => {
275
- const [{ config }, paymentDetail = []] = await Promise.all([
276
- request.send(common.getConfig({ appSecret })),
277
- request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' })),
278
- ])
279
- const siteConfig = JSON.parse(window.atob(config))
280
- return { siteConfig, paymentDetail }
281
- },
282
- fetchBanksList: async (context, event) => {
283
- const { currentDirect } = context
284
- const method = currentDirect.method
285
- return await request.send(payment.getBankList(method))
286
- },
287
- fetchCalculation: async (context, event) => {
288
- const { currentMethod, amount, promotion } = context
289
- return await request.send(
290
- payment.getDepositExpectedResult({
291
- method: currentMethod,
292
- amount: Number(amount),
293
- promotionsNo: promotion?.activityNo,
294
- })
295
- )
296
- },
297
- submitDeposit: async (context, event) => {
298
- const { currentMethod, amount, selectedBank, promotion } = context
299
- return await request.send(
300
- payment.submitDepositTransactionBank({
301
- method: currentMethod,
302
- amount,
303
- applyerBankCode: selectedBank.bankCode,
304
- promotionsNo: promotion?.activityNo,
305
- })
306
- )
307
- },
308
- },
309
- }
310
- )
311
- }
@@ -1,375 +0,0 @@
1
- import { assign, createMachine } from 'xstate'
2
- import payment from '../../api/payment.js'
3
- import common from '../../api/common.js'
4
-
5
- export default function (request) {
6
- const { appSecret } = request.config
7
- return createMachine(
8
- {
9
- id: 'float',
10
- predictableActionArguments: true,
11
- initial: 'loading',
12
- context: {
13
- method: 'amb_float',
14
- userAccount: {},
15
- siteConfig: null,
16
- amount: 0,
17
-
18
- bankList: [],
19
- options: [],
20
- minimum: 0,
21
- maximum: 0,
22
-
23
- calculation: null,
24
-
25
- houseAccountName: null,
26
- houseAccountNumber: null,
27
- houseBankName: null,
28
- calculatedAmount: 0,
29
-
30
- grandTotalEnable: 1,
31
- ttl: 120,
32
-
33
- promotion: null,
34
- bonusPreviewData: [],
35
- },
36
- states: {
37
- loading: {
38
- initial: 'checkingUserAccount',
39
- states: {
40
- checkingUserAccount: {
41
- invoke: {
42
- src: 'fetchPaymentInfo',
43
- onDone: [
44
- {
45
- target: 'initializing',
46
- actions: 'setUserAccount',
47
- cond: 'hasUserAccount',
48
- },
49
- { target: '#float.accountUnbound' },
50
- ],
51
- onError: {
52
- target: '#float.unavailable',
53
- },
54
- },
55
- },
56
- initializing: {
57
- invoke: {
58
- src: 'initialize',
59
- onDone: {
60
- target: '#float.loaded',
61
- actions: 'setInitialization',
62
- },
63
- onError: {
64
- target: '#float.unavailable',
65
- },
66
- },
67
- },
68
- },
69
- },
70
- checking: {
71
- always: [
72
- {
73
- target: 'fetching',
74
- cond: (context, event) => {
75
- const { siteConfig = {}, promotion = {} } = context
76
- const { bonusPreviewEnable } = siteConfig
77
- return bonusPreviewEnable && promotion.activityNo != 'none'
78
- },
79
- },
80
- { target: 'loaded' },
81
- ],
82
- },
83
- fetching: {
84
- invoke: {
85
- src: 'fetchBonusPreview',
86
- onDone: {
87
- target: 'loaded',
88
- actions: 'setBonusPreview',
89
- },
90
- onError: {
91
- target: 'loaded',
92
- },
93
- },
94
- },
95
- loaded: {
96
- on: {
97
- SELECT_AMOUNT: [
98
- {
99
- target: 'debouncing',
100
- actions: 'addAmount',
101
- cond: 'isGrandTotalEnable',
102
- },
103
- {
104
- target: 'debouncing',
105
- actions: 'setAmount',
106
- },
107
- ],
108
- KEY_IN: {
109
- target: 'calculating',
110
- actions: 'setAmount',
111
- },
112
- CLEAR_CALCULATION: {
113
- target: 'debouncing',
114
- actions: 'clearCalculation',
115
- },
116
- },
117
- },
118
- debouncing: {
119
- on: {
120
- SELECT_AMOUNT: [
121
- {
122
- target: 'debouncing',
123
- actions: 'addAmount',
124
- cond: 'isGrandTotalEnable',
125
- },
126
- {
127
- target: 'debouncing',
128
- actions: 'setAmount',
129
- },
130
- ],
131
- KEY_IN: {
132
- target: 'debouncing',
133
- actions: 'setAmount',
134
- },
135
- },
136
- after: {
137
- 1000: {
138
- target: 'calculating',
139
- },
140
- },
141
- },
142
- calculable: {
143
- entry: 'clearCalculation',
144
- on: {
145
- SELECT_AMOUNT: [
146
- {
147
- target: 'debouncing',
148
- actions: 'addAmount',
149
- cond: 'isGrandTotalEnable',
150
- },
151
- {
152
- target: 'debouncing',
153
- actions: 'setAmount',
154
- },
155
- ],
156
- KEY_IN: {
157
- target: 'debouncing',
158
- actions: 'setAmount',
159
- },
160
- CLEAR_CALCULATION: {
161
- target: 'debouncing',
162
- actions: 'clearCalculation',
163
- },
164
- CLEAR: {
165
- actions: 'setAmount',
166
- },
167
- },
168
- },
169
- calculating: {
170
- invoke: {
171
- src: 'fetchCalculation',
172
- onDone: {
173
- target: 'calculated',
174
- actions: 'setCalculation',
175
- },
176
- onError: {
177
- target: 'calculable',
178
- },
179
- },
180
- },
181
- calculated: {
182
- on: {
183
- SELECT_AMOUNT: [
184
- {
185
- target: 'debouncing',
186
- actions: 'addAmount',
187
- cond: 'isGrandTotalEnable',
188
- },
189
- {
190
- target: 'debouncing',
191
- actions: 'setAmount',
192
- },
193
- ],
194
- KEY_IN: {
195
- target: 'debouncing',
196
- actions: 'setAmount',
197
- },
198
- CONFIRM: {
199
- target: 'submitting',
200
- },
201
- CLEAR: {
202
- actions: 'setAmount',
203
- },
204
- CLEAR_CALCULATION: {
205
- target: 'debouncing',
206
- actions: 'clearCalculation',
207
- },
208
- },
209
- },
210
- submitting: {
211
- invoke: {
212
- src: 'submitDeposit',
213
- onDone: {
214
- target: 'countdown',
215
- actions: 'setHouseBank',
216
- },
217
- onError: {
218
- target: 'calculated',
219
- },
220
- },
221
- },
222
- countdown: {
223
- after: {
224
- 1000: [
225
- {
226
- target: 'countdown',
227
- actions: 'decreaseTtl',
228
- cond: (context) => context.ttl > 0,
229
- },
230
- {
231
- target: 'loaded',
232
- },
233
- ],
234
- },
235
- },
236
- accountUnbound: {},
237
- unavailable: {},
238
- },
239
- on: {
240
- SET_PROMOTION: {
241
- actions: 'setPromotion',
242
- },
243
- },
244
- },
245
- {
246
- actions: {
247
- setUserAccount: assign((context, event) => {
248
- return {
249
- userAccount: event.data?.[0],
250
- }
251
- }),
252
- setPromotion: assign((context, event) => {
253
- const promotion = event.data
254
- return {
255
- promotion,
256
- }
257
- }),
258
- setBonusPreview: assign((context, event) => {
259
- return {
260
- bonusPreviewData: event.data,
261
- }
262
- }),
263
- setHouseBank: assign((context, event) => {
264
- const { accountName, accountNumber, bankName, amount } = event.data
265
- return {
266
- houseAccountName: accountName,
267
- houseAccountNumber: accountNumber,
268
- houseBankName: bankName,
269
- calculatedAmount: amount,
270
- }
271
- }),
272
- setInitialization: assign((context, event) => {
273
- const { siteConfig, housePayment, bankList } = event.data
274
- const { optional, minimum, maximum, grandTotalEnable } = housePayment
275
- return {
276
- siteConfig,
277
- options: optional,
278
- minimum,
279
- maximum,
280
- bankList: bankList?.data ? bankList.data : bankList,
281
- grandTotalEnable,
282
- }
283
- }),
284
- addAmount: assign((context, event) => {
285
- const { amount, maximum } = context
286
- return {
287
- amount: Math.min(amount + event.data, maximum),
288
- }
289
- }),
290
- setAmount: assign((context, event) => {
291
- return {
292
- amount: event.data,
293
- }
294
- }),
295
- setCalculation: assign((context, event) => {
296
- // V2接口轉換中回傳的資料結構不同
297
- const { data } = event.data
298
- if (data) {
299
- return {
300
- calculation: data,
301
- }
302
- } else {
303
- return {
304
- calculation: event.data,
305
- }
306
- }
307
- }),
308
- clearCalculation: assign((context, event) => {
309
- return {
310
- calculation: null,
311
- }
312
- }),
313
- decreaseTtl: assign((context, evnet) => {
314
- const ms = context.ttl
315
- return {
316
- ttl: Math.max(ms - 1, 0),
317
- }
318
- }),
319
- },
320
- guards: {
321
- hasUserAccount: (context, event) => {
322
- return event.data?.[0]
323
- },
324
- isGrandTotalEnable: (context, event) => {
325
- return context.grandTotalEnable === 1
326
- },
327
- },
328
- services: {
329
- fetchPaymentInfo: async (context, event) => {
330
- const { bankInfo } = await request.send(payment.getPaymentInfo())
331
- const filterArray = bankInfo?.filter((item) => item.bindingType !== 'CRYPTO' && item.bindingType !== 'EWALLET')
332
- return filterArray || []
333
- },
334
- initialize: async (context, event) => {
335
- const [{ config }, payments, bankList] = await Promise.all([
336
- request.send(common.getConfig({ appSecret })),
337
- request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' })),
338
- request.send(payment.getBankList('amb')),
339
- ])
340
- const siteConfig = JSON.parse(window.atob(config))
341
- return { siteConfig, housePayment: payments.find((payment) => payment.method === context.method), bankList }
342
- },
343
- fetchBonusPreview: async (context, event) => {
344
- const { method, promotion } = context
345
- return await request.send(
346
- payment.getBonusPreview({
347
- method,
348
- promotionsNo: promotion?.activityNo,
349
- })
350
- )
351
- },
352
- submitDeposit: async (context, event) => {
353
- const { method, amount, promotion } = context
354
- return await request.send(
355
- payment.submitDepositTransaction({
356
- method,
357
- amount,
358
- promotionsNo: promotion?.activityNo,
359
- })
360
- )
361
- },
362
- fetchCalculation: async (context, event) => {
363
- const { method, amount, promotion } = context
364
- return await request.send(
365
- payment.getDepositExpectedResult({
366
- method,
367
- amount: Number(amount),
368
- promotionsNo: promotion?.activityNo,
369
- })
370
- )
371
- },
372
- },
373
- }
374
- )
375
- }