@jetthai/cuora 1.1.346-wallet-1 → 1.1.346

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,22 +2,6 @@
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.346-wallet-1](https://github.com/jetthai/cuora-module/compare/v1.1.353...v1.1.346-wallet-1) (2025-04-10)
6
-
7
- ### [1.1.353](https://github.com/jetthai/cuora-module/compare/v1.1.352...v1.1.353) (2025-04-02)
8
-
9
- ### [1.1.352](https://github.com/jetthai/cuora-module/compare/v1.1.351...v1.1.352) (2025-04-02)
10
-
11
- ### [1.1.351](https://github.com/jetthai/cuora-module/compare/v1.1.350...v1.1.351) (2025-04-02)
12
-
13
- ### [1.1.350](https://github.com/jetthai/cuora-module/compare/v1.1.349...v1.1.350) (2025-03-31)
14
-
15
- ### [1.1.349](https://github.com/jetthai/cuora-module/compare/v1.1.348...v1.1.349) (2025-03-30)
16
-
17
- ### [1.1.348](https://github.com/jetthai/cuora-module/compare/v1.1.347...v1.1.348) (2025-03-30)
18
-
19
- ### [1.1.347](https://github.com/jetthai/cuora-module/compare/v1.1.346...v1.1.347) (2025-03-30)
20
-
21
5
  ### [1.1.346](https://github.com/jetthai/cuora-module/compare/v1.1.345...v1.1.346) (2025-03-27)
22
6
 
23
7
  ### [1.1.345](https://github.com/jetthai/cuora-module/compare/v1.1.344...v1.1.345) (2025-03-25)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.1.346-wallet-1",
3
+ "version": "1.1.346",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
package/resetGitBranch.sh CHANGED
@@ -59,53 +59,4 @@ git branch --set-upstream-to=origin/dev dev
59
59
  if [ $? -ne 0 ]; then
60
60
  echo "設定 dev 分支的上游分支為 origin/dev 失敗"
61
61
  exit 1
62
- fi
63
-
64
- # 切換到 master 分支
65
- git checkout master
66
- if [ $? -ne 0 ]; then
67
- echo "切換到 master 分支失敗"
68
- exit 1
69
- fi
70
-
71
- # 刪除本地的 qa 分支
72
- git branch -D qa
73
- if [ $? -ne 0 ]; then
74
- echo "刪除本地 qa 分支失敗"
75
- exit 1
76
- fi
77
-
78
- # 刪除遠端的 qa 分支
79
- git push origin --delete qa
80
- if [ $? -ne 0 ]; then
81
- echo "刪除遠端 qa 分支失敗"
82
- exit 1
83
- fi
84
-
85
- # 建立並切換到新的 qa 分支
86
- git checkout -b qa
87
- if [ $? -ne 0 ]; then
88
- echo "建立並切換到新的 qa 分支失敗"
89
- exit 1
90
- fi
91
-
92
- # 強制推送新的 qa 分支到遠端
93
- git push -f origin qa
94
- if [ $? -ne 0 ]; then
95
- echo "強制推送新的 qa 分支到遠端失敗"
96
- exit 1
97
- fi
98
-
99
- # 設定 qa 分支的上游分支為 origin/qa
100
- git branch --set-upstream-to=origin/qa qa
101
- if [ $? -ne 0 ]; then
102
- echo "設定 qa 分支的上游分支為 origin/qa 失敗"
103
- exit 1
104
- fi
105
-
106
- # 切換到 master 分支
107
- git checkout master
108
- if [ $? -ne 0 ]; then
109
- echo "切換到 master 分支失敗"
110
- exit 1
111
62
  fi
package/src/api/game.js CHANGED
@@ -1,4 +1,7 @@
1
1
  export default {
2
+ getGameSHA: () => ({ method: 'get', url: 'game/list/v2/sha' }),
3
+ getOptionMap: (code) => ({ method: 'get', url: 'game/list/v2/options', params: { code } }),
4
+ getGameStatus: () => ({ method: 'get', url: 'game/list/v2/status' }),
2
5
  getGameCategory: ({ id, first } = {}) => ({ method: 'get', url: 'game/list/v2/category', params: { id, first } }),
3
6
  addFavoriteGame: (code) => ({ method: 'post', url: 'game/myfavorite/add', params: { games: [code] } }),
4
7
  removeFavoriteGame: (code) => ({ method: 'post', url: 'game/myfavorite/remove', params: { games: [code] } }),
@@ -97,5 +100,4 @@ export default {
97
100
  }),
98
101
  getFreeGameList: () => ({ method: 'get', url: 'activities/getFreeGameRewardList' }),
99
102
  getFreeGameReward: ({ activityNo, receiveNo }) => ({ method: 'post', url: 'activities/getFreeGameReward', params: { activityNo, receiveNo } }),
100
- getV3GameInfo: ({ appSecret, gameCodes }) => ({ method: 'post', url: 'game/list/v3/gameInfo', params: { appSecret, gameCodes } }),
101
103
  }
