@jetthai/cuora 1.1.306 → 1.1.307-dev-2

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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [1.1.307-dev-2](https://github.com/jetthai/cuora-module/compare/v1.0.307-dev-2...v1.1.307-dev-2) (2024-09-19)
6
+
7
+ ### [1.0.307-dev-2](https://github.com/jetthai/cuora-module/compare/v1.1.307-dev-1...v1.0.307-dev-2) (2024-09-19)
8
+
9
+ ### [1.1.307-dev-1](https://github.com/jetthai/cuora-module/compare/v1.1.307...v1.1.307-dev-1) (2024-09-18)
10
+
11
+ ### [1.1.307](https://github.com/jetthai/cuora-module/compare/v1.1.306...v1.1.307) (2024-09-16)
12
+
5
13
  ### [1.1.306](https://github.com/jetthai/cuora-module/compare/v1.1.305...v1.1.306) (2024-09-16)
6
14
 
7
15
  ### [1.1.305](https://github.com/jetthai/cuora-module/compare/v1.1.304...v1.1.305) (2024-09-09)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.1.306",
3
+ "version": "1.1.307-dev-2",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
@@ -87,7 +87,7 @@ export default {
87
87
  exchangeAward,
88
88
  },
89
89
  }),
90
- getHonorBoard: (appSecret) => ({ url: 'activities/honorBoard', method: 'get', params: { appSecret }, isPublic: true }),
90
+ getHonorBroadcast: (appSecret) => ({ url: 'activities/honorBroadcast', method: 'get', params: { appSecret }, isPublic: true }),
91
91
  getInstantRebateCollectTime: () => ({ url: 'activities/rebate/collectTime', method: 'get' }),
92
92
  instantRebateEstimate: () => ({ url: 'activities/rebate/estimate', method: 'get' }),
93
93
  instantRebateCollect: () => ({ url: 'activities/rebate/collect', method: 'get' }),
