@jetthai/cuora 1.1.488-dev.1 → 1.2.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 (221) hide show
  1. package/.husky/pre-commit +3 -1
  2. package/.prettierignore +1 -2
  3. package/CHANGELOG.md +0 -746
  4. package/README.md +15 -299
  5. package/package.json +3 -6
  6. package/resetGitBranch.sh +101 -0
  7. package/src/api/activity.js +39 -24
  8. package/src/api/auth.js +35 -4
  9. package/src/api/common.js +1 -8
  10. package/src/api/game.js +10 -0
  11. package/src/api/index.js +1 -3
  12. package/src/api/payment.js +55 -18
  13. package/src/api/user.js +16 -11
  14. package/src/index.js +2 -2
  15. package/src/lib/fingerprint_v3_11_12.js +11433 -0
  16. package/src/machine/activity/activity.js +209 -0
  17. package/src/machine/activity/activity_cash.js +18 -71
  18. package/src/machine/activity/diamond_shop_activity_cash.js +1 -0
  19. package/src/machine/activity/diamond_shop_activity_fc.js +196 -0
  20. package/src/machine/activity/diamond_shop_activity_vn.js +178 -0
  21. package/src/machine/activity/fafafa_activity.js +10 -0
  22. package/src/machine/activity/index.js +12 -0
  23. package/src/machine/activity/invite_friends_activity.js +114 -0
  24. package/src/machine/activity/mini_game_activity.js +68 -0
  25. package/src/machine/activity/return_bonus_activity.js +153 -0
  26. package/src/machine/activity/roulette_activity_v2.js +0 -5
  27. package/src/machine/auth.js +140 -192
  28. package/src/machine/auth_otp_v2.js +177 -0
  29. package/src/machine/auth_otp_v3.js +32 -111
  30. package/src/machine/bank_binding.js +2 -2
  31. package/src/machine/bank_binding_amb.js +145 -0
  32. package/src/machine/bonus.js +75 -0
  33. package/src/machine/common.js +91 -27
  34. package/src/machine/deposit/amb.js +92 -0
  35. package/src/machine/deposit/crypto_bank.js +325 -0
  36. package/src/machine/deposit/crypto_bank_cash.js +8 -19
  37. package/src/machine/deposit/crypto_qrcode.js +148 -0
  38. package/src/machine/deposit/crypto_qrcode_cash.js +41 -26
  39. package/src/machine/deposit/crypto_way.js +247 -0
  40. package/src/machine/deposit/crypto_way_cash.js +32 -52
  41. package/src/machine/deposit/deposit_fc.js +271 -0
  42. package/src/machine/deposit/direct.js +310 -0
  43. package/src/machine/deposit/direct_cash.js +9 -8
  44. package/src/machine/deposit/float.js +374 -0
  45. package/src/machine/deposit/index.js +28 -0
  46. package/src/machine/deposit/krway.js +151 -0
  47. package/src/machine/deposit/loadcard_cash.js +31 -14
  48. package/src/machine/deposit/loadcard_vn.js +351 -0
  49. package/src/machine/deposit/manual_cash.js +10 -8
  50. package/src/machine/deposit/manual_vn.js +458 -0
  51. package/src/machine/deposit/qrcode_cash.js +30 -14
  52. package/src/machine/deposit/qrcode_v2.js +338 -0
  53. package/src/machine/deposit/usdt.js +144 -0
  54. package/src/machine/deposit/virtual_bank_cash.js +2 -5
  55. package/src/machine/deposit/virtual_bank_vn.js +269 -0
  56. package/src/machine/deposit/vpay.js +367 -0
  57. package/src/machine/error.js +0 -7
  58. package/src/machine/game_hot_new.js +79 -0
  59. package/src/machine/game_info.js +12 -5
  60. package/src/machine/game_replay.js +46 -0
  61. package/src/machine/game_search_v2.js +401 -0
  62. package/src/machine/game_v2_1.js +88 -58
  63. package/src/machine/honor_board.js +132 -0
  64. package/src/machine/honor_board_cash.js +18 -15
  65. package/src/machine/inbox.js +12 -0
  66. package/src/machine/index.js +32 -0
  67. package/src/machine/leaderboard.js +11 -8
  68. package/src/machine/merge.js +57 -0
  69. package/src/machine/payment_data.js +86 -0
  70. package/src/machine/promotions.js +170 -0
  71. package/src/machine/ranking.js +25 -43
  72. package/src/machine/reward.js +255 -0
  73. package/src/machine/reward_cash.js +41 -2
  74. package/src/machine/reward_fc.js +98 -0
  75. package/src/machine/roulette_v2.js +25 -20
  76. package/src/machine/side.js +154 -0
  77. package/src/machine/side_cash.js +2 -3
  78. package/src/machine/side_v2.js +209 -0
  79. package/src/machine/user_reset_password.js +15 -4
  80. package/src/machine/user_sign_up.js +60 -49
  81. package/src/machine/vip_table.js +57 -0
  82. package/src/machine/websocket.js +325 -378
  83. package/src/machine/welcome.js +110 -0
  84. package/src/machine/withdraw/index.js +6 -0
  85. package/src/machine/withdraw/withdraw_crypto_cash.js +327 -0
  86. package/src/machine/withdraw/withdraw_krway.js +222 -0
  87. package/src/machine/withdraw/withdraw_manual.js +533 -0
  88. package/src/machine/withdraw/withdraw_manual_cash.js +43 -74
  89. package/src/request/config.js +0 -2
  90. package/src/request/request.js +64 -231
  91. package/src/util/constant.js +2 -12
  92. package/src/util/deviceToken.js +59 -0
  93. package/src/util/index.js +4 -2
  94. package/src/util/math.js +4 -0
  95. package/.claude/commands/sync-ai-prompts.md +0 -180
  96. package/.claude/settings.local.json +0 -25
  97. package/.github/copilot-instructions.md +0 -459
  98. package/.husky/post-checkout +0 -32
  99. package/.husky/pre-push +0 -36
  100. package/AGENTS.md +0 -459
  101. package/AI_PROMPT_SOURCE.md +0 -457
  102. package/CLAUDE.md +0 -459
  103. package/GEMINI.md +0 -459
  104. package/docs/kibana/crypto-way-deposit-amount-bug-analysis.md +0 -1003
  105. package/docs/kibana/play-providerId-error.md +0 -202
  106. package/docs/kibana/play-selectedWalletType.md +0 -1
  107. package/docs/kibana/play-selectedWalletType_2.md +0 -1
  108. package/docs/kibana/play-selectedWalletType_analysis.md +0 -565
  109. package/docs/my-claude/feat-sharon-JT-1790247240-socket/branch-transfer.md +0 -14
  110. package/docs/my-claude/feat-sharon-JT-1790247240-socket/cash-module-preparation.json +0 -40
  111. package/docs/my-claude/feat-sharon-JT-1790247240-socket/cash-module-verification.md +0 -41
  112. package/docs/my-claude/feat-sharon-JT-1790247240-socket/implementation-ledger.md +0 -87
  113. package/docs/my-claude/feat-sharon-JT-1790247240-socket/module-report.md +0 -73
  114. package/docs/my-claude/feat-sharon-JT-1790247240-socket/plan.md +0 -309
  115. package/docs/my-claude/feat-sharon-JT-1790247240-socket/test-cases.md +0 -245
  116. package/docs/my-claude/feat-sharon-JT-1791180540-onesignal/transfer.md +0 -9
  117. package/e2e/feature-map.md +0 -19
  118. package/prepare-for-pr/JT-1776243420.md +0 -85
  119. package/prepare-for-pr/TI-16026/STATE.md +0 -18
  120. package/prepare-for-pr/TI-16026/after-prepare-authorization.md +0 -3
  121. package/prepare-for-pr/TI-16026/analysis.md +0 -38
  122. package/prepare-for-pr/TI-16026/answer-analyze-01.md +0 -1
  123. package/prepare-for-pr/TI-16026/answer-commit-01.md +0 -2
  124. package/prepare-for-pr/TI-16026/answer-commit-02.md +0 -1
  125. package/prepare-for-pr/TI-16026/bundle.json +0 -18
  126. package/prepare-for-pr/TI-16026/checklist.md +0 -196
  127. package/prepare-for-pr/TI-16026/checklist.unit-test-original.md +0 -39
  128. package/prepare-for-pr/TI-16026/claude-after-model +0 -1
  129. package/prepare-for-pr/TI-16026/claude-commit-session +0 -1
  130. package/prepare-for-pr/TI-16026/claude-harvest-session +0 -1
  131. package/prepare-for-pr/TI-16026/claude-hops/01-analyze.err +0 -1
  132. package/prepare-for-pr/TI-16026/claude-hops/01-analyze.out +0 -2
  133. package/prepare-for-pr/TI-16026/claude-hops/02-analyze.err +0 -1
  134. package/prepare-for-pr/TI-16026/claude-hops/02-analyze.out +0 -4
  135. package/prepare-for-pr/TI-16026/claude-hops/03-dev.err +0 -1
  136. package/prepare-for-pr/TI-16026/claude-hops/03-dev.out +0 -4
  137. package/prepare-for-pr/TI-16026/claude-hops/04-dev.err +0 -1
  138. package/prepare-for-pr/TI-16026/claude-hops/04-dev.out +0 -4
  139. package/prepare-for-pr/TI-16026/claude-hops/05-dev.err +0 -1
  140. package/prepare-for-pr/TI-16026/claude-hops/05-dev.out +0 -3
  141. package/prepare-for-pr/TI-16026/claude-hops/06-after.err +0 -1
  142. package/prepare-for-pr/TI-16026/claude-hops/06-after.out +0 -2
  143. package/prepare-for-pr/TI-16026/claude-hops/07-commit.err +0 -1
  144. package/prepare-for-pr/TI-16026/claude-hops/07-commit.out +0 -2
  145. package/prepare-for-pr/TI-16026/claude-hops/08-commit.err +0 -1
  146. package/prepare-for-pr/TI-16026/claude-hops/08-commit.out +0 -2
  147. package/prepare-for-pr/TI-16026/claude-hops/09-commit.err +0 -1
  148. package/prepare-for-pr/TI-16026/claude-hops/09-commit.out +0 -8
  149. package/prepare-for-pr/TI-16026/claude-hops/10-harvest.err +0 -1
  150. package/prepare-for-pr/TI-16026/claude-hops/10-harvest.out +0 -3
  151. package/prepare-for-pr/TI-16026/claude-hops/11-harvest.err +0 -1
  152. package/prepare-for-pr/TI-16026/claude-hops/11-harvest.out +0 -3
  153. package/prepare-for-pr/TI-16026/commit-note.md +0 -5
  154. package/prepare-for-pr/TI-16026/evidence-index.json +0 -215
  155. package/prepare-for-pr/TI-16026/feature-map.before.md +0 -61
  156. package/prepare-for-pr/TI-16026/harvest-redaction.json +0 -34
  157. package/prepare-for-pr/TI-16026/harvest-redaction.out +0 -37
  158. package/prepare-for-pr/TI-16026/harvest.md +0 -46
  159. package/prepare-for-pr/TI-16026/lessons.md +0 -5
  160. package/prepare-for-pr/TI-16026/note-harvest-redaction.md +0 -1
  161. package/prepare-for-pr/TI-16026/open-questions.md +0 -6
  162. package/prepare-for-pr/TI-16026/publish.md +0 -32
  163. package/prepare-for-pr/TI-16026/review-convergence-response.md +0 -3
  164. package/prepare-for-pr/TI-16026/review-input/scope.md +0 -18
  165. package/prepare-for-pr/TI-16026/review-log.md +0 -57
  166. package/prepare-for-pr/TI-16026/review-notes.md +0 -97
  167. package/prepare-for-pr/TI-16026/review-response-r1.md +0 -7
  168. package/prepare-for-pr/TI-16026/self-test-report.md +0 -67
  169. package/prepare-for-pr/TI-16026/spec-proposal.md +0 -34
  170. package/prepare-for-pr/TI-16026/spec-snapshot.md +0 -291
  171. package/prepare-for-pr/TI-16026/state-log.md +0 -57
  172. package/prepare-for-pr/TI-16026/user-messages/01.md +0 -12
  173. package/prepare-for-pr/TI-16026/user-messages/02.md +0 -20
  174. package/prepare-for-pr/TI-16026/user-messages/03.md +0 -1
  175. package/prepare-for-pr/TI-16026/user-messages/04.md +0 -1
  176. package/prepare-for-pr/TI-16026/user-messages/05.md +0 -1
  177. package/prepare-for-pr/TI-16026/user-messages/06.md +0 -1
  178. package/prepare-for-pr/TI-16026/user-messages/07.md +0 -1
  179. package/prepare-for-pr/TI-16026/user-messages/08.md +0 -1
  180. package/prepare-for-pr/TI-16026/user-messages/09.md +0 -1
  181. package/prepare-for-pr/TI-16026/user-messages/10.md +0 -1
  182. package/prepare-for-pr/TI-16026/user-messages/11.md +0 -1
  183. package/prepare-for-pr/TI-16026/user-messages/12.md +0 -1
  184. package/prepare-for-pr/TI-16026/user-messages/13.md +0 -1
  185. package/prepare-for-pr/TI-16026/user-messages/14.md +0 -1
  186. package/prepare-for-pr/TI-16026/user-messages/15.md +0 -1
  187. package/prepare-for-pr/TI-16026/user-messages/16.md +0 -1
  188. package/prepare-for-pr/TI-16026/user-messages/17.md +0 -1
  189. package/prepare-for-pr/TI-16026/user-messages/18.md +0 -10
  190. package/prepare-for-pr/TI-16026/user-messages/19.md +0 -1
  191. package/prepare-for-pr/TI-16026/user-messages/20.md +0 -1
  192. package/prepare-for-pr/TI-16026/user-messages/21.md +0 -1
  193. package/prepare-for-pr/TI-16026/user-messages/22.md +0 -1
  194. package/prepare-for-pr/TI-16026/user-messages/23.md +0 -8
  195. package/prepare-for-pr/TI-16026/user-messages/24.md +0 -24
  196. package/prepare-for-pr/TI-16026/user-question.md +0 -24
  197. package/prepare-for-pr/TI-16026/verify/metrics-check.json +0 -13
  198. package/prepare-for-pr/TI-16026/verify/redaction.json +0 -38
  199. package/prepare-for-pr/TI-16026/verify/row-closure.json +0 -45
  200. package/prepare-for-pr/TI-16026/verify/s04-ws-capture.md +0 -23
  201. package/prepare-for-pr/TI-16026/verify-after.md +0 -23
  202. package/prepare-for-pr/TI-16026/verify.json +0 -80
  203. package/prepare-for-pr/TI-16026.md +0 -408
  204. package/scripts/auto-version.js +0 -69
  205. package/scripts/auto-version.sh +0 -33
  206. package/scripts/branch-auto-npm-publish.js +0 -36
  207. package/scripts/check-version.sh +0 -36
  208. package/scripts/clean-tags.sh +0 -84
  209. package/src/api/account.js +0 -7
  210. package/src/api/otp.js +0 -5
  211. package/src/util/amount.js +0 -8
  212. package/src/util/err998SentryExtra.js +0 -26
  213. package/src/util/paramStore.js +0 -139
  214. package/src/util/socketPolicy.js +0 -57
  215. package/src/util/tokenStore.js +0 -44
  216. package/test/auth_otp_v3.test.js +0 -323
  217. package/test/auth_self_timeout.test.js +0 -171
  218. package/test/request_self.test.js +0 -288
  219. package/test/withdraw_manual_cash.test.js +0 -149
  220. package/tests/session.test.mjs +0 -177
  221. package/tests/websocket.test.mjs +0 -779