@@ -186,7 +186,8 @@ export default function (request) {
186
186
  services: {
187
187
  fetchList: async (context, event) => {
188
188
  const hasToken = request.getToken()
189
- const apiCallable = hasToken
189
+ const isDoubleWallet = context.siteConfig?.walletMode === '4'
190
+ const apiCallable = hasToken && isDoubleWallet
190
191
  const [{ data }, promotionList] = await Promise.all([
191
192
  hasToken ? request.send(activity.getActivityList({ appSecret })) : request.send(activity.getAllActivityList({ appSecret })),
192
193
  apiCallable && !context.isPlaying ? request.send(payment.getPromotionsList()) : [],
@@ -58,6 +58,7 @@ export default function (request) {
58
58
  always: [
59
59
  {
60
60
  target: 'loaded',
61
+ cond: 'isDoubleWalletMode',
61
62
  },
62
63
  {
63
64
  target: 'calculating',
@@ -90,7 +91,7 @@ export default function (request) {
90
91
  SUBMIT: [
91
92
  {
92
93
  target: 'pending',
93
- cond: (context, event) => !!context.calculation,
94
+ cond: (context, event) => context.siteConfig?.walletMode === '4' && !!context.calculation,
94
95
  },
95
96
  {
96
97
  target: 'submitting',
@@ -128,7 +129,7 @@ export default function (request) {
128
129
  SUBMIT: [
129
130
  {
130
131
  target: 'pending',
131
- cond: (context, event) => !!context.calculation,
132
+ cond: (context, event) => context.siteConfig?.walletMode === '4' && !!context.calculation,
132
133
  },
133
134
  {
134
135
  target: 'submitting',
@@ -246,6 +247,9 @@ export default function (request) {
246
247
  }),
247
248
  },
248
249
  guards: {
250
+ isDoubleWalletMode: (context, event) => {
251
+ return context.siteConfig?.walletMode === '4'
252
+ },
249
253
  isCalculable: (context, event) => {
250
254
  const {
251
255
  amount,
@@ -72,8 +72,8 @@ export default function (request) {
72
72
  target: 'fetching',
73
73
  cond: (context, event) => {
74
74
  const { siteConfig = {}, promotion = {} } = context
75
- const { bonusPreviewEnable } = siteConfig
76
- return bonusPreviewEnable && promotion.activityNo != 'none'
75
+ const { walletMode = '', bonusPreviewEnable } = siteConfig
76
+ return walletMode === '4' && bonusPreviewEnable && promotion.activityNo != 'none'
77
77
  },
78
78
  },
79
79
  { target: 'loaded' },
@@ -49,8 +49,8 @@ export default function (request) {
49
49
  target: 'fetching',
50
50
  cond: (context, event) => {
51
51
  const { siteConfig = {}, promotion = {}, selectedCard } = context
52
- const { bonusPreviewEnable } = siteConfig
53
- return !!selectedCard && bonusPreviewEnable && promotion.activityNo != 'none'
52
+ const { walletMode = '', bonusPreviewEnable } = siteConfig
53
+ return !!selectedCard && walletMode === '4' && bonusPreviewEnable && promotion.activityNo != 'none'
54
54
  },
55
55
  },
56
56
  { target: 'loaded' },
@@ -78,8 +78,8 @@ export default function (request) {
78
78
  actions: 'setCard',
79
79
  cond: (context, event) => {
80
80
  const { siteConfig = {}, promotion = {} } = context
81
- const { bonusPreviewEnable } = siteConfig
82
- return bonusPreviewEnable && promotion.activityNo != 'none'
81
+ const { walletMode = '', bonusPreviewEnable } = siteConfig
82
+ return walletMode === '4' && bonusPreviewEnable && promotion.activityNo != 'none'
83
83
  },
84
84
  },
85
85
  {
@@ -87,6 +87,11 @@ export default function (request) {
87
87
  },
88
88
  ],
89
89
  SELECT_AMOUNT: [
90
+ {
91
+ target: 'pending',
92
+ actions: 'setAmount',
93
+ cond: 'isFreeWalletMode',
94
+ },
90
95
  {
91
96
  target: 'debouncing',
92
97
  actions: 'setAmount',
@@ -94,6 +99,19 @@ export default function (request) {
94
99
  ],
95
100
  },
96
101
  },
102
+ pending: {
103
+ on: {
104
+ SELECT_AMOUNT: {
105
+ actions: 'setAmount',
106
+ },
107
+ CONFIRM: {
108
+ target: 'debouncing',
109
+ },
110
+ BACK: {
111
+ target: 'loaded',
112
+ },
113
+ },
114
+ },
97
115
  debouncing: {
98
116
  on: {
99
117
  SELECT_AMOUNT: {
@@ -114,6 +132,19 @@ export default function (request) {
114
132
  invoke: {
115
133
  src: 'fetchCalculation',
116
134
  onDone: [
135
+ {
136
+ target: 'submitting',
137
+ actions: 'setCalculation',
138
+ cond: (context, event) => {
139
+ const { siteConfig = {}, selectedCard = {} } = context
140
+ return siteConfig.walletMode === '2' && selectedCard.jumpLinkEnable === 1
141
+ },
142
+ },
143
+ {
144
+ target: 'cardInfo',
145
+ actions: 'setCalculation',
146
+ cond: 'isFreeWalletMode',
147
+ },
117
148
  {
118
149
  target: 'calculated',
119
150
  actions: 'setCalculation',
@@ -127,10 +158,17 @@ export default function (request) {
127
158
  calculable: {
128
159
  entry: 'clearCalculation',
129
160
  on: {
130
- SELECT_AMOUNT: {
131
- target: 'debouncing',
132
- actions: 'setAmount',
133
- },
161
+ SELECT_AMOUNT: [
162
+ {
163
+ target: 'pending',
164
+ actions: 'setAmount',
165
+ cond: 'isFreeWalletMode',
166
+ },
167
+ {
168
+ target: 'debouncing',
169
+ actions: 'setAmount',
170
+ },
171
+ ],
134
172
  BACK: {
135
173
  target: 'loaded',
136
174
  },
@@ -178,8 +216,8 @@ export default function (request) {
178
216
  actions: 'setCard',
179
217
  cond: (context, event) => {
180
218
  const { siteConfig = {}, promotion = {} } = context
181
- const { bonusPreviewEnable } = siteConfig
182
- return bonusPreviewEnable && promotion.activityNo != 'none'
219
+ const { walletMode = '', bonusPreviewEnable } = siteConfig
220
+ return walletMode === '4' && bonusPreviewEnable && promotion.activityNo != 'none'
183
221
  },
184
222
  },
185
223
  {
@@ -287,6 +325,9 @@ export default function (request) {
287
325
  }),
288
326
  },
289
327
  guards: {
328
+ isFreeWalletMode: (context, event) => {
329
+ return context.siteConfig?.walletMode === '2'
330
+ },
290
331
  isSubmittable: (context, event) => {
291
332
  const { cardNumber, serialNumber } = context
292
333
  return cardNumber && serialNumber
@@ -75,8 +75,24 @@ export default function (request) {
75
75
  },
76
76
  },
77
77
  step1: {
78
- initial: 'idle',
78
+ initial: 'promotion',
79
79
  states: {
80
+ promotion: {
81
+ always: [
82
+ {
83
+ target: 'idle',
84
+ cond: 'isDoubleWalletMode',
85
+ },
86
+ {
87
+ target: 'calculating',
88
+ actions: 'setPromotionDefaultAmount',
89
+ cond: 'hasMinPromotionDeposit',
90
+ },
91
+ {
92
+ target: 'idle',
93
+ },
94
+ ],
95
+ },
80
96
  idle: {},
81
97
  calculating: {
82
98
  invoke: {
@@ -121,10 +137,11 @@ export default function (request) {
121
137
  {
122
138
  target: 'pending',
123
139
  cond: (context, event) => {
124
- const { calculation, promotion } = context
140
+ const { siteConfig = {}, calculation, promotion } = context
141
+ const { walletMode } = siteConfig
125
142
  const { promotionsNo, activityNo } = promotion
126
143
  const isNoBonus = promotionsNo === 'none' || activityNo === 'none'
127
- return !!calculation && !isNoBonus
144
+ return walletMode === '4' && !!calculation && !isNoBonus
128
145
  },
129
146
  },
130
147
  {
@@ -368,6 +385,9 @@ export default function (request) {
368
385
  }),
369
386
  },
370
387
  guards: {
388
+ isDoubleWalletMode: (context, event) => {
389
+ return context.siteConfig?.walletMode === '4'
390
+ },
371
391
  isCalculable: (context, event) => {
372
392
  const {
373
393
  amount,
@@ -49,8 +49,16 @@ export default function (request) {
49
49
  target: 'fetching',
50
50
  cond: (context, event) => {
51
51
  const { siteConfig = {}, promotion = {}, selectedQrcode } = context
52
- const { bonusPreviewEnable } = siteConfig
53
- return !!selectedQrcode && bonusPreviewEnable && promotion.activityNo != 'none'
52
+ const { walletMode = '', bonusPreviewEnable } = siteConfig
53
+ return !!selectedQrcode && walletMode === '4' && bonusPreviewEnable && promotion.activityNo != 'none'
54
+ },
55
+ },
56
+ {
57
+ target: 'debouncing',
58
+ actions: 'setPromotionDefaultAmount',
59
+ cond: (context, event) => {
60
+ const { siteConfig = {}, promotion = {} } = context
61
+ return siteConfig.walletMode === '3' && !!promotion?.minimumAmount
54
62
  },
55
63
  },
56
64
  { target: 'loaded' },
@@ -78,21 +86,51 @@ export default function (request) {
78
86
  actions: 'setQrcode',
79
87
  cond: (context, event) => {
80
88
  const { siteConfig = {}, promotion = {} } = context
81
- const { bonusPreviewEnable } = siteConfig
82
- return bonusPreviewEnable && promotion.activityNo != 'none'
89
+ const { walletMode = '', bonusPreviewEnable } = siteConfig
90
+ return walletMode === '4' && bonusPreviewEnable && promotion.activityNo != 'none'
83
91
  },
84
92
  },
93
+ {
94
+ target: 'debouncing',
95
+ actions: ['setQrcode', 'setPromotionDefaultAmount'],
96
+ cond: (context, event) => context.siteConfig?.walletMode === '3' && context.promotion?.minimumAmount,
97
+ },
85
98
  {
86
99
  actions: 'setQrcode',
87
100
  },
88
101
  ],
89
102
  SELECT_AMOUNT: [
103
+ {
104
+ target: 'debouncing',
105
+ actions: 'setAmount',
106
+ cond: 'isDoubleWalletMode',
107
+ },
108
+ {
109
+ target: 'pending',
110
+ actions: 'addAmount',
111
+ cond: (context, event) => context.siteConfig?.walletMode === '2' && context.grandTotalEnable === 1,
112
+ },
113
+ {
114
+ target: 'pending',
115
+ actions: 'setAmount',
116
+ cond: 'isFreeWalletMode',
117
+ },
118
+ {
119
+ target: 'debouncing',
120
+ actions: 'addAmount',
121
+ cond: 'isGrandTotalEnable',
122
+ },
90
123
  {
91
124
  target: 'debouncing',
92
125
  actions: 'setAmount',
93
126
  },
94
127
  ],
95
128
  KEY_IN: [
129
+ {
130
+ target: 'pending',
131
+ actions: 'setAmount',
132
+ cond: 'isFreeWalletMode',
133
+ },
96
134
  {
97
135
  target: 'calculating',
98
136
  actions: 'setAmount',
@@ -100,9 +138,51 @@ export default function (request) {
100
138
  ],
101
139
  },
102
140
  },
141
+ pending: {
142
+ on: {
143
+ SELECT_AMOUNT: [
144
+ {
145
+ actions: 'addAmount',
146
+ cond: 'isGrandTotalEnable',
147
+ },
148
+ {
149
+ actions: 'setAmount',
150
+ },
151
+ ],
152
+ KEY_IN: {
153
+ actions: 'setAmount',
154
+ },
155
+ CONFIRM: {
156
+ target: 'calculating',
157
+ },
158
+ BACK: {
159
+ target: 'loaded',
160
+ },
161
+ },
162
+ },
103
163
  debouncing: {
104
164
  on: {
105
165
  SELECT_AMOUNT: [
166
+ {
167
+ target: 'debouncing',
168
+ actions: 'setAmount',
169
+ cond: 'isDoubleWalletMode',
170
+ },
171
+ {
172
+ target: 'debouncing',
173
+ actions: 'addAmount',
174
+ cond: (context, event) => context.siteConfig?.walletMode === '2' && context.grandTotalEnable === 1,
175
+ },
176
+ {
177
+ target: 'debouncing',
178
+ actions: 'setAmount',
179
+ cond: 'isFreeWalletMode',
180
+ },
181
+ {
182
+ target: 'debouncing',
183
+ actions: 'addAmount',
184
+ cond: 'isGrandTotalEnable',
185
+ },
106
186
  {
107
187
  target: 'debouncing',
108
188
  actions: 'setAmount',
@@ -122,6 +202,26 @@ export default function (request) {
122
202
  entry: 'clearCalculation',
123
203
  on: {
124
204
  SELECT_AMOUNT: [
205
+ {
206
+ target: 'debouncing',
207
+ actions: 'setAmount',
208
+ cond: 'isDoubleWalletMode',
209
+ },
210
+ {
211
+ target: 'pending',
212
+ actions: 'addAmount',
213
+ cond: (context, event) => context.siteConfig?.walletMode === '2' && context.grandTotalEnable === 1,
214
+ },
215
+ {
216
+ target: 'pending',
217
+ actions: 'setAmount',
218
+ cond: 'isFreeWalletMode',
219
+ },
220
+ {
221
+ target: 'debouncing',
222
+ actions: 'addAmount',
223
+ cond: 'isGrandTotalEnable',
224
+ },
125
225
  {
126
226
  target: 'debouncing',
127
227
  actions: 'setAmount',
@@ -140,6 +240,11 @@ export default function (request) {
140
240
  invoke: {
141
241
  src: 'fetchCalculation',
142
242
  onDone: [
243
+ {
244
+ target: 'submitting',
245
+ actions: 'setCalculation',
246
+ cond: 'isFreeWalletMode',
247
+ },
143
248
  {
144
249
  target: 'calculated',
145
250
  actions: 'setCalculation',
@@ -153,6 +258,16 @@ export default function (request) {
153
258
  calculated: {
154
259
  on: {
155
260
  SELECT_AMOUNT: [
261
+ {
262
+ target: 'pending',
263
+ actions: 'addAmount',
264
+ cond: (context, event) => context.siteConfig?.walletMode === '2' && context.grandTotalEnable === 1,
265
+ },
266
+ {
267
+ target: 'pending',
268
+ actions: 'setAmount',
269
+ cond: 'isFreeWalletMode',
270
+ },
156
271
  {
157
272
  target: 'debouncing',
158
273
  actions: 'addAmount',
@@ -199,8 +314,8 @@ export default function (request) {
199
314
  actions: 'setQrcode',
200
315
  cond: (context, event) => {
201
316
  const { siteConfig = {}, promotion = {} } = context
202
- const { bonusPreviewEnable } = siteConfig
203
- return bonusPreviewEnable && promotion.activityNo != 'none'
317
+ const { walletMode = '', bonusPreviewEnable } = siteConfig
318
+ return walletMode === '4' && bonusPreviewEnable && promotion.activityNo != 'none'
204
319
  },
205
320
  },
206
321
  {
@@ -280,8 +395,19 @@ export default function (request) {
280
395
  promotion,
281
396
  }
282
397
  }),
398
+ setPromotionDefaultAmount: assign((context, event) => {
399
+ return {
400
+ selectedAmount: context.promotion.minimumAmount,
401
+ }
402
+ }),
283
403
  },
284
404
  guards: {
405
+ isDoubleWalletMode: (context, event) => {
406
+ return context.siteConfig?.walletMode === '4'
407
+ },
408
+ isFreeWalletMode: (context, event) => {
409
+ return context.siteConfig?.walletMode === '2'
410
+ },
285
411
  isGrandTotalEnable: (context, event) => {
286
412
  return context.grandTotalEnable === 1
287
413
  },
@@ -45,8 +45,24 @@ export default function (request) {
45
45
  },
46
46
  },
47
47
  step1: {
48
- initial: 'idle',
48
+ initial: 'promotion',
49
49
  states: {
50
+ promotion: {
51
+ always: [
52
+ {
53
+ target: 'idle',
54
+ cond: 'isDoubleWalletMode',
55
+ },
56
+ {
57
+ target: 'calculating',
58
+ actions: 'setPromotionDefaultAmount',
59
+ cond: 'hasMinPromotionDeposit',
60
+ },
61
+ {
62
+ target: 'idle',
63
+ },
64
+ ],
65
+ },
50
66
  idle: {},
51
67
  calculating: {
52
68
  invoke: {
@@ -88,10 +104,11 @@ export default function (request) {
88
104
  {
89
105
  target: 'pending',
90
106
  cond: (context, event) => {
91
- const { calculation, promotion } = context
107
+ const { siteConfig = {}, calculation, promotion } = context
108
+ const { walletMode } = siteConfig
92
109
  const { promotionsNo, activityNo } = promotion
93
110
  const isNoBonus = promotionsNo === 'none' || activityNo === 'none'
94
- return !!calculation && !isNoBonus
111
+ return walletMode === '4' && !!calculation && !isNoBonus
95
112
  },
96
113
  },
97
114
  {
@@ -214,8 +231,16 @@ export default function (request) {
214
231
  promotion: event.data,
215
232
  }
216
233
  }),
234
+ setPromotionDefaultAmount: assign((context, event) => {
235
+ return {
236
+ amount: context.promotion.minimumAmount,
237
+ }
238
+ }),
217
239
  },
218
240
  guards: {
241
+ isDoubleWalletMode: (context, event) => {
242
+ return context.siteConfig?.walletMode === '4'
243
+ },
219
244
  isCalculable: (context, event) => {
220
245
  const {
221
246
  amount,
@@ -229,6 +254,9 @@ export default function (request) {
229
254
  isProcessing: (context, event) => {
230
255
  return context.processing
231
256
  },
257
+ hasMinPromotionDeposit: (context, event) => {
258
+ return context.promotion?.minimumAmount
259
+ },
232
260
  },
233
261
  services: {
234
262
  fetchPaymentDetail: async (context, event) => {
@@ -74,8 +74,8 @@ export default function (request) {
74
74
  target: 'fetching',
75
75
  cond: (context, event) => {
76
76
  const { siteConfig = {}, promotion = {} } = context
77
- const { bonusPreviewEnable } = siteConfig
78
- return bonusPreviewEnable && promotion.activityNo != 'none'
77
+ const { walletMode = '', bonusPreviewEnable } = siteConfig
78
+ return walletMode === '4' && bonusPreviewEnable && promotion.activityNo != 'none'
79
79
  },
80
80
  },
81
81
  { target: 'loaded' },
@@ -1,9 +1,6 @@
1
1
  import { assign, createMachine } from 'xstate'
2
- import api from '../api/game.js'
3
-
4
- export default function (request) {
5
- const { appSecret } = request.config
6
2
 
3
+ export default function () {
7
4
  return createMachine(
8
5
  {
9
6
  id: 'error',
@@ -11,7 +8,6 @@ export default function (request) {
11
8
  context: {
12
9
  error: null,
13
10
  gameCode: null,
14
- game: null,
15
11
  },
16
12
  states: {
17
13
  normal: {
@@ -32,23 +28,15 @@ export default function (request) {
32
28
  { target: 'unfinishedGame', cond: 'isUnfinishedGame', actions: 'setUnfinishedGame' },
33
29
  { target: 'freeGameSettle', cond: 'isFreeGameSettle' },
34
30
  { target: 'freeGameGiveUp', cond: 'isFreeGameGiveUp' },
31
+ // { target: 'hall' },
35
32
  ],
36
33
  },
37
34
  logout: {},
38
35
  deposit: {},
39
- unfinishedGame: {
40
- invoke: {
41
- src: 'getGameInfo',
42
- onDone: {
43
- actions: 'setGame',
44
- },
45
- onError: {
46
- target: 'unfinishedGame',
47
- },
48
- },
49
- },
36
+ unfinishedGame: {},
50
37
  freeGameSettle: {},
51
38
  freeGameGiveUp: {},
39
+ // hall: {},
52
40
  },
53
41
  },
54
42
  },
@@ -70,12 +58,6 @@ export default function (request) {
70
58
  gameCode: context.error.extend.split(/_(.+)/)[1],
71
59
  }
72
60
  }),
73
- setGame: assign((context, event) => {
74
- const { data = [] } = event.data
75
- return {
76
- game: data?.[0],
77
- }
78
- }),
79
61
  },
80
62
  guards: {
81
63
  isLogout: (context, event) => {
@@ -94,12 +76,7 @@ export default function (request) {
94
76
  return context.error.code === 'ERR_G125'
95
77
  },
96
78
  },
97
- services: {
98
- getGameInfo: async (context, event) => {
99
- const { gameCode } = context
100
- return await request.send(api.getV3GameInfo({ appSecret, gameCodes: [gameCode] }))
101
- },
102
- },
79
+ services: {},
103
80
  }
104
81
  )
105
82
  }
@@ -5,7 +5,7 @@ export default function (request) {
5
5
  return createMachine(
6
6
  {
7
7
  id: 'game_search_cash',
8
- initial: 'init',
8
+ initial: 'preset',
9
9
  context: {
10
10
  initialized: false,
11
11
  keyword: '',
@@ -20,7 +20,7 @@ export default function (request) {
20
20
  clickDefault: null,
21
21
  traceId: null,
22
22
  gameCode: null,
23
- lang: 'en-US',
23
+ lang: 'en_US',
24
24
 
25
25
  // v2
26
26
  recentlySearch: [],
@@ -32,14 +32,6 @@ export default function (request) {
32
32
  isRecentlySearch: null,
33
33
  },
34
34
  states: {
35
- init: {
36
- on: {
37
- INIT: {
38
- target: 'preset',
39
- actions: ['setLang'],
40
- },
41
- },
42
- },
43
35
  preset: {
44
36
  exit: 'setInitialized',
45
37
  invoke: {
@@ -5,7 +5,7 @@ export default function (request) {
5
5
  return createMachine(
6
6
  {
7
7
  id: 'game_search_v2',
8
- initial: 'init',
8
+ initial: 'preset',
9
9
  context: {
10
10
  keyword: '',
11
11
  tagId: null,
@@ -25,17 +25,9 @@ export default function (request) {
25
25
  isRecentlyGame: null,
26
26
  isRecentlySearch: null,
27
27
  gameCode: null,
28
- lang: 'en-US',
28
+ lang: 'en_US',
29
29
  },
30
30
  states: {
31
- init: {
32
- on: {
33
- INIT: {
34
- target: 'preset',
35
- actions: ['setLang'],
36
- },
37
- },
38
- },
39
31
  preset: {
40
32
  invoke: {
41
33
  src: 'fetchTags',
@@ -40,7 +40,7 @@ export default function (request) {
40
40
  gameCode: null,
41
41
  name: null,
42
42
  },
43
- walletType: null,
43
+ walletMode: null,
44
44
  lang: 'en_US',
45
45
  isMobile: new UAParser().getResult().device.type,
46
46
  gameURL: null,
@@ -49,6 +49,7 @@ export default function (request) {
49
49
  gameWalletType: null,
50
50
  switchGame: null,
51
51
  isPlaying: false,
52
+ ...oldContext,
52
53
  },
53
54
  states: {
54
55
  flow: {
@@ -81,7 +82,7 @@ export default function (request) {
81
82
  },
82
83
  ENTER_GAME: {
83
84
  target: 'connecting',
84
- actions: ['setGameInfo', 'setLang', 'setwalletType'],
85
+ actions: ['setGameInfo', 'setLang', 'setWalletMode'],
85
86
  },
86
87
  MENU_ENTER_GAME: {
87
88
  target: 'connecting',
@@ -206,6 +207,7 @@ export default function (request) {
206
207
  actions: ['setIsPlaying', 'resetContent', 'resetSHA'],
207
208
  },
208
209
  LEAVE_GAME_REFRESH: {
210
+ target: '#game.oldTimer',
209
211
  actions: 'setIsPlaying',
210
212
  },
211
213
  },
@@ -246,17 +248,6 @@ export default function (request) {
246
248
  LEAVE_GAME_REFRESH: {
247
249
  actions: 'setIsPlaying',
248
250
  },
249
- LOAD: {
250
- target: 'routing',
251
- actions: 'setLoadable',
252
- },
253
- SET_ROOM: {
254
- cond: 'isDifferentRoom',
255
- actions: ['setRoom', 'resetContent'],
256
- },
257
- SET_STATIC_DATA: {
258
- actions: 'setStaticData',
259
- },
260
251
  },
261
252
  },
262
253
  },
@@ -291,6 +282,63 @@ export default function (request) {
291
282
  },
292
283
  },
293
284
  },
285
+ oldTimer: {
286
+ initial: 'fetchingGameSHA',
287
+ states: {
288
+ fetchingGameSHA: {
289
+ invoke: {
290
+ src: 'fetchGameSHA',
291
+ onDone: {
292
+ target: 'checking',
293
+ actions: 'setGameSHA',
294
+ },
295
+ onError: {
296
+ target: 'pending',
297
+ },
298
+ },
299
+ },
300
+ checking: {
301
+ always: [{ target: 'updatingStatus', cond: 'isStatusChanged' }, { target: 'pending' }],
302
+ },
303
+ updatingStatus: {
304
+ invoke: {
305
+ src: 'fetchStatus',
306
+ onDone: {
307
+ target: 'updatingOption',
308
+ actions: ['setStatus'],
309
+ },
310
+ onError: {
311
+ target: 'pending',
312
+ },
313
+ },
314
+ },
315
+ updatingOption: {
316
+ invoke: {
317
+ src: 'fetchOption',
318
+ onDone: {
319
+ target: 'pending',
320
+ actions: 'mergeOption',
321
+ },
322
+ onError: {
323
+ target: 'pending',
324
+ },
325
+ },
326
+ },
327
+ pending: {
328
+ after: {
329
+ 20000: [
330
+ {
331
+ target: 'fetchingGameSHA',
332
+ cond: 'isNotInGame',
333
+ },
334
+ {
335
+ target: 'pending',
336
+ },
337
+ ],
338
+ },
339
+ },
340
+ },
341
+ },
294
342
  },
295
343
  },
296
344
  {
@@ -407,6 +455,9 @@ export default function (request) {
407
455
  return event.data.gameWalletType
408
456
  },
409
457
  }),
458
+ clearGameInfo: assign((context, event) => {
459
+ return { game: { providerId: null, gameId: null, gameTypeId: null, mappingId: null } }
460
+ }),
410
461
  setGameInfo: assign((context, event) => {
411
462
  const { providerId, gameId, gameTypeId, mappingId, portrait, gameCode, name } = event.data.game
412
463
  return { game: { providerId, gameId, gameTypeId, mappingId, portrait: portrait ? 1 : 0, gameCode, name } }
@@ -418,8 +469,8 @@ export default function (request) {
418
469
  const { providerId, gameId, gameTypeId, mappingId, portrait, gameCode, name } = context.switchGame
419
470
  return { game: { providerId, gameId, gameTypeId, mappingId, portrait: portrait ? 1 : 0, gameCode, name } }
420
471
  }),
421
- setwalletType: assign((context, event) => {
422
- return { walletType: event.data.walletType }
472
+ setWalletMode: assign((context, event) => {
473
+ return { walletMode: event.data.walletMode }
423
474
  }),
424
475
  setLang: assign((context, event) => {
425
476
  const lang = event.data.locale.replace('-', '_')
@@ -440,6 +491,7 @@ export default function (request) {
440
491
  isPlaying: event.data,
441
492
  }
442
493
  }),
494
+ ...oldActions,
443
495
  },
444
496
  guards: {
445
497
  isDifferentRoom: (context, event) => context.room?.categoryId !== event.data?.categoryId,
@@ -448,9 +500,13 @@ export default function (request) {
448
500
  // 是否有下一頁
449
501
  return loadable && !isLastPage
450
502
  },
503
+ isNotInGame: (context, event) => {
504
+ return !context.isPlaying
505
+ },
451
506
  hasRoomAndIsNotInGame: (context, event) => {
452
507
  return context.room?.categoryId && !context.isPlaying
453
508
  },
509
+ ...oldGuards,
454
510
  },
455
511
  services: {
456
512
  batchFetch: async (context, event) => {
@@ -557,7 +613,7 @@ export default function (request) {
557
613
  },
558
614
  connectGame: async (context, event) => {
559
615
  const returnProviders = ['RSG', 'KP', 'EPICWIN', 'AMBSLOT', 'SEXY_VENUS', 'SEXY_SEXYBCRT', 'PG', 'NPG']
560
- const { lang, isMobile, walletType } = context
616
+ const { lang, isMobile, walletMode } = context
561
617
  const { providerId, gameId, gameTypeId, mappingId } = context.game
562
618
  const params = {
563
619
  provider_id: providerId,
@@ -567,7 +623,7 @@ export default function (request) {
567
623
  is_demo: false,
568
624
  is_mobile: isMobile === 'mobile' ? 'y' : null,
569
625
  lang,
570
- selected_wallet_type: walletType,
626
+ selected_wallet_type: walletMode,
571
627
  return_url: returnProviders.includes(providerId) ? `${window.location.origin}${context.base}return` : window.location.href, // For providers to return.
572
628
  }
573
629
  const { type, redirect_url, gameToken, gameHtml, wallet_type } = await request.send(api.playGame(params))
@@ -578,7 +634,75 @@ export default function (request) {
578
634
  const provider_id = context.game.providerId
579
635
  return await request.send(api.logoutGame({ uid_site, provider_id }))
580
636
  },
637
+ ...oldServices(request),
581
638
  },
582
639
  }
583
640
  )
584
641
  }
642
+
643
+ const oldContext = {
644
+ sha: {
645
+ status: null,
646
+ },
647
+ isStatusChanged: false,
648
+ statusMap: {},
649
+ optionMap: {},
650
+ }
651
+
652
+ const oldActions = {
653
+ setGameSHA: assign((context, event) => {
654
+ const { sha } = context
655
+ const newSha = event.data
656
+ return {
657
+ sha: newSha,
658
+ isStatusChanged: !sha.status || sha.status !== newSha.status,
659
+ }
660
+ }),
661
+ setStatus: assign((context, event) => {
662
+ return {
663
+ statusMap: event.data,
664
+ }
665
+ }),
666
+ mergeOption: assign((context, event) => {
667
+ const { optionMap } = context
668
+ return {
669
+ optionMap: { ...optionMap, ...event.data },
670
+ }
671
+ }),
672
+ resetSHA: assign((context, event) => {
673
+ return {
674
+ sha: {
675
+ status: null,
676
+ },
677
+ isStatusChanged: false,
678
+ statusMap: {},
679
+ optionMap: {},
680
+ }
681
+ }),
682
+ }
683
+
684
+ const oldGuards = {
685
+ isStatusChanged: (context, event) => context.isStatusChanged,
686
+ }
687
+
688
+ const oldServices = (request) => ({
689
+ fetchOption: async (context, event) => {
690
+ if (request.getToken()) {
691
+ return await request.send(api.getOptionMap())
692
+ }
693
+ },
694
+ fetchGameSHA: async (context, event) => {
695
+ if (request.getToken()) {
696
+ return await request.send(api.getGameSHA())
697
+ } else {
698
+ return {
699
+ status: null,
700
+ }
701
+ }
702
+ },
703
+ fetchStatus: async (context, event) => {
704
+ if (request.getToken()) {
705
+ return await request.send(api.getGameStatus())
706
+ }
707
+ },
708
+ })
@@ -1,6 +1,5 @@
1
1
  import { assign, createMachine } from 'xstate'
2
2
  import common from '../api/common.js'
3
- import game from '../api/game.js'
4
3
 
5
4
  export default function (request) {
6
5
  const { appSecret } = request.config
@@ -9,38 +8,15 @@ export default function (request) {
9
8
  id: 'navbar',
10
9
  initial: 'fetching',
11
10
  context: {
12
- navbar: [],
13
- gameCodes: [],
11
+ navbar: null,
14
12
  },
15
13
  states: {
16
14
  fetching: {
17
15
  invoke: {
18
16
  src: 'fetchNavbar',
19
- onDone: [
20
- {
21
- target: 'checking',
22
- actions: ['setNavbar', 'filterGameCodes'],
23
- cond: 'haveGames',
24
- },
25
- {
26
- target: 'idle',
27
- actions: 'setNavbar',
28
- },
29
- ],
30
- onError: {
31
- target: 'idle',
32
- },
33
- },
34
- },
35
- checking: {
36
- always: [{ target: 'combinning', cond: (context, event) => context.gameCodes?.length > 0 }, { target: 'idle' }],
37
- },
38
- combinning: {
39
- invoke: {
40
- src: 'getGameInfo',
41
17
  onDone: {
42
18
  target: 'idle',
43
- actions: 'combindGames',
19
+ actions: 'setNavbar',
44
20
  },
45
21
  onError: {
46
22
  target: 'idle',
@@ -58,47 +34,6 @@ export default function (request) {
58
34
  navbar: navbarConfig.settings,
59
35
  }
60
36
  }),
61
- filterGameCodes: assign((context, event) => {
62
- const { navbar = [] } = context
63
- const gameCodes = navbar.reduce((acc, item) => {
64
- if (item.type.toLowerCase() === 'game' && item.gameCode) {
65
- acc.push(item.gameCode)
66
- }
67
- return acc
68
- }, [])
69
-
70
- return { gameCodes }
71
- }),
72
- combindGames: assign((context, event) => {
73
- const gameInfo = event.data?.data || []
74
- const { navbar = [] } = context
75
- const combindNavBar = navbar.map((item) => {
76
- if (item.type.toLowerCase() === 'game') {
77
- const currentGame = gameInfo.find((game) => game.gameCode === item.gameCode)
78
- return {
79
- ...item,
80
- ...currentGame,
81
- }
82
- } else {
83
- return item
84
- }
85
- })
86
-
87
- return {
88
- navbar: combindNavBar,
89
- }
90
- }),
91
- },
92
- guards: {
93
- haveGames: (context, event) => {
94
- const { navbarConfig = {} } = event.data
95
- const { settings = [] } = navbarConfig
96
- if (settings?.length) {
97
- return settings.some((item) => item.type.toLowerCase() === 'game')
98
- } else {
99
- return false
100
- }
101
- },
102
37
  },
103
38
  services: {
104
39
  fetchNavbar: async (context, event) => {
@@ -116,10 +51,6 @@ export default function (request) {
116
51
  )
117
52
  return { navbarConfig: JSON.parse(decodeResult) }
118
53
  },
119
- getGameInfo: async (context, event) => {
120
- const { gameCodes } = context
121
- return await request.send(game.getV3GameInfo({ appSecret, gameCodes }))
122
- },
123
54
  },
124
55
  }
125
56
  )
@@ -7,6 +7,7 @@ export default function (request) {
7
7
  id: 'promotions',
8
8
  initial: 'loading',
9
9
  context: {
10
+ noBonus: {},
10
11
  userInfo: {},
11
12
  siteConfig: {},
12
13
  withdrawRule: {},
@@ -86,10 +87,10 @@ export default function (request) {
86
87
  actions: {
87
88
  setPromotionsList: assign((context, event) => {
88
89
  const promotionsList = JSON.parse(JSON.stringify(event.data))
89
- const { userInfo, siteConfig } = context
90
+ const { noBonus, userInfo, siteConfig } = context
90
91
  const { withdraw_rule, balance, bank_amount } = userInfo
91
- const { currencyConversionLimit } = siteConfig
92
- const balanceAvailable = parseFloat(bank_amount) < parseFloat(`${currencyConversionLimit}`)
92
+ const { currencyConversionLimit, walletMode } = siteConfig
93
+ const balanceAvailable = parseFloat(`${walletMode === '4' ? bank_amount : balance}`) < parseFloat(`${currencyConversionLimit}`)
93
94
  const isFreeLimitRule = withdraw_rule.includes('FREE_LIMIT')
94
95
  const includesDefaultRule = withdraw_rule === 'DEFAULT' || withdraw_rule.includes('FREE_DEFAULT')
95
96
 
@@ -111,7 +112,7 @@ export default function (request) {
111
112
  }
112
113
  return {
113
114
  promotionsList,
114
- selectedPromo: promotionsList[0],
115
+ selectedPromo: siteConfig?.walletMode === '4' ? promotionsList[0] : noBonus,
115
116
  }
116
117
  }),
117
118
  setSelectedPromo: assign((context, event) => {
@@ -147,6 +147,7 @@ export default function (request) {
147
147
  },
148
148
  SET_ATTACHMENT_TYPE: {
149
149
  actions: 'setAttachmentType',
150
+ cond: 'isNewWalletMode',
150
151
  },
151
152
  POOL: {
152
153
  target: 'pooling',
@@ -322,7 +323,7 @@ export default function (request) {
322
323
  balance,
323
324
  siteConfig,
324
325
  userInfo,
325
- attachmentType: 'withdraw',
326
+ attachmentType: siteConfig.walletMode > 0 ? 'withdraw' : null,
326
327
  }
327
328
  }),
328
329
  updateWithdrawCondition: assign((context, event) => {
@@ -433,6 +434,7 @@ export default function (request) {
433
434
  isOtpRequired: (context, event) => {
434
435
  return event.data?.status === 'otp-verifying'
435
436
  },
437
+ isNewWalletMode: (context, event) => context.siteConfig.walletMode > 0,
436
438
  },
437
439
  services: {
438
440
  fetchInitData: async (context, event) => {
@@ -355,7 +355,7 @@ export default function (request) {
355
355
  const methods = siteConfig?.paymentMethods?.withdraw || []
356
356
  return {
357
357
  methods,
358
- attachmentType: 'withdraw',
358
+ attachmentType: siteConfig.walletMode > 0 ? 'withdraw' : null,
359
359
  }
360
360
  }),
361
361
  setMode: assign((context, event) => {
@@ -397,8 +397,9 @@ export default function (request) {
397
397
  return { bindingPaymentList, bindingPaymentInfo, boundBanks: combinedData, currentBank: combinedData[0] }
398
398
  }),
399
399
  preset: assign((context, event) => {
400
+ const { siteConfig } = context
400
401
  return {
401
- attachmentType: 'withdraw',
402
+ attachmentType: siteConfig.walletMode > 0 ? 'withdraw' : null,
402
403
  }
403
404
  }),
404
405
  setMode: assign((context, event) => {
@@ -193,6 +193,7 @@ export default function (request) {
193
193
  },
194
194
  SET_ATTACHMENT_TYPE: {
195
195
  actions: 'setAttachmentType',
196
+ cond: 'isNewWalletMode',
196
197
  },
197
198
  SUBMIT: [
198
199
  {
@@ -358,7 +359,7 @@ export default function (request) {
358
359
  balance,
359
360
  siteConfig,
360
361
  userInfo,
361
- attachmentType: 'withdraw',
362
+ attachmentType: siteConfig.walletMode > 0 ? 'withdraw' : null,
362
363
  }
363
364
  }),
364
365
  updateWithdrawCondition: assign((context, event) => {
@@ -452,6 +453,7 @@ export default function (request) {
452
453
  isOtpRequired: (context, event) => {
453
454
  return event.data?.status === 'otp-verifying'
454
455
  },
456
+ isNewWalletMode: (context, event) => context.siteConfig.walletMode > 0,
455
457
  isNotWithdrawMinDepositAmount: (context, event) => {
456
458
  const { withdrawCheck } = context
457
459
  return !withdrawCheck?.passDepositeLimit
@@ -373,7 +373,7 @@ export default function (request) {
373
373
  const methods = siteConfig?.paymentMethods?.withdraw || []
374
374
  return {
375
375
  methods,
376
- attachmentType: 'withdraw',
376
+ attachmentType: siteConfig.walletMode > 0 ? 'withdraw' : null,
377
377
  }
378
378
  }),
379
379
  setMode: assign((context, event) => {