@@ -6,80 +6,56 @@ export default function (request) {
6
6
  {
7
7
  id: 'instant_rebate_activity',
8
8
  context: {
9
- enableCollectButton: false,
9
+ showColletButton: false,
10
+ estimateStartTime: null,
11
+ estimateEndTime: null,
10
12
  lastCollectTime: null,
11
13
  lastEstimateTime: null,
12
14
  collectAvailable: false,
13
- settlementTime: null,
14
- validTurnover: null,
15
- rebateAmount: null,
15
+ cumulativeValidTurnover: null,
16
+ cumulativeRebateAmount: null,
17
+ actualRebateAmount: null,
16
18
  rewardType: null,
17
19
  singleMinimumAmountReceive: null,
18
20
  remainingCount: 0,
19
21
  dailyRedemptionLimit: 0,
20
- collectAmount: 0,
22
+ reachedAmountLimit: false,
21
23
  activityNo: null,
24
+ claimResultData: null,
22
25
  },
23
26
  initial: 'idle',
24
27
  states: {
25
28
  idle: {
26
29
  on: {
27
30
  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
31
  target: 'estimating',
32
+ actions: 'setActivityNo',
52
33
  },
53
34
  },
54
35
  },
55
- cantEstimate: {},
56
36
  estimating: {
57
37
  invoke: {
58
38
  src: 'estimate',
59
39
  onDone: {
60
- target: 'estimated',
40
+ target: 'checking',
61
41
  actions: 'setEstimateResult',
62
42
  },
63
43
  onError: {
64
- target: 'loaded',
65
- },
66
- },
67
- },
68
- estimated: {
69
- after: {
70
- 0: {
71
- target: 'checking',
44
+ target: 'fail',
72
45
  },
73
46
  },
74
47
  },
75
48
  checking: {
76
49
  always: [
50
+ { target: 'claimAmountLimitReached', cond: 'isClaimAmountLimitReached' },
77
51
  { target: 'claimExhausted', cond: 'isClaimExhausted' },
78
52
  { target: 'insufficientAmount', cond: 'isInsufficientAmount' },
79
53
  { target: 'claimEnable', cond: 'isClaimEnable' },
80
- { target: 'cantEstimate' },
54
+ { target: 'pending' },
81
55
  ],
82
56
  },
57
+ pending: {},
58
+ claimAmountLimitReached: {},
83
59
  claimExhausted: {},
84
60
  insufficientAmount: {},
85
61
  claimEnable: {
@@ -93,19 +69,33 @@ export default function (request) {
93
69
  invoke: {
94
70
  src: 'claimRebateAmount',
95
71
  onDone: {
96
- target: 'claimed',
72
+ target: 'checkClaimStatus',
73
+ actions: 'setClaimesult',
97
74
  },
98
75
  onError: {
99
76
  target: 'fail',
100
77
  },
101
78
  },
102
79
  },
80
+ checkClaimStatus: {
81
+ always: [{ target: 'claimed', cond: 'isClaimSuccess' }, { target: 'claimFail' }],
82
+ },
83
+ claimFail: {
84
+ after: {
85
+ 0: {
86
+ target: 'claimEnable',
87
+ },
88
+ },
89
+ },
103
90
  claimed: {},
104
91
  fail: {},
105
92
  },
106
93
  on: {
94
+ ESTIMATE: {
95
+ target: '.estimating',
96
+ },
107
97
  START: {
108
- target: '.loading',
98
+ target: '.estimating',
109
99
  },
110
100
  STOP: {
111
101
  target: '.idle',
@@ -119,90 +109,78 @@ export default function (request) {
119
109
  activityNo: event.data,
120
110
  }
121
111
  }),
122
- setInitData: assign((context, event) => {
123
- const { enableCollectButton = false, lastCollectTime = 0, lastEstimateTime = 0, rewardType } = event.data
124
- return { enableCollectButton, lastCollectTime, lastEstimateTime, rewardType }
125
- }),
126
112
  setEstimateResult: assign((context, event) => {
127
113
  const {
114
+ showColletButton = false,
115
+ estimateStartTime = 0,
116
+ estimateEndTime = 0,
128
117
  lastCollectTime = 0,
129
118
  collectAvailable = false,
130
- settlementTime = 0,
131
- validTurnover = '0',
132
- rebateAmount = '0',
119
+ cumulativeValidTurnover = '0',
120
+ cumulativeRebateAmount = '0',
121
+ actualRebateAmount = '0',
133
122
  rewardType = null,
134
123
  singleMinimumAmountReceive = 0,
135
124
  remainingCount = 0,
136
125
  dailyRedemptionLimit = 0,
126
+ reachedAmountLimit = false,
137
127
  } = event.data
138
128
 
139
129
  return {
130
+ showColletButton,
131
+ estimateStartTime,
132
+ estimateEndTime,
140
133
  lastCollectTime,
141
134
  collectAvailable,
142
- settlementTime,
143
- validTurnover,
144
- rebateAmount,
135
+ cumulativeValidTurnover,
136
+ cumulativeRebateAmount,
137
+ actualRebateAmount,
145
138
  rewardType,
146
139
  singleMinimumAmountReceive,
147
140
  remainingCount,
148
141
  dailyRedemptionLimit,
142
+ reachedAmountLimit,
143
+ }
144
+ }),
145
+ setClaimesult: assign((context, event) => {
146
+ return {
147
+ claimResultData: event.data,
149
148
  }
150
149
  }),
151
150
  },
152
151
  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
- }
152
+ isClaimAmountLimitReached: (context, event) => {
153
+ const { collectAvailable, reachedAmountLimit } = context
154
+ return !collectAvailable && reachedAmountLimit
163
155
  },
164
156
  isClaimExhausted: (context, event) => {
165
157
  const { collectAvailable, remainingCount, dailyRedemptionLimit } = context
166
158
  return !collectAvailable && parseInt(`${remainingCount}`) === parseInt(`${dailyRedemptionLimit}`)
167
159
  },