@@ -0,0 +1,178 @@
1
+ import { assign, createMachine } from 'xstate'
2
+ import api from '../../api/activity.js'
3
+
4
+ export default function (request) {
5
+ const { appSecret } = request.config
6
+ return createMachine(
7
+ {
8
+ id: 'diamond_shop_activity',
9
+ context: {
10
+ activityNo: null,
11
+ activityDetail: null,
12
+ totalPoints: 0,
13
+ awardList: [],
14
+ totalAmount: 0,
15
+ subtractPoints: 0,
16
+ callback: () => {},
17
+ },
18
+ initial: 'fetching',
19
+ states: {
20
+ fetching: {
21
+ invoke: {
22
+ src: 'fetchActivityList',
23
+ onDone: {
24
+ target: 'checking',
25
+ actions: 'setDiamondShopActivities',
26
+ },
27
+ onError: {
28
+ target: 'idle',
29
+ },
30
+ },
31
+ },
32
+ idle: {},
33
+ checking: {
34
+ always: [{ target: 'loading', cond: 'hasActivityNo' }],
35
+ },
36
+ loading: {
37
+ invoke: {
38
+ src: 'fetchActivityDetail',
39
+ onDone: {
40
+ target: 'loaded',
41
+ actions: ['setActivityDetail', 'setAwardList'],
42
+ },
43
+ onError: {
44
+ target: 'idle',
45
+ },
46
+ },
47
+ },
48
+ loaded: {
49
+ on: {
50
+ SELECT_EXCHANGE_AMOUNT: {
51
+ actions: 'selectExchangeAmount',
52
+ },
53
+ SET_MAX_EXCHANGE_AMOUNT: {
54
+ target: 'fetchingMaxAmount',
55
+ },
56
+ RESET_EXCHANGE_AMOUNT: {
57
+ actions: 'resetExchangeAmount',
58
+ },
59
+ SETTLE_AMOUNT: {
60
+ target: 'settling',
61
+ actions: 'setCallback',
62
+ cond: 'settlable',
63
+ },
64
+ },
65
+ },
66
+ fetchingMaxAmount: {
67
+ invoke: {
68
+ src: 'fetchMaxExchangeAmount',
69
+ onDone: {
70
+ target: 'loaded',
71
+ actions: 'setMaxExchangeAmount',
72
+ },
73
+ onError: {
74
+ target: 'loaded',
75
+ },
76
+ },
77
+ },
78
+ settling: {
79
+ invoke: {
80
+ src: 'settleAmount',
81
+ onDone: {
82
+ target: 'settled',
83
+ actions: ['resetExchangeAmount', 'doCallback'],
84
+ },
85
+ onError: {
86
+ target: 'settled',
87
+ },
88
+ },
89
+ },
90
+ settled: {
91
+ after: {
92
+ 0: {
93
+ target: 'loaded',
94
+ },
95
+ },
96
+ },
97
+ },
98
+ },
99
+ {
100
+ actions: {
101
+ setDiamondShopActivities: assign((context, event) => {
102
+ const activity = event.data.filter((item) => item.activityType === 91)
103
+ return {
104
+ activityNo: activity?.[0]?.activityNo,
105
+ }
106
+ }),
107
+ setActivityDetail: assign((context, event) => {
108
+ return {
109
+ activityDetail: event.data,
110
+ }
111
+ }),
112
+ setAwardList: assign((context, event) => {
113
+ return {
114
+ awardList: event.data?.awards || [],
115
+ }
116
+ }),
117
+ selectExchangeAmount: assign((context, event) => {
118
+ const { totalAmount = 0, subtractPoints = 0 } = context
119
+ const { award = 0, points = 0 } = event.data
120
+ return {
121
+ totalAmount: parseFloat(`${totalAmount}`) + parseFloat(`${award}`),
122
+ subtractPoints: parseFloat(`${subtractPoints}`) + parseFloat(`${points}`),
123
+ }
124
+ }),
125
+ setMaxExchangeAmount: assign((context, event) => {
126
+ const { addCash = 0, subtractDiamond = 0 } = event.data
127
+ return {
128
+ totalAmount: parseFloat(`${addCash}`),
129
+ subtractPoints: parseFloat(`${subtractDiamond}`),
130
+ }
131
+ }),
132
+ resetExchangeAmount: assign((context, event) => {
133
+ return {
134
+ totalAmount: 0,
135
+ subtractPoints: 0,
136
+ }
137
+ }),
138
+ setCallback: assign((context, event) => {
139
+ return {
140
+ callback: event.data?.callback || (() => {}),
141
+ }
142
+ }),
143
+ doCallback: (context, event) => {
144
+ context.callback()
145
+ },
146
+ },
147
+ guards: {
148
+ settlable: (context, event) => {
149
+ const { totalPoints, totalAmount, subtractPoints } = context
150
+ return totalAmount > 0 && subtractPoints <= totalPoints
151
+ },
152
+ hasActivityNo: (context, event) => {
153
+ return !!context.activityNo
154
+ },
155
+ },
156
+ services: {
157
+ fetchActivityList: async (context, event) => {
158
+ const { data } = await request.send(api.getActivityList({ appSecret }))
159
+ return data
160
+ },
161
+ fetchActivityDetail: async (context, event) => {
162
+ const { activityNo } = context
163
+ const { data } = await request.send(api.getActivityDetail({ activityNo, appSecret }))
164
+ return data
165
+ },
166
+ fetchMaxExchangeAmount: async (context, event) => {
167
+ const { activityNo } = context
168
+ const { data } = await request.send(api.getMaxExchangeAmount({ activityNo, appSecret }))
169
+ return data
170
+ },
171
+ settleAmount: async (context, event) => {
172
+ const { activityNo, totalAmount } = context
173
+ return await request.send(api.settleAmount({ activityNo, totalCash: totalAmount, appSecret }))
174
+ },
175
+ },
176
+ }
177
+ )
178
+ }
@@ -60,6 +60,11 @@ export default function (request, context) {
60
60
  },
