@jetthai/cuora 1.0.205 → 1.0.302-sl-1

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 (109) hide show
  1. package/.husky/pre-commit +4 -0
  2. package/.prettierignore +1 -0
  3. package/CHANGELOG.md +846 -0
  4. package/README.md +6 -0
  5. package/package.json +6 -9
  6. package/src/api/activity.js +43 -2
  7. package/src/api/auth.js +22 -7
  8. package/src/api/common.js +2 -1
  9. package/src/api/game.js +20 -7
  10. package/src/api/mailbox.js +9 -5
  11. package/src/api/payment.js +167 -19
  12. package/src/api/user.js +7 -0
  13. package/src/lib/fingerprint.js +9779 -0
  14. package/src/machine/activity/activity.js +111 -26
  15. package/src/machine/activity/activity_cash.js +159 -0
  16. package/src/machine/activity/cash_rain_activity.js +153 -0
  17. package/src/machine/activity/continue_deposit_activity.js +11 -2
  18. package/src/machine/activity/deposit_activity.js +13 -4
  19. package/src/machine/activity/diamond_shop_activity_cash.js +179 -0
  20. package/src/machine/activity/diamond_shop_activity_vn.js +54 -89
  21. package/src/machine/activity/fafafa_activity.js +34 -19
  22. package/src/machine/activity/{affiliate_invite_friends_activity.js → friend_invite_friends_activity.js} +70 -41
  23. package/src/machine/activity/index.js +22 -4
  24. package/src/machine/activity/instant_rebate_activity.js +217 -0
  25. package/src/machine/activity/invite_friends_activity.js +14 -14
  26. package/src/machine/activity/jackpot.js +74 -0
  27. package/src/machine/activity/otp_verified_activity.js +74 -0
  28. package/src/machine/activity/ranking_activity.js +11 -2
  29. package/src/machine/activity/roulette_activity_v2.js +90 -0
  30. package/src/machine/activity/sign_in_activity.js +21 -14
  31. package/src/machine/activity/sign_in_monthly_activity.js +65 -0
  32. package/src/machine/activity/specify_bets_activity.js +25 -3
  33. package/src/machine/activity/specify_turnover_activity.js +25 -3
  34. package/src/machine/activity/time_bomb_activity.js +11 -2
  35. package/src/machine/activity/vip_card_activity.js +140 -0
  36. package/src/machine/auth.js +141 -27
  37. package/src/machine/auth_otp_v2.js +10 -4
  38. package/src/machine/auth_otp_v3.js +11 -3
  39. package/src/machine/bank_binding.js +112 -12
  40. package/src/machine/bank_binding_amb.js +145 -0
  41. package/src/machine/common.js +113 -25
  42. package/src/machine/deposit/amb.js +92 -0
  43. package/src/machine/deposit/crypto.js +50 -29
  44. package/src/machine/deposit/crypto_bank.js +317 -0
  45. package/src/machine/deposit/crypto_bank_cash.js +287 -0
  46. package/src/machine/deposit/crypto_button.js +174 -39
  47. package/src/machine/deposit/crypto_cash.js +255 -0
  48. package/src/machine/deposit/crypto_qrcode.js +148 -0
  49. package/src/machine/deposit/crypto_qrcode_cash.js +131 -0
  50. package/src/machine/deposit/crypto_way.js +239 -0
  51. package/src/machine/deposit/crypto_way_cash.js +256 -0
  52. package/src/machine/deposit/deposit_fc.js +8 -5
  53. package/src/machine/deposit/direct.js +111 -16
  54. package/src/machine/deposit/direct_cash.js +217 -0
  55. package/src/machine/deposit/float.js +366 -0
  56. package/src/machine/deposit/index.js +43 -2
  57. package/src/machine/deposit/krway.js +151 -0
  58. package/src/machine/deposit/loadcard_cash.js +207 -0
  59. package/src/machine/deposit/loadcard_vn.js +191 -43
  60. package/src/machine/deposit/manual_cash.js +356 -0
  61. package/src/machine/deposit/manual_vn.js +182 -60
  62. package/src/machine/deposit/qrcode_cash.js +217 -0
  63. package/src/machine/deposit/qrcode_v2.js +285 -52
  64. package/src/machine/deposit/usdt.js +144 -0
  65. package/src/machine/deposit/usdt_cash.js +138 -0
  66. package/src/machine/deposit/vpay.js +359 -0
  67. package/src/machine/game_favorite_v2.js +74 -28
  68. package/src/machine/game_info.js +57 -0
  69. package/src/machine/game_search_cash.js +390 -0
  70. package/src/machine/game_search_v2.js +64 -24
  71. package/src/machine/game_v2_1.js +662 -0
  72. package/src/machine/honor_board_cash.js +63 -0
  73. package/src/machine/inbox.js +259 -34
  74. package/src/machine/index.js +22 -17
  75. package/src/machine/leaderboard.js +31 -8
  76. package/src/machine/promotions.js +171 -0
  77. package/src/machine/reward.js +74 -7
  78. package/src/machine/reward_cash.js +219 -0
  79. package/src/machine/roulette_v2.js +276 -0
  80. package/src/machine/setting.js +5 -2
  81. package/src/machine/side_cash.js +110 -0
  82. package/src/machine/side_v2.js +33 -28
  83. package/src/machine/user_photo.js +65 -0
  84. package/src/machine/user_sign_up.js +101 -17
  85. package/src/machine/withdraw/index.js +23 -0
  86. package/src/machine/{withdraw_vn.js → withdraw/withdraw_amb.js} +146 -78
  87. package/src/machine/{withdraw_crypto.js → withdraw/withdraw_crypto.js} +220 -69
  88. package/src/machine/withdraw/withdraw_crypto2.js +540 -0
  89. package/src/machine/withdraw/withdraw_crypto_cash.js +319 -0
  90. package/src/machine/{withdraw_fc.js → withdraw/withdraw_fc.js} +2 -2
  91. package/src/machine/withdraw/withdraw_krway.js +207 -0
  92. package/src/machine/withdraw/withdraw_manual.js +595 -0
  93. package/src/machine/withdraw/withdraw_manual_cash.js +303 -0
  94. package/src/machine/withdraw/withdraw_vn.js +533 -0
  95. package/src/machine/withdraw/withdraw_vn2.js +548 -0
  96. package/src/request/request.js +10 -5
  97. package/src/util/constant.js +19 -1
  98. package/src/util/deviceToken.js +18 -8
  99. package/src/util/index.js +2 -1
  100. package/src/util/math.js +4 -0
  101. package/src/util/storage.js +22 -22
  102. package/dist/bundle.mjs +0 -18462
  103. package/rollup.config.js +0 -16
  104. package/src/machine/auth_otp.js +0 -201
  105. package/src/machine/deposit/qrcode_vn.js +0 -206
  106. package/src/machine/game.js +0 -285
  107. package/src/machine/game_favorite.js +0 -123
  108. package/src/machine/game_search.js +0 -244
  109. package/src/machine/game_v2.js +0 -356