168
160
  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}`)
161
+ const { collectAvailable, singleMinimumAmountReceive, actualRebateAmount } = context
162
+ const formattedSingleMinimumAmountReceive = parseFloat(singleMinimumAmountReceive.replace(/,/g, ''))
163
+ const formattedActualRebateAmount = parseFloat(actualRebateAmount.replace(/,/g, ''))
164
+
165
+ return !collectAvailable && parseFloat(`${formattedActualRebateAmount}`) < parseFloat(`${formattedSingleMinimumAmountReceive}`)
181
166
  },
182
167
  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)
168
+ const { collectAvailable, remainingCount, dailyRedemptionLimit, actualRebateAmount, singleMinimumAmountReceive } = context
169
+ const formattedSingleMinimumAmountReceive = parseFloat(singleMinimumAmountReceive.replace(/,/g, ''))
170
+ const formattedActualRebateAmount = parseFloat(actualRebateAmount.replace(/,/g, ''))
171
+
194
172
  return (
195
173
  collectAvailable &&
196
174
  parseInt(`${remainingCount}`) < parseInt(`${dailyRedemptionLimit}`) &&
197
- deformatRebateAmount >= parseFloat(`${singleMinimumAmountReceive}`)
175
+ parseFloat(`${formattedActualRebateAmount}`) >= parseFloat(`${formattedSingleMinimumAmountReceive}`)
198
176
  )
199
177
  },
178
+ isClaimSuccess: (context, event) => {
179
+ const { claimResultData } = context
180
+ return claimResultData?.result === 'success'
181
+ },
200
182
  },
201
183
  services: {
202
- fetchCollectTime: async (context, event) => {
203
- const { data } = await request.send(api.getInstantRebateCollectTime())
204
- return data
205
- },
206
184
  estimate: async (context, event) => {
207
185
  const { data } = await request.send(api.instantRebateEstimate())
208
186
  return data
@@ -0,0 +1,118 @@
1
+ import { assign, createMachine } 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: 'honor_board',
9
+ type: 'parallel',
10
+ context: {
11
+ tick: 6000,
12
+ },
13
+ states: {
14
+ feed: {
15
+ initial: 'updating',
16
+ states: {
17
+ updating: {
18
+ invoke: {
19
+ src: 'fetchHonorBoardList',
20
+ onDone: {
21
+ target: 'waiting',
22
+ actions: 'setBroadcastList',
23
+ },
24
+ onError: {
25
+ target: 'waiting',
26
+ },
27
+ },
28
+ },
29
+ waiting: {
30
+ after: {
31
+ TIMEOUT: {
32
+ target: 'updating',
33
+ },
34
+ },
35
+ },
36
+ },
37
+ },
38
+ broadcast: {
39
+ initial: 'idle',
40
+ states: {
41
+ idle: {
42
+ on: {
43
+ START_BROADCAST: {
44
+ target: 'picking',
45
+ },
46
+ },
47
+ },
48
+ picking: {
49
+ after: {
50
+ 5000: {
51
+ target: 'display',
52
+ actions: 'setBroadcast',
53
+ },
54
+ },
55
+ },
56
+ display: {
57
+ after: {
58
+ 5000: {
59
+ target: 'picking',
60
+ },
61
+ },
62
+ },
63
+ },
64
+ on: {
65
+ RESET_BROADCAST: {
66
+ target: '.idle',
67
+ actions: 'resetBroadcast',
68
+ },
69
+ },
70
+ },
71
+ },
72
+ },
73
+ {
74
+ delays: {
75
+ TIMEOUT: (context, event) => {
76
+ return context.tick * 10
77
+ },
78
+ },
79
+ actions: {
80
+ setBroadcastList: assign((context, event) => {
81
+ const broadcastList = (event.data || []).map((item) => item.data).flat()
82
+ const sortBroadcastList = broadcastList.sort((a, b) => {
83
+ if (!a.time) return -1
84
+ if (!b.time) return 1
85
+ return a.time - b.time
86
+ })
87
+ return { broadcastList: sortBroadcastList }
88
+ }),
89
+ setBroadcast: assign((context, event) => {
90
+ const { broadcastList = [], sentNormalBroadcastList = [], normalBroadcast = [] } = context
91
+ let sentNormalList = sentNormalBroadcastList
92
+ if (normalBroadcast) {
93
+ sentNormalList = [...sentNormalBroadcastList, normalBroadcast]
94
+ }
95
+ const nextNormalBroadcast = broadcastList?.find((broadcast) => {
96
+ return !sentNormalList.some((item) => item.broadcastId === broadcast.broadcastId)
97
+ })
98
+ return {
99
+ normalBroadcast: nextNormalBroadcast,
100
+ sentNormalBroadcastList: sentNormalList,
101
+ }
102
+ }),
103
+ resetBroadcast: assign((context, event) => {
104
+ return {
105
+ normalBroadcast: null,
106
+ sentNormalBroadcastList: [],
107
+ }
108
+ }),
109
+ },
110
+ services: {
111
+ fetchHonorBoardList: async (context, event) => {
112
+ const { data } = await request.send(activity.getHonorBroadcast(appSecret))
113
+ return data
114
+ },
115
+ },
116
+ }
117
+ )
118
+ }
@@ -9,9 +9,14 @@ export default function (request) {
9
9
  initial: 'fetching',
10
10
  context: {
11
11
  tick: 6000,
12
- bigWinList: [],
13
- maxBetList: [],
14
- withdrawList: [],
12
+ tabs: [],
13
+ cashRain: {},
14
+ deposit: {},
15
+ roulette: {},
16
+ jackpot: {},
17
+ bigWin: {},
18
+ maxBet: {},
19
+ withdraw: {},
15
20
  },
16
21
  states: {
17
22
  fetching: {
@@ -38,11 +43,32 @@ export default function (request) {
38
43
  {
39
44
  actions: {
40
45
  setHonorBoardList: assign((context, event) => {
41
- const { bigWinList = [], maxBetList = [], withdrawList = [] } = event.data
42
46
  return {
43
- bigWinList,
44
- maxBetList,
45
- withdrawList,
47
+ tabs: (event.data || []).map((list) => {
48
+ switch (list.type) {
49
+ case 'CASH_RAIN':
50
+ return 'cashRain'
51
+ case 'DEPOSIT':
52
+ return 'deposit'
53
+ case 'FREE_ROULETTE_SPIN':
54
+ return 'roulette'
55
+ case 'JACKPOT':
56
+ return 'jackpot'
57
+ case 'WIN_SCORE':
58
+ return 'bigWin'
59
+ case 'WIN_MULTIPLIER':
60
+ return 'maxBet'
61
+ case 'WITHDRAW':
62
+ return 'withdraw'
63
+ }
64
+ }),
65
+ cashRain: (event.data || []).find((item) => item.type === 'CASH_RAIN') || {},
66
+ deposit: (event.data || []).find((item) => item.type === 'DEPOSIT') || {},
67
+ roulette: (event.data || []).find((item) => item.type === 'FREE_ROULETTE_SPIN') || {},
68
+ jackpot: (event.data || []).find((item) => item.type === 'JACKPOT') || {},
69
+ bigWin: (event.data || []).find((item) => item.type === 'WIN_SCORE') || {},
70
+ maxBet: (event.data || []).find((item) => item.type === 'WIN_MULTIPLIER') || {},
71
+ withdraw: (event.data || []).find((item) => item.type === 'WITHDRAW') || {},
46
72
  }
47
73
  }),
48
74
  },
@@ -54,7 +80,7 @@ export default function (request) {
54
80
  },
55
81
  services: {
56
82
  fetchHonorBoardList: async (context, event) => {
57
- const { data } = await request.send(activity.getHonorBoard(appSecret))
83
+ const { data } = await request.send(activity.getHonorBroadcast(appSecret))
58
84
  return data
59
85
  },
60
86
  },
@@ -34,6 +34,7 @@ import vip_table from './vip_table.js'
34
34
  import promotions from './promotions.js'
35
35
  import roulette_v2 from './roulette_v2.js'
36
36
  import honor_board_cash from './honor_board_cash.js'
37
+ import honor_board from './honor_board.js'
37
38
  import user_photo from './user_photo.js'
38
39
  import navbar from './navbar.js'
39
40
 
@@ -73,6 +74,7 @@ export default {
73
74
  promotions,
74
75
  roulette_v2,
75
76
  honor_board_cash,
77
+ honor_board,
76
78
  user_photo,
77
79
  navbar,
78
80
  ...withdraw,
@@ -66,6 +66,15 @@ export default function (request) {
66
66
  }
67
67
  }),
68
68
  },
69
+ {
70
+ target: 'passWithdrawCooldownTime',
71
+ cond: 'isPassWithdrawCooldownTime',
72
+ actions: assign((context, event) => {
73
+ return {
74
+ withdrawCheck: event.data,
75
+ }
76
+ }),
77
+ },
69
78
  {
70
79
  target: 'notWithdrawable',
71
80
  cond: 'isNotWithdrawable',
@@ -80,6 +89,7 @@ export default function (request) {
80
89
  },
81
90
  },
82
91
  notWithdrawMinDepositAmount: {},
92
+ passWithdrawCooldownTime: {},
83
93
  inProcessing: {},
84
94
  notWithdrawable: {},
85
95
  withdrawable: {
@@ -170,7 +180,10 @@ export default function (request) {
170
180
  return !enableWithdraw || balance < minWithdrawAmount
171
181
  },
172
182
  isNotWithdrawMinDepositAmount: (context, event) => {
173
- return !event.data?.enableWithdraw
183
+ return !event.data?.passDepositeLimit
184
+ },
185
+ isPassWithdrawCooldownTime: (context, event) => {
186
+ return !event.data?.passWithdrawCooldownTime
174
187
  },
175
188
  },
176
189
  services: {
@@ -168,6 +168,7 @@ export default function (request) {
168
168
  invoke: {
169
169
  src: 'withdrawCheck',
170
170
  onDone: [
171
+ // 提款最低存款金額
171
172
  {
172
173
  target: 'notWithdrawMinDepositAmount',
173
174
  cond: 'isNotWithdrawMinDepositAmount',
@@ -177,6 +178,16 @@ export default function (request) {
177
178
  }
178
179
  }),
179
180
  },
181
+ // 提款冷卻時間
182
+ {
183
+ target: 'passWithdrawCooldownTime',
184
+ cond: 'isPassWithdrawCooldownTime',
185
+ actions: assign((context, event) => {
186
+ return {
187
+ withdrawCheck: event.data,
188
+ }
189
+ }),
190
+ },
180
191
  {
181
192
  target: 'notWithdrawable',
182
193
  cond: 'isNotWithdrawable',
@@ -191,6 +202,7 @@ export default function (request) {
191
202
  },
192
203
  },
193
204
  notWithdrawMinDepositAmount: {},
205
+ passWithdrawCooldownTime: {},
194
206
  notWithdrawable: {},
195
207
  unbound: {
196
208
  // to bank_binding.js
@@ -513,7 +525,10 @@ export default function (request) {
513
525
  return event.data?.status === 'otp-verifying'
514
526
  },
515
527
  isNotWithdrawMinDepositAmount: (context, event) => {
516
- return !event.data?.enableWithdraw
528
+ return !event.data?.passDepositeLimit
529
+ },
530
+ isPassWithdrawCooldownTime: (context, event) => {
531
+ return !event.data?.passWithdrawCooldownTime
517
532
  },
518
533
  },
519
534
  services: {
@@ -150,6 +150,15 @@ export default function (request) {
150
150
  }
151
151
  }),
152
152
  },
153
+ {
154
+ target: 'passWithdrawCooldownTime',
155
+ cond: 'isPassWithdrawCooldownTime',
156
+ actions: assign((context, event) => {
157
+ return {
158
+ withdrawCheck: event.data,
159
+ }
160
+ }),
161
+ },
153
162
  {
154
163
  target: 'notWithdrawable',
155
164
  cond: 'isNotWithdrawable',
@@ -164,6 +173,7 @@ export default function (request) {
164
173
  },
165
174
  },
166
175
  notWithdrawMinDepositAmount: {},
176
+ passWithdrawCooldownTime: {},
167
177
  notWithdrawable: {},
168
178
  unbound: {
169
179
  // to bank_binding.js
@@ -449,7 +459,10 @@ export default function (request) {
449
459
  },
450
460
  isNewWalletMode: (context, event) => context.siteConfig.walletMode > 0,
451
461
  isNotWithdrawMinDepositAmount: (context, event) => {
452
- return !event.data?.enableWithdraw
462
+ return !event.data?.passDepositeLimit
463
+ },
464
+ isPassWithdrawCooldownTime: (context, event) => {
465
+ return !event.data?.passWithdrawCooldownTime
453
466
  },
454
467
  },
455
468
  services: {
@@ -178,6 +178,15 @@ export default function (request) {
178
178
  }
179
179
  }),
180
180
  },
181
+ {
182
+ target: 'passWithdrawCooldownTime',
183
+ cond: 'isPassWithdrawCooldownTime',
184
+ actions: assign((context, event) => {
185
+ return {
186
+ withdrawCheck: event.data,
187
+ }
188
+ }),
189
+ },
181
190
  {
182
191
  target: 'notWithdrawable',
183
192
  cond: 'isNotWithdrawable',
@@ -192,6 +201,7 @@ export default function (request) {
192
201
  },
193
202
  },
194
203
  notWithdrawMinDepositAmount: {},
204
+ passWithdrawCooldownTime: {},
195
205
  notWithdrawable: {},
196
206
  unbound: {
197
207
  // to bank_binding.js
@@ -474,7 +484,10 @@ export default function (request) {
474
484
  return event.data?.status === 'otp-verifying'
475
485
  },
476
486
  isNotWithdrawMinDepositAmount: (context, event) => {
477
- return !event.data?.enableWithdraw
487
+ return !event.data?.passDepositeLimit
488
+ },
489
+ isPassWithdrawCooldownTime: (context, event) => {
490
+ return !event.data?.passWithdrawCooldownTime
478
491
  },
479
492
  },
480
493
  services: {