61
61
  awarded: {
62
62
  entry: 'setDuration',
63
+ on: {
64
+ REFRESH_ACTIVITY: {
65
+ target: 'loading',
66
+ },
67
+ },
63
68
  after: {
64
69
  1000: [{ target: 'loading', cond: 'shouldCheckNewPeriod' }, { target: 'awarded' }],
65
70
  },
@@ -97,6 +102,11 @@ export default function (request, context) {
97
102
  },
98
103
  result: {
99
104
  entry: 'setDuration',
105
+ on: {
106
+ REFRESH_ACTIVITY: {
107
+ target: 'loading',
108
+ },
109
+ },
100
110
  after: {
101
111
  1000: [{ target: 'loading', cond: 'shouldCheckNewPeriod' }, { target: 'result' }],
102
112
  },
@@ -1,15 +1,21 @@
1
+ import activity from './activity.js'
1
2
  import activity_cash from './activity_cash.js'
2
3
  import continue_deposit_activity from './continue_deposit_activity.js'
3
4
  import deposit_activity from './deposit_activity.js'
5
+ import diamond_shop_activity_fc from './diamond_shop_activity_fc.js'
6
+ import diamond_shop_activity_vn from './diamond_shop_activity_vn.js'
4
7
  import diamond_shop_activity_cash from './diamond_shop_activity_cash.js'
5
8
  import fafafa_activity from './fafafa_activity.js'
9
+ import invite_friends_activity from './invite_friends_activity.js'
6
10
  import jackpot from './jackpot.js'
7
11
  import friend_invite_friends_activity from './friend_invite_friends_activity.js'
8
12
  import ranking_activity from './ranking_activity.js'
13
+ import return_bonus_activity from './return_bonus_activity.js'
9
14
  import specify_bets_activity from './specify_bets_activity.js'
10
15
  import specify_turnover_activity from './specify_turnover_activity.js'
11
16
  import sign_in_activity from './sign_in_activity.js'
12
17
  import time_bomb_activity from './time_bomb_activity.js'
18
+ import mini_game_activity from './mini_game_activity.js'
13
19
  import roulette_activity_v2 from './roulette_activity_v2.js'
14
20
  import sign_in_monthly_activity from './sign_in_monthly_activity.js'
15
21
  import otp_verified_activity from './otp_verified_activity.js'
@@ -18,18 +24,24 @@ import instant_rebate_activity from './instant_rebate_activity.js'
18
24
  import cash_rain_activity from './cash_rain_activity.js'
19
25
 
20
26
  export default {
27
+ activity,
21
28
  activity_cash,
22
29
  continue_deposit_activity,
23
30
  deposit_activity,
31
+ diamond_shop_activity_fc,
32
+ diamond_shop_activity_vn,
24
33
  diamond_shop_activity_cash,
25
34
  fafafa_activity,
35
+ invite_friends_activity,
26
36
  jackpot,
27
37
  friend_invite_friends_activity,
28
38
  ranking_activity,
39
+ return_bonus_activity,
29
40
  specify_bets_activity,
30
41
  specify_turnover_activity,
31
42
  sign_in_activity,
32
43
  time_bomb_activity,
44
+ mini_game_activity,
33
45
  roulette_activity_v2,
34
46
  sign_in_monthly_activity,
35
47
  otp_verified_activity,
@@ -0,0 +1,114 @@
1
+ import { assign, createMachine } from 'xstate'
2
+ import user from '../../api/user.js'
3
+ import api from '../../api/activity.js'
4
+
5
+ export default function (request) {
6
+ const { appSecret } = request.config
7
+ return createMachine(
8
+ {
9
+ id: 'invite_friends_activity',
10
+ context: {
11
+ activityNo: null,
12
+ bindingCode: null,
13
+ uidSite: null,
14
+ receiveNo: null,
15
+ friendCode: null,
16
+ downlineCount: 0,
17
+ },
18
+ initial: 'idle',
19
+ states: {
20
+ idle: {
21
+ on: {
22
+ FETCH_FRIEND_CODE: {
23
+ target: 'fetching',
24
+ },
25
+ BIND_FRIEND_CODE: {
26
+ target: 'binding',
27
+ actions: ['setActivityNo', 'setBindingCode', 'setUidSite'],
28
+ },
29
+ },
30
+ },
31
+ fetching: {
32
+ invoke: {
33
+ src: 'fetchFriends',
34
+ onDone: {
35
+ target: 'idle',
36
+ actions: 'setFriendCode',
37
+ },
38
+ onError: {
39
+ target: 'idle',
40
+ },
41
+ },
42
+ },
43
+ binding: {
44
+ invoke: {
45
+ src: 'postFriends',
46
+ onDone: {
47
+ target: 'awarding',
48
+ },
49
+ onError: {
50
+ target: 'idle',
51
+ },
52
+ },
53
+ },
54
+ awarding: {
55
+ invoke: {
56
+ src: 'awardPrize',
57
+ onDone: {
58
+ target: 'bound',
59
+ },
60
+ onError: {
61
+ target: 'idle',
62
+ },
63
+ },
64
+ },
65
+ bound: {
66
+ after: {
67
+ 0: {
68
+ target: 'idle',
69
+ },
70
+ },
71
+ },
72
+ },
73
+ },
74
+ {
75
+ actions: {
76
+ setFriendCode: assign((context, event) => {
77
+ const { friendCode, downlineCount } = event.data
78
+ return {
79
+ friendCode,
80
+ downlineCount,
81
+ }
82
+ }),
83
+ setBindingCode: assign((context, event) => {
84
+ return {
85
+ bindingCode: event.data.bindingCode,
86
+ }
87
+ }),
88
+ setActivityNo: assign((context, event) => {
89
+ return {
90
+ activityNo: event.data.activityNo,
91
+ }
92
+ }),
93
+ setUidSite: assign((context, event) => {
94
+ return {
95
+ uidSite: event.data.uidSite,
96
+ }
97
+ }),
98
+ },
99
+ services: {
100
+ postFriends: async (context, event) => {
101
+ return await request.send(user.postFriends({ friendCode: context.bindingCode }))
102
+ },
103
+ fetchFriends: async (context, event) => {
104
+ return await request.send(user.getFriends())
105
+ },
106
+ awardPrize: async (context, event) => {
107
+ const { activityNo, uidSite, bindingCode } = context
108
+ const { data } = await request.send(api.sentAward({ activityNo, uidSite, affiliateCode: bindingCode, appSecret }))
109
+ return data
110
+ },
111
+ },
112
+ }
113
+ )
114
+ }
@@ -0,0 +1,68 @@
1
+ import { assign, createMachine } from 'xstate'
2
+ import api from '../../api/activity.js'
3
+
4
+ export default function (request) {
5
+ const { appSecret } = request.config
6
+ return createMachine(
7
+ {
8
+ id: 'mini_game_activity',
9
+ context: {
10
+ activityNo: null,
11
+ activityDetail: null,
12
+ },
13
+ initial: 'idle',
14
+ states: {
15
+ idle: {
16
+ on: {
17
+ SET_ACTIVITY_NO: {
18
+ target: 'loading',
19
+ actions: 'setActivityNo',
20
+ },
21
+ },
22
+ },
23
+ loading: {
24
+ invoke: {
25
+ src: 'fetchActivityDetail',
26
+ onDone: {
27
+ target: 'loaded',
28
+ actions: 'setActivityDetail',
29
+ },
30
+ onError: {
31
+ target: 'idle',
32
+ },
33
+ },
34
+ },
35
+ loaded: {},
36
+ },
37
+ },
38
+ {
39
+ actions: {
40
+ setActivityNo: assign((context, event) => {
41
+ return {
42
+ activityNo: event.data,
43
+ }
44
+ }),
45
+ setDiamondShopActivities: assign((context, event) => {
46
+ const rankActivities = event.data.filter((item) => item.activityType === 92)
47
+ return {
48
+ rankActivities,
49
+ activityNo: rankActivities?.[0]?.activityNo,
50
+ }
51
+ }),
52
+ setActivityDetail: assign((context, event) => {
53
+ return {
54
+ activityDetail: event.data,
55
+ }
56
+ }),
57
+ },
58
+ guards: {},
59
+ services: {
60
+ fetchActivityDetail: async (context, event) => {
61
+ const { activityNo } = context
62
+ const { data } = await request.send(api.getActivityDetail({ activityNo, appSecret }))
63
+ return data
64
+ },
65
+ },
66
+ }
67
+ )
68
+ }
@@ -0,0 +1,153 @@
1
+ import { assign, createMachine } from 'xstate'
2
+ import api from '../../api/activity.js'
3
+ import isEqual from 'lodash/isEqual.js'
4
+
5
+ // const isEqual = require('lodash/isEqual')
6
+
7
+ export default function (request) {
8
+ const { appSecret } = request.config
9
+ return createMachine(
10
+ {
11
+ id: 'return_bonus_activity',
12
+ context: {
13
+ activityNo: null,
14
+ activityDetail: null,
15
+ rewardList: [],
16
+ callback: () => {},
17
+ },
18
+ initial: 'idle',
19
+ states: {
20
+ idle: {
21
+ always: [{ target: 'loading', cond: 'hasActivityNo' }],
22
+ on: {
23
+ SET_REWARD_LIST: {
24
+ actions: 'setRewardList',
25
+ },
26
+ },
27
+ },
28
+ loading: {
29
+ invoke: {
30
+ src: 'fetchActivityDetail',
31
+ onDone: {
32
+ target: 'loaded',
33
+ actions: 'setActivityDetail',
34
+ },
35
+ onError: {
36
+ target: 'idle',
37
+ },
38
+ },
39
+ on: {
40
+ SET_REWARD_LIST: {
41
+ actions: 'setRewardList',
42
+ },
43
+ },
44
+ },
45
+ loaded: {
46
+ always: [{ target: 'receivable', cond: 'isReceivable' }, { target: 'notReceivableYet', cond: 'isNotReceivableYet' }, { target: 'empty' }],
47
+ },
48
+ receivable: {
49
+ on: {
50
+ RECEIVE_REWARD: {
51
+ target: 'receiving',
52
+ actions: 'setCallback',
53
+ },
54
+ },
55
+ },
56
+ notReceivableYet: {
57
+ after: {
58
+ 20000: {
59
+ target: 'loading',
60
+ },
61
+ },
62
+ },
63
+ empty: {
64
+ after: {
65
+ 20000: {
66
+ target: 'loading',
67
+ },
68
+ },
69
+ },
70
+ receiving: {
71
+ invoke: {
72
+ src: 'receiveReward',
73
+ onDone: {
74
+ target: 'loading',
75
+ actions: 'doCallback',
76
+ },
77
+ onError: {
78
+ target: 'loading',
79
+ },
80
+ },
81
+ },
82
+ },
83
+ on: {
84
+ SET_ACTIVITY_NO: {
85
+ target: '.idle',
86
+ actions: 'setActivityNo',
87
+ cond: 'isActivityChanged',
88
+ },
89
+ SET_REWARD_LIST: {
90
+ target: '.loaded',
91
+ actions: 'setRewardList',
92
+ },
93
+ },
94
+ },
95
+ {
96
+ actions: {
97
+ setActivityNo: assign((context, event) => {
98
+ return {
99
+ activityNo: event.data,
100
+ }
101
+ }),
102
+ setActivityDetail: assign((context, event) => {
103
+ return {
104
+ activityDetail: event.data,
105
+ }
106
+ }),
107
+ setRewardList: assign((context, event) => {
108
+ const rewardList = event.data.filter((item) => item.activityType === 4 && item.receiveStatus === 0)
109
+ return { rewardList }
110
+ }),
111
+ setCallback: assign((context, event) => {
112
+ return {
113
+ callback: event.data?.callback || (() => {}),
114
+ }
115
+ }),
116
+ doCallback: (context, event) => {
117
+ context.callback()
118
+ },
119
+ },
120
+ guards: {
121
+ isActivityChanged: (context, event) => {
122
+ return !isEqual(context.activityNo, event.data)
123
+ },
124
+ hasActivityNo: (context, event) => {
125
+ return context.activityNo
126
+ },
127
+ isReceivable: (context, event) => {
128
+ return context.rewardList?.length > 0
129
+ },
130
+ isNotReceivableYet: (context, event) => {
131
+ return !context.rewardList?.length && context.activityDetail?.rebateAmount > 0
132
+ },
133
+ },
134
+ services: {
135
+ fetchActivityDetail: async (context, event) => {
136
+ const { activityNo } = context
137
+ const { data } = await request.send(api.getActivityDetail({ activityNo, appSecret }))
138
+ return data
139
+ },
140
+ receiveReward: async (context, event) => {
141
+ const { activityNo, receiveNo } = context.rewardList[0]
142
+ const validateReceiveNo = Number(receiveNo) > 0 ? Number(receiveNo) : undefined
143
+ const { data } = await request.send(api.getReward({ activityNo, receiveNo: validateReceiveNo, appSecret }))
144
+ return data
145
+ },
146
+ fetchRewardList: async (context, event) => {
147
+ const { data } = await request.send(api.getRewardList({ appSecret, count: 30 }))
148
+ return data
149
+ },
150
+ },
151
+ }
152
+ )
153
+ }
@@ -42,11 +42,6 @@ export default function (request, context) {
42
42
  target: 'loaded',
43
43
  },
44
44
  },
45
- on: {
46
- REFRESH_ACTIVITY_DETAIL: {
47
- target: 'loading',
48
- },
49
- },
50
45
  },
51
46
  expired: {},
52
47
  },