@@ -6,14 +6,15 @@ export default function (request) {
6
6
  const { appSecret } = request.config
7
7
  return createMachine(
8
8
  {
9
- id: 'affiliate_invite_friends_activity',
9
+ id: 'friend_invite_friends_activity',
10
10
  context: {
11
- affiliateEnable: false,
11
+ friendsEnable: false,
12
12
  activityNo: null,
13
13
  bindingCode: null,
14
14
  uidSite: null,
15
15
  receiveNo: null,
16
- affiliateCode: '',
16
+ friendCode: '',
17
+ bindFriendLimitDaysAfterRegistered: 0,
17
18
  commission: 0,
18
19
  downLine: 0,
19
20
  activeDownLine: 0,
@@ -21,16 +22,16 @@ export default function (request) {
21
22
  pastTable: [],
22
23
  levelDownLine: {},
23
24
  currentLevel: 1,
24
- page: 1
25
+ page: 1,
25
26
  },
26
27
  initial: 'fetching1',
27
28
  states: {
28
29
  fetching1: {
29
30
  invoke: {
30
- src: 'fetchAffiliateCode',
31
+ src: 'fetchFriendCode',
31
32
  onDone: {
32
33
  target: 'checking',
33
- actions: 'setAffiliateCode',
34
+ actions: 'setFriendsCode',
34
35
  },
35
36
  onError: {
36
37
  target: 'fetching2',
@@ -38,14 +39,11 @@ export default function (request) {
38
39
  },
39
40
  },
40
41
  checking: {
41
- always: [
42
- { target: 'fetching2', cond: 'isAffiliateEnable' },
43
- { target: 'idle' },
44
- ],
42
+ always: [{ target: 'fetching2', cond: 'isFriendsEnable' }, { target: 'idle' }],
45
43
  },
46
44
  fetching2: {
47
45
  invoke: {
48
- src: 'fetchAffiliateData',
46
+ src: 'fetchFriendsData',
49
47
  onDone: {
50
48
  target: 'idle',
51
49
  actions: 'setInitialData',
@@ -57,24 +55,29 @@ export default function (request) {
57
55
  },
58
56
  idle: {
59
57
  on: {
60
- BIND_AFFILIATE_CODE: {
58
+ BIND_FRIEND_CODE: {
61
59
  target: 'binding',
62
60
  actions: ['setBindingCode', 'setUidSite', 'setActivityNo'],
63
61
  },
64
62
  SELECT_LEVEL: {
65
63
  target: 'fetchingList',
66
- actions: 'setLevelSearch'
67
- }
68
- }
64
+ actions: ['setLevelSearch', 'reset'],
65
+ },
66
+ LOAD_DATA: {
67
+ target: 'fetchingList',
68
+ actions: 'setPage',
69
+ cond: 'isNotEnd',
70
+ },
71
+ },
69
72
  },
70
73
  binding: {
71
74
  invoke: {
72
- src: 'postAffiliate',
75
+ src: 'postFriends',
73
76
  onDone: {
74
77
  target: 'awarding',
75
78
  },
76
79
  onError: {
77
- target: 'fail',
80
+ target: 'idle',
78
81
  },
79
82
  },
80
83
  },
@@ -85,7 +88,7 @@ export default function (request) {
85
88
  target: 'bound',
86
89
  },
87
90
  onError: {
88
- target: 'fail',
91
+ target: 'idle',
89
92
  },
90
93
  },
91
94
  },
@@ -101,7 +104,7 @@ export default function (request) {
101
104
  src: 'fetchLevelDownLineList',
102
105
  onDone: {
103
106
  target: 'idle',
104
- actions: 'setLevelDownLineList'
107
+ actions: 'setLevelDownLineList',
105
108
  },
106
109
  onError: {
107
110
  target: 'idle',
@@ -113,10 +116,11 @@ export default function (request) {
113
116
  },
114
117
  {
115
118
  actions: {
116
- setAffiliateCode: assign((context, event) => {
117
- const { affiliateCode = '' } = event.data || {}
119
+ setFriendsCode: assign((context, event) => {
120
+ const { friendCode = '', bindFriendLimitDaysAfterRegistered } = event.data || {}
118
121
  return {
119
- affiliateCode
122
+ friendCode,
123
+ bindFriendLimitDaysAfterRegistered,
120
124
  }
121
125
  }),
122
126
  setInitialData: assign((context, event) => {
@@ -127,7 +131,7 @@ export default function (request) {
127
131
  downLine,
128
132
  activeDownLine,
129
133
  levelTable,
130
- pastTable
134
+ pastTable,
131
135
  }
132
136
  }),
133
137
  setBindingCode: assign((context, event) => {
@@ -146,33 +150,47 @@ export default function (request) {
146
150
  }
147
151
  }),
148
152
  setLevelSearch: assign((context, event) => {
149
- const { level, page } = event.data
153
+ const { level } = event.data
150
154
  return {
151
155
  currentLevel: level,
152
- page
156
+ }
157
+ }),
158
+ reset: assign((context, event) => {
159
+ return {
160
+ page: 1,
161
+ levelDownLine: {},
162
+ }
163
+ }),
164
+ setPage: assign((context, event) => {
165
+ return {
166
+ page: context.page + 1,
153
167
  }
154
168
  }),
155
169
  setLevelDownLineList: assign((context, event) => {
156
170
  return {
157
- levelDownLine: event.data
171
+ levelDownLine: event.data,
158
172
  }
159
- })
173
+ }),
160
174
  },
161
175
  guards: {
162
- isAffiliateEnable: (context, event) => context.affiliateEnable
176
+ isNotEnd: (context, event) => {
177
+ const { page } = context.levelDownLine
178
+ return page.current < page.total
179
+ },
180
+ isFriendsEnable: (context, event) => context.friendsEnable,
163
181
  },
164
182
  services: {
165
- fetchAffiliateCode: async () => {
166
- return await request.send(user.getAffiliate())
183
+ fetchFriendCode: async () => {
184
+ return await request.send(user.getFriends())
167
185
  },
168
- fetchAffiliateData: async (context, event) => {
169
- const affiliateHomeAPI = request.send(user.getAffiliateHome())
170
- const affiliateDashboard = request.send(user.getAffiliateDashboard())
171
- const [affiliateHomeData, affiliateDashboardData] = await Promise.all([affiliateHomeAPI, affiliateDashboard])
172
- return [affiliateHomeData, affiliateDashboardData]
186
+ fetchFriendsData: async (context, event) => {
187
+ const friendsHomeAPI = request.send(user.getFriendsHome())
188
+ const friendsDashboard = request.send(user.getFriendsDashboard())
189
+ const [friendsHomeData, friendsDashboardData] = await Promise.all([friendsHomeAPI, friendsDashboard])
190
+ return [friendsHomeData, friendsDashboardData]
173
191
  },
174
- postAffiliate: async (context, event) => {
175
- return await request.send(user.postAffiliate({ affiliateCode: context.bindingCode }))
192
+ postFriends: async (context, event) => {
193
+ return await request.send(user.postFriends({ friendCode: context.bindingCode }))
176
194
  },
177
195
  awardPrize: async (context, event) => {
178
196
  const { activityNo, uidSite, bindingCode } = context
@@ -180,10 +198,21 @@ export default function (request) {
180
198
  return data
181
199
  },
182
200
  fetchLevelDownLineList: async (context, event) => {
183
- const { currentLevel, page } = context
184
- return await request.send(user.getAffiliateDashboardList({ level: currentLevel, page, row: 10 }))
185
- }
201
+ const { currentLevel, page, levelDownLine } = context
202
+ const copiedObj = JSON.parse(JSON.stringify(levelDownLine))
203
+ const copiedList = copiedObj.data
204
+ const resopnseData = await request.send(user.getFriendsDashboardList({ level: currentLevel, page, row: 10 }))
205
+ if (!!copiedList && !!resopnseData?.data) {
206
+ const combindData = {
207
+ ...resopnseData,
208
+ data: [...copiedList, ...resopnseData?.data],
209
+ }
210
+ return combindData
211
+ } else {
212
+ return resopnseData
213
+ }
214
+ },
186
215
  },
187
216
  }
188
217
  )
189
- }
218
+ }
@@ -1,10 +1,14 @@
1
+ import activity from './activity.js'
2
+ import activity_cash from './activity_cash.js'
1
3
  import continue_deposit_activity from './continue_deposit_activity.js'
2
4
  import deposit_activity from './deposit_activity.js'
3
5
  import diamond_shop_activity_fc from './diamond_shop_activity_fc.js'
4
6
  import diamond_shop_activity_vn from './diamond_shop_activity_vn.js'
7
+ import diamond_shop_activity_cash from './diamond_shop_activity_cash.js'
5
8
  import fafafa_activity from './fafafa_activity.js'
6
9
  import invite_friends_activity from './invite_friends_activity.js'
7
- import affiliate_invite_friends_activity from './affiliate_invite_friends_activity.js'
10
+ import jackpot from './jackpot.js'
11
+ import friend_invite_friends_activity from './friend_invite_friends_activity.js'
8
12
  import ranking_activity from './ranking_activity.js'
9
13
  import return_bonus_activity from './return_bonus_activity.js'
10
14
  import specify_bets_activity from './specify_bets_activity.js'
@@ -12,16 +16,25 @@ import specify_turnover_activity from './specify_turnover_activity.js'
12
16
  import sign_in_activity from './sign_in_activity.js'
13
17
  import time_bomb_activity from './time_bomb_activity.js'
14
18
  import mini_game_activity from './mini_game_activity.js'
15
- import activity from './activity.js'
19
+ import roulette_activity_v2 from './roulette_activity_v2.js'
20
+ import sign_in_monthly_activity from './sign_in_monthly_activity.js'
21
+ import otp_verified_activity from './otp_verified_activity.js'
22
+ import vip_card_activity from './vip_card_activity.js'
23
+ import instant_rebate_activity from './instant_rebate_activity.js'
24
+ import cash_rain_activity from './cash_rain_activity.js'
16
25
 
17
26
  export default {
27
+ activity,
28
+ activity_cash,
18
29
  continue_deposit_activity,
19
30
  deposit_activity,
20
31
  diamond_shop_activity_fc,
21
32
  diamond_shop_activity_vn,
33
+ diamond_shop_activity_cash,
22
34
  fafafa_activity,
23
35
  invite_friends_activity,
24
- affiliate_invite_friends_activity,
36
+ jackpot,
37
+ friend_invite_friends_activity,
25
38
  ranking_activity,
26
39
  return_bonus_activity,
27
40
  specify_bets_activity,
@@ -29,5 +42,10 @@ export default {
29
42
  sign_in_activity,
30
43
  time_bomb_activity,
31
44
  mini_game_activity,
32
- activity,
45
+ roulette_activity_v2,
46
+ sign_in_monthly_activity,
47
+ otp_verified_activity,
48
+ vip_card_activity,
49
+ instant_rebate_activity,
50
+ cash_rain_activity,
33
51
  }
@@ -0,0 +1,217 @@
1
+ import { assign, createMachine } from 'xstate'
2
+ import api from '../../api/activity.js'
3
+
4
+ export default function (request) {
5
+ return createMachine(
6
+ {
7
+ id: 'instant_rebate_activity',
8
+ context: {
9
+ enableCollectButton: false,
10
+ lastCollectTime: null,
11
+ lastEstimateTime: null,
12
+ collectAvailable: false,
13
+ settlementTime: null,
14
+ validTurnover: null,
15
+ rebateAmount: null,
16
+ rewardType: null,
17
+ singleMinimumAmountReceive: null,
18
+ remainingCount: 0,
19
+ dailyRedemptionLimit: 0,
20
+ collectAmount: 0,
21
+ activityNo: null,
22
+ },
23
+ initial: 'idle',
24
+ states: {
25
+ idle: {
26
+ on: {
27
+ SET_ACTIVITY_NO: {
28
+ target: 'loading',
29
+ actions: 'setActivityNo',
30
+ },
31
+ },
32
+ },
33
+ loading: {
34
+ invoke: {
35
+ src: 'fetchCollectTime',
36
+ onDone: {
37
+ target: 'pending',
38
+ actions: 'setInitData',
39
+ },
40
+ onError: {
41
+ target: 'fail',
42
+ },
43
+ },
44
+ },
45
+ pending: {
46
+ always: [{ target: 'loaded', cond: 'isEstimatable' }, { target: 'cantEstimate' }],
47
+ },
48
+ loaded: {
49
+ on: {
50
+ ESTIMATE: {
51
+ target: 'estimating',
52
+ },
53
+ },
54
+ },
55
+ cantEstimate: {},
56
+ estimating: {
57
+ invoke: {
58
+ src: 'estimate',
59
+ onDone: {
60
+ target: 'estimated',
61
+ actions: 'setEstimateResult',
62
+ },
63
+ onError: {
64
+ target: 'loaded',
65
+ },
66
+ },
67
+ },
68
+ estimated: {
69
+ after: {
70
+ 0: {
71
+ target: 'checking',
72
+ },
73
+ },
74
+ },
75
+ checking: {
76
+ always: [
77
+ { target: 'claimExhausted', cond: 'isClaimExhausted' },
78
+ { target: 'insufficientAmount', cond: 'isInsufficientAmount' },
79
+ { target: 'claimEnable', cond: 'isClaimEnable' },
80
+ { target: 'cantEstimate' },
81
+ ],
82
+ },
83
+ claimExhausted: {},
84
+ insufficientAmount: {},
85
+ claimEnable: {
86
+ on: {
87
+ CLAIM: {
88
+ target: 'claiming',
89
+ },
90
+ },
91
+ },
92
+ claiming: {
93
+ invoke: {
94
+ src: 'claimRebateAmount',
95
+ onDone: {
96
+ target: 'claimed',
97
+ },
98
+ onError: {
99
+ target: 'fail',
100
+ },
101
+ },
102
+ },
103
+ claimed: {},
104
+ fail: {},
105
+ },
106
+ on: {
107
+ START: {
108
+ target: '.loading',
109
+ },
110
+ STOP: {
111
+ target: '.idle',
112
+ },
113
+ },
114
+ },
115
+ {
116
+ actions: {
117
+ setActivityNo: assign((context, event) => {
118
+ return {
119
+ activityNo: event.data,
120
+ }
121
+ }),
122
+ setInitData: assign((context, event) => {
123
+ const { enableCollectButton = false, lastCollectTime = 0, lastEstimateTime = 0, rewardType } = event.data
124
+ return { enableCollectButton, lastCollectTime, lastEstimateTime, rewardType }
125
+ }),
126
+ setEstimateResult: assign((context, event) => {
127
+ const {
128
+ lastCollectTime = 0,
129
+ collectAvailable = false,
130
+ settlementTime = 0,
131
+ validTurnover = '0',
132
+ rebateAmount = '0',
133
+ rewardType = null,
134
+ singleMinimumAmountReceive = 0,
135
+ remainingCount = 0,
136
+ dailyRedemptionLimit = 0,
137
+ } = event.data
138
+
139
+ return {
140
+ lastCollectTime,
141
+ collectAvailable,
142
+ settlementTime,
143
+ validTurnover,
144
+ rebateAmount,
145
+ rewardType,
146
+ singleMinimumAmountReceive,
147
+ remainingCount,
148
+ dailyRedemptionLimit,
149
+ }
150
+ }),
151
+ },
152
+ guards: {
153
+ isEstimatable: (context, event) => {
154
+ const { lastCollectTime, lastEstimateTime } = context
155
+ if (lastCollectTime === lastEstimateTime) {
156
+ return true
157
+ } else {
158
+ const fiveMinutes = 60 * 5
159
+ const currentTime = new Date().getTime() / 1000
160
+
161
+ return parseInt(`${currentTime}`) - parseInt(`${lastEstimateTime}`) > fiveMinutes
162
+ }
163
+ },
164
+ isClaimExhausted: (context, event) => {
165
+ const { collectAvailable, remainingCount, dailyRedemptionLimit } = context
166
+ return !collectAvailable && parseInt(`${remainingCount}`) === parseInt(`${dailyRedemptionLimit}`)
167
+ },
168
+ isInsufficientAmount: (context, event) => {
169
+ const { collectAvailable, singleMinimumAmountReceive, rebateAmount } = context
170
+ let splitArray = rebateAmount?.split(',')
171
+ let combindString = '0'
172
+ if (splitArray?.length > 0) {
173
+ splitArray.forEach((item) => {
174
+ combindString += item
175
+ })
176
+ } else {
177
+ combindString = rebateAmount
178
+ }
179
+ const deformatRebateAmount = parseFloat(`${combindString}`)
180
+ return !collectAvailable && deformatRebateAmount < parseFloat(`${singleMinimumAmountReceive}`)
181
+ },
182
+ isClaimEnable: (context, event) => {
183
+ const { collectAvailable, remainingCount, dailyRedemptionLimit, rebateAmount, singleMinimumAmountReceive } = context
184
+ let splitArray = rebateAmount?.split(',')
185
+ let combindString = '0'
186
+ if (splitArray?.length > 0) {
187
+ splitArray.forEach((item) => {
188
+ combindString += item
189
+ })
190
+ } else {
191
+ combindString = rebateAmount
192
+ }
193
+ const deformatRebateAmount = parseFloat(combindString)
194
+ return (
195
+ collectAvailable &&
196
+ parseInt(`${remainingCount}`) < parseInt(`${dailyRedemptionLimit}`) &&
197
+ deformatRebateAmount >= parseFloat(`${singleMinimumAmountReceive}`)
198
+ )
199
+ },
200
+ },
201
+ services: {
202
+ fetchCollectTime: async (context, event) => {
203
+ const { data } = await request.send(api.getInstantRebateCollectTime())
204
+ return data
205
+ },
206
+ estimate: async (context, event) => {
207
+ const { data } = await request.send(api.instantRebateEstimate())
208
+ return data
209
+ },
210
+ claimRebateAmount: async (context, event) => {
211
+ const { data } = await request.send(api.instantRebateCollect())
212
+ return data
213
+ },
214
+ },
215
+ }
216
+ )
217
+ }
@@ -12,17 +12,17 @@ export default function (request) {
12
12
  bindingCode: null,
13
13
  uidSite: null,
14
14
  receiveNo: null,
15
- affiliateCode: null,
15
+ friendCode: null,
16
16
  downlineCount: 0,
17
17
  },
18
18
  initial: 'idle',
19
19
  states: {
20
20
  idle: {
21
21
  on: {
22
- FETCH_AFFILIATE_CODE: {
22
+ FETCH_FRIEND_CODE: {
23
23
  target: 'fetching',
24
24
  },
25
- BIND_AFFILIATE_CODE: {
25
+ BIND_FRIEND_CODE: {
26
26
  target: 'binding',
27
27
  actions: ['setActivityNo', 'setBindingCode', 'setUidSite'],
28
28
  },
@@ -30,10 +30,10 @@ export default function (request) {
30
30
  },
31
31
  fetching: {
32
32
  invoke: {
33
- src: 'fetchAffiliate',
33
+ src: 'fetchFriends',
34
34
  onDone: {
35
35
  target: 'idle',
36
- actions: 'setAffiliateCode',
36
+ actions: 'setFriendCode',
37
37
  },
38
38
  onError: {
39
39
  target: 'idle',
@@ -42,7 +42,7 @@ export default function (request) {
42
42
  },
43
43
  binding: {
44
44
  invoke: {
45
- src: 'postAffiliate',
45
+ src: 'postFriends',
46
46
  onDone: {
47
47
  target: 'awarding',
48
48
  },
@@ -73,10 +73,10 @@ export default function (request) {
73
73
  },
74
74
  {
75
75
  actions: {
76
- setAffiliateCode: assign((context, event) => {
77
- const { affiliateCode, downlineCount } = event.data
76
+ setFriendCode: assign((context, event) => {
77
+ const { friendCode, downlineCount } = event.data
78
78
  return {
79
- affiliateCode,
79
+ friendCode,
80
80
  downlineCount,
81
81
  }
82
82
  }),
@@ -97,11 +97,11 @@ export default function (request) {
97
97
  }),
98
98
  },
99
99
  services: {
100
- postAffiliate: async (context, event) => {
101
- return await request.send(user.postAffiliate({ affiliateCode: context.bindingCode }))
100
+ postFriends: async (context, event) => {
101
+ return await request.send(user.postFriends({ friendCode: context.bindingCode }))
102
102
  },
103
- fetchAffiliate: async (context, event) => {
104
- return await request.send(user.getAffiliate())
103
+ fetchFriends: async (context, event) => {
104
+ return await request.send(user.getFriends())
105
105
  },
106
106
  awardPrize: async (context, event) => {
107
107
  const { activityNo, uidSite, bindingCode } = context
@@ -111,4 +111,4 @@ export default function (request) {
111
111
  },
112
112
  }
113
113
  )
114
- }
114
+ }
@@ -0,0 +1,74 @@
1
+ import { createMachine, assign } from 'xstate'
2
+ import activity from '../../api/activity.js'
3
+
4
+ export default function (request) {
5
+ const { appSecret } = request.config
6
+ return createMachine(
7
+ {
8
+ id: 'jackpot',
9
+ initial: 'pending',
10
+ context: {
11
+ tick: 6000,
12
+ jackpotList: [],
13
+ jackpotEnable: false,
14
+ },
15
+ states: {
16
+ fetchingList: {
17
+ invoke: {
18
+ src: 'fetchList',
19
+ onDone: {
20
+ target: 'pending',
21
+ actions: ['setJackpotList'],
22
+ },
23
+ onError: {
24
+ target: 'pending',
25
+ },
26
+ },
27
+ },
28
+ pending: {
29
+ after: {
30
+ TIMEOUT: {
31
+ target: 'fetchingList',
32
+ },
33
+ },
34
+ on: {
35
+ SET_JACKPOT_ENABLE: {
36
+ actions: 'setJackpotEnable',
37
+ target: 'fetchingList',
38
+ },
39
+ },
40
+ },
41
+ },
42
+ },
43
+ {
44
+ actions: {
45
+ setJackpotList: assign((context, event) => {
46
+ const { jackpotList } = event.data
47
+ return {
48
+ jackpotList,
49
+ }
50
+ }),
51
+ setJackpotEnable: assign((context, event) => {
52
+ return {
53
+ jackpotEnable: event.data,
54
+ }
55
+ }),
56
+ },
57
+ delays: {
58
+ TIMEOUT: (context, event) => {
59
+ const { tick } = context
60
+ return tick * 10
61
+ },
62
+ },
63
+ services: {
64
+ fetchList: async (context, event) => {
65
+ const { jackpotEnable } = context
66
+
67
+ const [jackpotList] = await Promise.all([jackpotEnable ? request.send(activity.getJackpotList({ appSecret })) : { data: [] }])
68
+
69
+ return { jackpotList: jackpotList.data }
70
+ },
71
+ },
72
+ }
73
+ )
74
+ }