@jetthai/cuora 1.1.13-3 → 1.1.13-4
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 +2 -0
- package/dist/bundle.mjs +65 -35
- package/package.json +1 -1
- package/src/api/payment.js +9 -2
- package/src/machine/promotions.js +57 -33
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
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.13-4](https://github.com/jetthai/cuora-module/compare/v1.1.13-3...v1.1.13-4) (2022-12-28)
|
|
6
|
+
|
|
5
7
|
### [1.1.13-3](https://github.com/jetthai/cuora-module/compare/v1.1.13-2...v1.1.13-3) (2022-12-27)
|
|
6
8
|
|
|
7
9
|
### [1.1.13-2](https://github.com/jetthai/cuora-module/compare/v1.1.13-1...v1.1.13-2) (2022-12-27)
|
package/dist/bundle.mjs
CHANGED
|
@@ -3845,8 +3845,15 @@ var payment = {
|
|
|
3845
3845
|
method: 'post',
|
|
3846
3846
|
params: { transferType: 'WITHDRAW', amount },
|
|
3847
3847
|
}),
|
|
3848
|
-
getPromotionsList: () => ({ url: `bankWallet/promotions`, method: 'get' }),
|
|
3849
|
-
|
|
3848
|
+
getPromotionsList: () => ({ url: `payment/v2/bankWallet/promotions`, method: 'get' }),
|
|
3849
|
+
applyPromotions: ({ promotionsNo, amount }) => ({
|
|
3850
|
+
url: `payment/v2/bankWallet/promotion/apply`,
|
|
3851
|
+
method: 'post',
|
|
3852
|
+
params: {
|
|
3853
|
+
promotionsNo,
|
|
3854
|
+
amount,
|
|
3855
|
+
},
|
|
3856
|
+
}),
|
|
3850
3857
|
};
|
|
3851
3858
|
|
|
3852
3859
|
var user = {
|
|
@@ -20122,6 +20129,8 @@ function promotions (request) {
|
|
|
20122
20129
|
withdrawLimitDetail: [],
|
|
20123
20130
|
limitGameDetail: [],
|
|
20124
20131
|
},
|
|
20132
|
+
oldTargetTurnoverLimit: 0,
|
|
20133
|
+
newTargetTurnoverLimit: 0,
|
|
20125
20134
|
promotionsList: [],
|
|
20126
20135
|
selectedPromo: {},
|
|
20127
20136
|
joinedPromotion: null,
|
|
@@ -20129,22 +20138,10 @@ function promotions (request) {
|
|
|
20129
20138
|
states: {
|
|
20130
20139
|
loading: {
|
|
20131
20140
|
invoke: {
|
|
20132
|
-
src: '
|
|
20133
|
-
onDone: {
|
|
20134
|
-
target: 'loaded',
|
|
20135
|
-
actions: 'setInit',
|
|
20136
|
-
},
|
|
20137
|
-
onError: {
|
|
20138
|
-
target: 'fail',
|
|
20139
|
-
},
|
|
20140
|
-
},
|
|
20141
|
-
},
|
|
20142
|
-
fetching: {
|
|
20143
|
-
invoke: {
|
|
20144
|
-
src: 'fetchJoinedPromotion',
|
|
20141
|
+
src: 'fetchInitData',
|
|
20145
20142
|
onDone: {
|
|
20146
20143
|
target: 'loaded',
|
|
20147
|
-
actions: '
|
|
20144
|
+
actions: 'setInitData',
|
|
20148
20145
|
},
|
|
20149
20146
|
onError: {
|
|
20150
20147
|
target: 'fail',
|
|
@@ -20154,32 +20151,52 @@ function promotions (request) {
|
|
|
20154
20151
|
loaded: {
|
|
20155
20152
|
on: {
|
|
20156
20153
|
SELECT_PROMO: {
|
|
20157
|
-
actions: 'setSelectedPromo',
|
|
20154
|
+
actions: ['reset', 'setSelectedPromo'],
|
|
20158
20155
|
},
|
|
20159
20156
|
SET_AMOUNT: {
|
|
20160
20157
|
actions: 'setAmount',
|
|
20161
20158
|
},
|
|
20159
|
+
JOIN: {
|
|
20160
|
+
target: 'check',
|
|
20161
|
+
cond: 'isValidAmount',
|
|
20162
|
+
},
|
|
20163
|
+
},
|
|
20164
|
+
},
|
|
20165
|
+
check: {
|
|
20166
|
+
entry: 'preset',
|
|
20167
|
+
on: {
|
|
20162
20168
|
CONFIRM: {
|
|
20163
20169
|
target: 'joinning',
|
|
20164
|
-
|
|
20170
|
+
},
|
|
20171
|
+
BACK: {
|
|
20172
|
+
target: 'loaded',
|
|
20165
20173
|
},
|
|
20166
20174
|
},
|
|
20167
20175
|
},
|
|
20176
|
+
joinning: {
|
|
20177
|
+
invoke: {
|
|
20178
|
+
src: 'applyPromotion',
|
|
20179
|
+
onDone: {
|
|
20180
|
+
target: 'joined',
|
|
20181
|
+
},
|
|
20182
|
+
onError: {
|
|
20183
|
+
target: 'fail',
|
|
20184
|
+
},
|
|
20185
|
+
},
|
|
20186
|
+
},
|
|
20187
|
+
joined: {},
|
|
20168
20188
|
fail: {},
|
|
20169
|
-
joinning: {},
|
|
20170
20189
|
},
|
|
20171
20190
|
},
|
|
20172
20191
|
{
|
|
20173
20192
|
actions: {
|
|
20174
|
-
|
|
20175
|
-
|
|
20176
|
-
|
|
20177
|
-
selectedPromo: context.noBonus,
|
|
20178
|
-
}
|
|
20179
|
-
}),
|
|
20180
|
-
setJoinedPromotion: assign((context, event) => {
|
|
20193
|
+
setInitData: assign((context, event) => {
|
|
20194
|
+
const { userInfo, promotionsList } = event.data;
|
|
20195
|
+
const { noBonus } = context;
|
|
20181
20196
|
return {
|
|
20182
|
-
|
|
20197
|
+
promotionsList,
|
|
20198
|
+
userInfo,
|
|
20199
|
+
selectedPromo: noBonus,
|
|
20183
20200
|
}
|
|
20184
20201
|
}),
|
|
20185
20202
|
setSelectedPromo: assign((context, event) => {
|
|
@@ -20192,21 +20209,34 @@ function promotions (request) {
|
|
|
20192
20209
|
amount: event.data,
|
|
20193
20210
|
}
|
|
20194
20211
|
}),
|
|
20212
|
+
reset: assign((context, event) => {
|
|
20213
|
+
return {
|
|
20214
|
+
amount: null,
|
|
20215
|
+
}
|
|
20216
|
+
}),
|
|
20217
|
+
preset: assign((context, event) => {
|
|
20218
|
+
const { userInfo, selectedPromo, amount } = context;
|
|
20219
|
+
const { turnoverLimitMultiple } = selectedPromo;
|
|
20220
|
+
return {
|
|
20221
|
+
oldTargetTurnoverLimit: userInfo.target_withdraw_limit,
|
|
20222
|
+
newTargetTurnoverLimit: parseFloat(`${amount}`) * parseFloat(`${turnoverLimitMultiple}`),
|
|
20223
|
+
}
|
|
20224
|
+
}),
|
|
20195
20225
|
},
|
|
20196
20226
|
guards: {
|
|
20197
20227
|
isValidAmount: (context, event) => {
|
|
20198
|
-
const {
|
|
20199
|
-
return minimumAmount <= amount
|
|
20228
|
+
const { selectedPromo, amount } = context;
|
|
20229
|
+
return selectedPromo.minimumAmount <= amount
|
|
20200
20230
|
},
|
|
20201
20231
|
},
|
|
20202
20232
|
services: {
|
|
20203
|
-
|
|
20204
|
-
const
|
|
20205
|
-
return
|
|
20233
|
+
fetchInitData: async (context, event) => {
|
|
20234
|
+
const [userInfo, promotionsList] = await Promise.all([request.send(user.getUserInfo()), request.send(payment.getPromotionsList())]);
|
|
20235
|
+
return { userInfo, promotionsList }
|
|
20206
20236
|
},
|
|
20207
|
-
|
|
20208
|
-
const {
|
|
20209
|
-
return
|
|
20237
|
+
applyPromotion: async (context, event) => {
|
|
20238
|
+
const { selectedPromo, amount } = context;
|
|
20239
|
+
return await request.send(payment.applyPromotions({ promotionsNo: selectedPromo.promotionsNo, amount: parseFloat(amount) }))
|
|
20210
20240
|
},
|
|
20211
20241
|
},
|
|
20212
20242
|
}
|
package/package.json
CHANGED
package/src/api/payment.js
CHANGED
|
@@ -114,6 +114,13 @@ export default {
|
|
|
114
114
|
method: 'post',
|
|
115
115
|
params: { transferType: 'WITHDRAW', amount },
|
|
116
116
|
}),
|
|
117
|
-
getPromotionsList: () => ({ url: `bankWallet/promotions`, method: 'get' }),
|
|
118
|
-
|
|
117
|
+
getPromotionsList: () => ({ url: `payment/v2/bankWallet/promotions`, method: 'get' }),
|
|
118
|
+
applyPromotions: ({ promotionsNo, amount }) => ({
|
|
119
|
+
url: `payment/v2/bankWallet/promotion/apply`,
|
|
120
|
+
method: 'post',
|
|
121
|
+
params: {
|
|
122
|
+
promotionsNo,
|
|
123
|
+
amount,
|
|
124
|
+
},
|
|
125
|
+
}),
|
|
119
126
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { assign, createMachine } from 'xstate'
|
|
2
2
|
import payment from '../api/payment.js'
|
|
3
|
+
import user from '../api/user.js'
|
|
3
4
|
|
|
4
5
|
export default function (request) {
|
|
5
6
|
return createMachine(
|
|
@@ -23,6 +24,8 @@ export default function (request) {
|
|
|
23
24
|
withdrawLimitDetail: [],
|
|
24
25
|
limitGameDetail: [],
|
|
25
26
|
},
|
|
27
|
+
oldTargetTurnoverLimit: 0,
|
|
28
|
+
newTargetTurnoverLimit: 0,
|
|
26
29
|
promotionsList: [],
|
|
27
30
|
selectedPromo: {},
|
|
28
31
|
joinedPromotion: null,
|
|
@@ -30,22 +33,10 @@ export default function (request) {
|
|
|
30
33
|
states: {
|
|
31
34
|
loading: {
|
|
32
35
|
invoke: {
|
|
33
|
-
src: '
|
|
36
|
+
src: 'fetchInitData',
|
|
34
37
|
onDone: {
|
|
35
38
|
target: 'loaded',
|
|
36
|
-
actions: '
|
|
37
|
-
},
|
|
38
|
-
onError: {
|
|
39
|
-
target: 'fail',
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
fetching: {
|
|
44
|
-
invoke: {
|
|
45
|
-
src: 'fetchJoinedPromotion',
|
|
46
|
-
onDone: {
|
|
47
|
-
target: 'loaded',
|
|
48
|
-
actions: 'setJoinedPromotion',
|
|
39
|
+
actions: 'setInitData',
|
|
49
40
|
},
|
|
50
41
|
onError: {
|
|
51
42
|
target: 'fail',
|
|
@@ -55,32 +46,52 @@ export default function (request) {
|
|
|
55
46
|
loaded: {
|
|
56
47
|
on: {
|
|
57
48
|
SELECT_PROMO: {
|
|
58
|
-
actions: 'setSelectedPromo',
|
|
49
|
+
actions: ['reset', 'setSelectedPromo'],
|
|
59
50
|
},
|
|
60
51
|
SET_AMOUNT: {
|
|
61
52
|
actions: 'setAmount',
|
|
62
53
|
},
|
|
54
|
+
JOIN: {
|
|
55
|
+
target: 'check',
|
|
56
|
+
cond: 'isValidAmount',
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
check: {
|
|
61
|
+
entry: 'preset',
|
|
62
|
+
on: {
|
|
63
63
|
CONFIRM: {
|
|
64
64
|
target: 'joinning',
|
|
65
|
-
|
|
65
|
+
},
|
|
66
|
+
BACK: {
|
|
67
|
+
target: 'loaded',
|
|
66
68
|
},
|
|
67
69
|
},
|
|
68
70
|
},
|
|
71
|
+
joinning: {
|
|
72
|
+
invoke: {
|
|
73
|
+
src: 'applyPromotion',
|
|
74
|
+
onDone: {
|
|
75
|
+
target: 'joined',
|
|
76
|
+
},
|
|
77
|
+
onError: {
|
|
78
|
+
target: 'fail',
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
joined: {},
|
|
69
83
|
fail: {},
|
|
70
|
-
joinning: {},
|
|
71
84
|
},
|
|
72
85
|
},
|
|
73
86
|
{
|
|
74
87
|
actions: {
|
|
75
|
-
|
|
88
|
+
setInitData: assign((context, event) => {
|
|
89
|
+
const { userInfo, promotionsList } = event.data
|
|
90
|
+
const { noBonus } = context
|
|
76
91
|
return {
|
|
77
|
-
promotionsList
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}),
|
|
81
|
-
setJoinedPromotion: assign((context, event) => {
|
|
82
|
-
return {
|
|
83
|
-
joinedPromotion: event.data,
|
|
92
|
+
promotionsList,
|
|
93
|
+
userInfo,
|
|
94
|
+
selectedPromo: noBonus,
|
|
84
95
|
}
|
|
85
96
|
}),
|
|
86
97
|
setSelectedPromo: assign((context, event) => {
|
|
@@ -93,21 +104,34 @@ export default function (request) {
|
|
|
93
104
|
amount: event.data,
|
|
94
105
|
}
|
|
95
106
|
}),
|
|
107
|
+
reset: assign((context, event) => {
|
|
108
|
+
return {
|
|
109
|
+
amount: null,
|
|
110
|
+
}
|
|
111
|
+
}),
|
|
112
|
+
preset: assign((context, event) => {
|
|
113
|
+
const { userInfo, selectedPromo, amount } = context
|
|
114
|
+
const { turnoverLimitMultiple } = selectedPromo
|
|
115
|
+
return {
|
|
116
|
+
oldTargetTurnoverLimit: userInfo.target_withdraw_limit,
|
|
117
|
+
newTargetTurnoverLimit: parseFloat(`${amount}`) * parseFloat(`${turnoverLimitMultiple}`),
|
|
118
|
+
}
|
|
119
|
+
}),
|
|
96
120
|
},
|
|
97
121
|
guards: {
|
|
98
122
|
isValidAmount: (context, event) => {
|
|
99
|
-
const {
|
|
100
|
-
return minimumAmount <= amount
|
|
123
|
+
const { selectedPromo, amount } = context
|
|
124
|
+
return selectedPromo.minimumAmount <= amount
|
|
101
125
|
},
|
|
102
126
|
},
|
|
103
127
|
services: {
|
|
104
|
-
|
|
105
|
-
const
|
|
106
|
-
return
|
|
128
|
+
fetchInitData: async (context, event) => {
|
|
129
|
+
const [userInfo, promotionsList] = await Promise.all([request.send(user.getUserInfo()), request.send(payment.getPromotionsList())])
|
|
130
|
+
return { userInfo, promotionsList }
|
|
107
131
|
},
|
|
108
|
-
|
|
109
|
-
const {
|
|
110
|
-
return
|
|
132
|
+
applyPromotion: async (context, event) => {
|
|
133
|
+
const { selectedPromo, amount } = context
|
|
134
|
+
return await request.send(payment.applyPromotions({ promotionsNo: selectedPromo.promotionsNo, amount: parseFloat(amount) }))
|
|
111
135
|
},
|
|
112
136
|
},
|
|
113
137
|
}
|